@yeaft/webchat-agent 0.0.9 → 0.0.10

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 (2) hide show
  1. package/package.json +1 -1
  2. package/service.js +11 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/service.js CHANGED
@@ -395,12 +395,13 @@ function winInstall(config) {
395
395
  // Create a batch file that sets env vars and starts node (with log redirection)
396
396
  mkdirSync(logDir, { recursive: true });
397
397
  const logFile = join(logDir, 'out.log');
398
- const batContent = `@echo off\r\n${envLines.join('\r\n')}\r\n"${nodePath}" "${cliPath}" >> "${logFile}" 2>&1\r\n`;
398
+ const cliDir = dirname(cliPath);
399
+ const batContent = `@echo off\r\ncd /d "${cliDir}"\r\n${envLines.join('\r\n')}\r\n"${nodePath}" "${cliPath}" >> "${logFile}" 2>&1\r\n`;
399
400
  const batPath = getWinBatPath();
400
401
  writeFileSync(batPath, batContent);
401
402
 
402
403
  // Create VBS wrapper to run hidden (no console window)
403
- const vbsContent = `Set WshShell = CreateObject("WScript.Shell")\r\nWshShell.Run """${batPath}""", 0, False\r\n`;
404
+ const vbsContent = `Set WshShell = CreateObject("WScript.Shell")\r\nWshShell.CurrentDirectory = "${cliDir}"\r\nWshShell.Run """${batPath}""", 0, False\r\n`;
404
405
  const vbsPath = getWinWrapperPath();
405
406
  writeFileSync(vbsPath, vbsContent);
406
407
 
@@ -439,6 +440,11 @@ function winInstall(config) {
439
440
  }
440
441
 
441
442
  console.log('Service installed and started.');
443
+ console.log(` Bat: ${batPath}`);
444
+ console.log(` VBS: ${vbsPath}`);
445
+ console.log(` Log: ${logFile}`);
446
+ console.log(` Node: ${nodePath}`);
447
+ console.log(` CLI: ${cliPath}`);
442
448
  console.log(`\nManage with:`);
443
449
  console.log(` yeaft-agent status`);
444
450
  console.log(` yeaft-agent logs`);
@@ -478,13 +484,14 @@ function winStart() {
478
484
  }
479
485
 
480
486
  function winStop() {
481
- // Find and kill the node process running cli.js
487
+ // Find and kill the node process running our cli.js
482
488
  try {
483
489
  const output = execSync('wmic process where "name=\'node.exe\'" get processid,commandline /format:csv', {
484
490
  encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe']
485
491
  });
492
+ const cliPath = getCliPath();
486
493
  for (const line of output.split('\n')) {
487
- if (line.includes('cli.js') && line.includes(SERVICE_NAME)) {
494
+ if (line.includes('cli.js') && (line.includes(SERVICE_NAME) || line.includes('webchat-agent'))) {
488
495
  const pid = line.trim().split(',').pop();
489
496
  if (pid && /^\d+$/.test(pid)) {
490
497
  execSync(`taskkill /pid ${pid} /f`, { stdio: 'pipe' });