mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 16:02:24 +00:00
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:
parent
398591fdb0
commit
51195bc9fc
3 changed files with 24 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue