@andreprado/agentkit 0.1.0-alpha.8 → 0.1.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 (117) hide show
  1. package/README.md +18 -1
  2. package/docs/guides/add-channel.md +251 -7
  3. package/docs/guides/add-knowledge.md +10 -0
  4. package/docs/guides/add-managed-composio.md +165 -0
  5. package/docs/guides/add-tool.md +10 -3
  6. package/docs/guides/channel-security.md +162 -32
  7. package/docs/guides/connect-discord.md +178 -0
  8. package/docs/guides/connect-slack.md +126 -0
  9. package/docs/guides/connect-telegram.md +61 -1
  10. package/docs/guides/connect-whatsapp-evolution.md +121 -0
  11. package/docs/guides/connect-whatsapp-uazapi.md +139 -0
  12. package/docs/guides/connect-whatsapp-zapster.md +119 -16
  13. package/docs/guides/create-agent.md +31 -4
  14. package/docs/guides/debug-channel.md +159 -0
  15. package/docs/guides/improve-from-production.md +151 -0
  16. package/docs/guides/prepare-deploy.md +32 -14
  17. package/docs/guides/replay-production-traces.md +72 -0
  18. package/docs/guides/run-evals.md +95 -25
  19. package/docs/guides/security-rules.md +9 -5
  20. package/docs/guides/send-feedback.md +135 -0
  21. package/docs/guides/use-jev.md +67 -0
  22. package/docs/guides/use-provider.md +70 -3
  23. package/docs/llms-full.txt +295 -25
  24. package/docs/llms.txt +54 -7
  25. package/package.json +3 -7
  26. package/src/cli/args.ts +23 -2
  27. package/src/cli/cloud-client.ts +121 -9
  28. package/src/cli/commands/channels.ts +1185 -50
  29. package/src/cli/commands/feedback.ts +438 -0
  30. package/src/cli/commands/provider.ts +47 -0
  31. package/src/cli/commands/transcribe.ts +171 -0
  32. package/src/cli/deploy-chat-ui.ts +232 -18
  33. package/src/cli/deploy-readiness.ts +227 -14
  34. package/src/cli/help.ts +68 -8
  35. package/src/cli/index.ts +740 -35
  36. package/src/cli/new-command.ts +41 -0
  37. package/src/cloud/client.ts +4 -3
  38. package/src/cloud/contracts.ts +1 -1
  39. package/src/create-project.ts +18 -35
  40. package/src/index.ts +565 -11
  41. package/src/providers/codex-auth.ts +111 -0
  42. package/src/providers/pi.ts +88 -19
  43. package/src/providers/test.ts +36 -0
  44. package/src/providers/types.ts +8 -0
  45. package/src/runtime/channel-test-harness.ts +21 -1
  46. package/src/runtime/channels/discord.ts +896 -0
  47. package/src/runtime/channels/generic-webhook.ts +974 -0
  48. package/src/runtime/channels/slack.ts +646 -0
  49. package/src/runtime/channels/telegram.ts +466 -23
  50. package/src/runtime/channels/whatsapp-evolution.ts +1357 -0
  51. package/src/runtime/channels/whatsapp-meta.ts +9 -0
  52. package/src/runtime/channels/whatsapp-uazapi.ts +1323 -0
  53. package/src/runtime/channels/whatsapp-zapster.ts +674 -40
  54. package/src/runtime/channels.ts +89 -4
  55. package/src/runtime/chat.ts +70 -44
  56. package/src/runtime/config.ts +489 -20
  57. package/src/runtime/core/manifest.ts +75 -5
  58. package/src/runtime/core/targets.ts +5 -5
  59. package/src/runtime/deploy-readiness.ts +34 -4
  60. package/src/runtime/dev-server.ts +639 -39
  61. package/src/runtime/env.ts +8 -3
  62. package/src/runtime/evals.ts +445 -74
  63. package/src/runtime/improve.ts +868 -0
  64. package/src/runtime/inspect.ts +173 -4
  65. package/src/runtime/integrations/composio.ts +425 -0
  66. package/src/runtime/knowledge/retrieve.ts +25 -5
  67. package/src/runtime/knowledge/schema.ts +45 -1
  68. package/src/runtime/prompt-context.ts +141 -0
  69. package/src/runtime/runtime-contract.ts +71 -7
  70. package/src/runtime/skills.ts +95 -0
  71. package/src/runtime/targets/cloudflare/build.ts +1010 -208
  72. package/src/runtime/targets/container/server.ts +1 -1
  73. package/src/runtime/targets/vps/deploy.ts +26 -9
  74. package/src/runtime/tool-runner.ts +9 -1
  75. package/src/runtime/tools.ts +26 -2
  76. package/src/runtime/transcription.ts +483 -0
  77. package/src/storage/sqlite.ts +7 -2
  78. package/src/templates/blank.ts +37 -9
  79. package/src/templates/dentista.ts +40 -14
  80. package/src/templates/skills/agentkit-build-agent/SKILL.md +34 -5
  81. package/src/templates/skills/agentkit-build-agent/templates/appointment-intake.instructions.md +2 -1
  82. package/src/templates/skills/agentkit-capsule/SKILL.md +32 -3
  83. package/src/templates/skills/agentkit-capsule/references/docs-router.md +2 -2
  84. package/src/templates/skills/agentkit-channels/SKILL.md +71 -6
  85. package/src/templates/skills/agentkit-channels/references/channel-buffering.md +9 -2
  86. package/src/templates/skills/agentkit-channels/references/channel-debugging.md +34 -5
  87. package/src/templates/skills/agentkit-channels/references/discord.md +93 -0
  88. package/src/templates/skills/agentkit-channels/references/slack.md +56 -0
  89. package/src/templates/skills/agentkit-channels/references/telegram.md +39 -4
  90. package/src/templates/skills/agentkit-channels/references/whatsapp-evolution.md +57 -0
  91. package/src/templates/skills/agentkit-channels/references/whatsapp-uazapi.md +54 -0
  92. package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +42 -8
  93. package/src/templates/skills/agentkit-database/SKILL.md +11 -0
  94. package/src/templates/skills/agentkit-deploy/SKILL.md +9 -1
  95. package/src/templates/skills/agentkit-evals/SKILL.md +77 -13
  96. package/src/templates/skills/agentkit-evals/templates/multi-turn.eval.md +13 -6
  97. package/src/templates/skills/agentkit-evals/templates/no-leak.eval.md +8 -4
  98. package/src/templates/skills/agentkit-evals/templates/smoke.eval.md +8 -4
  99. package/src/templates/skills/agentkit-evals/templates/tool-call.eval.md +16 -7
  100. package/src/templates/skills/agentkit-improve/SKILL.md +96 -0
  101. package/src/templates/skills/agentkit-improve/references/replay-side-effects.md +18 -0
  102. package/src/templates/skills/agentkit-improve/references/trace-packets.md +22 -0
  103. package/src/templates/skills/agentkit-improve/templates/regression.eval.md +18 -0
  104. package/src/templates/skills/agentkit-integrations/SKILL.md +98 -0
  105. package/src/templates/skills/agentkit-knowledge/SKILL.md +4 -1
  106. package/src/templates/skills/agentkit-prompts/SKILL.md +3 -1
  107. package/src/templates/skills/agentkit-provider/SKILL.md +29 -4
  108. package/src/templates/skills/agentkit-security/SKILL.md +5 -2
  109. package/src/templates/skills/agentkit-tools/SKILL.md +8 -1
  110. package/src/templates/skills/agentkit-tools/examples/eval-safe-external-action.tool.md +8 -8
  111. package/src/templates/skills/agentkit-tools/examples/jev-service-fit.tool.md +110 -0
  112. package/src/templates/skills/agentkit-troubleshooting/SKILL.md +25 -1
  113. package/src/templates/support.ts +42 -12
  114. package/docs/guides/agentkit-skills-architecture.md +0 -471
  115. package/docs/guides/channels-implementation-map.md +0 -243
  116. package/docs/guides/channels-production-handoff.md +0 -101
  117. package/docs/portable-deploy-release-checklist.md +0 -41
