Skip to content

Commit 50c6c14

Browse files
committed
Merge upstream main into OMP support
2 parents 4fb85f2 + 314fac0 commit 50c6c14

29 files changed

Lines changed: 3628 additions & 76 deletions

Cargo.lock

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "memex"
3-
version = "0.9.1"
3+
version = "0.10.1"
44
edition = "2024"
55
build = "build.rs"
66
description = "CLI tool for indexing and searching local agent conversation history"
@@ -47,5 +47,9 @@ tempfile = "3"
4747
libc = "0.2"
4848
libloading = { version = "0.8", optional = true }
4949
tiny_http = "0.12"
50+
base64 = "0.22"
51+
getrandom = "0.3"
52+
hmac = "0.12"
53+
subtle = "2.6"
5054

5155
[dev-dependencies]

README.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# memex
22

3-
Fast local history search for Claude, Codex CLI, Cursor, OpenCode, Pi Coding Agent, Oh My Pi, OpenClaw, and GitHub Copilot CLI logs. Uses BM-25 and optionally embeds your transcripts locally for hybrid search.
3+
Fast local history search for Claude, Codex CLI, Cursor, OpenCode, Pi Coding Agent, Oh My Pi, OpenClaw, GitHub Copilot CLI, and Hermes usage records. Uses BM-25 and optionally embeds your transcripts locally for hybrid search.
44

55
Mostly intended for agents to use via skill. The intended workflow is to ask agent about a previous session & then the agent can narrow things down & retrieve history as needed.
66

@@ -213,19 +213,20 @@ Token tracking is disabled by default because it scans and caches local agent lo
213213
token_usage = true
214214
```
215215

216-
Then reconstruct historical token usage from local Claude Code, Codex, Cursor, OpenCode, Pi, Oh My Pi, OpenClaw, and Copilot logs:
216+
Then reconstruct historical token usage from local Claude Code, Codex, Cursor, OpenCode, Pi, Oh My Pi, OpenClaw, Copilot, and Hermes records:
217217

218218
```
219219
memex usage
220220
memex usage --source codex --since 2026-07-01
221+
memex usage --source hermes --since 2026-07-01
221222
memex usage --json --events
222223
```
223224

224225
`--cost auto` prefers a provider-stored request cost and otherwise applies the versioned built-in API price catalog. `--cost source` uses only stored costs; `--cost reprice` always applies the catalog. Calculated costs are API-equivalent estimates, not subscription charges. Events with unknown models or prices remain in token totals and are reported as unpriced.
225226

226227
Each source also reports prompt-cache efficiency: the cache hit rate, plus an estimate of cache waste — prompt tokens that were in the previous request's prompt but were re-billed at input rates instead of read from cache, priced at catalog rates and attributed to idle gaps past the cache TTL or model switches where those apply. Waste is estimated per transcript file chain and errs toward undercounting: subagent sidechains, ambiguous dedupe deltas, and prompts that shrink past compaction are not counted.
227228

228-
Local token history is reconstructed usage. It is deliberately kept separate from authoritative subscription quota percentages and reset windows.
229+
Local token history is reconstructed usage. It is deliberately kept separate from authoritative subscription quota percentages and reset windows. Hermes usage is read from `state.db` in the Hermes root and immediate profile directories (`HERMES_PROFILE_ROOTS`, `HERMES_HOME`, or `HERMES_STATE_DIR`, with safe local defaults), opened read-only and WAL-compatible. The `sessions` aggregate is used for legacy databases; newer `session_model_usage` delta rows are emitted by model/task and reconciled against the session aggregate so historical seeded rows count once and positive residuals are retained. Snapshots, backups, arbitrary nested databases, JSON/JSONL transcripts, and auth, config, memory, skills, plugins, and cron paths are excluded. Hermes queries never read message, system-prompt, tool, reasoning-text, or credential tables. Usage output contains counters and metadata only. Any API-equivalent cost estimate is analytical and is not a Hermes subscription quota measurement; source-stored API costs are not quota percentages. Hermes parser-version changes invalidate only Hermes usage cache rows.
229230

230231
When token tracking is enabled, press `Ctrl+T` on the TUI home screen to toggle the 30-day activity chart between session count and token volume. Token activity is loaded lazily and cached when first shown.
231232

@@ -269,7 +270,7 @@ This detects which tools are installed (Claude/Codex/OpenCode/Pi/Oh My Pi) and p
269270
- `--role <user|assistant|tool_use|tool_result>`
270271
- `--tool <tool_name>`
271272
- `--session <session_id>`
272-
- `--source claude|codex|cursor|opencode|pi|omp|openclaw|copilot`
273+
- `--source claude|codex|cursor|opencode|pi|omp|openclaw|copilot|hermes`
273274
- `--since <iso|unix>` / `--until <iso|unix>`
274275
- `--limit <n>`
275276
- `--min-score <float>`
@@ -296,6 +297,21 @@ memex index-service enable --continuous
296297
memex index-service enable --web-ui
297298
```
298299

