@misterhuydo/sentinel 1.4.99 → 1.5.1
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
CHANGED
|
@@ -2877,6 +2877,7 @@ async def _run_tool(name: str, inputs: dict, cfg_loader, store, slack_client=Non
|
|
|
2877
2877
|
# Only inject API key when Claude Pro is NOT preferred for heavy tasks
|
|
2878
2878
|
if cfg.anthropic_api_key and not cfg.claude_pro_for_tasks:
|
|
2879
2879
|
env["ANTHROPIC_API_KEY"] = cfg.anthropic_api_key
|
|
2880
|
+
api_env = {**env, "ANTHROPIC_API_KEY": cfg.anthropic_api_key} if cfg.anthropic_api_key else None
|
|
2880
2881
|
|
|
2881
2882
|
# Build project context block (all repos this Sentinel instance manages)
|
|
2882
2883
|
_project_name = _read_project_name(Path("."))
|
|
@@ -2927,15 +2928,26 @@ async def _run_tool(name: str, inputs: dict, cfg_loader, store, slack_client=Non
|
|
|
2927
2928
|
f"{_mode_instruction}\n\n"
|
|
2928
2929
|
f"Question / Task: {question}"
|
|
2929
2930
|
)
|
|
2931
|
+
from .fix_engine import _is_auth_error
|
|
2932
|
+
cmd = (
|
|
2933
|
+
[cfg.claude_code_bin, "--dangerously-skip-permissions", "--bare", "--print", prompt]
|
|
2934
|
+
if os.getuid() != 0 else
|
|
2935
|
+
[cfg.claude_code_bin, "--bare", "--print", prompt]
|
|
2936
|
+
)
|
|
2937
|
+
run_kwargs = dict(capture_output=True, text=True, timeout=300,
|
|
2938
|
+
cwd=str(local_path), stdin=subprocess.DEVNULL)
|
|
2930
2939
|
try:
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
if os.getuid() != 0 else
|
|
2934
|
-
[cfg.claude_code_bin, "--bare", "--print", prompt]),
|
|
2935
|
-
capture_output=True, text=True, timeout=300, env=env,
|
|
2936
|
-
cwd=str(local_path), stdin=subprocess.DEVNULL,
|
|
2937
|
-
)
|
|
2940
|
+
# Try OAuth first (or API key if claude_pro_for_tasks=False)
|
|
2941
|
+
r = subprocess.run(cmd, env=env, **run_kwargs)
|
|
2938
2942
|
output = (r.stdout or "").strip()
|
|
2943
|
+
auth_failed = _is_auth_error(output) or _is_auth_error(r.stderr or "")
|
|
2944
|
+
|
|
2945
|
+
# Silent fallback: retry with API key if OAuth session expired
|
|
2946
|
+
if auth_failed and api_env:
|
|
2947
|
+
logger.warning("ask_codebase/%s: OAuth session issue — retrying with API key", repo_name)
|
|
2948
|
+
r = subprocess.run(cmd, env=api_env, **run_kwargs)
|
|
2949
|
+
output = (r.stdout or "").strip()
|
|
2950
|
+
|
|
2939
2951
|
logger.info("Boss ask_codebase %s mode=%s rc=%d len=%d", repo_name, mode, r.returncode, len(output))
|
|
2940
2952
|
if r.returncode != 0 and not output:
|
|
2941
2953
|
raw_err = (r.stderr or "")
|