antigravity-mobile 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: antigravity-mobile
3
+ Version: 0.1.0
4
+ Summary: A remote monitor and scheduler CLI tool for Antigravity 2.0 IDE
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: fastapi>=0.100.0
9
+ Requires-Dist: uvicorn>=0.22.0
10
+ Requires-Dist: jinja2>=3.1.0
11
+ Requires-Dist: websockets>=11.0
12
+ Requires-Dist: psutil>=5.9.0
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
15
+ Requires-Dist: httpx>=0.24.0; extra == "dev"
16
+
17
+ # Antigravity Remote Monitor & Task Scheduler
18
+
19
+ `antigravity-remote` is a lightweight command-line tool and FastAPI-powered web application designed for the **Google Antigravity IDE and CLI**. It enables you to securely monitor your development workflow, switch AI models, track usage quotas, view real-time log outputs, and confirm or reject commands directly from your mobile device while you are away from your workstation.
20
+
21
+ ---
22
+
23
+ ## Key Features
24
+
25
+ - 📱 **Mobile-Optimized Dashboard**: Responsive, glassmorphic UI styled in a beautiful dark theme with real-time stats.
26
+ - 🤖 **Model Control**: Switch active models (Gemini 3.5 Flash, Claude 4.5 Sonnet, GPT-OSS, etc.) directly from your phone.
27
+ - 📊 **Quota & Limit Progress**: Live tracking of request limits (Gemini Weekly/5-Hr and Claude/GPT Weekly/5-Hr limits).
28
+ - 💻 **Live Agent Thought Output Console**: A real-time console streaming step-by-step developer thoughts, planned tools, and logs from the agent to your phone.
29
+ - 🛡️ **Interactive Mobile Approvals**: Run terminal commands and get interruptive Yes/No popup prompts on your phone instead of the PC desktop.
30
+ - 🔌 **Automatic Offline Fallback**: Automatically bypasses the mobile check and falls back to standard PC desktop prompts if your FastAPI server is offline.
31
+ - ⚡ **PC CLI Run Wrapper (`run`)**: Execute commands directly on your PC that log to the server and appear on your phone, bypassing all sandbox desktop security prompts.
32
+ - 🎛️ **Remote Toggle Switch (`remote`)**: Turn remote mode ON or OFF at any time to save tokens and resources when coding locally.
33
+ - 🔒 **PIN Authentication**: Secure authorization PIN generated on first start, requiring authentication on the mobile client.
34
+
35
+ ---
36
+
37
+ ## Installation
38
+
39
+ ### From Source (Editable Mode)
40
+ ```bash
41
+ # Clone the repository and navigate to the folder
42
+ cd "d:\Remote Antigravity"
43
+
44
+ # Install dependencies and CLI tool in editable mode
45
+ pip install -e .
46
+ ```
47
+
48
+ ### Packaging & Publishing to PyPI
49
+ To build and publish the package so others can install it via `pip install antigravity-remote`:
50
+ 1. **Install Build Tools**:
51
+ ```bash
52
+ pip install --upgrade build twine
53
+ ```
54
+ 2. **Build Distribution Archives**:
55
+ ```bash
56
+ python -m build
57
+ ```
58
+ *(This generates `.whl` and `.tar.gz` files in the `dist/` directory.)*
59
+ 3. **Upload to PyPI**:
60
+ ```bash
61
+ python -m twine upload dist/*
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Setup & IDE Configuration
67
+
68
+ To enable silent executions on your PC and redirect confirmations to your phone, update your **Antigravity IDE User Settings**:
69
+
70
+ 1. Open your settings file: `C:\Users\K\AppData\Roaming\Antigravity IDE\User\settings.json`
71
+ 2. Add the following options to allow automatic local command approvals:
72
+ ```json
73
+ {
74
+ "antigravity.autoApprove": true,
75
+ "antigravity.autonomyLevel": "full"
76
+ }
77
+ ```
78
+ 3. Press **`Ctrl + Shift + P`** in the IDE, type **`Developer: Reload Window`**, and press **Enter** to apply changes.
79
+
80
+ ---
81
+
82
+ ## Usage
83
+
84
+ ### 1. Initialize Configuration
85
+ ```bash
86
+ antigravity-remote init
87
+ ```
88
+ Generates a randomized access PIN for mobile login (stored in `config.json`).
89
+
90
+ ### 2. Start the Server & Tunnel
91
+ Start the server and expose it using localtunnel:
92
+ ```bash
93
+ # Start FastAPI server on all interfaces
94
+ antigravity-remote start --host 0.0.0.0 --port 8000
95
+
96
+ # Expose it to the internet so you can access it on your phone
97
+ npx localtunnel --port 8000
98
+ ```
99
+ Open the localtunnel URL on your mobile phone browser and enter your access PIN!
100
+
101
+ ### 3. CLI Command Execution
102
+ To execute commands on your PC, log them to the server, and monitor them live on your phone with **no desktop prompts**:
103
+ ```bash
104
+ antigravity-remote run "pytest tests/test_server.py"
105
+ ```
106
+
107
+ ### 4. Remote Mode Toggle
108
+ Turn remote monitoring and control on/off:
109
+ ```bash
110
+ # Enable remote mode (wakes up daemon, streams logs)
111
+ antigravity-remote remote --on
112
+
113
+ # Disable remote mode (puts daemon to sleep, stops logging)
114
+ antigravity-remote remote --off
115
+
116
+ # Check status
117
+ antigravity-remote remote --status
118
+ ```
119
+
120
+ ---
121
+
122
+ ## Project Structure
123
+
124
+ ```
125
+ d:/Remote Antigravity/
126
+ ├── .agents/
127
+ │ ├── AGENTS.md # Global agent logging & mobile approval rules
128
+ │ └── skills/
129
+ │ └── remote_control/
130
+ │ └── SKILL.md # Remote loop instruction skill for AI agents
131
+ ├── antigravity_remote/
132
+ │ ├── __init__.py
133
+ │ ├── cli.py # CLI Command handling
134
+ │ ├── server.py # FastAPI server with WebSocket logging & dashboard
135
+ │ ├── agent_daemon.py # Background sidecar polling daemon
136
+ │ ├── agent_approve.py # Mobile approval helper script
137
+ │ ├── task_runner.py # Background subprocess runner
138
+ │ ├── templates/
139
+ │ │ └── index.html # Mobile-responsive glassmorphic dashboard
140
+ │ └── static/
141
+ │ ├── css/
142
+ │ │ └── styles.css # Custom dashboard styles
143
+ │ └── js/
144
+ │ └── main.js # Client-side WebSocket & model switcher logic
145
+ ├── pyproject.toml # Packaging metadata & entrypoints
146
+ └── README.md # Documentation
147
+ ```
@@ -0,0 +1,131 @@
1
+ # Antigravity Remote Monitor & Task Scheduler
2
+
3
+ `antigravity-remote` is a lightweight command-line tool and FastAPI-powered web application designed for the **Google Antigravity IDE and CLI**. It enables you to securely monitor your development workflow, switch AI models, track usage quotas, view real-time log outputs, and confirm or reject commands directly from your mobile device while you are away from your workstation.
4
+
5
+ ---
6
+
7
+ ## Key Features
8
+
9
+ - 📱 **Mobile-Optimized Dashboard**: Responsive, glassmorphic UI styled in a beautiful dark theme with real-time stats.
10
+ - 🤖 **Model Control**: Switch active models (Gemini 3.5 Flash, Claude 4.5 Sonnet, GPT-OSS, etc.) directly from your phone.
11
+ - 📊 **Quota & Limit Progress**: Live tracking of request limits (Gemini Weekly/5-Hr and Claude/GPT Weekly/5-Hr limits).
12
+ - 💻 **Live Agent Thought Output Console**: A real-time console streaming step-by-step developer thoughts, planned tools, and logs from the agent to your phone.
13
+ - 🛡️ **Interactive Mobile Approvals**: Run terminal commands and get interruptive Yes/No popup prompts on your phone instead of the PC desktop.
14
+ - 🔌 **Automatic Offline Fallback**: Automatically bypasses the mobile check and falls back to standard PC desktop prompts if your FastAPI server is offline.
15
+ - ⚡ **PC CLI Run Wrapper (`run`)**: Execute commands directly on your PC that log to the server and appear on your phone, bypassing all sandbox desktop security prompts.
16
+ - 🎛️ **Remote Toggle Switch (`remote`)**: Turn remote mode ON or OFF at any time to save tokens and resources when coding locally.
17
+ - 🔒 **PIN Authentication**: Secure authorization PIN generated on first start, requiring authentication on the mobile client.
18
+
19
+ ---
20
+
21
+ ## Installation
22
+
23
+ ### From Source (Editable Mode)
24
+ ```bash
25
+ # Clone the repository and navigate to the folder
26
+ cd "d:\Remote Antigravity"
27
+
28
+ # Install dependencies and CLI tool in editable mode
29
+ pip install -e .
30
+ ```
31
+
32
+ ### Packaging & Publishing to PyPI
33
+ To build and publish the package so others can install it via `pip install antigravity-remote`:
34
+ 1. **Install Build Tools**:
35
+ ```bash
36
+ pip install --upgrade build twine
37
+ ```
38
+ 2. **Build Distribution Archives**:
39
+ ```bash
40
+ python -m build
41
+ ```
42
+ *(This generates `.whl` and `.tar.gz` files in the `dist/` directory.)*
43
+ 3. **Upload to PyPI**:
44
+ ```bash
45
+ python -m twine upload dist/*
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Setup & IDE Configuration
51
+
52
+ To enable silent executions on your PC and redirect confirmations to your phone, update your **Antigravity IDE User Settings**:
53
+
54
+ 1. Open your settings file: `C:\Users\K\AppData\Roaming\Antigravity IDE\User\settings.json`
55
+ 2. Add the following options to allow automatic local command approvals:
56
+ ```json
57
+ {
58
+ "antigravity.autoApprove": true,
59
+ "antigravity.autonomyLevel": "full"
60
+ }
61
+ ```
62
+ 3. Press **`Ctrl + Shift + P`** in the IDE, type **`Developer: Reload Window`**, and press **Enter** to apply changes.
63
+
64
+ ---
65
+
66
+ ## Usage
67
+
68
+ ### 1. Initialize Configuration
69
+ ```bash
70
+ antigravity-remote init
71
+ ```
72
+ Generates a randomized access PIN for mobile login (stored in `config.json`).
73
+
74
+ ### 2. Start the Server & Tunnel
75
+ Start the server and expose it using localtunnel:
76
+ ```bash
77
+ # Start FastAPI server on all interfaces
78
+ antigravity-remote start --host 0.0.0.0 --port 8000
79
+
80
+ # Expose it to the internet so you can access it on your phone
81
+ npx localtunnel --port 8000
82
+ ```
83
+ Open the localtunnel URL on your mobile phone browser and enter your access PIN!
84
+
85
+ ### 3. CLI Command Execution
86
+ To execute commands on your PC, log them to the server, and monitor them live on your phone with **no desktop prompts**:
87
+ ```bash
88
+ antigravity-remote run "pytest tests/test_server.py"
89
+ ```
90
+
91
+ ### 4. Remote Mode Toggle
92
+ Turn remote monitoring and control on/off:
93
+ ```bash
94
+ # Enable remote mode (wakes up daemon, streams logs)
95
+ antigravity-remote remote --on
96
+
97
+ # Disable remote mode (puts daemon to sleep, stops logging)
98
+ antigravity-remote remote --off
99
+
100
+ # Check status
101
+ antigravity-remote remote --status
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Project Structure
107
+
108
+ ```
109
+ d:/Remote Antigravity/
110
+ ├── .agents/
111
+ │ ├── AGENTS.md # Global agent logging & mobile approval rules
112
+ │ └── skills/
113
+ │ └── remote_control/
114
+ │ └── SKILL.md # Remote loop instruction skill for AI agents
115
+ ├── antigravity_remote/
116
+ │ ├── __init__.py
117
+ │ ├── cli.py # CLI Command handling
118
+ │ ├── server.py # FastAPI server with WebSocket logging & dashboard
119
+ │ ├── agent_daemon.py # Background sidecar polling daemon
120
+ │ ├── agent_approve.py # Mobile approval helper script
121
+ │ ├── task_runner.py # Background subprocess runner
122
+ │ ├── templates/
123
+ │ │ └── index.html # Mobile-responsive glassmorphic dashboard
124
+ │ └── static/
125
+ │ ├── css/
126
+ │ │ └── styles.css # Custom dashboard styles
127
+ │ └── js/
128
+ │ └── main.js # Client-side WebSocket & model switcher logic
129
+ ├── pyproject.toml # Packaging metadata & entrypoints
130
+ └── README.md # Documentation
131
+ ```
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: antigravity-mobile
3
+ Version: 0.1.0
4
+ Summary: A remote monitor and scheduler CLI tool for Antigravity 2.0 IDE
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: fastapi>=0.100.0
9
+ Requires-Dist: uvicorn>=0.22.0
10
+ Requires-Dist: jinja2>=3.1.0
11
+ Requires-Dist: websockets>=11.0
12
+ Requires-Dist: psutil>=5.9.0
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
15
+ Requires-Dist: httpx>=0.24.0; extra == "dev"
16
+
17
+ # Antigravity Remote Monitor & Task Scheduler
18
+
19
+ `antigravity-remote` is a lightweight command-line tool and FastAPI-powered web application designed for the **Google Antigravity IDE and CLI**. It enables you to securely monitor your development workflow, switch AI models, track usage quotas, view real-time log outputs, and confirm or reject commands directly from your mobile device while you are away from your workstation.
20
+
21
+ ---
22
+
23
+ ## Key Features
24
+
25
+ - 📱 **Mobile-Optimized Dashboard**: Responsive, glassmorphic UI styled in a beautiful dark theme with real-time stats.
26
+ - 🤖 **Model Control**: Switch active models (Gemini 3.5 Flash, Claude 4.5 Sonnet, GPT-OSS, etc.) directly from your phone.
27
+ - 📊 **Quota & Limit Progress**: Live tracking of request limits (Gemini Weekly/5-Hr and Claude/GPT Weekly/5-Hr limits).
28
+ - 💻 **Live Agent Thought Output Console**: A real-time console streaming step-by-step developer thoughts, planned tools, and logs from the agent to your phone.
29
+ - 🛡️ **Interactive Mobile Approvals**: Run terminal commands and get interruptive Yes/No popup prompts on your phone instead of the PC desktop.
30
+ - 🔌 **Automatic Offline Fallback**: Automatically bypasses the mobile check and falls back to standard PC desktop prompts if your FastAPI server is offline.
31
+ - ⚡ **PC CLI Run Wrapper (`run`)**: Execute commands directly on your PC that log to the server and appear on your phone, bypassing all sandbox desktop security prompts.
32
+ - 🎛️ **Remote Toggle Switch (`remote`)**: Turn remote mode ON or OFF at any time to save tokens and resources when coding locally.
33
+ - 🔒 **PIN Authentication**: Secure authorization PIN generated on first start, requiring authentication on the mobile client.
34
+
35
+ ---
36
+
37
+ ## Installation
38
+
39
+ ### From Source (Editable Mode)
40
+ ```bash
41
+ # Clone the repository and navigate to the folder
42
+ cd "d:\Remote Antigravity"
43
+
44
+ # Install dependencies and CLI tool in editable mode
45
+ pip install -e .
46
+ ```
47
+
48
+ ### Packaging & Publishing to PyPI
49
+ To build and publish the package so others can install it via `pip install antigravity-remote`:
50
+ 1. **Install Build Tools**:
51
+ ```bash
52
+ pip install --upgrade build twine
53
+ ```
54
+ 2. **Build Distribution Archives**:
55
+ ```bash
56
+ python -m build
57
+ ```
58
+ *(This generates `.whl` and `.tar.gz` files in the `dist/` directory.)*
59
+ 3. **Upload to PyPI**:
60
+ ```bash
61
+ python -m twine upload dist/*
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Setup & IDE Configuration
67
+
68
+ To enable silent executions on your PC and redirect confirmations to your phone, update your **Antigravity IDE User Settings**:
69
+
70
+ 1. Open your settings file: `C:\Users\K\AppData\Roaming\Antigravity IDE\User\settings.json`
71
+ 2. Add the following options to allow automatic local command approvals:
72
+ ```json
73
+ {
74
+ "antigravity.autoApprove": true,
75
+ "antigravity.autonomyLevel": "full"
76
+ }
77
+ ```
78
+ 3. Press **`Ctrl + Shift + P`** in the IDE, type **`Developer: Reload Window`**, and press **Enter** to apply changes.
79
+
80
+ ---
81
+
82
+ ## Usage
83
+
84
+ ### 1. Initialize Configuration
85
+ ```bash
86
+ antigravity-remote init
87
+ ```
88
+ Generates a randomized access PIN for mobile login (stored in `config.json`).
89
+
90
+ ### 2. Start the Server & Tunnel
91
+ Start the server and expose it using localtunnel:
92
+ ```bash
93
+ # Start FastAPI server on all interfaces
94
+ antigravity-remote start --host 0.0.0.0 --port 8000
95
+
96
+ # Expose it to the internet so you can access it on your phone
97
+ npx localtunnel --port 8000
98
+ ```
99
+ Open the localtunnel URL on your mobile phone browser and enter your access PIN!
100
+
101
+ ### 3. CLI Command Execution
102
+ To execute commands on your PC, log them to the server, and monitor them live on your phone with **no desktop prompts**:
103
+ ```bash
104
+ antigravity-remote run "pytest tests/test_server.py"
105
+ ```
106
+
107
+ ### 4. Remote Mode Toggle
108
+ Turn remote monitoring and control on/off:
109
+ ```bash
110
+ # Enable remote mode (wakes up daemon, streams logs)
111
+ antigravity-remote remote --on
112
+
113
+ # Disable remote mode (puts daemon to sleep, stops logging)
114
+ antigravity-remote remote --off
115
+
116
+ # Check status
117
+ antigravity-remote remote --status
118
+ ```
119
+
120
+ ---
121
+
122
+ ## Project Structure
123
+
124
+ ```
125
+ d:/Remote Antigravity/
126
+ ├── .agents/
127
+ │ ├── AGENTS.md # Global agent logging & mobile approval rules
128
+ │ └── skills/
129
+ │ └── remote_control/
130
+ │ └── SKILL.md # Remote loop instruction skill for AI agents
131
+ ├── antigravity_remote/
132
+ │ ├── __init__.py
133
+ │ ├── cli.py # CLI Command handling
134
+ │ ├── server.py # FastAPI server with WebSocket logging & dashboard
135
+ │ ├── agent_daemon.py # Background sidecar polling daemon
136
+ │ ├── agent_approve.py # Mobile approval helper script
137
+ │ ├── task_runner.py # Background subprocess runner
138
+ │ ├── templates/
139
+ │ │ └── index.html # Mobile-responsive glassmorphic dashboard
140
+ │ └── static/
141
+ │ ├── css/
142
+ │ │ └── styles.css # Custom dashboard styles
143
+ │ └── js/
144
+ │ └── main.js # Client-side WebSocket & model switcher logic
145
+ ├── pyproject.toml # Packaging metadata & entrypoints
146
+ └── README.md # Documentation
147
+ ```
@@ -0,0 +1,16 @@
1
+ README.md
2
+ pyproject.toml
3
+ antigravity_mobile.egg-info/PKG-INFO
4
+ antigravity_mobile.egg-info/SOURCES.txt
5
+ antigravity_mobile.egg-info/dependency_links.txt
6
+ antigravity_mobile.egg-info/entry_points.txt
7
+ antigravity_mobile.egg-info/requires.txt
8
+ antigravity_mobile.egg-info/top_level.txt
9
+ antigravity_remote/__init__.py
10
+ antigravity_remote/agent_approve.py
11
+ antigravity_remote/agent_daemon.py
12
+ antigravity_remote/cli.py
13
+ antigravity_remote/server.py
14
+ antigravity_remote/task_runner.py
15
+ antigravity_remote/templates/index.html
16
+ tests/test_server.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ antigravity-mobile = antigravity_remote.cli:main
@@ -0,0 +1,9 @@
1
+ fastapi>=0.100.0
2
+ uvicorn>=0.22.0
3
+ jinja2>=3.1.0
4
+ websockets>=11.0
5
+ psutil>=5.9.0
6
+
7
+ [dev]
8
+ pytest>=7.0.0
9
+ httpx>=0.24.0
@@ -0,0 +1 @@
1
+ antigravity_remote
@@ -0,0 +1,2 @@
1
+ # Antigravity Remote Monitor package
2
+ __version__ = "0.1.0"
@@ -0,0 +1,158 @@
1
+ import os
2
+ import sys
3
+ import json
4
+ import time
5
+ import urllib.request
6
+ import urllib.error
7
+ import argparse
8
+
9
+ def get_auth_token(base_url: str, pin: str) -> str:
10
+ login_url = f"{base_url}/api/login"
11
+ data = json.dumps({"pin": pin}).encode("utf-8")
12
+ req = urllib.request.Request(
13
+ login_url,
14
+ data=data,
15
+ headers={"Content-Type": "application/json"}
16
+ )
17
+ try:
18
+ with urllib.request.urlopen(req, timeout=5) as response:
19
+ res = json.loads(response.read().decode("utf-8"))
20
+ return res.get("token", "")
21
+ except Exception as e:
22
+ print(f"Error logging in: {e}")
23
+ return ""
24
+
25
+ def request_approval(base_url: str, token: str, action_type: str, target: str) -> bool:
26
+ approve_req_url = f"{base_url}/api/agent/approve/request"
27
+ data = json.dumps({"type": action_type, "target": target}).encode("utf-8")
28
+ headers = {
29
+ "Content-Type": "application/json",
30
+ "Authorization": f"Bearer {token}"
31
+ }
32
+ req = urllib.request.Request(approve_req_url, data=data, headers=headers)
33
+ try:
34
+ with urllib.request.urlopen(req, timeout=5) as response:
35
+ return response.status == 200
36
+ except Exception as e:
37
+ print(f"Failed to post approval request: {e}")
38
+ return False
39
+
40
+ def poll_approval_decision(base_url: str, token: str, timeout_seconds: int = 300) -> int:
41
+ check_url = f"{base_url}/api/agent/approve/check"
42
+ headers = {"Authorization": f"Bearer {token}"}
43
+ req = urllib.request.Request(check_url, headers=headers)
44
+
45
+ start_time = time.time()
46
+ print(f"Polling for mobile confirmation (Timeout: {timeout_seconds}s)...")
47
+
48
+ while time.time() - start_time < timeout_seconds:
49
+ # 1. Check local file fallback first
50
+ resp_file = "agent_approval_response.json"
51
+ if os.path.exists(resp_file):
52
+ try:
53
+ with open(resp_file, "r", encoding="utf-8") as f:
54
+ data = json.load(f)
55
+ status = data.get("status")
56
+
57
+ # Small delay to ensure server finished writing/closing before delete
58
+ time.sleep(0.1)
59
+ try:
60
+ os.remove(resp_file)
61
+ except Exception:
62
+ pass
63
+
64
+ if status == "approved":
65
+ print("MOBILE_CONFIRMATION (FILE): APPROVED")
66
+ return 0
67
+ elif status == "rejected":
68
+ print("MOBILE_CONFIRMATION (FILE): REJECTED")
69
+ return 1
70
+ except Exception as e:
71
+ print(f"Error reading file fallback: {e}")
72
+
73
+ # 2. Check HTTP API fallback
74
+ try:
75
+ with urllib.request.urlopen(req, timeout=3) as response:
76
+ data = json.loads(response.read().decode("utf-8"))
77
+ status = data.get("status")
78
+
79
+ if status == "approved":
80
+ print("MOBILE_CONFIRMATION (API): APPROVED")
81
+ return 0
82
+ elif status == "rejected":
83
+ print("MOBILE_CONFIRMATION (API): REJECTED")
84
+ return 1
85
+ except Exception:
86
+ pass # Suppress network errors during polling
87
+
88
+ time.sleep(1.5)
89
+
90
+ print("MOBILE_CONFIRMATION: TIMEOUT")
91
+ return 2
92
+
93
+ def main():
94
+ parser = argparse.ArgumentParser(description="Antigravity Remote Agent Command Approval Helper")
95
+ parser.add_argument("--type", required=True, choices=["command", "edit", "create", "delete"], help="Type of action requiring approval")
96
+ parser.add_argument("--target", required=True, help="Target action/command details")
97
+ parser.add_argument("--url", default="http://127.0.0.1:8000", help="FastAPI Server URL")
98
+ parser.add_argument("--timeout", type=int, default=300, help="Approval timeout in seconds")
99
+ args = parser.parse_args()
100
+
101
+ # Check if server is online first
102
+ server_online = False
103
+ try:
104
+ req = urllib.request.Request(f"{args.url}/api/status", method="GET")
105
+ with urllib.request.urlopen(req, timeout=2) as response:
106
+ server_online = True
107
+ except urllib.error.HTTPError as e:
108
+ if e.code in (401, 403, 405):
109
+ server_online = True
110
+ except Exception:
111
+ pass
112
+
113
+ if not server_online:
114
+ print("MOBILE_CONNECTION: OFFLINE")
115
+ sys.exit(3)
116
+
117
+ # Always write file-based request fallback first
118
+ try:
119
+ with open("agent_approval_request.json", "w", encoding="utf-8") as f:
120
+ json.dump({"type": args.type, "target": args.target}, f)
121
+ except Exception as e:
122
+ print(f"Warning: Failed to write file-based fallback: {e}")
123
+
124
+ # Read config.json to get PIN
125
+ config_path = "config.json"
126
+ if not os.path.exists(config_path):
127
+ print(f"Error: {config_path} not found.")
128
+ sys.exit(3)
129
+
130
+ try:
131
+ with open(config_path, "r") as f:
132
+ config = json.load(f)
133
+ pin = config.get("pin")
134
+ except Exception as e:
135
+ print(f"Error reading config: {e}")
136
+ sys.exit(3)
137
+
138
+ # Login to get token
139
+ token = get_auth_token(args.url, pin)
140
+
141
+ if token:
142
+ # Post approval request over API
143
+ request_approval(args.url, token, args.type, args.target)
144
+
145
+ # Poll for user decision
146
+ exit_code = poll_approval_decision(args.url, token or "", args.timeout)
147
+
148
+ # Cleanup request file if it exists
149
+ if os.path.exists("agent_approval_request.json"):
150
+ try:
151
+ os.remove("agent_approval_request.json")
152
+ except Exception:
153
+ pass
154
+
155
+ sys.exit(exit_code)
156
+
157
+ if __name__ == "__main__":
158
+ main()