feat: add streaming support for x402 payment flow to bypass Cloudflare timeout

- Extract ParseSSEStream as shared function from CallWithRequestStream
- Add DoX402RequestStream and X402CallStream for streaming x402 payments
- Switch Claw402Client.Call to use streaming (X402CallStream)
- TeeReader fallback: SSE parsing with JSON fallback for non-SSE responses
- Idle timeout watchdog (90s) protects against stalled streams
This commit is contained in:
tinkle-community
2026-03-16 12:41:30 +08:00
parent 780bb39a92
commit 0f06f9b2a2
3 changed files with 252 additions and 7 deletions

View File

@@ -125,7 +125,7 @@ func (c *Claw402Client) resolveEndpoint() string {
func (c *Claw402Client) SetAuthHeader(h http.Header) { X402SetAuthHeader(h) }
func (c *Claw402Client) Call(systemPrompt, userPrompt string) (string, error) {
return X402Call(c.Client, c.signPayment, "Claw402", systemPrompt, userPrompt)
return X402CallStream(c.Client, c.signPayment, "Claw402", systemPrompt, userPrompt, nil)
}
func (c *Claw402Client) CallWithRequestFull(req *mcp.Request) (*mcp.LLMResponse, error) {