@botpress/adk 2.0.1-beta.2 → 2.0.1-beta.4

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
@@ -4801,7 +4801,7 @@ var _format = null, _formatLoaded = false, formatCode = async (code, filepath) =
4801
4801
  `));
4802
4802
  return code;
4803
4803
  }
4804
- }, ADK_VERSION = "2.0.1-beta.2", relative = (from, to) => {
4804
+ }, ADK_VERSION = "2.0.1-beta.4", relative = (from, to) => {
4805
4805
  const fromDir = path14.dirname(from);
4806
4806
  const relative2 = path14.relative(fromDir, to);
4807
4807
  return relative2.startsWith(".") ? relative2 : `./${relative2}`;
@@ -15754,84 +15754,6 @@ caused by: ` + e.fullStack(i);
15754
15754
  module.exports = r5();
15755
15755
  });
15756
15756
 
15757
- // src/generators/action-types.ts
15758
- var exports_action_types = {};
15759
- __export(exports_action_types, {
15760
- generateActionTypes: () => generateActionTypes
15761
- });
15762
- import { z as z9 } from "@botpress/sdk";
15763
- import path41 from "path";
15764
- async function generateActionTypes(project) {
15765
- const actionDefs = [];
15766
- for (const action of project.actions) {
15767
- if (action.definition.attributes?.visibility === "hidden") {
15768
- continue;
15769
- }
15770
- try {
15771
- if (action.path === "<adk:builtin>") {
15772
- const inputType = action.definition.input ? transforms5.fromJSONSchema(action.definition.input).toTypescriptType({ treatDefaultAsOptional: true }) : "{}";
15773
- const outputType = action.definition.output ? transforms5.fromJSONSchema(action.definition.output).toTypescriptType() : "{}";
15774
- actionDefs.push(` "${action.definition.name}": {
15775
- input: ${inputType};
15776
- output: ${outputType};
15777
- };`);
15778
- continue;
15779
- }
15780
- const absolutePath = path41.join(project.path, action.path);
15781
- const actionModule = await import(`${absolutePath}?t=${Date.now()}`);
15782
- const actionInstance = actionModule[action.export] || actionModule.default;
15783
- if (actionInstance && actionInstance.input && actionInstance.output) {
15784
- const inputType = actionInstance.input.toTypescriptType ? actionInstance.input.toTypescriptType() : "any";
15785
- const outputType = actionInstance.output.toTypescriptType ? actionInstance.output.toTypescriptType() : "any";
15786
- actionDefs.push(` "${action.definition.name}": {
15787
- input: ${inputType};
15788
- output: ${outputType};
15789
- };`);
15790
- }
15791
- } catch (error) {
15792
- console.warn(`Warning: Could not process action ${action.definition.name}:`, error);
15793
- actionDefs.push(` "${action.definition.name}": {
15794
- input: any;
15795
- output: any;
15796
- };`);
15797
- }
15798
- }
15799
- const content = `
15800
- ////////////////////////////////////////////////////////
15801
- // DO NOT EDIT THIS FILE DIRECTLY
15802
- // This file is auto-generated from the Botpress ADK
15803
- // ADK Version: ${ADK_VERSION}
15804
- // Generated at: ${new Date().toISOString()}
15805
- ////////////////////////////////////////////////////////
15806
-
15807
- declare module "@botpress/runtime/_types/actions" {
15808
-
15809
- export interface CallableAction<I, O> {
15810
- (input: I): Promise<O>;
15811
- asTool(): import("@botpress/runtime").Autonomous.Tool;
15812
- }
15813
-
15814
- export type BotActionDefinitions = {
15815
- ${actionDefs.join(`
15816
- `)}
15817
- };
15818
-
15819
- export type BotActions = {
15820
- [K in keyof BotActionDefinitions]:
15821
- CallableAction<BotActionDefinitions[K]["input"], BotActionDefinitions[K]["output"]>
15822
- };
15823
- }
15824
- `;
15825
- const actionTypesPath = path41.join(project.path, ".adk", "action-types.d.ts");
15826
- await createFile(actionTypesPath, await formatCode(content));
15827
- }
15828
- var transforms5;
15829
- var init_action_types = __esm(() => {
15830
- init_utils();
15831
- init_fs();
15832
- ({ transforms: transforms5 } = z9);
15833
- });
15834
-
15835
15757
  // src/generators/integration-action-types.ts
15836
15758
  var exports_integration_action_types = {};