package/README.md CHANGED
@@ -24,12 +24,15 @@ Generated capsules use the built-in `test/fake` provider by default, so the firs
24
24
  ## What To Know First
25
25
 
26
26
  ```sh
27
- agentkit new <name> [--template blank|support|dentista] [--no-install]
27
+ agentkit new [name] [--template blank|support|dentista] [--no-install]
28
+ agentkit new .
28
29
  agentkit dev
29
30
  agentkit chat --message <text> [--conversation-id <id>]
30
31
  agentkit inspect
31
32
  ```
32
33
 
34
+ Run `agentkit new` without a name in an interactive terminal to be prompted for the project folder. Use `agentkit new .` to create the capsule in the current directory.
35
+
33
36
  Once the capsule is running:
34
37
 
35
38
  ```sh
@@ -37,29 +40,43 @@ agentkit tool <name> [--input <path-or-json>]
37
40
  agentkit knowledge add <path-or-url>
38
41
  agentkit knowledge sync
39
42
  agentkit knowledge search <query> [--top-k <number>]
43
+ agentkit integrations status
44
+ agentkit integrations connect composio --toolkit gmail
40
45
  agentkit spec init --brief <text>
41
46
  agentkit db migrate
42
47
  agentkit sync run
43
48
  agentkit eval run
44
49
  agentkit eval from-conversation <conversation-id>
50
+ agentkit improve collect --deploy --since 24h
51
+ agentkit improve evals .agentkit/improve/<run>
52
+ agentkit replay .agentkit/improve/<run> --against local
45
53
  agentkit conversations list
46
54
  agentkit conversations trace <conversation-id>
47
55
  ```
48
56
 
49
57
  Knowledge indexes local `.md`, `.txt`, and `.csv` sources into the capsule database and registers the internal `agentkit_search_knowledge` chat tool when `knowledge` is configured in `agentkit.config.ts`. `agentkit dev` and `agentkit chat` sync configured sources automatically; when embeddings are configured, local semantic search uses a libSQL vector sidecar. Hosted Cloudflare deploys package configured local Knowledge sources and sync them into the project Turso database automatically during `agentkit deploy`; when embeddings are configured, the deploy also creates and populates the hosted Turso vector index.
50
58
 
59
+ Every chat run receives dynamic runtime date context: current ISO timestamp, local date, weekday, local date/time, and timezone. Set `timeZone` in `agentkit.config.ts` for scheduling agents so relative dates like "today" and "next Friday" resolve in the right business/user timezone.
60
+
61
+ AgentKit-managed Composio is a paid hosted integration layer for per-agent connected apps. Configure it with `composioManaged({...})`, deploy with a `managed_composio` entitlement, then use `agentkit integrations connect composio --toolkit <slug>` to create hosted Connect Links. BYO Composio remains available through normal `defineTool` wrappers.
62
+
51
63
  ## Deploy Later
