zenflo 0.11.8 → 0.11.9

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.
@@ -3,7 +3,7 @@
3
3
  var chalk = require('chalk');
4
4
  var os = require('node:os');
5
5
  var node_crypto = require('node:crypto');
6
- var types = require('./types-uaIx8ab0.cjs');
6
+ var types = require('./types-BNjAQcO4.cjs');
7
7
  var node_child_process = require('node:child_process');
8
8
  var node_path = require('node:path');
9
9
  var node_readline = require('node:readline');
@@ -34,6 +34,7 @@ var fastifyTypeProviderZod = require('fastify-type-provider-zod');
34
34
  var mcp_js = require('@modelcontextprotocol/sdk/server/mcp.js');
35
35
  var node_http = require('node:http');
36
36
  var streamableHttp_js = require('@modelcontextprotocol/sdk/server/streamableHttp.js');
37
+ var url = require('url');
37
38
  var http = require('http');
38
39
  var util = require('util');
39
40
 
@@ -1020,10 +1021,10 @@ class AbortError extends Error {
1020
1021
  }
1021
1022
  }
1022
1023
 
1023
- const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-DXM6ppoL.cjs', document.baseURI).href)));
1024
- const __dirname$1 = node_path.join(__filename$1, "..");
1024
+ const __filename$2 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-GoBFTs9u.cjs', document.baseURI).href)));
1025
+ const __dirname$2 = node_path.join(__filename$2, "..");
1025
1026
  function getDefaultClaudeCodePath() {
1026
- return node_path.join(__dirname$1, "..", "..", "..", "node_modules", "@anthropic-ai", "claude-code", "cli.js");
1027
+ return node_path.join(__dirname$2, "..", "..", "..", "node_modules", "@anthropic-ai", "claude-code", "cli.js");
1027
1028
  }
