@botpress/adk 1.8.4 → 1.10.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/bot-generator/generator.d.ts +2 -0
- package/dist/bot-generator/generator.d.ts.map +1 -1
- package/dist/commands/bp-cli.d.ts +5 -1
- package/dist/commands/bp-cli.d.ts.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/manager.d.ts +48 -0
- package/dist/config/manager.d.ts.map +1 -0
- package/dist/generators/configuration-types.d.ts +3 -0
- package/dist/generators/configuration-types.d.ts.map +1 -0
- package/dist/generators/conversation-types.d.ts.map +1 -1
- package/dist/generators/index.d.ts +1 -0
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/tag-types.d.ts +3 -0
- package/dist/generators/tag-types.d.ts.map +1 -0
- package/dist/generators/workflow-types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +528 -244
- package/dist/index.js.map +15 -12
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -654,7 +654,7 @@ var PRETTIER_CONFIG, formatCode = async (code, filepath) => {
|
|
|
654
654
|
`));
|
|
655
655
|
return code;
|
|
656
656
|
}
|
|
657
|
-
}, ADK_VERSION = "1.
|
|
657
|
+
}, ADK_VERSION = "1.10.1", relative2 = (from, to) => {
|
|
658
658
|
const fromDir = path10.dirname(from);
|
|
659
659
|
const relative3 = path10.relative(fromDir, to);
|
|
660
660
|
return relative3.startsWith(".") ? relative3 : `./${relative3}`;
|
|
@@ -678,7 +678,7 @@ var exports_action_types = {};
|
|
|
678
678
|
__export(exports_action_types, {
|
|
679
679
|
generateActionTypes: () => generateActionTypes
|
|
680
680
|
});
|
|
681
|
-
import
|
|
681
|
+
import path30 from "path";
|
|
682
682
|
async function generateActionTypes(project) {
|
|
683
683
|
const actionDefs = [];
|
|
684
684
|
for (const action of project.actions) {
|
|
@@ -693,7 +693,7 @@ async function generateActionTypes(project) {
|
|
|
693
693
|
};`);
|
|
694
694
|
continue;
|
|
695
695
|
}
|
|
696
|
-
const absolutePath =
|
|
696
|
+
const absolutePath = path30.join(project.path, action.path);
|
|
697
697
|
const actionModule = await import(`${absolutePath}?t=${Date.now()}`);
|
|
698
698
|
const actionInstance = actionModule[action.export] || actionModule.default;
|
|
699
699
|
if (actionInstance && actionInstance.input && actionInstance.output) {
|
|
@@ -738,7 +738,7 @@ ${actionDefs.join(`
|
|
|
738
738
|
};
|
|
739
739
|
}
|
|
740
740
|
`;
|
|
741
|
-
const actionTypesPath =
|
|
741
|
+
const actionTypesPath = path30.join(project.path, ".adk", "action-types.d.ts");
|
|
742
742
|
await createFile(actionTypesPath, await formatCode(content));
|
|
743
743
|
}
|
|
744
744
|
var init_action_types = __esm(() => {
|
|
@@ -751,7 +751,7 @@ var exports_integration_action_types = {};
|
|
|
751
751
|
__export(exports_integration_action_types, {
|
|
752
752
|
generateIntegrationActionTypes: () => generateIntegrationActionTypes
|
|
753
753
|
});
|
|
754
|
-
import
|
|
754
|
+
import path31 from "path";
|
|
755
755
|
async function generateIntegrationActionTypes(project) {
|
|
756
756
|
const content = `
|
|
757
757
|
////////////////////////////////////////////////////////
|
|
@@ -785,7 +785,7 @@ type IntegrationsMap<T> = {
|
|
|
785
785
|
export type IntegrationActions = IntegrationsMap<Integrations>;
|
|
786
786
|
}
|
|
787
787
|
`;
|
|
788
|
-
const integrationActionTypesPath =
|
|
788
|
+
const integrationActionTypesPath = path31.join(project.path, ".adk", "integration-action-types.d.ts");
|
|
789
789
|
await createFile(integrationActionTypesPath, await formatCode(content));
|
|
790
790
|
}
|
|
791
791
|
var init_integration_action_types = __esm(() => {
|
|
@@ -797,7 +797,7 @@ var init_integration_action_types = __esm(() => {
|
|
|
797
797
|
var require_package = __commonJS((exports, module) => {
|
|
798
798
|
module.exports = {
|
|
799
799
|
name: "@botpress/adk",
|
|
800
|
-
version: "1.
|
|
800
|
+
version: "1.10.1",
|
|
801
801
|
description: "Core ADK library for building AI agents on Botpress",
|
|
802
802
|
type: "module",
|
|
803
803
|
main: "dist/index.js",
|
|
@@ -844,8 +844,9 @@ var require_package = __commonJS((exports, module) => {
|
|
|
844
844
|
"@botpress/cli": "^4.27.3",
|
|
845
845
|
"@botpress/client": "^1.27.2",
|
|
846
846
|
"@botpress/cognitive": "^0.2.0",
|
|
847
|
-
"@botpress/runtime": "^1.
|
|
847
|
+
"@botpress/runtime": "^1.10.1",
|
|
848
848
|
"@botpress/sdk": "^4.18.1",
|
|
849
|
+
"@bpinternal/jex": "^1.2.4",
|
|
849
850
|
"@bpinternal/yargs-extra": "^0.0.21",
|
|
850
851
|
"@parcel/watcher": "^2.5.1",
|
|
851
852
|
"@types/glob": "^9.0.0",
|
|
@@ -1069,81 +1070,24 @@ class BaseCommand {
|
|
|
1069
1070
|
}
|
|
1070
1071
|
}
|
|
1071
1072
|
// src/commands/bp-add-command.ts
|
|
1072
|
-
import { execa
|
|
1073
|
+
import { execa } from "execa";
|
|
1073
1074
|
|
|
1074
1075
|
// src/commands/bp-cli.ts
|
|
1075
|
-
import {
|
|
1076
|
+
import { existsSync } from "fs";
|
|
1077
|
+
import os3 from "os";
|
|
1076
1078
|
import path4 from "path";
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
const cliDir = path4.dirname(cliPackagePath);
|
|
1085
|
-
const bundledBpPath = path4.join(cliDir, "dist", "bp-cli", "bin.js");
|
|
1086
|
-
await access(bundledBpPath);
|
|
1087
|
-
return bundledBpPath;
|
|
1088
|
-
} catch {}
|
|
1089
|
-
return null;
|
|
1090
|
-
} catch {
|
|
1091
|
-
return null;
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
async function findBpPath(projectPath) {
|
|
1095
|
-
const basePath = projectPath || process.cwd();
|
|
1096
|
-
const bundledPath = await findBundledBpPath();
|
|
1097
|
-
if (bundledPath) {
|
|
1098
|
-
return bundledPath;
|
|
1099
|
-
}
|
|
1100
|
-
try {
|
|
1101
|
-
const require2 = createRequire2(path4.join(basePath, "package.json"));
|
|
1102
|
-
const cliPath = require2.resolve("@botpress/cli/package.json");
|
|
1103
|
-
const cliDir = path4.dirname(cliPath);
|
|
1104
|
-
return path4.join(cliDir, "bin.js");
|
|
1105
|
-
} catch {
|
|
1106
|
-
try {
|
|
1107
|
-
const require2 = createRequire2(path4.join(process.cwd(), "package.json"));
|
|
1108
|
-
const cliPath = require2.resolve("@botpress/cli/package.json");
|
|
1109
|
-
const cliDir = path4.dirname(cliPath);
|
|
1110
|
-
return path4.join(cliDir, "bin.js");
|
|
1111
|
-
} catch {
|
|
1112
|
-
return null;
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
async function getVersionFromPath(bpPath) {
|
|
1117
|
-
try {
|
|
1118
|
-
const { stdout } = await execa("node", [bpPath, "--version"]);
|
|
1119
|
-
return parseVersion(stdout);
|
|
1120
|
-
} catch {
|
|
1121
|
-
return "unknown";
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
function parseVersion(versionOutput) {
|
|
1125
|
-
const match = versionOutput.match(/v?(\d+\.\d+\.\d+)/);
|
|
1126
|
-
return match?.[1] || "0.0.0";
|
|
1127
|
-
}
|
|
1128
|
-
async function getBpCli(projectPath) {
|
|
1129
|
-
const localBpPath = await findBpPath(projectPath);
|
|
1130
|
-
if (localBpPath) {
|
|
1131
|
-
const version = await getVersionFromPath(localBpPath);
|
|
1132
|
-
return {
|
|
1133
|
-
path: localBpPath,
|
|
1134
|
-
version
|
|
1135
|
-
};
|
|
1136
|
-
}
|
|
1137
|
-
try {
|
|
1138
|
-
const { stdout } = await execa("bp", ["--version"]);
|
|
1139
|
-
const version = parseVersion(stdout);
|
|
1140
|
-
return {
|
|
1141
|
-
path: "bp",
|
|
1142
|
-
version
|
|
1143
|
-
};
|
|
1144
|
-
} catch {
|
|
1145
|
-
throw new Error("Botpress CLI not found. This should not happen as @botpress/cli is bundled with the ADK CLI.");
|
|
1079
|
+
var BP_CLI_VERSION = "4.27.3";
|
|
1080
|
+
var BP_CLI_INSTALL_ALL = path4.join(os3.homedir(), ".adk", `bp-cli`);
|
|
1081
|
+
var BP_CLI_INSTALL_DIR = path4.join(BP_CLI_INSTALL_ALL, BP_CLI_VERSION);
|
|
1082
|
+
var BP_CLI_BIN_PATH = path4.join(BP_CLI_INSTALL_DIR, "node_modules", "@botpress", "cli", "bin.js");
|
|
1083
|
+
function getBpCli() {
|
|
1084
|
+
if (!existsSync(BP_CLI_BIN_PATH)) {
|
|
1085
|
+
throw new Error(`@botpress/cli version ${BP_CLI_VERSION} is not installed in the ADK directory "${BP_CLI_INSTALL_DIR}". This is a bug, please report it to the Botpress team.`);
|
|
1146
1086
|
}
|
|
1087
|
+
return {
|
|
1088
|
+
path: BP_CLI_BIN_PATH,
|
|
1089
|
+
version: BP_CLI_VERSION
|
|
1090
|
+
};
|
|
1147
1091
|
}
|
|
1148
1092
|
|
|
1149
1093
|
// src/commands/bp-add-command.ts
|
|
@@ -1157,7 +1101,7 @@ class BpAddCommand extends BaseCommand {
|
|
|
1157
1101
|
}
|
|
1158
1102
|
async run() {
|
|
1159
1103
|
const { resource, botPath, workspaceId, credentials } = this.options;
|
|
1160
|
-
const { path: bpCommand } =
|
|
1104
|
+
const { path: bpCommand } = getBpCli();
|
|
1161
1105
|
const args = [
|
|
1162
1106
|
"add",
|
|
1163
1107
|
resource,
|
|
@@ -1171,7 +1115,7 @@ class BpAddCommand extends BaseCommand {
|
|
|
1171
1115
|
"--apiUrl",
|
|
1172
1116
|
credentials.apiUrl
|
|
1173
1117
|
];
|
|
1174
|
-
this.childProcess =
|
|
1118
|
+
this.childProcess = execa(bpCommand, args, {
|
|
1175
1119
|
cwd: botPath,
|
|
1176
1120
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1177
1121
|
});
|
|
@@ -1209,9 +1153,9 @@ class BpAddCommand extends BaseCommand {
|
|
|
1209
1153
|
}
|
|
1210
1154
|
}
|
|
1211
1155
|
// src/commands/bp-build-command.ts
|
|
1212
|
-
import { execa as
|
|
1156
|
+
import { execa as execa2 } from "execa";
|
|
1213
1157
|
import { join } from "path";
|
|
1214
|
-
import { access
|
|
1158
|
+
import { access } from "fs/promises";
|
|
1215
1159
|
|
|
1216
1160
|
// src/utils/source-map-optimizer.ts
|
|
1217
1161
|
import { readFile, writeFile } from "fs/promises";
|
|
@@ -1467,9 +1411,9 @@ class BpBuildCommand extends BaseCommand {
|
|
|
1467
1411
|
}
|
|
1468
1412
|
async run() {
|
|
1469
1413
|
const { botPath } = this.options;
|
|
1470
|
-
const { path: bpCommand } =
|
|
1414
|
+
const { path: bpCommand } = getBpCli();
|
|
1471
1415
|
const args = ["build", "--sourceMap"];
|
|
1472
|
-
this.childProcess =
|
|
1416
|
+
this.childProcess = execa2(bpCommand, args, {
|
|
1473
1417
|
cwd: botPath,
|
|
1474
1418
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1475
1419
|
});
|
|
@@ -1504,7 +1448,7 @@ class BpBuildCommand extends BaseCommand {
|
|
|
1504
1448
|
const { botPath } = this.options;
|
|
1505
1449
|
const sourceMapPath = join(botPath, ".botpress", "dist", "index.cjs.map");
|
|
1506
1450
|
try {
|
|
1507
|
-
await
|
|
1451
|
+
await access(sourceMapPath);
|
|
1508
1452
|
const agentSrcPath = join(botPath, "..", "..", "src");
|
|
1509
1453
|
await optimizeSourceMap({
|
|
1510
1454
|
sourceMapPath,
|
|
@@ -1520,7 +1464,7 @@ class BpBuildCommand extends BaseCommand {
|
|
|
1520
1464
|
}
|
|
1521
1465
|
}
|
|
1522
1466
|
// src/commands/bp-deploy-command.ts
|
|
1523
|
-
import { execa as
|
|
1467
|
+
import { execa as execa3 } from "execa";
|
|
1524
1468
|
class BpDeployCommand extends BaseCommand {
|
|
1525
1469
|
options;
|
|
1526
1470
|
childProcess = null;
|
|
@@ -1531,7 +1475,7 @@ class BpDeployCommand extends BaseCommand {
|
|
|
1531
1475
|
}
|
|
1532
1476
|
async run() {
|
|
1533
1477
|
const { botPath, botId, workspaceId, credentials } = this.options;
|
|
1534
|
-
const { path: bpCommand } =
|
|
1478
|
+
const { path: bpCommand } = getBpCli();
|
|
1535
1479
|
const args = [
|
|
1536
1480
|
"deploy",
|
|
1537
1481
|
"--botId",
|
|
@@ -1544,7 +1488,7 @@ class BpDeployCommand extends BaseCommand {
|
|
|
1544
1488
|
"--apiUrl",
|
|
1545
1489
|
credentials.apiUrl
|
|
1546
1490
|
];
|
|
1547
|
-
this.childProcess =
|
|
1491
|
+
this.childProcess = execa3(bpCommand, args, {
|
|
1548
1492
|
cwd: botPath,
|
|
1549
1493
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1550
1494
|
});
|
|
@@ -1582,9 +1526,9 @@ class BpDeployCommand extends BaseCommand {
|
|
|
1582
1526
|
}
|
|
1583
1527
|
}
|
|
1584
1528
|
// src/commands/bp-dev-command.ts
|
|
1585
|
-
import { execa as
|
|
1529
|
+
import { execa as execa4 } from "execa";
|
|
1586
1530
|
import { join as join2 } from "path";
|
|
1587
|
-
import { access as
|
|
1531
|
+
import { access as access2 } from "fs/promises";
|
|
1588
1532
|
class BpDevCommand extends BaseCommand {
|
|
1589
1533
|
options;
|
|
1590
1534
|
childProcess = null;
|
|
@@ -1598,7 +1542,7 @@ class BpDevCommand extends BaseCommand {
|
|
|
1598
1542
|
}
|
|
1599
1543
|
async run() {
|
|
1600
1544
|
const { port, botPath, workspaceId, credentials, sourceMap = true } = this.options;
|
|
1601
|
-
const { path: bpCommand } =
|
|
1545
|
+
const { path: bpCommand } = getBpCli();
|
|
1602
1546
|
const bpArgs = [
|
|
1603
1547
|
"dev",
|
|
1604
1548
|
"--port",
|
|
@@ -1613,7 +1557,7 @@ class BpDevCommand extends BaseCommand {
|
|
|
1613
1557
|
if (sourceMap) {
|
|
1614
1558
|
bpArgs.push("--sourceMap");
|
|
1615
1559
|
}
|
|
1616
|
-
this.childProcess =
|
|
1560
|
+
this.childProcess = execa4(bpCommand, bpArgs, {
|
|
1617
1561
|
cwd: botPath,
|
|
1618
1562
|
env: {
|
|
1619
1563
|
...process.env,
|
|
@@ -1783,7 +1727,7 @@ ${this.stderrLines.join(`
|
|
|
1783
1727
|
const { botPath } = this.options;
|
|
1784
1728
|
const sourceMapPath = join2(botPath, ".botpress", "dist", "index.cjs.map");
|
|
1785
1729
|
try {
|
|
1786
|
-
await
|
|
1730
|
+
await access2(sourceMapPath);
|
|
1787
1731
|
const agentSrcPath = join2(botPath, "..", "..", "src");
|
|
1788
1732
|
await optimizeSourceMap({
|
|
1789
1733
|
sourceMapPath,
|
|
@@ -1812,7 +1756,7 @@ ${this.stderrLines.join(`
|
|
|
1812
1756
|
}
|
|
1813
1757
|
}
|
|
1814
1758
|
// src/commands/bp-chat-command.ts
|
|
1815
|
-
import { execa as
|
|
1759
|
+
import { execa as execa5 } from "execa";
|
|
1816
1760
|
class BpChatCommand extends BaseCommand {
|
|
1817
1761
|
options;
|
|
1818
1762
|
childProcess = null;
|
|
@@ -1821,8 +1765,8 @@ class BpChatCommand extends BaseCommand {
|
|
|
1821
1765
|
this.options = options;
|
|
1822
1766
|
}
|
|
1823
1767
|
async run() {
|
|
1824
|
-
const { botId, workspaceId, credentials
|
|
1825
|
-
const { path: bpCommand } =
|
|
1768
|
+
const { botId, workspaceId, credentials } = this.options;
|
|
1769
|
+
const { path: bpCommand } = getBpCli();
|
|
1826
1770
|
const bpArgs = [
|
|
1827
1771
|
"chat",
|
|
1828
1772
|
"--botId",
|
|
@@ -1834,7 +1778,7 @@ class BpChatCommand extends BaseCommand {
|
|
|
1834
1778
|
"--apiUrl",
|
|
1835
1779
|
credentials.apiUrl
|
|
1836
1780
|
];
|
|
1837
|
-
this.childProcess =
|
|
1781
|
+
this.childProcess = execa5(bpCommand, bpArgs, {
|
|
1838
1782
|
stdio: "inherit"
|
|
1839
1783
|
});
|
|
1840
1784
|
try {
|
|
@@ -2415,7 +2359,7 @@ import { Client as Client4 } from "@botpress/client";
|
|
|
2415
2359
|
// src/integrations/enhanced-cache.ts
|
|
2416
2360
|
import fs6 from "fs/promises";
|
|
2417
2361
|
import path7 from "path";
|
|
2418
|
-
import
|
|
2362
|
+
import os4 from "os";
|
|
2419
2363
|
|
|
2420
2364
|
class EnhancedIntegrationCache {
|
|
2421
2365
|
cacheDir;
|
|
@@ -2424,7 +2368,7 @@ class EnhancedIntegrationCache {
|
|
|
2424
2368
|
noCache;
|
|
2425
2369
|
constructor(noCache = false) {
|
|
2426
2370
|
this.noCache = noCache;
|
|
2427
|
-
this.cacheDir = path7.join(
|
|
2371
|
+
this.cacheDir = path7.join(os4.homedir(), ".adk", "cache", "integrations");
|
|
2428
2372
|
this.resolutionsDir = path7.join(this.cacheDir, "resolutions");
|
|
2429
2373
|
this.definitionsDir = path7.join(this.cacheDir, "definitions");
|
|
2430
2374
|
}
|
|
@@ -2805,13 +2749,13 @@ class IntegrationManager {
|
|
|
2805
2749
|
// src/integrations/cache.ts
|
|
2806
2750
|
import fs7 from "fs/promises";
|
|
2807
2751
|
import path8 from "path";
|
|
2808
|
-
import
|
|
2752
|
+
import os5 from "os";
|
|
2809
2753
|
|
|
2810
2754
|
class IntegrationCache {
|
|
2811
2755
|
cacheDir;
|
|
2812
2756
|
integrationsDir;
|
|
2813
2757
|
constructor() {
|
|
2814
|
-
this.cacheDir = path8.join(
|
|
2758
|
+
this.cacheDir = path8.join(os5.homedir(), ".adk", "cache");
|
|
2815
2759
|
this.integrationsDir = path8.join(this.cacheDir, "integrations");
|
|
2816
2760
|
}
|
|
2817
2761
|
async ensureCacheDir() {
|
|
@@ -2891,10 +2835,10 @@ import * as process2 from "process";
|
|
|
2891
2835
|
import { Client as Client5 } from "@botpress/client";
|
|
2892
2836
|
import * as fs8 from "fs/promises";
|
|
2893
2837
|
import * as path9 from "path";
|
|
2894
|
-
import * as
|
|
2838
|
+
import * as os6 from "os";
|
|
2895
2839
|
class HubCache {
|
|
2896
2840
|
static CACHE_FILE = "botpress-hub-cache.json";
|
|
2897
|
-
static CACHE_DIR = path9.join(
|
|
2841
|
+
static CACHE_DIR = path9.join(os6.homedir(), ".adk", "cache");
|
|
2898
2842
|
static CACHE_PATH = path9.join(HubCache.CACHE_DIR, HubCache.CACHE_FILE);
|
|
2899
2843
|
static CACHE_DURATION = 30 * 60 * 1000;
|
|
2900
2844
|
client;
|
|
@@ -3661,7 +3605,7 @@ import { Client as Client9 } from "@botpress/client";
|
|
|
3661
3605
|
// src/interfaces/enhanced-cache.ts
|
|
3662
3606
|
import fs9 from "fs/promises";
|
|
3663
3607
|
import path12 from "path";
|
|
3664
|
-
import
|
|
3608
|
+
import os7 from "os";
|
|
3665
3609
|
|
|
3666
3610
|
class EnhancedInterfaceCache {
|
|
3667
3611
|
cacheDir;
|
|
@@ -3670,7 +3614,7 @@ class EnhancedInterfaceCache {
|
|
|
3670
3614
|
noCache;
|
|
3671
3615
|
constructor(noCache = false) {
|
|
3672
3616
|
this.noCache = noCache;
|
|
3673
|
-
this.cacheDir = path12.join(
|
|
3617
|
+
this.cacheDir = path12.join(os7.homedir(), ".adk", "cache", "interfaces");
|
|
3674
3618
|
this.resolutionsDir = path12.join(this.cacheDir, "resolutions");
|
|
3675
3619
|
this.definitionsDir = path12.join(this.cacheDir, "definitions");
|
|
3676
3620
|
}
|
|
@@ -4781,6 +4725,99 @@ class FileWatcher extends EventEmitter2 {
|
|
|
4781
4725
|
init_validation_errors();
|
|
4782
4726
|
init_agent_resolver();
|
|
4783
4727
|
init_types();
|
|
4728
|
+
// src/config/manager.ts
|
|
4729
|
+
import { Client as Client10 } from "@botpress/client";
|
|
4730
|
+
import { sync as jex } from "@bpinternal/jex";
|
|
4731
|
+
class ConfigManager {
|
|
4732
|
+
botId;
|
|
4733
|
+
client;
|
|
4734
|
+
constructor(botId) {
|
|
4735
|
+
this.botId = botId;
|
|
4736
|
+
}
|
|
4737
|
+
async getClient() {
|
|
4738
|
+
if (!this.client) {
|
|
4739
|
+
const credentials = await auth.getActiveCredentials();
|
|
4740
|
+
this.client = new Client10({
|
|
4741
|
+
token: credentials.token,
|
|
4742
|
+
apiUrl: credentials.apiUrl,
|
|
4743
|
+
botId: this.botId,
|
|
4744
|
+
headers: {
|
|
4745
|
+
"x-multiple-integrations": "true"
|
|
4746
|
+
}
|
|
4747
|
+
});
|
|
4748
|
+
}
|
|
4749
|
+
return this.client;
|
|
4750
|
+
}
|
|
4751
|
+
async load() {
|
|
4752
|
+
try {
|
|
4753
|
+
const client = await this.getClient();
|
|
4754
|
+
const { bot } = await client.getBot({ id: this.botId });
|
|
4755
|
+
return bot.configuration?.data || {};
|
|
4756
|
+
} catch (error) {
|
|
4757
|
+
console.warn(`Failed to load configuration from bot ${this.botId}:`, error);
|
|
4758
|
+
return {};
|
|
4759
|
+
}
|
|
4760
|
+
}
|
|
4761
|
+
async save(config, schema) {
|
|
4762
|
+
try {
|
|
4763
|
+
const client = await this.getClient();
|
|
4764
|
+
const { bot } = await client.getBot({ id: this.botId });
|
|
4765
|
+
const updates = {
|
|
4766
|
+
id: this.botId,
|
|
4767
|
+
configuration: {
|
|
4768
|
+
data: config
|
|
4769
|
+
}
|
|
4770
|
+
};
|
|
4771
|
+
if (schema) {
|
|
4772
|
+
const schemaJson = schema.toJSONSchema();
|
|
4773
|
+
const currentSchema = bot.configuration?.schema || {};
|
|
4774
|
+
if (!jex.jsonSchemaEquals(currentSchema, schemaJson)) {
|
|
4775
|
+
updates.configuration.schema = schemaJson;
|
|
4776
|
+
}
|
|
4777
|
+
}
|
|
4778
|
+
await client.updateBot(updates);
|
|
4779
|
+
} catch (error) {
|
|
4780
|
+
throw new Error(`Failed to save configuration to bot ${this.botId}: ${error}`);
|
|
4781
|
+
}
|
|
4782
|
+
}
|
|
4783
|
+
async get(key) {
|
|
4784
|
+
const config = await this.load();
|
|
4785
|
+
return config[key];
|
|
4786
|
+
}
|
|
4787
|
+
async set(key, value, schema) {
|
|
4788
|
+
const config = await this.load();
|
|
4789
|
+
config[key] = value;
|
|
4790
|
+
await this.save(config, schema);
|
|
4791
|
+
}
|
|
4792
|
+
async getAll() {
|
|
4793
|
+
return await this.load();
|
|
4794
|
+
}
|
|
4795
|
+
async validate(schema) {
|
|
4796
|
+
const config = await this.getAll();
|
|
4797
|
+
const result = schema.safeParse(config);
|
|
4798
|
+
if (result.success) {
|
|
4799
|
+
return { valid: true, errors: [], missing: [] };
|
|
4800
|
+
}
|
|
4801
|
+
const errors = [];
|
|
4802
|
+
const missing = [];
|
|
4803
|
+
for (const issue of result.error.issues) {
|
|
4804
|
+
const key = issue.path.join(".");
|
|
4805
|
+
if (issue.code === "invalid_type" && issue.received === "undefined") {
|
|
4806
|
+
missing.push(key);
|
|
4807
|
+
}
|
|
4808
|
+
errors.push(`${key}: ${issue.message}`);
|
|
4809
|
+
}
|
|
4810
|
+
return { valid: false, errors, missing };
|
|
4811
|
+
}
|
|
4812
|
+
async getMissingKeys(schema) {
|
|
4813
|
+
const validation = await this.validate(schema);
|
|
4814
|
+
return validation.missing;
|
|
4815
|
+
}
|
|
4816
|
+
async isValid(schema) {
|
|
4817
|
+
const validation = await this.validate(schema);
|
|
4818
|
+
return validation.valid;
|
|
4819
|
+
}
|
|
4820
|
+
}
|
|
4784
4821
|
// src/agent-init/agent-project-generator.ts
|
|
4785
4822
|
init_utils();
|
|
4786
4823
|
import * as fs11 from "fs";
|
|
@@ -4829,7 +4866,7 @@ class AgentProjectGenerator {
|
|
|
4829
4866
|
deploy: "adk deploy"
|
|
4830
4867
|
},
|
|
4831
4868
|
dependencies: {
|
|
4832
|
-
"@botpress/runtime": `^${"1.
|
|
4869
|
+
"@botpress/runtime": `^${"1.10.1"}`
|
|
4833
4870
|
},
|
|
4834
4871
|
devDependencies: {
|
|
4835
4872
|
typescript: "^5.9.3"
|
|
@@ -5405,9 +5442,9 @@ Description: ${tag?.description}`);
|
|
|
5405
5442
|
}
|
|
5406
5443
|
// src/bot-generator/generator.ts
|
|
5407
5444
|
import dedent from "dedent";
|
|
5408
|
-
import { existsSync as
|
|
5445
|
+
import { existsSync as existsSync6 } from "fs";
|
|
5409
5446
|
import fs15 from "fs/promises";
|
|
5410
|
-
import
|
|
5447
|
+
import path32 from "path";
|
|
5411
5448
|
|
|
5412
5449
|
// src/generators/interface-types.ts
|
|
5413
5450
|
import { transforms as transforms2 } from "@botpress/sdk";
|
|
@@ -5724,10 +5761,201 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
5724
5761
|
await createFile(stateTypesPath, await formatCode(content));
|
|
5725
5762
|
}
|
|
5726
5763
|
|
|
5764
|
+
// src/generators/tag-types.ts
|
|
5765
|
+
init_utils();
|
|
5766
|
+
init_fs();
|
|
5767
|
+
import path22 from "path";
|
|
5768
|
+
async function generateTagTypes(project) {
|
|
5769
|
+
let botTagsType = "Record<string, string | undefined>";
|
|
5770
|
+
let userTagsType = "Record<string, string | undefined>";
|
|
5771
|
+
let conversationTagsType = "Record<string, string | undefined>";
|
|
5772
|
+
let messageTagsType = "Record<string, string | undefined>";
|
|
5773
|
+
let workflowTagsType = "Record<string, string | undefined>";
|
|
5774
|
+
try {
|
|
5775
|
+
const configPath = path22.join(project.path, "agent.config.ts");
|
|
5776
|
+
const configModule = await import(`${configPath}?t=${Date.now()}`);
|
|
5777
|
+
const config = configModule.default;
|
|
5778
|
+
if (config?.bot?.tags) {
|
|
5779
|
+
const tagKeys = Object.keys(config.bot.tags);
|
|
5780
|
+
if (tagKeys.length > 0) {
|
|
5781
|
+
const tagProps = tagKeys.map((key) => {
|
|
5782
|
+
const tag = config.bot.tags[key];
|
|
5783
|
+
const jsdoc = tag.description ? `/**
|
|
5784
|
+
* ${tag.title}
|
|
5785
|
+
*
|
|
5786
|
+
* ${tag.description}
|
|
5787
|
+
*/
|
|
5788
|
+
` : `/** ${tag.title} */
|
|
5789
|
+
`;
|
|
5790
|
+
return `${jsdoc}${key}?: string | undefined`;
|
|
5791
|
+
}).join(`
|
|
5792
|
+
`);
|
|
5793
|
+
botTagsType = `{
|
|
5794
|
+
${tagProps}
|
|
5795
|
+
}`;
|
|
5796
|
+
}
|
|
5797
|
+
}
|
|
5798
|
+
if (config?.user?.tags) {
|
|
5799
|
+
const tagKeys = Object.keys(config.user.tags);
|
|
5800
|
+
if (tagKeys.length > 0) {
|
|
5801
|
+
const tagProps = tagKeys.map((key) => {
|
|
5802
|
+
const tag = config.user.tags[key];
|
|
5803
|
+
const jsdoc = tag.description ? `/**
|
|
5804
|
+
* ${tag.title}
|
|
5805
|
+
*
|
|
5806
|
+
* ${tag.description}
|
|
5807
|
+
*/
|
|
5808
|
+
` : `/** ${tag.title} */
|
|
5809
|
+
`;
|
|
5810
|
+
return `${jsdoc}${key}?: string | undefined`;
|
|
5811
|
+
}).join(`
|
|
5812
|
+
`);
|
|
5813
|
+
userTagsType = `{
|
|
5814
|
+
${tagProps}
|
|
5815
|
+
}`;
|
|
5816
|
+
}
|
|
5817
|
+
}
|
|
5818
|
+
if (config?.conversation?.tags) {
|
|
5819
|
+
const tagKeys = Object.keys(config.conversation.tags);
|
|
5820
|
+
if (tagKeys.length > 0) {
|
|
5821
|
+
const tagProps = tagKeys.map((key) => {
|
|
5822
|
+
const tag = config.conversation.tags[key];
|
|
5823
|
+
const jsdoc = tag.description ? `/**
|
|
5824
|
+
* ${tag.title}
|
|
5825
|
+
*
|
|
5826
|
+
* ${tag.description}
|
|
5827
|
+
*/
|
|
5828
|
+
` : `/** ${tag.title} */
|
|
5829
|
+
`;
|
|
5830
|
+
return `${jsdoc}${key}?: string | undefined`;
|
|
5831
|
+
}).join(`
|
|
5832
|
+
`);
|
|
5833
|
+
conversationTagsType = `{
|
|
5834
|
+
${tagProps}
|
|
5835
|
+
}`;
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
if (config?.message?.tags) {
|
|
5839
|
+
const tagKeys = Object.keys(config.message.tags);
|
|
5840
|
+
if (tagKeys.length > 0) {
|
|
5841
|
+
const tagProps = tagKeys.map((key) => {
|
|
5842
|
+
const tag = config.message.tags[key];
|
|
5843
|
+
const jsdoc = tag.description ? `/**
|
|
5844
|
+
* ${tag.title}
|
|
5845
|
+
*
|
|
5846
|
+
* ${tag.description}
|
|
5847
|
+
*/
|
|
5848
|
+
` : `/** ${tag.title} */
|
|
5849
|
+
`;
|
|
5850
|
+
return `${jsdoc}${key}?: string | undefined`;
|
|
5851
|
+
}).join(`
|
|
5852
|
+
`);
|
|
5853
|
+
messageTagsType = `{
|
|
5854
|
+
${tagProps}
|
|
5855
|
+
}`;
|
|
5856
|
+
}
|
|
5857
|
+
}
|
|
5858
|
+
if (config?.workflow?.tags) {
|
|
5859
|
+
const tagKeys = Object.keys(config.workflow.tags);
|
|
5860
|
+
if (tagKeys.length > 0) {
|
|
5861
|
+
const tagProps = tagKeys.map((key) => {
|
|
5862
|
+
const tag = config.workflow.tags[key];
|
|
5863
|
+
const jsdoc = tag.description ? `/**
|
|
5864
|
+
* ${tag.title}
|
|
5865
|
+
*
|
|
5866
|
+
* ${tag.description}
|
|
5867
|
+
*/
|
|
5868
|
+
` : `/** ${tag.title} */
|
|
5869
|
+
`;
|
|
5870
|
+
return `${jsdoc}${key}?: string | undefined`;
|
|
5871
|
+
}).join(`
|
|
5872
|
+
`);
|
|
5873
|
+
workflowTagsType = `{
|
|
5874
|
+
${tagProps}
|
|
5875
|
+
}`;
|
|
5876
|
+
}
|
|
5877
|
+
}
|
|
5878
|
+
} catch (error) {
|
|
5879
|
+
console.warn("Failed to load agent config for tag types:", error);
|
|
5880
|
+
}
|
|
5881
|
+
const content = `
|
|
5882
|
+
////////////////////////////////////////////////////////
|
|
5883
|
+
// DO NOT EDIT THIS FILE DIRECTLY
|
|
5884
|
+
// This file is auto-generated from the Botpress ADK
|
|
5885
|
+
// ADK Version: ${ADK_VERSION}
|
|
5886
|
+
// Generated at: ${new Date().toISOString()}
|
|
5887
|
+
////////////////////////////////////////////////////////
|
|
5888
|
+
|
|
5889
|
+
declare module "@botpress/runtime/_types/tags" {
|
|
5890
|
+
/**
|
|
5891
|
+
* Bot-level tags defined in agent.config.ts
|
|
5892
|
+
*/
|
|
5893
|
+
export type BotTags = ${botTagsType};
|
|
5894
|
+
|
|
5895
|
+
/**
|
|
5896
|
+
* User-level tags defined in agent.config.ts
|
|
5897
|
+
*/
|
|
5898
|
+
export type UserTags = ${userTagsType};
|
|
5899
|
+
|
|
5900
|
+
/**
|
|
5901
|
+
* Conversation-level tags defined in agent.config.ts
|
|
5902
|
+
*/
|
|
5903
|
+
export type ConversationTags = ${conversationTagsType};
|
|
5904
|
+
|
|
5905
|
+
/**
|
|
5906
|
+
* Message-level tags defined in agent.config.ts
|
|
5907
|
+
*/
|
|
5908
|
+
export type MessageTags = ${messageTagsType};
|
|
5909
|
+
|
|
5910
|
+
/**
|
|
5911
|
+
* Workflow-level tags defined in agent.config.ts
|
|
5912
|
+
*/
|
|
5913
|
+
export type WorkflowTags = ${workflowTagsType};
|
|
5914
|
+
}
|
|
5915
|
+
`;
|
|
5916
|
+
const tagTypesPath = path22.join(project.path, ".adk", "tag-types.d.ts");
|
|
5917
|
+
await createFile(tagTypesPath, await formatCode(content));
|
|
5918
|
+
}
|
|
5919
|
+
|
|
5920
|
+
// src/generators/configuration-types.ts
|
|
5921
|
+
init_utils();
|
|
5922
|
+
init_fs();
|
|
5923
|
+
import path23 from "path";
|
|
5924
|
+
async function generateConfigurationTypes(project) {
|
|
5925
|
+
let configurationType = "{}";
|
|
5926
|
+
try {
|
|
5927
|
+
const configPath = path23.join(project.path, "agent.config.ts");
|
|
5928
|
+
const configModule = await import(`${configPath}?t=${Date.now()}`);
|
|
5929
|
+
const config = configModule.default;
|
|
5930
|
+
if (config?.configuration?.schema) {
|
|
5931
|
+
const configSchema = config.configuration.schema;
|
|
5932
|
+
if (configSchema.toTypescriptType) {
|
|
5933
|
+
configurationType = configSchema.toTypescriptType();
|
|
5934
|
+
}
|
|
5935
|
+
}
|
|
5936
|
+
} catch (error) {
|
|
5937
|
+
console.warn("Failed to load agent config for configuration types:", error);
|
|
5938
|
+
}
|
|
5939
|
+
const content = `
|
|
5940
|
+
////////////////////////////////////////////////////////
|
|
5941
|
+
// DO NOT EDIT THIS FILE DIRECTLY
|
|
5942
|
+
// This file is auto-generated from the Botpress ADK
|
|
5943
|
+
// ADK Version: ${ADK_VERSION}
|
|
5944
|
+
// Generated at: ${new Date().toISOString()}
|
|
5945
|
+
////////////////////////////////////////////////////////
|
|
5946
|
+
|
|
5947
|
+
declare module "@botpress/runtime/_types/configuration" {
|
|
5948
|
+
export type Configuration = ${configurationType};
|
|
5949
|
+
}
|
|
5950
|
+
`;
|
|
5951
|
+
const configTypesPath = path23.join(project.path, ".adk", "configuration-types.d.ts");
|
|
5952
|
+
await createFile(configTypesPath, await formatCode(content));
|
|
5953
|
+
}
|
|
5954
|
+
|
|
5727
5955
|
// src/generators/workflow-types.ts
|
|
5728
5956
|
init_utils();
|
|
5729
5957
|
init_fs();
|
|
5730
|
-
import * as
|
|
5958
|
+
import * as path24 from "path";
|
|
5731
5959
|
import { BuiltInWorkflows as BuiltInWorkflows2 } from "@botpress/runtime/internal";
|
|
5732
5960
|
function isBuiltinWorkflow(name) {
|
|
5733
5961
|
return !!Object.values(BuiltInWorkflows2).find((x) => x.name === name);
|
|
@@ -5739,7 +5967,7 @@ async function generateWorkflowTypes(project) {
|
|
|
5739
5967
|
if (isBuiltinWorkflow(workflowRef.definition.name)) {
|
|
5740
5968
|
continue;
|
|
5741
5969
|
}
|
|
5742
|
-
const workflowPath =
|
|
5970
|
+
const workflowPath = path24.join(project.path, workflowRef.path);
|
|
5743
5971
|
const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
|
|
5744
5972
|
const workflowInstance = workflowModule[workflowRef.export] || workflowModule.default;
|
|
5745
5973
|
if (!workflowInstance) {
|
|
@@ -5773,29 +6001,32 @@ async function generateWorkflowTypes(project) {
|
|
|
5773
6001
|
output: ${workflow.output};
|
|
5774
6002
|
state: ${workflow.state};
|
|
5775
6003
|
requests: ${workflow.requests};
|
|
6004
|
+
tags: WorkflowTags;
|
|
5776
6005
|
};`).join(`
|
|
5777
6006
|
`);
|
|
5778
6007
|
const content = `// Generated workflow type definitions
|
|
5779
6008
|
// Do not edit this file directly - it will be overwritten
|
|
5780
6009
|
|
|
6010
|
+
type WorkflowTags = import("@botpress/runtime/_types/tags").WorkflowTags;
|
|
6011
|
+
|
|
5781
6012
|
declare module "@botpress/runtime/_types/workflows" {
|
|
5782
6013
|
export type WorkflowDefinitions = {
|
|
5783
6014
|
${typeDefinitions || " // No workflows defined yet"}
|
|
5784
6015
|
};
|
|
5785
6016
|
}`;
|
|
5786
|
-
const workflowTypesPath =
|
|
6017
|
+
const workflowTypesPath = path24.join(project.path, ".adk", "workflow-types.d.ts");
|
|
5787
6018
|
await createFile(workflowTypesPath, await formatCode(content));
|
|
5788
6019
|
}
|
|
5789
6020
|
|
|
5790
6021
|
// src/generators/conversation-types.ts
|
|
5791
6022
|
init_utils();
|
|
5792
6023
|
init_fs();
|
|
5793
|
-
import
|
|
6024
|
+
import path25 from "path";
|
|
5794
6025
|
async function generateConversationTypes(project) {
|
|
5795
6026
|
const conversationTypes = {};
|
|
5796
6027
|
for (const conversationRef of project.conversations) {
|
|
5797
6028
|
try {
|
|
5798
|
-
const conversationPath =
|
|
6029
|
+
const conversationPath = path25.join(project.path, conversationRef.path);
|
|
5799
6030
|
const conversationModule = await import(`${conversationPath}?t=${Date.now()}`);
|
|
5800
6031
|
const conversationInstance = conversationModule[conversationRef.export] || conversationModule.default;
|
|
5801
6032
|
if (!conversationInstance) {
|
|
@@ -5827,8 +6058,8 @@ async function generateConversationTypes(project) {
|
|
|
5827
6058
|
channel: "${channel}";
|
|
5828
6059
|
integration: "${integration}";
|
|
5829
6060
|
state: ${info.state};
|
|
5830
|
-
tags: Integrations["${integration}"]["channels"]["${channelName}"]["conversation"]["tags"];
|
|
5831
|
-
messageTags: Integrations["${integration}"]["channels"]["${channelName}"]["message"]["tags"];
|
|
6061
|
+
tags: Integrations["${integration}"]["channels"]["${channelName}"]["conversation"]["tags"] & ConversationTags;
|
|
6062
|
+
messageTags: Integrations["${integration}"]["channels"]["${channelName}"]["message"]["tags"] & MessageTags;
|
|
5832
6063
|
messages: Integrations["${integration}"]["channels"]["${channelName}"]["messages"];
|
|
5833
6064
|
events: Integrations["${integration}"]["events"];
|
|
5834
6065
|
};`;
|
|
@@ -5843,6 +6074,8 @@ async function generateConversationTypes(project) {
|
|
|
5843
6074
|
////////////////////////////////////////////////////////
|
|
5844
6075
|
|
|
5845
6076
|
type Integrations = import("@botpress/runtime/_types/integrations").Integrations;
|
|
6077
|
+
type ConversationTags = import("@botpress/runtime/_types/tags").ConversationTags;
|
|
6078
|
+
type MessageTags = import("@botpress/runtime/_types/tags").MessageTags;
|
|
5846
6079
|
|
|
5847
6080
|
declare module "@botpress/runtime/_types/conversations" {
|
|
5848
6081
|
export type ConversationDefinitions = {
|
|
@@ -5850,14 +6083,14 @@ ${channelDefinitions || " // No conversations defined yet"}
|
|
|
5850
6083
|
};
|
|
5851
6084
|
}
|
|
5852
6085
|
`;
|
|
5853
|
-
const conversationTypesPath =
|
|
6086
|
+
const conversationTypesPath = path25.join(project.path, ".adk", "conversation-types.d.ts");
|
|
5854
6087
|
await createFile(conversationTypesPath, await formatCode(content));
|
|
5855
6088
|
}
|
|
5856
6089
|
|
|
5857
6090
|
// src/generators/event-types.ts
|
|
5858
6091
|
init_utils();
|
|
5859
6092
|
init_fs();
|
|
5860
|
-
import
|
|
6093
|
+
import path26 from "path";
|
|
5861
6094
|
async function generateEventTypes(project) {
|
|
5862
6095
|
const integrationEvents = [];
|
|
5863
6096
|
for (const int of project.integrations) {
|
|
@@ -5896,7 +6129,7 @@ ${integrationEvents.join(`
|
|
|
5896
6129
|
export type EventPayload<T extends EventName> = Events[T];
|
|
5897
6130
|
}
|
|
5898
6131
|
`;
|
|
5899
|
-
const eventTypesPath =
|
|
6132
|
+
const eventTypesPath = path26.join(project.path, ".adk", "event-types.d.ts");
|
|
5900
6133
|
await createFile(eventTypesPath, await formatCode(content));
|
|
5901
6134
|
}
|
|
5902
6135
|
|
|
@@ -5904,10 +6137,10 @@ ${integrationEvents.join(`
|
|
|
5904
6137
|
init_fs();
|
|
5905
6138
|
|
|
5906
6139
|
// src/bot-generator/dev-id-manager.ts
|
|
5907
|
-
import
|
|
6140
|
+
import path27 from "path";
|
|
5908
6141
|
import fs12 from "fs/promises";
|
|
5909
|
-
import { existsSync as
|
|
5910
|
-
import { Client as
|
|
6142
|
+
import { existsSync as existsSync3 } from "fs";
|
|
6143
|
+
import { Client as Client11 } from "@botpress/client";
|
|
5911
6144
|
class DevIdManager {
|
|
5912
6145
|
projectPath;
|
|
5913
6146
|
botProjectPath;
|
|
@@ -5916,7 +6149,7 @@ class DevIdManager {
|
|
|
5916
6149
|
constructor(projectPath, botProjectPath) {
|
|
5917
6150
|
this.projectPath = projectPath;
|
|
5918
6151
|
this.botProjectPath = botProjectPath;
|
|
5919
|
-
this.projectCachePath =
|
|
6152
|
+
this.projectCachePath = path27.join(botProjectPath, ".botpress", "project.cache.json");
|
|
5920
6153
|
}
|
|
5921
6154
|
async getClient() {
|
|
5922
6155
|
if (!this.client) {
|
|
@@ -5926,7 +6159,7 @@ class DevIdManager {
|
|
|
5926
6159
|
if (!workspaceId) {
|
|
5927
6160
|
throw new Error('No workspace ID found in agent.json or current profile. Please login again with "adk login"');
|
|
5928
6161
|
}
|
|
5929
|
-
this.client = new
|
|
6162
|
+
this.client = new Client11({
|
|
5930
6163
|
token: credentials.token,
|
|
5931
6164
|
apiUrl: credentials.apiUrl,
|
|
5932
6165
|
workspaceId,
|
|
@@ -5942,7 +6175,7 @@ class DevIdManager {
|
|
|
5942
6175
|
}
|
|
5943
6176
|
async readProjectCache() {
|
|
5944
6177
|
try {
|
|
5945
|
-
if (
|
|
6178
|
+
if (existsSync3(this.projectCachePath)) {
|
|
5946
6179
|
const content = await fs12.readFile(this.projectCachePath, "utf-8");
|
|
5947
6180
|
return JSON.parse(content);
|
|
5948
6181
|
}
|
|
@@ -5953,7 +6186,7 @@ class DevIdManager {
|
|
|
5953
6186
|
}
|
|
5954
6187
|
async saveProjectCache(cache2) {
|
|
5955
6188
|
try {
|
|
5956
|
-
await fs12.mkdir(
|
|
6189
|
+
await fs12.mkdir(path27.dirname(this.projectCachePath), { recursive: true });
|
|
5957
6190
|
await fs12.writeFile(this.projectCachePath, JSON.stringify(cache2, null, 2));
|
|
5958
6191
|
} catch (error) {
|
|
5959
6192
|
console.error("Error saving project.cache.json:", error);
|
|
@@ -6002,9 +6235,9 @@ class DevIdManager {
|
|
|
6002
6235
|
}
|
|
6003
6236
|
|
|
6004
6237
|
// src/bot-generator/integration-sync.ts
|
|
6005
|
-
import
|
|
6238
|
+
import path28 from "path";
|
|
6006
6239
|
import fs13 from "fs/promises";
|
|
6007
|
-
import { existsSync as
|
|
6240
|
+
import { existsSync as existsSync4 } from "fs";
|
|
6008
6241
|
class IntegrationSync {
|
|
6009
6242
|
projectPath;
|
|
6010
6243
|
botProjectPath;
|
|
@@ -6012,7 +6245,7 @@ class IntegrationSync {
|
|
|
6012
6245
|
constructor(projectPath, botProjectPath) {
|
|
6013
6246
|
this.projectPath = projectPath;
|
|
6014
6247
|
this.botProjectPath = botProjectPath;
|
|
6015
|
-
this.bpModulesPath =
|
|
6248
|
+
this.bpModulesPath = path28.join(botProjectPath, "bp_modules");
|
|
6016
6249
|
}
|
|
6017
6250
|
async parseIntegrations() {
|
|
6018
6251
|
const project = await AgentProject.load(this.projectPath);
|
|
@@ -6043,13 +6276,13 @@ class IntegrationSync {
|
|
|
6043
6276
|
return integrations;
|
|
6044
6277
|
}
|
|
6045
6278
|
async isIntegrationSynced(integration) {
|
|
6046
|
-
const targetFolder =
|
|
6047
|
-
if (!
|
|
6279
|
+
const targetFolder = path28.join(this.bpModulesPath, `integration_${integration.alias}`);
|
|
6280
|
+
if (!existsSync4(targetFolder)) {
|
|
6048
6281
|
return false;
|
|
6049
6282
|
}
|
|
6050
6283
|
try {
|
|
6051
|
-
const indexPath =
|
|
6052
|
-
if (!
|
|
6284
|
+
const indexPath = path28.join(targetFolder, "index.ts");
|
|
6285
|
+
if (!existsSync4(indexPath)) {
|
|
6053
6286
|
return false;
|
|
6054
6287
|
}
|
|
6055
6288
|
const indexContent = await fs13.readFile(indexPath, "utf-8");
|
|
@@ -6081,19 +6314,19 @@ class IntegrationSync {
|
|
|
6081
6314
|
}
|
|
6082
6315
|
async renameIntegrationFolder(integration) {
|
|
6083
6316
|
console.log(integration.name, integration.alias);
|
|
6084
|
-
const sourceFolder =
|
|
6085
|
-
const targetFolder =
|
|
6086
|
-
if (!
|
|
6317
|
+
const sourceFolder = path28.join(this.bpModulesPath, integration.name.replace("/", "-"));
|
|
6318
|
+
const targetFolder = path28.join(this.bpModulesPath, `integration_${integration.alias}`);
|
|
6319
|
+
if (!existsSync4(sourceFolder)) {
|
|
6087
6320
|
throw new Error(`Integration folder not found: ${sourceFolder}`);
|
|
6088
6321
|
}
|
|
6089
|
-
if (
|
|
6322
|
+
if (existsSync4(targetFolder)) {
|
|
6090
6323
|
await fs13.rm(targetFolder, { recursive: true, force: true });
|
|
6091
6324
|
}
|
|
6092
6325
|
await fs13.rename(sourceFolder, targetFolder);
|
|
6093
6326
|
}
|
|
6094
6327
|
async removeIntegrationFolder(alias) {
|
|
6095
|
-
const targetFolder =
|
|
6096
|
-
if (
|
|
6328
|
+
const targetFolder = path28.join(this.bpModulesPath, `integration_${alias}`);
|
|
6329
|
+
if (existsSync4(targetFolder)) {
|
|
6097
6330
|
await fs13.rm(targetFolder, { recursive: true, force: true });
|
|
6098
6331
|
}
|
|
6099
6332
|
}
|
|
@@ -6126,9 +6359,9 @@ class IntegrationSync {
|
|
|
6126
6359
|
}
|
|
6127
6360
|
|
|
6128
6361
|
// src/bot-generator/interface-sync.ts
|
|
6129
|
-
import
|
|
6362
|
+
import path29 from "path";
|
|
6130
6363
|
import fs14 from "fs/promises";
|
|
6131
|
-
import { existsSync as
|
|
6364
|
+
import { existsSync as existsSync5 } from "fs";
|
|
6132
6365
|
init_constants();
|
|
6133
6366
|
class InterfaceSync {
|
|
6134
6367
|
projectPath;
|
|
@@ -6137,7 +6370,7 @@ class InterfaceSync {
|
|
|
6137
6370
|
constructor(projectPath, botProjectPath) {
|
|
6138
6371
|
this.projectPath = projectPath;
|
|
6139
6372
|
this.botProjectPath = botProjectPath;
|
|
6140
|
-
this.bpModulesPath =
|
|
6373
|
+
this.bpModulesPath = path29.join(botProjectPath, "bp_modules");
|
|
6141
6374
|
}
|
|
6142
6375
|
async parseInterfaces() {
|
|
6143
6376
|
const interfaces = [];
|
|
@@ -6155,13 +6388,13 @@ class InterfaceSync {
|
|
|
6155
6388
|
return interfaces;
|
|
6156
6389
|
}
|
|
6157
6390
|
async isInterfaceSynced(interfaceInfo) {
|
|
6158
|
-
const targetFolder =
|
|
6159
|
-
if (!
|
|
6391
|
+
const targetFolder = path29.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
|
|
6392
|
+
if (!existsSync5(targetFolder)) {
|
|
6160
6393
|
return false;
|
|
6161
6394
|
}
|
|
6162
6395
|
try {
|
|
6163
|
-
const indexPath =
|
|
6164
|
-
if (!
|
|
6396
|
+
const indexPath = path29.join(targetFolder, "index.ts");
|
|
6397
|
+
if (!existsSync5(indexPath)) {
|
|
6165
6398
|
return false;
|
|
6166
6399
|
}
|
|
6167
6400
|
const indexContent = await fs14.readFile(indexPath, "utf-8");
|
|
@@ -6206,19 +6439,19 @@ class InterfaceSync {
|
|
|
6206
6439
|
});
|
|
6207
6440
|
}
|
|
6208
6441
|
async renameInterfaceFolder(interfaceInfo) {
|
|
6209
|
-
const sourceFolder =
|
|
6210
|
-
const targetFolder =
|
|
6211
|
-
if (!
|
|
6442
|
+
const sourceFolder = path29.join(this.bpModulesPath, interfaceInfo.name);
|
|
6443
|
+
const targetFolder = path29.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
|
|
6444
|
+
if (!existsSync5(sourceFolder)) {
|
|
6212
6445
|
throw new Error(`Interface folder not found: ${sourceFolder}`);
|
|
6213
6446
|
}
|
|
6214
|
-
if (
|
|
6447
|
+
if (existsSync5(targetFolder)) {
|
|
6215
6448
|
await fs14.rm(targetFolder, { recursive: true, force: true });
|
|
6216
6449
|
}
|
|
6217
6450
|
await fs14.rename(sourceFolder, targetFolder);
|
|
6218
6451
|
}
|
|
6219
6452
|
async removeInterfaceFolder(alias) {
|
|
6220
|
-
const targetFolder =
|
|
6221
|
-
if (
|
|
6453
|
+
const targetFolder = path29.join(this.bpModulesPath, `interface_${pascalCase(alias)}`);
|
|
6454
|
+
if (existsSync5(targetFolder)) {
|
|
6222
6455
|
await fs14.rm(targetFolder, { recursive: true, force: true });
|
|
6223
6456
|
}
|
|
6224
6457
|
}
|
|
@@ -6262,26 +6495,26 @@ function isBuiltinAction(name) {
|
|
|
6262
6495
|
return !!Object.values(BuiltInActions2).find((x) => x.name === name);
|
|
6263
6496
|
}
|
|
6264
6497
|
function getImportPath(from, to) {
|
|
6265
|
-
return
|
|
6498
|
+
return path32.relative(path32.dirname(from), to).replace(/\.ts$/, "").replace(/\\/g, "/");
|
|
6266
6499
|
}
|
|
6267
6500
|
|
|
6268
6501
|
class BotGenerator {
|
|
6269
6502
|
projectPath;
|
|
6270
6503
|
outputPath;
|
|
6271
6504
|
constructor(options) {
|
|
6272
|
-
this.projectPath =
|
|
6273
|
-
this.outputPath =
|
|
6505
|
+
this.projectPath = path32.resolve(options.projectPath);
|
|
6506
|
+
this.outputPath = path32.resolve(options.outputPath || path32.join(this.projectPath, ".adk"));
|
|
6274
6507
|
}
|
|
6275
6508
|
async listFilesRecursive(rootDir) {
|
|
6276
6509
|
try {
|
|
6277
|
-
if (!
|
|
6510
|
+
if (!existsSync6(rootDir))
|
|
6278
6511
|
return [];
|
|
6279
6512
|
const result = [];
|
|
6280
6513
|
const walk = async (dir, relativeBase) => {
|
|
6281
6514
|
const entries = await fs15.readdir(dir, { withFileTypes: true });
|
|
6282
6515
|
for (const entry of entries) {
|
|
6283
|
-
const abs =
|
|
6284
|
-
const rel =
|
|
6516
|
+
const abs = path32.join(dir, entry.name);
|
|
6517
|
+
const rel = path32.join(relativeBase, entry.name);
|
|
6285
6518
|
if (entry.isDirectory()) {
|
|
6286
6519
|
await walk(abs, rel);
|
|
6287
6520
|
} else {
|
|
@@ -6296,13 +6529,13 @@ class BotGenerator {
|
|
|
6296
6529
|
}
|
|
6297
6530
|
}
|
|
6298
6531
|
async removeEmptyDirectories(rootDir) {
|
|
6299
|
-
if (!
|
|
6532
|
+
if (!existsSync6(rootDir))
|
|
6300
6533
|
return;
|
|
6301
6534
|
const removeIfEmpty = async (dir) => {
|
|
6302
6535
|
const entries = await fs15.readdir(dir, { withFileTypes: true });
|
|
6303
6536
|
for (const entry of entries) {
|
|
6304
6537
|
if (entry.isDirectory()) {
|
|
6305
|
-
const subdir =
|
|
6538
|
+
const subdir = path32.join(dir, entry.name);
|
|
6306
6539
|
await removeIfEmpty(subdir);
|
|
6307
6540
|
}
|
|
6308
6541
|
}
|
|
@@ -6325,7 +6558,9 @@ class BotGenerator {
|
|
|
6325
6558
|
await this.generateInterfacesTypes();
|
|
6326
6559
|
await this.generateTableTypes();
|
|
6327
6560
|
await this.generateTriggerTypes();
|
|
6561
|
+
await this.generateTagTypes();
|
|
6328
6562
|
await this.generateStateTypes();
|
|
6563
|
+
await this.generateConfigurationTypes();
|
|
6329
6564
|
await this.generateWorkflowTypes();
|
|
6330
6565
|
await this.generateConversationTypes();
|
|
6331
6566
|
await this.generateActionTypes();
|
|
@@ -6340,22 +6575,22 @@ class BotGenerator {
|
|
|
6340
6575
|
}
|
|
6341
6576
|
async generateIntegrationsTypes() {
|
|
6342
6577
|
const project = await AgentProject.load(this.projectPath);
|
|
6343
|
-
const
|
|
6578
|
+
const manager3 = new IntegrationManager({
|
|
6344
6579
|
workspaceId: project.agentInfo?.workspaceId
|
|
6345
6580
|
});
|
|
6346
|
-
const integrations = await
|
|
6347
|
-
const integrationsDir =
|
|
6581
|
+
const integrations = await manager3.loadIntegrations(project.dependencies || {});
|
|
6582
|
+
const integrationsDir = path32.join(this.projectPath, ".adk", "integrations");
|
|
6348
6583
|
const existingIntegrationFiles = await this.listFilesRecursive(integrationsDir);
|
|
6349
6584
|
let aliases = new Set;
|
|
6350
6585
|
let files = new Set;
|
|
6351
6586
|
for (const integration of integrations.integrations) {
|
|
6352
6587
|
if (integration.enabled && integration.definition) {
|
|
6353
6588
|
const types6 = await generateIntegrationTypes(integration);
|
|
6354
|
-
const importPath = `./${
|
|
6589
|
+
const importPath = `./${path32.join("integrations", types6.names.paths.index).replace(/\\/g, "/")}`;
|
|
6355
6590
|
aliases.add(`"${integration.alias}": import("${importPath}").${types6.names.typings.index}`);
|
|
6356
6591
|
for (const [filePath, content] of Object.entries(types6.files)) {
|
|
6357
|
-
const fullPath =
|
|
6358
|
-
const dir =
|
|
6592
|
+
const fullPath = path32.join(this.projectPath, ".adk", "integrations", filePath);
|
|
6593
|
+
const dir = path32.dirname(fullPath);
|
|
6359
6594
|
await fs15.mkdir(dir, { recursive: true });
|
|
6360
6595
|
await createFile(fullPath, content);
|
|
6361
6596
|
files.add(filePath);
|
|
@@ -6376,11 +6611,11 @@ class BotGenerator {
|
|
|
6376
6611
|
};
|
|
6377
6612
|
}
|
|
6378
6613
|
`;
|
|
6379
|
-
await createFile(
|
|
6614
|
+
await createFile(path32.join(this.projectPath, ".adk", "integrations-types.d.ts"), await formatCode(types5));
|
|
6380
6615
|
const staleIntegrationFiles = existingIntegrationFiles.filter((f) => !files.has(f));
|
|
6381
6616
|
if (staleIntegrationFiles.length > 0) {
|
|
6382
6617
|
for (const rel of staleIntegrationFiles) {
|
|
6383
|
-
const abs =
|
|
6618
|
+
const abs = path32.join(integrationsDir, rel);
|
|
6384
6619
|
try {
|
|
6385
6620
|
await fs15.rm(abs, { force: true });
|
|
6386
6621
|
} catch {}
|
|
@@ -6396,10 +6631,18 @@ class BotGenerator {
|
|
|
6396
6631
|
const project = await AgentProject.load(this.projectPath);
|
|
6397
6632
|
await generateTriggerTypes(project);
|
|
6398
6633
|
}
|
|
6634
|
+
async generateTagTypes() {
|
|
6635
|
+
const project = await AgentProject.load(this.projectPath);
|
|
6636
|
+
await generateTagTypes(project);
|
|
6637
|
+
}
|
|
6399
6638
|
async generateStateTypes() {
|
|
6400
6639
|
const project = await AgentProject.load(this.projectPath);
|
|
6401
6640
|
await generateStateTypes(project);
|
|
6402
6641
|
}
|
|
6642
|
+
async generateConfigurationTypes() {
|
|
6643
|
+
const project = await AgentProject.load(this.projectPath);
|
|
6644
|
+
await generateConfigurationTypes(project);
|
|
6645
|
+
}
|
|
6403
6646
|
async generateEventTypes() {
|
|
6404
6647
|
const project = await AgentProject.load(this.projectPath);
|
|
6405
6648
|
await generateEventTypes(project);
|
|
@@ -6424,10 +6667,10 @@ class BotGenerator {
|
|
|
6424
6667
|
}
|
|
6425
6668
|
async generateRuntimeTypes() {
|
|
6426
6669
|
const project = await AgentProject.load(this.projectPath);
|
|
6427
|
-
const
|
|
6670
|
+
const manager3 = new IntegrationManager({
|
|
6428
6671
|
workspaceId: project.agentInfo?.workspaceId
|
|
6429
6672
|
});
|
|
6430
|
-
const integrations = await
|
|
6673
|
+
const integrations = await manager3.loadIntegrations(project.dependencies || {});
|
|
6431
6674
|
const channels = [];
|
|
6432
6675
|
for (const integration of integrations.integrations) {
|
|
6433
6676
|
if (integration.enabled && integration.definition) {
|
|
@@ -6441,7 +6684,7 @@ class BotGenerator {
|
|
|
6441
6684
|
let botStateType = "{}";
|
|
6442
6685
|
let userStateType = "{}";
|
|
6443
6686
|
try {
|
|
6444
|
-
const configPath =
|
|
6687
|
+
const configPath = path32.join(project.path, "agent.config.ts");
|
|
6445
6688
|
const configModule = await import(`${configPath}?t=${Date.now()}`);
|
|
6446
6689
|
const config = configModule.default;
|
|
6447
6690
|
if (config?.bot?.state) {
|
|
@@ -6477,28 +6720,28 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6477
6720
|
export type UserState = ${userStateType};
|
|
6478
6721
|
}
|
|
6479
6722
|
`;
|
|
6480
|
-
await createFile(
|
|
6723
|
+
await createFile(path32.join(this.projectPath, ".adk", "runtime.d.ts"), await formatCode(types5));
|
|
6481
6724
|
}
|
|
6482
6725
|
async generateInterfacesTypes() {
|
|
6483
6726
|
const project = await AgentProject.load(this.projectPath);
|
|
6484
6727
|
const integrationManager = new IntegrationManager({
|
|
6485
6728
|
workspaceId: project.agentInfo?.workspaceId
|
|
6486
6729
|
});
|
|
6487
|
-
const
|
|
6488
|
-
const interfacesDir =
|
|
6730
|
+
const manager3 = new InterfaceManager;
|
|
6731
|
+
const interfacesDir = path32.join(this.projectPath, ".adk", "interfaces");
|
|
6489
6732
|
const existingInterfaceFiles = await this.listFilesRecursive(interfacesDir);
|
|
6490
|
-
const interfaces = await
|
|
6733
|
+
const interfaces = await manager3.loadInterfaces(project.dependencies || {}).then((result) => result.interfaces.filter((int) => int.definition).map((x) => x.definition));
|
|
6491
6734
|
const integrations = await integrationManager.loadIntegrations(project.dependencies || {}).then((result) => result.integrations.filter((int) => int.enabled && int.definition).map((x) => x.definition));
|
|
6492
6735
|
let imports = new Set;
|
|
6493
6736
|
let aliases = new Set;
|
|
6494
6737
|
let files = new Set;
|
|
6495
6738
|
for (const int of interfaces) {
|
|
6496
6739
|
const types6 = await generateInterfaceTypes(int, integrations);
|
|
6497
|
-
imports.add(`import { ${types6.names.typings.index} } from "./${
|
|
6740
|
+
imports.add(`import { ${types6.names.typings.index} } from "./${path32.join("interfaces", types6.names.paths.index).replace(/\\/g, "/")}";`);
|
|
6498
6741
|
aliases.add(`"${types6.names.name}": ${types6.names.typings.index}`);
|
|
6499
6742
|
for (const [filePath, content] of Object.entries(types6.files)) {
|
|
6500
|
-
const fullPath =
|
|
6501
|
-
const dir =
|
|
6743
|
+
const fullPath = path32.join(this.projectPath, ".adk", "interfaces", filePath);
|
|
6744
|
+
const dir = path32.dirname(fullPath);
|
|
6502
6745
|
await fs15.mkdir(dir, { recursive: true });
|
|
6503
6746
|
await createFile(fullPath, content);
|
|
6504
6747
|
files.add(filePath);
|
|
@@ -6535,12 +6778,12 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6535
6778
|
`)}
|
|
6536
6779
|
};
|
|
6537
6780
|
`;
|
|
6538
|
-
await createFile(
|
|
6539
|
-
await createFile(
|
|
6781
|
+
await createFile(path32.join(this.projectPath, ".adk", "interfaces.d.ts"), await formatCode(types5));
|
|
6782
|
+
await createFile(path32.join(this.projectPath, ".adk", "interfaces.ts"), await formatCode(consts));
|
|
6540
6783
|
const staleInterfaceFiles = existingInterfaceFiles.filter((f) => !files.has(f));
|
|
6541
6784
|
if (staleInterfaceFiles.length > 0) {
|
|
6542
6785
|
for (const rel of staleInterfaceFiles) {
|
|
6543
|
-
const abs =
|
|
6786
|
+
const abs = path32.join(interfacesDir, rel);
|
|
6544
6787
|
try {
|
|
6545
6788
|
await fs15.rm(abs, { force: true });
|
|
6546
6789
|
} catch {}
|
|
@@ -6573,7 +6816,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6573
6816
|
`) : ""}
|
|
6574
6817
|
} as Record<string, IntegrationPackage>;
|
|
6575
6818
|
`;
|
|
6576
|
-
await createFile(
|
|
6819
|
+
await createFile(path32.join(this.outputPath, "src", "integrations.ts"), content);
|
|
6577
6820
|
}
|
|
6578
6821
|
async generateInterfacesDefinition() {
|
|
6579
6822
|
const interfaces = BUILTIN_INTERFACES;
|
|
@@ -6596,7 +6839,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6596
6839
|
`) : ""}
|
|
6597
6840
|
} as Record<string, InterfacePackage>;
|
|
6598
6841
|
`;
|
|
6599
|
-
await createFile(
|
|
6842
|
+
await createFile(path32.join(this.outputPath, "src", "interfaces.ts"), await formatCode(content));
|
|
6600
6843
|
}
|
|
6601
6844
|
async generateBotDefinition() {
|
|
6602
6845
|
const project = await AgentProject.load(this.projectPath);
|
|
@@ -6611,8 +6854,22 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6611
6854
|
const configData = config && Object.keys(config).length > 0 ? `, configuration: ${JSON.stringify(config)}` : "";
|
|
6612
6855
|
addIntegrations.push(`bot.addIntegration(${importName}, { alias: "${alias}", enabled: true${configType}${configData} });`);
|
|
6613
6856
|
}
|
|
6857
|
+
const userTags = {};
|
|
6614
6858
|
const conversationTags = {};
|
|
6859
|
+
const messageTags = {};
|
|
6615
6860
|
const workflowTags = {};
|
|
6861
|
+
if (project.config?.user?.tags) {
|
|
6862
|
+
Object.assign(userTags, project.config.user.tags);
|
|
6863
|
+
}
|
|
6864
|
+
if (project.config?.conversation?.tags) {
|
|
6865
|
+
Object.assign(conversationTags, project.config.conversation.tags);
|
|
6866
|
+
}
|
|
6867
|
+
if (project.config?.message?.tags) {
|
|
6868
|
+
Object.assign(messageTags, project.config.message.tags);
|
|
6869
|
+
}
|
|
6870
|
+
if (project.config?.workflow?.tags) {
|
|
6871
|
+
Object.assign(workflowTags, project.config.workflow.tags);
|
|
6872
|
+
}
|
|
6616
6873
|
const crypto4 = __require("crypto");
|
|
6617
6874
|
const hashString = (str) => {
|
|
6618
6875
|
return crypto4.createHash("md5").update(str).digest("hex").substring(0, 5).toUpperCase();
|
|
@@ -6633,7 +6890,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6633
6890
|
if (isBuiltinWorkflow2(workflow.definition.name)) {
|
|
6634
6891
|
continue;
|
|
6635
6892
|
}
|
|
6636
|
-
const workflowPath =
|
|
6893
|
+
const workflowPath = path32.join(project.path, workflow.path);
|
|
6637
6894
|
const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
|
|
6638
6895
|
const workflowInstance = workflowModule.default || workflowModule[workflow.export];
|
|
6639
6896
|
if (workflowInstance) {
|
|
@@ -6690,6 +6947,8 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6690
6947
|
};
|
|
6691
6948
|
}
|
|
6692
6949
|
const toEventName = (ename) => ename.replaceAll(/[^a-zA-Z0-9]/g, "").toLowerCase();
|
|
6950
|
+
const configSchema = project.config?.configuration?.schema;
|
|
6951
|
+
const configSchemaCode = configSchema ? transforms3.fromJSONSchema(configSchema.toJSONSchema()).toTypescriptSchema() : undefined;
|
|
6693
6952
|
const content = dedent`
|
|
6694
6953
|
import { BotDefinition, z } from "@botpress/sdk";
|
|
6695
6954
|
import {
|
|
@@ -6712,20 +6971,40 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6712
6971
|
runtime: "adk",
|
|
6713
6972
|
runtimeVersion: "${ADK_VERSION}",
|
|
6714
6973
|
},
|
|
6715
|
-
|
|
6974
|
+
${configSchemaCode ? `
|
|
6975
|
+
configuration: {
|
|
6976
|
+
schema: ${configSchemaCode}
|
|
6977
|
+
},
|
|
6978
|
+
` : ""}
|
|
6979
|
+
${Object.keys(userTags).length > 0 ? `user: {
|
|
6980
|
+
tags: {
|
|
6981
|
+
${Object.entries(userTags).map(([tag, meta]) => `// ${meta.title}
|
|
6982
|
+
${meta.description ? `// ${meta.description}
|
|
6983
|
+
` : ""}"${tag}": ${JSON.stringify(meta)}`).join(`,
|
|
6984
|
+
`)}
|
|
6985
|
+
},
|
|
6986
|
+
},` : ""}
|
|
6987
|
+
${Object.keys(messageTags).length > 0 ? `message: {
|
|
6988
|
+
tags: {
|
|
6989
|
+
${Object.entries(messageTags).map(([tag, meta]) => `// ${meta.title}
|
|
6990
|
+
${meta.description ? `// ${meta.description}
|
|
6991
|
+
` : ""}"${tag}": ${JSON.stringify(meta)}`).join(`,
|
|
6992
|
+
`)}
|
|
6993
|
+
},
|
|
6994
|
+
},` : ""}
|
|
6716
6995
|
conversation: {
|
|
6717
6996
|
tags: {
|
|
6718
6997
|
${Object.entries(conversationTags).map(([tag, meta]) => `// ${meta.title}
|
|
6719
|
-
|
|
6720
|
-
"${tag}": ${JSON.stringify(meta)}`).join(`,
|
|
6721
|
-
`)}
|
|
6998
|
+
${meta.description ? `// ${meta.description}
|
|
6999
|
+
` : ""}"${tag}": ${JSON.stringify(meta)}`).join(`,
|
|
7000
|
+
`)}${Object.keys(conversationTags).length > 0 ? "," : ""}
|
|
6722
7001
|
},
|
|
6723
7002
|
},
|
|
6724
7003
|
${Object.keys(workflowTags).length > 0 ? `workflow: {
|
|
6725
7004
|
tags: {
|
|
6726
7005
|
${Object.entries(workflowTags).map(([tag, meta]) => `// ${meta.title}
|
|
6727
|
-
|
|
6728
|
-
"${tag}": ${JSON.stringify(meta)}`).join(`,
|
|
7006
|
+
${meta.description ? `// ${meta.description}
|
|
7007
|
+
` : ""}"${tag}": ${JSON.stringify(meta)}`).join(`,
|
|
6729
7008
|
`)}
|
|
6730
7009
|
},
|
|
6731
7010
|
},` : ""}
|
|
@@ -6839,7 +7118,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6839
7118
|
|
|
6840
7119
|
export default bot;
|
|
6841
7120
|
`;
|
|
6842
|
-
await createFile(
|
|
7121
|
+
await createFile(path32.join(this.outputPath, "bot.definition.ts"), await formatCode(content));
|
|
6843
7122
|
}
|
|
6844
7123
|
async generateBotIndex() {
|
|
6845
7124
|
const content = dedent`
|
|
@@ -6873,7 +7152,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6873
7152
|
|
|
6874
7153
|
export default bot
|
|
6875
7154
|
`;
|
|
6876
|
-
await createFile(
|
|
7155
|
+
await createFile(path32.join(this.outputPath, "src", "index.ts"), await formatCode(content));
|
|
6877
7156
|
}
|
|
6878
7157
|
async generatePackageJson(project) {
|
|
6879
7158
|
const packageJson = {
|
|
@@ -6892,7 +7171,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6892
7171
|
typescript: "^5.9.3"
|
|
6893
7172
|
}
|
|
6894
7173
|
};
|
|
6895
|
-
await createFile(
|
|
7174
|
+
await createFile(path32.join(this.outputPath, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
6896
7175
|
}
|
|
6897
7176
|
async generateTsConfig() {
|
|
6898
7177
|
const tsConfig = {
|
|
@@ -6923,7 +7202,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6923
7202
|
},
|
|
6924
7203
|
include: [".botpress/**/*", "src/**/*", "bp_modules/**/*", "./*.ts", "./*.json", "../*.d.ts"]
|
|
6925
7204
|
};
|
|
6926
|
-
await createFile(
|
|
7205
|
+
await createFile(path32.join(this.outputPath, "tsconfig.json"), JSON.stringify(tsConfig, null, 2));
|
|
6927
7206
|
}
|
|
6928
7207
|
async generateGlobalTypes() {
|
|
6929
7208
|
const content = dedent`
|
|
@@ -6946,12 +7225,12 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6946
7225
|
|
|
6947
7226
|
export {};
|
|
6948
7227
|
`;
|
|
6949
|
-
await createFile(
|
|
7228
|
+
await createFile(path32.join(this.outputPath, "global.d.ts"), await formatCode(content));
|
|
6950
7229
|
}
|
|
6951
7230
|
async copyAssets() {
|
|
6952
|
-
const assetsPath =
|
|
6953
|
-
const targetPath =
|
|
6954
|
-
if (
|
|
7231
|
+
const assetsPath = path32.join(this.projectPath, "assets");
|
|
7232
|
+
const targetPath = path32.join(this.outputPath, "assets");
|
|
7233
|
+
if (existsSync6(assetsPath)) {
|
|
6955
7234
|
await fs15.mkdir(targetPath, { recursive: true });
|
|
6956
7235
|
await this.copyDirectory(assetsPath, targetPath);
|
|
6957
7236
|
}
|
|
@@ -6959,8 +7238,8 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6959
7238
|
async copyDirectory(src, dest) {
|
|
6960
7239
|
const entries = await fs15.readdir(src, { withFileTypes: true });
|
|
6961
7240
|
for (const entry of entries) {
|
|
6962
|
-
const srcPath =
|
|
6963
|
-
const destPath =
|
|
7241
|
+
const srcPath = path32.join(src, entry.name);
|
|
7242
|
+
const destPath = path32.join(dest, entry.name);
|
|
6964
7243
|
if (entry.isDirectory()) {
|
|
6965
7244
|
await fs15.mkdir(destPath, { recursive: true });
|
|
6966
7245
|
await this.copyDirectory(srcPath, destPath);
|
|
@@ -6972,16 +7251,16 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
6972
7251
|
async generateAdkRuntime() {
|
|
6973
7252
|
const project = new AgentProject(this.projectPath);
|
|
6974
7253
|
await project.reload();
|
|
6975
|
-
const srcDir =
|
|
7254
|
+
const srcDir = path32.join(this.outputPath, "src");
|
|
6976
7255
|
{
|
|
6977
|
-
const dest =
|
|
7256
|
+
const dest = path32.join(srcDir, "conversations.ts");
|
|
6978
7257
|
const imports = new Map;
|
|
6979
7258
|
const exports = new Set;
|
|
6980
7259
|
let index = 1;
|
|
6981
7260
|
for (const conversation of project.conversations) {
|
|
6982
7261
|
if (!imports.has(conversation.path)) {
|
|
6983
7262
|
const name = `conversations_${index++}`;
|
|
6984
|
-
const importPath = getImportPath(dest,
|
|
7263
|
+
const importPath = getImportPath(dest, path32.join(project.path, conversation.path));
|
|
6985
7264
|
imports.set(conversation.path, {
|
|
6986
7265
|
name,
|
|
6987
7266
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -7007,14 +7286,14 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
7007
7286
|
await createFile(dest, await formatCode(content2));
|
|
7008
7287
|
}
|
|
7009
7288
|
{
|
|
7010
|
-
const dest =
|
|
7289
|
+
const dest = path32.join(srcDir, "knowledge.ts");
|
|
7011
7290
|
const imports = new Map;
|
|
7012
7291
|
const exports = new Set;
|
|
7013
7292
|
let index = 1;
|
|
7014
7293
|
for (const knowledge of project.knowledge) {
|
|
7015
7294
|
if (!imports.has(knowledge.path)) {
|
|
7016
7295
|
const name = `knowledge_${index++}`;
|
|
7017
|
-
const importPath = getImportPath(dest,
|
|
7296
|
+
const importPath = getImportPath(dest, path32.join(project.path, knowledge.path));
|
|
7018
7297
|
imports.set(knowledge.path, {
|
|
7019
7298
|
name,
|
|
7020
7299
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -7040,7 +7319,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
7040
7319
|
await createFile(dest, await formatCode(content2));
|
|
7041
7320
|
}
|
|
7042
7321
|
{
|
|
7043
|
-
const dest =
|
|
7322
|
+
const dest = path32.join(srcDir, "triggers.ts");
|
|
7044
7323
|
const { transforms: transforms4 } = await import("@botpress/sdk");
|
|
7045
7324
|
const imports = new Map;
|
|
7046
7325
|
const exports = new Set;
|
|
@@ -7049,7 +7328,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
7049
7328
|
for (const trigger of project.triggers) {
|
|
7050
7329
|
if (!imports.has(trigger.path)) {
|
|
7051
7330
|
const name = `triggers_${index++}`;
|
|
7052
|
-
const importPath = getImportPath(dest,
|
|
7331
|
+
const importPath = getImportPath(dest, path32.join(project.path, trigger.path));
|
|
7053
7332
|
imports.set(trigger.path, {
|
|
7054
7333
|
name,
|
|
7055
7334
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -7059,7 +7338,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
7059
7338
|
}
|
|
7060
7339
|
for (const trigger of project.triggers) {
|
|
7061
7340
|
try {
|
|
7062
|
-
const absolutePath =
|
|
7341
|
+
const absolutePath = path32.join(project.path, trigger.path);
|
|
7063
7342
|
const triggerModule = await import(`${absolutePath}?t=${Date.now()}`);
|
|
7064
7343
|
const triggerInstance = triggerModule[trigger.export] || triggerModule.default;
|
|
7065
7344
|
if (triggerInstance && triggerInstance.payload) {
|
|
@@ -7102,7 +7381,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
7102
7381
|
await createFile(dest, await formatCode(content2));
|
|
7103
7382
|
}
|
|
7104
7383
|
{
|
|
7105
|
-
const dest =
|
|
7384
|
+
const dest = path32.join(srcDir, "workflows.ts");
|
|
7106
7385
|
const imports = new Map;
|
|
7107
7386
|
const exports = new Set;
|
|
7108
7387
|
let index = 1;
|
|
@@ -7112,7 +7391,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
7112
7391
|
}
|
|
7113
7392
|
if (!imports.has(workflow.path)) {
|
|
7114
7393
|
const name = `workflows_${index++}`;
|
|
7115
|
-
const importPath = getImportPath(dest,
|
|
7394
|
+
const importPath = getImportPath(dest, path32.join(project.path, workflow.path));
|
|
7116
7395
|
const statement = `import * as ${name} from "${importPath}";`;
|
|
7117
7396
|
imports.set(workflow.path, {
|
|
7118
7397
|
name,
|
|
@@ -7146,7 +7425,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
7146
7425
|
await createFile(dest, await formatCode(content2));
|
|
7147
7426
|
}
|
|
7148
7427
|
{
|
|
7149
|
-
const dest =
|
|
7428
|
+
const dest = path32.join(srcDir, "actions.ts");
|
|
7150
7429
|
const imports = new Map;
|
|
7151
7430
|
const exports = new Set;
|
|
7152
7431
|
let index = 1;
|
|
@@ -7156,7 +7435,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
7156
7435
|
}
|
|
7157
7436
|
if (!imports.has(action.path)) {
|
|
7158
7437
|
const name = `actions_${index++}`;
|
|
7159
|
-
const importPath = getImportPath(dest,
|
|
7438
|
+
const importPath = getImportPath(dest, path32.join(project.path, action.path));
|
|
7160
7439
|
imports.set(action.path, {
|
|
7161
7440
|
name,
|
|
7162
7441
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -7182,14 +7461,14 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
7182
7461
|
await createFile(dest, await formatCode(content2));
|
|
7183
7462
|
}
|
|
7184
7463
|
{
|
|
7185
|
-
const dest =
|
|
7464
|
+
const dest = path32.join(srcDir, "tables.ts");
|
|
7186
7465
|
const imports = new Map;
|
|
7187
7466
|
const exports = new Set;
|
|
7188
7467
|
let index = 1;
|
|
7189
7468
|
for (const table of project.tables) {
|
|
7190
7469
|
if (!imports.has(table.path)) {
|
|
7191
7470
|
const name = `tables_${index++}`;
|
|
7192
|
-
const importPath = getImportPath(dest,
|
|
7471
|
+
const importPath = getImportPath(dest, path32.join(project.path, table.path));
|
|
7193
7472
|
imports.set(table.path, {
|
|
7194
7473
|
name,
|
|
7195
7474
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -7215,8 +7494,8 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
7215
7494
|
await createFile(dest, await formatCode(content2));
|
|
7216
7495
|
}
|
|
7217
7496
|
{
|
|
7218
|
-
const dest =
|
|
7219
|
-
const importPath = getImportPath(dest,
|
|
7497
|
+
const dest = path32.join(srcDir, "config.ts");
|
|
7498
|
+
const importPath = getImportPath(dest, path32.join(project.path, "agent.config.ts"));
|
|
7220
7499
|
const content2 = `
|
|
7221
7500
|
////////////////////////////////////////////////////////
|
|
7222
7501
|
// DO NOT EDIT THIS FILE DIRECTLY
|
|
@@ -7282,13 +7561,13 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
7282
7561
|
handlers.actions.setup(bot);
|
|
7283
7562
|
}
|
|
7284
7563
|
`;
|
|
7285
|
-
await createFile(
|
|
7564
|
+
await createFile(path32.join(this.outputPath, "src", "adk-runtime.ts"), await formatCode(content));
|
|
7286
7565
|
}
|
|
7287
7566
|
async copyAssetsRuntime() {
|
|
7288
|
-
const assetsRuntimePath =
|
|
7289
|
-
if (
|
|
7567
|
+
const assetsRuntimePath = path32.join(this.projectPath, ".adk", "assets-runtime.ts");
|
|
7568
|
+
if (existsSync6(assetsRuntimePath)) {
|
|
7290
7569
|
const content = await fs15.readFile(assetsRuntimePath, "utf-8");
|
|
7291
|
-
await createFile(
|
|
7570
|
+
await createFile(path32.join(this.outputPath, "src", "assets-runtime.ts"), await formatCode(content));
|
|
7292
7571
|
}
|
|
7293
7572
|
}
|
|
7294
7573
|
}
|
|
@@ -7297,9 +7576,9 @@ async function generateBotProject(options) {
|
|
|
7297
7576
|
await generator.generate();
|
|
7298
7577
|
await generator.generateAdkRuntime();
|
|
7299
7578
|
await generator.copyAssetsRuntime();
|
|
7300
|
-
const devIdManager = new DevIdManager(options.projectPath, options.outputPath ||
|
|
7579
|
+
const devIdManager = new DevIdManager(options.projectPath, options.outputPath || path32.join(options.projectPath, ".adk", "bot"));
|
|
7301
7580
|
await devIdManager.restoreDevId();
|
|
7302
|
-
const integrationSync = new IntegrationSync(options.projectPath, options.outputPath ||
|
|
7581
|
+
const integrationSync = new IntegrationSync(options.projectPath, options.outputPath || path32.join(options.projectPath, ".adk", "bot"));
|
|
7303
7582
|
const integrationSyncResult = await integrationSync.syncIntegrations();
|
|
7304
7583
|
if (integrationSyncResult.errors.length > 0) {
|
|
7305
7584
|
console.warn(`⚠️ Some integrations failed to sync:`);
|
|
@@ -7307,7 +7586,7 @@ async function generateBotProject(options) {
|
|
|
7307
7586
|
console.warn(` - ${alias}: ${error}`);
|
|
7308
7587
|
});
|
|
7309
7588
|
}
|
|
7310
|
-
const interfaceSync = new InterfaceSync(options.projectPath, options.outputPath ||
|
|
7589
|
+
const interfaceSync = new InterfaceSync(options.projectPath, options.outputPath || path32.join(options.projectPath, ".adk", "bot"));
|
|
7311
7590
|
const interfaceSyncResult = await interfaceSync.syncInterfaces();
|
|
7312
7591
|
if (interfaceSyncResult.errors.length > 0) {
|
|
7313
7592
|
console.warn(`⚠️ Some interfaces failed to sync:`);
|
|
@@ -7317,7 +7596,7 @@ async function generateBotProject(options) {
|
|
|
7317
7596
|
}
|
|
7318
7597
|
}
|
|
7319
7598
|
// src/tables/table-manager.ts
|
|
7320
|
-
import { Client as
|
|
7599
|
+
import { Client as Client12 } from "@botpress/client";
|
|
7321
7600
|
import { transforms as transforms4 } from "@botpress/sdk";
|
|
7322
7601
|
class TableManager {
|
|
7323
7602
|
client;
|
|
@@ -7331,7 +7610,7 @@ class TableManager {
|
|
|
7331
7610
|
if (!this.client) {
|
|
7332
7611
|
const credentials = await auth.getActiveCredentials();
|
|
7333
7612
|
this.assertBotId("initialize client");
|
|
7334
|
-
this.client = new
|
|
7613
|
+
this.client = new Client12({
|
|
7335
7614
|
token: credentials.token,
|
|
7336
7615
|
apiUrl: credentials.apiUrl,
|
|
7337
7616
|
botId: this.botId,
|
|
@@ -7795,10 +8074,10 @@ class TableManager {
|
|
|
7795
8074
|
}
|
|
7796
8075
|
// src/knowledge/manager.ts
|
|
7797
8076
|
import crypto4 from "crypto";
|
|
7798
|
-
import
|
|
8077
|
+
import path33 from "path";
|
|
7799
8078
|
import fs16 from "fs/promises";
|
|
7800
8079
|
import { glob } from "glob";
|
|
7801
|
-
import { Client as
|
|
8080
|
+
import { Client as Client13 } from "@botpress/client";
|
|
7802
8081
|
import { DataSource } from "@botpress/runtime";
|
|
7803
8082
|
|
|
7804
8083
|
// src/knowledge/types.ts
|
|
@@ -7842,7 +8121,7 @@ class KnowledgeManager {
|
|
|
7842
8121
|
if (!this.client) {
|
|
7843
8122
|
const credentials = await auth.getActiveCredentials();
|
|
7844
8123
|
this.assertBotId("initialize client");
|
|
7845
|
-
this.client = new
|
|
8124
|
+
this.client = new Client13({
|
|
7846
8125
|
token: credentials.token,
|
|
7847
8126
|
apiUrl: credentials.apiUrl,
|
|
7848
8127
|
botId: this.botId,
|
|
@@ -8185,14 +8464,14 @@ class KnowledgeManager {
|
|
|
8185
8464
|
}
|
|
8186
8465
|
async scanLocalFileHashes(directoryPath, filterFn) {
|
|
8187
8466
|
const projectDir = this.project.path;
|
|
8188
|
-
const directory =
|
|
8467
|
+
const directory = path33.resolve(projectDir, directoryPath);
|
|
8189
8468
|
if (this.fileHashCache.has(directory)) {
|
|
8190
8469
|
return this.fileHashCache.get(directory);
|
|
8191
8470
|
}
|
|
8192
8471
|
const files = glob.sync(directory + "/**/*.*", { absolute: true, nodir: true }).filter((file) => !filterFn || filterFn(file));
|
|
8193
8472
|
const hashes = {};
|
|
8194
8473
|
for (const file of files) {
|
|
8195
|
-
const relPath =
|
|
8474
|
+
const relPath = path33.relative(directory, file);
|
|
8196
8475
|
const content = await fs16.readFile(file);
|
|
8197
8476
|
hashes[relPath] = crypto4.createHash("sha256").update(content).digest("hex");
|
|
8198
8477
|
}
|
|
@@ -8297,7 +8576,7 @@ class KnowledgeManager {
|
|
|
8297
8576
|
}
|
|
8298
8577
|
async syncDirectorySource(client, kbName, sourceId, directoryPath, filterFn, force) {
|
|
8299
8578
|
const projectDir = this.project.path;
|
|
8300
|
-
const directory =
|
|
8579
|
+
const directory = path33.resolve(projectDir, directoryPath);
|
|
8301
8580
|
if (!directory.startsWith(projectDir)) {
|
|
8302
8581
|
throw new Error("Directory path must be within the agent's directory");
|
|
8303
8582
|
}
|
|
@@ -8318,8 +8597,8 @@ class KnowledgeManager {
|
|
|
8318
8597
|
return true;
|
|
8319
8598
|
}).map((f) => ({
|
|
8320
8599
|
abs: f,
|
|
8321
|
-
rel:
|
|
8322
|
-
name:
|
|
8600
|
+
rel: path33.relative(directory, f),
|
|
8601
|
+
name: path33.basename(f)
|
|
8323
8602
|
}));
|
|
8324
8603
|
console.log(` Found ${allFiles.length} files in ${directoryPath}`);
|
|
8325
8604
|
const cachedHashes = await this.scanLocalFileHashes(directoryPath, filterFn);
|
|
@@ -8391,7 +8670,7 @@ class KnowledgeManager {
|
|
|
8391
8670
|
return null;
|
|
8392
8671
|
}
|
|
8393
8672
|
} catch {}
|
|
8394
|
-
const title =
|
|
8673
|
+
const title = path33.basename(local.name, path33.extname(local.name));
|
|
8395
8674
|
const metadata = {
|
|
8396
8675
|
hash,
|
|
8397
8676
|
sourceId,
|
|
@@ -8519,7 +8798,7 @@ class KBSyncFormatter {
|
|
|
8519
8798
|
import { watch as watch2, readdirSync as readdirSync2 } from "fs";
|
|
8520
8799
|
import { EventEmitter as EventEmitter3 } from "events";
|
|
8521
8800
|
import { join as join8, relative as relative3 } from "path";
|
|
8522
|
-
import { existsSync as
|
|
8801
|
+
import { existsSync as existsSync7 } from "fs";
|
|
8523
8802
|
|
|
8524
8803
|
class FileWatcher2 extends EventEmitter3 {
|
|
8525
8804
|
projectPath;
|
|
@@ -8537,12 +8816,12 @@ class FileWatcher2 extends EventEmitter3 {
|
|
|
8537
8816
|
const rootFiles = ["package.json", "agent.json", "agent.config.ts"];
|
|
8538
8817
|
for (const file of rootFiles) {
|
|
8539
8818
|
const filePath = join8(this.projectPath, file);
|
|
8540
|
-
if (
|
|
8819
|
+
if (existsSync7(filePath)) {
|
|
8541
8820
|
this.watchFile(filePath);
|
|
8542
8821
|
}
|
|
8543
8822
|
}
|
|
8544
8823
|
const srcPath = join8(this.projectPath, "src");
|
|
8545
|
-
if (
|
|
8824
|
+
if (existsSync7(srcPath)) {
|
|
8546
8825
|
this.initializeDirectoryState(srcPath);
|
|
8547
8826
|
this.watchDirectory(srcPath);
|
|
8548
8827
|
}
|
|
@@ -8591,7 +8870,7 @@ class FileWatcher2 extends EventEmitter3 {
|
|
|
8591
8870
|
}
|
|
8592
8871
|
}
|
|
8593
8872
|
handleFileChange(filePath) {
|
|
8594
|
-
const fileExists =
|
|
8873
|
+
const fileExists = existsSync7(filePath);
|
|
8595
8874
|
const previousState = this.fileStates.get(filePath);
|
|
8596
8875
|
let changeType;
|
|
8597
8876
|
if (!fileExists && previousState !== undefined) {
|
|
@@ -8631,7 +8910,7 @@ class FileWatcher2 extends EventEmitter3 {
|
|
|
8631
8910
|
this.emit("change", event);
|
|
8632
8911
|
}
|
|
8633
8912
|
updateFileState(filePath) {
|
|
8634
|
-
if (
|
|
8913
|
+
if (existsSync7(filePath)) {
|
|
8635
8914
|
this.fileStates.set(filePath, Date.now());
|
|
8636
8915
|
}
|
|
8637
8916
|
}
|
|
@@ -8655,8 +8934,8 @@ class FileWatcher2 extends EventEmitter3 {
|
|
|
8655
8934
|
}
|
|
8656
8935
|
}
|
|
8657
8936
|
// src/preflight/checker.ts
|
|
8658
|
-
import { Client as
|
|
8659
|
-
import
|
|
8937
|
+
import { Client as Client14 } from "@botpress/client";
|
|
8938
|
+
import path34 from "path";
|
|
8660
8939
|
|
|
8661
8940
|
// src/preflight/types.ts
|
|
8662
8941
|
function hasIntegrationChanges(integrations) {
|
|
@@ -8870,7 +9149,7 @@ class PreflightChecker {
|
|
|
8870
9149
|
if (!workspaceId) {
|
|
8871
9150
|
throw new Error('No workspace ID found. Please login with "adk login"');
|
|
8872
9151
|
}
|
|
8873
|
-
this.client = new
|
|
9152
|
+
this.client = new Client14({
|
|
8874
9153
|
token: credentials.token,
|
|
8875
9154
|
apiUrl: credentials.apiUrl,
|
|
8876
9155
|
workspaceId,
|
|
@@ -9018,7 +9297,7 @@ class PreflightChecker {
|
|
|
9018
9297
|
options?.onProgress?.("Regenerating bot project...");
|
|
9019
9298
|
await generateBotProject({
|
|
9020
9299
|
projectPath: this.projectPath,
|
|
9021
|
-
outputPath:
|
|
9300
|
+
outputPath: path34.join(this.projectPath, ".adk", "bot")
|
|
9022
9301
|
});
|
|
9023
9302
|
options?.onSuccess?.("Bot project regenerated");
|
|
9024
9303
|
}
|
|
@@ -9062,6 +9341,8 @@ export {
|
|
|
9062
9341
|
FileWatcher2 as FileWatcher,
|
|
9063
9342
|
EnhancedInterfaceCache,
|
|
9064
9343
|
DevIdManager,
|
|
9344
|
+
CredentialsManager,
|
|
9345
|
+
ConfigManager,
|
|
9065
9346
|
BpDevCommand,
|
|
9066
9347
|
BpDeployCommand,
|
|
9067
9348
|
BpChatCommand,
|
|
@@ -9069,10 +9350,13 @@ export {
|
|
|
9069
9350
|
BpAddCommand,
|
|
9070
9351
|
BotGenerator,
|
|
9071
9352
|
BaseCommand,
|
|
9353
|
+
BP_CLI_VERSION,
|
|
9354
|
+
BP_CLI_INSTALL_DIR,
|
|
9355
|
+
BP_CLI_BIN_PATH,
|
|
9072
9356
|
AssetsManager,
|
|
9073
9357
|
AgentProjectGenerator,
|
|
9074
9358
|
AgentProject
|
|
9075
9359
|
};
|
|
9076
9360
|
|
|
9077
|
-
//# debugId=
|
|
9361
|
+
//# debugId=DE1D2CDC9130C9B064756E2164756E21
|
|
9078
9362
|
//# sourceMappingURL=index.js.map
|