@botpress/adk-cli 1.6.5 → 1.6.6
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/cli.js +150 -28
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -316257,6 +316257,83 @@ function isLeafTag(obj, options) {
|
|
|
316257
316257
|
}
|
|
316258
316258
|
return false;
|
|
316259
316259
|
}
|
|
316260
|
+
function extractHtmlMetadata(html) {
|
|
316261
|
+
const metadata = {};
|
|
316262
|
+
const titleMatch = html.match(/<title[^>]*>([^<]+)<\/title>/i);
|
|
316263
|
+
if (titleMatch && titleMatch[1]) {
|
|
316264
|
+
metadata.title = titleMatch[1].trim();
|
|
316265
|
+
}
|
|
316266
|
+
let descriptionMatch = html.match(/<meta\s+(?:name|property)=["'](?:description|og:description)["']\s+content="([^"]+)"/i);
|
|
316267
|
+
if (!descriptionMatch) {
|
|
316268
|
+
descriptionMatch = html.match(/<meta\s+(?:name|property)=["'](?:description|og:description)["']\s+content='([^']+)'/i);
|
|
316269
|
+
}
|
|
316270
|
+
if (descriptionMatch && descriptionMatch[1]) {
|
|
316271
|
+
metadata.description = descriptionMatch[1].trim();
|
|
316272
|
+
}
|
|
316273
|
+
const faviconPatterns = [
|
|
316274
|
+
/<link\s+[^>]*rel="(?:icon|shortcut icon|apple-touch-icon)"[^>]*href="([^"]+)"/i,
|
|
316275
|
+
/<link\s+[^>]*rel='(?:icon|shortcut icon|apple-touch-icon)'[^>]*href='([^']+)'/i,
|
|
316276
|
+
/<link\s+[^>]*href="([^"]+)"[^>]*rel="(?:icon|shortcut icon|apple-touch-icon)"/i,
|
|
316277
|
+
/<link\s+[^>]*href='([^']+)'[^>]*rel='(?:icon|shortcut icon|apple-touch-icon)'/i
|
|
316278
|
+
];
|
|
316279
|
+
for (const pattern of faviconPatterns) {
|
|
316280
|
+
const faviconMatch = html.match(pattern);
|
|
316281
|
+
if (faviconMatch && faviconMatch[1]) {
|
|
316282
|
+
metadata.favicon = faviconMatch[1].trim();
|
|
316283
|
+
break;
|
|
316284
|
+
}
|
|
316285
|
+
}
|
|
316286
|
+
if (!metadata.favicon) {
|
|
316287
|
+
metadata.favicon = "/favicon.ico";
|
|
316288
|
+
}
|
|
316289
|
+
return metadata;
|
|
316290
|
+
}
|
|
316291
|
+
function resolveUrl(url22, baseUrl) {
|
|
316292
|
+
if (url22.startsWith("http://") || url22.startsWith("https://")) {
|
|
316293
|
+
return url22;
|
|
316294
|
+
}
|
|
316295
|
+
try {
|
|
316296
|
+
const base3 = new URL(baseUrl);
|
|
316297
|
+
return new URL(url22, base3.origin).href;
|
|
316298
|
+
} catch {
|
|
316299
|
+
return url22;
|
|
316300
|
+
}
|
|
316301
|
+
}
|
|
316302
|
+
async function fetchHtml(url22, options) {
|
|
316303
|
+
const userAgent = options?.userAgent || "Mozilla/5.0 (compatible; BotpressBot/1.0)";
|
|
316304
|
+
const fetchOptions = {
|
|
316305
|
+
headers: {
|
|
316306
|
+
"User-Agent": userAgent
|
|
316307
|
+
}
|
|
316308
|
+
};
|
|
316309
|
+
if (options?.timeout) {
|
|
316310
|
+
fetchOptions.signal = AbortSignal.timeout(options.timeout);
|
|
316311
|
+
}
|
|
316312
|
+
const response = await fetch(url22, fetchOptions);
|
|
316313
|
+
if (!response.ok) {
|
|
316314
|
+
throw new Error(`Failed to fetch ${url22}: ${response.status} ${response.statusText}`);
|
|
316315
|
+
}
|
|
316316
|
+
const contentType = response.headers.get("content-type") || "text/html";
|
|
316317
|
+
const content = await response.text();
|
|
316318
|
+
const isHtml = contentType.includes("text/html") || contentType.includes("application/xhtml");
|
|
316319
|
+
if (!isHtml) {
|
|
316320
|
+
return {
|
|
316321
|
+
url: url22,
|
|
316322
|
+
contentType,
|
|
316323
|
+
content
|
|
316324
|
+
};
|
|
316325
|
+
}
|
|
316326
|
+
const extracted = extractHtmlMetadata(content);
|
|
316327
|
+
if (extracted.favicon) {
|
|
316328
|
+
extracted.favicon = resolveUrl(extracted.favicon, url22);
|
|
316329
|
+
}
|
|
316330
|
+
return {
|
|
316331
|
+
url: url22,
|
|
316332
|
+
contentType,
|
|
316333
|
+
content,
|
|
316334
|
+
metadata: extracted
|
|
316335
|
+
};
|
|
316336
|
+
}
|
|
316260
316337
|
function debugLog(...args) {
|
|
316261
316338
|
if (DEBUG_ENABLED) {
|
|
316262
316339
|
console.log(...args);
|
|
@@ -319533,7 +319610,7 @@ var init_internal = __esm(() => {
|
|
|
319533
319610
|
});
|
|
319534
319611
|
init_define_PACKAGE_VERSIONS = __esm2({
|
|
319535
319612
|
"<define:__PACKAGE_VERSIONS__>"() {
|
|
319536
|
-
define_PACKAGE_VERSIONS_default = { runtime: "1.6.
|
|
319613
|
+
define_PACKAGE_VERSIONS_default = { runtime: "1.6.6", adk: "not-installed", sdk: "4.17.3", llmz: "0.0.27", zai: "2.4.0", cognitive: "0.2.0" };
|
|
319537
319614
|
}
|
|
319538
319615
|
});
|
|
319539
319616
|
init_globalThis = __esm2({
|
|
@@ -343606,7 +343683,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
343606
343683
|
var currentUrlParts = parseUrl(this._currentUrl);
|
|
343607
343684
|
var currentHost = currentHostHeader || currentUrlParts.host;
|
|
343608
343685
|
var currentUrl = /^\w+:/.test(location) ? this._currentUrl : url22.format(Object.assign(currentUrlParts, { host: currentHost }));
|
|
343609
|
-
var redirectUrl =
|
|
343686
|
+
var redirectUrl = resolveUrl2(location, currentUrl);
|
|
343610
343687
|
debug("redirecting to", redirectUrl.href);
|
|
343611
343688
|
this._isRedirect = true;
|
|
343612
343689
|
spreadUrlObject(redirectUrl, this._options);
|
|
@@ -343689,7 +343766,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
343689
343766
|
}
|
|
343690
343767
|
return parsed;
|
|
343691
343768
|
}
|
|
343692
|
-
function
|
|
343769
|
+
function resolveUrl2(relative, base3) {
|
|
343693
343770
|
return useNativeURL ? new URL2(relative, base3) : parseUrl(url22.resolve(base3, relative));
|
|
343694
343771
|
}
|
|
343695
343772
|
function validateUrl(input) {
|
|
@@ -355555,6 +355632,8 @@ ${iteration.status.execution_error.stack}`;
|
|
|
355555
355632
|
init_define_BUILD();
|
|
355556
355633
|
init_define_PACKAGE_VERSIONS();
|
|
355557
355634
|
METADATA_SYMBOL2 = XmlNode.getMetaDataSymbol();
|
|
355635
|
+
init_define_BUILD();
|
|
355636
|
+
init_define_PACKAGE_VERSIONS();
|
|
355558
355637
|
State = X.object({
|
|
355559
355638
|
urls: X.array(X.object({
|
|
355560
355639
|
loc: X.string(),
|
|
@@ -355571,6 +355650,7 @@ ${iteration.status.execution_error.stack}`;
|
|
|
355571
355650
|
urls;
|
|
355572
355651
|
filterFn;
|
|
355573
355652
|
customFetch;
|
|
355653
|
+
fetchStrategy;
|
|
355574
355654
|
maxPages;
|
|
355575
355655
|
maxDepth;
|
|
355576
355656
|
transformFn;
|
|
@@ -355581,49 +355661,84 @@ ${iteration.status.execution_error.stack}`;
|
|
|
355581
355661
|
this.sitemapUrl = options.sitemapUrl ?? undefined;
|
|
355582
355662
|
this.urls = options.urls ?? undefined;
|
|
355583
355663
|
this.filterFn = "filter" in options ? options.filter : undefined;
|
|
355584
|
-
|
|
355664
|
+
if (typeof options.fetch === "string") {
|
|
355665
|
+
this.fetchStrategy = options.fetch;
|
|
355666
|
+
this.customFetch = undefined;
|
|
355667
|
+
} else if (typeof options.fetch === "function") {
|
|
355668
|
+
this.customFetch = options.fetch;
|
|
355669
|
+
this.fetchStrategy = "node:fetch";
|
|
355670
|
+
} else {
|
|
355671
|
+
this.fetchStrategy = "node:fetch";
|
|
355672
|
+
this.customFetch = undefined;
|
|
355673
|
+
}
|
|
355585
355674
|
this.maxPages = Math.max(1, Math.min(("maxPages" in options ? options.maxPages : undefined) ?? 50000, 50000));
|
|
355586
355675
|
this.maxDepth = Math.max(1, Math.min(("maxDepth" in options ? options.maxDepth : undefined) ?? 20, 20));
|
|
355587
355676
|
}
|
|
355588
355677
|
isBrowserIntegrationAvailable() {
|
|
355589
355678
|
return !!adk.project.integrations.get("browser");
|
|
355590
355679
|
}
|
|
355680
|
+
convertMetadata(metadata) {
|
|
355681
|
+
const result = {};
|
|
355682
|
+
if (metadata.title) {
|
|
355683
|
+
result[WellKnownMetadata.knowledge.TITLE] = metadata.title;
|
|
355684
|
+
}
|
|
355685
|
+
if (metadata.description) {
|
|
355686
|
+
result[WellKnownMetadata.knowledge.DESCRIPTION] = metadata.description;
|
|
355687
|
+
}
|
|
355688
|
+
if (metadata.favicon) {
|
|
355689
|
+
result[WellKnownMetadata.knowledge.FAVICON] = metadata.favicon;
|
|
355690
|
+
}
|
|
355691
|
+
return result;
|
|
355692
|
+
}
|
|
355693
|
+
async defaultFetch(url22) {
|
|
355694
|
+
const result = await fetchHtml(url22, {
|
|
355695
|
+
timeout: 30000
|
|
355696
|
+
});
|
|
355697
|
+
if (!result.metadata) {
|
|
355698
|
+
return {
|
|
355699
|
+
url: result.url,
|
|
355700
|
+
contentType: result.contentType,
|
|
355701
|
+
content: result.content
|
|
355702
|
+
};
|
|
355703
|
+
}
|
|
355704
|
+
return {
|
|
355705
|
+
url: result.url,
|
|
355706
|
+
contentType: result.contentType,
|
|
355707
|
+
content: result.content,
|
|
355708
|
+
metadata: this.convertMetadata(result.metadata)
|
|
355709
|
+
};
|
|
355710
|
+
}
|
|
355591
355711
|
async fetchSitemap(url22) {
|
|
355592
355712
|
if (this.customFetch) {
|
|
355593
355713
|
try {
|
|
355594
355714
|
return await this.customFetch(url22);
|
|
355595
355715
|
} catch (err) {
|
|
355596
|
-
console.warn(`Custom fetch failed for ${url22}, falling back...`);
|
|
355716
|
+
console.warn(`Custom fetch failed for ${url22}, falling back to ${this.fetchStrategy}...`);
|
|
355597
355717
|
}
|
|
355598
355718
|
}
|
|
355599
|
-
if (
|
|
355600
|
-
|
|
355601
|
-
}
|
|
355602
|
-
|
|
355603
|
-
urls: [url22],
|
|
355604
|
-
timeout: 30000,
|
|
355605
|
-
waitFor: 500
|
|
355606
|
-
});
|
|
355607
|
-
const result = output2?.results[0];
|
|
355608
|
-
if (!result || !result.content) {
|
|
355609
|
-
throw new Error(`Failed to fetch content from ${url22}`);
|
|
355719
|
+
if (this.fetchStrategy === "integration:browser") {
|
|
355720
|
+
return this.fetchWithBrowserIntegration(url22, { raw: true });
|
|
355721
|
+
} else {
|
|
355722
|
+
return this.defaultFetch(url22);
|
|
355610
355723
|
}
|
|
355611
|
-
return {
|
|
355612
|
-
url: result.url,
|
|
355613
|
-
contentType: "application/html",
|
|
355614
|
-
content: result.raw
|
|
355615
|
-
};
|
|
355616
355724
|
}
|
|
355617
355725
|
async fetchUrl(url22) {
|
|
355618
355726
|
if (this.customFetch) {
|
|
355619
355727
|
try {
|
|
355620
355728
|
return await this.customFetch(url22);
|
|
355621
355729
|
} catch (err) {
|
|
355622
|
-
console.warn(`Custom fetch failed for ${url22}, falling back...`);
|
|
355730
|
+
console.warn(`Custom fetch failed for ${url22}, falling back to ${this.fetchStrategy}...`);
|
|
355623
355731
|
}
|
|
355624
355732
|
}
|
|
355733
|
+
if (this.fetchStrategy === "integration:browser") {
|
|
355734
|
+
return this.fetchWithBrowserIntegration(url22, { raw: false });
|
|
355735
|
+
} else {
|
|
355736
|
+
return this.defaultFetch(url22);
|
|
355737
|
+
}
|
|
355738
|
+
}
|
|
355739
|
+
async fetchWithBrowserIntegration(url22, options) {
|
|
355625
355740
|
if (!this.isBrowserIntegrationAvailable()) {
|
|
355626
|
-
throw new Error(`The 'browser' integration is not installed
|
|
355741
|
+
throw new Error(`The 'browser' integration is not installed. Please install it or use fetch: 'node:fetch'.`);
|
|
355627
355742
|
}
|
|
355628
355743
|
const output2 = await adk.project.integrations.get("browser")?.actions.browsePages({
|
|
355629
355744
|
urls: [url22],
|
|
@@ -355634,6 +355749,13 @@ ${iteration.status.execution_error.stack}`;
|
|
|
355634
355749
|
if (!result || !result.content) {
|
|
355635
355750
|
throw new Error(`Failed to fetch content from ${url22}`);
|
|
355636
355751
|
}
|
|
355752
|
+
if (options.raw && result.raw) {
|
|
355753
|
+
return {
|
|
355754
|
+
url: result.url,
|
|
355755
|
+
contentType: "application/html",
|
|
355756
|
+
content: result.raw
|
|
355757
|
+
};
|
|
355758
|
+
}
|
|
355637
355759
|
return {
|
|
355638
355760
|
url: result.url,
|
|
355639
355761
|
contentType: "text/markdown",
|
|
@@ -371664,7 +371786,7 @@ class AgentProjectGenerator {
|
|
|
371664
371786
|
deploy: "adk deploy"
|
|
371665
371787
|
},
|
|
371666
371788
|
dependencies: {
|
|
371667
|
-
"@botpress/runtime": "^1.6.
|
|
371789
|
+
"@botpress/runtime": "^1.6.6"
|
|
371668
371790
|
},
|
|
371669
371791
|
devDependencies: {
|
|
371670
371792
|
typescript: "^5.0.0"
|
|
@@ -380871,7 +380993,7 @@ var init_Separator = __esm(async () => {
|
|
|
380871
380993
|
var require_package3 = __commonJS((exports, module) => {
|
|
380872
380994
|
module.exports = {
|
|
380873
380995
|
name: "@botpress/adk",
|
|
380874
|
-
version: "1.6.
|
|
380996
|
+
version: "1.6.6",
|
|
380875
380997
|
description: "Core ADK library for building AI agents on Botpress",
|
|
380876
380998
|
type: "module",
|
|
380877
380999
|
main: "dist/index.js",
|
|
@@ -380918,7 +381040,7 @@ var require_package3 = __commonJS((exports, module) => {
|
|
|
380918
381040
|
"@botpress/cli": "^4.20",
|
|
380919
381041
|
"@botpress/client": "^1.27.0",
|
|
380920
381042
|
"@botpress/cognitive": "^0.2.0",
|
|
380921
|
-
"@botpress/runtime": "^1.6.
|
|
381043
|
+
"@botpress/runtime": "^1.6.6",
|
|
380922
381044
|
"@botpress/sdk": "^4.17.3",
|
|
380923
381045
|
"@bpinternal/yargs-extra": "^0.0.21",
|
|
380924
381046
|
"@parcel/watcher": "^2.5.1",
|
|
@@ -382306,7 +382428,7 @@ function checkRuntimeVersion(agentRoot) {
|
|
|
382306
382428
|
`));
|
|
382307
382429
|
}
|
|
382308
382430
|
}
|
|
382309
|
-
var semver2, EXPECTED_RUNTIME_VERSION = "1.6.
|
|
382431
|
+
var semver2, EXPECTED_RUNTIME_VERSION = "1.6.6";
|
|
382310
382432
|
var init_runtime_version_check = __esm(() => {
|
|
382311
382433
|
init_source();
|
|
382312
382434
|
semver2 = __toESM(require_semver2(), 1);
|
|
@@ -397905,7 +398027,7 @@ if (!checkNodeVersion(true)) {
|
|
|
397905
398027
|
}
|
|
397906
398028
|
var __filename2 = fileURLToPath9(import.meta.url);
|
|
397907
398029
|
var __dirname5 = dirname3(__filename2);
|
|
397908
|
-
var CLI_VERSION = "1.6.
|
|
398030
|
+
var CLI_VERSION = "1.6.6";
|
|
397909
398031
|
program.name("adk").description("Botpress Agent Development Kit (ADK) - CLI for building AI agents").version(CLI_VERSION).option("--no-cache", "Disable caching for integration lookups").configureHelp({
|
|
397910
398032
|
formatHelp: () => formatHelp(program, CLI_VERSION)
|
|
397911
398033
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/adk-cli",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.6",
|
|
4
4
|
"description": "Command-line interface for the Botpress Agent Development Kit (ADK)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"url": "https://github.com/botpress/adk"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@botpress/adk": "^1.6.
|
|
43
|
+
"@botpress/adk": "^1.6.6",
|
|
44
44
|
"@botpress/cli": "^4.20",
|
|
45
|
-
"@botpress/runtime": "^1.6.
|
|
45
|
+
"@botpress/runtime": "^1.6.6",
|
|
46
46
|
"adm-zip": "^0.5.16",
|
|
47
47
|
"chalk": "^5.4.1",
|
|
48
48
|
"clipboardy": "^4.0.0",
|