@clawos-dev/clawd 0.2.260 → 0.2.261
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21114,6 +21114,26 @@ var import_node_child_process = require("child_process");
|
|
|
21114
21114
|
var import_node_child_process2 = require("child_process");
|
|
21115
21115
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
21116
21116
|
|
|
21117
|
+
// ../protocol/src/methods.ts
|
|
21118
|
+
var RPC_METHOD_STATUSES = ["allowed", "conditional", "denied"];
|
|
21119
|
+
var RpcMethodStatusSchema = external_exports.enum(RPC_METHOD_STATUSES);
|
|
21120
|
+
var RpcMethodInfoSchema = external_exports.object({
|
|
21121
|
+
/** canonical method 名,直接可作为 clawd-rpc call 的 method 参数 */
|
|
21122
|
+
name: external_exports.string().min(1),
|
|
21123
|
+
status: RpcMethodStatusSchema,
|
|
21124
|
+
/**
|
|
21125
|
+
* `denied` 必带:daemon error code(`UNAUTHORIZED` / `FEISHU_LOGIN_REQUIRED` /
|
|
21126
|
+
* `METHOD_NOT_IMPLEMENTED`)。`conditional` 必带:谁来做二次校验。
|
|
21127
|
+
* `allowed` 恒无。
|
|
21128
|
+
*/
|
|
21129
|
+
reason: external_exports.string().optional()
|
|
21130
|
+
});
|
|
21131
|
+
var MetaMethodsResultSchema = external_exports.object({
|
|
21132
|
+
type: external_exports.literal("meta:methods"),
|
|
21133
|
+
/** METHOD_NAMES 全集,顺序与之一致 */
|
|
21134
|
+
methods: external_exports.array(RpcMethodInfoSchema)
|
|
21135
|
+
});
|
|
21136
|
+
|
|
21117
21137
|
// ../protocol/src/events.ts
|
|
21118
21138
|
var SESSION_STATUS_VALUES = [
|
|
21119
21139
|
"idle",
|
|
@@ -6890,7 +6890,8 @@ var require_dist = __commonJS({
|
|
|
6890
6890
|
// src/rpc-tool/mcp-server.ts
|
|
6891
6891
|
var mcp_server_exports = {};
|
|
6892
6892
|
__export(mcp_server_exports, {
|
|
6893
|
-
handleCallToolCall: () => handleCallToolCall
|
|
6893
|
+
handleCallToolCall: () => handleCallToolCall,
|
|
6894
|
+
handleListToolCall: () => handleListToolCall
|
|
6894
6895
|
});
|
|
6895
6896
|
module.exports = __toCommonJS(mcp_server_exports);
|
|
6896
6897
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
@@ -21171,6 +21172,38 @@ async function handleCallToolCall(input, ctx) {
|
|
|
21171
21172
|
log("call ok", { url });
|
|
21172
21173
|
return { content: [{ type: "text", text: JSON.stringify(json.result) }] };
|
|
21173
21174
|
}
|
|
21175
|
+
async function handleListToolCall(ctx) {
|
|
21176
|
+
const raw = await handleCallToolCall({ method: "meta:methods" }, ctx);
|
|
21177
|
+
if (raw.isError) return raw;
|
|
21178
|
+
let methods;
|
|
21179
|
+
try {
|
|
21180
|
+
methods = JSON.parse(raw.content[0].text).methods;
|
|
21181
|
+
} catch {
|
|
21182
|
+
return { content: [{ type: "text", text: "meta:methods returned an unexpected shape" }], isError: true };
|
|
21183
|
+
}
|
|
21184
|
+
return { content: [{ type: "text", text: formatMethodList(methods) }] };
|
|
21185
|
+
}
|
|
21186
|
+
function formatMethodList(methods) {
|
|
21187
|
+
const HEADINGS = {
|
|
21188
|
+
allowed: "callable now",
|
|
21189
|
+
conditional: "dispatcher lets these through, but the handler re-checks \u2014 may still be denied",
|
|
21190
|
+
denied: "not callable with this connection"
|
|
21191
|
+
};
|
|
21192
|
+
const lines = [];
|
|
21193
|
+
for (const status of ["allowed", "conditional", "denied"]) {
|
|
21194
|
+
const group = methods.filter((m) => m.status === status);
|
|
21195
|
+
if (group.length === 0) continue;
|
|
21196
|
+
lines.push(`## ${status} (${group.length}) \u2014 ${HEADINGS[status]}`);
|
|
21197
|
+
const byReason = /* @__PURE__ */ new Map();
|
|
21198
|
+
for (const m of group) byReason.set(m.reason ?? "", [...byReason.get(m.reason ?? "") ?? [], m.name]);
|
|
21199
|
+
for (const [reason, names] of byReason) {
|
|
21200
|
+
lines.push(reason ? `[${reason}] ${names.join(", ")}` : names.join(", "));
|
|
21201
|
+
}
|
|
21202
|
+
lines.push("");
|
|
21203
|
+
}
|
|
21204
|
+
lines.push("Call any of these with the `call` tool: call({ method, args }).");
|
|
21205
|
+
return lines.join("\n");
|
|
21206
|
+
}
|
|
21174
21207
|
async function main() {
|
|
21175
21208
|
const daemonUrl = process.env.CLAWD_DAEMON_URL;
|
|
21176
21209
|
const daemonToken = process.env.CLAWD_DAEMON_TOKEN;
|
|
@@ -21189,6 +21222,15 @@ async function main() {
|
|
|
21189
21222
|
},
|
|
21190
21223
|
async (input) => handleCallToolCall(input, { daemonUrl, daemonToken, sessionId })
|
|
21191
21224
|
);
|
|
21225
|
+
server.registerTool(
|
|
21226
|
+
"list",
|
|
21227
|
+
{
|
|
21228
|
+
title: "List callable clawd daemon RPC methods",
|
|
21229
|
+
description: "List every RPC method this daemon exposes, grouped by whether THIS connection can call it. Use it before guessing a method name \u2014 the daemon has 100+ methods and `call` does no local validation. Takes no arguments.",
|
|
21230
|
+
inputSchema: {}
|
|
21231
|
+
},
|
|
21232
|
+
async () => handleListToolCall({ daemonUrl, daemonToken, sessionId })
|
|
21233
|
+
);
|
|
21192
21234
|
await server.connect(new StdioServerTransport());
|
|
21193
21235
|
}
|
|
21194
21236
|
var isMainModule = typeof require !== "undefined" && typeof module !== "undefined" && require.main === module;
|
|
@@ -21205,5 +21247,6 @@ if (isMainModule) {
|
|
|
21205
21247
|
}
|
|
21206
21248
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21207
21249
|
0 && (module.exports = {
|
|
21208
|
-
handleCallToolCall
|
|
21250
|
+
handleCallToolCall,
|
|
21251
|
+
handleListToolCall
|
|
21209
21252
|
});
|