Skip to content

Port upstream 0.67.0: Add xKiro daily free-token provider - #663

Closed
Finesssee wants to merge 2 commits into
port/upstream-0.67.0from
port/micro-0.67.0-xkiro
Closed

Finesssee wants to merge 2 commits into
port/upstream-0.67.0from
port/micro-0.67.0-xkiro

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Summary

Adds the xKiro provider (upstream 0.67.0). It reads the documented free-token quota from GET https://api.xkiro.com/v1/usage with a bearer API key (XKIRO_API_KEY or the key saved in Preferences) and shows it as one daily lane, "Daily free tokens".

  • Primary lane: used_today / limit_per_day, window 1440 minutes, resets at the next 00:00 UTC. A limit of 0 counts as fully used.
  • The paid wallet balance and windows are ignored, so paid balance is never shown as free-token headroom.
  • Missing or null counters stay missing (no invented zero). A payload with no usable counter, a wrong object, or a negative, fractional, non-numeric or above-2^53-1 counter is reported as unrecognized without echoing the response.
  • Only an explicit plan: null maps to "Pay as you go". A named plan is shown trimmed; email is shown when present.
  • HTTP 401/403/429/5xx/other are classified into friendly errors; Retry-After is bounded to 10 s; response bodies are size-capped.
  • Default disabled, no credits, dashboard https://xkiro.com, brand #52C99B, source modes auto + api.
  • No token accounts (upstream has none).

Upstream reference

  • Release bullet: v0.67.0, "xKiro provider".
  • Upstream PR xKiro: add Free daily token allowance and rate-limit tracking steipete/CodexBar#3729; commits 9090006d3, 68c386867.
  • Tag-pinned (v0.67.0) files: Sources/CodexBarCore/Resources/Plugins/xkiro.ts, Sources/CodexBarCore/Providers/XKiro/XKiroProviderDescriptor.swift, Sources/CodexBar/Resources/ProviderIcon-xkiro.svg, Tests/CodexBarTests/XKiroPluginTests.swift, docs/xkiro.md.

Ported / Deferred

Ported: everything above, plus the full new-provider recipe from docs/PORTING.md section 5 (ProviderId + metadata, provider module, factory arm, token-account arm, API-key catalog entry, dashboard and desktop icons, desktop catalog, tray dashboard link, Preferences short label, docs, README row).

Deferred / limits:

  • Live API behavior is unverified. Upstream shipped against the documented example only; the fixtures here are the same synthetic shape.
  • Upstream's plugin-engine daily-reset fix is replaced by an injected clock (now) in the Rust parser, so the reset is deterministic in tests.
  • No bounded host-level retry beyond mapping Retry-After into the error message.
  • No token accounts (none upstream).
  • CHANGELOG not touched; the README provider count is already stale, so only a matrix row was added.

Validation

Toolchain cargo +1.98.0, via the E-core wrappers, slot-4.

  • cargo fmt --all: clean
  • cargo clippy --workspace --all-targets -- -D warnings: pass
  • cargo test -p codexbar -- --test-threads=4: 2175 passed, 0 failed, 1 ignored (pre-existing). xkiro filter: 15 passed.
  • cargo test -p codexbar-desktop-tauri -- --test-threads=4: one failure, commands::tests::bootstrap_payload_exposes_every_provider_variant, on the final size assertion (left: 80, right: 79). Every active provider, including xkiro, is present in the catalog (the earlier "missing provider" assertion passed). The catalog includes deprecated providers that are enabled in the machine's real (DPAPI-protected) settings, so the count is off by one on this workstation independent of this change; I could not read the settings to confirm which provider. Needs a clean-profile run (hosted CI) to confirm.
  • pnpm test (apps/desktop-tauri): 402 passed, 67 files (one unrelated timing flake on the first run under load, clean on rerun).
  • pnpm run lint: only pre-existing warnings in untouched files. pnpm run build: pass.
  • No file crossed 1000 lines; provider.rs was already over.

Affected areas

  • Provider (Rust): new providers/xkiro, ProviderId::XKiro, factory, API-key catalog
  • Desktop UI: provider icon and catalog, tray dashboard link, Preferences API short label
  • CLI dashboard: embedded icon
  • Docs: docs/PROVIDERS.md, README.md
  • Tray icon rendering / float bar / settings chrome (no change beyond the new provider entry)

