mystack-rig 1.3.2__tar.gz → 1.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/CLI_STORAGE_SUMMARY.md +2 -2
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/GLOSSARY.md +13 -1
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/HETZNER_STORAGE_GUIDE.md +2 -2
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/HETZNER_STORAGE_SECURITY_GUIDE.md +1 -1
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/PKG-INFO +61 -4
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/README.md +60 -3
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/STORAGE_CLI_GUIDE.md +4 -4
- mystack_rig-1.5.0/docs/adr/0004-agents-run-as-live-agents-in-tmux.md +20 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/pyproject.toml +3 -0
- mystack_rig-1.5.0/sample.env +17 -0
- mystack_rig-1.5.0/src/cli/ansible_filters/rig_live.py +88 -0
- mystack_rig-1.5.0/src/cli/assets/rig-agent-queue +33 -0
- mystack_rig-1.5.0/src/cli/assets/rig-agent-state +12 -0
- mystack_rig-1.5.0/src/cli/assets/tmux.conf +27 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/config.py +43 -24
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/encrypt.py +15 -6
- mystack_rig-1.5.0/src/cli/live_agent.py +238 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/main.py +215 -2
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/remote_dev.py +324 -22
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/storage.py +46 -13
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/PKG-INFO +61 -4
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/SOURCES.txt +9 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/scm_file_list.json +9 -0
- mystack_rig-1.5.0/src/mystack_rig.egg-info/scm_version.json +8 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/conftest.py +6 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_attach_command.py +7 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_encrypt_coverage.py +16 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_init_command.py +183 -16
- mystack_rig-1.5.0/tests/test_live_agent.py +614 -0
- mystack_rig-1.5.0/tests/test_live_agent_cli.py +507 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_outputs_storage.py +2 -2
- mystack_rig-1.5.0/tests/test_r2_storage.py +150 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_real_e2e_storage.py +11 -7
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_remote_dev_coverage_extensions.py +1 -1
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_rig_ansible_vars.py +1 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_rig_config.py +10 -10
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_small_module_coverage.py +2 -2
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_state_bucket.py +20 -1
- mystack_rig-1.3.2/sample.env +0 -12
- mystack_rig-1.3.2/src/mystack_rig.egg-info/scm_version.json +0 -8
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/.coveragerc +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/.git-blame-ignore-revs +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/.github/workflows/release.yml +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/.github/workflows/tests.yml +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/.gitignore +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/.rig/playbooks/README.md +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/.rig/playbooks/vpn-gateway.yml +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/Dockerfile +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/GIT_CLONE_FEATURE.md +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/LICENSE +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/Makefile +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/README_REAL_E2E.md +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/docs/adr/0001-per-profile-generated-state-bucket.md +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/docs/adr/0002-outputs-as-separate-object-via-file-handoff.md +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/docs/adr/0003-mcp-servers-declared-once-rendered-at-authorize.md +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/docs/architecture.md +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/docs/architecture.png +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/docs/architecture.svg +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/forged-idea.md +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/pytest.ini +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/requirements.txt +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/scripts/coverage_badge.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/scripts/pypi_version.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/setup.cfg +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/__init__.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/__init__.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/__main__.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/agents.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/ansible_filters/__init__.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/ansible_filters/rig_mcp.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/git.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/git_author.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/last_env.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/last_session.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/log.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/mcp.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/outputs.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/requirements.txt +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/snapshots.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/state_bucket.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/vault_keys.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/cli/vpn.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/dependency_links.txt +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/entry_points.txt +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/requires.txt +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/top_level.txt +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/test_hetzner_integration.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_agents.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_ansible_galaxy.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_credential_security.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_destroy_command.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_dev_command.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_encrypt_command.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_firewall_client_ip.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_git_clone_unit.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_git_credentials_and_author.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_git_manager.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_gitignore_init.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_hetzner_storage.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_inspect_describe.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_last_env.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_last_session.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_log.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_main_coverage.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_mcp_command.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_mcp_render.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_outputs.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_pypi_version.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_python_floor.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_real_e2e_integration.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_real_e2e_vpn.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_real_e2e_vpn_tunnel.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_remote_dev.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_secret_prompt_hidden.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_setup_provision.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_simulation_storage.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_snapshots.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_storage_basic.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_vault_keys.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_vpn_optional.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_vpn_unit.py +0 -0
- {mystack_rig-1.3.2 → mystack_rig-1.5.0}/tests/test_workspace_git_clone.py +0 -0
|
@@ -76,13 +76,13 @@ The solution provides comprehensive storage management for Hetzner S3-compatible
|
|
|
76
76
|
#### Environment Variables
|
|
77
77
|
```bash
|
|
78
78
|
export HZ_TOKEN="your-hetzner-cloud-token"
|
|
79
|
-
export
|
|
79
|
+
export RIG_STATE_ENDPOINT_URL="https://fsn1.yourdomain.com" # Optional override
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
#### Configuration File (`config.yaml`)
|
|
83
83
|
```yaml
|
|
84
84
|
hz_token: "your-hetzner-cloud-token"
|
|
85
|
-
|
|
85
|
+
state_endpoint_url: "https://fsn1.yourdomain.com"
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
### 5. Usage Examples
|
|
@@ -13,9 +13,13 @@ The storage bucket holding environment state for one Profile within one workspac
|
|
|
13
13
|
_Avoid_: Production bucket, installation bucket
|
|
14
14
|
|
|
15
15
|
**Workspace**:
|
|
16
|
-
A
|
|
16
|
+
A folder containing `rig.yml` and a `.rig/` directory, which groups zero or more Repos and owns its own State buckets. It need not itself be a git repository.
|
|
17
17
|
_Avoid_: Project (ambiguous with a Hetzner Cloud project)
|
|
18
18
|
|
|
19
|
+
**Repo**:
|
|
20
|
+
A git repository included in a Workspace and cloned onto its Environments.
|
|
21
|
+
_Avoid_: Project
|
|
22
|
+
|
|
19
23
|
**Environment**:
|
|
20
24
|
A remote development machine provisioned by rig, owned by one identity and tracked in a State bucket.
|
|
21
25
|
_Avoid_: Instance, VM, server
|
|
@@ -32,6 +36,14 @@ _Avoid_: Dev bucket
|
|
|
32
36
|
A coding CLI that rig installs on an Environment: OpenCode, Claude Code or Cursor CLI.
|
|
33
37
|
_Avoid_: Coding agent type, CLI, assistant
|
|
34
38
|
|
|
39
|
+
**Agent session**:
|
|
40
|
+
An Agent's saved conversation, which can be resumed by its id.
|
|
41
|
+
_Avoid_: Chat, thread
|
|
42
|
+
|
|
43
|
+
**Live agent**:
|
|
44
|
+
An Agent's running process on an Environment, kept alive when no terminal is connected. Attaching joins it; ending the Agent ends it.
|
|
45
|
+
_Avoid_: Background agent, daemon, detached session
|
|
46
|
+
|
|
35
47
|
**Stage**:
|
|
36
48
|
One of the playbook steps rig runs in order when creating an Environment: provision, configure, authorize, materialize, finalize. Only provision and configure are cached in a snapshot.
|
|
37
49
|
_Avoid_: Phase, step
|
|
@@ -83,12 +83,12 @@ The CLI follows a modular architecture:
|
|
|
83
83
|
|
|
84
84
|
### Environment Variables
|
|
85
85
|
- `HZ_TOKEN`: Hetzner Cloud API token (required)
|
|
86
|
-
- `
|
|
86
|
+
- `RIG_STATE_ENDPOINT_URL`: S3 endpoint URL (defaults to `https://fsn1.yourdomain.com`)
|
|
87
87
|
|
|
88
88
|
### Configuration File (`config.yaml`)
|
|
89
89
|
```yaml
|
|
90
90
|
hz_token: "your-hetzner-cloud-token"
|
|
91
|
-
|
|
91
|
+
state_endpoint_url: "https://fsn1.yourdomain.com"
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
## How It Works
|
|
@@ -125,7 +125,7 @@ export HZ_TOKEN="your-hetzner-cloud-token"
|
|
|
125
125
|
```yaml
|
|
126
126
|
# config.yaml
|
|
127
127
|
hz_token: "your-hetzner-cloud-token" # Only stored in environment variables
|
|
128
|
-
|
|
128
|
+
state_endpoint_url: "https://fsn1.yourdomain.com" # Default Hetzner endpoint
|
|
129
129
|
```
|
|
130
130
|
|
|
131
131
|
## Security Features
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mystack-rig
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: Ephemeral remotes with full local parity for coding agents
|
|
5
5
|
Author: mystack-cloud
|
|
6
6
|
License-Expression: MIT
|
|
@@ -52,6 +52,15 @@ Run `rig` from your machine, CI/CD, or a control plane: it provisions cloud VMs
|
|
|
52
52
|
|
|
53
53
|
`rig create` reads `host.provider`. Omit it and the provider is Hetzner. `--provider` overrides the file. `aws` and `gcp` are accepted as names and refused until those clouds can provision.
|
|
54
54
|
|
|
55
|
+
State storage (environment records, outputs) is separate from the VM provider and can be any of:
|
|
56
|
+
|
|
57
|
+
| Storage | Selected by | Status |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| [Hetzner Object Storage](https://www.hetzner.com/storage/object-storage) | default endpoint (`https://fsn1.your-objectstorage.com`) | Supported |
|
|
60
|
+
| [Cloudflare R2](https://www.cloudflare.com/developer-platform/products/r2/) | `state_endpoint_url` = `https://<account-id>.r2.cloudflarestorage.com` | Supported |
|
|
61
|
+
|
|
62
|
+
See [State backend](#state-backend-hetzner-object-storage-or-cloudflare-r2) for the settings.
|
|
63
|
+
|
|
55
64
|
## Coding agents
|
|
56
65
|
|
|
57
66
|
Chosen at `rig init` (`agent.enabled` in `rig.yml`, same multi-select as git projects: numbers, names, or `all`). Every selected agent is installed and configured on the VM. When more than one is selected, init asks which is the default for `rig attach` (`agent.default`). Pass `--agent` to open another one.
|
|
@@ -102,6 +111,48 @@ rig mcp remove awx
|
|
|
102
111
|
- Support files for a server (for example a stdio wrapper script) are not managed by rig: install them from your own playbook (provision, configure or authorize) and point `command` at that path.
|
|
103
112
|
- The per-agent `.rig/.claude|.cursor|.opencode/mcp.json` files from earlier versions are no longer deployed. If one still declares servers, `rig apply`/`create` and `rig mcp check` warn; move them to `.rig/mcp.json`.
|
|
104
113
|
|
|
114
|
+
## Live agents
|
|
115
|
+
|
|
116
|
+
`rig attach` runs the agent as a **live agent**: a process kept running on the Environment inside its own tmux session (`tmux -L rig`, with a config rig ships, so it never touches a tmux you use yourself). Closing the terminal or losing the connection only detaches; the agent keeps working, and the next `rig attach` joins it.
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
rig attach # start the live agent, or join the running one
|
|
120
|
+
# leave: close the terminal, or detach with Ctrl+b d. Ctrl+C still goes to the agent.
|
|
121
|
+
rig attach --restart # replace it with a fresh process (resumes the same conversation)
|
|
122
|
+
rig attach --no-persist # old behaviour: the agent ends with the SSH session
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
- One live agent per Agent type per Environment. A second `rig attach` joins the first (both terminals see the same screen). Resume flags (`-c`, `--resume`, `--session`) apply only when a live agent is *started*; joining ignores them with a warning.
|
|
126
|
+
- A bare `rig attach` joins whichever live agent is running. `--agent` picks another.
|
|
127
|
+
- `rig inspect` lists live agents. `rig apply` and `rig delete` warn when there are any: a live agent keeps the credentials and MCP config it started with until `rig attach --restart`, and deleting the Environment ends it.
|
|
128
|
+
- If the agent exits while nobody is attached, tmux has logged its output on the VM, and the next `rig attach` recovers the resume id from that log.
|
|
129
|
+
|
|
130
|
+
### `rig exec`
|
|
131
|
+
|
|
132
|
+
Start an agent on a task and leave:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
rig exec "fix the failing tests in /workspace/api"
|
|
136
|
+
rig exec @task.md # prompt from a file
|
|
137
|
+
echo "review the diff" | rig exec - # prompt from stdin
|
|
138
|
+
rig exec --name dev-ab12cd34 --agent claude "..."
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`rig exec` starts the live agent with the prompt, prints how to attach, and returns. It never creates an Environment and never waits.
|
|
142
|
+
|
|
143
|
+
- **Approvals are skipped by default** (`--permission-mode bypassPermissions` for Claude Code, `--force` for Cursor, `--auto` for OpenCode), because an unattended agent that stops at a prompt just sits there. Claude Code refuses bypass mode as root unless it is told it runs in a sandbox, so rig sets `IS_SANDBOX=1` for that run, and authorize pre-accepts Claude's first-use warning dialog (`skipDangerousModePermissionPrompt`), whose default answer is "exit". The Environment has internet access, your tokens and root, so an agent reading untrusted text could be talked into acting on it. Use `--no-auto-approve` to supervise the run; it then pauses at each approval until you attach.
|
|
144
|
+
- **If a live agent is already running**, `rig exec` queues the prompt into it for Claude Code, which runs it after the current turn. rig does this only when Claude's hooks report it idle or working, never while it waits at an approval dialog (typing there would answer the dialog). If it is waiting, the state is unknown, or the agent is OpenCode or Cursor (queue behaviour not yet verified), `rig exec` refuses with the reason; `--restart` replaces the live agent instead. A queued prompt runs under the existing agent's permission mode.
|
|
145
|
+
- The agent's startup is checked: if it exits within a couple of seconds (for example no credentials), `rig exec` prints its output and fails.
|
|
146
|
+
|
|
147
|
+
The prompt reaches the VM on stdin and a private temporary file that is deleted when the agent starts, never on a command line.
|
|
148
|
+
|
|
149
|
+
### How it works
|
|
150
|
+
|
|
151
|
+
- tmux is installed at provision. The tmux config, two small helper scripts (`rig-agent-state`, `rig-agent-queue`) and Claude Code's state hooks are deployed by `authorize.yml`, so changing them never rebuilds the cached image. The hooks are merged into `~/.claude/settings.json` next to any hooks you added.
|
|
152
|
+
- The hooks record `idle`, `working`, `waiting` or `ended` in `/run/rig/agents/claude.state`; `rig-agent-queue` reads it before pasting.
|
|
153
|
+
- A failed agent leaves its (dead) pane so the error stays readable; the next `rig attach` or `rig exec` replaces it.
|
|
154
|
+
- Agent output is logged to `/var/log/rig/rig-<agent>.log` (the previous run's log is kept as `.prev`).
|
|
155
|
+
|
|
105
156
|
## IDEs
|
|
106
157
|
|
|
107
158
|
`rig dev` opens the remote `/workspace`. Default is local editor + Remote-SSH; `--browser` uses code-server on the VM.
|
|
@@ -221,7 +272,8 @@ destroy playbooks:
|
|
|
221
272
|
| **init** | Scaffold `rig.yml` + `.rig/`. Collect Hetzner creds, repo PATs, agent choices and a key per agent. |
|
|
222
273
|
| **create** | Boot VM (base/system snapshot). Run provision → configure → authorize → materialize. Snapshot after **configure** only. |
|
|
223
274
|
| **apply** | Default: authorize → materialize. Flags: `--provision` / `--configure` / `--authorize` / `--materialize` / `--finalize` / `--destroy` (playbooks only; the VM stays). `--tags` is passed to every playbook in the run. |
|
|
224
|
-
| **attach** | SSH TTY into
|
|
275
|
+
| **attach** | SSH TTY into the agent's [live agent](#live-agents) on `/workspace` (started if needed, joined if running). `--agent` picks among installed agents. |
|
|
276
|
+
| **exec** | Start a live agent with a prompt and return; the work continues unattended. See [Live agents](#live-agents). |
|
|
225
277
|
| **dev** | Open VS Code/Cursor via Remote-SSH on `/workspace` (or `--browser` for code-server). |
|
|
226
278
|
| **delete** | Run finalize → destroy playbooks, then delete VM / firewall / SSH key. `--tags` is passed to both playbooks. |
|
|
227
279
|
|
|
@@ -263,11 +315,12 @@ Global: `-v` playbook tasks and debug · `-vv`/`-vvv`/`-vvvv` ansible verbosity
|
|
|
263
315
|
| `init` | | Interactive scaffold |
|
|
264
316
|
| `create` | `[--name]` `[--provider]` `[--type]` `[--availability-zone]` `[--image]` `[--no-attach]` `[--force-playbooks\|--force-system\|--force-workspace]` | Host defaults from `rig.yml`. `--provider` defaults to `hetzner`. `--type` sets `host.server_type`. `host.type` defaults to `vm`. `--region` aliases `--availability-zone`. |
|
|
265
317
|
| `apply` | `[name]` `[--provision\|--configure\|--authorize\|--materialize\|--finalize\|--destroy]` `[--tags TAGS]` | Default: authorize then materialize. Each flag runs that playbook (`--provision` also runs configure and authorize; `--materialize` also runs authorize). `--finalize` and `--destroy` do not delete the VM. `--tags` limits every playbook in the run |
|
|
266
|
-
| `attach` | `[name]` `[-c\|--continue]` `[-s\|--session ID]` `[--resume [ID]]` `[--agent opencode\|claude\|cursor]` `[-- …agent args]` |
|
|
318
|
+
| `attach` | `[name]` `[-c\|--continue]` `[-s\|--session ID]` `[--resume [ID]]` `[--agent opencode\|claude\|cursor]` `[--restart]` `[--no-persist]` `[-- …agent args]` | Joins the running live agent, or starts one (reopening the last remembered session). `--restart` replaces it; `--no-persist` runs the agent as the SSH session's own process |
|
|
319
|
+
| `exec` | `PROMPT\|@FILE\|-` `[--name]` `[--agent opencode\|claude\|cursor]` `[--restart]` `[--no-auto-approve]` | Start a live agent with the prompt and return; approvals are skipped unless `--no-auto-approve`. Queues into a running Claude Code when that is safe |
|
|
267
320
|
| `ssh` | `[name]` `[-- command]` | Shell on the VM in `/workspace`. A command after `--` runs instead of a login shell |
|
|
268
321
|
| `dev` | `[name]` `[--path /workspace]` `[--browser]` `[--editor code\|cursor\|…]` | Remote-SSH by default; `--editor` opens another IDE from `editor.enabled`. Defaults to `editor.default` |
|
|
269
322
|
| `list` | | Lists envs, or `No remote environments` |
|
|
270
|
-
| `inspect` | `[name]` `[--json]` | Technical details of one env: stored record plus live Hetzner status. Falls back to stored data (flagged stale) if the API is unreachable. Data goes to stdout |
|
|
323
|
+
| `inspect` | `[name]` `[--json]` | Technical details of one env: stored record plus live Hetzner status, and its live agents when the VM is running. Falls back to stored data (flagged stale) if the API is unreachable. Data goes to stdout |
|
|
271
324
|
| `describe` | `[name]` `[--json]` `[--show-secrets]` | Outputs published by the env's playbooks (see below). Sensitive values are masked unless `--show-secrets` |
|
|
272
325
|
| `delete` | `[name …]` `[--tags TAGS]` | Runs finalize then destroy playbooks, then deletes the VM; multi-name OK. `--tags` limits both playbooks |
|
|
273
326
|
| `cache` | `list\|clear` `[--system\|--workspace] [--all] [-y]` | List or clear; unused by default, `--all` includes current |
|
|
@@ -344,6 +397,10 @@ See `docs/adr/0002-outputs-as-separate-object-via-file-handoff.md`.
|
|
|
344
397
|
| `/tmp/.rig/.personal-data-key` / `.shared-data-key` | Materialized Ansible vault passwords after unlock (tmpfs). |
|
|
345
398
|
| `/tmp/<env>-key` | Per-env SSH private key (attach / apply / delete finalizers). |
|
|
346
399
|
|
|
400
|
+
### State backend: Hetzner Object Storage or Cloudflare R2
|
|
401
|
+
|
|
402
|
+
State (environment records, outputs) lives in an S3-compatible bucket. The endpoint decides the provider: set `state_endpoint_url` in `~/.rig/config` (or `RIG_STATE_ENDPOINT_URL`) to your R2 endpoint, `https://<account-id>.r2.cloudflarestorage.com` (or the `.eu.` / `.fedramp.` variant), and use an R2 API token as `state_access_key` / `state_secret_key` (`RIG_STATE_ACCESS_KEY` / `RIG_STATE_SECRET_KEY`). The older `HETZNER_S3_*`, `S3_ENDPOINT_URL` and `hetzner_s3_*` / `s3_endpoint_url` names are still read as fallbacks. rig signs R2 requests with region `auto`. The Hetzner Cloud token is still required for the servers.
|
|
403
|
+
|
|
347
404
|
`RIG_IDENTITY` overrides the configured identity. Teammates joining an existing workspace paste the shared data key once (`rig vars export-shared-key` from an unlocked machine).
|
|
348
405
|
|
|
349
406
|
OpenCode without an API key uses free Zen models. With a key, config switches to the paid provider path. When several agents are selected, keys are `opencode_api_key`, `claude_api_key`, and `cursor_api_key` (`RIG_OPENCODE_API_KEY`, `RIG_ANTHROPIC_API_KEY`, `RIG_CURSOR_API_KEY`). A single agent still uses `coding_agent_api_key` (`RIG_CODING_AGENT_API_KEY`).
|
|
@@ -30,6 +30,15 @@ Run `rig` from your machine, CI/CD, or a control plane: it provisions cloud VMs
|
|
|
30
30
|
|
|
31
31
|
`rig create` reads `host.provider`. Omit it and the provider is Hetzner. `--provider` overrides the file. `aws` and `gcp` are accepted as names and refused until those clouds can provision.
|
|
32
32
|
|
|
33
|
+
State storage (environment records, outputs) is separate from the VM provider and can be any of:
|
|
34
|
+
|
|
35
|
+
| Storage | Selected by | Status |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
| [Hetzner Object Storage](https://www.hetzner.com/storage/object-storage) | default endpoint (`https://fsn1.your-objectstorage.com`) | Supported |
|
|
38
|
+
| [Cloudflare R2](https://www.cloudflare.com/developer-platform/products/r2/) | `state_endpoint_url` = `https://<account-id>.r2.cloudflarestorage.com` | Supported |
|
|
39
|
+
|
|
40
|
+
See [State backend](#state-backend-hetzner-object-storage-or-cloudflare-r2) for the settings.
|
|
41
|
+
|
|
33
42
|
## Coding agents
|
|
34
43
|
|
|
35
44
|
Chosen at `rig init` (`agent.enabled` in `rig.yml`, same multi-select as git projects: numbers, names, or `all`). Every selected agent is installed and configured on the VM. When more than one is selected, init asks which is the default for `rig attach` (`agent.default`). Pass `--agent` to open another one.
|
|
@@ -80,6 +89,48 @@ rig mcp remove awx
|
|
|
80
89
|
- Support files for a server (for example a stdio wrapper script) are not managed by rig: install them from your own playbook (provision, configure or authorize) and point `command` at that path.
|
|
81
90
|
- The per-agent `.rig/.claude|.cursor|.opencode/mcp.json` files from earlier versions are no longer deployed. If one still declares servers, `rig apply`/`create` and `rig mcp check` warn; move them to `.rig/mcp.json`.
|
|
82
91
|
|
|
92
|
+
## Live agents
|
|
93
|
+
|
|
94
|
+
`rig attach` runs the agent as a **live agent**: a process kept running on the Environment inside its own tmux session (`tmux -L rig`, with a config rig ships, so it never touches a tmux you use yourself). Closing the terminal or losing the connection only detaches; the agent keeps working, and the next `rig attach` joins it.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
rig attach # start the live agent, or join the running one
|
|
98
|
+
# leave: close the terminal, or detach with Ctrl+b d. Ctrl+C still goes to the agent.
|
|
99
|
+
rig attach --restart # replace it with a fresh process (resumes the same conversation)
|
|
100
|
+
rig attach --no-persist # old behaviour: the agent ends with the SSH session
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- One live agent per Agent type per Environment. A second `rig attach` joins the first (both terminals see the same screen). Resume flags (`-c`, `--resume`, `--session`) apply only when a live agent is *started*; joining ignores them with a warning.
|
|
104
|
+
- A bare `rig attach` joins whichever live agent is running. `--agent` picks another.
|
|
105
|
+
- `rig inspect` lists live agents. `rig apply` and `rig delete` warn when there are any: a live agent keeps the credentials and MCP config it started with until `rig attach --restart`, and deleting the Environment ends it.
|
|
106
|
+
- If the agent exits while nobody is attached, tmux has logged its output on the VM, and the next `rig attach` recovers the resume id from that log.
|
|
107
|
+
|
|
108
|
+
### `rig exec`
|
|
109
|
+
|
|
110
|
+
Start an agent on a task and leave:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
rig exec "fix the failing tests in /workspace/api"
|
|
114
|
+
rig exec @task.md # prompt from a file
|
|
115
|
+
echo "review the diff" | rig exec - # prompt from stdin
|
|
116
|
+
rig exec --name dev-ab12cd34 --agent claude "..."
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`rig exec` starts the live agent with the prompt, prints how to attach, and returns. It never creates an Environment and never waits.
|
|
120
|
+
|
|
121
|
+
- **Approvals are skipped by default** (`--permission-mode bypassPermissions` for Claude Code, `--force` for Cursor, `--auto` for OpenCode), because an unattended agent that stops at a prompt just sits there. Claude Code refuses bypass mode as root unless it is told it runs in a sandbox, so rig sets `IS_SANDBOX=1` for that run, and authorize pre-accepts Claude's first-use warning dialog (`skipDangerousModePermissionPrompt`), whose default answer is "exit". The Environment has internet access, your tokens and root, so an agent reading untrusted text could be talked into acting on it. Use `--no-auto-approve` to supervise the run; it then pauses at each approval until you attach.
|
|
122
|
+
- **If a live agent is already running**, `rig exec` queues the prompt into it for Claude Code, which runs it after the current turn. rig does this only when Claude's hooks report it idle or working, never while it waits at an approval dialog (typing there would answer the dialog). If it is waiting, the state is unknown, or the agent is OpenCode or Cursor (queue behaviour not yet verified), `rig exec` refuses with the reason; `--restart` replaces the live agent instead. A queued prompt runs under the existing agent's permission mode.
|
|
123
|
+
- The agent's startup is checked: if it exits within a couple of seconds (for example no credentials), `rig exec` prints its output and fails.
|
|
124
|
+
|
|
125
|
+
The prompt reaches the VM on stdin and a private temporary file that is deleted when the agent starts, never on a command line.
|
|
126
|
+
|
|
127
|
+
### How it works
|
|
128
|
+
|
|
129
|
+
- tmux is installed at provision. The tmux config, two small helper scripts (`rig-agent-state`, `rig-agent-queue`) and Claude Code's state hooks are deployed by `authorize.yml`, so changing them never rebuilds the cached image. The hooks are merged into `~/.claude/settings.json` next to any hooks you added.
|
|
130
|
+
- The hooks record `idle`, `working`, `waiting` or `ended` in `/run/rig/agents/claude.state`; `rig-agent-queue` reads it before pasting.
|
|
131
|
+
- A failed agent leaves its (dead) pane so the error stays readable; the next `rig attach` or `rig exec` replaces it.
|
|
132
|
+
- Agent output is logged to `/var/log/rig/rig-<agent>.log` (the previous run's log is kept as `.prev`).
|
|
133
|
+
|
|
83
134
|
## IDEs
|
|
84
135
|
|
|
85
136
|
`rig dev` opens the remote `/workspace`. Default is local editor + Remote-SSH; `--browser` uses code-server on the VM.
|
|
@@ -199,7 +250,8 @@ destroy playbooks:
|
|
|
199
250
|
| **init** | Scaffold `rig.yml` + `.rig/`. Collect Hetzner creds, repo PATs, agent choices and a key per agent. |
|
|
200
251
|
| **create** | Boot VM (base/system snapshot). Run provision → configure → authorize → materialize. Snapshot after **configure** only. |
|
|
201
252
|
| **apply** | Default: authorize → materialize. Flags: `--provision` / `--configure` / `--authorize` / `--materialize` / `--finalize` / `--destroy` (playbooks only; the VM stays). `--tags` is passed to every playbook in the run. |
|
|
202
|
-
| **attach** | SSH TTY into
|
|
253
|
+
| **attach** | SSH TTY into the agent's [live agent](#live-agents) on `/workspace` (started if needed, joined if running). `--agent` picks among installed agents. |
|
|
254
|
+
| **exec** | Start a live agent with a prompt and return; the work continues unattended. See [Live agents](#live-agents). |
|
|
203
255
|
| **dev** | Open VS Code/Cursor via Remote-SSH on `/workspace` (or `--browser` for code-server). |
|
|
204
256
|
| **delete** | Run finalize → destroy playbooks, then delete VM / firewall / SSH key. `--tags` is passed to both playbooks. |
|
|
205
257
|
|
|
@@ -241,11 +293,12 @@ Global: `-v` playbook tasks and debug · `-vv`/`-vvv`/`-vvvv` ansible verbosity
|
|
|
241
293
|
| `init` | | Interactive scaffold |
|
|
242
294
|
| `create` | `[--name]` `[--provider]` `[--type]` `[--availability-zone]` `[--image]` `[--no-attach]` `[--force-playbooks\|--force-system\|--force-workspace]` | Host defaults from `rig.yml`. `--provider` defaults to `hetzner`. `--type` sets `host.server_type`. `host.type` defaults to `vm`. `--region` aliases `--availability-zone`. |
|
|
243
295
|
| `apply` | `[name]` `[--provision\|--configure\|--authorize\|--materialize\|--finalize\|--destroy]` `[--tags TAGS]` | Default: authorize then materialize. Each flag runs that playbook (`--provision` also runs configure and authorize; `--materialize` also runs authorize). `--finalize` and `--destroy` do not delete the VM. `--tags` limits every playbook in the run |
|
|
244
|
-
| `attach` | `[name]` `[-c\|--continue]` `[-s\|--session ID]` `[--resume [ID]]` `[--agent opencode\|claude\|cursor]` `[-- …agent args]` |
|
|
296
|
+
| `attach` | `[name]` `[-c\|--continue]` `[-s\|--session ID]` `[--resume [ID]]` `[--agent opencode\|claude\|cursor]` `[--restart]` `[--no-persist]` `[-- …agent args]` | Joins the running live agent, or starts one (reopening the last remembered session). `--restart` replaces it; `--no-persist` runs the agent as the SSH session's own process |
|
|
297
|
+
| `exec` | `PROMPT\|@FILE\|-` `[--name]` `[--agent opencode\|claude\|cursor]` `[--restart]` `[--no-auto-approve]` | Start a live agent with the prompt and return; approvals are skipped unless `--no-auto-approve`. Queues into a running Claude Code when that is safe |
|
|
245
298
|
| `ssh` | `[name]` `[-- command]` | Shell on the VM in `/workspace`. A command after `--` runs instead of a login shell |
|
|
246
299
|
| `dev` | `[name]` `[--path /workspace]` `[--browser]` `[--editor code\|cursor\|…]` | Remote-SSH by default; `--editor` opens another IDE from `editor.enabled`. Defaults to `editor.default` |
|
|
247
300
|
| `list` | | Lists envs, or `No remote environments` |
|
|
248
|
-
| `inspect` | `[name]` `[--json]` | Technical details of one env: stored record plus live Hetzner status. Falls back to stored data (flagged stale) if the API is unreachable. Data goes to stdout |
|
|
301
|
+
| `inspect` | `[name]` `[--json]` | Technical details of one env: stored record plus live Hetzner status, and its live agents when the VM is running. Falls back to stored data (flagged stale) if the API is unreachable. Data goes to stdout |
|
|
249
302
|
| `describe` | `[name]` `[--json]` `[--show-secrets]` | Outputs published by the env's playbooks (see below). Sensitive values are masked unless `--show-secrets` |
|
|
250
303
|
| `delete` | `[name …]` `[--tags TAGS]` | Runs finalize then destroy playbooks, then deletes the VM; multi-name OK. `--tags` limits both playbooks |
|
|
251
304
|
| `cache` | `list\|clear` `[--system\|--workspace] [--all] [-y]` | List or clear; unused by default, `--all` includes current |
|
|
@@ -322,6 +375,10 @@ See `docs/adr/0002-outputs-as-separate-object-via-file-handoff.md`.
|
|
|
322
375
|
| `/tmp/.rig/.personal-data-key` / `.shared-data-key` | Materialized Ansible vault passwords after unlock (tmpfs). |
|
|
323
376
|
| `/tmp/<env>-key` | Per-env SSH private key (attach / apply / delete finalizers). |
|
|
324
377
|
|
|
378
|
+
### State backend: Hetzner Object Storage or Cloudflare R2
|
|
379
|
+
|
|
380
|
+
State (environment records, outputs) lives in an S3-compatible bucket. The endpoint decides the provider: set `state_endpoint_url` in `~/.rig/config` (or `RIG_STATE_ENDPOINT_URL`) to your R2 endpoint, `https://<account-id>.r2.cloudflarestorage.com` (or the `.eu.` / `.fedramp.` variant), and use an R2 API token as `state_access_key` / `state_secret_key` (`RIG_STATE_ACCESS_KEY` / `RIG_STATE_SECRET_KEY`). The older `HETZNER_S3_*`, `S3_ENDPOINT_URL` and `hetzner_s3_*` / `s3_endpoint_url` names are still read as fallbacks. rig signs R2 requests with region `auto`. The Hetzner Cloud token is still required for the servers.
|
|
381
|
+
|
|
325
382
|
`RIG_IDENTITY` overrides the configured identity. Teammates joining an existing workspace paste the shared data key once (`rig vars export-shared-key` from an unlocked machine).
|
|
326
383
|
|
|
327
384
|
OpenCode without an API key uses free Zen models. With a key, config switches to the paid provider path. When several agents are selected, keys are `opencode_api_key`, `claude_api_key`, and `cursor_api_key` (`RIG_OPENCODE_API_KEY`, `RIG_ANTHROPIC_API_KEY`, `RIG_CURSOR_API_KEY`). A single agent still uses `coding_agent_api_key` (`RIG_CODING_AGENT_API_KEY`).
|
|
@@ -21,14 +21,14 @@ This CLI tool is specifically designed to manage storage operations with Hetzner
|
|
|
21
21
|
|
|
22
22
|
2. **Configure environment variables** (recommended):
|
|
23
23
|
```bash
|
|
24
|
-
export
|
|
24
|
+
export RIG_STATE_ENDPOINT_URL="https://fsn1.yourdomain.com"
|
|
25
25
|
export S3_ACCESS_KEY="your-access-key"
|
|
26
26
|
export S3_SECRET_KEY="your-secret-key"
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
3. **Or create a config.yaml file**:
|
|
30
30
|
```yaml
|
|
31
|
-
|
|
31
|
+
state_endpoint_url: "https://fsn1.yourdomain.com"
|
|
32
32
|
s3_access_key: "your-access-key"
|
|
33
33
|
s3_secret_key: "your-secret-key"
|
|
34
34
|
```
|
|
@@ -91,14 +91,14 @@ The CLI follows a modular architecture:
|
|
|
91
91
|
## Configuration Options
|
|
92
92
|
|
|
93
93
|
### Environment Variables
|
|
94
|
-
- `
|
|
94
|
+
- `RIG_STATE_ENDPOINT_URL`: The S3 endpoint URL (e.g., `https://fsn1.yourdomain.com`)
|
|
95
95
|
- `S3_ACCESS_KEY`: Access key for authentication
|
|
96
96
|
- `S3_SECRET_KEY`: Secret key for authentication
|
|
97
97
|
|
|
98
98
|
### Configuration File
|
|
99
99
|
The CLI reads from `config.yaml` if it exists. The file should contain:
|
|
100
100
|
```yaml
|
|
101
|
-
|
|
101
|
+
state_endpoint_url: "https://fsn1.yourdomain.com"
|
|
102
102
|
s3_access_key: "your-access-key"
|
|
103
103
|
s3_secret_key: "your-secret-key"
|
|
104
104
|
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Agents run as live agents in a rig-owned tmux, and `rig exec` starts them unattended
|
|
2
|
+
|
|
3
|
+
`rig attach` used to run the agent as the SSH session's own process, so closing the terminal killed it. Agents now run as live agents in a tmux session on a socket of their own (`tmux -L rig`, a config rig ships), which keeps them alive when the terminal goes away. `rig exec` starts one with a prompt and returns; it skips the agent's approval prompts by default, and queues a prompt into an already-running Claude Code only when Claude's hooks say that is safe.
|
|
4
|
+
|
|
5
|
+
## Considered Options
|
|
6
|
+
|
|
7
|
+
- **dtach / abduco**: rejected. They keep no screen state and give no scrollback, the redraw on reattach is uncertain, and abduco was not confirmed in Ubuntu 24.04. tmux is in the default repositories (3.4), and Claude Code documents a tmux configuration.
|
|
8
|
+
- **screen**: rejected. No evidence it handles the Agents' key sequences, and Cursor's docs say it intercepts Shift+Enter like tmux does.
|
|
9
|
+
- **Sharing the user's tmux or a default tmux config**: rejected. A separate socket and `-f` file mean rig never changes the behaviour of a tmux someone runs on the VM, and rig can set status bar off and the settings Claude Code recommends.
|
|
10
|
+
- **Queueing by sending keystrokes to every Agent**: rejected. A pasted prompt and Enter would answer an approval or trust dialog, and the Agents differ (Claude queues, OpenCode steers, Cursor is undocumented). Queueing is gated on Claude's hook-written state and supported for Claude Code only; the others refuse with a reason until verified.
|
|
11
|
+
- **Opt-in persistence (`--persist`)**: rejected. Losing an agent's work to a dropped connection is the worse default; `--no-persist` keeps the old behaviour.
|
|
12
|
+
- **A separate flag for unattended approval skipping**: rejected in favour of making it the default for `rig exec`, because an unattended agent that stops at a prompt is not unattended. `--no-auto-approve` opts out.
|
|
13
|
+
|
|
14
|
+
## Consequences
|
|
15
|
+
|
|
16
|
+
- Claude Code refuses its bypass mode as root, so `rig exec` launches it with `IS_SANDBOX=1`, and authorize pre-accepts its first-use warning dialog. Both were found by running against a real VM, and both would otherwise stop an unattended run silently.
|
|
17
|
+
- An unattended agent can run any command on the Environment, which has internet access, tokens and root. Prompt injection from repository content is a real risk, and `rig exec` says so every time it skips approvals.
|
|
18
|
+
- A live agent keeps the credentials and MCP config it started with; `rig attach --restart` picks up changes. `rig apply` and `rig delete` warn about running live agents but do not stop.
|
|
19
|
+
- tmux is part of the provisioned image, and Claude Code's settings carry rig-owned hooks (merged with the user's, identified by their command path).
|
|
20
|
+
- Agent output is logged on the VM so a resume id survives an unattended exit. The log can contain whatever the agent printed.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Sample environment file for RIG project
|
|
2
|
+
# This file should be renamed to .env and populated with actual credentials
|
|
3
|
+
|
|
4
|
+
# Hetzner Cloud API Token
|
|
5
|
+
HETZNER_CLOUD_API_TOKEN="your-hetzner-cloud-token-here"
|
|
6
|
+
|
|
7
|
+
# Optional: Hetzner S3-Compatible Storage Endpoint
|
|
8
|
+
# RIG_STATE_ENDPOINT_URL="https://fsn1.yourdomain.com"
|
|
9
|
+
|
|
10
|
+
# GitHub Personal Access Token for git clone operations
|
|
11
|
+
# Required for cloning private repositories or for higher rate limits
|
|
12
|
+
RIG_GITHUB_PAT="your-github-personal-access-token-here"
|
|
13
|
+
# Cloudflare R2 for state: point the endpoint at R2 and use an R2 API token
|
|
14
|
+
# as the S3 keys (the Hetzner Cloud token above is still needed for servers).
|
|
15
|
+
# RIG_STATE_ENDPOINT_URL="https://<account-id>.r2.cloudflarestorage.com"
|
|
16
|
+
# RIG_STATE_ACCESS_KEY="r2-access-key-id"
|
|
17
|
+
# RIG_STATE_SECRET_KEY="r2-secret-access-key"
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""Claude Code hooks for live agents (Ansible filter plugin, standard library only).
|
|
2
|
+
|
|
3
|
+
``rig exec`` may queue a prompt into a running Claude Code, but typing into a TUI
|
|
4
|
+
that waits at an approval dialog would answer the dialog. These hooks record what
|
|
5
|
+
Claude is doing in a state file that ``rig-agent-queue`` reads first:
|
|
6
|
+
|
|
7
|
+
idle SessionStart, Stop, Notification(idle_prompt)
|
|
8
|
+
working UserPromptSubmit, PreToolUse, PostToolUse
|
|
9
|
+
waiting PermissionRequest, Notification(permission_prompt | agent_needs_input)
|
|
10
|
+
ended SessionEnd
|
|
11
|
+
|
|
12
|
+
Claude has no event for "the user answered the dialog"; the next tool event
|
|
13
|
+
marks the work as resumed.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import copy
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
STATE_HELPER = "/usr/local/bin/rig-agent-state"
|
|
22
|
+
AGENT = "claude"
|
|
23
|
+
|
|
24
|
+
# (event, matcher or None, state)
|
|
25
|
+
HOOKS: tuple[tuple[str, str | None, str], ...] = (
|
|
26
|
+
("SessionStart", None, "idle"),
|
|
27
|
+
("UserPromptSubmit", None, "working"),
|
|
28
|
+
("PreToolUse", None, "working"),
|
|
29
|
+
("PostToolUse", None, "working"),
|
|
30
|
+
("PermissionRequest", None, "waiting"),
|
|
31
|
+
("Notification", "permission_prompt", "waiting"),
|
|
32
|
+
("Notification", "agent_needs_input", "waiting"),
|
|
33
|
+
("Notification", "idle_prompt", "idle"),
|
|
34
|
+
("Stop", None, "idle"),
|
|
35
|
+
("SessionEnd", None, "ended"),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _command(state: str) -> str:
|
|
40
|
+
return f"{STATE_HELPER} {AGENT} {state}"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _is_rig_handler(handler: Any) -> bool:
|
|
44
|
+
return isinstance(handler, dict) and str(handler.get("command", "")).startswith(STATE_HELPER)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def merge_hooks(settings: Any) -> dict[str, Any]:
|
|
48
|
+
"""Return ``settings`` with rig's state hooks installed.
|
|
49
|
+
|
|
50
|
+
Hooks the user added are kept. Earlier rig entries are removed first, so
|
|
51
|
+
running this again (or with a changed event list) does not duplicate them.
|
|
52
|
+
"""
|
|
53
|
+
out = copy.deepcopy(settings) if isinstance(settings, dict) else {}
|
|
54
|
+
hooks = out.get("hooks")
|
|
55
|
+
hooks = hooks if isinstance(hooks, dict) else {}
|
|
56
|
+
|
|
57
|
+
for event, groups in list(hooks.items()):
|
|
58
|
+
if not isinstance(groups, list):
|
|
59
|
+
continue
|
|
60
|
+
kept = []
|
|
61
|
+
for group in groups:
|
|
62
|
+
handlers = group.get("hooks") if isinstance(group, dict) else None
|
|
63
|
+
if not isinstance(handlers, list):
|
|
64
|
+
kept.append(group)
|
|
65
|
+
continue
|
|
66
|
+
remaining = [h for h in handlers if not _is_rig_handler(h)]
|
|
67
|
+
if remaining:
|
|
68
|
+
kept.append({**group, "hooks": remaining})
|
|
69
|
+
hooks[event] = kept
|
|
70
|
+
|
|
71
|
+
for event, matcher, state in HOOKS:
|
|
72
|
+
rig_group: dict[str, Any] = {"hooks": [{"type": "command", "command": _command(state)}]}
|
|
73
|
+
if matcher:
|
|
74
|
+
rig_group = {"matcher": matcher, **rig_group}
|
|
75
|
+
hooks.setdefault(event, []).append(rig_group)
|
|
76
|
+
|
|
77
|
+
out["hooks"] = {event: groups for event, groups in hooks.items() if groups}
|
|
78
|
+
return out
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def rig_claude_hooks(settings: Any) -> dict[str, Any]:
|
|
82
|
+
"""``{{ existing_settings | rig_claude_hooks }}``"""
|
|
83
|
+
return merge_hooks(settings)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class FilterModule:
|
|
87
|
+
def filters(self) -> dict[str, Any]:
|
|
88
|
+
return {"rig_claude_hooks": rig_claude_hooks}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Queue a prompt (read from stdin) into a running live agent, but only when that is safe.
|
|
3
|
+
# rig-agent-queue AGENT
|
|
4
|
+
# The agent's hooks keep a state file (see rig-agent-state). Typing into a TUI that is
|
|
5
|
+
# waiting at an approval dialog would answer the dialog, so the prompt is delivered only
|
|
6
|
+
# when the agent is idle or working. Exit status:
|
|
7
|
+
# 0 queued 10 waiting for approval 11 state unknown (no hooks / no state)
|
|
8
|
+
# 12 no live agent 13 delivery failed
|
|
9
|
+
set -u
|
|
10
|
+
agent="${1:?usage: rig-agent-queue AGENT}"
|
|
11
|
+
socket="${RIG_TMUX_SOCKET:-rig}"
|
|
12
|
+
conf="${RIG_TMUX_CONF:-/etc/rig/tmux.conf}"
|
|
13
|
+
state_dir="${RIG_STATE_DIR:-/run/rig/agents}"
|
|
14
|
+
session="rig-$agent"
|
|
15
|
+
tmux_cmd() { tmux -L "$socket" -f "$conf" "$@"; }
|
|
16
|
+
|
|
17
|
+
tmux_cmd has-session -t "$session" 2>/dev/null || exit 12
|
|
18
|
+
[ "$(tmux_cmd list-panes -t "$session" -F '#{pane_dead}' 2>/dev/null | head -n 1)" = "0" ] || exit 12
|
|
19
|
+
|
|
20
|
+
state_file="$state_dir/$agent.state"
|
|
21
|
+
[ -r "$state_file" ] || exit 11
|
|
22
|
+
state="$(cut -d' ' -f1 < "$state_file")"
|
|
23
|
+
case "$state" in
|
|
24
|
+
idle|working) ;;
|
|
25
|
+
waiting) exit 10 ;;
|
|
26
|
+
*) exit 11 ;;
|
|
27
|
+
esac
|
|
28
|
+
|
|
29
|
+
buffer="rig-queue-$$"
|
|
30
|
+
tmux_cmd load-buffer -b "$buffer" - || exit 13
|
|
31
|
+
# -p: bracketed paste, so newlines stay part of one message; -d: drop the buffer after.
|
|
32
|
+
tmux_cmd paste-buffer -p -d -b "$buffer" -t "$session" || exit 13
|
|
33
|
+
tmux_cmd send-keys -t "$session" Enter || exit 13
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Record what a coding agent is doing, for `rig exec` to read before it queues a prompt.
|
|
3
|
+
# Called by the agent's hooks (see authorize.yml): rig-agent-state AGENT STATE
|
|
4
|
+
# STATE is one of: idle working waiting ended. Writes "STATE EPOCH" to the state file.
|
|
5
|
+
set -eu
|
|
6
|
+
agent="${1:?usage: rig-agent-state AGENT STATE}"
|
|
7
|
+
state="${2:?usage: rig-agent-state AGENT STATE}"
|
|
8
|
+
dir="${RIG_STATE_DIR:-/run/rig/agents}"
|
|
9
|
+
mkdir -p "$dir"
|
|
10
|
+
tmp="$dir/.$agent.$$"
|
|
11
|
+
printf '%s %s\n' "$state" "$(date +%s)" > "$tmp"
|
|
12
|
+
mv -f "$tmp" "$dir/$agent.state"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# rig's tmux configuration for live agents. Used only with `tmux -L rig -f <this file>`,
|
|
2
|
+
# so it never touches a tmux the user runs themselves. Deployed by authorize.yml.
|
|
3
|
+
|
|
4
|
+
# The agent's TUI should look exactly as it does outside tmux.
|
|
5
|
+
set -g status off
|
|
6
|
+
set -g default-shell /bin/bash
|
|
7
|
+
set -g default-terminal "tmux-256color"
|
|
8
|
+
set -ga terminal-overrides ",xterm-256color:RGB"
|
|
9
|
+
|
|
10
|
+
# Recommended by Claude Code's docs (https://code.claude.com/docs/en/terminal-config):
|
|
11
|
+
# without these Shift+Enter submits and desktop notifications never reach the terminal.
|
|
12
|
+
set -g allow-passthrough on
|
|
13
|
+
set -g focus-events on
|
|
14
|
+
set -s extended-keys on
|
|
15
|
+
set -as terminal-features 'xterm*:extkeys'
|
|
16
|
+
|
|
17
|
+
# A smaller scrollback keeps Cursor's reattach redraw short.
|
|
18
|
+
set -g history-limit 1000
|
|
19
|
+
set -sg escape-time 10
|
|
20
|
+
|
|
21
|
+
# Several terminals can join one live agent; follow the most recently active one.
|
|
22
|
+
set -g window-size latest
|
|
23
|
+
set -g aggressive-resize on
|
|
24
|
+
|
|
25
|
+
# Keep the pane when the agent fails so its error stays readable. `rig attach` and
|
|
26
|
+
# `rig exec` replace a dead pane the next time.
|
|
27
|
+
set -g remain-on-exit failed
|