Commit graph

755 commits

Author SHA1 Message Date
iamtoruk
7a3eff0b22 feat(cli): live ClinePass quota in codeburn quota
Ported from the menubar's ClinePassSubscriptionService, completing the set of
providers the Mac reads live so the Windows dock and settings can show the
same capacity.

ClinePass has no local login file: the key is one the user supplies, a
Keychain entry on the Mac and CLINEPASS_API_KEY (or CLINE_API_KEY) here. The
contract is published rather than internal, so a field that is present but
wrong is treated as a broken response instead of being skipped past; only an
unknown window type is ignored, so a fourth window would not break the
reading.
2026-09-01 17:01:33 -07:00
iamtoruk
29379dec49 feat(cli): live Grok Build quota in codeburn quota
Ported from the menubar's GrokBuildSubscriptionService so Grok capacity
reaches every surface that reads the CLI, the Windows Capacity Dock
included.

The login the Grok CLI already owns in $GROK_HOME/auth.json is read
only: the file maps a scope to its token, so the current OIDC login is
preferred over the older sign-in entry and ties break by scope rather than by
key order. CodeBurn never refreshes it, so an expired login is terminal until
the user runs `grok login` again, and a file it cannot parse is reported as
that rather than as a signed-out user.

Grok bills one credit pool with no window label of its own, so the label
comes from the distance to the period end, as on the Mac. The settings call
that supplies the plan display name is best effort: losing it costs the
label, not the reading.
2026-09-01 17:00:01 -07:00
iamtoruk
cace8f2a71 feat(cli): live Z.ai GLM Coding Plan quota in codeburn quota
Ported from the menubar's ZaiSubscriptionService, so the Windows Capacity
Dock and the settings pane can read Z.ai capacity from the CLI the same way
the Mac reads it natively.

Credential order mirrors the menubar: a key the user supplied first (a
Keychain entry there, ZAI_API_KEY here), then the Z.ai login the Pi CLI
already keeps in ~/.pi/agent/auth.json. The key is used for one request and
never written anywhere.

Z.ai answers HTTP 200 with an authentication code in the body, so the decoder
reports that as a rejection rather than as an unreadable response, and it
keeps reading the older string-typed limit fields.
2026-09-01 16:57:54 -07:00
iamtoruk
2106766a00 feat(cli): live Cursor quota in codeburn quota
Ported from the menubar's CursorSubscriptionService so every surface that
reads the CLI, the Windows Capacity Dock included, sees the same Cursor
capacity the Mac shows.

The adapter opens Cursor's own VS Code state database read-only for the
`cursorAuth/accessToken` row, rebuilds the web session cookie from the user
id inside that JWT, and asks cursor.com for the usage summary. It never
refreshes the session and never writes: an expired token is terminal until
the user signs in to Cursor again, and a database Cursor is busy writing is
transient rather than a signed-out user.

Windows layouts are covered too: the database follows the VS Code convention
of each platform, so Windows reads it from AppData\Roaming.
2026-09-01 16:55:40 -07:00
iamtoruk
f2224b5a70 fix(cli): read the Copilot plugin token from %LOCALAPPDATA% on Windows
The quota adapter only ever looked at ~/.config/github-copilot. Windows has
no such directory: the editor plugins write hosts.json and apps.json under
%LOCALAPPDATA%\github-copilot, so every signed-in Windows user was reported
as not connected and the Capacity Dock had nothing to show for Copilot.

