agentacct 0.1.0__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 (111) hide show
  1. agentacct-0.1.0/LICENSE +21 -0
  2. agentacct-0.1.0/MANIFEST.in +7 -0
  3. agentacct-0.1.0/PKG-INFO +497 -0
  4. agentacct-0.1.0/README.md +463 -0
  5. agentacct-0.1.0/pyproject.toml +81 -0
  6. agentacct-0.1.0/setup.cfg +4 -0
  7. agentacct-0.1.0/src/agent_chronicle/__init__.py +0 -0
  8. agentacct-0.1.0/src/agent_chronicle/activation.py +993 -0
  9. agentacct-0.1.0/src/agent_chronicle/agent_capabilities.py +801 -0
  10. agentacct-0.1.0/src/agent_chronicle/agent_loop.py +131 -0
  11. agentacct-0.1.0/src/agent_chronicle/agent_smoke.py +173 -0
  12. agentacct-0.1.0/src/agent_chronicle/api.py +15284 -0
  13. agentacct-0.1.0/src/agent_chronicle/autostart.py +389 -0
  14. agentacct-0.1.0/src/agent_chronicle/canonical/__init__.py +127 -0
  15. agentacct-0.1.0/src/agent_chronicle/canonical/benchmark.py +1230 -0
  16. agentacct-0.1.0/src/agent_chronicle/canonical/cutover.py +2602 -0
  17. agentacct-0.1.0/src/agent_chronicle/canonical/lane_inventory.py +173 -0
  18. agentacct-0.1.0/src/agent_chronicle/canonical/legacy_import.py +1529 -0
  19. agentacct-0.1.0/src/agent_chronicle/canonical/legacy_recovery.py +1083 -0
  20. agentacct-0.1.0/src/agent_chronicle/canonical/live_paths.py +119 -0
  21. agentacct-0.1.0/src/agent_chronicle/canonical/migration_archive.py +1790 -0
  22. agentacct-0.1.0/src/agent_chronicle/canonical/migration_disposition_policy.py +167 -0
  23. agentacct-0.1.0/src/agent_chronicle/canonical/product_parity.py +2404 -0
  24. agentacct-0.1.0/src/agent_chronicle/canonical/read_canary.py +1122 -0
  25. agentacct-0.1.0/src/agent_chronicle/canonical/repository.py +129 -0
  26. agentacct-0.1.0/src/agent_chronicle/canonical/safe_scratch.py +335 -0
  27. agentacct-0.1.0/src/agent_chronicle/canonical/schema.sql +549 -0
  28. agentacct-0.1.0/src/agent_chronicle/canonical/snapshot.py +1261 -0
  29. agentacct-0.1.0/src/agent_chronicle/canonical/sqlite.py +3664 -0
  30. agentacct-0.1.0/src/agent_chronicle/canonical/types.py +511 -0
  31. agentacct-0.1.0/src/agent_chronicle/canonical/unsupported_legacy_routing.py +276 -0
  32. agentacct-0.1.0/src/agent_chronicle/canonical/v1_events.py +369 -0
  33. agentacct-0.1.0/src/agent_chronicle/canonical_day_cube.py +358 -0
  34. agentacct-0.1.0/src/agent_chronicle/canonical_live.py +923 -0
  35. agentacct-0.1.0/src/agent_chronicle/canonical_read.py +693 -0
  36. agentacct-0.1.0/src/agent_chronicle/capture/__init__.py +38 -0
  37. agentacct-0.1.0/src/agent_chronicle/capture/adapters.py +899 -0
  38. agentacct-0.1.0/src/agent_chronicle/capture/base.py +328 -0
  39. agentacct-0.1.0/src/agent_chronicle/capture/manifests.py +247 -0
  40. agentacct-0.1.0/src/agent_chronicle/capture/registry.py +139 -0
  41. agentacct-0.1.0/src/agent_chronicle/capture/service.py +233 -0
  42. agentacct-0.1.0/src/agent_chronicle/capture_runtime.py +107 -0
  43. agentacct-0.1.0/src/agent_chronicle/cli.py +8121 -0
  44. agentacct-0.1.0/src/agent_chronicle/client_usage.py +7822 -0
  45. agentacct-0.1.0/src/agent_chronicle/confidence.py +46 -0
  46. agentacct-0.1.0/src/agent_chronicle/connector_runtime.py +134 -0
  47. agentacct-0.1.0/src/agent_chronicle/connectors/__init__.py +47 -0
  48. agentacct-0.1.0/src/agent_chronicle/connectors/base.py +355 -0
  49. agentacct-0.1.0/src/agent_chronicle/connectors/control.py +344 -0
  50. agentacct-0.1.0/src/agent_chronicle/connectors/entire.py +378 -0
  51. agentacct-0.1.0/src/agent_chronicle/connectors/openlit.py +483 -0
  52. agentacct-0.1.0/src/agent_chronicle/connectors/paperclip.py +319 -0
  53. agentacct-0.1.0/src/agent_chronicle/connectors/registry.py +44 -0
  54. agentacct-0.1.0/src/agent_chronicle/context_bridge.py +555 -0
  55. agentacct-0.1.0/src/agent_chronicle/control_plane.py +2661 -0
  56. agentacct-0.1.0/src/agent_chronicle/control_web.py +359 -0
  57. agentacct-0.1.0/src/agent_chronicle/cost.py +870 -0
  58. agentacct-0.1.0/src/agent_chronicle/deep_provider_validation.py +189 -0
  59. agentacct-0.1.0/src/agent_chronicle/env_compat.py +48 -0
  60. agentacct-0.1.0/src/agent_chronicle/evidence.py +1236 -0
  61. agentacct-0.1.0/src/agent_chronicle/evidence_html.py +684 -0
  62. agentacct-0.1.0/src/agent_chronicle/evidence_product.py +1031 -0
  63. agentacct-0.1.0/src/agent_chronicle/evidence_rebuild_activation.py +2539 -0
  64. agentacct-0.1.0/src/agent_chronicle/evidence_rebuild_candidate.py +2798 -0
  65. agentacct-0.1.0/src/agent_chronicle/evidence_rebuild_snapshot.py +1840 -0
  66. agentacct-0.1.0/src/agent_chronicle/evidence_runtime.py +744 -0
  67. agentacct-0.1.0/src/agent_chronicle/evidence_store.py +2704 -0
  68. agentacct-0.1.0/src/agent_chronicle/finding_disposition.py +358 -0
  69. agentacct-0.1.0/src/agent_chronicle/hooks.py +1330 -0
  70. agentacct-0.1.0/src/agent_chronicle/ingestion_health.py +1429 -0
  71. agentacct-0.1.0/src/agent_chronicle/install_guide.py +616 -0
  72. agentacct-0.1.0/src/agent_chronicle/join_rules.py +632 -0
  73. agentacct-0.1.0/src/agent_chronicle/localhost_guard.py +175 -0
  74. agentacct-0.1.0/src/agent_chronicle/log_evidence.py +991 -0
  75. agentacct-0.1.0/src/agent_chronicle/mcp.py +1589 -0
  76. agentacct-0.1.0/src/agent_chronicle/mcp_client_smoke.py +271 -0
  77. agentacct-0.1.0/src/agent_chronicle/mechanical_checks.py +184 -0
  78. agentacct-0.1.0/src/agent_chronicle/outcome.py +361 -0
  79. agentacct-0.1.0/src/agent_chronicle/platform_support.py +28 -0
  80. agentacct-0.1.0/src/agent_chronicle/policy.py +126 -0
  81. agentacct-0.1.0/src/agent_chronicle/pricing_catalog.py +525 -0
  82. agentacct-0.1.0/src/agent_chronicle/provider_smoke.py +222 -0
  83. agentacct-0.1.0/src/agent_chronicle/proxy.py +418 -0
  84. agentacct-0.1.0/src/agent_chronicle/refreshable_usage.py +683 -0
  85. agentacct-0.1.0/src/agent_chronicle/reports.py +130 -0
  86. agentacct-0.1.0/src/agent_chronicle/runner.py +357 -0
  87. agentacct-0.1.0/src/agent_chronicle/service.py +1789 -0
  88. agentacct-0.1.0/src/agent_chronicle/session_observations.py +431 -0
  89. agentacct-0.1.0/src/agent_chronicle/source_discovery.py +543 -0
  90. agentacct-0.1.0/src/agent_chronicle/source_paths.py +141 -0
  91. agentacct-0.1.0/src/agent_chronicle/source_policy.py +455 -0
  92. agentacct-0.1.0/src/agent_chronicle/storage.py +268 -0
  93. agentacct-0.1.0/src/agent_chronicle/store_merge.py +520 -0
  94. agentacct-0.1.0/src/agent_chronicle/store_resolution.py +259 -0
  95. agentacct-0.1.0/src/agent_chronicle/supervisor.py +1177 -0
  96. agentacct-0.1.0/src/agent_chronicle/task_continuations.py +976 -0
  97. agentacct-0.1.0/src/agent_chronicle/task_identity.py +141 -0
  98. agentacct-0.1.0/src/agent_chronicle/task_intelligence.py +463 -0
  99. agentacct-0.1.0/src/agent_chronicle/task_outcome.py +327 -0
  100. agentacct-0.1.0/src/agent_chronicle/task_projection.py +1016 -0
  101. agentacct-0.1.0/src/agent_chronicle/usage_cube.py +547 -0
  102. agentacct-0.1.0/src/agent_chronicle/usage_truth.py +1229 -0
  103. agentacct-0.1.0/src/agent_chronicle/work_events.py +302 -0
  104. agentacct-0.1.0/src/agent_chronicle/work_ledger.py +4667 -0
  105. agentacct-0.1.0/src/agent_chronicle/wrappers.py +204 -0
  106. agentacct-0.1.0/src/agentacct.egg-info/PKG-INFO +497 -0
  107. agentacct-0.1.0/src/agentacct.egg-info/SOURCES.txt +109 -0
  108. agentacct-0.1.0/src/agentacct.egg-info/dependency_links.txt +1 -0
  109. agentacct-0.1.0/src/agentacct.egg-info/entry_points.txt +4 -0
  110. agentacct-0.1.0/src/agentacct.egg-info/requires.txt +8 -0
  111. agentacct-0.1.0/src/agentacct.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Agent Chronicle contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ # The sdist ships the package source, not the test suite: setuptools' default