UI proof

Pending: coordinator will capture CUA proof on a fresh build.

@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Thermo-nuclear review

Reviewed against the upstream v0.67.0 xkiro.ts spec and the repo conventions. Behavior matches the spec: fixed origin, bearer auth, parse rules, HTTP mapping, injected-clock midnight reset, strict plan === null pay-as-you-go, wallet and windows ignored. Registration is complete and consistent with Neuralwatt/Deepgram (exhaustive factory arm, token-account arm, api-key catalog, icons, tray/settings sets). No file approaches 1000 lines (mod.rs 379, tests.rs 267). No new dependencies, no secret logging, error bodies are never echoed.

Findings (all small, all in rust/src/providers/xkiro/mod.rs):

  1. Tri-state Counter enum leaks through the whole module. Only limit_per_day needs the absent-vs-null distinction; used_today and remaining collapse both to "no value". The enum plus .value() accessor adds a concept every reader has to hold. Reframe as Option<u64> counters plus one uncapped: bool (limit was explicit null); the enum, the accessor and the Counter::Null matches disappear.
  2. plan: Option<Option<String>>. Nested option resolved to a login-method string later in a match. Resolve it once at parse time to login_method: Option<String>; the result builder loses a branch.
  3. result_from_usage builds four ProviderDisplayDetail rows with copy-pasted blocks (two of them for the same allowance row). Build the rows as data and fold them through the existing with_display_detail(Option<_>) boundary.
  4. 429 message rounds with {:.0}, so a Retry-After: 0.5 renders "retry after 0s". Print the bounded value as is.

Left as is, with reasons:

  • Hand-walking serde_json::Value instead of #[derive(Deserialize)]: the tri-state limit and upstream's tolerant user/plan handling (a wrong-typed email is ignored, not a parse failure) would need custom deserializers, which move the complexity instead of deleting it.
  • Private format_count: the repo has no canonical thousands-separator helper (seven private copies in other providers); consolidating is a separate cross-provider change.

Fixes follow in one commit.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Thermo-nuclear review fixes landed (commit "Address thermo review", 0472ff8). Fixes by Codex gpt-6-luna (xhigh); verified and validated by Claude.

Fixed, all in rust/src/providers/xkiro/:

  1. Counter enum removed: counters are Option<u64> plus one uncapped: bool.
  2. plan: Option<Option<String>> resolved at parse time to login_method: Option<String>.
  3. Detail rows built as data and folded through with_display_detail(Option<_>).
  4. 429 message prints the bounded Retry-After as is (0.5s, not 0s); test added.
  5. New: counters now accept only unsigned JSON integers. The spec says "not string/bool/float/negative", and the old code accepted 5.0/1e3. Tests updated.

Left as is: hand-walking serde_json::Value and the private format_count, for the reasons in the review.

Commands run: cargo +1.98.0 fmt --all -- --check, cargo +1.98.0 clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings, cargo +1.98.0 test --manifest-path rust/Cargo.toml --lib xkiro (15 passed). Tauri crate and frontend are untouched, so not re-run. No user-visible UI change.

@Finesssee

Finesssee commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

CUA proof

Build commit: 0472ff8d068f6c0091be4675f1879d8a89f0c3c0 (debug build via pnpm --dir apps/desktop-tauri run tauri:build:debug, fresh rebuild).

Proof-only patches (throwaway, restored, never committed):

  • root Cargo.toml [patch.crates-io] dirs = <local shim> so home/config/data dirs are isolated under CODEXBAR_PROOF_HOME.
  • rust/src/providers/xkiro/mod.rs: credential target renamed to codexbar-xkiro-proofonly; usage_url overridable via CODEXBAR_PROOF_XKIRO_URL (points at a local mock, so the real request + parser path runs; TLS/URL validation untouched in shipped code).

Setup: isolated profile, dummy XKIRO_API_KEY, python mock of /v1/usage (payg fixture, bearer auth checked; server log shows 2 requests, auth_ok=True). Driven with cua-driver CLI in background only (UIA invoke / set_value, no foreground, no global input), windows on the second monitor. Launch: launch.sh trayPanel payg.

