@botpress/adk 1.19.0-beta.9 → 2.0.0-alpha.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.
Files changed (199) hide show
  1. package/dist/agent-init/agent-project-generator.d.ts +5 -1
  2. package/dist/agent-init/agent-project-generator.d.ts.map +1 -1
  3. package/dist/agent-project/agent-project.d.ts +3 -3
  4. package/dist/agent-project/agent-project.d.ts.map +1 -1
  5. package/dist/agent-project/agent-resolver.d.ts.map +1 -1
  6. package/dist/agent-project/config-writer.d.ts +1 -1
  7. package/dist/agent-project/dependency-state-to-dependencies.d.ts +11 -0
  8. package/dist/agent-project/dependency-state-to-dependencies.d.ts.map +1 -0
  9. package/dist/agent-project/types.d.ts +9 -4
  10. package/dist/agent-project/types.d.ts.map +1 -1
  11. package/dist/agent0/capabilities/commands/adk-build.md +6 -5
  12. package/dist/agent0/capabilities/commands/adk-debug.md +1 -1
  13. package/dist/agent0/capabilities/commands/adk-dev-console.md +1 -1
  14. package/dist/agent0/capabilities/commands/adk-document.md +10 -2
  15. package/dist/agent0/capabilities/commands/adk-eval.md +1 -1
  16. package/dist/agent0/capabilities/commands/adk-explain.md +2 -2
  17. package/dist/agent0/capabilities/commands/adk-init.md +2 -2
  18. package/dist/agent0/capabilities/commands/adk-ship.md +1 -1
  19. package/dist/agent0/capabilities/commands/adk-test.md +3 -3
  20. package/dist/agent0/capabilities/commands/adk-validate.md +3 -3
  21. package/dist/agent0/capabilities/skills/adk/SKILL.md +21 -21
  22. package/dist/agent0/capabilities/skills/adk/references/actions.md +245 -239
  23. package/dist/agent0/capabilities/skills/adk/references/advanced-patterns.md +185 -218
  24. package/dist/agent0/capabilities/skills/adk/references/agent-config.md +74 -71
  25. package/dist/agent0/capabilities/skills/adk/references/assets.md +45 -48
  26. package/dist/agent0/capabilities/skills/adk/references/autonomous-execution.md +40 -46
  27. package/dist/agent0/capabilities/skills/adk/references/cli.md +17 -7
  28. package/dist/agent0/capabilities/skills/adk/references/context-api.md +98 -94
  29. package/dist/agent0/capabilities/skills/adk/references/conversation-lifecycle.md +65 -62
  30. package/dist/agent0/capabilities/skills/adk/references/conversations.md +395 -385
  31. package/dist/agent0/capabilities/skills/adk/references/custom-components.md +1 -1
  32. package/dist/agent0/capabilities/skills/adk/references/desk.md +236 -234
  33. package/dist/agent0/capabilities/skills/adk/references/explain-config.md +54 -37
  34. package/dist/agent0/capabilities/skills/adk/references/files.md +301 -306
  35. package/dist/agent0/capabilities/skills/adk/references/integration-actions.md +211 -214
  36. package/dist/agent0/capabilities/skills/adk/references/integrations.md +33 -31
  37. package/dist/agent0/capabilities/skills/adk/references/interfaces.md +13 -12
  38. package/dist/agent0/capabilities/skills/adk/references/knowledge-bases.md +98 -111
  39. package/dist/agent0/capabilities/skills/adk/references/mcp-server.md +6 -0
  40. package/dist/agent0/capabilities/skills/adk/references/messages.md +280 -256
  41. package/dist/agent0/capabilities/skills/adk/references/model-configuration.md +52 -49
  42. package/dist/agent0/capabilities/skills/adk/references/patterns-mistakes.md +102 -101
  43. package/dist/agent0/capabilities/skills/adk/references/plugins.md +15 -15
  44. package/dist/agent0/capabilities/skills/adk/references/tables.md +204 -210
  45. package/dist/agent0/capabilities/skills/adk/references/tags.md +141 -143
  46. package/dist/agent0/capabilities/skills/adk/references/tools.md +191 -199
  47. package/dist/agent0/capabilities/skills/adk/references/triggers.md +331 -336
  48. package/dist/agent0/capabilities/skills/adk/references/workflow-steps.md +132 -96
  49. package/dist/agent0/capabilities/skills/adk/references/workflows.md +479 -464
  50. package/dist/agent0/capabilities/skills/adk/references/zai-agent-reference.md +127 -129
  51. package/dist/agent0/capabilities/skills/adk/references/zai-complete-guide.md +255 -276
  52. package/dist/agent0/capabilities/skills/adk-debugger/SKILL.md +21 -17
  53. package/dist/agent0/capabilities/skills/adk-debugger/references/common-failures.md +25 -25
  54. package/dist/agent0/capabilities/skills/adk-debugger/references/conversation-analysis.md +49 -41
  55. package/dist/agent0/capabilities/skills/adk-debugger/references/debug-workflow.md +20 -14
  56. package/dist/agent0/capabilities/skills/adk-debugger/references/llm-debugging.md +13 -13
  57. package/dist/agent0/capabilities/skills/adk-debugger/references/trace-summarization.md +18 -18
  58. package/dist/agent0/capabilities/skills/adk-debugger/references/traces-and-logs.md +67 -67
  59. package/dist/agent0/capabilities/skills/adk-dev-console/SKILL.md +36 -36
  60. package/dist/agent0/capabilities/skills/adk-dev-console/references/agent-steps.md +14 -6
  61. package/dist/agent0/capabilities/skills/adk-dev-console/references/multi-agent-dashboard.md +13 -13
  62. package/dist/agent0/capabilities/skills/adk-dev-console/references/pages.md +18 -0
  63. package/dist/agent0/capabilities/skills/adk-docs/SKILL.md +13 -13
  64. package/dist/agent0/capabilities/skills/adk-docs/references/doc-standards.md +15 -0
  65. package/dist/agent0/capabilities/skills/adk-evals/SKILL.md +29 -23
  66. package/dist/agent0/capabilities/skills/adk-evals/references/eval-format.md +31 -23
  67. package/dist/agent0/capabilities/skills/adk-evals/references/test-patterns.md +25 -36
  68. package/dist/agent0/capabilities/skills/adk-evals/references/testing-workflow.md +6 -4
  69. package/dist/agent0/index.js +41 -19
  70. package/dist/agent0/index.js.map +7 -7
  71. package/dist/agent0/runtime/client.d.ts +2 -0
  72. package/dist/agent0/runtime/client.d.ts.map +1 -1
  73. package/dist/agent0/runtime/engine.d.ts +2 -1
  74. package/dist/agent0/runtime/engine.d.ts.map +1 -1
  75. package/dist/agent0/runtime/process.d.ts +1 -0
  76. package/dist/agent0/runtime/process.d.ts.map +1 -1
  77. package/dist/assets/manager.d.ts +3 -0
  78. package/dist/assets/manager.d.ts.map +1 -1
  79. package/dist/auth/credentials.d.ts +1 -1
  80. package/dist/bot-generator/generator.d.ts +22 -0
  81. package/dist/bot-generator/generator.d.ts.map +1 -1
  82. package/dist/bot-generator/plugin-sync.d.ts.map +1 -1
  83. package/dist/commands/base-command.d.ts +1 -0
  84. package/dist/commands/base-command.d.ts.map +1 -1
  85. package/dist/commands/bp-dev-command.d.ts +1 -1
  86. package/dist/commands/bp-dev-command.d.ts.map +1 -1
  87. package/dist/commands/bp-dev-stderr.d.ts +9 -0
  88. package/dist/commands/bp-dev-stderr.d.ts.map +1 -1
  89. package/dist/commands/index.d.ts +1 -0
  90. package/dist/commands/index.d.ts.map +1 -1
  91. package/dist/dependencies/catalog/catalog-service.d.ts +53 -0
  92. package/dist/dependencies/catalog/catalog-service.d.ts.map +1 -0
  93. package/dist/dependencies/catalog/client-factory.d.ts +33 -0
  94. package/dist/dependencies/catalog/client-factory.d.ts.map +1 -0
  95. package/dist/dependencies/catalog/integration-source.d.ts +34 -0
  96. package/dist/dependencies/catalog/integration-source.d.ts.map +1 -0
  97. package/dist/dependencies/catalog/interface-source.d.ts +23 -0
  98. package/dist/dependencies/catalog/interface-source.d.ts.map +1 -0
  99. package/dist/dependencies/catalog/plugin-source.d.ts +49 -0
  100. package/dist/dependencies/catalog/plugin-source.d.ts.map +1 -0
  101. package/dist/dependencies/catalog/resolution-cache.d.ts +76 -0
  102. package/dist/dependencies/catalog/resolution-cache.d.ts.map +1 -0
  103. package/dist/dependencies/dependency-manager.d.ts +31 -16
  104. package/dist/dependencies/dependency-manager.d.ts.map +1 -1
  105. package/dist/dependencies/errors.d.ts +2 -2
  106. package/dist/dependencies/errors.d.ts.map +1 -1
  107. package/dist/dependencies/index.d.ts +5 -4
  108. package/dist/dependencies/index.d.ts.map +1 -1
  109. package/dist/dependencies/index.js +2089 -1670
  110. package/dist/dependencies/index.js.map +37 -30
  111. package/dist/dependencies/legacy-lock-file.d.ts +15 -0
  112. package/dist/dependencies/legacy-lock-file.d.ts.map +1 -0
  113. package/dist/dependencies/migration.d.ts +19 -0
  114. package/dist/dependencies/migration.d.ts.map +1 -1
  115. package/dist/dependencies/resolvers/integration-resolver.d.ts +4 -3
  116. package/dist/dependencies/resolvers/integration-resolver.d.ts.map +1 -1
  117. package/dist/dependencies/resolvers/plugin-resolver.d.ts +4 -4
  118. package/dist/dependencies/resolvers/plugin-resolver.d.ts.map +1 -1
  119. package/dist/dependencies/snapshot-store.d.ts +59 -0
  120. package/dist/dependencies/snapshot-store.d.ts.map +1 -0
  121. package/dist/dependencies/status-resolver.d.ts +36 -0
  122. package/dist/dependencies/status-resolver.d.ts.map +1 -0
  123. package/dist/dependencies/status.d.ts +214 -0
  124. package/dist/dependencies/status.d.ts.map +1 -0
  125. package/dist/dependencies/types.d.ts +380 -29
  126. package/dist/dependencies/types.d.ts.map +1 -1
  127. package/dist/file-watcher/watcher.d.ts +21 -5
  128. package/dist/file-watcher/watcher.d.ts.map +1 -1
  129. package/dist/generators/action-types.d.ts.map +1 -1
  130. package/dist/generators/client-wrapper.d.ts.map +1 -1
  131. package/dist/index.d.ts +4 -5
  132. package/dist/index.d.ts.map +1 -1
  133. package/dist/index.js +3134 -2226
  134. package/dist/index.js.map +55 -48
  135. package/dist/integrations/config-utils.d.ts +11 -7
  136. package/dist/integrations/config-utils.d.ts.map +1 -1
  137. package/dist/integrations/hub-cache.d.ts +0 -58
  138. package/dist/integrations/hub-cache.d.ts.map +1 -1
  139. package/dist/integrations/index.d.ts +1 -3
  140. package/dist/integrations/index.d.ts.map +1 -1
  141. package/dist/integrations/manager.d.ts +19 -53
  142. package/dist/integrations/manager.d.ts.map +1 -1
  143. package/dist/interfaces/enhanced-cache.d.ts +7 -7
  144. package/dist/interfaces/enhanced-cache.d.ts.map +1 -1
  145. package/dist/interfaces/manager.d.ts +11 -17
  146. package/dist/interfaces/manager.d.ts.map +1 -1
  147. package/dist/knowledge/manager.d.ts +3 -0
  148. package/dist/knowledge/manager.d.ts.map +1 -1
  149. package/dist/plugins/index.d.ts +0 -1
  150. package/dist/plugins/index.d.ts.map +1 -1
  151. package/dist/plugins/manager.d.ts +16 -48
  152. package/dist/plugins/manager.d.ts.map +1 -1
  153. package/dist/preflight/checker.d.ts +6 -1
  154. package/dist/preflight/checker.d.ts.map +1 -1
  155. package/dist/preflight/dependency-gate.d.ts +37 -0
  156. package/dist/preflight/dependency-gate.d.ts.map +1 -0
  157. package/dist/preflight/index.d.ts +2 -1
  158. package/dist/preflight/index.d.ts.map +1 -1
  159. package/dist/preflight/types.d.ts +18 -0
  160. package/dist/preflight/types.d.ts.map +1 -1
  161. package/dist/runner/script-runner.d.ts.map +1 -1
  162. package/dist/tables/table-manager.d.ts +3 -0
  163. package/dist/tables/table-manager.d.ts.map +1 -1
  164. package/dist/templates/README.md +23 -13
  165. package/dist/templates/blank/agent.config.ts +3 -3
  166. package/dist/templates/blank/src/triggers/index.ts +1 -1
  167. package/dist/templates/botpress-desk/evals/index.eval.ts +1 -1
  168. package/dist/templates/botpress-desk/src/triggers/index.ts +1 -1
  169. package/dist/templates/crm-enrichment/README.md +3 -3
  170. package/dist/templates/crm-enrichment/agent.config.ts +2 -2
  171. package/dist/templates/crm-enrichment/src/conversations/index.ts +1 -1
  172. package/dist/templates/hello-world/agent.config.ts +3 -3
  173. package/dist/templates/hello-world/src/triggers/index.ts +1 -1
  174. package/dist/templates/knowledge-assistant/src/triggers/index.ts +1 -1
  175. package/dist/templates/template.config.json +3 -3
  176. package/dist/utils/ids.d.ts +10 -0
  177. package/dist/utils/ids.d.ts.map +1 -1
  178. package/dist/workspace/workspace-cache.d.ts +2 -1
  179. package/dist/workspace/workspace-cache.d.ts.map +1 -1
  180. package/package.json +3 -3
  181. package/dist/agent-project/lock-to-dependencies.d.ts +0 -11
  182. package/dist/agent-project/lock-to-dependencies.d.ts.map +0 -1
  183. package/dist/dependencies/lock-file.d.ts +0 -15
  184. package/dist/dependencies/lock-file.d.ts.map +0 -1
  185. package/dist/integrations/enhanced-cache.d.ts +0 -53
  186. package/dist/integrations/enhanced-cache.d.ts.map +0 -1
  187. package/dist/plugins/enhanced-cache.d.ts +0 -53
  188. package/dist/plugins/enhanced-cache.d.ts.map +0 -1
  189. package/dist/templates/blank/package.json +0 -17
  190. package/dist/templates/blank/tsconfig.json +0 -25
  191. package/dist/templates/botpress-desk/package.json +0 -17
  192. package/dist/templates/crm-enrichment/package.json +0 -18
  193. package/dist/templates/crm-enrichment/tsconfig.json +0 -25
  194. package/dist/templates/hello-world/package.json +0 -18
  195. package/dist/templates/hello-world/tsconfig.json +0 -25
  196. package/dist/templates/knowledge-assistant/package.json +0 -18
  197. package/dist/templates/knowledge-assistant/tsconfig.json +0 -25
  198. package/dist/templates/slack-triage/package.json +0 -18
  199. package/dist/templates/slack-triage/tsconfig.json +0 -25
