tokenjam 0.3.0__tar.gz → 0.3.2__tar.gz

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 (271) hide show
  1. tokenjam-0.3.2/PKG-INFO +275 -0
  2. tokenjam-0.3.2/README.md +217 -0
  3. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/configuration.md +4 -4
  4. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/installation.md +2 -2
  5. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/optimize/cache.md +4 -4
  6. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/optimize/downsize.md +3 -3
  7. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/optimize/script.md +2 -2
  8. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/optimize/trim.md +7 -7
  9. tokenjam-0.3.2/docs/python-sdk.md +79 -0
  10. tokenjam-0.3.2/docs/typescript-sdk.md +73 -0
  11. {tokenjam-0.3.0 → tokenjam-0.3.2}/pricing/models.toml +16 -4
  12. {tokenjam-0.3.0 → tokenjam-0.3.2}/pyproject.toml +1 -1
  13. {tokenjam-0.3.0 → tokenjam-0.3.2}/sdk-ts/package.json +1 -1
  14. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/integration/test_cli.py +1 -1
  15. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/manual-new-release-tests.md +6 -6
  16. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/manual-pre-release-testing.md +15 -15
  17. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_cache_efficacy.py +4 -4
  18. tokenjam-0.3.2/tests/unit/test_cmd_tokenmaxx.py +97 -0
  19. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_cost.py +17 -2
  20. tokenjam-0.3.2/tests/unit/test_pricing_override.py +114 -0
  21. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_prompt_bloat.py +9 -9
  22. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_workflow_restructure.py +13 -13
  23. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/optimize.py +1 -1
  24. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_optimize.py +17 -19
  25. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_report.py +14 -14
  26. tokenjam-0.3.2/tokenjam/cli/cmd_tokenmaxx.py +270 -0
  27. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/main.py +2 -0
  28. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/export/claude_code.py +1 -1
  29. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/optimize/README.md +1 -1
  30. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/optimize/__init__.py +1 -1
  31. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/optimize/analyzers/budget_projection.py +1 -1
  32. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/optimize/analyzers/cache_efficacy.py +2 -2
  33. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/optimize/analyzers/model_downgrade.py +1 -1
  34. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/optimize/analyzers/prompt_bloat.py +7 -7
  35. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/optimize/analyzers/workflow_restructure.py +3 -3
  36. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/optimize/runner.py +9 -9
  37. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/optimize/types.py +4 -4
  38. tokenjam-0.3.2/tokenjam/core/pricing.py +135 -0
  39. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/mcp/server.py +2 -2
  40. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/pricing/models.toml +14 -8
  41. tokenjam-0.3.0/PKG-INFO +0 -699
  42. tokenjam-0.3.0/README.md +0 -641
  43. tokenjam-0.3.0/tokenjam/core/pricing.py +0 -72
  44. {tokenjam-0.3.0 → tokenjam-0.3.2}/.github/CODEOWNERS +0 -0
  45. {tokenjam-0.3.0 → tokenjam-0.3.2}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  46. {tokenjam-0.3.0 → tokenjam-0.3.2}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  47. {tokenjam-0.3.0 → tokenjam-0.3.2}/.github/ISSUE_TEMPLATE/integration_request.md +0 -0
  48. {tokenjam-0.3.0 → tokenjam-0.3.2}/.github/pull_request_template.md +0 -0
  49. {tokenjam-0.3.0 → tokenjam-0.3.2}/.github/workflows/ci.yml +0 -0
  50. {tokenjam-0.3.0 → tokenjam-0.3.2}/.github/workflows/publish-npm.yml +0 -0
  51. {tokenjam-0.3.0 → tokenjam-0.3.2}/.github/workflows/publish-pypi.yml +0 -0
  52. {tokenjam-0.3.0 → tokenjam-0.3.2}/.gitignore +0 -0
  53. {tokenjam-0.3.0 → tokenjam-0.3.2}/AGENTS.md +0 -0
  54. {tokenjam-0.3.0 → tokenjam-0.3.2}/CHANGELOG.md +0 -0
  55. {tokenjam-0.3.0 → tokenjam-0.3.2}/CLAUDE.md +0 -0
  56. {tokenjam-0.3.0 → tokenjam-0.3.2}/CONTRIBUTING.md +0 -0
  57. {tokenjam-0.3.0 → tokenjam-0.3.2}/LICENSE +0 -0
  58. {tokenjam-0.3.0 → tokenjam-0.3.2}/Makefile +0 -0
  59. {tokenjam-0.3.0 → tokenjam-0.3.2}/SECURITY.md +0 -0
  60. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/alerts.md +0 -0
  61. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/architecture.md +0 -0
  62. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/backfill/helicone.md +0 -0
  63. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/backfill/langfuse.md +0 -0
  64. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/backfill/otlp.md +0 -0
  65. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/backfill/overview.md +0 -0
  66. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/claude-code-integration.md +0 -0
  67. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/cli-reference.md +0 -0
  68. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/export.md +0 -0
  69. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/framework-support.md +0 -0
  70. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/internal/specs/.gitkeep +0 -0
  71. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/nemoclaw-integration.md +0 -0
  72. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/openclaw.md +0 -0
  73. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/policy/overview.md +0 -0
  74. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/screenshots/tj-alerts.png +0 -0
  75. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/screenshots/tj-budget.png +0 -0
  76. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/screenshots/tj-cost.png +0 -0
  77. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/screenshots/tj-status.png +0 -0
  78. {tokenjam-0.3.0 → tokenjam-0.3.2}/docs/screenshots/tj-traces.png +0 -0
  79. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/README.md +0 -0
  80. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/alerts_and_drift/_shared.py +0 -0
  81. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/alerts_and_drift/budget_breach_demo.py +0 -0
  82. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/alerts_and_drift/drift_demo.py +0 -0
  83. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/alerts_and_drift/sensitive_actions_demo.py +0 -0
  84. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/multi/rag_pipeline.py +0 -0
  85. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/multi/research_team.py +0 -0
  86. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/multi/router_agent.py +0 -0
  87. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/multi/sample_docs/agent_patterns.txt +0 -0
  88. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/multi/sample_docs/cost_management.txt +0 -0
  89. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/multi/sample_docs/observability.txt +0 -0
  90. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/multi/sample_docs/safety.txt +0 -0
  91. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/openclaw/README.md +0 -0
  92. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/single_framework/autogen_agent.py +0 -0
  93. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/single_framework/crewai_agent.py +0 -0
  94. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/single_framework/langchain_agent.py +0 -0
  95. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/single_framework/langgraph_agent.py +0 -0
  96. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/single_framework/llamaindex_agent.py +0 -0
  97. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/single_provider/anthropic_agent.py +0 -0
  98. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/single_provider/bedrock_agent.py +0 -0
  99. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/single_provider/gemini_agent.py +0 -0
  100. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/single_provider/litellm_agent.py +0 -0
  101. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/single_provider/openai_agent.py +0 -0
  102. {tokenjam-0.3.0 → tokenjam-0.3.2}/examples/single_provider/openai_agents_sdk_agent.py +0 -0
  103. {tokenjam-0.3.0 → tokenjam-0.3.2}/incidents/hallucination-drift/BLOG.md +0 -0
  104. {tokenjam-0.3.0 → tokenjam-0.3.2}/incidents/hallucination-drift/README.md +0 -0
  105. {tokenjam-0.3.0 → tokenjam-0.3.2}/incidents/hallucination-drift/scenario.py +0 -0
  106. {tokenjam-0.3.0 → tokenjam-0.3.2}/incidents/retry-loop/BLOG.md +0 -0
  107. {tokenjam-0.3.0 → tokenjam-0.3.2}/incidents/retry-loop/README.md +0 -0
  108. {tokenjam-0.3.0 → tokenjam-0.3.2}/incidents/retry-loop/scenario.py +0 -0
  109. {tokenjam-0.3.0 → tokenjam-0.3.2}/incidents/surprise-cost/BLOG.md +0 -0
  110. {tokenjam-0.3.0 → tokenjam-0.3.2}/incidents/surprise-cost/README.md +0 -0
  111. {tokenjam-0.3.0 → tokenjam-0.3.2}/incidents/surprise-cost/scenario.py +0 -0
  112. {tokenjam-0.3.0 → tokenjam-0.3.2}/sdk-ts/README.md +0 -0
  113. {tokenjam-0.3.0 → tokenjam-0.3.2}/sdk-ts/package-lock.json +0 -0
  114. {tokenjam-0.3.0 → tokenjam-0.3.2}/sdk-ts/src/client.test.ts +0 -0
  115. {tokenjam-0.3.0 → tokenjam-0.3.2}/sdk-ts/src/client.ts +0 -0
  116. {tokenjam-0.3.0 → tokenjam-0.3.2}/sdk-ts/src/index.ts +0 -0
  117. {tokenjam-0.3.0 → tokenjam-0.3.2}/sdk-ts/src/semconv.test.ts +0 -0
  118. {tokenjam-0.3.0 → tokenjam-0.3.2}/sdk-ts/src/semconv.ts +0 -0
  119. {tokenjam-0.3.0 → tokenjam-0.3.2}/sdk-ts/src/span-builder.test.ts +0 -0
  120. {tokenjam-0.3.0 → tokenjam-0.3.2}/sdk-ts/src/span-builder.ts +0 -0
  121. {tokenjam-0.3.0 → tokenjam-0.3.2}/sdk-ts/src/types.ts +0 -0
  122. {tokenjam-0.3.0 → tokenjam-0.3.2}/sdk-ts/tsconfig.json +0 -0
  123. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/__init__.py +0 -0
  124. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/agents/__init__.py +0 -0
  125. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/agents/email_agent_budget_breach.py +0 -0
  126. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/agents/email_agent_drift.py +0 -0
  127. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/agents/email_agent_loop.py +0 -0
  128. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/agents/email_agent_normal.py +0 -0
  129. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/agents/mock_llm.py +0 -0
  130. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/agents/test_mock_scenarios.py +0 -0
  131. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/conftest.py +0 -0
  132. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/e2e/__init__.py +0 -0
  133. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/e2e/conftest.py +0 -0
  134. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/e2e/test_real_llm.py +0 -0
  135. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/factories.py +0 -0
  136. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/fixtures/helicone_real_response.json +0 -0
  137. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/fixtures/langfuse_real_response.json +0 -0
  138. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/fixtures/otlp_sample.json +0 -0
  139. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/integration/__init__.py +0 -0
  140. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/integration/test_api.py +0 -0
  141. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/integration/test_db.py +0 -0
  142. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/integration/test_demos.py +0 -0
  143. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/integration/test_full_pipeline.py +0 -0
  144. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/integration/test_logs_api.py +0 -0
  145. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/synthetic/__init__.py +0 -0
  146. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/synthetic/test_alert_rules.py +0 -0
  147. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/synthetic/test_cost_tracking.py +0 -0
  148. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/synthetic/test_drift_detection.py +0 -0
  149. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/synthetic/test_ingest.py +0 -0
  150. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/synthetic/test_schema_validation.py +0 -0
  151. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/toy_agent/toy_agent.py +0 -0
  152. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/__init__.py +0 -0
  153. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_alerts.py +0 -0
  154. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_backfill.py +0 -0
  155. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_cache_recommend.py +0 -0
  156. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_cmd_policy.py +0 -0
  157. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_cmd_stop.py +0 -0
  158. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_compare.py +0 -0
  159. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_config.py +0 -0
  160. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_config_secret_divergence.py +0 -0
  161. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_demo_env.py +0 -0
  162. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_demo_scenarios.py +0 -0
  163. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_drift.py +0 -0
  164. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_export_claude_code.py +0 -0
  165. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_formatting.py +0 -0
  166. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_ingest_helicone.py +0 -0
  167. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_ingest_langfuse.py +0 -0
  168. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_ingest_otlp.py +0 -0
  169. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_litellm_client.py +0 -0
  170. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_litellm_integration.py +0 -0
  171. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_logs_converter.py +0 -0
  172. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_mcp_server.py +0 -0
  173. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_models.py +0 -0
  174. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_onboard_codex.py +0 -0
  175. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_onboard_daemon.py +0 -0
  176. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_openclaw_ingest.py +0 -0
  177. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_optimize.py +0 -0
  178. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_spans_stats_repair.py +0 -0
  179. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_time_parse.py +0 -0
  180. {tokenjam-0.3.0 → tokenjam-0.3.2}/tests/unit/test_transport_401.py +0 -0
  181. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/__init__.py +0 -0
  182. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/__init__.py +0 -0
  183. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/app.py +0 -0
  184. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/deps.py +0 -0
  185. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/middleware.py +0 -0
  186. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/__init__.py +0 -0
  187. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/agents.py +0 -0
  188. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/alerts.py +0 -0
  189. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/budget.py +0 -0
  190. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/cost.py +0 -0
  191. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/cost_compare.py +0 -0
  192. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/drift.py +0 -0
  193. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/logs.py +0 -0
  194. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/metrics.py +0 -0
  195. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/otlp.py +0 -0
  196. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/spans.py +0 -0
  197. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/status.py +0 -0
  198. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/tools.py +0 -0
  199. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/api/routes/traces.py +0 -0
  200. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/__init__.py +0 -0
  201. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_alerts.py +0 -0
  202. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_backfill.py +0 -0
  203. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_budget.py +0 -0
  204. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_cost.py +0 -0
  205. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_demo.py +0 -0
  206. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_doctor.py +0 -0
  207. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_drift.py +0 -0
  208. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_export.py +0 -0
  209. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_mcp.py +0 -0
  210. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_onboard.py +0 -0
  211. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_policy.py +0 -0
  212. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_serve.py +0 -0
  213. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_status.py +0 -0
  214. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_stop.py +0 -0
  215. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_tools.py +0 -0
  216. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_traces.py +0 -0
  217. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/cli/cmd_uninstall.py +0 -0
  218. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/__init__.py +0 -0
  219. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/alerts.py +0 -0
  220. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/api_backend.py +0 -0
  221. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/backfill.py +0 -0
  222. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/config.py +0 -0
  223. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/cost.py +0 -0
  224. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/db.py +0 -0
  225. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/drift.py +0 -0
  226. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/export/__init__.py +0 -0
  227. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/ingest.py +0 -0
  228. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/ingest_adapters/__init__.py +0 -0
  229. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/ingest_adapters/helicone.py +0 -0
  230. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/ingest_adapters/langfuse.py +0 -0
  231. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/ingest_adapters/otlp.py +0 -0
  232. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/models.py +0 -0
  233. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/optimize/analyzers/__init__.py +0 -0
  234. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/optimize/analyzers/cache_recommend.py +0 -0
  235. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/optimize/registry.py +0 -0
  236. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/retention.py +0 -0
  237. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/core/schema_validator.py +0 -0
  238. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/demo/__init__.py +0 -0
  239. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/demo/env.py +0 -0
  240. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/mcp/__init__.py +0 -0
  241. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/otel/__init__.py +0 -0
  242. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/otel/exporters.py +0 -0
  243. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/otel/otlp_parsing.py +0 -0
  244. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/otel/provider.py +0 -0
  245. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/otel/semconv.py +0 -0
  246. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/py.typed +0 -0
  247. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/__init__.py +0 -0
  248. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/agent.py +0 -0
  249. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/bootstrap.py +0 -0
  250. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/client.py +0 -0
  251. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/http_exporter.py +0 -0
  252. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/__init__.py +0 -0
  253. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/anthropic.py +0 -0
  254. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/autogen.py +0 -0
  255. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/base.py +0 -0
  256. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/bedrock.py +0 -0
  257. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/crewai.py +0 -0
  258. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/gemini.py +0 -0
  259. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/langchain.py +0 -0
  260. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/langgraph.py +0 -0
  261. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/litellm.py +0 -0
  262. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/llamaindex.py +0 -0
  263. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/nemoclaw.py +0 -0
  264. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/openai.py +0 -0
  265. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/integrations/openai_agents_sdk.py +0 -0
  266. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/sdk/transport.py +0 -0
  267. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/ui/index.html +0 -0
  268. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/utils/__init__.py +0 -0
  269. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/utils/formatting.py +0 -0
  270. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/utils/ids.py +0 -0
  271. {tokenjam-0.3.0 → tokenjam-0.3.2}/tokenjam/utils/time_parse.py +0 -0
