@andreprado/agentkit 0.1.1 → 0.2.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 (95) hide show
  1. package/README.md +8 -77
  2. package/docs/guides/add-channel.md +14 -92
  3. package/docs/guides/add-knowledge.md +0 -21
  4. package/docs/guides/add-tool.md +5 -11
  5. package/docs/guides/channel-security.md +3 -207
  6. package/docs/guides/connect-discord.md +7 -172
  7. package/docs/guides/connect-slack.md +6 -121
  8. package/docs/guides/connect-telegram.md +6 -165
  9. package/docs/guides/connect-whatsapp-evolution.md +6 -116
  10. package/docs/guides/connect-whatsapp-uazapi.md +6 -134
  11. package/docs/guides/connect-whatsapp-zapster.md +6 -202
  12. package/docs/guides/create-agent.md +5 -14
  13. package/docs/guides/debug-channel.md +4 -156
  14. package/docs/guides/improve-local.md +13 -0
  15. package/docs/guides/local-only-migration.md +35 -0
  16. package/docs/guides/replay-local-traces.md +11 -0
  17. package/docs/guides/run-evals.md +2 -4
  18. package/docs/guides/security-rules.md +5 -154
  19. package/docs/guides/use-jev.md +3 -6
  20. package/docs/guides/use-provider.md +0 -3
  21. package/docs/guides/write-feedback.md +10 -0
  22. package/docs/llms-full.txt +27 -448
  23. package/docs/llms.txt +8 -44
  24. package/package.json +2 -4
  25. package/src/cli/commands/channels.ts +8 -1613
  26. package/src/cli/commands/feedback.ts +8 -86
  27. package/src/cli/constants.ts +0 -3
  28. package/src/cli/flags.ts +0 -28
  29. package/src/cli/help.ts +16 -92
  30. package/src/cli/index.ts +15 -1091
  31. package/src/index.ts +6 -158
  32. package/src/providers/pi.ts +2 -0
  33. package/src/runtime/channels/discord.ts +2 -2
  34. package/src/runtime/chat.ts +5 -3
  35. package/src/runtime/config.ts +14 -148
  36. package/src/runtime/database.ts +2 -2
  37. package/src/runtime/dev-server.ts +8 -8
  38. package/src/runtime/env.ts +11 -0
  39. package/src/runtime/improve.ts +2 -262
  40. package/src/runtime/inspect.ts +13 -73
  41. package/src/runtime/knowledge/ingest.ts +1 -1
  42. package/src/runtime/knowledge/tool.ts +16 -2
  43. package/src/runtime/knowledge/vector.ts +1 -1
  44. package/src/runtime/tool-runner.ts +5 -3
  45. package/src/runtime/tools.ts +10 -14
  46. package/src/storage/sqlite.ts +11 -32
  47. package/src/templates/blank.ts +15 -102
  48. package/src/templates/common.ts +60 -0
  49. package/src/templates/dentista.ts +7 -74
  50. package/src/templates/skills/agentkit-capsule/SKILL.md +5 -7
  51. package/src/templates/skills/agentkit-capsule/references/docs-router.md +2 -3
  52. package/src/templates/skills/agentkit-channels/SKILL.md +6 -119
  53. package/src/templates/skills/agentkit-channels/references/channel-buffering.md +0 -9
  54. package/src/templates/skills/agentkit-channels/references/channel-debugging.md +1 -64
  55. package/src/templates/skills/agentkit-channels/references/discord.md +2 -92
  56. package/src/templates/skills/agentkit-channels/references/slack.md +2 -55
  57. package/src/templates/skills/agentkit-channels/references/telegram.md +2 -71
  58. package/src/templates/skills/agentkit-channels/references/whatsapp-evolution.md +2 -56
  59. package/src/templates/skills/agentkit-channels/references/whatsapp-uazapi.md +2 -53
  60. package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +2 -70
  61. package/src/templates/skills/agentkit-database/SKILL.md +2 -4
  62. package/src/templates/skills/agentkit-evals/SKILL.md +1 -1
  63. package/src/templates/skills/agentkit-improve/SKILL.md +6 -85
  64. package/src/templates/skills/agentkit-improve/references/trace-packets.md +1 -1
  65. package/src/templates/skills/agentkit-provider/SKILL.md +0 -1
  66. package/src/templates/skills/agentkit-security/SKILL.md +1 -3
  67. package/src/templates/skills/agentkit-tools/SKILL.md +1 -1
  68. package/src/templates/skills/agentkit-tools/examples/database-write.tool.md +1 -2
  69. package/src/templates/skills/agentkit-troubleshooting/SKILL.md +5 -11
  70. package/src/templates/support.ts +8 -92
  71. package/docs/guides/add-managed-composio.md +0 -165
  72. package/docs/guides/improve-from-production.md +0 -151
  73. package/docs/guides/prepare-deploy.md +0 -227
  74. package/docs/guides/replay-production-traces.md +0 -72
  75. package/docs/guides/send-feedback.md +0 -135
  76. package/src/cli/cloud-client.ts +0 -377
  77. package/src/cli/deploy-chat-ui.ts +0 -606
  78. package/src/cli/deploy-readiness.ts +0 -561
  79. package/src/cloud/artifact.ts +0 -139
  80. package/src/cloud/client.ts +0 -80
  81. package/src/cloud/contracts.ts +0 -63
  82. package/src/cloud/index.ts +0 -3
  83. package/src/runtime/build.ts +0 -43
  84. package/src/runtime/core/deploy-state.ts +0 -54
  85. package/src/runtime/core/manifest.ts +0 -283
  86. package/src/runtime/core/targets.ts +0 -133
  87. package/src/runtime/deploy-readiness.ts +0 -135
  88. package/src/runtime/deploy.ts +0 -1
  89. package/src/runtime/integrations/composio.ts +0 -425
  90. package/src/runtime/targets/cloudflare/build.ts +0 -3319
  91. package/src/runtime/targets/container/build.ts +0 -146
  92. package/src/runtime/targets/container/server.ts +0 -33
  93. package/src/runtime/targets/vps/deploy.ts +0 -223
  94. package/src/templates/skills/agentkit-deploy/SKILL.md +0 -52
  95. package/src/templates/skills/agentkit-integrations/SKILL.md +0 -98
@@ -37,8 +37,6 @@ agentkit new [name] [--template blank|support|dentista] [--no-install]
37
37
  agentkit new .
38
38
  agentkit dev [--port <number>]
39
39
  agentkit open
40
- agentkit chat-ui --deploy
41
- agentkit chat-ui --deploy [--port <number>] [--token-file <path>]
42
40
  agentkit chat --message <text> [--conversation-id <id>]
43
41
  agentkit tool <name> [--input <path-or-json>]
44
42
  agentkit knowledge add <path-or-url>
@@ -51,57 +49,20 @@ agentkit db shell
51
49
  agentkit db seed [--file <path>]
52
50
  agentkit eval run
53
51
  agentkit eval from-conversation <conversation-id> [--out <path>] [--force]
54
- agentkit improve collect [--deploy] [--since <duration|iso>] [--conversation-id <id>] [--out <directory>]
52
+ agentkit improve collect [--since <duration|iso>] [--conversation-id <id>] [--out <directory>]
55
53
  agentkit improve evals <bundle-dir-or-json> [--force]
56
54
  agentkit replay <bundle-dir-or-json> --against local
57
- agentkit feedback create [--about last-run|deploy|manual] [--kind bug|confusion|missing_docs|feature_request|deploy_issue|runtime_issue|other] --summary <text> [--message <text>] [--out <path>]
55
+ agentkit feedback create [--about last-run|manual] [--kind bug|confusion|missing_docs|feature_request|runtime_issue|other] --summary <text> [--message <text>] [--out <path>]
58
56
  agentkit feedback preview [draft.json]
59
- agentkit feedback send [draft.json] [--about last-run|deploy|manual] [--kind <kind>] --summary <text> [--message <text>] [--api <url>] [--save]
60
57
  agentkit conversations list
61
58
  agentkit conversations show <conversation-id>
62
- agentkit conversations trace <conversation-id> [--deploy]
59
+ agentkit conversations trace <conversation-id>
63
60
  agentkit channels list
64
- agentkit channels add <website|telegram|whatsapp|discord|slack|webhook> <name> [--provider zapster|meta|uazapi|evolution] [--mode interactions|bot] [--api <url>]
65
- agentkit channels connect <website|telegram|whatsapp|discord|slack|webhook> <name> [--provider zapster|meta|uazapi|evolution] [--mode interactions|bot] [--api <url>]
66
- agentkit channels setup <name> [--apply] [--api <url>]
67
- agentkit channels status <name> [--api <url>]
68
- agentkit channels test <name> [--message <text>] [--fixture <path>] [--api <url>]
69
- agentkit channels test-audio <name> [--fixture voice-note|audio-file|<path>] [--api <url>]
70
- agentkit channels deliveries list <name> [--api <url>]
71
- agentkit channels deliveries show <delivery-id> [--api <url>]
72
- agentkit integrations status [--toolkit <slug>] [--api <url>]
73
- agentkit integrations connect composio [--toolkit <slug>] [--callback-url <url>] [--api <url>]
74
61
  agentkit skills status
75
62
  agentkit skills sync
76
63
  agentkit inspect
77
- agentkit build [--target cloudflare|container]
78
- agentkit billing checkout --slots <count> [--email <email>] [--api <url>]
79
- agentkit billing status <billing-intent-id> --secret <secret> [--api <url>]
80
- agentkit billing claim <billing-intent-id> --secret <secret> [--token-name <name>] [--api <url>]
81
- agentkit billing portal [--api <url>]
82
64
  agentkit provider login|status|logout openai-codex
83
- agentkit login --token <token>
84
- agentkit logout
85
- agentkit account token create <name> [--api <url>] [--use] [--out <path>]
86
- agentkit account token list [--api <url>]
87
- agentkit account token revoke <token-id> [--api <url>]
88
- agentkit deploy [--target cloudflare|vps] [--host <host>] [--api <url>] [--dry-run] [--anonymous] [--local-wrangler] [--smoke <message>]
89
- agentkit deploy doctor [--api <url>] [--anonymous]
90
- agentkit deploy smoke [--message <text>] [--api <url>]
91
- agentkit deploy status
92
- agentkit deploy pause
93
- agentkit deploy resume
94
65
  agentkit transcribe smoke [--provider test|openai|groq] [--model <model>] [--fixture <audio-file>]
95
- agentkit secret set <NAME> <VALUE>
96
- agentkit secret set <NAME> --stdin
97
- agentkit secret set <NAME> --from-env [ENV_NAME]
98
- agentkit secret set <NAME> --from-local-env
99
- agentkit secret sync --from-local
100
- agentkit secret list
101
- agentkit secret unset <NAME>
102
- agentkit access token create <name> [--api <url>] [--out <path>]
103
- agentkit access token list
104
- agentkit access token revoke <token-id>
105
66
  agentkit env set <NAME> <VALUE>
106
67
  agentkit env set <NAME> --stdin
107
68
  agentkit env set <NAME> --from-env [ENV_NAME]
@@ -115,13 +76,12 @@ agentkit handoff claude [goal]
115
76
  agentkit help commands
116
77
  ```
117
78
 
118
- Prefer `env set --stdin` or `--from-env` for local secret values, and prefer `secret set --stdin`, `--from-env`, or `--from-local-env` for hosted secrets. Inline `<VALUE>` forms exist for simple non-sensitive values, but agents should avoid putting secrets in shell history.
79
+ Keep secrets in ignored `.env`. Prefer `agentkit env set <NAME> --stdin` or `--from-env`; never put values in shell history or committed files.
119
80
 
120
- Use `agentkit feedback create` when AgentKit itself fails, confuses the coding agent, or lacks docs. Drafts are local files under `.agentkit/feedback/` and are not sent automatically. Use `agentkit feedback send` only after reviewing the draft and logging in with `agentkit login --token agk_user_...`. Feedback upload uses authenticated AgentKit Cloud account auth, redacts common token/key patterns, does not upload arbitrary files, and does not cause the deployed agent runtime to phone home.
81
+ Use `agentkit feedback create` and `preview` to prepare a local redacted report. Review and share it manually; no report is uploaded.
121
82
 
122
83
  On Windows PowerShell, if `npm.ps1` or `npx.ps1` is blocked with `PSSecurityException`, run capsule scripts through the `.cmd` shims instead of changing the workflow. Examples: `npx.cmd @andreprado/agentkit@alpha new demo --template blank`, `npm.cmd run agentkit -- inspect`, `npm.cmd run agentkit -- knowledge sync`, and `npm.cmd run eval`.
123
84
 
124
- Managed Composio is configured with `composioManaged({...})` in `agentkit.config.ts` and is paid hosted AgentKit infrastructure. It requires a non-anonymous AgentKit Cloud deploy with `managed_composio`, uses one Composio settings profile per agent, injects `COMPOSIO_API_KEY` as an AgentKit-managed secret, resolves toolkit auth configs from AgentKit Cloud, validates toolkit readiness during `agentkit deploy doctor`, and exposes the generated `agentkit_composio_execute` tool only for explicit configured action slugs. Calendar starters should include `GOOGLECALENDAR_EVENTS_LIST`, `GOOGLECALENDAR_CREATE_EVENT`, and `GOOGLECALENDAR_UPDATE_EVENT`; create-event calls must pass UTC `start_datetime` plus explicit duration. An integration containing external write actions is operator-only; invoke it directly with `agentkit tool`, and pass `confirmed: true` for writes unless the integration disables that secondary check. See `docs/guides/add-managed-composio.md`.
125
85
 
126
86
  ## Create And Test A Capsule
127
87
 
@@ -176,7 +136,7 @@ npm run agentkit -- handoff claude "Develop an appointment and intake agent for
176
136
 
177
137
  The command prints a ready-to-paste prompt that points the coding agent at `AGENTKIT.md`, the repo-local `skills/agentkit-capsule/SKILL.md` router when present, and the packaged `llms.txt` docs router. Load `llms-full.txt` only when a skill or ambiguous framework behavior requires the complete contract.
178
138
 
179
- The generated docs and handoff prompt must make UI testing explicit. For local UI testing, run `npm run dev`, open the printed `Chat:` URL, and tell the owner the exact URL. For hosted UI testing after deploy, run `npm run agentkit -- chat-ui --deploy`, open the printed `Chat:` URL, and tell the owner it is connected to the hosted deploy.
139
+ The generated docs and handoff prompt must make UI testing explicit. For local UI testing, run `npm run dev`, open the printed `Chat:` URL, and tell the owner the exact URL.
180
140
 
181
141
  ## Agent Config
182
142
 
@@ -187,7 +147,7 @@ import { defineAgent } from "@andreprado/agentkit";
187
147
 
188
148
  export default defineAgent({
189
149
  name: "support-agent",
190
- runtime: "edge",
150
+ runtime: "local",
191
151
  provider: {
192
152
  name: "test",
193
153
  model: "fake",
@@ -255,9 +215,9 @@ secrets: [],
255
215
 
256
216
  `test/fake` is deterministic. It is useful for scaffold checks, direct tool checks, and fake-provider evals, but it does not validate natural conversation quality.
257
217
 
258
- Before claiming real conversation behavior has been tested, ask the owner which provider to use: OpenRouter, OpenAI, Anthropic, OpenCode Zen, OpenCode Go, or another supported provider. Do not choose for them. After the owner chooses, update `agentkit.config.ts`, `.env.schema`, local secrets, hosted secrets if deploying, then rerun chat/UI checks.
218
+ Before claiming real conversation behavior has been tested, ask the owner which provider to use: OpenRouter, OpenAI, Anthropic, OpenCode Zen, OpenCode Go, or another supported provider. Do not choose for them. After the owner chooses, update `agentkit.config.ts`, `.env.schema`, local secrets, then rerun chat/UI checks.
259
219
 
260
- ChatGPT/Codex subscription login (local only): run `agentkit provider login openai-codex` in an interactive terminal, sign in through the printed URL, and set `provider: { name: "openai-codex", model: "gpt-5.4" }`. No `OPENAI_API_KEY` is required for this provider. Keep secrets needed by tools or other services. The AgentKit session is stored outside capsules in `~/.agentkit/providers/openai-codex.json`, renewed through Pi, and never copied from or into the Codex app cache. `agentkit provider status openai-codex` reports local status without tokens; `agentkit provider logout openai-codex` removes the local session without revoking it at OpenAI. Cloudflare, container, and VPS builds reject this provider with `target_runtime_incompatible`; hosted OAuth is not supported. See `docs/guides/use-provider.md`.
220
+ ChatGPT/Codex subscription login (local only): run `agentkit provider login openai-codex` in an interactive terminal, sign in through the printed URL, and set `provider: { name: "openai-codex", model: "gpt-5.4" }`. No `OPENAI_API_KEY` is required for this provider. Keep secrets needed by tools or other services. The AgentKit session is stored outside capsules in `~/.agentkit/providers/openai-codex.json`, renewed through Pi, and never copied from or into the Codex app cache. `agentkit provider status openai-codex` reports local status without tokens; `agentkit provider logout openai-codex` removes the local session without revoking it at OpenAI. See `docs/guides/use-provider.md`.
261
221
 
262
222
  OpenAI example:
263
223
 
@@ -369,236 +329,39 @@ Expected output:
369
329
  Tool agentkit_search_knowledge: completed
370
330
  ```
