@optima-chat/gen-cli 1.0.0
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/dist/backends/bfl.d.ts +18 -0
- package/dist/backends/bfl.d.ts.map +1 -0
- package/dist/backends/bfl.js +130 -0
- package/dist/backends/bfl.js.map +1 -0
- package/dist/backends/comfyui.d.ts +10 -0
- package/dist/backends/comfyui.d.ts.map +1 -0
- package/dist/backends/comfyui.js +121 -0
- package/dist/backends/comfyui.js.map +1 -0
- package/dist/backends/index.d.ts +24 -0
- package/dist/backends/index.d.ts.map +1 -0
- package/dist/backends/index.js +59 -0
- package/dist/backends/index.js.map +1 -0
- package/dist/backends/types.d.ts +99 -0
- package/dist/backends/types.d.ts.map +1 -0
- package/dist/backends/types.js +2 -0
- package/dist/backends/types.js.map +1 -0
- package/dist/backends/video-dashscope.d.ts +10 -0
- package/dist/backends/video-dashscope.d.ts.map +1 -0
- package/dist/backends/video-dashscope.js +108 -0
- package/dist/backends/video-dashscope.js.map +1 -0
- package/dist/backends/video-index.d.ts +23 -0
- package/dist/backends/video-index.d.ts.map +1 -0
- package/dist/backends/video-index.js +57 -0
- package/dist/backends/video-index.js.map +1 -0
- package/dist/commands/asr.d.ts +3 -0
- package/dist/commands/asr.d.ts.map +1 -0
- package/dist/commands/asr.js +133 -0
- package/dist/commands/asr.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +105 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/download.d.ts +3 -0
- package/dist/commands/download.d.ts.map +1 -0
- package/dist/commands/download.js +169 -0
- package/dist/commands/download.js.map +1 -0
- package/dist/commands/edit.d.ts +3 -0
- package/dist/commands/edit.d.ts.map +1 -0
- package/dist/commands/edit.js +155 -0
- package/dist/commands/edit.js.map +1 -0
- package/dist/commands/generate.d.ts +3 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +135 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/image.d.ts +3 -0
- package/dist/commands/image.d.ts.map +1 -0
- package/dist/commands/image.js +139 -0
- package/dist/commands/image.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +144 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/interrupt.d.ts +3 -0
- package/dist/commands/interrupt.d.ts.map +1 -0
- package/dist/commands/interrupt.js +54 -0
- package/dist/commands/interrupt.js.map +1 -0
- package/dist/commands/model.d.ts +3 -0
- package/dist/commands/model.d.ts.map +1 -0
- package/dist/commands/model.js +82 -0
- package/dist/commands/model.js.map +1 -0
- package/dist/commands/node.d.ts +3 -0
- package/dist/commands/node.d.ts.map +1 -0
- package/dist/commands/node.js +148 -0
- package/dist/commands/node.js.map +1 -0
- package/dist/commands/queue.d.ts +3 -0
- package/dist/commands/queue.d.ts.map +1 -0
- package/dist/commands/queue.js +199 -0
- package/dist/commands/queue.js.map +1 -0
- package/dist/commands/system.d.ts +3 -0
- package/dist/commands/system.d.ts.map +1 -0
- package/dist/commands/system.js +85 -0
- package/dist/commands/system.js.map +1 -0
- package/dist/commands/task.d.ts +3 -0
- package/dist/commands/task.d.ts.map +1 -0
- package/dist/commands/task.js +176 -0
- package/dist/commands/task.js.map +1 -0
- package/dist/commands/tryon.d.ts +3 -0
- package/dist/commands/tryon.d.ts.map +1 -0
- package/dist/commands/tryon.js +178 -0
- package/dist/commands/tryon.js.map +1 -0
- package/dist/commands/tts.d.ts +3 -0
- package/dist/commands/tts.d.ts.map +1 -0
- package/dist/commands/tts.js +157 -0
- package/dist/commands/tts.js.map +1 -0
- package/dist/commands/video.d.ts +3 -0
- package/dist/commands/video.d.ts.map +1 -0
- package/dist/commands/video.js +137 -0
- package/dist/commands/video.js.map +1 -0
- package/dist/commands/workflow.d.ts +3 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/commands/workflow.js +244 -0
- package/dist/commands/workflow.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/services/api.d.ts +23 -0
- package/dist/services/api.d.ts.map +1 -0
- package/dist/services/api.js +108 -0
- package/dist/services/api.js.map +1 -0
- package/dist/services/auth.d.ts +10 -0
- package/dist/services/auth.d.ts.map +1 -0
- package/dist/services/auth.js +34 -0
- package/dist/services/auth.js.map +1 -0
- package/dist/services/bfl-api.d.ts +67 -0
- package/dist/services/bfl-api.d.ts.map +1 -0
- package/dist/services/bfl-api.js +108 -0
- package/dist/services/bfl-api.js.map +1 -0
- package/dist/services/config.d.ts +12 -0
- package/dist/services/config.d.ts.map +1 -0
- package/dist/services/config.js +30 -0
- package/dist/services/config.js.map +1 -0
- package/dist/services/dashscope-api.d.ts +69 -0
- package/dist/services/dashscope-api.d.ts.map +1 -0
- package/dist/services/dashscope-api.js +134 -0
- package/dist/services/dashscope-api.js.map +1 -0
- package/dist/services/dashscope-tts-api.d.ts +23 -0
- package/dist/services/dashscope-tts-api.d.ts.map +1 -0
- package/dist/services/dashscope-tts-api.js +56 -0
- package/dist/services/dashscope-tts-api.js.map +1 -0
- package/dist/services/fashn-api.d.ts +57 -0
- package/dist/services/fashn-api.d.ts.map +1 -0
- package/dist/services/fashn-api.js +84 -0
- package/dist/services/fashn-api.js.map +1 -0
- package/dist/services/generation-api.d.ts +139 -0
- package/dist/services/generation-api.d.ts.map +1 -0
- package/dist/services/generation-api.js +236 -0
- package/dist/services/generation-api.js.map +1 -0
- package/dist/services/groq-api.d.ts +18 -0
- package/dist/services/groq-api.d.ts.map +1 -0
- package/dist/services/groq-api.js +30 -0
- package/dist/services/groq-api.js.map +1 -0
- package/dist/services/websocket.d.ts +33 -0
- package/dist/services/websocket.d.ts.map +1 -0
- package/dist/services/websocket.js +217 -0
- package/dist/services/websocket.js.map +1 -0
- package/dist/utils/helpText.d.ts +15 -0
- package/dist/utils/helpText.d.ts.map +1 -0
- package/dist/utils/helpText.js +37 -0
- package/dist/utils/helpText.js.map +1 -0
- package/dist/utils/logger.d.ts +5 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +14 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/output.d.ts +54 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +76 -0
- package/dist/utils/output.js.map +1 -0
- package/dist/utils/workflow.d.ts +17 -0
- package/dist/utils/workflow.d.ts.map +1 -0
- package/dist/utils/workflow.js +81 -0
- package/dist/utils/workflow.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { success, info } from '../utils/logger.js';
|
|
5
|
+
import { outputSuccess, outputError, isPrettyMode } from '../utils/output.js';
|
|
6
|
+
import { addEnhancedHelp } from '../utils/helpText.js';
|
|
7
|
+
import { getConfigValue } from '../services/config.js';
|
|
8
|
+
import { GenerationApiClient, GenerationApiError, validateVideoParams, fileToBase64, downloadResult, } from '../services/generation-api.js';
|
|
9
|
+
export function registerVideoCommand(program) {
|
|
10
|
+
const cmd = program
|
|
11
|
+
.command('video')
|
|
12
|
+
.description('生成视频(图生视频)- 通过 optima-generation 调用 DashScope wan2.6')
|
|
13
|
+
.argument('<image>', '输入图像路径')
|
|
14
|
+
.option('-p, --prompt <text>', '运动描述提示词', '')
|
|
15
|
+
.option('-n, --negative <text>', '负向提示词', '')
|
|
16
|
+
.option('-r, --resolution <res>', '分辨率: 720P | 1080P', '1080P')
|
|
17
|
+
.option('-d, --duration <seconds>', '视频时长: 5 | 10 秒', '5')
|
|
18
|
+
.option('--prompt-extend', '启用智能改写 prompt (默认开启)')
|
|
19
|
+
.option('--no-prompt-extend', '禁用智能改写 prompt')
|
|
20
|
+
.option('--audio', '启用自动配音 (默认开启)')
|
|
21
|
+
.option('--no-audio', '禁用自动配音')
|
|
22
|
+
.option('--audio-url <url>', '自定义音频 URL')
|
|
23
|
+
.option('--shot-type <type>', '镜头类型: single | multi', 'single')
|
|
24
|
+
.option('--watermark', '添加 AI 生成水印')
|
|
25
|
+
.option('--seed <number>', '随机种子')
|
|
26
|
+
.option('-o, --output <dir>', '输出目录', '')
|
|
27
|
+
.action(async (image, options) => {
|
|
28
|
+
const pretty = isPrettyMode(options);
|
|
29
|
+
try {
|
|
30
|
+
const imagePath = path.resolve(image);
|
|
31
|
+
if (!fs.existsSync(imagePath)) {
|
|
32
|
+
outputError('IMAGE_NOT_FOUND', `图像文件不存在: ${imagePath}`, options);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const duration = parseInt(options.duration);
|
|
36
|
+
const resolution = options.resolution;
|
|
37
|
+
// CLI 层快速校验
|
|
38
|
+
validateVideoParams({ duration, resolution });
|
|
39
|
+
const imageBase64 = await fileToBase64(imagePath);
|
|
40
|
+
const params = {
|
|
41
|
+
image: imageBase64,
|
|
42
|
+
prompt: options.prompt || undefined,
|
|
43
|
+
negative_prompt: options.negative || undefined,
|
|
44
|
+
resolution: resolution,
|
|
45
|
+
duration,
|
|
46
|
+
prompt_extend: options.promptExtend,
|
|
47
|
+
audio: options.audio,
|
|
48
|
+
audio_url: options.audioUrl,
|
|
49
|
+
shot_type: options.shotType,
|
|
50
|
+
watermark: options.watermark || false,
|
|
51
|
+
seed: options.seed ? parseInt(options.seed) : undefined,
|
|
52
|
+
};
|
|
53
|
+
const client = new GenerationApiClient();
|
|
54
|
+
const outputDir = options.output || getConfigValue('outputDir') || './gen-output';
|
|
55
|
+
const spinner = pretty ? ora('正在提交视频生成任务...').start() : null;
|
|
56
|
+
if (pretty)
|
|
57
|
+
spinner.text = '正在生成视频(预计 1-5 分钟)...';
|
|
58
|
+
const result = await client.submitAndPoll('video', params, {
|
|
59
|
+
onProgress: (status) => {
|
|
60
|
+
if (pretty)
|
|
61
|
+
spinner.text = `视频生成中 (${status})...`;
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
if (result.status === 'completed' && result.result_url) {
|
|
65
|
+
const filename = `video_${result.task_id.slice(0, 8)}.mp4`;
|
|
66
|
+
const outputPath = await downloadResult(result.result_url, outputDir, filename);
|
|
67
|
+
if (pretty) {
|
|
68
|
+
spinner.succeed('视频生成完成!');
|
|
69
|
+
success(`输出文件: ${outputPath}`);
|
|
70
|
+
info(`任务 ID: ${result.task_id}`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
outputSuccess({
|
|
74
|
+
task_id: result.task_id,
|
|
75
|
+
status: result.status,
|
|
76
|
+
output: outputPath,
|
|
77
|
+
result_url: result.result_url,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
if (pretty) {
|
|
83
|
+
spinner.info(`任务状态: ${result.status}`);
|
|
84
|
+
if (result.error_message)
|
|
85
|
+
info(`错误: ${result.error_message}`);
|
|
86
|
+
info(`使用 'gen task get ${result.task_id}' 查看最新状态`);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
outputSuccess({
|
|
90
|
+
task_id: result.task_id,
|
|
91
|
+
status: result.status,
|
|
92
|
+
error_message: result.error_message,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
if (err instanceof GenerationApiError) {
|
|
99
|
+
outputError(err.code, err.message, options);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
outputError('VIDEO_FAILED', `生成失败: ${err}`, options);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
addEnhancedHelp(cmd, {
|
|
107
|
+
examples: [
|
|
108
|
+
'# 基本用法',
|
|
109
|
+
'$ gen video cat.png --prompt "cat walking"',
|
|
110
|
+
'',
|
|
111
|
+
'# 高清长视频',
|
|
112
|
+
'$ gen video cat.png --duration 10 --resolution 1080P',
|
|
113
|
+
'',
|
|
114
|
+
'# 禁用自动配音',
|
|
115
|
+
'$ gen video cat.png --no-audio',
|
|
116
|
+
],
|
|
117
|
+
outputJson: `{
|
|
118
|
+
"success": true,
|
|
119
|
+
"data": {
|
|
120
|
+
"task_id": "abc-123-def",
|
|
121
|
+
"status": "completed",
|
|
122
|
+
"output": "./gen-output/video_abc123.mp4"
|
|
123
|
+
}
|
|
124
|
+
}`,
|
|
125
|
+
relatedCommands: [
|
|
126
|
+
{ command: 'task get <id>', description: '查看任务状态' },
|
|
127
|
+
{ command: 'image <prompt>', description: '生成图像' },
|
|
128
|
+
],
|
|
129
|
+
notes: [
|
|
130
|
+
'通过 optima-generation 调用 DashScope wan2.6-i2v 模型',
|
|
131
|
+
'需要 Optima 账号(OPTIMA_TOKEN 或 ~/.optima/token.json)',
|
|
132
|
+
'支持 720P/1080P,5/10 秒',
|
|
133
|
+
'视频生成需要 1-5 分钟',
|
|
134
|
+
],
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=video.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video.js","sourceRoot":"","sources":["../../src/commands/video.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAElB,mBAAmB,EACnB,YAAY,EACZ,cAAc,GACf,MAAM,+BAA+B,CAAC;AAEvC,MAA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;YACH,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,kBAAkB,EAAE,CAAC;gBACtC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC;iBAAM,CAAC;gBACN,WAAW,CAAC,cAAc,EAAE,SAAS,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,eAAe,CAAC,GAAG,EAAE;QACnB,QAAQ,EAAE;YACR,QAAQ;YACR,4CAA4C;YAC5C,EAAE;YACF,SAAS;YACT,sDAAsD;YACtD,EAAE;YACF,UAAU;YACV,gCAAgC;SACjC;QACD,UAAU,EAAE;;;;;;;EAOd;QACE,eAAe,EAAE;YACf,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE;YACnD,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE;SACnD;QACD,KAAK,EAAE;YACL,iDAAiD;YACjD,mDAAmD;YACnD,sBAAsB;YACtB,eAAe;SAChB;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/commands/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,QA+PvD"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { ComfyAPIClient } from '../services/api.js';
|
|
2
|
+
import { loadWorkflow, extractVariables } from '../utils/workflow.js';
|
|
3
|
+
import { success, info } from '../utils/logger.js';
|
|
4
|
+
import { outputSuccess, outputError, isPrettyMode } from '../utils/output.js';
|
|
5
|
+
import { addEnhancedHelp } from '../utils/helpText.js';
|
|
6
|
+
import Table from 'cli-table3';
|
|
7
|
+
export function registerWorkflowCommand(program) {
|
|
8
|
+
const workflowCmd = program
|
|
9
|
+
.command('workflow')
|
|
10
|
+
.description('工作流管理');
|
|
11
|
+
// comfy workflow submit
|
|
12
|
+
const submitCmd = workflowCmd
|
|
13
|
+
.command('submit')
|
|
14
|
+
.description('提交工作流 - 提交自定义 ComfyUI workflow JSON 文件')
|
|
15
|
+
.argument('<file>', 'workflow JSON 文件路径')
|
|
16
|
+
.option('--wait', '等待执行完成')
|
|
17
|
+
.action(async (file, options) => {
|
|
18
|
+
const pretty = isPrettyMode(options);
|
|
19
|
+
try {
|
|
20
|
+
if (pretty) {
|
|
21
|
+
info(`正在加载工作流: ${file}`);
|
|
22
|
+
}
|
|
23
|
+
// 加载 workflow
|
|
24
|
+
const workflow = loadWorkflow(file);
|
|
25
|
+
// 提取变量
|
|
26
|
+
const variables = extractVariables(workflow);
|
|
27
|
+
if (pretty && variables.length > 0) {
|
|
28
|
+
info(`检测到 ${variables.length} 个变量: ${variables.join(', ')}`);
|
|
29
|
+
info('提示: 使用 generate/edit/video 命令可以自动填充这些变量');
|
|
30
|
+
}
|
|
31
|
+
// 提交到 ComfyUI
|
|
32
|
+
const client = new ComfyAPIClient();
|
|
33
|
+
const result = await client.submitWorkflow(workflow);
|
|
34
|
+
if (pretty) {
|
|
35
|
+
success(`工作流已提交`);
|
|
36
|
+
info(`Prompt ID: ${result.prompt_id}`);
|
|
37
|
+
if (options.wait) {
|
|
38
|
+
info('等待执行完成...');
|
|
39
|
+
// TODO: 实现 WebSocket 监控
|
|
40
|
+
info('WebSocket 监控功能即将推出');
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
info(`使用 'comfy workflow get ${result.prompt_id}' 查看结果`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
outputSuccess({
|
|
48
|
+
prompt_id: result.prompt_id,
|
|
49
|
+
variables: variables.length > 0 ? variables : undefined,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
outputError('WORKFLOW_SUBMIT_FAILED', `提交失败: ${err}`, options);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
// Add enhanced help for submit command
|
|
58
|
+
addEnhancedHelp(submitCmd, {
|
|
59
|
+
examples: [
|
|
60
|
+
'# 提交工作流',
|
|
61
|
+
'$ comfy workflow submit my-workflow.json',
|
|
62
|
+
'',
|
|
63
|
+
'# 提交并等待完成',
|
|
64
|
+
'$ comfy workflow submit my-workflow.json --wait',
|
|
65
|
+
],
|
|
66
|
+
outputJson: `{
|
|
67
|
+
"success": true,
|
|
68
|
+
"data": {
|
|
69
|
+
"prompt_id": "abc-123-def",
|
|
70
|
+
"variables": ["prompt", "width"]
|
|
71
|
+
}
|
|
72
|
+
}`,
|
|
73
|
+
relatedCommands: [
|
|
74
|
+
{ command: 'workflow list', description: '查看工作流历史' },
|
|
75
|
+
{ command: 'workflow get <id>', description: '查看工作流结果' },
|
|
76
|
+
{ command: 'download <id>', description: '下载输出结果' },
|
|
77
|
+
],
|
|
78
|
+
notes: [
|
|
79
|
+
'workflow 文件为标准 ComfyUI workflow JSON 格式',
|
|
80
|
+
'支持变量替换(使用 {{variable_name}} 格式)',
|
|
81
|
+
'提交后返回 prompt_id 用于查询和下载结果',
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
// comfy workflow list
|
|
85
|
+
const listCmd = workflowCmd
|
|
86
|
+
.command('list')
|
|
87
|
+
.description('列出工作流历史 - 查看最近提交的工作流执行记录')
|
|
88
|
+
.option('--limit <number>', '限制数量 (默认: 10)', '10')
|
|
89
|
+
.action(async (options) => {
|
|
90
|
+
const pretty = isPrettyMode(options);
|
|
91
|
+
try {
|
|
92
|
+
const client = new ComfyAPIClient();
|
|
93
|
+
const history = await client.getHistory();
|
|
94
|
+
const historyArray = Object.entries(history).slice(0, parseInt(options.limit));
|
|
95
|
+
if (pretty) {
|
|
96
|
+
if (historyArray.length === 0) {
|
|
97
|
+
info('暂无历史记录');
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const table = new Table({
|
|
101
|
+
head: ['Prompt ID', '状态', '时间'],
|
|
102
|
+
colWidths: [40, 15, 25],
|
|
103
|
+
});
|
|
104
|
+
historyArray.forEach(([promptId, data]) => {
|
|
105
|
+
const status = data.status?.completed ? '✓ 完成' : '✗ 失败';
|
|
106
|
+
const timestamp = data.status?.status_str || '-';
|
|
107
|
+
table.push([promptId, status, timestamp]);
|
|
108
|
+
});
|
|
109
|
+
console.log(table.toString());
|
|
110
|
+
info(`共 ${historyArray.length} 条记录`);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const workflows = historyArray.map(([promptId, data]) => ({
|
|
114
|
+
prompt_id: promptId,
|
|
115
|
+
completed: data.status?.completed || false,
|
|
116
|
+
status_str: data.status?.status_str || null,
|
|
117
|
+
}));
|
|
118
|
+
outputSuccess({
|
|
119
|
+
workflows,
|
|
120
|
+
total: historyArray.length,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
outputError('WORKFLOW_LIST_FAILED', `获取历史失败: ${err}`, options);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
// Add enhanced help for list command
|
|
129
|
+
addEnhancedHelp(listCmd, {
|
|
130
|
+
examples: [
|
|
131
|
+
'# 列出最近 10 条工作流历史(默认 JSON)',
|
|
132
|
+
'$ comfy workflow list',
|
|
133
|
+
'',
|
|
134
|
+
'# 列出最近 20 条',
|
|
135
|
+
'$ comfy workflow list --limit 20',
|
|
136
|
+
'',
|
|
137
|
+
'# Pretty 模式',
|
|
138
|
+
'$ comfy workflow list --pretty',
|
|
139
|
+
],
|
|
140
|
+
outputJson: `{
|
|
141
|
+
"success": true,
|
|
142
|
+
"data": {
|
|
143
|
+
"workflows": [
|
|
144
|
+
{
|
|
145
|
+
"prompt_id": "abc-123-def",
|
|
146
|
+
"completed": true,
|
|
147
|
+
"status_str": "success"
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"total": 10
|
|
151
|
+
}
|
|
152
|
+
}`,
|
|
153
|
+
relatedCommands: [
|
|
154
|
+
{ command: 'workflow get <id>', description: '查看单个工作流详情' },
|
|
155
|
+
{ command: 'download <id>', description: '下载工作流输出结果' },
|
|
156
|
+
{ command: 'queue status', description: '查看当前队列状态' },
|
|
157
|
+
],
|
|
158
|
+
notes: [
|
|
159
|
+
'默认显示最近 10 条记录',
|
|
160
|
+
'使用 --limit 参数控制数量',
|
|
161
|
+
'记录包含 prompt_id、完成状态和状态信息',
|
|
162
|
+
],
|
|
163
|
+
});
|
|
164
|
+
// comfy workflow get
|
|
165
|
+
const getCmd = workflowCmd
|
|
166
|
+
.command('get')
|
|
167
|
+
.description('获取工作流结果 - 查看指定工作流的执行详情和输出')
|
|
168
|
+
.argument('<prompt_id>', 'Prompt ID')
|
|
169
|
+
.option('--download', '下载输出图像')
|
|
170
|
+
.option('--output <dir>', '输出目录 (默认: ./output)', './output')
|
|
171
|
+
.action(async (promptId, options) => {
|
|
172
|
+
const pretty = isPrettyMode(options);
|
|
173
|
+
try {
|
|
174
|
+
const client = new ComfyAPIClient();
|
|
175
|
+
const result = await client.getHistory(promptId);
|
|
176
|
+
if (!result[promptId]) {
|
|
177
|
+
outputError('WORKFLOW_NOT_FOUND', `未找到 Prompt ID: ${promptId}`, options);
|
|
178
|
+
}
|
|
179
|
+
const data = result[promptId];
|
|
180
|
+
if (pretty) {
|
|
181
|
+
success(`Prompt ID: ${promptId}`);
|
|
182
|
+
if (data.status) {
|
|
183
|
+
info(`状态: ${data.status.completed ? '✓ 完成' : '✗ 失败'}`);
|
|
184
|
+
if (data.status.status_str) {
|
|
185
|
+
info(`消息: ${data.status.status_str}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (data.outputs) {
|
|
189
|
+
info('输出:');
|
|
190
|
+
console.log(JSON.stringify(data.outputs, null, 2));
|
|
191
|
+
}
|
|
192
|
+
if (options.download) {
|
|
193
|
+
info('下载功能即将推出');
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
outputSuccess({
|
|
198
|
+
prompt_id: promptId,
|
|
199
|
+
completed: data.status?.completed || false,
|
|
200
|
+
status_str: data.status?.status_str || null,
|
|
201
|
+
outputs: data.outputs || null,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch (err) {
|
|
206
|
+
outputError('WORKFLOW_GET_FAILED', `获取结果失败: ${err}`, options);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
// Add enhanced help for get command
|
|
210
|
+
addEnhancedHelp(getCmd, {
|
|
211
|
+
examples: [
|
|
212
|
+
'# 查看工作流结果',
|
|
213
|
+
'$ comfy workflow get abc-123-def',
|
|
214
|
+
'',
|
|
215
|
+
'# 查看结果并下载输出文件',
|
|
216
|
+
'$ comfy workflow get abc-123-def --download',
|
|
217
|
+
'',
|
|
218
|
+
'# 下载到指定目录',
|
|
219
|
+
'$ comfy workflow get abc-123-def --download --output ./my-images',
|
|
220
|
+
'',
|
|
221
|
+
'# Pretty 模式',
|
|
222
|
+
'$ comfy workflow get abc-123-def --pretty',
|
|
223
|
+
],
|
|
224
|
+
outputJson: `{
|
|
225
|
+
"success": true,
|
|
226
|
+
"data": {
|
|
227
|
+
"prompt_id": "abc-123-def",
|
|
228
|
+
"completed": true,
|
|
229
|
+
"status_str": "success",
|
|
230
|
+
"outputs": {...}
|
|
231
|
+
}
|
|
232
|
+
}`,
|
|
233
|
+
relatedCommands: [
|
|
234
|
+
{ command: 'download <id>', description: '下载工作流输出文件' },
|
|
235
|
+
{ command: 'workflow list', description: '查看所有工作流历史' },
|
|
236
|
+
],
|
|
237
|
+
notes: [
|
|
238
|
+
'返回工作流的完整执行信息',
|
|
239
|
+
'包含状态、输出节点等详细信息',
|
|
240
|
+
'使用 download 命令下载实际文件',
|
|
241
|
+
],
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/commands/workflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAoB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,OAAO,EAAS,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAa,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,MAAM,YAAY,CAAC;AAG/B,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,MAAM,WAAW,GAAG,OAAO;SACxB,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,OAAO,CAAC,CAAC;IAExB,wBAAwB;IACxB,MAAM,SAAS,GAAG,WAAW;SAC1B,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,wCAAwC,CAAC;SACrD,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;SACxC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC;SAC1B,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,OAAO,EAAE,EAAE;QACtC,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;QAErC,IAAI,CAAC;YACH,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;YAC3B,CAAC;YAED,cAAc;YACd,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;YAEpC,OAAO;YACP,MAAM,SAAS,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YAE7C,IAAI,MAAM,IAA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AAK,EAAE;YACL,cAAc;YACd,gBAAgB;YAChB,sBAAsB;SACvB;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname, join } from 'path';
|
|
6
|
+
import { setGlobalPrettyMode } from './utils/output.js';
|
|
7
|
+
import { registerImageCommand } from './commands/image.js';
|
|
8
|
+
import { registerVideoCommand } from './commands/video.js';
|
|
9
|
+
import { registerTtsCommand } from './commands/tts.js';
|
|
10
|
+
import { registerAsrCommand } from './commands/asr.js';
|
|
11
|
+
import { registerTryonCommand } from './commands/tryon.js';
|
|
12
|
+
import { registerTaskCommand } from './commands/task.js';
|
|
13
|
+
import { registerConfigCommand } from './commands/config.js';
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = dirname(__filename);
|
|
16
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));
|
|
17
|
+
const program = new Command();
|
|
18
|
+
program
|
|
19
|
+
.name('gen')
|
|
20
|
+
.description('Optima Gen CLI - AI 内容生成命令行工具')
|
|
21
|
+
.version(packageJson.version)
|
|
22
|
+
.option('--pretty', '使用人类可读的表格格式输出(默认为 JSON)')
|
|
23
|
+
.hook('preAction', (thisCommand) => {
|
|
24
|
+
const opts = thisCommand.optsWithGlobals();
|
|
25
|
+
if (opts.pretty) {
|
|
26
|
+
setGlobalPrettyMode(true);
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
.addHelpText('after', `
|
|
30
|
+
Output Formats:
|
|
31
|
+
默认输出 JSON 格式(AI 友好),支持两种输出模式:
|
|
32
|
+
--json JSON 格式(默认)- 机器可读,AI 友好,减少 50%+ token
|
|
33
|
+
--pretty 表格格式 - 人类可读,带颜色和表格
|
|
34
|
+
|
|
35
|
+
常用命令:
|
|
36
|
+
$ gen image "a cat" # 生成图像
|
|
37
|
+
$ gen video cat.png --prompt "walk" # 图生视频
|
|
38
|
+
$ gen tts "你好世界" --voice Cherry # 文本转语音
|
|
39
|
+
$ gen asr audio.mp3 --language zh # 语音识别
|
|
40
|
+
$ gen tryon person.jpg dress.jpg # 虚拟试穿
|
|
41
|
+
$ gen task list # 查看任务列表
|
|
42
|
+
|
|
43
|
+
文档:
|
|
44
|
+
GitHub: https://github.com/Optima-Chat/optima-gen
|
|
45
|
+
Issues: https://github.com/Optima-Chat/optima-gen/issues
|
|
46
|
+
`);
|
|
47
|
+
// 生成命令
|
|
48
|
+
registerImageCommand(program);
|
|
49
|
+
registerVideoCommand(program);
|
|
50
|
+
registerTtsCommand(program);
|
|
51
|
+
registerAsrCommand(program);
|
|
52
|
+
registerTryonCommand(program);
|
|
53
|
+
// 任务管理
|
|
54
|
+
registerTaskCommand(program);
|
|
55
|
+
// 配置
|
|
56
|
+
registerConfigCommand(program);
|
|
57
|
+
program.parse();
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,oBAA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AC5B,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAE9B,OAAO;AACP,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAE7B,KAAK;AACL,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAE/B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare class ComfyAPIClient {
|
|
2
|
+
private client;
|
|
3
|
+
constructor();
|
|
4
|
+
getSystemStats(): Promise<any>;
|
|
5
|
+
getQueue(): Promise<any>;
|
|
6
|
+
submitWorkflow(workflow: any): Promise<any>;
|
|
7
|
+
getHistory(promptId?: string): Promise<any>;
|
|
8
|
+
clearQueue(): Promise<any>;
|
|
9
|
+
deleteQueueItem(itemId: string): Promise<any>;
|
|
10
|
+
interrupt(): Promise<any>;
|
|
11
|
+
listModels(folder?: string): Promise<any>;
|
|
12
|
+
getObjectInfo(nodeClass?: string): Promise<any>;
|
|
13
|
+
uploadImage(file: Buffer, filename: string): Promise<{
|
|
14
|
+
name: string;
|
|
15
|
+
}>;
|
|
16
|
+
downloadImage(filename: string, subfolder?: string, type?: string): Promise<Buffer>;
|
|
17
|
+
getOutputFiles(promptId: string): Promise<Array<{
|
|
18
|
+
filename: string;
|
|
19
|
+
subfolder: string;
|
|
20
|
+
type: string;
|
|
21
|
+
}>>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/services/api.ts"],"names":[],"mappings":"AAIA,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAgB;;IAUxB,cAAc;IAKd,QAAQ;IAKR,cAAc,CAAC,QAAQ,EAAE,GAAG;IAK5B,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM;IAM5B,UAAU;IAKV,eAAe,CAAC,MAAM,EAAE,MAAM;IAK9B,SAAS;IAKT,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM;IAM1B,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM;IAMhC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAYtE,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,MAAW,EAAE,IAAI,GAAE,MAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAajG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAuC9G"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import FormData from 'form-data';
|
|
3
|
+
import { getConfig } from './config.js';
|
|
4
|
+
export class ComfyAPIClient {
|
|
5
|
+
client;
|
|
6
|
+
constructor() {
|
|
7
|
+
const config = getConfig();
|
|
8
|
+
this.client = axios.create({
|
|
9
|
+
baseURL: config.server,
|
|
10
|
+
timeout: config.timeout,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async getSystemStats() {
|
|
14
|
+
const response = await this.client.get('/system_stats');
|
|
15
|
+
return response.data;
|
|
16
|
+
}
|
|
17
|
+
async getQueue() {
|
|
18
|
+
const response = await this.client.get('/queue');
|
|
19
|
+
return response.data;
|
|
20
|
+
}
|
|
21
|
+
async submitWorkflow(workflow) {
|
|
22
|
+
const response = await this.client.post('/prompt', { prompt: workflow });
|
|
23
|
+
return response.data;
|
|
24
|
+
}
|
|
25
|
+
async getHistory(promptId) {
|
|
26
|
+
const url = promptId ? `/history/${promptId}` : '/history';
|
|
27
|
+
const response = await this.client.get(url);
|
|
28
|
+
return response.data;
|
|
29
|
+
}
|
|
30
|
+
async clearQueue() {
|
|
31
|
+
const response = await this.client.post('/queue', { clear: true });
|
|
32
|
+
return response.data;
|
|
33
|
+
}
|
|
34
|
+
async deleteQueueItem(itemId) {
|
|
35
|
+
const response = await this.client.post('/queue', { delete: [itemId] });
|
|
36
|
+
return response.data;
|
|
37
|
+
}
|
|
38
|
+
async interrupt() {
|
|
39
|
+
const response = await this.client.post('/interrupt');
|
|
40
|
+
return response.data;
|
|
41
|
+
}
|
|
42
|
+
async listModels(folder) {
|
|
43
|
+
const url = folder ? `/models/${folder}` : '/models';
|
|
44
|
+
const response = await this.client.get(url);
|
|
45
|
+
return response.data;
|
|
46
|
+
}
|
|
47
|
+
async getObjectInfo(nodeClass) {
|
|
48
|
+
const url = nodeClass ? `/object_info/${nodeClass}` : '/object_info';
|
|
49
|
+
const response = await this.client.get(url);
|
|
50
|
+
return response.data;
|
|
51
|
+
}
|
|
52
|
+
async uploadImage(file, filename) {
|
|
53
|
+
const formData = new FormData();
|
|
54
|
+
formData.append('image', file, filename);
|
|
55
|
+
formData.append('overwrite', 'true');
|
|
56
|
+
const response = await this.client.post('/upload/image', formData, {
|
|
57
|
+
headers: formData.getHeaders(),
|
|
58
|
+
timeout: 120000, // 2 分钟超时,用于大文件上传
|
|
59
|
+
});
|
|
60
|
+
return response.data;
|
|
61
|
+
}
|
|
62
|
+
async downloadImage(filename, subfolder = '', type = 'output') {
|
|
63
|
+
const params = new URLSearchParams({
|
|
64
|
+
filename,
|
|
65
|
+
subfolder,
|
|
66
|
+
type,
|
|
67
|
+
});
|
|
68
|
+
const response = await this.client.get(`/view?${params.toString()}`, {
|
|
69
|
+
responseType: 'arraybuffer',
|
|
70
|
+
timeout: 120000, // 2 分钟超时,用于大文件下载
|
|
71
|
+
});
|
|
72
|
+
return Buffer.from(response.data);
|
|
73
|
+
}
|
|
74
|
+
async getOutputFiles(promptId) {
|
|
75
|
+
const history = await this.getHistory(promptId);
|
|
76
|
+
const data = history[promptId];
|
|
77
|
+
if (!data || !data.outputs) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
const files = [];
|
|
81
|
+
// 遍历所有输出节点
|
|
82
|
+
for (const nodeId in data.outputs) {
|
|
83
|
+
const output = data.outputs[nodeId];
|
|
84
|
+
// 检查图片输出
|
|
85
|
+
if (output.images) {
|
|
86
|
+
for (const image of output.images) {
|
|
87
|
+
files.push({
|
|
88
|
+
filename: image.filename,
|
|
89
|
+
subfolder: image.subfolder || '',
|
|
90
|
+
type: image.type || 'output',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// 检查视频输出
|
|
95
|
+
if (output.gifs) {
|
|
96
|
+
for (const gif of output.gifs) {
|
|
97
|
+
files.push({
|
|
98
|
+
filename: gif.filename,
|
|
99
|
+
subfolder: gif.subfolder || '',
|
|
100
|
+
type: gif.type || 'output',
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return files;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/services/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,OAAO,cAAc;IACjB,MAAM,CAAgB;IAE9B;QACE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,MAAM,CAAC,MAAM;YACtB,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACxD,OAAO,QAAQ,CAAC,IAA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,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,QAAQ;qBAC3B,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 读取 Optima token
|
|
3
|
+
* 优先级: 环境变量 OPTIMA_TOKEN > ~/.optima/token.json
|
|
4
|
+
*/
|
|
5
|
+
export declare function getToken(): string;
|
|
6
|
+
/**
|
|
7
|
+
* 获取 Generation API 的 base URL
|
|
8
|
+
*/
|
|
9
|
+
export declare function getGenerationApiUrl(): string;
|
|
10
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/services/auth.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,QAAQ,IAAI,MAAM,CAsBjC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C"}
|