@pixelbyte-software/pixcode 1.49.4 → 1.49.5

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.
@@ -349,7 +349,6 @@ function buildHermesShellCommand(kind, env) {
349
349
  const configureScript = path.join(APP_ROOT, 'scripts', 'hermes', 'configure-pixcode-mcp.mjs');
350
350
  const isWindows = os.platform() === 'win32';
351
351
  const quote = isWindows ? shellQuotePowerShell : shellQuotePosix;
352
- const configure = `node ${quote(configureScript)}`;
353
352
  if (isWindows) {
354
353
  const setEnv = [
355
354
  `$env:PIXCODE_BASE_URL=${quote(env.PIXCODE_BASE_URL)}`,
@@ -386,10 +385,16 @@ function buildHermesShellCommand(kind, env) {
386
385
  'return $null;',
387
386
  '}',
388
387
  ].join(' ');
388
+ const configure = [
389
+ 'function Invoke-PixcodeHermesConfigure {',
390
+ `& node ${quote(configureScript)};`,
391
+ 'if ($LASTEXITCODE -ne 0) { Write-Warning "Pixcode MCP configure failed; starting Hermes anyway."; $global:LASTEXITCODE = 0; }',
392
+ '}',
393
+ ].join(' ');
389
394
  const installHermesIfMissing = [
390
395
  'function Install-HermesIfMissing {',
391
396
  '$script:HermesCmd = Resolve-HermesCommand;',
392
- 'if ($script:HermesCmd) { Write-Host "Hermes already installed:"; & $script:HermesCmd --version; return; }',
397
+ 'if ($script:HermesCmd) { & $script:HermesCmd --version *> $null; return; }',
393
398
  '$installer = Join-Path $env:TEMP "pixcode-hermes-install.ps1";',
394
399
  'Invoke-WebRequest -Uri "https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.ps1" -UseBasicParsing -OutFile $installer;',
395
400
  '& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $installer -SkipSetup -Branch main;',
@@ -400,9 +405,9 @@ function buildHermesShellCommand(kind, env) {
400
405
  '}',
401
406
  ].join(' ');
402
407
  if (kind === 'pixcode:hermes:install') {
403
- return `${setEnv}; ${resolveHermesCommand}; ${installHermesIfMissing}; Install-HermesIfMissing; ${configure}`;
408
+ return `${setEnv}; ${resolveHermesCommand}; ${configure}; ${installHermesIfMissing}; Install-HermesIfMissing; Invoke-PixcodeHermesConfigure`;
404
409
  }
405
- return `${setEnv}; ${resolveHermesCommand}; ${installHermesIfMissing}; Install-HermesIfMissing; ${configure}; & $script:HermesCmd chat --toolsets "hermes-cli,mcp-pixcode"`;
410
+ return `${setEnv}; ${resolveHermesCommand}; ${configure}; ${installHermesIfMissing}; Install-HermesIfMissing; Invoke-PixcodeHermesConfigure; & $script:HermesCmd`;
406
411
  }
407
412
  const setEnv = [
408
413
  `PIXCODE_BASE_URL=${quote(env.PIXCODE_BASE_URL)}`,
@@ -425,15 +430,15 @@ function buildHermesShellCommand(kind, env) {
425
430
  const installHermesIfMissing = [
426
431
  'installHermesIfMissing() {',
427
432
  'HERMES_CMD="$(resolveHermesCommand 2>/dev/null || true)";',
428
- 'if [ -n "$HERMES_CMD" ]; then echo "Hermes already installed:"; "$HERMES_CMD" --version 2>/dev/null || true; return 0; fi;',
433
+ 'if [ -n "$HERMES_CMD" ]; then "$HERMES_CMD" --version >/dev/null 2>&1 || true; return 0; fi;',
429
434
  'echo "Hermes is not installed. Use Pixcode Settings > Hermes Agent > Install or repair, then start again." >&2;',
430
435
  'exit 127;',
431
436
  '}',
432
437
  ].join(' ');
433
438
  if (kind === 'pixcode:hermes:install') {
434
- return `${setEnv} sh -lc ${quote(`${resolveHermesCommand} ${installHermesIfMissing} installHermesIfMissing && node ${shellQuotePosix(configureScript)}`)}`;
439
+ return `${setEnv} sh -lc ${quote(`${resolveHermesCommand} ${installHermesIfMissing} installHermesIfMissing && { node ${shellQuotePosix(configureScript)} || echo "Pixcode MCP configure failed; continuing."; }`)}`;
435
440
  }
436
- return `${setEnv} sh -lc ${quote(`${resolveHermesCommand} ${installHermesIfMissing} installHermesIfMissing && node ${shellQuotePosix(configureScript)} && "$HERMES_CMD" chat --toolsets "hermes-cli,mcp-pixcode"`)}`;
441
+ return `${setEnv} sh -lc ${quote(`${resolveHermesCommand} ${installHermesIfMissing} installHermesIfMissing && { node ${shellQuotePosix(configureScript)} || echo "Pixcode MCP configure failed; starting Hermes anyway."; } && "$HERMES_CMD"`)}`;
437
442
  }
438
443
  // Single WebSocket server that handles both paths
439
444
  const wss = new WebSocketServer({
@@ -2111,6 +2116,7 @@ function handleShellConnection(ws, request) {
2111
2116
  const provider = data.provider || 'claude';
2112
2117
  let initialCommand = data.initialCommand;
2113
2118
  const hermesCommand = HERMES_SHELL_COMMANDS.has(initialCommand) ? initialCommand : null;
2119
+ const isHermesShellSession = Boolean(hermesCommand);
2114
2120
  if (hermesCommand) {
2115
2121
  const apiKey = getOrCreateHermesApiKey(request?.user?.id);
2116
2122
  if (!apiKey) {
@@ -2143,7 +2149,7 @@ function handleShellConnection(ws, request) {
2143
2149
  initialCommand.includes('auth login'));
2144
2150
  // Include command hash in session key so different commands get separate sessions
2145
2151
  const commandSuffix = isPlainShell && initialCommand
2146
- ? `_cmd_${Buffer.from(initialCommand).toString('base64').slice(0, 16)}`
2152
+ ? (isHermesShellSession ? '_hermes' : `_cmd_${Buffer.from(initialCommand).toString('base64').slice(0, 16)}`)
2147
2153
  : '';
2148
2154
  // Include provider in the key so a fresh "new session" in OpenCode
2149
2155
  // doesn't reattach to a cached Claude PTY for the same project (or
@@ -2386,7 +2392,8 @@ function handleShellConnection(ws, request) {
2386
2392
  projectPath,
2387
2393
  sessionId,
2388
2394
  provider,
2389
- isPlainShell
2395
+ isPlainShell,
2396
+ keepAliveUntilExit: isHermesShellSession,
2390
2397
  });
2391
2398
  // Handle data output
2392
2399
  shellProcess.onData((data) => {
@@ -2498,6 +2505,11 @@ function handleShellConnection(ws, request) {
2498
2505
  if (ptySessionKey) {
2499
2506
  const session = ptySessionsMap.get(ptySessionKey);
2500
2507
  if (session) {
2508
+ if (session.keepAliveUntilExit) {
2509
+ console.log('⏳ PTY session kept alive until process exit:', ptySessionKey);
2510
+ session.ws = null;
2511
+ return;
2512
+ }
2501
2513
  console.log('⏳ PTY session kept alive, will timeout in 30 minutes:', ptySessionKey);
2502
2514
  session.ws = null;
2503
2515
  session.timeoutId = setTimeout(() => {