Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ and its resources.
GitLab: made once on the run's machine with its token, its tasks' lock, the stack's command line), `proxy` (a
tinyproxy of a unit's own for the tasks that ask for a proxy) and, in `startup/`,
`sitecustomize`: its VMs' disk write limit in every process its driver starts), `catalogue/agents/<key>/`
(the reference `agent`; JiuwenSwarm's `agent` and mini-swe-agent's `run`, the wrappers that start them) and `catalogue/capabilities/<key>/` (the keyword-memory `capability`); `workspace` (and
(the reference `agent`; DigitalMate's `run` and `gateway` (product startup and task submission);
JiuwenSwarm's `agent` and mini-swe-agent's `run`, the wrappers that start them) and `catalogue/capabilities/<key>/` (the keyword-memory `capability`); `workspace` (and
`workspace_cli`, its shell command),
`cli` and `__main__` (the unified `nullius` and `python -m nullius` commands),
`paths` (user config, data and cache locations), `ondisk` (a file written whole then renamed into place, a lock, a digest), `prices` (the user's model price list: fetched on request and before a capped run; what a cost is estimated from), `migrate` (explicit copying of legacy checkout storage), `settings`, `hosts`, `constraints` (what Nullius may use on each machine: one table, the container and systemd scope probes, the warnings), `execution`, `progress` (what a run is doing, one line per stage), `prerequisites` (what a recipe needs of each machine it runs on, asked before Run and again as it starts), `onboarding` (the Getting started checklist: what this machine
Expand Down
80 changes: 80 additions & 0 deletions app/nullius/catalogue/agents/digitalmate/agent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"schema": "nullius.agent/v1",
"key": "digitalmate",
"label": "DigitalMate",
"summary": "DigitalMate's Personal Agent service with its owned WorkSwarm runtime.",
"upstream": {
"repository": "https://github.com/openJiuwen-ai/DigitalMate",
"tested": "709f4d39d613cf191d0dbb8bf1e4bec8e8695edf",
"license": "Apache-2.0",
"tag": "v0.1.12",
"core": "Bundled WorkSwarm 0d6857507236d1299276caf0f6fe09e5baaa4c23 and agent-core 8f9f112698d5580b749158b21b1a89a54e16a8f9, verified and installed by the release installer",
"version": "0.1.12"
},
"install": {
"python": "3.13",
"project": ".",
"pip": [
"websockets==15.0.1"
],
"commands": [
[
"uv",
"pip",
"install",
"--quiet",
"--python",
"{install}/.venv/bin/python",
"{install}/src/harness/personal-agent/services/agent_bridge[geo]"
],
[
"uv",
"venv",
"--quiet",
"--seed",
"--python",
"{install}/.venv/bin/python",
"{install}/runtime"
],
[
"{install}/runtime/bin/python",
"{install}/src/harness/personal-agent/deploy/install_runtime.py"
]
]
},
"start": {
"command": [
"{install}/.venv/bin/python",
"{here}/run.py",
"--install",
"{install}",
"{prompt}"
]
},
"model": {
"apis": [
"chat"
],
"env": {
"API_BASE": "{base_url}",
"API_KEY": "{key}",
"MODEL_NAME": "{model}",
"MODEL_PROVIDER": "OpenAI"
}
},
"offers": [
"agent.task/v1"
],
"proven": {
"agent.task/v1": {
"passed": "3/3",
"on": "2026-11-20",
"model": "meta/muse-spark-1.3-contributor",
"provider": "openrouter",
"version": "0.1.12",
"kit_version": 1,
"backend": "container",
"job": "2026-11-20__15-16-06__kit__agent-task-v1__digitalmate"
}
}
}
99 changes: 99 additions & 0 deletions app/nullius/catalogue/agents/digitalmate/gateway.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
"""Submit a task through DigitalMate's native Gateway and return its final answer."""
from __future__ import annotations

import json
from pathlib import Path
import time
import uuid

from websockets.exceptions import WebSocketException
from websockets.sync.client import connect


class Gateway:
def __init__(self, socket, deadline: float):
self.socket = socket
self.deadline = deadline
self.sequence = 0

def request(self, **params) -> dict:
self.sequence += 1
request_id = f"nullius-{self.sequence}"
end = min(self.deadline, time.monotonic() + 120)
if time.monotonic() >= end:
raise TimeoutError("DigitalMate task deadline exceeded")
self.socket.send(json.dumps({
"id": request_id, "method": "digitalmate.request", "params": params,
}, ensure_ascii=False))
while True:
remaining = end - time.monotonic()
if remaining <= 0:
raise TimeoutError("DigitalMate request timed out: " + params["action"])
reply = json.loads(self.socket.recv(timeout=remaining))
# Ignore streamed events; only task snapshots contain the final result.
if not isinstance(reply, dict) or reply.get("id") != request_id:
continue
if reply.get("ok") is not True:
error = reply.get("error") or {}
raise RuntimeError("DigitalMate request rejected: " + str(error.get("code", "unknown")))
result = reply.get("result")
if not isinstance(result, dict):
raise RuntimeError("DigitalMate Gateway returned an invalid response")
return result


def find_task(snapshot: dict, room_id: str, submission_id: str) -> dict | None:
root = snapshot.get("snapshot", snapshot)
if not isinstance(root, dict) or not isinstance(root.get("tasks", []), list):
raise RuntimeError("DigitalMate Gateway returned an invalid snapshot")
for task in root.get("tasks", []):
if isinstance(task, dict) and task.get("room_id") == room_id and task.get("submission_id") == submission_id:
return task
return None


def final_answer(task: dict) -> str:
if task.get("status") != "completed":
raise RuntimeError("DigitalMate task did not complete: " + str(task.get("status")))
answer = task.get("result")
if not isinstance(answer, str) or not answer.strip():
raise RuntimeError("DigitalMate completed without a final answer")
return answer


def submit_task(prompt: str, project_path: Path, token: str, *, timeout: float = 600,
url: str = "ws://127.0.0.1:18092/digitalmate/ws") -> str:
"""Use the isolated local service; forward the prompt and workspace unchanged."""
deadline = time.monotonic() + timeout
try:
with connect(url,
additional_headers={"Authorization": "Bearer " + token},
open_timeout=min(30, timeout), close_timeout=5,
max_size=32 * 1024 * 1024, proxy=None) as socket:
gateway = Gateway(socket, deadline)
created = gateway.request(action="room.create", title="Nullius task", agent_id="digitalmate")
room_id = created.get("room_id")
if not isinstance(room_id, str) or not room_id:
raise RuntimeError("DigitalMate room.create returned no room_id")
submission_id = str(uuid.uuid4())
snapshot = gateway.request(
action="room.message", room_id=room_id, submission_id=submission_id,
agent_id="digitalmate", text=prompt, project_path=str(project_path),
client={"language": "en", "device": "mobile"},
)
task = find_task(snapshot, room_id, submission_id)
if task is None and not snapshot.get("task_id"):
raise RuntimeError("DigitalMate room.message returned no task receipt")
while True:
if task is not None:
status = task.get("status")
if status not in {"pending", "queued", "running"}:
return final_answer(task)
remaining = deadline - time.monotonic()
if remaining <= 0:
raise TimeoutError("DigitalMate task deadline exceeded")
time.sleep(min(1, remaining))
task = find_task(gateway.request(action="snapshot"), room_id, submission_id)
except WebSocketException as error:
# Keep authentication headers and connection internals out of stderr.
raise RuntimeError("DigitalMate Gateway connection failed") from error
126 changes: 126 additions & 0 deletions app/nullius/catalogue/agents/digitalmate/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
"""Start the product service with relay credentials and submit Nullius's task."""
from __future__ import annotations

import argparse
import json
import os
from pathlib import Path
import signal
import subprocess
import sys
import tempfile
import time
from urllib.error import URLError
from urllib.request import urlopen
import uuid

from gateway import submit_task


def stop(service: subprocess.Popen) -> None:
# The supervisor and tool children belong to this trial too.
try:
os.killpg(service.pid, signal.SIGTERM)
except ProcessLookupError:
service.wait()
return
try:
service.wait(timeout=15)
except subprocess.TimeoutExpired:
pass
try:
os.killpg(service.pid, signal.SIGKILL)
except ProcessLookupError:
pass
service.wait()


def require_container() -> None:
if not any(Path(path).exists() for path in ("/.dockerenv", "/run/.containerenv")):
raise RuntimeError("DigitalMate requires --backend container for service isolation and cleanup")


def run(install: Path, prompt: str) -> str:
source = install / "src"
runtime = install / "runtime/bin/python"
launcher = source / "harness/personal-agent/services/agent_bridge/src/server_engine/workswarm_launcher.py"
if not runtime.is_file() or not launcher.is_file():
raise RuntimeError("DigitalMate installation is missing its runtime or product launcher")
for name in ("API_BASE", "API_KEY", "MODEL_NAME"):
if not os.environ.get(name):
raise RuntimeError("Nullius relay setting is missing: " + name)
require_container()

# Keep product state outside the benchmark workspace and isolated per trial.
with tempfile.TemporaryDirectory(prefix="digitalmate-", dir=Path.home()) as temporary:
state = Path(temporary)
env = dict(os.environ)
token = uuid.uuid4().hex
env.update(
DIGITALMATE_ACCESS_TOKEN=token,
DIGITALMATE_WORKSWARM_COMMAND=json.dumps([str(runtime), str(launcher)]),
DIGITALMATE_SEARCH_PYTHON=sys.executable,
DIGITALMATE_WORKSWARM_TOOL_PYTHON=str(runtime),
)
# Match the release's deploy/entrypoint.py defaults for its owned state.
env.setdefault("DIGITALMATE_SECRET_STORE", "file")
env.setdefault("DIGITALMATE_MEMORY_BACKEND", "sqlite-offline")
env.setdefault("DIGITALMATE_SCHEDULE_SCAN_ENABLED", "0")
# These values must not redirect this trial to a deployed service.
for key in ("DIGITALMATE_WORKSWARM_WS", "DIGITALMATE_CONFIG_FILE", "DIGITALMATE_CLIENT_AUTH"):
env.pop(key, None)
service = subprocess.Popen(
[sys.executable, "-m", "server_engine.engine_cli", "serve", "--workspace", str(state),
"--host", "127.0.0.1", "--port", "18092"],
env=env, stdin=subprocess.DEVNULL, stdout=sys.stderr, stderr=sys.stderr,
start_new_session=True,
)
previous = {}
def interrupted(signum, _frame):
raise SystemExit(128 + signum)
for signum in (signal.SIGTERM, signal.SIGINT):
previous[signum] = signal.signal(signum, interrupted)
try:
deadline = time.monotonic() + 180
while True:
if service.poll() is not None:
raise RuntimeError("DigitalMate service exited during startup; inspect agent stderr")
try:
with urlopen("http://127.0.0.1:18092/health/ready", timeout=2) as response:
if response.status == 200:
break
except (URLError, TimeoutError):
pass
if time.monotonic() >= deadline:
raise RuntimeError("DigitalMate service did not become ready in 180 seconds")
time.sleep(0.5)
return submit_task(prompt, Path.cwd(), token)
finally:
stop(service)
# Preserve WorkSwarm's separate log before deleting trial state.
runtime_log = state / "workswarm/process.log"
if runtime_log.is_file():
from server_engine.engine_config import redact_credentials
with runtime_log.open("rb") as handle:
handle.seek(max(0, runtime_log.stat().st_size - 32768))
tail = handle.read().decode("utf-8", errors="replace")
print(redact_credentials(tail, env), file=sys.stderr)
for signum, handler in previous.items():
signal.signal(signum, handler)


def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--install", required=True, type=Path)
parser.add_argument("prompt")
args = parser.parse_args()
try:
print(run(args.install.resolve(), args.prompt))
return 0
except (RuntimeError, subprocess.SubprocessError, ValueError, OSError) as error:
print("digitalmate-nullius: " + str(error), file=sys.stderr)
return 1


if __name__ == "__main__":
raise SystemExit(main())
16 changes: 13 additions & 3 deletions app/nullius/standard/contract/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
SLOTS = {"here", "install", "prompt"}
_WORD = re.compile(r"^(?:[A-Za-z0-9_./:=@+-]|\{[a-z]+\})+$")
_SLOT = re.compile(r"\{([a-z]+)\}")
# An install command's word may also name a package's extras (path[extra,other]).
_INSTALL_WORD = re.compile(r"^(?:[A-Za-z0-9_./:=@+,\[\]-]|\{[a-z]+\})+$")
_KEY = re.compile(r"^[a-z][a-z0-9-]{0,39}$")
_ID = re.compile(r"^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$")
_TAG = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._+/-]{0,127}$")
Expand Down Expand Up @@ -344,7 +346,9 @@ def _install(d: dict, where: str = "install") -> List[str]:
``locked``, the project's own lock file (``uv.lock``) installed as its
pins, ``pip`` resolved beside them, rather than its loose requirements;
``virtual``, with ``locked``, those pins without the project itself, as
``uv sync`` installs a project that declares no build system.
``uv sync`` installs a project that declares no build system;
``commands``, the upstream's own install steps, run in the folder once its
packages are in (``{install}`` names it).
A benchmark's driver has the same block, ``driver.install`` (:func:`driver_install`):
``where`` is the name its problems are said under."""
inst = d.get("install") or {}
Expand Down Expand Up @@ -403,6 +407,12 @@ def _install_block(d: dict, inst: dict) -> List[str]:
bad.append(f"install.prefetch: {m!r} is not a hub model id (owner/name)")
if inst.get("prefetch") and not (inst.get("pip") or inst.get("project") or inst.get("indexes") or inst.get("wheels")):
bad.append("install: prefetch goes with pip, project or indexes, the environment it is installed in")
if "commands" in inst:
if not isinstance(inst["commands"], list) or not inst["commands"]:
bad.append("install.commands: a list of commands")
else:
for i, cmd in enumerate(inst["commands"]):
bad += _command(f"install.commands[{i}]", cmd, {"install"}, _INSTALL_WORD)
return bad


Expand Down Expand Up @@ -695,12 +705,12 @@ def options_of(d: dict, given: Optional[dict] = None) -> Tuple[dict, List[str]]:
return {n: given.get(n, o.get("default")) for n, o in opts.items()}, bad


def _command(where: str, cmd, slots=SLOTS) -> List[str]:
def _command(where: str, cmd, slots=SLOTS, word=_WORD) -> List[str]:
if not isinstance(cmd, list) or not cmd or not all(isinstance(w, str) for w in cmd):
return [f"{where}: a list of words"]
bad = []
for w in cmd:
if not _WORD.match(w):
if not word.match(w):
bad.append(f"{where}: {w!r} is not a plain word")
for s in _SLOT.findall(w):
if s not in slots:
Expand Down
5 changes: 4 additions & 1 deletion app/nullius/standard/requirements/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

- ``agents/<key>/<digest>/`` and ``capabilities/<key>/<digest>/``: the packages a
definition's ``install`` names (``npm`` into ``node_modules``, ``pip`` and
``wheels`` - a wheel by its URL, checked by its sha256 - into a ``uv`` environment), the digest taken over that list so a re-pin installs
``wheels`` - a wheel by its URL, checked by its sha256 - into a ``uv`` environment, then
its ``commands``, the upstream's own install steps), the digest taken over that list so a re-pin installs
beside the old one rather than over it;
- ``drivers/<key>/<digest>/``: a benchmark's ``driver.install`` the same way -
the environment its upstream's own code needs, which its driver imports
Expand Down Expand Up @@ -257,6 +258,8 @@ def _steps(inst: dict, where: str, up: Optional[dict], src: Optional[str], log:
if inst.get("prefetch"):
step([py, "-c", "import sys\nfrom huggingface_hub import snapshot_download\nfor m in sys.argv[1:]: snapshot_download(m)"]
+ list(inst["prefetch"]), env={"HF_HUB_CACHE": os.path.join(where, HF)})
for cmd in inst.get("commands") or []: # the upstream's own installer, once its packages are in
step([w.replace("{install}", where) for w in cmd])


def process_env(d: dict, where: str, home: str, options: Optional[dict] = None) -> dict:
Expand Down
Loading