@useconvoy/cli 0.108.0 → 0.113.1

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 (97) hide show
  1. package/README.md +4 -2
  2. package/dist/src/agent/app/runner.d.ts +6 -0
  3. package/dist/src/agent/app/runner.js +20 -2
  4. package/dist/src/agent/app/runner.js.map +1 -1
  5. package/dist/src/agent/runtimes/registry.js +2 -1
  6. package/dist/src/agent/runtimes/registry.js.map +1 -1
  7. package/dist/src/commands/connect/workflow.js +15 -4
  8. package/dist/src/commands/connect/workflow.js.map +1 -1
  9. package/dist/src/commands/environment/command.d.ts +3 -0
  10. package/dist/src/commands/environment/command.js +5 -5
  11. package/dist/src/commands/environment/command.js.map +1 -1
  12. package/dist/src/commands/environment/index.d.ts +13 -0
  13. package/dist/src/commands/environment/index.js +4 -0
  14. package/dist/src/commands/environment/index.js.map +1 -1
  15. package/dist/src/commands/environment/projects.d.ts +1 -1
  16. package/dist/src/commands/environment/validators.d.ts +1 -6
  17. package/dist/src/commands/environment/validators.js +1 -1
  18. package/dist/src/commands/environment/validators.js.map +1 -1
  19. package/dist/src/commands/environment/workflow.d.ts +1 -2
  20. package/dist/src/commands/environment/workflow.js +0 -5
  21. package/dist/src/commands/environment/workflow.js.map +1 -1
  22. package/dist/src/commands/keys/workflow.d.ts +2 -0
  23. package/dist/src/commands/project/command.js +36 -4
  24. package/dist/src/commands/project/command.js.map +1 -1
  25. package/dist/src/commands/project/formatters.d.ts +30 -0
  26. package/dist/src/commands/project/formatters.js +77 -0
  27. package/dist/src/commands/project/formatters.js.map +1 -0
  28. package/dist/src/commands/project/launcher.d.ts +21 -3
  29. package/dist/src/commands/project/launcher.js +37 -15
  30. package/dist/src/commands/project/launcher.js.map +1 -1
  31. package/dist/src/commands/project/validators.d.ts +55 -1
  32. package/dist/src/commands/project/validators.js +14 -0
  33. package/dist/src/commands/project/validators.js.map +1 -1
  34. package/dist/src/commands/project/workflow.d.ts +5 -1
  35. package/dist/src/commands/project/workflow.js +72 -2
  36. package/dist/src/commands/project/workflow.js.map +1 -1
  37. package/dist/src/commands/remote/command.js +3 -3
  38. package/dist/src/commands/remote/command.js.map +1 -1
  39. package/dist/src/commands/remote/index.d.ts +1 -1
  40. package/dist/src/commands/remote/index.js +1 -1
  41. package/dist/src/commands/remote/index.js.map +1 -1
  42. package/dist/src/commands/remote/ssh.d.ts +8 -2
  43. package/dist/src/commands/remote/ssh.js +41 -15
  44. package/dist/src/commands/remote/ssh.js.map +1 -1
  45. package/dist/src/commands/remote/workflow.d.ts +83 -0
  46. package/dist/src/commands/remote/workflow.js +48 -0
  47. package/dist/src/commands/remote/workflow.js.map +1 -0
  48. package/dist/src/commands/service/client.js +2 -1
  49. package/dist/src/commands/service/client.js.map +1 -1
  50. package/dist/src/commands/service/formatters.js +3 -0
  51. package/dist/src/commands/service/formatters.js.map +1 -1
  52. package/dist/src/commands/service/server.js +1 -1
  53. package/dist/src/commands/service/server.js.map +1 -1
  54. package/dist/src/commands/service/validators.d.ts +14 -0
  55. package/dist/src/commands/service/validators.js +4 -0
  56. package/dist/src/commands/service/validators.js.map +1 -1
  57. package/dist/src/commands/service/workflow.js +28 -1
  58. package/dist/src/commands/service/workflow.js.map +1 -1
  59. package/dist/src/commands/tui/actions/app.js +8 -6
  60. package/dist/src/commands/tui/actions/app.js.map +1 -1
  61. package/dist/src/commands/tui/actions/formatters.js +6 -1
  62. package/dist/src/commands/tui/actions/formatters.js.map +1 -1
  63. package/dist/src/commands/tui/actions/validators.d.ts +3 -1
  64. package/dist/src/commands/tui/actions/validators.js +2 -1
  65. package/dist/src/commands/tui/actions/validators.js.map +1 -1
  66. package/dist/src/commands/tui/actions/workflow.d.ts +3 -1
  67. package/dist/src/commands/tui/actions/workflow.js +51 -13
  68. package/dist/src/commands/tui/actions/workflow.js.map +1 -1
  69. package/dist/src/commands/tui/app.js +6 -4
  70. package/dist/src/commands/tui/app.js.map +1 -1
  71. package/dist/src/commands/tui/credentials/app.js +9 -1
  72. package/dist/src/commands/tui/credentials/app.js.map +1 -1
  73. package/dist/src/commands/tui/environments/app.js +4 -7
  74. package/dist/src/commands/tui/environments/app.js.map +1 -1
  75. package/dist/src/commands/tui/formatters.d.ts +3 -0
  76. package/dist/src/commands/tui/formatters.js +6 -0
  77. package/dist/src/commands/tui/formatters.js.map +1 -1
  78. package/dist/src/commands/tui/onboarding/app.js +4 -3
  79. package/dist/src/commands/tui/onboarding/app.js.map +1 -1
  80. package/dist/src/commands/tui/resolution.d.ts +7 -2
  81. package/dist/src/commands/tui/resolution.js +10 -6
  82. package/dist/src/commands/tui/resolution.js.map +1 -1
  83. package/dist/src/commands/tui/validators.d.ts +1 -1
  84. package/dist/src/commands/tui/workflow.d.ts +2 -0
  85. package/dist/src/lib/connect-events.d.ts +6 -0
  86. package/dist/src/lib/connect-events.js.map +1 -1
  87. package/dist/templates/project-isolation/README.md +28 -13
  88. package/dist/templates/project-isolation/__pycache__/install.cpython-311.pyc +0 -0
  89. package/dist/templates/project-isolation/__pycache__/launcher.cpython-311.pyc +0 -0
  90. package/dist/templates/project-isolation/environment.py +2 -55
  91. package/dist/templates/project-isolation/environment.test.py +1 -1
  92. package/dist/templates/project-isolation/install.py +39 -6
  93. package/dist/templates/project-isolation/install.test.py +32 -0
  94. package/dist/templates/project-isolation/launcher.py +224 -18
  95. package/dist/templates/project-isolation/launcher.test.py +179 -2
  96. package/package.json +1 -1
  97. package/dist/templates/project-isolation/__pycache__/environment.cpython-311.pyc +0 -0
