@siftd/connect-agent 0.2.35 → 0.2.36

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.
@@ -162,18 +162,33 @@ Include: job_id=${jobId}, timestamp, summary of work done, files modified, key f
162
162
  This ensures nothing is lost even if your output gets truncated.`;
163
163
  // Escape single quotes in task for shell safety
164
164
  const escapedTask = enhancedTask.replace(/'/g, "'\\''");
165
+ // Build the claude command
166
+ const claudeCmd = `claude -p '${escapedTask}' --output-format text --dangerously-skip-permissions`;
167
+ // If running as root, run workers as 'lia' user to avoid --dangerously-skip-permissions being blocked
168
+ // The Claude CLI blocks this flag for root users as a security measure
169
+ const isRoot = process.getuid?.() === 0;
170
+ let shellCmd;
171
+ let spawnEnv = {
172
+ ...process.env,
173
+ ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY,
174
+ GH_TOKEN: process.env.GH_TOKEN,
175
+ GITHUB_TOKEN: process.env.GITHUB_TOKEN
176
+ };
177
+ if (isRoot) {
178
+ // When running as root, use runuser to switch to 'lia' user while preserving env
179
+ // runuser -l creates a login shell but -m preserves the environment
180
+ shellCmd = `runuser -u lia -- /bin/bash -l -c "${claudeCmd.replace(/"/g, '\\"')}"`;
181
+ }
182
+ else {
183
+ shellCmd = claudeCmd;
184
+ }
165
185
  // Spawn using /bin/bash -l -c to ensure proper PATH resolution (NVM, etc.)
166
186
  // Use absolute path to bash to avoid ENOENT errors in restricted environments
167
- const child = spawn('/bin/bash', ['-l', '-c', `claude -p '${escapedTask}' --output-format text --dangerously-skip-permissions`], {
187
+ const child = spawn('/bin/bash', ['-l', '-c', shellCmd], {
168
188
  cwd: workspace,
169
189
  detached: true,
170
190
  stdio: ['ignore', 'pipe', 'pipe'],
171
- env: {
172
- ...process.env,
173
- ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY,
174
- GH_TOKEN: process.env.GH_TOKEN,
175
- GITHUB_TOKEN: process.env.GITHUB_TOKEN
176
- }
191
+ env: spawnEnv
177
192
  });
178
193
  job.status = 'running';
179
194
  job.started = new Date().toISOString();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siftd/connect-agent",
3
- "version": "0.2.35",
3
+ "version": "0.2.36",
4
4
  "description": "Master orchestrator agent - control Claude Code remotely via web",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",