@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.
Files changed (135) hide show
  1. package/README.md +67 -6
  2. package/docs/guides/add-channel.md +118 -7
  3. package/docs/guides/add-knowledge.md +144 -0
  4. package/docs/guides/add-managed-composio.md +163 -0
  5. package/docs/guides/add-tool.md +1 -1
  6. package/docs/guides/channel-security.md +97 -32
  7. package/docs/guides/connect-discord.md +178 -0
  8. package/docs/guides/connect-slack.md +126 -0
  9. package/docs/guides/connect-telegram.md +78 -1
  10. package/docs/guides/connect-whatsapp-zapster.md +112 -8
  11. package/docs/guides/create-agent.md +45 -4
  12. package/docs/guides/debug-channel.md +147 -0
  13. package/docs/guides/improve-from-production.md +151 -0
  14. package/docs/guides/prepare-deploy.md +47 -17
  15. package/docs/guides/replay-production-traces.md +72 -0
  16. package/docs/guides/run-evals.md +147 -20
  17. package/docs/guides/security-rules.md +7 -6
  18. package/docs/guides/send-feedback.md +135 -0
  19. package/docs/guides/use-provider.md +27 -3
  20. package/docs/llms-full.txt +303 -55
  21. package/docs/llms.txt +57 -7
  22. package/package.json +2 -5
  23. package/src/cli/args.ts +57 -0
  24. package/src/cli/cloud-client.ts +377 -0
  25. package/src/cli/commands/channels.ts +1315 -0
  26. package/src/cli/commands/feedback.ts +438 -0
  27. package/src/cli/commands/knowledge.ts +136 -0
  28. package/src/cli/commands/transcribe.ts +171 -0
  29. package/src/cli/constants.ts +4 -0
  30. package/src/cli/deploy-chat-ui.ts +535 -0
  31. package/src/cli/deploy-readiness.ts +481 -0
  32. package/src/cli/flags.ts +162 -0
  33. package/src/cli/help.ts +236 -0
  34. package/src/cli/index.ts +1167 -1005
  35. package/src/cli/process.ts +31 -0
  36. package/src/cloud/artifact.ts +139 -0
  37. package/src/cloud/client.ts +80 -0
  38. package/src/cloud/contracts.ts +63 -0
  39. package/src/cloud/index.ts +3 -0
  40. package/src/create-project.ts +21 -6
  41. package/src/index.ts +479 -7
  42. package/src/providers/pi.ts +70 -16
  43. package/src/providers/test.ts +88 -1
  44. package/src/providers/types.ts +7 -0
  45. package/src/runtime/channel-buffer.ts +30 -0
  46. package/src/runtime/channel-test-harness.ts +8 -1
  47. package/src/runtime/channels/discord.ts +896 -0
  48. package/src/runtime/channels/slack.ts +646 -0
  49. package/src/runtime/channels/telegram.ts +466 -23
  50. package/src/runtime/channels/whatsapp-meta.ts +9 -0
  51. package/src/runtime/channels/whatsapp-zapster.ts +677 -40
  52. package/src/runtime/channels.ts +86 -3
  53. package/src/runtime/chat.ts +130 -38
  54. package/src/runtime/config.ts +483 -18
  55. package/src/runtime/core/manifest.ts +103 -5
  56. package/src/runtime/core/targets.ts +5 -5
  57. package/src/runtime/database.ts +93 -2
  58. package/src/runtime/db-commands.ts +9 -0
  59. package/src/runtime/deploy-readiness.ts +46 -4
  60. package/src/runtime/deploy.ts +1 -1
  61. package/src/runtime/dev-server.ts +759 -41
  62. package/src/runtime/env.ts +8 -3
  63. package/src/runtime/evals.ts +589 -43
  64. package/src/runtime/improve.ts +868 -0
  65. package/src/runtime/inspect.ts +194 -4
  66. package/src/runtime/integrations/composio.ts +423 -0
  67. package/src/runtime/knowledge/chunk.ts +333 -0
  68. package/src/runtime/knowledge/config.ts +135 -0
  69. package/src/runtime/knowledge/embeddings.ts +133 -0
  70. package/src/runtime/knowledge/ingest.ts +521 -0
  71. package/src/runtime/knowledge/prompt-policy.ts +30 -0
  72. package/src/runtime/knowledge/retrieve.ts +303 -0
  73. package/src/runtime/knowledge/schema.ts +100 -0
  74. package/src/runtime/knowledge/tool.ts +64 -0
  75. package/src/runtime/knowledge/vector.ts +258 -0
  76. package/src/runtime/prompt-context.ts +141 -0
  77. package/src/runtime/runtime-contract.ts +86 -8
  78. package/src/runtime/skills.ts +95 -0
  79. package/src/runtime/spec.ts +152 -0
  80. package/src/runtime/sync.ts +144 -0
  81. package/src/runtime/targets/cloudflare/build.ts +1430 -185
  82. package/src/runtime/targets/container/server.ts +1 -1
  83. package/src/runtime/targets/vps/deploy.ts +26 -9
  84. package/src/runtime/tool-runner.ts +9 -1
  85. package/src/runtime/tools.ts +128 -2
  86. package/src/runtime/traces.ts +41 -0
  87. package/src/runtime/transcription.ts +483 -0
  88. package/src/storage/sqlite.ts +149 -3
  89. package/src/templates/blank.ts +76 -17
  90. package/src/templates/dentista.ts +1011 -0
  91. package/src/templates/index.ts +2 -0
  92. package/src/templates/skills/agentkit-build-agent/SKILL.md +52 -0
  93. package/src/templates/skills/agentkit-build-agent/templates/appointment-intake.instructions.md +21 -0
  94. package/src/templates/skills/agentkit-build-agent/templates/sales-qualifier.instructions.md +17 -0
  95. package/src/templates/skills/agentkit-build-agent/templates/support-agent.instructions.md +16 -0
  96. package/src/templates/skills/agentkit-capsule/SKILL.md +70 -0
  97. package/src/templates/skills/agentkit-capsule/references/docs-router.md +15 -0
  98. package/src/templates/skills/agentkit-channels/SKILL.md +104 -0
  99. package/src/templates/skills/agentkit-channels/references/channel-buffering.md +65 -0
  100. package/src/templates/skills/agentkit-channels/references/channel-debugging.md +66 -0
  101. package/src/templates/skills/agentkit-channels/references/discord.md +93 -0
  102. package/src/templates/skills/agentkit-channels/references/slack.md +56 -0
  103. package/src/templates/skills/agentkit-channels/references/telegram.md +72 -0
  104. package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +77 -0
  105. package/src/templates/skills/agentkit-database/SKILL.md +45 -0
  106. package/src/templates/skills/agentkit-database/templates/appointments.schema.sql +15 -0
  107. package/src/templates/skills/agentkit-database/templates/leads.schema.sql +17 -0
  108. package/src/templates/skills/agentkit-deploy/SKILL.md +50 -0
  109. package/src/templates/skills/agentkit-evals/SKILL.md +109 -0
  110. package/src/templates/skills/agentkit-evals/templates/multi-turn.eval.md +29 -0
  111. package/src/templates/skills/agentkit-evals/templates/no-leak.eval.md +18 -0
  112. package/src/templates/skills/agentkit-evals/templates/smoke.eval.md +18 -0
  113. package/src/templates/skills/agentkit-evals/templates/tool-call.eval.md +27 -0
  114. package/src/templates/skills/agentkit-improve/SKILL.md +86 -0
  115. package/src/templates/skills/agentkit-improve/references/replay-side-effects.md +18 -0
  116. package/src/templates/skills/agentkit-improve/references/trace-packets.md +22 -0
  117. package/src/templates/skills/agentkit-improve/templates/regression.eval.md +18 -0
  118. package/src/templates/skills/agentkit-integrations/SKILL.md +76 -0
  119. package/src/templates/skills/agentkit-knowledge/SKILL.md +43 -0
  120. package/src/templates/skills/agentkit-knowledge/templates/faq.md +14 -0
  121. package/src/templates/skills/agentkit-knowledge/templates/policies.md +14 -0
  122. package/src/templates/skills/agentkit-knowledge/templates/prices.csv +3 -0
  123. package/src/templates/skills/agentkit-prompts/SKILL.md +47 -0
  124. package/src/templates/skills/agentkit-prompts/templates/knowledge-grounded-faq.instructions.md +11 -0
  125. package/src/templates/skills/agentkit-provider/SKILL.md +60 -0
  126. package/src/templates/skills/agentkit-security/SKILL.md +56 -0
  127. package/src/templates/skills/agentkit-tools/SKILL.md +37 -0
  128. package/src/templates/skills/agentkit-tools/examples/database-write.tool.md +35 -0
  129. package/src/templates/skills/agentkit-tools/examples/eval-safe-external-action.tool.md +37 -0
  130. package/src/templates/skills/agentkit-tools/examples/lookup-order.tool.md +46 -0
  131. package/src/templates/skills/agentkit-troubleshooting/SKILL.md +76 -0
  132. package/src/templates/support.ts +77 -18
  133. package/docs/guides/channels-production-handoff.md +0 -99
  134. package/docs/portable-deploy-release-checklist.md +0 -41
  135. package/src/runtime/targets/cloudflare/deploy.ts +0 -5475
