viben 1.1.9 → 1.2.0

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/dist/index.cjs CHANGED
@@ -2168,7 +2168,7 @@ __export(index_exports, {
2168
2168
  module.exports = __toCommonJS(index_exports);
2169
2169
 
2170
2170
  // ../../packages/core/dist/index.js
2171
- var os2 = __toESM(require("os"), 1);
2171
+ var os3 = __toESM(require("os"), 1);
2172
2172
  var import_os = __toESM(require("os"), 1);
2173
2173
  var path21 = __toESM(require("path"), 1);
2174
2174
  var import_path = __toESM(require("path"), 1);
@@ -12241,7 +12241,7 @@ function cleanOldTelemetryFiles(baseDir, retentionDays = 7) {
12241
12241
  }
12242
12242
  }
12243
12243
  function getDefaultTelemetryDir() {
12244
- const stateDir = process.env.VIBEN_STATE_DIR || path21.join(process.env.HOME || "~", ".viben");
12244
+ const stateDir = process.env.VIBEN_STATE_DIR || path21.join(os3.homedir(), ".viben");
12245
12245
  return path21.join(stateDir, "telemetry");
12246
12246
  }
12247
12247
  var init_telemetry = __esm({
@@ -24078,14 +24078,14 @@ var require_is_docker = __commonJS2({
24078
24078
  });
24079
24079
  var require_is_wsl = __commonJS2({
24080
24080
  "../../node_modules/.pnpm/is-wsl@2.2.0/node_modules/is-wsl/index.js"(exports2, module2) {
24081
- var os4 = __require("os");
24081
+ var os5 = __require("os");
24082
24082
  var fs23 = __require("fs");
24083
24083
  var isDocker = require_is_docker();
24084
24084
  var isWsl = () => {
24085
24085
  if (process.platform !== "linux") {
24086
24086
  return false;
24087
24087
  }
24088
- if (os4.release().toLowerCase().includes("microsoft")) {
24088
+ if (os5.release().toLowerCase().includes("microsoft")) {
24089
24089
  if (isDocker()) {
24090
24090
  return false;
24091
24091
  }
@@ -24112,7 +24112,7 @@ var require_utils2 = __commonJS2({
24112
24112
  var isWSL = require_is_wsl();
24113
24113
  var path24 = __require("path");
24114
24114
  var url2 = __require("url");
24115
- var os4 = __require("os");
24115
+ var os5 = __require("os");
24116
24116
  var fs23 = __require("fs");
24117
24117
  var net2 = __require("net");
24118
24118
  var BUFFER_SIZE = 1024;
@@ -24498,19 +24498,19 @@ var require_utils2 = __commonJS2({
24498
24498
  return options;
24499
24499
  };
24500
24500
  module2.exports.isMac = function() {
24501
- return os4.type() === "Darwin";
24501
+ return os5.type() === "Darwin";
24502
24502
  };
24503
24503
  module2.exports.isMountainLion = function() {
24504
- return os4.type() === "Darwin" && semver.satisfies(garanteeSemverFormat(os4.release()), ">=12.0.0");
24504
+ return os5.type() === "Darwin" && semver.satisfies(garanteeSemverFormat(os5.release()), ">=12.0.0");
24505
24505
  };
24506
24506
  module2.exports.isWin8 = function() {
24507
- return os4.type() === "Windows_NT" && semver.satisfies(garanteeSemverFormat(os4.release()), ">=6.2.9200");
24507
+ return os5.type() === "Windows_NT" && semver.satisfies(garanteeSemverFormat(os5.release()), ">=6.2.9200");
24508
24508
  };
24509
24509
  module2.exports.isWSL = function() {
24510
24510
  return isWSL;
24511
24511
  };
24512
24512
  module2.exports.isLessThanWin8 = function() {
24513
- return os4.type() === "Windows_NT" && semver.satisfies(garanteeSemverFormat(os4.release()), "<6.2.9200");
24513
+ return os5.type() === "Windows_NT" && semver.satisfies(garanteeSemverFormat(os5.release()), "<6.2.9200");
24514
24514
  };
24515
24515
  function garanteeSemverFormat(version2) {
24516
24516
  if (version2.split(".").length === 2) {
@@ -24762,7 +24762,7 @@ var require_which = __commonJS2({
24762
24762
  });
24763
24763
  var require_notifysend = __commonJS2({
24764
24764
  "../../node_modules/.pnpm/node-notifier@10.0.1/node_modules/node-notifier/notifiers/notifysend.js"(exports2, module2) {
24765
- var os4 = __require("os");
24765
+ var os5 = __require("os");
24766
24766
  var which3 = require_which();
24767
24767
  var utils = require_utils2();
24768
24768
  var EventEmitter14 = __require("events").EventEmitter;
@@ -24796,7 +24796,7 @@ var require_notifysend = __commonJS2({
24796
24796
  callback(new Error("Message is required."));
24797
24797
  return this;
24798
24798
  }
24799
- if (os4.type() !== "Linux" && !os4.type().match(/BSD$/)) {
24799
+ if (os5.type() !== "Linux" && !os5.type().match(/BSD$/)) {
24800
24800
  callback(new Error("Only supported on Linux and *BSD systems"));
24801
24801
  return this;
24802
24802
  }
@@ -25214,7 +25214,7 @@ var require_balloon = __commonJS2({
25214
25214
  var utils = require_utils2();
25215
25215
  var Toaster = require_toaster();
25216
25216
  var Growl = require_growl();
25217
- var os4 = __require("os");
25217
+ var os5 = __require("os");
25218
25218
  var EventEmitter14 = __require("events").EventEmitter;
25219
25219
  var util3 = __require("util");
25220
25220
  var hasGrowl;
@@ -25282,7 +25282,7 @@ var require_balloon = __commonJS2({
25282
25282
  });
25283
25283
  var allowedArguments = ["t", "d", "p", "m", "i", "e", "q", "w", "xp"];
25284
25284
  function doNotification(options, notifierOptions, callback) {
25285
- const is64Bit = os4.arch() === "x64";
25285
+ const is64Bit = os5.arch() === "x64";
25286
25286
  options = options || {};
25287
25287
  options = utils.mapToNotifu(options);
25288
25288
  options.p = options.p || "Node Notification:";
@@ -25638,7 +25638,7 @@ var require_toaster = __commonJS2({
25638
25638
  var notifier = path24.resolve(__dirname, "../vendor/snoreToast/snoretoast");
25639
25639
  var utils = require_utils2();
25640
25640
  var Balloon = require_balloon();
25641
- var os4 = __require("os");
25641
+ var os5 = __require("os");
25642
25642
  var { v4: uuid } = (init_esm_node(), __toCommonJS2(esm_node_exports));
25643
25643
  var EventEmitter14 = __require("events").EventEmitter;
25644
25644
  var util3 = __require("util");
@@ -25677,7 +25677,7 @@ var require_toaster = __commonJS2({
25677
25677
  function notifyRaw(options, callback) {
25678
25678
  options = utils.clone(options || {});
25679
25679
  callback = callback || noop2;
25680
- const is64Bit = os4.arch() === "x64";
25680
+ const is64Bit = os5.arch() === "x64";
25681
25681
  let resultBuffer;
25682
25682
  const server = {
25683
25683
  namedPipe: getPipeName()
@@ -25752,7 +25752,7 @@ var require_toaster = __commonJS2({
25752
25752
  });
25753
25753
  var require_node_notifier = __commonJS2({
25754
25754
  "../../node_modules/.pnpm/node-notifier@10.0.1/node_modules/node-notifier/index.js"(exports2, module2) {
25755
- var os4 = __require("os");
25755
+ var os5 = __require("os");
25756
25756
  var utils = require_utils2();
25757
25757
  var NotifySend = require_notifysend();
25758
25758
  var NotificationCenter = require_notificationcenter();
@@ -25760,7 +25760,7 @@ var require_node_notifier = __commonJS2({
25760
25760
  var Growl = require_growl();
25761
25761
  var WindowsBalloon = require_balloon();
25762
25762
  var options = { withFallback: true };
25763
- var osType = utils.isWSL() ? "WSL" : os4.type();
25763
+ var osType = utils.isWSL() ? "WSL" : os5.type();
25764
25764
  switch (osType) {
25765
25765
  case "Linux":
25766
25766
  module2.exports = new NotifySend(options);
@@ -25784,7 +25784,7 @@ var require_node_notifier = __commonJS2({
25784
25784
  module2.exports.Notification = WindowsToaster;
25785
25785
  break;
25786
25786
  default:
25787
- if (os4.type().match(/BSD$/)) {
25787
+ if (os5.type().match(/BSD$/)) {
25788
25788
  module2.exports = new NotifySend(options);
25789
25789
  module2.exports.Notification = NotifySend;
25790
25790
  } else {
@@ -38953,7 +38953,7 @@ var require_has_flag = __commonJS2({
38953
38953
  });
38954
38954
  var require_supports_color = __commonJS2({
38955
38955
  "../../node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js"(exports2, module2) {
38956
- var os4 = __require("os");
38956
+ var os5 = __require("os");
38957
38957
  var tty = __require("tty");
38958
38958
  var hasFlag = require_has_flag();
38959
38959
  var { env } = process;
@@ -39010,7 +39010,7 @@ var require_supports_color = __commonJS2({
39010
39010
  return min;
39011
39011
  }
39012
39012
  if (process.platform === "win32") {
39013
- const osRelease = os4.release().split(".");
39013
+ const osRelease = os5.release().split(".");
39014
39014
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
39015
39015
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
39016
39016
  }
@@ -132529,9 +132529,9 @@ var init_session_store = __esm({
132529
132529
  }
132530
132530
  });
132531
132531
  async function sendNotification(options) {
132532
- const os4 = (0, import_os.platform)();
132532
+ const os5 = (0, import_os.platform)();
132533
132533
  try {
132534
- switch (os4) {
132534
+ switch (os5) {
132535
132535
  case "darwin":
132536
132536
  return await sendMacOSNotification(options);
132537
132537
  case "linux":
@@ -132539,7 +132539,7 @@ async function sendNotification(options) {
132539
132539
  case "win32":
132540
132540
  return await sendWindowsNotification(options);
132541
132541
  default:
132542
- console.warn(`[Notifications] Unsupported platform: ${os4}`);
132542
+ console.warn(`[Notifications] Unsupported platform: ${os5}`);
132543
132543
  return false;
132544
132544
  }
132545
132545
  } catch (error) {
@@ -135477,7 +135477,7 @@ async function getCodexPath() {
135477
135477
  // Local node_modules
135478
135478
  "./node_modules/.bin/codex",
135479
135479
  // User's npm bin
135480
- `${process.env.HOME}/.npm-global/bin/codex`,
135480
+ `${(0, import_os.homedir)()}/.npm-global/bin/codex`,
135481
135481
  // Homebrew on macOS
135482
135482
  "/opt/homebrew/bin/codex",
135483
135483
  "/usr/local/bin/codex"
@@ -135575,8 +135575,8 @@ Error: ${err.message}`,
135575
135575
  provider: { type: "codex", name: this.name }
135576
135576
  };
135577
135577
  }
135578
- const os4 = (0, import_os.platform)();
135579
- const sandboxSubcommand = os4 === "darwin" ? "macos" : "linux";
135578
+ const os5 = (0, import_os.platform)();
135579
+ const sandboxSubcommand = os5 === "darwin" ? "macos" : "linux";
135580
135580
  const spawnArgs = [
135581
135581
  "sandbox",
135582
135582
  sandboxSubcommand,
@@ -135645,7 +135645,7 @@ async function getSrtPath() {
135645
135645
  // Local node_modules
135646
135646
  "./node_modules/.bin/srt",
135647
135647
  // User's npm bin
135648
- `${process.env.HOME}/.npm-global/bin/srt`,
135648
+ `${(0, import_os.homedir)()}/.npm-global/bin/srt`,
135649
135649
  // Homebrew on macOS
135650
135650
  "/opt/homebrew/bin/srt",
135651
135651
  "/usr/local/bin/srt"
@@ -137276,8 +137276,7 @@ var init_mcp_monitor = __esm({
137276
137276
  }
137277
137277
  });
137278
137278
  function getMcpServersConfigPath() {
137279
- const homedir30 = process.env.HOME || process.env.USERPROFILE || "";
137280
- return path21.join(homedir30, ".viben", "mcp-servers.json");
137279
+ return path21.join((0, import_os.homedir)(), ".viben", "mcp-servers.json");
137281
137280
  }
137282
137281
  var log15;
137283
137282
  var ConfigWatcherService;
@@ -148707,7 +148706,7 @@ var startupConfig;
148707
148706
  var gatewayStartTime;
148708
148707
  var init_health = __esm({
148709
148708
  "src/gateway/routes/health.ts"() {
148710
- VERSION3 = "1.1.9";
148709
+ VERSION3 = "1.2.0";
148711
148710
  startupConfig = null;
148712
148711
  gatewayStartTime = Date.now();
148713
148712
  }
@@ -148716,7 +148715,7 @@ function encodeWorkspacePath(workspacePath) {
148716
148715
  return workspacePath.replace(/\//g, "-");
148717
148716
  }
148718
148717
  function getClaudeProjectsDir() {
148719
- return path21.join(os2.homedir(), ".claude", "projects");
148718
+ return path21.join(os3.homedir(), ".claude", "projects");
148720
148719
  }
148721
148720
  async function discoverClaudeCodeSessions(workspacePath) {
148722
148721
  const projectsDir = getClaudeProjectsDir();
@@ -148904,11 +148903,11 @@ function convertClaudeMessageToUI(msg) {
148904
148903
  }
148905
148904
  function getCodexSessionsDir() {
148906
148905
  if (process.platform === "darwin") {
148907
- return path21.join(os2.homedir(), "Library", "Application Support", "codex", "sessions");
148906
+ return path21.join(os3.homedir(), "Library", "Application Support", "codex", "sessions");
148908
148907
  } else if (process.platform === "win32") {
148909
148908
  return path21.join(process.env.APPDATA || "", "codex", "sessions");
148910
148909
  } else {
148911
- return path21.join(os2.homedir(), ".config", "codex", "sessions");
148910
+ return path21.join(os3.homedir(), ".config", "codex", "sessions");
148912
148911
  }
148913
148912
  }
148914
148913
  async function discoverCodexSessions(workspacePath) {
@@ -148999,10 +148998,10 @@ function convertCodexMessageToUI(msg) {
148999
148998
  }
149000
148999
  }
149001
149000
  function getExecutorConfigPaths(type2, workspacePath) {
149002
- const homedir30 = os2.homedir();
149001
+ const homedir34 = os3.homedir();
149003
149002
  switch (type2) {
149004
149003
  case "CLAUDE_CODE": {
149005
- const globalConfigDir = path21.join(homedir30, ".claude");
149004
+ const globalConfigDir = path21.join(homedir34, ".claude");
149006
149005
  const workspaceConfigDir = workspacePath ? path21.join(workspacePath, ".claude") : void 0;
149007
149006
  return {
149008
149007
  globalConfigPath: fs20.existsSync(globalConfigDir) ? globalConfigDir : void 0,
@@ -149014,11 +149013,11 @@ function getExecutorConfigPaths(type2, workspacePath) {
149014
149013
  case "CODEX": {
149015
149014
  let configDir;
149016
149015
  if (process.platform === "darwin") {
149017
- configDir = path21.join(homedir30, "Library", "Application Support", "codex");
149016
+ configDir = path21.join(homedir34, "Library", "Application Support", "codex");
149018
149017
  } else if (process.platform === "win32") {
149019
149018
  configDir = path21.join(process.env.APPDATA || "", "codex");
149020
149019
  } else {
149021
- configDir = path21.join(homedir30, ".config", "codex");
149020
+ configDir = path21.join(homedir34, ".config", "codex");
149022
149021
  }
149023
149022
  const workspaceConfigDir = workspacePath ? path21.join(workspacePath, ".codex") : void 0;
149024
149023
  return {
@@ -149031,11 +149030,11 @@ function getExecutorConfigPaths(type2, workspacePath) {
149031
149030
  case "CURSOR_AGENT": {
149032
149031
  let configDir;
149033
149032
  if (process.platform === "darwin") {
149034
- configDir = path21.join(homedir30, "Library", "Application Support", "Cursor", "User");
149033
+ configDir = path21.join(homedir34, "Library", "Application Support", "Cursor", "User");
149035
149034
  } else if (process.platform === "win32") {
149036
149035
  configDir = path21.join(process.env.APPDATA || "", "Cursor", "User");
149037
149036
  } else {
149038
- configDir = path21.join(homedir30, ".config", "Cursor", "User");
149037
+ configDir = path21.join(homedir34, ".config", "Cursor", "User");
149039
149038
  }
149040
149039
  const workspaceConfigDir = workspacePath ? path21.join(workspacePath, ".cursor") : void 0;
149041
149040
  return {
@@ -149046,7 +149045,7 @@ function getExecutorConfigPaths(type2, workspacePath) {
149046
149045
  };
149047
149046
  }
149048
149047
  case "GEMINI": {
149049
- const globalConfigDir = path21.join(homedir30, ".gemini");
149048
+ const globalConfigDir = path21.join(homedir34, ".gemini");
149050
149049
  const workspaceConfigDir = workspacePath ? path21.join(workspacePath, ".gemini") : void 0;
149051
149050
  return {
149052
149051
  globalConfigPath: fs20.existsSync(globalConfigDir) ? globalConfigDir : void 0,
@@ -149058,11 +149057,11 @@ function getExecutorConfigPaths(type2, workspacePath) {
149058
149057
  case "AMP": {
149059
149058
  let configDir;
149060
149059
  if (process.platform === "darwin") {
149061
- configDir = path21.join(homedir30, "Library", "Application Support", "amp");
149060
+ configDir = path21.join(homedir34, "Library", "Application Support", "amp");
149062
149061
  } else if (process.platform === "win32") {
149063
149062
  configDir = path21.join(process.env.APPDATA || "", "amp");
149064
149063
  } else {
149065
- configDir = path21.join(homedir30, ".config", "amp");
149064
+ configDir = path21.join(homedir34, ".config", "amp");
149066
149065
  }
149067
149066
  const workspaceConfigDir = workspacePath ? path21.join(workspacePath, ".amp") : void 0;
149068
149067
  return {
@@ -149073,7 +149072,7 @@ function getExecutorConfigPaths(type2, workspacePath) {
149073
149072
  };
149074
149073
  }
149075
149074
  case "OPENCLAW": {
149076
- const globalConfigDir = path21.join(homedir30, ".openclaw");
149075
+ const globalConfigDir = path21.join(homedir34, ".openclaw");
149077
149076
  const globalConfigFile = path21.join(globalConfigDir, "openclaw.json");
149078
149077
  const workspaceConfigDir = workspacePath ? path21.join(workspacePath, ".openclaw") : void 0;
149079
149078
  return {
@@ -149084,7 +149083,7 @@ function getExecutorConfigPaths(type2, workspacePath) {
149084
149083
  };
149085
149084
  }
149086
149085
  default: {
149087
- const globalConfigDir = path21.join(homedir30, ".viben");
149086
+ const globalConfigDir = path21.join(homedir34, ".viben");
149088
149087
  const workspaceConfigDir = workspacePath ? path21.join(workspacePath, ".viben") : void 0;
149089
149088
  return {
149090
149089
  globalConfigPath: fs20.existsSync(globalConfigDir) ? globalConfigDir : void 0,
@@ -149163,7 +149162,7 @@ function checkExecutorAvailability(type2, workspacePath) {
149163
149162
  supports_mcp: supportsMcp,
149164
149163
  capabilities,
149165
149164
  has_workspace_config: hasWorkspaceConfig,
149166
- workspace_path: workspacePath || os2.homedir()
149165
+ workspace_path: workspacePath || os3.homedir()
149167
149166
  };
149168
149167
  }
149169
149168
  function discoverExecutors(workspacePath) {
@@ -149229,7 +149228,7 @@ function registerExecutorRoutes(fastify2) {
149229
149228
  const executors = discoverExecutors(workspacePath);
149230
149229
  return {
149231
149230
  executors,
149232
- workspace_path: workspacePath || os2.homedir(),
149231
+ workspace_path: workspacePath || os3.homedir(),
149233
149232
  include_global: includeGlobal,
149234
149233
  total: executors.length
149235
149234
  };
@@ -149288,12 +149287,12 @@ function registerExecutorRoutes(fastify2) {
149288
149287
  return { messages, total: messages.length };
149289
149288
  });
149290
149289
  function getMcpConfigPath(workspacePath, executorType) {
149291
- const base = workspacePath || os2.homedir();
149290
+ const base = workspacePath || os3.homedir();
149292
149291
  switch (executorType) {
149293
149292
  case "CLAUDE_CODE":
149294
149293
  const projectMcp = path21.join(base, ".mcp.json");
149295
149294
  if (fs20.existsSync(projectMcp)) return projectMcp;
149296
- return path21.join(os2.homedir(), ".claude.json");
149295
+ return path21.join(os3.homedir(), ".claude.json");
149297
149296
  case "CURSOR_AGENT":
149298
149297
  return path21.join(base, ".cursor", "mcp.json");
149299
149298
  default:
@@ -149340,7 +149339,7 @@ function registerExecutorRoutes(fastify2) {
149340
149339
  return { servers, total: servers.length };
149341
149340
  });
149342
149341
  function getSkillsConfigPath(workspacePath, executorType) {
149343
- const base = workspacePath || os2.homedir();
149342
+ const base = workspacePath || os3.homedir();
149344
149343
  switch (executorType) {
149345
149344
  case "CLAUDE_CODE":
149346
149345
  return {
@@ -149436,7 +149435,7 @@ function registerExecutorRoutes(fastify2) {
149436
149435
  return { skills, total: skills.length };
149437
149436
  });
149438
149437
  function getSubagentsPath(workspacePath, executorType) {
149439
- const base = workspacePath || os2.homedir();
149438
+ const base = workspacePath || os3.homedir();
149440
149439
  switch (executorType) {
149441
149440
  case "CLAUDE_CODE":
149442
149441
  return path21.join(base, ".claude", "agents");
@@ -149527,7 +149526,7 @@ function registerExecutorRoutes(fastify2) {
149527
149526
  }
149528
149527
  });
149529
149528
  function getCommandsPath(workspacePath, executorType) {
149530
- const base = workspacePath || os2.homedir();
149529
+ const base = workspacePath || os3.homedir();
149531
149530
  switch (executorType) {
149532
149531
  case "CLAUDE_CODE":
149533
149532
  return path21.join(base, ".claude", "commands");
@@ -149634,7 +149633,7 @@ function registerExecutorRoutes(fastify2) {
149634
149633
  }
149635
149634
  });
149636
149635
  function getPromptsPath(workspacePath, executorType) {
149637
- const base = workspacePath || os2.homedir();
149636
+ const base = workspacePath || os3.homedir();
149638
149637
  switch (executorType) {
149639
149638
  case "CLAUDE_CODE":
149640
149639
  return path21.join(base, ".claude", "prompts");
@@ -150035,7 +150034,7 @@ function registerAgentRoutes(fastify2, state) {
150035
150034
  }, async (request) => {
150036
150035
  const { workspace_path, include_global } = request.query;
150037
150036
  const includeGlobal = include_global !== "false";
150038
- const homeDir = process.env.HOME || "/";
150037
+ const homeDir = (0, import_os.homedir)();
150039
150038
  const transformAgent = (a, sourceOverride, workspacePathOverride) => {
150040
150039
  if (!a) return null;
150041
150040
  const source = sourceOverride || (a.path && a.path.startsWith(homeDir) && a.path.includes("/.viben/agents/") ? "global" : "workspace");
@@ -150113,7 +150112,7 @@ function registerAgentRoutes(fastify2, state) {
150113
150112
  approvals: body.approvals
150114
150113
  });
150115
150114
  reply.code(201);
150116
- const homeDir = process.env.HOME || "/";
150115
+ const homeDir = (0, import_os.homedir)();
150117
150116
  const isGlobalAgent = agent.path && agent.path.startsWith(homeDir) && agent.path.includes("/.viben/agents/");
150118
150117
  const agentSource = isGlobalAgent ? "global" : "workspace";
150119
150118
  const agentWorkspacePath = !isGlobalAgent && agent.path ? agent.path.replace(/\/.viben\/agents\/[^/]+$/, "") : void 0;
@@ -150237,7 +150236,7 @@ function registerAgentRoutes(fastify2, state) {
150237
150236
  try {
150238
150237
  const agent = await agentManager.createFromTemplate(id, agent_id, { name, base_path }, template_workspace_path);
150239
150238
  reply.code(201);
150240
- const homeDir = process.env.HOME || "/";
150239
+ const homeDir = (0, import_os.homedir)();
150241
150240
  const isGlobalAgent = agent.path && agent.path.startsWith(homeDir) && agent.path.includes("/.viben/agents/");
150242
150241
  const agentSource = isGlobalAgent ? "global" : "workspace";
150243
150242
  const agentWorkspacePath = !isGlobalAgent && agent.path ? agent.path.replace(/\/.viben\/agents\/[^/]+$/, "") : void 0;
@@ -150488,7 +150487,7 @@ function registerAgentRoutes(fastify2, state) {
150488
150487
  "/api/agent/:id/availability",
150489
150488
  async (request, reply) => {
150490
150489
  const { id } = request.params;
150491
- const homeDir = process.env.HOME || "/";
150490
+ const homeDir = (0, import_os.homedir)();
150492
150491
  const executorTypes = [
150493
150492
  "CLAUDE_CODE",
150494
150493
  "CODEX",
@@ -150644,7 +150643,7 @@ function registerAgentRoutes(fastify2, state) {
150644
150643
  fastify2.get("/api/agent/:id", async (request, reply) => {
150645
150644
  const { id } = request.params;
150646
150645
  const { workspace_path } = request.query;
150647
- const homeDir = process.env.HOME || "/";
150646
+ const homeDir = (0, import_os.homedir)();
150648
150647
  let agent = null;
150649
150648
  let source = "global";
150650
150649
  if (workspace_path) {
@@ -150714,7 +150713,7 @@ function registerAgentRoutes(fastify2, state) {
150714
150713
  };
150715
150714
  try {
150716
150715
  const agent = await agentManager.updateAgent(id, updates, workspace_path);
150717
- const homeDir = process.env.HOME || "/";
150716
+ const homeDir = (0, import_os.homedir)();
150718
150717
  const isGlobalAgent = agent.path && agent.path.startsWith(homeDir) && agent.path.includes("/.viben/agents/");
150719
150718
  const agentSource = isGlobalAgent ? "global" : "workspace";
150720
150719
  const agentWorkspacePath = !isGlobalAgent && agent.path ? agent.path.replace(/\/.viben\/agents\/[^/]+$/, "") : void 0;
@@ -157577,7 +157576,7 @@ var init_history2 = __esm({
157577
157576
  }
157578
157577
  });
157579
157578
  function getDefaultShell() {
157580
- if (os2.platform() === "win32") {
157579
+ if (os3.platform() === "win32") {
157581
157580
  return process.env.COMSPEC || "cmd.exe";
157582
157581
  }
157583
157582
  return process.env.SHELL || "/bin/bash";
@@ -163172,11 +163171,46 @@ function getPythonCandidates() {
163172
163171
  );
163173
163172
  } else if (process.platform === "win32") {
163174
163173
  const localAppData = process.env.LOCALAPPDATA || (0, import_path.join)(home, "AppData/Local");
163174
+ candidates.push("py", "C:\\Windows\\py.exe");
163175
163175
  candidates.push(
163176
+ (0, import_path.join)(localAppData, "Programs/Python/Python314/python.exe"),
163176
163177
  (0, import_path.join)(localAppData, "Programs/Python/Python313/python.exe"),
163177
163178
  (0, import_path.join)(localAppData, "Programs/Python/Python312/python.exe"),
163178
163179
  (0, import_path.join)(localAppData, "Programs/Python/Python311/python.exe"),
163179
- (0, import_path.join)(localAppData, "Programs/Python/Python310/python.exe")
163180
+ (0, import_path.join)(localAppData, "Programs/Python/Python310/python.exe"),
163181
+ (0, import_path.join)(localAppData, "Programs/Python/Python39/python.exe")
163182
+ );
163183
+ candidates.push(
163184
+ (0, import_path.join)(localAppData, "Microsoft/WindowsApps/python.exe"),
163185
+ (0, import_path.join)(localAppData, "Microsoft/WindowsApps/python3.exe")
163186
+ );
163187
+ candidates.push(
163188
+ (0, import_path.join)(home, ".pyenv/pyenv-win/shims/python.exe"),
163189
+ (0, import_path.join)(home, ".pyenv/pyenv-win/shims/python3.exe")
163190
+ );
163191
+ candidates.push((0, import_path.join)(home, "scoop/apps/python/current/python.exe"));
163192
+ candidates.push(
163193
+ (0, import_path.join)(home, "miniconda3/python.exe"),
163194
+ (0, import_path.join)(home, "anaconda3/python.exe"),
163195
+ (0, import_path.join)(home, "Miniconda3/python.exe"),
163196
+ (0, import_path.join)(home, "Anaconda3/python.exe"),
163197
+ (0, import_path.join)(localAppData, "miniconda3/python.exe"),
163198
+ (0, import_path.join)(localAppData, "anaconda3/python.exe")
163199
+ );
163200
+ candidates.push(
163201
+ "C:\\ProgramData\\miniconda3\\python.exe",
163202
+ "C:\\ProgramData\\anaconda3\\python.exe",
163203
+ "C:\\ProgramData\\Miniconda3\\python.exe",
163204
+ "C:\\ProgramData\\Anaconda3\\python.exe",
163205
+ "C:\\miniconda3\\python.exe",
163206
+ "C:\\anaconda3\\python.exe"
163207
+ );
163208
+ candidates.push(
163209
+ "C:\\Python314\\python.exe",
163210
+ "C:\\Python313\\python.exe",
163211
+ "C:\\Python312\\python.exe",
163212
+ "C:\\Python311\\python.exe",
163213
+ "C:\\Python310\\python.exe"
163180
163214
  );
163181
163215
  } else {
163182
163216
  candidates.push(
@@ -163188,9 +163222,10 @@ function getPythonCandidates() {
163188
163222
  }
163189
163223
  return candidates;
163190
163224
  }
163191
- async function isExecutable(path24) {
163225
+ async function isExecutable(filePath) {
163192
163226
  try {
163193
- await (0, import_promises.access)(path24, import_promises.constants.X_OK);
163227
+ const mode = process.platform === "win32" ? import_promises.constants.F_OK : import_promises.constants.X_OK;
163228
+ await (0, import_promises.access)(filePath, mode);
163194
163229
  return true;
163195
163230
  } catch {
163196
163231
  return false;
@@ -163199,20 +163234,29 @@ async function isExecutable(path24) {
163199
163234
  async function checkPython(path24) {
163200
163235
  try {
163201
163236
  let actualPath = path24;
163202
- if (!path24.startsWith("/") && !path24.includes("\\")) {
163237
+ const isAbsolute6 = path24.startsWith("/") || /^[A-Za-z]:[\\/]/.test(path24);
163238
+ if (!isAbsolute6) {
163203
163239
  try {
163204
- const { stdout: stdout2 } = await execAsync5(`which ${path24}`);
163205
- actualPath = stdout2.trim();
163240
+ const whichCmd = process.platform === "win32" ? `where "${path24}"` : `which ${path24}`;
163241
+ const { stdout: stdout2 } = await execAsync5(whichCmd, { windowsHide: true });
163242
+ actualPath = stdout2.trim().split(/\r?\n/)[0].trim();
163206
163243
  } catch {
163207
163244
  }
163208
163245
  }
163209
- if (actualPath.startsWith("/") || actualPath.includes("\\")) {
163210
- if (!await isExecutable(actualPath)) {
163246
+ if (actualPath.startsWith("/") || /^[A-Za-z]:[\\/]/.test(actualPath)) {
163247
+ if (process.platform === "win32") {
163248
+ try {
163249
+ await (0, import_promises.access)(actualPath, import_promises.constants.F_OK);
163250
+ } catch {
163251
+ return null;
163252
+ }
163253
+ } else if (!await isExecutable(actualPath)) {
163211
163254
  return null;
163212
163255
  }
163213
163256
  }
163214
163257
  const { stdout, stderr } = await execAsync5(`"${actualPath}" --version`, {
163215
- timeout: 5e3
163258
+ timeout: 5e3,
163259
+ windowsHide: true
163216
163260
  });
163217
163261
  const versionOutput = stdout.trim() || stderr.trim();
163218
163262
  const versionMatch = versionOutput.match(/Python\s+(\d+\.\d+\.\d+)/);
@@ -163306,11 +163350,49 @@ function getCliToolCandidates(tool) {
163306
163350
  const programFiles = process.env.ProgramFiles || "C:\\Program Files";
163307
163351
  const programFilesX86 = process.env["ProgramFiles(x86)"] || "C:\\Program Files (x86)";
163308
163352
  if (tool === "python") {
163353
+ candidates.push("python", "python3", "py");
163354
+ candidates.push("C:\\Windows\\py.exe");
163309
163355
  candidates.push(
163356
+ (0, import_path.join)(localAppData, "Programs/Python/Python314/python.exe"),
163310
163357
  (0, import_path.join)(localAppData, "Programs/Python/Python313/python.exe"),
163311
163358
  (0, import_path.join)(localAppData, "Programs/Python/Python312/python.exe"),
163312
163359
  (0, import_path.join)(localAppData, "Programs/Python/Python311/python.exe"),
163313
- (0, import_path.join)(localAppData, "Programs/Python/Python310/python.exe")
163360
+ (0, import_path.join)(localAppData, "Programs/Python/Python310/python.exe"),
163361
+ (0, import_path.join)(localAppData, "Programs/Python/Python39/python.exe")
163362
+ );
163363
+ candidates.push(
163364
+ (0, import_path.join)(localAppData, "Microsoft/WindowsApps/python.exe"),
163365
+ (0, import_path.join)(localAppData, "Microsoft/WindowsApps/python3.exe")
163366
+ );
163367
+ candidates.push(
163368
+ (0, import_path.join)(home, ".pyenv/pyenv-win/shims/python.exe"),
163369
+ (0, import_path.join)(home, ".pyenv/pyenv-win/shims/python3.exe")
163370
+ );
163371
+ candidates.push(
163372
+ (0, import_path.join)(home, "scoop/apps/python/current/python.exe")
163373
+ );
163374
+ candidates.push(
163375
+ (0, import_path.join)(home, "miniconda3/python.exe"),
163376
+ (0, import_path.join)(home, "anaconda3/python.exe"),
163377
+ (0, import_path.join)(home, "Miniconda3/python.exe"),
163378
+ (0, import_path.join)(home, "Anaconda3/python.exe"),
163379
+ (0, import_path.join)(localAppData, "miniconda3/python.exe"),
163380
+ (0, import_path.join)(localAppData, "anaconda3/python.exe")
163381
+ );
163382
+ candidates.push(
163383
+ "C:\\ProgramData\\miniconda3\\python.exe",
163384
+ "C:\\ProgramData\\anaconda3\\python.exe",
163385
+ "C:\\ProgramData\\Miniconda3\\python.exe",
163386
+ "C:\\ProgramData\\Anaconda3\\python.exe",
163387
+ "C:\\miniconda3\\python.exe",
163388
+ "C:\\anaconda3\\python.exe"
163389
+ );
163390
+ candidates.push(
163391
+ "C:\\Python314\\python.exe",
163392
+ "C:\\Python313\\python.exe",
163393
+ "C:\\Python312\\python.exe",
163394
+ "C:\\Python311\\python.exe",
163395
+ "C:\\Python310\\python.exe"
163314
163396
  );
163315
163397
  } else if (tool === "git") {
163316
163398
  candidates.push(
@@ -163380,7 +163462,8 @@ async function detectCliToolVersion(toolPath, tool) {
163380
163462
  const versionArg = config.versionArg || "--version";
163381
163463
  try {
163382
163464
  const { stdout, stderr } = await execAsync5(`"${toolPath}" ${versionArg}`, {
163383
- timeout: 5e3
163465
+ timeout: 5e3,
163466
+ windowsHide: true
163384
163467
  });
163385
163468
  const output2 = stdout.trim() || stderr.trim();
163386
163469
  let version2 = null;
@@ -163468,12 +163551,12 @@ async function detectCliTool(tool, userConfigPath) {
163468
163551
  }
163469
163552
  }
163470
163553
  }
163471
- const toolCmd = tool === "python" ? "python3" : tool;
163554
+ const toolCmd = tool === "python" ? process.platform === "win32" ? "python" : "python3" : tool;
163472
163555
  try {
163473
163556
  const whichCmd = process.platform === "win32" ? "where" : "which";
163474
- const { stdout } = await execAsync5(`${whichCmd} ${toolCmd}`, { timeout: 5e3 });
163475
- const toolPath = stdout.trim().split("\n")[0];
163476
- if (toolPath) {
163557
+ const { stdout } = await execAsync5(`${whichCmd} ${toolCmd}`, { timeout: 5e3, windowsHide: true });
163558
+ const toolPaths = stdout.trim().split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
163559
+ for (const toolPath of toolPaths) {
163477
163560
  const { version: version2, valid } = await detectCliToolVersion(toolPath, tool);
163478
163561
  if (valid) {
163479
163562
  await addPath(toolPath, version2 || void 0, getToolSource(toolPath));
@@ -163481,6 +163564,77 @@ async function detectCliTool(tool, userConfigPath) {
163481
163564
  }
163482
163565
  } catch {
163483
163566
  }
163567
+ let condaBaseDir = null;
163568
+ if (tool === "python" && process.platform === "win32") {
163569
+ try {
163570
+ const { stdout: condaStdout } = await execAsync5("where conda", { timeout: 3e3, windowsHide: true });
163571
+ const condaExe = condaStdout.trim().split(/\r?\n/)[0].trim();
163572
+ if (condaExe) {
163573
+ condaBaseDir = (0, import_path.join)((0, import_path.dirname)(condaExe), "..");
163574
+ const pythonFromConda = (0, import_path.join)(condaBaseDir, "python.exe");
163575
+ if (await isExecutable(pythonFromConda)) {
163576
+ const { version: version2, valid } = await detectCliToolVersion(pythonFromConda, tool);
163577
+ if (valid) {
163578
+ await addPath(pythonFromConda, version2 || void 0, "system-path");
163579
+ }
163580
+ }
163581
+ }
163582
+ } catch {
163583
+ }
163584
+ }
163585
+ if (tool === "python") {
163586
+ const localAppData = process.env.LOCALAPPDATA || (0, import_path.join)(home, "AppData/Local");
163587
+ const condaBases = [];
163588
+ if (condaBaseDir) condaBases.push(condaBaseDir);
163589
+ if (process.platform === "win32") {
163590
+ condaBases.push(
163591
+ "C:\\ProgramData\\miniconda3",
163592
+ "C:\\ProgramData\\anaconda3",
163593
+ "C:\\ProgramData\\Miniconda3",
163594
+ "C:\\ProgramData\\Anaconda3",
163595
+ (0, import_path.join)(home, "miniconda3"),
163596
+ (0, import_path.join)(home, "anaconda3"),
163597
+ (0, import_path.join)(home, "Miniconda3"),
163598
+ (0, import_path.join)(home, "Anaconda3"),
163599
+ (0, import_path.join)(localAppData, "miniconda3"),
163600
+ (0, import_path.join)(localAppData, "anaconda3")
163601
+ );
163602
+ } else {
163603
+ condaBases.push(
163604
+ (0, import_path.join)(home, "miniconda3"),
163605
+ (0, import_path.join)(home, "anaconda3"),
163606
+ "/opt/miniconda3",
163607
+ "/opt/anaconda3"
163608
+ );
163609
+ }
163610
+ for (const existing of allPaths) {
163611
+ const parentDir = (0, import_path.dirname)(existing.path);
163612
+ if (!condaBases.includes(parentDir)) {
163613
+ condaBases.push(parentDir);
163614
+ }
163615
+ }
163616
+ const pythonInEnvSuffix = process.platform === "win32" ? "python.exe" : (0, import_path.join)("bin", "python");
163617
+ const seenEnvsDirs = /* @__PURE__ */ new Set();
163618
+ for (const base of condaBases) {
163619
+ const envsDir = (0, import_path.join)(base, "envs");
163620
+ if (seenEnvsDirs.has(envsDir)) continue;
163621
+ seenEnvsDirs.add(envsDir);
163622
+ try {
163623
+ const envEntries = await (0, import_promises.readdir)(envsDir, { withFileTypes: true });
163624
+ for (const envEntry of envEntries) {
163625
+ if (!envEntry.isDirectory()) continue;
163626
+ const pythonInEnv = (0, import_path.join)(envsDir, envEntry.name, pythonInEnvSuffix);
163627
+ if (await isExecutable(pythonInEnv)) {
163628
+ const { version: version2, valid } = await detectCliToolVersion(pythonInEnv, tool);
163629
+ if (valid) {
163630
+ await addPath(pythonInEnv, version2 || void 0, "system-path");
163631
+ }
163632
+ }
163633
+ }
163634
+ } catch {
163635
+ }
163636
+ }
163637
+ }
163484
163638
  if (config.detectMethod === "npm-global" && process.platform !== "win32") {
163485
163639
  const nvmVersionsDir = (0, import_path.join)(home, ".nvm/versions/node");
163486
163640
  try {
@@ -163610,7 +163764,7 @@ async function checkPackageInstalled(pythonPath, packageName) {
163610
163764
  const pipCommand = `"${pythonPath}" -m pip show ${packageName}`;
163611
163765
  log35.debug({ pipCommand }, "Checking package with pip");
163612
163766
  try {
163613
- const { stdout, stderr } = await execAsync5(pipCommand, { timeout: 1e4 });
163767
+ const { stdout, stderr } = await execAsync5(pipCommand, { timeout: 1e4, windowsHide: true });
163614
163768
  log35.debug({ stdout: stdout.slice(0, 200) }, "pip show stdout");
163615
163769
  if (stderr) {
163616
163770
  log35.debug({ stderr: stderr.slice(0, 200) }, "pip show stderr");
@@ -163630,7 +163784,7 @@ async function checkPackageInstalled(pythonPath, packageName) {
163630
163784
  const importCommand = `"${pythonPath}" -c "import ${moduleName2}; print(getattr(${moduleName2}, '__version__', 'unknown'))"`;
163631
163785
  log35.debug({ importCommand }, "Trying import");
163632
163786
  try {
163633
- const { stdout: importStdout } = await execAsync5(importCommand, { timeout: 1e4 });
163787
+ const { stdout: importStdout } = await execAsync5(importCommand, { timeout: 1e4, windowsHide: true });
163634
163788
  const version2 = importStdout.trim() || "unknown";
163635
163789
  log35.debug({ packageName, version: version2 }, "Package found via import");
163636
163790
  return {
@@ -163644,7 +163798,7 @@ async function checkPackageInstalled(pythonPath, packageName) {
163644
163798
  const moduleCommand = `"${pythonPath}" -m ${moduleName2} --version`;
163645
163799
  log35.debug({ moduleCommand }, "Trying module version");
163646
163800
  try {
163647
- const { stdout: modStdout } = await execAsync5(moduleCommand, { timeout: 1e4 });
163801
+ const { stdout: modStdout } = await execAsync5(moduleCommand, { timeout: 1e4, windowsHide: true });
163648
163802
  const versionMatch = modStdout.match(/(\d+\.\d+\.\d+)/);
163649
163803
  const version2 = versionMatch ? versionMatch[1] : "installed";
163650
163804
  log35.debug({ packageName, version: version2 }, "Package found via module");
@@ -182222,8 +182376,15 @@ async function startGateway(ctx, options) {
182222
182376
  });
182223
182377
  fs20.closeSync(logFd);
182224
182378
  child.unref();
182225
- await new Promise((resolve28) => setTimeout(resolve28, 500));
182226
- const pid = findProcessOnPort(port);
182379
+ let pid = null;
182380
+ const pollStart = Date.now();
182381
+ const pollMaxMs = 15e3;
182382
+ const pollInterval = 500;
182383
+ while (Date.now() - pollStart < pollMaxMs) {
182384
+ await new Promise((resolve28) => setTimeout(resolve28, pollInterval));
182385
+ pid = findProcessOnPort(port);
182386
+ if (pid !== null) break;
182387
+ }
182227
182388
  if (pid !== null) {
182228
182389
  output(
182229
182390
  ctx,
@@ -183800,7 +183961,7 @@ ${import_chalk.default.bold("Telemetry \u7EDF\u8BA1")}:
183800
183961
  init_lib();
183801
183962
  init_update();
183802
183963
  var execAsync11 = (0, import_util.promisify)(import_child_process.exec);
183803
- var CURRENT_VERSION = "1.1.9";
183964
+ var CURRENT_VERSION = "1.2.0";
183804
183965
  var GITHUB_REPO = "LinXueyuanStdio/viben";
183805
183966
  var NPM_PACKAGE = "viben";
183806
183967
  function compareSemver(a, b) {
@@ -192076,7 +192237,7 @@ function registerCommands(program) {
192076
192237
  registerPageCommand(program);
192077
192238
  registerAccountCommand(program);
192078
192239
  }
192079
- var VERSION4 = "1.1.9";
192240
+ var VERSION4 = "1.2.0";
192080
192241
  function createProgram() {
192081
192242
  const program = new import_commander.Command();
192082
192243
  program.name("viben").description("Viben - Agent Swarm \xD7 Code Evolution").version(VERSION4, "-v, --version", "Output the version number");