@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
@@ -1,139 +1,11 @@
1
- # Connect WhatsApp Through UAZAPI
1
+ # Connect WhatsApp Through UAZAPI Locally
2
2
 
3
- ## Goal
3
+ Add `whatsappChannel({ name: "support-whatsapp", provider: "uazapi" })` to `channels` with `runtime: "local"`. Set `UAZAPI_BASE_URL`, `UAZAPI_TOKEN`, and `UAZAPI_WEBHOOK_TOKEN` in ignored `.env`.
4
4
 
5
- Connect a UAZAPI WhatsApp instance to an AgentKit WhatsApp channel locally or when hosted.
5
+ Generate `UAZAPI_WEBHOOK_TOKEN` yourself; it is not issued by UAZAPI. Register `https://<tunnel-host>/channels/support-whatsapp/whatsapp/uazapi/webhook?token=<UAZAPI_WEBHOOK_TOKEN>` with `addUrlEvents: false` and `addUrlTypesMessages: false`. Keep the complete tokenized URL secret. The API base URL must be public HTTPS; private-network targets are rejected before forwarding credentials.
6
6
 
7
- ## When To Use It
7
+ AgentKit ignores fromMe/wasSentByApi messages. Replies use `/send/text`. Audio transcription requires top-level `transcription` and channel `audio: { mode: "transcribe" }`; media comes from `/message/download` with `return_base64: true`, never an arbitrary webhook-provided URL.
8
8
 
9
- Use this after `whatsappChannel({ name: "support-whatsapp", provider: "uazapi" })` exists in `agentkit.config.ts`.
9
+ Run `agentkit inspect`, `agentkit channels list`, and `agentkit dev`. Configure the provider webhook manually using an HTTPS tunnel to the printed port. Only authenticated webhook routes accept tunnel hosts; the dev UI and other APIs stay loopback-only. Keep the local process running and update registration if the tunnel hostname changes.
10
10
 
