@kunal_dutt/token-lens 0.0.0-stage → 0.2.17
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/GATEWAY.md +491 -0
- package/LICENSE +21 -0
- package/PRIVACY.md +36 -0
- package/README.md +80 -2
- package/agent-cost-check.yml +49 -0
- package/check-agent.mjs +3298 -0
- package/cli.mjs +22 -0
- package/gateway.mjs +3365 -0
- package/package.json +45 -4
- package/sdk.mjs +207719 -0
- package/server.mjs +3392 -0
- package/token-lens.mcpb +0 -0
- package/types/src/core/advice.d.ts +27 -0
- package/types/src/core/budget.d.ts +28 -0
- package/types/src/core/compress.d.ts +29 -0
- package/types/src/core/cost.d.ts +32 -0
- package/types/src/core/guard.d.ts +20 -0
- package/types/src/core/hotspots.d.ts +124 -0
- package/types/src/core/index.d.ts +74 -0
- package/types/src/core/media.d.ts +29 -0
- package/types/src/core/models.d.ts +81 -0
- package/types/src/core/plans.d.ts +88 -0
- package/types/src/core/redos.d.ts +32 -0
- package/types/src/core/review.d.ts +46 -0
- package/types/src/core/rules.d.ts +47 -0
- package/types/src/core/tasks.d.ts +44 -0
- package/types/src/core/tokens.d.ts +19 -0
- package/types/src/core/verify.d.ts +19 -0
- package/types/src/gateway/config.d.ts +217 -0
- package/types/src/gateway/guard.d.ts +56 -0
- package/types/src/gateway/images.d.ts +40 -0
- package/types/src/gateway/metrics.d.ts +287 -0
- package/types/src/gateway/optimize.d.ts +102 -0
- package/types/src/gateway/protocol.d.ts +68 -0
- package/types/src/gateway/runs.d.ts +182 -0
- package/types/src/gateway/shared.d.ts +57 -0
- package/types/src/gateway/signals.d.ts +38 -0
- package/types/src/gateway/storage.d.ts +88 -0
- package/types/src/gateway/verify.d.ts +51 -0
- package/types/src/sdk/index.d.ts +228 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Token Lens agent cost check: comments on every pull request that changes an
|
|
2
|
+
# agent's prompts or tool definitions with the token and dollar change per call,
|
|
3
|
+
# and what could be trimmed with the same output. Runs inside your CI; nothing is
|
|
4
|
+
# sent anywhere.
|
|
5
|
+
#
|
|
6
|
+
# Copy to .github/workflows/token-lens.yml and set:
|
|
7
|
+
# --model the model your agent runs on (pricing and token counts follow it)
|
|
8
|
+
# paths git pathspecs of your agent files (.json specs, or prompt files)
|
|
9
|
+
# Optional: --calls-per-month N for a monthly figure, --fail-above <tokens> to
|
|
10
|
+
# fail the check when a change adds more than that per call.
|
|
11
|
+
name: Token Lens agent cost check
|
|
12
|
+
|
|
13
|
+
on:
|
|
14
|
+
pull_request:
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
pull-requests: write
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
agent-cost:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
with:
|
|
26
|
+
fetch-depth: 0
|
|
27
|
+
- uses: actions/setup-node@v4
|
|
28
|
+
with:
|
|
29
|
+
node-version: 22
|
|
30
|
+
- run: >
|
|
31
|
+
npx -y @kunal_dutt/token-lens@latest check-agent
|
|
32
|
+
--model claude-opus-5-5
|
|
33
|
+
--base origin/${{ github.base_ref }}
|
|
34
|
+
--calls-per-month 100000
|
|
35
|
+
--out token-lens.md
|
|
36
|
+
'agents/**' 'prompts/**'
|
|
37
|
+
- name: Comment on the pull request
|
|
38
|
+
if: hashFiles('token-lens.md') != ''
|
|
39
|
+
uses: actions/github-script@v7
|
|
40
|
+
with:
|
|
41
|
+
script: |
|
|
42
|
+
const marker = "<!-- token-lens-agent-check -->";
|
|
43
|
+
const body = marker + "\n" + require("fs").readFileSync("token-lens.md", "utf8");
|
|
44
|
+
const { owner, repo } = context.repo;
|
|
45
|
+
const issue_number = context.issue.number;
|
|
46
|
+
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number });
|
|
47
|
+
const mine = comments.find((c) => c.body?.startsWith(marker));
|
|
48
|
+
if (mine) await github.rest.issues.updateComment({ owner, repo, comment_id: mine.id, body });
|
|
49
|
+
else await github.rest.issues.createComment({ owner, repo, issue_number, body });
|