agent-usage-tracker 0.1.0__py3-none-any.whl

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 (113) hide show
  1. agent_usage_tracker/__init__.py +8 -0
  2. agent_usage_tracker/backup.py +225 -0
  3. agent_usage_tracker/cli.py +479 -0
  4. agent_usage_tracker/collectors/__init__.py +115 -0
  5. agent_usage_tracker/collectors/_util.py +310 -0
  6. agent_usage_tracker/collectors/activity_common.py +294 -0
  7. agent_usage_tracker/collectors/activitywatch.py +394 -0
  8. agent_usage_tracker/collectors/claude_code.py +484 -0
  9. agent_usage_tracker/collectors/claude_code_activity.py +317 -0
  10. agent_usage_tracker/collectors/codex.py +612 -0
  11. agent_usage_tracker/collectors/commits.py +154 -0
  12. agent_usage_tracker/collectors/cursor.py +193 -0
  13. agent_usage_tracker/collectors/cursor_api.py +247 -0
  14. agent_usage_tracker/collectors/cursor_cli.py +592 -0
  15. agent_usage_tracker/collectors/cursor_sdk.py +95 -0
  16. agent_usage_tracker/collectors/generic_sdk.py +100 -0
  17. agent_usage_tracker/collectors/pi.py +397 -0
  18. agent_usage_tracker/collectors/session_digest.py +379 -0
  19. agent_usage_tracker/collectors/t3.py +490 -0
  20. agent_usage_tracker/config.py +392 -0
  21. agent_usage_tracker/coverage.py +615 -0
  22. agent_usage_tracker/coverage_catalog.json +588 -0
  23. agent_usage_tracker/cursor_run.py +62 -0
  24. agent_usage_tracker/diagnostics.py +74 -0
  25. agent_usage_tracker/episode_store.py +78 -0
  26. agent_usage_tracker/event.py +132 -0
  27. agent_usage_tracker/git_day_cache.py +128 -0
  28. agent_usage_tracker/git_days.py +499 -0
  29. agent_usage_tracker/git_safe.py +58 -0
  30. agent_usage_tracker/harness_inventory.py +208 -0
  31. agent_usage_tracker/history_steers.py +88 -0
  32. agent_usage_tracker/improve/__init__.py +1 -0
  33. agent_usage_tracker/improve/case_view.py +112 -0
  34. agent_usage_tracker/improve/cli.py +138 -0
  35. agent_usage_tracker/improve/desktop.py +347 -0
  36. agent_usage_tracker/improve/evidence.py +322 -0
  37. agent_usage_tracker/improve/judge.py +671 -0
  38. agent_usage_tracker/improve/proposals.py +72 -0
  39. agent_usage_tracker/improve/rubric.py +360 -0
  40. agent_usage_tracker/improve/rubrics/avoidable_recovery.md +20 -0
  41. agent_usage_tracker/improve/rubrics/code_quality.md +22 -0
  42. agent_usage_tracker/improve/rubrics/completion_supported.md +20 -0
  43. agent_usage_tracker/improve/rubrics/redundant_tests.md +21 -0
  44. agent_usage_tracker/improve/rubrics/verbosity.md +21 -0
  45. agent_usage_tracker/improve/runtime.py +117 -0
  46. agent_usage_tracker/improve/schedule.py +291 -0
  47. agent_usage_tracker/improve/search_check.py +563 -0
  48. agent_usage_tracker/improve/store.py +244 -0
  49. agent_usage_tracker/improve/studies.py +285 -0
  50. agent_usage_tracker/improve/study_cli.py +46 -0
  51. agent_usage_tracker/improve/study_decision.py +121 -0
  52. agent_usage_tracker/improve/study_followup.py +174 -0
  53. agent_usage_tracker/improve/t3.py +269 -0
  54. agent_usage_tracker/improve/trial.py +318 -0
  55. agent_usage_tracker/improve/validation.py +148 -0
  56. agent_usage_tracker/inspector.py +350 -0
  57. agent_usage_tracker/label/__init__.py +22 -0
  58. agent_usage_tracker/label/backends.py +742 -0
  59. agent_usage_tracker/label/bakeoff.py +661 -0
  60. agent_usage_tracker/label/baseline.py +173 -0
  61. agent_usage_tracker/label/clef.py +258 -0
  62. agent_usage_tracker/label/context.py +382 -0
  63. agent_usage_tracker/label/core.py +355 -0
  64. agent_usage_tracker/label/covered_run.py +92 -0
  65. agent_usage_tracker/label/evalset.py +154 -0
  66. agent_usage_tracker/label/gold.py +209 -0
  67. agent_usage_tracker/label/local.py +326 -0
  68. agent_usage_tracker/label/local_parallel.py +232 -0
  69. agent_usage_tracker/label/merge.py +57 -0
  70. agent_usage_tracker/label/outcome_coverage.py +57 -0
  71. agent_usage_tracker/label/replay.py +194 -0
  72. agent_usage_tracker/label/run.py +339 -0
  73. agent_usage_tracker/label/tasks.py +579 -0
  74. agent_usage_tracker/label/teach.py +145 -0
  75. agent_usage_tracker/local_page.py +128 -0
  76. agent_usage_tracker/manual_time.py +69 -0
  77. agent_usage_tracker/net.py +23 -0
  78. agent_usage_tracker/observation_cli.py +65 -0
  79. agent_usage_tracker/observation_report.py +116 -0
  80. agent_usage_tracker/observation_server.py +110 -0
  81. agent_usage_tracker/observations.py +365 -0
  82. agent_usage_tracker/outcome_git.py +383 -0
  83. agent_usage_tracker/outcomes.py +464 -0
  84. agent_usage_tracker/pricing.py +248 -0
  85. agent_usage_tracker/push.py +530 -0
  86. agent_usage_tracker/redact.py +45 -0
  87. agent_usage_tracker/repo_keys.py +165 -0
  88. agent_usage_tracker/review.py +252 -0
  89. agent_usage_tracker/scan.py +472 -0
  90. agent_usage_tracker/scheduled.py +164 -0
  91. agent_usage_tracker/sdk.py +79 -0
  92. agent_usage_tracker/sink.py +82 -0
  93. agent_usage_tracker/sink_stack/README.md +71 -0
  94. agent_usage_tracker/sink_stack/apply.sh +63 -0
  95. agent_usage_tracker/sink_stack/compose.yaml +94 -0
  96. agent_usage_tracker/sink_stack/env.example +20 -0
  97. agent_usage_tracker/sink_stack/grafana/dashboards/agents-effort.json +634 -0
  98. agent_usage_tracker/sink_stack/grafana/dashboards/agents-usage.json +1279 -0
  99. agent_usage_tracker/sink_stack/grafana/provisioning/dashboards/aut.yaml +9 -0
  100. agent_usage_tracker/sink_stack/grafana/provisioning/datasources/agents.yaml +16 -0
  101. agent_usage_tracker/sink_stack/sql/01_schema.sql +1186 -0
  102. agent_usage_tracker/sink_stack/sql/02_price.sql +60 -0
  103. agent_usage_tracker/sink_stack/sql/03_effort.sql +1180 -0
  104. agent_usage_tracker/sink_stack/sql/04_grants.sql +149 -0
  105. agent_usage_tracker/sink_stack/sql/refresh.sql +66 -0
  106. agent_usage_tracker/sources.py +180 -0
  107. agent_usage_tracker/state.py +191 -0
  108. agent_usage_tracker/telemetry.py +165 -0
  109. agent_usage_tracker-0.1.0.dist-info/METADATA +366 -0
  110. agent_usage_tracker-0.1.0.dist-info/RECORD +113 -0
  111. agent_usage_tracker-0.1.0.dist-info/WHEEL +4 -0
  112. agent_usage_tracker-0.1.0.dist-info/entry_points.txt +3 -0
  113. agent_usage_tracker-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,60 @@
