Commit Graph

81 Commits

Author SHA1 Message Date
Nikketryhard
146be139a2 fix: re-enable tool stripping after testing
With tools present, LS enters full agentic mode doing multi-turn
tool calls (file searches, terminal commands, etc.). A simple
weather question caused 40+ Google API calls in 120s before timeout.
Tool stripping is required to maintain single-turn behavior.
2026-02-14 22:18:02 -06:00
Nikketryhard
3e3af85798 feat: add proxyctl daemon manager, fix standalone LS cleanup
- Add proxyctl CLI script for systemd service management
- Add systemd user service file for background operation
- Fix standalone LS kill: properly track real LS PID via pgrep
  and use sudo kill for cross-user cleanup on shutdown
- Remove deprecated scripts (dns-redirect, iptables-redirect,
  mitm-wrapper, standalone-ls, parse-snapshot)
- Disable tool stripping in MITM for tool call investigation
- Update GEMINI.md with CLI tools documentation
2026-02-14 22:14:00 -06:00
Nikketryhard
f64f007421 fix: reduce GetCascadeTrajectory log spam from debug to trace 2026-02-14 21:43:36 -06:00
Nikketryhard
b965be3f60 feat: add reactive streaming and remove dead panel stream code
- Subscribe to StreamCascadeReactiveUpdates for real-time cascade state diffs
- Fall back to timer-based polling if streaming RPC unavailable
- Remove StreamCascadePanelReactiveUpdates code (dead end, only has plan_status/user_settings)
- Remove debug diff file-saving code
- Add stream_reactive_rpc() helper to backend
2026-02-14 21:39:04 -06:00
Nikketryhard
3d7a7f492b fix: reduce poll intervals for smoother streaming
Streaming poll: 800-1200ms → 150-250ms (5x faster)
Sync poll: 1000-1800ms → 200-400ms (4x faster)

Verified via STEP_DUMP instrumentation that the LS updates
plannerResponse.response incrementally during GENERATING status,
so faster polling yields smoother progressive text delivery.

Also restructured streaming to emit reasoning events first
when thinking content is detected in LS steps before response text.
2026-02-14 20:34:37 -06:00
Nikketryhard
b1a089d21d feat: emit streaming reasoning events per OpenAI spec
Adds proper streaming SSE events for reasoning content:
- response.output_item.added (reasoning)
- response.reasoning_summary_part.added
- response.reasoning_summary_text.delta
- response.reasoning_summary_text.done
- response.reasoning_summary_part.done
- response.output_item.done (reasoning)

These are emitted before the message events, matching the format
that OpenAI-compatible clients expect for displaying thinking content.
2026-02-14 19:57:52 -06:00
Nikketryhard
5c1f4c77d9 fix: add retry logic for MITM thinking text merge race condition
The LS makes two Google API calls for thinking models. Call 2 (thinking
summary) may not have arrived by the time usage_from_poll runs after
Call 1 (response). Now we peek first, and if thinking tokens exist but
text is missing, wait up to 1s for the merge to happen.

Also adds peek_usage method to MitmStore for non-consuming reads.
2026-02-14 19:54:37 -06:00
Nikketryhard
34b9553484 feat: capture thinking text via MITM dual-call merge
The LS makes TWO separate Google API calls for thinking models:
  Call 1: response + thinking token count (no thinking text)
  Call 2: thinking summary text (no thinking tokens)

Each hits a different StreamingAccumulator, so we:
1. Capture response_text in StreamingAccumulator (non-thinking parts)
2. In MitmStore::record_usage, detect when Call 2 arrives for a
   cascade that already has thinking tokens from Call 1
3. Merge Call 2's response_text as thinking_text on Call 1's usage

Also injects includeThoughts into Google API requests via MITM
modify to ensure thinking text is available in SSE responses.
2026-02-14 19:49:15 -06:00
Nikketryhard
905d55beb5 feat: capture thinking text from MITM-intercepted API responses
The LS strips thinking/reasoning text from plannerResponse steps —
only the thinkingSignature (opaque verification blob) is preserved.
The actual thinking text flows through the MITM proxy in the raw
Google SSE response (parts with thought: true) and Anthropic SSE
(thinking_delta content blocks).

Changes:
- StreamingAccumulator now accumulates thinking text from SSE events
- ApiUsage gains thinking_text: Option<String>
- usage_from_poll returns (Usage, Option<thinking_text>)
- Thinking text priority: MITM-captured > LS-extracted (fallback)
- Reasoning output item now populated from real API data
- Removed debug dump code
2026-02-14 19:30:09 -06:00
Nikketryhard
19dc920872 fix: return thinking as reasoning output item per OpenAI spec
Thinking content was previously returned as non-standard top-level
fields (thinking, thinking_duration). Now follows the official OpenAI
Responses API format:

- Reasoning appears as a 'type: reasoning' item in the output array
  with summary[].text containing the thinking content
- Message item follows after the reasoning item
- thinking_signature kept as proxy extension (internal multi-turn data)
- Removed ResponseOutput/OutputContent structs in favor of
  serde_json::Value for polymorphic output items
2026-02-14 19:16:12 -06:00
Nikketryhard
7c4e781900 feat: aggressive request stripping — keep only identity + conversation
Strip everything from intercepted LLM requests except:
- <identity> section in system instruction
- Actual conversation turns (user messages + model responses)

Removed: tool_calling, web_app_dev, knowledge_discovery,
persistent_context, skills, ephemeral_message, communication_style,
user_information, user_rules, MEMORY, workflows, mcp_servers,
conversation_summaries, ADDITIONAL_METADATA, Step Id prefixes.