2
+ # file list would include tests/test_*.py but NOT tests/conftest.py (the
3
+ # autouse store pin + real-store byte-tripwire) or examples/ (which one test
4
+ # imports) — an uncollectable suite with the store-safety net stripped.
5
+ # The repo is the test suite's home.
6
+ prune tests
7
+ prune examples
@@ -0,0 +1,497 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentacct
3
+ Version: 0.1.0
4
+ Summary: Local-first Agent Work Intelligence for coding agents: usage truth, recorded work, and honest joins
5
+ Author: mikehasa
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/mikehasa/agentacct
8
+ Project-URL: Repository, https://github.com/mikehasa/agentacct
9
+ Project-URL: Issues, https://github.com/mikehasa/agentacct/issues
10
+ Keywords: agent,ai-agents,finops,llm,cost-tracking,claude-code,codex,mcp,developer-tools
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development
20
+ Classifier: Topic :: Software Development :: Quality Assurance
21
+ Classifier: Topic :: System :: Monitoring
22
+ Requires-Python: >=3.11
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: typer>=0.12
26
+ Requires-Dist: rich>=13
27
+ Requires-Dist: psutil>=5
28
+ Requires-Dist: pydantic>=2
29
+ Requires-Dist: fastapi>=0.115
30
+ Requires-Dist: httpx>=0.27
31
+ Requires-Dist: PyYAML>=6.0
32
+ Requires-Dist: uvicorn>=0.30
33
+ Dynamic: license-file
34
+
35
+ # agentacct
36
+
37
+ Local-first Agent Work Intelligence for coding agents: usage truth, recorded work, and honest joins.
38
+
39
+ agentacct is local-first Agent Work Intelligence for coding agents:
40
+
41
+ - a usage ledger of client-reported tokens, imported from the coding agent's own local session files;
42
+ - an MCP work context: sections and events the agent records while working, joined to usage with honest confidence labels;
43
+ - an additive Evidence v2 store that keeps native hooks, OTLP spans, MCP claims, orchestrator snapshots, Git checkpoints, and provider evidence separate by source and authority;
44
+ - a Task Intelligence dashboard that turns those records into an evidence-backed decision brief;
45
+ - a managed local runtime for continuous usage sync and the dashboard.
46
+
47
+ Client logs are the usage truth. Recorded sections and events are the work meaning. The product is the join between the two: every attribution carries a confidence label, and a missing attribution always beats a wrong one.
48
+
49
+ > **Status:** early alpha, local-first. Working today: one-command project onboarding for Claude Code and Codex; live-observed local usage paths for Claude Code, Codex, and the bounded Hermes `state.db` scope; experimental synthetic-fixture import paths for OpenCode exports and OpenClaw JSONL; a single-version-live-observed, observation-only Cursor primary `state.vscdb` path; MCP work context; metadata-only Claude Code/Codex/Cursor payload normalization into Evidence v2 when manually wired; mechanical-only Session/Task projection with observed models and recognized checks; local OTLP ingestion; read-only Paperclip/OpenLIT/Entire connectors; local evidence views; and an opt-in control plane limited to agentacct-owned local processes. Generic mechanical capture is not installed by onboarding, does not provide token/cost truth, and does not invent work meaning. Activation remains an explicit project-local action. Interfaces may change.
50
+
51
+ ## What works today
52
+
53
+ - Join imported usage to recorded work with labeled confidence (`exact`/`high`/`medium`/`low`); when agentacct cannot prove a link, the dashboard shows a dash instead of a guess.
54
+ - Record work sections and machine checks from any MCP-capable agent (`sentinel_record_section`, `sentinel_record_machine_check`) and roll them up into attributed sessions and work items on the dashboard's Sessions page.
55
+ - Capture real Claude Code session/transcript ids with the installed hook bridge (at session start and on every tool call) — high-confidence join keys; exact attribution still requires ids explicitly authored on the recording call.
56
+ - Import client-reported token usage through the declared per-agent paths. Claude Code/Codex and bounded Hermes usage have live local evidence; OpenCode export and OpenClaw JSONL paths remain experimental and synthetic-fixture verified. Inspect `agentacct capabilities agents --json` or **Advanced → Agent capability coverage** for exact scope and limitations.
57
+ - Connect a project with `agentacct onboard`, then keep continuous local usage sync and the dashboard alive independently of the invoking shell.
58
+ - Open a Task decision brief with independent execution, outcome, and control state plus a bounded evidence timeline.
59
+ - Browse everything on a local dashboard/API at `127.0.0.1`: detected local sources, usage, events, sections, and attribution rollups.
60
+ - Record local events from the CLI, API, or MCP tools.
61
+ - Inspect the Work Graph, Evidence Matrix, Discrepancies, and Cost & Outcome Basis without collapsing claims into observations.
62
+
63
+ ## What it does not claim yet
64
+
65
+ - No hosted dashboard or phone-home telemetry. agentacct can receive telemetry locally when you explicitly point an OTLP exporter at it.
66
+ - No automatic cloud account sync.
67
+ - No exact Claude Code/Codex subscription invoice access.
68
+ - No silent monitoring of unrelated processes started outside agentacct/integrations.
69
+ - No universal process control: hard stops apply only to agentacct-owned runs or the opt-in proxy path (see Optional enforcement extras below).
70
+
71
+ ## Safety defaults
72
+
73
+ - Local-first state; no phone-home telemetry.
74
+ - Provider API keys are not stored by agentacct and must come from environment variables.
75
+ - Observe-only setup does not require provider API keys.
76
+ - Dashboard/API bind to localhost by default.
77
+ - Provider forwarding is disabled by default and requires an explicit budget cap; agentacct only pauses/kills processes it launched and recorded as agentacct-owned.
78
+
79
+ ## What “telemetry” means here
80
+
81
+ Telemetry is machine-emitted evidence about a running agent: for example a session start, a tool span, a trace/span id, a model label, a duration, or a client-reported token field. OpenTelemetry/OTLP is one standard wire format for those records; OpenLIT instruments runtimes and exports that format.
82
+
83
+ It is not the same thing as MCP. MCP is an agent-to-tool protocol and is especially useful for semantic claims such as “I started this task”, “this section is complete”, or “this blocker occurred”. A native hook is a host callback that fires mechanically. A local client log is the client's own persisted usage/session record. agentacct accepts all four, keeps their provenance, and decides authority per evidence dimension. OTLP arriving locally is not automatically provider billing truth, and a missing MCP event does not mean no work happened.
84
+
85
+ ## Install
86
+
87
+ Requires Python >= 3.11 on macOS or Linux; Windows is supported only via WSL.
88
+
89
+ The fastest path is to paste this into the coding agent working in your target repo:
90
+
91
+ ```text
92
+ Install and set up agentacct in this repo — a local-first dashboard that reads my
93
+ coding-agent logs read-only and shows honest token usage and cost.
94
+
95
+ Run `pipx install agentacct`
96
+ (or `pipx install git+https://github.com/mikehasa/agentacct`),
97
+ then `agentacct onboard` from this repo root, then tell me the dashboard URL.
98
+
99
+ Observe-only: never store, request, or echo any API key; all state stays local
100
+ under `.agent-sentinel/`. Don't modify my global client config without showing
101
+ the exact command first.
102
+ ```
103
+
104
+ The agent then follows [INSTALL.md](INSTALL.md), the canonical runbook with the public install path, an advanced manual fallback, and an honest per-client capability matrix. `agentacct setup prompt --agent <client>` prints this same prompt as a single line; add `--full` for a self-contained prompt.
105
+
106
+ Preferred CLI path, no agent involved. Install the CLI, then run onboarding from the target repo root:
107
+
108
+ ```bash
109
+ pipx install agentacct
110
+ # or, straight from the public repository:
111
+ # pipx install git+https://github.com/mikehasa/agentacct
112
+ agentacct onboard
113
+ agentacct status
114
+ ```
115
+
116
+ `onboard` detects a known local client source, initializes the project-local store and recording configuration, performs one real local usage sync, and starts continuous sync plus the dashboard. Detection means data is present on this machine; it is not a whole-client support badge. It does not request provider keys, connect to a billing account, or modify global client settings. Then open a **NEW** agent session in this project: MCP servers and hooks bind when the client session starts, so the session that ran onboarding cannot become the first recorded Task.
117
+
118
+ The managed runtime has an idempotent lifecycle:
119
+
120
+ ```bash
121
+ agentacct start # start continuous sync and the dashboard
122
+ agentacct status # inspect dashboard, sync, and ingestion readiness
123
+ agentacct stop # stop only processes agentacct can prove it owns
124
+ agentacct repair # clear dead/corrupt owned runtime state safely
125
+ ```
126
+
127
+ The default dashboard is `http://127.0.0.1:8765`. `status`, `stop`, and `repair` use the same project-local store; they refuse to treat an unknown process as agentacct-owned.
128
+
129
+ Advanced manual setup fallback. Use this when client auto-detection is unavailable or you need to configure each integration separately:
130
+
131
+ ```bash
132
+ # Codex (see INSTALL.md for Hermes/OpenCode/OpenClaw):
133
+ agentacct init --agent codex --write-mcp
134
+ agentacct doctor
135
+
136
+ # Claude Code — the hook bridge is the attribution keystone:
137
+ agentacct init --agent claude-code --write-mcp
138
+ agentacct hooks claude-code install
139
+ # then merge BOTH the "hooks" and "env" blocks (including ENABLE_TOOL_SEARCH=auto)
140
+ # from .claude/settings.agent-sentinel.example.json into .claude/settings.local.json
141
+ agentacct hooks claude-code doctor
142
+
143
+ # Either client:
144
+ agentacct mcp doctor
145
+ agentacct serve
146
+ ```
147
+
148
+ agentacct state is project-local under `.agent-sentinel/` (gitignored; the store directory keeps the pre-rename name `.agent-sentinel/` for compatibility with existing stores). Observe-only setup does not require provider API keys and does not connect to billing APIs. The new-session requirement applies to both onboarding paths.
149
+
150
+ Optional zero-key demo — `agentacct demo` alone uses a throwaway temp store; after `init`, keep demo runs in the project store and browse them:
151
+
152
+ ```bash
153
+ agentacct init
154
+ agentacct demo --store-dir .agent-sentinel/state
155
+ agentacct report latest
156
+ agentacct serve
157
+ ```
158
+
159
+ Open:
160
+
161
+ ```text
162
+ http://127.0.0.1:8765
163
+ ```
164
+
165
+ The demo uses only local commands. It does not require provider API keys and does not make paid API calls.
166
+
167
+ ## Task Intelligence
168
+
169
+ The top-level product object is a Task, not an individual event or sub-run. A recognized root client session creates the default observed Task boundary; explicitly linked continuation sessions can remain part of the same Task. Public routes use a stable opaque Task id rather than exposing a raw client session id:
170
+
171
+ ```text
172
+ http://127.0.0.1:8765/tasks/task_<opaque-id>
173
+ http://127.0.0.1:8765/api/tasks/task_<opaque-id>
174
+ ```
175
+
176
+ The Task page leads with a decision brief: what was attempted, the current outcome, the strongest proof, usage/cost basis, unresolved findings, and a next action only when an owner was actually recorded. The evidence timeline is available underneath for inspection.
177
+
178
+ Task status is deliberately split into three independent axes:
179
+
180
+ - **Execution:** whether an attempt is queued, running, finished, cancelled, or lost.
181
+ - **Outcome:** whether the result is unknown, agent-reported, verified, blocked, or has an open finding.
182
+ - **Control:** whether agentacct is ready, awaiting approval, holding on policy, or encountered a control failure.
183
+
184
+ This keeps a failed target-product check from being mislabeled as a agentacct failure or automatically turned into a user action. See [Task Intelligence and the local control plane](docs/task-control-plane.md) for the contract.
185
+
186
+ ## Local Control
187
+
188
+ The **Control** page is a separate, opt-in surface for processes agentacct itself launches. It does not adopt or signal an existing Codex, Claude Code, Paperclip, OpenLIT, Entire, or other orchestrator process. Normal agent sessions remain observed on **Work**.
189
+
190
+ Register one explicit workspace and one fixed argv adapter, then create a reviewable Task Contract:
191
+
192
+ ```bash
193
+ agentacct control register-workspace \
194
+ --store-dir .agent-sentinel/state --root . --workspace-id project
195
+
196
+ agentacct control register-agent \
197
+ --store-dir .agent-sentinel/state \
198
+ --agent-id local-agent --display-name "Local agent" \
199
+ --argv-json '["/absolute/command","arg"]'
200
+
201
+ agentacct control plan \
202
+ --store-dir .agent-sentinel/state \
203
+ --objective "Run the bounded local task" \
204
+ --workspace-id project --agent-id local-agent \
205
+ --permission-envelope-json '{"mutation_mode":"read_only"}' \
206
+ --success-check "the owned process exits successfully"
207
+ ```
208
+
209
+ Open `http://127.0.0.1:8765/control` to review pending attempts, independent execution/outcome/control state, approvals, budgets, and schedules. Nothing launches when a contract is created. The dashboard keeps a persistent local supervisor while it is running; the CLI `control launch` command deliberately supervises in the foreground instead of pretending a one-shot shell command is a daemon.
210
+
211
+ Every mutation uses an idempotency key and expected revision. Workspace-write attempts created in the web UI follow `hold → request → approve → consume once → ready`; the supervisor refuses `awaiting_approval`, `policy_hold`, and `control_failure` attempts. Each attempt also freezes the registered agent revision, so changing that agent's argv after approval cannot change what the approval authorizes: create a new attempt for the new revision. Product JSON omits registered paths, argv, PIDs/process groups, executable/cwd fingerprints, manifest ids, and ownership nonces.
212
+
213
+ ## Migration from the pre-rename install
214
+
215
+ agentacct was formerly Agent Sentinel. Existing installs keep working without re-setup:
216
+
217
+ - Environment variables: every `AGENT_CHRONICLE_*` variable accepts its pre-rename `AGENT_SENTINEL_*` alias — the old names are accepted indefinitely, the new name wins when both are set, and conflicting store-dir values refuse rather than silently split the ledger. There is no runtime deprecation nag; the old names simply keep working.
218
+ - Binaries: the published package ships only agentacct-branded console scripts — `agentacct` plus the `agentacct-claude` / `agentacct-codex` wrappers. Pre-rename MCP registrations, hook wrappers, and launchd jobs that resolve the old `agent-chronicle` / `agent-sentinel` binary names are still recognized at runtime, but the old console scripts are no longer shipped (they collide with unrelated PyPI packages of those names).
219
+ - Stored data and the `.agent-sentinel/` store directory keep their pre-rename spellings forever; they are data format, not branding.
220
+ - Caveat — foreign PyPI package collision: an unrelated project named `agent-sentinel` (0.5.0) exists on PyPI and also installs a `bin/agent-sentinel` script. Installing both packages into the same environment makes the later install silently overwrite that script (pip prints no warning), and `pip uninstall agent-sentinel` (the foreign package) deletes the alias out from under agentacct — anything resolving the old binary name dies until `pip install --force-reinstall agentacct`. Avoid installing both in one environment; pipx refuses the second install outright because the app names collide.
221
+
222
+ ## How the join works
223
+
224
+ agentacct keeps two evidence streams separate and joins them on real client ids instead of guessing:
225
+
226
+ - **Usage truth** comes from the client's own local session files: imported tokens are labeled `client_reported`, and costs are pricing-table estimates — never provider invoices.
227
+ - **Work meaning** comes from the sections and events the agent records over MCP while it works.
228
+ - **The join** links the two through session/transcript ids and labels every attribution `exact`, `high`, `medium`, or `low`. Missing attribution beats wrong attribution: when the ids do not prove a link, the dashboard shows the gap instead of inventing one.
229
+
230
+ Per client, the join keys arrive differently:
231
+
232
+ - **Claude Code** — the installed hook bridge captures real session/transcript ids at session start and on every tool call. Recorded work context needs the full three-lever settings merge: the SessionStart hook entry delivers the record-your-work directive, `ENABLE_TOOL_SEARCH=auto` in the settings `env` block makes the agentacct tools arrive directly callable (without it they stay deferred and un-primed sessions record nothing), and the hook itself supplies the join ids.
233
+ - **Codex** — the client cannot pass its own session id in-session. At usage import, agentacct pairs each agentacct-recorded event with the Codex session log that created it (client-log evidence): high confidence, never `exact`, and a section evidenced by more than one session links to none.
234
+ - **Everywhere** — inherited ids are never `exact`; only ids passed explicitly on the recording call earn `exact`.
235
+
236
+ ## What each client can claim
237
+
238
+ <!-- Consistency contract: the capability matrix below is defined in
239
+ src/agent_chronicle/install_guide.py and embedded here verbatim, exactly as
240
+ in INSTALL.md. tests/test_install_guide.py fails if this list drifts. -->
241
+
242
+ - Claude Code: automatic high-confidence joins between usage and recorded work via the installed hook bridge (SessionStart and PreToolUse capture real session/transcript ids). Exact attribution still requires ids authored explicitly on the recording call; hook-derived ids are not bound to that MCP request. Recorded work context needs all three levers: the merged hooks settings entry including SessionStart (delivery — the SessionStart hook is the only path proven to make un-primed sessions record work, and it adds session-start/resume id capture; PreToolUse still captures the session/transcript ids on every tool call), `ENABLE_TOOL_SEARCH=auto` in the settings `env` block (discoverability — without it the agentacct tools stay deferred and un-primed sessions record nothing), and the hook bridge itself (join keys — without it recorded sections fall back to project-level context, never session-linked).
243
+ - Codex: session-linked work context via client-log evidence (high) — at usage import, agentacct pairs each agentacct-recorded event with the Codex session log that created it (creation responses only, never read-tool echoes). Sections still never earn `exact` (the link is evidenced from the log at import time, not client-authored in-session), a section evidenced by more than one session links to none, and sessions whose rollouts have not been imported fall back to project-level context only.
244
+ - Hermes: local `state.db` usage import plus a manual MCP registration preview; agentacct does not yet install Hermes mechanical hooks.
245
+ - OpenCode: captured/exported JSON usage import plus a manual MCP registration preview; agentacct does not yet parse the current official SQLite store or install a realtime plugin.
246
+ - OpenClaw: local JSONL usage import plus a manual MCP registration preview; agentacct does not yet join `sessions.json` routing metadata or install typed plugin hooks.
247
+ - Cursor: the primary `User/globalStorage/state.vscdb` can produce observation-only composer sessions through an explicit local import/refresh. It never emits usage or cost, never scans backups or ai-tracking stores, and onboarding does not install or activate it. Metadata-only hook payload normalization remains a separate manual primitive.
248
+ - Generic MCP clients: recorded work context only unless a separate trusted usage importer exists; join confidence depends on ids the client actually exposes.
249
+ - Mechanical Claude Code/Codex/Cursor capture, when manually wired, writes Evidence v2 and projects bounded session activity into the homepage as an observed Task with models/checks when present. It is not activated by onboarding, does not report token/cost truth, and does not invent named work steps; MCP remains the richer semantic source.
250
+ - All clients: imported tokens are client_reported (read from the client's own local session files); costs are estimates from a local pricing table — never provider invoices.
251
+ - Always: local-first, observe-only, no telemetry, no provider API keys stored or requested.
252
+
253
+ ## Daily workflow: import usage and browse
254
+
255
+ ```bash
256
+ # 1. See what agentacct can read on this machine.
257
+ agentacct usage discover-sources
258
+
259
+ # 2. Start the local dashboard. Product pages render saved rows; the /raw page
260
+ # runs the read-only local scan.
261
+ agentacct serve
262
+
263
+ # 3. Save current local usage summaries into agentacct's ledger.
264
+ agentacct usage import-local --client all
265
+
266
+ # 4. Optionally keep importing new sessions in the background
267
+ # (add --refresh to also update growing sessions' totals).
268
+ agentacct usage watch --interval-seconds 60
269
+
270
+ # 5. In another terminal, inspect per-source receipts and watcher health.
271
+ agentacct usage health
272
+ ```
273
+
274
+ The primary dashboard has three destinations. **Work** (`/`) is one compact, deduplicated feed of named work and otherwise-unlabelled local activity. Explicit blockers are user-action items; unresolved failed checks remain non-actionable open findings until the agent resolves them, rather than being assigned to the user. Completed work is labeled `Verified` when a current passing machine check is linked and `Agent reported` otherwise. Attribution gaps, missing join keys, source coverage, and evidence conflicts remain available in the full `/sessions` explorer and **Advanced** (`/advanced`) instead of becoming user-facing tasks. **Usage** (`/tokens`) owns token, cache, cost, and confidence analysis. The stable `/raw`, `/work-graph`, `/evidence-matrix`, `/discrepancies`, and `/cost-outcome-basis` routes remain available under Advanced. Old `/?tab=raw` / `/?tab=product` links keep working via 302 redirects.
275
+
276
+ Evidence **Source coverage** is historical evidence, not a connection monitor: “Evidence received” means agentacct saved records from that source, and the connection remains `not_verified` without an independent live check. **Activity sync** is separate operational state. It comes from durable per-source scan receipts plus the watcher's lease/heartbeat, so the Work page can distinguish a successful manual refresh, a live watcher, and a degraded or stale synchronizer. Full source, attribution, and evidence explanations stay inspectable in Sessions and Advanced.
277
+
278
+ Preview any import with `--dry-run`, and add `--estimate-costs` to attach pricing-table cost estimates. A dry run returns source diagnostics but writes neither usage nor health state. A real import or dashboard refresh atomically records per-source attempt/success timestamps, parsed/skipped/error counts, watermark, and scan-limit diagnostics under the selected store. Inspect them with `agentacct usage health --json` or `GET /ingestion/health`; `GET /health` keeps service liveness (`ok`) separate from `ingestion_status`.
279
+
280
+ The watcher does not wrap or launch your coding agents; it periodically imports sessions from implemented local usage paths that clients have already written to disk. By default the CLI and watcher record each session once, at first observation, and never update it — a session that keeps growing stays at its first-seen totals until the dashboard's **Refresh** action replaces re-observed rows with fresh totals, or you pass `--refresh` to `usage import-local` / `usage watch`. One live watcher owns a store through a lease; a second is rejected, a lost lease stops the old process, and a stale heartbeat is reported with a restart action. Long-running Python processes do not hot-reload upgraded agentacct code: after every package/source upgrade, stop the existing watcher through the terminal or process supervisor that launched it, start `usage watch` again, and confirm its `importer_version` and fresh heartbeat with `usage health --json`.
281
+
282
+ For Codex, `--limit-sessions` counts recent **root conversation groups**, not flat thread rows. agentacct resolves Codex-recorded parent edges before applying the limit, then returns the selected root and all discovered descendants so internal reviews cannot crowd their root chat out of the scan. An internal workflow label such as `codex-auto-review` is not a billable model: it inherits a model only from its exact recorded parent, with provenance; otherwise the model stays unknown and unpriced. agentacct never borrows a scan-wide model from another task.
283
+
284
+ Local imports do not read provider API keys, call provider APIs, or upload session data. Imported usage is labeled `client_reported`; estimated costs are labeled `estimated_from_tokens`, not provider billing. Cursor's local path is observation-only and never contributes usage or cost. Unknown models remain unpriced until a trusted catalog entry exists — pricing paths keep a store-local LiteLLM pricing snapshot fresh automatically (7-day TTL; the fetch is a plain GET of LiteLLM's public open-source price table, not telemetry — nothing is sent; disable with `AGENT_CHRONICLE_PRICING_AUTO_REFRESH=0`; details in [docs/usage-truth-table.md](docs/usage-truth-table.md)). Explicit per-client import flags (`--opencode-home`, `--hermes-home`, `--openclaw-home`, `--cursor-home`) are documented in [docs/coding-agent-integrations.md](docs/coding-agent-integrations.md).
285
+
286
+ To see what each integration path can and cannot prove:
287
+
288
+ ```bash
289
+ agentacct usage truth-table
290
+ ```
291
+
292
+ ## Cost and usage confidence
293
+
294
+ agentacct keeps usage confidence separate from cost confidence so dashboards do not imply more precision than the data supports.
295
+
296
+ Common labels:
297
+
298
+ ```text
299
+ usage_confidence:
300
+ provider_reported provider returned token usage
301
+ client_reported local client session store reported token usage
302
+ estimated agentacct estimated usage before/without provider data
303
+ unknown unavailable
304
+
305
+ cost_confidence:
306
+ provider_billed provider returned a finite non-negative cost
307
+ estimated_from_tokens agentacct estimated cost from tokens and pricing table
308
+ approximate_subscription_allocation user-entered subscription allocation
309
+ subscription_unavailable no fair subscription allocation denominator
310
+ unknown unavailable
311
+
312
+ cost_basis:
313
+ provider_invoice
314
+ local_client_session
315
+ pricing_table
316
+ user_subscription
317
+ none
318
+ ```
319
+
320
+ How to read the labels:
321
+
322
+ - `provider_billed`: safe basis for hard dollar budget enforcement.
323
+ - `estimated_from_tokens` or subscription allocation: useful for warnings, dashboards, and opt-in hard stops.
324
+ - `unknown`: use token, runtime, or checkpoint budgets instead of dollar hard stops.
325
+
326
+ ### Subscription allocation
327
+
328
+ Claude Code/Codex subscriptions usually do not expose exact per-run billing to agentacct. Save a plan with `agentacct cost subscription-set`, then estimate an allocation from local events:
329
+
330
+ ```bash
331
+ agentacct cost subscription-estimate --subscription-name claude-code-pro
332
+ ```
333
+
334
+ When no fair allocation denominator exists, the result is labeled `subscription_unavailable`. This is an explicit approximation, not as exact provider billing. It is an allocation model, not invoice truth. Provider invoices or exposed provider usage data remain the source of truth.
335
+
336
+ ## Local events and MCP tools
337
+
338
+ Record a note and summarize events:
339
+
340
+ ```bash
341
+ agentacct event note "Reviewed Codex output"
342
+ agentacct event summary
343
+ agentacct event list
344
+ ```
345
+
346
+ Run the local dashboard/API:
347
+
348
+ ```bash
349
+ agentacct serve
350
+ curl http://127.0.0.1:8765/usage/sources
351
+ curl http://127.0.0.1:8765/usage/preview
352
+ curl http://127.0.0.1:8765/usage/summary
353
+ curl http://127.0.0.1:8765/health
354
+ curl http://127.0.0.1:8765/ingestion/health
355
+ curl http://127.0.0.1:8765/events/summary
356
+ ```
357
+
358
+ `/events/summary?limit=N` keeps its recent-event aggregates bounded, but join-health counters and coverage ratios are computed over every matching event in the store. Machine consumers must inspect `result_scope.partial` and the bridge's `detail_scope.partial`: `links`, `attributions`, and `unlinked_contexts` may be capped even when the canonical full-store ratios are complete. A degraded response includes stable `degraded_reasons` instead of treating one successful join as healthy.
359
+
360
+ Evidence v2 is additive and enabled by default. It shadows existing v1 writes; it does not replace `events.jsonl` or rename any public `sentinel_*` MCP tool. Inspect or replay it with:
361
+
362
+ ```bash
363
+ agentacct evidence status --store-dir .agent-sentinel/state
364
+ agentacct evidence replay-v1 --store-dir .agent-sentinel/state
365
+ agentacct evidence product --store-dir .agent-sentinel/state --json
366
+ ```
367
+
368
+ Mechanical capture is opt-in. These commands disclose capabilities and render a fragment, but do not edit active host configuration:
369
+
370
+ ```bash
371
+ agentacct capabilities agents
372
+ agentacct capabilities agents --json
373
+ agentacct capture capabilities --json
374
+ agentacct capture manifest --vendor claude-code
375
+ agentacct capture manifest --vendor codex
376
+ agentacct capture manifest --vendor cursor
377
+ ```
378
+
379
+ `capabilities agents` is the canonical per-agent manifest. It deliberately has no whole-client support badge: local session discovery, usage import, mechanical capture, MCP semantics, model attribution, cache read/write, installation mode, and verification evidence remain independent. The Dashboard renders the same truth under **Advanced → Agent capability coverage**; `/usage/sources` and `/ingestion/health` continue to describe this machine's current runtime state instead.
380
+
381
+ Read-only external adapters support dry runs before durable import:
382
+
383
+ ```bash
384
+ agentacct connector openlit /path/to/otlp.json --dry-run --json
385
+ agentacct connector paperclip /path/to/paperclip-export.json --dry-run --json
386
+ agentacct connector entire /path/to/git-repository --dry-run --json
387
+ ```
388
+
389
+ The localhost API accepts OTLP/HTTP JSON at `POST /v1/traces`. Start evidence inspection at `/advanced`; the stable projections remain available at `/work-graph`, `/evidence-matrix`, `/discrepancies`, and `/cost-outcome-basis`. `GET /evidence/events` uses bounded arrival-order cursor pages (`limit`, then `cursor=next_cursor`). Set `AGENT_CHRONICLE_EVIDENCE_V2=0` for a v1-only rollback; existing v2 evidence remains untouched.
390
+
391
+ Start the MCP server over stdio:
392
+
393
+ ```bash
394
+ agentacct mcp serve
395
+ ```
396
+
397
+ Current MCP tools include:
398
+
399
+ - `sentinel_list_runs`
400
+ - `sentinel_get_report`
401
+ - `sentinel_record_event`
402
+ - `sentinel_attach_client_context`
403
+ - `sentinel_record_section`
404
+ - `sentinel_record_agent_usage_debug`
405
+ - `sentinel_list_events`
406
+ - `sentinel_get_event_summary`
407
+ - `sentinel_record_machine_check`
408
+ - `sentinel_prepare_judge`
409
+ - `sentinel_compute_value`
410
+
411
+ Use local usage import for token/cost truth, and use MCP tools for workflow context. `sentinel_attach_client_context` stores local session/turn/message identifiers, while `sentinel_record_section` stores human-readable task chapters that can later be joined to imported usage. `sentinel_record_agent_usage_debug` stores agent-visible usage snapshots for comparison only; it does not add to agentacct's usage or cost totals.
412
+
413
+ How agents learn to record: the MCP server returns record-your-work instructions in its initialize result, and for Claude Code the SessionStart hook injects the same directive into every new session. `agentacct setup instructions --agent <client> --user` writes a standing instruction block into user-level `~/.claude/CLAUDE.md` / `~/.codex/AGENTS.md` (idempotent markers; `--remove` strips it, `--dry-run` previews). For one machine-wide store and dashboard instead of per-repo installs, follow the "Global install" section of [INSTALL.md](INSTALL.md); fold older per-project stores in with `agentacct usage merge-store`.
414
+
415
+ Verify the local MCP event workflow without paid APIs:
416
+
417
+ ```bash
418
+ agentacct mcp workflow-smoke --json
419
+ ```
420
+
421
+ The workflow smoke does not call Claude, Codex, or provider APIs. By default it records its test events in a throwaway temporary store (the printed store path vanishes on cleanup/reboot); pass `--store-dir` only if you deliberately want smoke events in a persistent ledger.
422
+
423
+ ## Verification and evidence
424
+
425
+ These helpers configure project-local onboarding. They do not mean agentacct automatically monitors every Claude Code/Codex/OpenCode/Hermes/OpenClaw session you start elsewhere.
426
+
427
+ Maintainer smoke tests have verified minimal Claude Code and Codex runs, agentacct has been smoke-tested as an MCP tool inside real interactive Claude Code and Codex sessions, and Hermes/OpenCode/OpenClaw MCP setup commands have been maintainer-probed on the VPS. See [docs/live-agent-smoke.md](docs/live-agent-smoke.md), [docs/live-smoke-results.md](docs/live-smoke-results.md), and [docs/live-mcp-client-smoke-results.md](docs/live-mcp-client-smoke-results.md) for sanitized evidence and current limitations.
428
+
429
+ Release-gate smoke commands, optional and not part of default CI because they can consume paid tokens:
430
+
431
+ ```bash
432
+ agentacct smoke claude-code
433
+ agentacct smoke codex
434
+ agentacct smoke all --json
435
+
436
+ # Real MCP-client smoke tests. Disabled by default because they use real API credits.
437
+ # Requires DEEPSEEK_API_KEY in the environment.
438
+ agentacct smoke mcp-client --client hermes --provider deepseek --i-understand-this-uses-real-api --json
439
+ ```
440
+
441
+ ## Optional enforcement extras
442
+
443
+ Enforcement is opt-in and secondary to observation.
444
+
445
+ agentacct provides explicit wrapper commands for runs you want agentacct to own directly:
446
+
447
+ ```bash
448
+ agentacct-claude -p "Reply with exactly: hello"
449
+ agentacct-codex exec --sandbox read-only --ephemeral --skip-git-repo-check "Reply with exactly: hello"
450
+ ```
451
+
452
+ Wrappers launch the underlying `claude` or `codex` binary through agentacct and write normal local run artifacts, with stdout/stderr capture, timeouts, and pause/kill limited to agentacct-owned runs. They do not automatically monitor Claude Code/Codex sessions started outside these wrapper commands, and they do not provide exact subscription billing by themselves.
453
+
454
+ An opt-in provider cost proxy (`agentacct cost proxy --enable-forwarding --max-total-usd ...`) can forward OpenRouter/OpenAI/DeepSeek API calls under a hard local budget cap: forwarding is disabled by default, requires an explicit cap, refuses non-local bind hosts by default, and stores provider-reported costs as `actual_provider_cost_usd`. Start with low-limit test keys; details in [Safety boundaries](docs/safety-boundaries.md).
455
+
456
+ ## More documentation
457
+
458
+ - [Full flow demo](docs/full-demo.md)
459
+ - [Architecture](docs/architecture.md)
460
+ - [Task Intelligence and local control plane](docs/task-control-plane.md)
461
+ - [Multi-source Evidence v2 architecture](docs/multi-source-evidence-architecture.md)
462
+ - [Multi-source privacy threat model](docs/multi-source-privacy-threat-model.md)
463
+ - [Integration license BOM](docs/integration-license-bom.md)
464
+ - [Safety boundaries](docs/safety-boundaries.md)
465
+ - [Public alpha checklist](docs/public-alpha-checklist.md)
466
+ - [Live agent smoke guide](docs/live-agent-smoke.md)
467
+ - [Live smoke results](docs/live-smoke-results.md)
468
+ - [Live MCP client smoke results](docs/live-mcp-client-smoke-results.md)
469
+ - [Coding agent integrations](docs/coding-agent-integrations.md)
470
+ - [agentacct workflow instructions](docs/agent-chronicle-workflow-instructions.md)
471
+ - [Usage and cost truth table](docs/usage-truth-table.md)
472
+ - [Prompt budget preview](docs/prompt-budget-optimizer.md)
473
+
474
+ ## Development
475
+
476
+ See [`CONTRIBUTING.md`](CONTRIBUTING.md) for contribution scope, safety principles, and PR expectations.
477
+
478
+ Run tests from a clone (the pipx install above ships no test tooling):
479
+
480
+ ```bash
481
+ python3 -m venv .venv
482
+ .venv/bin/python -m pip install -e .
483
+ .venv/bin/python -m pip install pytest
484
+ .venv/bin/python -m pytest tests/ -q --tb=short
485
+ ```
486
+
487
+ ## Feedback
488
+
489
+ agentacct is early alpha. Useful feedback:
490
+
491
+ - Which agent or tool do you use?
492
+ - What runaway, cost, or observability issue did you hit?
493
+ - Which join/attribution result looked wrong or missing?
494
+ - What report would help you trust a run?
495
+ - Which integration should be supported next?
496
+
497
+ Open an issue with a bug report, feature request, or integration request. Please scrub any provider API keys or private paths from logs before sharing them.