52
64
 
53
65
  ```sh
54
66
  agentkit login --token <token>
55
67
  agentkit deploy doctor
68
+ agentkit skills status
56
69
  agentkit secret set OPENAI_API_KEY --from-local-env
57
70
  agentkit deploy
58
71
  agentkit deploy status
72
+ agentkit channels test support-telegram --message "hello"
73
+ agentkit channels connect webhook n8n-webhook
74
+ agentkit transcribe smoke --provider groq
59
75
  agentkit chat-ui --deploy
60
76
  ```
61
77
 
62
78
  Production secrets are managed secrets, not committed `.env` values.
79
+ After upgrading AgentKit in an existing capsule, run `agentkit skills status` and `agentkit skills sync` if local agent-facing skills are stale.
63
80
  Private hosted deploys automatically store a local chat/UI deploy access token at `.agentkit/chat-access-token.json`. `agentkit chat-ui --deploy` serves a local UI pointed at the hosted deploy without exposing that token to browser code.
64
81
 
65
82
  The npm package contains the public CLI/runtime/client surface only. AgentKit Cloud's control-plane server, operator commands, Postgres store, and Cloudflare/Turso/R2 publisher live in the private repo workspace and are not part of the published package.
@@ -6,7 +6,7 @@ Add a hosted messaging channel to an Agent Capsule, create the hosted channel re
6
6
 
7
7
  ## When To Use It
8
8
 
9
- Use this when the agent should receive messages from website chat, Telegram, or WhatsApp through AgentKit-owned webhook infrastructure.
9
+ Use this when the agent should receive messages from website chat, Telegram, WhatsApp, Discord, Slack, or a generic webhook through AgentKit-owned channel infrastructure, or when an inbound channel should reply through another configured channel.
10
10
 
11
11
  ## Commands
12
12
 
@@ -16,26 +16,35 @@ agentkit deploy
16
16
  agentkit channels list
17
17
  agentkit channels add website website-chat
18
18
  agentkit channels add telegram support-telegram
19
+ agentkit channels connect discord support-discord
20
+ agentkit channels connect discord server-discord --mode bot
21
+ agentkit channels connect slack support-slack
22
+ agentkit channels connect webhook n8n-webhook
19
23
  agentkit channels add whatsapp support-whatsapp --provider zapster
24
+ agentkit channels connect whatsapp support-uazapi --provider uazapi
25
+ agentkit channels connect whatsapp main-whatsapp --provider evolution
20
26
  agentkit channels setup support-telegram
21
27
  agentkit channels status support-telegram
22
28
  agentkit channels test support-telegram --message "hello"
23
29
  agentkit channels deliveries list support-telegram
30
+ agentkit channels buffers list support-telegram
24
31
  ```
25
32
 
26
- Use `--api <url>` with hosted commands when testing against a non-default AgentKit Cloud API.
33
+ Use `--api <url>` only when the owner gives you a non-default AgentKit Cloud API URL.
27
34
 
28
35
  ## Files Created Or Edited
29
36
 
30
- - `agentkit.config.ts`: declare channel config with `websiteChannel`, `telegramChannel`, or `whatsappChannel`.
37
+ - `agentkit.config.ts`: declare channel config with `websiteChannel`, `telegramChannel`, `whatsappChannel`, `discordChannel`, `slackChannel`, `webhookChannel`, or `webhookOutputChannel`.
31
38
  - `.agentkit/deploy.json`: written by `agentkit deploy`; used by `agentkit channels ...`.
32
- - No user Turso tables: AgentKit channel resources, dedupe, identities, queue state, and delivery logs are control-plane owned.
39
+ - No user Turso tables: AgentKit owns channel resources, dedupe, identities, queue state, and delivery logs.
33
40
  - Website channel clients must send `AGENTKIT_WEBSITE_CHANNEL_TOKEN` as `Authorization: Bearer <token>` or `X-AgentKit-Channel-Token`.
41
+ - Generic inbound webhook clients must send `AGENTKIT_WEBHOOK_SECRET` as `Authorization: Bearer <token>`, `X-AgentKit-Webhook-Secret`, or `X-AgentKit-Webhook-Signature: sha256=<hmac>`.
42
+ - Generic outbound webhook channels send replies to an HTTPS URL stored in a managed secret such as `CRM_CALLBACK_URL`.
34
43
 
35
44
  ## Minimal Working Example
36
45
 
37
46
  ```ts
38
- import { defineAgent, telegramChannel, whatsappChannel, websiteChannel } from "@andreprado/agentkit";
47
+ import { defineAgent, discordChannel, slackChannel, telegramChannel, webhookChannel, webhookOutputChannel, whatsappChannel, websiteChannel } from "@andreprado/agentkit";
39
48
 
