@andreprado/agentkit 0.1.0-alpha.2 → 0.1.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -6
- package/docs/guides/add-channel.md +118 -7
- package/docs/guides/add-knowledge.md +144 -0
- package/docs/guides/add-managed-composio.md +163 -0
- package/docs/guides/add-tool.md +1 -1
- package/docs/guides/channel-security.md +97 -32
- package/docs/guides/connect-discord.md +178 -0
- package/docs/guides/connect-slack.md +126 -0
- package/docs/guides/connect-telegram.md +78 -1
- package/docs/guides/connect-whatsapp-zapster.md +112 -8
- package/docs/guides/create-agent.md +45 -4
- package/docs/guides/debug-channel.md +147 -0
- package/docs/guides/improve-from-production.md +151 -0
- package/docs/guides/prepare-deploy.md +47 -17
- package/docs/guides/replay-production-traces.md +72 -0
- package/docs/guides/run-evals.md +147 -20
- package/docs/guides/security-rules.md +7 -6
- package/docs/guides/send-feedback.md +135 -0
- package/docs/guides/use-provider.md +27 -3
- package/docs/llms-full.txt +303 -55
- package/docs/llms.txt +57 -7
- package/package.json +2 -5
- package/src/cli/args.ts +57 -0
- package/src/cli/cloud-client.ts +377 -0
- package/src/cli/commands/channels.ts +1315 -0
- package/src/cli/commands/feedback.ts +438 -0
- package/src/cli/commands/knowledge.ts +136 -0
- package/src/cli/commands/transcribe.ts +171 -0
- package/src/cli/constants.ts +4 -0
- package/src/cli/deploy-chat-ui.ts +535 -0
- package/src/cli/deploy-readiness.ts +481 -0
- package/src/cli/flags.ts +162 -0
- package/src/cli/help.ts +236 -0
- package/src/cli/index.ts +1167 -1005
- package/src/cli/process.ts +31 -0
- package/src/cloud/artifact.ts +139 -0
- package/src/cloud/client.ts +80 -0
- package/src/cloud/contracts.ts +63 -0
- package/src/cloud/index.ts +3 -0
- package/src/create-project.ts +21 -6
- package/src/index.ts +479 -7
- package/src/providers/pi.ts +70 -16
- package/src/providers/test.ts +88 -1
- package/src/providers/types.ts +7 -0
- package/src/runtime/channel-buffer.ts +30 -0
- package/src/runtime/channel-test-harness.ts +8 -1
- package/src/runtime/channels/discord.ts +896 -0
- package/src/runtime/channels/slack.ts +646 -0
- package/src/runtime/channels/telegram.ts +466 -23
- package/src/runtime/channels/whatsapp-meta.ts +9 -0
- package/src/runtime/channels/whatsapp-zapster.ts +677 -40
- package/src/runtime/channels.ts +86 -3
- package/src/runtime/chat.ts +130 -38
- package/src/runtime/config.ts +483 -18
- package/src/runtime/core/manifest.ts +103 -5
- package/src/runtime/core/targets.ts +5 -5
- package/src/runtime/database.ts +93 -2
- package/src/runtime/db-commands.ts +9 -0
- package/src/runtime/deploy-readiness.ts +46 -4
- package/src/runtime/deploy.ts +1 -1
- package/src/runtime/dev-server.ts +759 -41
- package/src/runtime/env.ts +8 -3
- package/src/runtime/evals.ts +589 -43
- package/src/runtime/improve.ts +868 -0
- package/src/runtime/inspect.ts +194 -4
- package/src/runtime/integrations/composio.ts +423 -0
- package/src/runtime/knowledge/chunk.ts +333 -0
- package/src/runtime/knowledge/config.ts +135 -0
- package/src/runtime/knowledge/embeddings.ts +133 -0
- package/src/runtime/knowledge/ingest.ts +521 -0
- package/src/runtime/knowledge/prompt-policy.ts +30 -0
- package/src/runtime/knowledge/retrieve.ts +303 -0
- package/src/runtime/knowledge/schema.ts +100 -0
- package/src/runtime/knowledge/tool.ts +64 -0
- package/src/runtime/knowledge/vector.ts +258 -0
- package/src/runtime/prompt-context.ts +141 -0
- package/src/runtime/runtime-contract.ts +86 -8
- package/src/runtime/skills.ts +95 -0
- package/src/runtime/spec.ts +152 -0
- package/src/runtime/sync.ts +144 -0
- package/src/runtime/targets/cloudflare/build.ts +1430 -185
- package/src/runtime/targets/container/server.ts +1 -1
- package/src/runtime/targets/vps/deploy.ts +26 -9
- package/src/runtime/tool-runner.ts +9 -1
- package/src/runtime/tools.ts +128 -2
- package/src/runtime/traces.ts +41 -0
- package/src/runtime/transcription.ts +483 -0
- package/src/storage/sqlite.ts +149 -3
- package/src/templates/blank.ts +76 -17
- package/src/templates/dentista.ts +1011 -0
- package/src/templates/index.ts +2 -0
- package/src/templates/skills/agentkit-build-agent/SKILL.md +52 -0
- package/src/templates/skills/agentkit-build-agent/templates/appointment-intake.instructions.md +21 -0
- package/src/templates/skills/agentkit-build-agent/templates/sales-qualifier.instructions.md +17 -0
- package/src/templates/skills/agentkit-build-agent/templates/support-agent.instructions.md +16 -0
- package/src/templates/skills/agentkit-capsule/SKILL.md +70 -0
- package/src/templates/skills/agentkit-capsule/references/docs-router.md +15 -0
- package/src/templates/skills/agentkit-channels/SKILL.md +104 -0
- package/src/templates/skills/agentkit-channels/references/channel-buffering.md +65 -0
- package/src/templates/skills/agentkit-channels/references/channel-debugging.md +66 -0
- package/src/templates/skills/agentkit-channels/references/discord.md +93 -0
- package/src/templates/skills/agentkit-channels/references/slack.md +56 -0
- package/src/templates/skills/agentkit-channels/references/telegram.md +72 -0
- package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +77 -0
- package/src/templates/skills/agentkit-database/SKILL.md +45 -0
- package/src/templates/skills/agentkit-database/templates/appointments.schema.sql +15 -0
- package/src/templates/skills/agentkit-database/templates/leads.schema.sql +17 -0
- package/src/templates/skills/agentkit-deploy/SKILL.md +50 -0
- package/src/templates/skills/agentkit-evals/SKILL.md +109 -0
- package/src/templates/skills/agentkit-evals/templates/multi-turn.eval.md +29 -0
- package/src/templates/skills/agentkit-evals/templates/no-leak.eval.md +18 -0
- package/src/templates/skills/agentkit-evals/templates/smoke.eval.md +18 -0
- package/src/templates/skills/agentkit-evals/templates/tool-call.eval.md +27 -0
- package/src/templates/skills/agentkit-improve/SKILL.md +86 -0
- package/src/templates/skills/agentkit-improve/references/replay-side-effects.md +18 -0
- package/src/templates/skills/agentkit-improve/references/trace-packets.md +22 -0
- package/src/templates/skills/agentkit-improve/templates/regression.eval.md +18 -0
- package/src/templates/skills/agentkit-integrations/SKILL.md +76 -0
- package/src/templates/skills/agentkit-knowledge/SKILL.md +43 -0
- package/src/templates/skills/agentkit-knowledge/templates/faq.md +14 -0
- package/src/templates/skills/agentkit-knowledge/templates/policies.md +14 -0
- package/src/templates/skills/agentkit-knowledge/templates/prices.csv +3 -0
- package/src/templates/skills/agentkit-prompts/SKILL.md +47 -0
- package/src/templates/skills/agentkit-prompts/templates/knowledge-grounded-faq.instructions.md +11 -0
- package/src/templates/skills/agentkit-provider/SKILL.md +60 -0
- package/src/templates/skills/agentkit-security/SKILL.md +56 -0
- package/src/templates/skills/agentkit-tools/SKILL.md +37 -0
- package/src/templates/skills/agentkit-tools/examples/database-write.tool.md +35 -0
- package/src/templates/skills/agentkit-tools/examples/eval-safe-external-action.tool.md +37 -0
- package/src/templates/skills/agentkit-tools/examples/lookup-order.tool.md +46 -0
- package/src/templates/skills/agentkit-troubleshooting/SKILL.md +76 -0
- package/src/templates/support.ts +77 -18
- package/docs/guides/channels-production-handoff.md +0 -99
- package/docs/portable-deploy-release-checklist.md +0 -41
- package/src/runtime/targets/cloudflare/deploy.ts +0 -5475
|
@@ -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.
|
package/src/templates/support.ts
CHANGED
|
@@ -63,6 +63,7 @@ node_modules/
|
|
|
63
63
|
contents: `# Optional: add real provider keys after switching away from test/fake.
|
|
64
64
|
OPENAI_API_KEY=
|
|
65
65
|
ANTHROPIC_API_KEY=
|
|
66
|
+
OPENROUTER_API_KEY=
|
|
66
67
|
`,
|
|
67
68
|
},
|
|
68
69
|
{
|
|
@@ -110,7 +111,9 @@ export default defineAgent({
|
|
|
110
111
|
},
|
|
111
112
|
{
|
|
112
113
|
path: "tools/lookup-order.ts",
|
|
113
|
-
contents: `
|
|
114
|
+
contents: `import type { AgentTool } from "@andreprado/agentkit";
|
|
115
|
+
|
|
116
|
+
const orders: Record<string, { status: string; eta: string }> = {
|
|
114
117
|
A100: { status: "preparing", eta: "today" },
|
|
115
118
|
B200: { status: "shipped", eta: "tomorrow" },
|
|
116
119
|
};
|
|
@@ -156,7 +159,7 @@ export const lookupOrder = {
|
|
|
156
159
|
eta: order.eta,
|
|
157
160
|
};
|
|
158
161
|
},
|
|
159
|
-
};
|
|
162
|
+
} satisfies AgentTool;
|
|
160
163
|
`,
|
|
161
164
|
},
|
|
162
165
|
{
|
|
@@ -168,13 +171,18 @@ Help users with clear answers. When order status is needed, use the lookup_order
|
|
|
168
171
|
},
|
|
169
172
|
{
|
|
170
173
|
path: "evals/smoke.eval.ts",
|
|
171
|
-
contents: `
|
|
174
|
+
contents: `import { defineEval } from "@andreprado/agentkit";
|
|
175
|
+
|
|
176
|
+
export default defineEval({
|
|
172
177
|
name: "smoke",
|
|
173
178
|
input: "Say hello as a support agent.",
|
|
174
179
|
expect: {
|
|
175
|
-
|
|
180
|
+
response: {
|
|
181
|
+
caseInsensitiveContains: "hello",
|
|
182
|
+
maxLength: 200,
|
|
183
|
+
},
|
|
176
184
|
},
|
|
177
|
-
};
|
|
185
|
+
});
|
|
178
186
|
`,
|
|
179
187
|
},
|
|
180
188
|
{
|
|
@@ -189,33 +197,48 @@ When the owner opens this folder in Codex, Claude Code, or another coding agent
|
|
|
189
197
|
|
|
190
198
|
Start building immediately:
|
|
191
199
|
|
|
192
|
-
-
|
|
200
|
+
- Start with \`skills/agentkit-capsule/SKILL.md\`, then use \`npm run agentkit -- docs llms\` as the docs router.
|
|
201
|
+
- Create or update \`AGENT_SPEC.md\` from the owner's request with \`npm run agentkit -- spec init --brief "<owner request>"\`; the owner should not fill this file by hand before work starts.
|
|
193
202
|
- Infer the first useful version from the owner's request.
|
|
194
203
|
- Edit \`prompts/instructions.md\` for support behavior.
|
|
195
204
|
- Edit \`agentkit.config.ts\` for provider, tools, secrets, access, and storage.
|
|
196
205
|
- Add or replace TypeScript tools under \`tools/\` when the requested support agent needs actions or external data.
|
|
206
|
+
- Add \`sync.ts\`, \`seed.sql\`, and ordered \`migrations/*.sql\` when the support agent depends on external catalogs or production-shaped data changes.
|
|
207
|
+
- Do not wait for a wizard or recipe. AgentKit provides the scaffold and contract; you decide the implementation from the owner's brief.
|
|
197
208
|
- Ask follow-up questions only when missing information blocks a safe local implementation.
|
|
198
209
|
- State assumptions in the final response.
|
|
199
210
|
|
|
200
211
|
## Local Commands
|
|
201
212
|
|
|
202
|
-
- \`npm install\`:
|
|
213
|
+
- \`npm install\`: restore capsule dependencies if this capsule used \`--no-install\`, install failed, or \`node_modules\` was deleted.
|
|
203
214
|
- \`npm run chat -- --message "hello"\`: send one local chat message.
|
|
204
215
|
- \`npm run agentkit -- tool lookup_order --input '{"orderId":"A100"}'\`: test the example tool directly.
|
|
205
216
|
- \`npm run eval\`: run agent evals.
|
|
217
|
+
- \`npm run agentkit -- spec check\`: verify the local agent implementation contract exists.
|
|
218
|
+
- \`npm run agentkit -- eval from-conversation <conversation-id>\`: turn a real conversation into a regression eval.
|
|
219
|
+
- \`npm run agentkit -- conversations trace <conversation-id>\`: inspect messages, runs, tool calls, inputs, outputs, rendered output, and final responses.
|
|
206
220
|
- \`npm run dev\`: run the local Agent Capsule runtime.
|
|
207
221
|
- \`npm run agentkit -- inspect\`: print machine-readable capsule state.
|
|
208
|
-
- \`npm run agentkit -- env set <NAME>
|
|
222
|
+
- \`printf %s "$VALUE" | npm run agentkit -- env set <NAME> --stdin\`: write a local secret value to ignored \`.env\` without putting it in shell history.
|
|
209
223
|
- \`npm run agentkit -- env list\`: list local secret names without printing values.
|
|
210
|
-
- \`npm run agentkit -- docs
|
|
224
|
+
- \`npm run agentkit -- docs llms\`: print the lightweight AgentKit docs router.
|
|
225
|
+
- \`npm run agentkit -- docs full\`: print the full AgentKit contract path only when a skill asks for it.
|
|
226
|
+
|
|
227
|
+
## Testing With A UI
|
|
228
|
+
|
|
229
|
+
- Local UI: run \`npm run dev\`, open the printed \`Chat:\` URL, and tell the owner the exact URL.
|
|
230
|
+
- Hosted UI: after \`npm run agentkit -- deploy\`, run \`npm run agentkit -- chat-ui --deploy\`, open the printed \`Chat:\` URL, and tell the owner it is connected to the hosted deploy.
|
|
231
|
+
- \`test/fake\` is deterministic. It is useful for scaffold checks, direct tool checks, and fake-provider evals, but it does not validate natural conversation quality.
|
|
232
|
+
- Before claiming real conversation behavior is tested, ask the owner which provider to use: OpenRouter, OpenAI, Anthropic, or another supported provider. Do not choose for them.
|
|
211
233
|
|
|
212
234
|
## Hosted Deploy
|
|
213
235
|
|
|
214
236
|
- Local scaffold, chat, eval, dev, inspect, tool, and build commands are token-free.
|
|
215
237
|
- Hosted deploy requires an invited AgentKit Cloud alpha token. If no token is stored yet, ask the owner for one and run \`npm run agentkit -- login --token <token>\`.
|
|
216
|
-
- Put production secret values into managed secrets with \`npm run agentkit -- secret set <NAME>
|
|
238
|
+
- Put production secret values into managed secrets with \`npm run agentkit -- secret set <NAME> --from-local-env\`, \`--from-env\`, or \`--stdin\`, not into committed files or shell history.
|
|
217
239
|
- Deploy with \`npm run agentkit -- deploy\`, then check \`npm run agentkit -- deploy status\`.
|
|
218
|
-
- Create client-facing
|
|
240
|
+
- Hosted deploy writes the local chat/UI deploy access token to \`.agentkit/chat-access-token.json\`. Create extra client-facing tokens with \`npm run agentkit -- access token create <name> --out <path>\` when a separate website or app needs its own credential.
|
|
241
|
+
- Use \`npm run agentkit -- deploy --smoke "hello"\` or \`npm run agentkit -- deploy smoke --message "hello"\` for an official hosted chat smoke check.
|
|
219
242
|
- Do not run operator/admin commands from a user capsule.
|
|
220
243
|
|
|
221
244
|
## Files
|
|
@@ -248,42 +271,71 @@ Example owner request:
|
|
|
248
271
|
Turn the request into a working local capsule:
|
|
249
272
|
|
|
250
273
|
- Update \`prompts/instructions.md\` with domain-specific behavior, boundaries, intake questions, and escalation rules.
|
|
274
|
+
- Create or update \`AGENT_SPEC.md\` with \`npm run agentkit -- spec init --brief "<owner request>"\`. The owner gives the general idea; the coding agent turns it into the structured contract.
|
|
251
275
|
- Update \`agentkit.config.ts\` when tools, secrets, provider, or access rules change.
|
|
252
276
|
- Add, replace, or remove TypeScript tools under \`tools/\` for real actions or external data.
|
|
277
|
+
- Use \`npm run agentkit -- sync init\` when the agent needs catalog sync, fixture seed data, or ordered migrations.
|
|
253
278
|
- Keep the first version runnable with \`test/fake\` unless the owner explicitly asks for a real provider.
|
|
279
|
+
- Do not use a wizard or recipe. Build the capsule directly from the scaffold, the AgentKit contract, and the owner's brief.
|
|
254
280
|
- Make practical assumptions and list them in your final response.
|
|
255
281
|
- Ask follow-up questions only when missing information blocks a safe local implementation.
|
|
256
282
|
|
|
257
283
|
## Local Commands
|
|
258
284
|
|
|
259
285
|
\`\`\`sh
|
|
260
|
-
npm install
|
|
261
286
|
npm run typecheck
|
|
262
287
|
npm run agentkit -- inspect
|
|
263
288
|
npm run agentkit -- tool lookup_order --input '{"orderId":"A100"}'
|
|
264
289
|
npm run eval
|
|
265
290
|
\`\`\`
|
|
266
291
|
|
|
292
|
+
\`test/fake\` proves the scaffold and deterministic tool paths. It does not prove natural conversation quality.
|
|
293
|
+
|
|
294
|
+
\`agentkit new\` installs dependencies by default. Run \`npm install\` only if the capsule was created with \`--no-install\`, install failed, or \`node_modules\` was deleted.
|
|
295
|
+
|
|
267
296
|
Set local development secrets without opening code:
|
|
268
297
|
|
|
269
298
|
\`\`\`sh
|
|
270
|
-
npm run agentkit -- env set OPENAI_API_KEY
|
|
299
|
+
printf %s "$OPENAI_API_KEY" | npm run agentkit -- env set OPENAI_API_KEY --stdin
|
|
271
300
|
npm run agentkit -- inspect
|
|
272
301
|
npm run chat -- --message "hello"
|
|
273
302
|
\`\`\`
|
|
274
303
|
|
|
304
|
+
## Testing With A UI
|
|
305
|
+
|
|
306
|
+
Local UI:
|
|
307
|
+
|
|
308
|
+
\`\`\`sh
|
|
309
|
+
npm run dev
|
|
310
|
+
\`\`\`
|
|
311
|
+
|
|
312
|
+
Open the printed \`Chat:\` URL and tell the owner the exact URL.
|
|
313
|
+
|
|
314
|
+
Hosted deploy UI:
|
|
315
|
+
|
|
316
|
+
\`\`\`sh
|
|
317
|
+
npm run agentkit -- deploy
|
|
318
|
+
npm run agentkit -- chat-ui --deploy
|
|
319
|
+
\`\`\`
|
|
320
|
+
|
|
321
|
+
Open the printed \`Chat:\` URL and tell the owner this local UI is connected to the hosted deploy.
|
|
322
|
+
|
|
323
|
+
Before claiming real conversation behavior has been tested, ask the owner which provider to use: OpenRouter, OpenAI, Anthropic, or another supported provider. Do not choose for them. After they choose, update \`agentkit.config.ts\`, \`.env.schema\`, local secrets, hosted secrets if deploying, then rerun chat/UI checks.
|
|
324
|
+
|
|
275
325
|
If you add a tool, also run a fake-provider tool smoke test:
|
|
276
326
|
|
|
277
327
|
\`\`\`sh
|
|
278
328
|
npm run agentkit -- tool tool_name --input '{}'
|
|
279
329
|
\`\`\`
|
|
280
330
|
|
|
281
|
-
For the
|
|
331
|
+
For the lightweight docs router, read the path printed by:
|
|
282
332
|
|
|
283
333
|
\`\`\`sh
|
|
284
|
-
npm run agentkit -- docs
|
|
334
|
+
npm run agentkit -- docs llms
|
|
285
335
|
\`\`\`
|
|
286
336
|
|
|
337
|
+
Read the full framework contract with \`npm run agentkit -- docs full\` only when a skill asks for it.
|
|
338
|
+
|
|
287
339
|
## Database Tools
|
|
288
340
|
|
|
289
341
|
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.
|
|
@@ -305,9 +357,10 @@ This capsule is deploy-ready by default.
|
|
|
305
357
|
1. Keep tools edge-safe and use \`ctx.db\` instead of importing database drivers.
|
|
306
358
|
2. Run \`npm run agentkit -- build\` only when you want to validate the artifact locally.
|
|
307
359
|
3. If the owner has not logged in yet, ask for an invited AgentKit Cloud alpha token and run \`npm run agentkit -- login --token <token>\`.
|
|
308
|
-
4. Put production secrets into managed secrets with \`npm run agentkit -- secret set <NAME>
|
|
360
|
+
4. Put production secrets into managed secrets with \`npm run agentkit -- secret set <NAME> --from-local-env\`, \`--from-env\`, or \`--stdin\`.
|
|
309
361
|
5. Run \`npm run agentkit -- deploy\`.
|
|
310
|
-
6. Create client-facing deploy access tokens with \`npm run agentkit -- access token create <name>\` when a website or app needs
|
|
362
|
+
6. Run \`npm run agentkit -- chat-ui --deploy\` to test the hosted agent through a local UI using the auto-created \`.agentkit/chat-access-token.json\`. Create extra client-facing deploy access tokens with \`npm run agentkit -- access token create <name> --out <path>\` when a separate website or app needs its own credential.
|
|
363
|
+
7. Use \`npm run agentkit -- deploy --smoke "hello"\` during deploy or \`npm run agentkit -- deploy smoke --message "hello"\` afterward for an official hosted smoke check.
|
|
311
364
|
|
|
312
365
|
AgentKit owns hosted infrastructure and production secrets. Do not put production secret values in this capsule. Do not run operator/admin commands from a user capsule.
|
|
313
366
|
`,
|
|
@@ -321,8 +374,10 @@ Use AgentKit conventions when editing this support capsule.
|
|
|
321
374
|
- The agent contract lives in \`agentkit.config.ts\`.
|
|
322
375
|
- The example tool lives in \`tools/lookup-order.ts\`.
|
|
323
376
|
- The default provider is \`test/fake\`, which can call tools from JSON messages during local tests.
|
|
377
|
+
- Ask the owner which real provider to use before switching from \`test/fake\`; do not choose OpenRouter, OpenAI, or Anthropic automatically.
|
|
324
378
|
- Keep required local secret names in \`.env.schema\` and values in ignored \`.env\`. AgentKit local commands load \`.env\` directly.
|
|
325
379
|
- Treat the owner's natural-language request as the brief and start implementing inside this capsule.
|
|
380
|
+
- Start with \`skills/agentkit-capsule/SKILL.md\` when the task is not obvious.
|
|
326
381
|
`,
|
|
327
382
|
},
|
|
328
383
|
{
|
|
@@ -334,14 +389,18 @@ Generated by AgentKit as a support Agent Capsule.
|
|
|
334
389
|
## Setup
|
|
335
390
|
|
|
336
391
|
\`\`\`sh
|
|
337
|
-
npm install
|
|
338
392
|
npm run chat -- --message "hello"
|
|
339
393
|
npm run agentkit -- tool lookup_order --input '{"orderId":"A100"}'
|
|
340
394
|
npm run eval
|
|
341
395
|
npm run dev
|
|
342
396
|
\`\`\`
|
|
343
397
|
|
|
398
|
+
\`agentkit new\` installs dependencies by default. Run \`npm install\` only if this capsule was created with \`--no-install\`, install failed, or \`node_modules\` was deleted.
|
|
399
|
+
|
|
344
400
|
The support template includes a local \`lookup_order\` TypeScript tool and uses \`test/fake\` by default.
|
|
401
|
+
\`test/fake\` does not validate real conversation quality. The owner must choose OpenRouter, OpenAI, Anthropic, or another supported provider before real model behavior is tested.
|
|
402
|
+
|
|
403
|
+
For UI testing, run \`npm run dev\` and open the printed \`Chat:\` URL. After hosted deploy, run \`npm run agentkit -- chat-ui --deploy\` and open its printed \`Chat:\` URL.
|
|
345
404
|
`,
|
|
346
405
|
},
|
|
347
406
|
];
|