371
331
 
372
- Cloudflare Knowledge deploys require `storage.driver: "agentkit"` and `storage.database.driver: "turso"`. `agentkit deploy doctor` and `agentkit build --target cloudflare` fail clearly when Knowledge is configured without Turso. Cloudflare artifacts include the Knowledge manifest, required embedding secret names, internal Knowledge schema, packaged local source contents, prompt policy, and hosted `agentkit_search_knowledge` runtime. During `agentkit deploy`, AgentKit Cloud applies the Knowledge schema, chunks packaged local sources, creates embeddings when configured, deletes stale hosted sources, and syncs sources, chunks, embedding metadata, FTS rows, and a native Turso `libsql_vector_idx` index into the project Turso database before publishing the Worker. Local `agentkit knowledge add/sync`, `agentkit dev`, and `agentkit chat` index configured Knowledge into local SQLite and the local libSQL vector sidecar; hosted deploy syncs configured local Knowledge sources automatically from the deploy artifact so private source material and embedding secrets do not move into client code. Hosted semantic search uses Turso native vector search when embeddings are configured and falls back to stored JSON embeddings if the native vector path is unavailable.
373
-
374
332
  Full guide: `docs/guides/add-knowledge.md`.
375
333
 
376
334
  ## Channel Contract
377
335
 
378
- Channels are hosted inbound/outbound conversation transports. They are separate from tools: channels receive user messages, while tools let the agent call external systems.
379
-
380
- Use these helpers in `agentkit.config.ts`:
336
+ Configure channels in `agentkit.config.ts` with `runtime: "local"`. Channels receive messages; tools let an agent call external systems. Helpers include `websiteChannel`, `telegramChannel`, `whatsappChannel`, `discordChannel`, `slackChannel`, `webhookChannel`, and `webhookOutputChannel`.
381
337
 
382
338
  ```ts
383
- import { defineAgent, discordChannel, slackChannel, telegramChannel, webhookChannel, webhookOutputChannel, whatsappChannel, websiteChannel } from "@andreprado/agentkit";
339
+ import { defineAgent, webhookChannel } from "@andreprado/agentkit";
384
340
 
385
341
  export default defineAgent({
386
- name: "support-agent",
387
- runtime: "edge",
342
+ name: "local-agent",
343
+ runtime: "local",
388
344
  provider: { name: "test", model: "fake" },
389
345
  instructions: "./prompts/instructions.md",
390
346
  secrets: [],
391
347
  tools: [],
392
- channels: [
393
- websiteChannel({ name: "website-chat" }),
394
- telegramChannel({ name: "support-telegram" }),
395
- whatsappChannel({ name: "support-whatsapp", provider: "zapster" }),
396
- whatsappChannel({ name: "support-uazapi", provider: "uazapi" }),
397
- discordChannel({ name: "support-discord" }),
398
- discordChannel({ name: "server-discord", mode: "bot" }),
399
- slackChannel({ name: "support-slack" }),
400
- webhookChannel({ name: "n8n-webhook" }),
401
- webhookOutputChannel({ name: "crm-callback", urlSecret: "CRM_CALLBACK_URL" }),
402
- ],
403
- access: { mode: "public" },
348
+ channels: [webhookChannel({ name: "inbox" })],
349
+ access: { mode: "private" },
404
350
  storage: { driver: "agentkit" },
405
351
  });
406
352
  ```
407
353
 