@@ -1,8 +1,9 @@
1
1
  # Convoy project environment
2
2
 
3
3
  This template is for the OS-1958 implementation. Runtime and Docker/VM acceptance
4
- are still pending. Execution starts disabled through `verified_runtimes: []`.
5
- Do not use it for sensitive projects until the acceptance procedure passes.
4
+ are still pending. Projects run Codex or Claude Code when a root-owned binary is
5
+ installed; the launcher checks at each start. Do not use it for sensitive projects
6
+ until the acceptance procedure passes.
6
7
 
7
8
  ## Install
8
9
 
@@ -60,8 +61,7 @@ The command returns without starting a connection. Complete non-interactive use:
60
61
  convoy project add a --url https://example.convex.cloud \
61
62
  --api-key "$PROJECT_A_KEY" --project "$PROJECT_A_ID" --profile-key a --non-interactive
62
63
  convoy project list
63
- convoy project shell a
64
- # In the private shell: authenticate the runtime, then exit.
64
+ convoy project login a --runtime codex
65
65
  convoy connect --profile a
66
66
  ```
67
67
 
@@ -117,10 +117,9 @@ scoped provider credentials.
117
117
  ## Acceptance procedure
118
118
 
119
119
  Use a disposable environment with two test projects and non-sensitive credentials.
120
- The administrator may enable candidate runtime names in
121
- `/etc/convoy-projects.json` while testing. Supported names are `claude-code`,
122
- `codex`, `cursor` and `opencode`. An empty list rejects all agent runtime launches.
123
- Only retain names whose complete checks pass; both Codex transports need testing.
120
+ The launcher runs only the runtimes Convoy has tested in the boundary, `codex` and
121
+ `claude-code`, and only from root-owned binaries. `install.py` prints its sandbox
122
+ check and the detected runtimes. Both Codex transports need testing.
124
123
 
125
124
  1. Register A and B and enter their shells. Record `id`, `/proc/self/status`,
126
125
  workspace ownership and HOME. Check distinct UIDs, empty supplementary groups,
@@ -129,7 +128,7 @@ Only retain names whose complete checks pass; both Codex transports need testing
129
128
  reads/writes fail. Verify B's processes and control sockets are absent. Test
130
129
  hard-linked input is rejected during reuse and a second A shell/connection
131
130
  cannot acquire the lease.
132
- 3. Enable one candidate runtime in the disposable setup. Run real agents in A/B,
131
+ 3. Install one runtime in the disposable setup. Run real agents in A/B,
133
132
  including shell commands, file edits, helpers, worktrees and a resumed thread.
134
133
  Verify legitimate work succeeds and cross-project access still fails.
135
134
  4. Cancel a run, close the terminal, kill the control process and kill the launcher
@@ -179,9 +178,8 @@ convoy service stop
179
178
  Closing a log viewer or the starting terminal leaves background work running.
180
179
  Explicit stop drains all workers and retains data. CLI 0.68.0 applies new
181
180
  registrations without restarting siblings. Remove a live project with
182
- `convoy project remove c --yes --interrupt`. For runtime login, pause C with
183
- `convoy service pause c --interrupt`, enter/exit its project shell, then reconnect
184
- using `convoy service reload --profile c --interrupt`. See the [persistent service guide](https://docs.convoy.build/docs/cli/project-service)
181
+ `convoy project remove c --yes --interrupt`. For runtime login, run
182
+ `convoy project login c --runtime codex`; it pauses C, runs the login and reloads C. See the [persistent service guide](https://docs.convoy.build/docs/cli/project-service)
185
183
  for A/B verification, retained logs and failure recovery.
186
184
 
187
185
  ## Managed Codex API keys
@@ -206,5 +204,22 @@ for project, service, attachment and browser smoke commands. It builds this
206
204
  bundled template through Docker with labeled Linux volumes, a custom seccomp
207
205
  policy for nested bubblewrap, and a host-only root lifecycle helper. See
208
206
  [Managed local environments](https://docs.convoy.build/docs/cli/managed-environments)
209
- for setup, runtime verification, updates, recovery and acceptance commands.
207
+ for setup, runtime login, updates, recovery and acceptance commands.
210
208
  The manual Dev Containers workflow above remains available.
209
+
210
+ ## Upgrading to CLI 0.111.0
211
+
212
+ The launcher now records who holds a project lease, tells the service why a
213
+ worker could not start, and answers `convoy project check`. On a VM, install the
214
+ new CLI and rerun `install.py` with the same arguments. In a managed Docker
215
+ environment, run Update CLI. An older launcher still runs projects; only
216
+ `project check` and the new service warnings need the update.
217
+
218
+ ## Upgrading to CLI 0.110.0
219
+
220
+ The launcher now detects runtimes at each start, creates `~/.codex` and `~/.claude`
221
+ in each project HOME, and runs `project login`. `verified_runtimes` is ignored and
222
+ `environment verify` is gone. On a VM, install the new CLI and rerun `install.py`
223
+ with the same arguments. In a managed Docker environment, run Update CLI.
224
+ Registrations, credentials and project files stay in place.
225
+
@@ -1,8 +1,6 @@
1
1
  #!/usr/bin/python3 -I
2
2
  """Host-only Docker lifecycle helper. Not a sudo capability for project users."""
3
3
  import fcntl
4
- import importlib.machinery
5
- import importlib.util
6
4
  import json
7
5
  import os
8
6
  from pathlib import Path
@@ -11,14 +9,12 @@ import shutil
11
9
  import signal
12
10
  import subprocess
13
11
  import sys
14
- import tempfile
15
12
  import time
16
13
 
17
14
  ROOT = Path('/opt/convoy')
18
15
  STATE = Path('/var/lib/convoy-projects')
19
16
  PACKAGE = ROOT / 'node_modules/@useconvoy/cli'
20
17
  JOURNAL = ROOT / 'update.json'
21
- RUNTIMES = ROOT / 'runtimes.json'
22
18
  NETWORK = ROOT / 'network.json'
23
19
  CLI = str(PACKAGE / 'dist/bin/convoy.js')
24
20
 
@@ -88,10 +84,6 @@ def stop():
88
84
  def install():
89
85
  run(['python3', '-I', str(PACKAGE / 'dist/templates/project-isolation/install.py'),
90
86
  '--control-user', 'node', '--workspace', '/workspace', '--package-root', str(PACKAGE)])
91
- config_path = Path('/etc/convoy-projects.json')
92
- config = json.loads(config_path.read_text())
93
- config['verified_runtimes'] = json.loads(RUNTIMES.read_text()) if RUNTIMES.exists() else []
94
- config_path.write_text(json.dumps(config))
95
87
 
96
88
 
97
89
  def start_service():
@@ -189,50 +181,6 @@ def update(target, local=False):
189
181
  raise
190
182
 
191
183
 
192
- def verify(runtime):
193
- if runtime not in ['codex', 'claude-code']:
194
- raise ValueError('Only preinstalled codex and claude-code may be enabled')
195
- loader = importlib.machinery.SourceFileLoader('launcher', '/usr/local/libexec/convoy-project-launcher')
196
- module = importlib.util.module_from_spec(importlib.util.spec_from_loader(loader.name, loader))
197
- loader.exec_module(module)
198
- config = json.loads(Path('/etc/convoy-projects.json').read_text())
199
- # Temporary UIDs are never registered or reused for real projects.
200
- uid = 65000
201
- workspace = Path(tempfile.mkdtemp(prefix='convoy-probe-', dir='/workspace'))
202
- home = Path(tempfile.mkdtemp(prefix='convoy-probe-', dir=config['state']))
203
- entry = {'uid': uid, 'identity': home.name, 'path': str(workspace)}
204
- trees = Path(str(workspace) + '-worktrees')
205
- trees.mkdir()
206
- other = Path(tempfile.mkdtemp(prefix='convoy-other-', dir='/workspace'))
207
- try:
208
- for path in [workspace, home, trees]:
209
- os.chown(path, uid, uid)
210
- path.chmod(0o700)
211
- module.write_identity_files(config, entry)
212
- script = '''import os, pathlib
213
- assert os.getuid() == 65000
214
- assert not os.getgroups()
215
- s = pathlib.Path('/proc/self/status').read_text()
216
- assert 'NoNewPrivs:\\t1' in s
217
- assert int(s.split('CapEff:\\t')[1].splitlines()[0], 16) == 0
218
- assert not pathlib.Path('/home/node').exists()
219
- assert not pathlib.Path('/var/run/docker.sock').exists()
220
- assert not pathlib.Path(os.environ['OTHER_PROJECT']).exists()
221
- pathlib.Path('probe.txt').write_text('private')
222
- '''
223
- command = module.sandbox_args(config, entry) + ['--setenv', 'OTHER_PROJECT', str(other), 'python3', '-c', script]
224
- run(command, preexec_fn=lambda: module.drop_privileges(uid), env=module.SAFE_ENV)
225
- enabled = json.loads(RUNTIMES.read_text()) if RUNTIMES.exists() else []
226
- RUNTIMES.write_text(json.dumps(sorted(set(enabled + [runtime]))))
227
- install()
228
- print('Boundary probes passed. Enabled candidate runtime ' + runtime + '. Complete real A/B agent acceptance.', file=sys.stderr)
229
- finally:
230
- for path in [workspace, home, trees, other]:
231
- shutil.rmtree(path, ignore_errors=True)
232
- for suffix in ['passwd', 'group']:
233
- (Path(config['state']) / (home.name + '.' + suffix)).unlink(missing_ok=True)
234
-
235
-
236
184
  def main():
237
185
  if os.geteuid() != 0:
238
186
  raise RuntimeError('This helper is only invoked by the host Docker controller')
@@ -254,12 +202,11 @@ def main():
254
202
  update(sys.argv[2], local=True)
255
203
  elif operation == 'allow-domain':
256
204
  firewall(sys.argv[2])
257
- elif operation == 'verify':
258
- verify(sys.argv[2])
259
205
  elif operation == 'status':
260
206
  print(json.dumps({'serviceVersion': version() if (PACKAGE / 'package.json').exists() else None, 'serviceRunning': not free_lock(),
261
207
  'recoveryPending': JOURNAL.exists(),
262
- 'runtimes': json.loads(RUNTIMES.read_text()) if RUNTIMES.exists() else []}))
208
+ # Required by the status schema of CLI 0.109.0 and older hosts; launch detects runtimes now.
209
+ 'runtimes': []}))
263
210
  else:
264
211
  raise ValueError('Unknown environment operation')
265
212
 
@@ -174,7 +174,7 @@ class StatusTests(unittest.TestCase):
174
174
  with tempfile.TemporaryDirectory() as directory:
175
175
  journal = Path(directory) / 'update.json'
176
176
  journal.write_text('{}')
177
- with patch.object(environment, 'PACKAGE', Path(directory) / 'missing'), patch.object(environment, 'JOURNAL', journal), patch.object(environment, 'RUNTIMES', Path(directory) / 'runtimes'), patch.object(environment, 'free_lock', return_value=True), patch.object(environment.os, 'geteuid', return_value=0), patch.object(environment.sys, 'argv', ['helper', 'status']), patch('builtins.open', mock_open()), patch.object(environment.fcntl, 'flock'), patch('builtins.print') as output:
177
+ with patch.object(environment, 'PACKAGE', Path(directory) / 'missing'), patch.object(environment, 'JOURNAL', journal), patch.object(environment, 'free_lock', return_value=True), patch.object(environment.os, 'geteuid', return_value=0), patch.object(environment.sys, 'argv', ['helper', 'status']), patch('builtins.open', mock_open()), patch.object(environment.fcntl, 'flock'), patch('builtins.print') as output:
178
178
  environment.main()
179
179
  self.assertEqual(json.loads(output.call_args.args[0]), {'serviceVersion': None, 'serviceRunning': False, 'recoveryPending': True, 'runtimes': []})
180
180
 
@@ -1,15 +1,46 @@
1
1
  #!/usr/bin/python3 -I
2
2
  """Administrator installation; never invoked by a project worker."""
3
3
  import argparse
4
+ import importlib.machinery
5
+ import importlib.util
4
6
  import json
5
7
  import os
6
8
  from pathlib import Path
7
9
  import pwd
8
10
  import re
9
11
  import shutil
12
+ import subprocess
10
13
  import sys
11
14
 
12
15
 
16
+ def load_launcher():
17
+ loader = importlib.machinery.SourceFileLoader("launcher", str(Path(__file__).with_name("launcher.py")))
18
+ module = importlib.util.module_from_spec(importlib.util.spec_from_loader(loader.name, loader))
19
+ loader.exec_module(module)
20
+ return module
21
+
22
+
23
+ def diagnose(launcher, config):
24
+ """Report the boundary check and detected runtimes; the gate itself stays at launch."""
25
+ try:
26
+ launcher.check_boundary(config)
27
+ print("Sandbox check passed.")
28
+ except (ValueError, OSError, subprocess.SubprocessError) as error:
29
+ print(f"{error if isinstance(error, ValueError) else f'Sandbox check could not run: {error}.'} Projects will not start until this passes. "
30
+ "After fixing it, reload the projects; no reinstall is needed.")
31
+ runtimes = launcher.detect_runtimes(config)
32
+ print(f"Detected runtimes: {', '.join(runtimes)}." if runtimes else
33
+ "No runtime detected. Install codex or claude root-owned, for example under /usr/local/bin, then reload the projects.")
34
+
35
+
36
+ def node_problem(node):
37
+ """A Node the sandbox cannot see, such as an nvm install, gets a system Node hint."""
38
+ if node.is_relative_to("/home") or node.is_relative_to("/root") or ".nvm" in node.parts:
39
+ return (f"{node} is under a user home or nvm, which projects cannot see. Install a system Node, "
40
+ "for example with apt install nodejs, and pass --node /usr/bin/node")
41
+ return None
42
+
43
+
13
44
  def main():
14
45
  parser = argparse.ArgumentParser()
15
46
  parser.add_argument("--control-user", required=True)
@@ -29,7 +60,10 @@ def main():
29
60
  cli = package / "dist/src/commands/project/worker.js"
30
61
  if not cli.is_file():
31
62
  parser.error("Install/build the Convoy CLI package first")
32
- for root in [package, Path(args.node).resolve(strict=True)]:
63
+ node = Path(args.node).resolve(strict=True)
64
+ if node_problem(node):
65
+ parser.error(node_problem(node))
66
+ for root in [package, node]:
33
67
  for item in [root, *root.parents]:
34
68
  info = item.stat()
35
69
  if info.st_uid != 0 or info.st_mode & 0o022:
@@ -46,19 +80,18 @@ def main():
46
80
  config_file = Path("/etc/convoy-projects.json")
47
81
  config = {"control_uid": account.pw_uid, "workspace": str(workspace), "state": str(state.resolve()),
48
82
  "package_root": str(package), "cli": str(cli), "node": str(Path(args.node).resolve()),
49
- "installation_root": str(package.parents[2]) if package.parent.name == "@useconvoy" and package.parent.parent.name == "node_modules" else str(package),
50
- "verified_runtimes": []}
83
+ "installation_root": str(package.parents[2]) if package.parent.name == "@useconvoy" and package.parent.parent.name == "node_modules" else str(package)}
51
84
  if config_file.exists():
52
85
  old = json.loads(config_file.read_text())
53
- if any(old.get(key) != value for key, value in config.items() if key != "verified_runtimes"):
86
+ if any(old.get(key) != value for key, value in config.items()):
54
87
  parser.error("An environment is already configured differently; perform an explicit administrator migration")
55
- config["verified_runtimes"] = old.get("verified_runtimes", [])
56
88
  config_file.write_text(json.dumps(config, indent=2) + "\n")
57
89
  config_file.chmod(0o600)
58
90
  sudoers = Path("/etc/sudoers.d/convoy-projects")
59
91
  sudoers.write_text(f"{args.control_user} ALL=(root) NOPASSWD: {launcher}\n")
60
92
  sudoers.chmod(0o440)
61
- print("Project launcher installed. Complete the acceptance procedure before enabling runtime execution.")
93
+ print("Project launcher installed.")
94
+ diagnose(load_launcher(), config)
62
95
 
63
96
 
64
97
  if __name__ == "__main__":
@@ -0,0 +1,32 @@
1
+ import importlib.util
2
+ import io
3
+ from contextlib import redirect_stdout
4
+ from pathlib import Path
5
+ from types import SimpleNamespace
6
+ import unittest
7
+
8
+ spec = importlib.util.spec_from_file_location("install", Path(__file__).with_name("install.py"))
9
+ install = importlib.util.module_from_spec(spec)
10
+ spec.loader.exec_module(install)
11
+
12
+
13
+ class DiagnoseTests(unittest.TestCase):
14
+ def test_failed_boundary_check_is_reported_without_failing_installation(self):
15
+ def denied(config):
16
+ raise ValueError("Sandbox check failed: bwrap: setting up uid map: Permission denied.")
17
+ output = io.StringIO()
18
+ with redirect_stdout(output):
19
+ install.diagnose(SimpleNamespace(check_boundary=denied, detect_runtimes=lambda config: ["codex"]), {})
20
+ self.assertIn("uid map: Permission denied. Projects will not start until this passes", output.getvalue())
21
+ self.assertIn("Detected runtimes: codex.", output.getvalue())
22
+
23
+
24
+ class NodeTests(unittest.TestCase):
25
+ def test_a_node_in_a_user_home_is_rejected_with_a_system_node_hint(self):
26
+ for path in ["/home/me/.nvm/versions/node/v22.0.0/bin/node", "/root/.local/bin/node", "/opt/.nvm/node"]:
27
+ self.assertIn("--node /usr/bin/node", install.node_problem(Path(path)))
28
+ self.assertIsNone(install.node_problem(Path("/usr/bin/node")))
29
+
30
+
31
+ if __name__ == "__main__":
32
+ unittest.main()