@andreprado/agentkit 0.1.0-alpha.17 → 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.
- package/docs/guides/add-channel.md +2 -2
- package/docs/guides/add-managed-composio.md +40 -16
- package/docs/guides/channel-security.md +36 -39
- package/docs/guides/debug-channel.md +141 -0
- package/docs/guides/prepare-deploy.md +5 -10
- package/docs/llms-full.txt +8 -6
- package/docs/llms.txt +5 -3
- package/package.json +1 -3
- package/src/cli/cloud-client.ts +12 -0
- package/src/cli/deploy-chat-ui.ts +146 -3
- package/src/cli/deploy-readiness.ts +54 -1
- package/src/cli/help.ts +6 -6
- package/src/cli/index.ts +69 -4
- package/src/index.ts +4 -0
- package/src/runtime/config.ts +4 -0
- package/src/runtime/core/manifest.ts +2 -0
- package/src/runtime/inspect.ts +1 -0
- package/src/runtime/integrations/composio.ts +168 -2
- package/src/runtime/targets/cloudflare/build.ts +235 -5
- package/src/templates/skills/agentkit-integrations/SKILL.md +11 -2
- package/docs/guides/agentkit-skills-architecture.md +0 -472
- package/docs/guides/channels-implementation-map.md +0 -243
- package/docs/guides/channels-production-handoff.md +0 -118
- package/docs/portable-deploy-release-checklist.md +0 -41
|
@@ -1,472 +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
|
-
- release-lane ownership;
|
|
355
|
-
- package publishing.
|
|
356
|
-
|
|
357
|
-
Those workflows belong in maintainer skills inside the AgentKit repository, not in generated user capsules.
|
|
358
|
-
|
|
359
|
-
Suggested maintainer skills:
|
|
360
|
-
|
|
361
|
-
```txt
|
|
362
|
-
skills/agentkit-maintainer-control-plane/
|
|
363
|
-
skills/agentkit-maintainer-channels/
|
|
364
|
-
skills/agentkit-maintainer-release/
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
## Generated Capsule Shape
|
|
368
|
-
|
|
369
|
-
V1 generated capsules should contain:
|
|
370
|
-
|
|
371
|
-
```txt
|
|
372
|
-
AGENTS.md
|
|
373
|
-
AGENTKIT.md
|
|
374
|
-
CLAUDE.md
|
|
375
|
-
README.md
|
|
376
|
-
skills/
|
|
377
|
-
agentkit-capsule/
|
|
378
|
-
SKILL.md
|
|
379
|
-
references/
|
|
380
|
-
docs-router.md
|
|
381
|
-
agentkit-build-agent/
|
|
382
|
-
SKILL.md
|
|
383
|
-
templates/
|
|
384
|
-
support-agent.instructions.md
|
|
385
|
-
appointment-intake.instructions.md
|
|
386
|
-
agentkit-prompts/
|
|
387
|
-
SKILL.md
|
|
388
|
-
templates/
|
|
389
|
-
support-agent.instructions.md
|
|
390
|
-
knowledge-grounded-faq.instructions.md
|
|
391
|
-
agentkit-tools/
|
|
392
|
-
SKILL.md
|
|
393
|
-
examples/
|
|
394
|
-
lookup-order.tool.ts
|
|
395
|
-
database-write.tool.ts
|
|
396
|
-
eval-safe-external-action.tool.ts
|
|
397
|
-
agentkit-database/
|
|
398
|
-
SKILL.md
|
|
399
|
-
templates/
|
|
400
|
-
appointments.schema.sql
|
|
401
|
-
leads.schema.sql
|
|
402
|
-
agentkit-evals/
|
|
403
|
-
SKILL.md
|
|
404
|
-
templates/
|
|
405
|
-
smoke.eval.ts
|
|
406
|
-
tool-call.eval.ts
|
|
407
|
-
agentkit-deploy/
|
|
408
|
-
SKILL.md
|
|
409
|
-
agentkit-security/
|
|
410
|
-
SKILL.md
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
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.
|
|
414
|
-
|
|
415
|
-
## Handoff Changes
|
|
416
|
-
|
|
417
|
-
Change generated `AGENTS.md` and `AGENTKIT.md` from:
|
|
418
|
-
|
|
419
|
-
```txt
|
|
420
|
-
Read AGENTKIT.md and the full docs path from npm run agentkit -- docs full.
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
To:
|
|
424
|
-
|
|
425
|
-
```txt
|
|
426
|
-
Start with skills/agentkit-capsule/SKILL.md.
|
|
427
|
-
Use npm run agentkit -- docs llms as the docs router.
|
|
428
|
-
Read npm run agentkit -- docs full only when a skill tells you the complete contract is needed.
|
|
429
|
-
```
|
|
430
|
-
|
|
431
|
-
Change `agentkit handoff codex|claude` so it points to:
|
|
432
|
-
|
|
433
|
-
```txt
|
|
434
|
-
Read these files first:
|
|
435
|
-
- AGENTKIT.md
|
|
436
|
-
- skills/agentkit-capsule/SKILL.md
|
|
437
|
-
- the path printed by npm run agentkit -- docs llms
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
It should not include the concrete `llms-full.txt` path by default. It may mention that `llms-full.txt` exists for complete-contract checks.
|
|
441
|
-
|
|
442
|
-
## CLI Packaging
|
|
443
|
-
|
|
444
|
-
Keep the first version simple:
|
|
445
|
-
|
|
446
|
-
```sh
|
|
447
|
-
agentkit new <name> --template blank
|
|
448
|
-
```
|
|
449
|
-
|
|
450
|
-
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.
|
|
451
|
-
|
|
452
|
-
## Acceptance Criteria
|
|
453
|
-
|
|
454
|
-
The skills architecture is working when:
|
|
455
|
-
|
|
456
|
-
- a new capsule contains a `skills/` directory;
|
|
457
|
-
- `AGENTS.md` points to `skills/agentkit-capsule/SKILL.md`;
|
|
458
|
-
- `agentkit handoff codex` points to the skill router and `docs llms`, not `llms-full.txt`;
|
|
459
|
-
- ordinary prompt/tool/database tasks do not require loading `llms-full.txt`;
|
|
460
|
-
- each skill has focused verification commands;
|
|
461
|
-
- examples and templates live beside skills and are loaded only when needed;
|
|
462
|
-
- docs remain canonical and tests still verify packaged docs sync;
|
|
463
|
-
- user capsules do not include maintainer/operator skills by default.
|
|
464
|
-
|
|
465
|
-
## Rollout Plan
|
|
466
|
-
|
|
467
|
-
1. Add the default skill pack under `packages/agentkit/src/templates/skills` or another package-owned source directory.
|
|
468
|
-
2. Update `blank`, `support`, and `dentista` templates to copy the skill pack.
|
|
469
|
-
3. Update generated `AGENTS.md`, `AGENTKIT.md`, and `CLAUDE.md` to prefer skills and `docs llms`.
|
|
470
|
-
4. Update `agentkit handoff` to prefer the skill router.
|
|
471
|
-
5. Add tests that generated capsules contain the default skills and no longer nudge default handoff to `llms-full.txt`.
|
|
472
|
-
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_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.
|