mirror of
https://github.com/gnh1201/welsonjs.git
synced 2026-04-18 18:18:42 +00:00
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:
parent
4101c03659
commit
d7f58a9b0c
|
|
@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user