feat: local drafter (pi against an OpenAI-compatible server on your own hardware)
tests / unittest (push) Failing after 28s
tests / unittest (push) Failing after 28s
drafter: local runs the pi agent against the model already loaded on a self-hosted server, as an unprivileged user, in the same sandbox as the Claude drafter. It fails soft when the server is unreachable or has no model loaded. Both drafters now refuse to continue if git metadata changed during drafting, and strip project pi configuration from the sandbox. Tested live against a self-hosted server: one run, 12 turns, docs PR opened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9dea56ce98
commit
1ef68f12fb
14 files changed
+1303
-42
No files matched your search
+20
-1
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import urllib.parse
|
||||
from collections.abc import Iterable, Mapping
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
@@ -27,6 +28,8 @@ class Inputs:
|
||||
model: str
|
||||
# Listed documents the drafter may read but not edit; each entry is within docs.
|
||||
review_only: tuple[str, ...] = ()
|
||||
# The local drafter's OpenAI-compatible base URL; set only when drafter is local.
|
||||
local_url: str | None = None
|
||||
|
||||
|
||||
def normalize_drafter(raw: str | None) -> str:
|
||||
@@ -35,6 +38,18 @@ def normalize_drafter(raw: str | None) -> str:
|
||||
return value if value in DRAFTERS else "none"
|
||||
|
||||
|
||||
def parse_local_url(raw: str | None) -> str:
|
||||
"""The local_url input without a trailing slash. Raises ValueError unless it is an
|
||||
http(s) URL with a host."""
|
||||
url = (raw or "").strip().rstrip("/")
|
||||
if not url:
|
||||
raise ValueError("input 'local_url' is required when drafter is local")
|
||||
parts = urllib.parse.urlsplit(url)
|
||||
if parts.scheme not in ("http", "https") or not parts.hostname:
|
||||
raise ValueError(f"input 'local_url' must be an http or https URL, got {url!r}")
|
||||
return url
|
||||
|
||||
|
||||
def _lines(raw: str | None) -> tuple[str, ...]:
|
||||
"""Split a newline-separated input, trimming and dropping blank lines."""
|
||||
return tuple(line.strip() for line in (raw or "").splitlines() if line.strip())
|
||||
@@ -64,8 +79,11 @@ def parse_inputs(env: Mapping[str, str]) -> Inputs:
|
||||
except ValueError:
|
||||
raise ValueError(f"input 'tracking_issue' must be an integer, got {issue_raw!r}") from None
|
||||
|
||||
drafter = normalize_drafter(env.get("INPUT_DRAFTER"))
|
||||
local_url = parse_local_url(env.get("INPUT_LOCAL_URL")) if drafter == "local" else None
|
||||
|
||||
return Inputs(
|
||||
drafter=normalize_drafter(env.get("INPUT_DRAFTER")),
|
||||
drafter=drafter,
|
||||
docs=docs,
|
||||
generated=_lines(env.get("INPUT_GENERATED")),
|
||||
top_level=_lines(env.get("INPUT_TOP_LEVEL")) or DEFAULT_TOP_LEVEL,
|
||||
@@ -75,6 +93,7 @@ def parse_inputs(env: Mapping[str, str]) -> Inputs:
|
||||
doc_guide=_text(env, "INPUT_DOC_GUIDE") or None,
|
||||
model=_text(env, "INPUT_MODEL") or DEFAULT_MODEL,
|
||||
review_only=review_only,
|
||||
local_url=local_url,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user