40
49
  export default defineAgent({
41
50
  name: "support-agent",
@@ -48,6 +57,13 @@ export default defineAgent({
48
57
  websiteChannel({ name: "website-chat" }),
49
58
  telegramChannel({ name: "support-telegram" }),
50
59
  whatsappChannel({ name: "support-whatsapp", provider: "zapster" }),
60
+ whatsappChannel({ name: "support-uazapi", provider: "uazapi" }),
61
+ whatsappChannel({ name: "main-whatsapp", provider: "evolution" }),
62
+ discordChannel({ name: "support-discord" }),
63
+ discordChannel({ name: "server-discord", mode: "bot" }),
64
+ slackChannel({ name: "support-slack" }),
65
+ webhookChannel({ name: "n8n-webhook" }),
66
+ webhookOutputChannel({ name: "crm-callback", urlSecret: "CRM_CALLBACK_URL" }),
51
67
  ],
52
68
  access: { mode: "public" },
53
69
  storage: { driver: "agentkit" },
@@ -76,6 +92,222 @@ Buffering is scoped to one channel conversation. AgentKit still validates and de
76
92
 
77
93
  Use `buffer: { mode: "off" }` or omit `buffer` to process each inbound message as its own agent run.
78
94
 
95
+ Buffer controls:
96
+
97
+ ```sh
98
+ agentkit channels buffers list support-whatsapp
99
+ agentkit channels buffers show support-whatsapp <conversation-id>
100
+ agentkit channels buffers flush support-whatsapp <conversation-id>
101
+ agentkit channels buffers clear support-whatsapp <conversation-id>
102
+ agentkit channels buffers retry support-whatsapp <conversation-id>
103
+ ```
104
+
105
+ Discord supports buffering for slash-command interactions and bot-mode server messages, but it does not support `audio` in V1.
106
+
107
+ ## Generic Webhooks
108
+
109
+ Use `webhookChannel` when n8n, Make, Zapier, Pipedream, or a custom server should push a text event into the agent.
110
+
111
+ ```ts
112
+ webhookChannel({
113
+ name: "n8n-webhook",
114
+ })
115
+ ```
116
+
117
+ After deploy:
118
+
119
+ ```sh
120
+ agentkit channels connect webhook n8n-webhook
121
+ ```
122
+
123
+ The hosted webhook URL is:
124
+
125
+ ```txt
126
+ https://<deploy-host>/channels/n8n-webhook/webhook
127
+ ```
128
+
129
+ Send canonical JSON:
130
+
131
+ ```json
132
+ {
133
+ "event_id": "evt_123",
134
+ "external_id": "customer_123",
135
+ "message": "hello from n8n"
136
+ }
137
+ ```
138
+
139
+ `event_id` is required for replay protection. `external_id` is optional but recommended; AgentKit hashes it before storing the channel identity and uses it to continue the same conversation. If `external_id` is omitted, the event id becomes the conversation identity and each event is treated as its own conversation.
140
+
141
+ Authenticate with a shared secret:
142
+
143
+ ```sh
144
+ curl -X POST https://<deploy-host>/channels/n8n-webhook/webhook \
145
+ -H 'content-type: application/json' \
146
+ -H 'authorization: Bearer <AGENTKIT_WEBHOOK_SECRET>' \
147
+ -d '{"event_id":"evt_123","external_id":"customer_123","message":"hello from n8n"}'
148
+ ```
149
+
150
+ For HMAC auth, compute `HMAC-SHA256(raw JSON body, AGENTKIT_WEBHOOK_SECRET)` and send:
151
+
152
+ ```txt
153
+ X-AgentKit-Webhook-Signature: sha256=<hex digest>
154
+ ```
155
+
156
+ Without `replyTo`, generic webhooks are inbound-only: the agent run is queued and delivery logs show the result, but AgentKit does not call back into the source system.
157
+
158
+ ## Reply Through Another Channel
159
+
160
+ Use `replyTo` when an inbound channel should receive on one transport and answer on another. The source channel still owns webhook validation, dedupe, and queueing; the target channel owns the outbound provider call.
161
+
162
+ Receive from a generic webhook and answer on WhatsApp:
163
+
164
+ ```ts
165
+ webhookChannel({
166
+ name: "lead-webhook",
167
+ replyTo: {
168
+ channel: "main-whatsapp",
169
+ recipientFrom: "phone",
170
+ },
171
+ })
172
+
173
+ whatsappChannel({
174
+ name: "main-whatsapp",
175
+ provider: "evolution",
176
+ })
177
+ ```
178
+
179
+ The inbound webhook payload must include the configured recipient field:
180
+
181
+ ```json
182
+ {
183
+ "event_id": "evt_124",
184
+ "external_id": "lead_123",
185
+ "phone": "+15551234567",
186
+ "message": "please follow up"
187
+ }
188
+ ```
189
+
190
+ `recipientFrom` is a dotted JSON path such as `phone`, `customer.phone`, or `payload.customer.phone`. AgentKit reads it from the raw inbound payload, requires a non-empty scalar value, and formats it for the target channel. Do not use `recipientFrom` for Discord or Slack replies; those require provider-native source identities from their own inbound events.
191
+
192
+ You can declare multiple webhook inputs by giving each `webhookChannel` a unique name:
193
+
194
+ ```ts
195
+ webhookChannel({ name: "n8n-webhook" })
196
+ webhookChannel({ name: "make-webhook" })
197
+ webhookChannel({ name: "crm-webhook", replyTo: { channel: "main-whatsapp", recipientFrom: "phone" } })
198
+ ```
199
+
200
+ ## Generic Output Webhooks
201
+
202
+ Use `webhookOutputChannel` when the agent should send the final answer to a generic callback URL, such as an internal CRM, n8n callback, Make webhook, or a custom API endpoint.
203
+
204
+ ```ts
205
+ webhookOutputChannel({
206
+ name: "crm-callback",
207
+ urlSecret: "CRM_CALLBACK_URL",
208
+ auth: {
209
+ type: "bearer",
210
+ tokenSecret: "CRM_CALLBACK_TOKEN",
211
+ },
212
+ })
213
+
214
+ webhookChannel({
215
+ name: "n8n-webhook",
216
+ replyTo: {
217
+ channel: "crm-callback",
218
+ recipientFrom: "crm_id",
219
+ },
220
+ })
221
+ ```
222
+
223
+ Set `CRM_CALLBACK_URL` as a managed secret. It must be a public HTTPS URL; AgentKit rejects localhost, private network, link-local, and metadata-service hosts before sending. Supported output auth modes are `none`, `bearer`, `header`, and `hmac`, and all auth values come from managed secrets.
224
+
225
+ Outbound generic webhook requests contain the agent's final text answer:
226
+
227
+ ```json
228
+ {
229
+ "event_id": "webhook:generic:crm-callback:<conversation-id>",
230
+ "conversation_id": "<conversation-id>",
231
+ "channel_id": "crm-callback",
232
+ "external_identity": "webhook:generic:recipient:acct_123",
233
+ "message": {
234
+ "role": "assistant",
235
+ "content_type": "text",
236
+ "content": "Thanks, I can help with that."
237
+ }
238
+ }
239
+ ```
240
+
241
+ Generic output channels do not have public inbound webhook URLs. `agentkit channels test <output-name>` is unsupported because there is no inbound endpoint to smoke.
242
+
243
+ ## Auto Transcribe Audio
244
+
245
+ Use `transcription` at the agent level and `audio.mode: "transcribe"` on each Telegram or WhatsApp channel that should accept voice notes or audio files.
246
+
247
+ ```ts
248
+ export default defineAgent({
249
+ name: "support-agent",
250
+ runtime: "edge",
251
+ provider: { name: "openai", model: "gpt-5.4-mini" },
252
+ instructions: "./prompts/instructions.md",
253
+ transcription: {
254
+ provider: "groq",
255
+ model: "whisper-large-v3-turbo",
256
+ secret: "GROQ_API_KEY",
257
+ language: "pt",
258
+ limits: {
259
+ maxDurationSeconds: 180,
260
+ maxBytes: 20_000_000,
261
+ },
262
+ },
263
+ channels: [
264
+ telegramChannel({
265
+ name: "support-telegram",
266
+ audio: { mode: "transcribe" },
267
+ }),
268
+ whatsappChannel({
269
+ name: "support-whatsapp",
270
+ provider: "zapster",
271
+ audio: { mode: "transcribe" },
272
+ }),
273
+ whatsappChannel({
274
+ name: "support-uazapi",
275
+ provider: "uazapi",
276
+ audio: { mode: "transcribe" },
277
+ }),
278
+ whatsappChannel({
279
+ name: "main-whatsapp",
280
+ provider: "evolution",
281
+ audio: { mode: "transcribe" },
282
+ }),
283
+ ],
284
+ access: { mode: "public" },
285
+ storage: { driver: "agentkit" },
286
+ });
287
+ ```
288
+
289
+ Supported transcription providers in V1:
290
+
291
+ | Provider | Default secret | Supported models |
292
+ | --- | --- | --- |
293
+ | `openai` | `OPENAI_API_KEY` | `gpt-4o-mini-transcribe`, `gpt-4o-transcribe`, `whisper-1` |
294
+ | `groq` | `GROQ_API_KEY` | `whisper-large-v3-turbo`, `whisper-large-v3`, `distil-whisper-large-v3-en` |
295
+
296
+ Audio transcription is paid by the capsule owner because AgentKit only passes through the configured provider secret. Hosted channel creation automatically requires the transcription secret when a channel enables `audio.mode: "transcribe"`.
297
+
298
+ Processing order:
299
+
300
+ 1. Provider webhook is validated and deduped.
301
+ 2. Channel adapter normalizes the audio metadata.
302
+ 3. AgentKit records `audio_received` and enqueues a channel job before acknowledging the webhook.
303
+ 4. The retryable channel worker downloads the audio using the channel provider secret.
304
+ 5. The transcription adapter sends the file to the configured transcription provider.
305
+ 6. The agent receives a text message containing the transcript.
306
+
307
+ Zapster audio downloads from trusted HTTPS Zapster media URLs. UAZAPI audio downloads through UAZAPI `/message/download` with base64 return enabled. Evolution audio downloads through Evolution API `/chat/getBase64FromMediaMessage/{instance}` with base64 return enabled. AgentKit does not fetch arbitrary UAZAPI or Evolution webhook media hosts.
308
+
309
+ V1 keeps the raw audio in memory for the request path and delivery metadata only records redacted status/error fields. `rawAudioTtlSeconds` is part of the manifest contract for future object-storage retention, but V1 does not persist raw audio by default.
310
+
79
311
  ## Safety Rules
80
312
 
81
313
  - Never put provider token values in `agentkit.config.ts`.
@@ -83,6 +315,7 @@ Use `buffer: { mode: "off" }` or omit `buffer` to process each inbound message a
83
315
  - Treat channel webhook URLs as public transport endpoints. Provider validation or the AgentKit website channel token controls authenticity.
84
316
  - Keep channels separate from tools. Channels deliver user messages; tools let the agent call external systems.
85
317
  - Keep `maxMessages` and `maxChars` bounded so one burst cannot create an oversized prompt or unexpected model spend.
318
+ - Keep `audio.limits` bounded so one voice note cannot create unexpected transcription spend.
86
319
 
87
320
  ## Verification
88
321
 
@@ -91,11 +324,16 @@ npm run typecheck
91
324
  bun test
92
325
  agentkit inspect
93
326
  agentkit channels list
327
+ agentkit channels test n8n-webhook --message "hello"
94
328
  agentkit channels test support-telegram --message "hello"
329
+ agentkit channels test-audio support-telegram --fixture voice-note
330
+ agentkit transcribe smoke --provider groq
95
331
  agentkit channels deliveries list support-telegram
332
+ agentkit channels buffers list support-telegram
96
333
  ```
97
334
 
98
335
  Expected hosted status includes `NAME`, `TYPE`, `PROVIDER`, `STATUS`, and `LAST_EVENT`. Secret output is name plus `set` or `missing`, never the value.
336
+ Outbound provider success is `provider_sent`. `adapter_stubbed` means no outbound provider call was made, either because explicit dry-run mode is enabled or the channel is inbound-only.
99
337
 
100
338
  ## Troubleshooting
101
339
 
@@ -106,9 +344,15 @@ Run `agentkit deploy` before creating hosted channel resources.
106
344
  Set the named hosted secret. Do not add production values to `.env`.
107
345
 
108
346
  `channel_signature_invalid`:
109
- The provider webhook secret/token does not match the managed secret.
347
+ The provider webhook secret, token, origin header, or Discord Ed25519 signature does not match the managed secret.
110
348
 
111
349
  `channel_limit_exceeded`:
112
- The channel daily message limit was reached. Website requests return `429`; Telegram and WhatsApp are acknowledged and skipped to avoid provider retry storms.
350
+ The channel daily message limit was reached. Website requests return `429`; Telegram, WhatsApp, and Discord are acknowledged and skipped to avoid provider retry storms.
351
+
352
+ `transcription_secret_missing`:
353
+ Set the managed transcription secret declared by `agentkit inspect`, for example `OPENAI_API_KEY` or `GROQ_API_KEY`.
354
+
355
+ `transcription_audio_format_unsupported`:
356
+ The channel delivered an audio format the configured transcription provider does not accept. Telegram voice notes are OGG/Opus and work with Groq in V1; OpenAI accepts MP3, MP4, MPEG, MPGA, M4A, WAV, and WEBM in the AgentKit adapter.
113
357
 
114
358
  Buffered messages stay in `buffered` delivery state until the quiet window or max wait flushes them into one queued run.
@@ -77,8 +77,17 @@ agentkit knowledge search "refund policy" --top-k 3
77
77
 
78
78
  `knowledge add` is useful for one-off local indexing. `knowledge sync` validates and indexes all configured `knowledge.sources` on demand. `agentkit dev` and `agentkit chat` also sync configured Knowledge automatically before local runs, and unchanged files are skipped by content hash.
79
79
 
80
+ On Windows PowerShell, if `npm.ps1` is blocked by `PSSecurityException`, run capsule scripts through the `.cmd` shim:
81
+
82
+ ```sh
83
+ npm.cmd run agentkit -- knowledge sync
84
+ npm.cmd run agentkit -- knowledge search "refund policy" --top-k 3
85
+ ```
86
+
80
87
  When embeddings are configured locally, AgentKit stores canonical Knowledge chunks in `.agentkit/agentkit.db` and rebuilds a local libSQL vector sidecar at `.agentkit/agentkit.vectors.db`. Local semantic search uses the sidecar's native `libsql_vector_idx` path and falls back to stored JSON embeddings if the native vector path is unavailable.
81
88
 
89
+ Local lexical search uses SQLite FTS5 when the local SQLite build provides it. If SQLite does not provide FTS5, AgentKit automatically keeps indexing and searching with a normal SQLite table and a simpler text-match fallback.
90
+
82
91
  ## Agent Behavior
83
92
 
84
93
  When `knowledge` is configured, AgentKit automatically registers the internal tool `agentkit_search_knowledge` during chat runs and appends a prompt policy. The policy tells the agent to search before answering business-specific factual questions and not to expose raw retrieval JSON, scores, or chunk IDs.
@@ -131,4 +140,5 @@ Local `agentkit knowledge add`, `agentkit knowledge sync`, `agentkit dev`, and `
131
140
  - `Knowledge source paths must stay inside the Agent Capsule`: move the source under the capsule root, usually `knowledge/`.
132
141
  - `Local Knowledge currently supports .md, .txt, and .csv files`: convert the source or add a tool for unsupported formats.
133
142
  - `Knowledge embeddings require missing secret`: set the env var named by `knowledge.embedding.secret`.
143
+ - `PSSecurityException` on Windows PowerShell: use `npm.cmd run agentkit -- knowledge sync` or `npm.cmd run agentkit -- knowledge search "refund policy" --top-k 3`.
134
144
  - Hosted build says Turso is required: add `storage.database.driver: "turso"` before deploying Knowledge.
@@ -0,0 +1,165 @@
1
+ # Add Managed Composio
2
+
3
+ ## Goal
4
+
5
+ Enable AgentKit-managed Composio for one deployed agent so the agent can use explicitly allowed external app actions without the user owning Composio credentials.
6
+
7
+ Use BYO `defineTool` wrappers instead when the user wants to use their own Composio account/API key for free.
8
+
9
+ ## Contract
10
+
11
+ Managed Composio is paid hosted AgentKit infrastructure:
12
+
13
+ - It works per agent/project, not per client.
14
+ - It requires an AgentKit Cloud account with `managed_composio`.
15
+ - AgentKit Cloud injects `COMPOSIO_API_KEY`; do not put it in `.env`, `.env.schema`, or `agentkit.config.ts`.
16
+ - AgentKit Cloud resolves toolkit auth configs from its managed registry. The capsule owner only declares allowed toolkits/actions.
17
+ - AgentKit Cloud assigns the deployed Composio `user_id` from the account, project, agent, and integration name. The local inspect/build id is only a preview.
18
+ - The agent gets one generated tool, `agentkit_composio_execute`, only when explicit Composio action slugs are configured.
19
+ - Anonymous deploys cannot use managed Composio.
20
+
21
+ ## Minimal Config
22
+
23
+ Edit `agentkit.config.ts`:
24
+
25
+ ```ts
26
+ import { composioManaged, defineAgent } from "@andreprado/agentkit";
27
+
28
+ export default defineAgent({
29
+ name: "acme-receptionist",
30
+ runtime: "edge",
31
+ provider: {
32
+ name: "test",
33
+ model: "fake",
34
+ },
35
+ instructions: "./prompts/instructions.md",
36
+ secrets: [],
37
+ tools: [],
38
+ integrations: [
39
+ composioManaged({
40
+ toolkits: ["gmail", "googlecalendar"],
41
+ tools: {
42
+ gmail: ["GMAIL_FETCH_EMAILS", "GMAIL_SEND_EMAIL"],
43
+ googlecalendar: [
44
+ "GOOGLECALENDAR_EVENTS_LIST",
45
+ "GOOGLECALENDAR_CREATE_EVENT",
46
+ "GOOGLECALENDAR_UPDATE_EVENT",
47
+ ],
48
+ },
49
+ confirmExternalWrites: true,
50
+ }),
51
+ ],
52
+ access: {
53
+ mode: "private",
54
+ },
55
+ storage: {
56
+ driver: "agentkit",
57
+ database: {
58
+ driver: "turso",
59
+ },
60
+ },
61
+ });
62
+ ```
63
+
64
+ ## Deploy
65
+
66
+ ```sh
67
+ agentkit login --token agk_user_...
68
+ agentkit deploy doctor
69
+ agentkit deploy
70
+ agentkit integrations status --toolkit googlecalendar
71
+ ```
72
+
73
+ Expected readiness:
74
+
75
+ - Hosted deploy access is active through `cloudflare_deploy_alpha` or purchased/manual deploy slots.
76
+ - `managed_composio` is active.
77
+ - `COMPOSIO_API_KEY` appears as an AgentKit-managed secret, not a user-managed hosted secret.
78
+ - Each configured toolkit auth config is available in AgentKit Cloud.
79
+
80
+ ## Connect Apps
81
+
82
+ The Composio connect link is deploy-scoped, so declare `composioManaged(...)` first, deploy, then connect. After deploy, create a hosted Composio Connect Link:
83
+
84
+ ```sh
85
+ agentkit integrations connect composio --toolkit gmail
86
+ agentkit integrations connect composio --toolkit googlecalendar
87
+ ```
88
+
89
+ AgentKit prints a URL. Send that URL to the person who owns the app account.
90
+
91
+ If the deploy has only one toolkit, `--toolkit` can be omitted.
92
+
93
+ `agentkit deploy` prints the recommended `integrations connect composio --toolkit <slug>` command for each configured toolkit in its production handoff.
94
+
95
+ ## Calendar Defaults
96
+
97
+ For Google Calendar agents, include read and write actions together. Do not expose only `GOOGLECALENDAR_CREATE_EVENT`; users naturally ask to see availability before booking.
98
+
99
+ Use these starter actions:
100
+
101
+ ```ts
102
+ googlecalendar: [
103
+ "GOOGLECALENDAR_EVENTS_LIST",
104
+ "GOOGLECALENDAR_CREATE_EVENT",
105
+ "GOOGLECALENDAR_UPDATE_EVENT",
106
+ ]
107
+ ```
108
+
109
+ `GOOGLECALENDAR_CREATE_EVENT` requires extra care:
110
+
111
+ - `start_datetime` must be explicit UTC RFC3339, such as `2026-06-03T15:00:00Z` for 12:00 in `America/Sao_Paulo`.
112
+ - `event_duration_minutes` or `event_duration_hour` must be explicit. AgentKit blocks the implicit Composio default because `event_duration_minutes` defaults to 30.
113
+ - Confirm the final title, date, local time, duration, timezone, and attendees/location when relevant before creating or updating an event.
114
+
115
+ ## Write Confirmation
116
+
117
+ Managed Composio requires operator invocation for external write actions. If an integration allows create, update, delete, send, patch, move, insert, clear, remove, import, or quick-add actions, AgentKit blocks that generated tool during model-driven chat, channel, and eval runs. Review the exact action and invoke `agentkit_composio_execute` directly with `agentkit tool`; write actions also require `confirmed: true` by default.
118
+
119
+ `confirmExternalWrites: false` disables only Composio's secondary `confirmed` input check. It does not bypass AgentKit's operator-only permission boundary:
120
+
121
+ ```ts
122
+ composioManaged({
123
+ toolkits: ["googlecalendar"],
124
+ tools: {
125
+ googlecalendar: ["GOOGLECALENDAR_EVENTS_LIST", "GOOGLECALENDAR_CREATE_EVENT"],
126
+ },
127
+ confirmExternalWrites: false,
128
+ })
129
+ ```
130
+
131
+ ## Verification
132
+
133
+ ```sh
134
+ agentkit inspect
135
+ agentkit build --target cloudflare
136
+ agentkit deploy doctor
137
+ agentkit integrations status --toolkit googlecalendar
138
+ ```
139
+
140
+ Expected:
141
+
142
+ - `inspect.integrations[0].provider` is `composio`.
143
+ - `inspect.tools` includes `agentkit_composio_execute` when allowed actions are configured.
144
+ - Build manifest includes `integrations`.
145
+ - Build manifest includes `COMPOSIO_API_KEY`.
146
+ - `deploy doctor` does not ask the user to set `COMPOSIO_API_KEY`.
147
+ - `deploy doctor` reports each configured toolkit auth config as present before the connect link flow.
148
+
149
+ ## Troubleshooting
150
+
151
+ `managed_composio_entitlement_required`:
152
+
153
+ Log in with a paid AgentKit Cloud account that has `managed_composio`.
154
+
155
+ `managed_composio_auth_config_missing`:
156
+
157
+ The AgentKit Cloud account is entitled, but the requested toolkit is not configured in AgentKit Cloud yet. Report the exact error code and toolkit slug to the AgentKit owner.
158
+
159
+ `managed_composio_not_configured`:
160
+
161
+ Managed Composio is not available for this AgentKit Cloud environment. Use BYO `defineTool` wrappers for now or ask the owner to enable managed Composio for the account.
162
+
163
+ `integration_toolkit_required`:
164
+
165
+ The deploy has multiple configured toolkits. Re-run connect with `--toolkit <slug>`.
@@ -8,6 +8,8 @@ Add a TypeScript tool to an Agent Capsule, register it in `agentkit.config.ts`,
8
8
 
9
9
  Use this when the agent needs to call code, read an API, query a database, or perform a small action behind a typed contract.
10
10
 
11
+ For requests such as “use Jev to qualify leads” or “use TypeSafe to rank candidates,” follow [Use Jev](use-jev.md) and adapt the bundled tool example to the requested behavior.
12
+
11
13
  ## Commands
12
14
 
13
15
  From a capsule root:
@@ -112,6 +114,8 @@ Direct tool test:
112
114
  npm run agentkit -- tool lookup_order --input '{"orderId":"A100"}'
113
115
  ```
114
116
 
117
+ When the tool touches live data, writes externally, or enforces business rules, also add deterministic checks. Use fixtures, eval-safe branches, seed data, or direct tool inputs for success and failure paths such as missing confirmation, validation errors, provider 429s/timeouts, unavailable records, and privacy/no-leak behavior. Add an eval when the agent should call the tool with specific inputs or refuse to call it until required intake or confirmation is complete.
118
+
115
119
  Expected output:
116
120
 
117
121
  ```json
@@ -129,9 +133,10 @@ Use this when a tool needs agent-owned tables and must work locally and after de
129
133
 
130
134
  Recommended contract:
131
135
 
132
- - Put all agent-owned tables in `schema.sql`.
136
+ - Put the idempotent bootstrap view of agent-owned tables in `schema.sql`.
137
+ - For production-shaped schema evolution, add ordered `migrations/*.sql` files such as `migrations/0001_clients.sql`.
133
138
  - Keep deploy-ready capsules on `storage.driver: "agentkit"`.
134
- - Local `agentkit chat`, `agentkit tool`, `agentkit dev`, and eval runs apply `schema.sql` to local development storage.
139
+ - Local `agentkit chat`, `agentkit tool`, `agentkit dev`, and eval runs apply ordered local migrations before `schema.sql`.
135
140
  - Use `agentkit db migrate`, `agentkit db reset --yes`, `agentkit db seed [--file seed.sql]`, and `agentkit db shell` for local database setup and inspection.
136
141
  - Hosted deploy migrates/provisions the managed database internally and applies the same `schema.sql`.
137
142
  - Tools use `ctx.db` as the canonical helper. `ctx.database` and `ctx.storage.sql` are supported aliases.
@@ -176,7 +181,7 @@ CREATE TABLE IF NOT EXISTS appointments (
176
181
  );
177
182
  ```
178
183
 
179
- `schema.sql` is an idempotent bootstrap file in v1. Prefer `CREATE TABLE IF NOT EXISTS`, `CREATE INDEX IF NOT EXISTS`, and safe additive `ALTER TABLE` statements. AgentKit does not run destructive schema changes or ordered `migrations/*.sql` automatically yet.
184
+ `schema.sql` is an idempotent bootstrap file. Prefer `CREATE TABLE IF NOT EXISTS`, `CREATE INDEX IF NOT EXISTS`, and safe additive `ALTER TABLE` statements. Use ordered `migrations/*.sql` for production-shaped schema evolution; `agentkit db migrate` applies unapplied local migrations before `schema.sql`.
180
185
 
181
186
  `tools/schedule-appointment.ts`:
182
187
 
@@ -262,6 +267,8 @@ Use it for diagnostics only, not for bypassing AgentKit runtime services or choo
262
267
  - Do not read arbitrary `process.env` inside tools.
263
268
  - Use `ctx.secrets.SECRET_NAME`.
264
269
  - Set `timeoutMs` for slow external calls.
270
+ - End read-only permissions with `:read`, for example `crm:contacts:read`.
271
+ - Declare writes, sends, deletes, payments, or broad external calls with a non-read permission such as `email:send`. AgentKit blocks those permissions during model-driven chat, channel, and eval runs; the local operator must review and invoke the exact call with `agentkit tool`.
265
272
  - Set `visibility: "internal"` for operational outputs such as classifications, scores, routing labels, fraud decisions, or other fields the agent should persist but not reveal literally to the user.
266
273
  - Do not log secret values.
267
274