OpenRouter crows; log which model answered each flight
- ChatBrain speaks OpenAI-style chat completions (OpenRouter now) - CROWS_PROVIDER picks anthropic or openrouter; default model openrouter/free; CROWS_MODEL overrides - Flight log records the model that actually answered - Token budgets fall back to a length estimate if usage is missing - start.command reads either key from .env Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UQnSw4RRWp8uqpj3nsnnXF
This commit is contained in:
5 files changed
+247
-26
No files matched your search
+18
-17
@@ -2,26 +2,27 @@
|
||||
# So Many Crows: local server.
|
||||
# Double-click to start. Close this window (or Ctrl-C) to stop.
|
||||
#
|
||||
# - Real crows (Claude) when .env in this folder holds ANTHROPIC_API_KEY=...; mock crows otherwise.
|
||||
# - `./start.command --mock` forces mock crows.
|
||||
# - Listens on this Mac only (127.0.0.1:8080). State lives in .crows/ (delete it to start fresh).
|
||||
# - Guardrails: 20,000 tokens per item, 100,000 per list; you approve everything until crows earn trust.
|
||||
# Which crows fly is set in .env in this folder (never committed):
|
||||
# OPENROUTER_API_KEY=... OpenRouter (default model: openrouter/free)
|
||||
# ANTHROPIC_API_KEY=... Claude direct from Anthropic (default: claude-sonnet-5-5)
|
||||
# CROWS_PROVIDER=openrouter optional: pick one when both keys are present
|
||||
# CROWS_MODEL=... optional: a specific model
|
||||
# `./start.command --mock` forces offline mock crows.
|
||||
#
|
||||
# Listens on this Mac only (127.0.0.1:8080). State lives in .crows/ (delete it to start fresh).
|
||||
# Guardrails: 20,000 tokens per item, 100,000 per list; you approve everything until crows earn trust.
|
||||
cd "$(dirname "$0")" || exit 1
|
||||
xattr -d com.apple.quarantine ./crows 2>/dev/null
|
||||
chmod +x ./crows
|
||||
|
||||
unset ANTHROPIC_API_KEY
|
||||
if [ "$1" != "--mock" ] && [ -f .env ]; then
|
||||
# Read only the key line; the file is never executed.
|
||||
ANTHROPIC_API_KEY="$(sed -n 's/^ANTHROPIC_API_KEY=//p' .env | head -n 1 | tr -d '[:space:]')"
|
||||
CROWS_MODEL_FROM_ENV="$(sed -n 's/^CROWS_MODEL=//p' .env | head -n 1 | tr -d '[:space:]')"
|
||||
[ -n "$CROWS_MODEL_FROM_ENV" ] && export CROWS_MODEL="$CROWS_MODEL_FROM_ENV"
|
||||
[ -n "$ANTHROPIC_API_KEY" ] && export ANTHROPIC_API_KEY
|
||||
fi
|
||||
if [ -n "$ANTHROPIC_API_KEY" ]; then
|
||||
echo "Real crows: Claude (${CROWS_MODEL:-claude-sonnet-5-5}). Each list is capped at 100,000 tokens."
|
||||
else
|
||||
echo "Mock crows (no key in .env, or --mock)."
|
||||
# Read only these lines from .env; the file is never executed.
|
||||
envval() { sed -n "s/^$1=//p" .env 2>/dev/null | head -n 1 | tr -d '[:space:]"'; }
|
||||
unset ANTHROPIC_API_KEY OPENROUTER_API_KEY CROWS_PROVIDER CROWS_MODEL
|
||||
if [ "$1" != "--mock" ]; then
|
||||
for v in ANTHROPIC_API_KEY OPENROUTER_API_KEY CROWS_PROVIDER CROWS_MODEL; do
|
||||
val="$(envval "$v")"
|
||||
[ -n "$val" ] && export "$v=$val"
|
||||
done
|
||||
fi
|
||||
|
||||
if lsof -iTCP:8080 -sTCP:LISTEN >/dev/null 2>&1; then
|
||||
@@ -29,4 +30,4 @@ if lsof -iTCP:8080 -sTCP:LISTEN >/dev/null 2>&1; then
|
||||
exit 1
|
||||
fi
|
||||
(sleep 1; open "http://127.0.0.1:8080") &
|
||||
exec ./crows serve -addr 127.0.0.1:8080
|
||||
exec ./crows serve -addr 127.0.0.1:8080 # prints which brain is flying
|
||||
Reference in new issue
Block a user