@klars/agentobs 0.2.0 → 0.2.1

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 (2) hide show
  1. package/README.md +45 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -36,16 +36,31 @@ account, no cloud, no telemetry.
36
36
  ```bash
37
37
  npm install -g @klars/agentobs
38
38
  agentobs init
39
+ agentobs import
39
40
  ```
40
41
 
41
- `init` prints a hook configuration block. Paste it into `~/.claude/settings.json`
42
- (or a project's `.claude/settings.json`), then:
42
+ `import` reads Claude Code's own session transcripts from `~/.claude/projects/`
43
+ and backfills everything you have already done — no configuration, no hooks.
44
+ Then:
43
45
 
44
46
  ```bash
45
47
  agentobs dashboard
46
48
  ```
47
49
 
48
- Run Claude Code as usual. Tool calls appear in the dashboard within seconds.
50
+ That is the fastest path to real data, and the one to try first.
51
+
52
+ ### Live capture (optional)
53
+
54
+ `import` is after-the-fact. To record calls **as they happen** — and to let
55
+ guardrails actually block them — add the hook configuration that
56
+ `agentobs init` prints to `~/.claude/settings.json`, then restart Claude Code.
57
+
58
+ > **If hooks record nothing:** this has been observed on at least one Windows
59
+ > install, where Claude Code did not invoke the configured command at all — a
60
+ > plain two-line `.cmd` file also never fired, so it is not specific to
61
+ > AgentObs. Check by running any tool and then `agentobs stats --today`. If it
62
+ > stays at zero, keep using `agentobs import`, which needs no hooks; only
63
+ > guardrail *blocking* depends on them.
49
64
 
50
65
  ---
51
66
 
@@ -85,6 +100,7 @@ Everything lives in `~/.agentobs/`. Uninstalling is `rm -rf ~/.agentobs`.
85
100
 
86
101
  ```
87
102
  agentobs init Set up ~/.agentobs and print the hook config
103
+ agentobs import [--days n] [--all] Import Claude Code transcripts (no hooks needed)
88
104
  agentobs dashboard [--port] [--host] Serve the dashboard (default 127.0.0.1:4300)
89
105
  agentobs stats [--today] [--since] Print totals in the terminal
90
106
  agentobs run -- <command...> Observe any command (coarse detail)
@@ -148,22 +164,37 @@ Two deliberate behaviours worth knowing:
148
164
 
149
165
  ## Agent support
150
166
 
151
- | Agent | How | Detail |
152
- | --------------- | -------------------------- | ------------------------------------------------- |
153
- | **Claude Code** | Native hooks | **Rich** — every tool call, plus policy enforcement |
154
- | Any CLI agent | `agentobs run -- <cmd>` | **Coarse** duration and exit code only |
155
- | Custom / in-house | `agentobs watch <file>` | **Rich**, if it writes JSONL |
167
+ | Agent | How | Detail | Needs setup? |
168
+ | --- | --- | --- | --- |
169
+ | **Claude Code** | `agentobs import` | **Rich** — every tool call, tokens, cost | **No** |
170
+ | **Claude Code** | Native hooks | **Rich**, live, and can *block* calls | Yes — hook config |
171
+ | Any CLI agent | `agentobs run -- <cmd>` | **Coarse** duration and exit code only | No |
172
+ | Custom / in-house | `agentobs watch <file>` | **Rich**, if it writes JSONL | No |
173
+
174
+ `import` and hooks read the same underlying data. The difference is timing:
175
+ hooks see a call *before* it runs, which is what makes blocking possible;
176
+ `import` reads the transcript afterwards. If you only want observability,
177
+ `import` is enough and needs no configuration.
156
178
 
157
179
  The dashboard labels coarse sessions as `coarse` rather than implying detail it
158
- does not have.
180
+ does not have, and `agentobs stats` explains why a coarse-only range shows zero
181
+ tool calls.
159
182
 
160
183
  ### A note on cost accuracy
161
184
 
162
- Claude Code's `PostToolUse` hook payload carries **no token or cost fields**.
163
- AgentObs therefore reads token usage from the session transcript at
164
- `SessionEnd`, which makes **session-level cost accurate** but leaves
165
- **per-tool-call cost blank** for hook-sourced data. It does not divide a total
166
- across calls to manufacture a number.
185
+ Claude Code's `PostToolUse` hook payload carries **no token or cost fields**,
186
+ so token usage comes from the session transcript at `SessionEnd` for hooks,
187
+ or directly via `agentobs import`. That makes **session-level cost accurate**
188
+ while leaving **per-tool-call cost blank**: usage is reported per assistant
189
+ message, not per tool call, and dividing a total across calls would be a
190
+ manufactured number.
191
+
192
+ **Cache tokens dominate a long session.** A cached conversation replays its
193
+ whole context on every turn, so `cache_read` can reach hundreds of millions of
194
+ tokens in a single session. AgentObs tracks cache reads (billed at 0.1x input)
195
+ and cache writes (1.25x) separately from fresh tokens, and `agentobs import`
196
+ prints the four lines separately — a single unexplained total looks like a bug
197
+ when the cache line legitimately dwarfs everything else.
167
198
 
168
199
  Model prices live in `~/.agentobs/pricing.json` and are yours to edit. A model
169
200
  missing from that file shows cost as `—`, never `$0.00`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klars/agentobs",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Observability and control layer for AI coding agents - see every tool call, token, and dollar your agents spend, and stop them before they do something risky.",
5
5
  "license": "MIT",
6
6
  "author": "Klars AI",