mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-17 09:24:36 +08:00
feat(agent): surface the AI500 index board in chat, tools, and sidebar
- 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
This commit is contained in:
32
provider/nofxos/client_resolve.go
Normal file
32
provider/nofxos/client_resolve.go
Normal file
@@ -0,0 +1,32 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user