@botpress/adk 1.13.10 → 1.13.11

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.
@@ -7,6 +7,6 @@
7
7
  * - Ad-hoc operations requiring an instantiated client
8
8
  * - Running tests (vitest etc) with programmatic API
9
9
  */
10
- export { ScriptRunner, runScript } from './script-runner.js';
11
- export type { ScriptRunnerOptions, RunScriptOptions, ScriptRunnerCredentials, RunOptions } from './script-runner.js';
10
+ export { ScriptRunner, runScript, setupTestRuntime } from './script-runner.js';
11
+ export type { ScriptRunnerOptions, RunScriptOptions, ScriptRunnerCredentials, RunOptions, TestRuntimeResult, SetupTestRuntimeOptions, } from './script-runner.js';
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runner/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC5D,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runner/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC9E,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,UAAU,EACV,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,oBAAoB,CAAA"}
@@ -33,6 +33,26 @@ export interface RunOptions {
33
33
  /** Whether to inherit stdio */
34
34
  inheritStdio?: boolean;
35
35
  }
36
+ export interface TestRuntimeResult {
37
+ /** Path to the bot project */
38
+ botPath: string;
39
+ /** Path to the adk-runtime module that can be imported */
40
+ runtimePath: string;
41
+ /** Bot ID being used */
42
+ botId: string;
43
+ /** Workspace ID */
44
+ workspaceId: string;
45
+ /** Whether using production bot */
46
+ isProd: boolean;
47
+ /** The prepared project instance */
48
+ project: AgentProject;
49
+ /**
50
+ * Import and initialize the ADK runtime in the current process.
51
+ * Call this once before running tests that need the runtime.
52
+ * Returns the bot instance.
53
+ */
54
+ initialize: () => Promise<unknown>;
55
+ }
36
56
  export declare class ScriptRunner {
37
57
  private projectPath;
38
58
  private forceRegenerate;
@@ -55,6 +75,28 @@ export declare class ScriptRunner {
55
75
  * Generate the script runner entry point that bootstraps the ADK runtime
56
76
  */
57
77
  private generateScriptRunner;
78
+ /**
79
+ * Setup the ADK runtime for use in tests (vitest, bun test, etc.)
80
+ *
81
+ * Unlike `run()`, this doesn't spawn a child process. Instead, it:
82
+ * 1. Prepares the bot project (generates types, etc.)
83
+ * 2. Sets up environment variables in the current process
84
+ * 3. Returns paths and an initialize() function to import the runtime
85
+ *
86
+ * Usage in tests:
87
+ * ```typescript
88
+ * import { ScriptRunner } from '@botpress/adk'
89
+ *
90
+ * const runner = new ScriptRunner({ projectPath: '.', credentials: {...} })
91
+ * const runtime = await runner.setupTestRuntime()
92
+ * await runtime.initialize()
93
+ *
94
+ * // Now you can import and use your actions, tools, etc.
95
+ * ```
96
+ */
97
+ setupTestRuntime(options?: {
98
+ env?: Record<string, string>;
99
+ }): Promise<TestRuntimeResult>;
58
100
  /**
59
101
  * Run a script with the ADK runtime initialized
60
102
  */
@@ -64,4 +106,55 @@ export declare class ScriptRunner {
64
106
  * Convenience function to run a script with the ADK runtime
65
107
  */
66
108
  export declare function runScript(options: RunScriptOptions): Promise<number>;
109
+ export interface SetupTestRuntimeOptions {
110
+ /**
111
+ * Path to the agent project root.
112
+ * If not provided, auto-detects by walking up from CWD looking for agent.config.ts
113
+ */
114
+ projectPath?: string;
115
+ /**
116
+ * Credentials for API access.
117
+ * If not provided, loads from the current ADK profile (~/.adk/credentials)
118
+ */
119
+ credentials?: ScriptRunnerCredentials;
120
+ /** Whether to regenerate the bot project even if it exists */
121
+ forceRegenerate?: boolean;
122
+ /** Use production bot ID instead of dev bot ID (default: false, uses devId) */
123
+ prod?: boolean;
124
+ /** Additional environment variables to set */
125
+ env?: Record<string, string>;
126
+ }
127
+ /**
128
+ * Convenience function to setup the ADK runtime for tests.
129
+ *
130
+ * This is designed to be called from test setup (beforeAll, globalSetup, etc.)
131
+ * to prepare the ADK runtime environment without spawning a child process.
132
+ *
133
+ * Features:
134
+ * - Auto-detects project path by walking up from CWD looking for agent.config.ts
135
+ * - Auto-loads credentials from the current ADK profile (~/.adk/credentials)
136
+ * - Both can be overridden via options
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * // Minimal usage - auto-detects everything
141
+ * import { setupTestRuntime } from '@botpress/adk'
142
+ *
143
+ * beforeAll(async () => {
144
+ * const runtime = await setupTestRuntime()
145
+ * await runtime.initialize()
146
+ * })
147
+ *
148
+ * // With explicit options
149
+ * beforeAll(async () => {
150
+ * const runtime = await setupTestRuntime({
151
+ * projectPath: '/path/to/agent',
152
+ * credentials: { token: 'custom-token', apiUrl: 'https://api.botpress.cloud' },
153
+ * prod: true,
154
+ * })
155
+ * await runtime.initialize()
156
+ * })
157
+ * ```
158
+ */
159
+ export declare function setupTestRuntime(options?: SetupTestRuntimeOptions): Promise<TestRuntimeResult>;
67
160
  //# sourceMappingURL=script-runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"script-runner.d.ts","sourceRoot":"","sources":["../../src/runner/script-runner.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAOxD,MAAM,WAAW,uBAAuB;IACtC,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,cAAc;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,iCAAiC;IACjC,WAAW,EAAE,uBAAuB,CAAA;IACpC,8DAA8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AAiB,CAAC,CAoCxG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/adk",
3
- "version": "1.13.10",
3
+ "version": "1.13.11",
4
4
  "description": "Core ADK library for building AI agents on Botpress",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -47,7 +47,7 @@
47
47
  "@botpress/cli": "^5.1.1",
48
48
  "@botpress/client": "^1.28.0",
49
49
  "@botpress/cognitive": "^0.3.3",
50
- "@botpress/runtime": "^1.13.10",
50
+ "@botpress/runtime": "^1.13.11",
51
51
  "@botpress/sdk": "^5.0.2",
52
52
  "@bpinternal/jex": "^1.2.4",
53
53
  "@bpinternal/yargs-extra": "^0.0.21",