Skip to content

Port upstream HTTP requestHandler / llmInference passthrough (BYOK bidirectional streaming) #140

Description

@krukow

Generated via Copilot on behalf of @krukow

Summary

Deferred from the v1.0.1 → v1.0.4 upstream sync (@github/copilot 1.0.63 → 1.0.65). The upstream Node.js SDK added an entire HTTP/WebSocket request-handler subsystem for BYOK providers that the runtime can drive over JSON-RPC. This is large, self-contained, and best landed as its own follow-up PR rather than bundled with the smaller config/spec changes in the v1.0.4 sync.

What upstream added

A new ~818-line copilotRequestHandler.ts implementing bidirectional streaming for LLM inference requests proxied from the runtime to the SDK client:

  • Buffered + SSE HTTP request/response forwarding.
  • WebSocket frame forwarding.
  • Dispatched runtime → client over JSON-RPC: llmInference.setProvider, LlmInferenceHttpRequestStart / Chunk, HttpResponseStart / Chunk, error / end-of-stream notifications, and WS frame messages.

Upstream PRs:

Python ships the equivalent via httpx + websockets.

Why it's deferred

The Clojure SDK currently has no HTTP or WebSocket client dependency wired in. An idiomatic port needs:

  • A streaming HTTP client (buffered + SSE) — likely core.async channels for chunk delivery.
  • A WebSocket client for frame forwarding.
  • Request cancellation / lifecycle management tied to session teardown.
  • New inbound JSON-RPC handlers in setup-request-handler! following the permission-handler precedent.
  • Specs + register-fdef! entries for any new public surface.

This is marked @experimental upstream, so there's no parity-breakage risk in shipping it separately.

Scope checklist (for the follow-up PR)

  • Choose HTTP + WS client deps (evaluate http-kit, hato/java.net.http, gniazdo/Jetty WS).
  • Port llmInference.setProvider registration.
  • Port HTTP request-start/chunk/response-start/chunk/error/end streaming over core.async.
  • Port WebSocket frame forwarding.
  • Cancellation + resource cleanup on session stop.
  • Specs + fdefs + instrumentation.
  • Red/green TDD against the mock server; E2E if feasible.
  • Docs (doc/auth/byok.md, API.md) + CHANGELOG.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions