Add authHeader option and fix print mode error handling

- Add 'authHeader' boolean option to models.json provider config
  When true, adds 'Authorization: Bearer <apiKey>' to model headers
  Useful for providers requiring explicit auth headers (fixes #81)

- Fix print mode (-p) silently failing on errors
  Now outputs error message to stderr and exits with code 1
  when assistant message has stopReason of error/aborted
This commit is contained in:
Mario Zechner 2025-12-05 11:31:14 +01:00
parent 398591fdb0
commit 51195bc9fc
3 changed files with 24 additions and 2 deletions

View file

@ -817,7 +817,15 @@ async function runSingleShotMode(
if (mode === "text") {
const lastMessage = agent.state.messages[agent.state.messages.length - 1];
if (lastMessage.role === "assistant") {
for (const content of lastMessage.content) {
const assistantMsg = lastMessage as AssistantMessage;
// Check for error/aborted and output error message
if (assistantMsg.stopReason === "error" || assistantMsg.stopReason === "aborted") {
console.error(assistantMsg.errorMessage || `Request ${assistantMsg.stopReason}`);
process.exit(1);
}
for (const content of assistantMsg.content) {
if (content.type === "text") {
console.log(content.text);
}