@andreprado/agentkit 0.1.0-alpha.2 → 0.1.0-alpha.21
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 +68 -6
- package/docs/guides/add-channel.md +189 -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 +128 -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-evolution.md +121 -0
- package/docs/guides/connect-whatsapp-uazapi.md +126 -0
- 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 +348 -55
- package/docs/llms.txt +62 -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 +1586 -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 +517 -8
- 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 +21 -1
- package/src/runtime/channels/discord.ts +896 -0
- package/src/runtime/channels/generic-webhook.ts +225 -0
- package/src/runtime/channels/slack.ts +646 -0
- package/src/runtime/channels/telegram.ts +466 -23
- package/src/runtime/channels/whatsapp-evolution.ts +1357 -0
- package/src/runtime/channels/whatsapp-meta.ts +9 -0
- package/src/runtime/channels/whatsapp-uazapi.ts +1327 -0
- package/src/runtime/channels/whatsapp-zapster.ts +677 -40
- package/src/runtime/channels.ts +87 -4
- package/src/runtime/chat.ts +130 -38
- package/src/runtime/config.ts +519 -19
- 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 +779 -45
- 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 +1468 -203
- 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 +127 -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-evolution.md +57 -0
- package/src/templates/skills/agentkit-channels/references/whatsapp-uazapi.md +61 -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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Replay Side Effects
|
|
2
|
+
|
|
3
|
+
Replay runs collected user turns through the local capsule with:
|
|
4
|
+
|
|
5
|
+
```txt
|
|
6
|
+
ctx.runtime.environment === "eval"
|
|
7
|
+
ctx.runtime.invocation === "eval"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Tools still execute. Any tool that writes externally, deletes data, charges money, sends email, sends messages, or calls a real customer system must guard eval mode:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
if (ctx.runtime.environment === "eval") {
|
|
14
|
+
return { ok: true, evalFixture: true };
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Do not rely on prompt text alone to prevent side effects.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Trace Packets
|
|
2
|
+
|
|
3
|
+
`agentkit improve collect` writes an ignored evidence bundle:
|
|
4
|
+
|
|
5
|
+
```txt
|
|
6
|
+
.agentkit/improve/<run>/
|
|
7
|
+
bundle.json
|
|
8
|
+
report.json
|
|
9
|
+
traces/
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Use `report.json` for a quick index and `traces/<trace_id>.json` for the full conversation trace.
|
|
13
|
+
|
|
14
|
+
The bundle can contain hosted or local traces. Treat both as sensitive source material. Do not commit `.agentkit/improve/`.
|
|
15
|
+
|
|
16
|
+
Generated evals belong in:
|
|
17
|
+
|
|
18
|
+
```txt
|
|
19
|
+
evals/regressions/
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Before committing generated evals, remove real client PII and replace brittle exact response assertions with the important behavior when needed. AgentKit redacts common email, phone, bearer token, and key patterns in generated eval text, but it cannot know every domain-specific identifier.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
import { defineEval } from "@andreprado/agentkit";
|
|
3
|
+
|
|
4
|
+
export default defineEval({
|
|
5
|
+
name: "production regression",
|
|
6
|
+
turns: [
|
|
7
|
+
{
|
|
8
|
+
input: "User message from the production trace.",
|
|
9
|
+
expect: {
|
|
10
|
+
response: {
|
|
11
|
+
containsAny: ["required phrase", "acceptable alternative"],
|
|
12
|
+
notRegex: ["API_KEY|secret|token"],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
});
|
|
18
|
+
```
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentkit-integrations
|
|
3
|
+
description: Use when adding, inspecting, connecting, or troubleshooting AgentKit-managed integrations such as managed Composio in an Agent Capsule.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentKit Integrations
|
|
7
|
+
|
|
8
|
+
Use this when the owner asks for managed connected apps, Gmail/Calendar/Slack/Linear through AgentKit, or paid AgentKit-managed Composio.
|
|
9
|
+
|
|
10
|
+
## Managed Composio
|
|
11
|
+
|
|
12
|
+
Managed Composio is a paid hosted AgentKit feature. Use it when the owner wants AgentKit to manage OAuth/connect links, per-agent connected app state, deploy readiness, and hosted Composio credentials.
|
|
13
|
+
|
|
14
|
+
Use BYO `defineTool` instead when the owner wants to bring their own Composio account/API key.
|
|
15
|
+
|
|
16
|
+
## Config
|
|
17
|
+
|
|
18
|
+
Edit `agentkit.config.ts`:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { composioManaged, defineAgent } from "@andreprado/agentkit";
|
|
22
|
+
|
|
23
|
+
export default defineAgent({
|
|
24
|
+
integrations: [
|
|
25
|
+
composioManaged({
|
|
26
|
+
toolkits: ["gmail", "googlecalendar"],
|
|
27
|
+
tools: {
|
|
28
|
+
gmail: ["GMAIL_FETCH_EMAILS", "GMAIL_SEND_EMAIL"],
|
|
29
|
+
googlecalendar: [
|
|
30
|
+
"GOOGLECALENDAR_EVENTS_LIST",
|
|
31
|
+
"GOOGLECALENDAR_CREATE_EVENT",
|
|
32
|
+
"GOOGLECALENDAR_UPDATE_EVENT",
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
confirmExternalWrites: true,
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Keep the action list explicit. Do not expose the whole Composio catalog by default.
|
|
42
|
+
|
|
43
|
+
For Google Calendar, do not configure create-only access. Include `GOOGLECALENDAR_EVENTS_LIST` so the agent can inspect availability before writing. For `GOOGLECALENDAR_CREATE_EVENT`, pass UTC `start_datetime` and explicit `event_duration_minutes` or `event_duration_hour`; AgentKit blocks Composio's implicit 30-minute duration default.
|
|
44
|
+
|
|
45
|
+
Managed Composio write actions require tool input `confirmed: true` by default. Set it only after the owner/user confirms the exact external change. Use `confirmExternalWrites: false` only when the capsule implements an equivalent confirmation guard elsewhere.
|
|
46
|
+
|
|
47
|
+
## Commands
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npm run agentkit -- inspect
|
|
51
|
+
npm run agentkit -- deploy doctor
|
|
52
|
+
npm run agentkit -- deploy
|
|
53
|
+
npm run agentkit -- integrations status --toolkit googlecalendar
|
|
54
|
+
npm run agentkit -- integrations connect composio --toolkit gmail
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Rules
|
|
58
|
+
|
|
59
|
+
- Do not add `COMPOSIO_API_KEY` to `.env.schema` for managed Composio.
|
|
60
|
+
- Do not ask the owner for a Composio key when using managed Composio.
|
|
61
|
+
- Do not ask the owner for Composio auth config ids; AgentKit Cloud resolves toolkit auth configs.
|
|
62
|
+
- Managed Composio requires a non-anonymous hosted deploy and `managed_composio` entitlement.
|
|
63
|
+
- The generated tool is `agentkit_composio_execute`.
|
|
64
|
+
- Use one Composio settings profile per agent.
|
|
65
|
+
|
|
66
|
+
## Verification
|
|
67
|
+
|
|
68
|
+
Expected `inspect` output includes:
|
|
69
|
+
|
|
70
|
+
```txt
|
|
71
|
+
integrations[0].provider = composio
|
|
72
|
+
tools includes agentkit_composio_execute
|
|
73
|
+
managedSecrets includes COMPOSIO_API_KEY
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
If `deploy doctor` reports `managed_composio_entitlement_required`, the owner must log in with a paid AgentKit Cloud account or ask an operator to grant it.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentkit-knowledge
|
|
3
|
+
description: Use when adding AgentKit Knowledge sources for grounded answers from local Markdown, text, or CSV files, configuring retrieval or embeddings, syncing/searching Knowledge, or deciding between Knowledge and tools.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentKit Knowledge
|
|
7
|
+
|
|
8
|
+
Use Knowledge for committed reference facts: FAQs, policies, prices, service descriptions, procedures, and CSV tables.
|
|
9
|
+
|
|
10
|
+
Use tools instead for live records, authorization-sensitive data, customer-specific data, payments, orders, or writes.
|
|
11
|
+
|
|
12
|
+
## Workflow
|
|
13
|
+
|
|
14
|
+
1. Create files under `knowledge/`.
|
|
15
|
+
2. Configure `knowledge.sources` in `agentkit.config.ts`.
|
|
16
|
+
3. Use lexical search by default. Add embeddings only when needed.
|
|
17
|
+
4. Run sync and search before relying on answers.
|
|
18
|
+
|
|
19
|
+
## Templates
|
|
20
|
+
|
|
21
|
+
- `templates/faq.md`
|
|
22
|
+
- `templates/policies.md`
|
|
23
|
+
- `templates/prices.csv`
|
|
24
|
+
|
|
25
|
+
## Commands
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm run agentkit -- knowledge add knowledge/faq.md
|
|
29
|
+
npm run agentkit -- knowledge sync
|
|
30
|
+
npm run agentkit -- knowledge inspect
|
|
31
|
+
npm run agentkit -- knowledge search "refund policy" --top-k 3
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
On Windows PowerShell, if `npm.ps1` is blocked with `PSSecurityException`, use `npm.cmd run agentkit -- knowledge sync` and `npm.cmd run agentkit -- knowledge search "refund policy" --top-k 3`.
|
|
35
|
+
|
|
36
|
+
Local lexical search uses SQLite FTS5 when available. If the local SQLite build does not provide FTS5, AgentKit automatically uses a plain SQLite fallback table and simpler text matching.
|
|
37
|
+
|
|
38
|
+
## Safety
|
|
39
|
+
|
|
40
|
+
- Do not put secrets, credentials, `.env` contents, or private tokens in Knowledge files.
|
|
41
|
+
- Treat committed Knowledge files as repo content.
|
|
42
|
+
- Use a private repo for private business docs.
|
|
43
|
+
- Do not expose raw retrieval JSON, scores, chunk IDs, or tool output objects to users.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# FAQ
|
|
2
|
+
|
|
3
|
+
## What services do you offer?
|
|
4
|
+
|
|
5
|
+
Replace this answer with the owner's real services.
|
|
6
|
+
|
|
7
|
+
## What are your hours?
|
|
8
|
+
|
|
9
|
+
Replace this answer with the owner's real business hours.
|
|
10
|
+
|
|
11
|
+
## How should users contact a human?
|
|
12
|
+
|
|
13
|
+
Replace this answer with the owner's real escalation path.
|
|
14
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentkit-prompts
|
|
3
|
+
description: Use when writing or revising AgentKit prompt files, especially prompts/instructions.md, including agent role, behavior, boundaries, escalation rules, tool-use policy, Knowledge policy, and user-facing tone.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentKit Prompts
|
|
7
|
+
|
|
8
|
+
Use this when editing `prompts/instructions.md`.
|
|
9
|
+
|
|
10
|
+
## Prompt Checklist
|
|
11
|
+
|
|
12
|
+
Include only behavior the runtime should apply on every conversation:
|
|
13
|
+
|
|
14
|
+
- agent role and audience;
|
|
15
|
+
- domain-specific goals;
|
|
16
|
+
- what information to collect;
|
|
17
|
+
- when to use tools;
|
|
18
|
+
- when to search Knowledge;
|
|
19
|
+
- how to interpret scheduling language such as today, tomorrow, and next Friday;
|
|
20
|
+
- what the agent must not claim;
|
|
21
|
+
- escalation and safety boundaries;
|
|
22
|
+
- response style.
|
|
23
|
+
|
|
24
|
+
AgentKit injects the current timestamp, local date, weekday, and timezone dynamically at runtime. Do not hardcode today's date in `prompts/instructions.md`; set `timeZone` in `agentkit.config.ts` when a scheduling agent needs a specific business/user timezone.
|
|
25
|
+
|
|
26
|
+
Keep operational secrets, provider details, and implementation notes out of prompts.
|
|
27
|
+
|
|
28
|
+
## Tool And Knowledge Policy
|
|
29
|
+
|
|
30
|
+
- Use tools for actions, live data, authorization-sensitive records, payments, orders, booking, and writes.
|
|
31
|
+
- Use Knowledge for committed reference facts such as FAQs, prices, services, policies, procedures, and CSV tables.
|
|
32
|
+
- Do not expose raw tool output, retrieval JSON, chunk IDs, scores, secrets, logs, or internal labels.
|
|
33
|
+
|
|
34
|
+
## Templates
|
|
35
|
+
|
|
36
|
+
- `templates/knowledge-grounded-faq.instructions.md`
|
|
37
|
+
- `../agentkit-build-agent/templates/support-agent.instructions.md`
|
|
38
|
+
- `../agentkit-build-agent/templates/appointment-intake.instructions.md`
|
|
39
|
+
|
|
40
|
+
## Verification
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
npm run chat -- --message "hello"
|
|
44
|
+
npm run eval
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
If the provider is still `test/fake`, say prompt behavior was not tested with a real model.
|
package/src/templates/skills/agentkit-prompts/templates/knowledge-grounded-faq.instructions.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
You are a knowledge-grounded FAQ agent.
|
|
2
|
+
|
|
3
|
+
Use the configured Knowledge search before answering business-specific factual questions about services, prices, policies, procedures, or support rules.
|
|
4
|
+
|
|
5
|
+
Rules:
|
|
6
|
+
- Answer from the retrieved source material when available.
|
|
7
|
+
- If the answer is not in the available sources, say that you do not have enough information.
|
|
8
|
+
- Do not expose raw retrieval JSON, scores, chunk IDs, or internal source metadata.
|
|
9
|
+
- Do not use Knowledge for secrets, credentials, live customer records, payments, or authorization-sensitive data.
|
|
10
|
+
- Use tools for live or customer-specific lookups.
|
|
11
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentkit-provider
|
|
3
|
+
description: Use when switching an AgentKit capsule from the deterministic test/fake provider to a real Pi-backed provider such as OpenAI, Anthropic, or OpenRouter, or when verifying provider secrets and model behavior.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentKit Provider
|
|
7
|
+
|
|
8
|
+
Use this when `test/fake` is no longer enough.
|
|
9
|
+
|
|
10
|
+
## Rule
|
|
11
|
+
|
|
12
|
+
Do not choose a real provider automatically. Ask the owner which provider to use: OpenRouter, OpenAI, Anthropic, or another supported provider.
|
|
13
|
+
|
|
14
|
+
## Workflow
|
|
15
|
+
|
|
16
|
+
1. Edit `agentkit.config.ts`.
|
|
17
|
+
2. Add required secret names to `secrets`.
|
|
18
|
+
3. Add names to `.env.schema`.
|
|
19
|
+
4. Set local secret values in ignored `.env` through AgentKit commands.
|
|
20
|
+
5. Run inspect, chat, and UI checks.
|
|
21
|
+
|
|
22
|
+
## Config Examples
|
|
23
|
+
|
|
24
|
+
OpenAI:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
provider: { name: "openai", model: "gpt-4o-mini" },
|
|
28
|
+
secrets: ["OPENAI_API_KEY"],
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Anthropic:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
provider: { name: "anthropic", model: "claude-3-5-haiku-latest" },
|
|
35
|
+
secrets: ["ANTHROPIC_API_KEY"],
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
OpenRouter:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
provider: { name: "openrouter", model: "gpt-4o-mini" },
|
|
42
|
+
secrets: ["OPENROUTER_API_KEY"],
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Prefer OpenRouter model ids or aliases known to the installed Pi SDK, such as `~google/gemini-flash-latest`. If a raw OpenRouter id is newer than Pi's registry, AgentKit passes it through to OpenRouter with conservative unknown-model metadata; OpenRouter can still reject invalid, inaccessible, or unsupported models.
|
|
46
|
+
|
|
47
|
+
## Verification
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npm run typecheck
|
|
51
|
+
npm run agentkit -- inspect
|
|
52
|
+
npm run chat -- --message "hello"
|
|
53
|
+
npm run dev
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
On Windows PowerShell, if `npm.ps1` is blocked with `PSSecurityException`, use `npm.cmd run typecheck`, `npm.cmd run agentkit -- inspect`, and `npm.cmd run chat -- --message "hello"`.
|
|
57
|
+
|
|
58
|
+
Open the printed `Chat:` URL and report it to the owner.
|
|
59
|
+
|
|
60
|
+
Do not import provider SDKs in the capsule. AgentKit resolves providers internally through Pi-backed adapters.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentkit-security
|
|
3
|
+
description: Use before or during AgentKit work involving secrets, external APIs, tools, evals from real data, public access, hosted deploys, or messaging channels.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentKit Security
|
|
7
|
+
|
|
8
|
+
Use this as a guardrail skill.
|
|
9
|
+
|
|
10
|
+
## Never Commit
|
|
11
|
+
|
|
12
|
+
```txt
|
|
13
|
+
.env
|
|
14
|
+
.agentkit/
|
|
15
|
+
node_modules/
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Secret values must not appear in:
|
|
19
|
+
|
|
20
|
+
```txt
|
|
21
|
+
agentkit.config.ts
|
|
22
|
+
.env.schema
|
|
23
|
+
AGENTS.md
|
|
24
|
+
AGENTKIT.md
|
|
25
|
+
CLAUDE.md
|
|
26
|
+
README.md
|
|
27
|
+
prompts/
|
|
28
|
+
evals/
|
|
29
|
+
docs/
|
|
30
|
+
skills/
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Rules
|
|
34
|
+
|
|
35
|
+
- `.env.schema` stores secret names only.
|
|
36
|
+
- Ignored `.env` stores local development values only.
|
|
37
|
+
- Hosted production uses managed secrets.
|
|
38
|
+
- Tools receive only secrets listed in that tool's `secrets` field.
|
|
39
|
+
- Prefer `ctx.secrets` over direct `process.env` reads in tools.
|
|
40
|
+
- Add `permissions` for external capabilities.
|
|
41
|
+
- Add timeouts to network tools.
|
|
42
|
+
- Remove client PII before writing evals.
|
|
43
|
+
- Keep `.agentkit/improve/` bundles out of commits and review generated regression evals before committing.
|
|
44
|
+
- Guard replay/eval mode inside external write tools with `ctx.runtime.environment === "eval"`.
|
|
45
|
+
- Treat hosted deploy URLs as addresses, not access control. Hosted chat, conversation reads, and trace reads require a deploy access token even if a config says `access.mode: "public"`.
|
|
46
|
+
|
|
47
|
+
## Checks
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
git status --short
|
|
51
|
+
npm run agentkit -- env list
|
|
52
|
+
npm run agentkit -- inspect
|
|
53
|
+
git diff --check
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Expected: secret names may appear, secret values do not.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentkit-tools
|
|
3
|
+
description: Use when adding, changing, registering, or testing AgentKit TypeScript tools with defineTool, including external APIs, local actions, input/output schemas, tool secrets, permissions, timeouts, and eval-safe side effects.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentKit Tools
|
|
7
|
+
|
|
8
|
+
Use this when the agent needs code, an API, live data, a write, or an external action.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Create or edit `tools/<name>.ts`.
|
|
13
|
+
2. Export a `defineTool` tool with `name`, `description`, `inputSchema`, and usually `outputSchema`.
|
|
14
|
+
3. Add `secrets`, `permissions`, and `timeoutMs` when needed.
|
|
15
|
+
4. Register the tool in `agentkit.config.ts`.
|
|
16
|
+
5. Keep secret names in `.env.schema`; values stay in ignored `.env` or hosted managed secrets.
|
|
17
|
+
6. Use `ctx.clock` for date-sensitive tool logic instead of calling `new Date()` directly.
|
|
18
|
+
7. Add eval guards for destructive or external side effects.
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
- `examples/lookup-order.tool.md`: simple lookup
|
|
23
|
+
- `examples/database-write.tool.md`: write through `ctx.db`
|
|
24
|
+
- `examples/eval-safe-external-action.tool.md`: safe eval branch for external side effects
|
|
25
|
+
|
|
26
|
+
Use `skills/agentkit-database/SKILL.md` for database-backed tools.
|
|
27
|
+
Use `skills/agentkit-security/SKILL.md` before adding external APIs or secrets.
|
|
28
|
+
|
|
29
|
+
## Verification
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
npm run typecheck
|
|
33
|
+
npm run agentkit -- tool <tool_name> --input '<json>'
|
|
34
|
+
npm run agentkit -- inspect
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Expected: input/output validation passes, tool calls persist, and no secret values appear in output or stored data.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Database Write Tool
|
|
2
|
+
|
|
3
|
+
Copy the code into a real tool file and make sure `schema.sql` contains the target table.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { defineTool } from "@andreprado/agentkit";
|
|
7
|
+
|
|
8
|
+
export const saveNote = defineTool({
|
|
9
|
+
name: "save_note",
|
|
10
|
+
description: "Saves a note in the AgentKit-managed database.",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
content: { type: "string" },
|
|
15
|
+
},
|
|
16
|
+
required: ["content"],
|
|
17
|
+
additionalProperties: false,
|
|
18
|
+
},
|
|
19
|
+
outputSchema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
id: { type: "string" },
|
|
23
|
+
content: { type: "string" },
|
|
24
|
+
},
|
|
25
|
+
required: ["id", "content"],
|
|
26
|
+
additionalProperties: false,
|
|
27
|
+
},
|
|
28
|
+
async execute(input: { content: string }, ctx) {
|
|
29
|
+
const id = crypto.randomUUID();
|
|
30
|
+
await ctx.db.execute("INSERT INTO notes (id, content) VALUES (?, ?)", [id, input.content]);
|
|
31
|
+
return { id, content: input.content };
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Eval-Safe External Action Tool
|
|
2
|
+
|
|
3
|
+
Use this pattern for tools that send email, call customer systems, charge money, delete data, or perform other external side effects.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { defineTool } from "@andreprado/agentkit";
|
|
7
|
+
|
|
8
|
+
export const sendFollowupEmail = defineTool({
|
|
9
|
+
name: "send_followup_email",
|
|
10
|
+
description: "Sends a follow-up email after explicit confirmation.",
|
|
11
|
+
secrets: ["EMAIL_API_KEY"],
|
|
12
|
+
permissions: ["email:send"],
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
email: { type: "string" },
|
|
17
|
+
confirmed: { type: "boolean" },
|
|
18
|
+
},
|
|
19
|
+
required: ["email", "confirmed"],
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
},
|
|
22
|
+
async execute(input: { email: string; confirmed: boolean }, ctx) {
|
|
23
|
+
if (!input.confirmed) {
|
|
24
|
+
return { sent: false, reason: "confirmation_required" };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (ctx.runtime.environment === "eval") {
|
|
28
|
+
return { sent: false, evalFixture: true, email: input.email };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const apiKey = ctx.secrets.EMAIL_API_KEY;
|
|
32
|
+
// Call the real email provider with apiKey here.
|
|
33
|
+
return { sent: true, evalFixture: false, email: input.email };
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Lookup Order Tool
|
|
2
|
+
|
|
3
|
+
Copy the code into `tools/lookup-order.ts` and register `lookupOrder` in `agentkit.config.ts`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { defineTool } from "@andreprado/agentkit";
|
|
7
|
+
|
|
8
|
+
const orders: Record<string, { status: string; eta: string }> = {
|
|
9
|
+
A100: { status: "preparing", eta: "today" },
|
|
10
|
+
B200: { status: "shipped", eta: "tomorrow" },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const lookupOrder = defineTool({
|
|
14
|
+
name: "lookup_order",
|
|
15
|
+
description: "Looks up a demo support order by order id.",
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: "object",
|
|
18
|
+
properties: {
|
|
19
|
+
orderId: { type: "string" },
|
|
20
|
+
},
|
|
21
|
+
required: ["orderId"],
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
},
|
|
24
|
+
outputSchema: {
|
|
25
|
+
type: "object",
|
|
26
|
+
properties: {
|
|
27
|
+
orderId: { type: "string" },
|
|
28
|
+
found: { type: "boolean" },
|
|
29
|
+
status: { type: "string" },
|
|
30
|
+
eta: { type: "string" },
|
|
31
|
+
},
|
|
32
|
+
required: ["orderId", "found", "status", "eta"],
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
},
|
|
35
|
+
execute(input: { orderId: string }) {
|
|
36
|
+
const order = orders[input.orderId];
|
|
37
|
+
return {
|
|
38
|
+
orderId: input.orderId,
|
|
39
|
+
found: Boolean(order),
|
|
40
|
+
status: order?.status ?? "unknown",
|
|
41
|
+
eta: order?.eta ?? "unknown",
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentkit-troubleshooting
|
|
3
|
+
description: Use when an AgentKit command, local chat, tool, eval, Knowledge sync, channel, or deploy fails and the coding agent needs to diagnose from CLI output and route to the right narrow skill or docs guide.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentKit Troubleshooting
|
|
7
|
+
|
|
8
|
+
Use this when something fails.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Read the exact error code and message.
|
|
13
|
+
2. Run the narrow inspect command before guessing.
|
|
14
|
+
3. Route to a task skill when the failure points to config, tools, database, provider, evals, deploy, Knowledge, or channels.
|
|
15
|
+
4. Load `llms-full.txt` only when the narrow skill and guide do not explain the behavior.
|
|
16
|
+
5. If the failure appears to be an AgentKit bug, missing docs, or unclear recovery path, create a local feedback draft after diagnosis.
|
|
17
|
+
|
|
18
|
+
## First Commands
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm run agentkit -- inspect
|
|
22
|
+
npm run agentkit -- skills status
|
|
23
|
+
npm run typecheck
|
|
24
|
+
npm run agentkit -- env list
|
|
25
|
+
git status --short
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For chat issues:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm run chat -- --message "hello"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
For tool issues:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npm run agentkit -- tool <tool_name> --input '<json>'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For deploy issues:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
npm run agentkit -- deploy doctor
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
For AgentKit product feedback:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npm run agentkit -- feedback create --about last-run --kind bug --summary "short concrete summary"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
For production behavior issues:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
npm run agentkit -- improve collect --deploy --since 24h
|
|
56
|
+
npm run agentkit -- improve evals .agentkit/improve/<run>
|
|
57
|
+
npm run agentkit -- replay .agentkit/improve/<run> --against local
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Common Causes
|
|
61
|
+
|
|
62
|
+
- missing dependencies: run `npm install`;
|
|
63
|
+
- missing provider key: set ignored `.env` and confirm with `inspect`;
|
|
64
|
+
- provider not chosen: stay on `test/fake` or ask the owner;
|
|
65
|
+
- schema missing: run `db migrate` and check `schema.sql`;
|
|
66
|
+
- tool validation failed: check `inputSchema` and `outputSchema`;
|
|
67
|
+
- channel secret missing: set hosted managed secret, not source files;
|
|
68
|
+
- production behavior drift: collect an improve bundle and convert it to regression evals before patching;
|
|
69
|
+
- local AgentKit skills are stale: run `npm run agentkit -- skills sync`.
|
|
70
|
+
|
|
71
|
+
## Feedback Rules
|
|
72
|
+
|
|
73
|
+
- `feedback create` writes a local draft only; it does not send anything.
|
|
74
|
+
- Review the draft before `feedback send`.
|
|
75
|
+
- Sending requires `agentkit login --token agk_user_...`.
|
|
76
|
+
- Do not paste `.env` values, provider keys, cookies, client PII, or full private transcripts into feedback.
|