@andreprado/agentkit 0.1.0-alpha.16 → 0.1.0-alpha.18

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 (39) hide show
  1. package/README.md +8 -0
  2. package/docs/guides/add-channel.md +4 -2
  3. package/docs/guides/add-managed-composio.md +161 -0
  4. package/docs/guides/channel-security.md +36 -39
  5. package/docs/guides/connect-telegram.md +3 -1
  6. package/docs/guides/debug-channel.md +141 -0
  7. package/docs/guides/prepare-deploy.md +7 -10
  8. package/docs/llms-full.txt +19 -5
  9. package/docs/llms.txt +11 -2
  10. package/package.json +1 -3
  11. package/src/cli/cloud-client.ts +12 -0
  12. package/src/cli/commands/channels.ts +119 -7
  13. package/src/cli/commands/transcribe.ts +171 -0
  14. package/src/cli/deploy-chat-ui.ts +146 -3
  15. package/src/cli/deploy-readiness.ts +112 -3
  16. package/src/cli/help.ts +19 -4
  17. package/src/cli/index.ts +198 -3
  18. package/src/create-project.ts +4 -32
  19. package/src/index.ts +149 -0
  20. package/src/runtime/chat.ts +2 -1
  21. package/src/runtime/config.ts +133 -0
  22. package/src/runtime/core/manifest.ts +31 -2
  23. package/src/runtime/deploy-readiness.ts +31 -1
  24. package/src/runtime/inspect.ts +109 -4
  25. package/src/runtime/integrations/composio.ts +423 -0
  26. package/src/runtime/skills.ts +95 -0
  27. package/src/runtime/targets/cloudflare/build.ts +395 -10
  28. package/src/runtime/tool-runner.ts +2 -1
  29. package/src/templates/skills/agentkit-capsule/SKILL.md +1 -0
  30. package/src/templates/skills/agentkit-channels/SKILL.md +2 -0
  31. package/src/templates/skills/agentkit-channels/references/channel-debugging.md +3 -1
  32. package/src/templates/skills/agentkit-channels/references/telegram.md +3 -1
  33. package/src/templates/skills/agentkit-deploy/SKILL.md +1 -1
  34. package/src/templates/skills/agentkit-integrations/SKILL.md +75 -0
  35. package/src/templates/skills/agentkit-troubleshooting/SKILL.md +3 -2
  36. package/docs/guides/agentkit-skills-architecture.md +0 -472
  37. package/docs/guides/channels-implementation-map.md +0 -243
  38. package/docs/guides/channels-production-handoff.md +0 -118
  39. package/docs/portable-deploy-release-checklist.md +0 -41
@@ -1,243 +0,0 @@
1
- # Channels Implementation Map
2
-
3
- Source of truth: [`../../CHANNELS_PRD.md`](../../CHANNELS_PRD.md).
4
-
5
- Use this map before implementing Channels. It identifies the current AgentKit files that should absorb the Channels contract and the blocker order from `TASKS.md`.
6
-
7
- ## Current State
8
-
9
- AgentKit already has the hosted deploy spine that Channels should extend:
10
-
11
- - Public config and exports live in `packages/agentkit/src/index.ts`.
12
- - Config loading and validation live in `packages/agentkit/src/runtime/config.ts`.
13
- - `agentkit inspect` state lives in `packages/agentkit/src/runtime/inspect.ts`.
14
- - Cloudflare artifact generation lives in `packages/agentkit/src/runtime/targets/cloudflare/build.ts`.
15
- - The CLI command switch lives in `packages/agentkit/src/cli/index.ts`.
16
- - Local AgentKit Cloud control-plane routes live in `packages/agentkit/src/runtime/deploy.ts`.
17
- - Local runtime conversation storage lives in `packages/agentkit/src/storage/sqlite.ts`.
18
-
19
- Channels should not start inside provider-specific code. The obvious implementation path is contract-first, fixture-first, then hosted ingress.
20
-
21
- ## First Files To Edit
22
-
23
- ### Config Contract
24
-
25
- Edit `packages/agentkit/src/index.ts` first.
26
-
27
- Add:
28
-
29
- - `AgentChannel`;
30
- - `WebsiteChannelConfig`;
31
- - `TelegramChannelConfig`;
32
- - `WhatsappChannelConfig`;
33
- - `ChannelType`;
34
- - `ChannelProvider`;
35
- - `websiteChannel(...)`;
36
- - `telegramChannel(...)`;
37
- - `whatsappChannel(...)`;
38
- - optional `channels?: AgentChannel[]` on `AgentConfig`.
39
-
40
- Reason: generated capsules import public helpers from `@andreprado/agentkit`, so the public contract must exist before config validation, templates, docs, or CLI commands can rely on it.
41
-
42
- ### Config Validation
43
-
44
- Edit `packages/agentkit/src/runtime/config.ts` after the public types exist.
45
-
46
- Add validation for:
47
-
48
- - lowercase stable channel names;
49
- - unique names within a capsule;
50
- - supported type/provider combinations;
51
- - required channel secret name arrays;
52
- - `runtime: "edge"` when channels are configured for hosted use;
53
- - no secret values in channel config.
54
-
55
- Tests belong in `packages/agentkit/src/runtime/config.test.ts`.
56
-
57
- ### Inspect State
58
-
59
- Edit `packages/agentkit/src/runtime/inspect.ts` after validation.
60
-
61
- Add:
62
-
63
- - channel summaries;
64
- - channel required secrets merged into the existing `secrets` status map;
65
- - no provider API values or webhook secret values.
66
-
67
- Tests belong in `packages/agentkit/src/runtime/config.test.ts` or a new focused inspect test if the file grows too large.
68
-
69
- ### Build Manifest
70
-
71
- Edit `packages/agentkit/src/runtime/targets/cloudflare/build.ts` after inspect.
72
-
73
- Add channels to:
74
-
75
- - `AgentManifest`;
76
- - `buildManifest(...)`;
77
- - generated Worker manifest JSON;
78
- - warning text if a channel needs hosted bindings that the current artifact cannot run yet.
79
-
80
- The generated Worker should not perform real channel processing until ingress/queue tasks land, but the manifest must carry enough metadata for the control plane to create resources.
81
-
82
- Tests belong in `packages/agentkit/src/runtime/build.test.ts`.
83
-
84
- ## New Runtime Modules
85
-
86
- Add `packages/agentkit/src/runtime/channels.ts` for normalized types and registry-level helpers.
87
-
88
- It should own:
89
-
90
- - `RawWebhookEvent`;
91
- - `NormalizedChannelEvent`;
92
- - `NormalizedChannelMessage`;
93
- - `ChannelAdapter`;
94
- - `ChannelSendInput`;
95
- - `ChannelSendResult`;
96
- - `WebhookVerificationInput`;
97
- - `WebhookVerificationResult`;
98
- - `ChannelStatusInput`;
99
- - `ChannelStatusResult`;
100
- - adapter lookup by channel type/provider;
101
- - shared secret redaction helpers if they are not already generic.
102
-
103
- Add adapter modules under `packages/agentkit/src/runtime/channels/`:
104
-
105
- - `website.ts`;
106
- - `telegram.ts`;
107
- - `whatsapp-zapster.ts`;
108
- - `whatsapp-meta.ts` as a compatibility stub.
109
-
110
- Add fixtures under `packages/agentkit/src/runtime/fixtures/channels/`:
111
-
112
- - `website-message.json`;
113
- - `telegram-message.json`;
114
- - `telegram-unsupported-update.json`;
115
- - `zapster-message.json`;
116
- - `zapster-unsupported-media.json`;
117
- - duplicate-event variants where useful.
118
-
119
- Default tests must use these fixtures and fake fetchers only.
120
-
121
- ## CLI Entry Points
122
-
123
- Edit `packages/agentkit/src/cli/index.ts` only after config/build/control-plane basics exist.
124
-
125
- Add a `channels` command with subcommands:
126
-
127
- - `list`;
128
- - `add`;
129
- - `setup`;
130
- - `status`;
131
- - `test`;
132
- - `deliveries list`;
133
- - `deliveries show`.
134
-
135
- Keep command behavior split:
136
-
137
- - Before deploy: read local capsule config and explain missing deploy/setup state.
138
- - After deploy: read `.agentkit/deploy.json` and call the AgentKit Cloud API.
139
-
140
- Do not make the CLI mutate real Telegram/Zapster settings in default tests. Provider mutations need explicit credentials and opt-in smoke gates.
141
-
142
- ## Control Plane
143
-
144
- Edit `packages/agentkit/src/runtime/deploy.ts` after manifest and CLI contracts are clear.
145
-
146
- Current control-plane API only serves:
147
-
148
- - `GET /health`;
149
- - `POST /v1/deploys`.
150
-
151
- Add:
152
-
153
- - `POST /v1/deploys/{deploy_id}/channels`;
154
- - `GET /v1/deploys/{deploy_id}/channels`;
155
- - `GET /v1/channels/{channel_id}`;
156
- - `DELETE /v1/channels/{channel_id}`;
157
- - public webhook routes for `/channels/{channel_name}/{type}/{provider}/webhook`, with old `chn_*` routes accepted for compatibility;
158
- - delivery inspection routes for CLI use.
159
-
160
- The local `npm run agentkit:operator -- serve` path can use an in-memory or local SQLite fake store first. Production Postgres support can follow once the contract is tested. In both stores, persist only secret names and statuses, never secret values.
161
-
162
- ## Hosted Worker And Cloudflare Bindings
163
-
164
- Edit `packages/agentkit/src/runtime/targets/cloudflare/build.ts` when adding real hosted ingress.
165
-
166
- The Worker currently handles:
167
-
168
- - `GET /_agentkit`;
169
- - `GET /`;
170
- - `POST /chat`;
171
- - Turso health/query helpers;
172
- - R2 file routes.
173
-
174
- Channels will need:
175
-
176
- - a channel ingress route;
177
- - raw body preservation for verification;
178
- - a channel coordination Durable Object for dedupe and identity mapping;
179
- - Cloudflare Queue producer and consumer bindings;
180
- - delivery state persistence or calls back to AgentKit Cloud;
181
- - redaction-aware logs.
182
-
183
- Do not put AgentKit channel plumbing in the user's Turso database. Turso remains only for the user's agent application tables.
184
-
185
- ## Storage Boundary Decision
186
-
187
- For local tests, use the AgentKit Cloud fake/control-plane store for channel resource metadata and delivery records.
188
-
189
- Use this boundary for V1 local cloud tests:
190
-
191
- | Record | Local `npm run agentkit:operator -- serve` store | Generated Worker / Durable Object / Queue contract |
192
- | --- | --- | --- |
193
- | Channel resource metadata | Yes: `channels` table or equivalent fake store keyed by `chn_...`. | Read-only manifest input after deploy. |
194
- | Channel secret references | Yes: names and `set`/`missing` status only. | Runtime receives injected secret values by name; no readback. |
195
- | Channel endpoint URL | Yes: generated from deploy URL plus stable channel name. | Worker forwards deploy ID and routes requests by channel name, type, and provider; old `chn_*` URLs remain compatibility routes. |
196
- | Channel delivery records | Yes: `deliveries` table keyed by `del_...` for CLI inspection. | Worker/consumer reports state transitions back to control plane or durable storage. |
197
- | Channel event audit records | Yes: compact event records keyed by `chevt_...`, with redacted provider metadata. | Ingress creates or reports event records after provider validation. |
198
- | External identity mappings | Fake DO-compatible store for local tests, keyed by `chid_...`. | Durable Object owns strongly consistent identity to conversation mapping. |
199
- | Dedupe keys | Fake DO-compatible store with default 14-day retention. | Durable Object owns deterministic dedupe keys and retention. |
200
- | Per-conversation ordering/backpressure | Fake DO-compatible store only when tests need it. | Durable Object owns locks and short-lived backpressure state. |
201
- | Queue payloads | In-memory fake queue drained by tests. | Cloudflare Queue owns async ingress to consumer handoff. |
202
- | Raw payload/media blobs | Do not persist by default in local tests; use fixtures. | R2 stores large raw payloads, media, exports, and debug bundles. |
203
- | User application data | Never. | Never. User application tables stay in Turso. |
204
-
205
- Use Durable Object-compatible abstractions for:
206
-
207
- - dedupe keys;
208
- - external identity to conversation ID mappings;
209
- - ordering/backpressure state.
210
-
211
- This keeps the implementation aligned with the production architecture while allowing deterministic tests without real Cloudflare bindings.
212
-
213
- The first implementation should prefer an in-memory fake store for tests unless persistence across local control-plane restarts is being tested. Production Postgres can mirror the same resource/delivery tables later, after API behavior is stable.
214
-
215
- ## Implementation Order
216
-
217
- Start with the unblocked tasks from `TASKS.md`:
218
-
219
- 1. CH-01: decide the final local fake store shape.
220
- 2. CH-02: add public channel config helpers.
221
- 3. CH-03: validate `channels` config.
222
- 4. CH-04: include channels in inspect/build manifests.
223
- 5. CH-05 and CH-06: add normalized runtime types and fixture-first adapter tests.
224
-
225
- Do not begin channel CRUD or ingress until CH-04 exists. The control plane needs channel metadata in the build manifest, otherwise hosted resources are disconnected from the deploy artifact.
226
-
227
- ## Test Strategy
228
-
229
- Default verification should stay offline:
230
-
231
- ```sh
232
- bun test
233
- npm run typecheck
234
- ```
235
-
236
- Provider tests should be opt-in:
237
-
238
- ```sh
239
- AGENTKIT_RUN_TELEGRAM_CHANNEL_TESTS=1 bun test
240
- AGENTKIT_RUN_ZAPSTER_CHANNEL_TESTS=1 bun test
241
- ```
242
-
243
- Real-provider smoke tests must document required secret names and must never print secret values.
@@ -1,118 +0,0 @@
1
- # Channels Production Handoff
2
-
3
- ## Goal
4
-
5
- Move Channels from local fake control-plane tests to production safely.
6
-
7
- ## Deployment Order
8
-
9
- 1. Build and typecheck:
10
-
11
- ```sh
12
- npm run typecheck
13
- bun test
14
- agentkit build --target cloudflare
15
- ```
16
-
17
- 2. Deploy AgentKit Cloud/control plane with:
18
-
19
- ```txt
20
- Cloudflare Worker
21
- Cloudflare Queue for channel jobs
22
- Durable Object namespace for channel coordination
23
- R2 bucket for large/raw payload handoff when enabled
24
- Turso/Postgres control-plane tables for deploys, channels, deliveries, events, and identities
25
- ```
26
-
27
- 3. Set managed secrets:
28
-
29
- ```txt
30
- OPENAI_API_KEY or another model provider key
31
- TELEGRAM_BOT_TOKEN
32
- TELEGRAM_WEBHOOK_SECRET
33
- ZAPSTER_API_KEY
34
- ZAPSTER_INSTANCE_ID
35
- ZAPSTER_WEBHOOK_ID
36
- META_WHATSAPP_ACCESS_TOKEN
37
- META_WHATSAPP_APP_SECRET
38
- META_WHATSAPP_VERIFY_TOKEN
39
- ```
40
-
41
- 4. Create channels:
42
-
43
- ```sh
44
- agentkit channels add telegram support-telegram
45
- agentkit channels add whatsapp support-whatsapp --provider zapster
46
- agentkit channels setup support-telegram --apply
47
- agentkit channels connect whatsapp support-whatsapp --provider zapster
48
- ```
49
-
50
- 5. Run smoke checks:
51
-
52
- ```sh
53
- agentkit channels status support-telegram
54
- agentkit channels test support-telegram --message "hello"
55
- agentkit channels status support-whatsapp
56
- agentkit channels test support-whatsapp --message "hello"
57
- agentkit channels deliveries list support-telegram --since 1h
58
- agentkit channels deliveries list support-whatsapp --since 1h
59
- agentkit channels buffers list support-whatsapp
60
- ```
61
-
62
- After deploy, record this exact handoff block:
63
-
64
- ```txt
65
- Deploy URL: https://<deploy-host>
66
- Telegram channel URL: https://<deploy-host>/channels/support-telegram/telegram/telegram/webhook
67
- Zapster channel URL: https://<deploy-host>/channels/support-whatsapp/whatsapp/zapster/webhook
68
- Required provider webhook settings: Telegram setWebhook URL/secret token; Zapster webhook URL plus optional ZAPSTER_WEBHOOK_TOKEN query parameter
69
- Required managed secrets: TELEGRAM_BOT_TOKEN, TELEGRAM_WEBHOOK_SECRET, ZAPSTER_API_KEY, ZAPSTER_INSTANCE_ID, ZAPSTER_WEBHOOK_ID
70
- Smoke commands: agentkit channels doctor <name>; agentkit channels test <name> --message "hello"; agentkit channels deliveries list <name> --since 1h
71
- Rollback command: curl -X DELETE "$AGENTKIT_CLOUD_API_URL/v1/channels/<channel-id>" -H "Authorization: Bearer $AGENTKIT_CLOUD_API_TOKEN"; then remove provider webhook registration before rolling back the Worker
72
- Known unverified items: any channel with no real provider inbound, no provider_sent outbound, stale buffers, or AGENTKIT_CHANNEL_SEND_DRY_RUN=1
73
- ```
74
-
75
- ## Local Fake Versus Real Provider Gates
76
-
77
- Default tests are offline and must pass without provider credentials:
78
-
79
- ```sh
80
- bun test
81
- ```
82
-
83
- Real-provider smoke tests are opt-in:
84
-
85
- ```sh
86
- AGENTKIT_RUN_TELEGRAM_CHANNEL_TESTS=1 bun test
87
- AGENTKIT_RUN_ZAPSTER_CHANNEL_TESTS=1 bun test
88
- ```
89
-
90
- Telegram smoke requires `TELEGRAM_BOT_TOKEN`, `TELEGRAM_WEBHOOK_SECRET`, and `AGENTKIT_TELEGRAM_WEBHOOK_URL`.
91
-
92
- Zapster smoke requires `ZAPSTER_API_KEY`, `ZAPSTER_INSTANCE_ID`, and `AGENTKIT_ZAPSTER_TO`. `AGENTKIT_ZAPSTER_SEND_URL` is optional and defaults to `https://api.zapsterapi.com/v1/wa/messages`.
93
-
94
- ## Smoke Checks
95
-
96
- - Unknown channel ID returns `404` and creates no tenant record.
97
- - Invalid Telegram signature or Zapster origin headers return `401` and create a failed delivery.
98
- - Duplicate provider event returns `200` with `duplicate` and creates no second queue job.
99
- - Accepted inbound text creates one queue job and one outbound delivery.
100
- - Real outbound success is `provider_sent` and includes a provider message ID. `adapter_stubbed` means dry-run mode built a request but did not call the provider.
101
- - Buffered inbound bursts stay in `buffered` state, then flush into one queue job and one outbound delivery.
102
- - Retryable failures dead-letter after the configured retry ceiling.
103
- - `channel_limit_exceeded` does not create queue backlog.
104
-
105
- ## Rollback
106
-
107
- - Disable the channel resource first; do not delete delivery history.
108
- - Remove provider webhook registration if the provider keeps retrying.
109
- - Roll back the Worker only after queue drain or pause.
110
- - Keep managed secrets; rotate only if a secret may have leaked.
111
-
112
- ## Production Defaults
113
-
114
- - Start with conservative per-channel daily message and cost limits.
115
- - For WhatsApp and Telegram agents that receive rapid client message bursts, start with `buffer.mode: "debounce"`, `quietWindowMs` between `1500` and `2500`, `maxWaitMs` between `8000` and `12000`, and strict `maxMessages`/`maxChars`.
116
- - Keep raw body storage disabled unless there is an explicit encrypted R2 retention policy.
117
- - Delivery APIs return hashes and redacted metadata, not payload bodies.
118
- - Turso remains reserved for the user's agent application data, not AgentKit channel plumbing.
@@ -1,41 +0,0 @@
1
- # Portable Deploy Release Checklist
2
-
3
- Run this before merging portable deploy target work.
4
-
5
- ## Tests
6
-
7
- ```sh
8
- bun test
9
- npm run typecheck
10
- npm run agentkit -- build --target cloudflare
11
- npm run agentkit -- build --target container
12
- npm run agentkit -- deploy --target vps --host agent.example.com --dry-run
13
- docker compose -f .agentkit/build/vps/compose.yaml config
14
- ```
15
-
16
- ## Smoke
17
-
18
- - Cloudflare build contains `worker.js`, `wrangler.jsonc`, `durable-object-schema.sql`, and `agent.manifest.json`.
19
- - Container build contains `server.js`, `Dockerfile`, `migrations/`, and `agent.manifest.json`.
20
- - VPS build contains `compose.yaml`, `.env.production.example`, `SECRETS.md`, and `PRODUCTION_HANDOFF.md`.
21
- - `/health`, `/_agentkit`, `/chat`, `/tools/:name`, `/files/:key`, and channel webhook fixtures pass on the local/container runtime.
22
-
23
- ## Secrets
24
-
25
- ```sh
26
- rg -n "sk-|OPENAI_API_KEY=.*[A-Za-z0-9]" .agentkit/build || true
27
- ```
28
-
29
- Expected: no secret values. Generated files may contain secret names only.
30
-
31
- ## Production Handoff
32
-
33
- - Cloudflare deploy has target-aware `.agentkit/deploy.json` with `target`, `runtime`, and `resources`.
34
- - VPS handoff documents `PORT`, `AGENTKIT_SQLITE_PATH`, reverse proxy expectations, smoke checks, SQLite backup, Postgres upgrade path, and rollback.
35
- - Rollback command is present in `.agentkit/build/vps/PRODUCTION_HANDOFF.md`.
36
-
37
- ## External Smokes
38
-
39
- - Cloudflare deployed smoke requires Cloudflare credentials and a provider key.
40
- - Docker image smoke requires a running Docker daemon.
41
- - Telegram/Zapster real send smoke requires explicit provider credentials.