style: fix CI lint
This commit is contained in:
parent
7d44ce72cf
commit
7e81432858
4 changed files with 40 additions and 22 deletions
|
|
@ -21,7 +21,7 @@ func newStartCommand() *cobra.Command {
|
|||
Short: "Start channels without gateway side services",
|
||||
Long: "Start enabled channels and AgentLoop without gateway side services.\n\n" +
|
||||
"This mode is channel-agnostic and follows your config. Current runtime validation is primarily focused on QQ; other channels are continuously validated.",
|
||||
Args: cobra.NoArgs,
|
||||
Args: cobra.NoArgs,
|
||||
PreRunE: func(_ *cobra.Command, _ []string) error {
|
||||
if noTruncate && !debug {
|
||||
return fmt.Errorf("the --no-truncate option can only be used in conjunction with --debug (-d)")
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
dedupTTL = 5 * time.Minute
|
||||
dedupInterval = 60 * time.Second
|
||||
dedupMaxSize = 10000 // hard cap on dedup map entries
|
||||
typingResend = 8 * time.Second
|
||||
typingSeconds = 10
|
||||
bytesPerMiB = 1024 * 1024
|
||||
dedupTTL = 5 * time.Minute
|
||||
dedupInterval = 60 * time.Second
|
||||
dedupMaxSize = 10000 // hard cap on dedup map entries
|
||||
typingResend = 8 * time.Second
|
||||
typingSeconds = 10
|
||||
bytesPerMiB = 1024 * 1024
|
||||
qqStartupProbe = 15 * time.Second
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,9 @@ func TestHandleGroupATMessage_PrefersGroupOpenIDFromRawPayload(t *testing.T) {
|
|||
ctx: context.Background(),
|
||||
}
|
||||
|
||||
raw := []byte(`{"d":{"group_openid":"group-openid-abc","author":{"id":"legacy-member-id","member_openid":"member-openid-xyz"}}}`)
|
||||
raw := []byte(
|
||||
`{"d":{"group_openid":"group-openid-abc","author":{"id":"legacy-member-id","member_openid":"member-openid-xyz"}}}`,
|
||||
)
|
||||
err := ch.handleGroupATMessage()(&dto.WSPayload{RawMessage: raw}, &dto.WSGroupATMessageData{
|
||||
ID: "group-openid-msg",
|
||||
GroupID: "legacy-group-id",
|
||||
|
|
@ -169,7 +171,9 @@ func TestHandleGroupATMessage_AllowListFallsBackToLegacyMemberID(t *testing.T) {
|
|||
ctx: context.Background(),
|
||||
}
|
||||
|
||||
raw := []byte(`{"d":{"group_openid":"group-openid-abc","author":{"id":"legacy-member-id","member_openid":"member-openid-xyz"}}}`)
|
||||
raw := []byte(
|
||||
`{"d":{"group_openid":"group-openid-abc","author":{"id":"legacy-member-id","member_openid":"member-openid-xyz"}}}`,
|
||||
)
|
||||
err := ch.handleGroupATMessage()(&dto.WSPayload{RawMessage: raw}, &dto.WSGroupATMessageData{
|
||||
ID: "group-allow-fallback",
|
||||
GroupID: "legacy-group-id",
|
||||
|
|
@ -196,11 +200,11 @@ func TestHandleGroupATMessage_AllowListFallsBackToLegacyMemberID(t *testing.T) {
|
|||
|
||||
func TestParseQQOpenIDs(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
raw []byte
|
||||
wantUser string
|
||||
wantMember string
|
||||
wantGroup string
|
||||
name string
|
||||
raw []byte
|
||||
wantUser string
|
||||
wantMember string
|
||||
wantGroup string
|
||||
}{
|
||||
{
|
||||
name: "empty",
|
||||
|
|
@ -217,8 +221,10 @@ func TestParseQQOpenIDs(t *testing.T) {
|
|||
wantGroup: "",
|
||||
},
|
||||
{
|
||||
name: "all openids",
|
||||
raw: []byte(`{"d":{"group_openid":"group-1","author":{"user_openid":"user-1","member_openid":"member-1"}}}`),
|
||||
name: "all openids",
|
||||
raw: []byte(
|
||||
`{"d":{"group_openid":"group-1","author":{"user_openid":"user-1","member_openid":"member-1"}}}`,
|
||||
),
|
||||
wantUser: "user-1",
|
||||
wantMember: "member-1",
|
||||
wantGroup: "group-1",
|
||||
|
|
|
|||
|
|
@ -177,7 +177,11 @@ func setupAndStartChannelServices(
|
|||
}
|
||||
|
||||
if runningServices.ListenHost != "" {
|
||||
fmt.Printf("✓ Health endpoints available at http://%s:%d/health and /ready\n", runningServices.ListenHost, runningServices.ListenPort)
|
||||
fmt.Printf(
|
||||
"✓ Health endpoints available at http://%s:%d/health and /ready\n",
|
||||
runningServices.ListenHost,
|
||||
runningServices.ListenPort,
|
||||
)
|
||||
} else {
|
||||
fmt.Println("⚠ Shared HTTP server disabled; /health and webhook endpoints are unavailable")
|
||||
}
|
||||
|
|
@ -190,10 +194,14 @@ func resolveChannelOnlyListenHost(host string, port int) (string, error) {
|
|||
return host, nil
|
||||
} else if isLoopbackHost(host) {
|
||||
if fallbackErr := probeTCPBind("0.0.0.0", port); fallbackErr == nil {
|
||||
logger.WarnCF("channels", "Loopback host unavailable in channel-only mode, fallback to wildcard", map[string]any{
|
||||
"host": host,
|
||||
"port": port,
|
||||
})
|
||||
logger.WarnCF(
|
||||
"channels",
|
||||
"Loopback host unavailable in channel-only mode, fallback to wildcard",
|
||||
map[string]any{
|
||||
"host": host,
|
||||
"port": port,
|
||||
},
|
||||
)
|
||||
return "0.0.0.0", nil
|
||||
}
|
||||
return "", fmt.Errorf("bind %s:%d failed: %w", host, port, err)
|
||||
|
|
@ -221,7 +229,11 @@ func isLoopbackHost(host string) bool {
|
|||
return ip != nil && ip.IsLoopback()
|
||||
}
|
||||
|
||||
func shutdownChannelRuntime(runningServices *channelServices, agentLoop *agent.AgentLoop, provider providers.LLMProvider) {
|
||||
func shutdownChannelRuntime(
|
||||
runningServices *channelServices,
|
||||
agentLoop *agent.AgentLoop,
|
||||
provider providers.LLMProvider,
|
||||
) {
|
||||
if cp, ok := provider.(providers.StatefulProvider); ok {
|
||||
cp.Close()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue