@andreprado/agentkit 0.1.0-alpha.4 → 0.1.0-alpha.6

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 (80) hide show
  1. package/README.md +5 -0
  2. package/docs/guides/add-channel.md +25 -0
  3. package/docs/guides/add-knowledge.md +134 -0
  4. package/docs/guides/agentkit-skills-architecture.md +471 -0
  5. package/docs/guides/channels-production-handoff.md +2 -0
  6. package/docs/guides/connect-telegram.md +15 -0
  7. package/docs/guides/connect-whatsapp-zapster.md +16 -0
  8. package/docs/guides/create-agent.md +1 -1
  9. package/docs/llms-full.txt +90 -1
  10. package/docs/llms.txt +9 -2
  11. package/package.json +2 -1
  12. package/src/cli/args.ts +36 -0
  13. package/src/cli/cloud-client.ts +257 -0
  14. package/src/cli/commands/channels.ts +459 -0
  15. package/src/cli/commands/knowledge.ts +136 -0
  16. package/src/cli/constants.ts +4 -0
  17. package/src/cli/deploy-chat-ui.ts +385 -0
  18. package/src/cli/deploy-readiness.ts +348 -0
  19. package/src/cli/flags.ts +162 -0
  20. package/src/cli/help.ts +166 -0
  21. package/src/cli/index.ts +219 -1912
  22. package/src/cli/process.ts +31 -0
  23. package/src/cloud/artifact.ts +92 -1
  24. package/src/cloud/contracts.ts +16 -0
  25. package/src/create-project.ts +38 -6
  26. package/src/index.ts +98 -0
  27. package/src/runtime/channel-buffer.ts +30 -0
  28. package/src/runtime/channels.ts +1 -0
  29. package/src/runtime/chat.ts +21 -2
  30. package/src/runtime/config.ts +167 -0
  31. package/src/runtime/core/manifest.ts +37 -0
  32. package/src/runtime/deploy-readiness.ts +12 -0
  33. package/src/runtime/dev-server.ts +159 -10
  34. package/src/runtime/inspect.ts +34 -0
  35. package/src/runtime/knowledge/chunk.ts +333 -0
  36. package/src/runtime/knowledge/config.ts +135 -0
  37. package/src/runtime/knowledge/embeddings.ts +133 -0
  38. package/src/runtime/knowledge/ingest.ts +521 -0
  39. package/src/runtime/knowledge/prompt-policy.ts +30 -0
  40. package/src/runtime/knowledge/retrieve.ts +283 -0
  41. package/src/runtime/knowledge/schema.ts +56 -0
  42. package/src/runtime/knowledge/tool.ts +64 -0
  43. package/src/runtime/knowledge/vector.ts +258 -0
  44. package/src/runtime/targets/cloudflare/build.ts +469 -4
  45. package/src/storage/sqlite.ts +5 -0
  46. package/src/templates/blank.ts +8 -4
  47. package/src/templates/dentista.ts +3 -1
  48. package/src/templates/skills/agentkit-build-agent/SKILL.md +49 -0
  49. package/src/templates/skills/agentkit-build-agent/templates/appointment-intake.instructions.md +20 -0
  50. package/src/templates/skills/agentkit-build-agent/templates/sales-qualifier.instructions.md +17 -0
  51. package/src/templates/skills/agentkit-build-agent/templates/support-agent.instructions.md +16 -0
  52. package/src/templates/skills/agentkit-capsule/SKILL.md +62 -0
  53. package/src/templates/skills/agentkit-capsule/references/docs-router.md +15 -0
  54. package/src/templates/skills/agentkit-channels/SKILL.md +62 -0
  55. package/src/templates/skills/agentkit-channels/references/channel-buffering.md +58 -0
  56. package/src/templates/skills/agentkit-channels/references/channel-debugging.md +37 -0
  57. package/src/templates/skills/agentkit-channels/references/telegram.md +37 -0
  58. package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +37 -0
  59. package/src/templates/skills/agentkit-database/SKILL.md +42 -0
  60. package/src/templates/skills/agentkit-database/templates/appointments.schema.sql +15 -0
  61. package/src/templates/skills/agentkit-database/templates/leads.schema.sql +17 -0
  62. package/src/templates/skills/agentkit-deploy/SKILL.md +44 -0
  63. package/src/templates/skills/agentkit-evals/SKILL.md +31 -0
  64. package/src/templates/skills/agentkit-evals/templates/no-leak.eval.md +14 -0
  65. package/src/templates/skills/agentkit-evals/templates/smoke.eval.md +14 -0
  66. package/src/templates/skills/agentkit-evals/templates/tool-call.eval.md +18 -0
  67. package/src/templates/skills/agentkit-knowledge/SKILL.md +40 -0
  68. package/src/templates/skills/agentkit-knowledge/templates/faq.md +14 -0
  69. package/src/templates/skills/agentkit-knowledge/templates/policies.md +14 -0
  70. package/src/templates/skills/agentkit-knowledge/templates/prices.csv +3 -0
  71. package/src/templates/skills/agentkit-prompts/SKILL.md +45 -0
  72. package/src/templates/skills/agentkit-prompts/templates/knowledge-grounded-faq.instructions.md +11 -0
  73. package/src/templates/skills/agentkit-provider/SKILL.md +57 -0
  74. package/src/templates/skills/agentkit-security/SKILL.md +55 -0
  75. package/src/templates/skills/agentkit-tools/SKILL.md +36 -0
  76. package/src/templates/skills/agentkit-tools/examples/database-write.tool.md +35 -0
  77. package/src/templates/skills/agentkit-tools/examples/eval-safe-external-action.tool.md +37 -0
  78. package/src/templates/skills/agentkit-tools/examples/lookup-order.tool.md +46 -0
  79. package/src/templates/skills/agentkit-troubleshooting/SKILL.md +52 -0
  80. package/src/templates/support.ts +8 -4
@@ -0,0 +1,45 @@
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
+ - what the agent must not claim;
20
+ - escalation and safety boundaries;
21
+ - response style.
22
+
23
+ Keep operational secrets, provider details, and implementation notes out of prompts.
24
+
25
+ ## Tool And Knowledge Policy
26
+
27
+ - Use tools for actions, live data, authorization-sensitive records, payments, orders, booking, and writes.
28
+ - Use Knowledge for committed reference facts such as FAQs, prices, services, policies, procedures, and CSV tables.
29
+ - Do not expose raw tool output, retrieval JSON, chunk IDs, scores, secrets, logs, or internal labels.
30
+
31
+ ## Templates
32
+
33
+ - `templates/knowledge-grounded-faq.instructions.md`
34
+ - `../agentkit-build-agent/templates/support-agent.instructions.md`
35
+ - `../agentkit-build-agent/templates/appointment-intake.instructions.md`
36
+
37
+ ## Verification
38
+
39
+ ```sh
40
+ npm run chat -- --message "hello"
41
+ npm run eval
42
+ ```
43
+
44
+ If the provider is still `test/fake`, say prompt behavior was not tested with a real model.
45
+
@@ -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,57 @@
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
+ ## Verification
46
+
47
+ ```sh
48
+ npm run typecheck
49
+ npm run agentkit -- inspect
50
+ npm run chat -- --message "hello"
51
+ npm run dev
52
+ ```
53
+
54
+ Open the printed `Chat:` URL and report it to the owner.
55
+
56
+ Do not import provider SDKs in the capsule. AgentKit resolves providers internally through Pi-backed adapters.
57
+
@@ -0,0 +1,55 @@
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
+ - Treat public deploy URLs as transport, not access control.
44
+
45
+ ## Checks
46
+
47
+ ```sh
48
+ git status --short
49
+ npm run agentkit -- env list
50
+ npm run agentkit -- inspect
51
+ git diff --check
52
+ ```
53
+
54
+ Expected: secret names may appear, secret values do not.
55
+
@@ -0,0 +1,36 @@
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. Add eval guards for destructive or external side effects.
18
+
19
+ ## Examples
20
+
21
+ - `examples/lookup-order.tool.md`: simple lookup
22
+ - `examples/database-write.tool.md`: write through `ctx.db`
23
+ - `examples/eval-safe-external-action.tool.md`: safe eval branch for external side effects
24
+
25
+ Use `skills/agentkit-database/SKILL.md` for database-backed tools.
26
+ Use `skills/agentkit-security/SKILL.md` before adding external APIs or secrets.
27
+
28
+ ## Verification
29
+
30
+ ```sh
31
+ npm run typecheck
32
+ npm run agentkit -- tool <tool_name> --input '<json>'
33
+ npm run agentkit -- inspect
34
+ ```
35
+
36
+ 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,52 @@
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
+
17
+ ## First Commands
18
+
19
+ ```sh
20
+ npm run agentkit -- inspect
21
+ npm run typecheck
22
+ npm run agentkit -- env list
23
+ git status --short
24
+ ```
25
+
26
+ For chat issues:
27
+
28
+ ```sh
29
+ npm run chat -- --message "hello"
30
+ ```
31
+
32
+ For tool issues:
33
+
34
+ ```sh
35
+ npm run agentkit -- tool <tool_name> --input '<json>'
36
+ ```
37
+
38
+ For deploy issues:
39
+
40
+ ```sh
41
+ npm run agentkit -- deploy doctor
42
+ ```
43
+
44
+ ## Common Causes
45
+
46
+ - missing dependencies: run `npm install`;
47
+ - missing provider key: set ignored `.env` and confirm with `inspect`;
48
+ - provider not chosen: stay on `test/fake` or ask the owner;
49
+ - schema missing: run `db migrate` and check `schema.sql`;
50
+ - tool validation failed: check `inputSchema` and `outputSchema`;
51
+ - channel secret missing: set hosted managed secret, not source files.
52
+
@@ -190,7 +190,7 @@ When the owner opens this folder in Codex, Claude Code, or another coding agent
190
190
 
