deputy-mcp 0.1.3 → 0.1.4
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.
- package/dist/deputy-mcp.js +75 -2
- package/package.json +1 -1
package/dist/deputy-mcp.js
CHANGED
|
@@ -69730,11 +69730,84 @@ async function runGoal(taskId, goal, tabId) {
|
|
|
69730
69730
|
tasks.fail(taskId, String(err instanceof Error ? err.message : err));
|
|
69731
69731
|
}
|
|
69732
69732
|
}
|
|
69733
|
+
var SECRET_ARG = /pass|secret|token|card|cvv|cvc|otp|\bpin\b|ssn|iban|api.?key|licen[cs]e/i;
|
|
69734
|
+
function describeArgs(args) {
|
|
69735
|
+
const show = (v2, k2 = "") => {
|
|
69736
|
+
if (SECRET_ARG.test(k2))
|
|
69737
|
+
return "•••";
|
|
69738
|
+
if (typeof v2 === "string")
|
|
69739
|
+
return v2.length > 48 ? `"${v2.slice(0, 45)}…"` : `"${v2}"`;
|
|
69740
|
+
if (Array.isArray(v2))
|
|
69741
|
+
return `[${v2.slice(0, 4).map((x2) => show(x2)).join(", ")}${v2.length > 4 ? ", …" : ""}]`;
|
|
69742
|
+
if (v2 && typeof v2 === "object") {
|
|
69743
|
+
const keys = Object.keys(v2);
|
|
69744
|
+
return keys.length > 4 ? `{${keys.length} fields}` : `{${keys.map((kk) => `${kk}: ${show(v2[kk], kk)}`).join(", ")}}`;
|
|
69745
|
+
}
|
|
69746
|
+
return String(v2);
|
|
69747
|
+
};
|
|
69748
|
+
if (!args || typeof args !== "object")
|
|
69749
|
+
return "";
|
|
69750
|
+
const line = Object.entries(args).filter(([k2, v2]) => k2 !== "tabId" && v2 !== undefined).map(([k2, v2]) => `${k2}: ${show(v2, k2)}`).join(", ");
|
|
69751
|
+
return line.length > 160 ? `${line.slice(0, 157)}…` : line;
|
|
69752
|
+
}
|
|
69753
|
+
function describeResult(result) {
|
|
69754
|
+
const items = result?.content ?? [];
|
|
69755
|
+
if (items.some((c2) => c2?.type === "image"))
|
|
69756
|
+
return "a screenshot";
|
|
69757
|
+
if (result?.resultType === "input_required")
|
|
69758
|
+
return "asked the user to approve";
|
|
69759
|
+
const text2 = items.filter((c2) => c2?.type === "text").map((c2) => String(c2.text)).join(`
|
|
69760
|
+
`).trim();
|
|
69761
|
+
if (!text2)
|
|
69762
|
+
return "done";
|
|
69763
|
+
let summary = text2;
|
|
69764
|
+
try {
|
|
69765
|
+
const v2 = JSON.parse(text2);
|
|
69766
|
+
if (Array.isArray(v2))
|
|
69767
|
+
summary = `${v2.length} item${v2.length === 1 ? "" : "s"}`;
|
|
69768
|
+
else if (Array.isArray(v2?.items))
|
|
69769
|
+
summary = `${v2.items.length} item${v2.items.length === 1 ? "" : "s"}${v2.total > v2.items.length ? ` of ${v2.total}` : ""}`;
|
|
69770
|
+
else if (typeof v2?.page === "string")
|
|
69771
|
+
summary = `${v2.page}${Array.isArray(v2.tools) && v2.tools.length ? `; ${v2.tools.length} form tool${v2.tools.length === 1 ? "" : "s"}` : ""}`;
|
|
69772
|
+
else
|
|
69773
|
+
summary = text2.split(`
|
|
69774
|
+
`).find((l2) => /\w/.test(l2)) ?? text2;
|
|
69775
|
+
} catch {
|
|
69776
|
+
summary = text2.split(`
|
|
69777
|
+
`).find((l2) => l2.trim()) ?? text2;
|
|
69778
|
+
}
|
|
69779
|
+
summary = summary.replace(/\s+/g, " ").trim();
|
|
69780
|
+
return summary.length > 160 ? `${summary.slice(0, 157)}…` : summary;
|
|
69781
|
+
}
|
|
69782
|
+
async function reported(tool, args, run) {
|
|
69783
|
+
const tabOf = () => typeof args?.tabId === "number" ? args.tabId : link.registry.activeTab()?.tabId;
|
|
69784
|
+
const tell = (tabId, entry2) => {
|
|
69785
|
+
if (tabId == null || !current)
|
|
69786
|
+
return;
|
|
69787
|
+
current.call({ op: "activity", tabId, entry: entry2 }).catch(() => {});
|
|
69788
|
+
};
|
|
69789
|
+
const entry = { call: randomUUID(), at: Date.now(), tool, args: describeArgs(args) };
|
|
69790
|
+
const before = tabOf();
|
|
69791
|
+
tell(before, entry);
|
|
69792
|
+
try {
|
|
69793
|
+
const result = await run();
|
|
69794
|
+
const after = tabOf();
|
|
69795
|
+
const done = { ...entry, result: describeResult(result), ok: !result?.isError, ms: Date.now() - entry.at };
|
|
69796
|
+
tell(before, done);
|
|
69797
|
+
if (after !== before)
|
|
69798
|
+
tell(after, done);
|
|
69799
|
+
return result;
|
|
69800
|
+
} catch (err) {
|
|
69801
|
+
tell(before, { ...entry, result: String(err instanceof Error ? err.message : err).slice(0, 160), ok: false, ms: Date.now() - entry.at });
|
|
69802
|
+
throw err;
|
|
69803
|
+
}
|
|
69804
|
+
}
|
|
69733
69805
|
function buildServer() {
|
|
69734
|
-
const server = new McpServer({ name: "deputy", version: "0.1.
|
|
69806
|
+
const server = new McpServer({ name: "deputy", version: "0.1.4" }, { instructions: INSTRUCTIONS });
|
|
69735
69807
|
const register2 = server.registerTool.bind(server);
|
|
69736
69808
|
const tools = new Map;
|
|
69737
|
-
server.registerTool = (name, config2,
|
|
69809
|
+
server.registerTool = (name, config2, handler) => {
|
|
69810
|
+
const cb = (args, extra) => reported(name, args, () => handler(args, extra));
|
|
69738
69811
|
const tool = register2(name, {
|
|
69739
69812
|
...config2,
|
|
69740
69813
|
annotations: { ...config2.annotations, ...READ_ONLY.has(name) ? { readOnlyHint: true } : {} },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deputy-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"mcpName": "io.github.zraisan/deputy",
|
|
5
5
|
"description": "Deputy's MCP bridge: Claude Code, Codex, Cursor and any MCP client use the pages in your browser as typed tools. Needs the Deputy Chrome extension; free to start, Deputy Pro adds 17 tools and hosted models.",
|
|
6
6
|
"type": "module",
|