@botpress/adk-cli 1.19.0-beta.4 → 1.19.0-beta.6

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 (87) hide show
  1. package/{dist/index-a3ZL0_Jr-q145h35p.js → assets/ui-dist/assets/index-BC_iUF2d.js} +2 -2
  2. package/assets/ui-dist/assets/index-BxpvDT_K.css +1 -0
  3. package/{dist/index-BESZeTO5-2rpmcefa.js → assets/ui-dist/assets/index-C7gAokRv.js} +2 -2
  4. package/assets/ui-dist/assets/{index-B3b7PPgV.js → index-exyr_Djl.js} +424 -424
  5. package/assets/ui-dist/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  6. package/assets/ui-dist/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  7. package/assets/ui-dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  8. package/assets/ui-dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  9. package/assets/ui-dist/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  10. package/assets/ui-dist/index.html +2 -2
  11. package/dist/{README-wjb7z7f0.md → README-824wa4jj.md} +1 -1
  12. package/dist/SKILL-75ym6tcj.md +257 -0
  13. package/dist/SKILL-chnwzmt1.md +548 -0
  14. package/dist/SKILL-d4bs53y3.md +244 -0
  15. package/dist/SKILL-h4b2f1n9.md +114 -0
  16. package/dist/SKILL-hbw5nt95.md +111 -0
  17. package/dist/actions-h7hxxvxr.md +823 -0
  18. package/dist/adk-build-emhwd0tg.md +39 -0
  19. package/dist/adk-debug-yrrdtpmb.md +23 -0
  20. package/dist/adk-dev-console-7z9rtjpy.md +17 -0
  21. package/dist/adk-document-ras6zzzh.md +68 -0
  22. package/dist/adk-eval-vx76dwq0.md +17 -0
  23. package/dist/adk-explain-fcsaw852.md +22 -0
  24. package/dist/adk-init-9kmxmbbe.md +30 -0
  25. package/dist/adk-ship-dybzn884.md +29 -0
  26. package/dist/adk-test-xq67savs.md +27 -0
  27. package/dist/adk-validate-1p4skv4m.md +31 -0
  28. package/dist/advanced-patterns-z86m9h1a.md +669 -0
  29. package/dist/agent-config-1aqvkrgf.md +450 -0
  30. package/dist/agent-steps-zj4c1n9t.md +115 -0
  31. package/dist/assets-q7jt8r2q.md +237 -0
  32. package/dist/autonomous-execution-fymc12e5.md +747 -0
  33. package/dist/cli-c31e06yr.md +1334 -0
  34. package/dist/cli.js +4241 -6449
  35. package/dist/commands.json +25 -4
  36. package/dist/common-failures-ht29w2db.md +231 -0
  37. package/dist/component-registry-bbpw0see.md +43 -0
  38. package/dist/context-api-760cvh0h.md +461 -0
  39. package/dist/conversation-analysis-8ka4nrm4.md +420 -0
  40. package/dist/conversation-lifecycle-4seqqjc1.md +311 -0
  41. package/dist/conversations-gwfvxaee.md +1111 -0
  42. package/dist/custom-components-y5wdgpey.md +167 -0
  43. package/dist/debug-workflow-vz84q80v.md +239 -0
  44. package/dist/desk-k54ktvsd.md +852 -0
  45. package/dist/doc-standards-ck6ax2jd.md +124 -0
  46. package/dist/eval-format-7n9brja4.md +354 -0
  47. package/dist/evals-y1zcr1mc.md +11 -0
  48. package/dist/explain-config-1yaq3zzd.md +424 -0
  49. package/dist/files-dzt0wxn3.md +918 -0
  50. package/dist/{index-3t354nbw.html → index-0qts7wfk.html} +2 -2
  51. package/{assets/ui-dist/assets/index-a3ZL0_Jr.js → dist/index-BC_iUF2d-3h9mqazs.js} +2 -2
  52. package/dist/index-BxpvDT_K-62864175.css +1 -0
  53. package/{assets/ui-dist/assets/index-BESZeTO5.js → dist/index-C7gAokRv-zr7dzkba.js} +2 -2
  54. package/dist/{index-B3b7PPgV-zetkb01w.js → index-exyr_Djl-ksys08wc.js} +424 -424
  55. package/dist/integration-actions-xang7tma.md +659 -0
  56. package/dist/integrations-k5ss07f4.md +266 -0
  57. package/dist/interfaces-6t0bpxs4.md +97 -0
  58. package/dist/jetbrains-mono-cyrillic-wght-normal-D73BlboJ-6vpq1jfh.woff2 +0 -0
  59. package/dist/jetbrains-mono-greek-wght-normal-Bw9x6K1M-jv5dqe09.woff2 +0 -0
  60. package/dist/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a-h2ysfc3f.woff2 +0 -0
  61. package/dist/jetbrains-mono-latin-wght-normal-B9CIFXIH-hj2e42wt.woff2 +0 -0
  62. package/dist/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq-wttk1pwp.woff2 +0 -0
  63. package/dist/knowledge-bases-20rg8p5c.md +456 -0
  64. package/dist/llm-debugging-76ng8rzm.md +209 -0
  65. package/dist/mcp-server-n1asyzhv.md +112 -0
  66. package/dist/messages-gkkg0b54.md +769 -0
  67. package/dist/model-configuration-f273kgd0.md +201 -0
  68. package/dist/multi-agent-dashboard-1mdfjdts.md +70 -0
  69. package/dist/pages-xn18xn73.md +273 -0
  70. package/dist/patterns-mistakes-5vb99dhf.md +469 -0
  71. package/dist/plugins-ttnx8f49.md +280 -0
  72. package/dist/tables-x45t36dd.md +1136 -0
  73. package/dist/tags-46td3qrg.md +516 -0
  74. package/dist/test-patterns-hj47w4nc.md +355 -0
  75. package/dist/testing-workflow-2vkp932f.md +225 -0
  76. package/dist/tools-wk7bq24z.md +581 -0
  77. package/dist/trace-summarization-hdyx1c2e.md +313 -0
  78. package/dist/traces-and-logs-f2kjfh19.md +203 -0
  79. package/dist/triggers-4j2cc86x.md +719 -0
  80. package/dist/ui-server-entry.js +1839 -791
  81. package/dist/workflow-steps-mrdrf1c5.md +851 -0
  82. package/dist/workflows-gadx3s69.md +1408 -0
  83. package/dist/zai-agent-reference-e6644aad.md +454 -0
  84. package/dist/zai-complete-guide-mnna5d6f.md +1408 -0
  85. package/package.json +4 -4
  86. package/assets/ui-dist/assets/index-DIFGtVmI.css +0 -1
  87. package/dist/index-DIFGtVmI-d4dhjg97.css +0 -1