191
191
  Start building immediately:
192
192
 
193
- - Read \`AGENTKIT.md\` and the full docs path from \`npm run agentkit -- docs full\`.
193
+ - Start with \`skills/agentkit-capsule/SKILL.md\`, then use \`npm run agentkit -- docs llms\` as the docs router.
194
194
  - Infer the first useful version from the owner's request.
195
195
  - Edit \`prompts/instructions.md\` for support behavior.
196
196
  - Edit \`agentkit.config.ts\` for provider, tools, secrets, access, and storage.
@@ -209,7 +209,8 @@ Start building immediately:
209
209
  - \`npm run agentkit -- inspect\`: print machine-readable capsule state.
210
210
  - \`printf %s "$VALUE" | npm run agentkit -- env set <NAME> --stdin\`: write a local secret value to ignored \`.env\` without putting it in shell history.
211
211
  - \`npm run agentkit -- env list\`: list local secret names without printing values.
212
- - \`npm run agentkit -- docs full\`: print the full AgentKit contract path.
212
+ - \`npm run agentkit -- docs llms\`: print the lightweight AgentKit docs router.
213
+ - \`npm run agentkit -- docs full\`: print the full AgentKit contract path only when a skill asks for it.
213
214
 
214
215
  ## Testing With A UI
215
216
 
@@ -313,12 +314,14 @@ If you add a tool, also run a fake-provider tool smoke test:
313
314
  npm run agentkit -- tool tool_name --input '{}'
314
315
  \`\`\`
315
316
 
316
- For the full framework contract, read the path printed by:
317
+ For the lightweight docs router, read the path printed by:
317
318
 
318
319
  \`\`\`sh
319
- npm run agentkit -- docs full
320
+ npm run agentkit -- docs llms
320
321
  \`\`\`
321
322
 
323
+ Read the full framework contract with \`npm run agentkit -- docs full\` only when a skill asks for it.
324
+
322
325
  ## Database Tools
323
326
 
324
327
  Tools that need agent-owned tables should use canonical \`ctx.db\` from the tool context. \`ctx.database\` and \`ctx.storage.sql\` are aliases. Do not import local database drivers or Node-only APIs in a tool.
@@ -360,6 +363,7 @@ Use AgentKit conventions when editing this support capsule.
360
363
  - Ask the owner which real provider to use before switching from \`test/fake\`; do not choose OpenRouter, OpenAI, or Anthropic automatically.
361
364
  - Keep required local secret names in \`.env.schema\` and values in ignored \`.env\`. AgentKit local commands load \`.env\` directly.
362
365
  - Treat the owner's natural-language request as the brief and start implementing inside this capsule.
366
+ - Start with \`skills/agentkit-capsule/SKILL.md\` when the task is not obvious.
363
367
  `,
364
368
  },
365
369
  {