1028
1029
  function logDebug(message) {
1029
1030
  if (process.env.DEBUG) {
@@ -3902,8 +3903,8 @@ function selectAuthenticationMethod() {
3902
3903
  async function doMobileAuth(keypair) {
3903
3904
  console.clear();
3904
3905
  console.log("\nMobile Authentication\n");
3905
- console.log("Scan this QR code with your Happy mobile app:\n");
3906
- const authUrl = "happy://terminal?" + types.encodeBase64Url(keypair.publicKey);
3906
+ console.log("Scan this QR code with your ZenFlo mobile app:\n");
3907
+ const authUrl = "zenflo://terminal?" + types.encodeBase64Url(keypair.publicKey);
3907
3908
  displayQRCode(authUrl);
3908
3909
  console.log("\nOr manually enter this URL:");
3909
3910
  console.log(authUrl);
@@ -4802,7 +4803,7 @@ async function runClaude(credentials, options = {}) {
4802
4803
  // Initialize lifecycle state
4803
4804
  lifecycleState: "running",
4804
4805
  lifecycleStateSince: Date.now(),
4805
- flavor: "claude"
4806
+ flavor: options.flavor || "claude"
4806
4807
  };
4807
4808
  const response = await api.getOrCreateSession({ tag: sessionTag, metadata, state });
4808
4809
  types.logger.debug(`Session created: ${response.id}`);
@@ -5039,16 +5040,120 @@ async function runClaude(credentials, options = {}) {
5039
5040
  process.exit(0);
5040
5041
  }
5041
5042
 
5042
- const PLIST_LABEL$1 = "com.happy-cli.daemon";
5043
- const PLIST_FILE$1 = `/Library/LaunchDaemons/${PLIST_LABEL$1}.plist`;
5044
- async function install$1() {
5043
+ const __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-GoBFTs9u.cjs', document.baseURI).href)));
5044
+ const __dirname$1 = path.dirname(__filename$1);
5045
+ const PLIST_LABEL$1 = "com.zenflo.daemon";
5046
+ const LAUNCH_AGENTS_DIR$1 = path.join(os$1.homedir(), "Library", "LaunchAgents");
5047
+ const PLIST_FILE$1 = path.join(LAUNCH_AGENTS_DIR$1, `${PLIST_LABEL$1}.plist`);
5048
+ const APP_BUNDLE_DIR = path.join(os$1.homedir(), "Library", "Application Support", "ZenFlo");
5049
+ const APP_BUNDLE_PATH = path.join(APP_BUNDLE_DIR, "ZenFlo Daemon.app");
5050
+ async function install$3() {
5045
5051
  try {
5052
+ console.log(chalk.cyan("\u{1F4E6} Installing ZenFlo daemon as LaunchAgent...\n"));
5046
5053
  if (fs$2.existsSync(PLIST_FILE$1)) {
5047
- types.logger.info("Daemon plist already exists. Uninstalling first...");
5048
- child_process.execSync(`launchctl unload ${PLIST_FILE$1}`, { stdio: "inherit" });
5054
+ console.log(chalk.yellow("\u26A0\uFE0F LaunchAgent already installed. Uninstalling first...\n"));
5055
+ try {
5056
+ child_process.execSync(`launchctl unload "${PLIST_FILE$1}"`, { stdio: "pipe" });
5057
+ } catch (error) {
5058
+ }
5059
+ }
5060
+ if (!fs$2.existsSync(LAUNCH_AGENTS_DIR$1)) {
5061
+ fs$2.mkdirSync(LAUNCH_AGENTS_DIR$1, { recursive: true });
5062
+ }
5063
+ let zenfloBinaryPath;
5064
+ try {
5065
+ zenfloBinaryPath = child_process.execSync("which zenflo", { encoding: "utf-8" }).trim();
5066
+ } catch (error) {
5067
+ throw new Error("Could not find zenflo binary in PATH. Is ZenFlo installed?");
5068
+ }
5069
+ console.log(chalk.cyan("Creating app bundle with ZenFlo icon..."));
5070
+ const contentsDir = path.join(APP_BUNDLE_PATH, "Contents");
5071
+ const macosDir = path.join(contentsDir, "MacOS");
5072
+ const resourcesDir = path.join(contentsDir, "Resources");
5073
+ fs$2.mkdirSync(macosDir, { recursive: true });
5074
+ fs$2.mkdirSync(resourcesDir, { recursive: true });
5075
+ const possibleIconPaths = [
5076
+ // PRIMARY: Icon Exports directory (user's actual branding)
5077
+ "/Users/quinnmay/developer/zenflo/Icon Exports/ZenFlo.icns",
5078
+ path.join(process.cwd(), "Icon Exports", "ZenFlo.icns"),
5079
+ path.join(__dirname$1, "..", "..", "..", "Icon Exports", "ZenFlo.icns"),
5080
+ // Fallback: Tauri icons (old location)
5081
+ "/Users/quinnmay/developer/zenflo/mobile/src-tauri/icons/icon.icns",
5082
+ "/Users/quinnmay/developer/zenflo/webapp/src-tauri/icons/icon.icns",
5083
+ path.join(process.cwd(), "mobile", "src-tauri", "icons", "icon.icns"),
5084
+ path.join(process.cwd(), "webapp", "src-tauri", "icons", "icon.icns"),
5085
+ path.join(__dirname$1, "..", "..", "..", "mobile", "src-tauri", "icons", "icon.icns"),
5086
+ path.join(__dirname$1, "..", "..", "..", "webapp", "src-tauri", "icons", "icon.icns")
5087
+ ];
5088
+ let iconCopied = false;
5089
+ for (const iconPath of possibleIconPaths) {
5090
+ if (fs$2.existsSync(iconPath)) {
5091
+ fs$2.copyFileSync(iconPath, path.join(resourcesDir, "AppIcon.icns"));
5092
+ console.log(chalk.green("\u2705 Copied ZenFlo icon"));
5093
+ console.log(chalk.dim(` Source: ${iconPath}`));
5094
+ iconCopied = true;
5095
+ break;
5096
+ }
5097
+ }
5098
+ if (!iconCopied) {
5099
+ console.log(chalk.yellow("\u26A0\uFE0F Could not find icon.icns (will use default icon)"));
5049
5100
  }
5050
- const happyPath = process.argv[0];
5051
- const scriptPath = process.argv[1];
5101
+ try {
5102
+ child_process.execSync(`touch "${APP_BUNDLE_PATH}"`);
5103
+ child_process.execSync("killall Dock 2>/dev/null || true", { stdio: "pipe" });
5104
+ child_process.execSync("killall Finder 2>/dev/null || true", { stdio: "pipe" });
5105
+ console.log(chalk.green("\u2705 Refreshed icon cache\n"));
5106
+ } catch (error) {
5107
+ console.log(chalk.dim(" (Icon cache refresh skipped)\n"));
5108
+ }
5109
+ const infoPlistContent = trimIdent(`
5110
+ <?xml version="1.0" encoding="UTF-8"?>
5111
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
5112
+ <plist version="1.0">
5113
+ <dict>
5114
+ <key>CFBundleExecutable</key>
5115
+ <string>zenflo-daemon</string>
5116
+ <key>CFBundleIconFile</key>
5117
+ <string>AppIcon.icns</string>
5118
+ <key>CFBundleIdentifier</key>
5119
+ <string>com.zenflo.daemon</string>
5120
+ <key>CFBundleName</key>
5121
+ <string>ZenFlo Daemon</string>
5122
+ <key>CFBundlePackageType</key>
5123
+ <string>APPL</string>
5124
+ <key>CFBundleShortVersionString</key>
5125
+ <string>1.0.0</string>
5126
+ <key>LSBackgroundOnly</key>
5127
+ <true/>
5128
+ <key>LSUIElement</key>
5129
+ <true/>
5130
+ </dict>
5131
+ </plist>
5132
+ `);
5133
+ fs$2.writeFileSync(path.join(contentsDir, "Info.plist"), infoPlistContent);
5134
+ console.log(chalk.green("\u2705 Created app bundle Info.plist"));
5135
+ let nodePath;
5136
+ let zenfloScriptPath;
5137
+ try {
5138
+ nodePath = child_process.execSync("which node", { encoding: "utf-8" }).trim();
5139
+ } catch (error) {
5140
+ throw new Error("Could not find node binary in PATH. Is Node.js installed?");
5141
+ }
5142
+ try {
5143
+ const symlinkTarget = child_process.execSync(`readlink "${zenfloBinaryPath}"`, { encoding: "utf-8" }).trim();
5144
+ const symlinkDir = path.dirname(zenfloBinaryPath);
5145
+ zenfloScriptPath = path.resolve(symlinkDir, symlinkTarget);
5146
+ } catch (error) {
5147
+ zenfloScriptPath = zenfloBinaryPath;
5148
+ }
5149
+ const wrapperScript = trimIdent(`
5150
+ #!/bin/bash
5151
+ # Use absolute paths to avoid issues when launched from / by LaunchAgent
5152
+ exec "${nodePath}" "${zenfloScriptPath}" daemon start-sync
5153
+ `);
5154
+ const wrapperPath = path.join(macosDir, "zenflo-daemon");
5155
+ fs$2.writeFileSync(wrapperPath, wrapperScript, { mode: 493 });
5156
+ console.log(chalk.green("\u2705 Created launcher script\n"));
5052
5157
  const plistContent = trimIdent(`
5053
5158
  <?xml version="1.0" encoding="UTF-8"?>
5054
5159
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -5056,92 +5161,411 @@ async function install$1() {
5056
5161
  <dict>
5057
5162
  <key>Label</key>
5058
5163
  <string>${PLIST_LABEL$1}</string>
5059
-
5164
+
5060
5165
  <key>ProgramArguments</key>
5061
5166
  <array>
5062
- <string>${happyPath}</string>
5063
- <string>${scriptPath}</string>
5064
- <string>happy-daemon</string>
5167
+ <string>/usr/bin/open</string>
5168
+ <string>-a</string>
5169
+ <string>${APP_BUNDLE_PATH}</string>
5170
+ <string>--background</string>
5065
5171
  </array>
5066
-
5067
- <key>EnvironmentVariables</key>
5068
- <dict>
5069
- <key>ZENFLO_DAEMON_MODE</key>
5070
- <string>true</string>
5071
- </dict>
5072
-
5172
+
5073
5173
  <key>RunAtLoad</key>
5074
5174
  <true/>
5075
-
5175
+
5076
5176
  <key>KeepAlive</key>
5077
- <true/>
5078
-
5177
+ <dict>
5178
+ <key>SuccessfulExit</key>
5179
+ <false/>
5180
+ </dict>
5181
+
5079
5182
  <key>StandardErrorPath</key>
5080
- <string>${os$1.homedir()}/.happy/daemon.err</string>
5081
-
5183
+ <string>${types.configuration.zenfloHomeDir}/daemon.err</string>
5184
+
5082
5185
  <key>StandardOutPath</key>
5083
- <string>${os$1.homedir()}/.happy/daemon.log</string>
5084
-
5186
+ <string>${types.configuration.zenfloHomeDir}/daemon.log</string>
5187
+
5085
5188
  <key>WorkingDirectory</key>
5086
- <string>/tmp</string>
5189
+ <string>${os$1.homedir()}</string>
5190
+
5191
+ <key>ProcessType</key>
5192
+ <string>Background</string>
5193
+
5194
+ <key>ThrottleInterval</key>
5195
+ <integer>10</integer>
5087
5196
  </dict>
5088
5197
  </plist>
5089
5198
  `);
5090
- fs$2.writeFileSync(PLIST_FILE$1, plistContent);
5091
- fs$2.chmodSync(PLIST_FILE$1, 420);
5092
- types.logger.info(`Created daemon plist at ${PLIST_FILE$1}`);
5093
- child_process.execSync(`launchctl load ${PLIST_FILE$1}`, { stdio: "inherit" });
5094
- types.logger.info("Daemon installed and started successfully");
5095
- types.logger.info("Check logs at ~/.happy/daemon.log");
5199
+ fs$2.writeFileSync(PLIST_FILE$1, plistContent, { mode: 420 });
5200
+ console.log(chalk.green("\u2705 Created LaunchAgent plist"));
5201
+ console.log(chalk.dim(` ${PLIST_FILE$1}
5202
+ `));
5203
+ try {
5204
+ child_process.execSync(`launchctl load "${PLIST_FILE$1}"`, { stdio: "pipe" });
5205
+ console.log(chalk.green("\u2705 LaunchAgent loaded successfully\n"));
5206
+ } catch (error) {
5207
+ throw new Error(`Failed to load LaunchAgent: ${error instanceof Error ? error.message : error}`);
5208
+ }
5209
+ console.log(chalk.green.bold("\u{1F389} Installation complete!\n"));
5210
+ console.log(chalk.cyan("The daemon will now:"));
5211
+ console.log(chalk.dim(" \u2022 Start automatically when you log in"));
5212
+ console.log(chalk.dim(" \u2022 Run in the background 24/7"));
5213
+ console.log(chalk.dim(" \u2022 Restart automatically if it crashes"));
5214
+ console.log(chalk.dim(" \u2022 Display with ZenFlo branding in Activity Monitor\n"));
5215
+ console.log(chalk.cyan("Next steps:"));
5216
+ console.log(chalk.dim(" \u2022 Check status: ") + chalk.white("zenflo daemon status"));
5217
+ console.log(chalk.dim(" \u2022 View logs: ") + chalk.white(`tail -f ${types.configuration.zenfloHomeDir}/daemon.log`));
5218
+ console.log(chalk.dim(" \u2022 Uninstall: ") + chalk.white("zenflo daemon uninstall\n"));
5219
+ console.log(chalk.yellow("\u{1F4A1} Tip: To grant Full Disk Access:"));
5220
+ console.log(chalk.dim(" 1. Open System Settings \u2192 Privacy & Security \u2192 Full Disk Access"));
5221
+ console.log(chalk.dim(" 2. Click the + button"));
5222
+ console.log(chalk.dim(" 3. Navigate to: ") + chalk.white(zenfloBinaryPath));
5223
+ console.log(chalk.dim(" 4. Enable the toggle\n"));
5096
5224
  } catch (error) {
5225
+ console.error(chalk.red("\u274C Installation failed:"), error instanceof Error ? error.message : error);
5097
5226
  types.logger.debug("Failed to install daemon:", error);
5098
5227
  throw error;
5099
5228
  }
5100
5229
  }
5101
5230
 
5102
- async function install() {
5103
- if (process.platform !== "darwin") {
5104
- throw new Error("Daemon installation is currently only supported on macOS");
5231
+ const TASK_NAME$1 = "ZenFlo Daemon";
5232
+ async function install$2() {
5233
+ try {
5234
+ console.log(chalk.cyan("\u{1F4E6} Installing ZenFlo daemon as Windows Task Scheduler task...\n"));
5235
+ try {
5236
+ child_process.execSync(`schtasks /Query /TN "${TASK_NAME$1}"`, { stdio: "pipe" });
5237
+ console.log(chalk.yellow("\u26A0\uFE0F Task already installed. Uninstalling first...\n"));
5238
+ try {
5239
+ child_process.execSync(`schtasks /Delete /TN "${TASK_NAME$1}" /F`, { stdio: "pipe" });
5240
+ } catch (error) {
5241
+ }
5242
+ } catch (error) {
5243
+ }
5244
+ let zenfloBinaryPath;
5245
+ try {
5246
+ zenfloBinaryPath = child_process.execSync("where zenflo", { encoding: "utf-8" }).trim().split("\n")[0];
5247
+ } catch (error) {
5248
+ throw new Error("Could not find zenflo binary in PATH. Is ZenFlo installed?");
5249
+ }
5250
+ let nodePath;
5251
+ try {
5252
+ nodePath = child_process.execSync("where node", { encoding: "utf-8" }).trim().split("\n")[0];
5253
+ } catch (error) {
5254
+ throw new Error("Could not find node.exe in PATH. Is Node.js installed?");
5255
+ }
5256
+ const xmlPath = path.join(types.configuration.zenfloHomeDir, "daemon-task.xml");
5257
+ const xmlContent = trimIdent(`
5258
+ <?xml version="1.0" encoding="UTF-16"?>
5259
+ <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
5260
+ <RegistrationInfo>
5261
+ <Date>2025-01-01T00:00:00</Date>
5262
+ <Author>${os$1.userInfo().username}</Author>
5263
+ <Description>ZenFlo AI coding assistant daemon service</Description>
5264
+ </RegistrationInfo>
5265
+ <Triggers>
5266
+ <LogonTrigger>
5267
+ <Enabled>true</Enabled>
5268
+ <UserId>${os$1.userInfo().username}</UserId>
5269
+ </LogonTrigger>
5270
+ </Triggers>
5271
+ <Principals>
5272
+ <Principal id="Author">
5273
+ <UserId>${os$1.userInfo().username}</UserId>
5274
+ <LogonType>InteractiveToken</LogonType>
5275
+ <RunLevel>LeastPrivilege</RunLevel>
5276
+ </Principal>
5277
+ </Principals>
5278
+ <Settings>
5279
+ <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
5280
+ <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
5281
+ <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
5282
+ <AllowHardTerminate>true</AllowHardTerminate>
5283
+ <StartWhenAvailable>true</StartWhenAvailable>
5284
+ <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
5285
+ <IdleSettings>
5286
+ <StopOnIdleEnd>false</StopOnIdleEnd>
5287
+ <RestartOnIdle>false</RestartOnIdle>
5288
+ </IdleSettings>
5289
+ <AllowStartOnDemand>true</AllowStartOnDemand>
5290
+ <Enabled>true</Enabled>
5291
+ <Hidden>false</Hidden>
5292
+ <RunOnlyIfIdle>false</RunOnlyIfIdle>
5293
+ <WakeToRun>false</WakeToRun>
5294
+ <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
5295
+ <Priority>7</Priority>
5296
+ <RestartOnFailure>
5297
+ <Interval>PT1M</Interval>
5298
+ <Count>3</Count>
5299
+ </RestartOnFailure>
5300
+ </Settings>
5301
+ <Actions Context="Author">
5302
+ <Exec>
5303
+ <Command>"${nodePath}"</Command>
5304
+ <Arguments>"${zenfloBinaryPath}" daemon start-sync</Arguments>
5305
+ <WorkingDirectory>${os$1.homedir()}</WorkingDirectory>
5306
+ </Exec>
5307
+ </Actions>
5308
+ </Task>
5309
+ `);
5310
+ fs$2.writeFileSync(xmlPath, xmlContent, { encoding: "utf-16le" });
5311
+ console.log(chalk.green("\u2705 Created task definition XML"));
5312
+ console.log(chalk.dim(` ${xmlPath}
5313
+ `));
5314
+ try {
5315
+ child_process.execSync(`schtasks /Create /XML "${xmlPath}" /TN "${TASK_NAME$1}"`, { stdio: "pipe" });
5316
+ console.log(chalk.green("\u2705 Task created successfully\n"));
5317
+ } catch (error) {
5318
+ throw new Error(`Failed to create scheduled task: ${error instanceof Error ? error.message : error}`);
5319
+ }
5320
+ try {
5321
+ child_process.execSync(`schtasks /Run /TN "${TASK_NAME$1}"`, { stdio: "pipe" });
5322
+ console.log(chalk.green("\u2705 Task started successfully\n"));
5323
+ } catch (error) {
5324
+ console.log(chalk.yellow("\u26A0\uFE0F Could not start task immediately (will start at next login)\n"));
5325
+ }
5326
+ console.log(chalk.green.bold("\u{1F389} Installation complete!\n"));
5327
+ console.log(chalk.cyan("The daemon will now:"));
5328
+ console.log(chalk.dim(" \u2022 Start automatically when you log in"));
5329
+ console.log(chalk.dim(" \u2022 Run in the background 24/7"));
5330
+ console.log(chalk.dim(" \u2022 Restart automatically if it crashes (up to 3 times)\n"));
5331
+ console.log(chalk.cyan("Next steps:"));
5332
+ console.log(chalk.dim(" \u2022 Check status: ") + chalk.white("zenflo daemon status"));
5333
+ console.log(chalk.dim(" \u2022 View logs: ") + chalk.white(`type ${types.configuration.zenfloHomeDir}\\daemon.log`));
5334
+ console.log(chalk.dim(" \u2022 Uninstall: ") + chalk.white("zenflo daemon uninstall\n"));
5335
+ console.log(chalk.yellow("\u{1F4A1} Tip: View task in Task Scheduler:"));
5336
+ console.log(chalk.dim(" 1. Press Win+R and type: taskschd.msc"));
5337
+ console.log(chalk.dim(' 2. Find "ZenFlo Daemon" in Task Scheduler Library'));
5338
+ console.log(chalk.dim(" 3. View history, logs, and configuration\n"));
5339
+ } catch (error) {
5340
+ console.error(chalk.red("\u274C Installation failed:"), error instanceof Error ? error.message : error);
5341
+ types.logger.debug("Failed to install daemon:", error);
5342
+ throw error;
5343
+ }
5344
+ }
5345
+
5346
+ const SERVICE_NAME$1 = "zenflo-daemon";
5347
+ const SYSTEMD_USER_DIR$1 = path.join(os$1.homedir(), ".config", "systemd", "user");
5348
+ const SERVICE_FILE$1 = path.join(SYSTEMD_USER_DIR$1, `${SERVICE_NAME$1}.service`);
5349
+ async function install$1() {
5350
+ try {
5351
+ console.log(chalk.cyan("\u{1F4E6} Installing ZenFlo daemon as systemd user service...\n"));
5352
+ if (fs$2.existsSync(SERVICE_FILE$1)) {
5353
+ console.log(chalk.yellow("\u26A0\uFE0F Service already installed. Uninstalling first...\n"));
5354
+ try {
5355
+ child_process.execSync(`systemctl --user stop ${SERVICE_NAME$1}`, { stdio: "pipe" });
5356
+ child_process.execSync(`systemctl --user disable ${SERVICE_NAME$1}`, { stdio: "pipe" });
5357
+ } catch (error) {
5358
+ }
5359
+ }
5360
+ if (!fs$2.existsSync(SYSTEMD_USER_DIR$1)) {
5361
+ fs$2.mkdirSync(SYSTEMD_USER_DIR$1, { recursive: true });
5362
+ }
5363
+ let zenfloBinaryPath;
5364
+ try {
5365
+ zenfloBinaryPath = child_process.execSync("which zenflo", { encoding: "utf-8" }).trim();
5366
+ } catch (error) {
5367
+ throw new Error("Could not find zenflo binary in PATH. Is ZenFlo installed?");
5368
+ }
5369
+ const serviceContent = trimIdent(`
5370
+ [Unit]
5371
+ Description=ZenFlo AI Coding Assistant Daemon
5372
+ After=network.target
5373
+
5374
+ [Service]
5375
+ Type=simple
5376
+ ExecStart=${zenfloBinaryPath} daemon start-sync
5377
+ Restart=on-failure
5378
+ RestartSec=10
5379
+ StandardOutput=append:${types.configuration.zenfloHomeDir}/daemon.log
5380
+ StandardError=append:${types.configuration.zenfloHomeDir}/daemon.err
5381
+ WorkingDirectory=${os$1.homedir()}
5382
+
5383
+ [Install]
5384
+ WantedBy=default.target
5385
+ `);
5386
+ fs$2.writeFileSync(SERVICE_FILE$1, serviceContent, { mode: 420 });
5387
+ console.log(chalk.green("\u2705 Created systemd service file"));
5388
+ console.log(chalk.dim(` ${SERVICE_FILE$1}
5389
+ `));
5390
+ try {
5391
+ child_process.execSync("systemctl --user daemon-reload", { stdio: "pipe" });
5392
+ console.log(chalk.green("\u2705 Reloaded systemd configuration"));
5393
+ } catch (error) {
5394
+ throw new Error(`Failed to reload systemd: ${error instanceof Error ? error.message : error}`);
5395
+ }
5396
+ try {
5397
+ child_process.execSync(`systemctl --user enable ${SERVICE_NAME$1}`, { stdio: "pipe" });
5398
+ console.log(chalk.green("\u2705 Service enabled (auto-start at login)"));
5399
+ } catch (error) {
5400
+ throw new Error(`Failed to enable service: ${error instanceof Error ? error.message : error}`);
5401
+ }
5402
+ try {
5403
+ child_process.execSync(`systemctl --user start ${SERVICE_NAME$1}`, { stdio: "pipe" });
5404
+ console.log(chalk.green("\u2705 Service started successfully\n"));
5405
+ } catch (error) {
5406
+ throw new Error(`Failed to start service: ${error instanceof Error ? error.message : error}`);
5407
+ }
5408
+ console.log(chalk.green.bold("\u{1F389} Installation complete!\n"));
5409
+ console.log(chalk.cyan("The daemon will now:"));
5410
+ console.log(chalk.dim(" \u2022 Start automatically when you log in"));
5411
+ console.log(chalk.dim(" \u2022 Run in the background 24/7"));
5412
+ console.log(chalk.dim(" \u2022 Restart automatically if it crashes\n"));
5413
+ console.log(chalk.cyan("Next steps:"));
5414
+ console.log(chalk.dim(" \u2022 Check status: ") + chalk.white("zenflo daemon status"));
5415
+ console.log(chalk.dim(" \u2022 View logs: ") + chalk.white(`tail -f ${types.configuration.zenfloHomeDir}/daemon.log`));
5416
+ console.log(chalk.dim(" \u2022 Uninstall: ") + chalk.white("zenflo daemon uninstall\n"));
5417
+ console.log(chalk.yellow("\u{1F4A1} Tip: systemd commands:"));
5418
+ console.log(chalk.dim(" \u2022 Check status: ") + chalk.white(`systemctl --user status ${SERVICE_NAME$1}`));
5419
+ console.log(chalk.dim(" \u2022 View logs: ") + chalk.white(`journalctl --user -u ${SERVICE_NAME$1} -f`));
5420
+ console.log(chalk.dim(" \u2022 Restart: ") + chalk.white(`systemctl --user restart ${SERVICE_NAME$1}
5421
+ `));
5422
+ } catch (error) {
5423
+ console.error(chalk.red("\u274C Installation failed:"), error instanceof Error ? error.message : error);
5424
+ types.logger.debug("Failed to install daemon:", error);
5425
+ throw error;
5105
5426
  }
5106
- if (process.getuid && process.getuid() !== 0) {
5107
- throw new Error("Daemon installation requires sudo privileges. Please run with sudo.");
5427
+ }
5428
+
5429
+ async function install() {
5430
+ switch (process.platform) {
5431
+ case "darwin":
5432
+ await install$3();
5433
+ break;
5434
+ case "win32":
5435
+ await install$2();
5436
+ break;
5437
+ case "linux":
5438
+ await install$1();
5439
+ break;
5440
+ default:
5441
+ throw new Error(`Daemon installation is not supported on platform: ${process.platform}`);
5108
5442
  }
5109
- types.logger.info("Installing ZenFlo CLI daemon for macOS...");
5110
- await install$1();
5111
5443
  }
5112
5444
 
5113
- const PLIST_LABEL = "com.happy-cli.daemon";
5114
- const PLIST_FILE = `/Library/LaunchDaemons/${PLIST_LABEL}.plist`;
5115
- async function uninstall$1() {
5445
+ const PLIST_LABEL = "com.zenflo.daemon";
5446
+ const LAUNCH_AGENTS_DIR = path.join(os$1.homedir(), "Library", "LaunchAgents");
5447
+ const PLIST_FILE = path.join(LAUNCH_AGENTS_DIR, `${PLIST_LABEL}.plist`);
5448
+ async function uninstall$3() {
5116
5449
  try {
5450
+ console.log(chalk.cyan("\u{1F5D1}\uFE0F Uninstalling ZenFlo daemon LaunchAgent...\n"));
5117
5451
  if (!fs$2.existsSync(PLIST_FILE)) {
5118
- types.logger.info("Daemon plist not found. Nothing to uninstall.");
5452
+ console.log(chalk.yellow("\u26A0\uFE0F LaunchAgent not found. Nothing to uninstall."));
5453
+ console.log(chalk.dim(` Expected location: ${PLIST_FILE}
5454
+ `));
5119
5455
  return;
5120
5456
  }
5121
5457
  try {
5122
- child_process.execSync(`launchctl unload ${PLIST_FILE}`, { stdio: "inherit" });
5123
- types.logger.info("Daemon stopped successfully");
5458
+ child_process.execSync(`launchctl unload "${PLIST_FILE}"`, { stdio: "pipe" });
5459
+ console.log(chalk.green("\u2705 LaunchAgent unloaded"));
5124
5460
  } catch (error) {
5125
- types.logger.info("Failed to unload daemon (it might not be running)");
5461
+ console.log(chalk.dim(" (LaunchAgent was not loaded)\n"));
5126
5462
  }
5127
5463
  fs$2.unlinkSync(PLIST_FILE);
5128
- types.logger.info(`Removed daemon plist from ${PLIST_FILE}`);
5129
- types.logger.info("Daemon uninstalled successfully");
5464
+ console.log(chalk.green("\u2705 Removed LaunchAgent plist\n"));
5465
+ console.log(chalk.green.bold("\u{1F389} Uninstallation complete!\n"));
5466
+ console.log(chalk.cyan("The daemon will no longer:"));
5467
+ console.log(chalk.dim(" \u2022 Start automatically at login"));
5468
+ console.log(chalk.dim(" \u2022 Run in the background\n"));
5469
+ console.log(chalk.cyan("Note: ") + chalk.dim("Auto-start will still work when you run ") + chalk.white("zenflo\n"));
5130
5470
  } catch (error) {
5471
+ console.error(chalk.red("\u274C Uninstallation failed:"), error instanceof Error ? error.message : error);
5131
5472
  types.logger.debug("Failed to uninstall daemon:", error);
5132
5473
  throw error;
5133
5474
  }
5134
5475
  }
5135
5476
 
5136
- async function uninstall() {
5137
- if (process.platform !== "darwin") {
5138
- throw new Error("Daemon uninstallation is currently only supported on macOS");
5477
+ const TASK_NAME = "ZenFlo Daemon";
5478
+ async function uninstall$2() {
5479
+ try {
5480
+ console.log(chalk.cyan("\u{1F5D1}\uFE0F Uninstalling ZenFlo daemon scheduled task...\n"));
5481
+ try {
5482
+ child_process.execSync(`schtasks /Query /TN "${TASK_NAME}"`, { stdio: "pipe" });
5483
+ } catch (error) {
5484
+ console.log(chalk.yellow("\u26A0\uFE0F Scheduled task not found. Nothing to uninstall.\n"));
5485
+ return;
5486
+ }
5487
+ try {
5488
+ child_process.execSync(`schtasks /End /TN "${TASK_NAME}"`, { stdio: "pipe" });
5489
+ console.log(chalk.green("\u2705 Task stopped"));
5490
+ } catch (error) {
5491
+ console.log(chalk.dim(" (Task was not running)\n"));
5492
+ }
5493
+ try {
5494
+ child_process.execSync(`schtasks /Delete /TN "${TASK_NAME}" /F`, { stdio: "pipe" });
5495
+ console.log(chalk.green("\u2705 Scheduled task removed\n"));
5496
+ } catch (error) {
5497
+ throw new Error(`Failed to delete scheduled task: ${error instanceof Error ? error.message : error}`);
5498
+ }
5499
+ console.log(chalk.green.bold("\u{1F389} Uninstallation complete!\n"));
5500
+ console.log(chalk.cyan("The daemon will no longer:"));
5501
+ console.log(chalk.dim(" \u2022 Start automatically at login"));
5502
+ console.log(chalk.dim(" \u2022 Run in the background\n"));
5503
+ console.log(chalk.cyan("Note: ") + chalk.dim("Auto-start will still work when you run ") + chalk.white("zenflo\n"));
5504
+ } catch (error) {
5505
+ console.error(chalk.red("\u274C Uninstallation failed:"), error instanceof Error ? error.message : error);
5506
+ types.logger.debug("Failed to uninstall daemon:", error);
5507
+ throw error;
5139
5508
  }
5140
- if (process.getuid && process.getuid() !== 0) {
5141
- throw new Error("Daemon uninstallation requires sudo privileges. Please run with sudo.");
5509
+ }
5510
+
5511
+ const SERVICE_NAME = "zenflo-daemon";
5512
+ const SYSTEMD_USER_DIR = path.join(os$1.homedir(), ".config", "systemd", "user");
5513
+ const SERVICE_FILE = path.join(SYSTEMD_USER_DIR, `${SERVICE_NAME}.service`);
5514
+ async function uninstall$1() {
5515
+ try {
5516
+ console.log(chalk.cyan("\u{1F5D1}\uFE0F Uninstalling ZenFlo daemon systemd service...\n"));
5517
+ if (!fs$2.existsSync(SERVICE_FILE)) {
5518
+ console.log(chalk.yellow("\u26A0\uFE0F Service not found. Nothing to uninstall."));
5519
+ console.log(chalk.dim(` Expected location: ${SERVICE_FILE}
5520
+ `));
5521
+ return;
5522
+ }
5523
+ try {
5524
+ child_process.execSync(`systemctl --user stop ${SERVICE_NAME}`, { stdio: "pipe" });
5525
+ console.log(chalk.green("\u2705 Service stopped"));
5526
+ } catch (error) {
5527
+ console.log(chalk.dim(" (Service was not running)"));
5528
+ }
5529
+ try {
5530
+ child_process.execSync(`systemctl --user disable ${SERVICE_NAME}`, { stdio: "pipe" });
5531
+ console.log(chalk.green("\u2705 Service disabled"));
5532
+ } catch (error) {
5533
+ console.log(chalk.dim(" (Service was not enabled)"));
5534
+ }
5535
+ fs$2.unlinkSync(SERVICE_FILE);
5536
+ console.log(chalk.green("\u2705 Removed service file\n"));
5537
+ try {
5538
+ child_process.execSync("systemctl --user daemon-reload", { stdio: "pipe" });
5539
+ console.log(chalk.green("\u2705 Reloaded systemd configuration\n"));
5540
+ } catch (error) {
5541
+ console.log(chalk.dim(" (Could not reload systemd)\n"));
5542
+ }
5543
+ console.log(chalk.green.bold("\u{1F389} Uninstallation complete!\n"));
5544
+ console.log(chalk.cyan("The daemon will no longer:"));
5545
+ console.log(chalk.dim(" \u2022 Start automatically at login"));
5546
+ console.log(chalk.dim(" \u2022 Run in the background\n"));
5547
+ console.log(chalk.cyan("Note: ") + chalk.dim("Auto-start will still work when you run ") + chalk.white("zenflo\n"));
5548
+ } catch (error) {
5549
+ console.error(chalk.red("\u274C Uninstallation failed:"), error instanceof Error ? error.message : error);
5550
+ types.logger.debug("Failed to uninstall daemon:", error);
5551
+ throw error;
5552
+ }
5553
+ }
5554
+
5555
+ async function uninstall() {
5556
+ switch (process.platform) {
5557
+ case "darwin":
5558
+ await uninstall$3();
5559
+ break;
5560
+ case "win32":
5561
+ await uninstall$2();
5562
+ break;
5563
+ case "linux":
5564
+ await uninstall$1();
5565
+ break;
5566
+ default:
5567
+ throw new Error(`Daemon uninstallation is not supported on platform: ${process.platform}`);
5142
5568
  }
5143
- types.logger.info("Uninstalling ZenFlo CLI daemon for macOS...");
5144
- await uninstall$1();
5145
5569
  }
5146
5570
 
5147
5571
  async function handleAuthCommand(args) {
@@ -5897,7 +6321,7 @@ async function handleConnectVendor(vendor, displayName) {
5897
6321
  return;
5898
6322
  } else if (subcommand === "codex") {
5899
6323
  try {
5900
- const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-C5pAgp-V.cjs'); });
6324
+ const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-DaGqRdiG.cjs'); });
5901
6325
  let startedBy = void 0;
5902
6326
  for (let i = 1; i < args.length; i++) {
5903
6327
  if (args[i] === "--started-by") {
@@ -5916,6 +6340,27 @@ async function handleConnectVendor(vendor, displayName) {
5916
6340
  process.exit(1);
5917
6341
  }
5918
6342
  return;
6343
+ } else if (subcommand === "ccr" || subcommand === "glm") {
6344
+ try {
6345
+ const { runCCR } = await Promise.resolve().then(function () { return require('./runCCR-CbB0wPJ6.cjs'); });
6346
+ let startedBy = void 0;
6347
+ for (let i = 1; i < args.length; i++) {
6348
+ if (args[i] === "--started-by") {
6349
+ startedBy = args[++i];
6350
+ }
6351
+ }
6352
+ const {
6353
+ credentials
6354
+ } = await authAndSetupMachineIfNeeded();
6355
+ await runCCR({ credentials, startedBy });
6356
+ } catch (error) {
6357
+ console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
6358
+ if (process.env.DEBUG) {
6359
+ console.error(error);
6360
+ }
6361
+ process.exit(1);
6362
+ }
6363
+ return;
5919
6364
  } else if (subcommand === "logout") {
5920
6365
  console.log(chalk.yellow('Note: "happy logout" is deprecated. Use "happy auth logout" instead.\n'));
5921
6366
  try {
@@ -5996,7 +6441,27 @@ async function handleConnectVendor(vendor, displayName) {
5996
6441
  await stopDaemon();
5997
6442
  process.exit(0);
5998
6443
  } else if (daemonSubcommand === "status") {
5999
- await runDoctorCommand("daemon");
6444
+ try {
6445
+ let statusModule;
6446
+ switch (process.platform) {
6447
+ case "darwin":
6448
+ statusModule = await Promise.resolve().then(function () { return require('./status-QtPjWqoQ.cjs'); });
6449
+ break;
6450
+ case "win32":
6451
+ statusModule = await Promise.resolve().then(function () { return require('./status-CXjOWgh0.cjs'); });
6452
+ break;
6453
+ case "linux":
6454
+ statusModule = await Promise.resolve().then(function () { return require('./status-BB4epZ_d.cjs'); });
6455
+ break;
6456
+ default:
6457
+ console.error(chalk.red(`Status command not supported on platform: ${process.platform}`));
6458
+ process.exit(1);
6459
+ }
6460
+ await statusModule.status();
6461
+ } catch (error) {
6462
+ console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
6463
+ process.exit(1);
6464
+ }
6000
6465
  process.exit(0);
6001
6466
  } else if (daemonSubcommand === "logs") {
6002
6467
  const latest = await types.getLatestDaemonLog();
@@ -6211,6 +6676,7 @@ exports.hashObject = hashObject;
6211
6676
  exports.initialMachineMetadata = initialMachineMetadata;
6212
6677
  exports.notifyDaemonSessionStarted = notifyDaemonSessionStarted;
6213
6678
  exports.registerKillSessionHandler = registerKillSessionHandler;
6679
+ exports.runClaude = runClaude;
6214
6680
  exports.startZenfloServer = startZenfloServer;
6215
6681
  exports.stopCaffeinate = stopCaffeinate;
6216
6682
  exports.trimIdent = trimIdent;