@kunal_dutt/token-lens 0.0.0-stage → 0.2.16

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 (40) hide show
  1. package/GATEWAY.md +491 -0
  2. package/LICENSE +21 -0
  3. package/PRIVACY.md +36 -0
  4. package/README.md +80 -2
  5. package/agent-cost-check.yml +49 -0
  6. package/check-agent.mjs +3298 -0
  7. package/cli.mjs +22 -0
  8. package/gateway.mjs +3365 -0
  9. package/package.json +45 -4
  10. package/sdk.mjs +207719 -0
  11. package/server.mjs +3392 -0
  12. package/token-lens.mcpb +0 -0
  13. package/types/src/core/advice.d.ts +27 -0
  14. package/types/src/core/budget.d.ts +28 -0
  15. package/types/src/core/compress.d.ts +29 -0
  16. package/types/src/core/cost.d.ts +32 -0
  17. package/types/src/core/guard.d.ts +20 -0
  18. package/types/src/core/hotspots.d.ts +124 -0
  19. package/types/src/core/index.d.ts +74 -0
  20. package/types/src/core/media.d.ts +29 -0
  21. package/types/src/core/models.d.ts +81 -0
  22. package/types/src/core/plans.d.ts +88 -0
  23. package/types/src/core/redos.d.ts +32 -0
  24. package/types/src/core/review.d.ts +46 -0
  25. package/types/src/core/rules.d.ts +47 -0
  26. package/types/src/core/tasks.d.ts +44 -0
  27. package/types/src/core/tokens.d.ts +19 -0
  28. package/types/src/core/verify.d.ts +19 -0
  29. package/types/src/gateway/config.d.ts +217 -0
  30. package/types/src/gateway/guard.d.ts +56 -0
  31. package/types/src/gateway/images.d.ts +40 -0
  32. package/types/src/gateway/metrics.d.ts +287 -0
  33. package/types/src/gateway/optimize.d.ts +102 -0
  34. package/types/src/gateway/protocol.d.ts +68 -0
  35. package/types/src/gateway/runs.d.ts +182 -0
  36. package/types/src/gateway/shared.d.ts +57 -0
  37. package/types/src/gateway/signals.d.ts +38 -0
  38. package/types/src/gateway/storage.d.ts +88 -0
  39. package/types/src/gateway/verify.d.ts +51 -0
  40. package/types/src/sdk/index.d.ts +228 -0
package/cli.mjs ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ // token-lens: one command for every local way to run Token Lens.
3
+ // npx -y @kunal_dutt/token-lens@latest MCP server over stdio (Claude Desktop, Claude Code, Cursor, VS Code…)
4
+ // npx -y @kunal_dutt/token-lens@latest --http 8787 your own connector at http://localhost:8787/mcp
5
+ // npx -y @kunal_dutt/token-lens@latest gateway the OpenAI/Anthropic-compatible gateway (see GATEWAY.md)
6
+ // npx -y @kunal_dutt/token-lens@latest check-agent … token and dollar change of a PR's agent prompts and tools
7
+ // Nothing here makes a network request of its own.
8
+ const [cmd] = process.argv.slice(2);
9
+ if (cmd === "gateway") await import("./gateway.mjs");
10
+ else if (cmd === "check-agent") process.exitCode = (await import("./check-agent.mjs")).main(process.argv.slice(3));
11
+ else if (cmd === "--help" || cmd === "-h" || cmd === "help") {
12
+ console.log(`Token Lens: count and cut the tokens your prompts, chats and agents use.
13
+
14
+ token-lens MCP server over stdio, for any MCP app
15
+ token-lens --http [port] MCP server over Streamable HTTP at /mcp (default port 8787)
16
+ token-lens gateway self-hosted OpenAI/Anthropic-compatible gateway (PORT, TOKEN_LENS_CONFIG…)
17
+ token-lens check-agent --model <model> [--base <ref>] [--out file.md] [--calls-per-month N]
18
+ [--fail-above <tokens>] <pathspec>...
19
+ token and dollar change a pull request makes to agent prompts and tools
20
+
21
+ Collects no data. https://www.npmjs.com/package/@kunal_dutt/token-lens`);
22
+ } else await import("./server.mjs");