408
- Rules:
409
-
410
- - `runtime: "edge"` is required when `channels` are configured.
411
- - Channel names are stable lowercase identifiers and must be unique.
412
- - Config stores secret names only, never secret values.
413
- - UAZAPI and Zapster WhatsApp channels require `UAZAPI_WEBHOOK_TOKEN` and `ZAPSTER_WEBHOOK_TOKEN`; webhooks without the matching query token are rejected.
414
- - AgentKit owns channel webhook URLs, dedupe, identities, queue state, and delivery logs.
415
- - Do not store channel plumbing in the user's Turso database.
416
- - Use `buffer.mode: "debounce"` when a channel should coalesce rapid client messages into one agent run.
417
- - Buffered deliveries show `buffered`, then flush to one `queued` run after `quietWindowMs`, `maxWaitMs`, `maxMessages`, or `maxChars`.
418
- - Use `replyTo` when an inbound channel should receive on one transport and answer on another configured channel.
419
- - Use `webhookOutputChannel` when the reply target is a generic HTTPS callback URL stored in a managed secret.
420
-
421
- Channel buffer example:
422
-
423
- ```ts
424
- whatsappChannel({
425
- name: "support-whatsapp",
426
- provider: "zapster",
427
- buffer: {
428
- mode: "debounce",
429
- quietWindowMs: 2500,
430
- maxWaitMs: 12000,
431
- maxMessages: 20,
432
- maxChars: 8000,
433
- },
434
- })
435
- ```
436
-
437
- Useful guides:
438
-
439
- - Add a channel: `docs/guides/add-channel.md`
440
- - Connect Discord: `docs/guides/connect-discord.md`
441
- - Connect Slack: `docs/guides/connect-slack.md`
442
- - Connect Telegram: `docs/guides/connect-telegram.md`
443
- - Connect WhatsApp through Evolution API: `docs/guides/connect-whatsapp-evolution.md`
444
- - Connect WhatsApp through UAZAPI: `docs/guides/connect-whatsapp-uazapi.md`
445
- - Connect WhatsApp through Zapster: `docs/guides/connect-whatsapp-zapster.md`
446
- - Debug a channel: `docs/guides/debug-channel.md`
447
- - Channel security: `docs/guides/channel-security.md`
448
-
449
- Telegram required secrets:
450
-
451
- ```txt
452
- TELEGRAM_BOT_TOKEN
453
- TELEGRAM_WEBHOOK_SECRET
454
- ```
455
-
456
- Zapster WhatsApp required secrets:
457
-
458
- ```txt
459
- ZAPSTER_API_KEY
460
- ZAPSTER_INSTANCE_ID
461
- ZAPSTER_WEBHOOK_ID
462
- ZAPSTER_WEBHOOK_TOKEN
463
- ```
464
-
465
- UAZAPI WhatsApp required secrets:
466
-
467
- ```txt
468
- UAZAPI_BASE_URL
469
- UAZAPI_TOKEN
470
- UAZAPI_WEBHOOK_TOKEN
471
- ```
472
-
473
- `UAZAPI_WEBHOOK_TOKEN` and `ZAPSTER_WEBHOOK_TOKEN` are AgentKit-owned secrets generated by the user, not provider-issued credentials. For local `agentkit dev`, expose the printed port through an HTTPS tunnel and register the exact `/channels/<name>/whatsapp/<provider>/webhook?token=<secret>` URL. Only authenticated channel webhook routes accept a tunnel host; other local endpoints remain loopback-only.
474
-
475
- Evolution API WhatsApp required secrets:
476
-
477
- ```txt
478
- EVOLUTION_API_BASE_URL
479
- EVOLUTION_API_KEY
480
- EVOLUTION_INSTANCE_NAME
481
- EVOLUTION_WEBHOOK_TOKEN
482
- ```
483
-
484
- Discord slash-command required secret:
485
-
486
- ```txt
487
- DISCORD_PUBLIC_KEY
488
- ```
489
-
490
- Discord bot-mode required secret:
491
-
492
- ```txt
493
- DISCORD_BOT_TOKEN
494
- ```
495
-
496
- Generic webhook required secret:
354
+ Run `agentkit env set AGENTKIT_WEBHOOK_SECRET --stdin`, `agentkit channels list`, and `agentkit dev`. POST authenticated fixtures to `/channels/inbox/webhook`. Generic webhooks accept bearer/header secrets or raw-body HMAC. Other providers use `/channels/<name>/<type>/<provider>/webhook` and their own signature/token contracts.
497
355
 
498
- ```txt
499
- AGENTKIT_WEBHOOK_SECRET
500
- ```
501
-
502
- Generic webhook payloads should be canonical JSON:
503
-
504
- ```json
505
- {
506
- "event_id": "evt_123",
507
- "external_id": "customer_123",
508
- "message": "hello from n8n"
509
- }
510
- ```
511
-
512
- Use `Authorization: Bearer <AGENTKIT_WEBHOOK_SECRET>`, `X-AgentKit-Webhook-Secret`, or `X-AgentKit-Webhook-Signature: sha256=<hmac>` where the HMAC is SHA-256 over the exact raw JSON body. The hosted URL is `/channels/<name>/webhook`.
513
-
514
- Without `replyTo`, generic webhooks are inbound-only and do not call back into the source system. To receive on one channel and answer on another, add a static `replyTo` route:
356
+ Only authenticated channel webhook routes accept public HTTPS tunnel hosts. Non-webhook APIs stay loopback-only. Register provider webhooks manually, and keep the local process running. The dev UI supports chat; it does not include a channel dashboard. Inspect webhook responses and `agentkit conversations trace <id>` for diagnostics.
515
357
 
516
- ```ts
517
- webhookChannel({
518
- name: "lead-webhook",
519
- replyTo: {
520
- channel: "main-whatsapp",
521
- recipientFrom: "phone",
522
- },
523
- })
524
-
525
- whatsappChannel({
526
- name: "main-whatsapp",
527
- provider: "evolution",
528
- })
529
- ```
530
-
531
- `recipientFrom` is a dotted JSON path such as `phone`, `customer.phone`, or `payload.customer.phone`. It must resolve to a non-empty scalar in the inbound payload. Do not use `recipientFrom` for Discord or Slack replies because those transports need provider-native source identities.
358
+ Buffers and duplicate tracking are in-memory and best-effort. Restarting the process loses pending buffered messages and deduplication state. There is no durable queue, retry worker, or buffer-management API. Discord interaction replies run inline and can exceed Discord's deadline with slow providers. No Discord Gateway worker is included; bot-mode events require an external bridge.
532
359
 
533
- Multiple webhooks are multiple named channels:
360
+ Declare secret names through channel helpers and store values in ignored `.env`. Use `replyTo` to route replies to another configured channel, and `webhookOutputChannel` for public HTTPS callback destinations. Output URLs and auth values come from local secrets; SSRF guards reject private-network targets.
534
361
 
