feat: add Amazon Quick local token usage provider - #316
Open
solangegamboa wants to merge 1 commit into
Open
solangegamboa wants to merge 1 commit into
solangegamboa wants to merge 1 commit into
Conversation
Reads real per-turn token_usage (input/output/cache read/write) from message_assistant_complete events in ~/.quickwork sessions.db. A single database holds every session, so multi-session totals are the natural sum; enterprise/team installs with multiple profiles are all scanned. Honours $QUICKWORK_HOME and custom scan roots. Aborted zero-token turns dropped; deleted sessions stay counted until the scan cache resets (Kiro/Aside policy). Validated against real local data: overall 502,798,367 tokens and today's 1,580,845 match the SQL reference exactly.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add local token-usage support for Amazon Quick (Quick Suite — Amazon's desktop AI assistant for macOS/Windows) through the existing provider-agnostic aggregation pipeline.
~/.quickwork/sessions/sessions.db(single-profile installs) and~/.quickwork/profiles/*/sessions/sessions.db(enterprise/team installs), plus optional custom scan roots, de-duplicating resolved database paths.token_usage, model); conversation bodies (full_content,session_messages.content) and credentials are never read.message_assistant_completeevents, whosedataJSON carries atoken_usageobject withinput_tokens/output_tokens/cache_read_tokens/cache_write_tokens. This is source-recorded usage, not the byte estimate Kiro falls back to.session_idcolumn separates them), so multi-session totals are the natural sum of all events — no per-session file scanning. Multiple profiles are all scanned.LocalAdditionalUsageCachelike Kiro/Aside: one scan per refresh feeds daily and enrichment, and each scan merges with previously-seen entries (dedupKeepMax(existing + loaded)). Deleting a session removes its events, so a plain rescan would make today's total go down; the merge keeps already-counted usage until the cache resets.sessions.dbunder a custom root, a busy WAL recovery) are skipped; an all-failed rescan returns[], which the merge treats as "nothing new" rather than zero usage.QUICKWORK_HOMEas a location override and include Amazon Quick in daily/weekly/monthly/active-block aggregation while preserving existing providers.session_eventsschema) and update the provider-registration and tab-layout guards.Type of change
Data semantics and limitations
timestamp, so tokens land in the day / 5-hour block they were generated in.token_usage.modelfield is Quick's plan-mode label ("balanced", etc.), not a public price-table model, so cost is marked unavailable rather than priced against an unrelated model.UI changes
None. The existing provider tab and aggregates display Amazon Quick automatically once data is present.
Validation
swift buildand fullswift testpass locally: 1088 tests, 12 skipped, 0 failures. The 10 newAmazonQuickUsageTestscover bucket parsing, multi-session summation in one DB, multi-profile + single-profile summation, thetypefilter, timestamp→local-day attribution, zero-token drop, unreadable-DB skip, malformed-JSON skip, provider registration + custom-root support, and shared-scan enrichment totals.message_assistant_completerows minus 7 zero-token aborted turns) and today's 1,580,845, matching ajson_extractsum over the same events. No personal database or diagnostic snapshot is included in this PR.Checklist
swift buildandswift testpass locally