整合数据

This commit is contained in:
2026-06-16 01:30:39 +08:00
parent 761a5cb69c
commit c0f70823a9
31 changed files with 4385 additions and 893 deletions
+9 -14
View File
@@ -1,9 +1,8 @@
// Package tokenprobe 使用号池内 Token 调用各厂商接口做可用性探测。
// Cursor 走 api2.cursor.sh 的 Connect + protobuf 二进制流(非 JSON 文本接口)。
package tokenprobe
import (
"bytes"
"crypto/tls"
"encoding/base64"
"encoding/json"
"fmt"
@@ -14,9 +13,13 @@ import (
"time"
)
var httpClient = &http.Client{Timeout: 25 * time.Second}
var httpClient = &http.Client{
Timeout: 12 * time.Second,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
// Result 探测结果(Cursor 会填充 ProbeMessage / Endpoint / BytesRead / RawPreview 等)
type Result struct {
OK bool `json:"ok"`
Detail string `json:"detail"`
@@ -30,7 +33,6 @@ type Result struct {
StreamNote string `json:"streamNote,omitempty"`
}
// ProbeOfficial 按号池模块探测 Tokencursor / windsurf / krio
func ProbeOfficial(module, rawToken string) Result {
tok := normalizeBearerToken(strings.TrimSpace(rawToken))
if tok == "" {
@@ -38,8 +40,7 @@ func ProbeOfficial(module, rawToken string) Result {
}
switch module {
case "cursor":
// 直接使用 cursor_hi.go 中已有的完整探测函数
return probeCursorHiAgent(tok)
return probeCursor(tok)
case "windsurf":
return probeWindsurf(tok)
case "krio":
@@ -57,12 +58,10 @@ func normalizeBearerToken(s string) string {
return s
}
// probeCursor Cursor Token 探测(直接使用 cursor_hi.go 的实现)
func probeCursor(token string) Result {
return probeCursorHiAgent(token)
}
// probeWindsurf WindSurf 探测
func probeWindsurf(apiKey string) Result {
payload := map[string]interface{}{
"metadata": map[string]string{
@@ -119,13 +118,12 @@ func probeWindsurf(apiKey string) Result {
}
}
// probeKiro Kiro 探测
func probeKiro(accessToken string) Result {
arn := findProfileArnInJWT(accessToken)
if arn == "" {
return Result{
OK: false,
Detail: "无法从 Token 中解析 profileArnKiro 暂无法自动探测(需完整登录 JWT",
Detail: "无法从 Token 中解析 profileArnKiro 暂无法自动探测",
}
}
@@ -163,7 +161,6 @@ func probeKiro(accessToken string) Result {
}
}
// decodeJWTPayloadMap 解析 JWT payload
func decodeJWTPayloadMap(raw string) (map[string]interface{}, error) {
tok := normalizeBearerToken(strings.TrimSpace(raw))
parts := strings.Split(tok, ".")
@@ -181,7 +178,6 @@ func decodeJWTPayloadMap(raw string) (map[string]interface{}, error) {
return m, nil
}
// findProfileArnInJWT 从 JWT 中查找 profileArn
func findProfileArnInJWT(raw string) string {
m, err := decodeJWTPayloadMap(raw)
if err != nil {
@@ -190,7 +186,6 @@ func findProfileArnInJWT(raw string) string {
return findProfileArnValue(m)
}
// findProfileArnValue 递归查找 profileArn
func findProfileArnValue(v interface{}) string {
switch x := v.(type) {
case map[string]interface{}: