@botpress/adk 1.19.0-beta.9 → 2.0.0-alpha.0

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
@@ -5,6 +5,7 @@ Tools are functions that AI models can call during conversations to perform acti
5
5
  ## Overview
6
6
 
7
7
  Tools enable you to:
8
+
8
9
  - Give AI capabilities like searching, creating records, sending messages
9
10
  - Perform actions autonomously based on conversation context
10
11
  - Access external APIs and integrations
@@ -22,68 +23,69 @@ Tools enable you to:
22
23
  ## Basic Tool Structure
23
24
 
24
25
  ```typescript
25
- import { Autonomous, z } from "@botpress/runtime";
26
+ import { Autonomous, z } from '@botpress/runtime'
26
27
 
27
28
  // Option 1: Named export (recommended)
28
29
  export const searchDocs = new Autonomous.Tool({
29
- name: "searchDocs",
30
- description: "Search documentation for answers to user questions",
30
+ name: 'searchDocs',
31
+ description: 'Search documentation for answers to user questions',
31
32
 
32
33
  input: z.object({
33
- query: z.string().describe("The search query"),
34
- maxResults: z.number().default(5).describe("Maximum results to return")
34
+ query: z.string().describe('The search query'),
35
+ maxResults: z.number().default(5).describe('Maximum results to return'),
35
36
  }),
36
37
 
37
38
  output: z.string(),
38
39
 
39
40
  handler: async ({ query, maxResults }) => {
40
- const results = await searchDocumentation(query, maxResults);
41
- return results.join("\n\n");
41
+ const results = await searchDocumentation(query, maxResults)
42
+ return results.join('\n\n')
42
43
  },
43
- });
44
+ })
44
45
 
45
46
  // Option 2: Default export (also valid)
46
47
  export default new Autonomous.Tool({
47
- name: "searchDocs",
48
+ name: 'searchDocs',
48
49
  // ... same configuration
49
- });
50
+ })
50
51
  ```
51
52
 
52
53
  **Why use `export const`?**
54
+
53
55
  - Enables direct imports: `import { searchDocs } from "./tools/searchDocs"`
54
56
  - Can pass directly to `execute()`: `tools: [searchDocs]`
55
57
  - Better for tool composition and reusability
56
58
 
57
59
  ## Tool Properties
58
60
 
59
- | Property | Type | Required | Description |
60
- |----------|------|----------|-------------|
61
- | **name** | `string` | Yes | Unique TypeScript-compatible identifier |
62
- | **description** | `string` | Recommended | Helps AI understand when and how to use the tool |
63
- | **input** | `z.ZodType` | No | Zod schema for input validation (defaults to `z.any()`) |
64
- | **output** | `z.ZodType` | No | Zod schema for output validation (defaults to `z.any()`) |
65
- | **handler** | `function` | Yes | Async function implementing tool logic |
66
- | **aliases** | `string[]` | No | Alternative names the AI can use to call this tool |
67
- | **metadata** | `Record<string, any>` | No | Custom information for tool categorization |
68
- | **staticInputValues** | `object` | No | Pre-set parameter values |
69
- | **retry** | `function` | No | Custom retry logic for failures |
61
+ | Property | Type | Required | Description |
62
+ | --------------------- | --------------------- | ----------- | -------------------------------------------------------- |
63
+ | **name** | `string` | Yes | Unique TypeScript-compatible identifier |
64
+ | **description** | `string` | Recommended | Helps AI understand when and how to use the tool |
65
+ | **input** | `z.ZodType` | No | Zod schema for input validation (defaults to `z.any()`) |
66
+ | **output** | `z.ZodType` | No | Zod schema for output validation (defaults to `z.any()`) |
67
+ | **handler** | `function` | Yes | Async function implementing tool logic |
68
+ | **aliases** | `string[]` | No | Alternative names the AI can use to call this tool |
69
+ | **metadata** | `Record<string, any>` | No | Custom information for tool categorization |
70
+ | **staticInputValues** | `object` | No | Pre-set parameter values |
71
+ | **retry** | `function` | No | Custom retry logic for failures |
70
72
 
