@botpress/runtime 1.7.19 → 1.8.1
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 +101 -25
- package/dist/definition.js.map +2 -2
- package/dist/internal.js +101 -25
- package/dist/internal.js.map +2 -2
- package/dist/library.js +101 -25
- package/dist/library.js.map +2 -2
- package/dist/primitives/conversation.d.ts.map +1 -1
- 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/interfaces.d.ts +5 -4
- package/dist/runtime/interfaces.d.ts.map +1 -1
- package/dist/runtime.js +103 -27
- 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.1", adk: "1.8.1", sdk: "4.19.0", llmz: "0.0.33", zai: "2.5.0", cognitive: "0.2.0" };
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -36341,14 +36341,15 @@ import { CitationsManager } from "llmz";
|
|
|
36341
36341
|
init_define_BUILD();
|
|
36342
36342
|
init_define_PACKAGE_VERSIONS();
|
|
36343
36343
|
var InterfaceMappings = class {
|
|
36344
|
-
|
|
36345
|
-
|
|
36344
|
+
mappings = {};
|
|
36345
|
+
registerMappings(mappings) {
|
|
36346
36346
|
this.mappings = { ...this.mappings, ...mappings };
|
|
36347
36347
|
}
|
|
36348
|
-
|
|
36348
|
+
getIntegrationAction(interfaceName, actionName, integrationName) {
|
|
36349
36349
|
return this.mappings[interfaceName]?.actions[`${integrationName}:${actionName}`];
|
|
36350
36350
|
}
|
|
36351
36351
|
};
|
|
36352
|
+
var interfaceMappings = getSingleton("__ADK_GLOBAL_INTERFACE_MAPPINGS", () => new InterfaceMappings());
|
|
36352
36353
|
|
|
36353
36354
|
// src/runtime/context/http.ts
|
|
36354
36355
|
init_define_BUILD();
|
|
@@ -42405,7 +42406,7 @@ var BaseConversationInstance = class {
|
|
|
42405
42406
|
* Start typing indicator
|
|
42406
42407
|
*/
|
|
42407
42408
|
async startTyping() {
|
|
42408
|
-
const mapping =
|
|
42409
|
+
const mapping = interfaceMappings.getIntegrationAction("typingIndicator", "startTypingIndicator", this.integration);
|
|
42409
42410
|
if (mapping) {
|
|
42410
42411
|
const message = context.get("message", { optional: true });
|
|
42411
42412
|
await this.client.callAction({
|
|
@@ -42422,7 +42423,7 @@ var BaseConversationInstance = class {
|
|
|
42422
42423
|
* Stop typing indicator
|
|
42423
42424
|
*/
|
|
42424
42425
|
async stopTyping() {
|
|
42425
|
-
const mapping =
|
|
42426
|
+
const mapping = interfaceMappings.getIntegrationAction("typingIndicator", "stopTypingIndicator", this.integration);
|
|
42426
42427
|
if (mapping) {
|
|
42427
42428
|
const message = context.get("message", { optional: true });
|
|
42428
42429
|
await this.client.callAction({
|
|
@@ -42520,6 +42521,8 @@ var BaseConversation = class {
|
|
|
42520
42521
|
const client = context.get("client");
|
|
42521
42522
|
const botpressConversation = context.get("conversation");
|
|
42522
42523
|
const conversationInstance = new BaseConversationInstance(botpressConversation, client);
|
|
42524
|
+
const startTypingPromise = conversationInstance.startTyping().catch(() => {
|
|
42525
|
+
});
|
|
42523
42526
|
let type;
|
|
42524
42527
|
let requestObject = void 0;
|
|
42525
42528
|
if (message) {
|
|
@@ -42631,6 +42634,8 @@ var BaseConversation = class {
|
|
|
42631
42634
|
execute
|
|
42632
42635
|
});
|
|
42633
42636
|
controller.abort();
|
|
42637
|
+
void startTypingPromise.then(() => conversationInstance.stopTyping().catch(() => {
|
|
42638
|
+
}));
|
|
42634
42639
|
}
|
|
42635
42640
|
};
|
|
42636
42641
|
|
|
@@ -43438,6 +43443,15 @@ var TableSource = class _TableSource extends DataSource {
|
|
|
43438
43443
|
this.table = table;
|
|
43439
43444
|
this.transformFn = options.transform ?? void 0;
|
|
43440
43445
|
}
|
|
43446
|
+
/** Get serializable configuration for change detection */
|
|
43447
|
+
getConfig() {
|
|
43448
|
+
return {
|
|
43449
|
+
id: this.id,
|
|
43450
|
+
type: this.type,
|
|
43451
|
+
tableName: this.table.name,
|
|
43452
|
+
transformFn: this.transformFn?.toString() || null
|
|
43453
|
+
};
|
|
43454
|
+
}
|
|
43441
43455
|
get syncWorkflow() {
|
|
43442
43456
|
return createSyncWorkflow({
|
|
43443
43457
|
type: "table",
|
|
@@ -45051,6 +45065,27 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45051
45065
|
this.maxPages = Math.max(1, Math.min(("maxPages" in options ? options.maxPages : void 0) ?? 5e4, 5e4));
|
|
45052
45066
|
this.maxDepth = Math.max(1, Math.min(("maxDepth" in options ? options.maxDepth : void 0) ?? 20, 20));
|
|
45053
45067
|
}
|
|
45068
|
+
/** Get serializable configuration for change detection (only user-provided options) */
|
|
45069
|
+
getConfig() {
|
|
45070
|
+
const config = {
|
|
45071
|
+
mode: this.mode,
|
|
45072
|
+
fetchStrategy: this.fetchStrategy
|
|
45073
|
+
};
|
|
45074
|
+
if (this.mode === "website") {
|
|
45075
|
+
config.baseUrl = this.baseUrl;
|
|
45076
|
+
config.maxPages = this.maxPages;
|
|
45077
|
+
config.maxDepth = this.maxDepth;
|
|
45078
|
+
} else if (this.mode === "sitemap") {
|
|
45079
|
+
config.sitemapUrl = this.sitemapUrl;
|
|
45080
|
+
config.maxPages = this.maxPages;
|
|
45081
|
+
} else if (this.mode === "urls") {
|
|
45082
|
+
config.urls = this.urls;
|
|
45083
|
+
}
|
|
45084
|
+
if (this.filterFn) {
|
|
45085
|
+
config.filterFn = this.filterFn.toString();
|
|
45086
|
+
}
|
|
45087
|
+
return config;
|
|
45088
|
+
}
|
|
45054
45089
|
isBrowserIntegrationAvailable() {
|
|
45055
45090
|
return !!adk.project.integrations.get("browser");
|
|
45056
45091
|
}
|
|
@@ -45370,28 +45405,28 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45370
45405
|
tags
|
|
45371
45406
|
}).collect()
|
|
45372
45407
|
);
|
|
45373
|
-
|
|
45374
|
-
|
|
45375
|
-
|
|
45376
|
-
const toRemove = existingFiles.filter(
|
|
45377
|
-
(f) => !discoveredUrls.find((u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL])
|
|
45378
|
-
);
|
|
45379
|
-
if (existingFiles.length > 0 && toRemove.length >= existingFiles.length * 0.8) {
|
|
45380
|
-
console.error(
|
|
45381
|
-
`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.`
|
|
45408
|
+
if (input.force && existingFiles.length > 0) {
|
|
45409
|
+
console.warn(
|
|
45410
|
+
`\u26A0\uFE0F Website source configuration changed - deleting ${existingFiles.length} existing files and recrawling`
|
|
45382
45411
|
);
|
|
45383
|
-
await step2.
|
|
45384
|
-
|
|
45412
|
+
await step2.map(
|
|
45413
|
+
"deleting all existing files for recrawl",
|
|
45414
|
+
existingFiles,
|
|
45415
|
+
(f) => client.deleteFile({ id: f.id }).catch(() => null),
|
|
45416
|
+
{ concurrency: 5 }
|
|
45417
|
+
);
|
|
45418
|
+
console.log(`\u2705 Deleted ${existingFiles.length} files, starting fresh crawl`);
|
|
45385
45419
|
}
|
|
45420
|
+
const existingFileMap = input.force ? /* @__PURE__ */ new Map() : new Map(existingFiles.map((f) => [f.metadata?.[WellKnownMetadata.knowledge.URL], f]));
|
|
45421
|
+
const toRemove = input.force ? [] : existingFiles.filter(
|
|
45422
|
+
(f) => !discoveredUrls.find((u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL])
|
|
45423
|
+
);
|
|
45386
45424
|
const toFetch = [];
|
|
45387
45425
|
let skippedUnchanged = 0;
|
|
45388
45426
|
for (const url2 of discoveredUrls) {
|
|
45389
45427
|
const existing = existingFileMap.get(url2.loc);
|
|
45390
45428
|
if (!existing) {
|
|
45391
45429
|
toFetch.push(url2);
|
|
45392
|
-
} else if (input.force) {
|
|
45393
|
-
console.log(`Force re-indexing page: ${url2.loc}`);
|
|
45394
|
-
toFetch.push(url2);
|
|
45395
45430
|
} else {
|
|
45396
45431
|
const existingMetadata = existing.metadata;
|
|
45397
45432
|
if (url2.lastmod && existingMetadata?.lastmod !== url2.lastmod) {
|
|
@@ -45505,7 +45540,17 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45505
45540
|
return new _WebsiteSource(id, "sitemap", { ...options, sitemapUrl });
|
|
45506
45541
|
}
|
|
45507
45542
|
static fromUrls(urls, options = {}) {
|
|
45508
|
-
|
|
45543
|
+
let defaultId = `urls_${urls.length}_pages`;
|
|
45544
|
+
if (urls.length > 0) {
|
|
45545
|
+
try {
|
|
45546
|
+
const firstUrl = new URL(urls[0]);
|
|
45547
|
+
const domain = firstUrl.hostname.replace(/^www\./, "").replace(/\./g, "_");
|
|
45548
|
+
const urlsHash = urls.slice().sort().join("|").split("").reduce((hash, char) => (hash << 5) - hash + char.charCodeAt(0) | 0, 0).toString(16).replace("-", "").slice(0, 8);
|
|
45549
|
+
defaultId = `urls_${domain}_${urlsHash}`;
|
|
45550
|
+
} catch {
|
|
45551
|
+
}
|
|
45552
|
+
}
|
|
45553
|
+
const id = options.id || defaultId;
|
|
45509
45554
|
return new _WebsiteSource(id, "urls", { ...options, urls });
|
|
45510
45555
|
}
|
|
45511
45556
|
};
|
|
@@ -45515,12 +45560,29 @@ init_define_BUILD();
|
|
|
45515
45560
|
init_define_PACKAGE_VERSIONS();
|
|
45516
45561
|
import { z as z23 } from "@botpress/sdk";
|
|
45517
45562
|
var DirectorySource = class _DirectorySource extends DataSource {
|
|
45518
|
-
|
|
45519
|
-
|
|
45563
|
+
_directoryPath;
|
|
45564
|
+
_filterFn;
|
|
45520
45565
|
constructor(id, directoryPath, options = {}) {
|
|
45521
45566
|
super(id, "directory");
|
|
45522
|
-
this.
|
|
45523
|
-
this.
|
|
45567
|
+
this._directoryPath = directoryPath;
|
|
45568
|
+
this._filterFn = options.filter ?? void 0;
|
|
45569
|
+
}
|
|
45570
|
+
/** Get the directory path for this source */
|
|
45571
|
+
get directoryPath() {
|
|
45572
|
+
return this._directoryPath;
|
|
45573
|
+
}
|
|
45574
|
+
/** Get the filter function for this source */
|
|
45575
|
+
get filterFn() {
|
|
45576
|
+
return this._filterFn;
|
|
45577
|
+
}
|
|
45578
|
+
/** Get serializable configuration for change detection */
|
|
45579
|
+
getConfig() {
|
|
45580
|
+
return {
|
|
45581
|
+
id: this.id,
|
|
45582
|
+
type: this.type,
|
|
45583
|
+
directoryPath: this._directoryPath,
|
|
45584
|
+
filterFn: this._filterFn?.toString() || null
|
|
45585
|
+
};
|
|
45524
45586
|
}
|
|
45525
45587
|
get syncWorkflow() {
|
|
45526
45588
|
return createSyncWorkflow({
|
|
@@ -45667,6 +45729,17 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
45667
45729
|
}
|
|
45668
45730
|
};
|
|
45669
45731
|
|
|
45732
|
+
// src/primitives/data-sources/index.ts
|
|
45733
|
+
function isDirectorySource(source) {
|
|
45734
|
+
return source.type === "directory";
|
|
45735
|
+
}
|
|
45736
|
+
function isWebsiteSource(source) {
|
|
45737
|
+
return source.type === "website";
|
|
45738
|
+
}
|
|
45739
|
+
function isTableSource(source) {
|
|
45740
|
+
return source.type === "table";
|
|
45741
|
+
}
|
|
45742
|
+
|
|
45670
45743
|
// src/primitives/knowledge.ts
|
|
45671
45744
|
init_define_BUILD();
|
|
45672
45745
|
init_define_PACKAGE_VERSIONS();
|
|
@@ -46003,6 +46076,9 @@ var DataSource2;
|
|
|
46003
46076
|
DataSource3.Table = TableSource;
|
|
46004
46077
|
DataSource3.Website = WebsiteSource;
|
|
46005
46078
|
DataSource3.Directory = DirectorySource;
|
|
46079
|
+
DataSource3.isDirectory = isDirectorySource;
|
|
46080
|
+
DataSource3.isWebsite = isWebsiteSource;
|
|
46081
|
+
DataSource3.isTable = isTableSource;
|
|
46006
46082
|
})(DataSource2 || (DataSource2 = {}));
|
|
46007
46083
|
|
|
46008
46084
|
// src/workers/index.ts
|