Spaces:
Runtime error
Runtime error
Upload 17 files
Browse files- Dockerfile +1 -3
- app/__pycache__/agy_bridge.cpython-313.pyc +0 -0
- app/agy_bridge.py +8 -2
- start.sh +3 -24
Dockerfile
CHANGED
|
@@ -2,9 +2,7 @@
|
|
| 2 |
FROM python:3.12-slim
|
| 3 |
|
| 4 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 5 |
-
curl ca-certificates
|
| 6 |
-
gnome-keyring libsecret-tools dbus dbus-x11 \
|
| 7 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
# HF Spaces run as uid 1000.
|
| 10 |
RUN useradd -m -u 1000 user
|
|
|
|
| 2 |
FROM python:3.12-slim
|
| 3 |
|
| 4 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 5 |
+
curl ca-certificates && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# HF Spaces run as uid 1000.
|
| 8 |
RUN useradd -m -u 1000 user
|
app/__pycache__/agy_bridge.cpython-313.pyc
CHANGED
|
Binary files a/app/__pycache__/agy_bridge.cpython-313.pyc and b/app/__pycache__/agy_bridge.cpython-313.pyc differ
|
|
|
app/agy_bridge.py
CHANGED
|
@@ -58,7 +58,8 @@ _ready_homes: set[str] = set()
|
|
| 58 |
# redirect HOME per key, each key's home needs its own copy of the credential.
|
| 59 |
# No-op on Windows (AGY_CREDS_JSON unset -> uses the shared OS keyring).
|
| 60 |
_CREDS_JSON = os.environ.get("AGY_CREDS_JSON", "").strip()
|
| 61 |
-
|
|
|
|
| 62 |
|
| 63 |
|
| 64 |
class AgyError(RuntimeError):
|
|
@@ -78,7 +79,12 @@ def ensure_home(home: Path) -> None:
|
|
| 78 |
cfg_dir.mkdir(parents=True, exist_ok=True)
|
| 79 |
(cfg_dir / "settings.json").write_text(json.dumps(_HARDENED_SETTINGS, indent=2), encoding="utf-8")
|
| 80 |
if _CREDS_JSON: # Linux/HF: each isolated home gets the credential file
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
_ready_homes.add(key)
|
| 83 |
|
| 84 |
|
|
|
|
| 58 |
# redirect HOME per key, each key's home needs its own copy of the credential.
|
| 59 |
# No-op on Windows (AGY_CREDS_JSON unset -> uses the shared OS keyring).
|
| 60 |
_CREDS_JSON = os.environ.get("AGY_CREDS_JSON", "").strip()
|
| 61 |
+
# agy reads its OAuth token from this file (relative to HOME), confirmed on Linux.
|
| 62 |
+
_CREDS_FILENAME = os.environ.get("AGY_CREDS_FILENAME", "antigravity-oauth-token")
|
| 63 |
|
| 64 |
|
| 65 |
class AgyError(RuntimeError):
|
|
|
|
| 79 |
cfg_dir.mkdir(parents=True, exist_ok=True)
|
| 80 |
(cfg_dir / "settings.json").write_text(json.dumps(_HARDENED_SETTINGS, indent=2), encoding="utf-8")
|
| 81 |
if _CREDS_JSON: # Linux/HF: each isolated home gets the credential file
|
| 82 |
+
cf = cfg_dir / _CREDS_FILENAME
|
| 83 |
+
cf.write_text(_CREDS_JSON, encoding="utf-8")
|
| 84 |
+
try:
|
| 85 |
+
os.chmod(cf, 0o600)
|
| 86 |
+
except OSError:
|
| 87 |
+
pass
|
| 88 |
_ready_homes.add(key)
|
| 89 |
|
| 90 |
|
start.sh
CHANGED
|
@@ -1,31 +1,10 @@
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
-
# Antaram startup on HF (Linux). agy
|
| 3 |
-
#
|
|
|
|
| 4 |
set -e
|
| 5 |
|
| 6 |
-
# 1) D-Bus session + unlocked gnome-keyring secrets service.
|
| 7 |
-
export $(dbus-launch)
|
| 8 |
-
eval "$(printf '\n' | gnome-keyring-daemon --unlock --components=secrets 2>/dev/null)" || true
|
| 9 |
-
printf '\n' | gnome-keyring-daemon --start --components=secrets 2>/dev/null || true
|
| 10 |
-
sleep 2
|
| 11 |
-
|
| 12 |
-
# 2) Seed the agy OAuth credential into the keyring.
|
| 13 |
-
# Windows target was "gemini:antigravity" => Secret Service service/username.
|
| 14 |
-
KR_SERVICE="${AGY_KEYRING_SERVICE:-gemini}"
|
| 15 |
-
KR_USER="${AGY_KEYRING_USER:-antigravity}"
|
| 16 |
-
if [ -n "$AGY_CREDS_JSON" ]; then
|
| 17 |
-
if printf '%s' "$AGY_CREDS_JSON" | secret-tool store --label="${KR_SERVICE}:${KR_USER}" \
|
| 18 |
-
service "$KR_SERVICE" username "$KR_USER" 2>/dev/null; then
|
| 19 |
-
echo "[start] seeded keyring credential (${KR_SERVICE}:${KR_USER})"
|
| 20 |
-
else
|
| 21 |
-
echo "[start] WARN: secret-tool store failed (keyring may be unavailable)"
|
| 22 |
-
fi
|
| 23 |
-
fi
|
| 24 |
-
|
| 25 |
-
# 3) Also drop the credential as a file (per-key homes do their own copy too).
|
| 26 |
python -c "from app.bootstrap import ensure_credentials; print('[start] creds file ->', ensure_credentials())" || true
|
| 27 |
-
|
| 28 |
echo "[start] agy version: $(${AGY_BIN:-agy} --version 2>/dev/null || echo '??')"
|
| 29 |
|
| 30 |
-
# 4) Serve (HF routes to $PORT, default 7860).
|
| 31 |
exec uvicorn app.agy_server:app --host 0.0.0.0 --port "${PORT:-7860}"
|
|
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
+
# Antaram startup on HF (Linux). agy reads its OAuth token from a file
|
| 3 |
+
# (.gemini/antigravity-cli/antigravity-oauth-token); each per-key home gets its
|
| 4 |
+
# own copy via agy_bridge.ensure_home(). We also write it to AGY_CREDS_PATH if set.
|
| 5 |
set -e
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
python -c "from app.bootstrap import ensure_credentials; print('[start] creds file ->', ensure_credentials())" || true
|
|
|
|
| 8 |
echo "[start] agy version: $(${AGY_BIN:-agy} --version 2>/dev/null || echo '??')"
|
| 9 |
|
|
|
|
| 10 |
exec uvicorn app.agy_server:app --host 0.0.0.0 --port "${PORT:-7860}"
|