300+
Regenerate the service from current config and restart it:
301+
```
302+
memex index-service restart
303+
```
304+
305+
Inspect the registered service and whether it is serving the Web UI:
306+
```
307+
memex index-service status
308+
```
309+
310+
Open an authenticated browser session:
311+
```
312+
memex index-service open
313+
```
314+
299315
Disable:
300316
```
301317
memex index-service disable
@@ -310,18 +326,31 @@ On successful enable, memex writes `auto_index_on_search = false` to config when
310326
`http://127.0.0.1:6363`. It mirrors the TUI's core workflow with search-as-you-type,
311327
source and project filters, a persistent session list, and Matches/History transcript
312328
previews. The server binds to loopback by default because the index
313-
contains private conversation history. Override the address explicitly when needed:
329+
contains private conversation history. Memex refuses non-loopback HTTP listeners. If
330+
remote access is required, use an authenticated TLS reverse proxy to `127.0.0.1` that
331+
injects the installation bearer token into upstream requests. To use a different local port:
314332

315333
```
316334
memex index-service enable --web-listen 127.0.0.1:8080
335+
memex index-service open --listen 127.0.0.1:8080
317336
```
318337

338+
The first Web UI start creates `~/.memex/web-auth-token` with mode `0600`. Private API
339+
routes require that token as `Authorization: Bearer ...` or a browser session established
340+
by `index-service open`. Browser links carry a signed, one-time credential in the URL
341+
fragment, remove it before navigation continues, and exchange it for an ephemeral bearer
342+
token held only in page memory. The browser token is never stored in a cookie,
343+
`localStorage`, or session storage. Browser sessions expire after 12 hours, disappear when
344+
the page closes, and are invalidated whenever the daemon restarts.
345+
319346
To run the same UI in the foreground without changing the background service:
320347

321348
```
322349
memex web
323350
```
324351

352+
Then run `memex index-service open` from another terminal.
353+
325354
The browser frontend lives in `web/`, uses React and shadcn components, and is
326355
built with `cd web && bun install && bun run build`. The generated static assets
327356
are embedded in the memex binary, so serving the UI does not add a JavaScript

flake.nix

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@
4949
pkg-config
5050
openssl
5151
rustToolchain
52-
]
53-
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
54-
pkgs.darwin.apple_sdk.frameworks.Security
55-
pkgs.darwin.apple_sdk.frameworks.CoreFoundation
56-
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
5752
];
5853

5954
nativeBuildInputs = with pkgs; [pkg-config];

herdr-plugin.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# with exactly this version.
99
id = "nicosuave.memex"
1010
name = "memex"
11-
version = "0.9.1"
11+
version = "0.10.1"
1212
min_herdr_version = "0.7.0"
1313
platforms = ["macos", "linux"]
1414
description = "Session desk for your agent history: search past Claude Code / Codex / Cursor / Pi / Oh My Pi sessions and resume one into a herdr tab."

herdr/plugin.sh

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,26 +240,23 @@ web)
240240
log="$dir/web.log"
241241
url="http://$web_listen"
242242
# Reuse a server that is already up — the background index service may well be serving it.
243-
if ! curl -fsS -m 1 "$url/api/stats" >/dev/null 2>&1; then
243+
if ! curl -fsS -m 1 "$url/healthz" >/dev/null 2>&1; then
244244
nohup "$MEMEX" web --listen "$web_listen" ${MEMEX_ROOT:+--root "$MEMEX_ROOT"} >>"$log" 2>&1 </dev/null &
245245
# The assets are embedded in the binary, so it comes up fast; give it ~3s anyway.
246246
up=""
247247
for _ in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
248248
sleep 0.2
249-
if curl -fsS -m 1 "$url/api/stats" >/dev/null 2>&1; then
249+
if curl -fsS -m 1 "$url/healthz" >/dev/null 2>&1; then
250250
up=1
251251
break
252252
fi
253253
done
254254
[ -n "$up" ] || refuse "memex web did not come up on $web_listen, see $log"
255255
fi
256-
case "$(uname -s)" in
257-
Darwin) opener="open" ;;
258-
*) opener="xdg-open" ;;
259-
esac
260-
command -v "$opener" >/dev/null 2>&1 || refuse "$opener not found; memex web is running at $url"
261-
"$opener" "$url" >/dev/null 2>&1 || refuse "failed to open $url with $opener"
262-
printf 'opened %s\n' "$url"
256+
open_args=(index-service open --listen "$web_listen")
257+
[ -n "${MEMEX_ROOT:-}" ] && open_args+=(--root "$MEMEX_ROOT")
258+
"$MEMEX" "${open_args[@]}" >/dev/null 2>&1 || refuse "failed to open authenticated memex web UI at $url"
259+
printf 'opened authenticated %s\n' "$url"
263260
;;
264261

265262
startup)

nix/package.nix

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
openssl,
66
onnxruntime,
77
stdenv,
8-
darwin,
98
}:
109
rustPlatform.buildRustPackage {
1110
pname = "memex";
@@ -25,11 +24,6 @@ rustPlatform.buildRustPackage {
2524
[
2625
openssl
2726
onnxruntime
28-
]
29-
++ lib.optionals stdenv.isDarwin [
30-
darwin.apple_sdk.frameworks.Security
31-
darwin.apple_sdk.frameworks.CoreFoundation
32-
darwin.apple_sdk.frameworks.SystemConfiguration
3327
];
3428

3529
# Tests require network access to download embedding models

0 commit comments

Comments
 (0)