71
73
  ## Tool Handler Syntax
72
74
 
73
75
  Tools receive input directly (not wrapped in `{ input }`) and can use global runtime proxies such as `user`, `bot`, `adk`, and `actions`. For optional per-request values like `conversation` or `message`, use the Context API.
74
76
 
75
77
  ```typescript
76
- import { Autonomous, z, user, adk, context } from "@botpress/runtime";
78
+ import { Autonomous, z, user, adk, context } from '@botpress/runtime'
77
79
 
78
80
  // ✅ Tools can destructure input parameters directly
79
81
  export default new Autonomous.Tool({
80
- name: "createCharacter",
81
- description: "Create a new character with name and race",
82
+ name: 'createCharacter',
83
+ description: 'Create a new character with name and race',
82
84
 
83
85
  input: z.object({
84
- name: z.string().describe("Character name"),
85
- race: z.enum(["human", "elf", "dwarf"]),
86
- background: z.enum(["warrior", "ranger"]).optional()
86
+ name: z.string().describe('Character name'),
87
+ race: z.enum(['human', 'elf', 'dwarf']),
88
+ background: z.enum(['warrior', 'ranger']).optional(),
87
89
  }),
88
90
 
89
91
  output: z.string(),
@@ -91,97 +93,98 @@ export default new Autonomous.Tool({
91
93
  // Handler destructures input directly
92
94
  handler: async ({ name, race, background }) => {
93
95
  // Direct access to user state
94
- user.state.characterName = name;
95
- user.state.race = race;
96
- user.state.background = background;
96
+ user.state.characterName = name
97
+ user.state.race = race
98
+ user.state.background = background
97
99
 
98
100
  // Use ADK utilities
99
101
  const stats = await adk.zai.extract(
100
102
  `Create character stats for ${name} the ${race}`,
101
103
  z.object({
102
104
  courage: z.number().min(0).max(100),
103
- wisdom: z.number().min(0).max(100)
105
+ wisdom: z.number().min(0).max(100),
104
106
  })
105
- );
107
+ )
106
108
 
107
- user.state.courage = stats.courage;
108
- user.state.wisdom = stats.wisdom;
109
+ user.state.courage = stats.courage
110
+ user.state.wisdom = stats.wisdom
109
111
 
110
- return `Created ${name} the ${race}!`;
111
- }
112
- });
112
+ return `Created ${name} the ${race}!`
113
+ },
114
+ })
113
115
 
114
116
  // ✅ Can also receive input as single parameter
115
117
  export const simpleSearch = new Autonomous.Tool({
116
- name: "search",
117
- description: "Search knowledge bases",
118
- input: z.string().describe("The query to search for").min(1).max(1024),
118
+ name: 'search',
119
+ description: 'Search knowledge bases',
120
+ input: z.string().describe('The query to search for').min(1).max(1024),
119
121
  output: z.string(),
120
122
 
121
123
  handler: async (query) => {
122
- const results = await performSearch(query);
123
- return results;
124
- }
125
- });
124
+ const results = await performSearch(query)
125
+ return results
126
+ },
127
+ })
126
128
 
127
129
  // ✅ Method syntax with context parameter
128
130
  export const anotherTool = new Autonomous.Tool({
129
- name: "anotherTool",
131
+ name: 'anotherTool',
130
132
  input: z.object({ param: z.string() }),
131
133
  output: z.string(),
132
134
 
133
135
  async handler(input, ctx) {
134
136
  // ctx.callId - unique identifier for this execution
135
- console.log(`Processing call: ${ctx.callId}`);
136
- return `Processed ${input.param}`;
137
- }
138
- });
137
+ console.log(`Processing call: ${ctx.callId}`)
138
+ return `Processed ${input.param}`
139
+ },
140
+ })
139
141
  ```