# Assertion Result
1 No real email/account from the user's machine visible (only mock [email protected]) PASS
2 xKiro appears in tray panel with data fetched through the real fetch/parse path from the mock PASS
3 Daily free tokens: 2% used, 124,035 used / 5,000,000 allowance / 4,875,965 remaining, reset 00:00 UTC, plan "Pay as you go" PASS
4 Dark theme still applied under theme: auto PASS
5 Settings > Providers lists xKiro with icon, detail pane shows same usage PASS

Screenshots (local, not committed): %LOCALAPPDATA%\Win-CodexBar\port-audit\proof\663\shots\ (tray-payg.png, settings-providers.png, settings-providers-xkiro.png).

Not exercised: pro / uncapped / exhausted fixtures (covered by unit tests in providers/xkiro/tests.rs).

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Port re-review: xKiro provider (#663, GAP row 15 of 0.67.0)

Re-checked the branch at the current head 0472ff8d against the 0.67.0 manifest spec for the xKiro provider item (upstream xkiro.ts + XKiroProviderDescriptor.swift, steipete#3729, commits 9090006/68c386867) and the thermo-review/fix/proof thread.

What I verified at the current head:

  • All four thermo findings fixed in 0472ff8, confirmed present in the code: (1) the tri-state Counter enum is gone — counters are Option<u64> plus a single uncapped: bool (limit_per_day == null); (2) plan resolves at parse time into login_method: Option<String> (only an explicit plan: null maps to "Pay as you go"); (3) detail rows are built as data and folded through with_display_detail(Option<_>); (4) the 429 message prints the bounded Retry-After as-is (retry_after_seconds returns f64, formatted without {:.0}, so 0.5 renders 0.5s), and counters now accept only unsigned JSON integers (the follow-up strictness fix, 5.0/1e3 rejected).
  • Core behavior: fixed origin GET https://api.xkiro.com/v1/usage, bearer key, one daily lane used_today / limit_per_day, 1440-minute window, next-00:00-UTC reset via the injected clock; limit 0 counts as fully used; wallet and windows ignored; missing/null counters stay missing (no invented zero); a payload with no usable counter, wrong shape, negative/fractional/non-numeric/above-2^53-1 counters reports unrecognized without echoing the response; Retry-After bounded to 10 s; bodies size-capped.
  • Registration: complete per the new-provider recipe — ProviderId::XKiro, brand #52C99B, default-off, factory/token-account/api-key-catalog arms, dashboard https://xkiro.com, tray/settings sets, icons, docs/README rows.
  • Existing evidence at this head: thermo review (4 findings + 1 follow-up strictness fix, all landed), CUA proof at 0472ff8d (real fetch/parse path against a local mock through a throwaway credential-target/URL override; daily 2%, counts, reset, "Pay as you go", dark theme, settings pane; mock server log shows bearer-checked requests).

Result: no new findings. Files under the cap (mod.rs 379, tests.rs 267); no dependency; no secret logging. The "live API unverified" caveat is carried from upstream and documented in the PR body.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

UI proof (browser-use)

Combined build of integrate/v0.70.0-ports at ddd85594 (all 40 port PRs and the follow-ups). Debug desktop build in proof mode, isolated config/data dirs, driven by browser-use over the WebView2 DevTools protocol with DOM events only (no mouse or keyboard input, no focus changes). All data is synthetic: local mock servers for L1, a seeded usage snapshot plus synthetic local logs for L2.

Scenario Check Result
L1 tray (mock servers) #663 xKiro: 2% of daily free tokens, 124,035 / 5,000,000 / 4,875,965, Pay as you go PASS
L1 mock request logs #663 xKiro mock: GET /v1/usage with the bearer PASS

Every surface also passed the privacy check (no email-like text, account e-mail nodes or profile paths in the DOM) and theme auto rendered dark on the tray flyout, float bar and settings windows.

Validation at ddd85594: cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test -p codexbar (3567 passed, 0 failed) and cargo test -p codexbar-desktop-tauri (606 passed, 0 failed). Screenshots were captured for each scenario and kept with the local proof kit.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Shipped in v0.70.0: this PR's head is included in main via #735 (merge commit 9d0a37a). Closing as integrated.

@Finesssee Finesssee closed this Oct 3, 2026
junglesub-bot Bot pushed a commit to junglesub/Win-CodexBar that referenced this pull request Oct 4, 2026
…n provider (registry merged next to llmman/DevPass)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant