@openagents-org/agent-launcher 0.2.140 → 0.2.141
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/package.json +1 -1
- package/src/adapters/claude.js +35 -2
package/package.json
CHANGED
package/src/adapters/claude.js
CHANGED
|
@@ -305,6 +305,15 @@ class ClaudeAdapter extends BaseAdapter {
|
|
|
305
305
|
if (jsMatch) {
|
|
306
306
|
return [nodeBin, path.resolve(cmdDir, jsMatch[1])];
|
|
307
307
|
}
|
|
308
|
+
// .cmd shims that forward to a native .exe (e.g. Claude Code's
|
|
309
|
+
// claude.cmd → @anthropic-ai/claude-code/bin/claude.exe). Resolve to the
|
|
310
|
+
// exe and spawn it directly. Wrapping such a .cmd in `cmd.exe /c` caps the
|
|
311
|
+
// command line at cmd.exe's 8191-char limit, which truncates the ~14KB
|
|
312
|
+
// --append-system-prompt and makes the agent hang ("command line too long").
|
|
313
|
+
const exeMatch = cmdContent.match(/%dp0%\\([^\s"*?]+\.exe)/i);
|
|
314
|
+
if (exeMatch) {
|
|
315
|
+
return [path.resolve(cmdDir, exeMatch[1])];
|
|
316
|
+
}
|
|
308
317
|
} else {
|
|
309
318
|
// Unix: symlink → resolve to actual .js file
|
|
310
319
|
try {
|
|
@@ -564,7 +573,7 @@ class ClaudeAdapter extends BaseAdapter {
|
|
|
564
573
|
const resolved = this._resolveToNodeCmd(oaBin);
|
|
565
574
|
if (resolved) {
|
|
566
575
|
mcpCommand = resolved[0];
|
|
567
|
-
mcpFinalArgs = [resolved
|
|
576
|
+
mcpFinalArgs = [...resolved.slice(1), ...mcpArgs];
|
|
568
577
|
} else {
|
|
569
578
|
mcpCommand = oaBin;
|
|
570
579
|
}
|
|
@@ -689,7 +698,7 @@ class ClaudeAdapter extends BaseAdapter {
|
|
|
689
698
|
const resolved = this._resolveToNodeCmd(filteredCmd[0]);
|
|
690
699
|
let finalCmd = filteredCmd;
|
|
691
700
|
if (resolved) {
|
|
692
|
-
finalCmd = [resolved
|
|
701
|
+
finalCmd = [...resolved, ...filteredCmd.slice(1)];
|
|
693
702
|
} else if (IS_WINDOWS && filteredCmd[0].toLowerCase().endsWith('.cmd')) {
|
|
694
703
|
finalCmd = ['cmd.exe', '/c', ...filteredCmd];
|
|
695
704
|
}
|
|
@@ -999,6 +1008,30 @@ class ClaudeAdapter extends BaseAdapter {
|
|
|
999
1008
|
}
|
|
1000
1009
|
}
|
|
1001
1010
|
|
|
1011
|
+
// Third-party Anthropic-compatible relays (the common reason a custom
|
|
1012
|
+
// ANTHROPIC_BASE_URL is set) authenticate via `Authorization: Bearer`, which
|
|
1013
|
+
// the Claude CLI only sends when ANTHROPIC_AUTH_TOKEN is set. With just
|
|
1014
|
+
// ANTHROPIC_API_KEY the CLI sends `x-api-key`, which most relays ignore — the
|
|
1015
|
+
// relay then rejects every request as 401 "invalid token / 无效的令牌". When a
|
|
1016
|
+
// non-official base URL is configured and no auth token was provided, mirror
|
|
1017
|
+
// the API key into ANTHROPIC_AUTH_TOKEN (it outranks the API key in Claude
|
|
1018
|
+
// Code's auth precedence) so the CLI uses Bearer auth. The launcher normally
|
|
1019
|
+
// sets this when saving env; this is the runtime backstop for envs saved by
|
|
1020
|
+
// an older launcher or coming from any other source. The official
|
|
1021
|
+
// api.anthropic.com endpoint keeps x-api-key, so it is left untouched.
|
|
1022
|
+
const anthropicBase = (cleanEnv.ANTHROPIC_BASE_URL || '').trim();
|
|
1023
|
+
const anthropicKey = (cleanEnv.ANTHROPIC_API_KEY || '').trim();
|
|
1024
|
+
if (anthropicKey && anthropicBase && !(cleanEnv.ANTHROPIC_AUTH_TOKEN || '').trim()) {
|
|
1025
|
+
let officialAnthropic = false;
|
|
1026
|
+
try {
|
|
1027
|
+
const host = new URL(anthropicBase).hostname.toLowerCase();
|
|
1028
|
+
officialAnthropic = host === 'anthropic.com' || host.endsWith('.anthropic.com');
|
|
1029
|
+
} catch { officialAnthropic = false; }
|
|
1030
|
+
if (!officialAnthropic) {
|
|
1031
|
+
cleanEnv.ANTHROPIC_AUTH_TOKEN = anthropicKey;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1002
1035
|
// Spawn a persistent process and send the first message via stdin
|
|
1003
1036
|
let effectiveContent = content;
|
|
1004
1037
|
for (let attempt = 0; attempt < 2; attempt++) {
|