535
- ```ts
536
- webhookChannel({ name: "n8n-webhook" })
537
- webhookChannel({ name: "make-webhook" })
538
- webhookChannel({ name: "crm-webhook", replyTo: { channel: "main-whatsapp", recipientFrom: "phone" } })
539
- ```
540
-
541
- Generic output webhook channels send the final agent answer to an HTTPS callback URL:
362
+ Telegram and WhatsApp adapters support configured audio transcription. Declare top-level `transcription` and channel `audio: { mode: "transcribe" }`. Media download and transcription run locally with the configured external provider. Signature checks, trusted download origins, and byte/duration limits still apply. Discord and Slack audio are unsupported.
542
363
 
543
- ```ts
544
- webhookOutputChannel({
545
- name: "crm-callback",
546
- urlSecret: "CRM_CALLBACK_URL",
547
- auth: {
548
- type: "bearer",
549
- tokenSecret: "CRM_CALLBACK_TOKEN",
550
- },
551
- })
552
-
553
- webhookChannel({
554
- name: "n8n-webhook",
555
- replyTo: {
556
- channel: "crm-callback",
557
- recipientFrom: "crm_id",
558
- },
559
- })
560
- ```
561
-
562
- `CRM_CALLBACK_URL` and output auth values are managed secrets only. The URL must be public HTTPS; AgentKit rejects localhost, private network, link-local, and metadata-service hosts. Supported output auth modes are `none`, `bearer`, `header`, and `hmac`. Generic output channels do not have public inbound webhook URLs, so `agentkit channels test <output-name>` is unsupported.
563
-
564
- Common channel verification:
565
-
566
- ```sh
567
- agentkit inspect
568
- agentkit deploy
569
- agentkit channels list
570
- agentkit channels add telegram support-telegram
571
- agentkit channels connect whatsapp main-whatsapp --provider evolution
572
- agentkit channels connect whatsapp support-whatsapp --provider uazapi
573
- agentkit channels connect discord support-discord
574
- agentkit channels connect discord server-discord --mode bot
575
- agentkit channels connect slack support-slack
576
- agentkit channels connect webhook n8n-webhook
577
- agentkit channels setup support-telegram
578
- agentkit channels test support-telegram --message "hello"
579
- agentkit channels test-audio support-telegram --fixture voice-note
580
- agentkit transcribe smoke --provider groq
581
- agentkit channels deliveries list support-telegram
582
- agentkit channels deliveries show <delivery-id>
583
- ```
584
-
585
- `channels connect` creates or refreshes the channel resource, validates secrets, runs provider setup when supported, then runs the official synthetic smoke. `channels setup` is read-only by default. `channels setup <telegram-name> --apply` calls Telegram `setWebhook` and requires `TELEGRAM_BOT_TOKEN` plus `TELEGRAM_WEBHOOK_SECRET`. `channels setup <uazapi-whatsapp-name> --apply` calls UAZAPI `/webhook` and requires `UAZAPI_BASE_URL`, `UAZAPI_TOKEN`, and `UAZAPI_WEBHOOK_TOKEN`. `channels setup <evolution-whatsapp-name> --apply` calls Evolution API `/webhook/set/{instance}` and requires `EVOLUTION_API_BASE_URL`, `EVOLUTION_API_KEY`, `EVOLUTION_INSTANCE_NAME`, and `EVOLUTION_WEBHOOK_TOKEN`.
586
-
587
- Discord slash-command mode validates `X-Signature-Ed25519` and `X-Signature-Timestamp` against `DISCORD_PUBLIC_KEY`, answers signed `PING` requests with `type: 1`, acknowledges slash commands with a deferred response, then sends the final answer as an interaction follow-up. Discord bot mode uses `DISCORD_BOT_TOKEN`, Discord Gateway `MESSAGE_CREATE`, Message Content Intent, and `/channels/<channel_id>/messages` bot replies. Discord channels support buffering but do not support `audio` in V1.
588
-
589
- Default tests are offline. Real provider smoke tests are opt-in:
590
-
591
- ```sh
592
- AGENTKIT_RUN_TELEGRAM_CHANNEL_TESTS=1 bun test
593
- AGENTKIT_RUN_ZAPSTER_CHANNEL_TESTS=1 bun test
594
- AGENTKIT_RUN_UAZAPI_CHANNEL_TESTS=1 bun test
595
- AGENTKIT_RUN_EVOLUTION_CHANNEL_TESTS=1 bun test
596
- ```
597
-
598
- Telegram smoke also requires `TELEGRAM_BOT_TOKEN`, `TELEGRAM_WEBHOOK_SECRET`, and `AGENTKIT_TELEGRAM_WEBHOOK_URL`.
599
- Zapster smoke also requires `ZAPSTER_API_KEY`, `ZAPSTER_WEBHOOK_TOKEN`, `AGENTKIT_ZAPSTER_SEND_URL`, and `AGENTKIT_ZAPSTER_TO`.
600
- UAZAPI smoke also requires `UAZAPI_BASE_URL`, `UAZAPI_TOKEN`, `UAZAPI_WEBHOOK_TOKEN`, and `AGENTKIT_UAZAPI_TO`.
601
- Evolution smoke also requires `EVOLUTION_API_BASE_URL`, `EVOLUTION_API_KEY`, `EVOLUTION_INSTANCE_NAME`, and `AGENTKIT_EVOLUTION_TO`.
364
+ See `docs/guides/add-channel.md`, the provider-specific guides, `docs/guides/channel-security.md`, and `docs/guides/debug-channel.md` for setup and verification.
602
365
 
603
366
  ## Tool Contract
604
367
 
@@ -666,7 +429,7 @@ Tool runtime rules:
666
429
  - tools can use `ctx.clock` for the same runtime clock injected into the agent prompt, including `now`, `isoTimestamp`, `timeZone`, `localDate`, `localWeekday`, and `localDateTime`;
667
430
  - tools must not import local database drivers or Node-only APIs. Use AgentKit runtime services instead.
668
431
 