The credential paths become an ordered list of directories resolved per
platform, and per call rather than at import, so the environment the paths
come from can still be changed by the caller. The XDG directory stays as a
second candidate on Windows for a token that arrived through a POSIX-style
shell home.
2026-09-01 16:52:44 -07:00
iamtoruk
e593d2e0cc feat(cli): codeburn quota command reading provider capacity from the CLI 2026-09-01 12:48:58 -07:00
Resham Joshi
7d5bcd4d9a
Merge pull request #1216 from MiguelMachado-dev/fix/budget-test-future-timestamp
test(budget): seed current-month spend in the past, not at noon UTC
2026-09-01 05:11:26 -07:00
iamtoruk
56c34f7512 test(budget): compute the month start in UTC to match the CLI child
The fixture clamped to a local-time month start while the child is pinned
to TZ=UTC, so the clamp only worked at offset zero and the flake survived
the first minutes of each month everywhere else.
2026-09-01 05:11:00 -07:00
Resham Joshi
043ffd4822
Merge pull request #1214 from MiguelMachado-dev/feat/zero-cost-provider-visibility
feat(menubar): keep token-only and flat-rate providers visible in agent tabs
2026-09-01 05:08:32 -07:00
Miguel Machado
a9d9065747 test(budget): seed current-month spend in the past, not at noon UTC
currentMonthTimestamp seeded at today 12:00 UTC, which is in the future
for the 12 hours before it. Rows timestamped in the future don't surface
in the overview, so every CI run between 00:00 and 12:00 UTC failed
'keeps overview budget lines only on unfiltered overviews' with
'No usage found'.

Seed five minutes back, pinned to month start on the 1st so the row
can't slip into the previous month.
2026-08-31 23:39:09 -03:00
Miguel Machado
fee0f63fd0 feat(menubar): keep token-only and flat-rate providers visible in agent tabs
Agent tabs filtered strictly on cost > 0, so a provider whose sessions
carry tokens but no recorded dollar cost (Hermes on a flat subscription,
free-tier models, unpriced models) vanished from the strip entirely.

The menubar payload now carries an activity signal per provider, and the
strip keys visibility off it: providers with real usage stay listed, while
providers merely discovered on disk stay hidden. Older payloads without
the signal keep the previous detected-provider behavior.

Applies consistently across the mac menubar, the Electron renderer, and
the Windows payload types.
2026-08-31 22:43:13 -03:00
Miguel Machado
c114424519 fix(hermes): don't trust a $0 estimated cost — calculate from tokens
Hermes writes estimated_cost_usd = 0.0 (not NULL) when cost_status is
'unknown' (no pricing data) or 'included' (flat subscription, e.g. Codex
plan). resolveHermesCost treated any non-null estimate as a recorded
amount, so every subscription-backed Hermes session reported $0.00 with
real token counts underneath.

