mirror of
https://github.com/gnh1201/welsonjs.git
synced 2026-04-18 18:18:42 +00:00
Allow no-reply notifications; also write messages to stderr
Treat a callback returning false as a signal to suppress a JSON-RPC reply (jsonrpc2.extract). Add a special-case in mcploader to return false for "notifications/initialized" so no response is sent. In stdio-server, skip sending falsy messages, keep object serialization, and write outgoing messages to both StdOut and StdErr (useful for logging/debugging). Small cleanup in catch formatting.
This commit is contained in:
parent
c22ca660ec
commit
03d078bde8
|
|
@ -69,12 +69,15 @@ function extract(message, callback) {
|
|||
try {
|
||||
var result = callback(data.method, params, id);
|
||||
|
||||
if (result !== false) {
|
||||
return {
|
||||
jsonrpc: "2.0",
|
||||
result: result === undefined ? null : result,
|
||||
id: id
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (e) {
|
||||
return {
|
||||
jsonrpc: "2.0",
|
||||
|
|
|
|||
|
|
@ -16,14 +16,17 @@ function StdioServer() {
|
|||
};
|
||||
|
||||
this.send = function (message) {
|
||||
if (!message) return;
|
||||
|
||||
if (typeof message === "object") {
|
||||
try {
|
||||
var _serialized = JSON.stringify(message);
|
||||
message = _serialized;
|
||||
} catch (e) { /* ignore */ };
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
|
||||
WScript.StdOut.WriteLine(message);
|
||||
WScript.StdErr.WriteLine(message);
|
||||
};
|
||||
|
||||
this.listen = function () {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ function main(args) {
|
|||
};
|
||||
}
|
||||
|
||||
if (method === "notifications/initialized") {
|
||||
// DO NOT return anything
|
||||
return false;
|
||||
}
|
||||
|
||||
if (method == "tools/list") {
|
||||
return {
|
||||
"tools": [
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user