669
- ## Database Tools And Dual Storage
432
+ ## Database Tools And Local Storage
670
433
 
671
434
  For agent-owned application tables, `schema.sql` is the single source of truth.
672
435
 
@@ -678,12 +441,6 @@ Local behavior:
678
441
  - before a tool runs, AgentKit applies `schema.sql` locally;
679
442
  - use `agentkit db migrate`, `agentkit db reset --yes`, `agentkit db seed [--file seed.sql]`, and `agentkit db shell` for local setup and inspection.
680
443
 
681
- Hosted behavior:
682
-
683
- - `agentkit deploy` builds and deploys the capsule;
684
- - AgentKit migrates/provisions hosted storage internally and applies the same `schema.sql`;
685
- - the user should not create hosted databases, buckets, or runtimes manually.
686
-
687
444
  Example `schema.sql`:
688
445
 
689
446
  ```sql
@@ -772,61 +529,7 @@ Agent-owned tables from `schema.sql` live in the same SQLite file locally. Runti
772
529
 
773
530
  ## Inspect Contract
774
531
 
775
- Run:
776
-
777
- ```sh
778
- agentkit inspect
779
- ```
780
-
781
- Example output:
782
-
783
- ```json
784
- {
785
- "agent": "demo",
786
- "runtime": "local",
787
- "provider": {
788
- "name": "test",
789
- "model": "fake"
790
- },
791
- "prompt": "prompts/instructions.md",
792
- "tools": [],
793
- "access": {
794
- "mode": "private"
795
- },
796
- "storage": ".agentkit/agentkit.db",
797
- "database": {
798
- "local": {
799
- "driver": "sqlite",
800
- "path": ".agentkit/agentkit.db",
801
- "schema": "./schema.sql"
802
- },
803
- "hosted": {
804
- "driver": "turso",
805
- "provisioning": "agentkit-managed",
806
- "schema": "./schema.sql"
807
- }
808
- },
809
- "secrets": {},
810
- "managedSecrets": ["TURSO_AUTH_TOKEN", "TURSO_DATABASE_URL"],
811
- "userSecrets": [],
812
- "runtimeContract": {
813
- "local": {
814
- "environment": "local",
815
- "target": "bun",
816
- "database": "sqlite"
817
- },
818
- "hosted": {
819
- "environment": "hosted",
820
- "target": "cloudflare",
821
- "database": "turso",
822
- "providerSupported": true
823
- },
824
- "aliases": ["ctx.db", "ctx.database", "ctx.storage.sql"]
825
- }
826
- }
827
- ```
828
-
829
- Secret values never appear. Each declared user secret appears as `set` or `missing`. `managedSecrets` are provisioned and injected by AgentKit Cloud; users do not put those values in local `.env`.
532
+ `agentkit inspect` reports the local runtime, provider, tools, channels, transcription, knowledge, SQLite path/schema/migrations, skill status, and missing secret names. Secret values never appear. There is no remote storage provisioning.
830
533
 
831
534
  ## Dev Server Contract
832
535
 
@@ -934,61 +637,9 @@ For date-sensitive evals, set top-level `now` to an ISO timestamp with an explic
934
637
 
935
638
  Evals run the normal capsule tools. If a tool would write externally, delete, charge money, send email, or call a real customer system, make its `execute` implementation branch on `ctx.runtime.environment === "eval"` and return deterministic non-destructive output for eval runs. Do not invent an eval-only mock API; keep the behavior inside the registered tool contract unless AgentKit adds a first-class mock facility later.
936
639
 
937
- ## Improve From Production
938
-
939
- Use AgentKit Improve when a hosted or local conversation should become a reproducible local fix loop. Hosted AgentKit Cloud exports evidence; the local coding agent edits the Agent Capsule, writes evals, replays, and deploys.
940
-
941
- Collect hosted evidence from the last deploy:
942
-
943
- ```sh
944
- agentkit improve collect --deploy --since 24h
945
- ```
946
-
947
- When the CLI is logged in to AgentKit Cloud, hosted collection first exports deploy evidence such as failed channel deliveries, deploy errors, and conversation IDs from the control plane, then reads replayable conversation traces from the deployed runtime. Without Cloud auth, it falls back to deploy-token conversation trace reads.
948
-
949
- Hosted conversation reads require a deploy access token even when the chat endpoint is public. `agentkit deploy` normally writes `.agentkit/chat-access-token.json`; use `agentkit access token create agentkit-chat-ui --out .agentkit/chat-access-token.json` to refresh it.
950
-
951
- Collect one hosted conversation:
952
-
953
- ```sh
954
- agentkit improve collect --deploy --conversation-id <conversation-id>
955
- ```
956
-
957
- Collect local evidence:
958
-
959
- ```sh
960
- agentkit improve collect --since 7d
961
- ```
962
-
963
- The command writes ignored local state:
964
-
965
- ```txt
966
- .agentkit/improve/<run>/
967
- bundle.json
968
- report.json
969
- traces/
970
- ```
971
-
972
- Generate committed regression evals:
640
+ ## Improve From Local Conversations
973
641
 
974
- ```sh
975
- agentkit improve evals .agentkit/improve/<run>
976
- ```
977
-
978
- Then replay before deploying:
979
-
980
- ```sh
981
- agentkit replay .agentkit/improve/<run> --against local
982
- npm run eval
983
- agentkit deploy --smoke "hello"
984
- ```
985
-
986
- Replay runs collected user turns through the local capsule with `ctx.runtime.environment === "eval"` and `ctx.runtime.invocation === "eval"`. Generated evals live under `evals/regressions/`; review them before committing, especially when traces contain real client details or overly strict prose assertions.
987
-
988
- Full guides:
989
-
990
- - `docs/guides/improve-from-production.md`
991
- - `docs/guides/replay-production-traces.md`
642
+ See `docs/guides/improve-local.md` and `docs/guides/replay-local-traces.md`. Collect local traces, generate regression evals, change capsule files, and replay before accepting a fix.
992
643
 
993
644
  ## Security Rules
994
645
 
@@ -1013,83 +664,9 @@ prompts/
1013
664
  docs/
1014
665
  ```