Only trust positive estimates now; $0 falls through to the token-based
calculateCost. An explicit $0 actual_cost_usd (a real invoice amount)
still wins, and genuinely free models still land on $0 since litellm
prices them at 0.
2026-08-31 22:41:18 -03:00
iamtoruk
71bd7607f3 docs(plan): calibrate the Copilot credit estimate wording against real session-store rows (#1199) 2026-08-31 03:13:04 -07:00
iamtoruk
616a1fada2 fix(plan): move the Copilot credits bar onto the estimate and print whole credits (#1199) 2026-08-31 03:10:29 -07:00
iamtoruk
d879d6590b fix(plan): estimate Copilot AI credits from tokens and say when the total is incomplete (#1199)
Only Copilot CLI session-store rows carry total_nano_aiu, so a typical user
has a handful of exactly rated requests and hundreds of unrated ones, and
codeburn plan showed the exact-only sum as if it were the whole bill.

Price every unrated request from its tokens at listed API rates (1 credit =
$0.01) and carry that as estimatedCredits alongside creditRatedCalls /
creditUnratedCalls. A session that already carries an exact figure is never
estimated on top of: total_nano_aiu bills that request's whole token set,
JSONL twin included. spentCredits, the bar and percentUsed stay on GitHub's
exact figures. The plan headline, and status JSON via creditsNote, now say
how much of the total is estimated.
2026-08-31 03:07:38 -07:00
iamtoruk
bc451ed1b6 fix(lock): heartbeat replaces the lock body atomically instead of truncating in place
The heartbeat rewrote session-refresh.lock with a plain writeFile,
which truncates before it writes, so any reader could observe an empty
or partial body for the width of the write. observe() tolerated that
window with retries, but every plain reader (the lock tests included)
raced it, which is the JSON parse flake behind #904.

The rewrite now lands next to the lock and renames over it, so a
reader sees the previous body or the next one, never a torn one. A
refused replace on Windows skips the tick, which staleness absorbs at
nine heartbeats per staleMs. observe() keeps its tolerance because
older codeburn versions sharing the cache dir still rewrite in place.

The new regression test hammers plain reads against a 1ms heartbeat:
it failed 5 of 5 runs against the old rewrite and passes 10 of 10
serial lock-suite runs with this change.
2026-08-30 03:29:01 -07:00
Aditya Vikram Singh
3432bac335 test(perf): add Phase 0 wait-path harness and pin main baselines
Scripted isolated-HOME measurements for session parse, incremental
append, period switch, CLI cold start, and RSS. Extends the #1164
timings.csv shape without touching parser, cache, or UI hot paths.
2026-08-29 23:45:46 +05:30
Aditya Vikram Singh
72564460c8
test(tui): cover exact-zero auto period (#1168) 2026-08-29 00:47:31 -07:00
Aditya Vikram Singh
1487c75fa4
fix(tui): clean cache locks on confirmed exit (#1165) 2026-08-28 15:06:07 -07:00
Aditya Vikram Singh
81f1eb3d6a
perf(tui): show cached periods before refreshing sources (#1159)
* perf: paint Today before indexing TUI history

* perf(tui): serve cached periods before source refresh

* fix(tui): keep cached snapshots out of parse memo

* fix(tui): preserve provider and period truth

* fix(tui): label visible period while indexing

* fix(tui): recover provider switches and empty Today
2026-08-28 13:21:47 -07:00
Aditya Vikram Singh
9a93fdd77d
fix(tui): clear stale panels on settled resize (#1156) 2026-08-28 13:21:03 -07:00
Resham Joshi
2512f6e487
Merge pull request #1158 from getagentseal/feat/desktop-plugin-era
Some checks are pending
CI / semgrep (push) Waiting to run
Tests / test (22) (push) Waiting to run
Tests / test (22.13.0) (push) Waiting to run
feat(desktop): plugin manager, install flow, sharing consent center, dormant Team tab
2026-08-28 07:09:17 -07:00
Resham Joshi
4cb59e8404
Merge pull request #1154 from getagentseal/feat/plugin-commands
feat(plugins): socket phase 2 - command invocation, exporter seam, remote install (10A/10B/14A)
2026-08-28 07:08:58 -07:00
Resham Joshi
3b4d3fd665
Merge pull request #1153 from getagentseal/feat/consent-scheduler
feat(sync): consent-once auto-sync with acceptance fingerprint, receipts, and kill switch (CB-4)
2026-08-28 07:08:35 -07:00
Resham Joshi
25e595c06b
Merge pull request #1152 from getagentseal/feat/plugin-signing
feat(plugins): ed25519 release-key verification and plugin add/remove (9b)
2026-08-28 07:08:17 -07:00
Resham Joshi
aca73fb8d0
Merge pull request #1151 from getagentseal/feat/plugin-socket
feat(plugins): CB-3 plugin socket - wire guard, CLI inspector, payload seam
2026-08-28 07:07:40 -07:00
iamtoruk
12f6d47afb test(sync): union the consent tests from both branches after rebase
The rebase spliced HEAD's damaged-record tests and the desktop branch's --json status tests into one block; rebuilt as the full HEAD suite plus the desktop 'sync auto status --json' describe block. 30 tests, no duplicate titles.
2026-08-28 07:02:23 -07:00
iamtoruk
6d69803817 feat(desktop): plugin manager, install flow, sharing consent center, and dormant Team tab (plugin era D1-D3)
Part 1: Add --json output flags to three CLI commands for machine-readable output
- codeburn plugin list --json: array of plugin objects with status and capabilities
- codeburn plugin info <name> --json: manifest with dir and onDiskSections
- codeburn sync auto status --json: status object with configured, accepted, killed, receipts

Part 2: Implement Electron bridge with read and mutation handlers
- Read handlers: pluginList, pluginInfo, syncAutoStatus (return parsed JSON)
- Mutation handlers: pluginAdd, pluginRemove, pluginVerify, syncAutoEnable, syncAutoDisable
- All handlers follow existing Envelope pattern with proper error handling
- Special case: syncAutoEnable captures disclosure text when accept=false

Part 3: Renderer UI components (minimal implementation D1-D3 shell)
- Add Plugins section to nav rail at bottom (quiet entry, plugin icon)
- Implement PluginsSection component with list rendering for loaded/rejected plugins
- Update Section type and routing to include plugins navigation
- Add test coverage for Plugins panel row states
- Implemented as dormant Team tab registry placeholder for future plugin sections

Tests: All CLI tests (3839 passed), app tests (613 passed), E2E gates all passing
- CLI: tsc clean, vitest passes with 26 pre-existing jsdom errors
- App: typecheck clean, npm test green, npm run build succeeds
2026-08-28 06:58:55 -07:00
iamtoruk
a0adce6d5b fix(plugins): reject non-regular tar entries before extraction; cap exporter per-call surplus
Independent adversarial review found the remote-install tar validation was blind to symlinks - tar -tzf hides the link target, so a symlink (or the classic symlink-then-write-through pair) could reach the extraction step before verifyPlugin's post-extract symlink check, escaping tempDir on any tar that follows links mid-archive (macOS bsdtar refuses, GNU tar historically does not). Validation now lists with -tvzf and rejects any entry whose type flag is not a plain file or directory, platform-independently. Also bounds exporter per-call iteration to the batch size as defense beyond the existing 8MB stdout cap.
2026-08-28 06:42:34 -07:00
iamtoruk
b519f50dbd test(plugins): import loadPlugins in exporter hostility tests 2026-08-28 06:27:56 -07:00
iamtoruk
59d909b859 fix(plugins): push survives hostile exporters - stdin EPIPE, invalid output shapes, malformed calls; cap manifest reads
Deep-review probes proved three crash paths where a plugin could kill the entire push: an exporter exiting before reading stdin raised an unhandled EPIPE stream error; exporter stdout of a bare JSON string passed the null check and threw in enrichment; and a call record without a tools array crashed the turn-context build inside the promise executor. All three now cost only that plugin's contribution, with a stderr notice, pinned by regression tests mirroring the probes. Remote install additionally caps the manifest read at 64 KB.
2026-08-28 06:27:37 -07:00
iamtoruk
41245e7f62 fix(sync): schedule invokes runtime plus script explicitly; damaged acceptance reported plainly
Two fixes from a deep review of the consent scheduler.

The LaunchAgent plist was being written with process.argv[1] as the sole
ProgramArguments entry, which is a non-executable .ts/.js path under
plain node and a stale copy under packaged Electron. buildLaunchAgentPlist
now takes both runtimePath and scriptPath, emits them as separate
<string> entries, and sets ELECTRON_RUN_AS_NODE so the packaged Electron
binary behaves as a node runtime. Both paths are XML-escaped before being
dropped into the plist so a stray & or < in a path cannot break it. The
non-darwin crontab hint now prints the same two-argument form. Caller in
src/sync/cli.ts passes process.execPath and process.argv[1].

When config.auto.accepted is present but missing fingerprint or
acceptedAt, sync auto status used to interpolate the missing field and
print the literal 'undefined'. It now detects the malformed record, prints
a single line telling the user to re-run sync auto enable, and exits non
zero. The run command already fails closed on this case and is unchanged.
2026-08-28 06:21:06 -07:00
iamtoruk
5fe757b25a fix(plugins): codepoint-ordered signature canonicalization; sign fails loudly on unreadable files
localeCompare is locale/ICU dependent and fed the signed digest, so a plugin signed on one machine could false-reject on another (live even in ASCII: README.md vs codeburn-plugin.json order flips between locale-aware and codepoint comparison). All four sort sites now use plain codepoint order, commented as a canonicalization requirement. The sign script now throws on unreadable files instead of signing an incomplete list; the loader keeps skipping (its omission causes a digest mismatch and rejection, the fail-closed direction). New test drives the real sign script over a tree with mixed-case and non-ASCII names, so test and production canonicalization cannot diverge again.
2026-08-28 05:52:36 -07:00
iamtoruk
463f7416af fix(plugins): update plugin-signing tests for stderr+exitCode error handling
The plugin CLI commands now write polite errors to stderr with exitCode=1
instead of throwing. Update three test cases to check stderr and exitCode
instead of expecting rejects.toThrow().

- plugin add refuses unsigned source: check stderr contains 'signature'
- plugin add refuses existing destination: check stderr contains 'already installed'
- plugin remove refuses without --confirm: check stderr contains '--confirm'
2026-08-28 05:48:27 -07:00
iamtoruk
4912be1915 fix(plugins): polite one-line errors for plugin commands instead of stack traces
Convert user-facing plugin commands (info, verify, add, remove) to use
process.stderr.write() + process.exitCode pattern. Wrap internal helper calls
in try-catch at action boundary. Update tests to capture stderr and check
exitCode instead of expecting thrown errors.
2026-08-28 05:43:18 -07:00
iamtoruk
56dcc402d7 fix(plugins): reject tarball entries that escape the extraction dir before extracting
- Validate tarball entries with tar -tzf BEFORE extraction to prevent path traversal
- Reject entries that: start with /, contain .., start with ~, or contain \
- Prevents malicious/compromised servers from writing outside temp dir
- Test: create malicious gzipped tar with ../evil.txt entry and verify rejection
- Extraction only proceeds after successful validation
2026-08-28 02:48:09 -07:00
iamtoruk
1a1a099a73 feat(plugins): remote plugin install from the org receiver (store v1, CLI half)
- Dispatch plugin add <source> to local or remote flow based on path-like vs plugin-name pattern
- Remote flow: readSyncConfig, refresh OIDC token, fetch manifest with sha256, download tarball with integrity verification (50MB limit)
- Extract via system tar to temp dir, detect single top-level dir or files at root
- Verify manifest name matches requested name, hand to shared verify+install path
- Refactor verify+install into reusable helper for both local and remote flows
- Add tests for happy path, sha256 mismatch, manifest 404, no sync config
- Secure token refresh, sha256 verification on both manifest and download header

ponytail: no retries or resume; failed download just reruns
2026-08-28 02:42:07 -07:00
iamtoruk
42d1e1e184 feat(plugins): derived turn context in exporter input and per-plugin state dir (10C host)
- Add buildTurnContextMap() helper to compute turn context (turnId, category, retries, hasEdits, oneShot) for calls grouped by session
- Include optional turn field in exporter stdin JSON when call is resolvable to a turn
- Create CODEBURN_PLUGIN_STATE_DIR (~/.config/codeburn/plugin-state/<plugin-name>) before spawning exporters
- Pass CODEBURN_PLUGIN_STATE_DIR to exporter processes; plugins write state outside their signed tree
- Add tests for turn context inclusion, state directory creation, and calls without turns
2026-08-28 02:36:21 -07:00
iamtoruk
62b3d95ad0 fix(plugins): route exporter enrichment through the wire-guard sanitizer; merge per-call attrs across plugins
Per-call attributes and span attributes now pass through filterPluginAttributes to enforce the #1128 sanitizer, rejecting credential/path-like stringValues and dropping non-scalar values (array, object). Fixes security regression where raw strings bypassed sanitization. When multiple plugins contribute attributes for the same deduplicationKey, they now merge into one list instead of overwriting, enabling multi-plugin enrichment of the same call. Tests added for sanitization of path-like values, rejection of arrayValues, and merging across plugins.
2026-08-28 02:31:57 -07:00
iamtoruk
484daabf99 feat(plugins): sync exporter seam - per-call attributes and declared extra spans, wire-guarded (10B)
Loaded plugins with exporters/sync.mjs now enrich sync pushes with per-call attributes and declared extra spans (CB-3 phase 2). CLI spawns exporter child processes, passes batch calls via stdin, collects JSON output with perCall Map and extra spans array. All enrichment is guarded: perCall attrs attached to matching deduplicationKey, extra spans filtered by declared spanKinds, attributes filtered by declared syncAttributes, core keys never overwritten. Exporter timeout (30s), size cap (8MB stdout), and failures are handled gracefully - plugin contributes nothing on crash/timeout/bad JSON, stderr notice printed, push completes. Extra spans are capped at 2x calls.length and >64KB spans dropped. No ledger on CLI side for extra spans (plugin's responsibility). Dry-run shows exporter contributions. Wire is byte-identical when no exporters present.
2026-08-28 02:23:29 -07:00
iamtoruk
8b0e9af431 fix(plugins): sign and install plugin trees recursively; sections stay runtime-mutable
Closes security hole: plugin commands (executable .mjs files under commands/) are now part of the signed digest, preventing tampering. getPluginFilesList and sign-plugin.mjs getFilesList now walk directories recursively with relative POSIX paths, hashing all regular files while excluding codeburn-plugin.sig (the signature itself) and sections/ (runtime-mutable plugin output). plugin add copies the full tree recursively, preserving directory structure including commands/ and commands/subdir/*.mjs. Installed plugins verify correctly without CODEBURN_PLUGIN_DEV. checkForSymlinks now recurses to catch symlinks anywhere in the tree. Sections may change at runtime without breaking verification because they are excluded from the canonical digest.
2026-08-28 02:14:51 -07:00
iamtoruk
d6bdff6d2e feat(plugins): invoke declared plugin commands as child processes (10A)
Loaded, signature-verified plugins declaring capabilities.commands now register as top-level CLI commands that spawn the plugin's command entry file as a child process. New function registerLoadedPluginCommands(program, loads?) in src/plugins/cli.ts handles collision detection (built-ins win), missing entry file detection with clean error reporting, and exit code propagation. Tests cover all five scenarios: successful invocation, child exit code propagation, missing file handling, collision detection, and rejection filtering. Integrated into src/main.ts else branch to wire plugin commands into the CLI. E2E test (non-dev environment with real signing key) confirms end-to-end plugin invocation works.
2026-08-28 02:10:43 -07:00
iamtoruk
9616bbd0f5 fix(sync): fresh-machine schedule install, work-matching disclosure line, named drift causes 2026-08-28 01:26:48 -07:00
iamtoruk
a9c5d8b6ec fix(sync): plain-language meanings for every core field in the consent disclosure 2026-08-28 01:08:06 -07:00
iamtoruk
1e3a7228c8 fix(sync): status recomputes the acceptance fingerprint with the same input as run 2026-08-28 01:04:44 -07:00
iamtoruk
05e4b7cbc1 fix(sync): honest 7-day scope and stored work-matching choice in acceptance; shared push helper 2026-08-28 01:00:54 -07:00
iamtoruk
d92ddd71f4 feat(sync): consent-once auto-sync with acceptance fingerprint, receipts, and kill switch (CB-4)
Reused menubar-installer pattern for schedule installer. On non-darwin, prints crontab line to add manually. Auto block is optional in sync config; add-only and never migrates existing installs.
2026-08-28 00:54:14 -07:00
iamtoruk
c01b7be4b0 fix(plugins): derive keygen keyId identically to sign; pin release-key ids in tests
Fixes critical bug where keygen() used random keyId but sign() derived it from sha256 of public key PEM. This caused embedded release key (f40248d0) to not match actual derived id (499923ae), breaking plugin verification.

Now both keygen and sign derive keyId consistently from sha256(publicKeyPem).slice(0,4).hex.

Added tests:
- keygen and sign derive identical keyIds from same ephemeral key
- RELEASE_PUBLIC_KEYS map keys match their derived keyIds from embedded PEM values

End-to-end verified: signing with private key and verifying with embedded public key now works without CODEBURN_PLUGIN_DEV.
2026-08-28 00:35:36 -07:00
iamtoruk
67320432ca feat(plugins): ed25519 release-key verification and plugin add/remove (9b)
Ships ed25519 signature verification for plugins with two new components:

- src/plugins/keys.ts: RELEASE_PUBLIC_KEYS map with one release keypair
- scripts/sign-plugin.mjs: keygen and sign commands for plugin developers
- verifyPlugin() in loader.ts: validates ed25519 signatures, rejects unsigned plugins unless CODEBURN_PLUGIN_DEV=1
- plugin add <path>: installs signed plugins to ~/.config/codeburn/plugins/
- plugin remove <name> --confirm: removes installed plugins

All three gates pass: tsc clean, vitest zero new failures, smoke test complete.

Design decision: public keys stored as base64-encoded PEM format rather than raw 32-byte keys. Node.js crypto.verify requires PEM/DER format or KeyObject for ed25519; raw bytes alone fail. PEM is standard and portable.

Private key written to: /tmp/codeburn-signing/codeburn-signing-key.pem
2026-08-28 00:30:43 -07:00
iamtoruk
5a72bb35c0 test(plugins): pin deny-by-default rejection of unsigned plugins without CODEBURN_PLUGIN_DEV 2026-08-28 00:16:11 -07:00