yymaxapi 1.0.119 → 1.0.120
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/bin/yymaxapi.js +70 -2
- package/package.json +1 -1
package/bin/yymaxapi.js
CHANGED
|
@@ -3846,7 +3846,7 @@ function scoreHermesWslCandidate(candidate) {
|
|
|
3846
3846
|
}
|
|
3847
3847
|
|
|
3848
3848
|
function getHermesWslMirrorInfo(options = {}) {
|
|
3849
|
-
if (process.platform !== 'win32'
|
|
3849
|
+
if (process.platform !== 'win32') {
|
|
3850
3850
|
return {
|
|
3851
3851
|
dataDir: null,
|
|
3852
3852
|
sourceConfigPath: null,
|
|
@@ -3892,7 +3892,8 @@ function getHermesWslMirrorInfo(options = {}) {
|
|
|
3892
3892
|
sourceConfigPath,
|
|
3893
3893
|
configPath: candidate.configPath,
|
|
3894
3894
|
envPath: candidate.envPath,
|
|
3895
|
-
target: candidate.target
|
|
3895
|
+
target: candidate.target,
|
|
3896
|
+
commandPath: selected?.commandPath || probeHermesWslCommand(candidate.target)
|
|
3896
3897
|
};
|
|
3897
3898
|
}
|
|
3898
3899
|
|
|
@@ -4115,6 +4116,36 @@ function readHermesCliConfig() {
|
|
|
4115
4116
|
};
|
|
4116
4117
|
}
|
|
4117
4118
|
|
|
4119
|
+
function buildHermesCliConfigFromRaw(configRaw, envRaw, configPath = '', envPath = '') {
|
|
4120
|
+
const parsed = parseSimpleYamlConfig(configRaw);
|
|
4121
|
+
const envEntries = parseEnvFile(envRaw);
|
|
4122
|
+
const modelConfig = parsed?.model && typeof parsed.model === 'object' ? parsed.model : {};
|
|
4123
|
+
const modelId = String(modelConfig.default || '').trim() || getDefaultClaudeModel().id;
|
|
4124
|
+
const provider = String(modelConfig.provider || '').trim().toLowerCase();
|
|
4125
|
+
const type = resolveHermesModelType(modelId, provider);
|
|
4126
|
+
const apiKey = type === 'codex'
|
|
4127
|
+
? (envEntries.OPENAI_API_KEY || '')
|
|
4128
|
+
: (envEntries.ANTHROPIC_API_KEY || envEntries.ANTHROPIC_TOKEN || '');
|
|
4129
|
+
|
|
4130
|
+
return {
|
|
4131
|
+
configPath,
|
|
4132
|
+
envPath,
|
|
4133
|
+
configured: !!configRaw || !!envRaw,
|
|
4134
|
+
modelId,
|
|
4135
|
+
provider,
|
|
4136
|
+
type,
|
|
4137
|
+
baseUrl: String(modelConfig.base_url || '').trim(),
|
|
4138
|
+
apiKey
|
|
4139
|
+
};
|
|
4140
|
+
}
|
|
4141
|
+
|
|
4142
|
+
function readHermesWslCliConfig(wslMirror = getHermesWslMirrorInfo()) {
|
|
4143
|
+
const configPath = wslMirror.sourceConfigPath || wslMirror.configPath;
|
|
4144
|
+
const configRaw = readWslTextFile(configPath, wslMirror.target);
|
|
4145
|
+
const envRaw = readWslTextFile(wslMirror.envPath, wslMirror.target);
|
|
4146
|
+
return buildHermesCliConfigFromRaw(configRaw, envRaw, configPath, wslMirror.envPath);
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4118
4149
|
function getOpencodeConfigPath() {
|
|
4119
4150
|
const home = os.homedir();
|
|
4120
4151
|
return process.platform === 'win32'
|
|
@@ -4374,6 +4405,9 @@ function testCodexCliConnection() {
|
|
|
4374
4405
|
|
|
4375
4406
|
function testHermesCliConnection() {
|
|
4376
4407
|
const cliBinary = resolveCommandBinary('hermes');
|
|
4408
|
+
if (!cliBinary && process.platform === 'win32') {
|
|
4409
|
+
return testHermesWslCliConnection();
|
|
4410
|
+
}
|
|
4377
4411
|
if (!cliBinary) return { name: 'Hermes CLI', status: 'skipped', detail: '未安装 hermes 命令' };
|
|
4378
4412
|
|
|
4379
4413
|
const config = readHermesCliConfig();
|
|
@@ -4419,6 +4453,40 @@ function testHermesCliConnection() {
|
|
|
4419
4453
|
};
|
|
4420
4454
|
}
|
|
4421
4455
|
|
|
4456
|
+
function testHermesWslCliConnection() {
|
|
4457
|
+
const wslMirror = getHermesWslMirrorInfo();
|
|
4458
|
+
const commandPath = wslMirror.commandPath || probeHermesWslCommand(wslMirror.target || {});
|
|
4459
|
+
if (!commandPath) return { name: 'Hermes CLI (WSL)', status: 'skipped', detail: '未检测到 WSL 内 hermes 命令' };
|
|
4460
|
+
|
|
4461
|
+
const config = readHermesWslCliConfig(wslMirror);
|
|
4462
|
+
if (!config.configured) return { name: 'Hermes CLI (WSL)', status: 'skipped', detail: '未检测到 WSL ~/.hermes/config.yaml 或 ~/.hermes/.env' };
|
|
4463
|
+
if (!config.apiKey) return { name: 'Hermes CLI (WSL)', status: 'failed', detail: 'Hermes 配置缺少 API Key' };
|
|
4464
|
+
|
|
4465
|
+
const providerArg = config.provider === 'anthropic' ? ' --provider anthropic' : '';
|
|
4466
|
+
const command = [
|
|
4467
|
+
`export HERMES_HOME=${shellQuote(wslMirror.dataDir)}`,
|
|
4468
|
+
'export NODE_TLS_REJECT_UNAUTHORIZED=0',
|
|
4469
|
+
'export NODE_NO_WARNINGS=1',
|
|
4470
|
+
'set -a',
|
|
4471
|
+
`[ -f "$HERMES_HOME/.env" ] && . "$HERMES_HOME/.env"`,
|
|
4472
|
+
'set +a',
|
|
4473
|
+
`${shellQuote(commandPath)} chat -Q -q ${shellQuote('请只回复 OK')}${providerArg}`
|
|
4474
|
+
].join('; ');
|
|
4475
|
+
const result = runWslCommand(command, { timeout: 120000, maxBuffer: 1024 * 1024 }, { ...(wslMirror.target || {}), login: true });
|
|
4476
|
+
const combined = cleanCliTestOutput(`${result.output || ''}\n${result.stdout || ''}\n${result.stderr || ''}`);
|
|
4477
|
+
const reply = extractHermesCliReply(combined);
|
|
4478
|
+
|
|
4479
|
+
if (result.ok && /^OK$/i.test(reply) && !looksLikeCliTestError(combined)) {
|
|
4480
|
+
return { name: 'Hermes CLI (WSL)', status: 'success', detail: 'OK' };
|
|
4481
|
+
}
|
|
4482
|
+
|
|
4483
|
+
return {
|
|
4484
|
+
name: 'Hermes CLI (WSL)',
|
|
4485
|
+
status: 'failed',
|
|
4486
|
+
detail: reply || summarizeCliTestOutput(combined) || result.error || '命令执行失败'
|
|
4487
|
+
};
|
|
4488
|
+
}
|
|
4489
|
+
|
|
4422
4490
|
async function testAdditionalCliConnections(args = {}, options = {}) {
|
|
4423
4491
|
if (args['no-app-test'] || args.noAppTest) return;
|
|
4424
4492
|
|