dank-ai 1.0.13 → 1.0.14

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