@andreprado/agentkit 0.1.1 → 0.2.0
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/README.md +8 -77
- package/docs/guides/add-channel.md +14 -92
- package/docs/guides/add-knowledge.md +0 -21
- package/docs/guides/add-tool.md +5 -11
- package/docs/guides/channel-security.md +3 -207
- package/docs/guides/connect-discord.md +7 -172
- package/docs/guides/connect-slack.md +6 -121
- package/docs/guides/connect-telegram.md +6 -165
- package/docs/guides/connect-whatsapp-evolution.md +6 -116
- package/docs/guides/connect-whatsapp-uazapi.md +6 -134
- package/docs/guides/connect-whatsapp-zapster.md +6 -202
- package/docs/guides/create-agent.md +5 -14
- package/docs/guides/debug-channel.md +4 -156
- package/docs/guides/improve-local.md +13 -0
- package/docs/guides/local-only-migration.md +35 -0
- package/docs/guides/replay-local-traces.md +11 -0
- package/docs/guides/run-evals.md +2 -4
- package/docs/guides/security-rules.md +5 -154
- package/docs/guides/use-jev.md +3 -6
- package/docs/guides/use-provider.md +0 -3
- package/docs/guides/write-feedback.md +10 -0
- package/docs/llms-full.txt +27 -448
- package/docs/llms.txt +8 -44
- package/package.json +2 -4
- package/src/cli/commands/channels.ts +8 -1613
- package/src/cli/commands/feedback.ts +8 -86
- package/src/cli/constants.ts +0 -3
- package/src/cli/flags.ts +0 -28
- package/src/cli/help.ts +16 -92
- package/src/cli/index.ts +15 -1091
- package/src/index.ts +6 -158
- package/src/providers/pi.ts +2 -0
- package/src/runtime/channels/discord.ts +2 -2
- package/src/runtime/chat.ts +5 -3
- package/src/runtime/config.ts +14 -148
- package/src/runtime/database.ts +2 -2
- package/src/runtime/dev-server.ts +8 -8
- package/src/runtime/env.ts +11 -0
- package/src/runtime/improve.ts +2 -262
- package/src/runtime/inspect.ts +13 -73
- package/src/runtime/knowledge/ingest.ts +1 -1
- package/src/runtime/knowledge/tool.ts +16 -2
- package/src/runtime/knowledge/vector.ts +1 -1
- package/src/runtime/tool-runner.ts +5 -3
- package/src/runtime/tools.ts +10 -14
- package/src/storage/sqlite.ts +11 -32
- package/src/templates/blank.ts +15 -102
- package/src/templates/common.ts +60 -0
- package/src/templates/dentista.ts +7 -74
- package/src/templates/skills/agentkit-capsule/SKILL.md +5 -7
- package/src/templates/skills/agentkit-capsule/references/docs-router.md +2 -3
- package/src/templates/skills/agentkit-channels/SKILL.md +6 -119
- package/src/templates/skills/agentkit-channels/references/channel-buffering.md +0 -9
- package/src/templates/skills/agentkit-channels/references/channel-debugging.md +1 -64
- package/src/templates/skills/agentkit-channels/references/discord.md +2 -92
- package/src/templates/skills/agentkit-channels/references/slack.md +2 -55
- package/src/templates/skills/agentkit-channels/references/telegram.md +2 -71
- package/src/templates/skills/agentkit-channels/references/whatsapp-evolution.md +2 -56
- package/src/templates/skills/agentkit-channels/references/whatsapp-uazapi.md +2 -53
- package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +2 -70
- package/src/templates/skills/agentkit-database/SKILL.md +2 -4
- package/src/templates/skills/agentkit-evals/SKILL.md +1 -1
- package/src/templates/skills/agentkit-improve/SKILL.md +6 -85
- package/src/templates/skills/agentkit-improve/references/trace-packets.md +1 -1
- package/src/templates/skills/agentkit-provider/SKILL.md +0 -1
- package/src/templates/skills/agentkit-security/SKILL.md +1 -3
- package/src/templates/skills/agentkit-tools/SKILL.md +1 -1
- package/src/templates/skills/agentkit-tools/examples/database-write.tool.md +1 -2
- package/src/templates/skills/agentkit-troubleshooting/SKILL.md +5 -11
- package/src/templates/support.ts +8 -92
- package/docs/guides/add-managed-composio.md +0 -165
- package/docs/guides/improve-from-production.md +0 -151
- package/docs/guides/prepare-deploy.md +0 -227
- package/docs/guides/replay-production-traces.md +0 -72
- package/docs/guides/send-feedback.md +0 -135
- package/src/cli/cloud-client.ts +0 -377
- package/src/cli/deploy-chat-ui.ts +0 -606
- package/src/cli/deploy-readiness.ts +0 -561
- package/src/cloud/artifact.ts +0 -139
- package/src/cloud/client.ts +0 -80
- package/src/cloud/contracts.ts +0 -63
- package/src/cloud/index.ts +0 -3
- package/src/runtime/build.ts +0 -43
- package/src/runtime/core/deploy-state.ts +0 -54
- package/src/runtime/core/manifest.ts +0 -283
- package/src/runtime/core/targets.ts +0 -133
- package/src/runtime/deploy-readiness.ts +0 -135
- package/src/runtime/deploy.ts +0 -1
- package/src/runtime/integrations/composio.ts +0 -425
- package/src/runtime/targets/cloudflare/build.ts +0 -3319
- package/src/runtime/targets/container/build.ts +0 -146
- package/src/runtime/targets/container/server.ts +0 -33
- package/src/runtime/targets/vps/deploy.ts +0 -223
- package/src/templates/skills/agentkit-deploy/SKILL.md +0 -52
- package/src/templates/skills/agentkit-integrations/SKILL.md +0 -98
package/README.md
CHANGED
|
@@ -1,86 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @andreprado/agentkit
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
3
|
+
Create and run local Agent Capsules with prompts, TypeScript tools, evals, SQLite storage, knowledge retrieval, and channel adapters.
|
|
6
4
|
|
|
7
5
|
```sh
|
|
8
|
-
npx @andreprado/agentkit
|
|
9
|
-
cd
|
|
6
|
+
npx @andreprado/agentkit new my-agent --template blank
|
|
7
|
+
cd my-agent
|
|
10
8
|
npm run dev
|
|
11
9
|
npm run chat -- --message "hello"
|
|
10
|
+
npm run agentkit -- inspect
|
|
12
11
|
```
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```sh
|
|
17
|
-
npx @andreprado/agentkit@alpha new clara-dentista --template dentista
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
`agentkit new` installs the generated capsule dependencies by default so `agentkit.config.ts` resolves `@andreprado/agentkit` immediately in editors. Use `--no-install` only for offline or scripted scaffolds where you want to run `npm install` later.
|
|
21
|
-
|
|
22
|
-
Generated capsules use the built-in `test/fake` provider by default, so the first local run works without provider keys.
|
|
23
|
-
|
|
24
|
-
## What To Know First
|
|
25
|
-
|
|
26
|
-
```sh
|
|
27
|
-
agentkit new [name] [--template blank|support|dentista] [--no-install]
|
|
28
|
-
agentkit new .
|
|
29
|
-
agentkit dev
|
|
30
|
-
agentkit chat --message <text> [--conversation-id <id>]
|
|
31
|
-
agentkit inspect
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Run `agentkit new` without a name in an interactive terminal to be prompted for the project folder. Use `agentkit new .` to create the capsule in the current directory.
|
|
35
|
-
|
|
36
|
-
Once the capsule is running:
|
|
37
|
-
|
|
38
|
-
```sh
|
|
39
|
-
agentkit tool <name> [--input <path-or-json>]
|
|
40
|
-
agentkit knowledge add <path-or-url>
|
|
41
|
-
agentkit knowledge sync
|
|
42
|
-
agentkit knowledge search <query> [--top-k <number>]
|
|
43
|
-
agentkit integrations status
|
|
44
|
-
agentkit integrations connect composio --toolkit gmail
|
|
45
|
-
agentkit spec init --brief <text>
|
|
46
|
-
agentkit db migrate
|
|
47
|
-
agentkit sync run
|
|
48
|
-
agentkit eval run
|
|
49
|
-
agentkit eval from-conversation <conversation-id>
|
|
50
|
-
agentkit improve collect --deploy --since 24h
|
|
51
|
-
agentkit improve evals .agentkit/improve/<run>
|
|
52
|
-
agentkit replay .agentkit/improve/<run> --against local
|
|
53
|
-
agentkit conversations list
|
|
54
|
-
agentkit conversations trace <conversation-id>
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Knowledge indexes local `.md`, `.txt`, and `.csv` sources into the capsule database and registers the internal `agentkit_search_knowledge` chat tool when `knowledge` is configured in `agentkit.config.ts`. `agentkit dev` and `agentkit chat` sync configured sources automatically; when embeddings are configured, local semantic search uses a libSQL vector sidecar. Hosted Cloudflare deploys package configured local Knowledge sources and sync them into the project Turso database automatically during `agentkit deploy`; when embeddings are configured, the deploy also creates and populates the hosted Turso vector index.
|
|
58
|
-
|
|
59
|
-
Every chat run receives dynamic runtime date context: current ISO timestamp, local date, weekday, local date/time, and timezone. Set `timeZone` in `agentkit.config.ts` for scheduling agents so relative dates like "today" and "next Friday" resolve in the right business/user timezone.
|
|
60
|
-
|
|
61
|
-
AgentKit-managed Composio is a paid hosted integration layer for per-agent connected apps. Configure it with `composioManaged({...})`, deploy with a `managed_composio` entitlement, then use `agentkit integrations connect composio --toolkit <slug>` to create hosted Connect Links. BYO Composio remains available through normal `defineTool` wrappers.
|
|
62
|
-
|
|
63
|
-
## Deploy Later
|
|
64
|
-
|
|
65
|
-
```sh
|
|
66
|
-
agentkit login --token <token>
|
|
67
|
-
agentkit deploy doctor
|
|
68
|
-
agentkit skills status
|
|
69
|
-
agentkit secret set OPENAI_API_KEY --from-local-env
|
|
70
|
-
agentkit deploy
|
|
71
|
-
agentkit deploy status
|
|
72
|
-
agentkit channels test support-telegram --message "hello"
|
|
73
|
-
agentkit channels connect webhook n8n-webhook
|
|
74
|
-
agentkit transcribe smoke --provider groq
|
|
75
|
-
agentkit chat-ui --deploy
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Production secrets are managed secrets, not committed `.env` values.
|
|
79
|
-
After upgrading AgentKit in an existing capsule, run `agentkit skills status` and `agentkit skills sync` if local agent-facing skills are stale.
|
|
80
|
-
Private hosted deploys automatically store a local chat/UI deploy access token at `.agentkit/chat-access-token.json`. `agentkit chat-ui --deploy` serves a local UI pointed at the hosted deploy without exposing that token to browser code.
|
|
81
|
-
|
|
82
|
-
The npm package contains the public CLI/runtime/client surface only. AgentKit Cloud's control-plane server, operator commands, Postgres store, and Cloudflare/Turso/R2 publisher live in the private repo workspace and are not part of the published package.
|
|
13
|
+
Requires Node 24+. Capsules start with the deterministic `test/fake` provider. Choose a real provider before testing conversation quality; provider adapters use Pi. Store local credentials with `agentkit env set <NAME> --stdin` and connect external services through `defineTool`.
|
|
83
14
|
|
|
84
|
-
|
|
15
|
+
Run `agentkit docs llms` for the docs router or `agentkit docs full` for the operating contract. Existing capsules should read `docs/guides/local-only-migration.md` when upgrading from a version with hosted features.
|
|
85
16
|
|
|
86
|
-
|
|
17
|
+
AgentKit runs locally. Channel webhooks can use an authenticated HTTPS tunnel while the local process is running. No account, billing, managed hosting, or deployment service is included.
|
|
@@ -2,45 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Goal
|
|
4
4
|
|
|
5
|
-
Add a
|
|
5
|
+
Add a local messaging channel to an Agent Capsule, create the local channel resource, and verify that inbound messages become AgentKit channel deliveries without exposing secrets.
|
|
6
6
|
|
|
7
7
|
## When To Use It
|
|
8
8
|
|
|
9
9
|
Use this when the agent should receive messages from website chat, Telegram, WhatsApp, Discord, Slack, or a generic webhook through AgentKit-owned channel infrastructure, or when an inbound channel should reply through another configured channel.
|
|
10
10
|
|
|
11
|
-
## Commands
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
agentkit inspect
|
|
15
|
-
agentkit deploy
|
|
16
|
-
agentkit channels list
|
|
17
|
-
agentkit channels add website website-chat
|
|
18
|
-
agentkit channels add telegram support-telegram
|
|
19
|
-
agentkit channels connect discord support-discord
|
|
20
|
-
agentkit channels connect discord server-discord --mode bot
|
|
21
|
-
agentkit channels connect slack support-slack
|
|
22
|
-
agentkit channels connect webhook n8n-webhook
|
|
23
|
-
agentkit channels add whatsapp support-whatsapp --provider zapster
|
|
24
|
-
agentkit channels connect whatsapp support-uazapi --provider uazapi
|
|
25
|
-
agentkit channels connect whatsapp main-whatsapp --provider evolution
|
|
26
|
-
agentkit channels setup support-telegram
|
|
27
|
-
agentkit channels status support-telegram
|
|
28
|
-
agentkit channels test support-telegram --message "hello"
|
|
29
|
-
agentkit channels deliveries list support-telegram
|
|
30
|
-
agentkit channels buffers list support-telegram
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Use `--api <url>` only when the owner gives you a non-default AgentKit Cloud API URL.
|
|
34
|
-
|
|
35
|
-
## Files Created Or Edited
|
|
36
|
-
|
|
37
|
-
- `agentkit.config.ts`: declare channel config with `websiteChannel`, `telegramChannel`, `whatsappChannel`, `discordChannel`, `slackChannel`, `webhookChannel`, or `webhookOutputChannel`.
|
|
38
|
-
- `.agentkit/deploy.json`: written by `agentkit deploy`; used by `agentkit channels ...`.
|
|
39
|
-
- No user Turso tables: AgentKit owns channel resources, dedupe, identities, queue state, and delivery logs.
|
|
40
|
-
- Website channel clients must send `AGENTKIT_WEBSITE_CHANNEL_TOKEN` as `Authorization: Bearer <token>` or `X-AgentKit-Channel-Token`.
|
|
41
|
-
- Generic inbound webhook clients must send `AGENTKIT_WEBHOOK_SECRET` as `Authorization: Bearer <token>`, `X-AgentKit-Webhook-Secret`, or `X-AgentKit-Webhook-Signature: sha256=<hmac>`.
|
|
42
|
-
- Generic outbound webhook channels send replies to an HTTPS URL stored in a managed secret such as `CRM_CALLBACK_URL`.
|
|
43
|
-
|
|
44
11
|
## Minimal Working Example
|
|
45
12
|
|
|
46
13
|
```ts
|
|
@@ -48,7 +15,7 @@ import { defineAgent, discordChannel, slackChannel, telegramChannel, webhookChan
|
|
|
48
15
|
|
|
49
16
|
export default defineAgent({
|
|
50
17
|
name: "support-agent",
|
|
51
|
-
runtime: "
|
|
18
|
+
runtime: "local",
|
|
52
19
|
provider: { name: "test", model: "fake" },
|
|
53
20
|
instructions: "./prompts/instructions.md",
|
|
54
21
|
secrets: [],
|
|
@@ -59,8 +26,7 @@ export default defineAgent({
|
|
|
59
26
|
whatsappChannel({ name: "support-whatsapp", provider: "zapster" }),
|
|
60
27
|
whatsappChannel({ name: "support-uazapi", provider: "uazapi" }),
|
|
61
28
|
whatsappChannel({ name: "main-whatsapp", provider: "evolution" }),
|
|
62
|
-
discordChannel({ name: "support-discord" }),
|
|
63
|
-
discordChannel({ name: "server-discord", mode: "bot" }),
|
|
29
|
+
discordChannel({ name: "support-discord", mode: "interactions" }),
|
|
64
30
|
slackChannel({ name: "support-slack" }),
|
|
65
31
|
webhookChannel({ name: "n8n-webhook" }),
|
|
66
32
|
webhookOutputChannel({ name: "crm-callback", urlSecret: "CRM_CALLBACK_URL" }),
|
|
@@ -94,15 +60,8 @@ Use `buffer: { mode: "off" }` or omit `buffer` to process each inbound message a
|
|
|
94
60
|
|
|
95
61
|
Buffer controls:
|
|
96
62
|
|
|
97
|
-
```sh
|
|
98
|
-
agentkit channels buffers list support-whatsapp
|
|
99
|
-
agentkit channels buffers show support-whatsapp <conversation-id>
|
|
100
|
-
agentkit channels buffers flush support-whatsapp <conversation-id>
|
|
101
|
-
agentkit channels buffers clear support-whatsapp <conversation-id>
|
|
102
|
-
agentkit channels buffers retry support-whatsapp <conversation-id>
|
|
103
|
-
```
|
|
104
63
|
|
|
105
|
-
Discord supports buffering for slash-command interactions
|
|
64
|
+
Discord supports buffering for slash-command interactions. Bot-mode server messages require your own Gateway bridge: AgentKit does not listen to the Gateway, and inviting a bot alone will not deliver messages. `agentkit inspect` warns when bot mode is configured. See [Connect Discord](connect-discord.md). Discord does not support `audio` in V1.
|
|
106
65
|
|
|
107
66
|
## Generic Webhooks
|
|
108
67
|
|
|
@@ -114,16 +73,13 @@ webhookChannel({
|
|
|
114
73
|
})
|
|
115
74
|
```
|
|
116
75
|
|
|
117
|
-
|
|
76
|
+
With the local process and HTTPS tunnel running:
|
|
118
77
|
|
|
119
|
-
```sh
|
|
120
|
-
agentkit channels connect webhook n8n-webhook
|
|
121
|
-
```
|
|
122
78
|
|
|
123
|
-
The
|
|
79
|
+
The local webhook URL is:
|
|
124
80
|
|
|
125
81
|
```txt
|
|
126
|
-
https://<
|
|
82
|
+
https://<tunnel-host>/channels/n8n-webhook/webhook
|
|
127
83
|
```
|
|
128
84
|
|
|
129
85
|
Send canonical JSON:
|
|
@@ -141,7 +97,7 @@ Send canonical JSON:
|
|
|
141
97
|
Authenticate with a shared secret:
|
|
142
98
|
|
|
143
99
|
```sh
|
|
144
|
-
curl -X POST https://<
|
|
100
|
+
curl -X POST https://<tunnel-host>/channels/n8n-webhook/webhook \
|
|
145
101
|
-H 'content-type: application/json' \
|
|
146
102
|
-H 'authorization: Bearer <AGENTKIT_WEBHOOK_SECRET>' \
|
|
147
103
|
-d '{"event_id":"evt_123","external_id":"customer_123","message":"hello from n8n"}'
|
|
@@ -220,7 +176,7 @@ webhookChannel({
|
|
|
220
176
|
})
|
|
221
177
|
```
|
|
222
178
|
|
|
223
|
-
Set `CRM_CALLBACK_URL`
|
|
179
|
+
Set `CRM_CALLBACK_URL` in local `.env`. It must be a public HTTPS URL; AgentKit rejects localhost, private network, link-local, and metadata-service hosts before sending. Supported output auth modes are `none`, `bearer`, `header`, and `hmac`, and all auth values come from local `.env`.
|
|
224
180
|
|
|
225
181
|
Outbound generic webhook requests contain the agent's final text answer:
|
|
226
182
|
|
|
@@ -238,7 +194,6 @@ Outbound generic webhook requests contain the agent's final text answer:
|
|
|
238
194
|
}
|
|
239
195
|
```
|
|
240
196
|
|
|
241
|
-
Generic output channels do not have public inbound webhook URLs. `agentkit channels test <output-name>` is unsupported because there is no inbound endpoint to smoke.
|
|
242
197
|
|
|
243
198
|
## Auto Transcribe Audio
|
|
244
199
|
|
|
@@ -247,7 +202,7 @@ Use `transcription` at the agent level and `audio.mode: "transcribe"` on each Te
|
|
|
247
202
|
```ts
|
|
248
203
|
export default defineAgent({
|
|
249
204
|
name: "support-agent",
|
|
250
|
-
runtime: "
|
|
205
|
+
runtime: "local",
|
|
251
206
|
provider: { name: "openai", model: "gpt-5.4-mini" },
|
|
252
207
|
instructions: "./prompts/instructions.md",
|
|
253
208
|
transcription: {
|
|
@@ -311,48 +266,15 @@ V1 keeps the raw audio in memory for the request path and delivery metadata only
|
|
|
311
266
|
## Safety Rules
|
|
312
267
|
|
|
313
268
|
- Never put provider token values in `agentkit.config.ts`.
|
|
314
|
-
- Keep local values in ignored `.env
|
|
269
|
+
- Keep local values in ignored `.env`.
|
|
315
270
|
- Treat channel webhook URLs as public transport endpoints. Provider validation or the AgentKit website channel token controls authenticity.
|
|
316
271
|
- Keep channels separate from tools. Channels deliver user messages; tools let the agent call external systems.
|
|
317
272
|
- Keep `maxMessages` and `maxChars` bounded so one burst cannot create an oversized prompt or unexpected model spend.
|
|
318
273
|
- Keep `audio.limits` bounded so one voice note cannot create unexpected transcription spend.
|
|
319
274
|
|
|
320
|
-
## Verification
|
|
321
|
-
|
|
322
|
-
```sh
|
|
323
|
-
npm run typecheck
|
|
324
|
-
bun test
|
|
325
|
-
agentkit inspect
|
|
326
|
-
agentkit channels list
|
|
327
|
-
agentkit channels test n8n-webhook --message "hello"
|
|
328
|
-
agentkit channels test support-telegram --message "hello"
|
|
329
|
-
agentkit channels test-audio support-telegram --fixture voice-note
|
|
330
|
-
agentkit transcribe smoke --provider groq
|
|
331
|
-
agentkit channels deliveries list support-telegram
|
|
332
|
-
agentkit channels buffers list support-telegram
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
Expected hosted status includes `NAME`, `TYPE`, `PROVIDER`, `STATUS`, and `LAST_EVENT`. Secret output is name plus `set` or `missing`, never the value.
|
|
336
|
-
Outbound provider success is `provider_sent`. `adapter_stubbed` means no outbound provider call was made, either because explicit dry-run mode is enabled or the channel is inbound-only.
|
|
337
|
-
|
|
338
|
-
## Troubleshooting
|
|
339
|
-
|
|
340
|
-
`No .agentkit/deploy.json found`:
|
|
341
|
-
Run `agentkit deploy` before creating hosted channel resources.
|
|
342
|
-
|
|
343
|
-
`channel_secret_missing`:
|
|
344
|
-
Set the named hosted secret. Do not add production values to `.env`.
|
|
345
|
-
|
|
346
|
-
`channel_signature_invalid`:
|
|
347
|
-
The provider webhook secret, token, origin header, or Discord Ed25519 signature does not match the managed secret.
|
|
348
|
-
|
|
349
|
-
`channel_limit_exceeded`:
|
|
350
|
-
The channel daily message limit was reached. Website requests return `429`; Telegram, WhatsApp, and Discord are acknowledged and skipped to avoid provider retry storms.
|
|
351
275
|
|
|
352
|
-
|
|
353
|
-
Set the managed transcription secret declared by `agentkit inspect`, for example `OPENAI_API_KEY` or `GROQ_API_KEY`.
|
|
276
|
+
## Run Locally
|
|
354
277
|
|
|
355
|
-
`
|
|
356
|
-
The channel delivered an audio format the configured transcription provider does not accept. Telegram voice notes are OGG/Opus and work with Groq in V1; OpenAI accepts MP3, MP4, MPEG, MPGA, M4A, WAV, and WEBM in the AgentKit adapter.
|
|
278
|
+
Set secret values with `agentkit env set <NAME> --stdin`, run `agentkit inspect`, then `agentkit dev`. Test channel fixtures with authenticated POST requests to the local webhook route, then inspect the response and conversation trace. Configure provider webhooks manually against an HTTPS tunnel to the printed port. Only authenticated channel webhook routes accept tunnel hosts; chat, tools, files, and inspection stay loopback-only. See each provider guide for required signatures or URL secrets. There is no automatic webhook registration or Discord Gateway worker.
|
|
357
279
|
|
|
358
|
-
|
|
280
|
+
Local buffers and duplicate tracking are in memory and best-effort. Restarting loses pending messages and deduplication state. There is no durable retry worker, channel dashboard, or manual buffer-control API.
|
|
@@ -106,26 +106,6 @@ Tool agentkit_search_knowledge: completed
|
|
|
106
106
|
|
|
107
107
|
The retrieved chunks are persisted as internal tool output in local SQLite for evals and inspection, but they are not shown directly to the user.
|
|
108
108
|
|
|
109
|
-
## Hosted Deploy
|
|
110
|
-
|
|
111
|
-
Cloudflare Knowledge deploys require AgentKit-managed Turso storage:
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
storage: {
|
|
115
|
-
driver: "agentkit",
|
|
116
|
-
database: {
|
|
117
|
-
driver: "turso",
|
|
118
|
-
schema: "./schema.sql",
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
`agentkit deploy doctor` and `agentkit build --target cloudflare` fail with an actionable error when Knowledge is configured without Turso. The Cloudflare artifact includes the Knowledge manifest, required embedding secret names, internal Knowledge schema, local source file contents, prompt policy, and hosted `agentkit_search_knowledge` runtime.
|
|
124
|
-
|
|
125
|
-
During `agentkit deploy`, AgentKit Cloud provisions or resolves the project Turso database, applies the Knowledge schema, chunks every packaged local source, creates embeddings when an embedding provider is configured, and writes sources, chunks, embedding metadata, FTS rows, and a native Turso `libsql_vector_idx` index into Turso before publishing the Worker. Removed configured sources are deleted from the hosted Knowledge tables during sync.
|
|
126
|
-
|
|
127
|
-
Local `agentkit knowledge add`, `agentkit knowledge sync`, `agentkit dev`, and `agentkit chat` index configured Knowledge into the local SQLite database and local libSQL vector sidecar. Hosted deploy syncs configured local Knowledge sources automatically from the deploy artifact so embedding secrets stay server-side and private source material does not move into client code. Hosted semantic search uses Turso native vector search when embeddings are configured and falls back to stored JSON embeddings if the native vector path is unavailable.
|
|
128
|
-
|
|
129
109
|
## Safety Rules
|
|
130
110
|
|
|
131
111
|
- Do not put API keys, passwords, private tokens, `.env` contents, or credential exports in Knowledge files.
|
|
@@ -141,4 +121,3 @@ Local `agentkit knowledge add`, `agentkit knowledge sync`, `agentkit dev`, and `
|
|
|
141
121
|
- `Local Knowledge currently supports .md, .txt, and .csv files`: convert the source or add a tool for unsupported formats.
|
|
142
122
|
- `Knowledge embeddings require missing secret`: set the env var named by `knowledge.embedding.secret`.
|
|
143
123
|
- `PSSecurityException` on Windows PowerShell: use `npm.cmd run agentkit -- knowledge sync` or `npm.cmd run agentkit -- knowledge search "refund policy" --top-k 3`.
|
|
144
|
-
- Hosted build says Turso is required: add `storage.database.driver: "turso"` before deploying Knowledge.
|
package/docs/guides/add-tool.md
CHANGED
|
@@ -129,16 +129,15 @@ Expected output:
|
|
|
129
129
|
|
|
130
130
|
## Database Tool Pattern
|
|
131
131
|
|
|
132
|
-
Use this when a tool needs agent-owned tables and must work locally
|
|
132
|
+
Use this when a tool needs agent-owned tables and must work locally through the same AgentKit database helper.
|
|
133
133
|
|
|
134
134
|
Recommended contract:
|
|
135
135
|
|
|
136
136
|
- Put the idempotent bootstrap view of agent-owned tables in `schema.sql`.
|
|
137
137
|
- For production-shaped schema evolution, add ordered `migrations/*.sql` files such as `migrations/0001_clients.sql`.
|
|
138
|
-
- Keep
|
|
138
|
+
- Keep local capsules on `storage.driver: "agentkit"`.
|
|
139
139
|
- Local `agentkit chat`, `agentkit tool`, `agentkit dev`, and eval runs apply ordered local migrations before `schema.sql`.
|
|
140
140
|
- Use `agentkit db migrate`, `agentkit db reset --yes`, `agentkit db seed [--file seed.sql]`, and `agentkit db shell` for local database setup and inspection.
|
|
141
|
-
- Hosted deploy migrates/provisions the managed database internally and applies the same `schema.sql`.
|
|
142
141
|
- Tools use `ctx.db` as the canonical helper. `ctx.database` and `ctx.storage.sql` are supported aliases.
|
|
143
142
|
- Use `ctx.db.batch([...])` for atomic writes. Local tools can also use `ctx.db.transaction(async (tx) => ...)`.
|
|
144
143
|
- Do not import local database drivers or Node-only APIs from a tool. Use runtime services such as `ctx.db`.
|
|
@@ -151,7 +150,7 @@ import { scheduleAppointment } from "./tools/schedule-appointment";
|
|
|
151
150
|
|
|
152
151
|
export default defineAgent({
|
|
153
152
|
name: "appointments",
|
|
154
|
-
runtime: "
|
|
153
|
+
runtime: "local",
|
|
155
154
|
provider: {
|
|
156
155
|
name: "test",
|
|
157
156
|
model: "fake",
|
|
@@ -238,15 +237,12 @@ npm run agentkit -- tool schedule_appointment --input '{"clientName":"Ada Lovela
|
|
|
238
237
|
npm run agentkit -- db shell
|
|
239
238
|
```
|
|
240
239
|
|
|
241
|
-
|
|
240
|
+
Verify locally:
|
|
242
241
|
|
|
243
242
|
```sh
|
|
244
243
|
npm run agentkit -- inspect
|
|
245
|
-
npm run agentkit -- build
|
|
246
|
-
npm run agentkit -- deploy
|
|
247
244
|
```
|
|
248
245
|
|
|
249
|
-
`inspect` shows the local runtime state and declared secret names. The user does not create hosted databases or buckets manually; AgentKit handles deploy infrastructure internally.
|
|
250
246
|
|
|
251
247
|
`ctx.runtime` tells a tool where it is running:
|
|
252
248
|
|
|
@@ -254,7 +250,7 @@ npm run agentkit -- deploy
|
|
|
254
250
|
ctx.runtime // { environment, invocation, target, database }
|
|
255
251
|
```
|
|
256
252
|
|
|
257
|
-
Use it for diagnostics only, not for bypassing AgentKit runtime services or
|
|
253
|
+
Use it for diagnostics only, not for bypassing AgentKit runtime services or opening independent database connections.
|
|
258
254
|
|
|
259
255
|
## Safety Rules
|
|
260
256
|
|
|
@@ -345,5 +341,3 @@ Tool hangs:
|
|
|
345
341
|
Set `timeoutMs`, pass `ctx.signal` to external fetch calls, and retry.
|
|
346
342
|
|
|
347
343
|
## Backend Contracts Used
|
|
348
|
-
|
|
349
|
-
Local tool calls are stored in SQLite `tool_calls`. Hosted tools later run under the managed Tool Gateway contract with scoped secrets, permission checks, timeouts, and redacted logs.
|
|
@@ -1,211 +1,7 @@
|
|
|
1
1
|
# Channel Security
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Validate the provider signature or channel secret against the raw request before normalizing it. Telegram uses its webhook secret header; Discord interactions use Ed25519 signatures; Slack uses timestamped HMAC. Zapster requires expected instance/webhook IDs plus an AgentKit URL secret; UAZAPI and Evolution require URL secrets. Generic webhooks require bearer/header authentication or an HMAC signature.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Keep tokenized URLs secret. Use HTTPS tunnels only for channel webhook paths; all other local APIs remain loopback-only. Keep provider credentials in ignored `.env`, declare their names in configuration, and never include values in prompts or fixtures. Do not weaken media download host restrictions or outbound SSRF protections.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Use this when a coding agent adds or changes channels in an Agent Capsule, enables audio transcription, inspects deliveries, prepares a hosted deploy that receives provider webhooks, or routes replies through another channel.
|
|
10
|
-
|
|
11
|
-
## Commands
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
agentkit inspect
|
|
15
|
-
agentkit channels status <name>
|
|
16
|
-
agentkit channels doctor <name>
|
|
17
|
-
agentkit channels deliveries list <name> --since 24h
|
|
18
|
-
agentkit channels deliveries show <delivery-id>
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Files Created Or Edited
|
|
22
|
-
|
|
23
|
-
- `agentkit.config.ts`: channel names, provider choices, audio/buffer config, and secret names only.
|
|
24
|
-
- `.env.schema`: local secret names only when the capsule needs a local provider or local smoke.
|
|
25
|
-
- `.env`: local-only secret values; do not commit it.
|
|
26
|
-
- Hosted managed secrets: production secret values with no readback.
|
|
27
|
-
|
|
28
|
-
## Safety Rules
|
|
29
|
-
|
|
30
|
-
- Public webhook URLs are not permission grants.
|
|
31
|
-
- Keep provider tokens, webhook secrets, output webhook URLs, bot tokens, transcription keys, and bearer tokens out of source files.
|
|
32
|
-
- Put secret names in `agentkit.config.ts`; put local values in ignored `.env`; upload production values with `agentkit secret set` or `agentkit secret sync`.
|
|
33
|
-
- Do not store raw webhook bodies, raw audio, or provider secret values in tools, prompts, evals, fixtures, or delivery notes.
|
|
34
|
-
- Do not expose Discord interaction tokens or bot tokens. Interaction tokens are reply tokens, not public identifiers.
|
|
35
|
-
- Do not expose Slack bot tokens or signing secrets. Slack signing secrets authenticate webhook origin; Slack bot tokens authorize outbound replies.
|
|
36
|
-
- Do not expose `AGENTKIT_WEBHOOK_SECRET`. Generic webhook clients must authenticate with bearer/header token auth or an HMAC signature over the exact raw body.
|
|
37
|
-
- Do not put generic output webhook URLs or auth values in payloads, prompts, tools, fixtures, or `agentkit.config.ts`. Use `urlSecret` and output auth secret names only.
|
|
38
|
-
- Keep generic output webhook URLs on public HTTPS origins. AgentKit rejects localhost, private network, link-local, and metadata-service hosts before sending.
|
|
39
|
-
- Do not route replies to a channel name from the inbound payload. `replyTo.channel` must be static config, and `recipientFrom` may only select the recipient identifier.
|
|
40
|
-
- Do not remove `EVOLUTION_WEBHOOK_TOKEN` from Evolution WhatsApp webhooks. Evolution provider docs expose webhook delivery setup but no webhook signing-secret contract, so AgentKit requires a secret token query parameter and rejects requests without it.
|
|
41
|
-
- Do not remove `UAZAPI_WEBHOOK_TOKEN` or `ZAPSTER_WEBHOOK_TOKEN`. These are AgentKit-owned URL secrets, not provider-issued tokens. The adapters require them because the providers' other webhook fields do not provide a strong shared-secret signature.
|
|
42
|
-
- A local HTTPS tunnel may forward only authenticated `/channels/.../webhook` routes to `agentkit dev`; the local chat, inspect, tools, files, and conversation APIs remain loopback-only.
|
|
43
|
-
- Keep `EVOLUTION_API_BASE_URL` on a public HTTPS origin. AgentKit rejects localhost, private network, link-local, and metadata-service hosts for Evolution outbound and media-download requests.
|
|
44
|
-
- Inspect delivery IDs, hashes, redacted metadata, and statuses instead of raw provider payloads.
|
|
45
|
-
- Keep channel plumbing out of the agent's application database. The user's Turso tables are for the agent's business data.
|
|
46
|
-
- Enable audio transcription only when the capsule declares a transcription provider and bounded `limits`.
|
|
47
|
-
- Keep channel buffer limits bounded so bursty client messages cannot create unbounded runs or provider spend.
|
|
48
|
-
|
|
49
|
-
## Minimal Working Example
|
|
50
|
-
|
|
51
|
-
```ts
|
|
52
|
-
telegramChannel({
|
|
53
|
-
name: "support-telegram",
|
|
54
|
-
secrets: ["TELEGRAM_BOT_TOKEN", "TELEGRAM_WEBHOOK_SECRET"],
|
|
55
|
-
});
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
With audio transcription:
|
|
59
|
-
|
|
60
|
-
```ts
|
|
61
|
-
export default defineAgent({
|
|
62
|
-
// ...
|
|
63
|
-
transcription: {
|
|
64
|
-
provider: "groq",
|
|
65
|
-
model: "whisper-large-v3-turbo",
|
|
66
|
-
secret: "GROQ_API_KEY",
|
|
67
|
-
limits: {
|
|
68
|
-
maxDurationSeconds: 180,
|
|
69
|
-
maxBytes: 20_000_000,
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
channels: [
|
|
73
|
-
telegramChannel({
|
|
74
|
-
name: "support-telegram",
|
|
75
|
-
audio: { mode: "transcribe" },
|
|
76
|
-
}),
|
|
77
|
-
],
|
|
78
|
-
});
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
The config contains secret names only. Hosted responses report status, not values:
|
|
82
|
-
|
|
83
|
-
```txt
|
|
84
|
-
TELEGRAM_BOT_TOKEN: set
|
|
85
|
-
TELEGRAM_WEBHOOK_SECRET: missing
|
|
86
|
-
GROQ_API_KEY: set
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Discord slash-command mode uses a public key rather than a shared webhook secret:
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
discordChannel({
|
|
93
|
-
name: "support-discord",
|
|
94
|
-
secrets: ["DISCORD_PUBLIC_KEY"],
|
|
95
|
-
});
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
AgentKit validates `X-Signature-Ed25519` and `X-Signature-Timestamp` against the raw body, returns `type: 1` for Discord `PING`, and sends follow-up replies with `allowed_mentions: { parse: [] }`.
|
|
99
|
-
|
|
100
|
-
Discord bot mode uses a bot token and Gateway connection:
|
|
101
|
-
|
|
102
|
-
```ts
|
|
103
|
-
discordChannel({
|
|
104
|
-
name: "server-discord",
|
|
105
|
-
mode: "bot",
|
|
106
|
-
secrets: ["DISCORD_BOT_TOKEN"],
|
|
107
|
-
});
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Bot mode requires Message Content Intent in the Discord Developer Portal and channel permissions for `View Channel`, `Read Message History`, and `Send Messages`. AgentKit must redact `DISCORD_BOT_TOKEN` anywhere delivery, queue, buffer, or doctor output is returned.
|
|
111
|
-
|
|
112
|
-
Slack Events API uses a bot token and signing secret:
|
|
113
|
-
|
|
114
|
-
```ts
|
|
115
|
-
slackChannel({
|
|
116
|
-
name: "support-slack",
|
|
117
|
-
secrets: ["SLACK_BOT_TOKEN", "SLACK_SIGNING_SECRET"],
|
|
118
|
-
});
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
AgentKit validates `X-Slack-Signature` and `X-Slack-Request-Timestamp` against the raw body, rejects stale timestamps, answers Slack `url_verification` with the literal challenge, skips bot/subtype messages, and sends replies with Slack control mentions escaped.
|
|
122
|
-
|
|
123
|
-
Generic webhooks use an AgentKit shared secret:
|
|
124
|
-
|
|
125
|
-
```ts
|
|
126
|
-
webhookChannel({
|
|
127
|
-
name: "n8n-webhook",
|
|
128
|
-
secrets: ["AGENTKIT_WEBHOOK_SECRET"],
|
|
129
|
-
});
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
AgentKit validates `Authorization: Bearer <secret>`, `X-AgentKit-Webhook-Secret`, or `X-AgentKit-Webhook-Signature` against the raw body before parsing business fields. Payloads must include `event_id` for replay protection. `external_id` is hashed before storage.
|
|
133
|
-
|
|
134
|
-
Generic output webhooks use managed URL and auth secrets:
|
|
135
|
-
|
|
136
|
-
```ts
|
|
137
|
-
webhookOutputChannel({
|
|
138
|
-
name: "crm-callback",
|
|
139
|
-
urlSecret: "CRM_CALLBACK_URL",
|
|
140
|
-
auth: {
|
|
141
|
-
type: "hmac",
|
|
142
|
-
secret: "CRM_CALLBACK_SIGNING_SECRET",
|
|
143
|
-
},
|
|
144
|
-
})
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
The output URL must be a public HTTPS URL stored in `CRM_CALLBACK_URL`. Supported auth modes are `none`, `bearer`, `header`, and `hmac`. For HMAC auth, AgentKit signs the exact JSON callback body and sends `sha256=<digest>` in `X-AgentKit-Webhook-Signature` unless a different `headerName` is configured.
|
|
148
|
-
|
|
149
|
-
Cross-channel replies use static routing:
|
|
150
|
-
|
|
151
|
-
```ts
|
|
152
|
-
webhookChannel({
|
|
153
|
-
name: "lead-webhook",
|
|
154
|
-
replyTo: {
|
|
155
|
-
channel: "crm-callback",
|
|
156
|
-
recipientFrom: "crm_id",
|
|
157
|
-
},
|
|
158
|
-
})
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
`replyTo.channel` must name another configured channel. `recipientFrom` is a dotted JSON path into the inbound payload and must resolve to a non-empty string, number, or boolean. It is for recipient identity only; never use inbound data to choose a callback URL, auth secret, or channel name.
|
|
162
|
-
|
|
163
|
-
Evolution WhatsApp uses a self-hosted API key and an AgentKit webhook token:
|
|
164
|
-
|
|
165
|
-
```ts
|
|
166
|
-
whatsappChannel({
|
|
167
|
-
name: "support-whatsapp",
|
|
168
|
-
provider: "evolution",
|
|
169
|
-
secrets: [
|
|
170
|
-
"EVOLUTION_API_BASE_URL",
|
|
171
|
-
"EVOLUTION_API_KEY",
|
|
172
|
-
"EVOLUTION_INSTANCE_NAME",
|
|
173
|
-
"EVOLUTION_WEBHOOK_TOKEN",
|
|
174
|
-
],
|
|
175
|
-
});
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
AgentKit configures Evolution's webhook URL with `?token=<EVOLUTION_WEBHOOK_TOKEN>`, validates the token on ingress, redacts Evolution secret values, and rejects unsafe Evolution API base URLs before sending messages or downloading audio media.
|
|
179
|
-
|
|
180
|
-
## Verification
|
|
181
|
-
|
|
182
|
-
```sh
|
|
183
|
-
npm run agentkit -- inspect
|
|
184
|
-
npm run agentkit -- deploy doctor
|
|
185
|
-
npm run agentkit -- channels status <name>
|
|
186
|
-
npm run agentkit -- channels doctor <name>
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
For a synthetic channel smoke after deploy:
|
|
190
|
-
|
|
191
|
-
```sh
|
|
192
|
-
npm run agentkit -- channels test <name> --message "hello"
|
|
193
|
-
npm run agentkit -- channels deliveries list <name> --since 1h
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
## Troubleshooting
|
|
197
|
-
|
|
198
|
-
Secret value appears in output:
|
|
199
|
-
Stop and remove the value from source, fixtures, prompts, evals, and delivery notes. Hosted delivery APIs must not return secret values.
|
|
200
|
-
|
|
201
|
-
Phone number appears in delivery logs:
|
|
202
|
-
Use the redacted delivery metadata and avoid pasting full phone numbers into committed fixtures.
|
|
203
|
-
|
|
204
|
-
`channel_secret_missing`:
|
|
205
|
-
Set the named hosted secret with `agentkit secret set <NAME> --from-local-env` or `agentkit secret sync --from-local`.
|
|
206
|
-
|
|
207
|
-
`channel_signature_invalid`:
|
|
208
|
-
Check that the provider webhook secret/token configured in the provider dashboard matches the hosted secret name declared by the channel. For Discord slash-command mode, check that `DISCORD_PUBLIC_KEY` matches the application's public key. For Discord bot mode, check that `DISCORD_BOT_TOKEN` is set and Message Content Intent is enabled.
|
|
209
|
-
|
|
210
|
-
Raw audio appears in files or logs:
|
|
211
|
-
Remove it. AgentKit may pass transcript text into the normalized agent message after successful transcription, but raw audio belongs outside committed capsule files.
|
|
7
|
+
Use redacted delivery metadata and local traces for diagnostics. Set `AGENTKIT_CHANNEL_SEND_DRY_RUN=1` for tests that must not contact a real message recipient. Synthetic tests must not be presented as proof of successful provider delivery.
|