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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,10 +14,10 @@ If `$ARGUMENTS` is empty, list the user's primitives and ask which to test.
14
14
 
15
15
  1. **Locate and identify type.** Glob `src/**/<name>.ts`. The directory tells you the type (action / tool / workflow / conversation / table / trigger / knowledge base).
16
16
  2. **Build an invocation appropriate for the type.** If the user provided input after the primitive name, use it as-is; otherwise generate a realistic probe from the primitive's schema:
17
- - **Tool / conversation handler / agent step:** `adk chat --single "<probe message that exercises this primitive>" --format json`. The probe should plausibly cause the LLM to call the tool / route to the handler.
17
+ - **Tool / conversation handler / agent step:** `adk chat --single '<probe message that exercises this primitive>' --format json`. The probe should plausibly cause the LLM to call the tool / route to the handler. Single-quote the message — in double quotes the shell expands `$`, so a probe like `"I spent $5"` reaches the bot mangled.
18
18
  - **Action:** invoke through `adk run .adk/scratch/test-<name>.ts` after writing a small disposable runner under `.adk/scratch/`, or via a chat probe that triggers a tool which calls the action. Prefer the runner when the action has a deterministic input shape.
19
19
  - **Workflow:** trigger via the documented entry point (chat probe, action call, or trigger event).
20
- - **Trigger:** simulate the source event the trigger subscribes to. If the event source is external, explain the limitation and fall back to invoking the trigger handler directly via `adk run`.
20
+ - **Trigger:** a `Trigger` fires on an external source event that usually can't be produced locally — invoke its handler directly via `adk run` with a synthetic event. (A Conversation's pushed `chat:custom` event is different: test it with an eval `event` turn and `adk evals` — see `/adk-eval`. `adk chat --single` only sends user text and can't push one.)
21
21
  - **Table:** insert a sample row, run a representative query, then **delete the row** before reporting. Tag the test row with a recognizable marker (e.g., a `__test_<timestamp>` value in a string column) so the cleanup query is unambiguous. If the project is linked to a shared or production workspace, ask the user before inserting at all — offer to scope the test to a local dev table instead.
22
22
  - **Knowledge base:** run a search query against it.
23
23
  3. **Run it and read traces.** Capture the response. Run `adk traces --format json` filtered to the most recent invocation if the response alone is not enough to judge correctness.
@@ -67,6 +67,8 @@ console.log(logo.mime) // "image/png"
67
67
  console.log(logo.size) // bytes
68
68
  ```
69
69
 
70
+ > `assets.get()` returns **metadata only** (URL, mime, size) — never the file's bytes. To ship a data table your code reads in-process (menu, catalog, rules), don't use assets — `import` the JSON statically instead. See [patterns-mistakes.md → Shipping a bundled data file](./patterns-mistakes.md#shipping-a-bundled-data-file).
71
+
70
72
  ### List All Assets
71
73
 
72
74
  ```typescript
@@ -362,12 +362,14 @@ adk chat [options]
362
362
 
363
363
  ```bash
364
364
  adk chat # interactive
365
- adk chat --single "<message>" # one-shot
366
- adk chat --single "<message>" --format json
367
- adk chat --single "Run the full analysis" --timeout 30s
368
- adk chat --single "Follow up" --conversation-id <id>
365
+ adk chat --single '<message>' # one-shot
366
+ adk chat --single '<message>' --format json
367
+ adk chat --single 'Run the full analysis' --timeout 30s
368
+ adk chat --single 'Follow up' --conversation-id <id>
369
369
  ```
370
370
 
371
+ > **Single-quote the message.** In double quotes the shell expands `$`, so `"I spent $5"` reaches the bot as `I spent ` (and `$10`→`0`, `$84.50`→`4.50`). It looks like the bot can't parse the input, but it's shell mangling. Use single quotes: `adk chat --single 'I spent $5'`.
372
+
371
373
  **Requires:**
372
374
 
373
375
  - `adk dev` running (also creates the `devId` on first run). Conversation continuation requires the dev server to be running — the user token is persisted automatically.
@@ -138,6 +138,8 @@ export const Chat = new Conversation({
138
138
 
139
139
  See **[Messages](./messages.md)** for complete guide on all message types, metadata, and sending patterns.
140
140
 
141
+ > **Route natural language to `execute()` — don't hand-roll parsers.** Match exact strings only for explicit slash-commands (`/help`) or structured event `type`s. For anything users phrase in their own words, call `execute({ instructions })` and pull structured fields with `adk.zai.extract` (see [zai-agent-reference.md](./zai-agent-reference.md)); keyword/regex/`startsWith` matching silently misses real phrasings.
142
+
141
143
  ## Custom & Proactive Events
142
144
 
143
145
  To push a message into a conversation from an external trigger (e.g. an announcement or status update), handle a custom event **inside the Conversation** — declare it in `events` and branch on `type === 'event'`. Don't build a separate `Trigger` + `client.createMessage`; an integration can't post messages as itself.
@@ -148,9 +150,9 @@ export const Chat = new Conversation({
148
150
  events: ['chat:custom'],
149
151
  async handler({ type, event, conversation }) {
150
152
  if (type === 'event') {
151
- // The pushed data is in event.payload. On channel '*' the handler types
152
- // event as `unknown`, so read its payload with a cast (or use a concrete channel).
153
- const { orderId } = (event as { payload: { orderId: string } }).payload
153
+ // The pushed data is nested at event.payload.payload. On channel '*' the handler
154
+ // types event as `unknown`, so read it with a cast (or use a concrete channel).
155
+ const { orderId } = (event as { payload: { payload: { orderId: string } } }).payload.payload
154
156
  await conversation.send({ type: 'text', payload: { text: `Order ${orderId} shipped!` } })
155
157
  return
156
158
  }
@@ -159,6 +161,8 @@ export const Chat = new Conversation({
159
161
  })
160
162
  ```
161
163
 
164
+ To test a pushed event without an external trigger, fire it from an eval `event` turn (`event: { payload: {...} }`) and run `adk evals` — `adk chat --single` only sends user text. See the `adk-evals` skill.
165
+
162
166
  ## Conversation Instance Methods
163
167
 
164
168
  The `conversation` object provides methods for interacting with the current conversation.
@@ -37,6 +37,16 @@ const { myAction } = await import('./actions/myAction')
37
37
  import { myAction } from './actions/myAction'
38
38
  ```
39
39
 
40
+ ### Shipping a bundled data file
41
+
42
+ To ship a data table your code reads at runtime (menu, catalog, pricing rules), **import the JSON statically** — the bundler inlines it into the build:
43
+
44
+ ```typescript
45
+ import menu from './data/menu.json' // ✅ inlined at build time
46
+ ```
47
+
48
+ Don't reach for `fs.readFile` (the file isn't on disk at runtime → ENOENT), `import.meta`/`fileURLToPath` (undefined in the bundle → throws), or `assets.get()` (returns a URL, not the file's contents). All three pass `adk check` and `tsc` but crash only at runtime.
49
+
40
50
  ### Handler Syntax
41
51
 
42
52
  #### Action Handlers
@@ -80,12 +90,28 @@ An event pushed into a conversation (e.g. an order shipped, a status update rela
80
90
  // ❌ WRONG - pushed event is chat:custom, so this never fires
81
91
  events: ['claimUpdate'],
82
92
 
83
- // ✅ CORRECT - branch on type === 'event', read event.payload
93
+ // ✅ CORRECT - branch on type === 'event', read event.payload.payload
84
94
  events: ['chat:custom'],
85
95
  ```
86
96
 
87
97
  The camelCase rule applies only to events you define/emit, not to receiving. See [conversations.md → Custom & Proactive Events](./conversations.md#custom--proactive-events).
88
98
 
99
+ ### Conversation Routing Mistakes
100
+
101
+ #### Don't hand-roll natural-language parsing
102
+
103
+ Keyword/regex/exact-string matching on what a user types misses real phrasings, so whole flows silently fail. Route natural language to `execute()`; reserve exact-string branching for explicit slash-commands and structured event `type`s.
104
+
105
+ ```typescript
106
+ // ❌ WRONG - misses "can you sum this up?", "tl;dr", ...
107
+ if (message?.payload.text.includes('summarize')) {
108
+ /* ... */
109
+ }
110
+
111
+ // ✅ CORRECT - the model interprets intent; extract fields with zai
112
+ await execute({ instructions: 'Summarize the conversation for the user' })
113
+ ```
114
+
89
115
  ### State Management Mistakes
90
116
 
91
117
  #### Conversation State Access
@@ -51,6 +51,8 @@ adk chat --single "the message that triggers the bug" --format json
51
51
 
52
52
  **Why minimal?** A single message isolates the problem. Most often, multi-turn conversations add noise — the issue might be in turn 3 but caused by context from turn 1. That being said, some bugs are only reproducible by going through many turns.
53
53
 
54
+ **Pushed-event or proactive bug?** `adk chat --single` only sends user text — it can't push a `chat:custom` event. Reproduce with an eval `event` turn (`event: { payload: {...} }`) and run `adk evals`; don't curl the chat webhook.
55
+
54
56
  **Save the conversation ID** from the JSON output — you'll need it for trace queries and follow up conversations.
55
57
 
56
58
  If the issue requires multi-turn context:
@@ -94,11 +94,11 @@ export default new Eval({
94
94
 
95
95
  ### Turn types
96
96
 
97
- | Turn | When to use |
98
- | -------------------------- | ------------------------------------------------ |
99
- | `user: 'message'` | Standard user message |
100
- | `event: { type, payload }` | Non-message trigger (webhook, integration event) |
101
- | `expectSilence: true` | Assert bot does NOT respond |
97
+ | Turn | When to use |
98
+ | --------------------- | ---------------------------------------------- |
99
+ | `user: 'message'` | Standard user message |
100
+ | `event: { payload }` | Push a custom event (arrives as `chat:custom`) |
101
+ | `expectSilence: true` | Assert bot does NOT respond |
102
102
 
103
103
  ### Assertion categories
104
104
 
@@ -134,7 +134,7 @@ adk evals runs --latest -v # with full details
134
134
  ```typescript
135
135
  // CORRECT
136
136
  { user: 'hello', expectSilence: true }
137
- { event: { type: 'payment.failed' }, expectSilence: true }
137
+ { event: { payload: { kind: 'payment.failed' } }, expectSilence: true }
138
138
  ```
139
139
 
140
140
  ❌ **`expectSilence` alone is not a valid turn**
@@ -85,12 +85,11 @@ Each entry in `conversation` is one turn. A turn must have either `user` or `eve
85
85
 
86
86
  ### Event Trigger
87
87
 
88
- Fire a non-message event (webhook, integration event) instead of a user message.
88
+ Push a custom event instead of a user message. The turn carries only a `payload`; the bot receives it as a `chat:custom` event and reads the data at `event.payload.payload`.
89
89
 
90
90
  ```typescript
91
91
  {
92
92
  event: {
93
- type: 'checkout:order_placed',
94
93
  payload: { orderId: 'ORD-001', total: 49.99 },
95
94
  },
96
95
  assert: {
@@ -108,7 +107,7 @@ Assert the bot does **not** respond. Add `expectSilence: true` to any turn.
108
107
  { user: 'Please ignore this.', expectSilence: true }
109
108
 
110
109
  // Silence after an event
111
- { event: { type: 'internal:ping' }, expectSilence: true }
110
+ { event: { payload: { kind: 'ping' } }, expectSilence: true }
112
111
  ```
113
112
 
114
113
  > **Note:** `expectSilence` is mutually exclusive with `assert.response`. Every turn must have `user` or `event` — `expectSilence` is a flag on top of that, not a standalone turn type.
@@ -347,13 +346,19 @@ export default defineConfig({
347
346
 
348
347
  ```typescript
349
348
  // WRONG — mutually exclusive
350
- { user: 'hello', event: { type: 'payment.failed' } }
349
+ { user: 'hello', event: { payload: { amount: 50 } } }
351
350
  ```
352
351
 
353
352
  ✅ **Correct — use separate turns**
354
353
 
355
354
  ```typescript
356
- { event: { type: 'payment.failed', payload: { amount: 50 } } }
355
+ {
356
+ event: {
357
+ payload: {
358
+ amount: 50
359
+ }
360
+ }
361
+ }
357
362
  ```
358
363
 
359
364
  ## See Also
@@ -192,7 +192,6 @@ export default new Eval({
192
192
  conversation: [
193
193
  {
194
194
  event: {
195
- type: 'payment:failed',
196
195
  payload: { amount: 99.99, currency: 'USD', customerId: 'cust-001' },
197
196
  },
198
197
  assert: {
@@ -213,8 +212,8 @@ export default new Eval({
213
212
 
214
213
  conversation: [
215
214
  {
216
- event: { type: 'internal:heartbeat' },
217
- expectSilence: true, // bot should not respond to internal events
215
+ event: { payload: { kind: 'heartbeat' } },
216
+ expectSilence: true, // bot should not respond to heartbeat payloads
218
217
  },
219
218
  ],
220
219
  })
@@ -40,17 +40,9 @@ export declare class BotGenerator {
40
40
  emitDependencyArtifacts(): Promise<void>;
41
41
  private generateIntegrationsTypes;
42
42
  private generatePluginsTypes;
43
- private generateTableTypes;
44
43
  private generateTriggerTypes;
45
- private generateTagTypes;
46
- private generateStateTypes;
47
- private generateConfigurationTypes;
48
- private generateSecretTypes;
49
44
  private generateEventTypes;
50
- private generateWorkflowTypes;
51
45
  private generateConversationTypes;
52
- private generateComponentTypes;
53
- private generateActionTypes;
54
46
  private generateIntegrationActionTypes;
55
47
  private generatePluginActionTypes;
56
48
  private generateClientWrapper;
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/bot-generator/generator.ts"],"names":[],"mappings":"AAuBA,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CACpC;AAuCD,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,YAAY,CAAA;IACnD,SAAS,CAAC,EAAE,aAAa,CAAA;CAC1B;AA4CD,qBAAa,YA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WV,aAAa;IAgBrB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;YA8f3B,0BAA0B;IAgBlC,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;CAqBzC;AAED,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgGpF"}
@@ -4801,7 +4801,7 @@ var _format = null, _formatLoaded = false, formatCode = async (code, filepath) =
4801
4801
  `));
4802
4802
  return code;
4803
4803
  }
4804
- }, ADK_VERSION = "2.0.1-beta.2", relative = (from, to) => {
4804
+ }, ADK_VERSION = "2.0.1-beta.4", relative = (from, to) => {
4805
4805
  const fromDir = path13.dirname(from);
4806
4806
  const relative2 = path13.relative(fromDir, to);
4807
4807
  return relative2.startsWith(".") ? relative2 : `./${relative2}`;
@@ -6657,4 +6657,4 @@ export {
6657
6657
  DEPENDENCY_ERROR_CODES
6658
6658
  };
6659
6659
 
6660
- //# debugId=9A311C5D6094A57864756E2164756E21
6660
+ //# debugId=5966248C1C9C8E2B64756E2164756E21