@botpress/adk 1.13.10 → 1.13.12

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.d.ts CHANGED
@@ -28,6 +28,6 @@ export { FileWatcher } from './file-watcher/index.js';
28
28
  export type { WatchChangeType, FileChange, FileChangeEvent as FileWatcherChangeEvent, FileWatcherOptions, } from './file-watcher/index.js';
29
29
  export { PreflightChecker, PreflightFormatter } from './preflight/index.js';
30
30
  export type { PreflightCheckResult, PendingPreflightResult } from './preflight/index.js';
31
- export { ScriptRunner, runScript } from './runner/index.js';
32
- export type { ScriptRunnerOptions, RunScriptOptions } from './runner/index.js';
31
+ export { ScriptRunner, runScript, setupTestRuntime } from './runner/index.js';
32
+ export type { ScriptRunnerOptions, RunScriptOptions, TestRuntimeResult, SetupTestRuntimeOptions } from './runner/index.js';
33
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG9F,cAAc,qBAAqB,CAAA;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAGvF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAm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,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAGxF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAC7E,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA"}
package/dist/index.js CHANGED
@@ -666,7 +666,7 @@ var PRETTIER_CONFIG, formatCode = async (code, filepath) => {
666
666
  `));
667
667
  return code;
668
668
  }
669
- }, ADK_VERSION = "1.13.10", relative2 = (from, to) => {
669
+ }, ADK_VERSION = "1.13.12", relative2 = (from, to) => {
670
670
  const fromDir = path10.dirname(from);
671
671
  const relative3 = path10.relative(fromDir, to);
672
672
  return relative3.startsWith(".") ? relative3 : `./${relative3}`;
@@ -809,7 +809,7 @@ var init_integration_action_types = __esm(() => {
809
809
  var require_package = __commonJS((exports, module) => {
810
810
  module.exports = {
811
811
  name: "@botpress/adk",
812
- version: "1.13.10",
812
+ version: "1.13.12",
813
813
  description: "Core ADK library for building AI agents on Botpress",
814
814
  type: "module",
815
815
  main: "dist/index.js",
@@ -856,7 +856,7 @@ var require_package = __commonJS((exports, module) => {
856
856
  "@botpress/cli": "^5.1.1",
857
857
  "@botpress/client": "^1.28.0",
858
858
  "@botpress/cognitive": "^0.3.3",
859
- "@botpress/runtime": "^1.13.10",
859
+ "@botpress/runtime": "^1.13.12",
860
860
  "@botpress/sdk": "^5.0.2",
861
861
  "@bpinternal/jex": "^1.2.4",
862
862
  "@bpinternal/yargs-extra": "^0.0.21",
@@ -6226,6 +6226,73 @@ name: "userdataTable"
6226
6226
  4. **Test in dev mode** with hot reloading (\`adk dev\`)
6227
6227
  5. **Follow TypeScript types** - They're auto-generated from integrations
6228
6228
 
6229
+ ## Running Tests
6230
+
6231
+ The ADK provides \`setupTestRuntime()\` to initialize the full ADK runtime within your test process. This sets up all environment variables, generates types, and imports the runtime so your tests can use actions, tools, workflows, etc.
6232
+
6233
+ ### Bun Test
6234
+
6235
+ \`\`\`toml
6236
+ # bunfig.toml
6237
+ [test]
6238
+ preload = ["./test-setup.ts"]
6239
+ \`\`\`
6240
+
6241
+ \`\`\`typescript
6242
+ // test-setup.ts
6243
+ import { beforeAll } from "bun:test";
6244
+ import { setupTestRuntime } from "@botpress/adk";
6245
+
6246
+ beforeAll(async () => {
6247
+ const runtime = await setupTestRuntime();
6248
+ await runtime.initialize();
6249
+ });
6250
+ \`\`\`
6251
+
6252
+ ### Vitest
6253
+
6254
+ \`\`\`typescript
6255
+ // vitest.setup.ts
6256
+ import { beforeAll } from "vitest";
6257
+ import { setupTestRuntime } from "@botpress/adk";
6258
+
6259
+ beforeAll(async () => {
6260
+ const runtime = await setupTestRuntime();
6261
+ await runtime.initialize();
6262
+ });
6263
+ \`\`\`
6264
+
6265
+ \`\`\`typescript
6266
+ // vitest.config.ts
6267
+ import { defineConfig } from "vitest/config";
6268
+
6269
+ export default defineConfig({
6270
+ test: {
6271
+ setupFiles: ["./vitest.setup.ts"],
6272
+ },
6273
+ });
6274
+ \`\`\`
6275
+
6276
+ ### Options
6277
+
6278
+ \`setupTestRuntime()\` auto-detects project path and credentials, but you can override:
6279
+
6280
+ \`\`\`typescript
6281
+ const runtime = await setupTestRuntime({
6282
+ projectPath: "/path/to/agent", // defaults to auto-detect from CWD
6283
+ credentials: { token: "...", apiUrl: "..." }, // defaults to ~/.adk/credentials
6284
+ prod: true, // use production bot instead of dev bot
6285
+ forceRegenerate: true, // force regenerate bot project
6286
+ env: { CUSTOM_VAR: "value" }, // additional env vars
6287
+ });
6288
+ \`\`\`
6289
+
6290
+ ### Prerequisites
6291
+
6292
+ - Must have \`@botpress/adk\` installed as a dev dependency (\`bun add -d @botpress/adk\`)
6293
+ - Must have run \`adk dev\` at least once (to create the dev bot)
6294
+ - Must be logged in (\`adk login\`) or provide credentials explicitly
6295
+
6229
6296
  ## Resources
6230
6297
 
6231
6298
  - [ADK Overview](https://botpress.com/docs/for-developers/adk/overview)
@@ -6280,7 +6347,7 @@ class AgentProjectGenerator {
6280
6347
  deploy: "adk deploy"
6281
6348
  },
6282
6349
  dependencies: {
6283
- "@botpress/runtime": `^${"1.13.10"}`
6350
+ "@botpress/runtime": `^${"1.13.12"}`
6284
6351
  },
6285
6352
  devDependencies: {
6286
6353
  typescript: "^5.9.3"
@@ -10984,6 +11051,21 @@ import fs18 from "fs/promises";
10984
11051
  import path36 from "path";
10985
11052
  import { spawn } from "child_process";
10986
11053
  init_utils();
11054
+ init_credentials();
11055
+ async function findAgentRoot(startPath) {
11056
+ let currentPath = path36.resolve(startPath);
11057
+ const root = path36.parse(currentPath).root;
11058
+ while (currentPath !== root) {
11059
+ try {
11060
+ await fs18.access(path36.join(currentPath, "agent.config.ts"));
11061
+ return currentPath;
11062
+ } catch {
11063
+ currentPath = path36.dirname(currentPath);
11064
+ }
11065
+ }
11066
+ return null;
11067
+ }
11068
+
10987
11069
  class ScriptRunner {
10988
11070
  projectPath;
10989
11071
  forceRegenerate;
@@ -11035,6 +11117,11 @@ class ScriptRunner {
11035
11117
  */
11036
11118
  import * as bp from '.botpress'
11037
11119
  import { setupAdkRuntime } from './adk-runtime'
11120
+ import { context, agentRegistry } from '@botpress/runtime/runtime'
11121
+ import { Autonomous } from '@botpress/runtime'
11122
+ import { Client } from '@botpress/client'
11123
+ import { BotSpecificClient, BotLogger } from '@botpress/sdk'
11124
+ import { Cognitive } from '@botpress/cognitive'
11038
11125
 
11039
11126
  // Create a minimal bot instance for runtime initialization
11040
11127
  const bot = new bp.Bot({
@@ -11044,6 +11131,33 @@ class ScriptRunner {
11044
11131
  // Initialize the ADK runtime
11045
11132
  setupAdkRuntime(bot)
11046
11133
 
11134
+ // Set up default context for script execution (outside of request handlers)
11135
+ const botId = process.env.ADK_BOT_ID!
11136
+ const token = process.env.ADK_TOKEN!
11137
+ const apiUrl = process.env.ADK_API_URL || 'https://api.botpress.cloud'
11138
+ const configuration = process.env.ADK_CONFIGURATION ? JSON.parse(process.env.ADK_CONFIGURATION) : {}
11139
+
11140
+ const vanillaClient = new Client({ token, apiUrl, botId })
11141
+ const client = new BotSpecificClient(vanillaClient as any)
11142
+ const cognitive = new Cognitive({ client: client as any, __experimental_beta: true })
11143
+ const logger = new BotLogger({})
11144
+
11145
+ context.setDefaultContext({
11146
+ executionId: 'script-execution',
11147
+ executionFinished: false,
11148
+ botId,
11149
+ client: client as any,
11150
+ cognitive: cognitive as any,
11151
+ citations: new Autonomous.CitationsManager(),
11152
+ logger: logger as any,
11153
+ configuration,
11154
+ integrations: agentRegistry.integrations,
11155
+ interfaces: agentRegistry.interfaces,
11156
+ states: [],
11157
+ tags: [],
11158
+ scheduledHeavyImports: new Set<string>(),
11159
+ })
11160
+
11047
11161
  // Export runtime utilities for scripts to use
11048
11162
  export { bot }
11049
11163
 
@@ -11088,6 +11202,81 @@ class ScriptRunner {
11088
11202
  `;
11089
11203
  await fs18.writeFile(path36.join(botPath, "src", "script-runner.ts"), await formatCode(content), "utf-8");
11090
11204
  }
11205
+ async setupTestRuntime(options = {}) {
11206
+ const { botPath, project } = await this.prepare();
11207
+ const botId = this.prod ? project.agentInfo?.botId : project.agentInfo?.devId || project.agentInfo?.botId;
11208
+ const workspaceId = project.agentInfo?.workspaceId || "";
11209
+ if (!botId) {
11210
+ const idType = this.prod ? "botId" : "devId";
11211
+ throw new Error(`No ${idType} found in agent.json. ` + (this.prod ? 'Please deploy your agent first with "adk deploy".' : 'Please run "adk dev" first to create a development bot, or use --prod to use the production bot.'));
11212
+ }
11213
+ let configuration;
11214
+ try {
11215
+ const manager3 = new ConfigManager(botId);
11216
+ configuration = await manager3.getAll();
11217
+ } catch {}
11218
+ const envVars = {
11219
+ ADK_PROJECT_PATH: this.projectPath,
11220
+ ADK_BOT_PATH: botPath,
11221
+ ADK_BOT_ID: botId,
11222
+ ADK_WORKSPACE_ID: workspaceId,
11223
+ ADK_IS_PROD: this.prod ? "true" : "false",
11224
+ BP_DISABLE_WORKER_MODE: "true",
11225
+ ADK_SCRIPT_MODE: "true",
11226
+ ADK_TOKEN: this.credentials.token,
11227
+ ADK_API_URL: this.credentials.apiUrl,
11228
+ ...configuration && { ADK_CONFIGURATION: JSON.stringify(configuration) },
11229
+ ...options.env
11230
+ };
11231
+ for (const [key, value] of Object.entries(envVars)) {
11232
+ process.env[key] = value;
11233
+ }
11234
+ const runtimePath = path36.join(botPath, "src", "index.ts");
11235
+ return {
11236
+ botPath,
11237
+ runtimePath,
11238
+ botId,
11239
+ workspaceId,
11240
+ isProd: this.prod,
11241
+ project,
11242
+ initialize: async () => {
11243
+ const botModule = await import(runtimePath);
11244
+ const runtimeModule = await import("@botpress/runtime/runtime");
11245
+ const { Autonomous } = await import("@botpress/runtime");
11246
+ const { context, agentRegistry } = runtimeModule;
11247
+ const { Client: Client16 } = await import("@botpress/client");
11248
+ const { BotSpecificClient, BotLogger } = await import("@botpress/sdk");
11249
+ const { Cognitive } = await import("@botpress/cognitive");
11250
+ const vanillaClient = new Client16({
11251
+ token: this.credentials.token,
11252
+ apiUrl: this.credentials.apiUrl,
11253
+ botId
11254
+ });
11255
+ const client = new BotSpecificClient(vanillaClient);
11256
+ const cognitive = new Cognitive({
11257
+ client,
11258
+ __experimental_beta: true
11259
+ });
11260
+ const logger = new BotLogger({});
11261
+ context.setDefaultContext({
11262
+ executionId: "test-execution",
11263
+ executionFinished: false,
11264
+ botId,
11265
+ client,
11266
+ cognitive,
11267
+ citations: new Autonomous.CitationsManager,
11268
+ logger,
11269
+ configuration: configuration ?? {},
11270
+ integrations: agentRegistry.integrations,
11271
+ interfaces: agentRegistry.interfaces,
11272
+ states: [],
11273
+ tags: [],
11274
+ scheduledHeavyImports: new Set
11275
+ });
11276
+ return botModule.default;
11277
+ }
11278
+ };
11279
+ }
11091
11280
  async run(scriptPath, options = {}) {
11092
11281
  const { botPath, runnerPath, project } = await this.prepare();
11093
11282
  const absoluteScriptPath = path36.isAbsolute(scriptPath) ? scriptPath : path36.resolve(this.projectPath, scriptPath);
@@ -11149,9 +11338,40 @@ async function runScript(options) {
11149
11338
  inheritStdio: options.inheritStdio
11150
11339
  });
