@botpress/runtime 1.7.18 → 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.
- package/dist/definition.js +91 -20
- package/dist/definition.js.map +2 -2
- package/dist/internal.js +91 -20
- package/dist/internal.js.map +2 -2
- package/dist/library.js +91 -20
- package/dist/library.js.map +2 -2
- package/dist/primitives/data-sources/index.d.ts +3 -0
- package/dist/primitives/data-sources/index.d.ts.map +1 -1
- package/dist/primitives/data-sources/source-base.d.ts +5 -0
- package/dist/primitives/data-sources/source-base.d.ts.map +1 -1
- package/dist/primitives/data-sources/source-directory.d.ts +8 -2
- package/dist/primitives/data-sources/source-directory.d.ts.map +1 -1
- package/dist/primitives/data-sources/source-table.d.ts +2 -0
- package/dist/primitives/data-sources/source-table.d.ts.map +1 -1
- package/dist/primitives/data-sources/source-website.d.ts +2 -0
- package/dist/primitives/data-sources/source-website.d.ts.map +1 -1
- package/dist/primitives/index.d.ts +7 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/runtime.js +91 -20
- package/dist/runtime.js.map +2 -2
- package/package.json +1 -1
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.
|
|
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
|
|
|
@@ -43438,6 +43438,15 @@ var TableSource = class _TableSource extends DataSource {
|
|
|
43438
43438
|
this.table = table;
|
|
43439
43439
|
this.transformFn = options.transform ?? void 0;
|
|
43440
43440
|
}
|
|
43441
|
+
/** Get serializable configuration for change detection */
|
|
43442
|
+
getConfig() {
|
|
43443
|
+
return {
|
|
43444
|
+
id: this.id,
|
|
43445
|
+
type: this.type,
|
|
43446
|
+
tableName: this.table.name,
|
|
43447
|
+
transformFn: this.transformFn?.toString() || null
|
|
43448
|
+
};
|
|
43449
|
+
}
|
|
43441
43450
|
get syncWorkflow() {
|
|
43442
43451
|
return createSyncWorkflow({
|
|
43443
43452
|
type: "table",
|
|
@@ -45051,6 +45060,27 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45051
45060
|
this.maxPages = Math.max(1, Math.min(("maxPages" in options ? options.maxPages : void 0) ?? 5e4, 5e4));
|
|
45052
45061
|
this.maxDepth = Math.max(1, Math.min(("maxDepth" in options ? options.maxDepth : void 0) ?? 20, 20));
|
|
45053
45062
|
}
|
|
45063
|
+
/** Get serializable configuration for change detection (only user-provided options) */
|
|
45064
|
+
getConfig() {
|
|
45065
|
+
const config = {
|
|
45066
|
+
mode: this.mode,
|
|
45067
|
+
fetchStrategy: this.fetchStrategy
|
|
45068
|
+
};
|
|
45069
|
+
if (this.mode === "website") {
|
|
45070
|
+
config.baseUrl = this.baseUrl;
|
|
45071
|
+
config.maxPages = this.maxPages;
|
|
45072
|
+
config.maxDepth = this.maxDepth;
|
|
45073
|
+
} else if (this.mode === "sitemap") {
|
|
45074
|
+
config.sitemapUrl = this.sitemapUrl;
|
|
45075
|
+
config.maxPages = this.maxPages;
|
|
45076
|
+
} else if (this.mode === "urls") {
|
|
45077
|
+
config.urls = this.urls;
|
|
45078
|
+
}
|
|
45079
|
+
if (this.filterFn) {
|
|
45080
|
+
config.filterFn = this.filterFn.toString();
|
|
45081
|
+
}
|
|
45082
|
+
return config;
|
|
45083
|
+
}
|
|
45054
45084
|
isBrowserIntegrationAvailable() {
|
|
45055
45085
|
return !!adk.project.integrations.get("browser");
|
|
45056
45086
|
}
|
|
@@ -45370,28 +45400,28 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45370
45400
|
tags
|
|
45371
45401
|
}).collect()
|
|
45372
45402
|
);
|
|
45373
|
-
|
|
45374
|
-
|
|
45375
|
-
|
|
45376
|
-
|
|
45377
|
-
|
|
45378
|
-
|
|
45379
|
-
|
|
45380
|
-
|
|
45381
|
-
|
|
45403
|
+
if (input.force && existingFiles.length > 0) {
|
|
45404
|
+
console.warn(
|
|
45405
|
+
`\u26A0\uFE0F Website source configuration changed - deleting ${existingFiles.length} existing files and recrawling`
|
|
45406
|
+
);
|
|
45407
|
+
await step2.map(
|
|
45408
|
+
"deleting all existing files for recrawl",
|
|
45409
|
+
existingFiles,
|
|
45410
|
+
(f) => client.deleteFile({ id: f.id }).catch(() => null),
|
|
45411
|
+
{ concurrency: 5 }
|
|
45382
45412
|
);
|
|
45383
|
-
|
|
45384
|
-
throw new Error("Aborting sync due to potential misconfiguration (all files to be removed)");
|
|
45413
|
+
console.log(`\u2705 Deleted ${existingFiles.length} files, starting fresh crawl`);
|
|
45385
45414
|
}
|
|
45415
|
+
const existingFileMap = input.force ? /* @__PURE__ */ new Map() : new Map(existingFiles.map((f) => [f.metadata?.[WellKnownMetadata.knowledge.URL], f]));
|
|
45416
|
+
const toRemove = input.force ? [] : existingFiles.filter(
|
|
45417
|
+
(f) => !discoveredUrls.find((u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL])
|
|
45418
|
+
);
|
|
45386
45419
|
const toFetch = [];
|
|
45387
45420
|
let skippedUnchanged = 0;
|
|
45388
45421
|
for (const url2 of discoveredUrls) {
|
|
45389
45422
|
const existing = existingFileMap.get(url2.loc);
|
|
45390
45423
|
if (!existing) {
|
|
45391
45424
|
toFetch.push(url2);
|
|
45392
|
-
} else if (input.force) {
|
|
45393
|
-
console.log(`Force re-indexing page: ${url2.loc}`);
|
|
45394
|
-
toFetch.push(url2);
|
|
45395
45425
|
} else {
|
|
45396
45426
|
const existingMetadata = existing.metadata;
|
|
45397
45427
|
if (url2.lastmod && existingMetadata?.lastmod !== url2.lastmod) {
|
|
@@ -45505,7 +45535,17 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45505
45535
|
return new _WebsiteSource(id, "sitemap", { ...options, sitemapUrl });
|
|
45506
45536
|
}
|
|
45507
45537
|
static fromUrls(urls, options = {}) {
|
|
45508
|
-
|
|
45538
|
+
let defaultId = `urls_${urls.length}_pages`;
|
|
45539
|
+
if (urls.length > 0) {
|
|
45540
|
+
try {
|
|
45541
|
+
const firstUrl = new URL(urls[0]);
|
|
45542
|
+
const domain = firstUrl.hostname.replace(/^www\./, "").replace(/\./g, "_");
|
|
45543
|
+
const urlsHash = urls.slice().sort().join("|").split("").reduce((hash, char) => (hash << 5) - hash + char.charCodeAt(0) | 0, 0).toString(16).replace("-", "").slice(0, 8);
|
|
45544
|
+
defaultId = `urls_${domain}_${urlsHash}`;
|
|
45545
|
+
} catch {
|
|
45546
|
+
}
|
|
45547
|
+
}
|
|
45548
|
+
const id = options.id || defaultId;
|
|
45509
45549
|
return new _WebsiteSource(id, "urls", { ...options, urls });
|
|
45510
45550
|
}
|
|
45511
45551
|
};
|
|
@@ -45515,12 +45555,29 @@ init_define_BUILD();
|
|
|
45515
45555
|
init_define_PACKAGE_VERSIONS();
|
|
45516
45556
|
import { z as z23 } from "@botpress/sdk";
|
|
45517
45557
|
var DirectorySource = class _DirectorySource extends DataSource {
|
|
45518
|
-
|
|
45519
|
-
|
|
45558
|
+
_directoryPath;
|
|
45559
|
+
_filterFn;
|
|
45520
45560
|
constructor(id, directoryPath, options = {}) {
|
|
45521
45561
|
super(id, "directory");
|
|
45522
|
-
this.
|
|
45523
|
-
this.
|
|
45562
|
+
this._directoryPath = directoryPath;
|
|
45563
|
+
this._filterFn = options.filter ?? void 0;
|
|
45564
|
+
}
|
|
45565
|
+
/** Get the directory path for this source */
|
|
45566
|
+
get directoryPath() {
|
|
45567
|
+
return this._directoryPath;
|
|
45568
|
+
}
|
|
45569
|
+
/** Get the filter function for this source */
|
|
45570
|
+
get filterFn() {
|
|
45571
|
+
return this._filterFn;
|
|
45572
|
+
}
|
|
45573
|
+
/** Get serializable configuration for change detection */
|
|
45574
|
+
getConfig() {
|
|
45575
|
+
return {
|
|
45576
|
+
id: this.id,
|
|
45577
|
+
type: this.type,
|
|
45578
|
+
directoryPath: this._directoryPath,
|
|
45579
|
+
filterFn: this._filterFn?.toString() || null
|
|
45580
|
+
};
|
|
45524
45581
|
}
|
|
45525
45582
|
get syncWorkflow() {
|
|
45526
45583
|
return createSyncWorkflow({
|
|
@@ -45667,6 +45724,17 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
45667
45724
|
}
|
|
45668
45725
|
};
|
|
45669
45726
|
|
|
45727
|
+
// src/primitives/data-sources/index.ts
|
|
45728
|
+
function isDirectorySource(source) {
|
|
45729
|
+
return source.type === "directory";
|
|
45730
|
+
}
|
|
45731
|
+
function isWebsiteSource(source) {
|
|
45732
|
+
return source.type === "website";
|
|
45733
|
+
}
|
|
45734
|
+
function isTableSource(source) {
|
|
45735
|
+
return source.type === "table";
|
|
45736
|
+
}
|
|
45737
|
+
|
|
45670
45738
|
// src/primitives/knowledge.ts
|
|
45671
45739
|
init_define_BUILD();
|
|
45672
45740
|
init_define_PACKAGE_VERSIONS();
|
|
@@ -46003,6 +46071,9 @@ var DataSource2;
|
|
|
46003
46071
|
DataSource3.Table = TableSource;
|
|
46004
46072
|
DataSource3.Website = WebsiteSource;
|
|
46005
46073
|
DataSource3.Directory = DirectorySource;
|
|
46074
|
+
DataSource3.isDirectory = isDirectorySource;
|
|
46075
|
+
DataSource3.isWebsite = isWebsiteSource;
|
|
46076
|
+
DataSource3.isTable = isTableSource;
|
|
46006
46077
|
})(DataSource2 || (DataSource2 = {}));
|
|
46007
46078
|
|
|
46008
46079
|
// src/workers/index.ts
|