@useconvoy/cli 0.91.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.
- package/README.md +72 -2
- package/dist/src/agent/app/chunk-flush-buffer.d.ts +2 -0
- package/dist/src/agent/app/chunk-flush-buffer.js +63 -16
- package/dist/src/agent/app/chunk-flush-buffer.js.map +1 -1
- package/dist/src/agent/app/runner.d.ts +14 -1
- package/dist/src/agent/app/runner.js +32 -5
- package/dist/src/agent/app/runner.js.map +1 -1
- package/dist/src/agent/app/thread-processor.js +1 -0
- package/dist/src/agent/app/thread-processor.js.map +1 -1
- package/dist/src/agent/runtimes/claudeCode/detect.d.ts +3 -3
- package/dist/src/agent/runtimes/claudeCode/detect.js +5 -6
- package/dist/src/agent/runtimes/claudeCode/detect.js.map +1 -1
- package/dist/src/agent/runtimes/claudeCode/runner.d.ts +3 -0
- package/dist/src/agent/runtimes/claudeCode/runner.js +9 -3
- package/dist/src/agent/runtimes/claudeCode/runner.js.map +1 -1
- package/dist/src/agent/runtimes/claudeCode/runtime.js +1 -0
- package/dist/src/agent/runtimes/claudeCode/runtime.js.map +1 -1
- package/dist/src/agent/runtimes/claudeCode/streaming.js +30 -14
- package/dist/src/agent/runtimes/claudeCode/streaming.js.map +1 -1
- package/dist/src/agent/runtimes/codex/app-server-runner.d.ts +2 -0
- package/dist/src/agent/runtimes/codex/app-server-runner.js +48 -20
- package/dist/src/agent/runtimes/codex/app-server-runner.js.map +1 -1
- package/dist/src/agent/runtimes/codex/auth.d.ts +20 -2
- package/dist/src/agent/runtimes/codex/auth.js +79 -32
- package/dist/src/agent/runtimes/codex/auth.js.map +1 -1
- package/dist/src/agent/runtimes/codex/detect.d.ts +3 -2
- package/dist/src/agent/runtimes/codex/detect.js +4 -2
- package/dist/src/agent/runtimes/codex/detect.js.map +1 -1
- package/dist/src/agent/runtimes/codex/errors.d.ts +4 -3
- package/dist/src/agent/runtimes/codex/errors.js +24 -7
- package/dist/src/agent/runtimes/codex/errors.js.map +1 -1
- package/dist/src/agent/runtimes/codex/models.d.ts +2 -0
- package/dist/src/agent/runtimes/codex/models.js +4 -0
- package/dist/src/agent/runtimes/codex/models.js.map +1 -1
- package/dist/src/agent/runtimes/codex/runner.js +3 -1
- package/dist/src/agent/runtimes/codex/runner.js.map +1 -1
- package/dist/src/agent/runtimes/codex/runtime.js +2 -1
- package/dist/src/agent/runtimes/codex/runtime.js.map +1 -1
- package/dist/src/agent/runtimes/codex/streaming.js +24 -0
- package/dist/src/agent/runtimes/codex/streaming.js.map +1 -1
- package/dist/src/agent/runtimes/contracts.d.ts +19 -2
- package/dist/src/agent/runtimes/contracts.js.map +1 -1
- package/dist/src/agent/runtimes/cursor/streaming.js +17 -0
- package/dist/src/agent/runtimes/cursor/streaming.js.map +1 -1
- package/dist/src/agent/runtimes/opencode/runtime.js +1 -1
- package/dist/src/agent/runtimes/opencode/runtime.js.map +1 -1
- package/dist/src/agent/runtimes/opencode/streaming.js +7 -0
- package/dist/src/agent/runtimes/opencode/streaming.js.map +1 -1
- package/dist/src/agent/runtimes/registry.d.ts +2 -2
- package/dist/src/agent/runtimes/registry.js +4 -3
- package/dist/src/agent/runtimes/registry.js.map +1 -1
- package/dist/src/cli.js +5 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/connect/workflow.d.ts +6 -1
- package/dist/src/commands/connect/workflow.js +43 -11
- package/dist/src/commands/connect/workflow.js.map +1 -1
- package/dist/src/commands/environment/command.d.ts +7 -1
- package/dist/src/commands/environment/command.js +16 -12
- package/dist/src/commands/environment/command.js.map +1 -1
- package/dist/src/commands/environment/docker.d.ts +2 -0
- package/dist/src/commands/environment/docker.js +3 -3
- package/dist/src/commands/environment/docker.js.map +1 -1
- package/dist/src/commands/environment/index.d.ts +33 -2
- package/dist/src/commands/environment/index.js +23 -5
- package/dist/src/commands/environment/index.js.map +1 -1
- package/dist/src/commands/environment/paths.d.ts +2 -2
- package/dist/src/commands/environment/paths.js +7 -4
- package/dist/src/commands/environment/paths.js.map +1 -1
- package/dist/src/commands/environment/projects.d.ts +10 -0
- package/dist/src/commands/environment/projects.js +37 -1
- package/dist/src/commands/environment/projects.js.map +1 -1
- package/dist/src/commands/environment/resolution.d.ts +3 -0
- package/dist/src/commands/environment/resolution.js +29 -0
- package/dist/src/commands/environment/resolution.js.map +1 -1
- package/dist/src/commands/environment/setup-entrypoint.js +5 -2
- package/dist/src/commands/environment/setup-entrypoint.js.map +1 -1
- package/dist/src/commands/environment/validators.d.ts +35 -4
- package/dist/src/commands/environment/validators.js +5 -1
- package/dist/src/commands/environment/validators.js.map +1 -1
- package/dist/src/commands/environment/workflow.d.ts +21 -3
- package/dist/src/commands/environment/workflow.js +155 -15
- package/dist/src/commands/environment/workflow.js.map +1 -1
- package/dist/src/commands/keys/command.js +102 -43
- package/dist/src/commands/keys/command.js.map +1 -1
- package/dist/src/commands/keys/workflow.d.ts +18 -1
- package/dist/src/commands/keys/workflow.js +30 -12
- package/dist/src/commands/keys/workflow.js.map +1 -1
- package/dist/src/commands/project/command.js +40 -5
- package/dist/src/commands/project/command.js.map +1 -1
- package/dist/src/commands/project/formatters.d.ts +30 -0
- package/dist/src/commands/project/formatters.js +77 -0
- package/dist/src/commands/project/formatters.js.map +1 -0
- package/dist/src/commands/project/launcher.d.ts +31 -2
- package/dist/src/commands/project/launcher.js +97 -20
- package/dist/src/commands/project/launcher.js.map +1 -1
- package/dist/src/commands/project/validators.d.ts +121 -1
- package/dist/src/commands/project/validators.js +46 -3
- package/dist/src/commands/project/validators.js.map +1 -1
- package/dist/src/commands/project/worker.js +8 -1
- package/dist/src/commands/project/worker.js.map +1 -1
- package/dist/src/commands/project/workflow.d.ts +8 -1
- package/dist/src/commands/project/workflow.js +121 -19
- package/dist/src/commands/project/workflow.js.map +1 -1
- package/dist/src/commands/remote/command.d.ts +4 -0
- package/dist/src/commands/remote/command.js +90 -0
- package/dist/src/commands/remote/command.js.map +1 -0
- package/dist/src/commands/remote/index.d.ts +3 -0
- package/dist/src/commands/remote/index.js +4 -0
- package/dist/src/commands/remote/index.js.map +1 -0
- package/dist/src/commands/remote/paths.d.ts +5 -0
- package/dist/src/commands/remote/paths.js +32 -0
- package/dist/src/commands/remote/paths.js.map +1 -0
- package/dist/src/commands/remote/ssh.d.ts +18 -0
- package/dist/src/commands/remote/ssh.js +120 -0
- package/dist/src/commands/remote/ssh.js.map +1 -0
- package/dist/src/commands/remote/validators.d.ts +18 -0
- package/dist/src/commands/remote/validators.js +11 -0
- package/dist/src/commands/remote/validators.js.map +1 -0
- package/dist/src/commands/remote/workflow.d.ts +83 -0
- package/dist/src/commands/remote/workflow.js +48 -0
- package/dist/src/commands/remote/workflow.js.map +1 -0
- package/dist/src/commands/service/attach.js +7 -2
- package/dist/src/commands/service/attach.js.map +1 -1
- package/dist/src/commands/service/bridge.js +2 -1
- package/dist/src/commands/service/bridge.js.map +1 -1
- package/dist/src/commands/service/client.d.ts +2 -1
- package/dist/src/commands/service/client.js +16 -8
- package/dist/src/commands/service/client.js.map +1 -1
- package/dist/src/commands/service/command.d.ts +1 -1
- package/dist/src/commands/service/command.js +3 -2
- package/dist/src/commands/service/command.js.map +1 -1
- package/dist/src/commands/service/errors.d.ts +9 -0
- package/dist/src/commands/service/errors.js +9 -0
- package/dist/src/commands/service/errors.js.map +1 -1
- package/dist/src/commands/service/formatters.js +3 -0
- package/dist/src/commands/service/formatters.js.map +1 -1
- package/dist/src/commands/service/resolution.js +6 -3
- package/dist/src/commands/service/resolution.js.map +1 -1
- package/dist/src/commands/service/runs.js +1 -1
- package/dist/src/commands/service/runs.js.map +1 -1
- package/dist/src/commands/service/server.js +1 -1
- package/dist/src/commands/service/server.js.map +1 -1
- package/dist/src/commands/service/service-entrypoint.js +1 -1
- package/dist/src/commands/service/service-entrypoint.js.map +1 -1
- package/dist/src/commands/service/validators.d.ts +89 -1
- package/dist/src/commands/service/validators.js +25 -1
- package/dist/src/commands/service/validators.js.map +1 -1
- package/dist/src/commands/service/workflow.js +39 -5
- package/dist/src/commands/service/workflow.js.map +1 -1
- package/dist/src/commands/setup/prompts.d.ts +8 -0
- package/dist/src/commands/setup/prompts.js +1 -1
- package/dist/src/commands/setup/prompts.js.map +1 -1
- package/dist/src/commands/setup/resolution.d.ts +5 -1
- package/dist/src/commands/setup/resolution.js +6 -4
- package/dist/src/commands/setup/resolution.js.map +1 -1
- package/dist/src/commands/tui/actions/app.d.ts +19 -0
- package/dist/src/commands/tui/actions/app.js +134 -0
- package/dist/src/commands/tui/actions/app.js.map +1 -0
- package/dist/src/commands/tui/actions/formatters.d.ts +2 -0
- package/dist/src/commands/tui/actions/formatters.js +53 -0
- package/dist/src/commands/tui/actions/formatters.js.map +1 -0
- package/dist/src/commands/tui/actions/index.d.ts +2 -0
- package/dist/src/commands/tui/actions/index.js +3 -0
- package/dist/src/commands/tui/actions/index.js.map +1 -0
- package/dist/src/commands/tui/actions/validators.d.ts +17 -0
- package/dist/src/commands/tui/actions/validators.js +3 -0
- package/dist/src/commands/tui/actions/validators.js.map +1 -0
- package/dist/src/commands/tui/actions/workflow.d.ts +35 -0
- package/dist/src/commands/tui/actions/workflow.js +249 -0
- package/dist/src/commands/tui/actions/workflow.js.map +1 -0
- package/dist/src/commands/tui/app.d.ts +7 -0
- package/dist/src/commands/tui/app.js +270 -0
- package/dist/src/commands/tui/app.js.map +1 -0
- package/dist/src/commands/tui/command.d.ts +2 -0
- package/dist/src/commands/tui/command.js +18 -0
- package/dist/src/commands/tui/command.js.map +1 -0
- package/dist/src/commands/tui/credentials/app.d.ts +10 -0
- package/dist/src/commands/tui/credentials/app.js +425 -0
- package/dist/src/commands/tui/credentials/app.js.map +1 -0
- package/dist/src/commands/tui/credentials/formatters.d.ts +11 -0
- package/dist/src/commands/tui/credentials/formatters.js +41 -0
- package/dist/src/commands/tui/credentials/formatters.js.map +1 -0
- package/dist/src/commands/tui/credentials/index.d.ts +1 -0
- package/dist/src/commands/tui/credentials/index.js +2 -0
- package/dist/src/commands/tui/credentials/index.js.map +1 -0
- package/dist/src/commands/tui/credentials/validators.d.ts +13 -0
- package/dist/src/commands/tui/credentials/validators.js +2 -0
- package/dist/src/commands/tui/credentials/validators.js.map +1 -0
- package/dist/src/commands/tui/credentials/workflow.d.ts +42 -0
- package/dist/src/commands/tui/credentials/workflow.js +40 -0
- package/dist/src/commands/tui/credentials/workflow.js.map +1 -0
- package/dist/src/commands/tui/dialog/app.d.ts +15 -0
- package/dist/src/commands/tui/dialog/app.js +59 -0
- package/dist/src/commands/tui/dialog/app.js.map +1 -0
- package/dist/src/commands/tui/dialog/index.d.ts +1 -0
- package/dist/src/commands/tui/dialog/index.js +2 -0
- package/dist/src/commands/tui/dialog/index.js.map +1 -0
- package/dist/src/commands/tui/environments/app.d.ts +6 -0
- package/dist/src/commands/tui/environments/app.js +173 -0
- package/dist/src/commands/tui/environments/app.js.map +1 -0
- package/dist/src/commands/tui/environments/index.d.ts +1 -0
- package/dist/src/commands/tui/environments/index.js +2 -0
- package/dist/src/commands/tui/environments/index.js.map +1 -0
- package/dist/src/commands/tui/formatters.d.ts +30 -0
- package/dist/src/commands/tui/formatters.js +100 -0
- package/dist/src/commands/tui/formatters.js.map +1 -0
- package/dist/src/commands/tui/index.d.ts +1 -0
- package/dist/src/commands/tui/index.js +2 -0
- package/dist/src/commands/tui/index.js.map +1 -0
- package/dist/src/commands/tui/logs/app.d.ts +9 -0
- package/dist/src/commands/tui/logs/app.js +181 -0
- package/dist/src/commands/tui/logs/app.js.map +1 -0
- package/dist/src/commands/tui/logs/export.d.ts +4 -0
- package/dist/src/commands/tui/logs/export.js +72 -0
- package/dist/src/commands/tui/logs/export.js.map +1 -0
- package/dist/src/commands/tui/logs/formatters.d.ts +3 -0
- package/dist/src/commands/tui/logs/formatters.js +19 -0
- package/dist/src/commands/tui/logs/formatters.js.map +1 -0
- package/dist/src/commands/tui/logs/index.d.ts +1 -0
- package/dist/src/commands/tui/logs/index.js +2 -0
- package/dist/src/commands/tui/logs/index.js.map +1 -0
- package/dist/src/commands/tui/logs/validators.d.ts +44 -0
- package/dist/src/commands/tui/logs/validators.js +14 -0
- package/dist/src/commands/tui/logs/validators.js.map +1 -0
- package/dist/src/commands/tui/logs/workflow.d.ts +25 -0
- package/dist/src/commands/tui/logs/workflow.js +133 -0
- package/dist/src/commands/tui/logs/workflow.js.map +1 -0
- package/dist/src/commands/tui/onboarding/app.d.ts +8 -0
- package/dist/src/commands/tui/onboarding/app.js +352 -0
- package/dist/src/commands/tui/onboarding/app.js.map +1 -0
- package/dist/src/commands/tui/onboarding/formatters.d.ts +2 -0
- package/dist/src/commands/tui/onboarding/formatters.js +24 -0
- package/dist/src/commands/tui/onboarding/formatters.js.map +1 -0
- package/dist/src/commands/tui/onboarding/index.d.ts +1 -0
- package/dist/src/commands/tui/onboarding/index.js +2 -0
- package/dist/src/commands/tui/onboarding/index.js.map +1 -0
- package/dist/src/commands/tui/onboarding/workflow.d.ts +18 -0
- package/dist/src/commands/tui/onboarding/workflow.js +55 -0
- package/dist/src/commands/tui/onboarding/workflow.js.map +1 -0
- package/dist/src/commands/tui/render.d.ts +2 -0
- package/dist/src/commands/tui/render.js +60 -0
- package/dist/src/commands/tui/render.js.map +1 -0
- package/dist/src/commands/tui/resolution.d.ts +42 -0
- package/dist/src/commands/tui/resolution.js +153 -0
- package/dist/src/commands/tui/resolution.js.map +1 -0
- package/dist/src/commands/tui/validators.d.ts +98 -0
- package/dist/src/commands/tui/validators.js +14 -0
- package/dist/src/commands/tui/validators.js.map +1 -0
- package/dist/src/commands/tui/workflow.d.ts +130 -0
- package/dist/src/commands/tui/workflow.js +462 -0
- package/dist/src/commands/tui/workflow.js.map +1 -0
- package/dist/src/convex/_generated/api.d.ts +10 -0
- package/dist/src/lib/config/convex-client.d.ts +10 -1
- package/dist/src/lib/config/convex-client.js +26 -4
- package/dist/src/lib/config/convex-client.js.map +1 -1
- package/dist/src/lib/config/credentials/resolution.d.ts +9 -4
- package/dist/src/lib/config/credentials/resolution.js +51 -17
- package/dist/src/lib/config/credentials/resolution.js.map +1 -1
- package/dist/src/lib/config/credentials/validators.d.ts +87 -0
- package/dist/src/lib/config/credentials/validators.js +21 -5
- package/dist/src/lib/config/credentials/validators.js.map +1 -1
- package/dist/src/lib/config/provider-keys.d.ts +10 -5
- package/dist/src/lib/config/provider-keys.js +36 -8
- package/dist/src/lib/config/provider-keys.js.map +1 -1
- package/dist/src/lib/config/toml.d.ts +8 -4
- package/dist/src/lib/config/toml.js +30 -11
- package/dist/src/lib/config/toml.js.map +1 -1
- package/dist/src/lib/config/types.d.ts +23 -2
- package/dist/src/lib/config/types.js +24 -0
- package/dist/src/lib/config/types.js.map +1 -1
- package/dist/src/lib/connect-events.d.ts +6 -0
- package/dist/src/lib/connect-events.js.map +1 -1
- package/dist/templates/devcontainer/README.md +1 -1
- package/dist/templates/devcontainer/init-firewall.sh +1 -0
- package/dist/templates/project-isolation/README.md +33 -14
- package/dist/templates/project-isolation/__pycache__/install.cpython-311.pyc +0 -0
- package/dist/templates/project-isolation/__pycache__/launcher.cpython-311.pyc +0 -0
- package/dist/templates/project-isolation/devcontainer.json +1 -1
- package/dist/templates/project-isolation/environment.py +21 -59
- package/dist/templates/project-isolation/environment.test.py +68 -3
- package/dist/templates/project-isolation/install.py +39 -6
- package/dist/templates/project-isolation/install.test.py +32 -0
- package/dist/templates/project-isolation/launcher.py +245 -27
- package/dist/templates/project-isolation/launcher.test.py +202 -2
- package/package.json +2 -1
|
@@ -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():
|
|
@@ -120,6 +112,8 @@ def recover():
|
|
|
120
112
|
|
|
121
113
|
|
|
122
114
|
def firewall(domain=None):
|
|
115
|
+
if os.environ.get("DEVCONTAINER_NETWORK_MODE", "strict") == "open":
|
|
116
|
+
return
|
|
123
117
|
stored = json.loads(NETWORK.read_text()) if NETWORK.exists() else []
|
|
124
118
|
if domain:
|
|
125
119
|
if not re.fullmatch(r'[a-zA-Z0-9.-]{1,253}', domain):
|
|
@@ -147,16 +141,25 @@ def start():
|
|
|
147
141
|
start_service()
|
|
148
142
|
|
|
149
143
|
|
|
150
|
-
def update(target):
|
|
151
|
-
if
|
|
144
|
+
def update(target, local=False):
|
|
145
|
+
if local:
|
|
146
|
+
archive = Path(target)
|
|
147
|
+
if not archive.is_absolute() or not archive.is_file():
|
|
148
|
+
raise ValueError("Local package must be an absolute file path")
|
|
149
|
+
elif not re.fullmatch(r'\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?', target):
|
|
152
150
|
raise ValueError('An exact package version is required')
|
|
153
151
|
recover()
|
|
154
152
|
staging = ROOT / 'staging'
|
|
155
153
|
shutil.rmtree(staging, ignore_errors=True)
|
|
156
154
|
# Stage without interrupting workers; a download failure leaves them running.
|
|
157
|
-
run(['npm', 'install', '--prefix', str(staging), '@useconvoy/cli@' + target], timeout=1200)
|
|
155
|
+
run(['npm', 'install', '--prefix', str(staging), target if local else '@useconvoy/cli@' + target], timeout=1200)
|
|
158
156
|
candidate = staging / 'node_modules/@useconvoy/cli'
|
|
159
|
-
|
|
157
|
+
metadata = json.loads((candidate / 'package.json').read_text())
|
|
158
|
+
if local:
|
|
159
|
+
if metadata.get('name') != '@useconvoy/cli' or not re.fullmatch(r'\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?', metadata.get('version', '')):
|
|
160
|
+
raise RuntimeError('Local package must be a versioned @useconvoy/cli package')
|
|
161
|
+
target = metadata['version']
|
|
162
|
+
elif metadata['version'] != target:
|
|
160
163
|
raise RuntimeError('Staged package version does not match the requested version')
|
|
161
164
|
if not (candidate / 'dist/templates/project-isolation/install.py').is_file():
|
|
162
165
|
raise RuntimeError('Staged package does not support project isolation')
|
|
@@ -178,53 +181,11 @@ def update(target):
|
|
|
178
181
|
raise
|
|
179
182
|
|
|
180
183
|
|
|
181
|
-
def verify(runtime):
|
|
182
|
-
if runtime not in ['codex', 'claude-code']:
|
|
183
|
-
raise ValueError('Only preinstalled codex and claude-code may be enabled')
|
|
184
|
-
loader = importlib.machinery.SourceFileLoader('launcher', '/usr/local/libexec/convoy-project-launcher')
|
|
185
|
-
module = importlib.util.module_from_spec(importlib.util.spec_from_loader(loader.name, loader))
|
|
186
|
-
loader.exec_module(module)
|
|
187
|
-
config = json.loads(Path('/etc/convoy-projects.json').read_text())
|
|
188
|
-
# Temporary UIDs are never registered or reused for real projects.
|
|
189
|
-
uid = 65000
|
|
190
|
-
workspace = Path(tempfile.mkdtemp(prefix='convoy-probe-', dir='/workspace'))
|
|
191
|
-
home = Path(tempfile.mkdtemp(prefix='convoy-probe-', dir=config['state']))
|
|
192
|
-
entry = {'uid': uid, 'identity': home.name, 'path': str(workspace)}
|
|
193
|
-
trees = Path(str(workspace) + '-worktrees')
|
|
194
|
-
trees.mkdir()
|
|
195
|
-
other = Path(tempfile.mkdtemp(prefix='convoy-other-', dir='/workspace'))
|
|
196
|
-
try:
|
|
197
|
-
for path in [workspace, home, trees]:
|
|
198
|
-
os.chown(path, uid, uid)
|
|
199
|
-
path.chmod(0o700)
|
|
200
|
-
module.write_identity_files(config, entry)
|
|
201
|
-
script = '''import os, pathlib
|
|
202
|
-
assert os.getuid() == 65000
|
|
203
|
-
assert not os.getgroups()
|
|
204
|
-
s = pathlib.Path('/proc/self/status').read_text()
|
|
205
|
-
assert 'NoNewPrivs:\\t1' in s
|
|
206
|
-
assert int(s.split('CapEff:\\t')[1].splitlines()[0], 16) == 0
|
|
207
|
-
assert not pathlib.Path('/home/node').exists()
|
|
208
|
-
assert not pathlib.Path('/var/run/docker.sock').exists()
|
|
209
|
-
assert not pathlib.Path(os.environ['OTHER_PROJECT']).exists()
|
|
210
|
-
pathlib.Path('probe.txt').write_text('private')
|
|
211
|
-
'''
|
|
212
|
-
command = module.sandbox_args(config, entry) + ['--setenv', 'OTHER_PROJECT', str(other), 'python3', '-c', script]
|
|
213
|
-
run(command, preexec_fn=lambda: module.drop_privileges(uid), env=module.SAFE_ENV)
|
|
214
|
-
enabled = json.loads(RUNTIMES.read_text()) if RUNTIMES.exists() else []
|
|
215
|
-
RUNTIMES.write_text(json.dumps(sorted(set(enabled + [runtime]))))
|
|
216
|
-
install()
|
|
217
|
-
print('Boundary probes passed. Enabled candidate runtime ' + runtime + '. Complete real A/B agent acceptance.', file=sys.stderr)
|
|
218
|
-
finally:
|
|
219
|
-
for path in [workspace, home, trees, other]:
|
|
220
|
-
shutil.rmtree(path, ignore_errors=True)
|
|
221
|
-
for suffix in ['passwd', 'group']:
|
|
222
|
-
(Path(config['state']) / (home.name + '.' + suffix)).unlink(missing_ok=True)
|
|
223
|
-
|
|
224
|
-
|
|
225
184
|
def main():
|
|
226
185
|
if os.geteuid() != 0:
|
|
227
186
|
raise RuntimeError('This helper is only invoked by the host Docker controller')
|
|
187
|
+
# Docker exec may inherit 000; staged installations must not be writable by workers.
|
|
188
|
+
os.umask(0o022)
|
|
228
189
|
with open('/run/convoy-environment.lock', 'w') as lock:
|
|
229
190
|
fcntl.flock(lock, fcntl.LOCK_EX)
|
|
230
191
|
operation = sys.argv[1]
|
|
@@ -237,14 +198,15 @@ def main():
|
|
|
237
198
|
start_service()
|
|
238
199
|
elif operation == 'update':
|
|
239
200
|
update(sys.argv[2])
|
|
201
|
+
elif operation == 'update-package':
|
|
202
|
+
update(sys.argv[2], local=True)
|
|
240
203
|
elif operation == 'allow-domain':
|
|
241
204
|
firewall(sys.argv[2])
|
|
242
|
-
elif operation == 'verify':
|
|
243
|
-
verify(sys.argv[2])
|
|
244
205
|
elif operation == 'status':
|
|
245
206
|
print(json.dumps({'serviceVersion': version() if (PACKAGE / 'package.json').exists() else None, 'serviceRunning': not free_lock(),
|
|
246
207
|
'recoveryPending': JOURNAL.exists(),
|
|
247
|
-
|
|
208
|
+
# Required by the status schema of CLI 0.109.0 and older hosts; launch detects runtimes now.
|
|
209
|
+
'runtimes': []}))
|
|
248
210
|
else:
|
|
249
211
|
raise ValueError('Unknown environment operation')
|
|
250
212
|
|
|
@@ -7,6 +7,7 @@ import subprocess
|
|
|
7
7
|
import sys
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
import tempfile
|
|
10
|
+
import tarfile
|
|
10
11
|
import unittest
|
|
11
12
|
from unittest.mock import patch, mock_open
|
|
12
13
|
|
|
@@ -38,9 +39,37 @@ class UpdateTests(unittest.TestCase):
|
|
|
38
39
|
if args[0] == 'npm':
|
|
39
40
|
package = self.root / 'staging/node_modules/@useconvoy/cli'
|
|
40
41
|
(package / 'dist/templates/project-isolation').mkdir(parents=True)
|
|
41
|
-
(package / 'package.json').write_text(json.dumps({'version': '0.76.0'}))
|
|
42
|
+
(package / 'package.json').write_text(json.dumps({'name': '@useconvoy/cli', 'version': '0.76.0'}))
|
|
42
43
|
(package / 'dist/templates/project-isolation/install.py').touch()
|
|
43
44
|
|
|
45
|
+
def test_local_package_uses_staging_and_reads_its_version(self):
|
|
46
|
+
archive = self.root / 'local package.tgz'
|
|
47
|
+
archive.touch()
|
|
48
|
+
with patch.object(environment, 'run', side_effect=self.stage) as execute:
|
|
49
|
+
environment.update(str(archive), local=True)
|
|
50
|
+
self.assertIn(str(archive), execute.call_args_list[0].args[0])
|
|
51
|
+
self.assertEqual(environment.version(), '0.76.0')
|
|
52
|
+
self.assertFalse(environment.JOURNAL.exists())
|
|
53
|
+
|
|
54
|
+
def test_local_install_failure_leaves_service_running(self):
|
|
55
|
+
archive = self.root / 'local.tgz'
|
|
56
|
+
archive.touch()
|
|
57
|
+
with patch.object(environment, 'run', side_effect=RuntimeError('install failed')):
|
|
58
|
+
with self.assertRaisesRegex(RuntimeError, 'install failed'):
|
|
59
|
+
environment.update(str(archive), local=True)
|
|
60
|
+
self.mocks[4].assert_not_called()
|
|
61
|
+
self.assertEqual(environment.version(), '0.75.0')
|
|
62
|
+
|
|
63
|
+
def test_local_health_failure_rolls_back(self):
|
|
64
|
+
archive = self.root / 'local.tgz'
|
|
65
|
+
archive.touch()
|
|
66
|
+
self.mocks[5].side_effect = [RuntimeError('health failed'), {}]
|
|
67
|
+
with patch.object(environment, 'run', side_effect=self.stage):
|
|
68
|
+
with self.assertRaisesRegex(RuntimeError, 'health failed'):
|
|
69
|
+
environment.update(str(archive), local=True)
|
|
70
|
+
self.assertEqual(environment.version(), '0.75.0')
|
|
71
|
+
self.assertFalse(environment.JOURNAL.exists())
|
|
72
|
+
|
|
44
73
|
def test_download_failure_does_not_stop_service(self):
|
|
45
74
|
with patch.object(environment, 'run', side_effect=RuntimeError('download failed')):
|
|
46
75
|
with self.assertRaisesRegex(RuntimeError, 'download failed'):
|
|
@@ -93,6 +122,33 @@ class UpdateTests(unittest.TestCase):
|
|
|
93
122
|
self.assertTrue(environment.JOURNAL.exists())
|
|
94
123
|
|
|
95
124
|
|
|
125
|
+
class PermissionTests(unittest.TestCase):
|
|
126
|
+
def test_host_update_stages_private_installation_under_permissive_docker_umask(self):
|
|
127
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
128
|
+
root = Path(directory)
|
|
129
|
+
package = root / 'package'
|
|
130
|
+
package.mkdir()
|
|
131
|
+
(package / 'package.json').write_text(json.dumps({'name': '@useconvoy/cli', 'version': '0.97.1'}))
|
|
132
|
+
archive = root / 'local.tgz'
|
|
133
|
+
with tarfile.open(archive, 'w:gz') as bundle:
|
|
134
|
+
bundle.add(package, arcname='package')
|
|
135
|
+
staging = root / 'staging'
|
|
136
|
+
|
|
137
|
+
def stage(*args, **kwargs):
|
|
138
|
+
environment.run(['npm', 'install', '--prefix', str(staging), str(archive),
|
|
139
|
+
'--ignore-scripts', '--no-audit', '--no-fund', '--offline'],
|
|
140
|
+
stdout=subprocess.DEVNULL)
|
|
141
|
+
|
|
142
|
+
previous = os.umask(0)
|
|
143
|
+
try:
|
|
144
|
+
with patch.object(environment.os, 'geteuid', return_value=0), patch.object(environment.sys, 'argv', ['helper', 'update-package', str(archive)]), patch('builtins.open', mock_open()), patch.object(environment.fcntl, 'flock'), patch.object(environment, 'update', side_effect=stage):
|
|
145
|
+
environment.main()
|
|
146
|
+
for path in [staging, staging / 'node_modules', staging / 'node_modules/@useconvoy', staging / 'node_modules/@useconvoy/cli']:
|
|
147
|
+
self.assertEqual(path.stat().st_mode & 0o022, 0, f'{path} is group/world writable')
|
|
148
|
+
finally:
|
|
149
|
+
os.umask(previous)
|
|
150
|
+
|
|
151
|
+
|
|
96
152
|
class ProcessTests(unittest.TestCase):
|
|
97
153
|
def test_timed_out_installation_kills_its_descendant_before_recovery(self):
|
|
98
154
|
with tempfile.TemporaryDirectory() as directory:
|
|
@@ -118,7 +174,7 @@ class StatusTests(unittest.TestCase):
|
|
|
118
174
|
with tempfile.TemporaryDirectory() as directory:
|
|
119
175
|
journal = Path(directory) / 'update.json'
|
|
120
176
|
journal.write_text('{}')
|
|
121
|
-
with patch.object(environment, 'PACKAGE', Path(directory) / 'missing'), patch.object(environment, 'JOURNAL', journal), patch.object(environment, '
|
|
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:
|
|
122
178
|
environment.main()
|
|
123
179
|
self.assertEqual(json.loads(output.call_args.args[0]), {'serviceVersion': None, 'serviceRunning': False, 'recoveryPending': True, 'runtimes': []})
|
|
124
180
|
|
|
@@ -141,10 +197,19 @@ class StopTests(unittest.TestCase):
|
|
|
141
197
|
|
|
142
198
|
|
|
143
199
|
class FirewallTests(unittest.TestCase):
|
|
200
|
+
def test_open_mode_skips_firewall_on_start_and_registration(self):
|
|
201
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
202
|
+
path = Path(directory) / 'network.json'
|
|
203
|
+
with patch.dict(os.environ, {'DEVCONTAINER_NETWORK_MODE': 'open'}, clear=True), patch.object(environment, 'NETWORK', path), patch.object(environment, 'run') as execute:
|
|
204
|
+
environment.firewall()
|
|
205
|
+
environment.firewall('example.convex.cloud')
|
|
206
|
+
execute.assert_not_called()
|
|
207
|
+
|
|
208
|
+
|
|
144
209
|
def test_project_registration_allows_cloud_and_mcp_site(self):
|
|
145
210
|
with tempfile.TemporaryDirectory() as directory:
|
|
146
211
|
path = Path(directory) / 'network.json'
|
|
147
|
-
with patch.object(environment, 'NETWORK', path), patch.object(environment, 'run') as execute:
|
|
212
|
+
with patch.dict(os.environ, {'DEVCONTAINER_NETWORK_MODE': 'strict'}, clear=True), patch.object(environment, 'NETWORK', path), patch.object(environment, 'run') as execute:
|
|
148
213
|
environment.firewall('example.convex.cloud')
|
|
149
214
|
hosts = execute.call_args.kwargs['env']['DEVCONTAINER_EXTRA_ALLOWED_DOMAINS'].split(',')
|
|
150
215
|
self.assertIn('example.convex.cloud', hosts)
|
|
@@ -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
|
-
|
|
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()
|
|
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.
|
|
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()
|