dank-ai 1.0.13 → 1.0.15

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.
@@ -174,11 +174,71 @@ class DockerManager {
174
174
  this.logger.info(`Using Homebrew to install Docker Desktop (found at: ${homebrewPath})...`);
175
175
 
176
176
  try {
177
- // Use the detected Homebrew path
178
- await this.runCommand(`${homebrewPath} install --cask docker`, 'Installing Docker Desktop via Homebrew');
177
+ // First, try to update Homebrew to ensure it's working
178
+ this.logger.info('Updating Homebrew...');
179
+ try {
180
+ const updateCommand = `${homebrewPath} update`;
181
+ this.logger.info(`🔧 About to run command: ${updateCommand}`);
182
+ await this.runCommandWithEnv(updateCommand, 'Updating Homebrew');
183
+ } catch (updateError) {
184
+ this.logger.warn('Homebrew update failed, continuing with installation...');
185
+ }
186
+
187
+ // Try different installation approaches
188
+ let installSuccess = false;
189
+
190
+ // Approach 1: Direct installation
191
+ try {
192
+ this.logger.info('Attempting direct installation...');
193
+ const command1 = `${homebrewPath} install --cask docker`;
194
+ this.logger.info(`🔧 About to run command: ${command1}`);
195
+ await this.runCommandWithEnv(command1, 'Installing Docker Desktop via Homebrew');
196
+ installSuccess = true;
197
+ } catch (error1) {
198
+ this.logger.warn('Direct installation failed, trying alternative approach...');
199
+
200
+ // Approach 2: Try with --force flag
201
+ try {
202
+ this.logger.info('Attempting installation with --force flag...');
203
+ const command2 = `${homebrewPath} install --cask --force docker`;
204
+ this.logger.info(`🔧 About to run command: ${command2}`);
205
+ await this.runCommandWithEnv(command2, 'Installing Docker Desktop via Homebrew (force)');
206
+ installSuccess = true;
207
+ } catch (error2) {
208
+ this.logger.warn('Force installation failed, trying with --no-quarantine flag...');
209
+
210
+ // Approach 3: Try with --no-quarantine flag
211
+ try {
212
+ this.logger.info('Attempting installation with --no-quarantine flag...');
213
+ const command3 = `${homebrewPath} install --cask --no-quarantine docker`;
214
+ this.logger.info(`🔧 About to run command: ${command3}`);
215
+ await this.runCommandWithEnv(command3, 'Installing Docker Desktop via Homebrew (no-quarantine)');
216
+ installSuccess = true;
217
+ } catch (error3) {
218
+ this.logger.error('All installation approaches failed');
219
+ throw error3;
220
+ }
221
+ }
222
+ }
223
+
224
+ if (installSuccess) {
225
+ // Try to start Docker Desktop
226
+ this.logger.info('Starting Docker Desktop...');
227
+ try {
228
+ const startCommand = 'open -a Docker';
229
+ this.logger.info(`🔧 About to run command: ${startCommand}`);
230
+ await this.runCommandWithEnv(startCommand, 'Starting Docker Desktop');
231
+ } catch (startError) {
232
+ this.logger.warn('Could not start Docker Desktop automatically. Please start it manually from Applications.');
233
+ }
234
+ }
235
+
179
236
  } catch (error) {
180
237
  this.logger.warn('Homebrew found but installation failed. Please install Docker Desktop manually from https://www.docker.com/products/docker-desktop/');
181
238
  this.logger.error(`Installation error: ${error.message}`);
239
+ this.logger.info('You can also try installing Docker Desktop manually:');
240
+ this.logger.info('1. Download from: https://www.docker.com/products/docker-desktop/');
241
+ this.logger.info('2. Or try: brew install --cask docker');
182
242
  throw new Error('Docker Desktop installation via Homebrew failed. Please install manually from https://www.docker.com/products/docker-desktop/');
183
243
  }
184
244
  } else {
@@ -347,6 +407,73 @@ class DockerManager {
347
407
  });
348
408
  }
349
409
 
410
+ /**
411
+ * Run a command with proper environment setup for Homebrew
412
+ */
413
+ async runCommandWithEnv(command, description) {
414
+ this.logger.info(`${description}...`);
415
+ this.logger.debug(`Executing command: ${command}`);
416
+
417
+ return new Promise((resolve, reject) => {
418
+ // Set up environment for Homebrew
419
+ const env = {
420
+ ...process.env,
421
+ PATH: process.env.PATH,
422
+ HOMEBREW_NO_AUTO_UPDATE: '1', // Prevent auto-update during installation
423
+ HOMEBREW_NO_INSTALL_CLEANUP: '1' // Keep installation files
424
+ };
425
+
426
+ // Debug: Log environment details
427
+ this.logger.debug(`Environment PATH: ${env.PATH}`);
428
+ this.logger.debug(`HOMEBREW_NO_AUTO_UPDATE: ${env.HOMEBREW_NO_AUTO_UPDATE}`);
429
+ this.logger.debug(`HOMEBREW_NO_INSTALL_CLEANUP: ${env.HOMEBREW_NO_INSTALL_CLEANUP}`);
430
+
431
+ // Use bash instead of sh for better environment support
432
+ const child = spawn('bash', ['-c', command], {
433
+ stdio: ['inherit', 'pipe', 'pipe'],
434
+ shell: true,
435
+ env: env
436
+ });
437
+
438
+ let stdout = '';
439
+ let stderr = '';
440
+
441
+ child.stdout.on('data', (data) => {
442
+ const output = data.toString();
443
+ stdout += output;
444
+ // Log output in debug mode
445
+ this.logger.debug(`STDOUT: ${output.trim()}`);
446
+ });
447
+
448
+ child.stderr.on('data', (data) => {
449
+ const output = data.toString();
450
+ stderr += output;
451
+ // Log stderr in debug mode
452
+ this.logger.debug(`STDERR: ${output.trim()}`);
453
+ });
454
+
455
+ child.on('close', (code) => {
456
+ if (code === 0) {
457
+ this.logger.info(`${description} completed successfully`);
458
+ resolve({ stdout, stderr });
459
+ } else {
460
+ const error = new Error(`Command failed with exit code ${code}: ${stderr}`);
461
+ this.logger.error(`${description} failed: ${error.message}`);
462
+ this.logger.error(`Command: ${command}`);
463
+ this.logger.error(`STDOUT: ${stdout}`);
464
+ this.logger.error(`STDERR: ${stderr}`);
465
+ reject(error);
466
+ }
467
+ });
468
+
469
+ child.on('error', (error) => {
470
+ this.logger.error(`${description} failed: ${error.message}`);
471
+ this.logger.error(`Command: ${command}`);
472
+ reject(error);
473
+ });
474
+ });
475
+ }
476
+
350
477
  /**
351
478
  * Sleep utility
352
479
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dank-ai",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Dank Agent Service - Docker-based AI agent orchestration platform",
5
5
  "main": "lib/index.js",
6
6
  "exports": {