@botpress/adk 2.0.1 → 2.0.3

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/index.js CHANGED
@@ -3868,8 +3868,9 @@ var init_agent_project = __esm(() => {
3868
3868
  }
3869
3869
  static async load(projectPath, options = {}) {
3870
3870
  const resolvedPath = path11.resolve(projectPath);
3871
+ const cacheKey = AgentProject._getCacheKey(resolvedPath, options);
3871
3872
  if (!options.noCache) {
3872
- const cached = AgentProject._projectCache.get(resolvedPath);
3873
+ const cached = AgentProject._projectCache.get(cacheKey);
3873
3874
  if (cached) {
3874
3875
  return cached;
3875
3876
  }
@@ -3877,16 +3878,26 @@ var init_agent_project = __esm(() => {
3877
3878
  const project = new AgentProject(resolvedPath, options);
3878
3879
  await project.reload();
3879
3880
  if (!options.noCache) {
3880
- AgentProject._projectCache.set(resolvedPath, project);
3881
+ AgentProject._projectCache.set(cacheKey, project);
3881
3882
  }
3882
3883
  return project;
3883
3884
  }
3885
+ static _getCacheKey(resolvedPath, options) {
3886
+ const adkCommand = options.adkCommand ?? "default";
3887
+ const offline = options.offline ? "offline" : "online";
3888
+ return `${resolvedPath}\x00${adkCommand}\x00${offline}`;
3889
+ }
3884
3890
  static clearCache() {
3885
3891
  AgentProject._projectCache.clear();
3886
3892
  }
3887
3893
  static clearCacheForPath(projectPath) {
3888
3894
  const resolvedPath = path11.resolve(projectPath);
3889
- AgentProject._projectCache.delete(resolvedPath);
3895
+ const prefix = `${resolvedPath}\x00`;
3896
+ for (const key of AgentProject._projectCache.keys()) {
3897
+ if (key.startsWith(prefix)) {
3898
+ AgentProject._projectCache.delete(key);
3899
+ }
3900
+ }
3890
3901
  }
3891
3902
  get path() {
3892
3903
  return this._path;
@@ -4801,7 +4812,7 @@ var _format = null, _formatLoaded = false, formatCode = async (code, filepath) =
4801
4812
  `));
4802
4813
  return code;
4803
4814
  }
4804
- }, ADK_VERSION = "2.0.1", relative = (from, to) => {
4815
+ }, ADK_VERSION = "2.0.3", relative = (from, to) => {
4805
4816
  const fromDir = path14.dirname(from);
4806
4817
  const relative2 = path14.relative(fromDir, to);
4807
4818
  return relative2.startsWith(".") ? relative2 : `./${relative2}`;
@@ -15805,7 +15816,7 @@ var init_integration_action_types = __esm(() => {
15805
15816
  var require_package = __commonJS((exports, module) => {
15806
15817
  module.exports = {
15807
15818
  name: "@botpress/adk",
15808
- version: "2.0.1",
15819
+ version: "2.0.3",
15809
15820
  description: "Core ADK library for building AI agents on Botpress",
15810
15821
  keywords: [
15811
15822
  "adk",
@@ -15863,10 +15874,10 @@ var require_package = __commonJS((exports, module) => {
15863
15874
  },
15864
15875
  dependencies: {
15865
15876
  "@botpress/chat": "~0.5.5",
15866
- "@botpress/cli": "~6.8.6",
15877
+ "@botpress/cli": "~6.8.10",
15867
15878
  "@botpress/client": "~1.46.0",
15868
15879
  "@botpress/cognitive": "~0.6.0",
15869
- "@botpress/runtime": "^2.0.1",
15880
+ "@botpress/runtime": "^2.0.3",
15870
15881
  "@botpress/sdk": "~6.11.1",
15871
15882
  "@bpinternal/jex": "^1.2.4",
15872
15883
  "@bpinternal/yargs-extra": "^0.0.21",
@@ -15900,7 +15911,7 @@ import os from "os";
15900
15911
  import path from "path";
15901
15912
  import createDebug from "debug";
15902
15913
  var debug = createDebug("adk:bp-cli");
15903
- var BP_CLI_VERSION = "6.8.6";
15914
+ var BP_CLI_VERSION = "6.8.10";
15904
15915
  var BP_CLI_INSTALL_ALL = path.join(os.homedir(), ".adk", `bp-cli`);
15905
15916
  var BP_CLI_INSTALL_DIR = path.join(BP_CLI_INSTALL_ALL, BP_CLI_VERSION);
15906
15917
  var BP_CLI_BIN_PATH = path.join(BP_CLI_INSTALL_DIR, "node_modules", "@botpress", "cli", "bin.js");
@@ -21819,23 +21830,25 @@ class IntegrationSync {
21819
21830
  projectPath;
21820
21831
  botProjectPath;
21821
21832
  bpModulesPath;
21833
+ adkCommand;
21822
21834
  credentialsPromise = null;
21823
- constructor(projectPath, botProjectPath) {
21835
+ constructor(projectPath, botProjectPath, options = {}) {
21824
21836
  this.projectPath = projectPath;
21825
21837
  this.botProjectPath = botProjectPath;
21826
21838
  this.bpModulesPath = path39.join(botProjectPath, "bp_modules");
21839
+ this.adkCommand = options.adkCommand;
21827
21840
  }
21828
21841
  getCredentials() {
21829
21842
  if (!this.credentialsPromise) {
21830
21843
  this.credentialsPromise = (async () => {
21831
- const project = await AgentProject.load(this.projectPath);
21844
+ const project = await AgentProject.load(this.projectPath, this.adkCommand ? { adkCommand: this.adkCommand } : {});
21832
21845
  return resolveWorkspaceCredentials({ project });
21833
21846
  })();
21834
21847
  }
21835
21848
  return this.credentialsPromise;
21836
21849
  }
21837
21850
  async parseIntegrations() {
21838
- const project = await AgentProject.load(this.projectPath);
21851
+ const project = await AgentProject.load(this.projectPath, this.adkCommand ? { adkCommand: this.adkCommand } : {});
21839
21852
  const dependencies = project.dependencies;
21840
21853
  if (!dependencies?.integrations) {
21841
21854
  return [];
@@ -22094,23 +22107,25 @@ class PluginSync {
22094
22107
  projectPath;
22095
22108
  botProjectPath;
22096
22109
  bpModulesPath;
22110
+ adkCommand;
22097
22111
  credentialsPromise = null;
22098
- constructor(projectPath, botProjectPath) {
22112
+ constructor(projectPath, botProjectPath, options = {}) {
22099
22113
  this.projectPath = projectPath;
22100
22114
  this.botProjectPath = botProjectPath;
22101
22115
  this.bpModulesPath = path41.join(botProjectPath, "bp_modules");
22116
+ this.adkCommand = options.adkCommand;
22102
22117
  }
22103
22118
  getCredentials() {
22104
22119
  if (!this.credentialsPromise) {
22105
22120
  this.credentialsPromise = (async () => {
22106
- const project = await AgentProject.load(this.projectPath);
22121
+ const project = await AgentProject.load(this.projectPath, this.adkCommand ? { adkCommand: this.adkCommand } : {});
22107
22122
  return resolveWorkspaceCredentials({ project });
22108
22123
  })();
22109
22124
  }
22110
22125
  return this.credentialsPromise;
22111
22126
  }
22112
22127
  async parsePlugins() {
22113
- const project = await AgentProject.load(this.projectPath);
22128
+ const project = await AgentProject.load(this.projectPath, this.adkCommand ? { adkCommand: this.adkCommand } : {});
22114
22129
  const dependencies = project.dependencies;
22115
22130
  if (!dependencies?.plugins) {
22116
22131
  return [];
@@ -22221,6 +22236,9 @@ init_constants();
22221
22236
  import { BuiltInActions as BuiltInActions2, BuiltInWorkflows as BuiltInWorkflows4, Primitives as Primitives3 } from "@botpress/runtime/internal";
22222
22237
  import { BUILT_IN_TAGS as BUILT_IN_TAGS2 } from "@botpress/runtime/definition";
22223
22238
  var { transforms: transforms6 } = z10;
22239
+ function projectLoadOptions(adkCommand) {
22240
+ return adkCommand ? { adkCommand } : {};
22241
+ }
22224
22242
  var plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
22225
22243
  function resolveIntegrationEnabled(integration, cloudEnabled) {
22226
22244
  if (integration.enabled !== undefined)
@@ -22257,6 +22275,9 @@ class BotGenerator {
22257
22275
  this.adkCommand = options.adkCommand;
22258
22276
  this.callbacks = options.callbacks;
22259
22277
  }
22278
+ loadProject() {
22279
+ return AgentProject.load(this.projectPath, projectLoadOptions(this.adkCommand));
22280
+ }
22260
22281
  async listFilesRecursive(rootDir) {
22261
22282
  try {
22262
22283
  if (!existsSync8(rootDir))
@@ -22301,7 +22322,7 @@ class BotGenerator {
22301
22322
  await removeIfEmpty(rootDir);
22302
22323
  }
22303
22324
  async generate() {
22304
- const project = await AgentProject.load(this.projectPath);
22325
+ const project = await this.loadProject();
22305
22326
  await fs19.mkdir(this.outputPath, { recursive: true });
22306
22327
  await this.generateInterfacesDefinition();
22307
22328
  await this.generateIntegrationsTypes();
@@ -22327,7 +22348,7 @@ class BotGenerator {
22327
22348
  await this.generatePluginsDefinition();
22328
22349
  }
22329
22350
  async generateIntegrationsTypes() {
22330
- const project = await AgentProject.load(this.projectPath);
22351
+ const project = await this.loadProject();
22331
22352
  const manager3 = new IntegrationManager({
22332
22353
  project
22333
22354
  });
@@ -22377,7 +22398,7 @@ class BotGenerator {
22377
22398
  await this.removeEmptyDirectories(integrationsDir);
22378
22399
  }
22379
22400
  async generatePluginsTypes() {
22380
- const project = await AgentProject.load(this.projectPath);
22401
+ const project = await this.loadProject();
22381
22402
  const manager3 = new PluginManager({
22382
22403
  project
22383
22404
  });
@@ -22427,32 +22448,32 @@ class BotGenerator {
22427
22448
  await this.removeEmptyDirectories(pluginsDir);
22428
22449
  }
22429
22450
  async generateTriggerTypes() {
22430
- const project = await AgentProject.load(this.projectPath);
22451
+ const project = await this.loadProject();
22431
22452
  await generateTriggerTypes(project);
22432
22453
  }
22433
22454
  async generateEventTypes() {
22434
- const project = await AgentProject.load(this.projectPath);
22455
+ const project = await this.loadProject();
22435
22456
  await generateEventTypes(project);
22436
22457
  }
22437
22458
  async generateConversationTypes() {
22438
- const project = await AgentProject.load(this.projectPath);
22459
+ const project = await this.loadProject();
22439
22460
  await generateConversationTypes(project);
22440
22461
  }
22441
22462
  async generateIntegrationActionTypes() {
22442
- const project = await AgentProject.load(this.projectPath);
22463
+ const project = await this.loadProject();
22443
22464
  const { generateIntegrationActionTypes: generateIntegrationActionTypes2 } = await Promise.resolve().then(() => (init_integration_action_types(), exports_integration_action_types));
22444
22465
  await generateIntegrationActionTypes2(project);
22445
22466
  }
22446
22467
  async generatePluginActionTypes() {
22447
- const project = await AgentProject.load(this.projectPath);
22468
+ const project = await this.loadProject();
22448
22469
  await generatePluginActionTypes(project);
22449
22470
  }
22450
22471
  async generateClientWrapper() {
22451
- const project = await AgentProject.load(this.projectPath);
22472
+ const project = await this.loadProject();
22452
22473
  await generateClientWrapper(project);
22453
22474
  }
22454
22475
  async generateRuntimeTypes() {
22455
- const project = await AgentProject.load(this.projectPath);
22476
+ const project = await this.loadProject();
22456
22477
  const manager3 = new IntegrationManager({
22457
22478
  project
22458
22479
  });
@@ -22509,7 +22530,7 @@ declare module "@botpress/runtime/_types/state" {
22509
22530
  await createFile(path43.join(this.projectPath, ".adk", "runtime.d.ts"), await formatCode(types5));
22510
22531
  }
22511
22532
  async generateInterfacesTypes() {
22512
- const project = await AgentProject.load(this.projectPath);
22533
+ const project = await this.loadProject();
22513
22534
  const integrationManager = new IntegrationManager({
22514
22535
  project
22515
22536
  });
@@ -22589,7 +22610,7 @@ declare module "@botpress/runtime/_types/state" {
22589
22610
  `);
22590
22611
  }
22591
22612
  async generateIntegrationsDefinition() {
22592
- const project = await AgentProject.load(this.projectPath);
22613
+ const project = await this.loadProject();
22593
22614
  const integrations = project.dependencies?.integrations || {};
22594
22615
  const aliases = Object.keys(integrations);
22595
22616
  const moduleExists = (alias) => existsSync8(path43.join(this.outputPath, "bp_modules", bpModuleDirName("integration", alias)));
@@ -22624,7 +22645,7 @@ declare module "@botpress/runtime/_types/state" {
22624
22645
  await createFile(path43.join(this.outputPath, "src", "integrations.ts"), content);
22625
22646
  }
22626
22647
  async generatePluginsDefinition() {
22627
- const project = await AgentProject.load(this.projectPath);
22648
+ const project = await this.loadProject();
22628
22649
  const plugins = project.dependencies?.plugins || {};
22629
22650
  const aliases = Object.keys(plugins);
22630
22651
  const moduleExists = (alias) => existsSync8(path43.join(this.outputPath, "bp_modules", bpModuleDirName("plugin", alias)));
@@ -22714,7 +22735,7 @@ declare module "@botpress/runtime/_types/state" {
22714
22735
  async generateBotDefinition() {
22715
22736
  this.integrationStatuses = {};
22716
22737
  this.pluginStatuses = {};
22717
- const project = await AgentProject.load(this.projectPath);
22738
+ const project = await this.loadProject();
22718
22739
  const integrations = project.integrations;
22719
22740
  const isDeployOrBuild = this.adkCommand === "adk-deploy" || this.adkCommand === "adk-build";
22720
22741
  const configTargetBotId = isDeployOrBuild ? project.agentInfo?.botId : undefined;
@@ -23702,7 +23723,7 @@ export default bot;`;
23702
23723
  const assetsRuntimePath = path43.join(this.projectPath, ".adk", "assets-runtime.ts");
23703
23724
  const isShippingBuild = this.adkCommand !== "adk-dev";
23704
23725
  if (isShippingBuild) {
23705
- const project = await AgentProject.load(this.projectPath);
23726
+ const project = await this.loadProject();
23706
23727
  await initAssets(this.projectPath, project.agentInfo?.botId, { dev: false });
23707
23728
  }
23708
23729
  if (existsSync8(assetsRuntimePath)) {
@@ -23722,7 +23743,7 @@ async function generateBotProject(options) {
23722
23743
  linkSdk(options.projectPath, botPath),
23723
23744
  devIdManager.restoreDevId()
23724
23745
  ]);
23725
- const integrationSync = new IntegrationSync(options.projectPath, botPath);
23746
+ const integrationSync = new IntegrationSync(options.projectPath, botPath, projectLoadOptions(options.adkCommand));
23726
23747
  const integrationSyncResult = await integrationSync.syncIntegrations();
23727
23748
  if (integrationSyncResult.errors.length > 0) {
23728
23749
  console.warn(`⚠️ Some integrations failed to sync:`);
@@ -23738,7 +23759,7 @@ async function generateBotProject(options) {
23738
23759
  console.warn(` - ${alias}: ${error}`);
23739
23760
  });
23740
23761
  }
23741
- const pluginSync = new PluginSync(options.projectPath, botPath);
23762
+ const pluginSync = new PluginSync(options.projectPath, botPath, projectLoadOptions(options.adkCommand));
23742
23763
  const pluginSyncResult = await pluginSync.syncPlugins();
23743
23764
  if (pluginSyncResult.errors.length > 0) {
23744
23765
  console.warn(`⚠️ Some plugins failed to sync:`);
@@ -23746,7 +23767,7 @@ async function generateBotProject(options) {
23746
23767
  console.warn(` - ${alias}: ${error}`);
23747
23768
  });
23748
23769
  }
23749
- const project = await AgentProject.load(options.projectPath);
23770
+ const project = await AgentProject.load(options.projectPath, projectLoadOptions(options.adkCommand));
23750
23771
  const syncErrorByAlias = new Map;
23751
23772
  for (const { alias, error } of [...integrationSyncResult.errors, ...pluginSyncResult.errors]) {
23752
23773
  syncErrorByAlias.set(alias, error);
@@ -26148,4 +26169,4 @@ export {
26148
26169
  ADK_MANIFEST_BOT_TAGS
26149
26170
  };
26150
26171
 
26151
- //# debugId=35A78955F48293A564756E2164756E21
26172
+ //# debugId=8B69F02A6C73998264756E2164756E21