@@ -7,16 +7,16 @@ Quick reference for configuring AI models at different levels in ADK agents.
7
7
  ## 1. Global Defaults (agent.config.ts)
8
8
 
9
9
  ```typescript
10
- import { defineConfig } from "@botpress/runtime";
10
+ import { defineConfig } from '@botpress/runtime'
11
11
 
12
12
  export default defineConfig({
13
- name: "my-agent",
13
+ name: 'my-agent',
14
14
 
15
15
  defaultModels: {
16
- autonomous: "openai:gpt-4o", // Used by execute()
17
- zai: "openai:gpt-4o-mini" // Used by Zai operations
18
- }
19
- });
16
+ autonomous: 'openai:gpt-4o', // Used by execute()
17
+ zai: 'openai:gpt-4o-mini', // Used by Zai operations
18
+ },
19
+ })
20
20
  ```
21
21
 
22
22
  ### With Fallback Arrays
@@ -38,22 +38,19 @@ defaultModels: {
38
38
 
39
39
  ```typescript
40
40
  await execute({
41
- instructions: "You are a helpful assistant",
42
- model: "anthropic:claude-3-5-sonnet",
43
- temperature: 0.7
44
- });
41
+ instructions: 'You are a helpful assistant',
42
+ model: 'anthropic:claude-3-5-sonnet',
43
+ temperature: 0.7,
44
+ })
45
45
  ```
46
46
 
47
47
  ### With Fallback Array
48
48
 
49
49
  ```typescript
50
50
  await execute({
51
- instructions: "You are a helpful assistant",
52
- model: [
53
- "openai:gpt-4o",
54
- "anthropic:claude-3-5-sonnet"
55
- ]
56
- });
51
+ instructions: 'You are a helpful assistant',
52
+ model: ['openai:gpt-4o', 'anthropic:claude-3-5-sonnet'],
53
+ })
57
54
  ```
58
55
 
59
56
  ---
@@ -63,10 +60,10 @@ await execute({
63
60
  Override the default Zai model per-instance using `.with()`:
64
61
 
65
62
  ```typescript
66
- import { adk } from "@botpress/runtime";
63
+ import { adk } from '@botpress/runtime'
67
64
 
68
- const preciseZai = adk.zai.with({ modelId: "openai:gpt-4o" });
69
- await preciseZai.extract(text, schema);
65
+ const preciseZai = adk.zai.with({ modelId: 'openai:gpt-4o' })
66
+ await preciseZai.extract(text, schema)
70
67
  ```
71
68
 
72
69
  > For full Zai configuration (initialization, chaining, learning, operations), see [zai-agent-reference.md](./zai-agent-reference.md) and [zai-complete-guide.md](./zai-complete-guide.md).
@@ -80,15 +77,16 @@ await preciseZai.extract(text, schema);
80
77
  Models follow the pattern: `{provider}:{model-name}`
81
78
 
82
79
  ```typescript
83
- "openai:gpt-4o" // Short name
84
- "openai:gpt-4.1-2025-04-14" // Dated version (more specific)
85
- "anthropic:claude-3-5-sonnet" // Short name
86
- "anthropic:claude-sonnet-4-5-20250929" // Dated version
87
- "best" // Zai shortcut (highest quality)
88
- "fast" // Zai shortcut (fastest/cheapest)
80
+ 'openai:gpt-4o' // Short name
81
+ 'openai:gpt-4.1-2025-04-14' // Dated version (more specific)
82
+ 'anthropic:claude-3-5-sonnet' // Short name
83
+ 'anthropic:claude-sonnet-4-5-20250929' // Dated version
84
+ 'best' // Zai shortcut (highest quality)
85
+ 'fast' // Zai shortcut (fastest/cheapest)
89
86
  ```
90
87
 
91
88
  **Finding Available Models:**
89
+
92
90
  - The Models type accepts any string, so new models work automatically
93
91
  - For current available models, check the `Models` type in `@botpress/cognitive`
94
92
  - Use TypeScript autocomplete: Start typing a provider name to see suggestions
@@ -97,6 +95,7 @@ Models follow the pattern: `{provider}:{model-name}`
97
95
  ### Common Models
98
96
 
99
97
  ### OpenAI
98
+
100
99
  ```
101
100
  openai:gpt-4o
102
101
  openai:gpt-4o-mini
@@ -105,6 +104,7 @@ openai:gpt-3.5-turbo
105
104
  ```
106
105
 
107
106
  ### Anthropic
107
+
108
108
  ```
109
109
  anthropic:claude-3-5-sonnet
110
110
  anthropic:claude-3-opus
@@ -112,17 +112,20 @@ anthropic:claude-3-haiku
112
112
  ```
113
113
 
114
114
  ### Google
115
+
115
116
  ```
116
117
  google:gemini-1.5-pro
117
118
  google:gemini-1.5-flash
118
119
  ```
119
120
 
120
121
  ### Cerebras
122
+
121
123
  ```
122
124
  cerebras:gpt-oss-120b
123
125
  ```
124
126
 
125
127
  ### Zai Shortcuts
128
+
126
129
  ```
127
130
  best # Highest quality model
128
131
  fast # Fastest/cheapest model
@@ -133,10 +136,12 @@ fast # Fastest/cheapest model
133
136
  ## 5. Precedence Order
134
137
 
135
138
  **For execute():**
139
+
136
140
  1. `execute({ model: "..." })` - Per-call override
137
141
  2. `agent.config.ts defaultModels.autonomous` - Global default
138
142
 
139
143
  **For Zai:**
144
+
140
145
  1. `zai.with({ modelId: "..." })` - Instance override
141
146
  2. `new Zai({ modelId: "..." })` - Constructor config
142
147
  3. `agent.config.ts defaultModels.zai` - Global default
@@ -147,12 +152,12 @@ fast # Fastest/cheapest model
147
152
 
148
153
  ```typescript
149
154
  export default defineConfig({
150
- name: "my-agent",
155
+ name: 'my-agent',
151
156
  defaultModels: {
152
- autonomous: process.env.AI_MODEL || "openai:gpt-4o",
153
- zai: process.env.ZAI_MODEL || "openai:gpt-4o-mini"
154
- }
155
- });
157
+ autonomous: process.env.AI_MODEL || 'openai:gpt-4o',
158
+ zai: process.env.ZAI_MODEL || 'openai:gpt-4o-mini',
159
+ },
160
+ })
156
161
  ```
157
162
 
158
163
  ---
@@ -163,39 +168,37 @@ export default defineConfig({
163
168
 
164
169
  ```typescript
