@andreprado/agentkit 0.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -0
- package/bin/agentkit.mjs +23 -0
- package/docs/guides/add-channel.md +114 -0
- package/docs/guides/add-knowledge.md +134 -0
- package/docs/guides/add-tool.md +342 -0
- package/docs/guides/agentkit-skills-architecture.md +471 -0
- package/docs/guides/channel-security.md +81 -0
- package/docs/guides/channels-implementation-map.md +243 -0
- package/docs/guides/channels-production-handoff.md +102 -0
- package/docs/guides/connect-telegram.md +110 -0
- package/docs/guides/connect-whatsapp-zapster.md +119 -0
- package/docs/guides/create-agent.md +220 -0
- package/docs/guides/prepare-deploy.md +209 -0
- package/docs/guides/run-evals.md +179 -0
- package/docs/guides/security-rules.md +156 -0
- package/docs/guides/use-provider.md +140 -0
- package/docs/llms-full.txt +876 -0
- package/docs/llms.txt +83 -0
- package/docs/portable-deploy-release-checklist.md +41 -0
- package/package.json +47 -0
- package/src/cli/args.ts +36 -0
- package/src/cli/cloud-client.ts +265 -0
- package/src/cli/commands/channels.ts +810 -0
- package/src/cli/commands/knowledge.ts +136 -0
- package/src/cli/constants.ts +4 -0
- package/src/cli/deploy-chat-ui.ts +392 -0
- package/src/cli/deploy-readiness.ts +348 -0
- package/src/cli/flags.ts +162 -0
- package/src/cli/help.ts +184 -0
- package/src/cli/index.ts +1276 -0
- package/src/cli/process.ts +31 -0
- package/src/cloud/artifact.ts +139 -0
- package/src/cloud/client.ts +79 -0
- package/src/cloud/contracts.ts +63 -0
- package/src/cloud/index.ts +3 -0
- package/src/create-project.ts +177 -0
- package/src/index.ts +408 -0
- package/src/providers/index.ts +25 -0
- package/src/providers/pi.ts +286 -0
- package/src/providers/test.ts +133 -0
- package/src/providers/types.ts +34 -0
- package/src/runtime/build.ts +43 -0
- package/src/runtime/channel-buffer.ts +30 -0
- package/src/runtime/channel-test-harness.ts +112 -0
- package/src/runtime/channels/telegram.ts +360 -0
- package/src/runtime/channels/website.ts +132 -0
- package/src/runtime/channels/whatsapp-meta.ts +71 -0
- package/src/runtime/channels/whatsapp-zapster.ts +278 -0
- package/src/runtime/channels.ts +138 -0
- package/src/runtime/chat.ts +218 -0
- package/src/runtime/config.ts +684 -0
- package/src/runtime/conversations.ts +38 -0
- package/src/runtime/core/deploy-state.ts +54 -0
- package/src/runtime/core/manifest.ts +213 -0
- package/src/runtime/core/targets.ts +133 -0
- package/src/runtime/database.ts +256 -0
- package/src/runtime/db-commands.ts +167 -0
- package/src/runtime/deploy-readiness.ts +105 -0
- package/src/runtime/deploy.ts +1 -0
- package/src/runtime/dev-server.ts +1247 -0
- package/src/runtime/docs.ts +36 -0
- package/src/runtime/env.ts +152 -0
- package/src/runtime/errors.ts +13 -0
- package/src/runtime/evals.ts +509 -0
- package/src/runtime/inspect.ts +203 -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 +283 -0
- package/src/runtime/knowledge/schema.ts +56 -0
- package/src/runtime/knowledge/tool.ts +64 -0
- package/src/runtime/knowledge/vector.ts +258 -0
- package/src/runtime/runtime-contract.ts +93 -0
- package/src/runtime/spec.ts +152 -0
- package/src/runtime/sync.ts +144 -0
- package/src/runtime/targets/cloudflare/build.ts +2517 -0
- package/src/runtime/targets/container/build.ts +146 -0
- package/src/runtime/targets/container/server.ts +33 -0
- package/src/runtime/targets/vps/deploy.ts +206 -0
- package/src/runtime/tool-runner.ts +65 -0
- package/src/runtime/tools.ts +470 -0
- package/src/runtime/traces.ts +41 -0
- package/src/storage/sqlite.ts +1118 -0
- package/src/templates/blank.ts +394 -0
- package/src/templates/dentista.ts +1003 -0
- package/src/templates/index.ts +33 -0
- package/src/templates/skills/agentkit-build-agent/SKILL.md +51 -0
- package/src/templates/skills/agentkit-build-agent/templates/appointment-intake.instructions.md +20 -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 +62 -0
- package/src/templates/skills/agentkit-capsule/references/docs-router.md +15 -0
- package/src/templates/skills/agentkit-channels/SKILL.md +62 -0
- package/src/templates/skills/agentkit-channels/references/channel-buffering.md +58 -0
- package/src/templates/skills/agentkit-channels/references/channel-debugging.md +41 -0
- package/src/templates/skills/agentkit-channels/references/telegram.md +38 -0
- package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +44 -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 +44 -0
- package/src/templates/skills/agentkit-evals/SKILL.md +60 -0
- package/src/templates/skills/agentkit-evals/templates/multi-turn.eval.md +22 -0
- package/src/templates/skills/agentkit-evals/templates/no-leak.eval.md +14 -0
- package/src/templates/skills/agentkit-evals/templates/smoke.eval.md +14 -0
- package/src/templates/skills/agentkit-evals/templates/tool-call.eval.md +18 -0
- package/src/templates/skills/agentkit-knowledge/SKILL.md +40 -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 +45 -0
- package/src/templates/skills/agentkit-prompts/templates/knowledge-grounded-faq.instructions.md +11 -0
- package/src/templates/skills/agentkit-provider/SKILL.md +57 -0
- package/src/templates/skills/agentkit-security/SKILL.md +55 -0
- package/src/templates/skills/agentkit-tools/SKILL.md +36 -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 +52 -0
- package/src/templates/support.ts +401 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { blankTemplate } from "./blank";
|
|
2
|
+
import { dentistaTemplate } from "./dentista";
|
|
3
|
+
import { supportTemplate } from "./support";
|
|
4
|
+
|
|
5
|
+
export type TemplateFile = {
|
|
6
|
+
path: string;
|
|
7
|
+
contents: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type AgentTemplate = {
|
|
11
|
+
name: string;
|
|
12
|
+
files(projectName: string, context?: AgentTemplateContext): TemplateFile[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type AgentTemplateContext = {
|
|
16
|
+
agentkitDependency?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const templates = new Map<string, AgentTemplate>([
|
|
20
|
+
[blankTemplate.name, blankTemplate],
|
|
21
|
+
[dentistaTemplate.name, dentistaTemplate],
|
|
22
|
+
[supportTemplate.name, supportTemplate],
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
export function getTemplate(name: string): AgentTemplate {
|
|
26
|
+
const template = templates.get(name);
|
|
27
|
+
|
|
28
|
+
if (!template) {
|
|
29
|
+
throw new Error(`Unknown template "${name}". Available templates: ${Array.from(templates.keys()).join(", ")}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return template;
|
|
33
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentkit-build-agent
|
|
3
|
+
description: Use when the owner gives a natural-language brief for a new or changed AgentKit agent and expects the coding agent to turn it into a working local capsule with prompts, tools, schema, evals, and verification.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build An AgentKit Agent
|
|
7
|
+
|
|
8
|
+
Use this when the owner asks for an agent in plain language.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Read `agentkit.config.ts`, `prompts/instructions.md`, `schema.sql`, `evals/`, and existing `tools/`.
|
|
13
|
+
2. If `AGENT_SPEC.md` does not exist, create it from the owner's plain-language request with `npm run agentkit -- spec init --brief "<owner request>"`. If it exists, update it directly before changing behavior.
|
|
14
|
+
3. Infer the first useful local version from the owner's brief and the spec. Do not ask the owner to fill a form.
|
|
15
|
+
4. Edit `prompts/instructions.md` for behavior, boundaries, intake questions, escalation rules, and tool-use policy.
|
|
16
|
+
5. Add tools only when the agent needs action, live data, authorization-sensitive data, or durable writes.
|
|
17
|
+
6. Add database tables to `schema.sql` or ordered `migrations/*.sql` when the agent owns records.
|
|
18
|
+
7. Add `sync.ts` and `seed.sql` with `npm run agentkit -- sync init` when the agent depends on external catalogs or recurring imports.
|
|
19
|
+
8. Add or update evals for the main flow. Prefer multi-turn `turns` evals for real conversations.
|
|
20
|
+
9. Keep the capsule runnable on `test/fake` unless the owner has chosen a real provider.
|
|
21
|
+
|
|
22
|
+
## Templates
|
|
23
|
+
|
|
24
|
+
Use these only when they match the brief:
|
|
25
|
+
|
|
26
|
+
- `templates/support-agent.instructions.md`
|
|
27
|
+
- `templates/appointment-intake.instructions.md`
|
|
28
|
+
- `templates/sales-qualifier.instructions.md`
|
|
29
|
+
|
|
30
|
+
For prompt-only work, use `skills/agentkit-prompts/SKILL.md`.
|
|
31
|
+
For database-backed tools, use `skills/agentkit-database/SKILL.md`.
|
|
32
|
+
|
|
33
|
+
## Verification
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
npm run typecheck
|
|
37
|
+
npm run agentkit -- inspect
|
|
38
|
+
npm run chat -- --message "hello"
|
|
39
|
+
npm run eval
|
|
40
|
+
npm run agentkit -- spec check
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If a tool was added:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npm run agentkit -- tool <tool_name> --input '<json>'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Final Response
|
|
50
|
+
|
|
51
|
+
Summarize the files changed, assumptions made, verification results, and whether the behavior was tested with `test/fake` or a real provider selected by the owner.
|
package/src/templates/skills/agentkit-build-agent/templates/appointment-intake.instructions.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
You are an appointment and intake agent.
|
|
2
|
+
|
|
3
|
+
Goal:
|
|
4
|
+
- Collect the information needed to understand the request.
|
|
5
|
+
- Offer available times only after checking availability through tools.
|
|
6
|
+
- Confirm the exact date, time, name, and contact details before saving.
|
|
7
|
+
|
|
8
|
+
Required intake:
|
|
9
|
+
- Full name
|
|
10
|
+
- Contact method
|
|
11
|
+
- Reason for visit
|
|
12
|
+
- Preferred date or time window
|
|
13
|
+
- Any urgency or special constraints
|
|
14
|
+
|
|
15
|
+
Rules:
|
|
16
|
+
- Do not diagnose, promise outcomes, or provide emergency guidance beyond directing urgent cases to appropriate human or emergency support.
|
|
17
|
+
- Do not create, change, or cancel an appointment without explicit user confirmation.
|
|
18
|
+
- Do not invent availability.
|
|
19
|
+
- Use the scheduling tools for availability and writes.
|
|
20
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
You are a sales qualification agent.
|
|
2
|
+
|
|
3
|
+
Goal:
|
|
4
|
+
- Understand the user's current situation, urgency, budget range, authority, and desired outcome.
|
|
5
|
+
- Identify whether the lead is a fit for the configured offer.
|
|
6
|
+
- Capture structured lead details through tools when available.
|
|
7
|
+
|
|
8
|
+
Behavior:
|
|
9
|
+
- Ask one focused question at a time.
|
|
10
|
+
- Avoid pressure and exaggerated claims.
|
|
11
|
+
- Be clear about what is known, unknown, and next.
|
|
12
|
+
- Escalate to a human when the user asks for pricing exceptions, legal terms, procurement details, or custom commitments.
|
|
13
|
+
|
|
14
|
+
Rules:
|
|
15
|
+
- Do not invent pricing, discounts, case studies, or availability.
|
|
16
|
+
- Do not expose internal lead scores or qualification labels.
|
|
17
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
You are a focused support agent.
|
|
2
|
+
|
|
3
|
+
Help users resolve the current issue clearly and efficiently.
|
|
4
|
+
|
|
5
|
+
Behavior:
|
|
6
|
+
- Ask for the minimum missing context needed to help.
|
|
7
|
+
- Use tools when order, account, booking, or case status is needed.
|
|
8
|
+
- Do not invent status, policy, price, or availability.
|
|
9
|
+
- Explain next steps in plain language.
|
|
10
|
+
- Escalate when the request involves billing disputes, safety, legal issues, account ownership, or anything outside the configured tools.
|
|
11
|
+
|
|
12
|
+
Boundaries:
|
|
13
|
+
- Do not claim to have changed anything unless a tool confirms it.
|
|
14
|
+
- Do not expose internal tool output, IDs, scores, secrets, or logs.
|
|
15
|
+
- If a tool fails, say what could not be verified and ask for a safe next step.
|
|
16
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentkit-capsule
|
|
3
|
+
description: Use when working inside an AgentKit Agent Capsule, especially after detecting agentkit.config.ts or when the owner asks to build, change, test, or deploy an AgentKit agent. Routes to task-specific AgentKit skills while avoiding loading the full docs by default.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentKit Capsule
|
|
7
|
+
|
|
8
|
+
Use this first inside an AgentKit Agent Capsule.
|
|
9
|
+
|
|
10
|
+
## Start
|
|
11
|
+
|
|
12
|
+
1. Treat the directory containing `agentkit.config.ts` as the capsule root.
|
|
13
|
+
2. Read `AGENTS.md` or `AGENTKIT.md` for capsule-specific rules.
|
|
14
|
+
3. Run `npm run agentkit -- docs llms` for the lightweight docs router.
|
|
15
|
+
4. Pick one task skill. Do not load `llms-full.txt` unless a task skill or ambiguous framework behavior requires the complete contract.
|
|
16
|
+
|
|
17
|
+
## Task Routing
|
|
18
|
+
|
|
19
|
+
- Build or reshape the agent from the owner's brief: `skills/agentkit-build-agent/SKILL.md`
|
|
20
|
+
- Edit prompts: `skills/agentkit-prompts/SKILL.md`
|
|
21
|
+
- Add actions or external data: `skills/agentkit-tools/SKILL.md`
|
|
22
|
+
- Add database tables or database-backed tools: `skills/agentkit-database/SKILL.md`
|
|
23
|
+
- Add docs, FAQs, prices, policies, or CSV facts: `skills/agentkit-knowledge/SKILL.md`
|
|
24
|
+
- Switch from `test/fake` to a real model provider: `skills/agentkit-provider/SKILL.md`
|
|
25
|
+
- Add or run evals: `skills/agentkit-evals/SKILL.md`
|
|
26
|
+
- Prepare hosted deploy: `skills/agentkit-deploy/SKILL.md`
|
|
27
|
+
- Work with secrets, external APIs, public access, channels, or real data: `skills/agentkit-security/SKILL.md`
|
|
28
|
+
- Add or debug website, Telegram, or WhatsApp channels: `skills/agentkit-channels/SKILL.md`
|
|
29
|
+
- Investigate command failures: `skills/agentkit-troubleshooting/SKILL.md`
|
|
30
|
+
|
|
31
|
+
For a compact docs map, read `references/docs-router.md`.
|
|
32
|
+
|
|
33
|
+
## Default Checks
|
|
34
|
+
|
|
35
|
+
Run these before finishing ordinary capsule work:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npm run typecheck
|
|
39
|
+
npm run agentkit -- inspect
|
|
40
|
+
npm run chat -- --message "hello"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If you add a tool, also run:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npm run agentkit -- tool <tool_name> --input '{}'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
If you change behavior, add or update an eval and run:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
npm run eval
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Rules
|
|
56
|
+
|
|
57
|
+
- Keep `.env`, `.agentkit/`, and `node_modules/` out of commits.
|
|
58
|
+
- Keep secret names in `.env.schema`; keep secret values in ignored `.env` or hosted managed secrets.
|
|
59
|
+
- Keep the first useful version runnable with `test/fake` unless the owner explicitly chooses a real provider.
|
|
60
|
+
- Ask follow-up questions only when missing information blocks a safe local implementation.
|
|
61
|
+
- Tell the owner when testing used `test/fake` instead of a real provider.
|
|
62
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# AgentKit Docs Router
|
|
2
|
+
|
|
3
|
+
Prefer the narrowest source that covers the task.
|
|
4
|
+
|
|
5
|
+
- Capsule creation and scaffold verification: `docs/guides/create-agent.md`
|
|
6
|
+
- Tools, schemas, secrets, and direct tool tests: `docs/guides/add-tool.md`
|
|
7
|
+
- Knowledge sources, indexing, search, and hosted sync: `docs/guides/add-knowledge.md`
|
|
8
|
+
- Evals and deterministic side-effect guards: `docs/guides/run-evals.md`
|
|
9
|
+
- Real provider setup: `docs/guides/use-provider.md`
|
|
10
|
+
- Deploy readiness, managed secrets, smoke checks, hosted UI: `docs/guides/prepare-deploy.md`
|
|
11
|
+
- Channels: `docs/guides/add-channel.md`, `connect-telegram.md`, `connect-whatsapp-zapster.md`, `debug-channel.md`
|
|
12
|
+
- Security: `docs/guides/security-rules.md`
|
|
13
|
+
|
|
14
|
+
Use `npm run agentkit -- docs full` only for a complete-contract audit, framework internals, or a behavior not covered by the task guide.
|
|
15
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentkit-channels
|
|
3
|
+
description: Use when adding, connecting, testing, buffering, or debugging AgentKit website, Telegram, or WhatsApp channels, including channel config helpers, provider secrets, webhook setup, channel tests, delivery logs, and burst-message buffers.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentKit Channels
|
|
7
|
+
|
|
8
|
+
Channels receive user messages. Tools let the agent call external systems. Keep them separate.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Add channel helpers in `agentkit.config.ts`.
|
|
13
|
+
2. Keep `runtime: "edge"` and `storage.driver: "agentkit"`.
|
|
14
|
+
3. Deploy before hosted channel creation.
|
|
15
|
+
4. Configure provider secrets as managed secrets.
|
|
16
|
+
5. Connect channel resources through the CLI.
|
|
17
|
+
6. Test, doctor, and inspect delivery logs.
|
|
18
|
+
|
|
19
|
+
## Buffering
|
|
20
|
+
|
|
21
|
+
Enable `buffer.mode: "debounce"` when clients send several short messages in a row and the agent should answer once.
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
whatsappChannel({
|
|
25
|
+
name: "support-whatsapp",
|
|
26
|
+
provider: "zapster",
|
|
27
|
+
buffer: {
|
|
28
|
+
mode: "debounce",
|
|
29
|
+
quietWindowMs: 2500,
|
|
30
|
+
maxWaitMs: 12000,
|
|
31
|
+
maxMessages: 20,
|
|
32
|
+
maxChars: 8000,
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Buffered deliveries show `buffered` until AgentKit flushes the conversation buffer into one queued run.
|
|
38
|
+
|
|
39
|
+
## Commands
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
npm run agentkit -- inspect
|
|
43
|
+
npm run agentkit -- deploy
|
|
44
|
+
npm run agentkit -- channels list
|
|
45
|
+
npm run agentkit -- channels add website website-chat
|
|
46
|
+
npm run agentkit -- channels connect telegram support-telegram
|
|
47
|
+
npm run agentkit -- channels add whatsapp support-whatsapp --provider zapster
|
|
48
|
+
npm run agentkit -- channels doctor support-telegram
|
|
49
|
+
npm run agentkit -- channels test support-telegram --message "hello"
|
|
50
|
+
npm run agentkit -- channels deliveries list support-telegram
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## References
|
|
54
|
+
|
|
55
|
+
- `references/telegram.md`
|
|
56
|
+
- `references/whatsapp-zapster.md`
|
|
57
|
+
- `references/channel-buffering.md`
|
|
58
|
+
- `references/channel-debugging.md`
|
|
59
|
+
|
|
60
|
+
## Safety
|
|
61
|
+
|
|
62
|
+
Do not paste provider tokens into code, docs, fixtures, prompts, evals, or delivery logs. Webhook URLs are public transport endpoints; authenticity comes from provider validation or channel tokens.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Channel Buffering
|
|
2
|
+
|
|
3
|
+
Use buffering when a client sends several messages in a burst and the agent should answer once.
|
|
4
|
+
|
|
5
|
+
Config:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
telegramChannel({
|
|
9
|
+
name: "support-telegram",
|
|
10
|
+
buffer: {
|
|
11
|
+
mode: "debounce",
|
|
12
|
+
quietWindowMs: 1500,
|
|
13
|
+
maxWaitMs: 8000,
|
|
14
|
+
maxMessages: 20,
|
|
15
|
+
maxChars: 8000,
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
whatsappChannel({
|
|
22
|
+
name: "support-whatsapp",
|
|
23
|
+
provider: "zapster",
|
|
24
|
+
buffer: {
|
|
25
|
+
mode: "debounce",
|
|
26
|
+
quietWindowMs: 2500,
|
|
27
|
+
maxWaitMs: 12000,
|
|
28
|
+
maxMessages: 20,
|
|
29
|
+
maxChars: 8000,
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Behavior:
|
|
35
|
+
|
|
36
|
+
- Buffer scope is one channel conversation.
|
|
37
|
+
- Provider validation and dedupe still run per webhook event.
|
|
38
|
+
- `quietWindowMs` flushes after the client stops sending messages.
|
|
39
|
+
- `maxWaitMs` guarantees a reply even if messages keep arriving.
|
|
40
|
+
- `maxMessages` and `maxChars` cap prompt size and cost.
|
|
41
|
+
- Omit `buffer` or set `buffer: { mode: "off" }` to run the agent once per inbound message.
|
|
42
|
+
|
|
43
|
+
Debug:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
agentkit channels deliveries list <name>
|
|
47
|
+
agentkit channels deliveries show <delivery-id>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Expected delivery states:
|
|
51
|
+
|
|
52
|
+
```txt
|
|
53
|
+
buffered
|
|
54
|
+
queued
|
|
55
|
+
running
|
|
56
|
+
agent_completed
|
|
57
|
+
outbound_sent
|
|
58
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Channel Debugging
|
|
2
|
+
|
|
3
|
+
Start with:
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
agentkit channels list
|
|
7
|
+
agentkit channels status <name>
|
|
8
|
+
agentkit channels doctor <name>
|
|
9
|
+
agentkit channels test <name> --message "hello"
|
|
10
|
+
agentkit channels deliveries list <name> --since 24h
|
|
11
|
+
agentkit channels deliveries show <delivery-id>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Common states:
|
|
15
|
+
|
|
16
|
+
```txt
|
|
17
|
+
webhook_received
|
|
18
|
+
validated
|
|
19
|
+
duplicate
|
|
20
|
+
buffered
|
|
21
|
+
queued
|
|
22
|
+
running
|
|
23
|
+
agent_completed
|
|
24
|
+
outbound_sent
|
|
25
|
+
delivered
|
|
26
|
+
provider_failed
|
|
27
|
+
synthetic_expected_failure
|
|
28
|
+
dead_lettered
|
|
29
|
+
skipped
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Common errors:
|
|
33
|
+
|
|
34
|
+
- `channel_not_found`: webhook URL points to an unknown channel.
|
|
35
|
+
- `channel_secret_missing`: required hosted secret is not set.
|
|
36
|
+
- `channel_signature_invalid`: webhook secret, token, or origin header mismatch.
|
|
37
|
+
- `channel_payload_invalid`: malformed or unsupported provider payload.
|
|
38
|
+
- `channel_event_duplicate`: provider retry; do not create a second run.
|
|
39
|
+
- `channel_limit_exceeded`: backpressure skipped the message.
|
|
40
|
+
- `synthetic_expected_failure`: a synthetic test reached AgentKit, but the provider correctly rejected a fake test recipient.
|
|
41
|
+
- `buffered` delivery state: message is waiting for the channel quiet window or max wait before one coalesced agent run is queued.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Telegram Channel
|
|
2
|
+
|
|
3
|
+
Required secrets:
|
|
4
|
+
|
|
5
|
+
```txt
|
|
6
|
+
TELEGRAM_BOT_TOKEN
|
|
7
|
+
TELEGRAM_WEBHOOK_SECRET
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Commands:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
agentkit deploy
|
|
14
|
+
agentkit secret set TELEGRAM_BOT_TOKEN --stdin
|
|
15
|
+
agentkit secret set TELEGRAM_WEBHOOK_SECRET --stdin
|
|
16
|
+
agentkit channels connect telegram support-telegram
|
|
17
|
+
agentkit channels doctor support-telegram
|
|
18
|
+
agentkit channels status support-telegram
|
|
19
|
+
agentkit channels test support-telegram --message "hello"
|
|
20
|
+
agentkit channels deliveries list support-telegram
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`connect` creates or reuses the hosted channel, validates managed secrets, calls Telegram `setWebhook`, confirms `getWebhookInfo`, runs a synthetic smoke, and prints the human Telegram steps. Use `setup --apply` only when you need to repeat webhook registration without running smoke.
|
|
24
|
+
|
|
25
|
+
Buffer rapid Telegram messages:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
telegramChannel({
|
|
29
|
+
name: "support-telegram",
|
|
30
|
+
buffer: {
|
|
31
|
+
mode: "debounce",
|
|
32
|
+
quietWindowMs: 1500,
|
|
33
|
+
maxWaitMs: 8000,
|
|
34
|
+
maxMessages: 20,
|
|
35
|
+
maxChars: 8000,
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# WhatsApp Through Zapster
|
|
2
|
+
|
|
3
|
+
Required secrets:
|
|
4
|
+
|
|
5
|
+
```txt
|
|
6
|
+
ZAPSTER_API_KEY
|
|
7
|
+
ZAPSTER_INSTANCE_ID
|
|
8
|
+
ZAPSTER_WEBHOOK_ID
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Optional hardening secret:
|
|
12
|
+
|
|
13
|
+
```txt
|
|
14
|
+
ZAPSTER_WEBHOOK_TOKEN
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Commands:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
agentkit deploy
|
|
21
|
+
agentkit channels add whatsapp support-whatsapp --provider zapster
|
|
22
|
+
agentkit channels setup support-whatsapp
|
|
23
|
+
agentkit channels status support-whatsapp
|
|
24
|
+
agentkit channels test support-whatsapp --message "hello"
|
|
25
|
+
agentkit channels deliveries list support-whatsapp
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Paste the stable AgentKit webhook URL into Zapster settings. If the channel declares `ZAPSTER_WEBHOOK_TOKEN`, append `?token=<ZAPSTER_WEBHOOK_TOKEN>` to the Zapster webhook URL. Keep phone numbers redacted in logs by default.
|
|
29
|
+
|
|
30
|
+
Buffer rapid WhatsApp messages:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
whatsappChannel({
|
|
34
|
+
name: "support-whatsapp",
|
|
35
|
+
provider: "zapster",
|
|
36
|
+
buffer: {
|
|
37
|
+
mode: "debounce",
|
|
38
|
+
quietWindowMs: 2500,
|
|
39
|
+
maxWaitMs: 12000,
|
|
40
|
+
maxMessages: 20,
|
|
41
|
+
maxChars: 8000,
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentkit-database
|
|
3
|
+
description: Use when adding AgentKit-managed database tables, editing schema.sql, writing database-backed tools, seeding local data, or verifying local/hosted storage compatibility through ctx.db.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentKit Database
|
|
7
|
+
|
|
8
|
+
Use this when a capsule owns durable application records.
|
|
9
|
+
|
|
10
|
+
## Rules
|
|
11
|
+
|
|
12
|
+
- Put the first idempotent bootstrap schema in `schema.sql`.
|
|
13
|
+
- For production-shaped changes, prefer ordered `migrations/*.sql` files such as `migrations/0001_initial.sql`.
|
|
14
|
+
- Keep `schema.sql` idempotent with `CREATE TABLE IF NOT EXISTS`, `CREATE INDEX IF NOT EXISTS`, and safe additive changes.
|
|
15
|
+
- Keep deploy-ready capsules on `storage.driver: "agentkit"`.
|
|
16
|
+
- Use `ctx.db` inside tools. `ctx.database` and `ctx.storage.sql` are aliases.
|
|
17
|
+
- Do not import SQLite, Turso, or other database drivers from tools.
|
|
18
|
+
- Do not edit `.agentkit/agentkit.db` by hand.
|
|
19
|
+
- For external catalogs, run `npm run agentkit -- sync init`, then implement `sync.ts` and keep local fixtures in `seed.sql`.
|
|
20
|
+
|
|
21
|
+
## Templates
|
|
22
|
+
|
|
23
|
+
- `templates/appointments.schema.sql`
|
|
24
|
+
- `templates/leads.schema.sql`
|
|
25
|
+
|
|
26
|
+
## Commands
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
npm run agentkit -- db migrate
|
|
30
|
+
npm run agentkit -- db seed --file seed.sql
|
|
31
|
+
npm run agentkit -- sync init
|
|
32
|
+
npm run agentkit -- sync run
|
|
33
|
+
npm run agentkit -- db shell
|
|
34
|
+
npm run agentkit -- db reset --yes
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Verification
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm run typecheck
|
|
41
|
+
npm run agentkit -- db migrate
|
|
42
|
+
npm run agentkit -- tool <tool_name> --input '<json>'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Hosted deploy applies AgentKit-managed storage internally. The user should not create hosted databases or buckets by hand.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS appointments (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
client_name TEXT NOT NULL,
|
|
4
|
+
contact TEXT NOT NULL,
|
|
5
|
+
starts_at TEXT NOT NULL,
|
|
6
|
+
notes TEXT,
|
|
7
|
+
status TEXT NOT NULL DEFAULT 'scheduled',
|
|
8
|
+
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
9
|
+
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
10
|
+
UNIQUE (starts_at)
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
CREATE INDEX IF NOT EXISTS appointments_contact_idx
|
|
14
|
+
ON appointments (contact);
|
|
15
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS leads (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
name TEXT NOT NULL,
|
|
4
|
+
email TEXT,
|
|
5
|
+
phone TEXT,
|
|
6
|
+
status TEXT NOT NULL DEFAULT 'new',
|
|
7
|
+
notes TEXT,
|
|
8
|
+
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
9
|
+
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE INDEX IF NOT EXISTS leads_status_idx
|
|
13
|
+
ON leads (status);
|
|
14
|
+
|
|
15
|
+
CREATE INDEX IF NOT EXISTS leads_email_idx
|
|
16
|
+
ON leads (email);
|
|
17
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentkit-deploy
|
|
3
|
+
description: Use when preparing or running AgentKit hosted deploys, deploy readiness checks, managed secrets, deploy smoke tests, hosted chat UI checks, access tokens, or production handoff.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentKit Deploy
|
|
7
|
+
|
|
8
|
+
Use this when the owner asks to prepare, test, or run hosted deploy.
|
|
9
|
+
|
|
10
|
+
## Rules
|
|
11
|
+
|
|
12
|
+
- The user should not choose hosting infrastructure. AgentKit owns target routing.
|
|
13
|
+
- Keep production secret values out of the capsule.
|
|
14
|
+
- Use hosted managed secrets, not committed `.env`.
|
|
15
|
+
- Run readiness checks before saying deploy-ready.
|
|
16
|
+
|
|
17
|
+
## Local Readiness
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm run typecheck
|
|
21
|
+
npm run agentkit -- inspect
|
|
22
|
+
npm run agentkit -- db migrate
|
|
23
|
+
npm run chat -- --message "hello"
|
|
24
|
+
npm run agentkit -- deploy --dry-run
|
|
25
|
+
npm run agentkit -- deploy doctor
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Hosted Flow
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm run agentkit -- login --token agk_user_...
|
|
32
|
+
npm run agentkit -- secret sync --from-local
|
|
33
|
+
npm run agentkit -- secret list
|
|
34
|
+
npm run agentkit -- deploy --smoke "hello"
|
|
35
|
+
npm run agentkit -- deploy status
|
|
36
|
+
npm run agentkit -- chat-ui --deploy
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Open the printed `Chat:` URL and report it to the owner.
|
|
40
|
+
|
|
41
|
+
## Production Handoff
|
|
42
|
+
|
|
43
|
+
Report changed files, required env/secret names, database schema changes, deploy order, smoke checks, rollback concerns, and whether the provider was still `test/fake`.
|
|
44
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentkit-evals
|
|
3
|
+
description: Use when adding, editing, or running AgentKit eval files, including smoke evals, response assertions, persisted tool call assertions, no-leak checks, and eval-safe handling for external side effects.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentKit Evals
|
|
7
|
+
|
|
8
|
+
Use evals after chat works and before claiming behavior is stable.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Create or edit `evals/<name>.eval.ts`.
|
|
13
|
+
2. Keep assertions small and deterministic.
|
|
14
|
+
3. Use `turns` for full conversation flows, such as user asks, agent calls a tool, then the answer follows the required format.
|
|
15
|
+
4. Use `persisted_tool_call` for tool behavior stored in local SQLite.
|
|
16
|
+
5. Convert real failures into regression tests with `npm run agentkit -- eval from-conversation <conversation-id>`.
|
|
17
|
+
6. Do not put secrets or real client PII in evals.
|
|
18
|
+
7. For tools that write externally, delete, charge money, send email, or call real customer systems, branch on `ctx.runtime.environment === "eval"` inside the registered tool.
|
|
19
|
+
|
|
20
|
+
## Multi-turn Example
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
export default {
|
|
24
|
+
name: "buyer under budget",
|
|
25
|
+
turns: [
|
|
26
|
+
{
|
|
27
|
+
input: "I want a house up to 600k near Pinheiros.",
|
|
28
|
+
expect: {
|
|
29
|
+
persisted_tool_call: {
|
|
30
|
+
name: "buscar_imoveis",
|
|
31
|
+
status: "completed",
|
|
32
|
+
input: { maxPrice: 600000 },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
input: "Show me the best two.",
|
|
38
|
+
expect: {
|
|
39
|
+
contains: ["R$", "Pinheiros"],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Templates
|
|
47
|
+
|
|
48
|
+
- `templates/smoke.eval.md`
|
|
49
|
+
- `templates/tool-call.eval.md`
|
|
50
|
+
- `templates/multi-turn.eval.md`
|
|
51
|
+
- `templates/no-leak.eval.md`
|
|
52
|
+
|
|
53
|
+
## Verification
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
npm run typecheck
|
|
57
|
+
npm run eval
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If eval output changes after switching providers, keep deterministic smoke evals on `test/fake` and add provider-specific evals separately.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
export default {
|
|
3
|
+
name: "main conversation flow",
|
|
4
|
+
turns: [
|
|
5
|
+
{
|
|
6
|
+
input: "I need help finding an option under my budget.",
|
|
7
|
+
expect: {
|
|
8
|
+
contains: "budget",
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
input: "Show me the best match.",
|
|
13
|
+
expect: {
|
|
14
|
+
persisted_tool_call: {
|
|
15
|
+
name: "replace_with_tool_name",
|
|
16
|
+
status: "completed",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
```
|