@andreprado/agentkit 0.1.0-alpha.9 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) 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 +856 -36
  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 +67 -9
  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 +904 -0
  47. package/src/runtime/channels/generic-webhook.ts +682 -0
  48. package/src/runtime/channels/net-guard.ts +480 -0
  49. package/src/runtime/channels/provider-fetch.ts +54 -0
  50. package/src/runtime/channels/slack.ts +652 -0
  51. package/src/runtime/channels/telegram.ts +379 -15
  52. package/src/runtime/channels/whatsapp-evolution.ts +1330 -0
  53. package/src/runtime/channels/whatsapp-meta.ts +9 -0
  54. package/src/runtime/channels/whatsapp-uazapi.ts +1192 -0
  55. package/src/runtime/channels/whatsapp-zapster.ts +702 -40
  56. package/src/runtime/channels.ts +83 -3
  57. package/src/runtime/chat.ts +70 -44
  58. package/src/runtime/config.ts +512 -20
  59. package/src/runtime/core/manifest.ts +75 -5
  60. package/src/runtime/core/targets.ts +5 -5
  61. package/src/runtime/deploy-readiness.ts +34 -4
  62. package/src/runtime/dev-server.ts +639 -39
  63. package/src/runtime/env.ts +8 -3
  64. package/src/runtime/evals.ts +445 -74
  65. package/src/runtime/improve.ts +868 -0
  66. package/src/runtime/inspect.ts +173 -4
  67. package/src/runtime/integrations/composio.ts +425 -0
  68. package/src/runtime/knowledge/embeddings.ts +45 -7
  69. package/src/runtime/knowledge/ingest.ts +69 -6
  70. package/src/runtime/knowledge/retrieve.ts +25 -5
  71. package/src/runtime/knowledge/schema.ts +45 -1
  72. package/src/runtime/knowledge/vector.ts +30 -30
  73. package/src/runtime/prompt-context.ts +141 -0
  74. package/src/runtime/runtime-contract.ts +71 -7
  75. package/src/runtime/skills.ts +95 -0
  76. package/src/runtime/targets/cloudflare/build.ts +1010 -208
  77. package/src/runtime/targets/container/server.ts +1 -1
  78. package/src/runtime/targets/vps/deploy.ts +26 -9
  79. package/src/runtime/tool-runner.ts +9 -1
  80. package/src/runtime/tools.ts +26 -2
  81. package/src/runtime/transcription.ts +483 -0
  82. package/src/storage/sqlite.ts +7 -2
  83. package/src/templates/blank.ts +37 -9
  84. package/src/templates/dentista.ts +40 -14
  85. package/src/templates/skills/agentkit-build-agent/SKILL.md +34 -5
  86. package/src/templates/skills/agentkit-build-agent/templates/appointment-intake.instructions.md +2 -1
  87. package/src/templates/skills/agentkit-capsule/SKILL.md +32 -3
  88. package/src/templates/skills/agentkit-capsule/references/docs-router.md +2 -2
  89. package/src/templates/skills/agentkit-channels/SKILL.md +66 -1
  90. package/src/templates/skills/agentkit-channels/references/channel-buffering.md +8 -1
  91. package/src/templates/skills/agentkit-channels/references/channel-debugging.md +28 -3
  92. package/src/templates/skills/agentkit-channels/references/discord.md +93 -0
  93. package/src/templates/skills/agentkit-channels/references/slack.md +56 -0
  94. package/src/templates/skills/agentkit-channels/references/telegram.md +34 -0
  95. package/src/templates/skills/agentkit-channels/references/whatsapp-evolution.md +57 -0
  96. package/src/templates/skills/agentkit-channels/references/whatsapp-uazapi.md +54 -0
  97. package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +42 -8
  98. package/src/templates/skills/agentkit-database/SKILL.md +11 -0
  99. package/src/templates/skills/agentkit-deploy/SKILL.md +9 -1
  100. package/src/templates/skills/agentkit-evals/SKILL.md +77 -13
  101. package/src/templates/skills/agentkit-evals/templates/multi-turn.eval.md +13 -6
  102. package/src/templates/skills/agentkit-evals/templates/no-leak.eval.md +8 -4
  103. package/src/templates/skills/agentkit-evals/templates/smoke.eval.md +8 -4
  104. package/src/templates/skills/agentkit-evals/templates/tool-call.eval.md +16 -7
  105. package/src/templates/skills/agentkit-improve/SKILL.md +96 -0
  106. package/src/templates/skills/agentkit-improve/references/replay-side-effects.md +18 -0
  107. package/src/templates/skills/agentkit-improve/references/trace-packets.md +22 -0
  108. package/src/templates/skills/agentkit-improve/templates/regression.eval.md +18 -0
  109. package/src/templates/skills/agentkit-integrations/SKILL.md +98 -0
  110. package/src/templates/skills/agentkit-knowledge/SKILL.md +4 -1
  111. package/src/templates/skills/agentkit-prompts/SKILL.md +3 -1
  112. package/src/templates/skills/agentkit-provider/SKILL.md +29 -4
  113. package/src/templates/skills/agentkit-security/SKILL.md +5 -2
  114. package/src/templates/skills/agentkit-tools/SKILL.md +8 -1
  115. package/src/templates/skills/agentkit-tools/examples/eval-safe-external-action.tool.md +8 -8
  116. package/src/templates/skills/agentkit-tools/examples/jev-service-fit.tool.md +110 -0
  117. package/src/templates/skills/agentkit-troubleshooting/SKILL.md +25 -1
  118. package/src/templates/support.ts +42 -12
  119. package/docs/guides/agentkit-skills-architecture.md +0 -471
  120. package/docs/guides/channels-implementation-map.md +0 -243
  121. package/docs/guides/channels-production-handoff.md +0 -101
  122. package/docs/portable-deploy-release-checklist.md +0 -41
