@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.
- package/dist/agent-init/agent-project-generator.d.ts +5 -1
- package/dist/agent-init/agent-project-generator.d.ts.map +1 -1
- package/dist/agent-project/agent-project.d.ts +3 -3
- package/dist/agent-project/agent-project.d.ts.map +1 -1
- package/dist/agent-project/agent-resolver.d.ts.map +1 -1
- package/dist/agent-project/config-writer.d.ts +1 -1
- package/dist/agent-project/dependency-state-to-dependencies.d.ts +11 -0
- package/dist/agent-project/dependency-state-to-dependencies.d.ts.map +1 -0
- package/dist/agent-project/types.d.ts +9 -4
- package/dist/agent-project/types.d.ts.map +1 -1
- package/dist/agent0/capabilities/commands/adk-build.md +6 -5
- package/dist/agent0/capabilities/commands/adk-debug.md +1 -1
- package/dist/agent0/capabilities/commands/adk-dev-console.md +1 -1
- package/dist/agent0/capabilities/commands/adk-document.md +10 -2
- package/dist/agent0/capabilities/commands/adk-eval.md +1 -1
- package/dist/agent0/capabilities/commands/adk-explain.md +2 -2
- package/dist/agent0/capabilities/commands/adk-init.md +2 -2
- package/dist/agent0/capabilities/commands/adk-ship.md +1 -1
- package/dist/agent0/capabilities/commands/adk-test.md +3 -3
- package/dist/agent0/capabilities/commands/adk-validate.md +3 -3
- package/dist/agent0/capabilities/skills/adk/SKILL.md +21 -21
- package/dist/agent0/capabilities/skills/adk/references/actions.md +245 -239
- package/dist/agent0/capabilities/skills/adk/references/advanced-patterns.md +185 -218
- package/dist/agent0/capabilities/skills/adk/references/agent-config.md +74 -71
- package/dist/agent0/capabilities/skills/adk/references/assets.md +45 -48
- package/dist/agent0/capabilities/skills/adk/references/autonomous-execution.md +40 -46
- package/dist/agent0/capabilities/skills/adk/references/cli.md +17 -7
- package/dist/agent0/capabilities/skills/adk/references/context-api.md +98 -94
- package/dist/agent0/capabilities/skills/adk/references/conversation-lifecycle.md +65 -62
- package/dist/agent0/capabilities/skills/adk/references/conversations.md +395 -385
- package/dist/agent0/capabilities/skills/adk/references/custom-components.md +1 -1
- package/dist/agent0/capabilities/skills/adk/references/desk.md +236 -234
- package/dist/agent0/capabilities/skills/adk/references/explain-config.md +54 -37
- package/dist/agent0/capabilities/skills/adk/references/files.md +301 -306
- package/dist/agent0/capabilities/skills/adk/references/integration-actions.md +211 -214
- package/dist/agent0/capabilities/skills/adk/references/integrations.md +33 -31
- package/dist/agent0/capabilities/skills/adk/references/interfaces.md +13 -12
- package/dist/agent0/capabilities/skills/adk/references/knowledge-bases.md +98 -111
- package/dist/agent0/capabilities/skills/adk/references/mcp-server.md +6 -0
- package/dist/agent0/capabilities/skills/adk/references/messages.md +280 -256
- package/dist/agent0/capabilities/skills/adk/references/model-configuration.md +52 -49
- package/dist/agent0/capabilities/skills/adk/references/patterns-mistakes.md +102 -101
- package/dist/agent0/capabilities/skills/adk/references/plugins.md +15 -15
- package/dist/agent0/capabilities/skills/adk/references/tables.md +204 -210
- package/dist/agent0/capabilities/skills/adk/references/tags.md +141 -143
- package/dist/agent0/capabilities/skills/adk/references/tools.md +191 -199
- package/dist/agent0/capabilities/skills/adk/references/triggers.md +331 -336
- package/dist/agent0/capabilities/skills/adk/references/workflow-steps.md +132 -96
- package/dist/agent0/capabilities/skills/adk/references/workflows.md +479 -464
- package/dist/agent0/capabilities/skills/adk/references/zai-agent-reference.md +127 -129
- package/dist/agent0/capabilities/skills/adk/references/zai-complete-guide.md +255 -276
- package/dist/agent0/capabilities/skills/adk-debugger/SKILL.md +21 -17
- package/dist/agent0/capabilities/skills/adk-debugger/references/common-failures.md +25 -25
- package/dist/agent0/capabilities/skills/adk-debugger/references/conversation-analysis.md +49 -41
- package/dist/agent0/capabilities/skills/adk-debugger/references/debug-workflow.md +20 -14
- package/dist/agent0/capabilities/skills/adk-debugger/references/llm-debugging.md +13 -13
- package/dist/agent0/capabilities/skills/adk-debugger/references/trace-summarization.md +18 -18
- package/dist/agent0/capabilities/skills/adk-debugger/references/traces-and-logs.md +67 -67
- package/dist/agent0/capabilities/skills/adk-dev-console/SKILL.md +36 -36
- package/dist/agent0/capabilities/skills/adk-dev-console/references/agent-steps.md +14 -6
- package/dist/agent0/capabilities/skills/adk-dev-console/references/multi-agent-dashboard.md +13 -13
- package/dist/agent0/capabilities/skills/adk-dev-console/references/pages.md +18 -0
- package/dist/agent0/capabilities/skills/adk-docs/SKILL.md +13 -13
- package/dist/agent0/capabilities/skills/adk-docs/references/doc-standards.md +15 -0
- package/dist/agent0/capabilities/skills/adk-evals/SKILL.md +29 -23
- package/dist/agent0/capabilities/skills/adk-evals/references/eval-format.md +31 -23
- package/dist/agent0/capabilities/skills/adk-evals/references/test-patterns.md +25 -36
- package/dist/agent0/capabilities/skills/adk-evals/references/testing-workflow.md +6 -4
- package/dist/agent0/index.js +41 -19
- package/dist/agent0/index.js.map +7 -7
- package/dist/agent0/runtime/client.d.ts +2 -0
- package/dist/agent0/runtime/client.d.ts.map +1 -1
- package/dist/agent0/runtime/engine.d.ts +2 -1
- package/dist/agent0/runtime/engine.d.ts.map +1 -1
- package/dist/agent0/runtime/process.d.ts +1 -0
- package/dist/agent0/runtime/process.d.ts.map +1 -1
- package/dist/assets/manager.d.ts +3 -0
- package/dist/assets/manager.d.ts.map +1 -1
- package/dist/auth/credentials.d.ts +1 -1
- package/dist/bot-generator/generator.d.ts +22 -0
- package/dist/bot-generator/generator.d.ts.map +1 -1
- package/dist/bot-generator/plugin-sync.d.ts.map +1 -1
- package/dist/commands/base-command.d.ts +1 -0
- package/dist/commands/base-command.d.ts.map +1 -1
- package/dist/commands/bp-dev-command.d.ts +1 -1
- package/dist/commands/bp-dev-command.d.ts.map +1 -1
- package/dist/commands/bp-dev-stderr.d.ts +9 -0
- package/dist/commands/bp-dev-stderr.d.ts.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/dependencies/catalog/catalog-service.d.ts +53 -0
- package/dist/dependencies/catalog/catalog-service.d.ts.map +1 -0
- package/dist/dependencies/catalog/client-factory.d.ts +33 -0
- package/dist/dependencies/catalog/client-factory.d.ts.map +1 -0
- package/dist/dependencies/catalog/integration-source.d.ts +34 -0
- package/dist/dependencies/catalog/integration-source.d.ts.map +1 -0
- package/dist/dependencies/catalog/interface-source.d.ts +23 -0
- package/dist/dependencies/catalog/interface-source.d.ts.map +1 -0
- package/dist/dependencies/catalog/plugin-source.d.ts +49 -0
- package/dist/dependencies/catalog/plugin-source.d.ts.map +1 -0
- package/dist/dependencies/catalog/resolution-cache.d.ts +76 -0
- package/dist/dependencies/catalog/resolution-cache.d.ts.map +1 -0
- package/dist/dependencies/dependency-manager.d.ts +31 -16
- package/dist/dependencies/dependency-manager.d.ts.map +1 -1
- package/dist/dependencies/errors.d.ts +2 -2
- package/dist/dependencies/errors.d.ts.map +1 -1
- package/dist/dependencies/index.d.ts +5 -4
- package/dist/dependencies/index.d.ts.map +1 -1
- package/dist/dependencies/index.js +2089 -1670
- package/dist/dependencies/index.js.map +37 -30
- package/dist/dependencies/legacy-lock-file.d.ts +15 -0
- package/dist/dependencies/legacy-lock-file.d.ts.map +1 -0
- package/dist/dependencies/migration.d.ts +19 -0
- package/dist/dependencies/migration.d.ts.map +1 -1
- package/dist/dependencies/resolvers/integration-resolver.d.ts +4 -3
- package/dist/dependencies/resolvers/integration-resolver.d.ts.map +1 -1
- package/dist/dependencies/resolvers/plugin-resolver.d.ts +4 -4
- package/dist/dependencies/resolvers/plugin-resolver.d.ts.map +1 -1
- package/dist/dependencies/snapshot-store.d.ts +59 -0
- package/dist/dependencies/snapshot-store.d.ts.map +1 -0
- package/dist/dependencies/status-resolver.d.ts +36 -0
- package/dist/dependencies/status-resolver.d.ts.map +1 -0
- package/dist/dependencies/status.d.ts +214 -0
- package/dist/dependencies/status.d.ts.map +1 -0
- package/dist/dependencies/types.d.ts +380 -29
- package/dist/dependencies/types.d.ts.map +1 -1
- package/dist/file-watcher/watcher.d.ts +21 -5
- package/dist/file-watcher/watcher.d.ts.map +1 -1
- package/dist/generators/action-types.d.ts.map +1 -1
- package/dist/generators/client-wrapper.d.ts.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3134 -2226
- package/dist/index.js.map +55 -48
- package/dist/integrations/config-utils.d.ts +11 -7
- package/dist/integrations/config-utils.d.ts.map +1 -1
- package/dist/integrations/hub-cache.d.ts +0 -58
- package/dist/integrations/hub-cache.d.ts.map +1 -1
- package/dist/integrations/index.d.ts +1 -3
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/manager.d.ts +19 -53
- package/dist/integrations/manager.d.ts.map +1 -1
- package/dist/interfaces/enhanced-cache.d.ts +7 -7
- package/dist/interfaces/enhanced-cache.d.ts.map +1 -1
- package/dist/interfaces/manager.d.ts +11 -17
- package/dist/interfaces/manager.d.ts.map +1 -1
- package/dist/knowledge/manager.d.ts +3 -0
- package/dist/knowledge/manager.d.ts.map +1 -1
- package/dist/plugins/index.d.ts +0 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/manager.d.ts +16 -48
- package/dist/plugins/manager.d.ts.map +1 -1
- package/dist/preflight/checker.d.ts +6 -1
- package/dist/preflight/checker.d.ts.map +1 -1
- package/dist/preflight/dependency-gate.d.ts +37 -0
- package/dist/preflight/dependency-gate.d.ts.map +1 -0
- package/dist/preflight/index.d.ts +2 -1
- package/dist/preflight/index.d.ts.map +1 -1
- package/dist/preflight/types.d.ts +18 -0
- package/dist/preflight/types.d.ts.map +1 -1
- package/dist/runner/script-runner.d.ts.map +1 -1
- package/dist/tables/table-manager.d.ts +3 -0
- package/dist/tables/table-manager.d.ts.map +1 -1
- package/dist/templates/README.md +23 -13
- package/dist/templates/blank/agent.config.ts +3 -3
- package/dist/templates/blank/src/triggers/index.ts +1 -1
- package/dist/templates/botpress-desk/evals/index.eval.ts +1 -1
- package/dist/templates/botpress-desk/src/triggers/index.ts +1 -1
- package/dist/templates/crm-enrichment/README.md +3 -3
- package/dist/templates/crm-enrichment/agent.config.ts +2 -2
- package/dist/templates/crm-enrichment/src/conversations/index.ts +1 -1
- package/dist/templates/hello-world/agent.config.ts +3 -3
- package/dist/templates/hello-world/src/triggers/index.ts +1 -1
- package/dist/templates/knowledge-assistant/src/triggers/index.ts +1 -1
- package/dist/templates/template.config.json +3 -3
- package/dist/utils/ids.d.ts +10 -0
- package/dist/utils/ids.d.ts.map +1 -1
- package/dist/workspace/workspace-cache.d.ts +2 -1
- package/dist/workspace/workspace-cache.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/agent-project/lock-to-dependencies.d.ts +0 -11
- package/dist/agent-project/lock-to-dependencies.d.ts.map +0 -1
- package/dist/dependencies/lock-file.d.ts +0 -15
- package/dist/dependencies/lock-file.d.ts.map +0 -1
- package/dist/integrations/enhanced-cache.d.ts +0 -53
- package/dist/integrations/enhanced-cache.d.ts.map +0 -1
- package/dist/plugins/enhanced-cache.d.ts +0 -53
- package/dist/plugins/enhanced-cache.d.ts.map +0 -1
- package/dist/templates/blank/package.json +0 -17
- package/dist/templates/blank/tsconfig.json +0 -25
- package/dist/templates/botpress-desk/package.json +0 -17
- package/dist/templates/crm-enrichment/package.json +0 -18
- package/dist/templates/crm-enrichment/tsconfig.json +0 -25
- package/dist/templates/hello-world/package.json +0 -18
- package/dist/templates/hello-world/tsconfig.json +0 -25
- package/dist/templates/knowledge-assistant/package.json +0 -18
- package/dist/templates/knowledge-assistant/tsconfig.json +0 -25
- package/dist/templates/slack-triage/package.json +0 -18
- package/dist/templates/slack-triage/tsconfig.json +0 -25
|
@@ -16,38 +16,28 @@ Enforce behavioral constraints on autonomous agents to prevent unwanted actions
|
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
18
|
// src/conversations/extensions/guardrails.ts
|
|
19
|
-
import { adk, Autonomous } from
|
|
19
|
+
import { adk, Autonomous } from '@botpress/runtime'
|
|
20
20
|
|
|
21
21
|
export const makeGuardrails = (message: any) => {
|
|
22
22
|
// Use zai to determine if knowledge search is needed
|
|
23
|
-
const isKnowledgeSearchAsync = adk.zai.check(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const onBeforeToolGuard: Autonomous.Hooks["onBeforeTool"] = async ({
|
|
31
|
-
iteration,
|
|
32
|
-
tool,
|
|
33
|
-
input,
|
|
34
|
-
controller,
|
|
35
|
-
}) => {
|
|
36
|
-
if (tool.name === "search_knowledge") {
|
|
37
|
-
hasSearched = true;
|
|
23
|
+
const isKnowledgeSearchAsync = adk.zai.check(message, `Is this a question that requires knowledge search?`)
|
|
24
|
+
|
|
25
|
+
let hasSearched = false
|
|
26
|
+
|
|
27
|
+
const onBeforeToolGuard: Autonomous.Hooks['onBeforeTool'] = async ({ iteration, tool, input, controller }) => {
|
|
28
|
+
if (tool.name === 'search_knowledge') {
|
|
29
|
+
hasSearched = true
|
|
38
30
|
}
|
|
39
31
|
|
|
40
|
-
const isKnowledgeSearch = await isKnowledgeSearchAsync
|
|
32
|
+
const isKnowledgeSearch = await isKnowledgeSearchAsync
|
|
41
33
|
|
|
42
|
-
if (tool.name ===
|
|
43
|
-
throw new Error(
|
|
44
|
-
`Knowledge search is required for this question. Please use "search_knowledge" first.`
|
|
45
|
-
);
|
|
34
|
+
if (tool.name === 'Message' && isKnowledgeSearch && !hasSearched) {
|
|
35
|
+
throw new Error(`Knowledge search is required for this question. Please use "search_knowledge" first.`)
|
|
46
36
|
}
|
|
47
|
-
}
|
|
37
|
+
}
|
|
48
38
|
|
|
49
|
-
return { onBeforeToolGuard }
|
|
50
|
-
}
|
|
39
|
+
return { onBeforeToolGuard }
|
|
40
|
+
}
|
|
51
41
|
```
|
|
52
42
|
|
|
53
43
|
> **Note:** `adk.zai.check()` is the recommended approach for AI-powered validation. An advanced pattern `adk.zai.learn().check()` exists for cached/reusable checks, but `adk.zai.check()` is simpler and covers most cases. See [zai-agent-reference.md](./zai-agent-reference.md) for all Zai operations and edge cases.
|
|
@@ -56,22 +46,22 @@ export const makeGuardrails = (message: any) => {
|
|
|
56
46
|
|
|
57
47
|
```typescript
|
|
58
48
|
// src/conversations/webchat.ts
|
|
59
|
-
import { Conversation } from
|
|
60
|
-
import { makeGuardrails } from
|
|
49
|
+
import { Conversation } from '@botpress/runtime'
|
|
50
|
+
import { makeGuardrails } from './extensions/guardrails'
|
|
61
51
|
|
|
62
52
|
export default new Conversation({
|
|
63
|
-
channel:
|
|
53
|
+
channel: '*',
|
|
64
54
|
handler: async ({ execute, message }) => {
|
|
65
|
-
const guardrail = makeGuardrails(message)
|
|
55
|
+
const guardrail = makeGuardrails(message)
|
|
66
56
|
|
|
67
57
|
await execute({
|
|
68
58
|
instructions: `You are a helpful assistant...`,
|
|
69
59
|
hooks: {
|
|
70
60
|
onBeforeTool: async (props) => guardrail.onBeforeToolGuard(props),
|
|
71
61
|
},
|
|
72
|
-
})
|
|
62
|
+
})
|
|
73
63
|
},
|
|
74
|
-
})
|
|
64
|
+
})
|
|
75
65
|
```
|
|
76
66
|
|
|
77
67
|
### Variations
|
|
@@ -80,49 +70,36 @@ export default new Conversation({
|
|
|
80
70
|
|
|
81
71
|
```typescript
|
|
82
72
|
export const makeCreditCheckGuardrail = () => {
|
|
83
|
-
let creditChecked = false
|
|
84
|
-
|
|
85
|
-
const onBeforeToolGuard: Autonomous.Hooks[
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
input,
|
|
89
|
-
controller,
|
|
90
|
-
}) => {
|
|
91
|
-
if (tool.name === "check_credit") {
|
|
92
|
-
creditChecked = true;
|
|
73
|
+
let creditChecked = false
|
|
74
|
+
|
|
75
|
+
const onBeforeToolGuard: Autonomous.Hooks['onBeforeTool'] = async ({ iteration, tool, input, controller }) => {
|
|
76
|
+
if (tool.name === 'check_credit') {
|
|
77
|
+
creditChecked = true
|
|
93
78
|
}
|
|
94
|
-
if (tool.name ===
|
|
95
|
-
throw new Error(
|
|
79
|
+
if (tool.name === 'process_payment' && !creditChecked) {
|
|
80
|
+
throw new Error('Credit check must be performed before processing payment')
|
|
96
81
|
}
|
|
97
|
-
}
|
|
82
|
+
}
|
|
98
83
|
|
|
99
|
-
return { onBeforeToolGuard }
|
|
100
|
-
}
|
|
84
|
+
return { onBeforeToolGuard }
|
|
85
|
+
}
|
|
101
86
|
```
|
|
102
87
|
|
|
103
88
|
**Data Validation Guardrail:**
|
|
104
89
|
|
|
105
90
|
```typescript
|
|
106
91
|
export const makeDataValidationGuardrail = () => {
|
|
107
|
-
const onBeforeToolGuard: Autonomous.Hooks[
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
input,
|
|
111
|
-
controller,
|
|
112
|
-
}) => {
|
|
113
|
-
if (tool.name === "send_email") {
|
|
114
|
-
const hasValidEmail = await adk.zai.check(
|
|
115
|
-
input,
|
|
116
|
-
"Does this contain a valid email address?"
|
|
117
|
-
);
|
|
92
|
+
const onBeforeToolGuard: Autonomous.Hooks['onBeforeTool'] = async ({ iteration, tool, input, controller }) => {
|
|
93
|
+
if (tool.name === 'send_email') {
|
|
94
|
+
const hasValidEmail = await adk.zai.check(input, 'Does this contain a valid email address?')
|
|
118
95
|
if (!hasValidEmail) {
|
|
119
|
-
throw new Error(
|
|
96
|
+
throw new Error('Invalid email address provided')
|
|
120
97
|
}
|
|
121
98
|
}
|
|
122
|
-
}
|
|
99
|
+
}
|
|
123
100
|
|
|
124
|
-
return { onBeforeToolGuard }
|
|
125
|
-
}
|
|
101
|
+
return { onBeforeToolGuard }
|
|
102
|
+
}
|
|
126
103
|
```
|
|
127
104
|
|
|
128
105
|
### Key Techniques
|
|
@@ -149,137 +126,132 @@ Implement privileged access control with temporary authentication for administra
|
|
|
149
126
|
|
|
150
127
|
```typescript
|
|
151
128
|
// src/conversations/extensions/admin-mode.ts
|
|
152
|
-
import { adk, Autonomous, context, user, z } from
|
|
129
|
+
import { adk, Autonomous, context, user, z } from '@botpress/runtime'
|
|
153
130
|
|
|
154
131
|
// Define user state schema for admin mode
|
|
155
132
|
export const AdminModeUserSchema: z.ZodRawShape = {
|
|
156
133
|
admin: z
|
|
157
134
|
.object({
|
|
158
|
-
adminUtil: z.string().nullable().describe(
|
|
159
|
-
code: z.string().nullable().describe(
|
|
160
|
-
codeValidUntil: z.string().nullable().describe(
|
|
135
|
+
adminUtil: z.string().nullable().describe('Expiration date of admin status (ISO).'),
|
|
136
|
+
code: z.string().nullable().describe('The admin access code.'),
|
|
137
|
+
codeValidUntil: z.string().nullable().describe('Expiration date of admin code (ISO).'),
|
|
161
138
|
})
|
|
162
139
|
.default({ adminUtil: null, code: null, codeValidUntil: null }),
|
|
163
|
-
}
|
|
140
|
+
}
|
|
164
141
|
|
|
165
142
|
// Admin-only tool: refresh knowledge bases
|
|
166
143
|
const getIndexKnowledgeBasesTool = () => {
|
|
167
|
-
const ctx = context.getAll()
|
|
144
|
+
const ctx = context.getAll()
|
|
168
145
|
return new Autonomous.Tool({
|
|
169
|
-
name:
|
|
170
|
-
description:
|
|
171
|
-
output: z.string().describe(
|
|
146
|
+
name: 'refreshKnowledgeBases',
|
|
147
|
+
description: 'Refresh and re-index all knowledge bases.',
|
|
148
|
+
output: z.string().describe('Confirmation message after refreshing.'),
|
|
172
149
|
handler: async () => {
|
|
173
|
-
context.enterWith(ctx)
|
|
174
|
-
await Promise.all(adk.project.knowledge.map((kb) => kb.refresh()))
|
|
175
|
-
return `Started re-indexing: ${adk.project.knowledge.map((kb) => kb.name).join(
|
|
150
|
+
context.enterWith(ctx) // Restore context for async operations
|
|
151
|
+
await Promise.all(adk.project.knowledge.map((kb) => kb.refresh()))
|
|
152
|
+
return `Started re-indexing: ${adk.project.knowledge.map((kb) => kb.name).join(', ')}`
|
|
176
153
|
},
|
|
177
|
-
})
|
|
178
|
-
}
|
|
154
|
+
})
|
|
155
|
+
}
|
|
179
156
|
|
|
180
157
|
// Generate one-time login code
|
|
181
158
|
const getLoginTool = () => {
|
|
182
|
-
const ctx = context.getAll()
|
|
183
|
-
user.state ??= {}
|
|
159
|
+
const ctx = context.getAll()
|
|
160
|
+
user.state ??= {}
|
|
184
161
|
|
|
185
|
-
const CODE_VALIDITY_DURATION_MS = 5 * 60 * 1000
|
|
162
|
+
const CODE_VALIDITY_DURATION_MS = 5 * 60 * 1000 // 5 minutes
|
|
186
163
|
|
|
187
|
-
const expectedCode = user.state.admin?.code?.toLowerCase().trim()
|
|
164
|
+
const expectedCode = user.state.admin?.code?.toLowerCase().trim()
|
|
188
165
|
const codeGenerated =
|
|
189
|
-
expectedCode &&
|
|
190
|
-
user.state.admin?.codeValidUntil &&
|
|
191
|
-
new Date(user.state.admin?.codeValidUntil) > new Date();
|
|
166
|
+
expectedCode && user.state.admin?.codeValidUntil && new Date(user.state.admin?.codeValidUntil) > new Date()
|
|
192
167
|
|
|
193
168
|
if (codeGenerated) {
|
|
194
169
|
return new Autonomous.Tool({
|
|
195
|
-
name:
|
|
196
|
-
description:
|
|
170
|
+
name: 'loginWithCode',
|
|
171
|
+
description: 'Log in as admin using an access code.',
|
|
197
172
|
input: z.string().describe('The admin access code, e.g. "ABC346"'),
|
|
198
|
-
output: z.boolean().describe(
|
|
173
|
+
output: z.boolean().describe('Returns true if login is successful.'),
|
|
199
174
|
handler: async (code: string) => {
|
|
200
|
-
context.enterWith(ctx)
|
|
201
|
-
const providedCode = code.toLowerCase().trim()
|
|
175
|
+
context.enterWith(ctx)
|
|
176
|
+
const providedCode = code.toLowerCase().trim()
|
|
202
177
|
|
|
203
178
|
if (expectedCode && providedCode === expectedCode) {
|
|
204
179
|
user.state.admin = {
|
|
205
180
|
adminUtil: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
|
|
206
181
|
code: null,
|
|
207
182
|
codeValidUntil: null,
|
|
208
|
-
}
|
|
209
|
-
return true
|
|
183
|
+
}
|
|
184
|
+
return true
|
|
210
185
|
}
|
|
211
186
|
|
|
212
|
-
throw new Autonomous.ThinkSignal(
|
|
187
|
+
throw new Autonomous.ThinkSignal('Invalid or expired admin access code')
|
|
213
188
|
},
|
|
214
|
-
})
|
|
189
|
+
})
|
|
215
190
|
}
|
|
216
191
|
|
|
217
192
|
return new Autonomous.Tool({
|
|
218
|
-
name:
|
|
219
|
-
description:
|
|
193
|
+
name: 'generateLoginCode',
|
|
194
|
+
description: 'Generate a one-time access code for admin login.',
|
|
220
195
|
handler: async () => {
|
|
221
|
-
context.enterWith(ctx)
|
|
222
|
-
const generatedCode = Math.random().toString(36).substring(2, 8).toUpperCase()
|
|
196
|
+
context.enterWith(ctx)
|
|
197
|
+
const generatedCode = Math.random().toString(36).substring(2, 8).toUpperCase()
|
|
223
198
|
|
|
224
199
|
user.state.admin = {
|
|
225
200
|
adminUtil: null,
|
|
226
201
|
code: generatedCode,
|
|
227
202
|
codeValidUntil: new Date(Date.now() + CODE_VALIDITY_DURATION_MS).toISOString(),
|
|
228
|
-
}
|
|
203
|
+
}
|
|
229
204
|
|
|
230
|
-
console.log(`Generated admin login code: ${generatedCode}`)
|
|
205
|
+
console.log(`Generated admin login code: ${generatedCode}`)
|
|
231
206
|
|
|
232
207
|
throw new Autonomous.ThinkSignal(
|
|
233
208
|
`An admin login code has been generated and logged in the developer console. Retrieve it from the Botpress dashboard.`
|
|
234
|
-
)
|
|
209
|
+
)
|
|
235
210
|
},
|
|
236
|
-
})
|
|
237
|
-
}
|
|
211
|
+
})
|
|
212
|
+
}
|
|
238
213
|
|
|
239
214
|
function isUserAdmin() {
|
|
240
|
-
return (
|
|
241
|
-
user.state.admin?.adminUtil &&
|
|
242
|
-
new Date(user.state.admin.adminUtil) > new Date()
|
|
243
|
-
);
|
|
215
|
+
return user.state.admin?.adminUtil && new Date(user.state.admin.adminUtil) > new Date()
|
|
244
216
|
}
|
|
245
217
|
|
|
246
218
|
export const getAdminModeObject = () =>
|
|
247
219
|
new Autonomous.Object({
|
|
248
|
-
name:
|
|
220
|
+
name: 'admin',
|
|
249
221
|
description: getAdminStatus(), // Dynamic description based on state
|
|
250
222
|
tools: isUserAdmin() ? [getIndexKnowledgeBasesTool()] : [getLoginTool()],
|
|
251
|
-
})
|
|
223
|
+
})
|
|
252
224
|
```
|
|
253
225
|
|
|
254
226
|
### Configuration in agent.config.ts
|
|
255
227
|
|
|
256
228
|
```typescript
|
|
257
|
-
import { z, defineConfig } from
|
|
258
|
-
import { AdminModeUserSchema } from
|
|
229
|
+
import { z, defineConfig } from '@botpress/runtime'
|
|
230
|
+
import { AdminModeUserSchema } from './src/conversations/extensions/admin-mode'
|
|
259
231
|
|
|
260
232
|
export default defineConfig({
|
|
261
|
-
name:
|
|
233
|
+
name: 'my-agent',
|
|
262
234
|
user: {
|
|
263
235
|
state: z.object({}).extend(AdminModeUserSchema),
|
|
264
236
|
},
|
|
265
|
-
})
|
|
237
|
+
})
|
|
266
238
|
```
|
|
267
239
|
|
|
268
240
|
### Usage in Conversation
|
|
269
241
|
|
|
270
242
|
```typescript
|
|
271
|
-
import { Conversation } from
|
|
272
|
-
import { getAdminModeObject } from
|
|
243
|
+
import { Conversation } from '@botpress/runtime'
|
|
244
|
+
import { getAdminModeObject } from './extensions/admin-mode'
|
|
273
245
|
|
|
274
246
|
export default new Conversation({
|
|
275
|
-
channel:
|
|
247
|
+
channel: '*',
|
|
276
248
|
handler: async ({ execute }) => {
|
|
277
249
|
await execute({
|
|
278
250
|
instructions: `You are a helpful assistant...`,
|
|
279
251
|
objects: [getAdminModeObject()],
|
|
280
|
-
})
|
|
252
|
+
})
|
|
281
253
|
},
|
|
282
|
-
})
|
|
254
|
+
})
|
|
283
255
|
```
|
|
284
256
|
|
|
285
257
|
### Key Techniques
|
|
@@ -300,107 +272,102 @@ Comprehensive logging and error tracking for production agents.
|
|
|
300
272
|
|
|
301
273
|
```typescript
|
|
302
274
|
// src/conversations/extensions/logging.ts
|
|
303
|
-
import { Autonomous } from
|
|
275
|
+
import { Autonomous } from '@botpress/runtime'
|
|
304
276
|
|
|
305
|
-
export const onTraceLogging: Autonomous.Hooks[
|
|
306
|
-
if (trace.type ===
|
|
307
|
-
console.error(`Code Execution Error: ${trace.message}`, trace.stackTrace)
|
|
277
|
+
export const onTraceLogging: Autonomous.Hooks['onTrace'] = ({ trace, iteration }) => {
|
|
278
|
+
if (trace.type === 'code_execution_exception') {
|
|
279
|
+
console.error(`Code Execution Error: ${trace.message}`, trace.stackTrace)
|
|
308
280
|
}
|
|
309
281
|
|
|
310
|
-
if (trace.type ===
|
|
282
|
+
if (trace.type === 'tool_call' && !trace.success) {
|
|
311
283
|
console.error(
|
|
312
284
|
`Error during tool call to "${trace.tool_name}" with input "${JSON.stringify(trace.input)}":`,
|
|
313
285
|
trace.error
|
|
314
|
-
)
|
|
286
|
+
)
|
|
315
287
|
}
|
|
316
|
-
}
|
|
288
|
+
}
|
|
317
289
|
```
|
|
318
290
|
|
|
319
291
|
### Usage in Conversation
|
|
320
292
|
|
|
321
293
|
```typescript
|
|
322
|
-
import { Conversation } from
|
|
323
|
-
import { onTraceLogging } from
|
|
294
|
+
import { Conversation } from '@botpress/runtime'
|
|
295
|
+
import { onTraceLogging } from './extensions/logging'
|
|
324
296
|
|
|
325
297
|
export default new Conversation({
|
|
326
|
-
channel:
|
|
298
|
+
channel: '*',
|
|
327
299
|
handler: async ({ execute }) => {
|
|
328
300
|
await execute({
|
|
329
301
|
instructions: `You are a helpful assistant...`,
|
|
330
302
|
hooks: {
|
|
331
303
|
onTrace: (props) => onTraceLogging!(props),
|
|
332
304
|
},
|
|
333
|
-
})
|
|
305
|
+
})
|
|
334
306
|
},
|
|
335
|
-
})
|
|
307
|
+
})
|
|
336
308
|
```
|
|
337
309
|
|
|
338
310
|
### Advanced: Comprehensive Trace Logging
|
|
339
311
|
|
|
340
312
|
```typescript
|
|
341
|
-
export const onTraceLogging: Autonomous.Hooks[
|
|
313
|
+
export const onTraceLogging: Autonomous.Hooks['onTrace'] = ({ trace, iteration }) => {
|
|
342
314
|
switch (trace.type) {
|
|
343
|
-
case
|
|
344
|
-
console.error(`[CODE ERROR] ${trace.message}`, trace.stackTrace)
|
|
345
|
-
break
|
|
346
|
-
case
|
|
315
|
+
case 'code_execution_exception':
|
|
316
|
+
console.error(`[CODE ERROR] ${trace.message}`, trace.stackTrace)
|
|
317
|
+
break
|
|
318
|
+
case 'tool_call':
|
|
347
319
|
if (trace.success) {
|
|
348
|
-
console.log(`[TOOL SUCCESS] ${trace.tool_name}`, trace.output)
|
|
320
|
+
console.log(`[TOOL SUCCESS] ${trace.tool_name}`, trace.output)
|
|
349
321
|
} else {
|
|
350
|
-
console.error(`[TOOL ERROR] ${trace.tool_name}`, trace.error)
|
|
322
|
+
console.error(`[TOOL ERROR] ${trace.tool_name}`, trace.error)
|
|
351
323
|
}
|
|
352
|
-
break
|
|
353
|
-
case
|
|
354
|
-
console.debug(`[THINK] ${trace.content}`)
|
|
355
|
-
break
|
|
324
|
+
break
|
|
325
|
+
case 'think':
|
|
326
|
+
console.debug(`[THINK] ${trace.content}`)
|
|
327
|
+
break
|
|
356
328
|
default:
|
|
357
|
-
console.log(`[TRACE] ${trace.type}`, trace)
|
|
329
|
+
console.log(`[TRACE] ${trace.type}`, trace)
|
|
358
330
|
}
|
|
359
|
-
}
|
|
331
|
+
}
|
|
360
332
|
```
|
|
361
333
|
|
|
362
334
|
### Advanced: Performance Monitoring
|
|
363
335
|
|
|
364
336
|
```typescript
|
|
365
337
|
export const makePerformanceMonitor = () => {
|
|
366
|
-
const startTime = Date.now()
|
|
367
|
-
const toolMetrics = new Map<string, number[]>()
|
|
368
|
-
|
|
369
|
-
const onBeforeTool: Autonomous.Hooks[
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
const onTrace: Autonomous.Hooks["onTrace"] = ({ trace, iteration }) => {
|
|
387
|
-
if (trace.type === "end") {
|
|
388
|
-
console.log(`[PERF] Total conversation: ${Date.now() - startTime}ms`);
|
|
389
|
-
console.log(`[PERF] Tool metrics:`, Object.fromEntries(toolMetrics));
|
|
338
|
+
const startTime = Date.now()
|
|
339
|
+
const toolMetrics = new Map<string, number[]>()
|
|
340
|
+
|
|
341
|
+
const onBeforeTool: Autonomous.Hooks['onBeforeTool'] = async ({ iteration, tool, input, controller }) => {
|
|
342
|
+
;(tool as any)._startTime = Date.now()
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const onAfterTool: Autonomous.Hooks['onAfterTool'] = async ({ tool, output }) => {
|
|
346
|
+
const duration = Date.now() - ((tool as any)._startTime || 0)
|
|
347
|
+
const metrics = toolMetrics.get(tool.name) || []
|
|
348
|
+
metrics.push(duration)
|
|
349
|
+
toolMetrics.set(tool.name, metrics)
|
|
350
|
+
console.log(`[PERF] ${tool.name}: ${duration}ms`)
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const onTrace: Autonomous.Hooks['onTrace'] = ({ trace, iteration }) => {
|
|
354
|
+
if (trace.type === 'end') {
|
|
355
|
+
console.log(`[PERF] Total conversation: ${Date.now() - startTime}ms`)
|
|
356
|
+
console.log(`[PERF] Tool metrics:`, Object.fromEntries(toolMetrics))
|
|
390
357
|
}
|
|
391
|
-
}
|
|
358
|
+
}
|
|
392
359
|
|
|
393
|
-
return { onBeforeTool, onAfterTool, onTrace }
|
|
394
|
-
}
|
|
360
|
+
return { onBeforeTool, onAfterTool, onTrace }
|
|
361
|
+
}
|
|
395
362
|
```
|
|
396
363
|
|
|
397
364
|
### Hook Signatures Reference
|
|
398
365
|
|
|
399
|
-
| Hook
|
|
400
|
-
|
|
366
|
+
| Hook | Parameters | Description |
|
|
367
|
+
| -------------- | ---------------------------------------- | --------------------------- |
|
|
401
368
|
| `onBeforeTool` | `{ iteration, tool, input, controller }` | Fires before each tool call |
|
|
402
|
-
| `onAfterTool`
|
|
403
|
-
| `onTrace`
|
|
369
|
+
| `onAfterTool` | `{ tool, output }` | Fires after each tool call |
|
|
370
|
+
| `onTrace` | `{ trace, iteration }` | Fires on every trace event |
|
|
404
371
|
|
|
405
372
|
---
|
|
406
373
|
|
|
@@ -410,16 +377,16 @@ Combine multiple extensions into a cohesive agent architecture.
|
|
|
410
377
|
|
|
411
378
|
```typescript
|
|
412
379
|
// src/conversations/webchat.ts
|
|
413
|
-
import { Conversation } from
|
|
414
|
-
import { WebsiteKB } from
|
|
415
|
-
import { getAdminModeObject } from
|
|
416
|
-
import { makeGuardrails } from
|
|
417
|
-
import { onTraceLogging } from
|
|
380
|
+
import { Conversation } from '@botpress/runtime'
|
|
381
|
+
import { WebsiteKB } from '../knowledge/website-docs'
|
|
382
|
+
import { getAdminModeObject } from './extensions/admin-mode'
|
|
383
|
+
import { makeGuardrails } from './extensions/guardrails'
|
|
384
|
+
import { onTraceLogging } from './extensions/logging'
|
|
418
385
|
|
|
419
386
|
export default new Conversation({
|
|
420
|
-
channel:
|
|
387
|
+
channel: '*',
|
|
421
388
|
handler: async ({ execute, message }) => {
|
|
422
|
-
const guardrail = makeGuardrails(message)
|
|
389
|
+
const guardrail = makeGuardrails(message)
|
|
423
390
|
|
|
424
391
|
await execute({
|
|
425
392
|
instructions: `You are a helpful assistant that provides accurate information.`,
|
|
@@ -429,9 +396,9 @@ export default new Conversation({
|
|
|
429
396
|
onBeforeTool: async (props) => guardrail.onBeforeToolGuard(props),
|
|
430
397
|
onTrace: (props) => onTraceLogging!(props),
|
|
431
398
|
},
|
|
432
|
-
})
|
|
399
|
+
})
|
|
433
400
|
},
|
|
434
|
-
})
|
|
401
|
+
})
|
|
435
402
|
```
|
|
436
403
|
|
|
437
404
|
### Architecture
|
|
@@ -450,15 +417,15 @@ Conversation Handler
|
|
|
450
417
|
### Multi-Extension Composition
|
|
451
418
|
|
|
452
419
|
```typescript
|
|
453
|
-
import { makeGuardrails } from
|
|
454
|
-
import { onTraceLogging } from
|
|
455
|
-
import { makePerformanceMonitor } from
|
|
420
|
+
import { makeGuardrails } from './extensions/guardrails'
|
|
421
|
+
import { onTraceLogging } from './extensions/logging'
|
|
422
|
+
import { makePerformanceMonitor } from './extensions/performance'
|
|
456
423
|
|
|
457
424
|
export default new Conversation({
|
|
458
|
-
channel:
|
|
425
|
+
channel: '*',
|
|
459
426
|
handler: async ({ execute, message }) => {
|
|
460
|
-
const guardrail = makeGuardrails(message)
|
|
461
|
-
const perfMonitor = makePerformanceMonitor()
|
|
427
|
+
const guardrail = makeGuardrails(message)
|
|
428
|
+
const perfMonitor = makePerformanceMonitor()
|
|
462
429
|
|
|
463
430
|
await execute({
|
|
464
431
|
instructions: `You are a documentation assistant. Always search before answering.`,
|
|
@@ -466,20 +433,20 @@ export default new Conversation({
|
|
|
466
433
|
objects: [getAdminModeObject()],
|
|
467
434
|
hooks: {
|
|
468
435
|
onBeforeTool: async (props) => {
|
|
469
|
-
await guardrail.onBeforeToolGuard(props)
|
|
470
|
-
await perfMonitor.onBeforeTool(props)
|
|
436
|
+
await guardrail.onBeforeToolGuard(props)
|
|
437
|
+
await perfMonitor.onBeforeTool(props)
|
|
471
438
|
},
|
|
472
439
|
onAfterTool: async (props) => {
|
|
473
|
-
await perfMonitor.onAfterTool(props)
|
|
440
|
+
await perfMonitor.onAfterTool(props)
|
|
474
441
|
},
|
|
475
442
|
onTrace: (props) => {
|
|
476
|
-
onTraceLogging!(props)
|
|
477
|
-
perfMonitor.onTrace(props)
|
|
443
|
+
onTraceLogging!(props)
|
|
444
|
+
perfMonitor.onTrace(props)
|
|
478
445
|
},
|
|
479
446
|
},
|
|
480
|
-
})
|
|
447
|
+
})
|
|
481
448
|
},
|
|
482
|
-
})
|
|
449
|
+
})
|
|
483
450
|
```
|
|
484
451
|
|
|
485
452
|
### Best Practices
|
|
@@ -565,16 +532,16 @@ Centralize Zod schemas to ensure consistency across Actions, Tables, Workflows,
|
|
|
565
532
|
|
|
566
533
|
```typescript
|
|
567
534
|
// src/schemas.ts
|
|
568
|
-
import { z } from
|
|
535
|
+
import { z } from '@botpress/runtime'
|
|
569
536
|
|
|
570
|
-
export type User = z.infer<typeof UserSchema
|
|
537
|
+
export type User = z.infer<typeof UserSchema>
|
|
571
538
|
export const UserSchema = z.object({
|
|
572
539
|
id: z.string(),
|
|
573
540
|
email: z.string().email(),
|
|
574
541
|
name: z.string().optional(),
|
|
575
|
-
role: z.enum([
|
|
576
|
-
createdAt: z.string().describe(
|
|
577
|
-
})
|
|
542
|
+
role: z.enum(['admin', 'user', 'guest']).default('user'),
|
|
543
|
+
createdAt: z.string().describe('ISO 8601 timestamp'),
|
|
544
|
+
})
|
|
578
545
|
```
|
|
579
546
|
|
|
580
547
|
### Reuse Across Components
|
|
@@ -582,50 +549,50 @@ export const UserSchema = z.object({
|
|
|
582
549
|
**In Actions:**
|
|
583
550
|
|
|
584
551
|
```typescript
|
|
585
|
-
import { Action } from
|
|
586
|
-
import { UserSchema } from
|
|
552
|
+
import { Action } from '@botpress/runtime'
|
|
553
|
+
import { UserSchema } from '../schemas'
|
|
587
554
|
|
|
588
555
|
export const GetUser = new Action({
|
|
589
|
-
name:
|
|
556
|
+
name: 'getUser',
|
|
590
557
|
input: z.object({ userId: z.string() }),
|
|
591
558
|
output: UserSchema,
|
|
592
559
|
handler: async ({ input }) => {
|
|
593
|
-
return await fetchUserFromAPI(input.userId)
|
|
560
|
+
return await fetchUserFromAPI(input.userId)
|
|
594
561
|
},
|
|
595
|
-
})
|
|
562
|
+
})
|
|
596
563
|
```
|
|
597
564
|
|
|
598
565
|
**In Tables:**
|
|
599
566
|
|
|
600
567
|
```typescript
|
|
601
|
-
import { Table } from
|
|
602
|
-
import { UserSchema } from
|
|
568
|
+
import { Table } from '@botpress/runtime'
|
|
569
|
+
import { UserSchema } from '../schemas'
|
|
603
570
|
|
|
604
571
|
export const UsersTable = new Table({
|
|
605
|
-
name:
|
|
606
|
-
description:
|
|
572
|
+
name: 'UsersTable',
|
|
573
|
+
description: 'Store user information',
|
|
607
574
|
columns: {
|
|
608
575
|
email: { schema: UserSchema.shape.email, searchable: true },
|
|
609
576
|
name: { schema: UserSchema.shape.name, searchable: true },
|
|
610
577
|
},
|
|
611
|
-
})
|
|
578
|
+
})
|
|
612
579
|
```
|
|
613
580
|
|
|
614
581
|
**In Workflows:**
|
|
615
582
|
|
|
616
583
|
```typescript
|
|
617
|
-
import { Workflow } from
|
|
618
|
-
import { UserSchema, ConversationSchema } from
|
|
584
|
+
import { Workflow } from '@botpress/runtime'
|
|
585
|
+
import { UserSchema, ConversationSchema } from '../schemas'
|
|
619
586
|
|
|
620
587
|
export const ProcessUser = new Workflow({
|
|
621
|
-
name:
|
|
588
|
+
name: 'processUser',
|
|
622
589
|
input: z.object({ user: UserSchema, conversationId: z.string() }),
|
|
623
590
|
state: z.object({ conversation: ConversationSchema.optional() }),
|
|
624
591
|
handler: async ({ input, state, step }) => {
|
|
625
|
-
console.log(`Processing user: ${input.user.email}`)
|
|
626
|
-
return { userId: input.user.id }
|
|
592
|
+
console.log(`Processing user: ${input.user.email}`)
|
|
593
|
+
return { userId: input.user.id }
|
|
627
594
|
},
|
|
628
|
-
})
|
|
595
|
+
})
|
|
629
596
|
```
|
|
630
597
|
|
|
631
598
|
### Schema Composition
|
|
@@ -636,17 +603,17 @@ export const BaseEntitySchema = z.object({
|
|
|
636
603
|
id: z.string(),
|
|
637
604
|
createdAt: z.string(),
|
|
638
605
|
updatedAt: z.string(),
|
|
639
|
-
})
|
|
606
|
+
})
|
|
640
607
|
|
|
641
608
|
// Extend
|
|
642
609
|
export const ConversationSchema = BaseEntitySchema.extend({
|
|
643
610
|
userId: z.string(),
|
|
644
|
-
status: z.enum([
|
|
645
|
-
})
|
|
611
|
+
status: z.enum(['open', 'closed', 'snoozed']),
|
|
612
|
+
})
|
|
646
613
|
|
|
647
614
|
// Pick / Omit
|
|
648
|
-
export const UserSummarySchema = UserSchema.pick({ id: true, email: true, name: true })
|
|
649
|
-
export const PublicUserSchema = UserSchema.omit({ metadata: true })
|
|
615
|
+
export const UserSummarySchema = UserSchema.pick({ id: true, email: true, name: true })
|
|
616
|
+
export const PublicUserSchema = UserSchema.omit({ metadata: true })
|
|
650
617
|
```
|
|
651
618
|
|
|
652
619
|
### Best Practices
|