Repository navigation
feat: agent runtime, protocol, vault, pairing and installer - #1
Merged
Merged
Conversation
…ion, and doctor command
…, and runtime startup
…uests and team roles
- command header carries a signed reply_to; replies and events are sealed to it
- every event body is { in_reply_to, data }, wrapped once in the handler context
- agent.subscribe/unsubscribe and server.status.changed events
- hello/auth transport frames and the agent connection answering them
- HTTP requests signed by the agent (pairing, backup upload URL)
- role grants, members.json, min_role per command and role checks in openCommand
- backup upload URL for the Tegra Cloud destination requested from the API
…p config read; fix server file groups - tegrad/crypto: encryptBlobChunks/decryptBlobChunks (TGB1, 1 MiB XChaCha20-Poly1305 chunks bound to index and last) - server.world.import (editor): download, verify, decrypt, safe unzip, swap the world with a prior backup - server.deploy.serverpack accepts an optional key for TGB1 blobs - server.backup.config.get (viewer) answers with server.backup.config.result - server files and the shared Java runtime now get group tegrad-srv, setgid directories and group access - tegrad doctor checks server file groups and modes - child processes are spawned by absolute path resolved from the fixed PATH - handler_error logs include the error name and a sanitized message - repeated WebSocket errors drop to debug after three failed attempts
…hides the interfaces
…packs from the archive root and stream large server packs to disk
The Minecraft process can swap any folder in its directory for a symbolic link. finalizeServerPath and secureTree checked with lstat and then changed group and mode by path, so a swap in that window could make the agent chown and chmod its own state for the server group. - Resolve every component through directory descriptors (/proc/self/fd, same guarantee as openat2 RESOLVE_BENEATH) and apply fchown/fchmod on the opened descriptor; links are refused at any depth. - Server units no longer see the agent state, the backups or other server folders (InaccessiblePaths, TemporaryFileSystem + BindPaths).
Mod code can swap any folder in the server directory for a symbolic link in the middle of an agent operation. Backups, recursive delete, move, copy, write, upload, read and listing used plain paths after an lstat check, so a swap at the right moment made the agent pack, delete, write or read its own state. Folders are now opened one component at a time with O_NOFOLLOW and every child is reached through /proc/self/fd/N/name (DirHandle), so a swap after opening has no effect. Race tests swap a folder in a separate process while the agent repeats each operation; all six fail on the old code and pass on the new one.
Commands now declare a level instead of a sensitive flag, split by the sandbox boundary: - session: everything that stays inside the server folder (files, mods, modpack install, server pack, origin, settings, backups create) - sudo: what leaves the folder (backup restore, server delete, playit key); needs an elevated session or the account key - account: backup delete and members; the account key only An elevated session is a session certificate with scope "elevated" inside the signed part, so older agents fail to verify it and refuse it. The agent refuses elevated certificates valid for more than 1 hour; the launcher closes the window earlier and drops the key. New errors elevation_required, elevation_invalid and account_key_required replace sensitive_requires_account_key. definition.sensitive stays as level !== "session" for launchers that only know the flag, which keep signing those commands with the account key.
…blocks the agent Commands were handled one at a time across the whole agent, so a loader change waiting on the Forge installer stopped every other request (server list, console, other servers) until it ended. Verification still runs in arrival order; reads now run right away and changes queue only behind changes to the same server (or the agent itself). Also: log the installer's own reason when Forge/NeoForge fail, and retry a background cloud upload that failed on the network (5 s, 30 s, 2 min).
…toggle mods and change their version server.mods.list now lists what is really in mods/: mods Tegra recorded, jars put there by hand, disabled jars and recorded mods whose file is gone. Each jar's name, version, authors and loader come from fabric.mod.json, quilt.mod.json, mods.toml or mcmod.info and are cached in .tegra/mods-manifest.json, so only new or changed jars are opened, one at a time. server.mods.toggle renames a jar to .disabled and back. server.mods.replace downloads another version of a mod, keeps it disabled if it was, and keeps a modpack mod in the modpack layer so the next modpack update still lists it.
Jars built by Gradle carry directory entries with a size, which the extraction parser rightly refuses, so no metadata was found. Metadata now comes from a small in-memory reader with capped reads that writes nothing to disk. A [[mods]] header followed by a comment is now recognized too.
The mods manifest now keeps each jar's CurseForge fingerprint next to its SHA-1, so mods with no project recorded (server pack contents, jars added by hand) can be looked up on CurseForge and Modrinth. server.mods.identify records the project and version found for them; a project already recorded is never replaced.
Saving the secret key now brings the tunnel up (or restarts it on the new key) instead of leaving it stopped, and tegrad starts it again at boot when a key is saved. A user stop is remembered in playit.disabled so a restart leaves the tunnel down until started again.
- tunnel.playit.claim.begin/status/cancel: tegrad generates a claim code, the user approves it on playit.gg, and tegrad trades it for the key of a self-managed agent, then starts the tunnel. No key is copied. - server.tunnel.get/create: a self-managed agent creates the server's Minecraft Java tunnel to 127.0.0.1:<port> itself and reports its public address; a port change is applied to the existing tunnel. - The playit status adds managed, key_hint and the current claim. A key pasted by hand drops the self-managed state, since its agent type is unknown.
… and history - /v1/tunnels/create takes name, protocol, origin with the agent id and an endpoint (shared global region), as playit's own Minecraft plugin sends; the older ports/alloc body was refused as unparsable. The agent id is read from /v1/agents/rundata, stored, and reported as agent_id_hint. - A Minecraft tunnel of the agent already aimed at the server port is adopted instead of creating a second one. - server.console.subscribe takes tail_lines to start near the end of the log, lines events carry from_offset, and server.console.history returns the lines before an offset so the console can page back on scroll.
…ared Servers on one agent often share a port, since only one runs at a time. Adopting an existing Minecraft tunnel by port picked the tunnel another server already owned, so a second server showed the first one's address. Adoption now skips tunnels another server owns, and a server recorded with another server's tunnel (from that bug) is treated as having none, so creating it again makes its own tunnel.
- server.create without a port takes the first one from 25565 up that no other server of the agent is set to and nothing on the machine listens on (read from /proc/net/tcp, so src/server still never opens a socket). - Starting a server whose port another running server holds fails with port_in_use and names that server, instead of Minecraft crashing on bind.
…e) and let a server replace its playit tunnel
… playit allocation errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work in progress on the agent: message protocol and crypto primitives, account vault, runtime (state, WebSocket client, command queue, CLI), pairing and revocation, the Linux installer with systemd units, server runtime, files, backups and updates.
Draft: more pieces are still landing on this branch.