@botpress/adk 1.9.0 → 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/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.9.0", relative2 = (from, to) => {
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 path28 from "path";
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 = path28.join(project.path, action.path);
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 = path28.join(project.path, ".adk", "action-types.d.ts");
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 path29 from "path";
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 = path29.join(project.path, ".adk", "integration-action-types.d.ts");
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.9.0",
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.9.0",
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",
@@ -4724,6 +4725,99 @@ class FileWatcher extends EventEmitter2 {
4724
4725
  init_validation_errors();
4725
4726
  init_agent_resolver();
4726
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
+ }
4727
4821
  // src/agent-init/agent-project-generator.ts
4728
4822
  init_utils();
4729
4823
  import * as fs11 from "fs";
@@ -4772,7 +4866,7 @@ class AgentProjectGenerator {
4772
4866
  deploy: "adk deploy"
4773
4867
  },
4774
4868
  dependencies: {
4775
- "@botpress/runtime": `^${"1.9.0"}`
4869
+ "@botpress/runtime": `^${"1.10.1"}`
4776
4870
  },
4777
4871
  devDependencies: {
4778
4872
  typescript: "^5.9.3"
@@ -5350,7 +5444,7 @@ Description: ${tag?.description}`);
5350
5444
  import dedent from "dedent";
5351
5445
  import { existsSync as existsSync6 } from "fs";
5352
5446
  import fs15 from "fs/promises";
5353
- import path30 from "path";
5447
+ import path32 from "path";
5354
5448
 
5355
5449
  // src/generators/interface-types.ts
5356
5450
  import { transforms as transforms2 } from "@botpress/sdk";
@@ -5667,10 +5761,201 @@ declare module "@botpress/runtime/_types/state" {
5667
5761
  await createFile(stateTypesPath, await formatCode(content));
5668
5762
  }
5669
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
+
5670
5955
  // src/generators/workflow-types.ts
5671
5956
  init_utils();
5672
5957
  init_fs();
5673
- import * as path22 from "path";
5958
+ import * as path24 from "path";
5674
5959
  import { BuiltInWorkflows as BuiltInWorkflows2 } from "@botpress/runtime/internal";
5675
5960
  function isBuiltinWorkflow(name) {
5676
5961
  return !!Object.values(BuiltInWorkflows2).find((x) => x.name === name);
@@ -5682,7 +5967,7 @@ async function generateWorkflowTypes(project) {
5682
5967
  if (isBuiltinWorkflow(workflowRef.definition.name)) {
5683
5968
  continue;
5684
5969
  }
5685
- const workflowPath = path22.join(project.path, workflowRef.path);
5970
+ const workflowPath = path24.join(project.path, workflowRef.path);
5686
5971
  const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
5687
5972
  const workflowInstance = workflowModule[workflowRef.export] || workflowModule.default;
5688
5973
  if (!workflowInstance) {
@@ -5716,29 +6001,32 @@ async function generateWorkflowTypes(project) {
5716
6001
  output: ${workflow.output};
5717
6002
  state: ${workflow.state};
5718
6003
  requests: ${workflow.requests};
6004
+ tags: WorkflowTags;
5719
6005
  };`).join(`
5720
6006
  `);
5721
6007
  const content = `// Generated workflow type definitions
5722
6008
  // Do not edit this file directly - it will be overwritten
5723
6009
 
6010
+ type WorkflowTags = import("@botpress/runtime/_types/tags").WorkflowTags;
6011
+
5724
6012
  declare module "@botpress/runtime/_types/workflows" {
5725
6013
  export type WorkflowDefinitions = {
5726
6014
  ${typeDefinitions || " // No workflows defined yet"}
5727
6015
  };
5728
6016
  }`;
5729
- const workflowTypesPath = path22.join(project.path, ".adk", "workflow-types.d.ts");
6017
+ const workflowTypesPath = path24.join(project.path, ".adk", "workflow-types.d.ts");
5730
6018
  await createFile(workflowTypesPath, await formatCode(content));
5731
6019
  }
5732
6020
 
5733
6021
  // src/generators/conversation-types.ts
5734
6022
  init_utils();
5735
6023
  init_fs();
5736
- import path23 from "path";
6024
+ import path25 from "path";
5737
6025
  async function generateConversationTypes(project) {
5738
6026
  const conversationTypes = {};
5739
6027
  for (const conversationRef of project.conversations) {
5740
6028
  try {
5741
- const conversationPath = path23.join(project.path, conversationRef.path);
6029
+ const conversationPath = path25.join(project.path, conversationRef.path);
5742
6030
  const conversationModule = await import(`${conversationPath}?t=${Date.now()}`);
5743
6031
  const conversationInstance = conversationModule[conversationRef.export] || conversationModule.default;
5744
6032
  if (!conversationInstance) {
@@ -5770,8 +6058,8 @@ async function generateConversationTypes(project) {
5770
6058
  channel: "${channel}";
5771
6059
  integration: "${integration}";
5772
6060
  state: ${info.state};
5773
- tags: Integrations["${integration}"]["channels"]["${channelName}"]["conversation"]["tags"];
5774
- 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;
5775
6063
  messages: Integrations["${integration}"]["channels"]["${channelName}"]["messages"];
5776
6064
  events: Integrations["${integration}"]["events"];
5777
6065
  };`;
@@ -5786,6 +6074,8 @@ async function generateConversationTypes(project) {
5786
6074
  ////////////////////////////////////////////////////////
5787
6075
 
5788
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;
5789
6079
 
5790
6080
  declare module "@botpress/runtime/_types/conversations" {
5791
6081
  export type ConversationDefinitions = {
@@ -5793,14 +6083,14 @@ ${channelDefinitions || " // No conversations defined yet"}
5793
6083
  };
5794
6084
  }
5795
6085
  `;
5796
- const conversationTypesPath = path23.join(project.path, ".adk", "conversation-types.d.ts");
6086
+ const conversationTypesPath = path25.join(project.path, ".adk", "conversation-types.d.ts");
5797
6087
  await createFile(conversationTypesPath, await formatCode(content));
5798
6088
  }
5799
6089
 
5800
6090
  // src/generators/event-types.ts
5801
6091
  init_utils();
5802
6092
  init_fs();
5803
- import path24 from "path";
6093
+ import path26 from "path";
5804
6094
  async function generateEventTypes(project) {
5805
6095
  const integrationEvents = [];
5806
6096
  for (const int of project.integrations) {
@@ -5839,7 +6129,7 @@ ${integrationEvents.join(`
5839
6129
  export type EventPayload<T extends EventName> = Events[T];
5840
6130
  }
5841
6131
  `;
5842
- const eventTypesPath = path24.join(project.path, ".adk", "event-types.d.ts");
6132
+ const eventTypesPath = path26.join(project.path, ".adk", "event-types.d.ts");
5843
6133
  await createFile(eventTypesPath, await formatCode(content));
5844
6134
  }
5845
6135
 
@@ -5847,10 +6137,10 @@ ${integrationEvents.join(`
5847
6137
  init_fs();
5848
6138
 
5849
6139
  // src/bot-generator/dev-id-manager.ts
5850
- import path25 from "path";
6140
+ import path27 from "path";
5851
6141
  import fs12 from "fs/promises";
5852
6142
  import { existsSync as existsSync3 } from "fs";
5853
- import { Client as Client10 } from "@botpress/client";
6143
+ import { Client as Client11 } from "@botpress/client";
5854
6144
  class DevIdManager {
5855
6145
  projectPath;
5856
6146
  botProjectPath;
@@ -5859,7 +6149,7 @@ class DevIdManager {
5859
6149
  constructor(projectPath, botProjectPath) {
5860
6150
  this.projectPath = projectPath;
5861
6151
  this.botProjectPath = botProjectPath;
5862
- this.projectCachePath = path25.join(botProjectPath, ".botpress", "project.cache.json");
6152
+ this.projectCachePath = path27.join(botProjectPath, ".botpress", "project.cache.json");
5863
6153
  }
5864
6154
  async getClient() {
5865
6155
  if (!this.client) {
@@ -5869,7 +6159,7 @@ class DevIdManager {
5869
6159
  if (!workspaceId) {
5870
6160
  throw new Error('No workspace ID found in agent.json or current profile. Please login again with "adk login"');
5871
6161
  }
5872
- this.client = new Client10({
6162
+ this.client = new Client11({
5873
6163
  token: credentials.token,
5874
6164
  apiUrl: credentials.apiUrl,
5875
6165
  workspaceId,
@@ -5896,7 +6186,7 @@ class DevIdManager {
5896
6186
  }
5897
6187
  async saveProjectCache(cache2) {
5898
6188
  try {
5899
- await fs12.mkdir(path25.dirname(this.projectCachePath), { recursive: true });
6189
+ await fs12.mkdir(path27.dirname(this.projectCachePath), { recursive: true });
5900
6190
  await fs12.writeFile(this.projectCachePath, JSON.stringify(cache2, null, 2));
5901
6191
  } catch (error) {
5902
6192
  console.error("Error saving project.cache.json:", error);
@@ -5945,7 +6235,7 @@ class DevIdManager {
5945
6235
  }
5946
6236
 
5947
6237
  // src/bot-generator/integration-sync.ts
5948
- import path26 from "path";
6238
+ import path28 from "path";
5949
6239
  import fs13 from "fs/promises";
5950
6240
  import { existsSync as existsSync4 } from "fs";
5951
6241
  class IntegrationSync {
@@ -5955,7 +6245,7 @@ class IntegrationSync {
5955
6245
  constructor(projectPath, botProjectPath) {
5956
6246
  this.projectPath = projectPath;
5957
6247
  this.botProjectPath = botProjectPath;
5958
- this.bpModulesPath = path26.join(botProjectPath, "bp_modules");
6248
+ this.bpModulesPath = path28.join(botProjectPath, "bp_modules");
5959
6249
  }
5960
6250
  async parseIntegrations() {
5961
6251
  const project = await AgentProject.load(this.projectPath);
@@ -5986,12 +6276,12 @@ class IntegrationSync {
5986
6276
  return integrations;
5987
6277
  }
5988
6278
  async isIntegrationSynced(integration) {
5989
- const targetFolder = path26.join(this.bpModulesPath, `integration_${integration.alias}`);
6279
+ const targetFolder = path28.join(this.bpModulesPath, `integration_${integration.alias}`);
5990
6280
  if (!existsSync4(targetFolder)) {
5991
6281
  return false;
5992
6282
  }
5993
6283
  try {
5994
- const indexPath = path26.join(targetFolder, "index.ts");
6284
+ const indexPath = path28.join(targetFolder, "index.ts");
5995
6285
  if (!existsSync4(indexPath)) {
5996
6286
  return false;
5997
6287
  }
@@ -6024,8 +6314,8 @@ class IntegrationSync {
6024
6314
  }
6025
6315
  async renameIntegrationFolder(integration) {
6026
6316
  console.log(integration.name, integration.alias);
6027
- const sourceFolder = path26.join(this.bpModulesPath, integration.name.replace("/", "-"));
6028
- const targetFolder = path26.join(this.bpModulesPath, `integration_${integration.alias}`);
6317
+ const sourceFolder = path28.join(this.bpModulesPath, integration.name.replace("/", "-"));
6318
+ const targetFolder = path28.join(this.bpModulesPath, `integration_${integration.alias}`);
6029
6319
  if (!existsSync4(sourceFolder)) {
6030
6320
  throw new Error(`Integration folder not found: ${sourceFolder}`);
6031
6321
  }
@@ -6035,7 +6325,7 @@ class IntegrationSync {
6035
6325
  await fs13.rename(sourceFolder, targetFolder);
6036
6326
  }
6037
6327
  async removeIntegrationFolder(alias) {
6038
- const targetFolder = path26.join(this.bpModulesPath, `integration_${alias}`);
6328
+ const targetFolder = path28.join(this.bpModulesPath, `integration_${alias}`);
6039
6329
  if (existsSync4(targetFolder)) {
6040
6330
  await fs13.rm(targetFolder, { recursive: true, force: true });
6041
6331
  }
@@ -6069,7 +6359,7 @@ class IntegrationSync {
6069
6359
  }
6070
6360
 
6071
6361
  // src/bot-generator/interface-sync.ts
6072
- import path27 from "path";
6362
+ import path29 from "path";
6073
6363
  import fs14 from "fs/promises";
6074
6364
  import { existsSync as existsSync5 } from "fs";
6075
6365
  init_constants();
@@ -6080,7 +6370,7 @@ class InterfaceSync {
6080
6370
  constructor(projectPath, botProjectPath) {
6081
6371
  this.projectPath = projectPath;
6082
6372
  this.botProjectPath = botProjectPath;
6083
- this.bpModulesPath = path27.join(botProjectPath, "bp_modules");
6373
+ this.bpModulesPath = path29.join(botProjectPath, "bp_modules");
6084
6374
  }
6085
6375
  async parseInterfaces() {
6086
6376
  const interfaces = [];
@@ -6098,12 +6388,12 @@ class InterfaceSync {
6098
6388
  return interfaces;
6099
6389
  }
6100
6390
  async isInterfaceSynced(interfaceInfo) {
6101
- const targetFolder = path27.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
6391
+ const targetFolder = path29.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
6102
6392
  if (!existsSync5(targetFolder)) {
6103
6393
  return false;
6104
6394
  }
6105
6395
  try {
6106
- const indexPath = path27.join(targetFolder, "index.ts");
6396
+ const indexPath = path29.join(targetFolder, "index.ts");
6107
6397
  if (!existsSync5(indexPath)) {
6108
6398
  return false;
6109
6399
  }
@@ -6149,8 +6439,8 @@ class InterfaceSync {
6149
6439
  });
6150
6440
  }
6151
6441
  async renameInterfaceFolder(interfaceInfo) {
6152
- const sourceFolder = path27.join(this.bpModulesPath, interfaceInfo.name);
6153
- const targetFolder = path27.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
6442
+ const sourceFolder = path29.join(this.bpModulesPath, interfaceInfo.name);
6443
+ const targetFolder = path29.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
6154
6444
  if (!existsSync5(sourceFolder)) {
6155
6445
  throw new Error(`Interface folder not found: ${sourceFolder}`);
6156
6446
  }
@@ -6160,7 +6450,7 @@ class InterfaceSync {
6160
6450
  await fs14.rename(sourceFolder, targetFolder);
6161
6451
  }
6162
6452
  async removeInterfaceFolder(alias) {
6163
- const targetFolder = path27.join(this.bpModulesPath, `interface_${pascalCase(alias)}`);
6453
+ const targetFolder = path29.join(this.bpModulesPath, `interface_${pascalCase(alias)}`);
6164
6454
  if (existsSync5(targetFolder)) {
6165
6455
  await fs14.rm(targetFolder, { recursive: true, force: true });
6166
6456
  }
@@ -6205,15 +6495,15 @@ function isBuiltinAction(name) {
6205
6495
  return !!Object.values(BuiltInActions2).find((x) => x.name === name);
6206
6496
  }
6207
6497
  function getImportPath(from, to) {
6208
- return path30.relative(path30.dirname(from), to).replace(/\.ts$/, "").replace(/\\/g, "/");
6498
+ return path32.relative(path32.dirname(from), to).replace(/\.ts$/, "").replace(/\\/g, "/");
6209
6499
  }
6210
6500
 
6211
6501
  class BotGenerator {
6212
6502
  projectPath;
6213
6503
  outputPath;
6214
6504
  constructor(options) {
6215
- this.projectPath = path30.resolve(options.projectPath);
6216
- this.outputPath = path30.resolve(options.outputPath || path30.join(this.projectPath, ".adk"));
6505
+ this.projectPath = path32.resolve(options.projectPath);
6506
+ this.outputPath = path32.resolve(options.outputPath || path32.join(this.projectPath, ".adk"));
6217
6507
  }
6218
6508
  async listFilesRecursive(rootDir) {
6219
6509
  try {
@@ -6223,8 +6513,8 @@ class BotGenerator {
6223
6513
  const walk = async (dir, relativeBase) => {
6224
6514
  const entries = await fs15.readdir(dir, { withFileTypes: true });
6225
6515
  for (const entry of entries) {
6226
- const abs = path30.join(dir, entry.name);
6227
- const rel = path30.join(relativeBase, entry.name);
6516
+ const abs = path32.join(dir, entry.name);
6517
+ const rel = path32.join(relativeBase, entry.name);
6228
6518
  if (entry.isDirectory()) {
6229
6519
  await walk(abs, rel);
6230
6520
  } else {
@@ -6245,7 +6535,7 @@ class BotGenerator {
6245
6535
  const entries = await fs15.readdir(dir, { withFileTypes: true });
6246
6536
  for (const entry of entries) {
6247
6537
  if (entry.isDirectory()) {
6248
- const subdir = path30.join(dir, entry.name);
6538
+ const subdir = path32.join(dir, entry.name);
6249
6539
  await removeIfEmpty(subdir);
6250
6540
  }
6251
6541
  }
@@ -6268,7 +6558,9 @@ class BotGenerator {
6268
6558
  await this.generateInterfacesTypes();
6269
6559
  await this.generateTableTypes();
6270
6560
  await this.generateTriggerTypes();
6561
+ await this.generateTagTypes();
6271
6562
  await this.generateStateTypes();
6563
+ await this.generateConfigurationTypes();
6272
6564
  await this.generateWorkflowTypes();
6273
6565
  await this.generateConversationTypes();
6274
6566
  await this.generateActionTypes();
@@ -6283,22 +6575,22 @@ class BotGenerator {
6283
6575
  }
6284
6576
  async generateIntegrationsTypes() {
6285
6577
  const project = await AgentProject.load(this.projectPath);
6286
- const manager2 = new IntegrationManager({
6578
+ const manager3 = new IntegrationManager({
6287
6579
  workspaceId: project.agentInfo?.workspaceId
6288
6580
  });
6289
- const integrations = await manager2.loadIntegrations(project.dependencies || {});
6290
- const integrationsDir = path30.join(this.projectPath, ".adk", "integrations");
6581
+ const integrations = await manager3.loadIntegrations(project.dependencies || {});
6582
+ const integrationsDir = path32.join(this.projectPath, ".adk", "integrations");
6291
6583
  const existingIntegrationFiles = await this.listFilesRecursive(integrationsDir);
6292
6584
  let aliases = new Set;
6293
6585
  let files = new Set;
6294
6586
  for (const integration of integrations.integrations) {
6295
6587
  if (integration.enabled && integration.definition) {
6296
6588
  const types6 = await generateIntegrationTypes(integration);
6297
- const importPath = `./${path30.join("integrations", types6.names.paths.index).replace(/\\/g, "/")}`;
6589
+ const importPath = `./${path32.join("integrations", types6.names.paths.index).replace(/\\/g, "/")}`;
6298
6590
  aliases.add(`"${integration.alias}": import("${importPath}").${types6.names.typings.index}`);
6299
6591
  for (const [filePath, content] of Object.entries(types6.files)) {
6300
- const fullPath = path30.join(this.projectPath, ".adk", "integrations", filePath);
6301
- const dir = path30.dirname(fullPath);
6592
+ const fullPath = path32.join(this.projectPath, ".adk", "integrations", filePath);
6593
+ const dir = path32.dirname(fullPath);
6302
6594
  await fs15.mkdir(dir, { recursive: true });
6303
6595
  await createFile(fullPath, content);
6304
6596
  files.add(filePath);
@@ -6319,11 +6611,11 @@ class BotGenerator {
6319
6611
  };
6320
6612
  }
6321
6613
  `;
6322
- await createFile(path30.join(this.projectPath, ".adk", "integrations-types.d.ts"), await formatCode(types5));
6614
+ await createFile(path32.join(this.projectPath, ".adk", "integrations-types.d.ts"), await formatCode(types5));
6323
6615
  const staleIntegrationFiles = existingIntegrationFiles.filter((f) => !files.has(f));
6324
6616
  if (staleIntegrationFiles.length > 0) {
6325
6617
  for (const rel of staleIntegrationFiles) {
6326
- const abs = path30.join(integrationsDir, rel);
6618
+ const abs = path32.join(integrationsDir, rel);
6327
6619
  try {
6328
6620
  await fs15.rm(abs, { force: true });
6329
6621
  } catch {}
@@ -6339,10 +6631,18 @@ class BotGenerator {
6339
6631
  const project = await AgentProject.load(this.projectPath);
6340
6632
  await generateTriggerTypes(project);
6341
6633
  }
6634
+ async generateTagTypes() {
6635
+ const project = await AgentProject.load(this.projectPath);
6636
+ await generateTagTypes(project);
6637
+ }
6342
6638
  async generateStateTypes() {
6343
6639
  const project = await AgentProject.load(this.projectPath);
6344
6640
  await generateStateTypes(project);
6345
6641
  }
6642
+ async generateConfigurationTypes() {
6643
+ const project = await AgentProject.load(this.projectPath);
6644
+ await generateConfigurationTypes(project);
6645
+ }
6346
6646
  async generateEventTypes() {
6347
6647
  const project = await AgentProject.load(this.projectPath);
6348
6648
  await generateEventTypes(project);
@@ -6367,10 +6667,10 @@ class BotGenerator {
6367
6667
  }
6368
6668
  async generateRuntimeTypes() {
6369
6669
  const project = await AgentProject.load(this.projectPath);
6370
- const manager2 = new IntegrationManager({
6670
+ const manager3 = new IntegrationManager({
6371
6671
  workspaceId: project.agentInfo?.workspaceId
6372
6672
  });
6373
- const integrations = await manager2.loadIntegrations(project.dependencies || {});
6673
+ const integrations = await manager3.loadIntegrations(project.dependencies || {});
6374
6674
  const channels = [];
6375
6675
  for (const integration of integrations.integrations) {
6376
6676
  if (integration.enabled && integration.definition) {
@@ -6384,7 +6684,7 @@ class BotGenerator {
6384
6684
  let botStateType = "{}";
6385
6685
  let userStateType = "{}";
6386
6686
  try {
6387
- const configPath = path30.join(project.path, "agent.config.ts");
6687
+ const configPath = path32.join(project.path, "agent.config.ts");
6388
6688
  const configModule = await import(`${configPath}?t=${Date.now()}`);
6389
6689
  const config = configModule.default;
6390
6690
  if (config?.bot?.state) {
@@ -6420,28 +6720,28 @@ declare module "@botpress/runtime/_types/state" {
6420
6720
  export type UserState = ${userStateType};
6421
6721
  }
6422
6722
  `;
6423
- await createFile(path30.join(this.projectPath, ".adk", "runtime.d.ts"), await formatCode(types5));
6723
+ await createFile(path32.join(this.projectPath, ".adk", "runtime.d.ts"), await formatCode(types5));
6424
6724
  }
6425
6725
  async generateInterfacesTypes() {
6426
6726
  const project = await AgentProject.load(this.projectPath);
6427
6727
  const integrationManager = new IntegrationManager({
6428
6728
  workspaceId: project.agentInfo?.workspaceId
6429
6729
  });
6430
- const manager2 = new InterfaceManager;
6431
- const interfacesDir = path30.join(this.projectPath, ".adk", "interfaces");
6730
+ const manager3 = new InterfaceManager;
6731
+ const interfacesDir = path32.join(this.projectPath, ".adk", "interfaces");
6432
6732
  const existingInterfaceFiles = await this.listFilesRecursive(interfacesDir);
6433
- const interfaces = await manager2.loadInterfaces(project.dependencies || {}).then((result) => result.interfaces.filter((int) => int.definition).map((x) => x.definition));
6733
+ const interfaces = await manager3.loadInterfaces(project.dependencies || {}).then((result) => result.interfaces.filter((int) => int.definition).map((x) => x.definition));
6434
6734
  const integrations = await integrationManager.loadIntegrations(project.dependencies || {}).then((result) => result.integrations.filter((int) => int.enabled && int.definition).map((x) => x.definition));
6435
6735
  let imports = new Set;
6436
6736
  let aliases = new Set;
6437
6737
  let files = new Set;
6438
6738
  for (const int of interfaces) {
6439
6739
  const types6 = await generateInterfaceTypes(int, integrations);
6440
- imports.add(`import { ${types6.names.typings.index} } from "./${path30.join("interfaces", types6.names.paths.index).replace(/\\/g, "/")}";`);
6740
+ imports.add(`import { ${types6.names.typings.index} } from "./${path32.join("interfaces", types6.names.paths.index).replace(/\\/g, "/")}";`);
6441
6741
  aliases.add(`"${types6.names.name}": ${types6.names.typings.index}`);
6442
6742
  for (const [filePath, content] of Object.entries(types6.files)) {
6443
- const fullPath = path30.join(this.projectPath, ".adk", "interfaces", filePath);
6444
- const dir = path30.dirname(fullPath);
6743
+ const fullPath = path32.join(this.projectPath, ".adk", "interfaces", filePath);
6744
+ const dir = path32.dirname(fullPath);
6445
6745
  await fs15.mkdir(dir, { recursive: true });
6446
6746
  await createFile(fullPath, content);
6447
6747
  files.add(filePath);
@@ -6478,12 +6778,12 @@ declare module "@botpress/runtime/_types/state" {
6478
6778
  `)}
6479
6779
  };
6480
6780
  `;
6481
- await createFile(path30.join(this.projectPath, ".adk", "interfaces.d.ts"), await formatCode(types5));
6482
- await createFile(path30.join(this.projectPath, ".adk", "interfaces.ts"), await formatCode(consts));
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));
6483
6783
  const staleInterfaceFiles = existingInterfaceFiles.filter((f) => !files.has(f));
6484
6784
  if (staleInterfaceFiles.length > 0) {
6485
6785
  for (const rel of staleInterfaceFiles) {
6486
- const abs = path30.join(interfacesDir, rel);
6786
+ const abs = path32.join(interfacesDir, rel);
6487
6787
  try {
6488
6788
  await fs15.rm(abs, { force: true });
6489
6789
  } catch {}
@@ -6516,7 +6816,7 @@ declare module "@botpress/runtime/_types/state" {
6516
6816
  `) : ""}
6517
6817
  } as Record<string, IntegrationPackage>;
6518
6818
  `;
6519
- await createFile(path30.join(this.outputPath, "src", "integrations.ts"), content);
6819
+ await createFile(path32.join(this.outputPath, "src", "integrations.ts"), content);
6520
6820
  }
6521
6821
  async generateInterfacesDefinition() {
6522
6822
  const interfaces = BUILTIN_INTERFACES;
@@ -6539,7 +6839,7 @@ declare module "@botpress/runtime/_types/state" {
6539
6839
  `) : ""}
6540
6840
  } as Record<string, InterfacePackage>;
6541
6841
  `;
6542
- await createFile(path30.join(this.outputPath, "src", "interfaces.ts"), await formatCode(content));
6842
+ await createFile(path32.join(this.outputPath, "src", "interfaces.ts"), await formatCode(content));
6543
6843
  }
6544
6844
  async generateBotDefinition() {
6545
6845
  const project = await AgentProject.load(this.projectPath);
@@ -6554,8 +6854,22 @@ declare module "@botpress/runtime/_types/state" {
6554
6854
  const configData = config && Object.keys(config).length > 0 ? `, configuration: ${JSON.stringify(config)}` : "";
6555
6855
  addIntegrations.push(`bot.addIntegration(${importName}, { alias: "${alias}", enabled: true${configType}${configData} });`);
6556
6856
  }
6857
+ const userTags = {};
6557
6858
  const conversationTags = {};
6859
+ const messageTags = {};
6558
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
+ }
6559
6873
  const crypto4 = __require("crypto");
6560
6874
  const hashString = (str) => {
6561
6875
  return crypto4.createHash("md5").update(str).digest("hex").substring(0, 5).toUpperCase();
@@ -6576,7 +6890,7 @@ declare module "@botpress/runtime/_types/state" {
6576
6890
  if (isBuiltinWorkflow2(workflow.definition.name)) {
6577
6891
  continue;
6578
6892
  }
6579
- const workflowPath = path30.join(project.path, workflow.path);
6893
+ const workflowPath = path32.join(project.path, workflow.path);
6580
6894
  const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
6581
6895
  const workflowInstance = workflowModule.default || workflowModule[workflow.export];
6582
6896
  if (workflowInstance) {
@@ -6633,6 +6947,8 @@ declare module "@botpress/runtime/_types/state" {
6633
6947
  };
6634
6948
  }
6635
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;
6636
6952
  const content = dedent`
6637
6953
  import { BotDefinition, z } from "@botpress/sdk";
6638
6954
  import {
@@ -6655,20 +6971,40 @@ declare module "@botpress/runtime/_types/state" {
6655
6971
  runtime: "adk",
6656
6972
  runtimeVersion: "${ADK_VERSION}",
6657
6973
  },
6658
-
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
+ },` : ""}
6659
6995
  conversation: {
6660
6996
  tags: {
6661
6997
  ${Object.entries(conversationTags).map(([tag, meta]) => `// ${meta.title}
6662
- // ${meta.description}
6663
- "${tag}": ${JSON.stringify(meta)}`).join(`,
6664
- `)}
6998
+ ${meta.description ? `// ${meta.description}
6999
+ ` : ""}"${tag}": ${JSON.stringify(meta)}`).join(`,
7000
+ `)}${Object.keys(conversationTags).length > 0 ? "," : ""}
6665
7001
  },
6666
7002
  },
6667
7003
  ${Object.keys(workflowTags).length > 0 ? `workflow: {
6668
7004
  tags: {
6669
7005
  ${Object.entries(workflowTags).map(([tag, meta]) => `// ${meta.title}
6670
- // ${meta.description}
6671
- "${tag}": ${JSON.stringify(meta)}`).join(`,
7006
+ ${meta.description ? `// ${meta.description}
7007
+ ` : ""}"${tag}": ${JSON.stringify(meta)}`).join(`,
6672
7008
  `)}
6673
7009
  },
6674
7010
  },` : ""}
@@ -6782,7 +7118,7 @@ declare module "@botpress/runtime/_types/state" {
6782
7118
 
6783
7119
  export default bot;
6784
7120
  `;
6785
- await createFile(path30.join(this.outputPath, "bot.definition.ts"), await formatCode(content));
7121
+ await createFile(path32.join(this.outputPath, "bot.definition.ts"), await formatCode(content));
6786
7122
  }
6787
7123
  async generateBotIndex() {
6788
7124
  const content = dedent`
@@ -6816,7 +7152,7 @@ declare module "@botpress/runtime/_types/state" {
6816
7152
 
6817
7153
  export default bot
6818
7154
  `;
6819
- await createFile(path30.join(this.outputPath, "src", "index.ts"), await formatCode(content));
7155
+ await createFile(path32.join(this.outputPath, "src", "index.ts"), await formatCode(content));
6820
7156
  }
6821
7157
  async generatePackageJson(project) {
6822
7158
  const packageJson = {
@@ -6835,7 +7171,7 @@ declare module "@botpress/runtime/_types/state" {
6835
7171
  typescript: "^5.9.3"
6836
7172
  }
6837
7173
  };
6838
- await createFile(path30.join(this.outputPath, "package.json"), JSON.stringify(packageJson, null, 2));
7174
+ await createFile(path32.join(this.outputPath, "package.json"), JSON.stringify(packageJson, null, 2));
6839
7175
  }
6840
7176
  async generateTsConfig() {
6841
7177
  const tsConfig = {
@@ -6866,7 +7202,7 @@ declare module "@botpress/runtime/_types/state" {
6866
7202
  },
6867
7203
  include: [".botpress/**/*", "src/**/*", "bp_modules/**/*", "./*.ts", "./*.json", "../*.d.ts"]
6868
7204
  };
6869
- await createFile(path30.join(this.outputPath, "tsconfig.json"), JSON.stringify(tsConfig, null, 2));
7205
+ await createFile(path32.join(this.outputPath, "tsconfig.json"), JSON.stringify(tsConfig, null, 2));
6870
7206
  }
6871
7207
  async generateGlobalTypes() {
6872
7208
  const content = dedent`
@@ -6889,11 +7225,11 @@ declare module "@botpress/runtime/_types/state" {
6889
7225
 
6890
7226
  export {};
6891
7227
  `;
6892
- await createFile(path30.join(this.outputPath, "global.d.ts"), await formatCode(content));
7228
+ await createFile(path32.join(this.outputPath, "global.d.ts"), await formatCode(content));
6893
7229
  }
6894
7230
  async copyAssets() {
6895
- const assetsPath = path30.join(this.projectPath, "assets");
6896
- const targetPath = path30.join(this.outputPath, "assets");
7231
+ const assetsPath = path32.join(this.projectPath, "assets");
7232
+ const targetPath = path32.join(this.outputPath, "assets");
6897
7233
  if (existsSync6(assetsPath)) {
6898
7234
  await fs15.mkdir(targetPath, { recursive: true });
6899
7235
  await this.copyDirectory(assetsPath, targetPath);
@@ -6902,8 +7238,8 @@ declare module "@botpress/runtime/_types/state" {
6902
7238
  async copyDirectory(src, dest) {
6903
7239
  const entries = await fs15.readdir(src, { withFileTypes: true });
6904
7240
  for (const entry of entries) {
6905
- const srcPath = path30.join(src, entry.name);
6906
- const destPath = path30.join(dest, entry.name);
7241
+ const srcPath = path32.join(src, entry.name);
7242
+ const destPath = path32.join(dest, entry.name);
6907
7243
  if (entry.isDirectory()) {
6908
7244
  await fs15.mkdir(destPath, { recursive: true });
6909
7245
  await this.copyDirectory(srcPath, destPath);
@@ -6915,16 +7251,16 @@ declare module "@botpress/runtime/_types/state" {
6915
7251
  async generateAdkRuntime() {
6916
7252
  const project = new AgentProject(this.projectPath);
6917
7253
  await project.reload();
6918
- const srcDir = path30.join(this.outputPath, "src");
7254
+ const srcDir = path32.join(this.outputPath, "src");
6919
7255
  {
6920
- const dest = path30.join(srcDir, "conversations.ts");
7256
+ const dest = path32.join(srcDir, "conversations.ts");
6921
7257
  const imports = new Map;
6922
7258
  const exports = new Set;
6923
7259
  let index = 1;
6924
7260
  for (const conversation of project.conversations) {
6925
7261
  if (!imports.has(conversation.path)) {
6926
7262
  const name = `conversations_${index++}`;
6927
- const importPath = getImportPath(dest, path30.join(project.path, conversation.path));
7263
+ const importPath = getImportPath(dest, path32.join(project.path, conversation.path));
6928
7264
  imports.set(conversation.path, {
6929
7265
  name,
6930
7266
  statement: `import * as ${name} from "${importPath}";`
@@ -6950,14 +7286,14 @@ declare module "@botpress/runtime/_types/state" {
6950
7286
  await createFile(dest, await formatCode(content2));
6951
7287
  }
6952
7288
  {
6953
- const dest = path30.join(srcDir, "knowledge.ts");
7289
+ const dest = path32.join(srcDir, "knowledge.ts");
6954
7290
  const imports = new Map;
6955
7291
  const exports = new Set;
6956
7292
  let index = 1;
6957
7293
  for (const knowledge of project.knowledge) {
6958
7294
  if (!imports.has(knowledge.path)) {
6959
7295
  const name = `knowledge_${index++}`;
6960
- const importPath = getImportPath(dest, path30.join(project.path, knowledge.path));
7296
+ const importPath = getImportPath(dest, path32.join(project.path, knowledge.path));
6961
7297
  imports.set(knowledge.path, {
6962
7298
  name,
6963
7299
  statement: `import * as ${name} from "${importPath}";`
@@ -6983,7 +7319,7 @@ declare module "@botpress/runtime/_types/state" {
6983
7319
  await createFile(dest, await formatCode(content2));
6984
7320
  }
6985
7321
  {
6986
- const dest = path30.join(srcDir, "triggers.ts");
7322
+ const dest = path32.join(srcDir, "triggers.ts");
6987
7323
  const { transforms: transforms4 } = await import("@botpress/sdk");
6988
7324
  const imports = new Map;
6989
7325
  const exports = new Set;
@@ -6992,7 +7328,7 @@ declare module "@botpress/runtime/_types/state" {
6992
7328
  for (const trigger of project.triggers) {
6993
7329
  if (!imports.has(trigger.path)) {
6994
7330
  const name = `triggers_${index++}`;
6995
- const importPath = getImportPath(dest, path30.join(project.path, trigger.path));
7331
+ const importPath = getImportPath(dest, path32.join(project.path, trigger.path));
6996
7332
  imports.set(trigger.path, {
6997
7333
  name,
6998
7334
  statement: `import * as ${name} from "${importPath}";`
@@ -7002,7 +7338,7 @@ declare module "@botpress/runtime/_types/state" {
7002
7338
  }
7003
7339
  for (const trigger of project.triggers) {
7004
7340
  try {
7005
- const absolutePath = path30.join(project.path, trigger.path);
7341
+ const absolutePath = path32.join(project.path, trigger.path);
7006
7342
  const triggerModule = await import(`${absolutePath}?t=${Date.now()}`);
7007
7343
  const triggerInstance = triggerModule[trigger.export] || triggerModule.default;
7008
7344
  if (triggerInstance && triggerInstance.payload) {
@@ -7045,7 +7381,7 @@ declare module "@botpress/runtime/_types/state" {
7045
7381
  await createFile(dest, await formatCode(content2));
7046
7382
  }
7047
7383
  {
7048
- const dest = path30.join(srcDir, "workflows.ts");
7384
+ const dest = path32.join(srcDir, "workflows.ts");
7049
7385
  const imports = new Map;
7050
7386
  const exports = new Set;
7051
7387
  let index = 1;
@@ -7055,7 +7391,7 @@ declare module "@botpress/runtime/_types/state" {
7055
7391
  }
7056
7392
  if (!imports.has(workflow.path)) {
7057
7393
  const name = `workflows_${index++}`;
7058
- const importPath = getImportPath(dest, path30.join(project.path, workflow.path));
7394
+ const importPath = getImportPath(dest, path32.join(project.path, workflow.path));
7059
7395
  const statement = `import * as ${name} from "${importPath}";`;
7060
7396
  imports.set(workflow.path, {
7061
7397
  name,
@@ -7089,7 +7425,7 @@ declare module "@botpress/runtime/_types/state" {
7089
7425
  await createFile(dest, await formatCode(content2));
7090
7426
  }
7091
7427
  {
7092
- const dest = path30.join(srcDir, "actions.ts");
7428
+ const dest = path32.join(srcDir, "actions.ts");
7093
7429
  const imports = new Map;
7094
7430
  const exports = new Set;
7095
7431
  let index = 1;
@@ -7099,7 +7435,7 @@ declare module "@botpress/runtime/_types/state" {
7099
7435
  }
7100
7436
  if (!imports.has(action.path)) {
7101
7437
  const name = `actions_${index++}`;
7102
- const importPath = getImportPath(dest, path30.join(project.path, action.path));
7438
+ const importPath = getImportPath(dest, path32.join(project.path, action.path));
7103
7439
  imports.set(action.path, {
7104
7440
  name,
7105
7441
  statement: `import * as ${name} from "${importPath}";`
@@ -7125,14 +7461,14 @@ declare module "@botpress/runtime/_types/state" {
7125
7461
  await createFile(dest, await formatCode(content2));
7126
7462
  }
7127
7463
  {
7128
- const dest = path30.join(srcDir, "tables.ts");
7464
+ const dest = path32.join(srcDir, "tables.ts");
7129
7465
  const imports = new Map;
7130
7466
  const exports = new Set;
7131
7467
  let index = 1;
7132
7468
  for (const table of project.tables) {
7133
7469
  if (!imports.has(table.path)) {
7134
7470
  const name = `tables_${index++}`;
7135
- const importPath = getImportPath(dest, path30.join(project.path, table.path));
7471
+ const importPath = getImportPath(dest, path32.join(project.path, table.path));
7136
7472
  imports.set(table.path, {
7137
7473
  name,
7138
7474
  statement: `import * as ${name} from "${importPath}";`
@@ -7158,8 +7494,8 @@ declare module "@botpress/runtime/_types/state" {
7158
7494
  await createFile(dest, await formatCode(content2));
7159
7495
  }
7160
7496
  {
7161
- const dest = path30.join(srcDir, "config.ts");
7162
- const importPath = getImportPath(dest, path30.join(project.path, "agent.config.ts"));
7497
+ const dest = path32.join(srcDir, "config.ts");
7498
+ const importPath = getImportPath(dest, path32.join(project.path, "agent.config.ts"));
7163
7499
  const content2 = `
7164
7500
  ////////////////////////////////////////////////////////
7165
7501
  // DO NOT EDIT THIS FILE DIRECTLY
@@ -7225,13 +7561,13 @@ declare module "@botpress/runtime/_types/state" {
7225
7561
  handlers.actions.setup(bot);
7226
7562
  }
7227
7563
  `;
7228
- await createFile(path30.join(this.outputPath, "src", "adk-runtime.ts"), await formatCode(content));
7564
+ await createFile(path32.join(this.outputPath, "src", "adk-runtime.ts"), await formatCode(content));
7229
7565
  }
7230
7566
  async copyAssetsRuntime() {
7231
- const assetsRuntimePath = path30.join(this.projectPath, ".adk", "assets-runtime.ts");
7567
+ const assetsRuntimePath = path32.join(this.projectPath, ".adk", "assets-runtime.ts");
7232
7568
  if (existsSync6(assetsRuntimePath)) {
7233
7569
  const content = await fs15.readFile(assetsRuntimePath, "utf-8");
7234
- await createFile(path30.join(this.outputPath, "src", "assets-runtime.ts"), await formatCode(content));
7570
+ await createFile(path32.join(this.outputPath, "src", "assets-runtime.ts"), await formatCode(content));
7235
7571
  }
7236
7572
  }
7237
7573
  }
@@ -7240,9 +7576,9 @@ async function generateBotProject(options) {
7240
7576
  await generator.generate();
7241
7577
  await generator.generateAdkRuntime();
7242
7578
  await generator.copyAssetsRuntime();
7243
- const devIdManager = new DevIdManager(options.projectPath, options.outputPath || path30.join(options.projectPath, ".adk", "bot"));
7579
+ const devIdManager = new DevIdManager(options.projectPath, options.outputPath || path32.join(options.projectPath, ".adk", "bot"));
7244
7580
  await devIdManager.restoreDevId();
7245
- const integrationSync = new IntegrationSync(options.projectPath, options.outputPath || path30.join(options.projectPath, ".adk", "bot"));
7581
+ const integrationSync = new IntegrationSync(options.projectPath, options.outputPath || path32.join(options.projectPath, ".adk", "bot"));
7246
7582
  const integrationSyncResult = await integrationSync.syncIntegrations();
7247
7583
  if (integrationSyncResult.errors.length > 0) {
7248
7584
  console.warn(`⚠️ Some integrations failed to sync:`);
@@ -7250,7 +7586,7 @@ async function generateBotProject(options) {
7250
7586
  console.warn(` - ${alias}: ${error}`);
7251
7587
  });
7252
7588
  }
7253
- const interfaceSync = new InterfaceSync(options.projectPath, options.outputPath || path30.join(options.projectPath, ".adk", "bot"));
7589
+ const interfaceSync = new InterfaceSync(options.projectPath, options.outputPath || path32.join(options.projectPath, ".adk", "bot"));
7254
7590
  const interfaceSyncResult = await interfaceSync.syncInterfaces();
7255
7591
  if (interfaceSyncResult.errors.length > 0) {
7256
7592
  console.warn(`⚠️ Some interfaces failed to sync:`);
@@ -7260,7 +7596,7 @@ async function generateBotProject(options) {
7260
7596
  }
7261
7597
  }
7262
7598
  // src/tables/table-manager.ts
7263
- import { Client as Client11 } from "@botpress/client";
7599
+ import { Client as Client12 } from "@botpress/client";
7264
7600
  import { transforms as transforms4 } from "@botpress/sdk";
7265
7601
  class TableManager {
7266
7602
  client;
@@ -7274,7 +7610,7 @@ class TableManager {
7274
7610
  if (!this.client) {
7275
7611
  const credentials = await auth.getActiveCredentials();
7276
7612
  this.assertBotId("initialize client");
7277
- this.client = new Client11({
7613
+ this.client = new Client12({
7278
7614
  token: credentials.token,
7279
7615
  apiUrl: credentials.apiUrl,
7280
7616
  botId: this.botId,
@@ -7738,10 +8074,10 @@ class TableManager {
7738
8074
  }
7739
8075
  // src/knowledge/manager.ts
7740
8076
  import crypto4 from "crypto";
7741
- import path31 from "path";
8077
+ import path33 from "path";
7742
8078
  import fs16 from "fs/promises";
7743
8079
  import { glob } from "glob";
7744
- import { Client as Client12 } from "@botpress/client";
8080
+ import { Client as Client13 } from "@botpress/client";
7745
8081
  import { DataSource } from "@botpress/runtime";
7746
8082
 
7747
8083
  // src/knowledge/types.ts
@@ -7785,7 +8121,7 @@ class KnowledgeManager {
7785
8121
  if (!this.client) {
7786
8122
  const credentials = await auth.getActiveCredentials();
7787
8123
  this.assertBotId("initialize client");
7788
- this.client = new Client12({
8124
+ this.client = new Client13({
7789
8125
  token: credentials.token,
7790
8126
  apiUrl: credentials.apiUrl,
7791
8127
  botId: this.botId,
@@ -8128,14 +8464,14 @@ class KnowledgeManager {
8128
8464
  }
8129
8465
  async scanLocalFileHashes(directoryPath, filterFn) {
8130
8466
  const projectDir = this.project.path;
8131
- const directory = path31.resolve(projectDir, directoryPath);
8467
+ const directory = path33.resolve(projectDir, directoryPath);
8132
8468
  if (this.fileHashCache.has(directory)) {
8133
8469
  return this.fileHashCache.get(directory);
8134
8470
  }
8135
8471
  const files = glob.sync(directory + "/**/*.*", { absolute: true, nodir: true }).filter((file) => !filterFn || filterFn(file));
8136
8472
  const hashes = {};
8137
8473
  for (const file of files) {
8138
- const relPath = path31.relative(directory, file);
8474
+ const relPath = path33.relative(directory, file);
8139
8475
  const content = await fs16.readFile(file);
8140
8476
  hashes[relPath] = crypto4.createHash("sha256").update(content).digest("hex");
8141
8477
  }
@@ -8240,7 +8576,7 @@ class KnowledgeManager {
8240
8576
  }
8241
8577
  async syncDirectorySource(client, kbName, sourceId, directoryPath, filterFn, force) {
8242
8578
  const projectDir = this.project.path;
8243
- const directory = path31.resolve(projectDir, directoryPath);
8579
+ const directory = path33.resolve(projectDir, directoryPath);
8244
8580
  if (!directory.startsWith(projectDir)) {
8245
8581
  throw new Error("Directory path must be within the agent's directory");
8246
8582
  }
@@ -8261,8 +8597,8 @@ class KnowledgeManager {
8261
8597
  return true;
8262
8598
  }).map((f) => ({
8263
8599
  abs: f,
8264
- rel: path31.relative(directory, f),
8265
- name: path31.basename(f)
8600
+ rel: path33.relative(directory, f),
8601
+ name: path33.basename(f)
8266
8602
  }));
8267
8603
  console.log(` Found ${allFiles.length} files in ${directoryPath}`);
8268
8604
  const cachedHashes = await this.scanLocalFileHashes(directoryPath, filterFn);
@@ -8334,7 +8670,7 @@ class KnowledgeManager {
8334
8670
  return null;
8335
8671
  }
8336
8672
  } catch {}
8337
- const title = path31.basename(local.name, path31.extname(local.name));
8673
+ const title = path33.basename(local.name, path33.extname(local.name));
8338
8674
  const metadata = {
8339
8675
  hash,
8340
8676
  sourceId,
@@ -8598,8 +8934,8 @@ class FileWatcher2 extends EventEmitter3 {
8598
8934
  }
8599
8935
  }
8600
8936
  // src/preflight/checker.ts
8601
- import { Client as Client13 } from "@botpress/client";
8602
- import path32 from "path";
8937
+ import { Client as Client14 } from "@botpress/client";
8938
+ import path34 from "path";
8603
8939
 
8604
8940
  // src/preflight/types.ts
8605
8941
  function hasIntegrationChanges(integrations) {
@@ -8813,7 +9149,7 @@ class PreflightChecker {
8813
9149
  if (!workspaceId) {
8814
9150
  throw new Error('No workspace ID found. Please login with "adk login"');
8815
9151
  }
8816
- this.client = new Client13({
9152
+ this.client = new Client14({
8817
9153
  token: credentials.token,
8818
9154
  apiUrl: credentials.apiUrl,
8819
9155
  workspaceId,
@@ -8961,7 +9297,7 @@ class PreflightChecker {
8961
9297
  options?.onProgress?.("Regenerating bot project...");
8962
9298
  await generateBotProject({
8963
9299
  projectPath: this.projectPath,
8964
- outputPath: path32.join(this.projectPath, ".adk", "bot")
9300
+ outputPath: path34.join(this.projectPath, ".adk", "bot")
8965
9301
  });
8966
9302
  options?.onSuccess?.("Bot project regenerated");
8967
9303
  }
@@ -9005,6 +9341,8 @@ export {
9005
9341
  FileWatcher2 as FileWatcher,
9006
9342
  EnhancedInterfaceCache,
9007
9343
  DevIdManager,
9344
+ CredentialsManager,
9345
+ ConfigManager,
9008
9346
  BpDevCommand,
9009
9347
  BpDeployCommand,
9010
9348
  BpChatCommand,
@@ -9020,5 +9358,5 @@ export {
9020
9358
  AgentProject
9021
9359
  };
9022
9360
 
9023
- //# debugId=172A55A72F67A32A64756E2164756E21
9361
+ //# debugId=DE1D2CDC9130C9B064756E2164756E21
9024
9362
  //# sourceMappingURL=index.js.map