@andreprado/agentkit 0.1.0-alpha.2 → 0.1.0-alpha.20
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 +67 -6
- package/docs/guides/add-channel.md +118 -7
- package/docs/guides/add-knowledge.md +144 -0
- package/docs/guides/add-managed-composio.md +163 -0
- package/docs/guides/add-tool.md +1 -1
- package/docs/guides/channel-security.md +97 -32
- package/docs/guides/connect-discord.md +178 -0
- package/docs/guides/connect-slack.md +126 -0
- package/docs/guides/connect-telegram.md +78 -1
- package/docs/guides/connect-whatsapp-zapster.md +112 -8
- package/docs/guides/create-agent.md +45 -4
- package/docs/guides/debug-channel.md +147 -0
- package/docs/guides/improve-from-production.md +151 -0
- package/docs/guides/prepare-deploy.md +47 -17
- package/docs/guides/replay-production-traces.md +72 -0
- package/docs/guides/run-evals.md +147 -20
- package/docs/guides/security-rules.md +7 -6
- package/docs/guides/send-feedback.md +135 -0
- package/docs/guides/use-provider.md +27 -3
- package/docs/llms-full.txt +303 -55
- package/docs/llms.txt +57 -7
- package/package.json +2 -5
- package/src/cli/args.ts +57 -0
- package/src/cli/cloud-client.ts +377 -0
- package/src/cli/commands/channels.ts +1315 -0
- package/src/cli/commands/feedback.ts +438 -0
- package/src/cli/commands/knowledge.ts +136 -0
- package/src/cli/commands/transcribe.ts +171 -0
- package/src/cli/constants.ts +4 -0
- package/src/cli/deploy-chat-ui.ts +535 -0
- package/src/cli/deploy-readiness.ts +481 -0
- package/src/cli/flags.ts +162 -0
- package/src/cli/help.ts +236 -0
- package/src/cli/index.ts +1167 -1005
- package/src/cli/process.ts +31 -0
- package/src/cloud/artifact.ts +139 -0
- package/src/cloud/client.ts +80 -0
- package/src/cloud/contracts.ts +63 -0
- package/src/cloud/index.ts +3 -0
- package/src/create-project.ts +21 -6
- package/src/index.ts +479 -7
- package/src/providers/pi.ts +70 -16
- package/src/providers/test.ts +88 -1
- package/src/providers/types.ts +7 -0
- package/src/runtime/channel-buffer.ts +30 -0
- package/src/runtime/channel-test-harness.ts +8 -1
- package/src/runtime/channels/discord.ts +896 -0
- package/src/runtime/channels/slack.ts +646 -0
- package/src/runtime/channels/telegram.ts +466 -23
- package/src/runtime/channels/whatsapp-meta.ts +9 -0
- package/src/runtime/channels/whatsapp-zapster.ts +677 -40
- package/src/runtime/channels.ts +86 -3
- package/src/runtime/chat.ts +130 -38
- package/src/runtime/config.ts +483 -18
- package/src/runtime/core/manifest.ts +103 -5
- package/src/runtime/core/targets.ts +5 -5
- package/src/runtime/database.ts +93 -2
- package/src/runtime/db-commands.ts +9 -0
- package/src/runtime/deploy-readiness.ts +46 -4
- package/src/runtime/deploy.ts +1 -1
- package/src/runtime/dev-server.ts +759 -41
- package/src/runtime/env.ts +8 -3
- package/src/runtime/evals.ts +589 -43
- package/src/runtime/improve.ts +868 -0
- package/src/runtime/inspect.ts +194 -4
- package/src/runtime/integrations/composio.ts +423 -0
- package/src/runtime/knowledge/chunk.ts +333 -0
- package/src/runtime/knowledge/config.ts +135 -0
- package/src/runtime/knowledge/embeddings.ts +133 -0
- package/src/runtime/knowledge/ingest.ts +521 -0
- package/src/runtime/knowledge/prompt-policy.ts +30 -0
- package/src/runtime/knowledge/retrieve.ts +303 -0
- package/src/runtime/knowledge/schema.ts +100 -0
- package/src/runtime/knowledge/tool.ts +64 -0
- package/src/runtime/knowledge/vector.ts +258 -0
- package/src/runtime/prompt-context.ts +141 -0
- package/src/runtime/runtime-contract.ts +86 -8
- package/src/runtime/skills.ts +95 -0
- package/src/runtime/spec.ts +152 -0
- package/src/runtime/sync.ts +144 -0
- package/src/runtime/targets/cloudflare/build.ts +1430 -185
- package/src/runtime/targets/container/server.ts +1 -1
- package/src/runtime/targets/vps/deploy.ts +26 -9
- package/src/runtime/tool-runner.ts +9 -1
- package/src/runtime/tools.ts +128 -2
- package/src/runtime/traces.ts +41 -0
- package/src/runtime/transcription.ts +483 -0
- package/src/storage/sqlite.ts +149 -3
- package/src/templates/blank.ts +76 -17
- package/src/templates/dentista.ts +1011 -0
- package/src/templates/index.ts +2 -0
- package/src/templates/skills/agentkit-build-agent/SKILL.md +52 -0
- package/src/templates/skills/agentkit-build-agent/templates/appointment-intake.instructions.md +21 -0
- package/src/templates/skills/agentkit-build-agent/templates/sales-qualifier.instructions.md +17 -0
- package/src/templates/skills/agentkit-build-agent/templates/support-agent.instructions.md +16 -0
- package/src/templates/skills/agentkit-capsule/SKILL.md +70 -0
- package/src/templates/skills/agentkit-capsule/references/docs-router.md +15 -0
- package/src/templates/skills/agentkit-channels/SKILL.md +104 -0
- package/src/templates/skills/agentkit-channels/references/channel-buffering.md +65 -0
- package/src/templates/skills/agentkit-channels/references/channel-debugging.md +66 -0
- package/src/templates/skills/agentkit-channels/references/discord.md +93 -0
- package/src/templates/skills/agentkit-channels/references/slack.md +56 -0
- package/src/templates/skills/agentkit-channels/references/telegram.md +72 -0
- package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +77 -0
- package/src/templates/skills/agentkit-database/SKILL.md +45 -0
- package/src/templates/skills/agentkit-database/templates/appointments.schema.sql +15 -0
- package/src/templates/skills/agentkit-database/templates/leads.schema.sql +17 -0
- package/src/templates/skills/agentkit-deploy/SKILL.md +50 -0
- package/src/templates/skills/agentkit-evals/SKILL.md +109 -0
- package/src/templates/skills/agentkit-evals/templates/multi-turn.eval.md +29 -0
- package/src/templates/skills/agentkit-evals/templates/no-leak.eval.md +18 -0
- package/src/templates/skills/agentkit-evals/templates/smoke.eval.md +18 -0
- package/src/templates/skills/agentkit-evals/templates/tool-call.eval.md +27 -0
- package/src/templates/skills/agentkit-improve/SKILL.md +86 -0
- package/src/templates/skills/agentkit-improve/references/replay-side-effects.md +18 -0
- package/src/templates/skills/agentkit-improve/references/trace-packets.md +22 -0
- package/src/templates/skills/agentkit-improve/templates/regression.eval.md +18 -0
- package/src/templates/skills/agentkit-integrations/SKILL.md +76 -0
- package/src/templates/skills/agentkit-knowledge/SKILL.md +43 -0
- package/src/templates/skills/agentkit-knowledge/templates/faq.md +14 -0
- package/src/templates/skills/agentkit-knowledge/templates/policies.md +14 -0
- package/src/templates/skills/agentkit-knowledge/templates/prices.csv +3 -0
- package/src/templates/skills/agentkit-prompts/SKILL.md +47 -0
- package/src/templates/skills/agentkit-prompts/templates/knowledge-grounded-faq.instructions.md +11 -0
- package/src/templates/skills/agentkit-provider/SKILL.md +60 -0
- package/src/templates/skills/agentkit-security/SKILL.md +56 -0
- package/src/templates/skills/agentkit-tools/SKILL.md +37 -0
- package/src/templates/skills/agentkit-tools/examples/database-write.tool.md +35 -0
- package/src/templates/skills/agentkit-tools/examples/eval-safe-external-action.tool.md +37 -0
- package/src/templates/skills/agentkit-tools/examples/lookup-order.tool.md +46 -0
- package/src/templates/skills/agentkit-troubleshooting/SKILL.md +76 -0
- package/src/templates/support.ts +77 -18
- package/docs/guides/channels-production-handoff.md +0 -99
- package/docs/portable-deploy-release-checklist.md +0 -41
- package/src/runtime/targets/cloudflare/deploy.ts +0 -5475
package/README.md
CHANGED
|
@@ -1,21 +1,82 @@
|
|
|
1
1
|
# AgentKit
|
|
2
2
|
|
|
3
|
-
AgentKit is a toolkit for creating, running, inspecting, and deploying Agent Capsules.
|
|
3
|
+
AgentKit is a CLI-first toolkit for creating, running, inspecting, and deploying Agent Capsules.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
4
6
|
|
|
5
7
|
```sh
|
|
6
8
|
npx @andreprado/agentkit@alpha new support-agent --template support
|
|
7
9
|
cd support-agent
|
|
8
|
-
npm install
|
|
9
10
|
npm run dev
|
|
11
|
+
npm run chat -- --message "hello"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
For a Portuguese dental-office starter, use:
|
|
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 dev
|
|
29
|
+
agentkit chat --message <text> [--conversation-id <id>]
|
|
30
|
+
agentkit inspect
|
|
10
31
|
```
|
|
11
32
|
|
|
12
|
-
|
|
33
|
+
Once the capsule is running:
|
|
13
34
|
|
|
14
35
|
```sh
|
|
15
|
-
agentkit
|
|
36
|
+
agentkit tool <name> [--input <path-or-json>]
|
|
37
|
+
agentkit knowledge add <path-or-url>
|
|
38
|
+
agentkit knowledge sync
|
|
39
|
+
agentkit knowledge search <query> [--top-k <number>]
|
|
40
|
+
agentkit integrations status
|
|
41
|
+
agentkit integrations connect composio --toolkit gmail
|
|
42
|
+
agentkit spec init --brief <text>
|
|
43
|
+
agentkit db migrate
|
|
44
|
+
agentkit sync run
|
|
45
|
+
agentkit eval run
|
|
46
|
+
agentkit eval from-conversation <conversation-id>
|
|
47
|
+
agentkit improve collect --deploy --since 24h
|
|
48
|
+
agentkit improve evals .agentkit/improve/<run>
|
|
49
|
+
agentkit replay .agentkit/improve/<run> --against local
|
|
50
|
+
agentkit conversations list
|
|
51
|
+
agentkit conversations trace <conversation-id>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
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.
|
|
55
|
+
|
|
56
|
+
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.
|
|
57
|
+
|
|
58
|
+
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.
|
|
59
|
+
|
|
60
|
+
## Deploy Later
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
agentkit login --token <token>
|
|
16
64
|
agentkit deploy doctor
|
|
17
|
-
agentkit
|
|
65
|
+
agentkit skills status
|
|
66
|
+
agentkit secret set OPENAI_API_KEY --from-local-env
|
|
18
67
|
agentkit deploy
|
|
68
|
+
agentkit deploy status
|
|
69
|
+
agentkit channels test support-telegram --message "hello"
|
|
70
|
+
agentkit transcribe smoke --provider groq
|
|
71
|
+
agentkit chat-ui --deploy
|
|
19
72
|
```
|
|
20
73
|
|
|
21
|
-
|
|
74
|
+
Production secrets are managed secrets, not committed `.env` values.
|
|
75
|
+
After upgrading AgentKit in an existing capsule, run `agentkit skills status` and `agentkit skills sync` if local agent-facing skills are stale.
|
|
76
|
+
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.
|
|
77
|
+
|
|
78
|
+
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.
|
|
79
|
+
|
|
80
|
+
## Full Reference
|
|
81
|
+
|
|
82
|
+
`agentkit --help` keeps the first surface focused. Run `agentkit help commands` for the full CLI reference and `agentkit docs full` to print the path to the full agent-facing operating contract.
|
|
@@ -6,7 +6,7 @@ Add a hosted messaging channel to an Agent Capsule, create the hosted channel re
|
|
|
6
6
|
|
|
7
7
|
## When To Use It
|
|
8
8
|
|
|
9
|
-
Use this when the agent should receive messages from website chat, Telegram, or
|
|
9
|
+
Use this when the agent should receive messages from website chat, Telegram, WhatsApp, or Discord through AgentKit-owned channel infrastructure.
|
|
10
10
|
|
|
11
11
|
## Commands
|
|
12
12
|
|
|
@@ -16,26 +16,30 @@ agentkit deploy
|
|
|
16
16
|
agentkit channels list
|
|
17
17
|
agentkit channels add website website-chat
|
|
18
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
|
|
19
22
|
agentkit channels add whatsapp support-whatsapp --provider zapster
|
|
20
23
|
agentkit channels setup support-telegram
|
|
21
24
|
agentkit channels status support-telegram
|
|
22
25
|
agentkit channels test support-telegram --message "hello"
|
|
23
26
|
agentkit channels deliveries list support-telegram
|
|
27
|
+
agentkit channels buffers list support-telegram
|
|
24
28
|
```
|
|
25
29
|
|
|
26
|
-
Use `--api <url>`
|
|
30
|
+
Use `--api <url>` only when the owner gives you a non-default AgentKit Cloud API URL.
|
|
27
31
|
|
|
28
32
|
## Files Created Or Edited
|
|
29
33
|
|
|
30
|
-
- `agentkit.config.ts`: declare channel config with `websiteChannel`, `telegramChannel`, or `
|
|
34
|
+
- `agentkit.config.ts`: declare channel config with `websiteChannel`, `telegramChannel`, `whatsappChannel`, `discordChannel`, or `slackChannel`.
|
|
31
35
|
- `.agentkit/deploy.json`: written by `agentkit deploy`; used by `agentkit channels ...`.
|
|
32
|
-
- No user Turso tables: AgentKit channel resources, dedupe, identities, queue state, and delivery logs
|
|
36
|
+
- No user Turso tables: AgentKit owns channel resources, dedupe, identities, queue state, and delivery logs.
|
|
33
37
|
- Website channel clients must send `AGENTKIT_WEBSITE_CHANNEL_TOKEN` as `Authorization: Bearer <token>` or `X-AgentKit-Channel-Token`.
|
|
34
38
|
|
|
35
39
|
## Minimal Working Example
|
|
36
40
|
|
|
37
41
|
```ts
|
|
38
|
-
import { defineAgent, telegramChannel, whatsappChannel, websiteChannel } from "@andreprado/agentkit";
|
|
42
|
+
import { defineAgent, discordChannel, slackChannel, telegramChannel, whatsappChannel, websiteChannel } from "@andreprado/agentkit";
|
|
39
43
|
|
|
40
44
|
export default defineAgent({
|
|
41
45
|
name: "support-agent",
|
|
@@ -48,18 +52,113 @@ export default defineAgent({
|
|
|
48
52
|
websiteChannel({ name: "website-chat" }),
|
|
49
53
|
telegramChannel({ name: "support-telegram" }),
|
|
50
54
|
whatsappChannel({ name: "support-whatsapp", provider: "zapster" }),
|
|
55
|
+
discordChannel({ name: "support-discord" }),
|
|
56
|
+
discordChannel({ name: "server-discord", mode: "bot" }),
|
|
57
|
+
slackChannel({ name: "support-slack" }),
|
|
51
58
|
],
|
|
52
59
|
access: { mode: "public" },
|
|
53
60
|
storage: { driver: "agentkit" },
|
|
54
61
|
});
|
|
55
62
|
```
|
|
56
63
|
|
|
64
|
+
## Buffer Bursty Messages
|
|
65
|
+
|
|
66
|
+
Use `buffer` when clients send several short messages in a row and the agent should answer once.
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
whatsappChannel({
|
|
70
|
+
name: "support-whatsapp",
|
|
71
|
+
provider: "zapster",
|
|
72
|
+
buffer: {
|
|
73
|
+
mode: "debounce",
|
|
74
|
+
quietWindowMs: 2500,
|
|
75
|
+
maxWaitMs: 12000,
|
|
76
|
+
maxMessages: 20,
|
|
77
|
+
maxChars: 8000,
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Buffering is scoped to one channel conversation. AgentKit still validates and dedupes each provider webhook, then stores the messages in a short-lived channel buffer. When the quiet window expires, AgentKit creates one agent run with the buffered messages and sends one outbound reply.
|
|
83
|
+
|
|
84
|
+
Use `buffer: { mode: "off" }` or omit `buffer` to process each inbound message as its own agent run.
|
|
85
|
+
|
|
86
|
+
Buffer controls:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
agentkit channels buffers list support-whatsapp
|
|
90
|
+
agentkit channels buffers show support-whatsapp <conversation-id>
|
|
91
|
+
agentkit channels buffers flush support-whatsapp <conversation-id>
|
|
92
|
+
agentkit channels buffers clear support-whatsapp <conversation-id>
|
|
93
|
+
agentkit channels buffers retry support-whatsapp <conversation-id>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Discord supports buffering for slash-command interactions and bot-mode server messages, but it does not support `audio` in V1.
|
|
97
|
+
|
|
98
|
+
## Auto Transcribe Audio
|
|
99
|
+
|
|
100
|
+
Use `transcription` at the agent level and `audio.mode: "transcribe"` on each Telegram or WhatsApp channel that should accept voice notes or audio files.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
export default defineAgent({
|
|
104
|
+
name: "support-agent",
|
|
105
|
+
runtime: "edge",
|
|
106
|
+
provider: { name: "openai", model: "gpt-5.4-mini" },
|
|
107
|
+
instructions: "./prompts/instructions.md",
|
|
108
|
+
transcription: {
|
|
109
|
+
provider: "groq",
|
|
110
|
+
model: "whisper-large-v3-turbo",
|
|
111
|
+
secret: "GROQ_API_KEY",
|
|
112
|
+
language: "pt",
|
|
113
|
+
limits: {
|
|
114
|
+
maxDurationSeconds: 180,
|
|
115
|
+
maxBytes: 20_000_000,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
channels: [
|
|
119
|
+
telegramChannel({
|
|
120
|
+
name: "support-telegram",
|
|
121
|
+
audio: { mode: "transcribe" },
|
|
122
|
+
}),
|
|
123
|
+
whatsappChannel({
|
|
124
|
+
name: "support-whatsapp",
|
|
125
|
+
provider: "zapster",
|
|
126
|
+
audio: { mode: "transcribe" },
|
|
127
|
+
}),
|
|
128
|
+
],
|
|
129
|
+
access: { mode: "public" },
|
|
130
|
+
storage: { driver: "agentkit" },
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Supported transcription providers in V1:
|
|
135
|
+
|
|
136
|
+
| Provider | Default secret | Supported models |
|
|
137
|
+
| --- | --- | --- |
|
|
138
|
+
| `openai` | `OPENAI_API_KEY` | `gpt-4o-mini-transcribe`, `gpt-4o-transcribe`, `whisper-1` |
|
|
139
|
+
| `groq` | `GROQ_API_KEY` | `whisper-large-v3-turbo`, `whisper-large-v3`, `distil-whisper-large-v3-en` |
|
|
140
|
+
|
|
141
|
+
Audio transcription is paid by the capsule owner because AgentKit only passes through the configured provider secret. Hosted channel creation automatically requires the transcription secret when a channel enables `audio.mode: "transcribe"`.
|
|
142
|
+
|
|
143
|
+
Processing order:
|
|
144
|
+
|
|
145
|
+
1. Provider webhook is validated and deduped.
|
|
146
|
+
2. Channel adapter normalizes the audio metadata.
|
|
147
|
+
3. AgentKit records `audio_received` and enqueues a channel job before acknowledging the webhook.
|
|
148
|
+
4. The retryable channel worker downloads the audio using the channel provider secret.
|
|
149
|
+
5. The transcription adapter sends the file to the configured transcription provider.
|
|
150
|
+
6. The agent receives a text message containing the transcript.
|
|
151
|
+
|
|
152
|
+
V1 keeps the raw audio in memory for the request path and delivery metadata only records redacted status/error fields. `rawAudioTtlSeconds` is part of the manifest contract for future object-storage retention, but V1 does not persist raw audio by default.
|
|
153
|
+
|
|
57
154
|
## Safety Rules
|
|
58
155
|
|
|
59
156
|
- Never put provider token values in `agentkit.config.ts`.
|
|
60
157
|
- Keep local values in ignored `.env`; hosted production uses managed secrets with no readback.
|
|
61
158
|
- Treat channel webhook URLs as public transport endpoints. Provider validation or the AgentKit website channel token controls authenticity.
|
|
62
159
|
- Keep channels separate from tools. Channels deliver user messages; tools let the agent call external systems.
|
|
160
|
+
- Keep `maxMessages` and `maxChars` bounded so one burst cannot create an oversized prompt or unexpected model spend.
|
|
161
|
+
- Keep `audio.limits` bounded so one voice note cannot create unexpected transcription spend.
|
|
63
162
|
|
|
64
163
|
## Verification
|
|
65
164
|
|
|
@@ -69,10 +168,14 @@ bun test
|
|
|
69
168
|
agentkit inspect
|
|
70
169
|
agentkit channels list
|
|
71
170
|
agentkit channels test support-telegram --message "hello"
|
|
171
|
+
agentkit channels test-audio support-telegram --fixture voice-note
|
|
172
|
+
agentkit transcribe smoke --provider groq
|
|
72
173
|
agentkit channels deliveries list support-telegram
|
|
174
|
+
agentkit channels buffers list support-telegram
|
|
73
175
|
```
|
|
74
176
|
|
|
75
177
|
Expected hosted status includes `NAME`, `TYPE`, `PROVIDER`, `STATUS`, and `LAST_EVENT`. Secret output is name plus `set` or `missing`, never the value.
|
|
178
|
+
Outbound provider success is `provider_sent`. Explicit dry-run mode is `adapter_stubbed`, which means the provider was not called.
|
|
76
179
|
|
|
77
180
|
## Troubleshooting
|
|
78
181
|
|
|
@@ -83,7 +186,15 @@ Run `agentkit deploy` before creating hosted channel resources.
|
|
|
83
186
|
Set the named hosted secret. Do not add production values to `.env`.
|
|
84
187
|
|
|
85
188
|
`channel_signature_invalid`:
|
|
86
|
-
The provider webhook secret
|
|
189
|
+
The provider webhook secret, token, origin header, or Discord Ed25519 signature does not match the managed secret.
|
|
87
190
|
|
|
88
191
|
`channel_limit_exceeded`:
|
|
89
|
-
The channel daily message limit was reached. Website requests return `429`; Telegram and
|
|
192
|
+
The channel daily message limit was reached. Website requests return `429`; Telegram, WhatsApp, and Discord are acknowledged and skipped to avoid provider retry storms.
|
|
193
|
+
|
|
194
|
+
`transcription_secret_missing`:
|
|
195
|
+
Set the managed transcription secret declared by `agentkit inspect`, for example `OPENAI_API_KEY` or `GROQ_API_KEY`.
|
|
196
|
+
|
|
197
|
+
`transcription_audio_format_unsupported`:
|
|
198
|
+
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.
|
|
199
|
+
|
|
200
|
+
Buffered messages stay in `buffered` delivery state until the quiet window or max wait flushes them into one queued run.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Add Knowledge
|
|
2
|
+
|
|
3
|
+
Knowledge is AgentKit's native retrieval layer for facts the agent should not invent: policies, prices, service details, FAQs, CSV tables, procedures, and internal reference docs.
|
|
4
|
+
|
|
5
|
+
Use Knowledge when the answer should come from source files instead of the base prompt. Do not use Knowledge for secrets, credentials, or data that should only be fetched live through a tool.
|
|
6
|
+
|
|
7
|
+
## Configure
|
|
8
|
+
|
|
9
|
+
Create a `knowledge/` directory in the Agent Capsule and list the sources in `agentkit.config.ts`:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
export default defineAgent({
|
|
13
|
+
// ...
|
|
14
|
+
knowledge: {
|
|
15
|
+
sources: [
|
|
16
|
+
"knowledge/faq.md",
|
|
17
|
+
{ path: "knowledge/prices.csv", title: "Prices" },
|
|
18
|
+
],
|
|
19
|
+
retrieval: {
|
|
20
|
+
topK: 8,
|
|
21
|
+
hybrid: false,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Local Knowledge supports `.md`, `.markdown`, `.txt`, and `.csv` files. Markdown is chunked by headings, text is chunked by paragraphs, and CSV rows preserve column headers.
|
|
28
|
+
|
|
29
|
+
The default embedding provider is `none`, which gives local lexical search without an API key. To add embeddings, configure them separately from the chat provider:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
knowledge: {
|
|
33
|
+
sources: ["knowledge/faq.md"],
|
|
34
|
+
embedding: {
|
|
35
|
+
provider: "openai",
|
|
36
|
+
model: "text-embedding-3-small",
|
|
37
|
+
secret: "KNOWLEDGE_OPENAI_API_KEY",
|
|
38
|
+
},
|
|
39
|
+
retrieval: {
|
|
40
|
+
topK: 8,
|
|
41
|
+
hybrid: true,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Then set the local secret without committing it:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
printf %s "$KNOWLEDGE_OPENAI_API_KEY" | agentkit env set KNOWLEDGE_OPENAI_API_KEY --stdin
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Index Locally
|
|
53
|
+
|
|
54
|
+
Index one source:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
agentkit knowledge add knowledge/faq.md
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Sync all configured sources:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
agentkit knowledge sync
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Inspect indexed sources:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
agentkit knowledge inspect
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Search locally:
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
agentkit knowledge search "refund policy" --top-k 3
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`knowledge add` is useful for one-off local indexing. `knowledge sync` validates and indexes all configured `knowledge.sources` on demand. `agentkit dev` and `agentkit chat` also sync configured Knowledge automatically before local runs, and unchanged files are skipped by content hash.
|
|
79
|
+
|
|
80
|
+
On Windows PowerShell, if `npm.ps1` is blocked by `PSSecurityException`, run capsule scripts through the `.cmd` shim:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
npm.cmd run agentkit -- knowledge sync
|
|
84
|
+
npm.cmd run agentkit -- knowledge search "refund policy" --top-k 3
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
When embeddings are configured locally, AgentKit stores canonical Knowledge chunks in `.agentkit/agentkit.db` and rebuilds a local libSQL vector sidecar at `.agentkit/agentkit.vectors.db`. Local semantic search uses the sidecar's native `libsql_vector_idx` path and falls back to stored JSON embeddings if the native vector path is unavailable.
|
|
88
|
+
|
|
89
|
+
Local lexical search uses SQLite FTS5 when the local SQLite build provides it. If SQLite does not provide FTS5, AgentKit automatically keeps indexing and searching with a normal SQLite table and a simpler text-match fallback.
|
|
90
|
+
|
|
91
|
+
## Agent Behavior
|
|
92
|
+
|
|
93
|
+
When `knowledge` is configured, AgentKit automatically registers the internal tool `agentkit_search_knowledge` during chat runs and appends a prompt policy. The policy tells the agent to search before answering business-specific factual questions and not to expose raw retrieval JSON, scores, or chunk IDs.
|
|
94
|
+
|
|
95
|
+
With the deterministic `test/fake` provider, verify the internal tool directly:
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
agentkit chat --message '{"tool":"agentkit_search_knowledge","input":{"query":"refund policy","topK":1}}'
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Expected output:
|
|
102
|
+
|
|
103
|
+
```txt
|
|
104
|
+
Tool agentkit_search_knowledge: completed
|
|
105
|
+
```
|
|
106
|
+
|
|
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
|
+
|
|
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
|
+
## Safety Rules
|
|
130
|
+
|
|
131
|
+
- Do not put API keys, passwords, private tokens, `.env` contents, or credential exports in Knowledge files.
|
|
132
|
+
- Treat committed Knowledge files as repository content. Use a private repo for private business docs.
|
|
133
|
+
- Use tools for live customer records, payments, orders, or anything requiring authorization checks.
|
|
134
|
+
- Use explicit `title` fields for CSVs or ambiguous files so search results have useful citations.
|
|
135
|
+
- Use `agentkit knowledge sync` to validate source changes explicitly; local `agentkit dev` and `agentkit chat` also sync configured sources automatically.
|
|
136
|
+
|
|
137
|
+
## Troubleshooting
|
|
138
|
+
|
|
139
|
+
- `No knowledge.sources are configured`: add `knowledge.sources` to `agentkit.config.ts` or use `agentkit knowledge add <path>`.
|
|
140
|
+
- `Knowledge source paths must stay inside the Agent Capsule`: move the source under the capsule root, usually `knowledge/`.
|
|
141
|
+
- `Local Knowledge currently supports .md, .txt, and .csv files`: convert the source or add a tool for unsupported formats.
|
|
142
|
+
- `Knowledge embeddings require missing secret`: set the env var named by `knowledge.embedding.secret`.
|
|
143
|
+
- `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.
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Add Managed Composio
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Enable AgentKit-managed Composio for one deployed agent so the agent can use explicitly allowed external app actions without the user owning Composio credentials.
|
|
6
|
+
|
|
7
|
+
Use BYO `defineTool` wrappers instead when the user wants to use their own Composio account/API key for free.
|
|
8
|
+
|
|
9
|
+
## Contract
|
|
10
|
+
|
|
11
|
+
Managed Composio is paid hosted AgentKit infrastructure:
|
|
12
|
+
|
|
13
|
+
- It works per agent/project, not per client.
|
|
14
|
+
- It requires an AgentKit Cloud account with `managed_composio`.
|
|
15
|
+
- AgentKit Cloud injects `COMPOSIO_API_KEY`; do not put it in `.env`, `.env.schema`, or `agentkit.config.ts`.
|
|
16
|
+
- AgentKit Cloud resolves toolkit auth configs from its managed registry. The capsule owner only declares allowed toolkits/actions.
|
|
17
|
+
- AgentKit Cloud assigns the deployed Composio `user_id` from the account, project, agent, and integration name. The local inspect/build id is only a preview.
|
|
18
|
+
- The agent gets one generated tool, `agentkit_composio_execute`, only when explicit Composio action slugs are configured.
|
|
19
|
+
- Anonymous deploys cannot use managed Composio.
|
|
20
|
+
|
|
21
|
+
## Minimal Config
|
|
22
|
+
|
|
23
|
+
Edit `agentkit.config.ts`:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { composioManaged, defineAgent } from "@andreprado/agentkit";
|
|
27
|
+
|
|
28
|
+
export default defineAgent({
|
|
29
|
+
name: "acme-receptionist",
|
|
30
|
+
runtime: "edge",
|
|
31
|
+
provider: {
|
|
32
|
+
name: "test",
|
|
33
|
+
model: "fake",
|
|
34
|
+
},
|
|
35
|
+
instructions: "./prompts/instructions.md",
|
|
36
|
+
secrets: [],
|
|
37
|
+
tools: [],
|
|
38
|
+
integrations: [
|
|
39
|
+
composioManaged({
|
|
40
|
+
toolkits: ["gmail", "googlecalendar"],
|
|
41
|
+
tools: {
|
|
42
|
+
gmail: ["GMAIL_FETCH_EMAILS", "GMAIL_SEND_EMAIL"],
|
|
43
|
+
googlecalendar: [
|
|
44
|
+
"GOOGLECALENDAR_EVENTS_LIST",
|
|
45
|
+
"GOOGLECALENDAR_CREATE_EVENT",
|
|
46
|
+
"GOOGLECALENDAR_UPDATE_EVENT",
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
confirmExternalWrites: true,
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
access: {
|
|
53
|
+
mode: "private",
|
|
54
|
+
},
|
|
55
|
+
storage: {
|
|
56
|
+
driver: "agentkit",
|
|
57
|
+
database: {
|
|
58
|
+
driver: "turso",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Deploy
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
agentkit login --token agk_user_...
|
|
68
|
+
agentkit deploy doctor
|
|
69
|
+
agentkit deploy
|
|
70
|
+
agentkit integrations status --toolkit googlecalendar
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Expected readiness:
|
|
74
|
+
|
|
75
|
+
- Hosted deploy access is active through `cloudflare_deploy_alpha` or purchased/manual deploy slots.
|
|
76
|
+
- `managed_composio` is active.
|
|
77
|
+
- `COMPOSIO_API_KEY` appears as an AgentKit-managed secret, not a user-managed hosted secret.
|
|
78
|
+
- Each configured toolkit auth config is available in AgentKit Cloud.
|
|
79
|
+
|
|
80
|
+
## Connect Apps
|
|
81
|
+
|
|
82
|
+
After deploy, create a hosted Composio Connect Link:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
agentkit integrations connect composio --toolkit gmail
|
|
86
|
+
agentkit integrations connect composio --toolkit googlecalendar
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
AgentKit prints a URL. Send that URL to the person who owns the app account.
|
|
90
|
+
|
|
91
|
+
If the deploy has only one toolkit, `--toolkit` can be omitted.
|
|
92
|
+
|
|
93
|
+
## Calendar Defaults
|
|
94
|
+
|
|
95
|
+
For Google Calendar agents, include read and write actions together. Do not expose only `GOOGLECALENDAR_CREATE_EVENT`; users naturally ask to see availability before booking.
|
|
96
|
+
|
|
97
|
+
Use these starter actions:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
googlecalendar: [
|
|
101
|
+
"GOOGLECALENDAR_EVENTS_LIST",
|
|
102
|
+
"GOOGLECALENDAR_CREATE_EVENT",
|
|
103
|
+
"GOOGLECALENDAR_UPDATE_EVENT",
|
|
104
|
+
]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`GOOGLECALENDAR_CREATE_EVENT` requires extra care:
|
|
108
|
+
|
|
109
|
+
- `start_datetime` must be explicit UTC RFC3339, such as `2026-06-03T15:00:00Z` for 12:00 in `America/Sao_Paulo`.
|
|
110
|
+
- `event_duration_minutes` or `event_duration_hour` must be explicit. AgentKit blocks the implicit Composio default because `event_duration_minutes` defaults to 30.
|
|
111
|
+
- Confirm the final title, date, local time, duration, timezone, and attendees/location when relevant before creating or updating an event.
|
|
112
|
+
|
|
113
|
+
## Write Confirmation
|
|
114
|
+
|
|
115
|
+
Managed Composio requires confirmation for external write actions by default. For actions such as create, update, delete, send, patch, move, insert, clear, remove, import, or quick add, the generated `agentkit_composio_execute` tool requires `confirmed: true`.
|
|
116
|
+
|
|
117
|
+
Set `confirmed: true` only after the user confirms the exact external change. If a capsule intentionally handles confirmation elsewhere, disable this guard explicitly:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
composioManaged({
|
|
121
|
+
toolkits: ["googlecalendar"],
|
|
122
|
+
tools: {
|
|
123
|
+
googlecalendar: ["GOOGLECALENDAR_EVENTS_LIST", "GOOGLECALENDAR_CREATE_EVENT"],
|
|
124
|
+
},
|
|
125
|
+
confirmExternalWrites: false,
|
|
126
|
+
})
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Verification
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
agentkit inspect
|
|
133
|
+
agentkit build --target cloudflare
|
|
134
|
+
agentkit deploy doctor
|
|
135
|
+
agentkit integrations status --toolkit googlecalendar
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Expected:
|
|
139
|
+
|
|
140
|
+
- `inspect.integrations[0].provider` is `composio`.
|
|
141
|
+
- `inspect.tools` includes `agentkit_composio_execute` when allowed actions are configured.
|
|
142
|
+
- Build manifest includes `integrations`.
|
|
143
|
+
- Build manifest includes `COMPOSIO_API_KEY`.
|
|
144
|
+
- `deploy doctor` does not ask the user to set `COMPOSIO_API_KEY`.
|
|
145
|
+
- `deploy doctor` reports each configured toolkit auth config as present before the connect link flow.
|
|
146
|
+
|
|
147
|
+
## Troubleshooting
|
|
148
|
+
|
|
149
|
+
`managed_composio_entitlement_required`:
|
|
150
|
+
|
|
151
|
+
Log in with a paid AgentKit Cloud account that has `managed_composio`.
|
|
152
|
+
|
|
153
|
+
`managed_composio_auth_config_missing`:
|
|
154
|
+
|
|
155
|
+
The AgentKit Cloud account is entitled, but the requested toolkit is not configured in AgentKit Cloud yet. Report the exact error code and toolkit slug to the AgentKit owner.
|
|
156
|
+
|
|
157
|
+
`managed_composio_not_configured`:
|
|
158
|
+
|
|
159
|
+
Managed Composio is not available for this AgentKit Cloud environment. Use BYO `defineTool` wrappers for now or ask the owner to enable managed Composio for the account.
|
|
160
|
+
|
|
161
|
+
`integration_toolkit_required`:
|
|
162
|
+
|
|
163
|
+
The deploy has multiple configured toolkits. Re-run connect with `--toolkit <slug>`.
|
package/docs/guides/add-tool.md
CHANGED
|
@@ -329,7 +329,7 @@ Compare the JSON message input to `inputSchema`.
|
|
|
329
329
|
Add the secret name to `.env.schema`, write the local value to ignored `.env`, and inspect again:
|
|
330
330
|
|
|
331
331
|
```sh
|
|
332
|
-
npm run agentkit -- env set CRM_API_KEY
|
|
332
|
+
printf %s "$CRM_API_KEY" | npm run agentkit -- env set CRM_API_KEY --stdin
|
|
333
333
|
npm run agentkit -- inspect
|
|
334
334
|
```
|
|
335
335
|
|