@@ -0,0 +1,275 @@
1
+ Metadata-Version: 2.4
2
+ Name: tokenjam
3
+ Version: 0.3.2
4
+ Summary: TokenJam — local-first OTel-native observability for Autonomous AI agents
5
+ Project-URL: Homepage, https://opencla.watch
6
+ Project-URL: Repository, https://github.com/Metabuilder-Labs/openclawwatch
7
+ Project-URL: Issues, https://github.com/Metabuilder-Labs/openclawwatch/issues
8
+ Author-email: Anil Murty <anil@metabldr.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: agents,ai,llm,observability,opentelemetry
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Classifier: Topic :: System :: Monitoring
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: apscheduler>=3.10
23
+ Requires-Dist: click>=8.1
24
+ Requires-Dist: duckdb>=0.10
25
+ Requires-Dist: fastapi>=0.110
26
+ Requires-Dist: genson>=1.2
27
+ Requires-Dist: httpx>=0.27
28
+ Requires-Dist: jsonschema>=4.0
29
+ Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.25
30
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.25
31
+ Requires-Dist: opentelemetry-exporter-prometheus>=0.46b0
32
+ Requires-Dist: opentelemetry-sdk>=1.25
33
+ Requires-Dist: pytz>=2024.1
34
+ Requires-Dist: rich>=13.0
35
+ Requires-Dist: tomli-w>=1.0
36
+ Requires-Dist: tomli>=2.0; python_version < '3.11'
37
+ Requires-Dist: uvicorn>=0.27
38
+ Requires-Dist: websockets>=12.0
39
+ Provides-Extra: autogen
40
+ Requires-Dist: pyautogen>=0.2; extra == 'autogen'
41
+ Provides-Extra: bloat
42
+ Requires-Dist: llmlingua>=0.2; extra == 'bloat'
43
+ Provides-Extra: crewai
44
+ Requires-Dist: crewai>=0.28; extra == 'crewai'
45
+ Provides-Extra: dev
46
+ Requires-Dist: httpx; extra == 'dev'
47
+ Requires-Dist: mypy; extra == 'dev'
48
+ Requires-Dist: pytest; extra == 'dev'
49
+ Requires-Dist: pytest-asyncio; extra == 'dev'
50
+ Requires-Dist: ruff; extra == 'dev'
51
+ Provides-Extra: langchain
52
+ Requires-Dist: langchain>=0.2; extra == 'langchain'
53
+ Provides-Extra: litellm
54
+ Requires-Dist: litellm>=1.40; extra == 'litellm'
55
+ Provides-Extra: mcp
56
+ Requires-Dist: fastmcp; extra == 'mcp'
57
+ Description-Content-Type: text/markdown
58
+
59
+ <div align="center">
60
+
61
+ <img src="https://tokenjam.dev/icon.svg" alt="TokenJam" width="72" height="72">
62
+
63
+ # TokenJam
64
+
65
+ ### Token Efficiency For AI Agents
66
+
67
+ TokenJam reads your agent's telemetry and tells you when to downsize, when to trim prompts, what to cache, and what to script. The result is a lower AI bill. Runs entirely on your machine.
68
+
69
+ [![CI](https://github.com/Metabuilder-Labs/tokenjam/actions/workflows/ci.yml/badge.svg)](https://github.com/Metabuilder-Labs/tokenjam/actions/workflows/ci.yml)
70
+ [![PyPI](https://img.shields.io/pypi/v/tokenjam?color=3d8eff&labelColor=0d1117)](https://pypi.org/project/tokenjam/)
71
+ [![Python](https://img.shields.io/badge/python-3.10%2B-3d8eff?labelColor=0d1117)](https://pypi.org/project/tokenjam/)
72
+ [![npm](https://img.shields.io/npm/v/@tokenjam/sdk?color=3d8eff&labelColor=0d1117)](https://www.npmjs.com/package/@tokenjam/sdk)
73
+ [![License: MIT](https://img.shields.io/badge/license-MIT-3d8eff?labelColor=0d1117)](LICENSE)
74
+ [![OTel](https://img.shields.io/badge/OTel-GenAI%20SemConv-3d8eff?labelColor=0d1117)](https://opentelemetry.io/docs/specs/semconv/gen-ai/)
75
+
76
+ ```
77
+ pip install tokenjam
78
+ ```
79
+
80
+ **No cloud · No signup · No vendor lock-in**
81
+
82
+ </div>
83
+
84
+ ---
85
+
86
+ ## Four Analyzers. One Install.
87
+
88
+ TokenJam reads telemetry from every major agent runtime, framework, provider, and observability tool and surfaces savings across four areas.
89
+
90
+ <table>
91
+ <tr>
92
+ <td width="50%" valign="top">
93
+
94
+ ### 🪶 Downsize
95
+
96
+ Flags sessions where a cheaper model in the same family is worth a look. Never claims quality equivalence — surfaces examples so you can spot-check.
97
+
98
+ <pre><code>tj optimize downsize</code></pre>
99
+
100
+ [Details →](docs/optimize/downsize.md)
101
+
102
+ </td>
103
+ <td width="50%" valign="top">
104
+
105
+ ### 💾 Cache
106
+
107
+ Shows your current caching ratio per (provider, model) and suggests Anthropic prompt-cache breakpoints from stable prefixes in your real usage.
108
+
109
+ <pre><code>tj optimize cache</code></pre>
110
+
111
+ [Details →](docs/optimize/cache.md)
112
+
113
+ </td>
114
+ </tr>
115
+ <tr>
116
+ <td width="50%" valign="top">
117
+
118
+ ### 📜 Script
119
+
120
+ Finds clusters of deterministic `(tool_name, arg_shape)` sequences that match the shape of work a plain script could replace.
121
+
122
+ <pre><code>tj optimize script</code></pre>
123
+
124
+ [Details →](docs/optimize/script.md)
125
+
126
+ </td>
127
+ <td width="50%" valign="top">
128
+
129
+ ### ✂️ Trim
130
+
131
+ Predicts which regions of your prompts the model gives little weight to. Surfaces what's safe to cut.
132
+
133
+ <pre><code>tj optimize trim</code></pre>
134
+
135
+ [Details →](docs/optimize/trim.md)
136
+
137
+ </td>
138
+ </tr>
139
+ </table>
140
+
141
+ Run all four with `tj optimize`. Run several with `tj optimize downsize cache trim`.
142
+
143
+ ---
144
+
145
+ ## 30-second quickstart
146
+
147
+ For **Claude Code** users — zero code, auto-backfills your last 30 days:
148
+
149
+ ```bash
150
+ pip install "tokenjam[mcp]"
151
+ tj onboard --claude-code
152
+ tj optimize # cost-saving candidates from your actual usage
153
+ ```
154
+
155
+ For any Python agent:
156
+
157
+ ```python
158
+ from tokenjam.sdk import watch
159
+ from tokenjam.sdk.integrations.anthropic import patch_anthropic
160
+
161
+ patch_anthropic()
162
+
163
+ @watch(agent_id="my-agent")
164
+ def run(task: str) -> str:
165
+ ...
166
+ ```
167
+
168
+ → [Python SDK](docs/python-sdk.md) · [TypeScript SDK](docs/typescript-sdk.md) · [Codex](docs/claude-code-integration.md#codex) · [OTel-compatible agents](docs/framework-support.md)
169
+
170
+ ---
171
+
172
+ ## Why local-first matters
173
+
174
+ Your spans contain prompts, completions, tool inputs, and customer data. Shipping that to a SaaS vendor for "observability" is a data-egress decision most teams aren't ready to make.
175
+
176
+ | | TokenJam | LangSmith | Langfuse | Datadog LLM Obs |
177
+ |---|---|---|---|---|
178
+ | Signup required | ❌ | ✅ | ✅ | ✅ |
179
+ | Data leaves your machine | ❌ | ✅ | cloud only | ✅ |
180
+ | Cost-optimization analyzers (Downsize, Cache, Script, Trim) | ✅ | ❌ | ❌ | ❌ |
181
+ | Real-time sensitive-action alerts | ✅ | ❌ | ❌ | ❌ |
182
+ | Behavioral drift detection | ✅ | ❌ | ❌ | ❌ |
183
+ | OTel GenAI SemConv native | ✅ | partial | partial | partial |
184
+ | Works with any agent / framework | ✅ | LangChain-first | partial | ❌ |
185
+ | Free, MIT licensed | ✅ | freemium | freemium | paid |
186
+
187
+ ---
188
+
189
+ ## Web UI
190
+
191
+ `tj serve` runs a local dashboard at `http://127.0.0.1:7391/` with status, traces, cost breakdown, alerts, budget, and drift.
192
+
193
+ <table>
194
+ <tr>
195
+ <td width="50%"><img src="docs/screenshots/tj-status.png" alt="tj status page" /></td>
196
+ <td width="50%"><img src="docs/screenshots/tj-cost.png" alt="tj cost page" /></td>
197
+ </tr>
198
+ <tr>
199
+ <td width="50%"><img src="docs/screenshots/tj-traces.png" alt="tj traces page" /></td>
200
+ <td width="50%"><img src="docs/screenshots/tj-alerts.png" alt="tj alerts page" /></td>
201
+ </tr>
202
+ </table>
203
+
204
+ ---
205
+
206
+ ## Beyond optimization
207
+
208
+ TokenJam is also a full observability stack. The four analyzers ride on top.
209
+
210
+ - **Real-time cost tracking** — every LLM call priced as it happens
211
+ - **Safety alerts** — 13 alert types, 6 channels (ntfy, Discord, Telegram, webhook, file, stdout)
212
+ - **Behavioral drift detection** — Z-score baselines, no LLM required
213
+ - **Schema validation** — declare or infer JSON Schema for tool outputs
214
+ - **OTel-native** — point any OTLP exporter at `tj serve` and you're done
215
+ - **MCP server** — 14 tools letting Claude Code query its own telemetry mid-session
216
+
217
+ ---
218
+
219
+ ## CLI
220
+
221
+ ```bash
222
+ tj optimize # all four cost-optimization analyzers
223
+ tj optimize downsize # one analyzer
224
+ tj status # current cost, tokens, active alerts
225
+ tj cost --since 7d # spend by agent / model / day / tool
226
+ tj alerts # everything that fired while you were away
227
+ tj drift # behavioral drift Z-scores
228
+ tj backfill claude-code # ingest historical ~/.claude/projects/ sessions
229
+ tj serve # start the web UI + REST API
230
+ ```
231
+
232
+ [Full CLI reference →](docs/cli-reference.md)
233
+
234
+ ---
235
+
236
+ ## Documentation
237
+
238
+ | Topic | Where |
239
+ |---|---|
240
+ | 🪶 Downsize / Cache / Script / Trim deep-dives | [docs/optimize/](docs/optimize/) |
241
+ | Claude Code & Codex integration | [docs/claude-code-integration.md](docs/claude-code-integration.md) |
242
+ | Python SDK reference | [docs/python-sdk.md](docs/python-sdk.md) |
243
+ | TypeScript SDK reference | [docs/typescript-sdk.md](docs/typescript-sdk.md) |
244
+ | Framework support (LangChain / CrewAI / etc.) | [docs/framework-support.md](docs/framework-support.md) |
245
+ | Alert channels & rule reference | [docs/alerts.md](docs/alerts.md) |
246
+ | Backfill from Langfuse / Helicone / OTLP | [docs/backfill/](docs/backfill/) |
247
+ | Configuration | [docs/configuration.md](docs/configuration.md) |
248
+ | Architecture deep-dive | [docs/architecture.md](docs/architecture.md) |
249
+ | Installation extras (Trim, framework patches) | [docs/installation.md](docs/installation.md) |
250
+ | Export to Grafana / Datadog / NDJSON | [docs/export.md](docs/export.md) |
251
+ | NemoClaw sandbox observer | [docs/nemoclaw-integration.md](docs/nemoclaw-integration.md) |
252
+
253
+ ---
254
+
255
+ ## Roadmap
256
+
257
+ **Shipped in 0.3.x:** Downsize · Cache · Script · Trim · Claude Code + Codex onboarding · MCP server · Web UI · Backfill adapters (Langfuse, Helicone, OTLP) · Period comparison · Routing-config export · Read-only policy preview
258
+
259
+ **Up next:**
260
+ - [ ] `tj policy add | edit | apply` — unified rule surface
261
+ - [ ] `tj replay` — replay captured sessions against new model versions
262
+ - [ ] TypeScript framework patches (LangChain JS, OpenAI Agents SDK)
263
+ - [ ] Vercel AI SDK & Mastra integrations
264
+ - [ ] Docker image
265
+ - [ ] GitHub Actions for CI drift/cost checks
266
+
267
+ ---
268
+
269
+ <div align="center">
270
+
271
+ **[tokenjam.dev](https://tokenjam.dev)** · [PyPI](https://pypi.org/project/tokenjam/) · [npm](https://www.npmjs.com/package/@tokenjam/sdk) · [Issues](https://github.com/Metabuilder-Labs/tokenjam/issues)
272
+
273
+ MIT License · Built by [Metabuilder Labs](https://github.com/Metabuilder-Labs)
274
+
275
+ </div>
@@ -0,0 +1,217 @@
1
+ <div align="center">
2
+
3
+ <img src="https://tokenjam.dev/icon.svg" alt="TokenJam" width="72" height="72">
4
+
5
+ # TokenJam
6
+
7
+ ### Token Efficiency For AI Agents
8
+
9
+ TokenJam reads your agent's telemetry and tells you when to downsize, when to trim prompts, what to cache, and what to script. The result is a lower AI bill. Runs entirely on your machine.
10
+
11
+ [![CI](https://github.com/Metabuilder-Labs/tokenjam/actions/workflows/ci.yml/badge.svg)](https://github.com/Metabuilder-Labs/tokenjam/actions/workflows/ci.yml)
12
+ [![PyPI](https://img.shields.io/pypi/v/tokenjam?color=3d8eff&labelColor=0d1117)](https://pypi.org/project/tokenjam/)
13
+ [![Python](https://img.shields.io/badge/python-3.10%2B-3d8eff?labelColor=0d1117)](https://pypi.org/project/tokenjam/)
14
+ [![npm](https://img.shields.io/npm/v/@tokenjam/sdk?color=3d8eff&labelColor=0d1117)](https://www.npmjs.com/package/@tokenjam/sdk)
15
+ [![License: MIT](https://img.shields.io/badge/license-MIT-3d8eff?labelColor=0d1117)](LICENSE)
16
+ [![OTel](https://img.shields.io/badge/OTel-GenAI%20SemConv-3d8eff?labelColor=0d1117)](https://opentelemetry.io/docs/specs/semconv/gen-ai/)
17
+
18
+ ```
19
+ pip install tokenjam
20
+ ```
21
+
22
+ **No cloud · No signup · No vendor lock-in**
23
+
24
+ </div>
25
+
26
+ ---
27
+
28
+ ## Four Analyzers. One Install.
29
+
30
+ TokenJam reads telemetry from every major agent runtime, framework, provider, and observability tool and surfaces savings across four areas.
31
+
32
+ <table>
33
+ <tr>
34
+ <td width="50%" valign="top">
35
+
36
+ ### 🪶 Downsize
37
+
38
+ Flags sessions where a cheaper model in the same family is worth a look. Never claims quality equivalence — surfaces examples so you can spot-check.
39
+
40
+ <pre><code>tj optimize downsize</code></pre>
41
+
42
+ [Details →](docs/optimize/downsize.md)
43
+
44
+ </td>
45
+ <td width="50%" valign="top">
46
+
47
+ ### 💾 Cache
48
+
49
+ Shows your current caching ratio per (provider, model) and suggests Anthropic prompt-cache breakpoints from stable prefixes in your real usage.
50
+
51
+ <pre><code>tj optimize cache</code></pre>
52
+
53
+ [Details →](docs/optimize/cache.md)
54
+
55
+ </td>
56
+ </tr>
57
+ <tr>
58
+ <td width="50%" valign="top">
59
+
60
+ ### 📜 Script
61
+
62
+ Finds clusters of deterministic `(tool_name, arg_shape)` sequences that match the shape of work a plain script could replace.
63
+
64
+ <pre><code>tj optimize script</code></pre>
65
+
66
+ [Details →](docs/optimize/script.md)
67
+
68
+ </td>
69
+ <td width="50%" valign="top">
70
+
71
+ ### ✂️ Trim
72
+
73
+ Predicts which regions of your prompts the model gives little weight to. Surfaces what's safe to cut.
74
+
75
+ <pre><code>tj optimize trim</code></pre>
76
+
77
+ [Details →](docs/optimize/trim.md)
78
+
79
+ </td>
80
+ </tr>
81
+ </table>
82
+
83
+ Run all four with `tj optimize`. Run several with `tj optimize downsize cache trim`.
84
+
85
+ ---
86
+
87
+ ## 30-second quickstart
88
+
89
+ For **Claude Code** users — zero code, auto-backfills your last 30 days:
90
+
91
+ ```bash
92
+ pip install "tokenjam[mcp]"
93
+ tj onboard --claude-code
94
+ tj optimize # cost-saving candidates from your actual usage
95
+ ```
96
+
97
+ For any Python agent:
98
+
99
+ ```python
100
+ from tokenjam.sdk import watch
101
+ from tokenjam.sdk.integrations.anthropic import patch_anthropic
102
+
103
+ patch_anthropic()
104
+
105
+ @watch(agent_id="my-agent")
106
+ def run(task: str) -> str:
107
+ ...
108
+ ```
109
+
110
+ → [Python SDK](docs/python-sdk.md) · [TypeScript SDK](docs/typescript-sdk.md) · [Codex](docs/claude-code-integration.md#codex) · [OTel-compatible agents](docs/framework-support.md)
111
+
112
+ ---
113
+
114
+ ## Why local-first matters
115
+
116
+ Your spans contain prompts, completions, tool inputs, and customer data. Shipping that to a SaaS vendor for "observability" is a data-egress decision most teams aren't ready to make.
117
+
118
+ | | TokenJam | LangSmith | Langfuse | Datadog LLM Obs |
119
+ |---|---|---|---|---|
120
+ | Signup required | ❌ | ✅ | ✅ | ✅ |
121
+ | Data leaves your machine | ❌ | ✅ | cloud only | ✅ |
122
+ | Cost-optimization analyzers (Downsize, Cache, Script, Trim) | ✅ | ❌ | ❌ | ❌ |
123
+ | Real-time sensitive-action alerts | ✅ | ❌ | ❌ | ❌ |
124
+ | Behavioral drift detection | ✅ | ❌ | ❌ | ❌ |
125
+ | OTel GenAI SemConv native | ✅ | partial | partial | partial |
126
+ | Works with any agent / framework | ✅ | LangChain-first | partial | ❌ |
127
+ | Free, MIT licensed | ✅ | freemium | freemium | paid |
128
+
129
+ ---
130
+
131
+ ## Web UI
132
+
133
+ `tj serve` runs a local dashboard at `http://127.0.0.1:7391/` with status, traces, cost breakdown, alerts, budget, and drift.
134
+
135
+ <table>
136
+ <tr>
137
+ <td width="50%"><img src="docs/screenshots/tj-status.png" alt="tj status page" /></td>
138
+ <td width="50%"><img src="docs/screenshots/tj-cost.png" alt="tj cost page" /></td>
139
+ </tr>
140
+ <tr>
141
+ <td width="50%"><img src="docs/screenshots/tj-traces.png" alt="tj traces page" /></td>
142
+ <td width="50%"><img src="docs/screenshots/tj-alerts.png" alt="tj alerts page" /></td>
143
+ </tr>
144
+ </table>
145
+
146
+ ---
147
+
148
+ ## Beyond optimization
149
+
150
+ TokenJam is also a full observability stack. The four analyzers ride on top.
151
+
152
+ - **Real-time cost tracking** — every LLM call priced as it happens
153
+ - **Safety alerts** — 13 alert types, 6 channels (ntfy, Discord, Telegram, webhook, file, stdout)
154
+ - **Behavioral drift detection** — Z-score baselines, no LLM required
155
+ - **Schema validation** — declare or infer JSON Schema for tool outputs
156
+ - **OTel-native** — point any OTLP exporter at `tj serve` and you're done
157
+ - **MCP server** — 14 tools letting Claude Code query its own telemetry mid-session
158
+
159
+ ---
160
+
161
+ ## CLI
162
+
163
+ ```bash
164
+ tj optimize # all four cost-optimization analyzers
165
+ tj optimize downsize # one analyzer
166
+ tj status # current cost, tokens, active alerts
167
+ tj cost --since 7d # spend by agent / model / day / tool
168
+ tj alerts # everything that fired while you were away
169
+ tj drift # behavioral drift Z-scores
170
+ tj backfill claude-code # ingest historical ~/.claude/projects/ sessions
171
+ tj serve # start the web UI + REST API
172
+ ```
173
+
174
+ [Full CLI reference →](docs/cli-reference.md)
175
+
176
+ ---
177
+
178
+ ## Documentation
179
+
180
+ | Topic | Where |
181
+ |---|---|
182
+ | 🪶 Downsize / Cache / Script / Trim deep-dives | [docs/optimize/](docs/optimize/) |
183
+ | Claude Code & Codex integration | [docs/claude-code-integration.md](docs/claude-code-integration.md) |
184
+ | Python SDK reference | [docs/python-sdk.md](docs/python-sdk.md) |
185
+ | TypeScript SDK reference | [docs/typescript-sdk.md](docs/typescript-sdk.md) |
186
+ | Framework support (LangChain / CrewAI / etc.) | [docs/framework-support.md](docs/framework-support.md) |
187
+ | Alert channels & rule reference | [docs/alerts.md](docs/alerts.md) |
188
+ | Backfill from Langfuse / Helicone / OTLP | [docs/backfill/](docs/backfill/) |
189
+ | Configuration | [docs/configuration.md](docs/configuration.md) |
190
+ | Architecture deep-dive | [docs/architecture.md](docs/architecture.md) |
191
+ | Installation extras (Trim, framework patches) | [docs/installation.md](docs/installation.md) |
192
+ | Export to Grafana / Datadog / NDJSON | [docs/export.md](docs/export.md) |
193
+ | NemoClaw sandbox observer | [docs/nemoclaw-integration.md](docs/nemoclaw-integration.md) |
194
+
195
+ ---
196
+
197
+ ## Roadmap
198
+
199
+ **Shipped in 0.3.x:** Downsize · Cache · Script · Trim · Claude Code + Codex onboarding · MCP server · Web UI · Backfill adapters (Langfuse, Helicone, OTLP) · Period comparison · Routing-config export · Read-only policy preview
200
+
201
+ **Up next:**
202
+ - [ ] `tj policy add | edit | apply` — unified rule surface
203
+ - [ ] `tj replay` — replay captured sessions against new model versions
204
+ - [ ] TypeScript framework patches (LangChain JS, OpenAI Agents SDK)
205
+ - [ ] Vercel AI SDK & Mastra integrations
206
+ - [ ] Docker image
207
+ - [ ] GitHub Actions for CI drift/cost checks
208
+
209
+ ---
210
+
211
+ <div align="center">
212
+
213
+ **[tokenjam.dev](https://tokenjam.dev)** · [PyPI](https://pypi.org/project/tokenjam/) · [npm](https://www.npmjs.com/package/@tokenjam/sdk) · [Issues](https://github.com/Metabuilder-Labs/tokenjam/issues)
214
+
215
+ MIT License · Built by [Metabuilder Labs](https://github.com/Metabuilder-Labs)
216
+
217
+ </div>
@@ -90,7 +90,7 @@ Set limits via CLI (`tj budget --daily 10`), the REST API (`POST /api/v1/budget`
90
90
 
91
91
  ## Content capture and privacy
92
92
 
93
- By default, `tj` does not capture prompt content, completion content, or tool inputs/outputs — only token counts, model names, tool names, timestamps, and structural metadata. Enable content capture selectively when you need it (for debugging, prompt-bloat analysis, or evaluation):
93
+ By default, `tj` does not capture prompt content, completion content, or tool inputs/outputs — only token counts, model names, tool names, timestamps, and structural metadata. Enable content capture selectively when you need it (for debugging, trim analysis, or evaluation):
94
94
 
95
95
  ```toml
96
96
  [capture]
@@ -108,9 +108,9 @@ The four flags are independent: capture prompts without completions, or tool inp
108
108
 
109
109
  **What this means for downstream analyzers.**
110
110
 
111
- - `tj optimize --finding cache-efficacy` reads token-count fields and works without content capture.
112
- - `tj optimize --finding prompt-bloat` reads prompt text and requires `capture.prompts = true`.
113
- - `tj optimize --finding cache-recommend` reads prompts and requires `capture.prompts = true`.
111
+ - `tj optimize cache` reads token-count fields and works without content capture.
112
+ - `tj optimize trim` reads prompt text and requires `capture.prompts = true`.
113
+ - `tj optimize cache-recommend` reads prompts and requires `capture.prompts = true`.
114
114
 
115
115
  The analyzers that need content fail with a clear message ("set `capture.prompts = true` in tj.toml and let the daemon collect a fresh window of data") rather than running on partial data.
116
116
 
@@ -27,7 +27,7 @@ TokenJam keeps heavyweight ML dependencies, framework adapters, and the MCP serv
27
27
  | Extra | What it pulls in | Why it's optional |
28
28
  |---|---|---|
29
29
  | `tokenjam[mcp]` | `fastmcp` | Only needed for the Claude Code / Codex MCP server (`tj mcp`). Pulled by `tj onboard --claude-code` automatically when invoked through the documented one-liner. |
30
- | `tokenjam[bloat]` | `llmlingua>=0.2`, transitively PyTorch + transformers (~2GB) | The Trim analyzer (`tj optimize --finding prompt-bloat`) scores token significance with LLMLingua-2. Most users don't run it; keeping torch out of the base install means `pip install tokenjam` stays small and fast on machines that don't have a GPU/CPU build of torch already. |
30
+ | `tokenjam[bloat]` | `llmlingua>=0.2`, transitively PyTorch + transformers (~2GB) | The Trim analyzer (`tj optimize trim`) scores token significance with LLMLingua-2. Most users don't run it; keeping torch out of the base install means `pip install tokenjam` stays small and fast on machines that don't have a GPU/CPU build of torch already. |
31
31
  | `tokenjam[langchain]` | `langchain>=0.2` | Convenience pin for `patch_langchain()`; you can also install langchain yourself. |
32
32
  | `tokenjam[crewai]` | `crewai>=0.28` | Convenience pin for `patch_crewai()`. |
33
33
  | `tokenjam[autogen]` | `pyautogen>=0.2` | Convenience pin for `patch_autogen()`. |
@@ -44,7 +44,7 @@ pip install "tokenjam[mcp,bloat]"
44
44
 
45
45
  `tokenjam[bloat]` is the largest extra — LLMLingua-2 transitively pulls in PyTorch and Hugging Face transformers, roughly 2GB on disk. On first run the analyzer downloads a ~110MB BERT-class classifier model under `~/.cache/tokenjam/models/` (override via `TOKENJAM_MODEL_CACHE`); subsequent runs are offline-capable.
46
46
 
47
- If you run `tj optimize --finding prompt-bloat` without the extra installed, the analyzer self-registers and exits with a clear hint pointing at this install command — nothing in the base install crashes from its absence.
47
+ If you run `tj optimize trim` without the extra installed, the analyzer self-registers and exits with a clear hint pointing at this install command — nothing in the base install crashes from its absence.
48
48
 
49
49
  See [`docs/optimize/trim.md`](optimize/trim.md) for performance numbers, capture requirements, and what the analyzer actually reports.
50
50
 
@@ -1,13 +1,13 @@
1
1
  # Cache
2
2
 
3
- Product name: **Cache**. Internal/CLI names: `cache-efficacy` and `cache-recommend`. Two related findings under the same product — both surface prompt-caching opportunities; they differ in what they need and what they recommend.
3
+ Product name: **Cache**. Internal/CLI names: `cache` and `cache-recommend`. Two related findings under the same product — both surface prompt-caching opportunities; they differ in what they need and what they recommend.
4
4
 
5
5
  ```bash
6
- tj optimize --finding cache-efficacy
7
- tj optimize --finding cache-recommend
6
+ tj optimize cache
7
+ tj optimize cache-recommend
8
8
  ```
9
9
 
10
- ## `cache-efficacy` — measure current caching
10
+ ## `cache` — measure current caching
11
11
 
12
12
  Reads aggregate `input_tokens` and `cache_tokens` from spans in the
13
13
  window. Computes the share of input bytes served from cache per
@@ -1,9 +1,9 @@
1
1
  # Downsize
2
2
 
3
- Product name: **Downsize**. Internal/CLI name: `model-downgrade`.
3
+ Product name: **Downsize**. Internal/CLI name: `downsize`.
4
4
 
5
5
  ```bash
6
- tj optimize --finding model-downgrade
6
+ tj optimize downsize
7
7
  ```
8
8
 
9
9
  Flags sessions whose structural shape — short input (< 5K tokens), short output (< 500 tokens), few tool calls (≤ 5) — matches a class of work where a cheaper model in the same provider family is worth reviewing.
@@ -37,7 +37,7 @@ JSON output mirrors the same data with top-level `plan` and `pricing_mode` field
37
37
 
38
38
  ## Confidence
39
39
 
40
- `structural`. The model-downgrade finding identifies a structural pattern in the captured data; it does not validate that the cheaper model would produce equivalent output. The mandatory caveat is the honest framing of that limitation.
40
+ `structural`. The downsize finding identifies a structural pattern in the captured data; it does not validate that the cheaper model would produce equivalent output. The mandatory caveat is the honest framing of that limitation.
41
41
 
42
42
  ## See also
43
43
 
@@ -1,9 +1,9 @@
1
1
  # Script
2
2
 
3
- Product name: **Script**. Internal/CLI name: `workflow-restructure`.
3
+ Product name: **Script**. Internal/CLI name: `script`.
4
4
 
5
5
  ```bash
6
- tj optimize --finding workflow-restructure
6
+ tj optimize script
7
7
  ```
8
8
 
9
9
  Flags sessions whose tool-call sequence is structurally identical
@@ -1,9 +1,9 @@
1
1
  # Trim
2
2
 
3
- Product name: **Trim**. Internal/CLI name: `prompt-bloat`.
3
+ Product name: **Trim**. Internal/CLI name: `trim`.
4
4
 
5
5
  ```bash
6
- tj optimize --finding prompt-bloat
6
+ tj optimize trim
7
7
  ```
8
8
 
9
9
  Scores token-by-token significance in captured prompts using
@@ -26,7 +26,7 @@ pip install "tokenjam[bloat]"
26
26
  ```
27
27
 
28
28
  The base `pip install tokenjam` does NOT pull torch. Trim shows up in
29
- `tj optimize --finding` choices regardless, but running it without the
29
+ `tj optimize` analyzer choices regardless, but running it without the
30
30
  extra prints a clear install hint and exits.
31
31
 
32
32
  ## Requirements
@@ -56,10 +56,10 @@ marked.
56
56
  ## HTML report
57
57
 
58
58
  ```bash
59
- tj report --bloat # all agents, 30d window
60
- tj report --bloat my-agent # scope to one agent
61
- tj report --bloat --since 7d # custom window
62
- tj report --bloat --no-open # write file without opening browser
59
+ tj report --trim # all agents, 30d window
60
+ tj report --trim my-agent # scope to one agent
61
+ tj report --trim --since 7d # custom window
62
+ tj report --trim --no-open # write file without opening browser
63
63
  ```
64
64
 
65
65
  Output goes to `~/.cache/tokenjam/reports/trim-<timestamp>.html` and