Commit Graph
1171 Commits
Author SHA1 Message Date
Kai (Tam Nhu) Tran 1ee7cac555 fix: reject case-variant symlinked file paths (#1629)
* fix: reject case-variant symlinked file paths

* fix: validate requested case-variant symlink paths
2026-07-01 01:26:48 -04:00
Kai (Tam Nhu) Tran 343899f6c1 fix: prevent default profile credential collision (#1628)
* fix: prevent default profile credential collision

* fix: isolate default profile credential fallback
2026-07-01 01:15:45 -04:00
Kai (Tam Nhu) Tran 0f9a87619c fix: cap native quota profile refresh fan-out (#1627)
* fix: cap native quota profile refresh fan-out

* fix: preserve native quota live cache state
2026-07-01 01:09:01 -04:00
Kai (Tam Nhu) Tran 3621f8dcb1 fix: validate CCS Bar launch shim target integrity (#1626)
* fix: validate CCS Bar launch shim target integrity

* fix: execute verified bar shim bytes
2026-07-01 00:49:56 -04:00
Kai (Tam Nhu) Tran 05685d1c21 fix: keep agy websearch permissions enabled (#1625) 2026-07-01 00:45:09 -04:00
Kai (Tam Nhu) Tran 0180b62453 fix(bar): use nonce-bound probe auth (#1623) 2026-06-30 13:10:56 -04:00
Kai (Tam Nhu) Tran 138ead0e1e fix(logging): redact browser debug endpoint (#1622)
* fix(logging): redact browser debug endpoint

* fix(logging): redact prompt argv values
2026-06-30 13:07:46 -04:00
Kai (Tam Nhu) Tran f2843ad2ce fix: fail closed on websearch launch provisioning (#1621) 2026-06-30 13:00:41 -04:00
Kai (Tam Nhu) Tran 0527e276b1 fix: skip paused codex accounts in bar refresh (#1620) 2026-06-30 12:59:54 -04:00
Kai (Tam Nhu) Tran 396e01ab6f fix: bound bar raw socket probes (#1618) 2026-06-30 12:53:35 -04:00
Kai (Tam Nhu) Tran 2f1453e397 fix(auth): honor legacy unified default profiles (#1619) 2026-06-30 12:53:03 -04:00
Kai (Tam Nhu) Tran 4283c4665c fix(cursor): propagate daemon auth token (#1616)
* fix(cursor): propagate daemon auth token

* fix(cursor): align daemon auth token propagation
2026-06-30 12:37:41 -04:00
Kai (Tam Nhu) Tran 3f1dce30bc fix: close bar launch case bypass (#1613) 2026-06-30 12:33:46 -04:00
Tam Nhu Tran 045fc93285 test(glmt): align thinking signature coverage 2026-06-29 12:58:38 -04:00
Sergey Galuza cbcdb6ba62 fix(glmt): emit thinking signature as opaque string
generateThinkingSignature() returned an object
({type, hash, length, timestamp}) but Anthropic requires a thinking
block's `signature` to be a non-empty opaque STRING. The object made
the thinking block invalid, breaking the stream against reasoning
backends and surfacing as a false 502 "did not respond within 600s".

Return a deterministic base64 token instead (no Date.now()), and
narrow ThinkingSignature to a string alias so existing imports stay
intact. The signature is only ever assigned, never read as an object,
so consumers are unaffected. Update the existing unit test to the
corrected string contract.

Built [OnSteroids](https://onsteroids.ai)
2026-06-29 13:27:09 +02:00
Sergey Galuza 37d2bae001 test(glmt): assert thinking signature is a non-empty opaque string
Add two contract tests on the public proxy path
createAnthropicProxyResponse: JSON and SSE. Anthropic requires a
thinking block's signature to be a non-empty opaque string, but ccs
currently fabricates the signature as an object via
generateThinkingSignature(), which breaks the stream against reasoning
backends.

Built [OnSteroids](https://onsteroids.ai)
2026-06-29 13:26:16 +02:00
Kai (Tam Nhu) Tran 9dd9bf2978 feat(websearch): add agy provider and deprecate gemini cli fallback (#1607)
Google retired the gemini CLI on 2026-06-18, so the gemini websearch fallback no longer
works. Add agy (Antigravity) as the primary CLI websearch provider end to end: runtime spawn
in websearch-transformer.cjs (agy --dangerously-skip-permissions --print-timeout Ns -p),
detection (agy.ts), config schema and defaults, hook env, status, dashboard persistence, and docs.

The legacy gemini provider stays present but is marked deprecated for enterprise users who
retain access. Image analysis already supported the agy provider (no change). The CLIProxy
gemini quota fetcher (Gemini API OAuth, not the cli binary) is untouched.

Validation: typecheck, lint, and the websearch + config + web-server unit suites pass.
2026-06-27 10:01:25 -04:00
Thibault Jaigu a167f94e1b feat: add Requesty as an OpenAI-compatible provider (#1604)
Add a Requesty provider preset to the provider preset catalog, mirroring the existing OpenRouter preset (base https://router.requesty.ai/v1, default model openai/gpt-4o-mini, OpenAI-compatible).
2026-06-26 15:41:24 -04:00
Thieu Nguyen ba0e768fbf fix(codex): normalize CLIProxy responses routes (#1605)
Normalize Codex Responses base URLs so CCS-backed Codex launches use /backend-api/codex on the original CLIProxy backend. Share the Codex Responses route builder with ccsxp provider repair, and repair stale native Codex provider auth blocks when env_key token injection is used.
2026-06-26 15:41:15 -04:00
Kai (Tam Nhu) Tran 482868ad97 Merge pull request #1596 from kaitranntt/kai/feat/1595-bar-multi-profile-quota
feat(bar): per-profile subscription quota for ccs auth + ccsx auth accounts
2026-06-24 17:01:40 -04:00
Tam Nhu Tran b514986ddd fix(bar): short-TTL parked rows + keep valid codex subs active
Addresses two review focus areas:

- Stale Parked Rows: profiles with no on-disk credentials cached their parked
  row for the full quota TTL, so a fresh login stayed dimmed for up to 10 min.
  Parked rows (quotaStatus 'unsupported') now use a 30s TTL so a new login is
  picked up within seconds.
- Codex Fallback: a named codex profile whose token authenticated but whose
  response lacked core windows was downgraded to a parked/needsAuth row, hiding
  a real subscription. It now emits an active (quota-less) row; only the bare
  default still falls back to global local session data.

Also fixes a latent coalescing bug the short TTL exposed: a synchronous return
inside the pending IIFE cleared state.pending during its own assignment, leaving
a stale resolved promise that the next call reused. The IIFE now yields once so
the assignment lands before the finally clears it.
2026-06-24 00:52:55 -04:00
Tam Nhu Tran a1a565177e fix(codex): route codex CLI to /backend-api/codex on original CLIProxy backend
The Codex CLI provider config uses wire_api = "responses", so the Codex CLI
appends "/responses" to its base_url. buildCodexCliproxyProviderBaseUrl derived
the base URL from the backend-aware route helper, which returns the bare root for
the original backend. Codex then called http://127.0.0.1:<port>/responses, which
the original CLIProxy binary does not serve, producing a 404 on every request.

The original backend serves the Codex Responses API only at /v1/responses and the
chatgpt_base_url-compatible alias /backend-api/codex/responses. Use that alias for
the original backend; keep the provider-scoped alias for the Plus backend.

Closes #1597
2026-06-24 00:08:02 -04:00
Tam Nhu Tran 7b610f0e82 fix(bar): keep is_default on cache-fallback rows
The collector cached each row before the default profile was resolved, so the
cache-fallback path (getCachedNativeAccountRows) served the default account with
is_default:false -- the UI then lost default ordering/tagging when /summary
served from cache. Write the resolved default flag back onto the cached copy so
the fallback stays consistent with a fresh collection.
2026-06-24 00:03:20 -04:00
Tam Nhu Tran a0a2dd00fa fix(bar): cache expired profiles and gate codex local fallback to the default
Addresses two review focus areas:

- Reauth polling: a 401/expired profile now caches its dimmed reauth row and
  opens a cooldown, so it is shown parked and re-checked at most every 10 min
  instead of being re-polled (and re-401'd) on every /summary refresh.
- Wrong fallback: the global ~/.codex session-log fallback now applies ONLY to
  the bare default account. A named codex profile with no on-disk auth parks
  instead of borrowing the default's local usage (no misattribution).
2026-06-23 23:47:06 -04:00
Tam Nhu Tran ed86a089ba feat(bar): enumerate ccs/ccsx subscription profiles with per-profile quota
Replace single-account native quota collection with per-profile enumeration:
read ccs auth (Claude) and ccsx auth (Codex) profile registries plus the bare
~/.codex login, fetch each profile's quota under the existing TTL cache,
per-profile circuit breaker and 2.5s summary deadline. Emit surface, profile
and is_subscription wire fields; account_id becomes "<surface>:<profile>".

Active profiles (valid token) are live-polled and shown undimmed regardless of
default status; profiles without resolvable on-disk credentials are parked
(cache-only, dimmed). Claude per-profile credentials are read from disk only --
no macOS Keychain access -- so a profile without a credentials file renders as
needs-reauth instead of triggering a keychain prompt.
2026-06-23 22:56:38 -04:00
Kai (Tam Nhu) Tran fb9509d9be fix: make CCS Bar launch descriptor use private shim
Use a private safe ccs.js shim for native CCS Bar launch descriptors so symlinked Bun installs do not fall back to an app environment without node on PATH.
2026-06-23 12:57:33 -04:00
Tam Nhu Tran 239f83df9d test(bar): cover ccs bar install --await-quit relaunch path 2026-06-22 21:07:13 -04:00
Kai (Tam Nhu) Tran 87eb4f2154 Merge pull request #1414 from cerebrixos/tuning-engines-provider
Add Tuning Engines provider
2026-06-22 17:18:57 -04:00
Kai (Tam Nhu) Tran 2e702b1d35 Merge pull request #1574 from ReWiG/fix/stream-options-include-usage
fix(proxy): forward stream_options.include_usage to OpenAI-compatible upstreams
2026-06-22 16:16:40 -04:00
Kai (Tam Nhu) Tran 05c203aff2 Merge pull request #1575 from walker1211/codex/fix-cliproxy-provider-routes
Fix CLIProxy provider routes for original backend
2026-06-22 16:11:28 -04:00
Tam Nhu Tran 6ed5b2d62b feat(bar): live Codex usage sync with force refresh and spend-chart periods
Codex quota in the menu bar came only from frozen local session logs, so it
showed stale data ("older session") that no refresh could update. Fetch it live
from the same source the dashboard uses, under the existing Claude-style safety
controls (10-min TTL, in-flight coalescing, 429 backoff, circuit breaker,
serve-stale), falling back to local logs when offline or rate-limited. A success
with no usable 5h/weekly window keeps the local reading rather than caching a
contentless row. The footer refresh and a new inline button on the Codex card
force a live pull past the open debounce, and a forced /summary re-pulls native
rows while serving the last-known cached rows if the live pull overruns its
budget, so the Claude/Codex cards never blank mid-refresh.

The spend strip gains a Today / 7d / 30d selector (default 7d), a taller chart,
and bottom time-axis labels (local hours for today, weekday for 7d, dates for
30d). The analytics endpoint now exposes a 24-bucket hourly series for today,
converted from the pipeline's UTC hour keys to the user's local clock so the
intra-day chart matches the dashboard.
2026-06-20 18:37:18 -04:00
Kai (Tam Nhu) Tran e37a87c3a2 fix: ignore malformed bar analytics date keys (#1556)
* fix: ignore malformed bar analytics date keys

* style: apply prettier formatting to dynamic imports
2026-06-20 16:23:22 -04:00
walker1211 99ed8090b1 fix(cliproxy): 按 backend 生成 provider 路由 2026-06-20 13:40:23 +08:00
VC b889a758b8 docs: normalize Tuning Engines provider preset 2026-06-19 17:02:52 -04:00
ReWiG 2aaad43fd7 fix(proxy): forward stream_options.include_usage to OpenAI-compatible upstreams
Claude Code's status line and the session log showed 0 tokens for every
streaming response routed through the OpenAI-compatible proxy. The root
cause was that the upstream request did not include
`stream_options: { include_usage: true }`, so the provider (LiteLLM and
other OpenAI-compatible endpoints) never emitted the final SSE chunk
that carries `usage`. The proxy's stream parser was already wired to
forward that chunk into an Anthropic-shaped `message_delta` event but
had nothing to forward.

Set `stream_options.include_usage` whenever the incoming Anthropic
request is streamed. Non-streamed requests are unaffected.

Ref: https://platform.openai.com/docs/api-reference/chat-streaming
     (search 'include_usage')
2026-06-19 21:45:47 +03:00
Kai (Tam Nhu) Tran 6e64a3ac6e Merge pull request #1573 from tiennm99/fix/update-provider-model-templates
fix(config): update provider default models
2026-06-19 10:00:20 -04:00
Tam Nhu Tran 34123a62a6 fix(usage): price updated provider defaults 2026-06-19 09:57:49 -04:00
Kai (Tam Nhu) Tran 1a0398579a fix: degrade WebSearch launch provisioning failures (#1571) 2026-06-18 22:56:20 -04:00
Kai (Tam Nhu) Tran b6ef4e5782 fix(cliproxy): guard unsupported Qwen account auth 2026-06-18 21:34:27 -04:00
Tam Nhu Tran 1462823be8 fix(logging): harden structured trace redaction
Redact StageOptions error payloads and summarize debug launch args.

Propagate request IDs through Cursor daemon and dashboard completion logs.

Mark remaining P2/P3 maintainability targets as partial instead of overclaiming.
2026-06-18 18:48:13 -04:00
Tam Nhu Tran 2f94f35ec3 feat(lint): P7 enforcement gates (no-new-throw-error + max-lines) + docs
Epic P7. Locks in the epic's gains with ESLint gates so the adoption work
does not regress.

- ccs/no-new-throw-error (error): custom flat-config rule that flags NEW
  throw new Error(...) outside a generated baseline allowlist. Forces the
  typed-error taxonomy (src/errors/error-types.ts). Existing 338 sites are
  grandfathered in eslint-rules/throw-error-baseline.json; only NEW violations
  error. Rule normalizes the filename to repo-root-relative to match baseline
  keys regardless of how ESLint reports paths.
- max-lines (warn, 400, skipBlankLines/skipComments): warns on files over
  400 LOC (goal of P5/P6 god-file splits). Currently 51 warnings on the
  not-yet-split god-files (P6 territory).
- scripts/generate-throw-error-baseline.js: emits the allowlist from raw
  source (superset of real throws; never undercounts). Run after intentionally
  grandfathering a site, or quarterly to prune.
- tests/unit/eslint-rules/no-throw-new-error.test.ts: rule logic (flags
  off-allowlist, passes on-allowlist/typed/rethrow, line-sensitivity).
- docs/code-standards.md: Lint Enforcement Gates section.
- docs/logging-contract.md: error.code -> ExitCode table (from P4).

validate + validate:ci-parity green.
2026-06-18 18:48:13 -04:00
Tam Nhu Tran 87aeb8f193 feat(logging): P3 hotpath console.error migration + redaction gate (928->267)
Epic P3. Migrates hotpath console.error/warn to the structured logger
(diagnostics) or process.stderr.write (user-facing), and adds a redaction
safety gate so the migration cannot leak credentials.

Redaction gate (MR1):
- log-redaction: scrub known credential token shapes (sk-ant, sk-, xoxb,
  ghp, glpat, AIza, JWT bodies, api_key=, Bearer/Basic/Token scheme) in
  string values, Error.message, AND the log message string (defense-in-depth).
- logger: message now passes through maskSecretTokens.

tool-sanitization-proxy: deleted the private file-logging subsystem
(initLogFile/writeLog/log/warn, logFilePath, debugMode); 13 call sites now
route through the existing createLogger('cliproxy:tool-sanitization-proxy').

Sweep (~120 diagnostic -> structured createLogger; ~540 user-facing -> stderr):
- diagnostics converted across proxy, web-server/routes, glmt pipeline, quota
  fetchers, executors, delegation, session-bridge, https-tunnel-proxy.
- user-facing CLI output (flows, arg-parser usage, installers, prompts, adapter
  launch errors, error display) moved to process.stderr.write (preserves stderr).
- src/utils/error-manager.ts reclassified CLI-UX-exempt (user-facing display).

Metric: hotpath console.error 928 -> 267 (71%); createLogger files 35 -> 64.
Residual 267 is user-facing CLI output (not diagnostics); documented in
docs/hardening-debt-burndown.md. Redaction gate makes further conversion safe.

Tests: hotpath-redaction-regression (12 token shapes); updated delegation-handler,
arg-parser, model-warnings spies (console.error -> process.stderr.write).
validate + validate:ci-parity green.
2026-06-18 18:48:12 -04:00
Tam Nhu Tran 5e1b8640ab feat(logging): P2 traceability foundation - requestId wrap, daemon forwarding (#NNN)
Epic P2. Closes the three real traceability gaps so every diagnostic log can
carry a requestId from origin (ccs.ts main) through HTTP edges and spawned
daemons.

- log-context: add REQUEST_ID_HEADER/ENV/PATTERN, resolveRequestIdFromEnv,
  forwardRequestIdEnv. runWithRequestId now reuses a forwarded CCS_REQUEST_ID
  when well-formed (child re-anchor), else mints fresh.
- request-logging-middleware: wrap the Express dashboard handler chain in
  withRequestContext so downstream route-handler logs carry requestId (mirrors
  src/proxy/server/proxy-server.ts, which is untouched prior art).
- forward CCS_REQUEST_ID at the 4 child-daemon spawn sites: delegation
  headless-executor, cursor-daemon, cursor-profile-executor, copilot-executor.
- cursor-daemon-entry: re-anchor via runWithRequestId so daemon startup logs
  correlate with the spawning CLI invocation (ALS does not cross spawn).
- logger adoption toe-hold: delegation/session-manager (load/save failures) and
  docker/supervisord-lifecycle (restart failure) now use createLogger.

api/channels/shared have no touchable diagnostic console.error (CLI-UX only or
pure data); dispatcher's only diagnostic is in pre-dispatch.ts, owned by plan
#1165. Those defer to P3's full per-site sweep.

Tests: request-context-middleware (handler log requestId === header),
request-id-forwarding (env resolve/reject, re-anchor, forwardRequestIdEnv).
validate + validate:ci-parity green.
2026-06-18 18:48:12 -04:00
Tam Nhu Tran 95a2864ef3 feat(hardening): P1 maintainability metrics baseline + freshness gate (#1561)
Epic P1. Adds maintainability-metrics script (typed-error adoption, createLogger coverage, hotpath console.error, files>400 LOC), merges maintainability block into hardening-inventory report, adds 30-day freshness gate to ci-parity-gate.sh, re-baselines burndown 2026-06-18. Local validate + validate:ci-parity green.
2026-06-18 18:48:12 -04:00
Kai (Tam Nhu) Tran 49a7b9dc85 fix(cliproxy): use root URL for Claude provider (#1554)
Built-in Claude provider now uses the CLIProxy root URL instead of /api/provider/claude (which 404'd since base CLIProxy registers /v1/messages at root). Repairs stale local Claude settings, keeps non-Claude providers on their scoped routes, and applies the same root-URL rule to the ccs api create --cliproxy-provider claude bridge path via a shared buildCliproxyProviderPath helper. Closes #1545.
2026-06-16 10:23:48 -04:00
Kai (Tam Nhu) Tran 3fa4a342f9 test(bar): harden bar-probe auth coverage; drop dead proxy shim (#1555)
* test(bar): cover socket-level 401/403 auth detection and liveness-poll rogue rejection

Add two new describe blocks to bar-command.test.ts:

1. `defaultFindRunningServer: socket-level 401/403 classifies authRequired=true`
   Drives `net.connect` via mock.module('net') to verify that status lines
   401 and 403 off the wire set authRequired=true.  A correct-token 200 must
   not set authRequired.  Prior tests bypassed the real status-line parser by
   injecting authRequired via deps; these tests couple to the actual branch.

2. `defaultWaitForServerLive: rogue 200 without matching token is rejected`
   Uses the same net mock pattern to verify that a 200 carrying a wrong
   x-ccs-bar-token never causes the liveness poll to resolve (rogue reflector
   cannot pass).  Correct token resolves immediately.

Export `defaultWaitForServerLive` from launch-subcommand.ts so the direct
unit test can import it without forcing a full handleBarLaunch invocation.

Both test groups are behavior-coupled: removing the relevant branch in
production causes the tests to fail (verified under mutation).

* refactor(bar): drop dead ensureLoopbackNoProxy proxy shim

The probe now uses raw net.connect() which never consults proxy env vars
(undici was fully removed in an earlier PR).  ensureLoopbackNoProxy()
permanently mutated process-wide NO_PROXY/no_proxy on every discovery call
with no effect on the actual network path.

Verified zero remaining references to ensureLoopbackNoProxy outside the
declaration and call site that are now removed.
2026-06-16 09:30:01 -04:00
Kai (Tam Nhu) Tran f25a1015ed fix(bar): authenticate reused local server probes (#1546)
Closes a spoofed-loopback-200 bar.json poisoning vector with a per-user 0600 capability token. The real bar server echoes its file-derived token on /bar/* responses; the launch probe verifies the echoed token against the locally-read file (fail-closed) before reusing a server, so a rogue loopback process that cannot read the token file is rejected.
2026-06-16 09:08:21 -04:00
Kai (Tam Nhu) Tran c0409862d2 fix: handle auth-protected bar launch probes (#1551)
Raw-socket probe detects auth-protected (401/403) bar servers, reuses them, and kills the orphaned detached server on auth timeout. Integrated with the non-blocking priority probe.
2026-06-16 08:45:41 -04:00
Kai (Tam Nhu) Tran 361328c788 fix: enforce tier lock during quota preflight (#1550)
Tier lock now fails closed in quota preflight when no healthy locked-tier account is available, instead of falling through cross-tier.
2026-06-16 08:45:35 -04:00
Kai (Tam Nhu) Tran 06e83091be fix: bound Codex rollout tail reads (#1547)
Replaces unbounded rollout-file reads with a bounded backward tail (1 MiB cap), preserving last-N-lines semantics.
2026-06-16 08:45:30 -04:00