text stringlengths 0 1.47k |
|---|
) |
# ───────────────────────────────────────────────────────────────────────────── |
# System prompt |
# ───────────────────────────────────────────────────────────────────────────── |
SYSTEM_PROMPT = ( |
"# TASK\n" |
"Pick the joint pair that defines one 3D rig's lateral facing axis. " |
"Rigs come from Objaverse |
# ===== file: gateway/backing.py ===== |
"""Pluggable backing stores for the harness gateway. |
The gateway needs three capabilities from the outside world, and nothing else: |
GraphStore — session/harness/response/api-key records + ownership edges |
BlobStore — traces, response records, workspace checkpoints, produced files |
SecretStore — model-provider connections/policies ("bring your own keys") |
Two implementations of each: |
local (this file) — SQLite + filesystem + env/file, zero cloud dependencies. The whole |
gateway runs on a laptop: HR_BACKING=local (or just leave |
VG_GATEWAY_URL unset). Point POOL_MGMT_ENDPOINT at a single runner |
process (the pool is only an identifier-routing proxy in front of |
runner replicas — the routes are identical). |
vg (backing_vg.py) — the production AgentStudio infra: vg-gateway (Cosmos graph + Azure |
blob) and the vault service. Verbatim the code that always ran here. |
Selection is one env var: HR_BACKING=vg|local; unset = vg when VG_GATEWAY_URL is set, local |
otherwise. The interface is deliberately SEMANTIC (get/upsert/find/add_edge), not query-shaped: |
call sites never build backend query strings, so an implementation is free to be a graph, a |
relational table, or anything else that can look up records by label + property equality. |
""" |
from __future__ import annotations |
import asyncio |
import base64 |
import contextlib |
import hashlib |
import secrets as secrets_mod |
import io |
import json |
import mimetypes |
import os |
import posixpath |
import re |
import shutil |
import sqlite3 |
import tarfile |
import time |
import uuid |
from pathlib import Path |
from typing import Protocol |
import httpx |
# ── interfaces ──────────────────────────────────────────────────────────────────── |
class GraphStore(Protocol): |
async def get(self, vid: str, label: str | None = None) -> dict | None: ... |
async def upsert(self, label: str, vid: str, props: dict, *, raise_on_fail: bool = False) -> None: ... |
async def add_edge(self, label: str, src: str, dst: str) -> None: ... |
async def find(self, label: str, eq: dict | None = None, neq: dict | None = None) -> list[dict]: ... |
async def delete(self, vid: str, label: str | None = None) -> bool: |
"""Remove one vertex and its edges; False when there was none (or the label differs).""" |
... |
async def probe(self) -> None: |
"""Raise if the store is unreachable/misconfigured. Used by /readyz, which must FAIL on a |
broken plane — the normal read paths swallow errors and return empty.""" |
... |
class BlobStore(Protocol): |
async def get(self, kb: str, file_id: str) -> bytes | None: ... |
async def put(self, kb: str, file_id: str, data: bytes) -> bool: ... |
async def delete(self, kb: str, file_id: str) -> bool: ... |
async def list(self, kb: str, prefix: str, limit: int = 20, cursor: str | None = None) -> dict: ... |
async def probe(self) -> None: ... |
class SecretStore(Protocol): |
async def get(self, tenant: str, name: str) -> str | None: ... |
async def delete(self, tenant: str, name: str) -> None: |
"""Forget a stored secret; nothing happens when there is none.""" |
... |
async def put(self, tenant: str, name: str, value: str, *, |
require_encryption: bool = False) -> None: |
"""`require_encryption=True` is the caller saying "this is a customer credential, not a |
provider key injected by the operator" — a database connection string, for instance. A |
store that cannot encrypt must raise SecretsNotConfigured rather than write it in the |
clear. Part of the interface, not of one implementation: a datasource must be refused |
the same way whichever backing is configured.""" |
... |
class WorkspaceFiles(Protocol): |
"""Reading and writing one file inside a session's workspace. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.