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:
parent
c88ed95b94
commit
249b9f80f9
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in New Issue