140
142
 
141
143
  **Key Differences from Actions:**
142
144
 
143
- | Feature | Actions | Tools |
144
- |---------|---------|-------|
145
- | Input parameter | `{ input, client }` wrapper | Direct input or destructuring |
146
- | Context access | Via imports or context API | Via imports (automatically available) |
147
- | Typical use | Internal functions, any context | AI-callable, conversation context |
148
- | Handler signature | `handler({ input, client })` | `handler(input, ctx?)` or `handler({ ...fields }, ctx?)` |
145
+ | Feature | Actions | Tools |
146
+ | ----------------- | ------------------------------- | -------------------------------------------------------- |
147
+ | Input parameter | `{ input, client }` wrapper | Direct input or destructuring |
148
+ | Context access | Via imports or context API | Via imports (automatically available) |
149
+ | Typical use | Internal functions, any context | AI-callable, conversation context |
150
+ | Handler signature | `handler({ input, client })` | `handler(input, ctx?)` or `handler({ ...fields }, ctx?)` |
149
151
 
150
152
  ## Accessing Context in Tools
151
153
 
152
154
  Tools can use global runtime proxies directly, but conversation-specific values should be loaded through `context.get(...)`:
153
155
 
154
156
  ```typescript
155
- import { Autonomous, z, user, bot, adk, actions, context } from "@botpress/runtime";
157
+ import { Autonomous, z, user, bot, adk, actions, context } from '@botpress/runtime'
156
158
 
157
159
  export default new Autonomous.Tool({
158
- name: "upgradeUser",
159
- description: "Upgrade user to pro tier",
160
+ name: 'upgradeUser',
161
+ description: 'Upgrade user to pro tier',
160
162
  input: z.object({}),
161
163
  output: z.string(),
162
164
 
163
165
  handler: async (input) => {
164
166
  // Direct access to context
165
- const userName = user.state.name;
166
- const currentTier = user.tags.tier;
167
- const conversation = context.get("conversation", { optional: true });
167
+ const userName = user.state.name
168
+ const currentTier = user.tags.tier
169
+ const conversation = context.get('conversation', { optional: true })
168
170
 
169
171
  // Update user state and tags
170
- user.tags.tier = "pro";
171
- bot.state.totalUpgrades += 1;
172
+ user.tags.tier = 'pro'
173
+ bot.state.totalUpgrades += 1
172
174
 
173
175
  // Call integration actions
174
176
  await actions.slack.sendMessage({
175
- channel: "upgrades",
176
- text: `${userName} upgraded from ${currentTier} to pro`
177
- });
177
+ channel: 'upgrades',
178
+ text: `${userName} upgraded from ${currentTier} to pro`,
179
+ })
178
180
 
179
- return `Upgraded ${userName} to pro tier`;
180
- }
181
- });
181
+ return `Upgraded ${userName} to pro tier`
182
+ },
183
+ })
182
184
  ```
183
185
 
184
186
  **Commonly used in tools:**
187
+
185
188
  - `user` - Current user (`.state`, `.tags`)
186
189
  - `bot` - Bot object (always available)
187
190
  - `adk` - ADK utilities (`adk.zai.extract()`, etc.)
@@ -196,44 +199,41 @@ For complete context access details including `client`, `citations`, availabilit
196
199
  `ThinkSignal` allows tools to return results with additional instructions for the AI. When thrown, it provides context that guides how the AI should use the information.
197
200
 