165
170
  export default new Conversation({
166
- channel: "*",
171
+ channel: '*',
167
172
  handler: async ({ execute }) => {
168
173
  await execute({
169
- instructions: "You are a helpful assistant",
170
- model: "anthropic:claude-3-5-sonnet"
171
- });
172
- }
173
- });
174
+ instructions: 'You are a helpful assistant',
175
+ model: 'anthropic:claude-3-5-sonnet',
176
+ })
177
+ },
178
+ })
174
179
  ```
175
180
 
176
181
  ### Workflow with Model Override
177
182
 
178
183
  ```typescript
179
184
  export default Workflow({
180
- name: "research",
185
+ name: 'research',
181
186
  handler: async ({ step, execute }) => {
182
- const result = await step("analyze", async () => {
187
+ const result = await step('analyze', async () => {
183
188
  return await execute({
184
- instructions: "Analyze this data",
185
- model: "openai:gpt-4o"
186
- });
187
- });
188
- return result;
189
- }
190
- });
189
+ instructions: 'Analyze this data',
190
+ model: 'openai:gpt-4o',
191
+ })
192
+ })
193
+ return result
194
+ },
195
+ })
191
196
  ```
192
197
 
193
198
  ### Zai Operation with Specific Model
194
199
 
195
200
  ```typescript