@@ -0,0 +1,121 @@
1
+ # Connect WhatsApp Through Evolution API
2
+
3
+ ## Goal
4
+
5
+ Connect a self-hosted Evolution API WhatsApp instance to a hosted AgentKit WhatsApp channel.
6
+
7
+ ## When To Use It
8
+
9
+ Use this after `whatsappChannel({ name: "main-whatsapp", provider: "evolution" })` exists in `agentkit.config.ts` and the capsule has been deployed.
10
+
11
+ ## Commands
12
+
13
+ ```sh
14
+ agentkit deploy
15
+ agentkit channels connect whatsapp main-whatsapp --provider evolution
16
+ agentkit channels status main-whatsapp
17
+ agentkit channels test main-whatsapp --message "hello"
18
+ agentkit channels deliveries list main-whatsapp
19
+ agentkit channels buffers list main-whatsapp
20
+ ```
21
+
22
+ Required secrets:
23
+
24
+ ```txt
25
+ EVOLUTION_API_BASE_URL
26
+ EVOLUTION_API_KEY
27
+ EVOLUTION_INSTANCE_NAME
28
+ EVOLUTION_WEBHOOK_TOKEN
29
+ ```
30
+
31
+ If WhatsApp audio transcription is enabled, also set the transcription provider secret declared by `agentkit inspect`, usually `OPENAI_API_KEY` or `GROQ_API_KEY`.
32
+
33
+ ## Minimal Working Example
34
+
35
+ ```ts
36
+ import { defineAgent, whatsappChannel } from "@andreprado/agentkit";
37
+
38
+ export default defineAgent({
39
+ name: "my-agent",
40
+ runtime: "edge",
41
+ provider: { name: "test", model: "fake" },
42
+ instructions: "./prompts/instructions.md",
43
+ secrets: [],
44
+ tools: [],
45
+ channels: [whatsappChannel({ name: "main-whatsapp", provider: "evolution" })],
46
+ access: { mode: "public" },
47
+ storage: { driver: "agentkit" },
48
+ });
49
+ ```
50
+
51
+ ## Setup Behavior
52
+
53
+ `agentkit channels connect whatsapp main-whatsapp --provider evolution` creates or updates the hosted channel, verifies managed secrets, calls Evolution API `POST /webhook/set/{instance}`, confirms the configured webhook through `GET /webhook/find/{instance}`, then runs a synthetic inbound smoke.
54
+
55
+ Expected webhook URL shape:
56
+
57
+ ```txt
58
+ https://<deploy-host>/channels/main-whatsapp/whatsapp/evolution/webhook
59
+ ```
60
+
61
+ AgentKit registers the webhook URL with the required token query parameter:
62
+
63
+ ```txt
64
+ https://<deploy-host>/channels/main-whatsapp/whatsapp/evolution/webhook?token=<EVOLUTION_WEBHOOK_TOKEN>
65
+ ```
66
+
67
+ `EVOLUTION_API_BASE_URL` must be the public HTTPS origin for the Evolution API server, for example `https://evolution.example.com`. AgentKit rejects HTTP, localhost, private-network, link-local, metadata, and credential-bearing base URLs before sending `EVOLUTION_API_KEY`.
68
+
69
+ ## Audio
70
+
71
+ Use `transcription` at the agent level and `audio.mode: "transcribe"` on the Evolution channel.
72
+
73
+ ```ts
74
+ whatsappChannel({
75
+ name: "main-whatsapp",
76
+ provider: "evolution",
77
+ audio: {
78
+ mode: "transcribe",
79
+ },
80
+ })
81
+ ```
82
+
83
+ Evolution audio webhooks become normalized audio messages. The retryable channel worker downloads media through Evolution API `POST /chat/getBase64FromMediaMessage/{instance}` and sends the bytes to AgentKit's configured transcription provider.
84
+
85
+ ## Safety Rules
86
+
87
+ - Keep phone numbers redacted in logs by default.
88
+ - Do not store Evolution API keys or webhook tokens in `agentkit.config.ts`.
89
+ - `EVOLUTION_WEBHOOK_TOKEN` is required because AgentKit V1 does not rely on an Evolution webhook body-signature contract.
90
+ - AgentKit ignores `fromMe` messages to avoid reply loops.
91
+ - Text replies call Evolution API `POST /message/sendText/{instance}` with the `apikey` header and a body containing `number` and `text`.
92
+ - Real provider success is recorded as `provider_sent` only when Evolution returns a provider message id.
93
+ - Only set `AGENTKIT_CHANNEL_SEND_DRY_RUN=1` in tests when Evolution should not receive a real message. Dry-run deliveries are recorded as `adapter_stubbed`, not sent.
94
+
95
+ ## Verification
96
+
97
+ ```sh
98
+ agentkit channels setup main-whatsapp --apply
99
+ agentkit channels status main-whatsapp
100
+ agentkit channels test main-whatsapp --message "hello"
101
+ agentkit channels test-audio main-whatsapp --fixture voice-note
102
+ agentkit channels deliveries list main-whatsapp
103
+ agentkit channels deliveries show <delivery-id>
104
+ ```
105
+
106
+ ## Troubleshooting
107
+
108
+ `channel_secret_missing`:
109
+ Set `EVOLUTION_API_BASE_URL`, `EVOLUTION_API_KEY`, `EVOLUTION_INSTANCE_NAME`, and `EVOLUTION_WEBHOOK_TOKEN` as hosted managed secrets.
110
+
111
+ `channel_signature_invalid`:
112
+ The Evolution webhook query token does not match.
113
+
114
+ `channel_provider_setup_invalid`:
115
+ `EVOLUTION_API_BASE_URL` is not an allowed public HTTPS base URL.
116
+
117
+ `channel_provider_setup_failed`:
118
+ AgentKit could not configure or verify the Evolution webhook through `/webhook/set/{instance}` and `/webhook/find/{instance}`.
119
+
120
+ `channel_audio_download_unavailable`:
121
+ Evolution did not return base64 media data from `/chat/getBase64FromMediaMessage/{instance}`, or the audio payload did not include a provider message id.
@@ -0,0 +1,139 @@
1
+ # Connect WhatsApp Through UAZAPI
2
+
3
+ ## Goal
4
+
5
+ Connect a UAZAPI WhatsApp instance to an AgentKit WhatsApp channel locally or when hosted.
6
+
7
+ ## When To Use It
8
+
9
+ Use this after `whatsappChannel({ name: "support-whatsapp", provider: "uazapi" })` exists in `agentkit.config.ts`.
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.
@@ -2,34 +2,45 @@
2
2
 
3
3
  ## Goal
4
4
 
5
- Connect a Zapster WhatsApp account to a hosted AgentKit WhatsApp channel.
5
+ Connect a Zapster WhatsApp account to an AgentKit WhatsApp channel locally or when hosted.
6
6
 
7
7
  ## When To Use It
8
8
 
9
- Use this after `whatsappChannel({ name: "support-whatsapp", provider: "zapster" })` exists in `agentkit.config.ts` and the capsule has been deployed.
9
+ Use this after `whatsappChannel({ name: "support-whatsapp", provider: "zapster" })` exists in `agentkit.config.ts`.
10
10
 
11
11
  ## Commands
12
12
 
13
13
  ```sh
14
- agentkit deploy
15
- agentkit channels add whatsapp support-whatsapp --provider zapster
16
- agentkit channels setup support-whatsapp
17
- agentkit channels status support-whatsapp
18
- agentkit channels test support-whatsapp --message "hello"
19
- agentkit channels deliveries list support-whatsapp --since 24h
14
+ node -e "process.stdout.write(require('node:crypto').randomBytes(32).toString('hex'))" | agentkit env set ZAPSTER_WEBHOOK_TOKEN --stdin
15
+ agentkit dev
20
16
  ```
21
17
 
22
18
  Required secrets:
23
19
 
24
20
  ```txt
25
21
  ZAPSTER_API_KEY
26
- ZAPSTER_WEBHOOK_SECRET
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
27
37
  ```
28
38
 
29
39
  ## Files Created Or Edited
30
40
 
31
41
  - `agentkit.config.ts`: `whatsappChannel({ name: "support-whatsapp", provider: "zapster" })`.
32
- - `.agentkit/deploy.json`: deploy state for resolving the hosted deploy.
42
+ - `.env`: ignored local provider credentials and the AgentKit-owned webhook token.
43
+ - `.agentkit/deploy.json`: deploy state only when using the hosted workflow.
33
44
  - No user-managed webhook server.
34
45
 
35
46
  ## Minimal Working Example
@@ -50,6 +61,28 @@ export default defineAgent({
50
61
  });
51
62
  ```
52
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
+
53
86
  To handle clients who send several WhatsApp messages before waiting, enable channel buffering:
54
87
 
55
88
  ```ts
@@ -66,22 +99,82 @@ whatsappChannel({
66
99
  })
67
100
  ```
68
101
 
69
- ## Setup Behavior
102
+ ## Auto Transcribe WhatsApp Audio
70
103
 
71
- `agentkit channels setup support-whatsapp` prints the stable AgentKit webhook URL. Paste it into Zapster webhook settings and configure Zapster to send the same shared secret as `ZAPSTER_WEBHOOK_SECRET`.
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.
72
152
 
73
153
  Expected webhook URL shape:
74
154
 
75
155
  ```txt
76
- https://<deploy-host>/channels/chn_<id>/whatsapp/zapster/webhook
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>
77
163
  ```
78
164
 
79
165
  ## Safety Rules
80
166
 
81
167
  - Keep phone numbers redacted in logs by default.
82
168
  - Do not store Zapster API keys in `agentkit.config.ts`.
83
- - Inbound validation uses `X-Zapster-Webhook-Secret`.
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.
84
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.
85
178
 
86
179
  ## Verification
87
180
 
@@ -90,15 +183,25 @@ agentkit channels status support-whatsapp
90
183
  agentkit channels test support-whatsapp --message "hello"
91
184
  agentkit channels deliveries list support-whatsapp
92
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>
93
190
  ```
94
191
 
95
192
  ## Troubleshooting
96
193
 
97
194
  `channel_secret_missing`:
98
- Set `ZAPSTER_API_KEY` and `ZAPSTER_WEBHOOK_SECRET` as hosted managed secrets.
195
+ Set `ZAPSTER_API_KEY`, `ZAPSTER_INSTANCE_ID`, `ZAPSTER_WEBHOOK_ID`, and `ZAPSTER_WEBHOOK_TOKEN` as secrets.
99
196
 