11
- ## Commands
12
-
13
- ```sh
14
- node -e "process.stdout.write(require('node:crypto').randomBytes(32).toString('hex'))" | agentkit env set UAZAPI_WEBHOOK_TOKEN --stdin
15
- agentkit dev
16
- ```
17
-
18
- Required secrets:
19
-
20
- ```txt
21
- UAZAPI_BASE_URL
22
- UAZAPI_TOKEN
23
- UAZAPI_WEBHOOK_TOKEN
24
- ```
25
-
26
- If WhatsApp audio transcription is enabled, also set the transcription provider secret declared by `agentkit inspect`, usually `OPENAI_API_KEY` or `GROQ_API_KEY`.
27
-
28
- ## Minimal Working Example
29
-
30
- ```ts
31
- import { defineAgent, whatsappChannel } from "@andreprado/agentkit";
32
-
33
- export default defineAgent({
34
- name: "support-agent",
35
- runtime: "edge",
36
- provider: { name: "test", model: "fake" },
37
- instructions: "./prompts/instructions.md",
38
- secrets: [],
39
- tools: [],
40
- channels: [whatsappChannel({ name: "support-whatsapp", provider: "uazapi" })],
41
- access: { mode: "public" },
42
- storage: { driver: "agentkit" },
43
- });
44
- ```
45
-
46
- ## Local Usage
47
-
48
- `UAZAPI_WEBHOOK_TOKEN` is an AgentKit-owned secret, not a token issued by UAZAPI. Generate a different value for every channel and keep it in the ignored local `.env`:
49
-
50
- ```sh
51
- node -e "process.stdout.write(require('node:crypto').randomBytes(32).toString('hex'))" | npm run agentkit -- env set UAZAPI_WEBHOOK_TOKEN --stdin
52
- npm run agentkit -- env set UAZAPI_BASE_URL --stdin
53
- npm run agentkit -- env set UAZAPI_TOKEN --stdin
54
- npm run agentkit -- dev
55
- ```
56
-
57
- Expose the printed local port through an HTTPS tunnel, then register this exact URL with UAZAPI:
58
-
59
- ```txt
60
- https://<tunnel-host>/channels/support-whatsapp/whatsapp/uazapi/webhook?token=<UAZAPI_WEBHOOK_TOKEN>
61
- ```
62
-
63
- Configure UAZAPI with `addUrlEvents: false` and `addUrlTypesMessages: false` so it calls that exact URL. AgentKit allows a public tunnel host only on authenticated channel webhook paths; local chat, inspect, tools, files, and conversation APIs remain loopback-only.
64
-
65
- Send a real WhatsApp message after registration. A `200` response proves UAZAPI preserved the tokenized URL and AgentKit accepted it. A `channel_signature_invalid` response means the configured URL omitted, changed, or stripped the token. If the tunnel hostname changes, update the registered webhook URL.
66
-
67
- ## Hosted Setup Behavior
68
-
69
- `agentkit channels connect whatsapp support-whatsapp --provider uazapi` creates or updates the hosted channel, verifies managed secrets, calls UAZAPI `/webhook`, confirms the configured webhook is listed by UAZAPI, then runs a synthetic inbound smoke.
70
-
71
- Expected webhook URL shape:
72
-
73
- ```txt
74
- https://<deploy-host>/channels/support-whatsapp/whatsapp/uazapi/webhook
75
- ```
76
-
77
- AgentKit requires `UAZAPI_WEBHOOK_TOKEN` and registers the webhook URL with the token query parameter:
78
-
79
- ```txt
80
- https://<deploy-host>/channels/support-whatsapp/whatsapp/uazapi/webhook?token=<UAZAPI_WEBHOOK_TOKEN>
81
- ```
82
-
83
- `UAZAPI_BASE_URL` must be an HTTPS UAZAPI instance URL, for example `https://api.uazapi.com`. AgentKit rejects localhost, private-network, link-local, metadata, and credential-bearing base URLs before sending `UAZAPI_TOKEN`.
84
-
85
- ## Audio
86
-
87
- Use `transcription` at the agent level and `audio.mode: "transcribe"` on the UAZAPI channel.
88
-
89
- ```ts
90
- whatsappChannel({
91
- name: "support-whatsapp",
92
- provider: "uazapi",
93
- audio: {
94
- mode: "transcribe",
95
- },
96
- })
97
- ```
98
-
99
- UAZAPI audio webhooks become normalized audio messages. The retryable channel worker downloads media through UAZAPI `/message/download` using `return_base64: true`; AgentKit does not fetch arbitrary webhook-provided media URLs.
100
-
101
- ## Safety Rules
102
-
103
- - Keep phone numbers redacted in logs by default.
104
- - Do not store UAZAPI tokens in `agentkit.config.ts`.
105
- - Keep `UAZAPI_WEBHOOK_TOKEN` configured. UAZAPI V1 has no body-signature contract, so AgentKit rejects webhooks without the secret query token.
106
- - UAZAPI does not expose a documented webhook body-signature contract in AgentKit V1; the AgentKit-owned query token is the authentication layer.
107
- - Treat the complete tokenized URL as a secret and rotate `UAZAPI_WEBHOOK_TOKEN` if it appears in logs or screenshots.
108
- - AgentKit ignores `fromMe` and `wasSentByApi` messages to avoid reply loops.
109
- - Text replies call UAZAPI `POST /send/text` with the `token` header and a body containing `number`, `text`, `readchat`, `async`, `track_source`, and `track_id`.
110
- - Real provider success is recorded as `provider_sent` only when UAZAPI returns a provider message id.
111
- - Only set `AGENTKIT_CHANNEL_SEND_DRY_RUN=1` in tests when UAZAPI should not receive a real message. Dry-run deliveries are recorded as `adapter_stubbed`, not sent.
112
-
113
- ## Verification
114
-
115
- ```sh
116
- agentkit channels setup support-whatsapp --apply
117
- agentkit channels status support-whatsapp
118
- agentkit channels test support-whatsapp --message "hello"
119
- agentkit channels test-audio support-whatsapp --fixture voice-note
120
- agentkit channels deliveries list support-whatsapp
121
- agentkit channels deliveries show <delivery-id>
122
- ```
123
-
124
- ## Troubleshooting
125
-
126
- `channel_secret_missing`:
127
- Set `UAZAPI_BASE_URL`, `UAZAPI_TOKEN`, and `UAZAPI_WEBHOOK_TOKEN` as secrets.
128
-
129
- `channel_signature_invalid`:
130
- The required UAZAPI webhook query token does not match.
131
-
132
- `channel_provider_setup_invalid`:
133
- `UAZAPI_BASE_URL` is not an allowed HTTPS public base URL.
134
-
135
- `channel_provider_setup_failed`:
136
- AgentKit could not configure or verify the UAZAPI webhook through `/webhook`.
137
-
138
- `channel_audio_download_unavailable`:
139
- UAZAPI did not return base64 media data from `/message/download`, or the audio payload did not include a provider message id.
11
+ Test with a correctly authenticated fixture and inspect the response, then use `agentkit conversations trace <id>`. A synthetic test does not prove real provider delivery. Use `AGENTKIT_CHANNEL_SEND_DRY_RUN=1` when a test must not send to real recipients. Local buffering is best-effort and in-memory; no durable retry worker is included.
@@ -1,207 +1,11 @@
1
- # Connect WhatsApp Through Zapster
1
+ # Connect WhatsApp Through Zapster Locally
2
2
 
3
- ## Goal
3
+ Add `whatsappChannel({ name: "support-whatsapp", provider: "zapster" })` to `channels` with `runtime: "local"`. Set `ZAPSTER_API_KEY`, `ZAPSTER_INSTANCE_ID`, `ZAPSTER_WEBHOOK_ID`, and `ZAPSTER_WEBHOOK_TOKEN` in ignored `.env`.
4
4
 
5
- Connect a Zapster WhatsApp account to an AgentKit WhatsApp channel locally or when hosted.
5
+ Generate `ZAPSTER_WEBHOOK_TOKEN` yourself and register `https://<tunnel-host>/channels/support-whatsapp/whatsapp/zapster/webhook?token=<ZAPSTER_WEBHOOK_TOKEN>`. AgentKit checks expected instance/webhook IDs and the secret token. Metadata headers alone are not cryptographic authentication. Keep the tokenized URL secret and rotate it if exposed.
6
6
 
7
- ## When To Use It
7
+ AgentKit normalizes message.received envelopes and sends replies through Zapster's messages API. Audio transcription requires top-level `transcription` and channel `audio: { mode: "transcribe" }`. The payload must provide a trusted Zapster HTTPS media URL; a media ID alone is insufficient. Arbitrary media hosts are rejected before credentials are sent.
8
8
 
9
- Use this after `whatsappChannel({ name: "support-whatsapp", provider: "zapster" })` exists in `agentkit.config.ts`.
9
+ Run `agentkit inspect`, `agentkit channels list`, and `agentkit dev`. Configure the provider webhook manually using an HTTPS tunnel to the printed port. Only authenticated webhook routes accept tunnel hosts; the dev UI and other APIs stay loopback-only. Keep the local process running and update registration if the tunnel hostname changes.
10
10
 
11
- ## Commands
12
-
13
- ```sh
14
- node -e "process.stdout.write(require('node:crypto').randomBytes(32).toString('hex'))" | agentkit env set ZAPSTER_WEBHOOK_TOKEN --stdin
15
- agentkit dev
16
- ```
17
-
18
- Required secrets:
19
-
20
- ```txt
21
- ZAPSTER_API_KEY
22
- ZAPSTER_INSTANCE_ID
23
- ZAPSTER_WEBHOOK_ID
24
- ZAPSTER_WEBHOOK_TOKEN
25
- ```
26
-
27
- If WhatsApp audio transcription is enabled, also set the transcription provider secret declared by `agentkit inspect`, usually:
28
-
29
- ```txt
30
- OPENAI_API_KEY
31
- ```
32
-
33
- or:
34
-
35
- ```txt
36
- GROQ_API_KEY
37
- ```
38
-
39
- ## Files Created Or Edited
40
-
41
- - `agentkit.config.ts`: `whatsappChannel({ name: "support-whatsapp", provider: "zapster" })`.
42
- - `.env`: ignored local provider credentials and the AgentKit-owned webhook token.
43
- - `.agentkit/deploy.json`: deploy state only when using the hosted workflow.
44
- - No user-managed webhook server.
45
-
46
- ## Minimal Working Example
47
-
48
- ```ts
49
- import { defineAgent, whatsappChannel } from "@andreprado/agentkit";
50
-
51
- export default defineAgent({
52
- name: "support-agent",
53
- runtime: "edge",
54
- provider: { name: "test", model: "fake" },
55
- instructions: "./prompts/instructions.md",
56
- secrets: [],
57
- tools: [],
58
- channels: [whatsappChannel({ name: "support-whatsapp", provider: "zapster" })],
59
- access: { mode: "public" },
60
- storage: { driver: "agentkit" },
61
- });
62
- ```
63
-
64
- ## Local Usage
65
-
66
- `ZAPSTER_WEBHOOK_TOKEN` is an AgentKit-owned secret, not a token issued by Zapster. Generate a different value for every channel and keep it in the ignored local `.env`:
67
-
68
- ```sh
69
- node -e "process.stdout.write(require('node:crypto').randomBytes(32).toString('hex'))" | npm run agentkit -- env set ZAPSTER_WEBHOOK_TOKEN --stdin
70
- npm run agentkit -- env set ZAPSTER_API_KEY --stdin
71
- npm run agentkit -- env set ZAPSTER_INSTANCE_ID --stdin
72
- npm run agentkit -- env set ZAPSTER_WEBHOOK_ID --stdin
73
- npm run agentkit -- dev
74
- ```
75
-
76
- Expose the printed local port through an HTTPS tunnel, then register this exact URL with Zapster:
77
-
78
- ```txt
79
- https://<tunnel-host>/channels/support-whatsapp/whatsapp/zapster/webhook?token=<ZAPSTER_WEBHOOK_TOKEN>
80
- ```
81
-
82
- Zapster stores a complete webhook URL and sends `X-Instance-ID` and `X-Webhook-ID` with deliveries. AgentKit requires both expected IDs and the URL secret because those identifiers alone are not cryptographic authentication. AgentKit allows a public tunnel host only on authenticated channel webhook paths; local chat, inspect, tools, files, and conversation APIs remain loopback-only.
83
-
84
- Send a real WhatsApp message after registration. A `200` response proves Zapster preserved the tokenized URL and AgentKit accepted it. A `channel_signature_invalid` response means the URL token or expected Zapster IDs did not match. If the tunnel hostname changes, update the registered webhook URL.
85
-
86
- To handle clients who send several WhatsApp messages before waiting, enable channel buffering:
87
-
88
- ```ts
89
- whatsappChannel({
90
- name: "support-whatsapp",
91
- provider: "zapster",
92
- buffer: {
93
- mode: "debounce",
94
- quietWindowMs: 2500,
95
- maxWaitMs: 12000,
96
- maxMessages: 20,
97
- maxChars: 8000,
98
- },
99
- })
100
- ```
101
-
102
- ## Auto Transcribe WhatsApp Audio
103
-
104
- Use `transcription` at the agent level and `audio.mode: "transcribe"` on the Zapster channel.
105
-
106
- ```ts
107
- import { defineAgent, whatsappChannel } from "@andreprado/agentkit";
108
-
109
- export default defineAgent({
110
- name: "support-agent",
111
- runtime: "edge",
112
- provider: { name: "openai", model: "gpt-5.4-mini" },
113
- instructions: "./prompts/instructions.md",
114
- transcription: {
115
- provider: "openai",
116
- model: "gpt-4o-mini-transcribe",
117
- secret: "OPENAI_API_KEY",
118
- language: "pt",
119
- limits: {
120
- maxDurationSeconds: 180,
121
- maxBytes: 20_000_000,
122
- },
123
- },
124
- channels: [
125
- whatsappChannel({
126
- name: "support-whatsapp",
127
- provider: "zapster",
128
- audio: {
129
- mode: "transcribe",
130
- },
131
- }),
132
- ],
133
- access: { mode: "public" },
134
- storage: { driver: "agentkit" },
135
- });
136
- ```
137
-
138
- Processing order:
139
-
140
- 1. AgentKit validates Zapster origin headers and the required webhook token.
141
- 2. Zapster audio payloads become normalized audio messages.
142
- 3. AgentKit records `audio_received` and enqueues a channel job before acknowledging Zapster.
143
- 4. The retryable channel worker downloads the media URL from a trusted Zapster HTTPS host using `ZAPSTER_API_KEY`.
144
- 5. AgentKit sends the audio bytes to the configured transcription provider using the user's managed secret.
145
- 6. The agent run receives a text message with the transcript.
146
-
147
- Zapster payloads must include a media download URL such as `audio.downloadUrl`, `audio.url`, `audio.mediaUrl`, or the snake_case equivalents. The URL must be HTTPS and hosted by Zapster; AgentKit rejects arbitrary webhook-provided hosts before sending `ZAPSTER_API_KEY`. If Zapster sends only a media ID without a download URL, AgentKit records `channel_audio_download_unavailable` and does not create an agent run for that audio in V1.
148
-
149
- ## Hosted Setup Behavior
150
-
151
- `agentkit channels setup support-whatsapp` prints the stable AgentKit webhook URL. Paste it into Zapster webhook settings.
152
-
153
- Expected webhook URL shape:
154
-
155
- ```txt
156
- https://<deploy-host>/channels/support-whatsapp/whatsapp/zapster/webhook
157
- ```
158
-
159
- AgentKit requires `ZAPSTER_WEBHOOK_TOKEN`; register the Zapster URL with the token as a query parameter:
160
-
161
- ```txt
162
- https://<deploy-host>/channels/support-whatsapp/whatsapp/zapster/webhook?token=<ZAPSTER_WEBHOOK_TOKEN>
163
- ```
164
-
165
- ## Safety Rules
166
-
167
- - Keep phone numbers redacted in logs by default.
168
- - Do not store Zapster API keys in `agentkit.config.ts`.
169
- - Inbound validation uses Zapster's `X-Instance-ID`, `X-Webhook-ID`, `X-Message-ID`, `X-Attempt-Count`, and `User-Agent: Zapsterapi/...` headers.
170
- - Zapster webhook headers are origin validation, not a cryptographic body signature.
171
- - Keep `ZAPSTER_WEBHOOK_TOKEN` in the webhook URL. Zapster's metadata headers are not a shared-secret signature, so AgentKit rejects webhooks without the secret query token.
172
- - Treat the complete tokenized URL as a secret and rotate `ZAPSTER_WEBHOOK_TOKEN` if it appears in logs or screenshots.
173
- - Unsupported media should be logged as skipped/unsupported without creating an agent run.
174
- - AgentKit handles Zapster `message.received` envelopes with event id at `id`, message text at `data.content.text`, and contact identity at `data.sender.id`.
175
- - Outbound replies call `POST https://api.zapsterapi.com/v1/wa/messages` with bearer auth and a JSON body containing `recipient`, `text`, and `instance_id`.
176
- - Real provider success is recorded as `provider_sent` only when Zapster returns a provider message ID.
177
- - Only set `AGENTKIT_CHANNEL_SEND_DRY_RUN=1` in tests when Zapster should not receive a real message. Dry-run deliveries are recorded as `adapter_stubbed`, not sent.
178
-
179
- ## Verification
180
-
181
- ```sh
182
- agentkit channels status support-whatsapp
183
- agentkit channels test support-whatsapp --message "hello"
184
- agentkit channels deliveries list support-whatsapp
185
- agentkit channels deliveries show <delivery-id>
186
- agentkit channels buffers list support-whatsapp
187
- agentkit channels buffers flush support-whatsapp <conversation-id>
188
- agentkit channels buffers clear support-whatsapp <conversation-id>
189
- agentkit channels buffers retry support-whatsapp <conversation-id>
190
- ```
191
-
192
- ## Troubleshooting
193
-
194
- `channel_secret_missing`:
195
- Set `ZAPSTER_API_KEY`, `ZAPSTER_INSTANCE_ID`, `ZAPSTER_WEBHOOK_ID`, and `ZAPSTER_WEBHOOK_TOKEN` as secrets.
196
-
197
- `channel_signature_invalid`:
198
- Zapster is not sending the expected instance/webhook IDs, or the required query token does not match.
199
-
200
- `channel_unsupported_message_type` or skipped delivery:
201
- The inbound WhatsApp event was not supported text. Inspect the delivery record for provider metadata.
202
-
203
- `channel_audio_download_unavailable`:
204
- Zapster sent an audio event without a usable media download URL, or the URL was not an HTTPS Zapster media host. Configure Zapster to include a trusted Zapster media URL in webhook payloads, or add a Zapster media lookup adapter before enabling `audio.mode: "transcribe"`.
205
-
206
- `transcription_secret_missing`:
207
- Set `OPENAI_API_KEY`, `GROQ_API_KEY`, or the custom secret named in `transcription.secret` as a managed hosted secret.
11
+ Test with a correctly authenticated fixture and inspect the response, then use `agentkit conversations trace <id>`. A synthetic test does not prove real provider delivery. Use `AGENTKIT_CHANNEL_SEND_DRY_RUN=1` when a test must not send to real recipients. Local buffering is best-effort and in-memory; no durable retry worker is included.
@@ -120,7 +120,7 @@ npm run agentkit -- spec check
120
120
 
121
121
  `AGENT_SPEC.md` is an internal working contract for the coding agent. It is not a form the owner must fill before work starts.
122
122
 
123
- The coding agent should build a testable capsule, not only a prompt. For each meaningful requirement in the brief or `AGENT_SPEC.md`, decide whether it needs a prompt instruction, tool, schema/migration, fixture, eval, direct tool check, or deploy/readiness check. Privacy, confirmation, external writes, bookings, customer data, business hours, dates, and integration failures should have evals or deterministic checks before the capsule is called done.
123
+ The coding agent should build a testable capsule, not only a prompt. For each meaningful requirement in the brief or `AGENT_SPEC.md`, decide whether it needs a prompt instruction, tool, schema/migration, fixture, eval, direct tool check, or local config and secret check. Privacy, confirmation, external writes, bookings, customer data, business hours, dates, and integration failures should have evals or deterministic checks before the capsule is called done.
124
124
 
125
125
  Optional shortcut when copying a prompt into another coding agent:
126
126
 
@@ -138,7 +138,7 @@ import { defineAgent } from "@andreprado/agentkit";
138
138
 
139
139
  export default defineAgent({
140
140
  name: "demo",
141
- runtime: "edge",
141
+ runtime: "local",
142
142
  provider: {
143
143
  name: "test",
144
144
  model: "fake",
@@ -153,13 +153,12 @@ export default defineAgent({
153
153
  driver: "agentkit",
154
154
  path: ".agentkit/agentkit.db",
155
155
  database: {
156
- driver: "turso",
156
+ driver: "sqlite",
157
157
  schema: "./schema.sql",
158
158
  },
159
159
  files: {
160
- driver: "r2",
161
- bucket: "agentkit-demo-files",
162
- prefix: "demo",
160
+ driver: "local",
161
+ prefix: "demo",
163
162
  },
164
163
  },
165
164
  });
@@ -181,14 +180,8 @@ npm run dev
181
180
 
182
181
  Open the printed `Chat:` URL and tell the owner the exact URL.
183
182
 
184
- Hosted deploy UI:
185
183
 
186
- ```sh
187
- npm run agentkit -- deploy
188
- npm run agentkit -- chat-ui --deploy
189
- ```
190
184
 
191
- Open the printed `Chat:` URL and tell the owner this local UI is connected to the hosted deploy.
192
185
 
193
186
  `test/fake` is deterministic. It validates the scaffold, direct tool checks, and fake-provider evals, but it does not validate natural conversation quality. Before claiming real conversation behavior is tested, ask the owner which provider to use: OpenRouter, OpenAI, Anthropic, OpenCode Zen, OpenCode Go, or another supported provider.
194
187
 
@@ -243,5 +236,3 @@ Check the `instructions` path in `agentkit.config.ts`.
243
236
  Use `blank` or `support`. `research` is planned but not implemented.
244
237
 
245
238
  ## Backend Contracts Used
246
-
247
- Local commands use local files and SQLite. Hosted deploy sends a build artifact to AgentKit Cloud with `agentkit deploy`; users do not create hosted projects or infrastructure by hand.
@@ -1,159 +1,7 @@
1
- # Debug A Channel
1
+ # Debug Local Channels
2
2
 
3
- ## Goal
3
+ Run `agentkit inspect` and `agentkit channels list` to check configuration and missing secret names. Start `agentkit dev`, POST an authenticated fixture to the local webhook route, and inspect its response and conversation trace. Buffers are in memory; there is no delivery dashboard or buffer-management API. Synthetic tests do not prove a real provider can deliver or receive messages.
4
4
 
5
- Diagnose website, Telegram, WhatsApp, Discord, Slack, generic inbound webhook, generic outbound webhook, cross-channel reply routing, webhook validation, dedupe, buffering, outbound sends, and delivery failures from the Agent Capsule CLI.
5
+ For real traffic, check the tunnel URL, configured provider webhook, signature or secret token, and provider credentials. Tunnel hostnames are accepted only on authenticated webhook routes. Check the conversation trace with `agentkit conversations trace <id>`. Keep raw payloads, phone numbers, credentials, and tokenized URLs out of reports.
6
6
 
7
- ## When To Use It
8
-
9
- Use this when a hosted channel is not responding, a provider is retrying messages, audio transcription is failing, cross-channel replies are going to the wrong target, or delivery status does not match the user's expectation.
10
-
11
- ## Commands
12
-
13
- ```sh
14
- agentkit channels list
15
- agentkit channels status <name>
16
- agentkit channels doctor <name>
17
- agentkit channels test <name> --message "hello"
18
- agentkit channels test-audio <name> --fixture voice-note
19
- agentkit transcribe smoke --provider groq
20
- agentkit channels test <name> --fixture ./fixtures/provider-event.json
21
- agentkit channels deliveries list <name> --since 24h
22
- agentkit channels deliveries show <delivery-id>
23
- agentkit channels deliveries list <reply-target-name> --since 24h
24
- agentkit channels buffers list <name>
25
- agentkit channels buffers show <conversation-id>
26
- agentkit channels buffers flush <conversation-id>
27
- agentkit channels buffers clear <conversation-id>
28
- agentkit channels buffers retry <conversation-id>
29
- ```
30
-
31
- ## Files Created Or Edited
32
-
33
- Debugging should not require source edits. Use fixtures only when reproducing provider payload shape, and never commit provider secrets, full phone numbers, raw audio, or private client data.
34
-
35
- ## Delivery States
36
-
37
- ```txt
38
- received
39
- validated
40
- duplicate
41
- audio_received
42
- audio_downloaded
43
- transcribing
44
- transcribed
45
- buffered
46
- queued
47
- running
48
- agent_completed
49
- provider_request_built
50
- provider_sent
51
- adapter_stubbed
52
- delivered
53
- provider_failed
54
- failed
55
- dead_lettered
56
- skipped
57
- ```
58
-
59
- ## Minimal Working Example
60
-
61
- ```sh
62
- agentkit channels test support-telegram --message "hello"
63
- agentkit channels deliveries list support-telegram --since 1h
64
- agentkit channels deliveries show del_123
65
- ```
66
-
67
- Expected `show` output includes signature status, dedupe key, queue/run state, outbound provider request ID when available, and a normalized error envelope.
68
-
69
- ## Safety Rules
70
-
71
- - Inspect delivery IDs, hashes, statuses, and redacted metadata rather than raw provider payloads.
72
- - Never paste provider secrets into fixtures or prompts.
73
- - Treat `adapter_stubbed` as "no outbound provider call happened", not proof that a client received a message. It can mean explicit dry-run mode or an inbound-only channel such as a generic webhook.
74
- - For `replyTo` routes, inspect the source channel delivery for validation, dedupe, buffer, queue, and agent-run state, then inspect the target channel delivery for the outbound provider result.
75
- - Generic output webhook channels do not have inbound endpoints. Use `agentkit channels doctor <name>` to inspect secret readiness and inspect target-channel deliveries after a source event triggers the route.
76
- - Before replaying or flushing buffered conversations, confirm the channel name and conversation ID.
77
- - Keep local `.env` values ignored and upload hosted production values through AgentKit secret commands.
78
-
79
- ## Troubleshooting By Error Code
80
-
81
- `channel_not_found`:
82
- The webhook URL points to an unknown or deleted channel. Stable hosted URLs use the channel name, for example `/channels/support-whatsapp/whatsapp/zapster/webhook`; old `chn_*` URLs are accepted only for compatibility.
83
-
84
- `agentkit channels test <name>` is the official synthetic smoke. If it fails while `channels list`, `status`, or `doctor` find the channel, rerun against the current deploy state in `.agentkit/deploy.json`.
85
-
86
- `channel_disabled`:
87
- The channel was disabled. Re-add or recreate it.
88
-
89
- `channel_secret_missing`:
90
- The hosted secret metadata says a required channel secret is missing. Set it with `agentkit secret set <NAME> --from-local-env` or `agentkit secret sync --from-local`.
91
-
92
- `channel_signature_invalid`:
93
- Provider authenticity validation failed. Check the provider webhook secret, token, origin settings, or Discord public key.
94
-
95
- `channel_payload_invalid`:
96
- The provider payload is malformed or does not match the route provider.
97
-
98
- Discord endpoint validation fails in the Developer Portal:
99
- Confirm `DISCORD_PUBLIC_KEY` is set from the application's public key and the webhook URL is `/channels/<name>/discord/discord/webhook`. AgentKit must validate Discord's signature headers before returning the `PING` PONG.
100
-
101
- Discord bot does not answer normal server messages:
102
- Confirm the channel was created with `--mode bot`, `DISCORD_BOT_TOKEN` is set, Message Content Intent is enabled in the Discord Developer Portal, the app is installed into the server, and the bot has `View Channel`, `Read Message History`, and `Send Messages` permissions for the channel.
103
-
104
- `audio_received`:
105
- The webhook contained a supported audio message and the channel is entering the audio handling path.
106
-
107
- `audio_downloaded`:
108
- The retryable channel worker downloaded the provider media file into memory. The delivery metadata should include only redacted size, MIME, and provider IDs.
109
-
110
- `transcribing`:
111
- AgentKit is calling the configured transcription provider with the user's managed transcription secret.
112
-
113
- `transcribed`:
114
- Transcription succeeded and the queued agent message contains transcript text instead of raw audio.
115
-
116
- `channel_event_duplicate` or `duplicate`:
117
- The provider retried an already-processed event. No second agent run should be created.
118
-
119
- `buffered`:
120
- The message is accepted and waiting inside a per-conversation channel buffer. It should move to `queued` after the quiet window, max wait, max message count, or max character count.
121
-
122
- `adapter_stubbed`:
123
- The adapter completed without calling an outbound provider. This can happen in explicit dry-run mode or for an inbound-only channel such as a generic webhook without `replyTo`.
124
-
125
- `provider_sent`:
126
- The provider API accepted the outbound request and returned a provider message ID. For cross-channel replies, this status appears on the reply target channel, such as WhatsApp or a generic output webhook.
127
-
128
- `channel_reply_target_missing`:
129
- The source channel has `replyTo.channel`, but the hosted channel resource for that target does not exist in the same deploy. Create or reconnect the target channel, then retry the source event.
130
-
131
- `channel_reply_recipient_missing`:
132
- The route needs a destination identity but `recipientFrom` was missing, resolved to an empty value, or the source identity cannot be reused by the target channel. Check the inbound payload and the configured dotted JSON path.
133
-
134
- `channel_reply_target_invalid`:
135
- The route points to an invalid target, such as an inbound-only generic webhook, or tries to use `recipientFrom` for a provider that requires native source identities such as Discord or Slack.
136
-
137
- `channel_limit_exceeded`:
138
- Backpressure skipped the message before queueing.
139
-
140
- `channel_audio_download_unavailable`:
141
- The channel provider reported audio but did not include enough metadata for AgentKit to download it.
142
-
143
- `transcription_secret_missing`:
144
- The transcription provider secret declared in `agentkit inspect` is not set as a managed hosted secret.
145
-
146
- `transcription_audio_too_large` or `transcription_audio_too_long`:
147
- The audio exceeded `transcription.limits` or the channel-level `audio.limits`.
148
-
149
- `transcription_audio_format_unsupported`:
150
- The configured transcription provider does not accept this audio MIME type or file extension.
151
-
152
- `transcription_provider_unavailable`:
153
- The transcription provider returned a retryable error, usually HTTP 429 or a server-side failure.
154
-
155
- `channel_provider_unavailable`:
156
- The agent run or provider send path failed with a retryable provider condition.
157
-
158
- `channel_delivery_dead_lettered`:
159
- The queue exhausted retries. Inspect the delivery and replay manually only after fixing the cause.
7
+ For cross-channel replies, check `replyTo.channel`, recipient routing, destination credentials, and outbound provider result. Use `AGENTKIT_CHANNEL_SEND_DRY_RUN=1` for tests that must not send real messages.
@@ -0,0 +1,13 @@
1
+ # Improve From Local Conversations
2
+
3
+ Collect a reproducible bundle before changing the capsule:
4
+
5
+ ```sh
6
+ agentkit improve collect --since 24h
7
+ agentkit improve collect --conversation-id <id>
8
+ agentkit improve evals .agentkit/improve/<run>
9
+ agentkit replay .agentkit/improve/<run> --against local
10
+ agentkit eval run
11
+ ```
12
+
13
+ Bundles contain local conversation traces and a report. Review them for sensitive data before sharing. Change capsule prompts, tools, or schema, then rerun the regression eval and replay. Generated evals guard external writes through the eval runtime; keep deterministic fixtures for external services. Never upload `.env` or the SQLite database.
@@ -0,0 +1,35 @@
1
+ # Upgrade To Local-Only AgentKit
2
+
3
+ AgentKit 0.2.0 runs capsules locally. This breaking upgrade removes account/billing commands, deployment targets, remote secrets, remote conversation collection, managed Composio, and the remote chat UI.
4
+
5
+ Before upgrading a working capsule, back up its configuration and local state. Existing local database and file paths remain unchanged.
6
+
7
+ ## Revoke Hosted Credentials Before Upgrading
8
+
9
+ The old CLI saved the account login token in `~/.agentkit/cloud.json`. Each deployed capsule may also contain `.agentkit/chat-access-token.json`, holding a hosted deploy access token. This upgrade leaves both files untouched. Removing a file or running the old `logout` command only removes a local copy; it does not revoke the live credential.
10
+
11
+ While the hosted service is still available, use your previous hosted-capable CLI and its configured API endpoint to:
12
+
13
+ 1. From each deployed capsule, run `agentkit access token list`, then `agentkit access token revoke <token-id>` for its retired deploy tokens, including the saved chat token and any tokens exported for other clients. Keep the existing deployment state until this is done.
14
+ 2. Run `agentkit account token list`, then `agentkit account token revoke <token-id>` for retired account tokens. Revoke the credential used for these operations last.
15
+ 3. Confirm successful server-side revocation before removing `~/.agentkit/cloud.json`, each capsule's `.agentkit/chat-access-token.json`, and any exported copies. Remove old `AGENTKIT_CLOUD_API_TOKEN` values from shell profiles or secret stores too.
16
+
17
+ Do this before the hosted service is retired; 0.2.0 has no `logout`, `account`, or `access` commands. If you already upgraded, use the previous CLI in a separate environment or ask the hosted-service operator to revoke the credentials. If the service is unreachable, deleting local files cannot establish that tokens were revoked. Never paste token values into chat, tickets, or logs.
18
+
19
+ ## Update The Capsule
20
+
21
+ 1. Set `runtime: "local"` in `agentkit.config.ts`.
22
+ 2. For application schemas/migrations, change `storage.database.driver` from `"turso"` to `"sqlite"`. Keep `schema`, `migrations`, and the storage path unchanged.
23
+ 3. Change `storage.files.driver` from `"r2"` to `"local"` and remove `bucket`. Keep the prefix and size limit.
24
+ 4. Remove `integrations`; implement external-service calls through `defineTool` with your own local credentials. The `composioManaged` helper is removed.
25
+ 5. Put required secret values in ignored `.env` using `agentkit env set <NAME> --stdin`. Secret values are never recovered automatically from a remote service.
26
+ 6. Run `agentkit skills sync`, remove obsolete `skills/agentkit-deploy` and `skills/agentkit-integrations` files after checking for your own edits, and update capsule instructions that mention removed commands.
27
+ 7. Run `agentkit inspect`, `agentkit eval run`, and `agentkit dev`.
28
+
29
+ Use `agentkit open` for the local UI. Collect local traces with `agentkit improve collect`; remote `--deploy`, `--api`, and `--target` options are rejected. Channel configuration remains in the capsule. Register provider webhooks manually against an HTTPS tunnel while the local process runs. Discord Gateway connections are not managed by AgentKit: bot-mode channels need your own bridge and produce an inspect warning; use interactions for the standard local setup.
30
+
31
+ ## Update Authenticated HTTP Clients
32
+
33
+ The legacy `x-agentkit-deploy-access-token` header is no longer accepted. Clients that send only this header to an endpoint enforcing token access now receive HTTP 401. Send `Authorization: Bearer <local-token>` or `x-agentkit-access-token: <local-token>` instead. Use the locally configured `AGENTKIT_PRIVATE_TOKEN` for private/admin endpoints or `AGENTKIT_ACCESS_TOKEN` for token-mode chat; hosted account/deploy tokens do not become local credentials automatically. Default loopback-only local access is unchanged.
34
+
35
+ This upgrade does not delete remote deployments, databases, accounts, or local credential files. Remote data is not copied into local storage. Retire any existing remote resources separately after handling the data you need.
@@ -0,0 +1,11 @@
1
+ # Replay Local Traces
2
+
3
+ Collect evidence with `agentkit improve collect`, then run:
4
+
5
+ ```sh
6
+ agentkit improve evals .agentkit/improve/<run>
7
+ agentkit replay .agentkit/improve/<run> --against local
8
+ agentkit eval run
9
+ ```
10
+
11
+ Replay uses isolated eval storage and identifies failures per conversation. Tools must check `ctx.runtime.environment === "eval"` and return deterministic fixtures instead of external writes. Inspect the bundle before sharing; redaction does not replace human review.