5757 *
5858 * @see OpenClawGatewayWsClient
5959 * @see OpenClawChatClient
60+ * @see OpenClawSseClient
6061 * @see OpenClawEmbeddingsClient
6162 * @see OpenClawResponsesClient
6263 * @see OpenClawToolInvokeClient
@@ -69,6 +70,7 @@ public class OpenClawClient implements AutoCloseable {
6970
7071 private final OpenClawWebhookClient gatewayHttpClient ;
7172 private final OpenClawChatClient chatClient ;
73+ private final OpenClawSseClient sseClient ;
7274 private final OpenClawEmbeddingsClient embeddingsClient ;
7375 private final OpenClawResponsesClient responsesClient ;
7476 private final OpenClawToolInvokeClient toolsInvokeClient ;
@@ -151,14 +153,17 @@ private OpenClawClient(OpenClawHttpClientConfig httpConfig, OpenClawCliConfig cl
151153 // HTTP 子系统初始化(enabled=false 时不创建,字段为 null)
152154 if (httpEnabled ) {
153155 this .gatewayHttpClient = new OpenClawWebhookClient (httpConfig , objectMapper , httpClient );
154- this .chatClient = new OpenClawChatClient (httpConfig , objectMapper , httpClient );
156+ this .sseClient = new OpenClawSseClient (httpConfig , objectMapper , httpClient );
157+ this .chatClient = new OpenClawChatClient (
158+ httpConfig , objectMapper , httpClient , sseClient );
155159 this .embeddingsClient = new OpenClawEmbeddingsClient (httpConfig , objectMapper , httpClient );
156160 this .responsesClient = new OpenClawResponsesClient (httpConfig , objectMapper , httpClient );
157161 this .toolsInvokeClient = new OpenClawToolInvokeClient (httpConfig , objectMapper , httpClient );
158162 this .wsClient = new OpenClawGatewayWsClient (httpConfig );
159163 } else {
160164 this .gatewayHttpClient = null ;
161165 this .chatClient = null ;
166+ this .sseClient = null ;
162167 this .embeddingsClient = null ;
163168 this .responsesClient = null ;
164169 this .toolsInvokeClient = null ;
@@ -215,13 +220,15 @@ public OpenClawClient(OpenClawHttpClientConfig httpConfig,
215220 OpenClawCliConfig cliConfig ,
216221 OpenClawWebhookClient gatewayHttpClient ,
217222 OpenClawChatClient chatClient ,
223+ OpenClawSseClient sseClient ,
218224 OpenClawEmbeddingsClient embeddingsClient ,
219225 OpenClawResponsesClient responsesClient ,
220226 OpenClawToolInvokeClient toolsInvokeClient ,
221227 OpenClawCli cli ,
222228 OpenClawGatewayWsClient wsClient ) {
223229 this .gatewayHttpClient = gatewayHttpClient ;
224230 this .chatClient = chatClient ;
231+ this .sseClient = sseClient ;
225232 this .embeddingsClient = embeddingsClient ;
226233 this .responsesClient = responsesClient ;
227234 this .toolsInvokeClient = toolsInvokeClient ;
@@ -416,6 +423,15 @@ public OpenClawChatClient chat() {
416423 return chatClient ;
417424 }
418425
426+ /**
427+ * 返回 SSE 场景客户端。
428+ *
429+ * @return SSE 客户端;HTTP 子系统未启用时为 {@code null}
430+ */
431+ public OpenClawSseClient sse () {
432+ return sseClient ;
433+ }
434+
419435 /**
420436 * HTTP system {@link OkHttpClient}.
421437 * <p>inject,lifecyclemanaged by caller.</p>
@@ -686,6 +702,7 @@ public OpenClawCli cli() {
686702 @ Override
687703 public void close () {
688704 // 逐一释放所有子客户端资源,任一失败不影响其他
705+ closeQuietly (sseClient );
689706 closeQuietly (gatewayHttpClient );
690707 closeQuietly (chatClient );
691708 closeQuietly (embeddingsClient );
0 commit comments