From f5086a9342ce258ad66d6e762d15d33b107bc43e Mon Sep 17 00:00:00 2001 From: OpenClaw Agent Date: Sun, 15 Mar 2026 13:08:00 +0800 Subject: [PATCH] feat: optional token echo in sse endpoint --- README.md | 1 + main.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0eef6e2..a19d7be 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,7 @@ knowledge_ocean/ - **TAO_SEARCH_MAX_FILES**:检索文件上限(默认 2000) - **TAO_ALLOWED_REPOS**:inspect_and_propose 允许的仓库白名单(逗号分隔) - **TAO_ALLOW_GIT_PULL**:是否允许 inspect_and_propose 执行 git pull(默认 false) +- **TAO_ENDPOINT_TOKEN_ECHO**:若为 true,SSE endpoint 事件会回显 token(用于不带 Header 的客户端;默认 false) --- diff --git a/main.go b/main.go index 069dcbe..58ba646 100644 --- a/main.go +++ b/main.go @@ -323,11 +323,16 @@ func (s *TaoServer) SSEHandler(w http.ResponseWriter, r *http.Request) { client = generateClientID() } - if queryToken != "" { + endpointToken := queryToken + if endpointToken == "" && getEnvBool("TAO_ENDPOINT_TOKEN_ECHO", false) { + endpointToken = token + } + + if endpointToken != "" { if strings.Contains(endpoint, "?") { - endpoint = endpoint + "&token=" + queryToken + endpoint = endpoint + "&token=" + endpointToken } else { - endpoint = endpoint + "?token=" + queryToken + endpoint = endpoint + "?token=" + endpointToken } } if client != "" {