@@ -0,0 +1,516 @@
1
+ # Tags
2
+
3
+ Tags are key-value pairs that can be attached to bots, users, conversations, and workflows. They provide a flexible way to track metadata, categorize entities, and store cross-handler state.
4
+
5
+ ## Basic Concepts
6
+
7
+ ### What are Tags?
8
+
9
+ - **Key-value pairs**: String keys with string values
10
+ - **Entity-scoped**: Available on bot, user, conversation, and workflow
11
+ - **Schema-defined**: Must be declared in `agent.config.ts`
12
+ - **Automatically persisted**: Changes are tracked and saved automatically
13
+ - **System vs Custom**: System tags (with `:`) are read-only
14
+
15
+ ### Tag Types
16
+
17
+ | Type | Example Key | Description |
18
+ |------|-------------|-------------|
19
+ | **Custom** | `tier`, `region` | User-defined, read-write |
20
+ | **System** | `webchat:owner` | Integration-managed, read-only |
21
+
22
+ ## Defining Tags
23
+
24
+ Tags must be defined in your `agent.config.ts` to be persisted:
25
+
26
+ ### User Tags
27
+
28
+ ```typescript
29
+ import { defineConfig, z } from "@botpress/runtime";
30
+
31
+ export default defineConfig({
32
+ name: "my-bot",
33
+
34
+ user: {
35
+ // User state (mutable object data)
36
+ state: z.object({
37
+ preferences: z.object({}).passthrough(),
38
+ }),
39
+
40
+ // User tags (key-value pairs for categorization)
41
+ // Tags are defined as { title: string, description?: string } objects, NOT Zod schemas
42
+ tags: {
43
+ tier: { title: "Subscription Tier", description: "User subscription level" },
44
+ region: { title: "Region", description: "User geographic region" },
45
+ source: { title: "Acquisition Source" },
46
+ referralCode: { title: "Referral Code" },
47
+ },
48
+ },
49
+ });
50
+ ```
51
+
52
+ ### Conversation Tags
53
+
54
+ ```typescript
55
+ export default defineConfig({
56
+ name: "my-bot",
57
+
58
+ conversation: {
59
+ tags: {
60
+ category: { title: "Category" },
61
+ priority: { title: "Priority", description: "Conversation priority level" },
62
+ assignedTo: { title: "Assigned To" },
63
+ department: { title: "Department" },
64
+ },
65
+ },
66
+ });
67
+ ```
68
+
69
+ ### Bot Tags
70
+
71
+ ```typescript
72
+ export default defineConfig({
73
+ name: "my-bot",
74
+
75
+ bot: {
76
+ state: z.object({
77
+ version: z.number().default(1),
78
+ }),
79
+
80
+ tags: {
81
+ environment: { title: "Environment", description: "Deployment environment" },
82
+ region: { title: "Region" },
83
+ version: { title: "Version" },
84
+ },
85
+ },
86
+ });
87
+ ```
88
+
89
+ ### Workflow Tags
90
+
91
+ ```typescript
92
+ export default defineConfig({
93
+ name: "my-bot",
94
+
95
+ workflow: {
96
+ tags: {
97
+ type: { title: "Workflow Type" },
98
+ priority: { title: "Priority" },
99
+ createdBy: { title: "Created By" },
100
+ },
101
+ },
102
+ });
103
+ ```
104
+
105
+ ## Using Tags
106
+
107
+ ### In Conversations
108
+
109
+ ```typescript
110
+ import { Conversation, user } from "@botpress/runtime";
111
+
112
+ export default new Conversation({
113
+ channel: "webchat.channel",
114
+
115
+ // conversation is provided as a handler parameter — no need for context.get()
116
+ async handler({ message, conversation }) {
117
+ // Read user tags
118
+ console.log(`User tier: ${user.tags.tier}`);
119
+ console.log(`User region: ${user.tags.region}`);
120
+
121
+ // Set user tags
122
+ user.tags.tier = "pro";
123
+ user.tags.source = "website";
124
+
125
+ // Read conversation tags
126
+ console.log(`Category: ${conversation.tags.category}`);
127
+
128
+ // Set conversation tags
129
+ conversation.tags.priority = "high";
130
+ conversation.tags.department = "support";
131
+
132
+ // Conditional logic based on tags
133
+ if (user.tags.tier === "enterprise") {
134
+ // Priority handling for enterprise users
135
+ conversation.tags.priority = "urgent";
136
+ }
137
+ },
138
+ });
139
+ ```
140
+
141
+ ### In Workflows
142
+
143
+ ```typescript
144
+ import { Workflow, z, bot } from "@botpress/runtime";
145
+
146
+ export const ProcessingWorkflow = new Workflow({
147
+ name: "processing",
148
+ input: z.object({ userId: z.string() }),
149
+
150
+ async handler({ input, workflow, step }) {
151
+ // Set workflow tags
152
+ workflow.tags.type = "data-processing";
153
+ workflow.tags.priority = "high";
154
+
155
+ // Access bot tags
156
+ console.log(`Environment: ${bot.tags.environment}`);
157
+
158
+ await step("process", async () => {
159
+ // Processing logic
160
+ });
161
+
162
+ return { success: true };
163
+ },
164
+ });
165
+ ```
166
+
167
+ ### In Actions
168
+
169
+ ```typescript
170
+ import { Action, z, user, context } from "@botpress/runtime";
171
+
172
+ export default new Action({
173
+ name: "upgradeUser",
174
+ input: z.object({
175
+ newTier: z.enum(["free", "pro", "enterprise"]),
176
+ }),
177
+ output: z.object({ success: z.boolean() }),
178
+
179
+ async handler({ input }) {
180
+ const oldTier = user.tags.tier;
181
+ const conversation = context.get("conversation", { optional: true });
182
+
183
+ // Update user tag
184
+ user.tags.tier = input.newTier;
185
+
186
+ // Log the upgrade in conversation
187
+ if (conversation) {
188
+ conversation.tags.category = "upgrade";
189
+ }
190
+
191
+ console.log(`Upgraded user from ${oldTier} to ${input.newTier}`);
192
+
193
+ return { success: true };
194
+ },
195
+ });
196
+ ```
197
+
198
+ ## Tags vs State
199
+
200
+ Understanding when to use tags versus state:
201
+
202
+ | Aspect | Tags | State |
203
+ |--------|------|-------|
204
+ | **Structure** | Flat key-value pairs | Nested objects |
205
+ | **Types** | Strings only | Any type (objects, arrays, numbers) |
206
+ | **Use case** | Categorization, filtering | Complex data storage |
207
+ | **Queryable** | Yes (via API) | Limited |
208
+ | **Size** | Small values | Larger structures |
209
+
210
+ ### When to Use Tags
211
+
212
+ ```typescript
213
+ // ✅ Good for tags - simple categorization
214
+ user.tags.tier = "pro";
215
+ user.tags.region = "us-east";
216
+ conversation.tags.priority = "high";
217
+
218
+ // ❌ Bad for tags - complex data belongs in state
219
+ user.tags.preferences = JSON.stringify({ theme: "dark" }); // Don't do this!
220
+ ```
221
+
222
+ ### When to Use State
223
+
224
+ ```typescript
225
+ // ✅ Good for state - complex structures
226
+ user.state.preferences = {
227
+ theme: "dark",
228
+ notifications: true,
229
+ language: "en",
230
+ };
231
+
232
+ user.state.history = [
233
+ { action: "login", timestamp: new Date() },
234
+ { action: "purchase", timestamp: new Date() },
235
+ ];
236
+ ```
237
+
238
+ ## System Tags
239
+
240
+ System tags are managed by integrations and are **read-only**. They contain a colon (`:`) in their key.
241
+
242
+ ### Common System Tags
243
+
244
+ ```typescript
245
+ // Webchat system tags (read-only)
246
+ console.log(user.tags["webchat:owner"]); // User who initiated webchat
247
+ console.log(conversation.tags["webchat:sessionId"]); // Session identifier
248
+
249
+ // Integration-specific system tags
250
+ console.log(user.tags["slack:userId"]); // Slack user ID
251
+ console.log(conversation.tags["discord:channelId"]); // Discord channel
252
+ ```
253
+
254
+ ### System Tag Behavior
255
+
256
+ ```typescript
257
+ // System tags are silently ignored when you try to set them
258
+ user.tags["webchat:owner"] = "new-value"; // No error, but no effect
259
+
260
+ // Only custom tags (without ':') can be modified
261
+ user.tags.tier = "enterprise"; // ✅ Works
262
+ user.tags.customField = "value"; // ✅ Works
263
+ ```
264
+
265
+ ## Advanced Patterns
266
+
267
+ ### Tag-Based Routing
268
+
269
+ ```typescript
270
+ import { Conversation, conversation, user } from "@botpress/runtime";
271
+
272
+ export default new Conversation({
273
+ channel: "webchat.channel",
274
+
275
+ async handler({ message, execute }) {
276
+ // Route based on conversation priority
277
+ const priority = conversation.tags.priority;
278
+
279
+ if (priority === "urgent") {
280
+ // Fast-track urgent conversations
281
+ await execute({
282
+ instructions: "This is an urgent request. Prioritize resolution.",
283
+ model: "openai:gpt-4o", // Use best model
284
+ });
285
+ } else {
286
+ await execute({
287
+ instructions: "Help the user with their request.",
288
+ model: "openai:gpt-4o-mini", // Cost-efficient model
289
+ });
290
+ }
291
+ },
292
+ });
293
+ ```
294
+
295
+ ### Tag-Based Analytics
296
+
297
+ ```typescript
298
+ import { Trigger } from "@botpress/runtime";
299
+ import { AnalyticsTable } from "../tables/Analytics";
300
+
301
+ export default new Trigger({
302
+ name: "trackConversation",
303
+ events: ["conversation.ended"],
304
+
305
+ async handler({ event }) {
306
+ const { conversationId, tags } = event.payload;
307
+
308
+ // Store conversation metrics by tags
309
+ await AnalyticsTable.createRows({
310
+ rows: [
311
+ {
312
+ conversationId,
313
+ category: tags.category || "uncategorized",
314
+ priority: tags.priority || "normal",
315
+ department: tags.department || "general",
316
+ timestamp: new Date(),
317
+ },
318
+ ],
319
+ });
320
+ },
321
+ });
322
+ ```
323
+
324
+ ### Progressive Tag Collection
325
+
326
+ ```typescript
327
+ import { Conversation, user, adk } from "@botpress/runtime";
328
+
329
+ export default new Conversation({
330
+ channel: "webchat.channel",
331
+
332
+ async handler({ message }) {
333
+ // Infer and set tags from conversation
334
+ if (!user.tags.region && message?.type === "text") {
335
+ const region = await adk.zai.extract(
336
+ message.payload.text,
337
+ z.string().optional(),
338
+ { instructions: "Extract geographic region if mentioned" }
339
+ );
340
+
341
+ if (region) {
342
+ user.tags.region = region;
343
+ }
344
+ }
345
+
346
+ // Set source tag if not already set
347
+ if (!user.tags.source) {
348
+ user.tags.source = "webchat";
349
+ }
350
+ },
351
+ });
352
+ ```
353
+
354
+ ### Tag Inheritance in Workflows
355
+
356
+ ```typescript
357
+ import { Workflow, z, user } from "@botpress/runtime";
358
+
359
+ export const SupportWorkflow = new Workflow({
360
+ name: "support",
361
+ input: z.object({
362
+ conversationId: z.string(),
363
+ issue: z.string(),
364
+ }),
365
+
366
+ async handler({ input, workflow, step }) {
367
+ // Inherit priority from user tier
368
+ const tier = user.tags.tier;
369
+
370
+ if (tier === "enterprise") {
371
+ workflow.tags.priority = "high";
372
+ } else if (tier === "pro") {
373
+ workflow.tags.priority = "normal";
374
+ } else {
375
+ workflow.tags.priority = "low";
376
+ }
377
+
378
+ // Set workflow type
379
+ workflow.tags.type = "support-ticket";
380
+
381
+ await step("process", async () => {
382
+ // Processing based on priority
383
+ });
384
+
385
+ return { processed: true };
386
+ },
387
+ });
388
+ ```
389
+
390
+ ## Best Practices
391
+
392
+ ### 1. Use Descriptive Tag Names
393
+
394
+ ```typescript
395
+ // ✅ Good - clear purpose
396
+ tags: {
397
+ subscriptionTier: { title: "Subscription Tier", description: "User subscription level" },
398
+ acquisitionChannel: { title: "Acquisition Channel" },
399
+ supportPriority: { title: "Support Priority" },
400
+ }
401
+
402
+ // ❌ Bad - unclear
403
+ tags: {
404
+ t: { title: "T" },
405
+ lvl: { title: "Lvl" },
406
+ p: { title: "P" },
407
+ }
408
+ ```
409
+
410
+ ### 2. Use Enums for Constrained Values
411
+
412
+ ```typescript
413
+ // ✅ Good - descriptive titles
414
+ tags: {
415
+ status: { title: "Account Status", description: "Active, inactive, or suspended" },
416
+ tier: { title: "Subscription Tier", description: "Free, pro, or enterprise" },
417
+ }
418
+
419
+ // ❌ Bad - missing descriptions
420
+ tags: {
421
+ status: { title: "Status" }, // Unclear what values are expected
422
+ }
423
+ ```
424
+
425
+ ### 3. Document Tag Purposes
426
+
427
+ ```typescript
428
+ export default defineConfig({
429
+ user: {
430
+ tags: {
431
+ tier: { title: "Subscription Tier", description: "Customer subscription level for feature gating" },
432
+ region: { title: "Region", description: "Geographic region for compliance and routing" },
433
+ acquisitionSource: { title: "Acquisition Source", description: "How the user discovered the bot" },
434
+ },
435
+ },
436
+ });
437
+ ```
438
+
439
+ ### 4. Set Tags Early
440
+
441
+ ```typescript
442
+ // Set identification tags early in the conversation
443
+ async handler({ message, type }) {
444
+ if (type === "conversation_started") {
445
+ // Set source immediately
446
+ conversation.tags.source = "webchat";
447
+ conversation.tags.startedAt = new Date().toISOString();
448
+ }
449
+ }
450
+ ```
451
+
452
+ ### 5. Use Tags for Filtering, Not Storage
453
+
454
+ ```typescript
455
+ // ✅ Good - tags for filtering/categorization
456
+ user.tags.tier = "enterprise";
457
+ conversation.tags.category = "billing";
458
+
459
+ // ❌ Bad - storing complex data in tags
460
+ user.tags.preferences = JSON.stringify({ notifications: true }); // Use state instead
461
+ ```
462
+
463
+ ## Troubleshooting
464
+
465
+ ### Tags Not Persisting
466
+
467
+ 1. **Check schema definition**: Tags must be defined in `agent.config.ts`
468
+ 2. **Verify tag key**: Custom tags cannot contain `:`
469
+ 3. **Check value type**: Tags only accept string values
470
+
471
+ ```typescript
472
+ // ✅ Correct
473
+ user.tags.tier = "pro"; // String value
474
+
475
+ // ❌ Wrong - will be ignored or cause errors
476
+ user.tags.count = 5; // Number (should be string)
477
+ user.tags.active = true; // Boolean (should be string)
478
+ ```
479
+
480
+ ### System Tags Appearing Read-Only
481
+
482
+ System tags (containing `:`) are managed by integrations:
483
+
484
+ ```typescript
485
+ // These are read-only - modifications are silently ignored
486
+ user.tags["webchat:owner"] = "new"; // No effect
487
+ conversation.tags["slack:channel"] = "new"; // No effect
488
+
489
+ // Only custom tags can be modified
490
+ user.tags.myCustomTag = "value"; // ✅ Works
491
+ ```
492
+
493
+ ### Tag Not in Schema Error
494
+
495
+ If you see errors about undefined tags, add them to your config:
496
+
497
+ ```typescript
498
+ // Before: Tag not in schema
499
+ user.tags.newTag = "value"; // Warning: Tag not defined
500
+
501
+ // Fix: Add to agent.config.ts
502
+ export default defineConfig({
503
+ user: {
504
+ tags: {
505
+ newTag: { title: "New Tag" }, // Now it will persist
506
+ },
507
+ },
508
+ });
509
+ ```
510
+
511
+ ## See Also
512
+
513
+ - **[Agent Configuration](./agent-config.md)** - Full agent.config.ts reference
514
+ - **[Conversations](./conversations.md)** - Using tags in conversation handlers
515
+ - **[Workflows](./workflows.md)** - Workflow tags and state management
516
+ - **[Context API](./context-api.md)** - Accessing bot, user, conversation context