# fanch-hui/agy-lab architecture

> Architecture diagram of the GitHub repository fanch-hui/agy-lab, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fanch-hui/agy-lab
- Repository: https://github.com/fanch-hui/agy-lab

## Overview

AGY Lab is an isolated Antigravity desktop copy that adds third-party model connections and account/workspace management. The main workflow is configure or discover a provider model, expose it in Antigravity’s native catalogue, then route selected generation through a local proxy to the provider while preserving tool and prompt behavior. Separate branches cover Google and ChatGPT account handling, history/project synchronization, remote workspaces, and diagnostics. Relationships are based on the README and shown source/index references; several UI and remote-workspace implementation details were not sampled.

Main entry points: [`lab/main.cjs`](https://github.com/fanch-hui/agy-lab/blob/main/lab/main.cjs) (Desktop coordinator), [`lab/cloud-proxy.cjs`](https://github.com/fanch-hui/agy-lab/blob/main/lab/cloud-proxy.cjs) (Cloud proxy), [`lab/provider.cjs`](https://github.com/fanch-hui/agy-lab/blob/main/lab/provider.cjs) (Provider generation), [`lab/connections.cjs`](https://github.com/fanch-hui/agy-lab/blob/main/lab/connections.cjs) (Connection store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Desktop integration"]
  node_settings["Connections UI<br/>[connections-ui.js]"]
  node_main["Desktop coordinator<br/>[main.cjs]"]
end

subgraph group_models["Model connections"]
  node_native["Native catalogue<br/>[native-models.cjs]"]
  node_connections[("Connection store<br/>[connections.cjs]")]
  node_discovery["Model discovery"]
  node_provider["Provider generation<br/>[provider.cjs]"]
  node_wire["Provider wire format<br/>[provider-wire.cjs]"]
  node_responses["Responses API<br/>[responses.cjs]"]
  node_native_route["Native request routing<br/>[native-route.cjs]"]
  node_prompt["Prompt stability"]
  node_cloud["Cloud proxy<br/>[cloud-proxy.cjs]"]
end

subgraph group_accounts["Accounts and history"]
  node_google["Google account manager"]
  node_google_import["Google token import<br/>[google-import.cjs]"]
  node_google_ui["Google accounts UI"]
  node_siwc["ChatGPT authorization<br/>[siwc.cjs]"]
  node_siwc_accounts[("ChatGPT accounts<br/>[siwc-accounts.cjs]")]
  node_history["History synchronization<br/>[history-sync.cjs]"]
  node_projects["Project synchronization"]
  node_history_ui["History settings UI<br/>[history-ui.js]"]
end

subgraph group_remote["Remote workspaces"]
  node_ssh["SSH workspace<br/>[ssh.cjs]"]
  node_ssh_proxy["SSH model proxy<br/>[ssh-proxy.cjs]"]
  node_wsl["WSL workspace<br/>[wsl.cjs]"]
  node_linux_server["Linux language server<br/>[linux-server.cjs]"]
end

subgraph group_observability["Diagnostics"]
  node_inventory[("Cloud request inventory")]
  node_diagnostics["Model diagnostics"]
  node_tool_probe["Tool compatibility probe<br/>[tool-probe.cjs]"]
end

node_user(("User"))
node_provider_service(("Model provider"))
node_openai(("OpenAI services"))

node_user -->|"configures"| node_settings
node_settings -->|"sends settings"| node_main
node_main -->|"manages"| node_connections
node_main -->|"dispatches account actions"| node_google
node_main -->|"sets history mode"| node_history
node_main -->|"starts proxy"| node_cloud
node_main -->|"opens diagnostics"| node_diagnostics
node_main -->|"tests tools"| node_tool_probe
node_settings -->|"requests models"| node_discovery
node_discovery -->|"uses provider formats"| node_provider
node_connections -->|"fetches catalogue"| node_discovery
node_connections -->|"resolves subscription"| node_siwc_accounts
node_native -->|"adds model catalogue"| node_connections
node_cloud -->|"resolves connection"| node_connections
node_cloud -->|"generates external models"| node_provider
node_provider -->|"encodes requests"| node_wire
node_provider -->|"uses Responses API"| node_responses
node_provider -->|"streams generation"| node_provider_service
node_native_route -->|"routes native models"| node_native
node_native_route -->|"maintains prompt prefix"| node_prompt
node_native_route -.->|"forwards generation"| node_cloud
node_google_ui -.->|"manages accounts"| node_main
node_main -->|"imports tokens"| node_google_import
node_google -.->|"uses imported credentials"| node_google_import
node_main -->|"runs sign-in"| node_siwc
node_siwc_accounts -->|"requests access tokens"| node_siwc
node_siwc -->|"authorizes subscription"| node_openai
node_history_ui -.->|"sets sync mode"| node_main
node_history -->|"synchronizes projects"| node_projects
node_ssh -.->|"opens remote proxy"| node_ssh_proxy
node_ssh_proxy -->|"reuses proxy handler"| node_cloud
node_wsl -->|"prepares server"| node_linux_server
node_wsl -->|"probes proxy"| node_cloud
node_cloud -->|"records request structure"| node_inventory
node_user -->|"exports report"| node_diagnostics
node_user -->|"views request list"| node_inventory
node_tool_probe -->|"tests compatibility"| node_provider

click node_settings "https://github.com/fanch-hui/agy-lab/blob/main/lab/connections-ui.js"
click node_main "https://github.com/fanch-hui/agy-lab/blob/main/lab/main.cjs"
click node_native "https://github.com/fanch-hui/agy-lab/blob/main/lab/native-models.cjs"
click node_connections "https://github.com/fanch-hui/agy-lab/blob/main/lab/connections.cjs"
click node_discovery "https://github.com/fanch-hui/agy-lab/blob/main/lab/model-discovery.cjs"
click node_provider "https://github.com/fanch-hui/agy-lab/blob/main/lab/provider.cjs"
click node_wire "https://github.com/fanch-hui/agy-lab/blob/main/lab/provider-wire.cjs"
click node_responses "https://github.com/fanch-hui/agy-lab/blob/main/lab/responses.cjs"
click node_native_route "https://github.com/fanch-hui/agy-lab/blob/main/lab/native-route.cjs"
click node_prompt "https://github.com/fanch-hui/agy-lab/blob/main/lab/prompt-stability.cjs"
click node_cloud "https://github.com/fanch-hui/agy-lab/blob/main/lab/cloud-proxy.cjs"
click node_google "https://github.com/fanch-hui/agy-lab/blob/main/lab/google-accounts.cjs"
click node_google_import "https://github.com/fanch-hui/agy-lab/blob/main/lab/google-import.cjs"
click node_google_ui "https://github.com/fanch-hui/agy-lab/blob/main/lab/google-accounts-ui.js"
click node_siwc "https://github.com/fanch-hui/agy-lab/blob/main/lab/siwc.cjs"
click node_siwc_accounts "https://github.com/fanch-hui/agy-lab/blob/main/lab/siwc-accounts.cjs"
click node_history "https://github.com/fanch-hui/agy-lab/blob/main/lab/history-sync.cjs"
click node_projects "https://github.com/fanch-hui/agy-lab/blob/main/lab/history-projects.cjs"
click node_history_ui "https://github.com/fanch-hui/agy-lab/blob/main/lab/history-ui.js"
click node_ssh "https://github.com/fanch-hui/agy-lab/blob/main/lab/ssh.cjs"
click node_ssh_proxy "https://github.com/fanch-hui/agy-lab/blob/main/lab/ssh-proxy.cjs"
click node_wsl "https://github.com/fanch-hui/agy-lab/blob/main/lab/wsl.cjs"
click node_linux_server "https://github.com/fanch-hui/agy-lab/blob/main/lab/linux-server.cjs"
click node_inventory "https://github.com/fanch-hui/agy-lab/blob/main/lab/cloud-inventory.cjs"
click node_diagnostics "https://github.com/fanch-hui/agy-lab/blob/main/lab/model-diagnostics.cjs"
click node_tool_probe "https://github.com/fanch-hui/agy-lab/blob/main/lab/tool-probe.cjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_settings,node_main,node_user toneBlue
class node_native,node_connections,node_discovery,node_provider,node_wire,node_responses,node_native_route,node_prompt,node_cloud toneAmber
class node_google,node_google_import,node_google_ui,node_siwc,node_siwc_accounts,node_history,node_projects,node_history_ui toneMint
class node_ssh,node_ssh_proxy,node_wsl,node_linux_server toneRose
class node_inventory,node_diagnostics,node_tool_probe,node_provider_service,node_openai toneIndigo
```

## Components

### Desktop integration

- [Connections UI](https://github.com/fanch-hui/agy-lab/blob/main/lab/connections-ui.js): `lab/connections-ui.js`
- [Desktop coordinator](https://github.com/fanch-hui/agy-lab/blob/main/lab/main.cjs): `lab/main.cjs`

### Model connections

- [Native catalogue](https://github.com/fanch-hui/agy-lab/blob/main/lab/native-models.cjs): `lab/native-models.cjs`
- [Connection store](https://github.com/fanch-hui/agy-lab/blob/main/lab/connections.cjs): `lab/connections.cjs`
- [Model discovery](https://github.com/fanch-hui/agy-lab/blob/main/lab/model-discovery.cjs): `lab/model-discovery.cjs`
- [Provider generation](https://github.com/fanch-hui/agy-lab/blob/main/lab/provider.cjs): `lab/provider.cjs`
- [Provider wire format](https://github.com/fanch-hui/agy-lab/blob/main/lab/provider-wire.cjs): `lab/provider-wire.cjs`
- [Responses API](https://github.com/fanch-hui/agy-lab/blob/main/lab/responses.cjs): `lab/responses.cjs`
- [Native request routing](https://github.com/fanch-hui/agy-lab/blob/main/lab/native-route.cjs): `lab/native-route.cjs`
- [Prompt stability](https://github.com/fanch-hui/agy-lab/blob/main/lab/prompt-stability.cjs): `lab/prompt-stability.cjs`
- [Cloud proxy](https://github.com/fanch-hui/agy-lab/blob/main/lab/cloud-proxy.cjs): `lab/cloud-proxy.cjs`

### Accounts and history

- [Google account manager](https://github.com/fanch-hui/agy-lab/blob/main/lab/google-accounts.cjs): `lab/google-accounts.cjs`
- [Google token import](https://github.com/fanch-hui/agy-lab/blob/main/lab/google-import.cjs): `lab/google-import.cjs`
- [Google accounts UI](https://github.com/fanch-hui/agy-lab/blob/main/lab/google-accounts-ui.js): `lab/google-accounts-ui.js`
- [ChatGPT authorization](https://github.com/fanch-hui/agy-lab/blob/main/lab/siwc.cjs): `lab/siwc.cjs`
- [ChatGPT accounts](https://github.com/fanch-hui/agy-lab/blob/main/lab/siwc-accounts.cjs): `lab/siwc-accounts.cjs`
- [History synchronization](https://github.com/fanch-hui/agy-lab/blob/main/lab/history-sync.cjs): `lab/history-sync.cjs`
- [Project synchronization](https://github.com/fanch-hui/agy-lab/blob/main/lab/history-projects.cjs): `lab/history-projects.cjs`
- [History settings UI](https://github.com/fanch-hui/agy-lab/blob/main/lab/history-ui.js): `lab/history-ui.js`

### Remote workspaces

- [SSH workspace](https://github.com/fanch-hui/agy-lab/blob/main/lab/ssh.cjs): `lab/ssh.cjs`
- [SSH model proxy](https://github.com/fanch-hui/agy-lab/blob/main/lab/ssh-proxy.cjs): `lab/ssh-proxy.cjs`
- [WSL workspace](https://github.com/fanch-hui/agy-lab/blob/main/lab/wsl.cjs): `lab/wsl.cjs`
- [Linux language server](https://github.com/fanch-hui/agy-lab/blob/main/lab/linux-server.cjs): `lab/linux-server.cjs`

### Diagnostics

- [Cloud request inventory](https://github.com/fanch-hui/agy-lab/blob/main/lab/cloud-inventory.cjs): `lab/cloud-inventory.cjs`
- [Model diagnostics](https://github.com/fanch-hui/agy-lab/blob/main/lab/model-diagnostics.cjs): `lab/model-diagnostics.cjs`
- [Tool compatibility probe](https://github.com/fanch-hui/agy-lab/blob/main/lab/tool-probe.cjs): `lab/tool-probe.cjs`

### Other components

- **User**
- **Model provider**
- **OpenAI services**

## Connections

- User → Connections UI: configures (evidence: `README.md`)
- Connections UI → Desktop coordinator: sends settings (evidence: `lab/main.cjs`)
- Desktop coordinator → Connection store: manages (evidence: `lab/main.cjs`)
- Desktop coordinator → Google account manager: dispatches account actions (evidence: `lab/main.cjs`)
- Desktop coordinator → History synchronization: sets history mode (evidence: `lab/main.cjs`)
- Desktop coordinator → Cloud proxy: starts proxy (evidence: `lab/main.cjs`)
- Desktop coordinator → Model diagnostics: opens diagnostics (evidence: `lab/main.cjs`)
- Desktop coordinator → Tool compatibility probe: tests tools (evidence: `lab/main.cjs`)
- Connections UI → Model discovery: requests models
- Model discovery → Provider generation: uses provider formats (evidence: `lab/model-discovery.cjs`)
- Connection store → Model discovery: fetches catalogue (evidence: `lab/connections.cjs`)
- Connection store → ChatGPT accounts: resolves subscription (evidence: `lab/connections.cjs`)
- Native catalogue → Connection store: adds model catalogue (evidence: `lab/cloud-proxy.cjs`)
- Cloud proxy → Connection store: resolves connection (evidence: `lab/cloud-proxy.cjs`)
- Cloud proxy → Provider generation: generates external models (evidence: `lab/cloud-proxy.cjs`)
- Provider generation → Provider wire format: encodes requests (evidence: `lab/provider.cjs`)
- Provider generation → Responses API: uses Responses API (evidence: `lab/provider.cjs`)
- Provider generation → Model provider: streams generation (evidence: `README.md`)
- Native request routing → Native catalogue: routes native models (evidence: `lab/native-route.cjs`)
- Native request routing → Prompt stability: maintains prompt prefix (evidence: `lab/native-route.cjs`)
- Native request routing → Cloud proxy: forwards generation (evidence: `lab/cloud-proxy.cjs`)
- Google accounts UI → Desktop coordinator: manages accounts
- Desktop coordinator → Google token import: imports tokens (evidence: `lab/main.cjs`)
- Google account manager → Google token import: uses imported credentials
- Desktop coordinator → ChatGPT authorization: runs sign-in (evidence: `lab/main.cjs`)
- ChatGPT accounts → ChatGPT authorization: requests access tokens (evidence: `lab/siwc-accounts.cjs`)
- ChatGPT authorization → OpenAI services: authorizes subscription (evidence: `README.md`)
- History settings UI → Desktop coordinator: sets sync mode
- History synchronization → Project synchronization: synchronizes projects (evidence: `lab/history-sync.cjs`)
- SSH workspace → SSH model proxy: opens remote proxy
- SSH model proxy → Cloud proxy: reuses proxy handler (evidence: `lab/ssh-proxy.cjs`)
- WSL workspace → Linux language server: prepares server (evidence: `lab/wsl.cjs`)
- WSL workspace → Cloud proxy: probes proxy (evidence: `lab/wsl.cjs`)
- Cloud proxy → Cloud request inventory: records request structure (evidence: `lab/cloud-proxy.cjs`)
- User → Model diagnostics: exports report (evidence: `README.md`)
- User → Cloud request inventory: views request list (evidence: `README.md`)
- Tool compatibility probe → Provider generation: tests compatibility (evidence: `lab/tool-probe.cjs`)