196
- import { adk } from "@botpress/runtime";
201
+ import { adk } from '@botpress/runtime'
197
202
 
198
- const analysis = await adk.zai
199
- .with({ modelId: "anthropic:claude-3-5-sonnet" })
200
- .extract(document, schema);
203
+ const analysis = await adk.zai.with({ modelId: 'anthropic:claude-3-5-sonnet' }).extract(document, schema)
201
204
  ```
@@ -10,15 +10,16 @@ Common patterns to follow and mistakes to avoid when building with the ADK.
10
10
 
11
11
  ```typescript
12
12
  // ❌ WRONG - Never import from these
13
- import { z } from "zod";
14
- import { Action } from "@botpress/sdk";
15
- import { Workflow } from "@botpress/cli";
13
+ import { z } from 'zod'
14
+ import { Action } from '@botpress/sdk'
15
+ import { Workflow } from '@botpress/cli'
16
16
 
17
17
  // ✅ CORRECT - Always import from @botpress/runtime
18
- import { z, Action, Workflow, Conversation } from "@botpress/runtime";
18
+ import { z, Action, Workflow, Conversation } from '@botpress/runtime'
19
19
  ```
20
20
 
21
21
  **Why this matters:**
22
+
22
23
  - `z` from `@botpress/runtime` is Botpress's internal fork of Zod (based on Zod 3.x)
23
24
  - Importing from `zod` directly can cause compatibility issues
24
25
  - ADK primitives (Action, Tool, Workflow, etc.) must come from `@botpress/runtime`
@@ -30,10 +31,10 @@ Botpress uses Zod 3.x internally. If adding `zod` to your project dependencies (
30
31
 
31
32
  ```typescript
