Propagate request id and add tools call handler

Forward the JSON-RPC request id through the dispatcher and handler so methods can access the id. JsonRpc2Dispatcher now passes the id to dispatchMethodAsync, and the JsonRpc2 endpoint lambda accepts the id parameter. Implemented a call for "tools/call" that extracts the tool name via ser.ExtractFrom(id, "params", "name") and invokes a new ResolveToolsCall(string) stub (TODO: implement actual tool logic). This prepares the codepath for tooling invocation based on request params.
This commit is contained in:
Namhyeon Go 2026-03-07 14:44:14 +09:00
parent 4101c03659
commit d7f58a9b0c
2 changed files with 8 additions and 3 deletions

View File

@ -74,7 +74,7 @@ namespace WelsonJS.Launcher.ApiEndpoints
{ {
await dispatcher.HandleAsync( await dispatcher.HandleAsync(
body, body,
async (method, ser, ct) => async (method, id, ser, ct) =>
{ {
switch (method) switch (method)
{ {
@ -83,7 +83,7 @@ namespace WelsonJS.Launcher.ApiEndpoints
break; break;
case "tools/call": case "tools/call":
// TODO: implement tool calling await ResolveToolsCall(ser.ExtractFrom(id, "params", "name"));
break; break;
} }
@ -92,5 +92,10 @@ namespace WelsonJS.Launcher.ApiEndpoints
cts.Token); cts.Token);
} }
} }
private async Task ResolveToolsCall(string toolsName)
{
// TODO: ex) get_weather
}
} }
} }

View File

@ -62,7 +62,7 @@ namespace WelsonJS.Launcher
Method = method Method = method
}; };
return await dispatchMethodAsync(req.Method, ser, ct); return await dispatchMethodAsync(req.Method, id, ser, ct);
} }
catch (JsonRpc2Exception) catch (JsonRpc2Exception)
{ {