feat: optional token echo in sse endpoint

This commit is contained in:
OpenClaw Agent
2026-03-15 13:08:00 +08:00
parent c20b33adb0
commit f5086a9342
2 changed files with 9 additions and 3 deletions

View File

@@ -151,6 +151,7 @@ knowledge_ocean/
- **TAO_SEARCH_MAX_FILES**:检索文件上限(默认 2000 - **TAO_SEARCH_MAX_FILES**:检索文件上限(默认 2000
- **TAO_ALLOWED_REPOS**inspect_and_propose 允许的仓库白名单(逗号分隔) - **TAO_ALLOWED_REPOS**inspect_and_propose 允许的仓库白名单(逗号分隔)
- **TAO_ALLOW_GIT_PULL**:是否允许 inspect_and_propose 执行 git pull默认 false - **TAO_ALLOW_GIT_PULL**:是否允许 inspect_and_propose 执行 git pull默认 false
- **TAO_ENDPOINT_TOKEN_ECHO**:若为 trueSSE endpoint 事件会回显 token用于不带 Header 的客户端;默认 false
--- ---

11
main.go
View File

@@ -323,11 +323,16 @@ func (s *TaoServer) SSEHandler(w http.ResponseWriter, r *http.Request) {
client = generateClientID() client = generateClientID()
} }
if queryToken != "" { endpointToken := queryToken
if endpointToken == "" && getEnvBool("TAO_ENDPOINT_TOKEN_ECHO", false) {
endpointToken = token
}
if endpointToken != "" {
if strings.Contains(endpoint, "?") { if strings.Contains(endpoint, "?") {
endpoint = endpoint + "&token=" + queryToken endpoint = endpoint + "&token=" + endpointToken
} else { } else {
endpoint = endpoint + "?token=" + queryToken endpoint = endpoint + "?token=" + endpointToken
} }
} }
if client != "" { if client != "" {