198
201
  ```typescript
199
- import { Autonomous, z } from "@botpress/runtime";
202
+ import { Autonomous, z } from '@botpress/runtime'
200
203
 
201
204
  export default new Autonomous.Tool({
202
- name: "searchKnowledge",
203
- description: "Search the knowledge base",
204
- input: z.string().describe("Search query"),
205
+ name: 'searchKnowledge',
206
+ description: 'Search the knowledge base',
207
+ input: z.string().describe('Search query'),
205
208
  output: z.string(),
206
209
 
207
210
  handler: async (query) => {
208
- const results = await knowledgeBase.search(query);
211
+ const results = await knowledgeBase.search(query)
209
212
 
210
213
  // Handle no results case
211
214
  if (!results.length) {
212
215
  throw new Autonomous.ThinkSignal(
213
- "No results found",
214
- "No results were found. Try rephrasing or ask something else. Do NOT make up an answer."
215
- );
216
+ 'No results found',
217
+ 'No results were found. Try rephrasing or ask something else. Do NOT make up an answer.'
218
+ )
216
219
  }
217
220
 
218
221
  // Format results for AI consumption
219
- const formatted = results
220
- .map((r, i) => `[${i + 1}] ${r.title}\n${r.content}`)
221
- .join("\n\n");
222
+ const formatted = results.map((r, i) => `[${i + 1}] ${r.title}\n${r.content}`).join('\n\n')
222
223
 
223
224
  // Return results with instructions for the AI
224
- throw new Autonomous.ThinkSignal(
225
- "Search complete - use these results to answer",
226
- formatted
227
- );
228
- }
229
- });
225
+ throw new Autonomous.ThinkSignal('Search complete - use these results to answer', formatted)
226
+ },
227
+ })
230
228
  ```
231
229
 
232
230
  **ThinkSignal parameters:**
231
+
233
232
  - **First argument**: Brief status message for logs
234
233
  - **Second argument**: Detailed content/instructions for the AI
235
234
 
236
235
  **When to use ThinkSignal:**
236
+
237
237
  - Providing search results with guidance
238
238
  - Handling edge cases (no results, errors)
239
239
  - Guiding AI behavior based on outcomes
@@ -247,11 +247,13 @@ Provide alternative names for the tool:
247
247
 
248
248
  ```typescript
249
249
  export default new Autonomous.Tool({
250
- name: "searchDocumentation",
251
- aliases: ["search_docs", "findDocs", "lookupDocs"],
252
- description: "Search documentation",
253
- handler: async (query) => { /* ... */ }
254
- });
250
+ name: 'searchDocumentation',
251
+ aliases: ['search_docs', 'findDocs', 'lookupDocs'],
252
+ description: 'Search documentation',
253
+ handler: async (query) => {
254
+ /* ... */
255
+ },
256
+ })
255
257
  ```
256
258
 
257
259
  ### Static Input Values
@@ -260,18 +262,20 @@ Pre-set parameter values for specialized tool variants:
260
262
 
261
263
  ```typescript
262
264
  const baseSearchTool = new Autonomous.Tool({
263
- name: "search",
265
+ name: 'search',
264
266
  input: z.object({
265
267
  query: z.string(),
266
- category: z.string()
268
+ category: z.string(),
267
269
  }),
268
- handler: async ({ query, category }) => { /* ... */ }
269
- });
270
+ handler: async ({ query, category }) => {
271
+ /* ... */
272
+ },
273
+ })
270
274
 
271
275
  // Create specialized version with pre-set category
272
276
  const productSearchTool = baseSearchTool.with({
273
- staticInputValues: { category: "products" }
274
- });
277
+ staticInputValues: { category: 'products' },
278
+ })
275
279
  ```
276
280
 
277
281
  ### Custom Retry Logic
@@ -280,24 +284,24 @@ Handle failures with custom retry behavior:
280
284
 
