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",
|
Short: "Start channels without gateway side services",
|
||||||
Long: "Start enabled channels and AgentLoop without gateway side services.\n\n" +
|
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.",
|
"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 {
|
PreRunE: func(_ *cobra.Command, _ []string) error {
|
||||||
if noTruncate && !debug {
|
if noTruncate && !debug {
|
||||||
return fmt.Errorf("the --no-truncate option can only be used in conjunction with --debug (-d)")
|
return fmt.Errorf("the --no-truncate option can only be used in conjunction with --debug (-d)")
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
dedupTTL = 5 * time.Minute
|
dedupTTL = 5 * time.Minute
|
||||||
dedupInterval = 60 * time.Second
|
dedupInterval = 60 * time.Second
|
||||||
dedupMaxSize = 10000 // hard cap on dedup map entries
|
dedupMaxSize = 10000 // hard cap on dedup map entries
|
||||||
typingResend = 8 * time.Second
|
typingResend = 8 * time.Second
|
||||||
typingSeconds = 10
|
typingSeconds = 10
|
||||||
bytesPerMiB = 1024 * 1024
|
bytesPerMiB = 1024 * 1024
|
||||||
qqStartupProbe = 15 * time.Second
|
qqStartupProbe = 15 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,9 @@ func TestHandleGroupATMessage_PrefersGroupOpenIDFromRawPayload(t *testing.T) {
|
||||||
ctx: context.Background(),
|
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{
|
err := ch.handleGroupATMessage()(&dto.WSPayload{RawMessage: raw}, &dto.WSGroupATMessageData{
|
||||||
ID: "group-openid-msg",
|
ID: "group-openid-msg",
|
||||||
GroupID: "legacy-group-id",
|
GroupID: "legacy-group-id",
|
||||||
|
|
@ -169,7 +171,9 @@ func TestHandleGroupATMessage_AllowListFallsBackToLegacyMemberID(t *testing.T) {
|
||||||
ctx: context.Background(),
|
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{
|
err := ch.handleGroupATMessage()(&dto.WSPayload{RawMessage: raw}, &dto.WSGroupATMessageData{
|
||||||
ID: "group-allow-fallback",
|
ID: "group-allow-fallback",
|
||||||
GroupID: "legacy-group-id",
|
GroupID: "legacy-group-id",
|
||||||
|
|
@ -196,11 +200,11 @@ func TestHandleGroupATMessage_AllowListFallsBackToLegacyMemberID(t *testing.T) {
|
||||||
|
|
||||||
func TestParseQQOpenIDs(t *testing.T) {
|
func TestParseQQOpenIDs(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
raw []byte
|
raw []byte
|
||||||
wantUser string
|
wantUser string
|
||||||
wantMember string
|
wantMember string
|
||||||
wantGroup string
|
wantGroup string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "empty",
|
name: "empty",
|
||||||
|
|
@ -217,8 +221,10 @@ func TestParseQQOpenIDs(t *testing.T) {
|
||||||
wantGroup: "",
|
wantGroup: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "all openids",
|
name: "all openids",
|
||||||
raw: []byte(`{"d":{"group_openid":"group-1","author":{"user_openid":"user-1","member_openid":"member-1"}}}`),
|
raw: []byte(
|
||||||
|
`{"d":{"group_openid":"group-1","author":{"user_openid":"user-1","member_openid":"member-1"}}}`,
|
||||||
|
),
|
||||||
wantUser: "user-1",
|
wantUser: "user-1",
|
||||||
wantMember: "member-1",
|
wantMember: "member-1",
|
||||||
wantGroup: "group-1",
|
wantGroup: "group-1",
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,11 @@ func setupAndStartChannelServices(
|
||||||
}
|
}
|
||||||
|
|
||||||
if runningServices.ListenHost != "" {
|
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 {
|
} else {
|
||||||
fmt.Println("⚠ Shared HTTP server disabled; /health and webhook endpoints are unavailable")
|
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
|
return host, nil
|
||||||
} else if isLoopbackHost(host) {
|
} else if isLoopbackHost(host) {
|
||||||
if fallbackErr := probeTCPBind("0.0.0.0", port); fallbackErr == nil {
|
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{
|
logger.WarnCF(
|
||||||
"host": host,
|
"channels",
|
||||||
"port": port,
|
"Loopback host unavailable in channel-only mode, fallback to wildcard",
|
||||||
})
|
map[string]any{
|
||||||
|
"host": host,
|
||||||
|
"port": port,
|
||||||
|
},
|
||||||
|
)
|
||||||
return "0.0.0.0", nil
|
return "0.0.0.0", nil
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("bind %s:%d failed: %w", host, port, err)
|
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()
|
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 {
|
if cp, ok := provider.(providers.StatefulProvider); ok {
|
||||||
cp.Close()
|
cp.Close()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue