diff --git a/README.md b/README.md
index 005e8b1..3a4a411 100644
--- a/README.md
+++ b/README.md
@@ -8,10 +8,10 @@ graph LR
Client["Client"] -->|"OpenAI / Gemini API"| Proxy["Proxy :8741"]
Proxy -->|"gRPC (dummy prompt)"| LS["Standalone LS"]
LS -->|"HTTPS :443"| MITM["MITM :8742"]
- MITM -->|"Modified request\n(real prompt + tools)"| Google["Google API"]
+ MITM -->|"Modified request
(real prompt + tools)"| Google["Google API"]
Google -->|"SSE response"| MITM
- MITM -->|"Usage, errors,\nfunction calls"| Proxy
- LS -.->|"iptables redirect\n(UID-scoped)"| MITM
+ MITM -->|"Usage, errors,
function calls"| Proxy
+ LS -.->|"iptables redirect
(UID-scoped)"| MITM
style Proxy fill:#7c3aed,color:#fff
style MITM fill:#e94560,color:#fff
diff --git a/docs/architecture.md b/docs/architecture.md
index 2d0b939..274ebff 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -4,16 +4,16 @@
```mermaid
flowchart LR
- Client["Client\n(curl, SDK, etc.)"]
- Proxy["Proxy\n:8741"]
- LS["Standalone LS\n:random"]
- MITM["MITM Proxy\n:8742"]
- Google["Google API\ndaily-cloudcode-pa\n.googleapis.com"]
+ Client["Client
(curl, SDK, etc.)"]
+ Proxy["Proxy
:8741"]
+ LS["Standalone LS
:random"]
+ MITM["MITM Proxy
:8742"]
+ Google["Google API
daily-cloudcode-pa
.googleapis.com"]
- Client -- "OpenAI / Gemini\nHTTP API" --> Proxy
- Proxy -- "gRPC\n(protobuf)" --> LS
- LS -- "HTTPS :443\n(iptables redirect)" --> MITM
- MITM -- "TLS\n(BoringSSL)" --> Google
+ Client -- "OpenAI / Gemini
HTTP API" --> Proxy
+ Proxy -- "gRPC
(protobuf)" --> LS
+ LS -- "HTTPS :443
(iptables redirect)" --> MITM
+ MITM -- "TLS
(BoringSSL)" --> Google
style Proxy fill:#7c3aed,color:#fff
style MITM fill:#dc2626,color:#fff
@@ -63,7 +63,7 @@ sequenceDiagram
```mermaid
graph TD
subgraph "API Layer"
- mod_api["api/mod.rs\n(router)"]
+ mod_api["api/mod.rs
(router)"]
completions["completions.rs"]
responses["responses.rs"]
gemini["gemini.rs"]
@@ -75,18 +75,18 @@ graph TD
end
subgraph "MITM Layer"
- proxy_mitm["proxy.rs\n(TLS termination)"]
- h2["h2_handler.rs\n(HTTP/2 framing)"]
- intercept["intercept.rs\n(SSE parsing)"]
- modify["modify.rs\n(request injection)"]
- store["store.rs\n(MitmStore)"]
- proto_mitm["proto.rs\n(protobuf codec)"]
- ca["ca.rs\n(cert generation)"]
+ proxy_mitm["proxy.rs
(TLS termination)"]
+ h2["h2_handler.rs
(HTTP/2 framing)"]
+ intercept["intercept.rs
(SSE parsing)"]
+ modify["modify.rs
(request injection)"]
+ store["store.rs
(MitmStore)"]
+ proto_mitm["proto.rs
(protobuf codec)"]
+ ca["ca.rs
(cert generation)"]
end
subgraph "Core"
main["main.rs"]
- backend["backend.rs\n(gRPC client)"]
+ backend["backend.rs
(gRPC client)"]
session["session.rs"]
trace["trace.rs"]
warmup["warmup.rs"]
@@ -97,7 +97,7 @@ graph TD
subgraph "Standalone LS"
spawn["spawn.rs"]
discovery["discovery.rs"]
- stub["stub.rs\n(extension server)"]
+ stub["stub.rs
(extension server)"]
end
subgraph "Protobuf"
diff --git a/docs/mitm.md b/docs/mitm.md
index 14fd4cf..3135fd1 100644
--- a/docs/mitm.md
+++ b/docs/mitm.md
@@ -32,13 +32,13 @@ sequenceDiagram
```mermaid
graph TD
subgraph "MITM Module"
- proxy["proxy.rs\nTLS termination\nSNI-based routing"]
- h2["h2_handler.rs\nHTTP/2 frame handling"]
- intercept["intercept.rs\nSSE parser\nUsage extraction"]
- modify["modify.rs\nRequest injection\n(tools, params, images)"]
- store["store.rs\nMitmStore\nEvent channels"]
- proto["proto.rs\nProtobuf codec"]
- ca["ca.rs\nCA + dynamic certs"]
+ proxy["proxy.rs
TLS termination
SNI-based routing"]
+ h2["h2_handler.rs
HTTP/2 frame handling"]
+ intercept["intercept.rs
SSE parser
Usage extraction"]
+ modify["modify.rs
Request injection
(tools, params, images)"]
+ store["store.rs
MitmStore
Event channels"]
+ proto["proto.rs
Protobuf codec"]
+ ca["ca.rs
CA + dynamic certs"]
end
proxy --> h2
@@ -72,20 +72,20 @@ When the MITM proxy intercepts an outgoing request from the LS, it applies modif
```mermaid
flowchart TD
A["Original LS Request"] --> B{"Has tools?"}
- B -- Yes --> C["Inject tool definitions\n+ toolConfig"]
+ B -- Yes --> C["Inject tool definitions
+ toolConfig"]
B -- No --> D{"Has generation params?"}
C --> D
- D -- Yes --> E["Inject temperature, top_p,\nmax_output_tokens, stop_sequences,\nfrequency/presence_penalty"]
+ D -- Yes --> E["Inject temperature, top_p,
max_output_tokens, stop_sequences,
frequency/presence_penalty"]
D -- No --> F{"Has image?"}
E --> F
- F -- Yes --> G["Inject inlineData\n(base64) into user parts"]
+ F -- Yes --> G["Inject inlineData
(base64) into user parts"]
F -- No --> H{"Has tool results?"}
G --> H
- H -- Yes --> I["Inject functionResponse\nparts"]
+ H -- Yes --> I["Inject functionResponse
parts"]
H -- No --> J{"Google Search?"}
I --> J
- J -- Yes --> K["Enable Google Search\ngrounding tool"]
- J -- No --> L["Replace user text\nwith real input"]
+ J -- Yes --> K["Enable Google Search
grounding tool"]
+ J -- No --> L["Replace user text
with real input"]
K --> L
L --> M["Update Content-Length"]
M --> N["Forward to Google"]