agentworks-cli 0.2.1__py3-none-any.whl

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.
Files changed (59) hide show
  1. agentworks/__init__.py +1 -0
  2. agentworks/agents/__init__.py +0 -0
  3. agentworks/agents/manager.py +1095 -0
  4. agentworks/agents/templates.py +145 -0
  5. agentworks/catalog.py +264 -0
  6. agentworks/catalog.toml +131 -0
  7. agentworks/cli.py +1462 -0
  8. agentworks/completions/__init__.py +33 -0
  9. agentworks/completions/bash.py +179 -0
  10. agentworks/completions/install.py +122 -0
  11. agentworks/completions/powershell.py +270 -0
  12. agentworks/completions/spec.py +216 -0
  13. agentworks/completions/zsh.py +256 -0
  14. agentworks/config.py +894 -0
  15. agentworks/db.py +1083 -0
  16. agentworks/doctor.py +430 -0
  17. agentworks/git_credentials/__init__.py +0 -0
  18. agentworks/git_credentials/azdo.py +29 -0
  19. agentworks/git_credentials/base.py +71 -0
  20. agentworks/git_credentials/github.py +22 -0
  21. agentworks/nerf-config.yaml +16 -0
  22. agentworks/output.py +296 -0
  23. agentworks/remote_exec.py +286 -0
  24. agentworks/sample-config.toml +289 -0
  25. agentworks/sessions/__init__.py +0 -0
  26. agentworks/sessions/console.py +164 -0
  27. agentworks/sessions/manager.py +1297 -0
  28. agentworks/sessions/templates.py +101 -0
  29. agentworks/sessions/tmux.py +503 -0
  30. agentworks/sources.py +303 -0
  31. agentworks/ssh.py +759 -0
  32. agentworks/ssh_config.py +255 -0
  33. agentworks/vm_hosts/__init__.py +0 -0
  34. agentworks/vm_hosts/manager.py +86 -0
  35. agentworks/vms/__init__.py +0 -0
  36. agentworks/vms/backup.py +409 -0
  37. agentworks/vms/base.py +56 -0
  38. agentworks/vms/bootstrap_script.py +185 -0
  39. agentworks/vms/cloud_init.py +55 -0
  40. agentworks/vms/initializer.py +1523 -0
  41. agentworks/vms/manager.py +1122 -0
  42. agentworks/vms/provisioners/__init__.py +0 -0
  43. agentworks/vms/provisioners/azure.py +602 -0
  44. agentworks/vms/provisioners/lima.py +295 -0
  45. agentworks/vms/provisioners/proxmox.py +279 -0
  46. agentworks/vms/provisioners/proxmox_api.py +261 -0
  47. agentworks/vms/provisioners/wsl2.py +340 -0
  48. agentworks/vms/templates.py +152 -0
  49. agentworks/workspaces/__init__.py +0 -0
  50. agentworks/workspaces/backends/__init__.py +0 -0
  51. agentworks/workspaces/backends/local.py +119 -0
  52. agentworks/workspaces/backends/vm.py +175 -0
  53. agentworks/workspaces/manager.py +1080 -0
  54. agentworks/workspaces/templates.py +76 -0
  55. agentworks/workspaces/tmuxinator.py +80 -0
  56. agentworks_cli-0.2.1.dist-info/METADATA +635 -0
  57. agentworks_cli-0.2.1.dist-info/RECORD +59 -0
  58. agentworks_cli-0.2.1.dist-info/WHEEL +4 -0
  59. agentworks_cli-0.2.1.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,635 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentworks-cli
