@botpress/adk 1.2.4 → 1.3.0

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
@@ -241,7 +241,7 @@ var exports_action_types = {};
241
241
  __export(exports_action_types, {
242
242
  generateActionTypes: () => generateActionTypes
243
243
  });
244
- import path26 from "path";
244
+ import path27 from "path";
245
245
  async function generateActionTypes(project) {
246
246
  const actionDefs = [];
247
247
  for (const action of project.actions) {
@@ -249,7 +249,7 @@ async function generateActionTypes(project) {
249
249
  continue;
250
250
  }
251
251
  try {
252
- const absolutePath = path26.join(project.path, action.path);
252
+ const absolutePath = path27.join(project.path, action.path);
253
253
  const actionModule = await import(`${absolutePath}?t=${Date.now()}`);
254
254
  const actionInstance = actionModule[action.export] || actionModule.default;
255
255
  if (actionInstance && actionInstance.input && actionInstance.output) {
@@ -294,7 +294,7 @@ ${actionDefs.join(`
294
294
  };
295
295
  }
296
296
  `;
297
- const actionTypesPath = path26.join(project.path, ".adk", "action-types.d.ts");
297
+ const actionTypesPath = path27.join(project.path, ".adk", "action-types.d.ts");
298
298
  await createFile(actionTypesPath, await formatCode(content));
299
299
  }
300
300
  var init_action_types = __esm(() => {
@@ -307,7 +307,7 @@ var exports_integration_action_types = {};
307
307
  __export(exports_integration_action_types, {
308
308
  generateIntegrationActionTypes: () => generateIntegrationActionTypes
309
309
  });
310
- import path27 from "path";
310
+ import path28 from "path";
311
311
  async function generateIntegrationActionTypes(project) {
312
312
  const content = `
313
313
  ////////////////////////////////////////////////////////
@@ -317,6 +317,8 @@ async function generateIntegrationActionTypes(project) {
317
317
  // Generated at: ${new Date().toISOString()}
318
318
  ////////////////////////////////////////////////////////
319
319
 
320
+ type Integrations = import("@botpress/runtime/_types/integrations").Integrations;
321
+
320
322
  declare module "@botpress/runtime/_types/integration-actions" {
321
323
 
322
324
  export interface CallableAction<I, O> {
@@ -339,7 +341,7 @@ type IntegrationsMap<T> = {
339
341
  export type IntegrationActions = IntegrationsMap<Integrations>;
340
342
  }
341
343
  `;
342
- const integrationActionTypesPath = path27.join(project.path, ".adk", "integration-action-types.d.ts");
344
+ const integrationActionTypesPath = path28.join(project.path, ".adk", "integration-action-types.d.ts");
343
345
  await createFile(integrationActionTypesPath, await formatCode(content));
344
346
  }
345
347
  var init_integration_action_types = __esm(() => {
@@ -4136,6 +4138,15 @@ class AgentProject {
4136
4138
  console.warn(`Failed to register data source workflows for ${kbPath}:`, error);
4137
4139
  }
4138
4140
  }
4141
+ getChannelsList(channelSpec) {
4142
+ if (channelSpec === "*") {
4143
+ return ["*"];
4144
+ } else if (Array.isArray(channelSpec)) {
4145
+ return channelSpec;
4146
+ } else {
4147
+ return [channelSpec];
4148
+ }
4149
+ }
4139
4150
  async loadAgentPrimitives() {
4140
4151
  if (this._options.adkCommand) {
4141
4152
  setAdkCommand(this._options.adkCommand);
@@ -4201,13 +4212,17 @@ class AgentProject {
4201
4212
  throw error;
4202
4213
  }
4203
4214
  if (Primitives2.Definitions.isConversationDefinition(definition)) {
4204
- const existing = this._conversations.find((p) => p.definition.channel === definition.channel);
4205
- if (existing) {
4215
+ const overlapping = this._conversations.find((p) => {
4216
+ const existingChannels = this.getChannelsList(p.definition.channel);
4217
+ const newChannels = this.getChannelsList(definition.channel);
4218
+ return existingChannels.some((ch) => newChannels.includes(ch));
4219
+ });
4220
+ if (overlapping) {
4206
4221
  this._warnings.push({
4207
4222
  $type: "ValidationError",
4208
4223
  code: "DUPLICATE_PRIMITIVE" /* DUPLICATE_PRIMITIVE */,
4209
4224
  severity: "warning" /* WARNING */,
4210
- message: `Duplicate conversation definition found: ${filename} -> ${key} (already defined in ${existing.path} -> ${existing.export})`,
4225
+ message: `Overlapping conversation channels found: ${filename} -> ${key} overlaps with ${overlapping.path} -> ${overlapping.export}`,
4211
4226
  file: relPath
4212
4227
  });
4213
4228
  continue;
@@ -4961,7 +4976,7 @@ Description: ${tag?.description}`);
4961
4976
  import dedent from "dedent";
4962
4977
  import { existsSync as existsSync5 } from "fs";
4963
4978
  import fs15 from "fs/promises";
4964
- import path28 from "path";
4979
+ import path29 from "path";
4965
4980
 
4966
4981
  // src/generators/interface-types.ts
4967
4982
  import { transforms as transforms2 } from "@botpress/sdk";
@@ -5341,10 +5356,78 @@ ${typeDefinitions || " // No workflows defined yet"}
5341
5356
  await createFile(workflowTypesPath, await formatCode(content));
5342
5357
  }
5343
5358
 
5344
- // src/generators/event-types.ts
5359
+ // src/generators/conversation-types.ts
5345
5360
  init_utils();
5346
5361
  init_fs();
5347
5362
  import path22 from "path";
5363
+ async function generateConversationTypes(project) {
5364
+ const conversationTypes = {};
5365
+ for (const conversationRef of project.conversations) {
5366
+ console.log(`[ConversationTypes] Processing conversation: ${conversationRef.export}`);
5367
+ try {
5368
+ const conversationPath = path22.join(project.path, conversationRef.path);
5369
+ const conversationModule = await import(`${conversationPath}?t=${Date.now()}`);
5370
+ const conversationInstance = conversationModule[conversationRef.export] || conversationModule.default;
5371
+ if (!conversationInstance) {
5372
+ continue;
5373
+ }
5374
+ const channel = conversationInstance.channel;
5375
+ const stateType = conversationInstance.schema ? conversationInstance.schema.toTypescriptType?.() || "any" : "{}";
5376
+ let channels;
5377
+ if (channel === "*") {
5378
+ channels = ["*"];
5379
+ } else if (Array.isArray(channel)) {
5380
+ channels = channel;
5381
+ } else {
5382
+ channels = [channel];
5383
+ }
5384
+ for (const ch of channels) {
5385
+ conversationTypes[ch] = {
5386
+ channel: ch,
5387
+ state: stateType
5388
+ };
5389
+ }
5390
+ } catch (error) {
5391
+ console.error(`Failed to process conversation ${conversationRef.export}:`, error);
5392
+ }
5393
+ }
5394
+ const channelDefinitions = Object.entries(conversationTypes).filter(([channel]) => channel !== "*").map(([channel, info]) => {
5395
+ const [integration, channelName] = channel.split(".");
5396
+ return ` "${channel}": {
5397
+ channel: "${channel}";
5398
+ integration: "${integration}";
5399
+ state: ${info.state};
5400
+ tags: Integrations["${integration}"]["channels"]["${channelName}"]["conversation"]["tags"];
5401
+ messageTags: Integrations["${integration}"]["channels"]["${channelName}"]["message"]["tags"];
5402
+ messages: Integrations["${integration}"]["channels"]["${channelName}"]["messages"];
5403
+ events: Integrations["${integration}"]["events"];
5404
+ };`;
5405
+ }).join(`
5406
+ `);
5407
+ const content = `
5408
+ ////////////////////////////////////////////////////////
5409
+ // DO NOT EDIT THIS FILE DIRECTLY
5410
+ // This file is auto-generated from the Botpress ADK
5411
+ // ADK Version: ${ADK_VERSION}
5412
+ // Generated at: ${new Date().toISOString()}
5413
+ ////////////////////////////////////////////////////////
5414
+
5415
+ type Integrations = import("@botpress/runtime/_types/integrations").Integrations;
5416
+
5417
+ declare module "@botpress/runtime/_types/conversations" {
5418
+ export type ConversationDefinitions = {
5419
+ ${channelDefinitions || " // No conversations defined yet"}
5420
+ };
5421
+ }
5422
+ `;
5423
+ const conversationTypesPath = path22.join(project.path, ".adk", "conversation-types.d.ts");
5424
+ await createFile(conversationTypesPath, await formatCode(content));
5425
+ }
5426
+
5427
+ // src/generators/event-types.ts
5428
+ init_utils();
5429
+ init_fs();
5430
+ import path23 from "path";
5348
5431
  async function generateEventTypes(project) {
5349
5432
  const integrationEvents = [];
5350
5433
  for (const int of project.integrations) {
@@ -5360,6 +5443,8 @@ async function generateEventTypes(project) {
5360
5443
  // Generated at: ${new Date().toISOString()}
5361
5444
  ////////////////////////////////////////////////////////
5362
5445
 
5446
+ type Integrations = import("@botpress/runtime/_types/integrations").Integrations;
5447
+
5363
5448
  declare module "@botpress/runtime/_types/events" {
5364
5449
  /**
5365
5450
  * Global Events type that includes all integration events.
@@ -5381,7 +5466,7 @@ ${integrationEvents.join(`
5381
5466
  export type EventPayload<T extends EventName> = Events[T];
5382
5467
  }
5383
5468
  `;
5384
- const eventTypesPath = path22.join(project.path, ".adk", "event-types.d.ts");
5469
+ const eventTypesPath = path23.join(project.path, ".adk", "event-types.d.ts");
5385
5470
  await createFile(eventTypesPath, await formatCode(content));
5386
5471
  }
5387
5472
 
@@ -5389,7 +5474,7 @@ ${integrationEvents.join(`
5389
5474
  init_fs();
5390
5475
 
5391
5476
  // src/bot-generator/dev-id-manager.ts
5392
- import path23 from "path";
5477
+ import path24 from "path";
5393
5478
  import fs12 from "fs/promises";
5394
5479
  import { existsSync as existsSync2 } from "fs";
5395
5480
  import { Client as Client9 } from "@botpress/client";
@@ -5401,7 +5486,7 @@ class DevIdManager {
5401
5486
  constructor(projectPath, botProjectPath) {
5402
5487
  this.projectPath = projectPath;
5403
5488
  this.botProjectPath = botProjectPath;
5404
- this.projectCachePath = path23.join(botProjectPath, ".botpress", "project.cache.json");
5489
+ this.projectCachePath = path24.join(botProjectPath, ".botpress", "project.cache.json");
5405
5490
  }
5406
5491
  async getClient() {
5407
5492
  if (!this.client) {
@@ -5435,7 +5520,7 @@ class DevIdManager {
5435
5520
  }
5436
5521
  async saveProjectCache(cache2) {
5437
5522
  try {
5438
- await fs12.mkdir(path23.dirname(this.projectCachePath), { recursive: true });
5523
+ await fs12.mkdir(path24.dirname(this.projectCachePath), { recursive: true });
5439
5524
  await fs12.writeFile(this.projectCachePath, JSON.stringify(cache2, null, 2));
5440
5525
  } catch (error) {
5441
5526
  console.error("Error saving project.cache.json:", error);
@@ -5489,7 +5574,7 @@ class DevIdManager {
5489
5574
  }
5490
5575
 
5491
5576
  // src/bot-generator/integration-sync.ts
5492
- import path24 from "path";
5577
+ import path25 from "path";
5493
5578
  import fs13 from "fs/promises";
5494
5579
  import { existsSync as existsSync3 } from "fs";
5495
5580
  class IntegrationSync {
@@ -5499,7 +5584,7 @@ class IntegrationSync {
5499
5584
  constructor(projectPath, botProjectPath) {
5500
5585
  this.projectPath = projectPath;
5501
5586
  this.botProjectPath = botProjectPath;
5502
- this.bpModulesPath = path24.join(botProjectPath, "bp_modules");
5587
+ this.bpModulesPath = path25.join(botProjectPath, "bp_modules");
5503
5588
  }
5504
5589
  async parseIntegrations() {
5505
5590
  const project = await AgentProject.load(this.projectPath);
@@ -5530,12 +5615,12 @@ class IntegrationSync {
5530
5615
  return integrations;
5531
5616
  }
5532
5617
  async isIntegrationSynced(integration) {
5533
- const targetFolder = path24.join(this.bpModulesPath, `integration_${integration.alias}`);
5618
+ const targetFolder = path25.join(this.bpModulesPath, `integration_${integration.alias}`);
5534
5619
  if (!existsSync3(targetFolder)) {
5535
5620
  return false;
5536
5621
  }
5537
5622
  try {
5538
- const indexPath = path24.join(targetFolder, "index.ts");
5623
+ const indexPath = path25.join(targetFolder, "index.ts");
5539
5624
  if (!existsSync3(indexPath)) {
5540
5625
  return false;
5541
5626
  }
@@ -5568,8 +5653,8 @@ class IntegrationSync {
5568
5653
  }
5569
5654
  async renameIntegrationFolder(integration) {
5570
5655
  console.log(integration.name, integration.alias);
5571
- const sourceFolder = path24.join(this.bpModulesPath, integration.name.replace("/", "-"));
5572
- const targetFolder = path24.join(this.bpModulesPath, `integration_${integration.alias}`);
5656
+ const sourceFolder = path25.join(this.bpModulesPath, integration.name.replace("/", "-"));
5657
+ const targetFolder = path25.join(this.bpModulesPath, `integration_${integration.alias}`);
5573
5658
  if (!existsSync3(sourceFolder)) {
5574
5659
  throw new Error(`Integration folder not found: ${sourceFolder}`);
5575
5660
  }
@@ -5579,7 +5664,7 @@ class IntegrationSync {
5579
5664
  await fs13.rename(sourceFolder, targetFolder);
5580
5665
  }
5581
5666
  async removeIntegrationFolder(alias) {
5582
- const targetFolder = path24.join(this.bpModulesPath, `integration_${alias}`);
5667
+ const targetFolder = path25.join(this.bpModulesPath, `integration_${alias}`);
5583
5668
  if (existsSync3(targetFolder)) {
5584
5669
  await fs13.rm(targetFolder, { recursive: true, force: true });
5585
5670
  }
@@ -5613,7 +5698,7 @@ class IntegrationSync {
5613
5698
  }
5614
5699
 
5615
5700
  // src/bot-generator/interface-sync.ts
5616
- import path25 from "path";
5701
+ import path26 from "path";
5617
5702
  import fs14 from "fs/promises";
5618
5703
  import { existsSync as existsSync4 } from "fs";
5619
5704
  import { spawn } from "child_process";
@@ -5624,7 +5709,7 @@ class InterfaceSync {
5624
5709
  constructor(projectPath, botProjectPath) {
5625
5710
  this.projectPath = projectPath;
5626
5711
  this.botProjectPath = botProjectPath;
5627
- this.bpModulesPath = path25.join(botProjectPath, "bp_modules");
5712
+ this.bpModulesPath = path26.join(botProjectPath, "bp_modules");
5628
5713
  }
5629
5714
  async parseInterfaces() {
5630
5715
  const interfaces = [];
@@ -5642,12 +5727,12 @@ class InterfaceSync {
5642
5727
  return interfaces;
5643
5728
  }
5644
5729
  async isInterfaceSynced(interfaceInfo) {
5645
- const targetFolder = path25.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
5730
+ const targetFolder = path26.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
5646
5731
  if (!existsSync4(targetFolder)) {
5647
5732
  return false;
5648
5733
  }
5649
5734
  try {
5650
- const indexPath = path25.join(targetFolder, "index.ts");
5735
+ const indexPath = path26.join(targetFolder, "index.ts");
5651
5736
  if (!existsSync4(indexPath)) {
5652
5737
  return false;
5653
5738
  }
@@ -5710,8 +5795,8 @@ class InterfaceSync {
5710
5795
  });
5711
5796
  }
5712
5797
  async renameInterfaceFolder(interfaceInfo) {
5713
- const sourceFolder = path25.join(this.bpModulesPath, interfaceInfo.name);
5714
- const targetFolder = path25.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
5798
+ const sourceFolder = path26.join(this.bpModulesPath, interfaceInfo.name);
5799
+ const targetFolder = path26.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
5715
5800
  if (!existsSync4(sourceFolder)) {
5716
5801
  throw new Error(`Interface folder not found: ${sourceFolder}`);
5717
5802
  }
@@ -5721,7 +5806,7 @@ class InterfaceSync {
5721
5806
  await fs14.rename(sourceFolder, targetFolder);
5722
5807
  }
5723
5808
  async removeInterfaceFolder(alias) {
5724
- const targetFolder = path25.join(this.bpModulesPath, `interface_${pascalCase(alias)}`);
5809
+ const targetFolder = path26.join(this.bpModulesPath, `interface_${pascalCase(alias)}`);
5725
5810
  if (existsSync4(targetFolder)) {
5726
5811
  await fs14.rm(targetFolder, { recursive: true, force: true });
5727
5812
  }
@@ -5769,8 +5854,8 @@ class BotGenerator {
5769
5854
  projectPath;
5770
5855
  outputPath;
5771
5856
  constructor(options) {
5772
- this.projectPath = path28.resolve(options.projectPath);
5773
- this.outputPath = path28.resolve(options.outputPath || path28.join(this.projectPath, ".adk"));
5857
+ this.projectPath = path29.resolve(options.projectPath);
5858
+ this.outputPath = path29.resolve(options.outputPath || path29.join(this.projectPath, ".adk"));
5774
5859
  }
5775
5860
  async listFilesRecursive(rootDir) {
5776
5861
  try {
@@ -5780,8 +5865,8 @@ class BotGenerator {
5780
5865
  const walk = async (dir, relativeBase) => {
5781
5866
  const entries = await fs15.readdir(dir, { withFileTypes: true });
5782
5867
  for (const entry of entries) {
5783
- const abs = path28.join(dir, entry.name);
5784
- const rel = path28.join(relativeBase, entry.name);
5868
+ const abs = path29.join(dir, entry.name);
5869
+ const rel = path29.join(relativeBase, entry.name);
5785
5870
  if (entry.isDirectory()) {
5786
5871
  await walk(abs, rel);
5787
5872
  } else {
@@ -5802,7 +5887,7 @@ class BotGenerator {
5802
5887
  const entries = await fs15.readdir(dir, { withFileTypes: true });
5803
5888
  for (const entry of entries) {
5804
5889
  if (entry.isDirectory()) {
5805
- const subdir = path28.join(dir, entry.name);
5890
+ const subdir = path29.join(dir, entry.name);
5806
5891
  await removeIfEmpty(subdir);
5807
5892
  }
5808
5893
  }
@@ -5827,6 +5912,7 @@ class BotGenerator {
5827
5912
  await this.generateTriggerTypes();
5828
5913
  await this.generateStateTypes();
5829
5914
  await this.generateWorkflowTypes();
5915
+ await this.generateConversationTypes();
5830
5916
  await this.generateActionTypes();
5831
5917
  await this.generateEventTypes();
5832
5918
  await this.generateIntegrationActionTypes();
@@ -5841,19 +5927,18 @@ class BotGenerator {
5841
5927
  const project = await AgentProject.load(this.projectPath);
5842
5928
  const manager2 = new IntegrationManager;
5843
5929
  const integrations = await manager2.loadIntegrations(project.dependencies || {});
5844
- const integrationsDir = path28.join(this.projectPath, ".adk", "integrations");
5930
+ const integrationsDir = path29.join(this.projectPath, ".adk", "integrations");
5845
5931
  const existingIntegrationFiles = await this.listFilesRecursive(integrationsDir);
5846
- let imports = new Set;
5847
5932
  let aliases = new Set;
5848
5933
  let files = new Set;
5849
5934
  for (const integration of integrations.integrations) {
5850
5935
  if (integration.enabled && integration.definition) {
5851
5936
  const types6 = await generateIntegrationTypes(integration);
5852
- imports.add(`import { ${types6.names.typings.index} } from "./${path28.join("integrations", types6.names.paths.index)}";`);
5853
- aliases.add(`"${integration.alias}": ${types6.names.typings.index}`);
5937
+ const importPath = `./${path29.join("integrations", types6.names.paths.index)}`;
5938
+ aliases.add(`"${integration.alias}": import("${importPath}").${types6.names.typings.index}`);
5854
5939
  for (const [filePath, content] of Object.entries(types6.files)) {
5855
- const fullPath = path28.join(this.projectPath, ".adk", "integrations", filePath);
5856
- const dir = path28.dirname(fullPath);
5940
+ const fullPath = path29.join(this.projectPath, ".adk", "integrations", filePath);
5941
+ const dir = path29.dirname(fullPath);
5857
5942
  await fs15.mkdir(dir, { recursive: true });
5858
5943
  await createFile(fullPath, content);
5859
5944
  files.add(filePath);
@@ -5867,20 +5952,17 @@ class BotGenerator {
5867
5952
  // File: integrations.ts
5868
5953
  ////////////////////////////////////////////////////////
5869
5954
 
5870
- ${Array.from(imports).join(`
5871
- `)}
5872
-
5873
- declare global {
5955
+ declare module "@botpress/runtime/_types/integrations" {
5874
5956
  export type Integrations = {
5875
5957
  ${Array.from(aliases).join(`, `)}
5876
5958
  };
5877
5959
  }
5878
5960
  `;
5879
- await createFile(path28.join(this.projectPath, ".adk", "integrations.d.ts"), await formatCode(types5));
5961
+ await createFile(path29.join(this.projectPath, ".adk", "integrations.d.ts"), await formatCode(types5));
5880
5962
  const staleIntegrationFiles = existingIntegrationFiles.filter((f) => !files.has(f));
5881
5963
  if (staleIntegrationFiles.length > 0) {
5882
5964
  for (const rel of staleIntegrationFiles) {
5883
- const abs = path28.join(integrationsDir, rel);
5965
+ const abs = path29.join(integrationsDir, rel);
5884
5966
  try {
5885
5967
  await fs15.rm(abs, { force: true });
5886
5968
  } catch {}
@@ -5908,6 +5990,10 @@ class BotGenerator {
5908
5990
  const project = await AgentProject.load(this.projectPath);
5909
5991
  await generateWorkflowTypes(project);
5910
5992
  }
5993
+ async generateConversationTypes() {
5994
+ const project = await AgentProject.load(this.projectPath);
5995
+ await generateConversationTypes(project);
5996
+ }
5911
5997
  async generateActionTypes() {
5912
5998
  const project = await AgentProject.load(this.projectPath);
5913
5999
  const { generateActionTypes: generateActionTypes2 } = await Promise.resolve().then(() => (init_action_types(), exports_action_types));
@@ -5920,10 +6006,22 @@ class BotGenerator {
5920
6006
  }
5921
6007
  async generateRuntimeTypes() {
5922
6008
  const project = await AgentProject.load(this.projectPath);
6009
+ const manager2 = new IntegrationManager;
6010
+ const integrations = await manager2.loadIntegrations(project.dependencies || {});
6011
+ const channels = [];
6012
+ for (const integration of integrations.integrations) {
6013
+ if (integration.enabled && integration.definition) {
6014
+ const alias = integration.alias;
6015
+ for (const channelName of Object.keys(integration.definition.channels || {})) {
6016
+ channels.push(`"${alias}.${channelName}"`);
6017
+ }
6018
+ }
6019
+ }
6020
+ const channelsType = channels.length > 0 ? channels.join(" | ") : "never";
5923
6021
  let botStateType = "{}";
5924
6022
  let userStateType = "{}";
5925
6023
  try {
5926
- const configPath = path28.join(project.path, "agent.config.ts");
6024
+ const configPath = path29.join(project.path, "agent.config.ts");
5927
6025
  const configModule = await import(`${configPath}?t=${Date.now()}`);
5928
6026
  const config = configModule.default;
5929
6027
  if (config?.bot?.state) {
@@ -5949,38 +6047,23 @@ class BotGenerator {
5949
6047
  // Generated at: ${new Date().toISOString()}
5950
6048
  ////////////////////////////////////////////////////////
5951
6049
 
5952
- import { Primitives, ZuiType } from "@botpress/runtime";
5953
-
5954
- declare module "@botpress/runtime" {
5955
- export type Channels = {
5956
- [K in keyof Integrations]: {
5957
- [C in keyof Integrations[K]["channels"]]: C extends string
5958
- ? \`\${K}.\${C}\`
5959
- : never;
5960
- }[keyof Integrations[K]["channels"]];
5961
- }[keyof Integrations];
5962
-
5963
- export class Conversation<
5964
- T extends Channels = Channels,
5965
- Schema extends ZuiType = ZuiType,
5966
- > extends Primitives.BaseConversation<Integrations, T, Schema> {}
5967
-
6050
+ declare module "@botpress/runtime/_types/channels" {
6051
+ export type Channels = ${channelsType};
6052
+ export type ChannelSpec = Channels | readonly Channels[] | '*';
5968
6053
  }
5969
6054
 
5970
6055
  declare module "@botpress/runtime/_types/state" {
5971
6056
  export type BotState = ${botStateType};
5972
6057
  export type UserState = ${userStateType};
5973
6058
  }
5974
-
5975
- export {};
5976
6059
  `;
5977
- await createFile(path28.join(this.projectPath, ".adk", "runtime.d.ts"), await formatCode(types5));
6060
+ await createFile(path29.join(this.projectPath, ".adk", "runtime.d.ts"), await formatCode(types5));
5978
6061
  }
5979
6062
  async generateInterfacesTypes() {
5980
6063
  const project = await AgentProject.load(this.projectPath);
5981
6064
  const integrationManager = new IntegrationManager;
5982
6065
  const manager2 = new InterfaceManager;
5983
- const interfacesDir = path28.join(this.projectPath, ".adk", "interfaces");
6066
+ const interfacesDir = path29.join(this.projectPath, ".adk", "interfaces");
5984
6067
  const existingInterfaceFiles = await this.listFilesRecursive(interfacesDir);
5985
6068
  const interfaces = await manager2.loadInterfaces(project.dependencies || {}).then((result) => result.interfaces.filter((int) => int.definition).map((x) => x.definition));
5986
6069
  const integrations = await integrationManager.loadIntegrations(project.dependencies || {}).then((result) => result.integrations.filter((int) => int.enabled && int.definition).map((x) => x.definition));
@@ -5989,11 +6072,11 @@ export {};
5989
6072
  let files = new Set;
5990
6073
  for (const int of interfaces) {
5991
6074
  const types6 = await generateInterfaceTypes(int, integrations);
5992
- imports.add(`import { ${types6.names.typings.index} } from "./${path28.join("interfaces", types6.names.paths.index)}";`);
6075
+ imports.add(`import { ${types6.names.typings.index} } from "./${path29.join("interfaces", types6.names.paths.index)}";`);
5993
6076
  aliases.add(`"${types6.names.name}": ${types6.names.typings.index}`);
5994
6077
  for (const [filePath, content] of Object.entries(types6.files)) {
5995
- const fullPath = path28.join(this.projectPath, ".adk", "interfaces", filePath);
5996
- const dir = path28.dirname(fullPath);
6078
+ const fullPath = path29.join(this.projectPath, ".adk", "interfaces", filePath);
6079
+ const dir = path29.dirname(fullPath);
5997
6080
  await fs15.mkdir(dir, { recursive: true });
5998
6081
  await createFile(fullPath, content);
5999
6082
  files.add(filePath);
@@ -6030,12 +6113,12 @@ export {};
6030
6113
  `)}
6031
6114
  };
6032
6115
  `;
6033
- await createFile(path28.join(this.projectPath, ".adk", "interfaces.d.ts"), await formatCode(types5));
6034
- await createFile(path28.join(this.projectPath, ".adk", "interfaces.ts"), await formatCode(consts));
6116
+ await createFile(path29.join(this.projectPath, ".adk", "interfaces.d.ts"), await formatCode(types5));
6117
+ await createFile(path29.join(this.projectPath, ".adk", "interfaces.ts"), await formatCode(consts));
6035
6118
  const staleInterfaceFiles = existingInterfaceFiles.filter((f) => !files.has(f));
6036
6119
  if (staleInterfaceFiles.length > 0) {
6037
6120
  for (const rel of staleInterfaceFiles) {
6038
- const abs = path28.join(interfacesDir, rel);
6121
+ const abs = path29.join(interfacesDir, rel);
6039
6122
  try {
6040
6123
  await fs15.rm(abs, { force: true });
6041
6124
  } catch {}
@@ -6064,7 +6147,7 @@ export {};
6064
6147
  `) : ""}
6065
6148
  } as Record<string, IntegrationPackage>;
6066
6149
  `;
6067
- await createFile(path28.join(this.outputPath, "src", "integrations.ts"), content);
6150
+ await createFile(path29.join(this.outputPath, "src", "integrations.ts"), content);
6068
6151
  }
6069
6152
  async generateInterfacesDefinition() {
6070
6153
  const interfaces = BUILTIN_INTERFACES;
@@ -6087,7 +6170,7 @@ export {};
6087
6170
  `) : ""}
6088
6171
  } as Record<string, InterfacePackage>;
6089
6172
  `;
6090
- await createFile(path28.join(this.outputPath, "src", "interfaces.ts"), await formatCode(content));
6173
+ await createFile(path29.join(this.outputPath, "src", "interfaces.ts"), await formatCode(content));
6091
6174
  }
6092
6175
  async generateBotDefinition() {
6093
6176
  const project = await AgentProject.load(this.projectPath);
@@ -6121,7 +6204,7 @@ export {};
6121
6204
  if (isBuiltinWorkflow2(workflow.definition.name)) {
6122
6205
  continue;
6123
6206
  }
6124
- const workflowPath = path28.join(project.path, workflow.path);
6207
+ const workflowPath = path29.join(project.path, workflow.path);
6125
6208
  const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
6126
6209
  const workflowInstance = workflowModule.default || workflowModule[workflow.export];
6127
6210
  if (workflowInstance) {
@@ -6177,9 +6260,11 @@ export {};
6177
6260
  cached: def.cached
6178
6261
  };
6179
6262
  }
6263
+ const toEventName = (ename) => ename.replaceAll(/[^a-zA-Z0-9]/g, "").toLowerCase();
6180
6264
  const content = dedent`
6181
6265
  import { BotDefinition, z } from "@botpress/sdk";
6182
6266
  import {
6267
+ BUILT_IN_STATES,
6183
6268
  TranscriptSchema,
6184
6269
  TrackedStateSchema,
6185
6270
  WorkflowCallbackEvent,
@@ -6232,7 +6317,7 @@ export {};
6232
6317
  `)}
6233
6318
  },` : ""}
6234
6319
  ${recurringWorkflows.length > 0 ? `recurringEvents: {
6235
- ${recurringWorkflows.map((wf) => `"${wf.name}Schedule": {
6320
+ ${recurringWorkflows.map((wf) => `"${toEventName(wf.name + "Schedule")}": {
6236
6321
  type: WorkflowScheduleEvent.name,
6237
6322
  schedule: { cron: "${wf.schedule}" },
6238
6323
  payload: { workflow: "${wf.name}" },
@@ -6273,7 +6358,7 @@ export {};
6273
6358
  * This is defined by the users at build-time when they define conversations.
6274
6359
  * Because each conversation can have its own state schema, we use \`z.any()\`
6275
6360
  */
6276
- state: {
6361
+ [BUILT_IN_STATES.conversation]: {
6277
6362
  type: "conversation",
6278
6363
  schema: TrackedStateSchema,
6279
6364
  },
@@ -6281,7 +6366,7 @@ export {};
6281
6366
  /**
6282
6367
  * Bot-wide global state that persists across all conversations
6283
6368
  */
6284
- botState: {
6369
+ [BUILT_IN_STATES.bot]: {
6285
6370
  type: "bot",
6286
6371
  schema: TrackedStateSchema,
6287
6372
  },
@@ -6289,7 +6374,7 @@ export {};
6289
6374
  /**
6290
6375
  * User-specific state that persists across conversations for each user
6291
6376
  */
6292
- userState: {
6377
+ [BUILT_IN_STATES.user]: {
6293
6378
  type: "user",
6294
6379
  schema: TrackedStateSchema,
6295
6380
  },
@@ -6297,7 +6382,7 @@ export {};
6297
6382
  /**
6298
6383
  * Workflow-specific state that persists across workflow executions
6299
6384
  */
6300
- workflowState: {
6385
+ [BUILT_IN_STATES.workflowState]: {
6301
6386
  type: "workflow",
6302
6387
  schema: TrackedStateSchema,
6303
6388
  },
@@ -6305,7 +6390,7 @@ export {};
6305
6390
  /**
6306
6391
  * Workflow cached steps executions
6307
6392
  */
6308
- workflowSteps: {
6393
+ [BUILT_IN_STATES.workflowSteps]: {
6309
6394
  type: "workflow",
6310
6395
  schema: TrackedStateSchema,
6311
6396
  },
@@ -6319,7 +6404,7 @@ export {};
6319
6404
 
6320
6405
  export default bot;
6321
6406
  `;
6322
- await createFile(path28.join(this.outputPath, "bot.definition.ts"), await formatCode(content));
6407
+ await createFile(path29.join(this.outputPath, "bot.definition.ts"), await formatCode(content));
6323
6408
  }
6324
6409
  async generateBotIndex() {
6325
6410
  const project = await AgentProject.load(this.projectPath);
@@ -6362,7 +6447,7 @@ export {};
6362
6447
 
6363
6448
  export default bot
6364
6449
  `;
6365
- await createFile(path28.join(this.outputPath, "src", "index.ts"), await formatCode(content));
6450
+ await createFile(path29.join(this.outputPath, "src", "index.ts"), await formatCode(content));
6366
6451
  }
6367
6452
  async generatePackageJson(project) {
6368
6453
  const packageJson = {
@@ -6381,7 +6466,7 @@ export {};
6381
6466
  typescript: "^5.6.3"
6382
6467
  }
6383
6468
  };
6384
- await createFile(path28.join(this.outputPath, "package.json"), JSON.stringify(packageJson, null, 2));
6469
+ await createFile(path29.join(this.outputPath, "package.json"), JSON.stringify(packageJson, null, 2));
6385
6470
  }
6386
6471
  async generateTsConfig() {
6387
6472
  const tsConfig = {
@@ -6418,7 +6503,7 @@ export {};
6418
6503
  "./*.json"
6419
6504
  ]
6420
6505
  };
6421
- await createFile(path28.join(this.outputPath, "tsconfig.json"), JSON.stringify(tsConfig, null, 2));
6506
+ await createFile(path29.join(this.outputPath, "tsconfig.json"), JSON.stringify(tsConfig, null, 2));
6422
6507
  }
6423
6508
  async generateGlobalTypes() {
6424
6509
  const content = dedent`
@@ -6441,11 +6526,11 @@ export {};
6441
6526
 
6442
6527
  export {};
6443
6528
  `;
6444
- await createFile(path28.join(this.outputPath, "global.d.ts"), await formatCode(content));
6529
+ await createFile(path29.join(this.outputPath, "global.d.ts"), await formatCode(content));
6445
6530
  }
6446
6531
  async copyAssets() {
6447
- const assetsPath = path28.join(this.projectPath, "assets");
6448
- const targetPath = path28.join(this.outputPath, "assets");
6532
+ const assetsPath = path29.join(this.projectPath, "assets");
6533
+ const targetPath = path29.join(this.outputPath, "assets");
6449
6534
  if (existsSync5(assetsPath)) {
6450
6535
  await fs15.mkdir(targetPath, { recursive: true });
6451
6536
  await this.copyDirectory(assetsPath, targetPath);
@@ -6454,8 +6539,8 @@ export {};
6454
6539
  async copyDirectory(src, dest) {
6455
6540
  const entries = await fs15.readdir(src, { withFileTypes: true });
6456
6541
  for (const entry of entries) {
6457
- const srcPath = path28.join(src, entry.name);
6458
- const destPath = path28.join(dest, entry.name);
6542
+ const srcPath = path29.join(src, entry.name);
6543
+ const destPath = path29.join(dest, entry.name);
6459
6544
  if (entry.isDirectory()) {
6460
6545
  await fs15.mkdir(destPath, { recursive: true });
6461
6546
  await this.copyDirectory(srcPath, destPath);
@@ -6467,16 +6552,16 @@ export {};
6467
6552
  async generateAdkRuntime() {
6468
6553
  const project = new AgentProject(this.projectPath);
6469
6554
  await project.reload();
6470
- const srcDir = path28.join(this.outputPath, "src");
6555
+ const srcDir = path29.join(this.outputPath, "src");
6471
6556
  {
6472
- const dest = path28.join(srcDir, "conversations.ts");
6557
+ const dest = path29.join(srcDir, "conversations.ts");
6473
6558
  const imports = new Map;
6474
6559
  const exports = new Set;
6475
6560
  let index = 1;
6476
6561
  for (const conversation of project.conversations) {
6477
6562
  if (!imports.has(conversation.path)) {
6478
6563
  const name = `conversations_${index++}`;
6479
- const importPath = path28.relative(path28.dirname(dest), path28.join(project.path, conversation.path)).replace(/\.ts$/, "");
6564
+ const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, conversation.path)).replace(/\.ts$/, "");
6480
6565
  imports.set(conversation.path, {
6481
6566
  name,
6482
6567
  statement: `import * as ${name} from "${importPath}";`
@@ -6502,14 +6587,14 @@ export {};
6502
6587
  await createFile(dest, await formatCode(content2));
6503
6588
  }
6504
6589
  {
6505
- const dest = path28.join(srcDir, "knowledge.ts");
6590
+ const dest = path29.join(srcDir, "knowledge.ts");
6506
6591
  const imports = new Map;
6507
6592
  const exports = new Set;
6508
6593
  let index = 1;
6509
6594
  for (const knowledge of project.knowledge) {
6510
6595
  if (!imports.has(knowledge.path)) {
6511
6596
  const name = `knowledge_${index++}`;
6512
- const importPath = path28.relative(path28.dirname(dest), path28.join(project.path, knowledge.path)).replace(/\.ts$/, "");
6597
+ const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, knowledge.path)).replace(/\.ts$/, "");
6513
6598
  imports.set(knowledge.path, {
6514
6599
  name,
6515
6600
  statement: `import * as ${name} from "${importPath}";`
@@ -6535,7 +6620,7 @@ export {};
6535
6620
  await createFile(dest, await formatCode(content2));
6536
6621
  }
6537
6622
  {
6538
- const dest = path28.join(srcDir, "triggers.ts");
6623
+ const dest = path29.join(srcDir, "triggers.ts");
6539
6624
  const { transforms: transforms4 } = await import("@botpress/sdk");
6540
6625
  const imports = new Map;
6541
6626
  const exports = new Set;
@@ -6544,7 +6629,7 @@ export {};
6544
6629
  for (const trigger of project.triggers) {
6545
6630
  if (!imports.has(trigger.path)) {
6546
6631
  const name = `triggers_${index++}`;
6547
- const importPath = path28.relative(path28.dirname(dest), path28.join(project.path, trigger.path)).replace(/\.ts$/, "");
6632
+ const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, trigger.path)).replace(/\.ts$/, "");
6548
6633
  imports.set(trigger.path, {
6549
6634
  name,
6550
6635
  statement: `import * as ${name} from "${importPath}";`
@@ -6554,7 +6639,7 @@ export {};
6554
6639
  }
6555
6640
  for (const trigger of project.triggers) {
6556
6641
  try {
6557
- const absolutePath = path28.join(project.path, trigger.path);
6642
+ const absolutePath = path29.join(project.path, trigger.path);
6558
6643
  const triggerModule = await import(`${absolutePath}?t=${Date.now()}`);
6559
6644
  const triggerInstance = triggerModule[trigger.export] || triggerModule.default;
6560
6645
  if (triggerInstance && triggerInstance.payload) {
@@ -6597,7 +6682,7 @@ export {};
6597
6682
  await createFile(dest, await formatCode(content2));
6598
6683
  }
6599
6684
  {
6600
- const dest = path28.join(srcDir, "workflows.ts");
6685
+ const dest = path29.join(srcDir, "workflows.ts");
6601
6686
  const imports = new Map;
6602
6687
  const exports = new Set;
6603
6688
  let index = 1;
@@ -6607,7 +6692,7 @@ export {};
6607
6692
  }
6608
6693
  if (!imports.has(workflow.path)) {
6609
6694
  const name = `workflows_${index++}`;
6610
- const importPath = path28.relative(path28.dirname(dest), path28.join(project.path, workflow.path)).replace(/\.ts$/, "");
6695
+ const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, workflow.path)).replace(/\.ts$/, "");
6611
6696
  const statement = `import * as ${name} from "${importPath}";`;
6612
6697
  imports.set(workflow.path, {
6613
6698
  name,
@@ -6641,14 +6726,14 @@ export {};
6641
6726
  await createFile(dest, await formatCode(content2));
6642
6727
  }
6643
6728
  {
6644
- const dest = path28.join(srcDir, "actions.ts");
6729
+ const dest = path29.join(srcDir, "actions.ts");
6645
6730
  const imports = new Map;
6646
6731
  const exports = new Set;
6647
6732
  let index = 1;
6648
6733
  for (const action of project.actions) {
6649
6734
  if (!imports.has(action.path)) {
6650
6735
  const name = `actions_${index++}`;
6651
- const importPath = path28.relative(path28.dirname(dest), path28.join(project.path, action.path)).replace(/\.ts$/, "");
6736
+ const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, action.path)).replace(/\.ts$/, "");
6652
6737
  imports.set(action.path, {
6653
6738
  name,
6654
6739
  statement: `import * as ${name} from "${importPath}";`
@@ -6674,14 +6759,14 @@ export {};
6674
6759
  await createFile(dest, await formatCode(content2));
6675
6760
  }
6676
6761
  {
6677
- const dest = path28.join(srcDir, "tables.ts");
6762
+ const dest = path29.join(srcDir, "tables.ts");
6678
6763
  const imports = new Map;
6679
6764
  const exports = new Set;
6680
6765
  let index = 1;
6681
6766
  for (const table of project.tables) {
6682
6767
  if (!imports.has(table.path)) {
6683
6768
  const name = `tables_${index++}`;
6684
- const importPath = path28.relative(path28.dirname(dest), path28.join(project.path, table.path)).replace(/\.ts$/, "");
6769
+ const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, table.path)).replace(/\.ts$/, "");
6685
6770
  imports.set(table.path, {
6686
6771
  name,
6687
6772
  statement: `import * as ${name} from "${importPath}";`
@@ -6707,8 +6792,8 @@ export {};
6707
6792
  await createFile(dest, await formatCode(content2));
6708
6793
  }
6709
6794
  {
6710
- const dest = path28.join(srcDir, "config.ts");
6711
- const importPath = path28.relative(path28.dirname(dest), path28.join(project.path, "agent.config.ts")).replace(/\.ts$/, "");
6795
+ const dest = path29.join(srcDir, "config.ts");
6796
+ const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, "agent.config.ts")).replace(/\.ts$/, "");
6712
6797
  const content2 = `
6713
6798
  ////////////////////////////////////////////////////////
6714
6799
  // DO NOT EDIT THIS FILE DIRECTLY
@@ -6773,13 +6858,13 @@ export {};
6773
6858
  handlers.workflow.setup(bot);
6774
6859
  }
6775
6860
  `;
6776
- await createFile(path28.join(this.outputPath, "src", "adk-runtime.ts"), await formatCode(content));
6861
+ await createFile(path29.join(this.outputPath, "src", "adk-runtime.ts"), await formatCode(content));
6777
6862
  }
6778
6863
  async copyAssetsRuntime() {
6779
- const assetsRuntimePath = path28.join(this.projectPath, ".adk", "assets-runtime.ts");
6864
+ const assetsRuntimePath = path29.join(this.projectPath, ".adk", "assets-runtime.ts");
6780
6865
  if (existsSync5(assetsRuntimePath)) {
6781
6866
  const content = await fs15.readFile(assetsRuntimePath, "utf-8");
6782
- await createFile(path28.join(this.outputPath, "src", "assets-runtime.ts"), await formatCode(content));
6867
+ await createFile(path29.join(this.outputPath, "src", "assets-runtime.ts"), await formatCode(content));
6783
6868
  }
6784
6869
  }
6785
6870
  }
@@ -6788,9 +6873,9 @@ async function generateBotProject(options) {
6788
6873
  await generator.generate();
6789
6874
  await generator.generateAdkRuntime();
6790
6875
  await generator.copyAssetsRuntime();
6791
- const devIdManager = new DevIdManager(options.projectPath, options.outputPath || path28.join(options.projectPath, ".adk", "bot"));
6876
+ const devIdManager = new DevIdManager(options.projectPath, options.outputPath || path29.join(options.projectPath, ".adk", "bot"));
6792
6877
  await devIdManager.restoreDevId();
6793
- const integrationSync = new IntegrationSync(options.projectPath, options.outputPath || path28.join(options.projectPath, ".adk", "bot"));
6878
+ const integrationSync = new IntegrationSync(options.projectPath, options.outputPath || path29.join(options.projectPath, ".adk", "bot"));
6794
6879
  const integrationSyncResult = await integrationSync.syncIntegrations();
6795
6880
  if (integrationSyncResult.errors.length > 0) {
6796
6881
  console.warn(`⚠️ Some integrations failed to sync:`);
@@ -6798,7 +6883,7 @@ async function generateBotProject(options) {
6798
6883
  console.warn(` - ${alias}: ${error}`);
6799
6884
  });
6800
6885
  }
6801
- const interfaceSync = new InterfaceSync(options.projectPath, options.outputPath || path28.join(options.projectPath, ".adk", "bot"));
6886
+ const interfaceSync = new InterfaceSync(options.projectPath, options.outputPath || path29.join(options.projectPath, ".adk", "bot"));
6802
6887
  const interfaceSyncResult = await interfaceSync.syncInterfaces();
6803
6888
  if (interfaceSyncResult.errors.length > 0) {
6804
6889
  console.warn(`⚠️ Some interfaces failed to sync:`);
@@ -7193,5 +7278,5 @@ export {
7193
7278
  AgentProject
7194
7279
  };
7195
7280
 
7196
- //# debugId=78C3235DFD64E97C64756E2164756E21
7281
+ //# debugId=97BD5BDF5EE523BE64756E2164756E21
7197
7282
  //# sourceMappingURL=index.js.map