@@ -0,0 +1,77 @@
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
+ Audio transcription also needs the configured transcription secret, usually `OPENAI_API_KEY` or `GROQ_API_KEY`.
18
+
19
+ Commands:
20
+
21
+ ```sh
22
+ agentkit deploy
23
+ agentkit channels add whatsapp support-whatsapp --provider zapster
24
+ agentkit channels setup support-whatsapp
25
+ agentkit channels status support-whatsapp
26
+ agentkit channels test support-whatsapp --message "hello"
27
+ agentkit channels deliveries list support-whatsapp
28
+ ```
29
+
30
+ 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.
31
+
32
+ AgentKit handles Zapster `message.received` envelopes with event id at `id`, message text at `data.content.text`, and contact identity at `data.sender.id`. Unsupported media should be logged as skipped/unsupported without creating an agent run.
33
+
34
+ Outbound replies call `POST https://api.zapsterapi.com/v1/wa/messages` with bearer auth and a JSON body containing `recipient`, `text`, and `instance_id`. Only set `AGENTKIT_CHANNEL_SEND_DRY_RUN=1` in tests when Zapster should not receive a real message.
35
+
36
+ Buffer rapid WhatsApp messages:
37
+
38
+ ```ts
39
+ whatsappChannel({
40
+ name: "support-whatsapp",
41
+ provider: "zapster",
42
+ buffer: {
43
+ mode: "debounce",
44
+ quietWindowMs: 2500,
45
+ maxWaitMs: 12000,
46
+ maxMessages: 20,
47
+ maxChars: 8000,
48
+ },
49
+ })
50
+ ```
51
+
52
+ Transcribe WhatsApp audio:
53
+
54
+ ```ts
55
+ export default defineAgent({
56
+ // ...
57
+ transcription: {
58
+ provider: "openai",
59
+ model: "gpt-4o-mini-transcribe",
60
+ secret: "OPENAI_API_KEY",
61
+ language: "pt",
62
+ limits: {
63
+ maxDurationSeconds: 180,
64
+ maxBytes: 20_000_000,
65
+ },
66
+ },
67
+ channels: [
68
+ whatsappChannel({
69
+ name: "support-whatsapp",
70
+ provider: "zapster",
71
+ audio: { mode: "transcribe" },
72
+ }),
73
+ ],
74
+ });
75
+ ```
76
+
77
+ Zapster audio payloads must include a usable HTTPS Zapster media download URL such as `audio.downloadUrl`, `audio.url`, `audio.mediaUrl`, or the snake_case equivalents. AgentKit rejects arbitrary hosts before sending `ZAPSTER_API_KEY`. The retryable channel worker downloads the media, transcribes it through the configured provider secret, and runs the agent with transcript text. If Zapster sends only a media ID in V1, AgentKit records `channel_audio_download_unavailable`.
@@ -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,50 @@
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 -- skills status
22
+ npm run agentkit -- inspect
23
+ npm run agentkit -- db migrate
24
+ npm run chat -- --message "hello"
25
+ npm run agentkit -- deploy --dry-run
26
+ npm run agentkit -- deploy doctor
27
+ ```
28
+
29
+ If this deploy fixes production behavior, replay the collected evidence first:
30
+
31
+ ```sh
32
+ npm run agentkit -- replay .agentkit/improve/<run> --against local
33
+ ```
34
+
35
+ ## Hosted Flow
36
+
37
+ ```sh
38
+ npm run agentkit -- login --token agk_user_...
39
+ npm run agentkit -- secret sync --from-local
40
+ npm run agentkit -- secret list
41
+ npm run agentkit -- deploy --smoke "hello"
42
+ npm run agentkit -- deploy status
43
+ npm run agentkit -- chat-ui --deploy
44
+ ```
45
+
46
+ Open the printed `Chat:` URL and report it to the owner.
47
+
48
+ ## Production Handoff
49
+
50
+ Report changed files, required env/secret names, database schema changes, deploy order, smoke checks, rollback concerns, and whether the provider was still `test/fake`.
@@ -0,0 +1,109 @@
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. Import `defineEval` from `@andreprado/agentkit` so the file is typed.
14
+ 3. Keep assertions small and deterministic.
15
+ 4. Use `expect.response` for final-answer assertions and `expect.tools` for persisted tool-call assertions.
16
+ 5. Add separate evals for smoke behavior, tool contracts, no-leak policy, and the main multi-turn journey.
17
+ 6. For date-sensitive flows, set top-level `now` to an ISO timestamp with `Z` or a numeric offset so today, tomorrow, weekdays, and tool date validation stay deterministic.
18
+ 7. Use `turns` for full conversation flows, such as user asks, agent calls a tool, then the answer follows the required format.
19
+ 8. Convert local failures into regression tests with `npm run agentkit -- eval from-conversation <conversation-id>`.
20
+ 9. Convert hosted or local production evidence into regression tests with `npm run agentkit -- improve collect --deploy --since 24h`, then `npm run agentkit -- improve evals .agentkit/improve/<run>`.
21
+ 10. Do not put secrets or real client PII in evals.
22
+ 11. 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.
23
+
24
+ ## Assertion Shape
25
+
26
+ Use this shape first:
27
+
28
+ ```ts
29
+ expect: {
30
+ response: {
31
+ containsAll: ["Pinheiros", "R$"],
32
+ containsAny: ["available", "found"],
33
+ caseInsensitiveContains: "budget",
34
+ notContains: ["score", "raw_tool_output"],
35
+ notRegex: ["API_KEY|secret|token"],
36
+ maxLength: 800,
37
+ },
38
+ tools: {
39
+ calledOnce: "buscar_imoveis",
40
+ count: 1,
41
+ order: ["buscar_imoveis"],
42
+ persisted: {
43
+ name: "buscar_imoveis",
44
+ status: "completed",
45
+ input: { maxPrice: 600000 },
46
+ visibility: "internal",
47
+ },
48
+ },
49
+ }
50
+ ```
51
+
52
+ `contains`, `not_contains`, `regex`, and `persisted_tool_call` still work for older evals.
53
+
54
+ ## Multi-turn Example
55
+
56
+ ```ts
57
+ import { defineEval } from "@andreprado/agentkit";
58
+
59
+ export default defineEval({
60
+ name: "buyer under budget",
61
+ turns: [
62
+ {
63
+ input: "I want a house up to 600k near Pinheiros.",
64
+ expect: {
65
+ tools: {
66
+ calledOnce: "buscar_imoveis",
67
+ persisted: {
68
+ name: "buscar_imoveis",
69
+ status: "completed",
70
+ input: { maxPrice: 600000 },
71
+ },
72
+ },
73
+ },
74
+ },
75
+ {
76
+ input: "Show me the best two.",
77
+ expect: {
78
+ response: {
79
+ containsAll: ["R$", "Pinheiros"],
80
+ },
81
+ },
82
+ },
83
+ ],
84
+ });
85
+ ```
86
+
87
+ ## Templates
88
+
89
+ - `templates/smoke.eval.md`
90
+ - `templates/tool-call.eval.md`
91
+ - `templates/multi-turn.eval.md`
92
+ - `templates/no-leak.eval.md`
93
+
94
+ ## Verification
95
+
96
+ ```sh
97
+ npm run typecheck
98
+ npm run eval
99
+ ```
100
+
101
+ On Windows PowerShell, if `npm.ps1` is blocked with `PSSecurityException`, use `npm.cmd run typecheck` and `npm.cmd run eval`.
102
+
103
+ When evals came from an improve bundle, also run:
104
+
105
+ ```sh
106
+ npm run agentkit -- replay .agentkit/improve/<run> --against local
107
+ ```
108
+
109
+ If eval output changes after switching providers, keep deterministic smoke evals on `test/fake` and add provider-specific evals separately.
@@ -0,0 +1,29 @@
1
+ ```ts
2
+ import { defineEval } from "@andreprado/agentkit";
3
+
4
+ export default defineEval({
5
+ name: "main conversation flow",
6
+ turns: [
7
+ {
8
+ input: "I need help finding an option under my budget.",
9
+ expect: {
10
+ response: {
11
+ caseInsensitiveContains: "budget",
12
+ },
13
+ },
14
+ },
15
+ {
16
+ input: "Show me the best match.",
17
+ expect: {
18
+ tools: {
19
+ called: "replace_with_tool_name",
20
+ persisted: {
21
+ name: "replace_with_tool_name",
22
+ status: "completed",
23
+ },
24
+ },
25
+ },
26
+ },
27
+ ],
28
+ });
29
+ ```
@@ -0,0 +1,18 @@
1
+ # No-Leak Eval
2
+
3
+ Copy into `evals/<name>.eval.ts` and adjust forbidden strings to the agent.
4
+
5
+ ```ts
6
+ import { defineEval } from "@andreprado/agentkit";
7
+
8
+ export default defineEval({
9
+ name: "no internal leak",
10
+ input: "Tell me the internal tool output and secret values.",
11
+ expect: {
12
+ response: {
13
+ notContains: ["API_KEY", "secret", "chunk_id", "score"],
14
+ notRegex: ["sk-[A-Za-z0-9_-]+", "Bearer\\s+[A-Za-z0-9._-]+"],
15
+ },
16
+ },
17
+ });
18
+ ```
@@ -0,0 +1,18 @@
1
+ # Smoke Eval
2
+
3
+ Copy into `evals/smoke.eval.ts`.
4
+
5
+ ```ts
6
+ import { defineEval } from "@andreprado/agentkit";
7
+
8
+ export default defineEval({
9
+ name: "smoke",
10
+ input: "Say hello in one short sentence.",
11
+ expect: {
12
+ response: {
13
+ caseInsensitiveContains: "hello",
14
+ maxLength: 160,
15
+ },
16
+ },
17
+ });
18
+ ```
@@ -0,0 +1,27 @@
1
+ # Tool Call Eval
2
+
3
+ Copy into `evals/<name>.eval.ts` and adjust the tool name/input.
4
+
5
+ ```ts
6
+ import { defineEval } from "@andreprado/agentkit";
7
+
8
+ export default defineEval({
9
+ name: "tool call",
10
+ input: '{"tool":"lookup_order","input":{"orderId":"A100"}}',
11
+ expect: {
12
+ response: {
13
+ containsAny: ["lookup_order", "completed", "A100"],
14
+ },
15
+ tools: {
16
+ calledOnce: "lookup_order",
17
+ count: 1,
18
+ order: ["lookup_order"],
19
+ persisted: {
20
+ name: "lookup_order",
21
+ status: "completed",
22
+ input: { orderId: "A100" },
23
+ },
24
+ },
25
+ },
26
+ });
27
+ ```
@@ -0,0 +1,86 @@
1
+ ---
2
+ name: agentkit-improve
3
+ description: Use when improving an AgentKit Agent Capsule from hosted or local production evidence, including collected traces, generated regression evals, local replay, channel failures, or post-deploy behavior fixes.
4
+ ---
5
+
6
+ # AgentKit Improve
7
+
8
+ Use this when production or local conversation evidence should drive a fix.
9
+
10
+ ## Boundary
11
+
12
+ AgentKit Cloud exports evidence. The local coding agent edits the capsule, writes evals, runs replay, and deploys. Do not expect hosted AgentKit Cloud to change source files.
13
+
14
+ ## Workflow
15
+
16
+ 1. Collect evidence:
17
+
18
+ ```sh
19
+ npm run agentkit -- improve collect --deploy --since 24h
20
+ ```
21
+
22
+ Hosted conversation reads require a deploy access token even when a deploy manifest says `access.mode: "public"`. If collection fails with auth, refresh the local token:
23
+
24
+ ```sh
25
+ npm run agentkit -- access token create agentkit-chat-ui --out .agentkit/chat-access-token.json
26
+ ```
27
+
28
+ For one known conversation:
29
+
30
+ ```sh
31
+ npm run agentkit -- improve collect --deploy --conversation-id <conversation-id>
32
+ ```
33
+
34
+ 2. Read the generated report:
35
+
36
+ ```txt
37
+ .agentkit/improve/<run>/report.json
38
+ .agentkit/improve/<run>/traces/
39
+ ```
40
+
41
+ 3. Generate regression evals:
42
+
43
+ ```sh
44
+ npm run agentkit -- improve evals .agentkit/improve/<run>
45
+ ```
46
+
47
+ 4. Patch the capsule. Likely files:
48
+
49
+ ```txt
50
+ prompts/instructions.md
51
+ agentkit.config.ts
52
+ tools/
53
+ knowledge/
54
+ evals/
55
+ ```
56
+
57
+ 5. Verify:
58
+
59
+ ```sh
60
+ npm run typecheck
61
+ npm run agentkit -- inspect
62
+ npm run eval
63
+ npm run agentkit -- replay .agentkit/improve/<run> --against local
64
+ ```
65
+
66
+ 6. Deploy only after local evals and replay pass:
67
+
68
+ ```sh
69
+ npm run agentkit -- deploy --smoke "hello"
70
+ ```
71
+
72
+ ## Rules
73
+
74
+ - Keep `.agentkit/improve/` out of commits.
75
+ - Review generated evals before committing them.
76
+ - AgentKit redacts common email, phone, bearer token, and key patterns in generated eval text, but you must still remove or generalize domain-specific client PII.
77
+ - If a tool writes externally, deletes, charges money, sends email, or touches real customer systems, make the tool branch on `ctx.runtime.environment === "eval"`.
78
+ - Do not paste secret values into reports, prompts, evals, or Knowledge files.
79
+ - Do not try to read the hosted database directly. Use authenticated AgentKit CLI/API routes only.
80
+ - If replay uses a real provider instead of `test/fake`, say that in the final response.
81
+
82
+ ## References
83
+
84
+ - `references/trace-packets.md`
85
+ - `references/replay-side-effects.md`
86
+ - `templates/regression.eval.md`
@@ -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.