3
+ Version: 0.2.1
4
+ Summary: CLI for orchestrating workspace lifecycle across multiple compute targets
5
+ Project-URL: Homepage, https://github.com/WayfarerLabs/agentworks
6
+ Project-URL: Repository, https://github.com/WayfarerLabs/agentworks
7
+ Project-URL: Issues, https://github.com/WayfarerLabs/agentworks/issues
8
+ Author: Scot Hastings (Wayfarer Labs)
9
+ License-Expression: MIT
10
+ Requires-Python: >=3.12
11
+ Requires-Dist: azure-identity>=1.25.1
12
+ Requires-Dist: azure-mgmt-compute>=37.0.1
13
+ Requires-Dist: azure-mgmt-network>=29.0.0
14
+ Requires-Dist: nerftools>=1.1.0
15
+ Requires-Dist: typer>=0.24.1
16
+ Description-Content-Type: text/markdown
17
+
18
+ # Agentworks CLI
19
+
20
+ CLI for interacting with Agentworks, the swiss army knife for managing agentic workloads.
21
+
22
+ ## The Problem Space
23
+
24
+ Agentworks is an attempt to address several growing problems around agentic engineering with a
25
+ single, (hopefully) coherent framework.
26
+
27
+ These problems are:
28
+
29
+ ### Security
30
+
31
+ Agentic engineering is inherently risky. These risks come from multiple directions, including:
32
+
33
+ - **Honest mistakes** - An agent can simply make a mistake that results in data loss, corruption, or
34
+ unintended side effects. It's very easy to find stories of Claude wiping out entire directories or
35
+ otherwise causing havoc.
36
+ - **Prompt injection** - Agents that are exposed to the outside world (e.g. by downloading untrusted
37
+ web content) can potentially be manipulated into doing things outside of their operator's intent
38
+ or control.
39
+ - **Supply chain attacks** - Agents may download and run compromised software or dependencies from
40
+ external sources, which could introduce malicious code into the environment, at build time,
41
+ runtime, or both.
42
+ - **Rogue agents** - The agent itself could behave maliciously due to a compromise of the model, the
43
+ provider, or emergent behavior.
44
+
45
+ While these are already in play to some extent, increasing AI capabilities guarantee that attacks
46
+ will become increasingly frequent and sophisticated. Supply chain attacks in particular have become
47
+ a near-constant backdrop: the XZ Utils backdoor (a multi-year social engineering campaign against a
48
+ burned-out maintainer, caught by luck in 2024), the Shai-Hulud self-replicating npm worm (500+
49
+ packages compromised in September 2025, escalating to 25,000+ repositories as "Shai-Hulud 2.0" in
50
+ November 2025), and the TeamPCP campaign (compromising `litellm`, `telnyx`, and the widely-used
51
+ `axios` npm package in March 2026) are just a few recent examples. North Korean threat actors alone
52
+ have pushed 1,700+ malicious packages across npm, PyPI, Go, and Rust. The registries that developers
53
+ (and their agents) depend on are under active, sustained attack.
54
+
55
+ All of these suggest similar solutions, though. You need strong guardrails (isolation, permissions,
56
+ etc.) to ensure that _when_ things go sideways, the blast radius is contained and the operator
57
+ retains control.
58
+
59
+ ### Workload Management
60
+
61
+ Anyone who has had more than one or two parallel agentic sessions has likely run into the problem of
62
+ keeping track of which agents are doing what, which sessions are active, how to coordinate work
63
+ across multiple agents (possibly working in the same repository or worktree), how to keep them all
64
+ running reliably (e.g. even when you close your laptop or lose your network connection), etc.
65
+
66
+ These are real challenges that impose real limits on how many agentic workloads a single operator
67
+ can reasonably manage at once. Most devs who have leaned into this space have developed some amount
68
+ of custom tooling to help with this problem. Solving for this at the platform layer should be a
69
+ significant enabler to delivering value more quickly.
70
+
71
+ ### Consistency
72
+
73
+ Similar to workload management, inconsistency across workload environments (different tools,
74
+ configuration, files, etc.) creates significant friction and potential for errors when trying to
75
+ scale up agentic engineering.
76
+
77
+ While sometimes these differences are intentional and should be preserved (e.g. wanting Agent A to
78
+ have different tools and permissions than Agent B), they often are accidental and introduce
79
+ unnecessary complexity and risk.
80
+
81
+ ### Control
82
+
83
+ The operator should retain control over what agents are doing, how workloads are executed, and what
84
+ resources they can access _even as those workloads become more autonomous_. This is a central design
85
+ goal of Agentworks, and it ties the preceding concerns together: without reliable knowledge of what
86
+ agents are doing, consistent environments, and contained blast radius, control is lost in practice
87
+ even if it's notionally retained.
88
+
89
+ A significant and growing part of the ecosystem treats loss of control as an inevitable cost of
90
+ agentic autonomy. Agentworks takes the opposite position: autonomy and control are not mutually
91
+ exclusive. A good platform should make it possible and straightforward to have both.
92
+
93
+ ## Core Concepts
94
+
95
+ Agentworks organizes work into five core concepts:
96
+
97
+ ### The Operator - the Person in Control
98
+
99
+ Agentworks is currently designed around a single human "operator" who is in control of all agentic
100
+ workloads. The operator is responsible for creating VMs, workspaces, agents, and sessions, and for
101
+ orchestrating how these components interact.
102
+
103
+ Note that while you might find some exceptions, we generally reserve the term "user" for the
104
+ technical Linux users that exist on the VMs (the admin user and the agentic identities).
105
+
106
+ ### VMs - the Compute Environment
107
+
108
+ VMs define the base **compute environment** for all workloads. As discussed in
109
+ [ADR 0001](../docs/adrs/0001-vm-based-infrastructure.md), Agentworks uses VMs as the fundamental
110
+ unit of compute to provide for strong isolation while providing all the capabilities of a full Linux
111
+ environment (full daemonized services, multi-user, ability to run containers, etc.).
112
+
113
+ VMs further use a single operating system (Debian Bookworm, see
114
+ [ADR 0002](../docs/adrs/0002-use-debian-as-the-vm-base-image.md)) to ensure consistency and minimize
115
+ VM management complexity and risk.
116
+
117
+ VMs are generally intended to be long-lived and are designed to support any number of agentic
118
+ workloads. A robust configuration and templating mechanism is provided so that VM provisioning can
119
+ be automated and standardized across environments. VMs can further be "reinitialized" to
120
+ declaratively update them based on changes to the template or configuration.
121
+
122
+ Each VM also includes an "admin" user that has full sudo privileges that is used for all
123
+ provisioning and management tasks on the VM. While not recommended, the admin user is also available
124
+ for agentic workloads if the operator so desires.
125
+
126
+ ### Workspaces - the Project
127
+
128
+ A workspace defines the **project scope**. Workspaces ultimately consist of a root directory that
129
+ can be based on a git repository or an empty directory. The workspace also maps to a Linux group
130
+ with workspace permissions and ACLs set to allow collaborative access to the files within the
131
+ workspace for all members of the group. Workspace-level configuration (e.g. Claude Code's project
132
+ settings) can be used to control how tools behave within the context of this workspace.
133
+
134
+ The Agentworks workspace mechanism fully supports any number of workspaces mapping to the same
135
+ underlying repository. To simplify administration, each is a full independent clone.
136
+
137
+ While VM workspaces are the primary supported workspace type, local workspaces can also be created
138
+ on the operator's workstation. Local workspaces do not support agents because the isolation model
139
+ that underpins agent execution requires Linux user management that is only available on VMs.
140
+
141
+ ### Agents - the Actor
142
+
143
+ An agent defines a **security identity** on a VM. Each agent maps to its own full Linux user,
144
+ capable of having its own processes, private files, shell environment, etc. This allows for the
145
+ creation of different identities with different privileges and capabilities.
146
+
147
+ Agents are mapped to workspaces, either explicitly via grants or implicitly via sessions (see
148
+ below). This mapping drives standard group and filesystem permissions that control what agents are
149
+ able to access.
150
+
151
+ Agents are only supported on VM workspaces because the isolation model requires Linux user
152
+ management (useradd, group membership).
153
+
154
+ ### Sessions - the Workloads
155
+
156
+ A session is the primary way of running interactive **workloads** in Agentworks (e.g. a Claude Code
157
+ instance). It provides the mechanism by which an agent can execute commands within the context of a
158
+ workspace. A unique name and a persistent tmux session allow the operator to have any number of
159
+ concurrent workloads running across their VMs, workspaces, and agents. Agentworks allows the
160
+ operator to attach to and detach from them as needed to monitor progress or interact with the
161
+ workload, and then to stop, restart, and delete them to manage their lifecycle.
162
+
163
+ ## Key Principles
164
+
165
+ ### Opinionated Consistency
166
+
167
+ Broadly-applicable systems like Agentworks can easily spiral into significant complexity by
168
+ attempting to support too many ways of doing the same thing. To protect against this, Agentworks
169
+ takes an opinionated stance on how things should be set up. A single base operating system,
170
+ tightly-integrated tooling, and emphasis on declarative configuration all help minimize variation
171
+ and surprises across different workloads.
172
+
173
+ ### Composable Isolation
174
+
175
+ This model provides several isolation mechanisms, which operators can compose to achieve their
176
+ desired security posture. While the system is optimized around the full isolation model (VMs,
177
+ agents, and workspaces), this is by no means required. Operators are free to use any subset that
178
+ makes sense for their security and operational requirements.
179
+
180
+ ### Ephemerality
181
+
182
+ The layers differ in intended lifespan. VMs are intended to be long-lived: provisioned once and used
183
+ across many projects. Workspaces are intended to be medium-lived: created to support a particular
184
+ workstream or project and destroyed when done. Agents can be long-lived or short-lived depending on
185
+ the operator's preferences. Long-lived agents can be reused across multiple workspaces and sessions
186
+ or they can be created for a single workspace or session and destroyed when no longer needed.
187
+ Sessions are intended to be the most ephemeral: started for a specific activity and discarded when
188
+ done.
189
+
190
+ ### Declarative Configuration and Templates
191
+
192
+ Each layer has a templating mechanism using declarative configuration so that patterns can be
193
+ defined once and stamped many times. The longer-lived resources (VMs and agents) provide for
194
+ [mostly idempotent](../docs/guides/idempotency.md) "reinitialization" so that they can be reliably
195
+ evolved over time.
196
+
197
+ ## Tightly Integrated Tools
198
+
199
+ In the spirit of opinionated consistency, Agentworks tightly integrates a small set of excellent
200
+ tools that add significant value. While these tools could theoretically be replaced with
201
+ alternatives, this would involve significant additional complexity that would slow down development
202
+ and increase the likelihood of inconsistencies or errors.
203
+
204
+ Those using Agentworks are highly encouraged to embrace these tools rather than attempting to work
205
+ around them.
206
+
207
+ ### SSH
208
+
209
+ SSH is the control plane for all VM operations. Agentworks uses SSH to provision VMs, initialize
210
+ them, manage agents, run sessions, transfer files, and execute commands. The operator's SSH key
211
+ (configured in `[operator]`) is deployed to VMs during provisioning and is the sole authentication
212
+ mechanism for all subsequent operations.
213
+
214
+ During provisioning, SSH access uses the platform's native transport (Lima shell, Azure public IP,
215
+ WSL2 exec, or Proxmox guest agent). Once Tailscale is joined (see below), all further SSH access
216
+ goes over the tailnet. Agentworks automatically manages `~/.ssh/config` entries for each VM so that
217
+ standard SSH tools (scp, ssh, VS Code Remote) work seamlessly.
218
+
219
+ ### Tailscale
220
+
221
+ VMs join a [Tailscale](https://tailscale.com/) tailnet during provisioning. All subsequent SSH
222
+ access (workspace shell, VM shell, initialization) goes over Tailscale, providing secure
223
+ connectivity without exposing SSH ports to the public internet.
224
+
225
+ During `vm create` (and `vm start` when re-joining), you will be prompted for a Tailscale auth key
226
+ unless the `TAILSCALE_AUTH_KEY` environment variable is set. Generate keys at the
227
+ [Tailscale admin console](https://login.tailscale.com/admin/settings/keys).
228
+
229
+ Ephemeral auth keys (with `?ephemeral=true` appended) are fully supported. The Tailscale node is
230
+ automatically removed from the tailnet when the VM goes offline. Agentworks handles re-joining
231
+ gracefully on `vm start` by prompting for a new auth key (or using `TAILSCALE_AUTH_KEY`).
232
+
233
+ ### Tmux
234
+
235
+ Sessions are built on [tmux](https://github.com/tmux/tmux), which provides persistent terminal
236
+ sessions that survive disconnects and support attach/detach. Each session maps 1:1 to a tmux session
237
+ on the VM.
238
+
239
+ Agentworks provides two console layers for interacting with sessions:
240
+
241
+ - **Workspace console** (`workspace console`): a tmuxinator-managed tmux session with one window per
242
+ session in the workspace, plus an admin shell. This is the recommended way to interact with
243
+ sessions.
244
+ - **VM console** (`vm console`): a dynamically-built tmux session spanning all workspaces on the VM.
245
+
246
+ Agent-mode sessions run on per-agent tmux sockets for proper process isolation and terminal resize
247
+ propagation. See the [tmux Architecture](#tmux-architecture) section for details.
248
+
249
+ ### Additional Tools
250
+
251
+ A few other tools, while not fundamental, warrant a brief mention:
252
+
253
+ - **Git** is fully integrated into workspace configuration, allowing operators to define workspace
254
+ templates around specific repositories. Integrated git credential management makes it easy to use
255
+ different providers (GitHub, Azure DevOps, etc.) with any number of scoped credentials (e.g.
256
+ access tokens) to control capabilities and blast radius.
257
+ - **VS Code Workspaces** are automatically generated (using the Remote - SSH extension) for each
258
+ workspace Agentworks manages, allowing developers to easily open an Agentworks workspace directly
259
+ in VS Code to view files, use the terminal, and leverage the full VS Code feature set.
260
+ - **[Mise en Place](https://mise.jdx.dev/)** is supported out of the box for easily adding tools,
261
+ including checksum validation using lockfiles where supported by the backend.
262
+ - **[Dotfiles](https://www.datacamp.com/tutorial/dotfiles)** can be configured for both the admin
263
+ user and agents, helping to ensure a consistent terminal environment (shell configuration, editor
264
+ settings, etc.) across workloads.
265
+
266
+ ## Getting Started
267
+
268
+ ```bash
269
+ uv sync
270
+ uv run agentworks config init # creates ~/.config/agentworks/config.toml
271
+ ```
272
+
273
+ Edit the config file (at minimum, set your SSH key paths), then:
274
+
275
+ ```bash
276
+ agentworks vm create # provision + initialize a VM
277
+ agentworks workspace create # create a workspace on the VM
278
+ agentworks workspace shell my-workspace
279
+ ```
280
+
281
+ ## Prerequisites
282
+
283
+ - Python 3.12+
284
+ - [uv](https://docs.astral.sh/uv/) package manager
285
+ - [Tailscale](https://tailscale.com/) installed and connected (for VM workspaces)
286
+ - One of: [Lima](https://lima-vm.io/), Azure CLI (`az`), or WSL2 (for VM provisioning)
287
+
288
+ ## Global Options
289
+
290
+ | Flag | Description |
291
+ | ------------------- | ------------------------------- |
292
+ | `--non-interactive` | Disable all interactive prompts |
293
+
294
+ When `--non-interactive` is set (or stdin is not a TTY), commands that would normally prompt for
295
+ missing values (VM selection, workspace selection, name generation) will fail with a clear error
296
+ indicating which flag is required. Auto-selection still works: if there is exactly one VM or
297
+ workspace, it is used without prompting.
298
+
299
+ ## Commands
300
+
301
+ ### Top-level
302
+
303
+ | Command | Description |
304
+ | --------------------------- | ---------------------------- |
305
+ | `agentworks doctor` | Check environment and config |
306
+ | `agentworks completion zsh` | Output zsh completion script |
307
+
308
+ ### VM Hosts
309
+
310
+ Manage machines that host VMs (for remote Lima mode).
311
+
312
+ | Command | Description |
313
+ | ------------------------------------------ | ------------------------ |
314
+ | `agentworks vm-host add <name> <ssh-host>` | Register a VM host |
315
+ | `agentworks vm-host list` | List registered VM hosts |
316
+ | `agentworks vm-host remove <name>` | Remove a VM host |
317
+
318
+ ### VMs
319
+
320
+ Manage virtual machines across Lima (local or remote), Azure, and WSL2.
321
+
322
+ | Command | Description |
323
+ | ------------------------------------------------ | ------------------------------------------ |
324
+ | `agentworks vm create` | Create a new VM (provision + initialize) |
325
+ | `agentworks vm list` | List VMs with status and resources |
326
+ | `agentworks vm describe <name>` | Show VM details, workspaces, and event log |
327
+ | `agentworks vm shell <name>` | SSH into a VM's home directory |
328
+ | `agentworks vm start <name>` | Start a stopped VM |
329
+ | `agentworks vm stop <name>` | Stop a running VM |
330
+ | `agentworks vm reinit <name>` | Re-run initialization on a provisioned VM |
331
+ | `agentworks vm delete <name>` | Delete a VM (with confirmation) |
332
+ | `agentworks vm logs <name>` | Show SSH logs for a VM |
333
+ | `agentworks vm console <name>` | Attach to the VM console |
334
+ | `agentworks vm add-git-credential <name> <cred>` | Add or update a git credential |
335
+
336
+ `vm create` accepts `--name`, `--platform`, `--vm-host`, `--admin-username`, `--cpus`, `--memory`,
337
+ `--disk`, and `--azure-vm-size`. These are immutable provisioning parameters stored in the database.
338
+ All initialization behavior (packages, install commands, etc.) is driven by config.
339
+
340
+ `vm reinit` re-runs the initialization phase using the current config without reprovisioning the VM.
341
+ Changes to config (new packages, different install commands, etc.) are picked up automatically.
342
+
343
+ `vm delete` requires `--force` if the VM has workspaces, agents, or sessions. The confirmation
344
+ message shows what will be deleted. Pass `--yes` to skip the prompt.
345
+
346
+ ### Workspaces
347
+
348
+ Manage workspaces on VMs or locally.
349
+
350
+ | Command | Description |
351
+ | -------------------------------------- | ------------------------------------ |
352
+ | `agentworks workspace create` | Create a workspace (VM or `--local`) |
353
+ | `agentworks workspace describe <name>` | Show workspace details and sessions |
354
+ | `agentworks workspace shell <name>` | Open a plain shell into a workspace |
355
+ | `agentworks workspace console <name>` | Open the workspace console (tmux) |
356
+ | `agentworks workspace list` | List workspaces |
357
+ | `agentworks workspace copy <source>` | Copy a workspace to a new location |
358
+ | `agentworks workspace rehome <name>` | Move workspace to a new path |
359
+ | `agentworks workspace repair <name>` | Repair workspace infrastructure |
360
+ | `agentworks workspace delete <name>` | Delete a workspace |
361
+
362
+ `workspace create` accepts `--name`, `--vm`, `--local`, `--template`, and `--open-vscode`.
363
+
364
+ `workspace console` opens a tmuxinator session (`ws-<name>-console`) with an admin-shell window plus
365
+ one window per session in the workspace. Pass `--recreate` to kill and rebuild the console. This is
366
+ the recommended way to interact with sessions from within VS Code or any terminal on the VM.
367
+
368
+ `workspace copy` copies a workspace to a new location. Accepts `--name`, `--vm`, and `--local` (same
369
+ pattern as `workspace create`). Works across VMs, VM to local, and local to VM.
370
+
371
+ `workspace delete` requires `--force` if the workspace has sessions. Running sessions are killed
372
+ during deletion. Pass `--yes` to skip the confirmation prompt.
373
+
374
+ ### Agents
375
+
376
+ Manage agents (isolated Linux users) on VMs. Agents are VM-scoped and access workspaces via grants.
377
+
378
+ | Command | Description |
379
+ | ------------------------------------------------------------ | ------------------------------ |
380
+ | `agentworks agent create [--name] [--vm]` | Create an agent on a VM |
381
+ | `agentworks agent list [--vm <vm>]` | List agents |
382
+ | `agentworks agent describe <name>` | Show agent details and grants |
383
+ | `agentworks agent reinit <name>` | Re-run agent setup |
384
+ | `agentworks agent workspace-grants grant <name> <ws>[,<ws>]` | Grant workspace access |
385
+ | `agentworks agent workspace-grants grant <name> --all` | Grant access to all workspaces |
386
+ | `agentworks agent workspace-grants deny <name> <ws>[,<ws>]` | Remove workspace access |
387
+ | `agentworks agent workspace-grants deny <name> --all` | Remove all explicit grants |
388
+ | `agentworks agent workspace-grants list <name>` | List workspace grants |
389
+ | `agentworks agent shell <name> [--workspace <ws>]` | Shell into an agent |
390
+ | `agentworks agent delete <name>` | Delete an agent |
391
+
392
+ `agent create` accepts `--name`, `--vm`, `--template`, and `--grant-all-workspaces`.
393
+
394
+ `agent delete` requires `--force` if the agent has running sessions. Pass `--yes` to skip the
395
+ confirmation prompt.
396
+
397
+ ### Sessions
398
+
399
+ Manage sessions (persistent tmux sessions running in workspaces). Session names are globally unique
400
+ -- no `--workspace` flag needed for most commands.
401
+
402
+ | Command | Description |
403
+ | -------------------------------------------- | ------------------------------ |
404
+ | `agentworks session create` | Create and start a session |
405
+ | `agentworks session describe <name>` | Show session details |
406
+ | `agentworks session list [--workspace <ws>]` | List sessions with status |
407
+ | `agentworks session attach <name>` | Attach to a running session |
408
+ | `agentworks session stop <name>` | Stop a running session |
409
+ | `agentworks session restart <name>` | Restart a session |
410
+ | `agentworks session delete <name>` | Stop and delete a session |
411
+ | `agentworks session logs <name>` | Dump session scrollback buffer |
412
+ | `agentworks vm console <vm-name>` | Attach to the VM console |
413
+
414
+ `session create` accepts `--name`, `--workspace`, `--template`, `--admin`, and `--agent`. Workspace,
415
+ mode (admin vs agent), and name are prompted interactively if omitted. If agents exist on the VM and
416
+ neither `--admin` nor `--agent` is specified, you are prompted to choose. Pass `--new-workspace` to
417
+ create a workspace on the fly (with optional `--workspace-name`, `--workspace-template`, and
418
+ `--vm`). When a session created with `--new-workspace` is later deleted, you are offered the option
419
+ to delete the workspace as well (if no other sessions remain).
420
+
421
+ ### tmux Architecture
422
+
423
+ Each session runs in its own locked-down tmux session on the VM. There are three ways to interact
424
+ with sessions, at different scopes:
425
+
426
+ | Method | Scope | tmux session name | Entry point |
427
+ | ------------------- | -------------- | ------------------------ | --------------------------- |
428
+ | `session attach` | One session | `<session-name>` | Operator's machine |
429
+ | `workspace console` | One workspace | `ws-<workspace>-console` | On-VM or operator's machine |
430
+ | `vm console` | All workspaces | `vm-console` | Operator's machine |
431
+
432
+ #### Session tmux sessions
433
+
434
+ Each session gets a locked-down tmux session using the session name directly as the tmux session
435
+ name. The user's `~/.tmux.conf` (customizable via dotfiles) is loaded first so that familiar
436
+ keybindings (prefix, detach, copy mode, scroll) work for direct `session attach`. Window/pane
437
+ creation, session management, and the command prompt are selectively unbound.
438
+
439
+ Agent-mode sessions run on a per-agent tmux socket so the agent's shell connects directly to the
440
+ tmux pane PTY. The socket path is persisted in the database.
441
+
442
+ #### Workspace console
443
+
444
+ `workspace console` uses tmuxinator to create or attach to a `ws-<name>-console` session. The
445
+ tmuxinator config (`.tmuxinator.yml` in the workspace root) is regenerated whenever sessions change,
446
+ so the console always reflects the current set of sessions. This is the recommended way to interact
447
+ with sessions from within VS Code or any terminal on the VM.
448
+
449
+ ```text
450
+ ws-myproject-console (tmuxinator, full tmux)
451
+ Window 1: admin-shell login shell for the admin user
452
+ Window 2: myproject-claude attached to session
453
+ Window 3: myproject-debug attached to session
454
+ ```
455
+
456
+ #### VM console
457
+
458
+ `vm console` creates or attaches to the `vm-console` session, which spans all workspaces on the VM.
459
+ This is built dynamically (not via tmuxinator) and is managed from the operator's machine.
460
+
461
+ #### Shells
462
+
463
+ `workspace shell` and `vm shell` open plain login shells with no tmux. Use these when you just need
464
+ a terminal without the console structure.
465
+
466
+ #### Key behaviors
467
+
468
+ - **Direct attach** (`session attach`): the user's prefix key, detach, copy mode, and scroll all
469
+ work normally. Status bar is hidden since there is only one pane.
470
+ - **Consoles** (`workspace console`, `vm console`): the console's prefix key eclipses the inner
471
+ session's prefix, so window switching, detach, etc. all operate at the console level. Session
472
+ windows use a wrapper that re-attaches if the inner session disconnects and shows a message when
473
+ the session ends.
474
+ - **Nesting protection**: both console commands refuse to run inside an existing tmux session to
475
+ avoid prefix key conflicts. Pass `--allow-nesting` to override.
476
+ - **Console lifecycle**: consoles are independent of sessions. Killing or detaching a console does
477
+ not affect running sessions. `--recreate` rebuilds from scratch.
478
+
479
+ ### Session Templates
480
+
481
+ Templates define the command a session runs. The built-in `default` template runs a login shell
482
+ (`$SHELL --login`), respecting whatever shell the user (admin or agent) is configured with. Define
483
+ custom templates in config:
484
+
485
+ ```toml
486
+ [session_templates.default] # override the built-in default
487
+ command = "claude --name {{session_name}}"
488
+ restart_command = "claude --resume {{session_name}}"
489
+ description = "Claude Code interactive session"
490
+ ```
491
+
492
+ Template commands support `{{session_name}}` and `{{workspace_name}}` variable substitution
493
+ (double-brace syntax, consistent with nerftools manifests). The optional `restart_command` is used
494
+ by `session restart` -- useful for tools like Claude Code where `--resume` picks up the previous
495
+ conversation. If omitted, the regular `command` is used.
496
+
497
+ ### Installers
498
+
499
+ Browse and inspect the built-in catalog of installable tools.
500
+
501
+ | Command | Description |
502
+ | -------------------------------------- | ---------------------------------- |
503
+ | `agentworks installer list` | List all available catalog entries |
504
+ | `agentworks installer describe <name>` | Show details of a catalog entry |
505
+
506
+ `installer list` accepts `--type` (apt-source, apt-package, system-install-cmd, user-install-cmd)
507
+ and `--source` (builtin, user) filters.
508
+
509
+ ### Config
510
+
511
+ | Command | Description |
512
+ | ------------------------------------------ | -------------------------------------------- |
513
+ | `agentworks config init` | Create a sample config file |
514
+ | `agentworks config edit` | Open config in `$EDITOR` |
515
+ | `agentworks config sample` | Print the sample config to stdout |
516
+ | `agentworks config sync-ssh-config` | Rebuild SSH config entries for all VMs |
517
+ | `agentworks config sync-vscode-workspaces` | Regenerate .code-workspace files for all VMs |
518
+
519
+ ## Configuration
520
+
521
+ Config lives at `~/.config/agentworks/config.toml`. Run `agentworks config init` to generate a
522
+ sample with all options documented. See [sample-config.toml](agentworks/sample-config.toml) for the
523
+ full reference.
524
+
525
+ Key sections:
526
+
527
+ - `[operator]` -- SSH keys (required), additional authorized keys, SSH config management
528
+ - `[paths]` -- local workspace, VM workspace, and VS Code workspace file directories
529
+ - `[defaults]` -- default platform, VM host
530
+ - `[vm_templates.*]` -- VM resources, apt packages, system install commands, mise
531
+ - `[admin.config]` -- admin user shell, dotfiles, git credentials, user install commands, mise
532
+ - `[agent_templates.*]` -- agent user shell, dotfiles, git credentials, user install commands, mise
533
+ - `[session.config]` -- session defaults (history limit)
534
+ - `[session_templates.*]` -- session templates with variable substitution
535
+ - `[workspace_templates.*]` -- workspace templates with inheritance
536
+ - `[git_credentials.*]` -- git credential providers (GitHub, Azure DevOps)
537
+ - `[apt_sources.*]` -- user-defined third-party apt repositories
538
+ - `[apt_packages.*]` -- user-defined named apt package sets
539
+ - `[system_install_commands.*]` -- user-defined system-level install commands
540
+ - `[user_install_commands.*]` -- user-defined per-user install commands
541
+ - `[azure]` -- Azure-specific settings
542
+ - `[proxmox]` -- Proxmox VE API settings
543
+
544
+ ### Mise (Polyglot Tool Manager)
545
+
546
+ Agentworks installs [mise](https://mise.jdx.dev/) by default on all VMs for managing CLI tools
547
+ (terraform, adr-tools, node, etc.) with optional lockfile-based integrity verification. See
548
+ [Using mise](../docs/guides/mise.md) for the full guide.
549
+
550
+ ### Nerf Tools (Claude Code Plugin)
551
+
552
+ Agentworks can build and deploy a Claude Code plugin containing "nerf tools" -- scoped,
553
+ safety-constrained wrappers for CLI operations like git, az, and other tools. Nerf tools enforce
554
+ guardrails (validated parameters, restricted flags, pre-flight checks) so AI agents operate safely.
555
+
556
+ Enable in your VM template:
557
+
558
+ ```toml
559
+ [vm_templates.default]
560
+ nerf_build_claude_plugin = true
561
+ ```
562
+
563
+ This builds the plugin to `nerf_home_dir/claude-plugin/` during VM init. To auto-install the plugin
564
+ for users, add to admin or agent config:
565
+
566
+ ```toml
567
+ [admin.config]
568
+ nerf_install_claude_plugin = true
569
+ ```
570
+
571
+ The plugin provides skills that document available tools, and operator commands for managing
572
+ permissions (`/nerftools:nerfctl-grant-allow`, `/nerftools:nerfctl-grant-deny`, etc.). Custom tool
573
+ manifests can be added via `nerf_addl_manifests`.
574
+
575
+ Plugin identity (name, marketplace metadata) is defined in agentworks' own `nerf-config.yaml` and
576
+ loaded via the nerftools config API. The version is a date-based build stamp that changes on each
577
+ reinit. The build always emits an embedded marketplace so the plugin directory is installable
578
+ standalone via `claude plugin marketplace add`.
579
+
580
+ ### Built-in Catalog
581
+
582
+ Agentworks ships a built-in catalog of common tools (apt sources, apt packages, system install
583
+ commands, and user install commands). Run `agentworks installer list` to see what is available.
584
+ Reference catalog entries by name in `vm_templates`, `admin.config`, and `agent_templates`.
585
+ User-defined entries in your config override built-in entries with the same name.
586
+
587
+ ## VM Initialization
588
+
589
+ VM creation follows a two-phase lifecycle tracked by separate status columns:
590
+
591
+ 1. **Provisioning** (`provisioning_status`) -- one-time, platform-specific, over the provisioning
592
+ transport (Lima shell, SSH, or WSL2 exec): create user, install system packages, add SSH key,
593
+ install and join Tailscale
594
+
595
+ 2. **Initialization** (`init_status`) -- repeatable via `vm reinit`, over Tailscale SSH: configure
596
+ apt sources, install apt packages, install snap packages, install mise, set shell, reconcile SSH
597
+ authorized keys, run system install commands, write mise config, configure PATH, configure git
598
+ credentials, sync dotfiles, fetch mise lockfile, run mise install, run user install commands for
599
+ the admin user
600
+
601
+ Initialization is fully declarative -- driven entirely by config. `vm create` only accepts immutable
602
+ provisioning parameters (name, platform, resources). `vm reinit` takes only the VM name and re-runs
603
+ initialization using the current config.
604
+
605
+ Non-fatal initialization failures (packages, dotfiles) produce a `partial` status rather than
606
+ aborting. Fatal failures prompt for deletion or reinit. Use `vm describe` to view the full event
607
+ log.
608
+
609
+ ## Shell Completion
610
+
611
+ ```bash
612
+ mkdir -p ~/.zfunc
613
+ agentworks completion zsh > ~/.zfunc/_agentworks
614
+ ```
615
+
616
+ Add to `.zshrc`:
617
+
618
+ ```bash
619
+ fpath=(~/.zfunc $fpath)
620
+ autoload -Uz compinit && compinit
621
+ ```
622
+
623
+ Completions include dynamic VM, workspace, VM host, session, and template name lookups.
624
+
625
+ ## State
626
+
627
+ All state is stored in `~/.config/agentworks/agentworks.db` (SQLite). Schema migrations are
628
+ forward-only and run automatically.
629
+
630
+ ## Environment Variables
631
+
632
+ | Variable | Description |
633
+ | ----------------------------- | ----------------------------------------------- |
634
+ | `TAILSCALE_AUTH_KEY` | Tailscale auth key (skips prompt) |
635
+ | `GIT_CREDENTIALS_<CRED_NAME>` | Git credential for `<CRED_NAME>` (skips prompt) |