Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions claude-copilot
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ CLAUDE_CONFIG_ALT="$CLAUDE_CONFIG_DIR/.claude.json"
export ANTHROPIC_BASE_URL="http://localhost:$PROXY_PORT"
export ANTHROPIC_API_KEY="$API_KEY"

# --- Start proxy as a proper daemon (survives shell exit) ---
# --- Ensure proxy is running via launchd (singleton, auto-restart, survives logout) ---
if ! curl -s "http://localhost:$PROXY_PORT/health" >/dev/null 2>&1; then
echo "Starting copilot-proxy on port $PROXY_PORT..."
# Start detached: nohup + background + disown survives shell exit
nohup node "$SCRIPT_DIR/proxy.mjs" > /tmp/copilot-proxy.log 2>&1 &
disown $! 2>/dev/null
# Load the launchd agent if not already loaded
launchctl bootstrap "gui/$(id -u)" "$HOME/Library/LaunchAgents/com.copilot.proxy.plist" 2>/dev/null \
|| launchctl kickstart -k "gui/$(id -u)/com.copilot.proxy" 2>/dev/null
for i in $(seq 1 10); do
curl -s "http://localhost:$PROXY_PORT/health" >/dev/null 2>&1 && break
sleep 0.5
Expand All @@ -31,7 +31,7 @@ if ! curl -s "http://localhost:$PROXY_PORT/health" >/dev/null 2>&1; then
echo "❌ Proxy failed to start. Check /tmp/copilot-proxy.log"
exit 1
fi
echo "✅ Proxy running"
echo "✅ Proxy running (launchd managed)"
fi

# --- Seed onboarding bypass so interactive mode skips the wizard ---
Expand Down
32 changes: 32 additions & 0 deletions launchd/com.copilot.proxy.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.copilot.proxy</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/node</string>
<string>/Users/timothy.schwarz/copilot-mcp-proxy/proxy.mjs</string>
</array>
<key>WorkingDirectory</key>
<string>/Users/timothy.schwarz/copilot-mcp-proxy</string>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/copilot-proxy.log</string>
<key>StandardErrorPath</key>
<string>/tmp/copilot-proxy.log</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string>
<key>HOME</key>
<string>/Users/timothy.schwarz</string>
</dict>
<key>ThrottleInterval</key>
<integer>5</integer>
</dict>
</plist>