@agentorchestrationprotocol/cli-dev 0.1.14 → 0.1.16
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.
- package/index.mjs +93 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -126,7 +126,7 @@ if (isRun) {
|
|
|
126
126
|
overwriteOrchestrations,
|
|
127
127
|
});
|
|
128
128
|
} else {
|
|
129
|
-
await
|
|
129
|
+
await runSetup({
|
|
130
130
|
apiBaseUrl,
|
|
131
131
|
appUrl,
|
|
132
132
|
scopes,
|
|
@@ -479,6 +479,98 @@ async function runOrchestrationsCommand({
|
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
+
async function runSetup({
|
|
483
|
+
apiBaseUrl,
|
|
484
|
+
appUrl,
|
|
485
|
+
scopes,
|
|
486
|
+
agentName,
|
|
487
|
+
agentModel,
|
|
488
|
+
tokenPathOverride,
|
|
489
|
+
orchestrationsPathOverride,
|
|
490
|
+
installOrchestrations,
|
|
491
|
+
overwriteOrchestrations,
|
|
492
|
+
}) {
|
|
493
|
+
const candidatePaths = tokenPathOverride
|
|
494
|
+
? [tokenPathOverride]
|
|
495
|
+
: [HOME_TOKEN_PATH, CWD_TOKEN_PATH];
|
|
496
|
+
|
|
497
|
+
for (const p of candidatePaths) {
|
|
498
|
+
let existing;
|
|
499
|
+
try {
|
|
500
|
+
existing = JSON.parse(await readFile(p, "utf8"));
|
|
501
|
+
} catch {
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
if (!existing?.apiKey) continue;
|
|
505
|
+
|
|
506
|
+
const prefix = existing.apiKey.split("_").slice(0, 2).join("_");
|
|
507
|
+
console.log("");
|
|
508
|
+
console.log(` ${c.bold}${c.cyan}AOP [dev]${c.reset} ${c.dim}Agent Orchestration Protocol${c.reset}`);
|
|
509
|
+
console.log("");
|
|
510
|
+
console.log(` ${c.yellow}!${c.reset} Found existing credentials at ${c.bold}${p}${c.reset}`);
|
|
511
|
+
console.log(` ${c.dim}Key prefix: ${prefix}_...${c.reset}`);
|
|
512
|
+
console.log("");
|
|
513
|
+
|
|
514
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
515
|
+
let answer;
|
|
516
|
+
try {
|
|
517
|
+
answer = await new Promise((resolve) => {
|
|
518
|
+
rl.question(
|
|
519
|
+
` Reuse this key? ${c.dim}[Y/n]${c.reset} `,
|
|
520
|
+
(a) => resolve(a.trim().toLowerCase()),
|
|
521
|
+
);
|
|
522
|
+
});
|
|
523
|
+
} finally {
|
|
524
|
+
rl.close();
|
|
525
|
+
process.stdin.unref();
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
if (answer === "" || answer === "y" || answer === "yes") {
|
|
529
|
+
if (installOrchestrations) {
|
|
530
|
+
const storageTargets = {
|
|
531
|
+
tokenPath: p,
|
|
532
|
+
orchestrationsPath: orchestrationsPathOverride ||
|
|
533
|
+
(p === HOME_TOKEN_PATH ? HOME_ORCHESTRATIONS_PATH : CWD_ORCHESTRATIONS_PATH),
|
|
534
|
+
};
|
|
535
|
+
try {
|
|
536
|
+
const orchestrationInstall = await installBundledOrchestrations({
|
|
537
|
+
destinationPath: storageTargets.orchestrationsPath,
|
|
538
|
+
overwrite: overwriteOrchestrations,
|
|
539
|
+
});
|
|
540
|
+
if (orchestrationInstall.status === "installed") {
|
|
541
|
+
console.log(` ${c.green}✔${c.reset} Orchestrations installed to ${c.bold}${storageTargets.orchestrationsPath}${c.reset}`);
|
|
542
|
+
} else if (orchestrationInstall.status === "overwritten") {
|
|
543
|
+
console.log(` ${c.green}✔${c.reset} Orchestrations refreshed at ${c.bold}${storageTargets.orchestrationsPath}${c.reset}`);
|
|
544
|
+
} else {
|
|
545
|
+
console.log(` ${c.yellow}!${c.reset} Orchestrations already exist ${c.dim}(use --overwrite-orchestrations to refresh)${c.reset}`);
|
|
546
|
+
}
|
|
547
|
+
} catch (err) {
|
|
548
|
+
console.log(` ${c.yellow}!${c.reset} Orchestrations install failed: ${toErrorMessage(err)}`);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
console.log("");
|
|
552
|
+
console.log(` ${c.green}✔${c.reset} Using existing credentials. Run ${c.bold}cli-dev run${c.reset} to start working.`);
|
|
553
|
+
console.log("");
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
console.log("");
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
await runDeviceFlow({
|
|
562
|
+
apiBaseUrl,
|
|
563
|
+
appUrl,
|
|
564
|
+
scopes,
|
|
565
|
+
agentName,
|
|
566
|
+
agentModel,
|
|
567
|
+
tokenPathOverride,
|
|
568
|
+
orchestrationsPathOverride,
|
|
569
|
+
installOrchestrations,
|
|
570
|
+
overwriteOrchestrations,
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
|
|
482
574
|
async function runDeviceFlow({
|
|
483
575
|
apiBaseUrl,
|
|
484
576
|
appUrl,
|