100
197
  `channel_signature_invalid`:
101
- Zapster is not sending the expected webhook secret.
198
+ Zapster is not sending the expected instance/webhook IDs, or the required query token does not match.
102
199
 
103
200
  `channel_unsupported_message_type` or skipped delivery:
104
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.
@@ -39,6 +39,31 @@ cd support-demo
39
39
  npm run agentkit -- tool lookup_order --input '{"orderId":"A100"}'
40
40
  ```
41
41
 
42
+ `agentkit new` can prompt for the project folder name when run in an interactive terminal:
43
+
44
+ ```sh
45
+ npx @andreprado/agentkit@alpha new
46
+ ```
47
+
48
+ Use `.` to create the capsule in the current directory:
49
+
50
+ ```sh
51
+ npx @andreprado/agentkit@alpha new . --template blank
52
+ ```
53
+
54
+ ## Windows PowerShell
55
+
56
+ If PowerShell blocks `npm.ps1` or `npx.ps1` with `PSSecurityException`, run the same commands through the Windows command shims:
57
+
58
+ ```sh
59
+ npx.cmd @andreprado/agentkit@alpha new demo --template blank
60
+ npm.cmd run typecheck
61
+ npm.cmd run chat -- --message "hello"
62
+ npm.cmd run agentkit -- inspect
63
+ ```
64
+
65
+ This keeps the capsule workflow the same without changing the machine-wide PowerShell execution policy.
66
+
42
67
  ## Files Created Or Edited
43
68
 
44
69
  Generated files:
@@ -76,7 +101,7 @@ Runtime files created after chat:
76
101
 
77
102
  ## Handoff To A Coding Agent
78
103
 
79
- The owner does not need to fill a separate brief file. The natural-language request they type into Codex, Claude Code, or another coding agent is the brief.
104
+ The owner does not need to run a brief wizard or fill a separate brief file. The natural-language request they type into Codex, Claude Code, or another coding agent is the brief.
80
105
 
81
106
  Primary flow:
82
107
 
@@ -84,9 +109,9 @@ Primary flow:
84
109
  Develop an appointment and intake agent for an ophthalmology office.
85
110
  ```
86
111
 
87
- The generated `AGENTS.md`, `AGENTKIT.md`, `CLAUDE.md`, and `skills/` pack tell the coding agent which files to edit, which task skill to load, and which verification commands to run. There is no wizard or recipe layer: the coding agent edits the capsule directly from the scaffold, contract, and owner request. The default router is `skills/agentkit-capsule/SKILL.md`; `llms-full.txt` is reserved for complete-contract checks.
112
+ The generated `AGENTS.md`, `AGENTKIT.md`, `CLAUDE.md`, and `skills/` pack tell the coding agent which files to edit, which task skill to load, and which verification commands to run. There is no AgentKit CLI wizard in the normal flow: the coding agent edits the capsule directly from the scaffold, contract, and owner request. The default router is `skills/agentkit-capsule/SKILL.md`; `llms-full.txt` is reserved for complete-contract checks.
88
113
 
89
- After the owner gives the general idea, the coding agent should create or update the implementation contract itself:
114
+ After the owner gives the general idea inside the coding-agent chat, the coding agent should create or update the implementation contract itself:
90
115
 
91
116
  ```sh
92
117
  npm run agentkit -- spec init --brief "Develop an appointment and intake agent for an ophthalmology office."
@@ -95,6 +120,8 @@ npm run agentkit -- spec check
95
120
 
96
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.
97
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.
124
+
98
125
  Optional shortcut when copying a prompt into another coding agent:
99
126
 
100
127
  ```sh
@@ -163,7 +190,7 @@ npm run agentkit -- chat-ui --deploy
163
190
 
164
191
  Open the printed `Chat:` URL and tell the owner this local UI is connected to the hosted deploy.
165
192
 
166
- `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, or another supported provider.
193
+ `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.
167
194
 
168
195
  ## Safety Rules
169
196