32
33
  // ❌ AVOID - Dynamic imports can cause issues
33
- const { myAction } = await import("./actions/myAction");
34
+ const { myAction } = await import('./actions/myAction')
34
35
 
35
36
  // ✅ PREFER - Static imports
36
- import { myAction } from "./actions/myAction";
37
+ import { myAction } from './actions/myAction'
37
38
  ```
38
39
 
39
40
  ### Handler Syntax
@@ -46,16 +47,16 @@ Action handlers receive a props object with `input` and `client`. Both arrow fun
46
47
  // ✅ CORRECT - Method syntax
47
48
  export const myAction = new Action({
48
49
  async handler({ input }) {
49
- return { data: input.userId };
50
+ return { data: input.userId }
50
51
  },
51
- });
52
+ })
52
53
 
53
54
  // ✅ ALSO CORRECT - Arrow function syntax
54
55
  export const myAction = new Action({
55
56
  handler: async ({ input }) => {
56
- return { data: input.userId };
57
+ return { data: input.userId }
57
58
  },
58
- });
59
+ })
59
60
  ```
60
61
 
61
62
  #### Tool Handlers
@@ -64,9 +65,9 @@ export const myAction = new Action({
64
65
  // ✅ Tools use arrow functions
65
66
  export const myTool = new Autonomous.Tool({
66
67
  handler: async ({ query, limit }) => {
67
- return searchResults;
68
+ return searchResults
68
69
  },
69
- });
70
+ })
70
71
  ```
71
72
 
72
73
  ### State Management Mistakes
@@ -80,17 +81,17 @@ Conversations receive `state` as a destructured handler parameter. Do **not** us
80
81
  export const Chat = new Conversation({
81
82
  state: z.object({ count: z.number().default(0) }),
82
83
  async handler({ message }) {
83
- this.state.count += 1; // ❌ Wrong!
84
+ this.state.count += 1 // ❌ Wrong!
84
85
  },
85
- });
86
+ })
86
87
 
87
88
  // ✅ CORRECT - Use the state parameter
88
89
  export const Chat = new Conversation({
89
90
  state: z.object({ count: z.number().default(0) }),
90
91
  handler: async ({ message, state }) => {
91
- state.count += 1; // ✅ Destructured from handler props
92
+ state.count += 1 // ✅ Destructured from handler props
92
93
  },
93
- });
94
+ })
94
95
  ```