15837
15759
  __export(exports_integration_action_types, {
@@ -15883,7 +15805,7 @@ var init_integration_action_types = __esm(() => {
15883
15805
  var require_package = __commonJS((exports, module) => {
15884
15806
  module.exports = {
15885
15807
  name: "@botpress/adk",
15886
- version: "2.0.1-beta.2",
15808
+ version: "2.0.1-beta.4",
15887
15809
  description: "Core ADK library for building AI agents on Botpress",
15888
15810
  keywords: [
15889
15811
  "adk",
@@ -15944,7 +15866,7 @@ var require_package = __commonJS((exports, module) => {
15944
15866
  "@botpress/cli": "~6.8.6",
15945
15867
  "@botpress/client": "~1.46.0",
15946
15868
  "@botpress/cognitive": "~0.6.0",
15947
- "@botpress/runtime": "^2.0.1-beta.2",
15869
+ "@botpress/runtime": "^2.0.1-beta.4",
15948
15870
  "@botpress/sdk": "~6.11.1",
15949
15871
  "@bpinternal/jex": "^1.2.4",
15950
15872
  "@bpinternal/yargs-extra": "^0.0.21",
@@ -19986,78 +19908,597 @@ if (typeof globalThis !== 'undefined') {
19986
19908
  await createFile(runtimePath, emptyRuntimeCode);
19987
19909
  }
19988
19910
  }
19989
- // src/generators/integration-types.ts
19990
- import { z as z5 } from "@botpress/sdk";
19991
- import crypto2 from "crypto";
19911
+ // src/generators/table-types.ts
19912
+ init_utils();
19913
+ init_fs();
19992
19914
  import path21 from "path";
19915
+ var stripUndefined = (type) => type.replace(/\s*\|\s*undefined\b/g, "");
19916
+ async function generateTableTypes(project) {
19917
+ const tables = [];
19918
+ for (const tableRef of project.tables) {
19919
+ try {
19920
+ const tablePath = path21.join(project.path, tableRef.path);
19921
+ const tableModule = await import(`${tablePath}?t=${Date.now()}`);
19922
+ const tableInstance = tableModule.default || tableModule[tableRef.export];
19923
+ if (tableInstance && tableInstance.columns) {
19924
+ const columns = {};
19925
+ for (const [colName, colDef] of Object.entries(tableInstance.columns)) {
19926
+ let schema;
19927
+ let computed = false;
19928
+ let searchable = false;
19929
+ if (typeof colDef === "object" && colDef !== null && "schema" in colDef) {
19930
+ schema = colDef.schema;
19931
+ computed = colDef.computed || false;
19932
+ searchable = colDef.searchable || false;
19933
+ } else {
19934
+ schema = colDef;
19935
+ }
19936
+ const tsType = schema.toTypescriptType ? schema.toTypescriptType() : "any";
19937
+ const optional = typeof schema.isOptional === "function" && schema.isOptional() || typeof schema.isNullable === "function" && schema.isNullable() || /\|\s*undefined\b/.test(tsType);
19938
+ columns[colName] = { type: tsType, computed, searchable, optional };
19939
+ }
19940
+ tables.push({
19941
+ name: tableRef.definition.name,
19942
+ columns
19943
+ });
19944
+ }
19945
+ } catch (error) {
19946
+ console.warn(`Failed to load table ${tableRef.definition.name}:`, error);
19947
+ }
19948
+ }
19949
+ let content = `
19950
+ ////////////////////////////////////////////////////////
19951
+ // DO NOT EDIT THIS FILE DIRECTLY
19952
+ // This file is auto-generated from the Botpress ADK
19953
+ // ADK Version: ${ADK_VERSION}
19954
+ // Generated at: ${new Date().toISOString()}
19955
+ ////////////////////////////////////////////////////////
19993
19956
 
19994
- // src/utils/strings.ts
19995
- function pascalCase(str) {
19996
- return str.split(/[-_\s]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
19997
- }
19998
- function camelCase(str) {
19999
- const pascal = pascalCase(str);
20000
- return pascal.charAt(0).toLowerCase() + pascal.slice(1);
19957
+ declare module "@botpress/runtime/_types/tables" {
19958
+ export type TableDefinitions = {
19959
+ `;
19960
+ if (tables.length === 0) {
19961
+ content += ` [key: string]: {
19962
+ `;
19963
+ content += ` Input: any;
19964
+ `;
19965
+ content += ` Output: {
19966
+ `;
19967
+ content += ` id: number;
19968
+ `;
19969
+ content += ` createdAt: string;
19970
+ `;
19971
+ content += ` updatedAt: string;
19972
+ `;
19973
+ content += ` } & any;
19974
+ `;
19975
+ content += ` };
19976
+ `;
19977
+ } else {
19978
+ for (const table of tables) {
19979
+ const inputColumns = Object.entries(table.columns).filter(([_, col]) => !col.computed).map(([name, col]) => ` ${name}${col.optional ? "?" : ""}: ${col.optional ? stripUndefined(col.type) : col.type};`).join(`
19980
+ `);
19981
+ const outputColumns = [
19982
+ " id: number;",
19983
+ " createdAt: string;",
19984
+ " updatedAt: string;",
19985
+ ...Object.entries(table.columns).map(([name, col]) => ` ${name}: ${col.type};`)
19986
+ ].join(`
19987
+ `);
19988
+ content += ` // Table: ${table.name}
19989
+ `;
19990
+ content += ` ${table.name}: {
19991
+ `;
19992
+ content += ` Input: {
19993
+ ${inputColumns}
19994
+ };
19995
+ `;
19996
+ content += ` Output: {
19997
+ ${outputColumns}
19998
+ };
19999
+ `;
20000
+ content += ` };
20001
+ `;
20002
+ }
20003
+ }
20004
+ content += ` };
20001
20005
  }
20002
- function snakeCase(str) {
20003
- return str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
20006
+ `;
20007
+ const tableTypesPath = path21.join(project.path, ".adk", "table-types.d.ts");
20008
+ await createFile(tableTypesPath, await formatCode(content));
20004
20009
  }
20005
20010
 
20006
- // src/generators/integration-types.ts
20011
+ // src/generators/state-types.ts
20007
20012
  init_utils();
20008
- var { transforms } = z5;
20009
- var getIntegrationHash = (integration) => {
20010
- return crypto2.createHash("sha256").update(`${integration.alias}|${integration.definition?.id}|${integration.definition?.version}|${integration.definition?.updatedAt}`).digest("hex");
20011
- };
20012
- var getPascalAlias = (integration) => pascalCase(getIntegrationAlias(integration.alias));
20013
- var getIntegrationNames = (integration) => ({
20014
- typings: {
20015
- index: `Integration_All_${getPascalAlias(integration)}`,
20016
- actions: `Integration_Actions_${getPascalAlias(integration)}`,
20017
- channels: `Integration_Channels_${getPascalAlias(integration)}`,
20018
- events: `Integration_Events_${getPascalAlias(integration)}`,
20019
- users: `Integration_Users_${getPascalAlias(integration)}`,
20020
- configurations: `Integration_Configurations_${getPascalAlias(integration)}`
20021
- },
20022
- paths: {
20023
- index: path21.join(snakeCase(getPascalAlias(integration)), `index.ts`),
20024
- actions: path21.join(snakeCase(getPascalAlias(integration)), `actions.ts`),
20025
- channels: path21.join(snakeCase(getPascalAlias(integration)), `channels.ts`),
20026
- events: path21.join(snakeCase(getPascalAlias(integration)), `events.ts`),
20027
- users: path21.join(snakeCase(getPascalAlias(integration)), `users.ts`),
20028
- configurations: path21.join(snakeCase(getPascalAlias(integration)), `configurations.ts`)
20013
+ init_fs();
20014
+ import path22 from "path";
20015
+ async function generateStateTypes(project) {
20016
+ let botStateType = "{}";
20017
+ let userStateType = "{}";
20018
+ try {
20019
+ const configPath = path22.join(project.path, "agent.config.ts");
20020
+ const configModule = await import(`${configPath}?t=${Date.now()}`);
20021
+ const config = configModule.default;
20022
+ if (config?.bot?.state) {
20023
+ const botSchema = config.bot.state;
20024
+ if (botSchema.toTypescriptType) {
20025
+ botStateType = botSchema.toTypescriptType();
20026
+ }
20027
+ }
20028
+ if (config?.user?.state) {
20029
+ const userSchema = config.user.state;
20030
+ if (userSchema.toTypescriptType) {
20031
+ userStateType = userSchema.toTypescriptType();
20032
+ }
20033
+ }
20034
+ } catch (error) {
20035
+ console.warn("Failed to load agent config for state types:", error);
20029
20036
  }
20030
- });
20031
- async function generateIntegrationTypes(integration) {
20032
- const names = getIntegrationNames(integration);
20033
- const hash = getIntegrationHash(integration);
20034
- const rel = (to) => {
20035
- const from = names.paths.index;
20036
- return relative(from, to).replace(/\.ts$/i, "");
20037
- };
20038
- let tIndex = `
20039
- ////////////////////////////////////////////////////////
20040
- // DO NOT EDIT THIS FILE DIRECTLY
20041
- // This file is auto-generated from the Botpress ADK
20042
- // ADK Version: ${ADK_VERSION}
20043
- // Integration: ${integration.definition?.name}
20044
- // Version: ${integration.definition?.version}
20045
- // File: ${names.paths.index}
20046
- // Hash: ${hash}
20047
- // Updated at: ${integration.definition?.updatedAt}
20048
- ////////////////////////////////////////////////////////
20049
-
20050
- import { Integration_Actions_${getPascalAlias(integration)} } from "${rel(names.paths.actions)}";
20051
- import { Integration_Channels_${getPascalAlias(integration)} } from "${rel(names.paths.channels)}";
20052
- import { Integration_Events_${getPascalAlias(integration)} } from "${rel(names.paths.events)}";
20053
- import { Integration_Users_${getPascalAlias(integration)} } from "${rel(names.paths.users)}";
20054
- import { Integration_Configurations_${getPascalAlias(integration)} } from "${rel(names.paths.configurations)}";
20037
+ const content = `
20038
+ ////////////////////////////////////////////////////////
20039
+ // DO NOT EDIT THIS FILE DIRECTLY
20040
+ // This file is auto-generated from the Botpress ADK
20041
+ // ADK Version: ${ADK_VERSION}
20042
+ // Generated at: ${new Date().toISOString()}
20043
+ ////////////////////////////////////////////////////////
20055
20044
 
20056
- export * from "${rel(names.paths.actions)}";
20057
- export * from "${rel(names.paths.channels)}";
20058
- export * from "${rel(names.paths.events)}";
20059
- export * from "${rel(names.paths.users)}";
20060
- export * from "${rel(names.paths.configurations)}";
20045
+ declare module "@botpress/runtime/_types/state" {
20046
+ export type BotState = ${botStateType};
20047
+ export type UserState = ${userStateType};
20048
+ }
20049
+ `;
20050
+ const stateTypesPath = path22.join(project.path, ".adk", "state-types.d.ts");
20051
+ await createFile(stateTypesPath, await formatCode(content));
20052
+ }
20053
+
20054
+ // src/generators/configuration-types.ts
20055
+ init_utils();
20056
+ init_fs();
20057
+ import path23 from "path";
20058
+ async function generateConfigurationTypes(project) {
20059
+ let configurationType = "{}";
20060
+ try {
20061
+ const configPath = path23.join(project.path, "agent.config.ts");
20062
+ const configModule = await import(`${configPath}?t=${Date.now()}`);
20063
+ const config = configModule.default;
20064
+ if (config?.configuration?.schema) {
20065
+ const configSchema = config.configuration.schema;
20066
+ if (configSchema.toTypescriptType) {
20067
+ configurationType = configSchema.toTypescriptType();
20068
+ }
20069
+ }
20070
+ } catch (error) {
20071
+ console.warn("Failed to load agent config for configuration types:", error);
20072
+ }
20073
+ const content = `
20074
+ ////////////////////////////////////////////////////////
20075
+ // DO NOT EDIT THIS FILE DIRECTLY
20076
+ // This file is auto-generated from the Botpress ADK
20077
+ // ADK Version: ${ADK_VERSION}
20078
+ // Generated at: ${new Date().toISOString()}
20079
+ ////////////////////////////////////////////////////////
20080
+
20081
+ declare module "@botpress/runtime/_types/configuration" {
20082
+ export type Configuration = ${configurationType};
20083
+ }
20084
+ `;
20085
+ const configTypesPath = path23.join(project.path, ".adk", "configuration-types.d.ts");
20086
+ await createFile(configTypesPath, await formatCode(content));
20087
+ }
20088
+
20089
+ // src/generators/secret-types.ts
20090
+ init_utils();
20091
+ init_fs();
20092
+ import path24 from "path";
20093
+ async function generateSecretTypes(project) {
20094
+ let secretsType = "{}";
20095
+ try {
20096
+ const configPath = path24.join(project.path, "agent.config.ts");
20097
+ const configModule = await import(`${configPath}?t=${Date.now()}`);
20098
+ const config = configModule.default;
20099
+ if (config?.secrets) {
20100
+ const secrets = config.secrets;
20101
+ const entries = Object.entries(secrets);
20102
+ if (entries.length > 0) {
20103
+ const props = entries.map(([key, def]) => {
20104
+ const type = def.optional ? "string | undefined" : "string";
20105
+ return ` ${JSON.stringify(key)}: ${type}`;
20106
+ });
20107
+ secretsType = `{
20108
+ ${props.join(`
20109
+ `)}
20110
+ }`;
20111
+ }
20112
+ }
20113
+ } catch (error) {
20114
+ console.warn("Failed to load agent config for secret types:", error);
20115
+ }
20116
+ const content = `
20117
+ ////////////////////////////////////////////////////////
20118
+ // DO NOT EDIT THIS FILE DIRECTLY
20119
+ // This file is auto-generated from the Botpress ADK
20120
+ // ADK Version: ${ADK_VERSION}
20121
+ // Generated at: ${new Date().toISOString()}
20122
+ ////////////////////////////////////////////////////////
20123
+
20124
+ declare module "@botpress/runtime/_types/secrets" {
20125
+ export type Secrets = ${secretsType};
20126
+ }
20127
+ `;
20128
+ const secretTypesPath = path24.join(project.path, ".adk", "secret-types.d.ts");
20129
+ await createFile(secretTypesPath, await formatCode(content));
20130
+ }
20131
+
20132
+ // src/generators/workflow-types.ts
20133
+ init_utils();
20134
+ init_fs();
20135
+ import * as path25 from "path";
20136
+ import { BuiltInWorkflows as BuiltInWorkflows2 } from "@botpress/runtime/internal";
20137
+ function isBuiltinWorkflow(name) {
20138
+ return !!Object.values(BuiltInWorkflows2).find((x) => x.name === name);
20139
+ }
20140
+ async function generateWorkflowTypes(project) {
20141
+ const workflows = [];
20142
+ for (const workflowRef of project.workflows) {
20143
+ try {
20144
+ if (isBuiltinWorkflow(workflowRef.definition.name)) {
20145
+ continue;
20146
+ }
20147
+ const workflowPath = path25.join(project.path, workflowRef.path);
20148
+ const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
20149
+ const workflowInstance = workflowModule[workflowRef.export] || workflowModule.default;
20150
+ if (!workflowInstance) {
20151
+ continue;
20152
+ }
20153
+ const inputType = workflowInstance.inputSchema ? workflowInstance.inputSchema.toTypescriptType?.() || "any" : "{}";
20154
+ const outputType = workflowInstance.outputSchema ? workflowInstance.outputSchema.toTypescriptType?.() || "any" : "{}";
20155
+ const stateType = workflowInstance.stateSchema ? workflowInstance.stateSchema.toTypescriptType?.() || "any" : "{}";
20156
+ let requestsType = "{}";
20157
+ const requestsSchemas = workflowInstance._requestsSchemas;
20158
+ if (requestsSchemas && Object.keys(requestsSchemas).length > 0) {
20159
+ const requestTypes = Object.entries(requestsSchemas).map(([key, schema]) => {
20160
+ const type = schema.toTypescriptType?.() || "any";
20161
+ return `${key}: ${type}`;
20162
+ }).join("; ");
20163
+ requestsType = `{ ${requestTypes} }`;
20164
+ }
20165
+ let notificationsType = "{}";
20166
+ const notificationsSchemas = workflowInstance._notificationsSchemas;
20167
+ if (notificationsSchemas && Object.keys(notificationsSchemas).length > 0) {
20168
+ const notificationTypes = Object.entries(notificationsSchemas).map(([key, schema]) => {
20169
+ const type = schema.toTypescriptType?.() || "any";
20170
+ return `${key}: ${type}`;
20171
+ }).join("; ");
20172
+ notificationsType = `{ ${notificationTypes} }`;
20173
+ }
20174
+ workflows.push({
20175
+ name: workflowRef.definition.name,
20176
+ input: inputType,
20177
+ output: outputType,
20178
+ state: stateType,
20179
+ requests: requestsType,
20180
+ notifications: notificationsType
20181
+ });
20182
+ } catch (error) {
20183
+ console.error(`Failed to process workflow ${workflowRef.definition.name}:`, error);
20184
+ }
20185
+ }
20186
+ const typeDefinitions = workflows.map((workflow) => ` ${workflow.name}: {
20187
+ input: ${workflow.input};
20188
+ output: ${workflow.output};
20189
+ state: ${workflow.state};
20190
+ requests: ${workflow.requests};
20191
+ notifications: ${workflow.notifications};
20192
+ tags: WorkflowTags;
20193
+ };`).join(`
20194
+ `);
20195
+ const content = `// Generated workflow type definitions
20196
+ // Do not edit this file directly - it will be overwritten
20197
+
20198
+ type WorkflowTags = import("@botpress/runtime/_types/tags").WorkflowTags;
20199
+
20200
+ declare module "@botpress/runtime/_types/workflows" {
20201
+ export type WorkflowDefinitions = {
20202
+ ${typeDefinitions || " // No workflows defined yet"}
20203
+ };
20204
+ }`;
20205
+ const workflowTypesPath = path25.join(project.path, ".adk", "workflow-types.d.ts");
20206
+ await createFile(workflowTypesPath, await formatCode(content));
20207
+ }
20208
+
20209
+ // src/generators/component-types.ts
20210
+ init_utils();
20211
+ init_fs();
20212
+ import path26 from "path";
20213
+ async function generateComponentTypes(project) {
20214
+ const components = project.customComponents;
20215
+ if (components.length === 0) {
20216
+ const content2 = `
20217
+ ////////////////////////////////////////////////////////
20218
+ // DO NOT EDIT THIS FILE DIRECTLY
20219
+ // This file is auto-generated from the Botpress ADK
20220
+ // ADK Version: ${ADK_VERSION}
20221
+ // Generated at: ${new Date().toISOString()}
20222
+ ////////////////////////////////////////////////////////
20223
+
20224
+ declare module "@botpress/runtime/_types/components" {
20225
+ export type CustomComponentMessage = never;
20226
+ }
20227
+ `;
20228
+ const typesPath2 = path26.join(project.path, ".adk", "component-types.d.ts");
20229
+ await createFile(typesPath2, await formatCode(content2));
20230
+ return;
20231
+ }
20232
+ const componentImports = [];
20233
+ const payloadUnionMembers = [];
20234
+ for (const comp of components) {
20235
+ const importPath = `../${comp.path.replace(/\.ts$/, "")}`;
20236
+ componentImports.push(`import("${importPath}").${comp.export}`);
20237
+ payloadUnionMembers.push(`{ component: import("${importPath}").${comp.export}; props: Parameters<import("${importPath}").${comp.export}["encode"]>[0] }`);
20238
+ }
20239
+ const content = `
20240
+ ////////////////////////////////////////////////////////
20241
+ // DO NOT EDIT THIS FILE DIRECTLY
20242
+ // This file is auto-generated from the Botpress ADK
20243
+ // ADK Version: ${ADK_VERSION}
20244
+ // Generated at: ${new Date().toISOString()}
20245
+ ////////////////////////////////////////////////////////
20246
+
20247
+ declare module "@botpress/runtime/_types/components" {
20248
+ export type CustomComponentMessage = ${payloadUnionMembers.join(`
20249
+ | `)};
20250
+ }
20251
+ `;
20252
+ const typesPath = path26.join(project.path, ".adk", "component-types.d.ts");
20253
+ await createFile(typesPath, await formatCode(content));
20254
+ }
20255
+
20256
+ // src/generators/tag-types.ts
20257
+ init_utils();
20258
+ init_fs();
20259
+ import path27 from "path";
20260
+ import { BUILT_IN_TAGS } from "@botpress/runtime/definition";
20261
+ function generateTagTypeString(builtInTags, configTags) {
20262
+ const builtInTagStrings = Object.entries(builtInTags).map(([key, tag]) => {
20263
+ const jsdoc = tag.description ? `/**
20264
+ * ${tag.title}
20265
+ *
20266
+ * ${tag.description}
20267
+ */
20268
+ ` : `/** ${tag.title} */
20269
+ `;
20270
+ return `${jsdoc}${key}?: string | undefined`;
20271
+ });
20272
+ const configTagStrings = configTags ? Object.entries(configTags).map(([key, tag]) => {
20273
+ const jsdoc = tag.description ? `/**
20274
+ * ${tag.title}
20275
+ *
20276
+ * ${tag.description}
20277
+ */
20278
+ ` : `/** ${tag.title} */
20279
+ `;
20280
+ return `${jsdoc}${key}?: string | undefined`;
20281
+ }) : [];
20282
+ const allTags = [...builtInTagStrings, ...configTagStrings];
20283
+ if (allTags.length === 0) {
20284
+ return "Record<string, string | undefined>";
20285
+ }
20286
+ return `{
20287
+ ${allTags.join(`
20288
+ `)}
20289
+ }`;
20290
+ }
20291
+ async function generateTagTypes(project) {
20292
+ let botTagsType = "Record<string, string | undefined>";
20293
+ let userTagsType = "Record<string, string | undefined>";
20294
+ let conversationTagsType = "Record<string, string | undefined>";
20295
+ let messageTagsType = "Record<string, string | undefined>";
20296
+ let workflowTagsType = "Record<string, string | undefined>";
20297
+ try {
20298
+ const configPath = path27.join(project.path, "agent.config.ts");
20299
+ const configModule = await import(`${configPath}?t=${Date.now()}`);
20300
+ const config = configModule.default;
20301
+ botTagsType = generateTagTypeString(BUILT_IN_TAGS.bot, config?.bot?.tags);
20302
+ userTagsType = generateTagTypeString(BUILT_IN_TAGS.user, config?.user?.tags);
20303
+ conversationTagsType = generateTagTypeString(BUILT_IN_TAGS.conversation, config?.conversation?.tags);
20304
+ messageTagsType = generateTagTypeString(BUILT_IN_TAGS.message, config?.message?.tags);
20305
+ workflowTagsType = generateTagTypeString(BUILT_IN_TAGS.workflow, config?.workflow?.tags);
20306
+ } catch (error) {
20307
+ console.warn("Failed to load agent config for tag types:", error);
20308
+ }
20309
+ const content = `
20310
+ ////////////////////////////////////////////////////////
20311
+ // DO NOT EDIT THIS FILE DIRECTLY
20312
+ // This file is auto-generated from the Botpress ADK
20313
+ // ADK Version: ${ADK_VERSION}
20314
+ // Generated at: ${new Date().toISOString()}
20315
+ ////////////////////////////////////////////////////////
20316
+
20317
+ declare module "@botpress/runtime/_types/tags" {
20318
+ /**
20319
+ * Bot-level tags defined in agent.config.ts
20320
+ */
20321
+ export type BotTags = ${botTagsType};
20322
+
20323
+ /**
20324
+ * User-level tags defined in agent.config.ts
20325
+ */
20326
+ export type UserTags = ${userTagsType};
20327
+
20328
+ /**
20329
+ * Conversation-level tags defined in agent.config.ts
20330
+ */
20331
+ export type ConversationTags = ${conversationTagsType};
20332
+
20333
+ /**
20334
+ * Message-level tags defined in agent.config.ts
20335
+ */
20336
+ export type MessageTags = ${messageTagsType};
20337
+
20338
+ /**
20339
+ * Workflow-level tags defined in agent.config.ts
20340
+ */
20341
+ export type WorkflowTags = ${workflowTagsType};
20342
+ }
20343
+ `;
20344
+ const tagTypesPath = path27.join(project.path, ".adk", "tag-types.d.ts");
20345
+ await createFile(tagTypesPath, await formatCode(content));
20346
+ }
20347
+
20348
+ // src/generators/action-types.ts
20349
+ init_utils();
20350
+ init_fs();
20351
+ import { z as z5 } from "@botpress/sdk";
20352
+ import path28 from "path";
20353
+ var { transforms } = z5;
20354
+ async function generateActionTypes(project) {
20355
+ const actionDefs = [];
20356
+ for (const action of project.actions) {
20357
+ if (action.definition.attributes?.visibility === "hidden") {
20358
+ continue;
20359
+ }
20360
+ try {
20361
+ if (action.path === "<adk:builtin>") {
20362
+ const inputType = action.definition.input ? transforms.fromJSONSchema(action.definition.input).toTypescriptType({ treatDefaultAsOptional: true }) : "{}";
20363
+ const outputType = action.definition.output ? transforms.fromJSONSchema(action.definition.output).toTypescriptType() : "{}";
20364
+ actionDefs.push(` "${action.definition.name}": {
20365
+ input: ${inputType};
20366
+ output: ${outputType};
20367
+ };`);
20368
+ continue;
20369
+ }
20370
+ const absolutePath = path28.join(project.path, action.path);
20371
+ const actionModule = await import(`${absolutePath}?t=${Date.now()}`);
20372
+ const actionInstance = actionModule[action.export] || actionModule.default;
20373
+ if (actionInstance && actionInstance.input && actionInstance.output) {
20374
+ const inputType = actionInstance.input.toTypescriptType ? actionInstance.input.toTypescriptType() : "any";
20375
+ const outputType = actionInstance.output.toTypescriptType ? actionInstance.output.toTypescriptType() : "any";
20376
+ actionDefs.push(` "${action.definition.name}": {
20377
+ input: ${inputType};
20378
+ output: ${outputType};
20379
+ };`);
20380
+ }
20381
+ } catch (error) {
20382
+ console.warn(`Warning: Could not process action ${action.definition.name}:`, error);
20383
+ actionDefs.push(` "${action.definition.name}": {
20384
+ input: any;
20385
+ output: any;
20386
+ };`);
20387
+ }
20388
+ }
20389
+ const content = `
20390
+ ////////////////////////////////////////////////////////
20391
+ // DO NOT EDIT THIS FILE DIRECTLY
20392
+ // This file is auto-generated from the Botpress ADK
20393
+ // ADK Version: ${ADK_VERSION}
20394
+ // Generated at: ${new Date().toISOString()}
20395
+ ////////////////////////////////////////////////////////
20396
+
20397
+ declare module "@botpress/runtime/_types/actions" {
20398
+
20399
+ export interface CallableAction<I, O> {
20400
+ (input: I): Promise<O>;
20401
+ asTool(): import("@botpress/runtime").Autonomous.Tool;
20402
+ }
20403
+
20404
+ export type BotActionDefinitions = {
20405
+ ${actionDefs.join(`
20406
+ `)}
20407
+ };
20408
+
20409
+ export type BotActions = {
20410
+ [K in keyof BotActionDefinitions]:
20411
+ CallableAction<BotActionDefinitions[K]["input"], BotActionDefinitions[K]["output"]>
20412
+ };
20413
+ }
20414
+ `;
20415
+ const actionTypesPath = path28.join(project.path, ".adk", "action-types.d.ts");
20416
+ await createFile(actionTypesPath, await formatCode(content));
20417
+ }
20418
+
20419
+ // src/generators/local-types.ts
20420
+ async function generateLocalTypes(project) {
20421
+ await generateTableTypes(project);
20422
+ await generateStateTypes(project);
20423
+ await generateConfigurationTypes(project);
20424
+ await generateSecretTypes(project);
20425
+ await generateWorkflowTypes(project);
20426
+ await generateComponentTypes(project);
20427
+ await generateTagTypes(project);
20428
+ await generateActionTypes(project);
20429
+ }
20430
+ // src/generators/integration-types.ts
20431
+ import { z as z6 } from "@botpress/sdk";
20432
+ import crypto2 from "crypto";
20433
+ import path29 from "path";
20434
+
20435
+ // src/utils/strings.ts
20436
+ function pascalCase(str) {
20437
+ return str.split(/[-_\s]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
20438
+ }
20439
+ function camelCase(str) {
20440
+ const pascal = pascalCase(str);
20441
+ return pascal.charAt(0).toLowerCase() + pascal.slice(1);
20442
+ }
20443
+ function snakeCase(str) {
20444
+ return str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
20445
+ }
20446
+
20447
+ // src/generators/integration-types.ts
20448
+ init_utils();
20449
+ var { transforms: transforms2 } = z6;
20450
+ var getIntegrationHash = (integration) => {
20451
+ return crypto2.createHash("sha256").update(`${integration.alias}|${integration.definition?.id}|${integration.definition?.version}|${integration.definition?.updatedAt}`).digest("hex");
20452
+ };
20453
+ var getPascalAlias = (integration) => pascalCase(getIntegrationAlias(integration.alias));
20454
+ var getIntegrationNames = (integration) => ({
20455
+ typings: {
20456
+ index: `Integration_All_${getPascalAlias(integration)}`,
20457
+ actions: `Integration_Actions_${getPascalAlias(integration)}`,
20458
+ channels: `Integration_Channels_${getPascalAlias(integration)}`,
20459
+ events: `Integration_Events_${getPascalAlias(integration)}`,
20460
+ users: `Integration_Users_${getPascalAlias(integration)}`,
20461
+ configurations: `Integration_Configurations_${getPascalAlias(integration)}`
20462
+ },
20463
+ paths: {
20464
+ index: path29.join(snakeCase(getPascalAlias(integration)), `index.ts`),
20465
+ actions: path29.join(snakeCase(getPascalAlias(integration)), `actions.ts`),
20466
+ channels: path29.join(snakeCase(getPascalAlias(integration)), `channels.ts`),
20467
+ events: path29.join(snakeCase(getPascalAlias(integration)), `events.ts`),
20468
+ users: path29.join(snakeCase(getPascalAlias(integration)), `users.ts`),
20469
+ configurations: path29.join(snakeCase(getPascalAlias(integration)), `configurations.ts`)
20470
+ }
20471
+ });
20472
+ async function generateIntegrationTypes(integration) {
20473
+ const names = getIntegrationNames(integration);
20474
+ const hash = getIntegrationHash(integration);
20475
+ const rel = (to) => {
20476
+ const from = names.paths.index;
20477
+ return relative(from, to).replace(/\.ts$/i, "");
20478
+ };
20479
+ let tIndex = `
20480
+ ////////////////////////////////////////////////////////
20481
+ // DO NOT EDIT THIS FILE DIRECTLY
20482
+ // This file is auto-generated from the Botpress ADK
20483
+ // ADK Version: ${ADK_VERSION}
20484
+ // Integration: ${integration.definition?.name}
20485
+ // Version: ${integration.definition?.version}
20486
+ // File: ${names.paths.index}
20487
+ // Hash: ${hash}
20488
+ // Updated at: ${integration.definition?.updatedAt}
20489
+ ////////////////////////////////////////////////////////
20490
+
20491
+ import { Integration_Actions_${getPascalAlias(integration)} } from "${rel(names.paths.actions)}";
20492
+ import { Integration_Channels_${getPascalAlias(integration)} } from "${rel(names.paths.channels)}";
20493
+ import { Integration_Events_${getPascalAlias(integration)} } from "${rel(names.paths.events)}";
20494
+ import { Integration_Users_${getPascalAlias(integration)} } from "${rel(names.paths.users)}";
20495
+ import { Integration_Configurations_${getPascalAlias(integration)} } from "${rel(names.paths.configurations)}";
20496
+
20497
+ export * from "${rel(names.paths.actions)}";
20498
+ export * from "${rel(names.paths.channels)}";
20499
+ export * from "${rel(names.paths.events)}";
20500
+ export * from "${rel(names.paths.users)}";
20501
+ export * from "${rel(names.paths.configurations)}";
20061
20502
 
20062
20503
  export type Integration_All_${getPascalAlias(integration)} = {
20063
20504
  actions: Integration_Actions_${getPascalAlias(integration)};
@@ -20081,8 +20522,8 @@ async function generateIntegrationTypes(integration) {
20081
20522
 
20082
20523
  export type Integration_Actions_${getPascalAlias(integration)} = {`;
20083
20524
  for (const [name, action] of Object.entries(integration.definition.actions)) {
20084
- const input = transforms.fromJSONSchema(action.input.schema).toTypescriptType();
20085
- const output = transforms.fromJSONSchema(action.output.schema).toTypescriptType();
20525
+ const input = transforms2.fromJSONSchema(action.input.schema).toTypescriptType();
20526
+ const output = transforms2.fromJSONSchema(action.output.schema).toTypescriptType();
20086
20527
  tActions += `
20087
20528
  ${toMultilineComment(`Title: ${action.title || name}
20088
20529
  Description: ${action.description || "No description"}`)}
@@ -20127,7 +20568,7 @@ Description: ${tag.description}`);
20127
20568
  }, "") + "}";
20128
20569
  let messagesBlock = "";
20129
20570
  for (const [messageName, messageDef] of Object.entries(channelDef.messages || {})) {
20130
- const messageType = transforms.fromJSONSchema(messageDef.schema).toTypescriptType();
20571
+ const messageType = transforms2.fromJSONSchema(messageDef.schema).toTypescriptType();
20131
20572
  messagesBlock += `
20132
20573
  "${messageName}": ${messageType};
20133
20574
  `;
@@ -20163,7 +20604,7 @@ Description: ${channelDef.description || "No description"}`)}
20163
20604
 
20164
20605
  export type Integration_Events_${getPascalAlias(integration)} = {`;
20165
20606
  for (const [eventName, event] of Object.entries(integration.definition.events || {})) {
20166
- const payloadType = transforms.fromJSONSchema(event.schema).toTypescriptType();
20607
+ const payloadType = transforms2.fromJSONSchema(event.schema).toTypescriptType();
20167
20608
  const attributesComment = Object.keys(event.attributes || {}).length ? `
20168
20609
  Attributes:
20169
20610
  ${Object.entries(event.attributes).map(([k, v]) => ` - ${k}: ${v}`).join(`
@@ -20224,7 +20665,7 @@ Description: ${tag?.description}`);
20224
20665
  const schema = defaultConfig.schema;
20225
20666
  let tsType = "{}";
20226
20667
  if (schema) {
20227
- tsType = transforms.fromJSONSchema(schema).toTypescriptType();
20668
+ tsType = transforms2.fromJSONSchema(schema).toTypescriptType();
20228
20669
  }
20229
20670
  const jsdocLines = ["/**"];
20230
20671
  jsdocLines.push(` * @title ${title}`);
@@ -20244,7 +20685,7 @@ Description: ${tag?.description}`);
20244
20685
  const schema = configRecord.schema;
20245
20686
  let tsType = "{}";
20246
20687
  if (schema) {
20247
- tsType = transforms.fromJSONSchema(schema).toTypescriptType();
20688
+ tsType = transforms2.fromJSONSchema(schema).toTypescriptType();
20248
20689
  }
20249
20690
  const jsdocLines = ["/**"];
20250
20691
  jsdocLines.push(` * @title ${title}`);
@@ -20280,14 +20721,14 @@ Description: ${tag?.description}`);
20280
20721
  // src/generators/client-wrapper.ts
20281
20722
  init_utils();
20282
20723
  init_fs();
20283
- import { z as z6 } from "@botpress/sdk";
20284
- import path22 from "path";
20724
+ import { z as z7 } from "@botpress/sdk";
20725
+ import path30 from "path";
20285
20726
  import crypto3 from "crypto";
20286
20727
  import { readFile as readFile4 } from "fs/promises";
20287
- import { BuiltInWorkflows as BuiltInWorkflows2 } from "@botpress/runtime/internal";
20288
- var { transforms: transforms2 } = z6;
20289
- function isBuiltinWorkflow(name) {
20290
- return !!Object.values(BuiltInWorkflows2).find((x) => x.name === name);
20728
+ import { BuiltInWorkflows as BuiltInWorkflows3 } from "@botpress/runtime/internal";
20729
+ var { transforms: transforms3 } = z7;
20730
+ function isBuiltinWorkflow2(name) {
20731
+ return !!Object.values(BuiltInWorkflows3).find((x) => x.name === name);
20291
20732
  }
20292
20733
  async function generateClientWrapper(project) {
20293
20734
  const actionTypes = [];
@@ -20297,8 +20738,8 @@ async function generateClientWrapper(project) {
20297
20738
  }
20298
20739
  try {
20299
20740
  if (action.path === "<adk:builtin>") {
20300
- const inputType = action.definition.input ? transforms2.fromJSONSchema(action.definition.input).toTypescriptType({ treatDefaultAsOptional: true }) : "{}";
20301
- const outputType = action.definition.output ? transforms2.fromJSONSchema(action.definition.output).toTypescriptType() : "{}";
20741
+ const inputType = action.definition.input ? transforms3.fromJSONSchema(action.definition.input).toTypescriptType({ treatDefaultAsOptional: true }) : "{}";
20742
+ const outputType = action.definition.output ? transforms3.fromJSONSchema(action.definition.output).toTypescriptType() : "{}";
20302
20743
  actionTypes.push({
20303
20744
  name: action.definition.name,
20304
20745
  inputType,
@@ -20306,7 +20747,7 @@ async function generateClientWrapper(project) {
20306
20747
  });
20307
20748
  continue;
20308
20749
  }
20309
- const absolutePath = path22.join(project.path, action.path);
20750
+ const absolutePath = path30.join(project.path, action.path);
20310
20751
  const actionModule = await import(`${absolutePath}?t=${Date.now()}`);
20311
20752
  const actionInstance = actionModule[action.export] || actionModule.default;
20312
20753
  if (actionInstance && actionInstance.input && actionInstance.output) {
@@ -20330,10 +20771,10 @@ async function generateClientWrapper(project) {
20330
20771
  const workflowTypes = [];
20331
20772
  for (const workflow of project.workflows) {
20332
20773
  try {
20333
- if (isBuiltinWorkflow(workflow.definition.name)) {
20774
+ if (isBuiltinWorkflow2(workflow.definition.name)) {
20334
20775
  continue;
20335
20776
  }
20336
- const workflowPath = path22.join(project.path, workflow.path);
20777
+ const workflowPath = path30.join(project.path, workflow.path);
20337
20778
  const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
20338
20779
  const workflowInstance = workflowModule[workflow.export] || workflowModule.default;
20339
20780
  if (workflowInstance) {
@@ -20352,7 +20793,7 @@ async function generateClientWrapper(project) {
20352
20793
  const tableTypes = [];
20353
20794
  for (const table of project.tables) {
20354
20795
  try {
20355
- const tablePath = path22.join(project.path, table.path);
20796
+ const tablePath = path30.join(project.path, table.path);
20356
20797
  const tableModule = await import(`${tablePath}?t=${Date.now()}`);
20357
20798
  const tableInstance = tableModule.default || tableModule[table.export];
20358
20799
  if (tableInstance && tableInstance.columns) {
@@ -20665,7 +21106,7 @@ export function createAdkClient(client: Client): AdkClient {
20665
21106
  }
20666
21107
  }
20667
21108
  `;
20668
- const clientWrapperPath = path22.join(project.path, ".adk", "client.ts");
21109
+ const clientWrapperPath = path30.join(project.path, ".adk", "client.ts");
20669
21110
  const formattedContent = await formatCode(content);
20670
21111
  const contentHash = crypto3.createHash("sha256").update(formattedContent.replace(/\/\/ Generated at: .+\n/, "")).digest("hex");
20671
21112
  try {
@@ -20685,189 +21126,55 @@ import fs19 from "fs/promises";
20685
21126
  import path43 from "path";
20686
21127
  init_config_utils();
20687
21128
 
20688
- // src/generators/plugin-types.ts
20689
- import { z as z7 } from "@botpress/sdk";
20690
- import crypto4 from "crypto";
20691
- import path23 from "path";
20692
- init_utils();
20693
- var { transforms: transforms3 } = z7;
20694
- function stripRefs(schema) {
20695
- if (typeof schema !== "object" || schema === null) {
20696
- return schema;
20697
- }
20698
- if (schema.$ref) {
20699
- return { type: "object", additionalProperties: true, "x-stripped-ref": schema.$ref };
20700
- }
20701
- const result = {};
20702
- for (const [key, value] of Object.entries(schema)) {
20703
- if (key === "$defs" || key === "definitions") {
20704
- continue;
20705
- }
20706
- if (Array.isArray(value)) {
20707
- result[key] = value.map((item) => typeof item === "object" && item !== null ? stripRefs(item) : item);
20708
- } else if (typeof value === "object" && value !== null) {
20709
- result[key] = stripRefs(value);
20710
- } else {
20711
- result[key] = value;
20712
- }
20713
- }
20714
- return result;
20715
- }
20716
- function jsonSchemaToTypescript(schema) {
20717
- const cleaned = stripRefs(schema);
20718
- return transforms3.fromJSONSchema(cleaned).toTypescriptType();
20719
- }
20720
- var getPluginHash = (plugin) => {
20721
- return crypto4.createHash("sha256").update(`${plugin.alias}|${plugin.definition?.id}|${plugin.definition?.version}|${plugin.definition?.updatedAt}`).digest("hex");
20722
- };
20723
- var getPascalAlias2 = (plugin) => pascalCase(getPluginAlias(plugin.alias));
20724
- var getPluginNames = (plugin) => ({
20725
- typings: {
20726
- index: `Plugin_All_${getPascalAlias2(plugin)}`,
20727
- actions: `Plugin_Actions_${getPascalAlias2(plugin)}`
20728
- },
20729
- paths: {
20730
- index: path23.join(snakeCase(getPascalAlias2(plugin)), `index.ts`),
20731
- actions: path23.join(snakeCase(getPascalAlias2(plugin)), `actions.ts`)
20732
- }
20733
- });
20734
- async function generatePluginTypes(plugin) {
20735
- const names = getPluginNames(plugin);
20736
- const hash = getPluginHash(plugin);
20737
- const rel = (to) => {
20738
- const from = names.paths.index;
20739
- return relative(from, to).replace(/\.ts$/i, "");
20740
- };
20741
- let tIndex = `
20742
- ////////////////////////////////////////////////////////
20743
- // DO NOT EDIT THIS FILE DIRECTLY
20744
- // This file is auto-generated from the Botpress ADK
20745
- // ADK Version: ${ADK_VERSION}
20746
- // Plugin: ${plugin.definition?.name}
20747
- // Version: ${plugin.definition?.version}
20748
- // File: ${names.paths.index}
20749
- // Hash: ${hash}
20750
- // Updated at: ${plugin.definition?.updatedAt}
20751
- ////////////////////////////////////////////////////////
20752
-
20753
- import { Plugin_Actions_${getPascalAlias2(plugin)} } from "${rel(names.paths.actions)}";
20754
-
20755
- export * from "${rel(names.paths.actions)}";
20756
-
20757
- export type Plugin_All_${getPascalAlias2(plugin)} = {
20758
- actions: Plugin_Actions_${getPascalAlias2(plugin)};
20759
- };
20760
- `;
20761
- let tActions = `
20762
- ////////////////////////////////////////////////////////
20763
- // DO NOT EDIT THIS FILE DIRECTLY
20764
- // This file is auto-generated from the Botpress ADK
20765
- // ADK Version: ${ADK_VERSION}
20766
- // Plugin: ${plugin.definition?.name}
20767
- // Version: ${plugin.definition?.version}
20768
- // File: ${names.paths.actions}
20769
- // Hash: ${hash}
20770
- // Updated at: ${plugin.definition?.updatedAt}
20771
- ////////////////////////////////////////////////////////
20772
-
20773
- export type Plugin_Actions_${getPascalAlias2(plugin)} = {`;
20774
- for (const [name, action] of Object.entries(plugin.definition.actions)) {
20775
- const input = jsonSchemaToTypescript(action.input.schema);
20776
- const output = jsonSchemaToTypescript(action.output.schema);
20777
- tActions += `
20778
- ${toMultilineComment(`Title: ${action.title || name}
20779
- Description: ${action.description || "No description"}`)}
20780
- "${name}": {
20781
- input: ${input};
20782
- output: ${output};
20783
- },
20784
- `;
20785
- }
20786
- tActions += `};`;
20787
- return {
20788
- names,
20789
- files: {
20790
- [names.paths.index]: await formatCode(tIndex),
20791
- [names.paths.actions]: await formatCode(tActions)
20792
- }
20793
- };
20794
- }
20795
-
20796
- // src/generators/plugin-action-types.ts
20797
- init_utils();
20798
- init_fs();
20799
- import path24 from "path";
20800
- async function generatePluginActionTypes(project) {
20801
- const content = `
20802
- ////////////////////////////////////////////////////////
20803
- // DO NOT EDIT THIS FILE DIRECTLY
20804
- // This file is auto-generated from the Botpress ADK
20805
- // ADK Version: ${ADK_VERSION}
20806
- // Generated at: ${new Date().toISOString()}
20807
- ////////////////////////////////////////////////////////
20808
-
20809
- type Plugins = import("@botpress/runtime/_types/plugins").Plugins;
20810
-
20811
- declare module "@botpress/runtime/_types/plugin-actions" {
20812
-
20813
- export interface CallableAction<I, O> {
20814
- (input: I): Promise<O>;
20815
- }
20816
-
20817
- type Callable<T> = T extends { input: infer I; output: infer O }
20818
- ? CallableAction<I, O>
20819
- : never;
20820
-
20821
- type PluginsMap<T> = {
20822
- [Plugin in keyof T]: T[Plugin] extends { actions: infer Actions }
20823
- ? {
20824
- actions: {
20825
- [Action in keyof Actions]: Callable<Actions[Action]>;
20826
- };
20827
- }
20828
- : never;
20829
- };
20830
-
20831
- export type PluginActions = PluginsMap<Plugins>;
20832
- }
20833
- `;
20834
- const pluginActionTypesPath = path24.join(project.path, ".adk", "plugin-action-types.d.ts");
20835
- await createFile(pluginActionTypesPath, await formatCode(content));
20836
- }
20837
-
20838
- // src/generators/interface-types.ts
21129
+ // src/generators/plugin-types.ts
20839
21130
  import { z as z8 } from "@botpress/sdk";
20840
- import crypto5 from "crypto";
20841
- import path25 from "path";
21131
+ import crypto4 from "crypto";
21132
+ import path31 from "path";
20842
21133
  init_utils();
20843
21134
  var { transforms: transforms4 } = z8;
20844
- var sameMajorVersion = (a, b) => {
20845
- const majorA = a.split(".")[0];
20846
- const majorB = b.split(".")[0];
20847
- return majorA === majorB;
20848
- };
20849
- var getIntegrationInterface = (integration, int) => {
20850
- return Object.values(integration.interfaces || {}).find((x) => x.name === int.name && sameMajorVersion(x.version, int.version));
20851
- };
20852
- var getInterfaceHash = (int, integrations) => {
20853
- const versions = integrations.filter((x) => !!getIntegrationInterface(x.definition, int)).map((x) => `${x.definition.id}|${x.definition.version}|${x.definition.updatedAt}|${x.alias}`).sort().join("|");
20854
- return crypto5.createHash("sha256").update(`${int.id}|${int.version}|${int.updatedAt}|${versions}`).digest("hex");
21135
+ function stripRefs(schema) {
21136
+ if (typeof schema !== "object" || schema === null) {
21137
+ return schema;
21138
+ }
21139
+ if (schema.$ref) {
21140
+ return { type: "object", additionalProperties: true, "x-stripped-ref": schema.$ref };
21141
+ }
21142
+ const result = {};
21143
+ for (const [key, value] of Object.entries(schema)) {
21144
+ if (key === "$defs" || key === "definitions") {
21145
+ continue;
21146
+ }
21147
+ if (Array.isArray(value)) {
21148
+ result[key] = value.map((item) => typeof item === "object" && item !== null ? stripRefs(item) : item);
21149
+ } else if (typeof value === "object" && value !== null) {
21150
+ result[key] = stripRefs(value);
21151
+ } else {
21152
+ result[key] = value;
21153
+ }
21154
+ }
21155
+ return result;
21156
+ }
21157
+ function jsonSchemaToTypescript(schema) {
21158
+ const cleaned = stripRefs(schema);
21159
+ return transforms4.fromJSONSchema(cleaned).toTypescriptType();
21160
+ }
21161
+ var getPluginHash = (plugin) => {
21162
+ return crypto4.createHash("sha256").update(`${plugin.alias}|${plugin.definition?.id}|${plugin.definition?.version}|${plugin.definition?.updatedAt}`).digest("hex");
20855
21163
  };
20856
- var getInterfaceNames = (int) => ({
20857
- name: camelCase(int.name),
21164
+ var getPascalAlias2 = (plugin) => pascalCase(getPluginAlias(plugin.alias));
21165
+ var getPluginNames = (plugin) => ({
20858
21166
  typings: {
20859
- index: `Interface_All_${pascalCase(int.name)}`,
20860
- actions: `Interface_Actions_${pascalCase(int.name)}`
21167
+ index: `Plugin_All_${getPascalAlias2(plugin)}`,
21168
+ actions: `Plugin_Actions_${getPascalAlias2(plugin)}`
20861
21169
  },
20862
21170
  paths: {
20863
- index: path25.join(snakeCase(int.name), `index.ts`),
20864
- actions: path25.join(snakeCase(int.name), `actions.ts`)
21171
+ index: path31.join(snakeCase(getPascalAlias2(plugin)), `index.ts`),
21172
+ actions: path31.join(snakeCase(getPascalAlias2(plugin)), `actions.ts`)
20865
21173
  }
20866
21174
  });
20867
- async function generateInterfaceTypes(int, integrations) {
20868
- const names = getInterfaceNames(int);
20869
- const hash = getInterfaceHash(int, integrations);
20870
- const implementors = integrations.filter((x) => !!getIntegrationInterface(x.definition, int)).sort((a, b) => a.alias.localeCompare(b.alias));
21175
+ async function generatePluginTypes(plugin) {
21176
+ const names = getPluginNames(plugin);
21177
+ const hash = getPluginHash(plugin);
20871
21178
  const rel = (to) => {
20872
21179
  const from = names.paths.index;
20873
21180
  return relative(from, to).replace(/\.ts$/i, "");
@@ -20877,212 +21184,61 @@ async function generateInterfaceTypes(int, integrations) {
20877
21184
  // DO NOT EDIT THIS FILE DIRECTLY
20878
21185
  // This file is auto-generated from the Botpress ADK
20879
21186
  // ADK Version: ${ADK_VERSION}
20880
- // Interface: ${int.name}
20881
- // Integrations: ${implementors.map((x) => x.alias).join(", ")}
20882
- // Version: ${int.version}
21187
+ // Plugin: ${plugin.definition?.name}
21188
+ // Version: ${plugin.definition?.version}
20883
21189
  // File: ${names.paths.index}
20884
21190
  // Hash: ${hash}
20885
- // Updated at: ${int.updatedAt}
21191
+ // Updated at: ${plugin.definition?.updatedAt}
20886
21192
  ////////////////////////////////////////////////////////
20887
21193
 
20888
- import { ${names.typings.actions} } from "${rel(names.paths.actions)}";
21194
+ import { Plugin_Actions_${getPascalAlias2(plugin)} } from "${rel(names.paths.actions)}";
20889
21195
 
20890
21196
  export * from "${rel(names.paths.actions)}";
20891
21197
 
20892
- export type ${names.typings.index} = {
20893
- actions: ${names.typings.actions};
21198
+ export type Plugin_All_${getPascalAlias2(plugin)} = {
21199
+ actions: Plugin_Actions_${getPascalAlias2(plugin)};
20894
21200
  };
20895
-
20896
- export const ${names.typings.index} = {
20897
- actions: ${names.typings.actions},
20898
- }
20899
21201
  `;
20900
- let iActions = ``;
20901
- let cActions = new Set;
20902
- for (const { alias, definition: integration } of implementors) {
20903
- iActions += `
20904
- // Integration: ${alias} (${integration.name}@${integration.version})
20905
- // Updated at: ${integration.updatedAt}
20906
- "${alias}": {`;
20907
- for (const [name, action] of Object.entries(int.actions)) {
20908
- const integrationInt = getIntegrationInterface(integration, int);
20909
- const mapping = integrationInt?.actions[name]?.name;
20910
- if (!mapping) {
20911
- continue;
20912
- }
20913
- const entities = Object.entries(integrationInt.entities).reduce((acc, [entityName, value]) => {
20914
- const entity = integration.entities[value.name];
20915
- if (entity) {
20916
- acc[entityName] = transforms4.fromJSONSchema(entity.schema).title(entity.title || entityName).describe(entity.description || "No description");
20917
- }
20918
- return acc;
20919
- }, {});
20920
- const input = transforms4.fromJSONSchema(action.input.schema).dereference(entities).toTypescriptType();
20921
- const output = transforms4.fromJSONSchema(action.output.schema).dereference(entities).toTypescriptType();
20922
- cActions.add(`"${alias}:${name}": "${alias}:${mapping}"`);
20923
- iActions += `
20924
- ${toMultilineComment(`Title: ${action.title || name}
20925
- Description: ${action.description || "No description"}`)}
20926
- "${name}": {
20927
- input: ${input};
20928
- output: ${output};
20929
- },
20930
- `;
20931
- }
20932
- iActions += `};`;
20933
- }
20934
- const tActions = `
21202
+ let tActions = `
20935
21203
  ////////////////////////////////////////////////////////
20936
21204
  // DO NOT EDIT THIS FILE DIRECTLY
20937
21205
  // This file is auto-generated from the Botpress ADK
20938
21206
  // ADK Version: ${ADK_VERSION}
20939
- // Interface: ${int.name}
20940
- // Integrations: ${implementors.map((x) => x.alias).join(", ")}
20941
- // Version: ${int.version}
20942
- // File: ${names.paths.index}
21207
+ // Plugin: ${plugin.definition?.name}
21208
+ // Version: ${plugin.definition?.version}
21209
+ // File: ${names.paths.actions}
20943
21210
  // Hash: ${hash}
20944
- // Updated at: ${int.updatedAt}
21211
+ // Updated at: ${plugin.definition?.updatedAt}
20945
21212
  ////////////////////////////////////////////////////////
20946
21213
 
20947
- export type ${names.typings.actions} = {
20948
- ${iActions}
20949
- };
20950
-
20951
- export const ${names.typings.actions} = {
20952
- ${Array.from(cActions).join(`,
20953
- `)}
20954
- };
20955
-
20956
- `;
21214
+ export type Plugin_Actions_${getPascalAlias2(plugin)} = {`;
21215
+ for (const [name, action] of Object.entries(plugin.definition.actions)) {
21216
+ const input = jsonSchemaToTypescript(action.input.schema);
21217
+ const output = jsonSchemaToTypescript(action.output.schema);
21218
+ tActions += `
21219
+ ${toMultilineComment(`Title: ${action.title || name}
21220
+ Description: ${action.description || "No description"}`)}
21221
+ "${name}": {
21222
+ input: ${input};
21223
+ output: ${output};
21224
+ },
21225
+ `;
21226
+ }
21227
+ tActions += `};`;
20957
21228
  return {
20958
21229
  names,
20959
21230
  files: {
20960
21231
  [names.paths.index]: await formatCode(tIndex),
20961
21232
  [names.paths.actions]: await formatCode(tActions)
20962
21233
  }
20963
- };
20964
- }
20965
-
20966
- // src/generators/table-types.ts
20967
- init_utils();
20968
- init_fs();
20969
- import path26 from "path";
20970
- var stripUndefined = (type) => type.replace(/\s*\|\s*undefined\b/g, "");
20971
- async function generateTableTypes(project) {
20972
- const tables = [];
20973
- for (const tableRef of project.tables) {
20974
- try {
20975
- const tablePath = path26.join(project.path, tableRef.path);
20976
- const tableModule = await import(`${tablePath}?t=${Date.now()}`);
20977
- const tableInstance = tableModule.default || tableModule[tableRef.export];
20978
- if (tableInstance && tableInstance.columns) {
20979
- const columns = {};
20980
- for (const [colName, colDef] of Object.entries(tableInstance.columns)) {
20981
- let schema;
20982
- let computed = false;
20983
- let searchable = false;
20984
- if (typeof colDef === "object" && colDef !== null && "schema" in colDef) {
20985
- schema = colDef.schema;
20986
- computed = colDef.computed || false;
20987
- searchable = colDef.searchable || false;
20988
- } else {
20989
- schema = colDef;
20990
- }
20991
- const tsType = schema.toTypescriptType ? schema.toTypescriptType() : "any";
20992
- const optional = typeof schema.isOptional === "function" && schema.isOptional() || typeof schema.isNullable === "function" && schema.isNullable() || /\|\s*undefined\b/.test(tsType);
20993
- columns[colName] = { type: tsType, computed, searchable, optional };
20994
- }
20995
- tables.push({
20996
- name: tableRef.definition.name,
20997
- columns
20998
- });
20999
- }
21000
- } catch (error) {
21001
- console.warn(`Failed to load table ${tableRef.definition.name}:`, error);
21002
- }
21003
- }
21004
- let content = `
21005
- ////////////////////////////////////////////////////////
21006
- // DO NOT EDIT THIS FILE DIRECTLY
21007
- // This file is auto-generated from the Botpress ADK
21008
- // ADK Version: ${ADK_VERSION}
21009
- // Generated at: ${new Date().toISOString()}
21010
- ////////////////////////////////////////////////////////
21011
-
21012
- declare module "@botpress/runtime/_types/tables" {
21013
- export type TableDefinitions = {
21014
- `;
21015
- if (tables.length === 0) {
21016
- content += ` [key: string]: {
21017
- `;
21018
- content += ` Input: any;
21019
- `;
21020
- content += ` Output: {
21021
- `;
21022
- content += ` id: number;
21023
- `;
21024
- content += ` createdAt: string;
21025
- `;
21026
- content += ` updatedAt: string;
21027
- `;
21028
- content += ` } & any;
21029
- `;
21030
- content += ` };
21031
- `;
21032
- } else {
21033
- for (const table of tables) {
21034
- const inputColumns = Object.entries(table.columns).filter(([_, col]) => !col.computed).map(([name, col]) => ` ${name}${col.optional ? "?" : ""}: ${col.optional ? stripUndefined(col.type) : col.type};`).join(`
21035
- `);
21036
- const outputColumns = [
21037
- " id: number;",
21038
- " createdAt: string;",
21039
- " updatedAt: string;",
21040
- ...Object.entries(table.columns).map(([name, col]) => ` ${name}: ${col.type};`)
21041
- ].join(`
21042
- `);
21043
- content += ` // Table: ${table.name}
21044
- `;
21045
- content += ` ${table.name}: {
21046
- `;
21047
- content += ` Input: {
21048
- ${inputColumns}
21049
- };
21050
- `;
21051
- content += ` Output: {
21052
- ${outputColumns}
21053
- };
21054
- `;
21055
- content += ` };
21056
- `;
21057
- }
21058
- }
21059
- content += ` };
21060
- }
21061
- `;
21062
- const tableTypesPath = path26.join(project.path, ".adk", "table-types.d.ts");
21063
- await createFile(tableTypesPath, await formatCode(content));
21064
- }
21065
-
21066
- // src/generators/trigger-types.ts
21067
- init_utils();
21068
- init_fs();
21069
- import path27 from "path";
21070
- async function generateTriggerTypes(project) {
21071
- const triggerEvents = {};
21072
- for (const trigger of project.triggers) {
21073
- triggerEvents[trigger.definition.name] = trigger.definition.events || [];
21074
- }
21075
- const triggersType = Object.entries(triggerEvents).map(([triggerName, events]) => {
21076
- let eventType = "never";
21077
- if (events.length > 0) {
21078
- eventType = events.map((event) => `Event<"${event}">`).join(" | ");
21079
- }
21080
- return ` "${triggerName}": {
21081
- events: [${events.map((e) => `"${e}"`).join(", ")}];
21082
- event: ${eventType};
21083
- };`;
21084
- }).join(`
21085
- `);
21234
+ };
21235
+ }
21236
+
21237
+ // src/generators/plugin-action-types.ts
21238
+ init_utils();
21239
+ init_fs();
21240
+ import path32 from "path";
21241
+ async function generatePluginActionTypes(project) {
21086
21242
  const content = `
21087
21243
  ////////////////////////////////////////////////////////
21088
21244
  // DO NOT EDIT THIS FILE DIRECTLY
@@ -21091,222 +21247,183 @@ async function generateTriggerTypes(project) {
21091
21247
  // Generated at: ${new Date().toISOString()}
21092
21248
  ////////////////////////////////////////////////////////
21093
21249
 
21094
- type SDKEvent = import("@botpress/client").Event;
21095
- type Events = import("@botpress/runtime/_types/events").Events;
21250
+ type Plugins = import("@botpress/runtime/_types/plugins").Plugins;
21096
21251
 
21097
- type Event<TName extends keyof Events> = Omit<SDKEvent, "payload" | "type"> & {
21098
- type: TName;
21099
- payload: Events[TName];
21100
- };
21252
+ declare module "@botpress/runtime/_types/plugin-actions" {
21101
21253
 
21102
- declare module "@botpress/runtime/_types/triggers" {
21103
- // Map of trigger names to their properties
21104
- export type Triggers = {
21105
- ${triggersType}
21106
- };
21107
- }
21108
- `;
21109
- const triggerTypesPath = path27.join(project.path, ".adk", "trigger-types.d.ts");
21110
- await createFile(triggerTypesPath, await formatCode(content));
21254
+ export interface CallableAction<I, O> {
21255
+ (input: I): Promise<O>;
21111
21256
  }
21112
21257
 
21113
- // src/generators/state-types.ts
21114
- init_utils();
21115
- init_fs();
21116
- import path28 from "path";
21117
- async function generateStateTypes(project) {
21118
- let botStateType = "{}";
21119
- let userStateType = "{}";
21120
- try {
21121
- const configPath = path28.join(project.path, "agent.config.ts");
21122
- const configModule = await import(`${configPath}?t=${Date.now()}`);
21123
- const config = configModule.default;
21124
- if (config?.bot?.state) {
21125
- const botSchema = config.bot.state;
21126
- if (botSchema.toTypescriptType) {
21127
- botStateType = botSchema.toTypescriptType();
21128
- }
21129
- }
21130
- if (config?.user?.state) {
21131
- const userSchema = config.user.state;
21132
- if (userSchema.toTypescriptType) {
21133
- userStateType = userSchema.toTypescriptType();
21258
+ type Callable<T> = T extends { input: infer I; output: infer O }
21259
+ ? CallableAction<I, O>
21260
+ : never;
21261
+
21262
+ type PluginsMap<T> = {
21263
+ [Plugin in keyof T]: T[Plugin] extends { actions: infer Actions }
21264
+ ? {
21265
+ actions: {
21266
+ [Action in keyof Actions]: Callable<Actions[Action]>;
21267
+ };
21134
21268
  }
21135
- }
21136
- } catch (error) {
21137
- console.warn("Failed to load agent config for state types:", error);
21138
- }
21139
- const content = `
21140
- ////////////////////////////////////////////////////////
21141
- // DO NOT EDIT THIS FILE DIRECTLY
21142
- // This file is auto-generated from the Botpress ADK
21143
- // ADK Version: ${ADK_VERSION}
21144
- // Generated at: ${new Date().toISOString()}
21145
- ////////////////////////////////////////////////////////
21269
+ : never;
21270
+ };
21146
21271
 
21147
- declare module "@botpress/runtime/_types/state" {
21148
- export type BotState = ${botStateType};
21149
- export type UserState = ${userStateType};
21272
+ export type PluginActions = PluginsMap<Plugins>;
21150
21273
  }
21151
21274
  `;
21152
- const stateTypesPath = path28.join(project.path, ".adk", "state-types.d.ts");
21153
- await createFile(stateTypesPath, await formatCode(content));
21275
+ const pluginActionTypesPath = path32.join(project.path, ".adk", "plugin-action-types.d.ts");
21276
+ await createFile(pluginActionTypesPath, await formatCode(content));
21154
21277
  }
21155
21278
 
21156
- // src/generators/tag-types.ts
21279
+ // src/generators/interface-types.ts
21280
+ import { z as z9 } from "@botpress/sdk";
21281
+ import crypto5 from "crypto";
21282
+ import path33 from "path";
21157
21283
  init_utils();
21158
- init_fs();
21159
- import path29 from "path";
21160
- import { BUILT_IN_TAGS } from "@botpress/runtime/definition";
21161
- function generateTagTypeString(builtInTags, configTags) {
21162
- const builtInTagStrings = Object.entries(builtInTags).map(([key, tag]) => {
21163
- const jsdoc = tag.description ? `/**
21164
- * ${tag.title}
21165
- *
21166
- * ${tag.description}
21167
- */
21168
- ` : `/** ${tag.title} */
21169
- `;
21170
- return `${jsdoc}${key}?: string | undefined`;
21171
- });
21172
- const configTagStrings = configTags ? Object.entries(configTags).map(([key, tag]) => {
21173
- const jsdoc = tag.description ? `/**
21174
- * ${tag.title}
21175
- *
21176
- * ${tag.description}
21177
- */
21178
- ` : `/** ${tag.title} */
21179
- `;
21180
- return `${jsdoc}${key}?: string | undefined`;
21181
- }) : [];
21182
- const allTags = [...builtInTagStrings, ...configTagStrings];
21183
- if (allTags.length === 0) {
21184
- return "Record<string, string | undefined>";
21185
- }
21186
- return `{
21187
- ${allTags.join(`
21188
- `)}
21189
- }`;
21190
- }
21191
- async function generateTagTypes(project) {
21192
- let botTagsType = "Record<string, string | undefined>";
21193
- let userTagsType = "Record<string, string | undefined>";
21194
- let conversationTagsType = "Record<string, string | undefined>";
21195
- let messageTagsType = "Record<string, string | undefined>";
21196
- let workflowTagsType = "Record<string, string | undefined>";
21197
- try {
21198
- const configPath = path29.join(project.path, "agent.config.ts");
21199
- const configModule = await import(`${configPath}?t=${Date.now()}`);
21200
- const config = configModule.default;
21201
- botTagsType = generateTagTypeString(BUILT_IN_TAGS.bot, config?.bot?.tags);
21202
- userTagsType = generateTagTypeString(BUILT_IN_TAGS.user, config?.user?.tags);
21203
- conversationTagsType = generateTagTypeString(BUILT_IN_TAGS.conversation, config?.conversation?.tags);
21204
- messageTagsType = generateTagTypeString(BUILT_IN_TAGS.message, config?.message?.tags);
21205
- workflowTagsType = generateTagTypeString(BUILT_IN_TAGS.workflow, config?.workflow?.tags);
21206
- } catch (error) {
21207
- console.warn("Failed to load agent config for tag types:", error);
21284
+ var { transforms: transforms5 } = z9;
21285
+ var sameMajorVersion = (a, b) => {
21286
+ const majorA = a.split(".")[0];
21287
+ const majorB = b.split(".")[0];
21288
+ return majorA === majorB;
21289
+ };
21290
+ var getIntegrationInterface = (integration, int) => {
21291
+ return Object.values(integration.interfaces || {}).find((x) => x.name === int.name && sameMajorVersion(x.version, int.version));
21292
+ };
21293
+ var getInterfaceHash = (int, integrations) => {
21294
+ const versions = integrations.filter((x) => !!getIntegrationInterface(x.definition, int)).map((x) => `${x.definition.id}|${x.definition.version}|${x.definition.updatedAt}|${x.alias}`).sort().join("|");
21295
+ return crypto5.createHash("sha256").update(`${int.id}|${int.version}|${int.updatedAt}|${versions}`).digest("hex");
21296
+ };
21297
+ var getInterfaceNames = (int) => ({
21298
+ name: camelCase(int.name),
21299
+ typings: {
21300
+ index: `Interface_All_${pascalCase(int.name)}`,
21301
+ actions: `Interface_Actions_${pascalCase(int.name)}`
21302
+ },
21303
+ paths: {
21304
+ index: path33.join(snakeCase(int.name), `index.ts`),
21305
+ actions: path33.join(snakeCase(int.name), `actions.ts`)
21208
21306
  }
21209
- const content = `
21210
- ////////////////////////////////////////////////////////
21211
- // DO NOT EDIT THIS FILE DIRECTLY
21212
- // This file is auto-generated from the Botpress ADK
21213
- // ADK Version: ${ADK_VERSION}
21214
- // Generated at: ${new Date().toISOString()}
21215
- ////////////////////////////////////////////////////////
21216
-
21217
- declare module "@botpress/runtime/_types/tags" {
21218
- /**
21219
- * Bot-level tags defined in agent.config.ts
21220
- */
21221
- export type BotTags = ${botTagsType};
21222
-
21223
- /**
21224
- * User-level tags defined in agent.config.ts
21225
- */
21226
- export type UserTags = ${userTagsType};
21307
+ });
21308
+ async function generateInterfaceTypes(int, integrations) {
21309
+ const names = getInterfaceNames(int);
21310
+ const hash = getInterfaceHash(int, integrations);
21311
+ const implementors = integrations.filter((x) => !!getIntegrationInterface(x.definition, int)).sort((a, b) => a.alias.localeCompare(b.alias));
21312
+ const rel = (to) => {
21313
+ const from = names.paths.index;
21314
+ return relative(from, to).replace(/\.ts$/i, "");
21315
+ };
21316
+ let tIndex = `
21317
+ ////////////////////////////////////////////////////////
21318
+ // DO NOT EDIT THIS FILE DIRECTLY
21319
+ // This file is auto-generated from the Botpress ADK
21320
+ // ADK Version: ${ADK_VERSION}
21321
+ // Interface: ${int.name}
21322
+ // Integrations: ${implementors.map((x) => x.alias).join(", ")}
21323
+ // Version: ${int.version}
21324
+ // File: ${names.paths.index}
21325
+ // Hash: ${hash}
21326
+ // Updated at: ${int.updatedAt}
21327
+ ////////////////////////////////////////////////////////
21227
21328
 
21228
- /**
21229
- * Conversation-level tags defined in agent.config.ts
21230
- */
21231
- export type ConversationTags = ${conversationTagsType};
21329
+ import { ${names.typings.actions} } from "${rel(names.paths.actions)}";
21232
21330
 
21233
- /**
21234
- * Message-level tags defined in agent.config.ts
21235
- */
21236
- export type MessageTags = ${messageTagsType};
21331
+ export * from "${rel(names.paths.actions)}";
21237
21332
 
21238
- /**
21239
- * Workflow-level tags defined in agent.config.ts
21240
- */
21241
- export type WorkflowTags = ${workflowTagsType};
21242
- }
21243
- `;
21244
- const tagTypesPath = path29.join(project.path, ".adk", "tag-types.d.ts");
21245
- await createFile(tagTypesPath, await formatCode(content));
21246
- }
21333
+ export type ${names.typings.index} = {
21334
+ actions: ${names.typings.actions};
21335
+ };
21247
21336
 
21248
- // src/generators/configuration-types.ts
21249
- init_utils();
21250
- init_fs();
21251
- import path30 from "path";
21252
- async function generateConfigurationTypes(project) {
21253
- let configurationType = "{}";
21254
- try {
21255
- const configPath = path30.join(project.path, "agent.config.ts");
21256
- const configModule = await import(`${configPath}?t=${Date.now()}`);
21257
- const config = configModule.default;
21258
- if (config?.configuration?.schema) {
21259
- const configSchema = config.configuration.schema;
21260
- if (configSchema.toTypescriptType) {
21261
- configurationType = configSchema.toTypescriptType();
21337
+ export const ${names.typings.index} = {
21338
+ actions: ${names.typings.actions},
21339
+ }
21340
+ `;
21341
+ let iActions = ``;
21342
+ let cActions = new Set;
21343
+ for (const { alias, definition: integration } of implementors) {
21344
+ iActions += `
21345
+ // Integration: ${alias} (${integration.name}@${integration.version})
21346
+ // Updated at: ${integration.updatedAt}
21347
+ "${alias}": {`;
21348
+ for (const [name, action] of Object.entries(int.actions)) {
21349
+ const integrationInt = getIntegrationInterface(integration, int);
21350
+ const mapping = integrationInt?.actions[name]?.name;
21351
+ if (!mapping) {
21352
+ continue;
21262
21353
  }
21354
+ const entities = Object.entries(integrationInt.entities).reduce((acc, [entityName, value]) => {
21355
+ const entity = integration.entities[value.name];
21356
+ if (entity) {
21357
+ acc[entityName] = transforms5.fromJSONSchema(entity.schema).title(entity.title || entityName).describe(entity.description || "No description");
21358
+ }
21359
+ return acc;
21360
+ }, {});
21361
+ const input = transforms5.fromJSONSchema(action.input.schema).dereference(entities).toTypescriptType();
21362
+ const output = transforms5.fromJSONSchema(action.output.schema).dereference(entities).toTypescriptType();
21363
+ cActions.add(`"${alias}:${name}": "${alias}:${mapping}"`);
21364
+ iActions += `
21365
+ ${toMultilineComment(`Title: ${action.title || name}
21366
+ Description: ${action.description || "No description"}`)}
21367
+ "${name}": {
21368
+ input: ${input};
21369
+ output: ${output};
21370
+ },
21371
+ `;
21263
21372
  }
21264
- } catch (error) {
21265
- console.warn("Failed to load agent config for configuration types:", error);
21373
+ iActions += `};`;
21266
21374
  }
21267
- const content = `
21268
- ////////////////////////////////////////////////////////
21269
- // DO NOT EDIT THIS FILE DIRECTLY
21270
- // This file is auto-generated from the Botpress ADK
21271
- // ADK Version: ${ADK_VERSION}
21272
- // Generated at: ${new Date().toISOString()}
21273
- ////////////////////////////////////////////////////////
21375
+ const tActions = `
21376
+ ////////////////////////////////////////////////////////
21377
+ // DO NOT EDIT THIS FILE DIRECTLY
21378
+ // This file is auto-generated from the Botpress ADK
21379
+ // ADK Version: ${ADK_VERSION}
21380
+ // Interface: ${int.name}
21381
+ // Integrations: ${implementors.map((x) => x.alias).join(", ")}
21382
+ // Version: ${int.version}
21383
+ // File: ${names.paths.index}
21384
+ // Hash: ${hash}
21385
+ // Updated at: ${int.updatedAt}
21386
+ ////////////////////////////////////////////////////////
21274
21387
 
21275
- declare module "@botpress/runtime/_types/configuration" {
21276
- export type Configuration = ${configurationType};
21277
- }
21278
- `;
21279
- const configTypesPath = path30.join(project.path, ".adk", "configuration-types.d.ts");
21280
- await createFile(configTypesPath, await formatCode(content));
21388
+ export type ${names.typings.actions} = {
21389
+ ${iActions}
21390
+ };
21391
+
21392
+ export const ${names.typings.actions} = {
21393
+ ${Array.from(cActions).join(`,
21394
+ `)}
21395
+ };
21396
+
21397
+ `;
21398
+ return {
21399
+ names,
21400
+ files: {
21401
+ [names.paths.index]: await formatCode(tIndex),
21402
+ [names.paths.actions]: await formatCode(tActions)
21403
+ }
21404
+ };
21281
21405
  }
21282
21406
 
21283
- // src/generators/secret-types.ts
21407
+ // src/generators/trigger-types.ts
21284
21408
  init_utils();
21285
21409
  init_fs();
21286
- import path31 from "path";
21287
- async function generateSecretTypes(project) {
21288
- let secretsType = "{}";
21289
- try {
21290
- const configPath = path31.join(project.path, "agent.config.ts");
21291
- const configModule = await import(`${configPath}?t=${Date.now()}`);
21292
- const config = configModule.default;
21293
- if (config?.secrets) {
21294
- const secrets = config.secrets;
21295
- const entries = Object.entries(secrets);
21296
- if (entries.length > 0) {
21297
- const props = entries.map(([key, def]) => {
21298
- const type = def.optional ? "string | undefined" : "string";
21299
- return ` ${JSON.stringify(key)}: ${type}`;
21300
- });
21301
- secretsType = `{
21302
- ${props.join(`
21303
- `)}
21304
- }`;
21305
- }
21306
- }
21307
- } catch (error) {
21308
- console.warn("Failed to load agent config for secret types:", error);
21410
+ import path34 from "path";
21411
+ async function generateTriggerTypes(project) {
21412
+ const triggerEvents = {};
21413
+ for (const trigger of project.triggers) {
21414
+ triggerEvents[trigger.definition.name] = trigger.definition.events || [];
21309
21415
  }
21416
+ const triggersType = Object.entries(triggerEvents).map(([triggerName, events]) => {
21417
+ let eventType = "never";
21418
+ if (events.length > 0) {
21419
+ eventType = events.map((event) => `Event<"${event}">`).join(" | ");
21420
+ }
21421
+ return ` "${triggerName}": {
21422
+ events: [${events.map((e) => `"${e}"`).join(", ")}];
21423
+ event: ${eventType};
21424
+ };`;
21425
+ }).join(`
21426
+ `);
21310
21427
  const content = `
21311
21428
  ////////////////////////////////////////////////////////
21312
21429
  // DO NOT EDIT THIS FILE DIRECTLY
@@ -21315,95 +21432,29 @@ ${props.join(`
21315
21432
  // Generated at: ${new Date().toISOString()}
21316
21433
  ////////////////////////////////////////////////////////
21317
21434
 
21318
- declare module "@botpress/runtime/_types/secrets" {
21319
- export type Secrets = ${secretsType};
21320
- }
21321
- `;
21322
- const secretTypesPath = path31.join(project.path, ".adk", "secret-types.d.ts");
21323
- await createFile(secretTypesPath, await formatCode(content));
21324
- }
21325
-
21326
- // src/generators/workflow-types.ts
21327
- init_utils();
21328
- init_fs();
21329
- import * as path32 from "path";
21330
- import { BuiltInWorkflows as BuiltInWorkflows3 } from "@botpress/runtime/internal";
21331
- function isBuiltinWorkflow2(name) {
21332
- return !!Object.values(BuiltInWorkflows3).find((x) => x.name === name);
21333
- }
21334
- async function generateWorkflowTypes(project) {
21335
- const workflows = [];
21336
- for (const workflowRef of project.workflows) {
21337
- try {
21338
- if (isBuiltinWorkflow2(workflowRef.definition.name)) {
21339
- continue;
21340
- }
21341
- const workflowPath = path32.join(project.path, workflowRef.path);
21342
- const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
21343
- const workflowInstance = workflowModule[workflowRef.export] || workflowModule.default;
21344
- if (!workflowInstance) {
21345
- continue;
21346
- }
21347
- const inputType = workflowInstance.inputSchema ? workflowInstance.inputSchema.toTypescriptType?.() || "any" : "{}";
21348
- const outputType = workflowInstance.outputSchema ? workflowInstance.outputSchema.toTypescriptType?.() || "any" : "{}";
21349
- const stateType = workflowInstance.stateSchema ? workflowInstance.stateSchema.toTypescriptType?.() || "any" : "{}";
21350
- let requestsType = "{}";
21351
- const requestsSchemas = workflowInstance._requestsSchemas;
21352
- if (requestsSchemas && Object.keys(requestsSchemas).length > 0) {
21353
- const requestTypes = Object.entries(requestsSchemas).map(([key, schema]) => {
21354
- const type = schema.toTypescriptType?.() || "any";
21355
- return `${key}: ${type}`;
21356
- }).join("; ");
21357
- requestsType = `{ ${requestTypes} }`;
21358
- }
21359
- let notificationsType = "{}";
21360
- const notificationsSchemas = workflowInstance._notificationsSchemas;
21361
- if (notificationsSchemas && Object.keys(notificationsSchemas).length > 0) {
21362
- const notificationTypes = Object.entries(notificationsSchemas).map(([key, schema]) => {
21363
- const type = schema.toTypescriptType?.() || "any";
21364
- return `${key}: ${type}`;
21365
- }).join("; ");
21366
- notificationsType = `{ ${notificationTypes} }`;
21367
- }
21368
- workflows.push({
21369
- name: workflowRef.definition.name,
21370
- input: inputType,
21371
- output: outputType,
21372
- state: stateType,
21373
- requests: requestsType,
21374
- notifications: notificationsType
21375
- });
21376
- } catch (error) {
21377
- console.error(`Failed to process workflow ${workflowRef.definition.name}:`, error);
21378
- }
21379
- }
21380
- const typeDefinitions = workflows.map((workflow) => ` ${workflow.name}: {
21381
- input: ${workflow.input};
21382
- output: ${workflow.output};
21383
- state: ${workflow.state};
21384
- requests: ${workflow.requests};
21385
- notifications: ${workflow.notifications};
21386
- tags: WorkflowTags;
21387
- };`).join(`
21388
- `);
21389
- const content = `// Generated workflow type definitions
21390
- // Do not edit this file directly - it will be overwritten
21435
+ type SDKEvent = import("@botpress/client").Event;
21436
+ type Events = import("@botpress/runtime/_types/events").Events;
21391
21437
 
21392
- type WorkflowTags = import("@botpress/runtime/_types/tags").WorkflowTags;
21438
+ type Event<TName extends keyof Events> = Omit<SDKEvent, "payload" | "type"> & {
21439
+ type: TName;
21440
+ payload: Events[TName];
21441
+ };
21393
21442
 
21394
- declare module "@botpress/runtime/_types/workflows" {
21395
- export type WorkflowDefinitions = {
21396
- ${typeDefinitions || " // No workflows defined yet"}
21443
+ declare module "@botpress/runtime/_types/triggers" {
21444
+ // Map of trigger names to their properties
21445
+ export type Triggers = {
21446
+ ${triggersType}
21397
21447
  };
21398
- }`;
21399
- const workflowTypesPath = path32.join(project.path, ".adk", "workflow-types.d.ts");
21400
- await createFile(workflowTypesPath, await formatCode(content));
21448
+ }
21449
+ `;
21450
+ const triggerTypesPath = path34.join(project.path, ".adk", "trigger-types.d.ts");
21451
+ await createFile(triggerTypesPath, await formatCode(content));
21401
21452
  }
21402
21453
 
21403
21454
  // src/generators/conversation-types.ts
21404
21455
  init_utils();
21405
21456
  init_fs();
21406
- import path33 from "path";
21457
+ import path35 from "path";
21407
21458
  function hasConversationIdProperty(schema) {
21408
21459
  if (!schema || typeof schema !== "object") {
21409
21460
  return false;
@@ -21426,7 +21477,7 @@ async function generateConversationTypes(project) {
21426
21477
  const conversationTypes = {};
21427
21478
  for (const conversationRef of project.conversations) {
21428
21479
  try {
21429
- const conversationPath = path33.join(project.path, conversationRef.path);
21480
+ const conversationPath = path35.join(project.path, conversationRef.path);
21430
21481
  const conversationModule = await import(`${conversationPath}?t=${Date.now()}`);
21431
21482
  const conversationInstance = conversationModule[conversationRef.export] || conversationModule.default;
21432
21483
  if (!conversationInstance) {
@@ -21514,61 +21565,14 @@ ${routableEventsDefinitions || " // No routable events found"}
21514
21565
  };
21515
21566
  }
21516
21567
  `;
21517
- const conversationTypesPath = path33.join(project.path, ".adk", "conversation-types.d.ts");
21568
+ const conversationTypesPath = path35.join(project.path, ".adk", "conversation-types.d.ts");
21518
21569
  await createFile(conversationTypesPath, await formatCode(content));
21519
21570
  }
21520
21571
 
21521
- // src/generators/component-types.ts
21522
- init_utils();
21523
- init_fs();
21524
- import path34 from "path";
21525
- async function generateComponentTypes(project) {
21526
- const components = project.customComponents;
21527
- if (components.length === 0) {
21528
- const content2 = `
21529
- ////////////////////////////////////////////////////////
21530
- // DO NOT EDIT THIS FILE DIRECTLY
21531
- // This file is auto-generated from the Botpress ADK
21532
- // ADK Version: ${ADK_VERSION}
21533
- // Generated at: ${new Date().toISOString()}
21534
- ////////////////////////////////////////////////////////
21535
-
21536
- declare module "@botpress/runtime/_types/components" {
21537
- export type CustomComponentMessage = never;
21538
- }
21539
- `;
21540
- const typesPath2 = path34.join(project.path, ".adk", "component-types.d.ts");
21541
- await createFile(typesPath2, await formatCode(content2));
21542
- return;
21543
- }
21544
- const componentImports = [];
21545
- const payloadUnionMembers = [];
21546
- for (const comp of components) {
21547
- const importPath = `../${comp.path.replace(/\.ts$/, "")}`;
21548
- componentImports.push(`import("${importPath}").${comp.export}`);
21549
- payloadUnionMembers.push(`{ component: import("${importPath}").${comp.export}; props: Parameters<import("${importPath}").${comp.export}["encode"]>[0] }`);
21550
- }
21551
- const content = `
21552
- ////////////////////////////////////////////////////////
21553
- // DO NOT EDIT THIS FILE DIRECTLY
21554
- // This file is auto-generated from the Botpress ADK
21555
- // ADK Version: ${ADK_VERSION}
21556
- // Generated at: ${new Date().toISOString()}
21557
- ////////////////////////////////////////////////////////
21558
-
21559
- declare module "@botpress/runtime/_types/components" {
21560
- export type CustomComponentMessage = ${payloadUnionMembers.join(`
21561
- | `)};
21562
- }
21563
- `;
21564
- const typesPath = path34.join(project.path, ".adk", "component-types.d.ts");
21565
- await createFile(typesPath, await formatCode(content));
21566
- }
21567
-
21568
21572
  // src/generators/event-types.ts
21569
21573
  init_utils();
21570
21574
  init_fs();
21571
- import path35 from "path";
21575
+ import path36 from "path";
21572
21576
  async function generateEventTypes(project) {
21573
21577
  const defaultEvents = ["register: {}"];
21574
21578
  const integrationEvents = [];
@@ -21620,7 +21624,7 @@ ${allEvents.map((e) => ` ${e}`).join(`
21620
21624
  export type EventPayload<T extends EventName> = Events[T];
21621
21625
  }
21622
21626
  `;
21623
- const eventTypesPath = path35.join(project.path, ".adk", "event-types.d.ts");
21627
+ const eventTypesPath = path36.join(project.path, ".adk", "event-types.d.ts");
21624
21628
  await createFile(eventTypesPath, await formatCode(content));
21625
21629
  }
21626
21630
 
@@ -21632,7 +21636,7 @@ init_fs();
21632
21636
  // src/utils/link-sdk.ts
21633
21637
  import { existsSync as existsSync4, realpathSync } from "fs";
21634
21638
  import fs14 from "fs/promises";
21635
- import path36 from "path";
21639
+ import path37 from "path";
21636
21640
  async function lexists(p) {
21637
21641
  try {
21638
21642
  await fs14.lstat(p);
@@ -21651,17 +21655,17 @@ function findPackage(name, startDir) {
21651
21655
  } catch {
21652
21656
  current = startDir;
21653
21657
  }
21654
- while (current !== path36.dirname(current)) {
21655
- const pkgPath = path36.join(current, "node_modules", name);
21658
+ while (current !== path37.dirname(current)) {
21659
+ const pkgPath = path37.join(current, "node_modules", name);
21656
21660
  if (existsSync4(pkgPath)) {
21657
21661
  return pkgPath;
21658
21662
  }
21659
- current = path36.dirname(current);
21663
+ current = path37.dirname(current);
21660
21664
  }
21661
21665
  return null;
21662
21666
  }
21663
21667
  async function linkSdk(agentDir, botDir) {
21664
- const targetSdkPath = path36.join(botDir, "node_modules", "@botpress", "sdk");
21668
+ const targetSdkPath = path37.join(botDir, "node_modules", "@botpress", "sdk");
21665
21669
  if (existsSync4(targetSdkPath)) {
21666
21670
  return;
21667
21671
  }
@@ -21675,7 +21679,7 @@ async function linkSdk(agentDir, botDir) {
21675
21679
  console.warn(`Warning: Could not find @botpress/sdk from @botpress/runtime location (${runtimePath})`);
21676
21680
  return;
21677
21681
  }
21678
- const targetBotpressDir = path36.join(botDir, "node_modules", "@botpress");
21682
+ const targetBotpressDir = path37.join(botDir, "node_modules", "@botpress");
21679
21683
  await fs14.mkdir(targetBotpressDir, { recursive: true });
21680
21684
  if (await lexists(targetSdkPath)) {
21681
21685
  await fs14.rm(targetSdkPath, { force: true });
@@ -21688,7 +21692,7 @@ async function linkSdk(agentDir, botDir) {
21688
21692
  init_auth();
21689
21693
  init_agent_project();
21690
21694
  init_validation_errors();
21691
- import path37 from "path";
21695
+ import path38 from "path";
21692
21696
  import fs15 from "fs/promises";
21693
21697
  import createDebug3 from "debug";
21694
21698
  var debug3 = createDebug3("adk:dev-id-manager");
@@ -21703,7 +21707,7 @@ class DevIdManager {
21703
21707
  constructor(projectPath, botProjectPath, options = {}) {
21704
21708
  this.projectPath = projectPath;
21705
21709
  this.botProjectPath = botProjectPath;
21706
- this.projectCachePath = path37.join(botProjectPath, ".botpress", "project.cache.json");
21710
+ this.projectCachePath = path38.join(botProjectPath, ".botpress", "project.cache.json");
21707
21711
  this.loadAgentProject = options.loadAgentProject ?? ((p) => AgentProject.load(p));
21708
21712
  this.validationErrors = options.validationErrors ?? ValidationErrors;
21709
21713
  }
@@ -21750,7 +21754,7 @@ class DevIdManager {
21750
21754
  }
21751
21755
  async saveProjectCache(cache2) {
21752
21756
  try {
21753
- await fs15.mkdir(path37.dirname(this.projectCachePath), { recursive: true });
21757
+ await fs15.mkdir(path38.dirname(this.projectCachePath), { recursive: true });
21754
21758
  await fs15.writeFile(this.projectCachePath, JSON.stringify(cache2, null, 2));
21755
21759
  } catch (error) {
21756
21760
  console.error("Error saving project.cache.json:", error);
@@ -21808,7 +21812,7 @@ function isProjectCache(value) {
21808
21812
  init_src();
21809
21813
  init_agent_project();
21810
21814
  init_auth();
21811
- import path38 from "path";
21815
+ import path39 from "path";
21812
21816
  import fs16 from "fs/promises";
21813
21817
  import { existsSync as existsSync5 } from "fs";
21814
21818
  class IntegrationSync {
@@ -21819,7 +21823,7 @@ class IntegrationSync {
21819
21823
  constructor(projectPath, botProjectPath) {
21820
21824
  this.projectPath = projectPath;
21821
21825
  this.botProjectPath = botProjectPath;
21822
- this.bpModulesPath = path38.join(botProjectPath, "bp_modules");
21826
+ this.bpModulesPath = path39.join(botProjectPath, "bp_modules");
21823
21827
  }
21824
21828
  getCredentials() {
21825
21829
  if (!this.credentialsPromise) {
@@ -21859,12 +21863,12 @@ class IntegrationSync {
21859
21863
  return integrations;
21860
21864
  }
21861
21865
  async isIntegrationSynced(integration) {
21862
- const targetFolder = path38.join(this.bpModulesPath, bpModuleDirName("integration", integration.alias));
21866
+ const targetFolder = path39.join(this.bpModulesPath, bpModuleDirName("integration", integration.alias));
21863
21867
  if (!existsSync5(targetFolder)) {
21864
21868
  return false;
21865
21869
  }
21866
21870
  try {
21867
- const indexPath = path38.join(targetFolder, "index.ts");
21871
+ const indexPath = path39.join(targetFolder, "index.ts");
21868
21872
  if (!existsSync5(indexPath)) {
21869
21873
  return false;
21870
21874
  }
@@ -21894,8 +21898,8 @@ class IntegrationSync {
21894
21898
  await command.output();
21895
21899
  }
21896
21900
  async renameIntegrationFolder(integration) {
21897
- const sourceFolder = path38.join(this.bpModulesPath, integration.name.replace(/[/_]/g, "-"));
21898
- const targetFolder = path38.join(this.bpModulesPath, bpModuleDirName("integration", integration.alias));
21901
+ const sourceFolder = path39.join(this.bpModulesPath, integration.name.replace(/[/_]/g, "-"));
21902
+ const targetFolder = path39.join(this.bpModulesPath, bpModuleDirName("integration", integration.alias));
21899
21903
  if (!existsSync5(sourceFolder)) {
21900
21904
  throw new AdkError({
21901
21905
  code: "GENERATED_FOLDER_MISSING",
@@ -21909,7 +21913,7 @@ class IntegrationSync {
21909
21913
  await fs16.rename(sourceFolder, targetFolder);
21910
21914
  }
21911
21915
  async removeIntegrationFolder(alias) {
21912
- const targetFolder = path38.join(this.bpModulesPath, bpModuleDirName("integration", alias));
21916
+ const targetFolder = path39.join(this.bpModulesPath, bpModuleDirName("integration", alias));
21913
21917
  if (existsSync5(targetFolder)) {
21914
21918
  await fs16.rm(targetFolder, { recursive: true, force: true });
21915
21919
  }
@@ -21946,7 +21950,7 @@ class IntegrationSync {
21946
21950
  init_src();
21947
21951
  init_agent_project();
21948
21952
  init_auth();
21949
- import path39 from "path";
21953
+ import path40 from "path";
21950
21954
  import fs17 from "fs/promises";
21951
21955
  import { existsSync as existsSync6 } from "fs";
21952
21956
  init_constants();
@@ -21958,7 +21962,7 @@ class InterfaceSync {
21958
21962
  constructor(projectPath, botProjectPath) {
21959
21963
  this.projectPath = projectPath;
21960
21964
  this.botProjectPath = botProjectPath;
21961
- this.bpModulesPath = path39.join(botProjectPath, "bp_modules");
21965
+ this.bpModulesPath = path40.join(botProjectPath, "bp_modules");
21962
21966
  }
21963
21967
  getCredentials() {
21964
21968
  if (!this.credentialsPromise) {
@@ -21985,12 +21989,12 @@ class InterfaceSync {
21985
21989
  return interfaces;
21986
21990
  }
21987
21991
  async isInterfaceSynced(interfaceInfo) {
21988
- const targetFolder = path39.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
21992
+ const targetFolder = path40.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
21989
21993
  if (!existsSync6(targetFolder)) {
21990
21994
  return false;
21991
21995
  }
21992
21996
  try {
21993
- const indexPath = path39.join(targetFolder, "index.ts");
21997
+ const indexPath = path40.join(targetFolder, "index.ts");
21994
21998
  if (!existsSync6(indexPath)) {
21995
21999
  return false;
21996
22000
  }
@@ -22031,8 +22035,8 @@ class InterfaceSync {
22031
22035
  });
22032
22036
  }
22033
22037
  async renameInterfaceFolder(interfaceInfo) {
22034
- const sourceFolder = path39.join(this.bpModulesPath, interfaceInfo.name);
22035
- const targetFolder = path39.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
22038
+ const sourceFolder = path40.join(this.bpModulesPath, interfaceInfo.name);
22039
+ const targetFolder = path40.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
22036
22040
  if (!existsSync6(sourceFolder)) {
22037
22041
  throw new AdkError({
22038
22042
  code: "GENERATED_FOLDER_MISSING",
@@ -22046,7 +22050,7 @@ class InterfaceSync {
22046
22050
  await fs17.rename(sourceFolder, targetFolder);
22047
22051
  }
22048
22052
  async removeInterfaceFolder(alias) {
22049
- const targetFolder = path39.join(this.bpModulesPath, `interface_${pascalCase(alias)}`);
22053
+ const targetFolder = path40.join(this.bpModulesPath, `interface_${pascalCase(alias)}`);
22050
22054
  if (existsSync6(targetFolder)) {
22051
22055
  await fs17.rm(targetFolder, { recursive: true, force: true });
22052
22056
  }
@@ -22083,7 +22087,7 @@ class InterfaceSync {
22083
22087
  init_src();
22084
22088
  init_agent_project();
22085
22089
  init_auth();
22086
- import path40 from "path";
22090
+ import path41 from "path";
22087
22091
  import fs18 from "fs/promises";
22088
22092
  import { existsSync as existsSync7 } from "fs";
22089
22093
  class PluginSync {
@@ -22094,7 +22098,7 @@ class PluginSync {
22094
22098
  constructor(projectPath, botProjectPath) {
22095
22099
  this.projectPath = projectPath;
22096
22100
  this.botProjectPath = botProjectPath;
22097
- this.bpModulesPath = path40.join(botProjectPath, "bp_modules");
22101
+ this.bpModulesPath = path41.join(botProjectPath, "bp_modules");
22098
22102
  }
22099
22103
  getCredentials() {
22100
22104
  if (!this.credentialsPromise) {
@@ -22126,12 +22130,12 @@ class PluginSync {
22126
22130
  return plugins;
22127
22131
  }
22128
22132
  async isPluginSynced(plugin) {
22129
- const targetFolder = path40.join(this.bpModulesPath, bpModuleDirName("plugin", plugin.alias));
22133
+ const targetFolder = path41.join(this.bpModulesPath, bpModuleDirName("plugin", plugin.alias));
22130
22134
  if (!existsSync7(targetFolder)) {
22131
22135
  return false;
22132
22136
  }
22133
22137
  try {
22134
- const indexPath = path40.join(targetFolder, "index.ts");
22138
+ const indexPath = path41.join(targetFolder, "index.ts");
22135
22139
  if (!existsSync7(indexPath)) {
22136
22140
  return false;
22137
22141
  }
@@ -22161,8 +22165,8 @@ class PluginSync {
22161
22165
  await command.output();
22162
22166
  }
22163
22167
  async renamePluginFolder(plugin) {
22164
- const sourceFolder = path40.join(this.bpModulesPath, plugin.name.replace("/", "-"));
22165
- const targetFolder = path40.join(this.bpModulesPath, bpModuleDirName("plugin", plugin.alias));
22168
+ const sourceFolder = path41.join(this.bpModulesPath, plugin.name.replace("/", "-"));
22169
+ const targetFolder = path41.join(this.bpModulesPath, bpModuleDirName("plugin", plugin.alias));
22166
22170
  if (!existsSync7(sourceFolder)) {
22167
22171
  throw new AdkError({
22168
22172
  code: "GENERATED_FOLDER_MISSING",
@@ -22176,7 +22180,7 @@ class PluginSync {
22176
22180
  await fs18.rename(sourceFolder, targetFolder);
22177
22181
  }
22178
22182
  async removePluginFolder(alias) {
22179
- const targetFolder = path40.join(this.bpModulesPath, bpModuleDirName("plugin", alias));
22183
+ const targetFolder = path41.join(this.bpModulesPath, bpModuleDirName("plugin", alias));
22180
22184
  if (existsSync7(targetFolder)) {
22181
22185
  await fs18.rm(targetFolder, { recursive: true, force: true });
22182
22186
  }
@@ -22303,16 +22307,9 @@ class BotGenerator {
22303
22307
  await this.generateIntegrationsTypes();
22304
22308
  await this.generatePluginsTypes();
22305
22309
  await this.generateInterfacesTypes();
22306
- await this.generateTableTypes();
22310
+ await generateLocalTypes(project);
22307
22311
  await this.generateTriggerTypes();
22308
- await this.generateTagTypes();
22309
- await this.generateStateTypes();
22310
- await this.generateConfigurationTypes();
22311
- await this.generateSecretTypes();
22312
- await this.generateWorkflowTypes();
22313
22312
  await this.generateConversationTypes();
22314
- await this.generateComponentTypes();
22315
- await this.generateActionTypes();
22316
22313
  await this.generateEventTypes();
22317
22314
  await this.generateIntegrationActionTypes();
22318
22315
  await this.generatePluginActionTypes();
@@ -22429,51 +22426,18 @@ class BotGenerator {
22429
22426
  }
22430
22427
  await this.removeEmptyDirectories(pluginsDir);
22431
22428
  }
22432
- async generateTableTypes() {
22433
- const project = await AgentProject.load(this.projectPath);
22434
- await generateTableTypes(project);
22435
- }
22436
22429
  async generateTriggerTypes() {
22437
22430
  const project = await AgentProject.load(this.projectPath);
22438
22431
  await generateTriggerTypes(project);
22439
22432
  }
22440
- async generateTagTypes() {
22441
- const project = await AgentProject.load(this.projectPath);
22442
- await generateTagTypes(project);
22443
- }
22444
- async generateStateTypes() {
22445
- const project = await AgentProject.load(this.projectPath);
22446
- await generateStateTypes(project);
22447
- }
22448
- async generateConfigurationTypes() {
22449
- const project = await AgentProject.load(this.projectPath);
22450
- await generateConfigurationTypes(project);
22451
- }
22452
- async generateSecretTypes() {
22453
- const project = await AgentProject.load(this.projectPath);
22454
- await generateSecretTypes(project);
22455
- }
22456
22433
  async generateEventTypes() {
22457
22434
  const project = await AgentProject.load(this.projectPath);
22458
22435
  await generateEventTypes(project);
22459
22436
  }
22460
- async generateWorkflowTypes() {
22461
- const project = await AgentProject.load(this.projectPath);
22462
- await generateWorkflowTypes(project);
22463
- }
22464
22437
  async generateConversationTypes() {
22465
22438
  const project = await AgentProject.load(this.projectPath);
22466
22439
  await generateConversationTypes(project);
22467
22440
  }
22468
- async generateComponentTypes() {
22469
- const project = await AgentProject.load(this.projectPath);
22470
- await generateComponentTypes(project);
22471
- }
22472
- async generateActionTypes() {
22473
- const project = await AgentProject.load(this.projectPath);
22474
- const { generateActionTypes: generateActionTypes2 } = await Promise.resolve().then(() => (init_action_types(), exports_action_types));
22475
- await generateActionTypes2(project);
22476
- }
22477
22441
  async generateIntegrationActionTypes() {
22478
22442
  const project = await AgentProject.load(this.projectPath);
22479
22443
  const { generateIntegrationActionTypes: generateIntegrationActionTypes2 } = await Promise.resolve().then(() => (init_integration_action_types(), exports_integration_action_types));
@@ -26110,6 +26074,7 @@ export {
26110
26074
  getProjectClient,
26111
26075
  getInnerTypeName,
26112
26076
  getChatClient,
26077
+ generateLocalTypes,
26113
26078
  generateIntegrationTypes,
26114
26079
  generateClientWrapper,
26115
26080
  generateBotProject,
@@ -26183,4 +26148,4 @@ export {
26183
26148
  ADK_MANIFEST_BOT_TAGS
26184
26149
  };
26185
26150
 
26186
- //# debugId=1AA56D31FBA32CE264756E2164756E21
26151
+ //# debugId=95CAA7F060AEC0CB64756E2164756E21