11151
11340
  }
11341
+ async function setupTestRuntime(options = {}) {
11342
+ let projectPath = options.projectPath;
11343
+ if (!projectPath) {
11344
+ const detected = await findAgentRoot(process.cwd());
11345
+ if (!detected) {
11346
+ throw new Error(`Could not find ADK agent project. No agent.config.ts found in current directory or parents.
11347
+ Either run from within an agent project directory, or provide projectPath explicitly.`);
11348
+ }
11349
+ projectPath = detected;
11350
+ }
11351
+ let credentials = options.credentials;
11352
+ if (!credentials) {
11353
+ const credentialsManager = new CredentialsManager;
11354
+ const loadedCredentials = await credentialsManager.getCredentials();
11355
+ if (!loadedCredentials) {
11356
+ throw new Error('No credentials found. Please run "adk login" first, or provide credentials explicitly.');
11357
+ }
11358
+ credentials = {
11359
+ token: loadedCredentials.token,
11360
+ apiUrl: loadedCredentials.apiUrl
11361
+ };
11362
+ }
11363
+ const runner = new ScriptRunner({
11364
+ projectPath,
11365
+ forceRegenerate: options.forceRegenerate,
11366
+ prod: options.prod,
11367
+ credentials
11368
+ });
11369
+ return runner.setupTestRuntime({ env: options.env });
11370
+ }
11152
11371
  export {
11153
11372
  workspaceCache,
11154
11373
  stringifyWithOrder,
11374
+ setupTestRuntime,
11155
11375
  runScript,
11156
11376
  orderKeys,
11157
11377
  integrationKeyOrder,
@@ -11208,4 +11428,4 @@ export {
11208
11428
  AgentProject
11209
11429
  };
11210
11430
 
11211
- //# debugId=34DC1EC72B61FDE964756E2164756E21
11431
+ //# debugId=04935BA1B40451BA64756E2164756E21