ollie-remote: wire streaming output to JSON-RPC notifications

ExecuteInSandbox uses StreamFunc(ctx) to emit partial output. The
context passed to it lacked a WithOutputStream callback, so no output
was ever streamed back to the client.

Fix: wrap ctx with WithOutputStream that encodes output as JSON-RPC
notifications (id=0, result={data:...}). The client side already
handles these via the outputNotification path in CallTool.
This commit is contained in:
Levi Neely 2026-07-31 11:18:53 +02:00
parent c88ed95b94
commit 249b9f80f9
1 changed files with 12 additions and 1 deletions

View File

@ -122,6 +122,10 @@ type shellParams struct {
Stdin string `json:"stdin,omitempty"`
}
type outputNotif struct {
Data string `json:"data"`
}
func serveRPC(ctx context.Context, srv *toolsrv.Server, in io.Reader, out io.Writer) {
dec := json.NewDecoder(in)
enc := json.NewEncoder(out)
@ -151,7 +155,14 @@ func serveRPC(ctx context.Context, srv *toolsrv.Server, in io.Reader, out io.Wri
})
continue
}
result, err := srv.ExecuteInSandbox(ctx, params.Command, params.Language, params.Timeout, "default", false, params.Stdin, false)
// Wire streaming output to JSON-RPC notifications.
streamCtx := toolsrv.WithOutputStream(ctx, func(data string) {
enc.Encode(rpcResponse{
JSONRPC: "2.0",
Result: outputNotif{Data: data},
})
})
result, err := srv.ExecuteInSandbox(streamCtx, params.Command, params.Language, params.Timeout, "default", false, params.Stdin, false)
if err != nil {
enc.Encode(rpcResponse{
JSONRPC: "2.0",