Merge pull request #1513 from trheyi/main

chore(dependencies): update AWS SDK and related packages to latest ve…
This commit is contained in:
Max 2026-04-08 17:45:33 +08:00 committed by GitHub
commit d27406b342
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 522 additions and 453 deletions

View file

@ -129,6 +129,15 @@ func (r *Runner) Stream(ctx context.Context, req *types.StreamRequest, handler m
return err return err
} }
// Mark session in store immediately after CLI process starts.
// Claude CLI creates session files on disk at startup, so subsequent
// requests must use --resume (not --session-id) even if this stream fails.
if chatID != "" {
storeKey := "claude-session:" + assistantID + ":" + chatID
sessionUUID := chatIDToSessionUUID(assistantID, chatID)
markChatSession(storeKey, sessionUUID, 90*24*time.Hour)
}
streamStart := time.Now() streamStart := time.Now()
completed, err := sess.runStream(handler) completed, err := sess.runStream(handler)
r.lastCompleted = completed r.lastCompleted = completed
@ -137,11 +146,6 @@ func (r *Runner) Stream(ctx context.Context, req *types.StreamRequest, handler m
r.logger.Debug("Stream: runStream returned completed=%v err=%v elapsed=%v", completed, err, elapsed) r.logger.Debug("Stream: runStream returned completed=%v err=%v elapsed=%v", completed, err, elapsed)
if completed { if completed {
sess.shutdown() sess.shutdown()
if chatID != "" {
storeKey := "claude-session:" + assistantID + ":" + chatID
sessionUUID := chatIDToSessionUUID(assistantID, chatID)
markChatSession(storeKey, sessionUUID, 90*24*time.Hour)
}
} }
return err return err
} }

View file

@ -3,6 +3,7 @@ package xun
import ( import (
"fmt" "fmt"
"math" "math"
"strings"
"time" "time"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
@ -333,9 +334,8 @@ func (store *Xun) GetAssistants(filter types.AssistantFilter, locale ...string)
qb.Where(func(qb query.Query) { qb.Where(func(qb query.Query) {
qb.Where("name", "like", kw). qb.Where("name", "like", kw).
OrWhere("description", "like", kw). OrWhere("description", "like", kw).
OrWhere("capabilities", "like", kw) OrWhere("capabilities", "like", kw).
localeVal := store.jsonContainsValue(kw) OrWhereRaw(store.localesLikeSQL(filter.Keywords))
qb.OrWhereJSONContains("locales", localeVal)
}) })
} }
@ -905,6 +905,25 @@ func (store *Xun) translate(model *types.AssistantModel, assistantID string, loc
// correctly through the LIKE query on the DB column. // correctly through the LIKE query on the DB column.
} }
// localesLikeSQL returns a dialect-specific raw SQL fragment for LIKE on the locales JSON column.
// PostgreSQL's json type does not support the LIKE operator directly; cast to text is required.
// The keyword is escaped and inlined (no bind parameter) to avoid placeholder incompatibility
// across dialects in WhereRaw (PostgreSQL uses $N, MySQL/SQLite use ?).
func (store *Xun) localesLikeSQL(keyword string) string {
escaped := strings.ReplaceAll(keyword, "'", "''")
escaped = strings.ReplaceAll(escaped, "%", "\\%")
escaped = strings.ReplaceAll(escaped, "_", "\\_")
pattern := "'%" + escaped + "%'"
switch store.getDriver() {
case "postgres":
return fmt.Sprintf(`"locales"::text LIKE %s`, pattern)
case "sqlite3":
return fmt.Sprintf("`locales` LIKE %s", pattern)
default:
return fmt.Sprintf("`locales` LIKE %s", pattern)
}
}
// sandboxRawSQL returns dialect-specific raw SQL fragments for sandbox JSON null detection. // sandboxRawSQL returns dialect-specific raw SQL fragments for sandbox JSON null detection.
// Returns (notNullExpr, isNullExpr) for filtering sandbox field. // Returns (notNullExpr, isNullExpr) for filtering sandbox field.
// WhereRaw is used here because this is a JSON literal `null` comparison, not a JSON array // WhereRaw is used here because this is a JSON literal `null` comparison, not a JSON array

View file