1
+ -- agents.model_price — API-equivalent per-token USD rates for the Grafana "$" cost view.
2
+ --
3
+ -- Source: LiteLLM's model_prices_and_context_window.json (+ models.dev fallback), produced by
4
+ -- a price sync job. aut does not fill this table yet. Rates are NOTIONAL / API-equivalent — the
5
+ -- tracked coding-agent subscriptions are flat-rate, so this is "what the same tokens would cost
6
+ -- on metered APIs", never a real bill.
7
+ --
8
+ -- Apply this schema during database bootstrap, then let a price sync job
9
+ -- refresh canonical and observed alias rows.
10
+ --
11
+ -- A one-time load is not enough. Rates change slowly; the MODEL LIST does not. A new model
12
+ -- with no row joins to NULL and costs exactly $0 in the Grafana panels. A cost view that
13
+ -- silently under-reports is worse than one that is obviously empty, because the number
14
+ -- still looks like an answer.
15
+ --
16
+ -- A monitoring check should flag any model with >100M tokens in 7 days and no price row,
17
+ -- so the next new model surfaces instead of quietly costing nothing. The threshold is high
18
+ -- on purpose: junk labels (empty strings, "codex-auto-review", grok-bot-*) should not page.
19
+ -- UI display names ("GPT-5.6 Sol (Auto Intelligence)") are aliased onto the canonical
20
+ -- LiteLLM key. Cursor Composer 2.5 uses published list prices when LiteLLM has no row.
21
+ -- The detector still does not invent a rate for an unknown model.
22
+ --
23
+ -- Grafana ($ panels) reads this via the read-only agents_ro role; the SELECT grant below is
24
+ -- what lets the dashboard cost panels join usage rows to prices.
25
+
26
+ BEGIN;
27
+
28
+ CREATE TABLE IF NOT EXISTS agents.model_price (
29
+ model_key text PRIMARY KEY, -- normalized model id (lowercased, provider/version stripped)
30
+ input_cost numeric, -- USD per input (fresh) token
31
+ output_cost numeric, -- USD per output token
32
+ cache_read_cost numeric, -- USD per cache-read token (falls back to input_cost if null)
33
+ cache_write_cost numeric, -- USD per cache-write token (falls back to input_cost if null)
34
+ synced_at timestamptz NOT NULL DEFAULT now()
35
+ );
36
+
37
+ COMMENT ON TABLE agents.model_price IS
38
+ 'API-equivalent per-token USD rates (LiteLLM via aut sync-prices); NOTIONAL, subscriptions are flat-rate.';
39
+
40
+ -- Guarded like 01_schema.sql: agents_ro is created outside this file. This file is safe
41
+ -- to rerun, so the grant lands on the first run after the role exists.
42
+ DO $$
43
+ BEGIN
44
+ IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'agents_ro') THEN
45
+ GRANT SELECT ON agents.model_price TO agents_ro;
46
+ END IF;
47
+ END $$;
48
+
49
+ COMMIT;
50
+
51
+ -- Cost of one row (API-equivalent), used by the Grafana $ panels:
52
+ -- input_tokens*input_cost
53
+ -- + output_tokens*output_cost
54
+ -- + cache_read_tokens*coalesce(cache_read_cost, input_cost)
55
+ -- + cache_write_tokens*coalesce(cache_write_cost, input_cost)
56
+ -- reasoning_tokens is NOT added: it is a subset of output_tokens (Codex and Pi both report
57
+ -- reasoning <= output and a total that already excludes it), so pricing it again double-charges.
58
+ -- joined: agents.usage_event u JOIN agents.model_price p ON lower(u.model) = p.model_key
59
+ -- Unmatched models (e.g. some Cursor "-thinking" variants absent from LiteLLM) simply drop out
60
+ -- of the $ figure — never priced with a guess (mirrors the tracker's priced_coverage semantics).