Expected reduction: ~92% (63KB → ~5KB for simple requests).
2026-02-14 19:05:49 -06:00
Nikketryhard
1a7c81e5f9 feat: strip ALL tools from intercepted requests by default
Tools are only needed by the Antigravity webview for tool-call UI.
Our proxy doesn't need them — the model generates text responses fine
without tool definitions. Stripping all 20 tools saves ~15KB per request.
2026-02-14 18:53:38 -06:00
Nikketryhard
89a8422291 fix: suppress profile picture warn, ensure release binary rebuilds 2026-02-14 18:50:37 -06:00
Nikketryhard
e678ec655b fix: standalone MITM — remove HTTPS_PROXY with iptables, fix is_agent detection
- Only set HTTPS_PROXY/HTTP_PROXY when iptables UID isolation is NOT
  available. With iptables, double-proxying caused profile picture
  fetches to fail with 'lookup http' DNS errors.
- Fix is_agent detection: handle JSON with spaces after colons
  ("requestType": "agent" vs "requestType":"agent")
- Suppress wrapper-not-installed warning in standalone mode
- Show 'iptables (standalone)' in banner instead of 'not installed'
2026-02-14 18:47:38 -06:00
Nikketryhard
f0c2574c88 feat: MITM request modification — strip bloat from LLM API requests
Intercepts streamGenerateContent requests and trims:
- System instruction: strips web_application_development, knowledge_discovery,
  persistent_context, skills sections (~18KB saved)
- Content messages: strips empty user_rules, workflows boilerplate,
  conversation summaries (~4.5KB saved)
- Tools: keeps 12 essential coding tools, strips 8 non-essential
  (browser_subagent, generate_image, search_web, etc. ~6KB saved)

Total: ~55% reduction in request size while keeping identity, user info,
and all coding-relevant tools intact. Only modifies 'agent' type requests,
checkpoint requests pass through unmodified.

Also:
- Standalone mode is now the default (use --no-standalone to attach to
  existing LS)
- Enable request modification by default
- Add mold linker, sccache, nextest config (8 thread cap)
- Add .cargo/config.toml and .config/nextest.toml
2026-02-14 18:35:07 -06:00
Nikketryhard
061b08fc8f fix: cascade correlation — fallback to _latest MITM usage
When the MITM can't extract a cascade ID from the intercepted request
(Content-Length: 0 / chunked encoding), usage is stored under '_latest'.
Now usage_from_poll and completions try the exact cascade_id first,
then fall back to '_latest' so MITM-captured tokens are actually used.
2026-02-14 18:10:04 -06:00
Nikketryhard
ca36ab0631 chore: clean up MITM logs and add Google SSE tests
- Demote non-LLM request logs to debug (only streamGenerateContent at info)
- Demote non-streaming response headers to debug
- Add 5 Google SSE parser tests (single event, multi-event accumulation,
  chunked framing, completion detection, no-thinking-tokens)
- Fix unused variable warning in proxy.rs
2026-02-14 17:55:17 -06:00
Nikketryhard
d4de436856 feat: MITM interception for standalone LS with UID isolation
- Spawn standalone LS as dedicated 'antigravity-ls' user via sudo
- UID-scoped iptables redirect (port 443 → MITM proxy) via mitm-redirect.sh
- Combined CA bundle (system CAs + MITM CA) for Go TLS trust
- Transparent TLS interception with chunked response detection
- Google SSE parser for streamGenerateContent usage extraction
- Timeouts on all MITM operations (TLS handshake, upstream, idle)
- Forward response data immediately (no buffering)
- Per-model token usage capture (input, output, thinking)
- Update docs and known issues to reflect resolved TLS blocker
2026-02-14 17:50:12 -06:00
Nikketryhard
6842bfeaa5 chore: clean up code — remove dead code, stale allows, eprintln→tracing, remove volatile data from docs 2026-02-14 16:11:34 -06:00
Nikketryhard
2ccc4b46f8 fix(#4): remove dead total_cost_usd field; map model enums to readable names 2026-02-14 15:54:03 -06:00
Nikketryhard
dd7b12a97d fix(#2): cap domain cert cache at 64 entries 2026-02-14 15:49:39 -06:00
Nikketryhard
7f5a0f51d3 docs: enrich module docs with binary analysis cross-references 2026-02-14 04:20:57 -06:00
Nikketryhard
edad784bcd refactor: extract GrpcUsage::into_api_usage to DRY up h2_handler 2026-02-14 04:13:46 -06:00
Nikketryhard
686f5820d6 refactor: extract ResponseData struct to eliminate 18-arg build_response_object 2026-02-14 04:09:41 -06:00
Nikketryhard
901cd3d2e3 fix: resolve clippy warnings (matches!, map_or, redundant guard, unnecessary allocations) 2026-02-14 04:06:18 -06:00
Nikketryhard
725bdb4e9a chore: add snapshot CLI binary and lib re-export 2026-02-14 04:04:47 -06:00
Nikketryhard
ee6fce12a7 fix: suppress unused direction field warning in snapshot 2026-02-14 04:04:35 -06:00
Nikketryhard
4fa8775b61 feat: transparent proxy mode with SNI extraction and DNS bypass for upstream 2026-02-14 04:03:19 -06:00
Nikketryhard
df7dcc96db fix: prefer .real binary PID and fallback to ss for port discovery 2026-02-14 04:03:15 -06:00
Nikketryhard
07e705084e fix: install rustls CryptoProvider at startup to prevent panic under load 2026-02-14 04:03:11 -06:00
Nikketryhard
d5e7f09225 feat: initial commit — antigravity proxy with MITM, standalone LS, and snapshot tooling 2026-02-14 02:24:35 -06:00