95
96
 
96
97
  #### State Reference vs Value
@@ -98,31 +99,32 @@ export const Chat = new Conversation({
98
99
  ```typescript
99
100
  // ❌ WRONG - Passing state reference to async function
100
101
  handler: async ({ step, state }) => {
101
- const results = await processItems(state.items);
102
+ const results = await processItems(state.items)
102
103
  // state.items may have changed while processItems was running
103
- state.items.push("new-item"); // processItems might see this!
104
+ state.items.push('new-item') // processItems might see this!
104
105
  }
105
106
 
106
107
  // ✅ CORRECT - Pass a copy of the value
107
108
  handler: async ({ step, state }) => {
108
- const itemsCopy = [...state.items];
109
- const results = await processItems(itemsCopy);
110
- state.items.push("new-item"); // safe, doesn't affect processItems
109
+ const itemsCopy = [...state.items]
110
+ const results = await processItems(itemsCopy)
111
+ state.items.push('new-item') // safe, doesn't affect processItems
111
112
  }
112
113
 
113
114
  // ✅ CORRECT - Extract values before async operation
114
115
  handler: async ({ step, state }) => {
115
- const currentCount = state.count; // Primitive - safe
116
- const currentItems = [...state.items]; // Array - needs spread
117
- const currentConfig = { ...state.config }; // Object - needs spread
116
+ const currentCount = state.count // Primitive - safe
117
+ const currentItems = [...state.items] // Array - needs spread
118
+ const currentConfig = { ...state.config } // Object - needs spread
118
119
 
119
- await step("process", async () => {
120
- return await processData(currentCount, currentItems, currentConfig);
121
- });
120
+ await step('process', async () => {
121
+ return await processData(currentCount, currentItems, currentConfig)
122
+ })
122
123
  }
123
124
  ```
124
125
 
125
126
  **Rules of thumb:**
127
+
126
128
  - **Primitives** (string, number, boolean): Can pass directly
127
129
  - **Arrays**: Use spread `[...state.items]` or `Array.from()`
128
130
  - **Objects**: Use spread `{ ...state.config }` or `structuredClone()`
@@ -136,35 +138,35 @@ handler: async ({ step, state }) => {
136
138
  // ❌ WRONG - Dynamic step names break resume
137
139
  for (let i = 0; i < items.length; i++) {
138
140
  await step(`process-${i}`, async () => {
139
- await processItem(items[i]);
140
- });
141
+ await processItem(items[i])
142
+ })
141
143
  }
142
144
 
143
145
  // ✅ CORRECT - Single step with loop
144
- await step("process-all", async () => {
146
+ await step('process-all', async () => {
145
147
  for (const item of items) {
146
- await processItem(item);
148
+ await processItem(item)
147
149
  }
148
- });
150
+ })
149
151
 
150
152
  // ✅ CORRECT - Or use step.map
151
- await step.map("process-items", items, async (item) => {
152
- return processItem(item);
153
- });
153
+ await step.map('process-items', items, async (item) => {
154
+ return processItem(item)
155
+ })
154
156
  ```
155
157
 
156
158
  #### Missing Await on Steps
157
159
 
158
160
  ```typescript
159
161
  // ❌ WRONG - Missing await
160
- const result = step("fetch", async () => {
161
- return fetchData();
162
- });
162
+ const result = step('fetch', async () => {
163
+ return fetchData()
164
+ })
163
165
 
164
166
  // ✅ CORRECT - Always await steps
165
- const result = await step("fetch", async () => {
166
- return fetchData();
167
- });
167
+ const result = await step('fetch', async () => {
168
+ return fetchData()
169
+ })
168
170
  ```
169
171
 
170
172
  ### Table Column Mistakes
@@ -192,15 +194,15 @@ columns: {
192
194
  // ❌ WRONG - Missing conversationId prevents communication
193
195
  await MyWorkflow.start({
194
196
  userId: user.id,
195
- data: "some data",
196
- });
197
+ data: 'some data',
198
+ })
197
199
 
198
200
  // ✅ CORRECT - Include conversationId for messaging
199
201
  await MyWorkflow.start({
200
202
  conversationId: conversation.id,
201
203
  userId: user.id,
202
- data: "some data",
203
- });
204
+ data: 'some data',
205
+ })
204
206
  ```
205
207
 
206
208
  ---
@@ -213,18 +215,15 @@ Request data from user during workflow execution:
213
215
 
214
216
  ```typescript
215
217
  export const MyWorkflow = new Workflow({
216
- name: "interactive",
218
+ name: 'interactive',
217
219
  requests: {
218
220
  topic: z.object({ topic: z.string() }),
219
221
  },
220
222
  handler: async ({ step, input }) => {
221
- const { topic } = await step.request(
222
- "topic",
223
- "What is the topic of the question?"
224
- );
225
- console.log(`Topic identified: ${topic}`);
223
+ const { topic } = await step.request('topic', 'What is the topic of the question?')
224
+ console.log(`Topic identified: ${topic}`)
226
225
  },
227
- });
226
+ })
228
227
  ```
229
228
 
230
229
  ### RAG with Citations
@@ -232,38 +231,38 @@ export const MyWorkflow = new Workflow({
232
231
  Use citations to track sources for AI-generated responses:
233
232
 
234
233
  ```typescript
235
- import { Autonomous, context } from "@botpress/runtime";
234
+ import { Autonomous, context } from '@botpress/runtime'
236
235
 
237
236
  const SearchTool = new Autonomous.Tool({
238
- name: "search",
237
+ name: 'search',
239
238
  input: z.string(),
240
239
  output: z.string(),
241
240
  handler: async (query) => {
242
- const client = context.get("client");
243
- const citations = context.get("citations");
241
+ const client = context.get('client')
242
+ const citations = context.get('citations')
244
243
 
245
244
  const { passages } = await client.searchFiles({
246
245
  query,
247
- tags: { type: "knowledge", kb: ["myKB"] },
248
- });
246
+ tags: { type: 'knowledge', kb: ['myKB'] },
247
+ })
249
248
 
250
- const message = ["Here are the search results:"];
251
- const { tag: example } = citations.registerSource({});
249
+ const message = ['Here are the search results:']
250
+ const { tag: example } = citations.registerSource({})
252
251
 
253
252
  for (const p of passages) {
254
- const { tag } = citations.registerSource({ file: p.file.key });
255
- message.push(`<${tag} file="${p.file.key}">`);
256
- message.push(`**${p.file.tags.title}**`);
257
- message.push(p.content);
258
- message.push(`</${tag}>`);
253
+ const { tag } = citations.registerSource({ file: p.file.key })
254
+ message.push(`<${tag} file="${p.file.key}">`)
255
+ message.push(`**${p.file.tags.title}**`)
256
+ message.push(p.content)
257
+ message.push(`</${tag}>`)
259
258
  }
260
259
 
261
260
  throw new Autonomous.ThinkSignal(
262
261
  `When answering, MUST add inline citations (eg: "The price is $10${example} ...")`,
263
- message.join("\n")
264
- );
262
+ message.join('\n')
263
+ )
265
264
  },
266
- });
265
+ })
267
266
  ```
268
267
 
269
268
  ### Context Access Patterns
@@ -273,19 +272,19 @@ The context API provides access to runtime services within handlers.
273
272
  #### Basic Context Usage
274
273
 
275
274
  ```typescript
276
- import { context } from "@botpress/runtime";
275
+ import { context } from '@botpress/runtime'
277
276
 
278
277
  export const myAction = new Action({
279
278
  handler: async ({ input }) => {
280
- const client = context.get("client");
281
- const cognitive = context.get("cognitive");
282
- const logger = context.get("logger");
279
+ const client = context.get('client')
280
+ const cognitive = context.get('cognitive')
281
+ const logger = context.get('logger')
283
282
 
284
- const { passages } = await client.searchFiles({ query: input.query });
285
- logger.info("Search completed", { resultCount: passages.length });
286
- return { results: passages };
283
+ const { passages } = await client.searchFiles({ query: input.query })
284
+ logger.info('Search completed', { resultCount: passages.length })
285
+ return { results: passages }
287
286
  },
288
- });
287
+ })
289
288
  ```
290
289
 
291
290
  #### Optional Context Keys
@@ -293,21 +292,22 @@ export const myAction = new Action({
293
292
  ```typescript
294
293
  export const myAction = new Action({
295
294
  handler: async ({ input }) => {
296
- const user = context.get("user", { optional: true });
297
- const conversation = context.get("conversation", { optional: true });
295
+ const user = context.get('user', { optional: true })
296
+ const conversation = context.get('conversation', { optional: true })
298
297
 
299
298
  if (user && conversation) {
300
- console.log(`User ${user.id} in conversation ${conversation.id}`);
299
+ console.log(`User ${user.id} in conversation ${conversation.id}`)
301
300
  } else {
302
- console.log("Processing without user context");
301
+ console.log('Processing without user context')
303
302
  }
304
303
  },
305
- });
304
+ })
306
305
  ```
307
306
 
308
307
  #### Common Context Keys
309
308
 
310
309
  **Always Available:**
310
+
311
311
  - `client` — Botpress API client
312
312
  - `cognitive` — AI model client
313
313
  - `logger` — Structured logger
@@ -316,6 +316,7 @@ export const myAction = new Action({
316
316
  - `runtime` — Runtime environment info
317
317
 
318
318
  **Conditionally Available:**
319
+
319
320
  - `user` — Current user (in conversation handlers)
320
321
  - `conversation` — Current conversation (in conversation handlers, not to be used within a conversation object: use the `conversation` parameter instead)
321
322
  - `message` — Incoming message (when triggered by message)
@@ -325,13 +326,13 @@ export const myAction = new Action({
325
326
 
326
327
  #### Context in Different Handler Types
327
328
 
328
- | Handler | Key context keys |
329
- |---------|-----------------|
330
- | **Actions** | `client`, `cognitive`, `logger`, `botId`, `configuration` |
331
- | **Tools** | `client`, `cognitive`, `citations`, `logger`, `user`?, `conversation`? |
332
- | **Workflows** | `client`, `workflow`, `workflowControlContext`, `logger` |
333
- | **Conversations** | `client`, `user`, `conversation`, `message`, `event`?, `logger` |
334
- | **Triggers** | `client`, `event`, `logger` |
329
+ | Handler | Key context keys |
330
+ | ----------------- | ---------------------------------------------------------------------- |
331
+ | **Actions** | `client`, `cognitive`, `logger`, `botId`, `configuration` |
332
+ | **Tools** | `client`, `cognitive`, `citations`, `logger`, `user`?, `conversation`? |
333
+ | **Workflows** | `client`, `workflow`, `workflowControlContext`, `logger` |
334
+ | **Conversations** | `client`, `user`, `conversation`, `message`, `event`?, `logger` |
335
+ | **Triggers** | `client`, `event`, `logger` |
335
336
 
336
337
  ---
337
338
 
@@ -372,19 +373,19 @@ src/knowledge/policies/privacy.md
372
373
 
373
374
  ```typescript
374
375
  // Actions
375
- export const fetchUser = new Action({ name: "fetchUser" });
376
+ export const fetchUser = new Action({ name: 'fetchUser' })
376
377
 
377
378
  // Workflows
378
- export const OnboardingWorkflow = new Workflow({ name: "onboarding" });
379
+ export const OnboardingWorkflow = new Workflow({ name: 'onboarding' })
379
380
 
380
381
  // Tables
381
- export const UsersTable = new Table({ name: "users" });
382
+ export const UsersTable = new Table({ name: 'users' })
382
383
 
383
384
  // Conversations
384
- export const Chat = new Conversation({ channel: "chat.channel" });
385
+ export const Chat = new Conversation({ channel: 'chat.channel' })
385
386
 
386
387
  // Triggers - use default export
387
- export default new Trigger({ name: "userEvents" });
388
+ export default new Trigger({ name: 'userEvents' })
388
389
  ```
389
390
 
390
391
  ---
@@ -433,12 +434,12 @@ grep -r "from \"@botpress/sdk\"" src/
433
434
  ```typescript
434
435
  // In conversations - use state parameter
435
436
  handler: async ({ state }) => {
436
- console.log("Conversation state:", JSON.stringify(state, null, 2));
437
+ console.log('Conversation state:', JSON.stringify(state, null, 2))
437
438
  }
438
439
 
439
440
  // In workflows - use state parameter
440
441
  handler: async ({ state }) => {
441
- console.log("Workflow state:", JSON.stringify(state, null, 2));
442
+ console.log('Workflow state:', JSON.stringify(state, null, 2))
442
443
  }
443
444
  ```
444
445
 
@@ -446,14 +447,14 @@ handler: async ({ state }) => {
446
447
 
447
448
  ```typescript
448
449
  handler: async ({ step }) => {
449
- console.log("Starting workflow");
450
+ console.log('Starting workflow')
450
451
 
451
- const result = await step("step1", async () => {
452
- console.log("Executing step1");
453
- return "data";
454
- });
452
+ const result = await step('step1', async () => {
453
+ console.log('Executing step1')
454
+ return 'data'
455
+ })
455
456
 
456
- console.log("Step1 result:", result);
457
+ console.log('Step1 result:', result)
457
458
  }
458
459
  ```
459
460