Skip to content

Commit 5b00f48

Browse files
grichaclaude
andcommitted
Enable host access by default with --no-host-access flag
- Host access is now enabled by default for direct machine access - Add --no-host-access flag to `workspace agent run` and `workspace agent install` - Support WS_NO_HOST_ACCESS=true environment variable for systemd - Update getting started docs with host access information 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8ba266d commit 5b00f48

5 files changed

Lines changed: 54 additions & 16 deletions

File tree

docs/docs/getting-started.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,42 @@ sidebar_position: 3
77
## Start Agent
88

99
```bash
10-
ws agent start
10+
workspace agent run
1111
```
1212

1313
Web UI: `http://localhost:7391`
1414

1515
Options:
1616
```bash
17-
ws agent start --port 3000 # Custom port
18-
ws agent start --host 0.0.0.0 # Remote access
17+
workspace agent run --port 3000 # Custom port
18+
workspace agent run --no-host-access # Disable direct host machine access
19+
```
20+
21+
## Host Access
22+
23+
By default, the agent enables direct access to your host machine. This allows running terminals and AI coding agents directly on your machine without Docker isolation.
24+
25+
To disable host access (workspaces-only mode):
26+
```bash
27+
workspace agent run --no-host-access
28+
```
29+
30+
Or via environment variable:
31+
```bash
32+
WS_NO_HOST_ACCESS=true workspace agent run
33+
```
34+
35+
For systemd service installation:
36+
```bash
37+
workspace agent install --no-host-access
1938
```
2039

2140
## Create Workspace
2241

2342
CLI:
2443
```bash
25-
ws create myproject
26-
ws create myproject --clone git@github.com:user/repo.git
44+
workspace create myproject
45+
workspace create myproject --clone git@github.com:user/repo.git
2746
```
2847

2948
Web UI:
@@ -36,7 +55,7 @@ Web UI:
3655

3756
SSH:
3857
```bash
39-
ws list # Find port
58+
workspace list # Find port
4059
ssh -p 2201 workspace@localhost
4160
```
4261

@@ -45,10 +64,9 @@ Web Terminal: Click workspace → Terminal
4564
## Commands
4665

4766
```bash
48-
ws list # List all
49-
ws start <name> # Start
50-
ws stop <name> # Stop
51-
ws delete <name> # Delete
52-
ws logs <name> # Logs
53-
ws agent stop # Stop agent
67+
workspace list # List all
68+
workspace start <name> # Start
69+
workspace stop <name> # Stop
70+
workspace delete <name> # Delete
71+
workspace logs <name> # Logs
5472
```

src/agent/run.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ function createAgentServer(configDir: string, config: AgentConfig) {
130130
export interface StartAgentOptions {
131131
port?: number;
132132
configDir?: string;
133+
noHostAccess?: boolean;
133134
}
134135

135136
async function getProcessUsingPort(port: number): Promise<string | null> {
@@ -159,6 +160,11 @@ export async function startAgent(options: StartAgentOptions = {}): Promise<void>
159160
await ensureConfigDir(configDir);
160161

161162
const config = await loadAgentConfig(configDir);
163+
164+
if (options.noHostAccess || process.env.WS_NO_HOST_ACCESS === 'true') {
165+
config.allowHostAccess = false;
166+
}
167+
162168
const port =
163169
options.port || parseInt(process.env.WS_PORT || '', 10) || config.port || DEFAULT_AGENT_PORT;
164170

src/agent/systemd.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function getServicePath(): string {
1919
interface InstallOptions {
2020
port?: number;
2121
configDir?: string;
22+
noHostAccess?: boolean;
2223
}
2324

2425
export function generateServiceFile(options: InstallOptions = {}): string {
@@ -28,6 +29,16 @@ export function generateServiceFile(options: InstallOptions = {}): string {
2829
const nodePath = process.execPath;
2930
const agentPath = path.resolve(__dirname, 'index.js');
3031

32+
const envLines = [
33+
`Environment=WS_PORT=${port}`,
34+
`Environment=WS_CONFIG_DIR=${configDir}`,
35+
`Environment=NODE_ENV=production`,
36+
];
37+
38+
if (options.noHostAccess) {
39+
envLines.push(`Environment=WS_NO_HOST_ACCESS=true`);
40+
}
41+
3142
return `[Unit]
3243
Description=${SERVICE_DESCRIPTION}
3344
After=network.target docker.service
@@ -38,9 +49,7 @@ Type=simple
3849
ExecStart=${nodePath} ${agentPath}
3950
Restart=on-failure
4051
RestartSec=5
41-
Environment=WS_PORT=${port}
42-
Environment=WS_CONFIG_DIR=${configDir}
43-
Environment=NODE_ENV=production
52+
${envLines.join('\n')}
4453
4554
[Install]
4655
WantedBy=default.target

src/config/loader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export function createDefaultAgentConfig(): AgentConfig {
2121
},
2222
scripts: {},
2323
agents: {},
24+
allowHostAccess: true,
2425
};
2526
}
2627

@@ -39,7 +40,7 @@ export async function loadAgentConfig(configDir?: string): Promise<AgentConfig>
3940
},
4041
scripts: config.scripts || {},
4142
agents: config.agents || {},
42-
allowHostAccess: config.allowHostAccess || false,
43+
allowHostAccess: config.allowHostAccess ?? true,
4344
};
4445
} catch (err: unknown) {
4546
if ((err as NodeJS.ErrnoException).code === 'ENOENT') {

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ agentCmd
3131
.description('Start the agent daemon')
3232
.option('-p, --port <port>', 'Port to listen on', parseInt)
3333
.option('-c, --config-dir <dir>', 'Configuration directory')
34+
.option('--no-host-access', 'Disable direct host machine access')
3435
.action(async (options) => {
3536
await startAgent({
3637
port: options.port,
3738
configDir: options.configDir,
39+
noHostAccess: options.hostAccess === false,
3840
});
3941
});
4042

@@ -43,10 +45,12 @@ agentCmd
4345
.description('Install agent as systemd user service')
4446
.option('-p, --port <port>', 'Port to listen on', parseInt)
4547
.option('-c, --config-dir <dir>', 'Configuration directory')
48+
.option('--no-host-access', 'Disable direct host machine access')
4649
.action(async (options) => {
4750
await installService({
4851
port: options.port,
4952
configDir: options.configDir,
53+
noHostAccess: options.hostAccess === false,
5054
});
5155
});
5256

0 commit comments

Comments
 (0)