281
285
  ```typescript
282
286
  export default new Autonomous.Tool({
283
- name: "externalAPI",
284
- description: "Call external API",
287
+ name: 'externalAPI',
288
+ description: 'Call external API',
285
289
  input: z.object({ endpoint: z.string() }),
286
290
  output: z.any(),
287
291
 
288
292
  retry: async ({ input, attempt, error }) => {
289
293
  if (attempt < 3 && error?.code === 'RATE_LIMIT') {
290
- await new Promise(r => setTimeout(r, 1000 * attempt));
291
- return true; // Retry
294
+ await new Promise((r) => setTimeout(r, 1000 * attempt))
295
+ return true // Retry
292
296
  }
293
- return false; // Don't retry
297
+ return false // Don't retry
294
298
  },
295
299
 
296
300
  handler: async ({ endpoint }) => {
297
- const response = await fetch(endpoint);
298
- return await response.json();
299
- }
300
- });
301
+ const response = await fetch(endpoint)
302
+ return await response.json()
303
+ },
304
+ })
301
305
  ```
302
306
 
303
307
  ## Autonomous Namespace
@@ -307,8 +311,8 @@ The `Autonomous` namespace provides types and utilities for AI-powered autonomou
307
311
  ### Autonomous.Tool
308
312
 
309
313
  ```typescript
310
- export const Tool = LlmzTool;
311
- export type Tool = InstanceType<typeof Tool>;
314
+ export const Tool = LlmzTool
315
+ export type Tool = InstanceType<typeof Tool>
312
316
  ```
313
317
 
314
318
  ### Autonomous.Model Type
@@ -316,28 +320,29 @@ export type Tool = InstanceType<typeof Tool>;
316
320
  Type for specifying AI models:
317
321
 
318
322
  ```typescript
319
- import { defineConfig } from "@botpress/runtime";
323
+ import { defineConfig } from '@botpress/runtime'
320
324
 
321
325
  export default defineConfig({
322
- name: "my-agent",
326
+ name: 'my-agent',
323
327
  defaultModels: {
324
- autonomous: "openai:gpt-4o",
325
- zai: "openai:gpt-4o-mini"
326
- }
327
- });
328
+ autonomous: 'openai:gpt-4o',
329
+ zai: 'openai:gpt-4o-mini',
330
+ },
331
+ })
328
332
 
329
333
  // With fallback chain
330
334
  export default defineConfig({
331
335
  defaultModels: {
332
- autonomous: ["openai:gpt-4o", "anthropic:claude-3-5-sonnet"],
333
- zai: "openai:gpt-4o-mini"
334
- }
335
- });
336
+ autonomous: ['openai:gpt-4o', 'anthropic:claude-3-5-sonnet'],
337
+ zai: 'openai:gpt-4o-mini',
338
+ },
339
+ })
336
340
  ```
337
341
 
338
342
  **Model format:** `"provider:model-name"`
339
343
 
340
344
  **Common providers:**
345
+
341
346
  - `openai:gpt-4o`, `openai:gpt-4o-mini`
342
347
  - `anthropic:claude-3-5-sonnet`
343
348
  - `cerebras:gpt-oss-120b`
@@ -349,72 +354,66 @@ Advanced hooks for controlling AI execution behavior:
349
354
  ```typescript
350
355
  export type Hooks = {
351
356
  onBeforeTool?: (event: {
352
- iteration: Iteration;
353
- tool: Autonomous.Tool;
354
- input: any;
355
- controller: AbortController;
356
- }) => Promise<{ input?: any; } | void>;
357
+ iteration: Iteration
358
+ tool: Autonomous.Tool
359
+ input: any
360
+ controller: AbortController
361
+ }) => Promise<{ input?: any } | void>
357
362
 
358
363
  onAfterTool?: (event: {
359
- iteration: Iteration;
360
- tool: Autonomous.Tool;
361
- input: any;
362
- output: any;
363
- controller: AbortController;
364
- }) => Promise<{ output?: any; } | void>;
365
-
366
- onBeforeExecution?: (
367
- iteration: Iteration,
364
+ iteration: Iteration
365
+ tool: Autonomous.Tool
366
+ input: any
367
+ output: any
368
368
  controller: AbortController
369
- ) => Promise<{ code?: string; } | void>;
369
+ }) => Promise<{ output?: any } | void>
370
370
 
371
- onExit?: <T = unknown>(result: ExitResult<T>) => Promise<void> | void;
371
+ onBeforeExecution?: (iteration: Iteration, controller: AbortController) => Promise<{ code?: string } | void>
372
372
 
373
- onTrace?: (props: { trace: Trace; iteration: number }) => void;
373
+ onExit?: <T = unknown>(result: ExitResult<T>) => Promise<void> | void
374
374
 
375
- onIterationEnd?: (
376
- iteration: Iteration,
377
- controller: IterationController
378
- ) => void | Promise<void>;
379
- };
375
+ onTrace?: (props: { trace: Trace; iteration: number }) => void
376
+
377
+ onIterationEnd?: (iteration: Iteration, controller: IterationController) => void | Promise<void>
378
+ }
380
379
  ```
