@orchagent/cli 0.2.4 → 0.2.5

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.
@@ -289,7 +289,9 @@ async function unzipBundle(zipPath, destDir) {
289
289
  });
290
290
  });
291
291
  }
292
- async function executeBundleAgent(config, org, agentName, version, agentData, args) {
292
+ async function executeBundleAgent(config, org, agentName, version, agentData, args, inputOption) {
293
+ // Capture the user's working directory before we change anything
294
+ const userCwd = process.cwd();
293
295
  // Create temp directory for the bundle
294
296
  const tempDir = path_1.default.join(os_1.default.tmpdir(), `orchagent-${agentName}-${Date.now()}`);
295
297
  await promises_1.default.mkdir(tempDir, { recursive: true });
@@ -331,30 +333,50 @@ async function executeBundleAgent(config, org, agentName, version, agentData, ar
331
333
  catch {
332
334
  throw new errors_1.CliError(`Entrypoint not found: ${entrypoint}`);
333
335
  }
334
- // Build input JSON from args
335
- // The first arg should be the input (file path or JSON string)
336
+ // Build input JSON from --input option or positional args
336
337
  let inputJson = '{}';
337
- if (args.length > 0) {
338
+ if (inputOption) {
339
+ // --input was provided, use it directly (should be valid JSON)
340
+ try {
341
+ // Parse and re-stringify to validate JSON
342
+ const parsed = JSON.parse(inputOption);
343
+ // Resolve any relative paths in the input to absolute paths
344
+ if (typeof parsed === 'object' && parsed !== null) {
345
+ for (const key of ['path', 'directory', 'file_path']) {
346
+ if (typeof parsed[key] === 'string' && !path_1.default.isAbsolute(parsed[key])) {
347
+ parsed[key] = path_1.default.resolve(userCwd, parsed[key]);
348
+ }
349
+ }
350
+ }
351
+ inputJson = JSON.stringify(parsed);
352
+ }
353
+ catch {
354
+ throw new errors_1.CliError('Invalid JSON in --input option');
355
+ }
356
+ }
357
+ else if (args.length > 0) {
338
358
  const firstArg = args[0];
359
+ // Resolve to absolute path relative to user's working directory
360
+ const resolvedArg = path_1.default.isAbsolute(firstArg) ? firstArg : path_1.default.resolve(userCwd, firstArg);
339
361
  // Check if it's a file path
340
362
  try {
341
- const stat = await promises_1.default.stat(firstArg);
363
+ const stat = await promises_1.default.stat(resolvedArg);
342
364
  if (stat.isFile()) {
343
365
  // Read file content as input
344
- const fileContent = await promises_1.default.readFile(firstArg, 'utf-8');
366
+ const fileContent = await promises_1.default.readFile(resolvedArg, 'utf-8');
345
367
  // Check if it's already JSON
346
368
  try {
347
369
  JSON.parse(fileContent);
348
370
  inputJson = fileContent;
349
371
  }
350
372
  catch {
351
- // Wrap as file_path in JSON
352
- inputJson = JSON.stringify({ file_path: firstArg });
373
+ // Wrap as file_path in JSON (use absolute path)
374
+ inputJson = JSON.stringify({ file_path: resolvedArg });
353
375
  }
354
376
  }
355
377
  else if (stat.isDirectory()) {
356
- // Pass directory path
357
- inputJson = JSON.stringify({ directory: firstArg });
378
+ // Pass directory path (use absolute path)
379
+ inputJson = JSON.stringify({ directory: resolvedArg });
358
380
  }
359
381
  }
360
382
  catch {
@@ -364,7 +386,7 @@ async function executeBundleAgent(config, org, agentName, version, agentData, ar
364
386
  inputJson = firstArg;
365
387
  }
366
388
  catch {
367
- // Treat as a simple string input
389
+ // Treat as a simple string input (could be a URL)
368
390
  inputJson = JSON.stringify({ input: firstArg });
369
391
  }
370
392
  }
@@ -536,7 +558,7 @@ function registerRunCommand(program) {
536
558
  return;
537
559
  }
538
560
  // Execute the bundle-based code agent locally
539
- await executeBundleAgent(resolved, org, parsed.agent, parsed.version, agentData, args);
561
+ await executeBundleAgent(resolved, org, parsed.agent, parsed.version, agentData, args, options.input);
540
562
  return;
541
563
  }
542
564
  // Check for pip/source-based local execution (legacy)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orchagent/cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Command-line interface for the OrchAgent AI agent marketplace",
5
5
  "license": "MIT",
6
6
  "author": "OrchAgent <hello@orchagent.io>",