agens-studio 0.1.3 → 0.1.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.
- package/cli.js +21 -0
- package/config.js +3 -1
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -469,9 +469,25 @@ async function mainMenu() {
|
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
471
|
|
|
472
|
+
/**
|
|
473
|
+
* 检查 API 是否已配置,未配置时自动引导 setup wizard
|
|
474
|
+
* @returns {Promise<boolean>} true = 已配置可继续,false = 用户取消
|
|
475
|
+
*/
|
|
476
|
+
async function ensureApiConfigured() {
|
|
477
|
+
if (config.agens.image.apiKey) return true;
|
|
478
|
+
console.log(`\n${C.red}${C.bold} ⚠ API Key 未配置,无法生成${C.reset}`);
|
|
479
|
+
console.log(`${C.gray} 请先配置 Agnes API Key 后重试${C.reset}\n`);
|
|
480
|
+
const go = await confirm('是否现在配置 API Key');
|
|
481
|
+
if (go) {
|
|
482
|
+
await setupWizard(false);
|
|
483
|
+
}
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
|
|
472
487
|
// ═══════════════════ [1] 文生图 ═══════════════════
|
|
473
488
|
|
|
474
489
|
async function modeText2Image() {
|
|
490
|
+
if (!(await ensureApiConfigured())) return;
|
|
475
491
|
console.log(`\n${C.bold}─────── 文生图 ───────${C.reset}`);
|
|
476
492
|
|
|
477
493
|
const rawPrompt = await ask('描述你想生成的画面');
|
|
@@ -511,6 +527,7 @@ async function modeText2Image() {
|
|
|
511
527
|
// ═══════════════════ [2] 图生图 ═══════════════════
|
|
512
528
|
|
|
513
529
|
async function modeImage2Image() {
|
|
530
|
+
if (!(await ensureApiConfigured())) return;
|
|
514
531
|
console.log(`\n${C.bold}─────── 图生图 ───────${C.reset}`);
|
|
515
532
|
console.log(`${C.gray}输入参考图片的本地文件路径(支持拖拽文件到窗口)${C.reset}`);
|
|
516
533
|
|
|
@@ -598,6 +615,7 @@ async function callVisionDirect(dataUri) {
|
|
|
598
615
|
// ═══════════════════ [3] 文生视频 ═══════════════════
|
|
599
616
|
|
|
600
617
|
async function modeText2Video() {
|
|
618
|
+
if (!(await ensureApiConfigured())) return;
|
|
601
619
|
console.log(`\n${C.bold}─────── 文生视频 ───────${C.reset}`);
|
|
602
620
|
|
|
603
621
|
const rawPrompt = await ask('描述你想生成的视频场景');
|
|
@@ -644,6 +662,7 @@ async function modeText2Video() {
|
|
|
644
662
|
// ═══════════════════ [4] 图生视频 ═══════════════════
|
|
645
663
|
|
|
646
664
|
async function modeImage2Video() {
|
|
665
|
+
if (!(await ensureApiConfigured())) return;
|
|
647
666
|
console.log(`\n${C.bold}─────── 图生视频 ───────${C.reset}`);
|
|
648
667
|
console.log(`${C.gray}输入参考图片路径(支持拖拽)${C.reset}`);
|
|
649
668
|
|
|
@@ -696,6 +715,7 @@ async function modeImage2Video() {
|
|
|
696
715
|
// ═══════════════════ [5] 多图生视频 ═══════════════════
|
|
697
716
|
|
|
698
717
|
async function modeMulti2Video() {
|
|
718
|
+
if (!(await ensureApiConfigured())) return;
|
|
699
719
|
console.log(`\n${C.bold}─────── 多图生视频 ───────${C.reset}`);
|
|
700
720
|
console.log(`${C.gray}输入多张图片路径,生成过渡视频(2-5 张)${C.reset}`);
|
|
701
721
|
|
|
@@ -758,6 +778,7 @@ async function modeMulti2Video() {
|
|
|
758
778
|
// ═══════════════════ [6] 关键帧动画 ═══════════════════
|
|
759
779
|
|
|
760
780
|
async function modeKeyframe() {
|
|
781
|
+
if (!(await ensureApiConfigured())) return;
|
|
761
782
|
console.log(`\n${C.bold}─────── 关键帧动画 ───────${C.reset}`);
|
|
762
783
|
console.log(`${C.gray}至少输入首帧和尾帧图片(2-5 张关键帧)${C.reset}`);
|
|
763
784
|
|
package/config.js
CHANGED
|
@@ -132,7 +132,9 @@ export function saveUserConfig(cfg) {
|
|
|
132
132
|
*/
|
|
133
133
|
export function readUserConfig() {
|
|
134
134
|
try {
|
|
135
|
-
|
|
135
|
+
const data = JSON.parse(fs.readFileSync(USER_CONFIG_FILE, 'utf8'));
|
|
136
|
+
if (data && typeof data === 'object' && Object.keys(data).length > 0) return data;
|
|
137
|
+
return null;
|
|
136
138
|
} catch {
|
|
137
139
|
return null;
|
|
138
140
|
}
|