@botpress/adk 1.13.19 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bot-generator/generator.d.ts +2 -0
- package/dist/bot-generator/generator.d.ts.map +1 -1
- package/dist/generators/client-wrapper.d.ts +3 -0
- package/dist/generators/client-wrapper.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +575 -174
- package/dist/index.js.map +6 -5
- package/dist/integrations/config-utils.d.ts +5 -2
- package/dist/integrations/config-utils.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
2
|
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
-
for (let key of __getOwnPropNames(mod))
|
|
11
|
-
if (!__hasOwnProp.call(to, key))
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: () => mod[key],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
3
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
4
|
var __export = (target, all) => {
|
|
20
5
|
for (var name in all)
|
|
@@ -666,7 +651,7 @@ var PRETTIER_CONFIG, formatCode = async (code, filepath) => {
|
|
|
666
651
|
`));
|
|
667
652
|
return code;
|
|
668
653
|
}
|
|
669
|
-
}, ADK_VERSION = "1.
|
|
654
|
+
}, ADK_VERSION = "1.14.1", relative2 = (from, to) => {
|
|
670
655
|
const fromDir = path10.dirname(from);
|
|
671
656
|
const relative3 = path10.relative(fromDir, to);
|
|
672
657
|
return relative3.startsWith(".") ? relative3 : `./${relative3}`;
|
|
@@ -690,7 +675,7 @@ var exports_action_types = {};
|
|
|
690
675
|
__export(exports_action_types, {
|
|
691
676
|
generateActionTypes: () => generateActionTypes
|
|
692
677
|
});
|
|
693
|
-
import
|
|
678
|
+
import path32 from "path";
|
|
694
679
|
async function generateActionTypes(project) {
|
|
695
680
|
const actionDefs = [];
|
|
696
681
|
for (const action of project.actions) {
|
|
@@ -705,7 +690,7 @@ async function generateActionTypes(project) {
|
|
|
705
690
|
};`);
|
|
706
691
|
continue;
|
|
707
692
|
}
|
|
708
|
-
const absolutePath =
|
|
693
|
+
const absolutePath = path32.join(project.path, action.path);
|
|
709
694
|
const actionModule = await import(`${absolutePath}?t=${Date.now()}`);
|
|
710
695
|
const actionInstance = actionModule[action.export] || actionModule.default;
|
|
711
696
|
if (actionInstance && actionInstance.input && actionInstance.output) {
|
|
@@ -750,7 +735,7 @@ ${actionDefs.join(`
|
|
|
750
735
|
};
|
|
751
736
|
}
|
|
752
737
|
`;
|
|
753
|
-
const actionTypesPath =
|
|
738
|
+
const actionTypesPath = path32.join(project.path, ".adk", "action-types.d.ts");
|
|
754
739
|
await createFile(actionTypesPath, await formatCode(content));
|
|
755
740
|
}
|
|
756
741
|
var init_action_types = __esm(() => {
|
|
@@ -763,7 +748,7 @@ var exports_integration_action_types = {};
|
|
|
763
748
|
__export(exports_integration_action_types, {
|
|
764
749
|
generateIntegrationActionTypes: () => generateIntegrationActionTypes
|
|
765
750
|
});
|
|
766
|
-
import
|
|
751
|
+
import path33 from "path";
|
|
767
752
|
async function generateIntegrationActionTypes(project) {
|
|
768
753
|
const content = `
|
|
769
754
|
////////////////////////////////////////////////////////
|
|
@@ -797,7 +782,7 @@ type IntegrationsMap<T> = {
|
|
|
797
782
|
export type IntegrationActions = IntegrationsMap<Integrations>;
|
|
798
783
|
}
|
|
799
784
|
`;
|
|
800
|
-
const integrationActionTypesPath =
|
|
785
|
+
const integrationActionTypesPath = path33.join(project.path, ".adk", "integration-action-types.d.ts");
|
|
801
786
|
await createFile(integrationActionTypesPath, await formatCode(content));
|
|
802
787
|
}
|
|
803
788
|
var init_integration_action_types = __esm(() => {
|
|
@@ -809,7 +794,7 @@ var init_integration_action_types = __esm(() => {
|
|
|
809
794
|
var require_package = __commonJS((exports, module) => {
|
|
810
795
|
module.exports = {
|
|
811
796
|
name: "@botpress/adk",
|
|
812
|
-
version: "1.
|
|
797
|
+
version: "1.14.1",
|
|
813
798
|
description: "Core ADK library for building AI agents on Botpress",
|
|
814
799
|
type: "module",
|
|
815
800
|
main: "dist/index.js",
|
|
@@ -856,7 +841,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
856
841
|
"@botpress/cli": "^5.2.0",
|
|
857
842
|
"@botpress/client": "^1.28.0",
|
|
858
843
|
"@botpress/cognitive": "^0.3.3",
|
|
859
|
-
"@botpress/runtime": "^1.
|
|
844
|
+
"@botpress/runtime": "^1.14.1",
|
|
860
845
|
"@botpress/sdk": "^5.1.0",
|
|
861
846
|
"@bpinternal/jex": "^1.2.4",
|
|
862
847
|
"@bpinternal/yargs-extra": "^0.0.21",
|
|
@@ -3455,9 +3440,9 @@ function configsMatch(current, desired, schemaDefaults = {}) {
|
|
|
3455
3440
|
return JSON.stringify(currentValue) === JSON.stringify(desiredValue);
|
|
3456
3441
|
});
|
|
3457
3442
|
}
|
|
3458
|
-
async function fetchServerIntegrationConfigs(project) {
|
|
3443
|
+
async function fetchServerIntegrationConfigs(project, targetBotId) {
|
|
3459
3444
|
const { devId, botId } = project.agentInfo ?? {};
|
|
3460
|
-
const targetId = devId || botId;
|
|
3445
|
+
const targetId = targetBotId || devId || botId;
|
|
3461
3446
|
if (!targetId) {
|
|
3462
3447
|
return { configs: {}, fetched: false, skipped: true };
|
|
3463
3448
|
}
|
|
@@ -3472,6 +3457,9 @@ async function fetchServerIntegrationConfigs(project) {
|
|
|
3472
3457
|
try {
|
|
3473
3458
|
return await fetchBotConfigs(client, targetId);
|
|
3474
3459
|
} catch (err) {
|
|
3460
|
+
if (targetBotId) {
|
|
3461
|
+
throw err;
|
|
3462
|
+
}
|
|
3475
3463
|
if (devId && botId && devId !== botId) {
|
|
3476
3464
|
return await fetchBotConfigs(client, botId);
|
|
3477
3465
|
}
|
|
@@ -6405,7 +6393,7 @@ class AgentProjectGenerator {
|
|
|
6405
6393
|
deploy: "adk deploy"
|
|
6406
6394
|
},
|
|
6407
6395
|
dependencies: {
|
|
6408
|
-
"@botpress/runtime": `^${"1.
|
|
6396
|
+
"@botpress/runtime": `^${"1.14.1"}`
|
|
6409
6397
|
},
|
|
6410
6398
|
devDependencies: {
|
|
6411
6399
|
typescript: "^5.9.3"
|
|
@@ -7015,16 +7003,419 @@ Description: ${tag?.description}`);
|
|
|
7015
7003
|
}
|
|
7016
7004
|
};
|
|
7017
7005
|
}
|
|
7006
|
+
// src/generators/client-wrapper.ts
|
|
7007
|
+
init_utils();
|
|
7008
|
+
init_fs();
|
|
7009
|
+
import path18 from "path";
|
|
7010
|
+
import crypto3 from "crypto";
|
|
7011
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
7012
|
+
import { BuiltInWorkflows as BuiltInWorkflows2 } from "@botpress/runtime/internal";
|
|
7013
|
+
function isBuiltinWorkflow(name) {
|
|
7014
|
+
return !!Object.values(BuiltInWorkflows2).find((x) => x.name === name);
|
|
7015
|
+
}
|
|
7016
|
+
async function generateClientWrapper(project) {
|
|
7017
|
+
const actionTypes = [];
|
|
7018
|
+
for (const action of project.actions) {
|
|
7019
|
+
if (action.definition.attributes?.visibility === "hidden") {
|
|
7020
|
+
continue;
|
|
7021
|
+
}
|
|
7022
|
+
if (action.path === "<adk:builtin>") {
|
|
7023
|
+
actionTypes.push({
|
|
7024
|
+
name: action.definition.name,
|
|
7025
|
+
path: "",
|
|
7026
|
+
export: "",
|
|
7027
|
+
isBuiltin: true
|
|
7028
|
+
});
|
|
7029
|
+
continue;
|
|
7030
|
+
}
|
|
7031
|
+
actionTypes.push({
|
|
7032
|
+
name: action.definition.name,
|
|
7033
|
+
path: action.path,
|
|
7034
|
+
export: action.export,
|
|
7035
|
+
isBuiltin: false
|
|
7036
|
+
});
|
|
7037
|
+
}
|
|
7038
|
+
const workflowTypes = [];
|
|
7039
|
+
for (const workflow of project.workflows) {
|
|
7040
|
+
if (isBuiltinWorkflow(workflow.definition.name)) {
|
|
7041
|
+
continue;
|
|
7042
|
+
}
|
|
7043
|
+
workflowTypes.push({
|
|
7044
|
+
name: workflow.definition.name,
|
|
7045
|
+
path: workflow.path,
|
|
7046
|
+
export: workflow.export
|
|
7047
|
+
});
|
|
7048
|
+
}
|
|
7049
|
+
const tableTypes = [];
|
|
7050
|
+
for (const table of project.tables) {
|
|
7051
|
+
try {
|
|
7052
|
+
const tablePath = path18.join(project.path, table.path);
|
|
7053
|
+
const tableModule = await import(`${tablePath}?t=${Date.now()}`);
|
|
7054
|
+
const tableInstance = tableModule.default || tableModule[table.export];
|
|
7055
|
+
if (tableInstance && tableInstance.columns) {
|
|
7056
|
+
const inputColumns = [];
|
|
7057
|
+
const outputColumns = ["id: number", "createdAt: string", "updatedAt: string"];
|
|
7058
|
+
for (const [colName, colDef] of Object.entries(tableInstance.columns)) {
|
|
7059
|
+
let schema;
|
|
7060
|
+
let computed = false;
|
|
7061
|
+
if (typeof colDef === "object" && colDef !== null && "schema" in colDef) {
|
|
7062
|
+
schema = colDef.schema;
|
|
7063
|
+
computed = colDef.computed || false;
|
|
7064
|
+
} else {
|
|
7065
|
+
schema = colDef;
|
|
7066
|
+
}
|
|
7067
|
+
const tsType = schema.toTypescriptType ? schema.toTypescriptType() : "any";
|
|
7068
|
+
if (!computed) {
|
|
7069
|
+
inputColumns.push(`${colName}: ${tsType}`);
|
|
7070
|
+
}
|
|
7071
|
+
outputColumns.push(`${colName}: ${tsType}`);
|
|
7072
|
+
}
|
|
7073
|
+
tableTypes.push({
|
|
7074
|
+
name: table.definition.name,
|
|
7075
|
+
inputType: `{ ${inputColumns.join("; ")} }`,
|
|
7076
|
+
outputType: `{ ${outputColumns.join("; ")} }`
|
|
7077
|
+
});
|
|
7078
|
+
}
|
|
7079
|
+
} catch (error) {
|
|
7080
|
+
console.warn(`Warning: Could not process table ${table.definition.name}:`, error);
|
|
7081
|
+
}
|
|
7082
|
+
}
|
|
7083
|
+
const actionImportMap = new Map;
|
|
7084
|
+
let actionImportIndex = 0;
|
|
7085
|
+
const actionImports = actionTypes.filter((action) => !action.isBuiltin).map((action) => {
|
|
7086
|
+
const importPath = action.path.replace(/\.ts$/, ".js");
|
|
7087
|
+
actionImportMap.set(action.name, actionImportIndex);
|
|
7088
|
+
const importStatement = `import type * as Action${actionImportIndex} from '../${importPath}'`;
|
|
7089
|
+
actionImportIndex++;
|
|
7090
|
+
return importStatement;
|
|
7091
|
+
}).join(`
|
|
7092
|
+
`);
|
|
7093
|
+
const workflowImports = workflowTypes.map((workflow, index) => {
|
|
7094
|
+
const importPath = workflow.path.replace(/\.ts$/, ".js");
|
|
7095
|
+
return `import type * as Workflow${index} from '../${importPath}'`;
|
|
7096
|
+
}).join(`
|
|
7097
|
+
`);
|
|
7098
|
+
const content = `
|
|
7099
|
+
// @ts-nocheck
|
|
7100
|
+
////////////////////////////////////////////////////////
|
|
7101
|
+
// DO NOT EDIT THIS FILE DIRECTLY
|
|
7102
|
+
// This file is auto-generated from the Botpress ADK
|
|
7103
|
+
// ADK Version: ${ADK_VERSION}
|
|
7104
|
+
// Generated at: ${new Date().toISOString()}
|
|
7105
|
+
////////////////////////////////////////////////////////
|
|
7106
|
+
|
|
7107
|
+
import type { Client, Workflow } from '@botpress/client'
|
|
7108
|
+
import type { z } from '@botpress/sdk'
|
|
7109
|
+
|
|
7110
|
+
${actionImports}
|
|
7111
|
+
${workflowImports}
|
|
7112
|
+
|
|
7113
|
+
// Utility type to simplify complex types
|
|
7114
|
+
type Simplify<T> = T extends (...args: infer A) => infer R
|
|
7115
|
+
? (...args: SimplifyTuple<A>) => Simplify<R>
|
|
7116
|
+
: T extends Array<infer E>
|
|
7117
|
+
? Array<Simplify<E>>
|
|
7118
|
+
: T extends ReadonlyArray<infer E>
|
|
7119
|
+
? ReadonlyArray<Simplify<E>>
|
|
7120
|
+
: T extends Promise<infer R>
|
|
7121
|
+
? Promise<Simplify<R>>
|
|
7122
|
+
: T extends Buffer
|
|
7123
|
+
? Buffer
|
|
7124
|
+
: T extends object
|
|
7125
|
+
? SimplifyObject<T>
|
|
7126
|
+
: T
|
|
7127
|
+
|
|
7128
|
+
type SimplifyTuple<T> = T extends [...infer A] ? { [K in keyof A]: Simplify<A[K]> } : never
|
|
7129
|
+
type SimplifyObject<T extends object> = T extends infer O ? { [K in keyof O]: Simplify<O[K]> } : never
|
|
7130
|
+
|
|
7131
|
+
type GenericWorkflowInput = Record<string, any>
|
|
7132
|
+
type GenericWorkflowOutput = Record<string, any>
|
|
7133
|
+
|
|
7134
|
+
type TypedWorkflow<TInput = GenericWorkflowInput, TOutput = GenericWorkflowOutput> = Simplify<
|
|
7135
|
+
Omit<Workflow, 'input' | 'output'> & {
|
|
7136
|
+
input: TInput
|
|
7137
|
+
output: TOutput
|
|
7138
|
+
}
|
|
7139
|
+
>
|
|
7140
|
+
|
|
7141
|
+
// Extract response types from Client methods
|
|
7142
|
+
type CreateWorkflowResponse = Simplify<Awaited<ReturnType<Client['createWorkflow']>>>
|
|
7143
|
+
type GetWorkflowResponse = Simplify<Awaited<ReturnType<Client['getWorkflow']>>>
|
|
7144
|
+
type UpdateWorkflowResponse = Simplify<Awaited<ReturnType<Client['updateWorkflow']>>>
|
|
7145
|
+
type DeleteWorkflowResponse = Simplify<Awaited<ReturnType<Client['deleteWorkflow']>>>
|
|
7146
|
+
type GetOrCreateWorkflowResponse = Simplify<Awaited<ReturnType<Client['getOrCreateWorkflow']>>>
|
|
7147
|
+
|
|
7148
|
+
type CreateTableRowsResponse = Simplify<Awaited<ReturnType<Client['createTableRows']>>>
|
|
7149
|
+
type UpdateTableRowsResponse = Simplify<Awaited<ReturnType<Client['updateTableRows']>>>
|
|
7150
|
+
type UpsertTableRowsResponse = Simplify<Awaited<ReturnType<Client['upsertTableRows']>>>
|
|
7151
|
+
type DeleteTableRowsResponse = Simplify<Awaited<ReturnType<Client['deleteTableRows']>>>
|
|
7152
|
+
type FindTableRowsResponse = Simplify<Awaited<ReturnType<Client['findTableRows']>>>
|
|
7153
|
+
type GetTableRowResponse = Simplify<Awaited<ReturnType<Client['getTableRow']>>>
|
|
7154
|
+
|
|
7155
|
+
// Extract parameter types from Client methods
|
|
7156
|
+
type ParamCreateWorkflow = Simplify<Parameters<Client['createWorkflow']>[0]>
|
|
7157
|
+
type ParamGetWorkflow = Simplify<Parameters<Client['getWorkflow']>[0]>
|
|
7158
|
+
type ParamUpdateWorkflow = Simplify<Parameters<Client['updateWorkflow']>[0]>
|
|
7159
|
+
type ParamDeleteWorkflow = Simplify<Parameters<Client['deleteWorkflow']>[0]>
|
|
7160
|
+
type ParamGetOrCreateWorkflow = Simplify<Parameters<Client['getOrCreateWorkflow']>[0]>
|
|
7161
|
+
|
|
7162
|
+
type ParamCreateTableRows = Simplify<Parameters<Client['createTableRows']>[0]>
|
|
7163
|
+
type ParamUpdateTableRows = Simplify<Parameters<Client['updateTableRows']>[0]>
|
|
7164
|
+
type ParamUpsertTableRows = Simplify<Parameters<Client['upsertTableRows']>[0]>
|
|
7165
|
+
type ParamDeleteTableRows = Simplify<Parameters<Client['deleteTableRows']>[0]>
|
|
7166
|
+
type ParamFindTableRows = Simplify<Parameters<Client['findTableRows']>[0]>
|
|
7167
|
+
type ParamGetTableRow = Simplify<Parameters<Client['getTableRow']>[0]>
|
|
7168
|
+
|
|
7169
|
+
/**
|
|
7170
|
+
* Typed ADK Client
|
|
7171
|
+
*
|
|
7172
|
+
* Provides strongly-typed wrappers around the Botpress Client for actions, workflows, and tables.
|
|
7173
|
+
*/
|
|
7174
|
+
export interface AdkClient {
|
|
7175
|
+
/**
|
|
7176
|
+
* Typed action calls
|
|
7177
|
+
*/
|
|
7178
|
+
actions: {
|
|
7179
|
+
${actionTypes.map((action) => {
|
|
7180
|
+
if (action.isBuiltin) {
|
|
7181
|
+
return `
|
|
7182
|
+
/**
|
|
7183
|
+
* Call action: ${action.name}
|
|
7184
|
+
*/
|
|
7185
|
+
'${action.name}': (input: any) => Promise<any>
|
|
7186
|
+
`;
|
|
7187
|
+
}
|
|
7188
|
+
const importIndex = actionImportMap.get(action.name);
|
|
7189
|
+
return `
|
|
7190
|
+
/**
|
|
7191
|
+
* Call action: ${action.name}
|
|
7192
|
+
*/
|
|
7193
|
+
'${action.name}': (input: z.input<typeof Action${importIndex}.default.input>) => Promise<z.infer<typeof Action${importIndex}.default.output>>
|
|
7194
|
+
`;
|
|
7195
|
+
}).join(`
|
|
7196
|
+
`)}
|
|
7197
|
+
}
|
|
7198
|
+
|
|
7199
|
+
/**
|
|
7200
|
+
* Typed workflow operations
|
|
7201
|
+
*/
|
|
7202
|
+
workflows: {
|
|
7203
|
+
${workflowTypes.map((workflow, index) => {
|
|
7204
|
+
const inputType = `z.input<typeof Workflow${index}.default.inputSchema>`;
|
|
7205
|
+
const outputType = `z.infer<typeof Workflow${index}.default.outputSchema>`;
|
|
7206
|
+
return `
|
|
7207
|
+
'${workflow.name}': {
|
|
7208
|
+
/**
|
|
7209
|
+
* Create workflow: ${workflow.name}
|
|
7210
|
+
*/
|
|
7211
|
+
createWorkflow: (params: Omit<ParamCreateWorkflow, 'name' | 'input'> & { input?: ${inputType} }) => Promise<Omit<CreateWorkflowResponse, 'workflow'> & { workflow: TypedWorkflow<${inputType}, ${outputType}> }>
|
|
7212
|
+
/**
|
|
7213
|
+
* Get workflow by ID
|
|
7214
|
+
*/
|
|
7215
|
+
getWorkflow: (params: ParamGetWorkflow) => Promise<Omit<GetWorkflowResponse, 'workflow'> & { workflow: TypedWorkflow<${inputType}, ${outputType}> }>
|
|
7216
|
+
/**
|
|
7217
|
+
* Update workflow
|
|
7218
|
+
*/
|
|
7219
|
+
updateWorkflow: (params: Omit<ParamUpdateWorkflow, 'output'> & { output?: ${outputType} }) => Promise<Omit<UpdateWorkflowResponse, 'workflow'> & { workflow: TypedWorkflow<${inputType}, ${outputType}> }>
|
|
7220
|
+
/**
|
|
7221
|
+
* Delete workflow
|
|
7222
|
+
*/
|
|
7223
|
+
deleteWorkflow: (params: ParamDeleteWorkflow) => Promise<DeleteWorkflowResponse>
|
|
7224
|
+
/**
|
|
7225
|
+
* Get or create workflow with deduplication key
|
|
7226
|
+
*/
|
|
7227
|
+
getOrCreateWorkflow: (params: Omit<ParamGetOrCreateWorkflow, 'name' | 'input'> & { input?: ${inputType} }) => Promise<Omit<GetOrCreateWorkflowResponse, 'workflow'> & { workflow: TypedWorkflow<${inputType}, ${outputType}> }>
|
|
7228
|
+
}
|
|
7229
|
+
`;
|
|
7230
|
+
}).join(`
|
|
7231
|
+
`)}
|
|
7232
|
+
}
|
|
7233
|
+
|
|
7234
|
+
/**
|
|
7235
|
+
* Typed table operations
|
|
7236
|
+
*/
|
|
7237
|
+
tables: {
|
|
7238
|
+
${tableTypes.map((table) => `
|
|
7239
|
+
'${table.name}': {
|
|
7240
|
+
/**
|
|
7241
|
+
* Find rows in table: ${table.name}
|
|
7242
|
+
*/
|
|
7243
|
+
findTableRows: (params?: Omit<ParamFindTableRows, 'table'>) => Promise<Omit<FindTableRowsResponse, 'rows'> & { rows: Array<${table.outputType}> }>
|
|
7244
|
+
/**
|
|
7245
|
+
* Get a single row by ID
|
|
7246
|
+
*/
|
|
7247
|
+
getTableRow: (params: Omit<ParamGetTableRow, 'table'>) => Promise<Omit<GetTableRowResponse, 'row'> & { row: ${table.outputType} }>
|
|
7248
|
+
/**
|
|
7249
|
+
* Create rows in table: ${table.name}
|
|
7250
|
+
*/
|
|
7251
|
+
createTableRows: (params: Omit<ParamCreateTableRows, 'table'>) => Promise<Omit<CreateTableRowsResponse, 'rows'> & { rows: Array<${table.outputType}> }>
|
|
7252
|
+
/**
|
|
7253
|
+
* Update rows in table: ${table.name}
|
|
7254
|
+
*/
|
|
7255
|
+
updateTableRows: (params: Omit<ParamUpdateTableRows, 'table'>) => Promise<Omit<UpdateTableRowsResponse, 'rows'> & { rows: Array<${table.outputType}> }>
|
|
7256
|
+
/**
|
|
7257
|
+
* Upsert rows in table: ${table.name}
|
|
7258
|
+
*/
|
|
7259
|
+
upsertTableRows: (params: Omit<ParamUpsertTableRows, 'table'>) => Promise<Omit<UpsertTableRowsResponse, 'rows'> & { rows: Array<${table.outputType}> }>
|
|
7260
|
+
/**
|
|
7261
|
+
* Delete rows by IDs
|
|
7262
|
+
*/
|
|
7263
|
+
deleteTableRows: (params: Omit<ParamDeleteTableRows, 'table'>) => Promise<Omit<DeleteTableRowsResponse, 'rows'> & { rows: Array<${table.outputType}> }>
|
|
7264
|
+
}
|
|
7265
|
+
`).join(`
|
|
7266
|
+
`)}
|
|
7267
|
+
}
|
|
7268
|
+
|
|
7269
|
+
/**
|
|
7270
|
+
* Raw Botpress client (no additional typing)
|
|
7271
|
+
*/
|
|
7272
|
+
client: Client
|
|
7273
|
+
}
|
|
7274
|
+
|
|
7275
|
+
/**
|
|
7276
|
+
* Create a typed ADK client wrapper around a Botpress Client
|
|
7277
|
+
*
|
|
7278
|
+
* @example
|
|
7279
|
+
* \`\`\`typescript
|
|
7280
|
+
* import { Client } from '@botpress/client'
|
|
7281
|
+
* import { createAdkClient } from './.adk/client'
|
|
7282
|
+
*
|
|
7283
|
+
* const client = new Client({ token: 'xxx', botId: 'yyy' })
|
|
7284
|
+
* const adk = createAdkClient(client)
|
|
7285
|
+
*
|
|
7286
|
+
* // Typed action calls
|
|
7287
|
+
* const result = await adk.actions.myAction({ foo: 'bar' })
|
|
7288
|
+
*
|
|
7289
|
+
* // Typed workflow operations
|
|
7290
|
+
* const wf = await adk.workflows.myWorkflow.createWorkflow({ input: { data: 'value' } })
|
|
7291
|
+
* const workflow = await adk.workflows.myWorkflow.getWorkflow({ id: wf.workflow.id })
|
|
7292
|
+
* await adk.workflows.myWorkflow.updateWorkflow({ id: wf.workflow.id, status: 'completed' })
|
|
7293
|
+
* await adk.workflows.myWorkflow.deleteWorkflow({ id: wf.workflow.id })
|
|
7294
|
+
* await adk.workflows.myWorkflow.getOrCreateWorkflow({ key: 'unique-key', input: { data: 'value' } })
|
|
7295
|
+
*
|
|
7296
|
+
* // Typed table operations
|
|
7297
|
+
* const rows = await adk.tables.myTable.findTableRows({ filter: { name: 'John' } })
|
|
7298
|
+
* const row = await adk.tables.myTable.getTableRow({ id: 123 })
|
|
7299
|
+
* await adk.tables.myTable.createTableRows({ rows: [{ name: 'Jane', age: 30 }] })
|
|
7300
|
+
* await adk.tables.myTable.updateTableRows({ rows: [{ id: 123, name: 'Jane' }] })
|
|
7301
|
+
* await adk.tables.myTable.upsertTableRows({ rows: [{ name: 'Bob', age: 25 }] })
|
|
7302
|
+
* await adk.tables.myTable.deleteTableRows({ ids: [123, 456] })
|
|
7303
|
+
* \`\`\`
|
|
7304
|
+
*/
|
|
7305
|
+
export function createAdkClient(client: Client): AdkClient {
|
|
7306
|
+
return {
|
|
7307
|
+
actions: {
|
|
7308
|
+
${actionTypes.map((action) => `
|
|
7309
|
+
'${action.name}': async (input) => {
|
|
7310
|
+
const response = await client.callAction({
|
|
7311
|
+
type: '${action.name}',
|
|
7312
|
+
input,
|
|
7313
|
+
})
|
|
7314
|
+
return response.output as any
|
|
7315
|
+
}
|
|
7316
|
+
`).join(`,
|
|
7317
|
+
`)}
|
|
7318
|
+
},
|
|
7319
|
+
|
|
7320
|
+
workflows: {
|
|
7321
|
+
${workflowTypes.map((workflow) => `
|
|
7322
|
+
'${workflow.name}': {
|
|
7323
|
+
createWorkflow: async (params) => {
|
|
7324
|
+
return client.createWorkflow({
|
|
7325
|
+
name: '${workflow.name}',
|
|
7326
|
+
...params,
|
|
7327
|
+
}) as any
|
|
7328
|
+
},
|
|
7329
|
+
getWorkflow: async (params) => {
|
|
7330
|
+
return client.getWorkflow(params) as any
|
|
7331
|
+
},
|
|
7332
|
+
updateWorkflow: async (params) => {
|
|
7333
|
+
return client.updateWorkflow(params) as any
|
|
7334
|
+
},
|
|
7335
|
+
deleteWorkflow: async (params) => {
|
|
7336
|
+
return client.deleteWorkflow(params) as any
|
|
7337
|
+
},
|
|
7338
|
+
getOrCreateWorkflow: async (params) => {
|
|
7339
|
+
return client.getOrCreateWorkflow({
|
|
7340
|
+
name: '${workflow.name}',
|
|
7341
|
+
...params,
|
|
7342
|
+
}) as any
|
|
7343
|
+
},
|
|
7344
|
+
}
|
|
7345
|
+
`).join(`,
|
|
7346
|
+
`)}
|
|
7347
|
+
},
|
|
7348
|
+
|
|
7349
|
+
tables: {
|
|
7350
|
+
${tableTypes.map((table) => `
|
|
7351
|
+
'${table.name}': {
|
|
7352
|
+
findTableRows: async (params) => {
|
|
7353
|
+
return client.findTableRows({
|
|
7354
|
+
table: '${table.name}',
|
|
7355
|
+
...params,
|
|
7356
|
+
}) as any
|
|
7357
|
+
},
|
|
7358
|
+
getTableRow: async (params) => {
|
|
7359
|
+
return client.getTableRow({
|
|
7360
|
+
table: '${table.name}',
|
|
7361
|
+
...params,
|
|
7362
|
+
}) as any
|
|
7363
|
+
},
|
|
7364
|
+
createTableRows: async (params) => {
|
|
7365
|
+
return client.createTableRows({
|
|
7366
|
+
table: '${table.name}',
|
|
7367
|
+
...params,
|
|
7368
|
+
}) as any
|
|
7369
|
+
},
|
|
7370
|
+
updateTableRows: async (params) => {
|
|
7371
|
+
return client.updateTableRows({
|
|
7372
|
+
table: '${table.name}',
|
|
7373
|
+
...params,
|
|
7374
|
+
}) as any
|
|
7375
|
+
},
|
|
7376
|
+
upsertTableRows: async (params) => {
|
|
7377
|
+
return client.upsertTableRows({
|
|
7378
|
+
table: '${table.name}',
|
|
7379
|
+
...params,
|
|
7380
|
+
}) as any
|
|
7381
|
+
},
|
|
7382
|
+
deleteTableRows: async (params) => {
|
|
7383
|
+
return client.deleteTableRows({
|
|
7384
|
+
table: '${table.name}',
|
|
7385
|
+
...params,
|
|
7386
|
+
}) as any
|
|
7387
|
+
},
|
|
7388
|
+
}
|
|
7389
|
+
`).join(`,
|
|
7390
|
+
`)}
|
|
7391
|
+
},
|
|
7392
|
+
|
|
7393
|
+
client,
|
|
7394
|
+
}
|
|
7395
|
+
}
|
|
7396
|
+
`;
|
|
7397
|
+
const clientWrapperPath = path18.join(project.path, ".adk", "client.ts");
|
|
7398
|
+
const formattedContent = await formatCode(content);
|
|
7399
|
+
const contentHash = crypto3.createHash("sha256").update(formattedContent.replace(/\/\/ Generated at: .+\n/, "")).digest("hex");
|
|
7400
|
+
try {
|
|
7401
|
+
const existingContent = await readFile3(clientWrapperPath, "utf-8");
|
|
7402
|
+
const existingHash = crypto3.createHash("sha256").update(existingContent.replace(/\/\/ Generated at: .+\n/, "")).digest("hex");
|
|
7403
|
+
if (contentHash === existingHash) {
|
|
7404
|
+
return;
|
|
7405
|
+
}
|
|
7406
|
+
} catch {}
|
|
7407
|
+
await createFile(clientWrapperPath, formattedContent);
|
|
7408
|
+
}
|
|
7018
7409
|
// src/bot-generator/generator.ts
|
|
7019
7410
|
import dedent from "dedent";
|
|
7020
7411
|
import { existsSync as existsSync7 } from "fs";
|
|
7021
7412
|
import fs16 from "fs/promises";
|
|
7022
|
-
import
|
|
7413
|
+
import path34 from "path";
|
|
7023
7414
|
|
|
7024
7415
|
// src/generators/interface-types.ts
|
|
7025
7416
|
import { transforms as transforms2 } from "@botpress/sdk";
|
|
7026
|
-
import
|
|
7027
|
-
import
|
|
7417
|
+
import crypto4 from "crypto";
|
|
7418
|
+
import path19 from "path";
|
|
7028
7419
|
init_utils();
|
|
7029
7420
|
var sameMajorVersion = (a, b) => {
|
|
7030
7421
|
const majorA = a.split(".")[0];
|
|
@@ -7036,7 +7427,7 @@ var getIntegrationInterface = (integration, int) => {
|
|
|
7036
7427
|
};
|
|
7037
7428
|
var getInterfaceHash = (int, integrations) => {
|
|
7038
7429
|
const versions = integrations.filter((x) => !!getIntegrationInterface(x.definition, int)).map((x) => `${x.definition.id}|${x.definition.version}|${x.definition.updatedAt}|${x.alias}`).sort().join("|");
|
|
7039
|
-
return
|
|
7430
|
+
return crypto4.createHash("sha256").update(`${int.id}|${int.version}|${int.updatedAt}|${versions}`).digest("hex");
|
|
7040
7431
|
};
|
|
7041
7432
|
var getInterfaceNames = (int) => ({
|
|
7042
7433
|
name: camelCase(int.name),
|
|
@@ -7045,8 +7436,8 @@ var getInterfaceNames = (int) => ({
|
|
|
7045
7436
|
actions: `Interface_Actions_${pascalCase(int.name)}`
|
|
7046
7437
|
},
|
|
7047
7438
|
paths: {
|
|
7048
|
-
index:
|
|
7049
|
-
actions:
|
|
7439
|
+
index: path19.join(snakeCase(int.name), `index.ts`),
|
|
7440
|
+
actions: path19.join(snakeCase(int.name), `actions.ts`)
|
|
7050
7441
|
}
|
|
7051
7442
|
});
|
|
7052
7443
|
async function generateInterfaceTypes(int, integrations) {
|
|
@@ -7151,12 +7542,12 @@ Description: ${action.description || "No description"}`)}
|
|
|
7151
7542
|
// src/generators/table-types.ts
|
|
7152
7543
|
init_utils();
|
|
7153
7544
|
init_fs();
|
|
7154
|
-
import
|
|
7545
|
+
import path20 from "path";
|
|
7155
7546
|
async function generateTableTypes(project) {
|
|
7156
7547
|
const tables = [];
|
|
7157
7548
|
for (const tableRef of project.tables) {
|
|
7158
7549
|
try {
|
|
7159
|
-
const tablePath =
|
|
7550
|
+
const tablePath = path20.join(project.path, tableRef.path);
|
|
7160
7551
|
const tableModule = await import(`${tablePath}?t=${Date.now()}`);
|
|
7161
7552
|
const tableInstance = tableModule.default || tableModule[tableRef.export];
|
|
7162
7553
|
if (tableInstance && tableInstance.columns) {
|
|
@@ -7242,14 +7633,14 @@ ${outputColumns}
|
|
|
7242
7633
|
content += ` };
|
|
7243
7634
|
}
|
|
7244
7635
|
`;
|
|
7245
|
-
const tableTypesPath =
|
|
7636
|
+
const tableTypesPath = path20.join(project.path, ".adk", "table-types.d.ts");
|
|
7246
7637
|
await createFile(tableTypesPath, await formatCode(content));
|
|
7247
7638
|
}
|
|
7248
7639
|
|
|
7249
7640
|
// src/generators/trigger-types.ts
|
|
7250
7641
|
init_utils();
|
|
7251
7642
|
init_fs();
|
|
7252
|
-
import
|
|
7643
|
+
import path21 from "path";
|
|
7253
7644
|
async function generateTriggerTypes(project) {
|
|
7254
7645
|
const triggerEvents = {};
|
|
7255
7646
|
for (const trigger of project.triggers) {
|
|
@@ -7289,19 +7680,19 @@ ${triggersType}
|
|
|
7289
7680
|
};
|
|
7290
7681
|
}
|
|
7291
7682
|
`;
|
|
7292
|
-
const triggerTypesPath =
|
|
7683
|
+
const triggerTypesPath = path21.join(project.path, ".adk", "trigger-types.d.ts");
|
|
7293
7684
|
await createFile(triggerTypesPath, await formatCode(content));
|
|
7294
7685
|
}
|
|
7295
7686
|
|
|
7296
7687
|
// src/generators/state-types.ts
|
|
7297
7688
|
init_utils();
|
|
7298
7689
|
init_fs();
|
|
7299
|
-
import
|
|
7690
|
+
import path22 from "path";
|
|
7300
7691
|
async function generateStateTypes(project) {
|
|
7301
7692
|
let botStateType = "{}";
|
|
7302
7693
|
let userStateType = "{}";
|
|
7303
7694
|
try {
|
|
7304
|
-
const configPath =
|
|
7695
|
+
const configPath = path22.join(project.path, "agent.config.ts");
|
|
7305
7696
|
const configModule = await import(`${configPath}?t=${Date.now()}`);
|
|
7306
7697
|
const config = configModule.default;
|
|
7307
7698
|
if (config?.bot?.state) {
|
|
@@ -7332,14 +7723,14 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
7332
7723
|
export type UserState = ${userStateType};
|
|
7333
7724
|
}
|
|
7334
7725
|
`;
|
|
7335
|
-
const stateTypesPath =
|
|
7726
|
+
const stateTypesPath = path22.join(project.path, ".adk", "state-types.d.ts");
|
|
7336
7727
|
await createFile(stateTypesPath, await formatCode(content));
|
|
7337
7728
|
}
|
|
7338
7729
|
|
|
7339
7730
|
// src/generators/tag-types.ts
|
|
7340
7731
|
init_utils();
|
|
7341
7732
|
init_fs();
|
|
7342
|
-
import
|
|
7733
|
+
import path23 from "path";
|
|
7343
7734
|
import { BUILT_IN_TAGS } from "@botpress/runtime/definition";
|
|
7344
7735
|
function generateTagTypeString(builtInTags, configTags) {
|
|
7345
7736
|
const builtInTagStrings = Object.entries(builtInTags).map(([key, tag]) => {
|
|
@@ -7378,7 +7769,7 @@ async function generateTagTypes(project) {
|
|
|
7378
7769
|
let messageTagsType = "Record<string, string | undefined>";
|
|
7379
7770
|
let workflowTagsType = "Record<string, string | undefined>";
|
|
7380
7771
|
try {
|
|
7381
|
-
const configPath =
|
|
7772
|
+
const configPath = path23.join(project.path, "agent.config.ts");
|
|
7382
7773
|
const configModule = await import(`${configPath}?t=${Date.now()}`);
|
|
7383
7774
|
const config = configModule.default;
|
|
7384
7775
|
botTagsType = generateTagTypeString(BUILT_IN_TAGS.bot, config?.bot?.tags);
|
|
@@ -7424,18 +7815,18 @@ declare module "@botpress/runtime/_types/tags" {
|
|
|
7424
7815
|
export type WorkflowTags = ${workflowTagsType};
|
|
7425
7816
|
}
|
|
7426
7817
|
`;
|
|
7427
|
-
const tagTypesPath =
|
|
7818
|
+
const tagTypesPath = path23.join(project.path, ".adk", "tag-types.d.ts");
|
|
7428
7819
|
await createFile(tagTypesPath, await formatCode(content));
|
|
7429
7820
|
}
|
|
7430
7821
|
|
|
7431
7822
|
// src/generators/configuration-types.ts
|
|
7432
7823
|
init_utils();
|
|
7433
7824
|
init_fs();
|
|
7434
|
-
import
|
|
7825
|
+
import path24 from "path";
|
|
7435
7826
|
async function generateConfigurationTypes(project) {
|
|
7436
7827
|
let configurationType = "{}";
|
|
7437
7828
|
try {
|
|
7438
|
-
const configPath =
|
|
7829
|
+
const configPath = path24.join(project.path, "agent.config.ts");
|
|
7439
7830
|
const configModule = await import(`${configPath}?t=${Date.now()}`);
|
|
7440
7831
|
const config = configModule.default;
|
|
7441
7832
|
if (config?.configuration?.schema) {
|
|
@@ -7459,26 +7850,26 @@ declare module "@botpress/runtime/_types/configuration" {
|
|
|
7459
7850
|
export type Configuration = ${configurationType};
|
|
7460
7851
|
}
|
|
7461
7852
|
`;
|
|
7462
|
-
const configTypesPath =
|
|
7853
|
+
const configTypesPath = path24.join(project.path, ".adk", "configuration-types.d.ts");
|
|
7463
7854
|
await createFile(configTypesPath, await formatCode(content));
|
|
7464
7855
|
}
|
|
7465
7856
|
|
|
7466
7857
|
// src/generators/workflow-types.ts
|
|
7467
7858
|
init_utils();
|
|
7468
7859
|
init_fs();
|
|
7469
|
-
import * as
|
|
7470
|
-
import { BuiltInWorkflows as
|
|
7471
|
-
function
|
|
7472
|
-
return !!Object.values(
|
|
7860
|
+
import * as path25 from "path";
|
|
7861
|
+
import { BuiltInWorkflows as BuiltInWorkflows3 } from "@botpress/runtime/internal";
|
|
7862
|
+
function isBuiltinWorkflow2(name) {
|
|
7863
|
+
return !!Object.values(BuiltInWorkflows3).find((x) => x.name === name);
|
|
7473
7864
|
}
|
|
7474
7865
|
async function generateWorkflowTypes(project) {
|
|
7475
7866
|
const workflows = [];
|
|
7476
7867
|
for (const workflowRef of project.workflows) {
|
|
7477
7868
|
try {
|
|
7478
|
-
if (
|
|
7869
|
+
if (isBuiltinWorkflow2(workflowRef.definition.name)) {
|
|
7479
7870
|
continue;
|
|
7480
7871
|
}
|
|
7481
|
-
const workflowPath =
|
|
7872
|
+
const workflowPath = path25.join(project.path, workflowRef.path);
|
|
7482
7873
|
const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
|
|
7483
7874
|
const workflowInstance = workflowModule[workflowRef.export] || workflowModule.default;
|
|
7484
7875
|
if (!workflowInstance) {
|
|
@@ -7525,14 +7916,14 @@ declare module "@botpress/runtime/_types/workflows" {
|
|
|
7525
7916
|
${typeDefinitions || " // No workflows defined yet"}
|
|
7526
7917
|
};
|
|
7527
7918
|
}`;
|
|
7528
|
-
const workflowTypesPath =
|
|
7919
|
+
const workflowTypesPath = path25.join(project.path, ".adk", "workflow-types.d.ts");
|
|
7529
7920
|
await createFile(workflowTypesPath, await formatCode(content));
|
|
7530
7921
|
}
|
|
7531
7922
|
|
|
7532
7923
|
// src/generators/conversation-types.ts
|
|
7533
7924
|
init_utils();
|
|
7534
7925
|
init_fs();
|
|
7535
|
-
import
|
|
7926
|
+
import path26 from "path";
|
|
7536
7927
|
function hasConversationIdProperty(schema) {
|
|
7537
7928
|
if (!schema || typeof schema !== "object") {
|
|
7538
7929
|
return false;
|
|
@@ -7555,7 +7946,7 @@ async function generateConversationTypes(project) {
|
|
|
7555
7946
|
const conversationTypes = {};
|
|
7556
7947
|
for (const conversationRef of project.conversations) {
|
|
7557
7948
|
try {
|
|
7558
|
-
const conversationPath =
|
|
7949
|
+
const conversationPath = path26.join(project.path, conversationRef.path);
|
|
7559
7950
|
const conversationModule = await import(`${conversationPath}?t=${Date.now()}`);
|
|
7560
7951
|
const conversationInstance = conversationModule[conversationRef.export] || conversationModule.default;
|
|
7561
7952
|
if (!conversationInstance) {
|
|
@@ -7641,14 +8032,14 @@ ${routableEventsDefinitions || " // No routable events found"}
|
|
|
7641
8032
|
};
|
|
7642
8033
|
}
|
|
7643
8034
|
`;
|
|
7644
|
-
const conversationTypesPath =
|
|
8035
|
+
const conversationTypesPath = path26.join(project.path, ".adk", "conversation-types.d.ts");
|
|
7645
8036
|
await createFile(conversationTypesPath, await formatCode(content));
|
|
7646
8037
|
}
|
|
7647
8038
|
|
|
7648
8039
|
// src/generators/event-types.ts
|
|
7649
8040
|
init_utils();
|
|
7650
8041
|
init_fs();
|
|
7651
|
-
import
|
|
8042
|
+
import path27 from "path";
|
|
7652
8043
|
async function generateEventTypes(project) {
|
|
7653
8044
|
const defaultEvents = ["register: {}"];
|
|
7654
8045
|
const integrationEvents = [];
|
|
@@ -7700,7 +8091,7 @@ ${allEvents.map((e) => ` ${e}`).join(`
|
|
|
7700
8091
|
export type EventPayload<T extends EventName> = Events[T];
|
|
7701
8092
|
}
|
|
7702
8093
|
`;
|
|
7703
|
-
const eventTypesPath =
|
|
8094
|
+
const eventTypesPath = path27.join(project.path, ".adk", "event-types.d.ts");
|
|
7704
8095
|
await createFile(eventTypesPath, await formatCode(content));
|
|
7705
8096
|
}
|
|
7706
8097
|
|
|
@@ -7710,7 +8101,7 @@ init_fs();
|
|
|
7710
8101
|
// src/utils/link-sdk.ts
|
|
7711
8102
|
import { existsSync as existsSync3, realpathSync } from "fs";
|
|
7712
8103
|
import fs12 from "fs/promises";
|
|
7713
|
-
import
|
|
8104
|
+
import path28 from "path";
|
|
7714
8105
|
function findPackage(name, startDir) {
|
|
7715
8106
|
let current;
|
|
7716
8107
|
try {
|
|
@@ -7718,17 +8109,17 @@ function findPackage(name, startDir) {
|
|
|
7718
8109
|
} catch {
|
|
7719
8110
|
current = startDir;
|
|
7720
8111
|
}
|
|
7721
|
-
while (current !==
|
|
7722
|
-
const pkgPath =
|
|
8112
|
+
while (current !== path28.dirname(current)) {
|
|
8113
|
+
const pkgPath = path28.join(current, "node_modules", name);
|
|
7723
8114
|
if (existsSync3(pkgPath)) {
|
|
7724
8115
|
return pkgPath;
|
|
7725
8116
|
}
|
|
7726
|
-
current =
|
|
8117
|
+
current = path28.dirname(current);
|
|
7727
8118
|
}
|
|
7728
8119
|
return null;
|
|
7729
8120
|
}
|
|
7730
8121
|
async function linkSdk(agentDir, botDir) {
|
|
7731
|
-
const targetSdkPath =
|
|
8122
|
+
const targetSdkPath = path28.join(botDir, "node_modules", "@botpress", "sdk");
|
|
7732
8123
|
if (existsSync3(targetSdkPath)) {
|
|
7733
8124
|
return;
|
|
7734
8125
|
}
|
|
@@ -7742,14 +8133,14 @@ async function linkSdk(agentDir, botDir) {
|
|
|
7742
8133
|
console.warn(`Warning: Could not find @botpress/sdk from @botpress/runtime location (${runtimePath})`);
|
|
7743
8134
|
return;
|
|
7744
8135
|
}
|
|
7745
|
-
const targetBotpressDir =
|
|
8136
|
+
const targetBotpressDir = path28.join(botDir, "node_modules", "@botpress");
|
|
7746
8137
|
await fs12.mkdir(targetBotpressDir, { recursive: true });
|
|
7747
8138
|
const symlinkType = process.platform === "win32" ? "junction" : undefined;
|
|
7748
8139
|
await fs12.symlink(sdkPath, targetSdkPath, symlinkType);
|
|
7749
8140
|
}
|
|
7750
8141
|
|
|
7751
8142
|
// src/bot-generator/dev-id-manager.ts
|
|
7752
|
-
import
|
|
8143
|
+
import path29 from "path";
|
|
7753
8144
|
import fs13 from "fs/promises";
|
|
7754
8145
|
import { existsSync as existsSync4 } from "fs";
|
|
7755
8146
|
import { Client as Client13 } from "@botpress/client";
|
|
@@ -7761,7 +8152,7 @@ class DevIdManager {
|
|
|
7761
8152
|
constructor(projectPath, botProjectPath) {
|
|
7762
8153
|
this.projectPath = projectPath;
|
|
7763
8154
|
this.botProjectPath = botProjectPath;
|
|
7764
|
-
this.projectCachePath =
|
|
8155
|
+
this.projectCachePath = path29.join(botProjectPath, ".botpress", "project.cache.json");
|
|
7765
8156
|
}
|
|
7766
8157
|
async getClient() {
|
|
7767
8158
|
if (!this.client) {
|
|
@@ -7798,7 +8189,7 @@ class DevIdManager {
|
|
|
7798
8189
|
}
|
|
7799
8190
|
async saveProjectCache(cache2) {
|
|
7800
8191
|
try {
|
|
7801
|
-
await fs13.mkdir(
|
|
8192
|
+
await fs13.mkdir(path29.dirname(this.projectCachePath), { recursive: true });
|
|
7802
8193
|
await fs13.writeFile(this.projectCachePath, JSON.stringify(cache2, null, 2));
|
|
7803
8194
|
} catch (error) {
|
|
7804
8195
|
console.error("Error saving project.cache.json:", error);
|
|
@@ -7847,7 +8238,7 @@ class DevIdManager {
|
|
|
7847
8238
|
}
|
|
7848
8239
|
|
|
7849
8240
|
// src/bot-generator/integration-sync.ts
|
|
7850
|
-
import
|
|
8241
|
+
import path30 from "path";
|
|
7851
8242
|
import fs14 from "fs/promises";
|
|
7852
8243
|
import { existsSync as existsSync5 } from "fs";
|
|
7853
8244
|
class IntegrationSync {
|
|
@@ -7857,7 +8248,7 @@ class IntegrationSync {
|
|
|
7857
8248
|
constructor(projectPath, botProjectPath) {
|
|
7858
8249
|
this.projectPath = projectPath;
|
|
7859
8250
|
this.botProjectPath = botProjectPath;
|
|
7860
|
-
this.bpModulesPath =
|
|
8251
|
+
this.bpModulesPath = path30.join(botProjectPath, "bp_modules");
|
|
7861
8252
|
}
|
|
7862
8253
|
async parseIntegrations() {
|
|
7863
8254
|
const project = await AgentProject.load(this.projectPath);
|
|
@@ -7888,12 +8279,12 @@ class IntegrationSync {
|
|
|
7888
8279
|
return integrations;
|
|
7889
8280
|
}
|
|
7890
8281
|
async isIntegrationSynced(integration) {
|
|
7891
|
-
const targetFolder =
|
|
8282
|
+
const targetFolder = path30.join(this.bpModulesPath, `integration_${integration.alias}`);
|
|
7892
8283
|
if (!existsSync5(targetFolder)) {
|
|
7893
8284
|
return false;
|
|
7894
8285
|
}
|
|
7895
8286
|
try {
|
|
7896
|
-
const indexPath =
|
|
8287
|
+
const indexPath = path30.join(targetFolder, "index.ts");
|
|
7897
8288
|
if (!existsSync5(indexPath)) {
|
|
7898
8289
|
return false;
|
|
7899
8290
|
}
|
|
@@ -7925,8 +8316,8 @@ class IntegrationSync {
|
|
|
7925
8316
|
await command.output();
|
|
7926
8317
|
}
|
|
7927
8318
|
async renameIntegrationFolder(integration) {
|
|
7928
|
-
const sourceFolder =
|
|
7929
|
-
const targetFolder =
|
|
8319
|
+
const sourceFolder = path30.join(this.bpModulesPath, integration.name.replace("/", "-"));
|
|
8320
|
+
const targetFolder = path30.join(this.bpModulesPath, `integration_${integration.alias}`);
|
|
7930
8321
|
if (!existsSync5(sourceFolder)) {
|
|
7931
8322
|
throw new Error(`Integration folder not found: ${sourceFolder}`);
|
|
7932
8323
|
}
|
|
@@ -7936,7 +8327,7 @@ class IntegrationSync {
|
|
|
7936
8327
|
await fs14.rename(sourceFolder, targetFolder);
|
|
7937
8328
|
}
|
|
7938
8329
|
async removeIntegrationFolder(alias) {
|
|
7939
|
-
const targetFolder =
|
|
8330
|
+
const targetFolder = path30.join(this.bpModulesPath, `integration_${alias}`);
|
|
7940
8331
|
if (existsSync5(targetFolder)) {
|
|
7941
8332
|
await fs14.rm(targetFolder, { recursive: true, force: true });
|
|
7942
8333
|
}
|
|
@@ -7970,7 +8361,7 @@ class IntegrationSync {
|
|
|
7970
8361
|
}
|
|
7971
8362
|
|
|
7972
8363
|
// src/bot-generator/interface-sync.ts
|
|
7973
|
-
import
|
|
8364
|
+
import path31 from "path";
|
|
7974
8365
|
import fs15 from "fs/promises";
|
|
7975
8366
|
import { existsSync as existsSync6 } from "fs";
|
|
7976
8367
|
init_constants();
|
|
@@ -7981,7 +8372,7 @@ class InterfaceSync {
|
|
|
7981
8372
|
constructor(projectPath, botProjectPath) {
|
|
7982
8373
|
this.projectPath = projectPath;
|
|
7983
8374
|
this.botProjectPath = botProjectPath;
|
|
7984
|
-
this.bpModulesPath =
|
|
8375
|
+
this.bpModulesPath = path31.join(botProjectPath, "bp_modules");
|
|
7985
8376
|
}
|
|
7986
8377
|
async parseInterfaces() {
|
|
7987
8378
|
const interfaces = [];
|
|
@@ -7999,12 +8390,12 @@ class InterfaceSync {
|
|
|
7999
8390
|
return interfaces;
|
|
8000
8391
|
}
|
|
8001
8392
|
async isInterfaceSynced(interfaceInfo) {
|
|
8002
|
-
const targetFolder =
|
|
8393
|
+
const targetFolder = path31.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
|
|
8003
8394
|
if (!existsSync6(targetFolder)) {
|
|
8004
8395
|
return false;
|
|
8005
8396
|
}
|
|
8006
8397
|
try {
|
|
8007
|
-
const indexPath =
|
|
8398
|
+
const indexPath = path31.join(targetFolder, "index.ts");
|
|
8008
8399
|
if (!existsSync6(indexPath)) {
|
|
8009
8400
|
return false;
|
|
8010
8401
|
}
|
|
@@ -8050,8 +8441,8 @@ class InterfaceSync {
|
|
|
8050
8441
|
});
|
|
8051
8442
|
}
|
|
8052
8443
|
async renameInterfaceFolder(interfaceInfo) {
|
|
8053
|
-
const sourceFolder =
|
|
8054
|
-
const targetFolder =
|
|
8444
|
+
const sourceFolder = path31.join(this.bpModulesPath, interfaceInfo.name);
|
|
8445
|
+
const targetFolder = path31.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
|
|
8055
8446
|
if (!existsSync6(sourceFolder)) {
|
|
8056
8447
|
throw new Error(`Interface folder not found: ${sourceFolder}`);
|
|
8057
8448
|
}
|
|
@@ -8061,7 +8452,7 @@ class InterfaceSync {
|
|
|
8061
8452
|
await fs15.rename(sourceFolder, targetFolder);
|
|
8062
8453
|
}
|
|
8063
8454
|
async removeInterfaceFolder(alias) {
|
|
8064
|
-
const targetFolder =
|
|
8455
|
+
const targetFolder = path31.join(this.bpModulesPath, `interface_${pascalCase(alias)}`);
|
|
8065
8456
|
if (existsSync6(targetFolder)) {
|
|
8066
8457
|
await fs15.rm(targetFolder, { recursive: true, force: true });
|
|
8067
8458
|
}
|
|
@@ -8098,26 +8489,28 @@ class InterfaceSync {
|
|
|
8098
8489
|
init_utils();
|
|
8099
8490
|
import { transforms as transforms3 } from "@botpress/sdk";
|
|
8100
8491
|
init_constants();
|
|
8101
|
-
import { BuiltInActions as BuiltInActions2, BuiltInWorkflows as
|
|
8492
|
+
import { BuiltInActions as BuiltInActions2, BuiltInWorkflows as BuiltInWorkflows4, Primitives as Primitives3 } from "@botpress/runtime/internal";
|
|
8102
8493
|
import { BUILT_IN_TAGS as BUILT_IN_TAGS2 } from "@botpress/runtime/definition";
|
|
8103
8494
|
var plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
8104
|
-
function
|
|
8105
|
-
return !!Object.values(
|
|
8495
|
+
function isBuiltinWorkflow3(name) {
|
|
8496
|
+
return !!Object.values(BuiltInWorkflows4).find((x) => x.name === name);
|
|
8106
8497
|
}
|
|
8107
8498
|
function isBuiltinAction(name) {
|
|
8108
8499
|
return !!Object.values(BuiltInActions2).find((x) => x.name === name);
|
|
8109
8500
|
}
|
|
8110
8501
|
function getImportPath(from, to) {
|
|
8111
|
-
return
|
|
8502
|
+
return path34.relative(path34.dirname(from), to).replace(/\.ts$/, "").replace(/\\/g, "/");
|
|
8112
8503
|
}
|
|
8113
8504
|
|
|
8114
8505
|
class BotGenerator {
|
|
8115
8506
|
projectPath;
|
|
8116
8507
|
outputPath;
|
|
8508
|
+
adkCommand;
|
|
8117
8509
|
callbacks;
|
|
8118
8510
|
constructor(options) {
|
|
8119
|
-
this.projectPath =
|
|
8120
|
-
this.outputPath =
|
|
8511
|
+
this.projectPath = path34.resolve(options.projectPath);
|
|
8512
|
+
this.outputPath = path34.resolve(options.outputPath || path34.join(this.projectPath, ".adk"));
|
|
8513
|
+
this.adkCommand = options.adkCommand;
|
|
8121
8514
|
this.callbacks = options.callbacks;
|
|
8122
8515
|
}
|
|
8123
8516
|
async listFilesRecursive(rootDir) {
|
|
@@ -8128,8 +8521,8 @@ class BotGenerator {
|
|
|
8128
8521
|
const walk = async (dir, relativeBase) => {
|
|
8129
8522
|
const entries = await fs16.readdir(dir, { withFileTypes: true });
|
|
8130
8523
|
for (const entry of entries) {
|
|
8131
|
-
const abs =
|
|
8132
|
-
const rel =
|
|
8524
|
+
const abs = path34.join(dir, entry.name);
|
|
8525
|
+
const rel = path34.join(relativeBase, entry.name);
|
|
8133
8526
|
if (entry.isDirectory()) {
|
|
8134
8527
|
await walk(abs, rel);
|
|
8135
8528
|
} else {
|
|
@@ -8150,7 +8543,7 @@ class BotGenerator {
|
|
|
8150
8543
|
const entries = await fs16.readdir(dir, { withFileTypes: true });
|
|
8151
8544
|
for (const entry of entries) {
|
|
8152
8545
|
if (entry.isDirectory()) {
|
|
8153
|
-
const subdir =
|
|
8546
|
+
const subdir = path34.join(dir, entry.name);
|
|
8154
8547
|
await removeIfEmpty(subdir);
|
|
8155
8548
|
}
|
|
8156
8549
|
}
|
|
@@ -8182,6 +8575,7 @@ class BotGenerator {
|
|
|
8182
8575
|
await this.generateEventTypes();
|
|
8183
8576
|
await this.generateIntegrationActionTypes();
|
|
8184
8577
|
await this.generateRuntimeTypes();
|
|
8578
|
+
await this.generateClientWrapper();
|
|
8185
8579
|
await this.generateBotIndex();
|
|
8186
8580
|
await this.generatePackageJson(project);
|
|
8187
8581
|
await this.generateTsConfig();
|
|
@@ -8194,18 +8588,18 @@ class BotGenerator {
|
|
|
8194
8588
|
workspaceId: project.agentInfo?.workspaceId
|
|
8195
8589
|
});
|
|
8196
8590
|
const integrations = await manager3.loadIntegrations(project.dependencies || {});
|
|
8197
|
-
const integrationsDir =
|
|
8591
|
+
const integrationsDir = path34.join(this.projectPath, ".adk", "integrations");
|
|
8198
8592
|
const existingIntegrationFiles = await this.listFilesRecursive(integrationsDir);
|
|
8199
8593
|
let aliases = new Set;
|
|
8200
8594
|
let files = new Set;
|
|
8201
8595
|
for (const integration of integrations.integrations) {
|
|
8202
8596
|
if (integration.definition) {
|
|
8203
8597
|
const types6 = await generateIntegrationTypes(integration);
|
|
8204
|
-
const importPath = `./${
|
|
8598
|
+
const importPath = `./${path34.join("integrations", types6.names.paths.index).replace(/\\/g, "/")}`;
|
|
8205
8599
|
aliases.add(`"${integration.alias}": import("${importPath}").${types6.names.typings.index}`);
|
|
8206
8600
|
for (const [filePath, content] of Object.entries(types6.files)) {
|
|
8207
|
-
const fullPath =
|
|
8208
|
-
const dir =
|
|
8601
|
+
const fullPath = path34.join(this.projectPath, ".adk", "integrations", filePath);
|
|
8602
|
+
const dir = path34.dirname(fullPath);
|
|
8209
8603
|
await fs16.mkdir(dir, { recursive: true });
|
|
8210
8604
|
await createFile(fullPath, content);
|
|
8211
8605
|
files.add(filePath);
|
|
@@ -8226,11 +8620,11 @@ class BotGenerator {
|
|
|
8226
8620
|
};
|
|
8227
8621
|
}
|
|
8228
8622
|
`;
|
|
8229
|
-
await createFile(
|
|
8623
|
+
await createFile(path34.join(this.projectPath, ".adk", "integrations-types.d.ts"), await formatCode(types5));
|
|
8230
8624
|
const staleIntegrationFiles = existingIntegrationFiles.filter((f) => !files.has(f));
|
|
8231
8625
|
if (staleIntegrationFiles.length > 0) {
|
|
8232
8626
|
for (const rel of staleIntegrationFiles) {
|
|
8233
|
-
const abs =
|
|
8627
|
+
const abs = path34.join(integrationsDir, rel);
|
|
8234
8628
|
try {
|
|
8235
8629
|
await fs16.rm(abs, { force: true });
|
|
8236
8630
|
} catch {}
|
|
@@ -8280,6 +8674,10 @@ class BotGenerator {
|
|
|
8280
8674
|
const { generateIntegrationActionTypes: generateIntegrationActionTypes2 } = await Promise.resolve().then(() => (init_integration_action_types(), exports_integration_action_types));
|
|
8281
8675
|
await generateIntegrationActionTypes2(project);
|
|
8282
8676
|
}
|
|
8677
|
+
async generateClientWrapper() {
|
|
8678
|
+
const project = await AgentProject.load(this.projectPath);
|
|
8679
|
+
await generateClientWrapper(project);
|
|
8680
|
+
}
|
|
8283
8681
|
async generateRuntimeTypes() {
|
|
8284
8682
|
const project = await AgentProject.load(this.projectPath);
|
|
8285
8683
|
const manager3 = new IntegrationManager({
|
|
@@ -8299,7 +8697,7 @@ class BotGenerator {
|
|
|
8299
8697
|
let botStateType = "{}";
|
|
8300
8698
|
let userStateType = "{}";
|
|
8301
8699
|
try {
|
|
8302
|
-
const configPath =
|
|
8700
|
+
const configPath = path34.join(project.path, "agent.config.ts");
|
|
8303
8701
|
const configModule = await import(`${configPath}?t=${Date.now()}`);
|
|
8304
8702
|
const config = configModule.default;
|
|
8305
8703
|
if (config?.bot?.state) {
|
|
@@ -8335,7 +8733,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
8335
8733
|
export type UserState = ${userStateType};
|
|
8336
8734
|
}
|
|
8337
8735
|
`;
|
|
8338
|
-
await createFile(
|
|
8736
|
+
await createFile(path34.join(this.projectPath, ".adk", "runtime.d.ts"), await formatCode(types5));
|
|
8339
8737
|
}
|
|
8340
8738
|
async generateInterfacesTypes() {
|
|
8341
8739
|
const project = await AgentProject.load(this.projectPath);
|
|
@@ -8343,7 +8741,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
8343
8741
|
workspaceId: project.agentInfo?.workspaceId
|
|
8344
8742
|
});
|
|
8345
8743
|
const manager3 = new InterfaceManager;
|
|
8346
|
-
const interfacesDir =
|
|
8744
|
+
const interfacesDir = path34.join(this.projectPath, ".adk", "interfaces");
|
|
8347
8745
|
const existingInterfaceFiles = await this.listFilesRecursive(interfacesDir);
|
|
8348
8746
|
const interfaces = await manager3.loadInterfaces(project.dependencies || {}).then((result) => result.interfaces.filter((int) => int.definition).map((x) => x.definition));
|
|
8349
8747
|
const integrationsWithAlias = await integrationManager.loadIntegrations(project.dependencies || {}).then((result) => result.integrations.filter((int) => int.enabled && int.definition).map((x) => ({ alias: x.alias, definition: x.definition })));
|
|
@@ -8352,11 +8750,11 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
8352
8750
|
let files = new Set;
|
|
8353
8751
|
for (const int of interfaces) {
|
|
8354
8752
|
const types6 = await generateInterfaceTypes(int, integrationsWithAlias);
|
|
8355
|
-
imports.add(`import { ${types6.names.typings.index} } from "./${
|
|
8753
|
+
imports.add(`import { ${types6.names.typings.index} } from "./${path34.join("interfaces", types6.names.paths.index).replace(/\\/g, "/")}";`);
|
|
8356
8754
|
aliases.add(`"${types6.names.name}": ${types6.names.typings.index}`);
|
|
8357
8755
|
for (const [filePath, content] of Object.entries(types6.files)) {
|
|
8358
|
-
const fullPath =
|
|
8359
|
-
const dir =
|
|
8756
|
+
const fullPath = path34.join(this.projectPath, ".adk", "interfaces", filePath);
|
|
8757
|
+
const dir = path34.dirname(fullPath);
|
|
8360
8758
|
await fs16.mkdir(dir, { recursive: true });
|
|
8361
8759
|
await createFile(fullPath, content);
|
|
8362
8760
|
files.add(filePath);
|
|
@@ -8393,12 +8791,12 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
8393
8791
|
`)}
|
|
8394
8792
|
};
|
|
8395
8793
|
`;
|
|
8396
|
-
await createFile(
|
|
8397
|
-
await createFile(
|
|
8794
|
+
await createFile(path34.join(this.projectPath, ".adk", "interfaces.d.ts"), await formatCode(types5));
|
|
8795
|
+
await createFile(path34.join(this.projectPath, ".adk", "interfaces.ts"), await formatCode(consts));
|
|
8398
8796
|
const staleInterfaceFiles = existingInterfaceFiles.filter((f) => !files.has(f));
|
|
8399
8797
|
if (staleInterfaceFiles.length > 0) {
|
|
8400
8798
|
for (const rel of staleInterfaceFiles) {
|
|
8401
|
-
const abs =
|
|
8799
|
+
const abs = path34.join(interfacesDir, rel);
|
|
8402
8800
|
try {
|
|
8403
8801
|
await fs16.rm(abs, { force: true });
|
|
8404
8802
|
} catch {}
|
|
@@ -8431,7 +8829,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
8431
8829
|
`) : ""}
|
|
8432
8830
|
} as Record<string, IntegrationPackage>;
|
|
8433
8831
|
`;
|
|
8434
|
-
await createFile(
|
|
8832
|
+
await createFile(path34.join(this.outputPath, "src", "integrations.ts"), content);
|
|
8435
8833
|
}
|
|
8436
8834
|
async generateInterfacesDefinition() {
|
|
8437
8835
|
const interfaces = BUILTIN_INTERFACES;
|
|
@@ -8454,7 +8852,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
8454
8852
|
`) : ""}
|
|
8455
8853
|
} as Record<string, InterfacePackage>;
|
|
8456
8854
|
`;
|
|
8457
|
-
await createFile(
|
|
8855
|
+
await createFile(path34.join(this.outputPath, "src", "interfaces.ts"), await formatCode(content));
|
|
8458
8856
|
}
|
|
8459
8857
|
reportServerConfigSync(serverConfigResult, integrations) {
|
|
8460
8858
|
if (!this.callbacks) {
|
|
@@ -8493,7 +8891,9 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
8493
8891
|
const project = await AgentProject.load(this.projectPath);
|
|
8494
8892
|
const integrations = project.integrations;
|
|
8495
8893
|
const enabledIntegrations = integrations.filter((i) => i.enabled);
|
|
8496
|
-
const
|
|
8894
|
+
const isDeployOrBuild = this.adkCommand === "adk-deploy" || this.adkCommand === "adk-build";
|
|
8895
|
+
const configTargetBotId = isDeployOrBuild ? project.agentInfo?.botId : undefined;
|
|
8896
|
+
const serverConfigResult = await fetchServerIntegrationConfigs(project, configTargetBotId);
|
|
8497
8897
|
this.reportServerConfigSync(serverConfigResult, enabledIntegrations);
|
|
8498
8898
|
const imports = [];
|
|
8499
8899
|
const addIntegrations = [];
|
|
@@ -8526,9 +8926,9 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
8526
8926
|
if (project.config?.workflow?.tags) {
|
|
8527
8927
|
Object.assign(workflowTags, project.config.workflow.tags);
|
|
8528
8928
|
}
|
|
8529
|
-
const
|
|
8929
|
+
const crypto5 = __require("crypto");
|
|
8530
8930
|
const hashString = (str) => {
|
|
8531
|
-
return
|
|
8931
|
+
return crypto5.createHash("md5").update(str).digest("hex").substring(0, 5).toUpperCase();
|
|
8532
8932
|
};
|
|
8533
8933
|
for (const trigger of project.triggers) {
|
|
8534
8934
|
const triggerName = trigger.definition.name;
|
|
@@ -8543,10 +8943,10 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
8543
8943
|
const workflowInstances = [];
|
|
8544
8944
|
for (const workflow of project.workflows) {
|
|
8545
8945
|
try {
|
|
8546
|
-
if (
|
|
8946
|
+
if (isBuiltinWorkflow3(workflow.definition.name)) {
|
|
8547
8947
|
continue;
|
|
8548
8948
|
}
|
|
8549
|
-
const workflowPath =
|
|
8949
|
+
const workflowPath = path34.join(project.path, workflow.path);
|
|
8550
8950
|
const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
|
|
8551
8951
|
const workflowInstance = workflowModule.default || workflowModule[workflow.export];
|
|
8552
8952
|
if (workflowInstance) {
|
|
@@ -8556,7 +8956,7 @@ declare module "@botpress/runtime/_types/state" {
|
|
|
8556
8956
|
console.error(`Failed to load workflow ${workflow.definition.name}:`, error);
|
|
8557
8957
|
}
|
|
8558
8958
|
}
|
|
8559
|
-
for (const workflow of Object.values(
|
|
8959
|
+
for (const workflow of Object.values(BuiltInWorkflows4)) {
|
|
8560
8960
|
workflowInstances.push(workflow);
|
|
8561
8961
|
}
|
|
8562
8962
|
for (const workflow of workflowInstances) {
|
|
@@ -8801,7 +9201,7 @@ configuration: {
|
|
|
8801
9201
|
const fullContent = content + integrationsSection + `
|
|
8802
9202
|
|
|
8803
9203
|
export default bot;`;
|
|
8804
|
-
await createFile(
|
|
9204
|
+
await createFile(path34.join(this.outputPath, "bot.definition.ts"), await formatCode(fullContent));
|
|
8805
9205
|
}
|
|
8806
9206
|
async generateBotIndex() {
|
|
8807
9207
|
const content = dedent`
|
|
@@ -8840,7 +9240,7 @@ export default bot;`;
|
|
|
8840
9240
|
|
|
8841
9241
|
export default bot
|
|
8842
9242
|
`;
|
|
8843
|
-
await createFile(
|
|
9243
|
+
await createFile(path34.join(this.outputPath, "src", "index.ts"), await formatCode(content));
|
|
8844
9244
|
}
|
|
8845
9245
|
async generatePackageJson(project) {
|
|
8846
9246
|
const packageJson = {
|
|
@@ -8854,7 +9254,7 @@ export default bot;`;
|
|
|
8854
9254
|
typescript: "^5.9.3"
|
|
8855
9255
|
}
|
|
8856
9256
|
};
|
|
8857
|
-
await createFile(
|
|
9257
|
+
await createFile(path34.join(this.outputPath, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
8858
9258
|
}
|
|
8859
9259
|
async generateTsConfig() {
|
|
8860
9260
|
const tsConfig = {
|
|
@@ -8885,7 +9285,7 @@ export default bot;`;
|
|
|
8885
9285
|
},
|
|
8886
9286
|
include: [".botpress/**/*", "src/**/*", "bp_modules/**/*", "./*.ts", "./*.json", "../*.d.ts"]
|
|
8887
9287
|
};
|
|
8888
|
-
await createFile(
|
|
9288
|
+
await createFile(path34.join(this.outputPath, "tsconfig.json"), JSON.stringify(tsConfig, null, 2));
|
|
8889
9289
|
}
|
|
8890
9290
|
async generateGlobalTypes() {
|
|
8891
9291
|
const content = dedent`
|
|
@@ -8908,11 +9308,11 @@ export default bot;`;
|
|
|
8908
9308
|
|
|
8909
9309
|
export {};
|
|
8910
9310
|
`;
|
|
8911
|
-
await createFile(
|
|
9311
|
+
await createFile(path34.join(this.outputPath, "global.d.ts"), await formatCode(content));
|
|
8912
9312
|
}
|
|
8913
9313
|
async copyAssets() {
|
|
8914
|
-
const assetsPath =
|
|
8915
|
-
const targetPath =
|
|
9314
|
+
const assetsPath = path34.join(this.projectPath, "assets");
|
|
9315
|
+
const targetPath = path34.join(this.outputPath, "assets");
|
|
8916
9316
|
if (existsSync7(assetsPath)) {
|
|
8917
9317
|
await fs16.mkdir(targetPath, { recursive: true });
|
|
8918
9318
|
await this.copyDirectory(assetsPath, targetPath);
|
|
@@ -8921,8 +9321,8 @@ export default bot;`;
|
|
|
8921
9321
|
async copyDirectory(src, dest) {
|
|
8922
9322
|
const entries = await fs16.readdir(src, { withFileTypes: true });
|
|
8923
9323
|
for (const entry of entries) {
|
|
8924
|
-
const srcPath =
|
|
8925
|
-
const destPath =
|
|
9324
|
+
const srcPath = path34.join(src, entry.name);
|
|
9325
|
+
const destPath = path34.join(dest, entry.name);
|
|
8926
9326
|
if (entry.isDirectory()) {
|
|
8927
9327
|
await fs16.mkdir(destPath, { recursive: true });
|
|
8928
9328
|
await this.copyDirectory(srcPath, destPath);
|
|
@@ -8934,16 +9334,16 @@ export default bot;`;
|
|
|
8934
9334
|
async generateAdkRuntime() {
|
|
8935
9335
|
const project = new AgentProject(this.projectPath);
|
|
8936
9336
|
await project.reload();
|
|
8937
|
-
const srcDir =
|
|
9337
|
+
const srcDir = path34.join(this.outputPath, "src");
|
|
8938
9338
|
{
|
|
8939
|
-
const dest =
|
|
9339
|
+
const dest = path34.join(srcDir, "conversations.ts");
|
|
8940
9340
|
const imports = new Map;
|
|
8941
9341
|
const exports = new Set;
|
|
8942
9342
|
let index = 1;
|
|
8943
9343
|
for (const conversation of project.conversations) {
|
|
8944
9344
|
if (!imports.has(conversation.path)) {
|
|
8945
9345
|
const name = `conversations_${index++}`;
|
|
8946
|
-
const importPath = getImportPath(dest,
|
|
9346
|
+
const importPath = getImportPath(dest, path34.join(project.path, conversation.path));
|
|
8947
9347
|
imports.set(conversation.path, {
|
|
8948
9348
|
name,
|
|
8949
9349
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -8969,14 +9369,14 @@ export default bot;`;
|
|
|
8969
9369
|
await createFile(dest, await formatCode(content2));
|
|
8970
9370
|
}
|
|
8971
9371
|
{
|
|
8972
|
-
const dest =
|
|
9372
|
+
const dest = path34.join(srcDir, "knowledge.ts");
|
|
8973
9373
|
const imports = new Map;
|
|
8974
9374
|
const exports = new Set;
|
|
8975
9375
|
let index = 1;
|
|
8976
9376
|
for (const knowledge of project.knowledge) {
|
|
8977
9377
|
if (!imports.has(knowledge.path)) {
|
|
8978
9378
|
const name = `knowledge_${index++}`;
|
|
8979
|
-
const importPath = getImportPath(dest,
|
|
9379
|
+
const importPath = getImportPath(dest, path34.join(project.path, knowledge.path));
|
|
8980
9380
|
imports.set(knowledge.path, {
|
|
8981
9381
|
name,
|
|
8982
9382
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -9002,7 +9402,7 @@ export default bot;`;
|
|
|
9002
9402
|
await createFile(dest, await formatCode(content2));
|
|
9003
9403
|
}
|
|
9004
9404
|
{
|
|
9005
|
-
const dest =
|
|
9405
|
+
const dest = path34.join(srcDir, "triggers.ts");
|
|
9006
9406
|
const { transforms: transforms4 } = await import("@botpress/sdk");
|
|
9007
9407
|
const imports = new Map;
|
|
9008
9408
|
const exports = new Set;
|
|
@@ -9011,7 +9411,7 @@ export default bot;`;
|
|
|
9011
9411
|
for (const trigger of project.triggers) {
|
|
9012
9412
|
if (!imports.has(trigger.path)) {
|
|
9013
9413
|
const name = `triggers_${index++}`;
|
|
9014
|
-
const importPath = getImportPath(dest,
|
|
9414
|
+
const importPath = getImportPath(dest, path34.join(project.path, trigger.path));
|
|
9015
9415
|
imports.set(trigger.path, {
|
|
9016
9416
|
name,
|
|
9017
9417
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -9021,7 +9421,7 @@ export default bot;`;
|
|
|
9021
9421
|
}
|
|
9022
9422
|
for (const trigger of project.triggers) {
|
|
9023
9423
|
try {
|
|
9024
|
-
const absolutePath =
|
|
9424
|
+
const absolutePath = path34.join(project.path, trigger.path);
|
|
9025
9425
|
const triggerModule = await import(`${absolutePath}?t=${Date.now()}`);
|
|
9026
9426
|
const triggerInstance = triggerModule[trigger.export] || triggerModule.default;
|
|
9027
9427
|
if (triggerInstance && triggerInstance.payload) {
|
|
@@ -9064,17 +9464,17 @@ export default bot;`;
|
|
|
9064
9464
|
await createFile(dest, await formatCode(content2));
|
|
9065
9465
|
}
|
|
9066
9466
|
{
|
|
9067
|
-
const dest =
|
|
9467
|
+
const dest = path34.join(srcDir, "workflows.ts");
|
|
9068
9468
|
const imports = new Map;
|
|
9069
9469
|
const exports = new Set;
|
|
9070
9470
|
let index = 1;
|
|
9071
9471
|
for (const workflow of project.workflows) {
|
|
9072
|
-
if (
|
|
9472
|
+
if (isBuiltinWorkflow3(workflow.definition.name)) {
|
|
9073
9473
|
continue;
|
|
9074
9474
|
}
|
|
9075
9475
|
if (!imports.has(workflow.path)) {
|
|
9076
9476
|
const name = `workflows_${index++}`;
|
|
9077
|
-
const importPath = getImportPath(dest,
|
|
9477
|
+
const importPath = getImportPath(dest, path34.join(project.path, workflow.path));
|
|
9078
9478
|
const statement = `import * as ${name} from "${importPath}";`;
|
|
9079
9479
|
imports.set(workflow.path, {
|
|
9080
9480
|
name,
|
|
@@ -9083,7 +9483,7 @@ export default bot;`;
|
|
|
9083
9483
|
}
|
|
9084
9484
|
}
|
|
9085
9485
|
for (const workflow of project.workflows) {
|
|
9086
|
-
if (
|
|
9486
|
+
if (isBuiltinWorkflow3(workflow.definition.name)) {
|
|
9087
9487
|
continue;
|
|
9088
9488
|
}
|
|
9089
9489
|
const importEntry = imports.get(workflow.path);
|
|
@@ -9108,7 +9508,7 @@ export default bot;`;
|
|
|
9108
9508
|
await createFile(dest, await formatCode(content2));
|
|
9109
9509
|
}
|
|
9110
9510
|
{
|
|
9111
|
-
const dest =
|
|
9511
|
+
const dest = path34.join(srcDir, "actions.ts");
|
|
9112
9512
|
const imports = new Map;
|
|
9113
9513
|
const exports = new Set;
|
|
9114
9514
|
let index = 1;
|
|
@@ -9118,7 +9518,7 @@ export default bot;`;
|
|
|
9118
9518
|
}
|
|
9119
9519
|
if (!imports.has(action.path)) {
|
|
9120
9520
|
const name = `actions_${index++}`;
|
|
9121
|
-
const importPath = getImportPath(dest,
|
|
9521
|
+
const importPath = getImportPath(dest, path34.join(project.path, action.path));
|
|
9122
9522
|
imports.set(action.path, {
|
|
9123
9523
|
name,
|
|
9124
9524
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -9144,14 +9544,14 @@ export default bot;`;
|
|
|
9144
9544
|
await createFile(dest, await formatCode(content2));
|
|
9145
9545
|
}
|
|
9146
9546
|
{
|
|
9147
|
-
const dest =
|
|
9547
|
+
const dest = path34.join(srcDir, "tables.ts");
|
|
9148
9548
|
const imports = new Map;
|
|
9149
9549
|
const exports = new Set;
|
|
9150
9550
|
let index = 1;
|
|
9151
9551
|
for (const table of project.tables) {
|
|
9152
9552
|
if (!imports.has(table.path)) {
|
|
9153
9553
|
const name = `tables_${index++}`;
|
|
9154
|
-
const importPath = getImportPath(dest,
|
|
9554
|
+
const importPath = getImportPath(dest, path34.join(project.path, table.path));
|
|
9155
9555
|
imports.set(table.path, {
|
|
9156
9556
|
name,
|
|
9157
9557
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -9177,8 +9577,8 @@ export default bot;`;
|
|
|
9177
9577
|
await createFile(dest, await formatCode(content2));
|
|
9178
9578
|
}
|
|
9179
9579
|
{
|
|
9180
|
-
const dest =
|
|
9181
|
-
const importPath = getImportPath(dest,
|
|
9580
|
+
const dest = path34.join(srcDir, "config.ts");
|
|
9581
|
+
const importPath = getImportPath(dest, path34.join(project.path, "agent.config.ts"));
|
|
9182
9582
|
const content2 = `
|
|
9183
9583
|
////////////////////////////////////////////////////////
|
|
9184
9584
|
// DO NOT EDIT THIS FILE DIRECTLY
|
|
@@ -9244,13 +9644,13 @@ export default bot;`;
|
|
|
9244
9644
|
handlers.actions.setup(bot);
|
|
9245
9645
|
}
|
|
9246
9646
|
`;
|
|
9247
|
-
await createFile(
|
|
9647
|
+
await createFile(path34.join(this.outputPath, "src", "adk-runtime.ts"), await formatCode(content));
|
|
9248
9648
|
}
|
|
9249
9649
|
async copyAssetsRuntime() {
|
|
9250
|
-
const assetsRuntimePath =
|
|
9650
|
+
const assetsRuntimePath = path34.join(this.projectPath, ".adk", "assets-runtime.ts");
|
|
9251
9651
|
if (existsSync7(assetsRuntimePath)) {
|
|
9252
9652
|
const content = await fs16.readFile(assetsRuntimePath, "utf-8");
|
|
9253
|
-
await createFile(
|
|
9653
|
+
await createFile(path34.join(this.outputPath, "src", "assets-runtime.ts"), await formatCode(content));
|
|
9254
9654
|
}
|
|
9255
9655
|
}
|
|
9256
9656
|
}
|
|
@@ -9259,11 +9659,11 @@ async function generateBotProject(options) {
|
|
|
9259
9659
|
await generator.generate();
|
|
9260
9660
|
await generator.generateAdkRuntime();
|
|
9261
9661
|
await generator.copyAssetsRuntime();
|
|
9262
|
-
const botPath = options.outputPath ||
|
|
9662
|
+
const botPath = options.outputPath || path34.join(options.projectPath, ".adk", "bot");
|
|
9263
9663
|
await linkSdk(options.projectPath, botPath);
|
|
9264
|
-
const devIdManager = new DevIdManager(options.projectPath, options.outputPath ||
|
|
9664
|
+
const devIdManager = new DevIdManager(options.projectPath, options.outputPath || path34.join(options.projectPath, ".adk", "bot"));
|
|
9265
9665
|
await devIdManager.restoreDevId();
|
|
9266
|
-
const integrationSync = new IntegrationSync(options.projectPath, options.outputPath ||
|
|
9666
|
+
const integrationSync = new IntegrationSync(options.projectPath, options.outputPath || path34.join(options.projectPath, ".adk", "bot"));
|
|
9267
9667
|
const integrationSyncResult = await integrationSync.syncIntegrations();
|
|
9268
9668
|
if (integrationSyncResult.errors.length > 0) {
|
|
9269
9669
|
console.warn(`⚠️ Some integrations failed to sync:`);
|
|
@@ -9271,7 +9671,7 @@ async function generateBotProject(options) {
|
|
|
9271
9671
|
console.warn(` - ${alias}: ${error}`);
|
|
9272
9672
|
});
|
|
9273
9673
|
}
|
|
9274
|
-
const interfaceSync = new InterfaceSync(options.projectPath, options.outputPath ||
|
|
9674
|
+
const interfaceSync = new InterfaceSync(options.projectPath, options.outputPath || path34.join(options.projectPath, ".adk", "bot"));
|
|
9275
9675
|
const interfaceSyncResult = await interfaceSync.syncInterfaces();
|
|
9276
9676
|
if (interfaceSyncResult.errors.length > 0) {
|
|
9277
9677
|
console.warn(`⚠️ Some interfaces failed to sync:`);
|
|
@@ -9779,8 +10179,8 @@ class TableManager {
|
|
|
9779
10179
|
}
|
|
9780
10180
|
}
|
|
9781
10181
|
// src/knowledge/manager.ts
|
|
9782
|
-
import
|
|
9783
|
-
import
|
|
10182
|
+
import crypto5 from "crypto";
|
|
10183
|
+
import path35 from "path";
|
|
9784
10184
|
import fs17 from "fs/promises";
|
|
9785
10185
|
import { glob } from "glob";
|
|
9786
10186
|
import { Client as Client15 } from "@botpress/client";
|
|
@@ -9870,7 +10270,7 @@ class KnowledgeManager {
|
|
|
9870
10270
|
const sortedEntries = Object.entries(fileHashes).sort(([a], [b]) => a.localeCompare(b));
|
|
9871
10271
|
const combined = sortedEntries.map(([filePath, hash]) => `${filePath}:${hash}`).join(`
|
|
9872
10272
|
`);
|
|
9873
|
-
return
|
|
10273
|
+
return crypto5.createHash("sha256").update(combined).digest("hex");
|
|
9874
10274
|
}
|
|
9875
10275
|
async listRemoteKnowledgeBases() {
|
|
9876
10276
|
const client = await this.getClient();
|
|
@@ -9985,7 +10385,7 @@ class KnowledgeManager {
|
|
|
9985
10385
|
}
|
|
9986
10386
|
computeConfigHash(config) {
|
|
9987
10387
|
const sortedConfig = JSON.stringify(config, Object.keys(config).sort());
|
|
9988
|
-
return
|
|
10388
|
+
return crypto5.createHash("sha256").update(sortedConfig).digest("hex");
|
|
9989
10389
|
}
|
|
9990
10390
|
async syncWebsiteSource(kbName, kbId, force) {
|
|
9991
10391
|
const client = await this.getClient();
|
|
@@ -10230,16 +10630,16 @@ class KnowledgeManager {
|
|
|
10230
10630
|
}
|
|
10231
10631
|
async scanLocalFileHashes(directoryPath, filterFn) {
|
|
10232
10632
|
const projectDir = this.project.path;
|
|
10233
|
-
const directory =
|
|
10633
|
+
const directory = path35.resolve(projectDir, directoryPath);
|
|
10234
10634
|
if (this.fileHashCache.has(directory)) {
|
|
10235
10635
|
return this.fileHashCache.get(directory);
|
|
10236
10636
|
}
|
|
10237
10637
|
const files = glob.sync(directory + "/**/*.*", { absolute: true, nodir: true }).filter((file) => !filterFn || filterFn(file));
|
|
10238
10638
|
const hashes = {};
|
|
10239
10639
|
for (const file of files) {
|
|
10240
|
-
const relPath =
|
|
10640
|
+
const relPath = path35.relative(directory, file);
|
|
10241
10641
|
const content = await fs17.readFile(file);
|
|
10242
|
-
hashes[relPath] =
|
|
10642
|
+
hashes[relPath] = crypto5.createHash("sha256").update(content).digest("hex");
|
|
10243
10643
|
}
|
|
10244
10644
|
this.fileHashCache.set(directory, hashes);
|
|
10245
10645
|
return hashes;
|
|
@@ -10345,7 +10745,7 @@ class KnowledgeManager {
|
|
|
10345
10745
|
}
|
|
10346
10746
|
async syncDirectorySource(client, kbName, kbId, dsId, directoryPath, filterFn, force) {
|
|
10347
10747
|
const projectDir = this.project.path;
|
|
10348
|
-
const directory =
|
|
10748
|
+
const directory = path35.resolve(projectDir, directoryPath);
|
|
10349
10749
|
if (!directory.startsWith(projectDir)) {
|
|
10350
10750
|
throw new Error("Directory path must be within the agent's directory");
|
|
10351
10751
|
}
|
|
@@ -10367,8 +10767,8 @@ class KnowledgeManager {
|
|
|
10367
10767
|
return true;
|
|
10368
10768
|
}).map((f) => ({
|
|
10369
10769
|
abs: f,
|
|
10370
|
-
rel:
|
|
10371
|
-
name:
|
|
10770
|
+
rel: path35.relative(directory, f),
|
|
10771
|
+
name: path35.basename(f)
|
|
10372
10772
|
}));
|
|
10373
10773
|
console.log(` Found ${allFiles.length} files in ${directoryPath}`);
|
|
10374
10774
|
const cachedHashes = await this.scanLocalFileHashes(directoryPath, filterFn);
|
|
@@ -10443,14 +10843,14 @@ class KnowledgeManager {
|
|
|
10443
10843
|
async upsertFile(client, local, dsId, tags, force, cachedHash) {
|
|
10444
10844
|
const key = `data_source://document/${dsId}/${local.rel}`;
|
|
10445
10845
|
const content = await fs17.readFile(local.abs);
|
|
10446
|
-
const hash = cachedHash ??
|
|
10846
|
+
const hash = cachedHash ?? crypto5.createHash("sha256").update(content).digest("hex");
|
|
10447
10847
|
try {
|
|
10448
10848
|
const { file } = await client.getFile({ id: key });
|
|
10449
10849
|
if (!force && isFileMetadata(file.metadata) && file.metadata.hash === hash) {
|
|
10450
10850
|
return null;
|
|
10451
10851
|
}
|
|
10452
10852
|
} catch {}
|
|
10453
|
-
const title =
|
|
10853
|
+
const title = path35.basename(local.name, path35.extname(local.name));
|
|
10454
10854
|
const metadata = {
|
|
10455
10855
|
hash,
|
|
10456
10856
|
dsId,
|
|
@@ -10715,7 +11115,7 @@ class FileWatcher2 extends EventEmitter3 {
|
|
|
10715
11115
|
}
|
|
10716
11116
|
// src/preflight/checker.ts
|
|
10717
11117
|
import { Client as Client16 } from "@botpress/client";
|
|
10718
|
-
import
|
|
11118
|
+
import path36 from "path";
|
|
10719
11119
|
|
|
10720
11120
|
// src/preflight/types.ts
|
|
10721
11121
|
function hasIntegrationChanges(integrations) {
|
|
@@ -11077,7 +11477,7 @@ class PreflightChecker {
|
|
|
11077
11477
|
options?.onProgress?.("Regenerating bot project...");
|
|
11078
11478
|
await generateBotProject({
|
|
11079
11479
|
projectPath: this.projectPath,
|
|
11080
|
-
outputPath:
|
|
11480
|
+
outputPath: path36.join(this.projectPath, ".adk", "bot"),
|
|
11081
11481
|
callbacks: options
|
|
11082
11482
|
});
|
|
11083
11483
|
options?.onSuccess?.("Bot project regenerated");
|
|
@@ -11087,19 +11487,19 @@ class PreflightChecker {
|
|
|
11087
11487
|
import dedent2 from "dedent";
|
|
11088
11488
|
import { existsSync as existsSync9 } from "fs";
|
|
11089
11489
|
import fs18 from "fs/promises";
|
|
11090
|
-
import
|
|
11490
|
+
import path37 from "path";
|
|
11091
11491
|
import { spawn } from "child_process";
|
|
11092
11492
|
init_utils();
|
|
11093
11493
|
init_credentials();
|
|
11094
11494
|
async function findAgentRoot(startPath) {
|
|
11095
|
-
let currentPath =
|
|
11096
|
-
const root =
|
|
11495
|
+
let currentPath = path37.resolve(startPath);
|
|
11496
|
+
const root = path37.parse(currentPath).root;
|
|
11097
11497
|
while (currentPath !== root) {
|
|
11098
11498
|
try {
|
|
11099
|
-
await fs18.access(
|
|
11499
|
+
await fs18.access(path37.join(currentPath, "agent.config.ts"));
|
|
11100
11500
|
return currentPath;
|
|
11101
11501
|
} catch {
|
|
11102
|
-
currentPath =
|
|
11502
|
+
currentPath = path37.dirname(currentPath);
|
|
11103
11503
|
}
|
|
11104
11504
|
}
|
|
11105
11505
|
return null;
|
|
@@ -11111,7 +11511,7 @@ class ScriptRunner {
|
|
|
11111
11511
|
prod;
|
|
11112
11512
|
credentials;
|
|
11113
11513
|
constructor(options) {
|
|
11114
|
-
this.projectPath =
|
|
11514
|
+
this.projectPath = path37.resolve(options.projectPath);
|
|
11115
11515
|
this.forceRegenerate = options.forceRegenerate ?? false;
|
|
11116
11516
|
this.prod = options.prod ?? false;
|
|
11117
11517
|
this.credentials = options.credentials;
|
|
@@ -11120,9 +11520,9 @@ class ScriptRunner {
|
|
|
11120
11520
|
const project = await AgentProject.load(this.projectPath, {
|
|
11121
11521
|
adkCommand: "adk-build"
|
|
11122
11522
|
});
|
|
11123
|
-
const botPath =
|
|
11124
|
-
const runnerPath =
|
|
11125
|
-
const botpressTypesPath =
|
|
11523
|
+
const botPath = path37.join(this.projectPath, ".adk", "bot");
|
|
11524
|
+
const runnerPath = path37.join(botPath, "src", "script-runner.ts");
|
|
11525
|
+
const botpressTypesPath = path37.join(botPath, ".botpress", "implementation", "index.ts");
|
|
11126
11526
|
const needsRegenerate = this.forceRegenerate || !existsSync9(runnerPath) || !existsSync9(botpressTypesPath);
|
|
11127
11527
|
if (needsRegenerate) {
|
|
11128
11528
|
try {
|
|
@@ -11239,7 +11639,7 @@ class ScriptRunner {
|
|
|
11239
11639
|
|
|
11240
11640
|
runScript()
|
|
11241
11641
|
`;
|
|
11242
|
-
await fs18.writeFile(
|
|
11642
|
+
await fs18.writeFile(path37.join(botPath, "src", "script-runner.ts"), await formatCode(content), "utf-8");
|
|
11243
11643
|
}
|
|
11244
11644
|
async setupTestRuntime(options = {}) {
|
|
11245
11645
|
const { botPath, project } = await this.prepare();
|
|
@@ -11270,7 +11670,7 @@ class ScriptRunner {
|
|
|
11270
11670
|
for (const [key, value] of Object.entries(envVars)) {
|
|
11271
11671
|
process.env[key] = value;
|
|
11272
11672
|
}
|
|
11273
|
-
const runtimePath =
|
|
11673
|
+
const runtimePath = path37.join(botPath, "src", "index.ts");
|
|
11274
11674
|
return {
|
|
11275
11675
|
botPath,
|
|
11276
11676
|
runtimePath,
|
|
@@ -11318,7 +11718,7 @@ class ScriptRunner {
|
|
|
11318
11718
|
}
|
|
11319
11719
|
async run(scriptPath, options = {}) {
|
|
11320
11720
|
const { botPath, runnerPath, project } = await this.prepare();
|
|
11321
|
-
const absoluteScriptPath =
|
|
11721
|
+
const absoluteScriptPath = path37.isAbsolute(scriptPath) ? scriptPath : path37.resolve(this.projectPath, scriptPath);
|
|
11322
11722
|
if (!existsSync9(absoluteScriptPath)) {
|
|
11323
11723
|
throw new Error(`Script not found: ${absoluteScriptPath}`);
|
|
11324
11724
|
}
|
|
@@ -11417,6 +11817,7 @@ export {
|
|
|
11417
11817
|
initAssets,
|
|
11418
11818
|
getRelativeTime,
|
|
11419
11819
|
generateIntegrationTypes,
|
|
11820
|
+
generateClientWrapper,
|
|
11420
11821
|
generateBotProject,
|
|
11421
11822
|
generateAssetsTypes,
|
|
11422
11823
|
generateAssetsRuntime,
|
|
@@ -11467,4 +11868,4 @@ export {
|
|
|
11467
11868
|
AgentProject
|
|
11468
11869
|
};
|
|
11469
11870
|
|
|
11470
|
-
//# debugId=
|
|
11871
|
+
//# debugId=9C7E68110BCAF64064756E2164756E21
|