@andreprado/agentkit 0.1.0-alpha.17 → 0.1.0-alpha.19

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 (64) hide show
  1. package/README.md +3 -0
  2. package/docs/guides/add-channel.md +14 -8
  3. package/docs/guides/add-knowledge.md +10 -0
  4. package/docs/guides/add-managed-composio.md +43 -17
  5. package/docs/guides/channel-security.md +60 -39
  6. package/docs/guides/connect-discord.md +178 -0
  7. package/docs/guides/create-agent.md +13 -0
  8. package/docs/guides/debug-channel.md +147 -0
  9. package/docs/guides/improve-from-production.md +151 -0
  10. package/docs/guides/prepare-deploy.md +30 -14
  11. package/docs/guides/replay-production-traces.md +72 -0
  12. package/docs/guides/run-evals.md +18 -0
  13. package/docs/guides/security-rules.md +5 -5
  14. package/docs/guides/use-provider.md +11 -1
  15. package/docs/llms-full.txt +106 -15
  16. package/docs/llms.txt +22 -4
  17. package/package.json +1 -3
  18. package/src/cli/args.ts +23 -2
  19. package/src/cli/cloud-client.ts +75 -0
  20. package/src/cli/commands/channels.ts +139 -14
  21. package/src/cli/deploy-chat-ui.ts +146 -3
  22. package/src/cli/deploy-readiness.ts +57 -1
  23. package/src/cli/help.ts +32 -8
  24. package/src/cli/index.ts +447 -17
  25. package/src/create-project.ts +13 -2
  26. package/src/index.ts +46 -3
  27. package/src/providers/pi.ts +49 -15
  28. package/src/runtime/channel-test-harness.ts +4 -1
  29. package/src/runtime/channels/discord.ts +887 -0
  30. package/src/runtime/channels.ts +15 -0
  31. package/src/runtime/config.ts +39 -3
  32. package/src/runtime/core/manifest.ts +2 -0
  33. package/src/runtime/dev-server.ts +149 -8
  34. package/src/runtime/evals.ts +27 -6
  35. package/src/runtime/improve.ts +868 -0
  36. package/src/runtime/inspect.ts +1 -0
  37. package/src/runtime/integrations/composio.ts +168 -2
  38. package/src/runtime/knowledge/retrieve.ts +25 -5
  39. package/src/runtime/knowledge/schema.ts +45 -1
  40. package/src/runtime/runtime-contract.ts +54 -0
  41. package/src/runtime/targets/cloudflare/build.ts +479 -194
  42. package/src/runtime/targets/vps/deploy.ts +1 -1
  43. package/src/storage/sqlite.ts +7 -2
  44. package/src/templates/skills/agentkit-capsule/SKILL.md +8 -1
  45. package/src/templates/skills/agentkit-capsule/references/docs-router.md +1 -2
  46. package/src/templates/skills/agentkit-channels/SKILL.md +6 -1
  47. package/src/templates/skills/agentkit-channels/references/channel-debugging.md +2 -1
  48. package/src/templates/skills/agentkit-channels/references/discord.md +93 -0
  49. package/src/templates/skills/agentkit-deploy/SKILL.md +6 -0
  50. package/src/templates/skills/agentkit-evals/SKILL.md +12 -3
  51. package/src/templates/skills/agentkit-improve/SKILL.md +86 -0
  52. package/src/templates/skills/agentkit-improve/references/replay-side-effects.md +18 -0
  53. package/src/templates/skills/agentkit-improve/references/trace-packets.md +22 -0
  54. package/src/templates/skills/agentkit-improve/templates/regression.eval.md +18 -0
  55. package/src/templates/skills/agentkit-integrations/SKILL.md +12 -2
  56. package/src/templates/skills/agentkit-knowledge/SKILL.md +4 -1
  57. package/src/templates/skills/agentkit-provider/SKILL.md +4 -1
  58. package/src/templates/skills/agentkit-security/SKILL.md +3 -2
  59. package/src/templates/skills/agentkit-troubleshooting/SKILL.md +9 -0
  60. package/src/templates/support.ts +4 -2
  61. package/docs/guides/agentkit-skills-architecture.md +0 -472
  62. package/docs/guides/channels-implementation-map.md +0 -243
  63. package/docs/guides/channels-production-handoff.md +0 -118
  64. package/docs/portable-deploy-release-checklist.md +0 -41
@@ -49,24 +49,37 @@ agentkit db reset --yes
49
49
  agentkit db shell
50
50
  agentkit db seed [--file <path>]
51
51
  agentkit eval run
52
+ agentkit eval from-conversation <conversation-id> [--out <path>] [--force]
53
+ agentkit improve collect [--deploy] [--since <duration|iso>] [--conversation-id <id>] [--out <directory>]
54
+ agentkit improve evals <bundle-dir-or-json> [--force]
55
+ agentkit replay <bundle-dir-or-json> --against local
52
56
  agentkit conversations list
53
57
  agentkit conversations show <conversation-id>
58
+ agentkit conversations trace <conversation-id> [--deploy]
54
59
  agentkit channels list
55
- agentkit channels add <website|telegram|whatsapp> <name> [--provider zapster|meta] [--api <url>]
60
+ agentkit channels add <website|telegram|whatsapp|discord> <name> [--provider zapster|meta] [--mode interactions|bot] [--api <url>]
61
+ agentkit channels connect <website|telegram|whatsapp|discord> <name> [--provider zapster|meta] [--mode interactions|bot] [--api <url>]
56
62
  agentkit channels setup <name> [--apply] [--api <url>]
57
63
  agentkit channels status <name> [--api <url>]
58
64
  agentkit channels test <name> [--message <text>] [--fixture <path>] [--api <url>]
59
65
  agentkit channels test-audio <name> [--fixture voice-note|audio-file|<path>] [--api <url>]
60
66
  agentkit channels deliveries list <name> [--api <url>]
61
67
  agentkit channels deliveries show <delivery-id> [--api <url>]
62
- agentkit integrations status [--api <url>]
68
+ agentkit integrations status [--toolkit <slug>] [--api <url>]
63
69
  agentkit integrations connect composio [--toolkit <slug>] [--callback-url <url>] [--api <url>]
64
70
  agentkit skills status
65
71
  agentkit skills sync
66
72
  agentkit inspect
67
73
  agentkit build [--target cloudflare|container]
74
+ agentkit billing checkout --slots <count> [--email <email>] [--api <url>]
75
+ agentkit billing status <billing-intent-id> --secret <secret> [--api <url>]
76
+ agentkit billing claim <billing-intent-id> --secret <secret> [--token-name <name>] [--api <url>]
77
+ agentkit billing portal [--api <url>]
68
78
  agentkit login --token <token>
69
79
  agentkit logout
80
+ agentkit account token create <name> [--api <url>] [--use] [--out <path>]
81
+ agentkit account token list [--api <url>]
82
+ agentkit account token revoke <token-id> [--api <url>]
70
83
  agentkit deploy [--target cloudflare|vps] [--host <host>] [--api <url>] [--dry-run] [--anonymous] [--local-wrangler] [--smoke <message>]
71
84
  agentkit deploy doctor [--api <url>] [--anonymous]
72
85
  agentkit deploy smoke [--message <text>] [--api <url>]
@@ -99,13 +112,9 @@ agentkit help commands
99
112
 
100
113
  Prefer `env set --stdin` or `--from-env` for local secret values, and prefer `secret set --stdin`, `--from-env`, or `--from-local-env` for hosted secrets. Inline `<VALUE>` forms exist for simple non-sensitive values, but agents should avoid putting secrets in shell history.
101
114
 
102
- Managed Composio is configured with `composioManaged({...})` in `agentkit.config.ts` and is paid hosted AgentKit infrastructure. It requires a non-anonymous AgentKit Cloud deploy with `managed_composio`, uses one Composio settings profile per agent, injects `COMPOSIO_API_KEY` as an AgentKit-managed secret, and exposes the generated `agentkit_composio_execute` tool only for explicit configured action slugs. See `docs/guides/add-managed-composio.md`.
115
+ On Windows PowerShell, if `npm.ps1` or `npx.ps1` is blocked with `PSSecurityException`, run capsule scripts through the `.cmd` shims instead of changing the workflow. Examples: `npx.cmd @andreprado/agentkit@alpha new demo --template blank`, `npm.cmd run agentkit -- inspect`, `npm.cmd run agentkit -- knowledge sync`, and `npm.cmd run eval`.
103
116
 
104
- Planned commands described by the contract but not implemented yet:
105
-
106
- ```sh
107
- agentkit eval from-conversation <conversation-id>
108
- ```
117
+ Managed Composio is configured with `composioManaged({...})` in `agentkit.config.ts` and is paid hosted AgentKit infrastructure. It requires a non-anonymous AgentKit Cloud deploy with `managed_composio`, uses one Composio settings profile per agent, injects `COMPOSIO_API_KEY` as an AgentKit-managed secret, resolves toolkit auth configs from AgentKit Cloud, validates toolkit readiness during `agentkit deploy doctor`, and exposes the generated `agentkit_composio_execute` tool only for explicit configured action slugs. Calendar starters should include `GOOGLECALENDAR_EVENTS_LIST`, `GOOGLECALENDAR_CREATE_EVENT`, and `GOOGLECALENDAR_UPDATE_EVENT`; create-event calls must pass UTC `start_datetime` plus explicit duration. Managed external write actions require tool input `confirmed: true` by default unless the integration sets `confirmExternalWrites: false`. See `docs/guides/add-managed-composio.md`.
109
118
 
