feat(resource): add stable resource registry with LLM-context alias compaction

Introduce resource://<handle> as the stable application identity for stored
objects, decoupling API responses, persisted rich text, and LLM prompts from
physical storage paths. Adds a resource catalog service (register/resolve/bind,
revocable expiring access grants), a request-local alias registry that compacts
resource references while in the LLM context and restores them (including across
streaming chunks), plus router, IM, chat-pipeline, and multimodal integration.

Includes schema migrations (resources, resource_bindings, resource_access_grants)
for sqlite, and hardens URL/output security handling.
This commit is contained in:
wizardchen
2026-07-15 16:31:21 +08:00
committed by lyingbug
parent 9733bd28bf
commit 6d14cc3536
32 changed files with 1790 additions and 59 deletions
+9 -2
View File
@@ -164,8 +164,12 @@ func IsValidURL(url string) bool {
return false
}
// 检查协议, 只允许 http, https, local, minio, cos, tos, oss 协议
allowedProtocols := []string{"http://", "https://", "local://", "minio://", "cos://", "tos://", "oss://"}
// Internal resource references are resolved through authenticated file
// proxies; provider schemes remain supported for legacy stored content.
allowedProtocols := []string{
"http://", "https://", "resource://", "storage://", "local://", "minio://",
"cos://", "tos://", "s3://", "oss://", "ks3://", "obs://",
}
isAllowed := false
for _, protocol := range allowedProtocols {
if strings.HasPrefix(strings.ToLower(url), protocol) {
@@ -486,6 +490,9 @@ func IsValidImageURL(url string) bool {
if !IsValidURL(url) {
return false
}
if strings.HasPrefix(strings.ToLower(url), "resource://") {
return true
}
// 检查是否为图片文件
imageExtensions := []string{".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".bmp", ".ico"}