381
380
 
382
381
  **Example - Logging tool calls:**
383
382
 
384
383
  ```typescript
385
384
  await execute({
386
- instructions: "Help the user",
385
+ instructions: 'Help the user',
387
386
  tools: [searchTool, createTicketTool],
388
387
  hooks: {
389
388
  onBeforeTool: async ({ tool, input }) => {
390
- console.log(`Calling tool: ${tool.name}`, input);
389
+ console.log(`Calling tool: ${tool.name}`, input)
391
390
  },
392
391
  onAfterTool: async ({ tool, output }) => {
393
- console.log(`Tool ${tool.name} returned:`, output);
394
- }
395
- }
396
- });
392
+ console.log(`Tool ${tool.name} returned:`, output)
393
+ },
394
+ },
395
+ })
397
396
  ```
398
397
 
399
398
  **Example - Modifying tool inputs:**
400
399
 
401
400
  ```typescript
402
401
  await execute({
403
- instructions: "Search for information",
402
+ instructions: 'Search for information',
404
403
  tools: [searchTool],
405
404
  hooks: {
406
405
  onBeforeTool: async ({ tool, input }) => {
407
- if (tool.name === "search") {
406
+ if (tool.name === 'search') {
408
407
  return {
409
408
  input: {
410
409
  ...input,
411
- query: `${input.query} site:docs.example.com`
412
- }
413
- };
410
+ query: `${input.query} site:docs.example.com`,
411
+ },
412
+ }
414
413
  }
415
- }
416
- }
417
- });
414
+ },
415
+ },
416
+ })
418
417
  ```
419
418
 
420
419
  ### Autonomous.Exit - Structured AI Exits
@@ -422,45 +421,47 @@ await execute({
422
421
  Exits provide type-safe, structured ways for AI to return different outcomes:
423
422
 
424
423
  ```typescript
425
- import { Autonomous, z } from "@botpress/runtime";
424
+ import { Autonomous, z } from '@botpress/runtime'
426
425
 
427
426
  const SearchExit = new Autonomous.Exit({
428
- name: "search_complete",
429
- description: "Search completed successfully",
427
+ name: 'search_complete',
428
+ description: 'Search completed successfully',
430
429
  schema: z.object({
431
430
  results: z.array(z.string()),
432
- count: z.number()
433
- })
434
- });
431
+ count: z.number(),
432
+ }),
433
+ })
435
434
 
436
435
  const NoResultsExit = new Autonomous.Exit({
437
- name: "no_results",
438
- description: "No results found for the query"
439
- });
436
+ name: 'no_results',
437
+ description: 'No results found for the query',
438
+ })
440
439
 
441
440
  // Use exits in execute()
442
441
  const result = await execute({
443
- instructions: "Search and return appropriate exit",
444
- exits: [SearchExit, NoResultsExit]
445
- });
442
+ instructions: 'Search and return appropriate exit',
443
+ exits: [SearchExit, NoResultsExit],
444
+ })
446
445
 
447
446
  // Type-safe handling
448
447
  if (result.is(SearchExit)) {
449
- console.log(`Found ${result.output.count} results`);
448
+ console.log(`Found ${result.output.count} results`)
450
449
  } else if (result.is(NoResultsExit)) {
451
- console.log("No results found");
450
+ console.log('No results found')
452
451
  }
453
452
  ```
454
453
 
455
454
  ### Other Autonomous Exports
456
455
 
457
456
  **Signal Classes:**
457
+
458
458
  ```typescript
459
- export const ThinkSignal = _ThinkSignal;
460
- export const SnapshotSignal = _SnapshotSignal;
459
+ export const ThinkSignal = _ThinkSignal
460
+ export const SnapshotSignal = _SnapshotSignal
461
461
  ```
462
462
 
463
463
  **Type Exports:**
464
+
464
465
  ```typescript
465
466
  export type Iteration = InstanceType<typeof LlmzIteration>;
466
467
  export type ExecuteResult = Awaited<ReturnType<Execute>>;
@@ -483,37 +484,28 @@ export type IterationController = /* controller interface */;
483
484
 
484
485
  ```typescript
485
486
  export default new Autonomous.Tool({
486
- name: "createSupportTicket",
487
- description: "Create a support ticket for user issues or requests",
487
+ name: 'createSupportTicket',
488
+ description: 'Create a support ticket for user issues or requests',
488
489
 
489
490
  input: z.object({
490
- title: z.string()
491
- .min(5)
492
- .max(100)
493
- .describe("Brief ticket title"),
494
- description: z.string()
495
- .min(10)
496
- .max(2000)
497
- .describe("Detailed issue description"),
498
- priority: z.enum(["low", "medium", "high", "urgent"])
499
- .default("medium")
500
- .describe("Ticket priority level"),
501
- category: z.enum(["bug", "feature", "question", "other"])
502
- .describe("Issue category")
491
+ title: z.string().min(5).max(100).describe('Brief ticket title'),
492
+ description: z.string().min(10).max(2000).describe('Detailed issue description'),
493
+ priority: z.enum(['low', 'medium', 'high', 'urgent']).default('medium').describe('Ticket priority level'),
494
+ category: z.enum(['bug', 'feature', 'question', 'other']).describe('Issue category'),
503
495
  }),
504
496
 
505
497
  output: z.object({
506
498
  ticketId: z.string(),
507
- url: z.string()
499
+ url: z.string(),
508
500
  }),
509
501
 
510
502
  handler: async ({ title, description, priority, category }) => {
511
503
  // Validate user has permission
512
- if (user.tags.tier === "free" && priority === "urgent") {
504
+ if (user.tags.tier === 'free' && priority === 'urgent') {
513
505
  throw new ThinkSignal(
514
- "Priority upgrade needed",
515
- "Urgent priority is only available for premium users. Would you like to upgrade?"
516
- );
506
+ 'Priority upgrade needed',
507
+ 'Urgent priority is only available for premium users. Would you like to upgrade?'
508
+ )
517
509
  }
518
510
 
519
511
  // Create ticket with context
@@ -523,20 +515,20 @@ export default new Autonomous.Tool({
523
515
  priority,
524
516
  metadata: {
525
517
  userId: user.id,
526
- conversationId: conversation?.id
527
- }
528
- });
518
+ conversationId: conversation?.id,
519
+ },
520
+ })
529
521
 
530
522
  // Update user state
531
- user.state.lastTicketId = ticket.id;
532
- user.state.lastTicketCreated = new Date().toISOString();
523
+ user.state.lastTicketId = ticket.id
524
+ user.state.lastTicketCreated = new Date().toISOString()
533
525
 
534
526
  return {
535
527
  ticketId: ticket.id,
536
- url: `https://support.example.com/ticket/${ticket.id}`
537
- };
538
- }
539
- });
528
+ url: `https://support.example.com/ticket/${ticket.id}`,
529
+ }
530
+ },
531
+ })
540
532
  ```
541
533
 
542
534
  ## Troubleshooting