@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
@@ -1,471 +0,0 @@
1
- # AgentKit Skills Architecture
2
-
3
- ## Recommendation
4
-
5
- Ship AgentKit skills as the default interface for the user's coding agent, while keeping the docs as the canonical source of truth.
6
-
7
- The current docs remain authoritative:
8
-
9
- ```txt
10
- docs/llms.txt short router
11
- docs/llms-full.txt complete operating contract
12
- docs/guides/*.md task guides
13
- ```
14
-
15
- Skills should become the context-efficient working surface:
16
-
17
- ```txt
18
- skills/agentkit-capsule/SKILL.md
19
- skills/agentkit-tools/SKILL.md
20
- skills/agentkit-deploy/SKILL.md
21
- ...
22
- ```
23
-
24
- The default agent path should be:
25
-
26
- ```txt
27
- AGENTS.md
28
- -> skills/agentkit-capsule/SKILL.md
29
- -> one task skill
30
- -> one reference, example, or template only when needed
31
- ```
32
-
33
- Do not make `llms-full.txt` part of the default handoff. It is the full contract and should be loaded only for ambiguous framework behavior, internals work, or broad audits.
34
-
35
- ## Problem
36
-
37
- `docs/llms-full.txt` is useful but too large for ordinary agent work. Loading it by default spends context on deploy, channels, backend contracts, evals, and storage details even when the owner only asked for a prompt change or one tool.
38
-
39
- The generated capsule files and `agentkit handoff` currently tell coding agents to read the full docs path. That is correct for completeness, but not for context economy.
40
-
41
- Skills solve this because they use progressive disclosure:
42
-
43
- - metadata is always discoverable;
44
- - `SKILL.md` loads only when the task matches;
45
- - examples, templates, scripts, and references load only when selected by the skill.
46
-
47
- ## Product Contract
48
-
49
- AgentKit should ship skills out of the box for agents that support repo-local skills.
50
-
51
- Generated capsules should include:
52
-
53
- ```txt
54
- skills/
55
- agentkit-capsule/
56
- SKILL.md
57
- references/
58
- docs-router.md
59
- ```
60
-
61
- Template-specific and task-specific skills can live either:
62
-
63
- - inside the generated capsule, for maximum out-of-the-box usability; or
64
- - inside the installed AgentKit package, copied into the capsule by `agentkit new`.
65
-
66
- The generated capsule must still include `AGENTS.md`, `AGENTKIT.md`, `CLAUDE.md`, and `README.md` for agents or tools that do not support skills.
67
-
68
- ## Skill Design Rules
69
-
70
- Each `SKILL.md` should be short and procedural. Target 300-800 words.
71
-
72
- Every skill should include:
73
-
74
- - when to use it;
75
- - files to inspect;
76
- - files it may edit;
77
- - exact commands;
78
- - safety rules;
79
- - verification;
80
- - links to optional references, examples, templates, or assets.
81
-
82
- Each skill should avoid:
83
-
84
- - duplicating whole guides;
85
- - copying large code examples into `SKILL.md`;
86
- - requiring `llms-full.txt` by default;
87
- - mixing user-capsule workflows with AgentKit maintainer/operator workflows.
88
-
89
- Use bundled resources this way:
90
-
91
- ```txt
92
- references/ deeper task notes loaded only when needed
93
- examples/ source examples the agent may inspect
94
- templates/ starter files the agent may copy and adapt
95
- scripts/ deterministic helpers for fragile/repeated tasks
96
- assets/ files used as output resources
97
- ```
98
-
99
- ## Core Skills To Ship
100
-
101
- ### agentkit-capsule
102
-
103
- The always-first router for work inside an Agent Capsule.
104
-
105
- Use when the agent detects `agentkit.config.ts` or the owner asks to build/change an AgentKit agent.
106
-
107
- Responsibilities:
108
-
109
- - establish the capsule root as the runtime boundary;
110
- - read `AGENTS.md` or `AGENTKIT.md`;
111
- - route to one task skill;
112
- - prefer `agentkit docs llms` over `agentkit docs full`;
113
- - load `llms-full.txt` only when the task needs the complete contract;
114
- - run the baseline checks before completion.
115
-
116
- Default verification:
117
-
118
- ```sh
119
- npm run typecheck
120
- npm run agentkit -- inspect
121
- npm run chat -- --message "hello"
122
- ```
123
-
124
- ### agentkit-build-agent
125
-
126
- Use when the owner gives a natural-language brief for a new or changed agent.
127
-
128
- Responsibilities:
129
-
130
- - translate the brief into prompt, tools, schema, evals, and assumptions;
131
- - keep the first useful version runnable with `test/fake` unless the owner chooses a real provider;
132
- - create domain-specific local behavior without waiting for a wizard;
133
- - add evals for the expected first behavior.
134
-
135
- Likely templates:
136
-
137
- ```txt
138
- templates/support-agent.instructions.md
139
- templates/appointment-intake.instructions.md
140
- templates/sales-qualifier.instructions.md
141
- templates/internal-operations.instructions.md
142
- ```
143
-
144
- ### agentkit-prompts
145
-
146
- Use when editing `prompts/instructions.md` or designing the agent's behavior.
147
-
148
- Responsibilities:
149
-
150
- - define role, boundaries, escalation rules, tone, and tool-use policy;
151
- - prevent false claims about actions not performed;
152
- - describe when to use Knowledge versus tools;
153
- - keep user-facing behavior specific to the owner's domain.
154
-
155
- Likely templates:
156
-
157
- ```txt
158
- templates/knowledge-grounded-faq.instructions.md
159
- templates/appointment-intake.instructions.md
160
- templates/support-agent.instructions.md
161
- ```
162
-
163
- ### agentkit-tools
164
-
165
- Use when adding or changing TypeScript tools.
166
-
167
- Responsibilities:
168
-
169
- - create `defineTool` tools with input/output schemas;
170
- - register tools in `agentkit.config.ts`;
171
- - declare tool secrets and permissions;
172
- - add timeouts;
173
- - test tools directly;
174
- - keep eval runs deterministic and non-destructive.
175
-
176
- Likely examples:
177
-
178
- ```txt
179
- examples/lookup-order.tool.ts
180
- examples/external-api-lookup.tool.ts
181
- examples/eval-safe-send-email.tool.ts
182
- ```
183
-
184
- Primary reference: `docs/guides/add-tool.md`.
185
-
186
- ### agentkit-database
187
-
188
- Use when adding agent-owned tables or database-backed tools.
189
-
190
- Responsibilities:
191
-
192
- - edit `schema.sql`;
193
- - keep schema changes idempotent;
194
- - use `ctx.db` in tools;
195
- - avoid local database driver imports;
196
- - run local migration/seed/shell checks;
197
- - preserve deploy-compatible `storage.driver: "agentkit"`.
198
-
199
- Likely templates:
200
-
201
- ```txt
202
- templates/appointments.schema.sql
203
- templates/leads.schema.sql
204
- templates/tickets.schema.sql
205
- templates/notes.schema.sql
206
- ```
207
-
208
- Primary reference: `docs/guides/add-tool.md` database section and `docs/guides/prepare-deploy.md`.
209
-
210
- ### agentkit-knowledge
211
-
212
- Use when the agent should answer from committed source files such as FAQs, prices, policies, CSVs, and procedures.
213
-
214
- Responsibilities:
215
-
216
- - create `knowledge/` sources;
217
- - configure `knowledge.sources`;
218
- - choose lexical search by default;
219
- - configure embeddings only when needed;
220
- - verify with `knowledge sync` and `knowledge search`;
221
- - keep secrets and live customer data out of Knowledge.
222
-
223
- Likely templates:
224
-
225
- ```txt
226
- templates/faq.md
227
- templates/prices.csv
228
- templates/policies.md
229
- ```
230
-
231
- Primary reference: `docs/guides/add-knowledge.md`.
232
-
233
- ### agentkit-provider
234
-
235
- Use when switching from `test/fake` to a real provider.
236
-
237
- Responsibilities:
238
-
239
- - ask the owner which provider to use;
240
- - update `agentkit.config.ts`;
241
- - update `.env.schema`;
242
- - set local secrets through AgentKit commands;
243
- - verify with chat, inspect, and UI;
244
- - never import provider SDKs into the capsule.
245
-
246
- Primary reference: `docs/guides/use-provider.md`.
247
-
248
- ### agentkit-evals
249
-
250
- Use when adding or running evals.
251
-
252
- Responsibilities:
253
-
254
- - create `evals/*.eval.ts`;
255
- - use deterministic assertions;
256
- - verify persisted tool calls;
257
- - avoid real PII and secrets;
258
- - guard external side effects with `ctx.runtime.environment === "eval"`;
259
- - run `npm run eval`.
260
-
261
- Likely templates:
262
-
263
- ```txt
264
- templates/smoke.eval.ts
265
- templates/tool-call.eval.ts
266
- templates/no-leak.eval.ts
267
- templates/knowledge-answer.eval.ts
268
- ```
269
-
270
- Primary reference: `docs/guides/run-evals.md`.
271
-
272
- ### agentkit-deploy
273
-
274
- Use when preparing or running hosted deploy.
275
-
276
- Responsibilities:
277
-
278
- - run readiness checks;
279
- - keep hosting target selection inside AgentKit;
280
- - use managed secrets, not committed `.env`;
281
- - run `deploy doctor`;
282
- - run `deploy --smoke`;
283
- - run hosted UI checks;
284
- - report production handoff details when deploy is ready.
285
-
286
- Primary reference: `docs/guides/prepare-deploy.md`.
287
-
288
- ### agentkit-security
289
-
290
- Use before or during any work involving secrets, external APIs, tools, evals from conversations, public access, channels, or hosted deploys.
291
-
292
- Responsibilities:
293
-
294
- - prevent `.env`, `.agentkit/`, and secret values from being committed;
295
- - enforce secret-name-only config;
296
- - confirm tool secrets and permissions;
297
- - check access mode assumptions;
298
- - require redaction for client data.
299
-
300
- Primary reference: `docs/guides/security-rules.md`.
301
-
302
- ### agentkit-channels
303
-
304
- Use when adding, connecting, testing, or debugging website, Telegram, or WhatsApp channels.
305
-
306
- Responsibilities:
307
-
308
- - add channel config helpers;
309
- - deploy before hosted channel creation;
310
- - manage provider secret names;
311
- - verify setup/status/test/delivery logs;
312
- - separate channels from tools;
313
- - debug webhook and delivery errors without leaking provider payloads.
314
-
315
- Likely references:
316
-
317
- ```txt
318
- references/telegram.md
319
- references/whatsapp-zapster.md
320
- references/channel-debugging.md
321
- ```
322
-
323
- Primary references:
324
-
325
- - `docs/guides/add-channel.md`
326
- - `docs/guides/connect-telegram.md`
327
- - `docs/guides/connect-whatsapp-zapster.md`
328
- - `docs/guides/debug-channel.md`
329
- - `docs/guides/channel-security.md`
330
-
331
- ### agentkit-troubleshooting
332
-
333
- Use when AgentKit commands fail or the agent is unsure which task skill applies.
334
-
335
- Responsibilities:
336
-
337
- - start from the error code;
338
- - run `inspect`;
339
- - check config, secrets, package install, provider, storage, and channel state;
340
- - route to a more specific skill;
341
- - load `llms-full.txt` only when narrower references cannot explain the behavior.
342
-
343
- Primary reference: `docs/llms-full.txt` troubleshooting section.
344
-
345
- ## Maintainer-Only Skills
346
-
347
- Do not ship these into user capsules by default:
348
-
349
- - control-plane deploy;
350
- - operator dashboard;
351
- - account grant/revoke;
352
- - backend contract implementation;
353
- - Cloudflare/Turso/R2 provisioning internals;
354
- - package publishing.
355
-
356
- Those workflows belong in maintainer skills inside the AgentKit repository, not in generated user capsules.
357
-
358
- Suggested maintainer skills:
359
-
360
- ```txt
361
- skills/agentkit-maintainer-control-plane/
362
- skills/agentkit-maintainer-channels/
363
- skills/agentkit-maintainer-release/
364
- ```
365
-
366
- ## Generated Capsule Shape
367
-
368
- V1 generated capsules should contain:
369
-
370
- ```txt
371
- AGENTS.md
372
- AGENTKIT.md
373
- CLAUDE.md
374
- README.md
375
- skills/
376
- agentkit-capsule/
377
- SKILL.md
378
- references/
379
- docs-router.md
380
- agentkit-build-agent/
381
- SKILL.md
382
- templates/
383
- support-agent.instructions.md
384
- appointment-intake.instructions.md
385
- agentkit-prompts/
386
- SKILL.md
387
- templates/
388
- support-agent.instructions.md
389
- knowledge-grounded-faq.instructions.md
390
- agentkit-tools/
391
- SKILL.md
392
- examples/
393
- lookup-order.tool.ts
394
- database-write.tool.ts
395
- eval-safe-external-action.tool.ts
396
- agentkit-database/
397
- SKILL.md
398
- templates/
399
- appointments.schema.sql
400
- leads.schema.sql
401
- agentkit-evals/
402
- SKILL.md
403
- templates/
404
- smoke.eval.ts
405
- tool-call.eval.ts
406
- agentkit-deploy/
407
- SKILL.md
408
- agentkit-security/
409
- SKILL.md
410
- ```
411
-
412
- Channel, Knowledge, provider, and troubleshooting skills are copied into every generated capsule. Since skills are context-lazy, the main tradeoff is filesystem size, not context usage.
413
-
414
- ## Handoff Changes
415
-
416
- Change generated `AGENTS.md` and `AGENTKIT.md` from:
417
-
418
- ```txt
419
- Read AGENTKIT.md and the full docs path from npm run agentkit -- docs full.
420
- ```
421
-
422
- To:
423
-
424
- ```txt
425
- Start with skills/agentkit-capsule/SKILL.md.
426
- Use npm run agentkit -- docs llms as the docs router.
427
- Read npm run agentkit -- docs full only when a skill tells you the complete contract is needed.
428
- ```
429
-
430
- Change `agentkit handoff codex|claude` so it points to:
431
-
432
- ```txt
433
- Read these files first:
434
- - AGENTKIT.md
435
- - skills/agentkit-capsule/SKILL.md
436
- - the path printed by npm run agentkit -- docs llms
437
- ```
438
-
439
- It should not include the concrete `llms-full.txt` path by default. It may mention that `llms-full.txt` exists for complete-contract checks.
440
-
441
- ## CLI Packaging
442
-
443
- Keep the first version simple:
444
-
445
- ```sh
446
- agentkit new <name> --template blank
447
- ```
448
-
449
- The generated capsule receives the default skill pack automatically. Add `agentkit skills list/install` later only if users need to refresh or extend skill packs in existing capsules.
450
-
451
- ## Acceptance Criteria
452
-
453
- The skills architecture is working when:
454
-
455
- - a new capsule contains a `skills/` directory;
456
- - `AGENTS.md` points to `skills/agentkit-capsule/SKILL.md`;
457
- - `agentkit handoff codex` points to the skill router and `docs llms`, not `llms-full.txt`;
458
- - ordinary prompt/tool/database tasks do not require loading `llms-full.txt`;
459
- - each skill has focused verification commands;
460
- - examples and templates live beside skills and are loaded only when needed;
461
- - docs remain canonical and tests still verify packaged docs sync;
462
- - user capsules do not include maintainer/operator skills by default.
463
-
464
- ## Rollout Plan
465
-
466
- 1. Add the default skill pack under `packages/agentkit/src/templates/skills` or another package-owned source directory.
467
- 2. Update `blank`, `support`, and `dentista` templates to copy the skill pack.
468
- 3. Update generated `AGENTS.md`, `AGENTKIT.md`, and `CLAUDE.md` to prefer skills and `docs llms`.
469
- 4. Update `agentkit handoff` to prefer the skill router.
470
- 5. Add tests that generated capsules contain the default skills and no longer nudge default handoff to `llms-full.txt`.
471
- 6. Keep `agentkit docs full` available for complete-contract audits.
@@ -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_id}/{type}/{provider}/webhook`;
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 ID. | Worker routes requests by channel ID, type, and provider. |
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.