mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-09 22:10:57 +08:00
- provider/nofxos: GetAI500ListCached — 5min TTL cache with stale fallback on upstream failure; ResolveClient routes through the claw402 gateway when a wallet key is configured (user's claw402 model key -> CLAW402_WALLET_KEY env -> direct nofxos) - new GET /api/ai500 endpoint serving the score-sorted board - new get_ai500_list agent tool + prompt rule: when the user wants coin picks or creates a strategy without naming coins, consult AI500's high-scoring entries by default - web: AI500 sidebar panel (rank, score badge, gain since entry, 5min auto-refresh); clicking an entry asks the agent to analyze it
33 lines
960 B
Go
33 lines
960 B
Go
package nofxos
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
|
|
"nofx/logger"
|
|
)
|
|
|
|
// ResolveClient returns a nofxos data client, routed through the claw402
|
|
// x402 payment gateway when a wallet key is available. Resolution order:
|
|
// the explicit walletKey argument, then the CLAW402_WALLET_KEY environment
|
|
// variable, then the direct nofxos.ai client with the default auth key.
|
|
func ResolveClient(walletKey string) *Client {
|
|
walletKey = strings.TrimSpace(walletKey)
|
|
if walletKey == "" {
|
|
walletKey = strings.TrimSpace(os.Getenv("CLAW402_WALLET_KEY"))
|
|
}
|
|
client := NewClient(DefaultBaseURL, DefaultAuthKey)
|
|
if walletKey == "" {
|
|
return client
|
|
}
|
|
|
|
claw402URL := strings.TrimSpace(os.Getenv("CLAW402_URL"))
|
|
claw402Client, err := NewClaw402DataClient(claw402URL, walletKey, &logger.MCPLogger{})
|
|
if err != nil {
|
|
logger.Warnf("⚠️ Failed to init claw402 data client: %v (using direct nofxos.ai)", err)
|
|
return client
|
|
}
|
|
client.SetClaw402(claw402Client)
|
|
return client
|
|
}
|