@ -1070,6 +1070,70 @@ func TestSaveAssistant(t *testing.T) {
} }
}) })
t.Run("KeywordsSearchLocales", func(t *testing.T) {
uniqueLocaleText := fmt.Sprintf("localekw-%d", time.Now().UnixNano())
assistant := &types.AssistantModel{
Name: "Locale Search Test",
Type: "assistant",
Connector: "openai",
Share: "private",
Locales: i18n.Map{
"zh-cn": i18n.I18n{
Locale: "zh-cn",
Messages: map[string]any{"name": uniqueLocaleText},
},
},
}
id, err := store.SaveAssistant(assistant)
if err != nil {
t.Fatalf("Failed to save assistant with locales: %v", err)
}
defer store.DeleteAssistant(id)
response, err := store.GetAssistants(types.AssistantFilter{
Keywords: uniqueLocaleText,
Page: 1,
PageSize: 20,
})
if err != nil {
t.Fatalf("Keywords search with locales should not error: %v", err)
}
found := false
for _, a := range response.Data {
if a.ID == id {
found = true
break
}
}
if !found {
t.Error("Expected to find assistant by locale text keyword search")
}
// Partial match should also work
partial := uniqueLocaleText[:10]
response2, err := store.GetAssistants(types.AssistantFilter{
Keywords: partial,
Page: 1,
PageSize: 20,
})
if err != nil {
t.Fatalf("Partial keywords search should not error: %v", err)
}
found = false
for _, a := range response2.Data {
if a.ID == id {
found = true
break
}
}
if !found {
t.Error("Expected to find assistant by partial locale text keyword search")
}
})
t.Run("UpdateSandbox", func(t *testing.T) { t.Run("UpdateSandbox", func(t *testing.T) {
assistant := &types.AssistantModel{ assistant := &types.AssistantModel{
Name: "Update Sandbox Test", Name: "Update Sandbox Test",

File diff suppressed because it is too large Load diff

24
go.mod
View file

@ -4,9 +4,9 @@ go 1.25.0
require ( require (
github.com/PuerkitoBio/goquery v1.10.3 github.com/PuerkitoBio/goquery v1.10.3
github.com/aws/aws-sdk-go-v2 v1.36.3 github.com/aws/aws-sdk-go-v2 v1.41.5
github.com/aws/aws-sdk-go-v2/credentials v1.17.67 github.com/aws/aws-sdk-go-v2/credentials v1.19.14
github.com/aws/aws-sdk-go-v2/service/s3 v1.79.3 github.com/aws/aws-sdk-go-v2/service/s3 v1.99.0
github.com/bwmarrin/discordgo v0.29.0 github.com/bwmarrin/discordgo v0.29.0
github.com/caarlos0/env/v6 v6.10.1 github.com/caarlos0/env/v6 v6.10.1
github.com/dchest/captcha v1.1.0 github.com/dchest/captcha v1.1.0
@ -65,15 +65,15 @@ require (
github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 // indirect github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 // indirect
github.com/andybalholm/cascadia v1.3.3 // indirect github.com/andybalholm/cascadia v1.3.3 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.8 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.34 // indirect github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.22 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.7 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.1 // indirect github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.13 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.21 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15 // indirect github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.21 // indirect
github.com/aws/smithy-go v1.22.3 // indirect github.com/aws/smithy-go v1.24.2 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect github.com/blang/semver/v4 v4.0.0 // indirect
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
github.com/bytedance/sonic v1.13.2 // indirect github.com/bytedance/sonic v1.13.2 // indirect

48
go.sum
View file

@ -19,30 +19,30 @@ github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kk
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA= github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aws/aws-sdk-go-v2 v1.36.3 h1:mJoei2CxPutQVxaATCzDUjcZEjVRdpsiiXi2o38yqWM= github.com/aws/aws-sdk-go-v2 v1.41.5 h1:dj5kopbwUsVUVFgO4Fi5BIT3t4WyqIDjGKCangnV/yY=
github.com/aws/aws-sdk-go-v2 v1.36.3/go.mod h1:LLXuLpgzEbD766Z5ECcRmi8AzSwfZItDtmABVkRLGzg= github.com/aws/aws-sdk-go-v2 v1.41.5/go.mod h1:mwsPRE8ceUUpiTgF7QmQIJ7lgsKUPQOUl3o72QBrE1o=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 h1:zAybnyUQXIZ5mok5Jqwlf58/TFE7uvd3IAsa1aF9cXs= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.8 h1:eBMB84YGghSocM7PsjmmPffTa+1FBUeNvGvFou6V/4o=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10/go.mod h1:qqvMj6gHLR/EXWZw4ZbqlPbQUyenf4h82UQUlKc+l14= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.8/go.mod h1:lyw7GFp3qENLh7kwzf7iMzAxDn+NzjXEAGjKS2UOKqI=
github.com/aws/aws-sdk-go-v2/credentials v1.17.67 h1:9KxtdcIA/5xPNQyZRgUSpYOE6j9Bc4+D7nZua0KGYOM= github.com/aws/aws-sdk-go-v2/credentials v1.19.14 h1:n+UcGWAIZHkXzYt87uMFBv/l8THYELoX6gVcUvgl6fI=
github.com/aws/aws-sdk-go-v2/credentials v1.17.67/go.mod h1:p3C44m+cfnbv763s52gCqrjaqyPikj9Sg47kUVaNZQQ= github.com/aws/aws-sdk-go-v2/credentials v1.19.14/go.mod h1:cJKuyWB59Mqi0jM3nFYQRmnHVQIcgoxjEMAbLkpr62w=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 h1:ZK5jHhnrioRkUNOc+hOgQKlUL5JeC3S6JgLxtQ+Rm0Q= github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21 h1:Rgg6wvjjtX8bNHcvi9OnXWwcE0a2vGpbwmtICOsvcf4=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34/go.mod h1:p4VfIceZokChbA9FzMbRGz5OV+lekcVtHlPKEO0gSZY= github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21/go.mod h1:A/kJFst/nm//cyqonihbdpQZwiUhhzpqTsdbhDdRF9c=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 h1:SZwFm17ZUNNg5Np0ioo/gq8Mn6u9w19Mri8DnJ15Jf0= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21 h1:PEgGVtPoB6NTpPrBgqSE5hE/o47Ij9qk/SEZFbUOe9A=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34/go.mod h1:dFZsC0BLo346mvKQLWmoJxT+Sjp+qcVR1tRVHQGOH9Q= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21/go.mod h1:p+hz+PRAYlY3zcpJhPwXlLC4C+kqn70WIHwnzAfs6ps=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.34 h1:ZNTqv4nIdE/DiBfUUfXcLZ/Spcuz+RjeziUtNJackkM= github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.22 h1:rWyie/PxDRIdhNf4DzRk0lvjVOqFJuNnO8WwaIRVxzQ=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.34/go.mod h1:zf7Vcd1ViW7cPqYWEHLHJkS50X0JS2IKz9Cgaj6ugrs= github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.22/go.mod h1:zd/JsJ4P7oGfUhXn1VyLqaRZwPmZwg44Jf2dS84Dm3Y=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 h1:eAh2A4b5IzM/lum78bZ590jy36+d/aFLgKF/4Vd1xPE= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.7 h1:5EniKhLZe4xzL7a+fU3C2tfUN4nWIqlLesfrjkuPFTY=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3/go.mod h1:0yKJC/kb8sAnmlYa6Zs3QVYqaC8ug2AbnNChv5Ox3uA= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.7/go.mod h1:x0nZssQ3qZSnIcePWLvcoFisRXJzcTVvYpAAdYX8+GI=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.1 h1:4nm2G6A4pV9rdlWzGMPv4BNtQp22v1hg3yrtkYpeLl8= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.13 h1:JRaIgADQS/U6uXDqlPiefP32yXTda7Kqfx+LgspooZM=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.1/go.mod h1:iu6FSzgt+M2/x3Dk8zhycdIcHjEFb36IS8HVUVFoMg0= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.13/go.mod h1:CEuVn5WqOMilYl+tbccq8+N2ieCy0gVn3OtRb0vBNNM=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 h1:dM9/92u2F1JbDaGooxTq18wmmFzbJRfXfVfy96/1CXM= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.21 h1:c31//R3xgIJMSC8S6hEVq+38DcvUlgFY0FM6mSI5oto=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15/go.mod h1:SwFBy2vjtA0vZbjjaFtfN045boopadnoVPhu4Fv66vY= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.21/go.mod h1:r6+pf23ouCB718FUxaqzZdbpYFyDtehyZcmP5KL9FkA=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15 h1:moLQUoVq91LiqT1nbvzDukyqAlCv89ZmwaHw/ZFlFZg= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.21 h1:ZlvrNcHSFFWURB8avufQq9gFsheUgjVD9536obIknfM=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15/go.mod h1:ZH34PJUc8ApjBIfgQCFvkWcUDBtl/WTD+uiYHjd8igA= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.21/go.mod h1:cv3TNhVrssKR0O/xxLJVRfd2oazSnZnkUeTf6ctUwfQ=
github.com/aws/aws-sdk-go-v2/service/s3 v1.79.3 h1:BRXS0U76Z8wfF+bnkilA2QwpIch6URlm++yPUt9QPmQ= github.com/aws/aws-sdk-go-v2/service/s3 v1.99.0 h1:hlSuz394kV0vhv9drL5lhuEFbEOEP1VyQpy15qWh1Pk=
github.com/aws/aws-sdk-go-v2/service/s3 v1.79.3/go.mod h1:bNXKFFyaiVvWuR6O16h/I1724+aXe/tAkA9/QS01t5k= github.com/aws/aws-sdk-go-v2/service/s3 v1.99.0/go.mod h1:uoA43SdFwacedBfSgfFSjjCvYe8aYBS7EnU5GZ/YKMM=
github.com/aws/smithy-go v1.22.3 h1:Z//5NuZCSW6R4PhQ93hShNbyBbn8BWCmCVCt+Q8Io5k= github.com/aws/smithy-go v1.24.2 h1:FzA3bu/nt/vDvmnkg+R8Xl46gmzEDam6mZ1hzmwXFng=
github.com/aws/smithy-go v1.22.3/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI= github.com/aws/smithy-go v1.24.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI= github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI=

View file

@ -3,9 +3,6 @@
"description": "Extract entities and relationships", "description": "Extract entities and relationships",
"type": "worker", "type": "worker",
"uses": { "search": "disabled" }, "uses": { "search": "disabled" },
"options": { "options": { "max_tokens": 2000 }
"max_tokens": 2000,
"temperature": 0.2
}
} }

View file

@ -3,8 +3,5 @@
"description": "Extract search keywords", "description": "Extract search keywords",
"type": "worker", "type": "worker",
"uses": { "search": "disabled" }, "uses": { "search": "disabled" },
"options": { "options": { "max_tokens": 500 }
"max_tokens": 500,
"temperature": 0.3
}
} }

View file

@ -3,8 +3,5 @@
"description": "Check if references are needed", "description": "Check if references are needed",
"type": "worker", "type": "worker",
"uses": { "search": "disabled" }, "uses": { "search": "disabled" },
"options": { "options": { "max_tokens": 200 }
"max_tokens": 200,
"temperature": 0.1
}
} }

View file

@ -3,7 +3,5 @@
"description": "Optimize prompts for better results", "description": "Optimize prompts for better results",
"type": "worker", "type": "worker",
"uses": { "search": "disabled" }, "uses": { "search": "disabled" },
"options": { "options": { }
"temperature": 0
}
} }

View file

@ -3,8 +3,5 @@
"description": "Build database queries", "description": "Build database queries",
"type": "worker", "type": "worker",
"uses": { "search": "disabled" }, "uses": { "search": "disabled" },
"options": { "options": { "max_tokens": 8192 }
"max_tokens": 8192,
"temperature": 0.2
}
} }

View file

@ -3,7 +3,5 @@
"description": "Generate system prompts for autonomous robots", "description": "Generate system prompts for autonomous robots",
"type": "worker", "type": "worker",
"uses": { "search": "disabled" }, "uses": { "search": "disabled" },
"options": { "options": { }
"temperature": 0.7
}
} }

View file

@ -3,7 +3,5 @@
"description": "Generate conversation titles", "description": "Generate conversation titles",
"type": "worker", "type": "worker",
"uses": { "search": "disabled" }, "uses": { "search": "disabled" },
"options": { "options": { }
"temperature": 0
}
} }