@andreprado/agentkit 0.1.0-alpha.10

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 +69 -0
  2. package/bin/agentkit.mjs +23 -0
  3. package/docs/guides/add-channel.md +114 -0
  4. package/docs/guides/add-knowledge.md +134 -0
  5. package/docs/guides/add-tool.md +342 -0
  6. package/docs/guides/agentkit-skills-architecture.md +471 -0
  7. package/docs/guides/channel-security.md +81 -0
  8. package/docs/guides/channels-implementation-map.md +243 -0
  9. package/docs/guides/channels-production-handoff.md +102 -0
  10. package/docs/guides/connect-telegram.md +110 -0
  11. package/docs/guides/connect-whatsapp-zapster.md +119 -0
  12. package/docs/guides/create-agent.md +220 -0
  13. package/docs/guides/prepare-deploy.md +209 -0
  14. package/docs/guides/run-evals.md +179 -0
  15. package/docs/guides/security-rules.md +156 -0
  16. package/docs/guides/use-provider.md +140 -0
  17. package/docs/llms-full.txt +876 -0
  18. package/docs/llms.txt +83 -0
  19. package/docs/portable-deploy-release-checklist.md +41 -0
  20. package/package.json +47 -0
  21. package/src/cli/args.ts +36 -0
  22. package/src/cli/cloud-client.ts +265 -0
  23. package/src/cli/commands/channels.ts +810 -0
  24. package/src/cli/commands/knowledge.ts +136 -0
  25. package/src/cli/constants.ts +4 -0
  26. package/src/cli/deploy-chat-ui.ts +392 -0
  27. package/src/cli/deploy-readiness.ts +348 -0
  28. package/src/cli/flags.ts +162 -0
  29. package/src/cli/help.ts +184 -0
  30. package/src/cli/index.ts +1276 -0
  31. package/src/cli/process.ts +31 -0
  32. package/src/cloud/artifact.ts +139 -0
  33. package/src/cloud/client.ts +79 -0
  34. package/src/cloud/contracts.ts +63 -0
  35. package/src/cloud/index.ts +3 -0
  36. package/src/create-project.ts +177 -0
  37. package/src/index.ts +408 -0
  38. package/src/providers/index.ts +25 -0
  39. package/src/providers/pi.ts +286 -0
  40. package/src/providers/test.ts +133 -0
  41. package/src/providers/types.ts +34 -0
  42. package/src/runtime/build.ts +43 -0
  43. package/src/runtime/channel-buffer.ts +30 -0
  44. package/src/runtime/channel-test-harness.ts +112 -0
  45. package/src/runtime/channels/telegram.ts +360 -0
  46. package/src/runtime/channels/website.ts +132 -0
  47. package/src/runtime/channels/whatsapp-meta.ts +71 -0
  48. package/src/runtime/channels/whatsapp-zapster.ts +278 -0
  49. package/src/runtime/channels.ts +138 -0
  50. package/src/runtime/chat.ts +218 -0
  51. package/src/runtime/config.ts +684 -0
  52. package/src/runtime/conversations.ts +38 -0
  53. package/src/runtime/core/deploy-state.ts +54 -0
  54. package/src/runtime/core/manifest.ts +213 -0
  55. package/src/runtime/core/targets.ts +133 -0
  56. package/src/runtime/database.ts +256 -0
  57. package/src/runtime/db-commands.ts +167 -0
  58. package/src/runtime/deploy-readiness.ts +105 -0
  59. package/src/runtime/deploy.ts +1 -0
  60. package/src/runtime/dev-server.ts +1247 -0
  61. package/src/runtime/docs.ts +36 -0
  62. package/src/runtime/env.ts +152 -0
  63. package/src/runtime/errors.ts +13 -0
  64. package/src/runtime/evals.ts +509 -0
  65. package/src/runtime/inspect.ts +203 -0
  66. package/src/runtime/knowledge/chunk.ts +333 -0
  67. package/src/runtime/knowledge/config.ts +135 -0
  68. package/src/runtime/knowledge/embeddings.ts +133 -0
  69. package/src/runtime/knowledge/ingest.ts +521 -0
  70. package/src/runtime/knowledge/prompt-policy.ts +30 -0
  71. package/src/runtime/knowledge/retrieve.ts +283 -0
  72. package/src/runtime/knowledge/schema.ts +56 -0
  73. package/src/runtime/knowledge/tool.ts +64 -0
  74. package/src/runtime/knowledge/vector.ts +258 -0
  75. package/src/runtime/runtime-contract.ts +93 -0
  76. package/src/runtime/spec.ts +152 -0
  77. package/src/runtime/sync.ts +144 -0
  78. package/src/runtime/targets/cloudflare/build.ts +2517 -0
  79. package/src/runtime/targets/container/build.ts +146 -0
  80. package/src/runtime/targets/container/server.ts +33 -0
  81. package/src/runtime/targets/vps/deploy.ts +206 -0
  82. package/src/runtime/tool-runner.ts +65 -0
  83. package/src/runtime/tools.ts +470 -0
  84. package/src/runtime/traces.ts +41 -0
  85. package/src/storage/sqlite.ts +1118 -0
  86. package/src/templates/blank.ts +394 -0
  87. package/src/templates/dentista.ts +1003 -0
  88. package/src/templates/index.ts +33 -0
  89. package/src/templates/skills/agentkit-build-agent/SKILL.md +51 -0
  90. package/src/templates/skills/agentkit-build-agent/templates/appointment-intake.instructions.md +20 -0
  91. package/src/templates/skills/agentkit-build-agent/templates/sales-qualifier.instructions.md +17 -0
  92. package/src/templates/skills/agentkit-build-agent/templates/support-agent.instructions.md +16 -0
  93. package/src/templates/skills/agentkit-capsule/SKILL.md +62 -0
  94. package/src/templates/skills/agentkit-capsule/references/docs-router.md +15 -0
  95. package/src/templates/skills/agentkit-channels/SKILL.md +62 -0
  96. package/src/templates/skills/agentkit-channels/references/channel-buffering.md +58 -0
  97. package/src/templates/skills/agentkit-channels/references/channel-debugging.md +41 -0
  98. package/src/templates/skills/agentkit-channels/references/telegram.md +38 -0
  99. package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +44 -0
  100. package/src/templates/skills/agentkit-database/SKILL.md +45 -0
  101. package/src/templates/skills/agentkit-database/templates/appointments.schema.sql +15 -0
  102. package/src/templates/skills/agentkit-database/templates/leads.schema.sql +17 -0
  103. package/src/templates/skills/agentkit-deploy/SKILL.md +44 -0
  104. package/src/templates/skills/agentkit-evals/SKILL.md +60 -0
  105. package/src/templates/skills/agentkit-evals/templates/multi-turn.eval.md +22 -0
  106. package/src/templates/skills/agentkit-evals/templates/no-leak.eval.md +14 -0
  107. package/src/templates/skills/agentkit-evals/templates/smoke.eval.md +14 -0
  108. package/src/templates/skills/agentkit-evals/templates/tool-call.eval.md +18 -0
  109. package/src/templates/skills/agentkit-knowledge/SKILL.md +40 -0
  110. package/src/templates/skills/agentkit-knowledge/templates/faq.md +14 -0
  111. package/src/templates/skills/agentkit-knowledge/templates/policies.md +14 -0
  112. package/src/templates/skills/agentkit-knowledge/templates/prices.csv +3 -0
  113. package/src/templates/skills/agentkit-prompts/SKILL.md +45 -0
  114. package/src/templates/skills/agentkit-prompts/templates/knowledge-grounded-faq.instructions.md +11 -0
  115. package/src/templates/skills/agentkit-provider/SKILL.md +57 -0
  116. package/src/templates/skills/agentkit-security/SKILL.md +55 -0
  117. package/src/templates/skills/agentkit-tools/SKILL.md +36 -0
  118. package/src/templates/skills/agentkit-tools/examples/database-write.tool.md +35 -0
  119. package/src/templates/skills/agentkit-tools/examples/eval-safe-external-action.tool.md +37 -0
  120. package/src/templates/skills/agentkit-tools/examples/lookup-order.tool.md +46 -0
  121. package/src/templates/skills/agentkit-troubleshooting/SKILL.md +52 -0
  122. package/src/templates/support.ts +401 -0
@@ -0,0 +1,471 @@
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.
@@ -0,0 +1,81 @@
1
+ # Channel Security
2
+
3
+ ## Goal
4
+
5
+ Keep channel webhooks, delivery logs, provider sends, and managed secrets safe by default.
6
+
7
+ ## When To Use It
8
+
9
+ Use this before adding a channel provider, changing webhook validation, adding delivery logging, or enabling real-provider smoke tests.
10
+
11
+ ## Commands
12
+
13
+ ```sh
14
+ agentkit inspect
15
+ agentkit channels status <name>
16
+ agentkit channels deliveries show <delivery-id>
17
+ bun test packages/agentkit/src/runtime/channels/adapters.test.ts
18
+ bun test packages/agentkit/src/runtime/deploy.test.ts
19
+ ```
20
+
21
+ Real-provider gates are opt-in:
22
+
23
+ ```sh
24
+ AGENTKIT_RUN_TELEGRAM_CHANNEL_TESTS=1 bun test
25
+ AGENTKIT_RUN_ZAPSTER_CHANNEL_TESTS=1 bun test
26
+ ```
27
+
28
+ Telegram smoke also requires `TELEGRAM_BOT_TOKEN`, `TELEGRAM_WEBHOOK_SECRET`, and `AGENTKIT_TELEGRAM_WEBHOOK_URL`.
29
+
30
+ Zapster smoke also requires `ZAPSTER_API_KEY`, `AGENTKIT_ZAPSTER_SEND_URL`, and `AGENTKIT_ZAPSTER_TO`.
31
+
32
+ ## Files Created Or Edited
33
+
34
+ - `agentkit.config.ts`: secret names only.
35
+ - Managed hosted secrets: production secret values, no readback.
36
+ - Delivery records: hashes, statuses, provider event IDs, redacted metadata.
37
+
38
+ ## Safety Rules
39
+
40
+ - Public webhook URLs are not permission grants.
41
+ - Validate provider authenticity when the provider supports it.
42
+ - Do not store channel plumbing in the user's Turso database.
43
+ - Do not store raw webhook bodies in delivery records; store a SHA-256 hash.
44
+ - Redact bearer tokens, bot tokens, signing secrets, provider API tokens, and phone numbers.
45
+ - Inject only channel-declared secrets into adapter code.
46
+ - Prefer acknowledging Telegram/WhatsApp over retry storms when a channel-level limit is exceeded.
47
+
48
+ ## Minimal Working Example
49
+
50
+ ```ts
51
+ telegramChannel({
52
+ name: "support-telegram",
53
+ secrets: ["TELEGRAM_BOT_TOKEN", "TELEGRAM_WEBHOOK_SECRET"],
54
+ });
55
+ ```
56
+
57
+ The config contains secret names only. Hosted responses report:
58
+
59
+ ```txt
60
+ TELEGRAM_BOT_TOKEN: set
61
+ TELEGRAM_WEBHOOK_SECRET: missing
62
+ ```
63
+
64
+ ## Verification
65
+
66
+ ```sh
67
+ bun test packages/agentkit/src/runtime/channels/adapters.test.ts
68
+ bun test packages/agentkit/src/runtime/deploy.test.ts
69
+ npm run typecheck
70
+ ```
71
+
72
+ ## Troubleshooting
73
+
74
+ Secret value appears in output:
75
+ Stop and add a regression test before changing behavior. Delivery APIs must never return secret values.
76
+
77
+ Phone number appears in delivery logs:
78
+ Redact it to a stable partial form such as `5511******9999`.
79
+
80
+ Webhook accepts invalid signatures or origin headers:
81
+ Fix `verifyWebhook` for the adapter before enabling provider setup docs.