1015
666
 
1016
- Local `.env` is development only. Use `.env.schema` as the committed secret-name contract; local AgentKit commands load `.env` directly. Hosted deploys require an AgentKit Cloud account with `cloudflare_deploy_alpha` or purchased/manual deploy slots. First-time paid access uses `agentkit billing checkout --slots <count>` and `agentkit billing claim billint_... --secret bsec_...`; existing accounts use `agentkit login --token ...`. Hosted secrets use `agentkit secret set/list/unset` or `agentkit secret sync --from-local`. Prefer `--stdin`, `--from-env`, `--from-local-env`, or sync from local `.env` so secret values do not appear in shell history. Inline `<VALUE>` forms exist only for compatibility and simple non-sensitive values.
1017
-
1018
667
  Tools are a security boundary. A tool must declare every secret it needs. The runtime injects only tool-declared secrets.
1019
668
  Agent Capsules are trusted executable TypeScript, not sandboxed configuration. Run AgentKit commands only in Capsules whose config, tools, evals, and sync modules you trust.
1020
669
 
1021
- ## Hosted Deploy Contract
1022
-
1023
- For the coding agent and user, deploy is one command. Do not ask the user to choose a hosting target.
1024
-
1025
- Current flow:
1026
-
1027
- ```sh
1028
- agentkit deploy --dry-run
1029
- agentkit billing checkout --slots 1 --email user@example.com
1030
- agentkit billing claim billint_... --secret bsec_...
1031
- agentkit login --token agk_user_...
1032
- agentkit account token create new-laptop --use
1033
- agentkit deploy doctor
1034
- agentkit deploy --smoke "hello"
1035
- agentkit deploy status
1036
- agentkit deploy smoke --message "hello"
1037
- agentkit chat-ui --deploy
1038
- ```
1039
-
1040
- `agentkit deploy doctor` checks AgentKit Cloud login, hosted deploy entitlement, online deploy capacity, hosted secrets, local `.env` names that still need `agentkit secret set`, managed Composio API/auth-config readiness by toolkit, and private-access runtime token handling. `agentkit deploy` sends the capsule to AgentKit Cloud, runs the same readiness check automatically before building and uploading, updates the current project deploy slot by default, writes the local chat/UI deploy access token to `.agentkit/chat-access-token.json`, and prints a production handoff with URL, UI command, secret status, database/schema artifact, integration connect commands, smoke status, and the next recommended command. `agentkit deploy --smoke "hello"` deploys and then tests `/v1/chat` with the deploy access token. `agentkit deploy smoke --message "hello"` repeats that smoke against the last local deploy. `agentkit chat-ui --deploy` serves a local UI pointed at the hosted deploy using that token without exposing it to browser code, shows the conversation id and tool calls, and supports starting a new conversation. Use `agentkit conversations trace <conversation-id> --deploy` to pull hosted conversation messages and tool calls from the last deploy. Production deploys require an account with `cloudflare_deploy_alpha` or purchased/manual deploy slots; local commands and dry-run builds do not require login. AgentKit owns infrastructure selection, backend migration, managed secrets, and public URL creation.
1041
-
1042
- The CLI defaults to the hosted AgentKit Cloud API at `https://agentkit-cloud.aibuilders.com.br`. Use `AGENTKIT_CLOUD_API_URL` or `agentkit deploy --api <url>` only when the owner gives you a non-default AgentKit Cloud API URL.
1043
-
1044
- Account/access flow:
1045
-
1046
- ```sh
1047
- agentkit secret set OPENAI_API_KEY --from-local-env
1048
- agentkit secret sync --from-local
1049
- agentkit secret list
1050
- agentkit account token list
1051
- agentkit skills status
1052
- agentkit skills sync
1053
- agentkit access token create website-chat --out .agentkit/website-chat-access-token.json
1054
- agentkit access token list
1055
- ```
1056
-
1057
- Production storage uses `storage.driver: "agentkit"`. `.env` is never uploaded.
1058
-
1059
- Hosted backend responses use this error envelope:
1060
-
1061
- ```json
1062
- {
1063
- "error": {
1064
- "code": "secret_not_found",
1065
- "message": "Secret OPENAI_API_KEY is not set for this deploy.",
1066
- "request_id": "req_123",
1067
- "details": {
1068
- "secret": "OPENAI_API_KEY"
1069
- }
1070
- }
1071
- }
1072
- ```
1073
-
1074
- Common hosted error codes:
1075
-
1076
- ```txt
1077
- unauthorized
1078
- forbidden
1079
- not_found
1080
- validation_error
1081
- conflict
1082
- rate_limited
1083
- quota_exceeded
1084
- secret_not_found
1085
- access_token_invalid
1086
- deploy_not_ready
1087
- deploy_paused
1088
- tool_timeout
1089
- provider_error
1090
- internal_error
1091
- ```
1092
-
1093
670
  ## Troubleshooting
1094
671
 
1095
672
  Missing `@andreprado/agentkit` types:
@@ -1143,3 +720,5 @@ tool_validation_error
1143
720
  ```
1144
721
 
1145
722
  Check the tool call input against `inputSchema`.
723
+
724
+ For existing capsules, read `docs/guides/local-only-migration.md` before upgrading.