110
119
  ## Create And Test A Capsule
111
120
 
@@ -254,6 +263,8 @@ npm run chat -- --message "hello"
254
263
 
255
264
  If a provider key is missing, the runtime returns `secret_not_found`.
256
265
 
266
+ For OpenRouter, prefer model ids or aliases known to the installed Pi SDK, such as `~google/gemini-flash-latest`. If an OpenRouter id is newer than Pi's registry, AgentKit passes the raw id through to OpenRouter with conservative unknown-model metadata. OpenRouter can still reject invalid, inaccessible, or unsupported models, and unknown-model cost/capability metadata is not authoritative.
267
+
257
268
  ## Knowledge Contract
258
269
 
259
270
  Knowledge is AgentKit's native retrieval layer for facts the agent should ground in source files. Use it for FAQs, prices, policies, service descriptions, procedures, CSV tables, and reference docs. Do not put secrets, credentials, `.env` contents, or live customer/payment records in Knowledge. Use tools for live or authorization-sensitive data.
@@ -303,7 +314,7 @@ agentkit knowledge inspect
303
314
  agentkit knowledge search "refund policy" --top-k 3
304
315
  ```
305
316
 
306
- `knowledge add` indexes one local path. `knowledge sync` indexes all configured `knowledge.sources` and skips unchanged files by content hash. `agentkit dev` and `agentkit chat` also sync configured Knowledge automatically before local runs. `knowledge inspect` lists indexed sources and chunk counts. `knowledge search` validates retrieval before relying on the agent. When embeddings are configured locally, AgentKit stores canonical chunks in `.agentkit/agentkit.db`, rebuilds a local libSQL vector sidecar at `.agentkit/agentkit.vectors.db`, uses native `libsql_vector_idx` semantic search, and falls back to stored JSON embeddings if the native vector path is unavailable.
317
+ `knowledge add` indexes one local path. `knowledge sync` indexes all configured `knowledge.sources` and skips unchanged files by content hash. `agentkit dev` and `agentkit chat` also sync configured Knowledge automatically before local runs. `knowledge inspect` lists indexed sources and chunk counts. `knowledge search` validates retrieval before relying on the agent. Local lexical search uses SQLite FTS5 when the local SQLite build provides it; when it does not, AgentKit automatically keeps indexing and searching with a normal SQLite table and simpler text matching. When embeddings are configured locally, AgentKit stores canonical chunks in `.agentkit/agentkit.db`, rebuilds a local libSQL vector sidecar at `.agentkit/agentkit.vectors.db`, uses native `libsql_vector_idx` semantic search, and falls back to stored JSON embeddings if the native vector path is unavailable.
307
318
 
308
319
  When `knowledge` is configured, AgentKit automatically registers the internal chat tool `agentkit_search_knowledge` and appends a prompt policy. The policy tells the agent to search before answering business-specific factual questions and not to expose raw retrieval JSON, scores, chunk IDs, or tool output objects. With `test/fake`, verify the internal tool directly:
309
320
 
@@ -328,7 +339,7 @@ Channels are hosted inbound/outbound conversation transports. They are separate
328
339
  Use these helpers in `agentkit.config.ts`:
329
340
 
330
341
  ```ts
331
- import { defineAgent, telegramChannel, whatsappChannel, websiteChannel } from "@andreprado/agentkit";
342
+ import { defineAgent, discordChannel, telegramChannel, whatsappChannel, websiteChannel } from "@andreprado/agentkit";
332
343
 
333
344
  export default defineAgent({
334
345
  name: "support-agent",
@@ -341,6 +352,8 @@ export default defineAgent({
341
352
  websiteChannel({ name: "website-chat" }),
342
353
  telegramChannel({ name: "support-telegram" }),
343
354
  whatsappChannel({ name: "support-whatsapp", provider: "zapster" }),
355
+ discordChannel({ name: "support-discord" }),
356
+ discordChannel({ name: "server-discord", mode: "bot" }),
344
357
  ],
345
358
  access: { mode: "public" },
346
359
  storage: { driver: "agentkit" },
@@ -376,11 +389,11 @@ whatsappChannel({
376
389
  Useful guides:
377
390
 
378
391
  - Add a channel: `docs/guides/add-channel.md`
392
+ - Connect Discord: `docs/guides/connect-discord.md`
379
393
  - Connect Telegram: `docs/guides/connect-telegram.md`
380
394
  - Connect WhatsApp through Zapster: `docs/guides/connect-whatsapp-zapster.md`
381
395
  - Debug a channel: `docs/guides/debug-channel.md`
382
396
  - Channel security: `docs/guides/channel-security.md`
383
- - Production handoff: `docs/guides/channels-production-handoff.md`
384
397
 
385
398
  Telegram required secrets:
386
399
 
@@ -397,6 +410,18 @@ ZAPSTER_INSTANCE_ID
397
410
  ZAPSTER_WEBHOOK_ID
398
411
  ```
399
412
 
413
+ Discord slash-command required secret:
414
+
415
+ ```txt
416
+ DISCORD_PUBLIC_KEY
417
+ ```
418
+
419
+ Discord bot-mode required secret:
420
+
421
+ ```txt
422
+ DISCORD_BOT_TOKEN
423
+ ```
424
+
400
425
  Common channel verification:
401
426
 
402
427
  ```sh
@@ -404,6 +429,8 @@ agentkit inspect
404
429
  agentkit deploy
405
430
  agentkit channels list
406
431
  agentkit channels add telegram support-telegram
432
+ agentkit channels connect discord support-discord
433
+ agentkit channels connect discord server-discord --mode bot
407
434
  agentkit channels setup support-telegram
408
435
  agentkit channels test support-telegram --message "hello"
409
436
  agentkit channels test-audio support-telegram --fixture voice-note
@@ -414,6 +441,8 @@ agentkit channels deliveries show <delivery-id>
414
441
 
415
442
  `channels connect` creates or refreshes the channel resource, validates secrets, runs provider setup when supported, then runs the official synthetic smoke. `channels setup` is read-only by default. `channels setup <telegram-name> --apply` calls Telegram `setWebhook` and requires `TELEGRAM_BOT_TOKEN` plus `TELEGRAM_WEBHOOK_SECRET`.
416
443
 
444
+ Discord slash-command mode validates `X-Signature-Ed25519` and `X-Signature-Timestamp` against `DISCORD_PUBLIC_KEY`, answers signed `PING` requests with `type: 1`, acknowledges slash commands with a deferred response, then sends the final answer as an interaction follow-up. Discord bot mode uses `DISCORD_BOT_TOKEN`, Discord Gateway `MESSAGE_CREATE`, Message Content Intent, and `/channels/<channel_id>/messages` bot replies. Discord channels support buffering but do not support `audio` in V1.
445
+
417
446
  Default tests are offline. Real provider smoke tests are opt-in:
418
447
 
419
448
  ```sh
@@ -685,6 +714,7 @@ GET /_agentkit
685
714
  POST /v1/chat
686
715
  GET /v1/conversations
687
716
  GET /v1/conversations/:id
717
+ GET /v1/conversations/:id/trace
688
718
  ```
689
719
 
690
720
  Chat request:
@@ -704,6 +734,7 @@ After chat:
704
734
  ```sh
705
735
  agentkit conversations list
706
736
  agentkit conversations show <conversation-id>
737
+ agentkit conversations trace <conversation-id>
707
738
  ```
708
739
 
709
740
  List output columns:
@@ -712,7 +743,7 @@ List output columns:
712
743
  id title updated_at messages
713
744
  ```
714
745
 
715
- Show output includes the conversation id, title, updated timestamp, and each message as `role: content`.
746
+ Show output includes the conversation id, title, updated timestamp, and each message as `role: content`. Trace output includes stored messages and tool calls for the conversation.
716
747
 
717
748
  ## Evals
718
749
 
@@ -753,6 +784,62 @@ For date-sensitive evals, set top-level `now` to an ISO timestamp with an explic
753
784
 
754
785
  Evals run the normal capsule tools. If a tool would write externally, delete, charge money, send email, or call a real customer system, make its `execute` implementation branch on `ctx.runtime.environment === "eval"` and return deterministic non-destructive output for eval runs. Do not invent an eval-only mock API; keep the behavior inside the registered tool contract unless AgentKit adds a first-class mock facility later.
755
786
 
787
+ ## Improve From Production
788
+
789
+ Use AgentKit Improve when a hosted or local conversation should become a reproducible local fix loop. Hosted AgentKit Cloud exports evidence; the local coding agent edits the Agent Capsule, writes evals, replays, and deploys.
790
+
791
+ Collect hosted evidence from the last deploy:
792
+
793
+ ```sh
794
+ agentkit improve collect --deploy --since 24h
795
+ ```
796
+
797
+ When the CLI is logged in to AgentKit Cloud, hosted collection first exports deploy evidence such as failed channel deliveries, deploy errors, and conversation IDs from the control plane, then reads replayable conversation traces from the deployed runtime. Without Cloud auth, it falls back to deploy-token conversation trace reads.
798
+
799
+ Hosted conversation reads require a deploy access token even when the chat endpoint is public. `agentkit deploy` normally writes `.agentkit/chat-access-token.json`; use `agentkit access token create agentkit-chat-ui --out .agentkit/chat-access-token.json` to refresh it.
800
+
801
+ Collect one hosted conversation:
802
+
803
+ ```sh
804
+ agentkit improve collect --deploy --conversation-id <conversation-id>
805
+ ```
806
+
807
+ Collect local evidence:
808
+
809
+ ```sh
810
+ agentkit improve collect --since 7d
811
+ ```
812
+
813
+ The command writes ignored local state:
814
+
815
+ ```txt
816
+ .agentkit/improve/<run>/
817
+ bundle.json
818
+ report.json
819
+ traces/
820
+ ```
821
+
822
+ Generate committed regression evals:
823
+
824
+ ```sh
825
+ agentkit improve evals .agentkit/improve/<run>
826
+ ```
827
+
828
+ Then replay before deploying:
829
+
830
+ ```sh
831
+ agentkit replay .agentkit/improve/<run> --against local
832
+ npm run eval
833
+ agentkit deploy --smoke "hello"
834
+ ```
835
+
836
+ Replay runs collected user turns through the local capsule with `ctx.runtime.environment === "eval"` and `ctx.runtime.invocation === "eval"`. Generated evals live under `evals/regressions/`; review them before committing, especially when traces contain real client details or overly strict prose assertions.
837
+
838
+ Full guides:
839
+
840
+ - `docs/guides/improve-from-production.md`
841
+ - `docs/guides/replay-production-traces.md`
842
+
756
843
  ## Security Rules
757
844
 
758
845
  Never commit:
@@ -776,7 +863,7 @@ prompts/
776
863
  docs/
777
864
  ```
778
865
 
779
- Local `.env` is development only. Use `.env.schema` as the committed secret-name contract; local AgentKit commands load `.env` directly. Hosted alpha deploys use `agentkit login --token ...` and managed secrets through `agentkit secret set/list/unset` or `agentkit secret sync --from-local`. Prefer `--stdin`, `--from-env`, `--from-local-env`, or sync from local `.env` so secret values do not appear in shell history. Inline `<VALUE>` forms exist only for compatibility and simple non-sensitive values.
866
+ Local `.env` is development only. Use `.env.schema` as the committed secret-name contract; local AgentKit commands load `.env` directly. Hosted deploys require an AgentKit Cloud account with `cloudflare_deploy_alpha` or purchased/manual deploy slots. First-time paid access uses `agentkit billing checkout --slots <count>` and `agentkit billing claim billint_... --secret bsec_...`; existing accounts use `agentkit login --token ...`. Hosted secrets use `agentkit secret set/list/unset` or `agentkit secret sync --from-local`. Prefer `--stdin`, `--from-env`, `--from-local-env`, or sync from local `.env` so secret values do not appear in shell history. Inline `<VALUE>` forms exist only for compatibility and simple non-sensitive values.
780
867
 
781
868
  Tools are a security boundary. A tool must declare every secret it needs. The runtime injects only tool-declared secrets.
782
869
 
@@ -788,7 +875,10 @@ Current flow:
788
875
 
789
876
  ```sh
790
877
  agentkit deploy --dry-run
878
+ agentkit billing checkout --slots 1 --email user@example.com
879
+ agentkit billing claim billint_... --secret bsec_...
791
880
  agentkit login --token agk_user_...
881
+ agentkit account token create new-laptop --use
792
882
  agentkit deploy doctor
793
883
  agentkit deploy --smoke "hello"
794
884
  agentkit deploy status
@@ -796,9 +886,9 @@ agentkit deploy smoke --message "hello"
796
886
  agentkit chat-ui --deploy
797
887
  ```
798
888
 
799
- `agentkit deploy doctor` checks AgentKit Cloud login, `cloudflare_deploy_alpha`, online deploy capacity, hosted secrets, local `.env` names that still need `agentkit secret set`, and private-access runtime token handling. `agentkit deploy` sends the capsule to AgentKit Cloud, runs the same readiness check automatically before building and uploading, and writes the local chat/UI deploy access token to `.agentkit/chat-access-token.json` for private hosted deploys. `agentkit deploy --smoke "hello"` deploys and then tests `/v1/chat` with the deploy access token. `agentkit deploy smoke --message "hello"` repeats that smoke against the last local deploy. `agentkit chat-ui --deploy` serves a local UI pointed at the hosted deploy using that token without exposing it to browser code. Production alpha deploys require an account with `cloudflare_deploy_alpha`; local commands and dry-run builds do not require login. AgentKit owns infrastructure selection, backend migration, managed secrets, and public URL creation.
889
+ `agentkit deploy doctor` checks AgentKit Cloud login, hosted deploy entitlement, online deploy capacity, hosted secrets, local `.env` names that still need `agentkit secret set`, managed Composio API/auth-config readiness by toolkit, and private-access runtime token handling. `agentkit deploy` sends the capsule to AgentKit Cloud, runs the same readiness check automatically before building and uploading, updates the current project deploy slot by default, and writes the local chat/UI deploy access token to `.agentkit/chat-access-token.json` for hosted deploys. `agentkit deploy --smoke "hello"` deploys and then tests `/v1/chat` with the deploy access token. `agentkit deploy smoke --message "hello"` repeats that smoke against the last local deploy. `agentkit chat-ui --deploy` serves a local UI pointed at the hosted deploy using that token without exposing it to browser code, shows the conversation id and tool calls, and supports starting a new conversation. Use `agentkit conversations trace <conversation-id> --deploy` to pull hosted conversation messages and tool calls from the last deploy. Production deploys require an account with `cloudflare_deploy_alpha` or purchased/manual deploy slots; local commands and dry-run builds do not require login. AgentKit owns infrastructure selection, backend migration, managed secrets, and public URL creation.
800
890
 
801
- The CLI defaults to the hosted AgentKit Cloud API at `https://agentkit-cloud.aibuilders.com.br`. Use `AGENTKIT_CLOUD_API_URL` or `agentkit deploy --api <url>` only for local or alternate control-plane tests.
891
+ The CLI defaults to the hosted AgentKit Cloud API at `https://agentkit-cloud.aibuilders.com.br`. Use `AGENTKIT_CLOUD_API_URL` or `agentkit deploy --api <url>` only when the owner gives you a non-default AgentKit Cloud API URL.
802
892
 
803
893
  Account/access flow:
804
894
 
@@ -806,6 +896,7 @@ Account/access flow:
806
896
  agentkit secret set OPENAI_API_KEY --from-local-env
807
897
  agentkit secret sync --from-local
808
898
  agentkit secret list
899
+ agentkit account token list
809
900
  agentkit skills status
810
901
  agentkit skills sync
811
902
  agentkit access token create website-chat --out .agentkit/website-chat-access-token.json
package/docs/llms.txt CHANGED
@@ -10,6 +10,8 @@ Task guides:
10
10
  - Add a TypeScript tool: `docs/guides/add-tool.md`
11
11
  - Add Knowledge from local docs/CSVs: `docs/guides/add-knowledge.md`
12
12
  - Run or prepare evals: `docs/guides/run-evals.md`
13
+ - Improve from production traces: `docs/guides/improve-from-production.md`
14
+ - Replay collected traces locally: `docs/guides/replay-production-traces.md`
13
15
  - Switch from `test/fake` to a real provider: `docs/guides/use-provider.md`
14
16
  - Prepare for hosted deploy: `docs/guides/prepare-deploy.md`
15
17
  - Build Cloudflare artifact: `agentkit build --target cloudflare`
@@ -18,12 +20,11 @@ Task guides:
18
20
  - Add hosted channels: `docs/guides/add-channel.md`
19
21
  - Add AgentKit-managed Composio: `docs/guides/add-managed-composio.md`
20
22
  - Buffer rapid channel messages: `docs/guides/add-channel.md#buffer-bursty-messages`
23
+ - Connect Discord: `docs/guides/connect-discord.md`
21
24
  - Connect Telegram: `docs/guides/connect-telegram.md`
22
25
  - Connect WhatsApp through Zapster: `docs/guides/connect-whatsapp-zapster.md`
23
26
  - Follow channel webhook and delivery-log safety rules: `docs/guides/channel-security.md`
24
- - Prepare Channels for production: `docs/guides/channels-production-handoff.md`
25
27
  - Follow secret, access, and tool safety rules: `docs/guides/security-rules.md`
26
- - Plan repo-local skills for coding agents: `docs/guides/agentkit-skills-architecture.md`
27
28
 
28
29
  Current local commands:
29
30
 
@@ -42,21 +43,31 @@ agentkit knowledge sync
42
43
  agentkit knowledge inspect
43
44
  agentkit knowledge search <query> [--top-k <number>]
44
45
  agentkit eval run
46
+ agentkit improve collect --deploy --since 24h
47
+ agentkit improve evals .agentkit/improve/<run>
48
+ agentkit replay .agentkit/improve/<run> --against local
45
49
  agentkit conversations list
46
50
  agentkit conversations show <conversation-id>
51
+ agentkit conversations trace <conversation-id> [--deploy]
47
52
  agentkit channels list
48
53
  agentkit channels add telegram support-telegram
54
+ agentkit channels connect discord support-discord
55
+ agentkit channels connect discord server-discord --mode bot
49
56
  agentkit channels setup support-telegram
50
57
  agentkit channels status support-telegram
51
58
  agentkit channels test support-telegram --message "hello"
52
59
  agentkit channels test-audio support-telegram --fixture voice-note
53
60
  agentkit transcribe smoke --provider groq
54
61
  agentkit channels deliveries list support-telegram
55
- agentkit integrations status
62
+ agentkit integrations status [--toolkit googlecalendar]
56
63
  agentkit integrations connect composio --toolkit gmail
57
64
  agentkit skills status
58
65
  agentkit skills sync
66
+ agentkit billing checkout --slots 1 --email user@example.com
67
+ agentkit billing claim billint_... --secret bsec_...
59
68
  agentkit login --token agk_user_...
69
+ agentkit account token create new-laptop --use
70
+ agentkit account token list
60
71
  agentkit deploy doctor
61
72
  agentkit deploy --smoke "hello"
62
73
  agentkit deploy status
@@ -72,12 +83,18 @@ agentkit dev
72
83
  agentkit open
73
84
  ```
74
85
 
86
+ On Windows PowerShell, if `npm.ps1` or `npx.ps1` is blocked with `PSSecurityException`, run capsule scripts through the `.cmd` shims, for example `npm.cmd run agentkit -- inspect`, `npm.cmd run agentkit -- knowledge sync`, or `npm.cmd run eval`.
87
+
75
88
  Generated capsules include `AGENTKIT.md`, `AGENTS.md`, and a repo-local `skills/` pack so Codex, Claude Code, or another coding agent can treat the owner's natural-language request as the brief and start building immediately without loading the full contract by default. Start with `skills/agentkit-capsule/SKILL.md`, then load the task skill for the current work. `agentkit handoff codex "Develop an ophthalmology office intake agent"` is an optional prompt-printing shortcut for users who are not already inside a coding-agent workspace. There is no wizard or recipe layer: the coding agent edits the capsule directly from the scaffold and contract.
76
89
 
77
90
  UI testing is part of the handoff. For local UI testing, run `agentkit dev`, open the printed `Chat:` URL, and tell the owner the exact URL. After hosted deploy, run `agentkit chat-ui --deploy`, open the printed `Chat:` URL, and tell the owner it is connected to the deploy.
78
91
 
92
+ Hosted Chat UI shows the current conversation id, tool calls, tool errors, and a new-conversation control. Use `agentkit conversations trace <conversation-id> --deploy` to pull the hosted trace from the last deploy.
93
+
79
94
  `test/fake` is deterministic and validates scaffold, direct tool calls, and fake-provider evals. It does not validate natural conversation quality. 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.
80
95
 
96
+ For OpenRouter, prefer model ids or aliases known to the installed Pi SDK, such as `~google/gemini-flash-latest`. If an OpenRouter id is newer than Pi's registry, AgentKit passes the raw id through to OpenRouter with conservative unknown-model metadata; OpenRouter can still reject invalid, inaccessible, or unsupported models.
97
+
81
98
  AgentKit injects the current ISO timestamp, local date, weekday, local date/time, and timezone dynamically into every chat run. Set `timeZone` in `agentkit.config.ts` for scheduling agents so "today", "tomorrow", and weekdays resolve in the business/user timezone; otherwise AgentKit falls back to `AGENTKIT_TIME_ZONE`, valid `TZ`, then the runtime default. Do not hardcode today's date in prompts.
82
99
 
83
100
  Current local endpoints from `agentkit dev`:
@@ -87,6 +104,7 @@ GET /_agentkit
87
104
  POST /v1/chat
88
105
  GET /v1/conversations
89
106
  GET /v1/conversations/:id
107
+ GET /v1/conversations/:id/trace
90
108
  ```
91
109
 
92
- Local `.env` is for development only. Use `.env.schema` as the committed secret-name contract; local AgentKit commands load `.env` directly. Hosted alpha deploys require `cloudflare_deploy_alpha` through `agentkit login --token ...`; production uses managed secrets in the hosted contract.
110
+ Local `.env` is for development only. Use `.env.schema` as the committed secret-name contract; local AgentKit commands load `.env` directly. Hosted deploys require an AgentKit Cloud account with `cloudflare_deploy_alpha` or purchased/manual deploy slots. Use `agentkit billing checkout` + `agentkit billing claim` for first-time paid access, or `agentkit login --token ...` when the user already has an `agk_user_...` token. Production uses managed secrets in the hosted contract.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andreprado/agentkit",
3
- "version": "0.1.0-alpha.17",
3
+ "version": "0.1.0-alpha.19",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "repository": {
@@ -18,8 +18,6 @@
18
18
  "!src/**/*.test.ts",
19
19
  "!src/runtime/fixtures",
20
20
  "docs",
21
- "!docs/guides/backend-contracts.md",
22
- "!docs/guides/debug-channel.md",
23
21
  "README.md"
24
22
  ],
25
23
  "publishConfig": {
package/src/cli/args.ts CHANGED
@@ -4,6 +4,15 @@ export type ParsedArgs = {
4
4
  flags: Record<string, string | boolean>;
5
5
  };
6
6
 
7
+ const dashPrefixedValueFlags = new Set([
8
+ "brief",
9
+ "input",
10
+ "input-json",
11
+ "message",
12
+ "prompt",
13
+ "smoke",
14
+ ]);
15
+
7
16
  export function parseArgs(argv: string[]): ParsedArgs {
8
17
  const [command, ...rest] = argv;
9
18
  const positional: string[] = [];
@@ -12,15 +21,27 @@ export function parseArgs(argv: string[]): ParsedArgs {
12
21
  for (let index = 0; index < rest.length; index += 1) {
13
22
  const value = rest[index];
14
23
 
24
+ if (value === "--") {
25
+ positional.push(...rest.slice(index + 1));
26
+ break;
27
+ }
28
+
15
29
  if (!value.startsWith("--")) {
16
30
  positional.push(value);
17
31
  continue;
18
32
  }
19
33
 
20
- const name = value.slice(2);
34
+ const equalsIndex = value.indexOf("=");
35
+ const name = equalsIndex === -1 ? value.slice(2) : value.slice(2, equalsIndex);
36
+
37
+ if (equalsIndex !== -1) {
38
+ flags[name] = value.slice(equalsIndex + 1);
39
+ continue;
40
+ }
41
+
21
42
  const next = rest[index + 1];
22
43
 
23
- if (next && !next.startsWith("--")) {
44
+ if (next && (dashPrefixedValueFlags.has(name) || !next.startsWith("--"))) {
24
45
  flags[name] = next;
25
46
  index += 1;
26
47
  } else {
@@ -39,6 +39,19 @@ export type CloudLimitsResponse = {
39
39
  };
40
40
  };
41
41
 
42
+ export type CloudManagedComposioResponse = {
43
+ managed_composio?: {
44
+ entitlement?: "active" | "missing" | string;
45
+ api_key?: "set" | "missing" | string;
46
+ toolkits?: Array<{
47
+ toolkit?: string;
48
+ auth_config_env?: string;
49
+ auth_config?: "set" | "missing" | string;
50
+ auth_config_source?: "project" | "account" | "global" | "env" | string;
51
+ }>;
52
+ };
53
+ };
54
+
42
55
  export type CloudProjectResolveResponse = {
43
56
  project?: {
44
57
  id?: string;
@@ -72,6 +85,68 @@ export type DeployAccessTokenListResponse = {
72
85
  }>;
73
86
  };
74
87
 
88
+ export type AccountApiTokenCreateResponse = {
89
+ token?: {
90
+ id?: string;
91
+ account_id?: string;
92
+ name?: string;
93
+ token?: string;
94
+ created_at?: string;
95
+ expires_at?: string;
96
+ last_used_at?: string;
97
+ };
98
+ };
99
+
100
+ export type AccountApiTokenListResponse = {
101
+ tokens?: Array<{
102
+ id?: string;
103
+ account_id?: string;
104
+ name?: string;
105
+ created_at?: string;
106
+ expires_at?: string;
107
+ last_used_at?: string;
108
+ revoked_at?: string;
109
+ }>;
110
+ };
111
+
112
+ export type BillingCheckoutResponse = {
113
+ checkout?: {
114
+ id?: string;
115
+ url?: string;
116
+ };
117
+ billing_intent?: {
118
+ id?: string;
119
+ account_id?: string;
120
+ email?: string;
121
+ requested_slots?: number;
122
+ status?: string;
123
+ secret?: string;
124
+ };
125
+ };
126
+
127
+ export type BillingCheckoutIntentResponse = {
128
+ billing_intent?: {
129
+ id?: string;
130
+ account_id?: string;
131
+ email?: string;
132
+ requested_slots?: number;
133
+ status?: string;
134
+ checkout_session_id?: string;
135
+ stripe_customer_id?: string;
136
+ stripe_subscription_id?: string;
137
+ completed_at?: string;
138
+ token_claimed_at?: string;
139
+ };
140
+ };
141
+
142
+ export type BillingClaimResponse = BillingCheckoutIntentResponse & AccountApiTokenCreateResponse;
143
+
144
+ export type BillingPortalResponse = {
145
+ portal?: {
146
+ url?: string;
147
+ };
148
+ };
149
+
75
150
  export type CloudSecretsResponse = {
76
151
  secrets?: Array<{
77
152
  name?: string;