@orchagent/cli 0.2.3 → 0.2.4

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.
@@ -390,29 +390,47 @@ async function executeBundleAgent(config, org, agentName, version, agentData, ar
390
390
  stderr += text;
391
391
  process.stderr.write(text);
392
392
  });
393
- await new Promise((resolve, reject) => {
393
+ const exitCode = await new Promise((resolve) => {
394
394
  proc.on('close', (code) => {
395
- if (code !== 0) {
396
- reject(new errors_1.CliError(`Agent exited with code ${code}`));
397
- }
398
- else {
399
- resolve();
400
- }
395
+ resolve(code ?? 1);
401
396
  });
402
397
  proc.on('error', (err) => {
403
- reject(err);
398
+ process.stderr.write(`Error running agent: ${err.message}\n`);
399
+ resolve(1);
404
400
  });
405
401
  });
406
- // Parse and print the output
402
+ // Handle output - check for errors in stdout even on failure
407
403
  if (stdout.trim()) {
408
404
  try {
409
405
  const result = JSON.parse(stdout.trim());
406
+ // Check if it's an error response
407
+ if (exitCode !== 0 && typeof result === 'object' && result !== null && 'error' in result) {
408
+ throw new errors_1.CliError(`Agent error: ${result.error}`);
409
+ }
410
+ if (exitCode !== 0) {
411
+ // Non-zero exit but output isn't an error object - show it and fail
412
+ (0, output_1.printJson)(result);
413
+ throw new errors_1.CliError(`Agent exited with code ${exitCode}`);
414
+ }
415
+ // Success - print result
410
416
  (0, output_1.printJson)(result);
411
417
  }
412
- catch {
418
+ catch (err) {
419
+ if (err instanceof errors_1.CliError)
420
+ throw err;
413
421
  // Not JSON, print as-is
414
422
  process.stdout.write(stdout);
423
+ if (exitCode !== 0) {
424
+ throw new errors_1.CliError(`Agent exited with code ${exitCode}`);
425
+ }
426
+ }
427
+ }
428
+ else if (exitCode !== 0) {
429
+ // No stdout, check stderr
430
+ if (stderr.trim()) {
431
+ throw new errors_1.CliError(`Agent error: ${stderr.trim()}`);
415
432
  }
433
+ throw new errors_1.CliError(`Agent exited with code ${exitCode} (no output)`);
416
434
  }
417
435
  }
418
436
  finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orchagent/cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Command-line interface for the OrchAgent AI agent marketplace",
5
5
  "license": "MIT",
6
6
  "author": "OrchAgent <hello@orchagent.io>",