Skip to content

Commit 7129dde

Browse files
authored
Add typed local and cloud model gateways for agent zones (#81)
1 parent f55cc28 commit 7129dde

9 files changed

Lines changed: 6969 additions & 0 deletions

‎sandbox/README.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ always refuses in this generation: the `ai` client cannot yet open a guest sessi
1717
| [`runtime.py`](ai_zones/runtime.py) | Bounded signed Python runtime manifests and verification, plus a root-only installation interface separate from the tool updater. |
1818
| [`deploy.py`](ai_zones/deploy.py) | Read-only plans, explicit offline staging, first-runtime bootstrap and guarded host preparation; activation remains disabled. |
1919
| [`cli.py`](ai_zones/cli.py), [`bin/ai`](bin/ai) | Fixed-zone SSH client and launcher; the required host `start` action currently refuses. |
20+
| [`model_gateway.py`](ai_zones/model_gateway.py) | Fixed local chat endpoint for Pi, with typed function tools and validated streaming. |
21+
| [`codex_gateway.py`](ai_zones/codex_gateway.py) | Typed Responses requests, fixed model catalogue and validated streaming for Codex. |
22+
| [`anthropic_gateway.py`](ai_zones/anthropic_gateway.py) | Typed Messages requests and validated streaming for Claude. |
23+
| [`cloud_service.py`](ai_zones/cloud_service.py) | Unprivileged internal-only Unix HTTP service with fixed provider roles and protected configuration. |
2024

2125
[`policy.example.json`](policy.example.json) contains synthetic paths and model
2226
settings. Schema validation alone grants no authority. Protected loading requires
@@ -102,6 +106,34 @@ installs and starts its SSH and broker relays. It does not prepare missing
102106
packages or fetch dependencies. No host services are installed or activated by
103107
generating seeds, profiles, unit fragments or VM arguments.
104108

109+
## Model services
110+
111+
The local adapter forwards to a fixed model service; it starts no inference
112+
process. Keep the existing oMLX inference server behind the Slopgate model
113+
gateway: one 125-billion-parameter model per Mac host serves both zones.
114+
115+
Cloud services are internal-only. Trusted launch option `--provider codex` or
116+
`--provider anthropic` selects distinct configuration, credential and socket
117+
paths. On macOS these are below `/Library/AgentSandbox`; Linux uses
118+
`/opt/agent-sandbox`. Each role reads `config/internal/<provider>.json` and
119+
`config/internal/<provider>-credentials.json`, and serves
120+
`run/internal/<provider>/cloud.sock`. Configuration must match the launch role.
121+
The service refuses root and unsafe or missing configuration. Its private
122+
credential group and broker socket group are distinct.
123+
124+
Guests cannot choose upstream origins, credentials or server configuration.
125+
Adapters accept the supported typed client operations and reject hosted tools
126+
and remote connectors. Client tool calls are returned to the guest; gateways
127+
do not execute them on the host. Cancellation and absolute deadlines cover
128+
upstream header waits as well as streaming. Malformed or truncated upstream responses cannot produce a successful
129+
completion marker.
130+
131+
Tests use the installed clients against local mock providers with dummy
132+
credentials. These results establish the tested protocol paths, not live
133+
subscription authentication, token refresh, Linux client compatibility or
134+
operating-system egress confinement. A guest-facing broker and protected host
135+
service activation are separate deployment work.
136+
105137
## Verification and deployment gates
106138

107139
From the repository root, run the affected standard-library unittest suite:

‎sandbox/ai_zones/anthropic_gateway.py‎

Lines changed: 677 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)