dsh-agy-link 0.4.98 → 0.4.99

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.99 (2026-10-31)
4
+
5
+ ### English
6
+
7
+ - **Feat(toolview): unwrap Antigravity MCP meta-tools into native terminal/search cards.** (thanks @Ronnoc, #64)
8
+ - External MCP tools are dispatched by agy through meta-tools (`call_mcp_tool` / `callMcpTool` / `mcp__<server>__<tool>`), so every MCP call previously rendered as one repetitive `call_mcp_tool` card with raw JSON. Host mirror presenters and Client toolviews now unwrap the inner invocation: terminal-ish tools (`ops_bash`, `sh`, `shell`, …) become native Terminal cards (`$ cmd`, cwd, exit code, timeout), glob/grep become Search cards, and other MCP tools show as `<server>: <tool>`. MCP text envelopes (`{content:[{type:'text',text}]}`) are cleaned. Adds tests (588+ passing).
9
+
10
+ ### 中文
11
+
12
+ - **新增(toolview):把 Antigravity 的 MCP 元工具拆包为原生终端/搜索卡片。**(感谢 @Ronnoc,#64)
13
+ - 外部 MCP 工具由 agy 经元工具(`call_mcp_tool` 等)调度,此前所有 MCP 调用都退化成一个重复的 `call_mcp_tool` 原始 JSON 卡片。现 Host 镜像 Presenter 与 Client Toolview 都会拆包内层调用:终端类(`ops_bash`/`sh`/`shell`…)渲染为原生终端卡片(`$ cmd`、cwd、退出码、超时),glob/grep 渲染为搜索卡片,其它 MCP 显示 `<server>: <tool>`;并清理 MCP 文本信封。补充测试(588+ 通过)。
14
+
15
+ **Full Changelog**: https://github.com/amlyczz/dsh-agy-link/compare/v0.4.98...v0.4.99
16
+
3
17
  ## 0.4.98 (2026-10-30)
4
18
 
5
19
  ### English
package/dist/client.js CHANGED
@@ -1760,10 +1760,50 @@ window.__ModuleLoader__.load({
1760
1760
  return null;
1761
1761
  }
1762
1762
  }
1763
+ function cleanString(val) {
1764
+ if (typeof val !== "string") return "";
1765
+ let s = val.trim();
1766
+ if (s.startsWith("\"") && s.endsWith("\"") || s.startsWith("'") && s.endsWith("'")) s = s.slice(1, -1).trim();
1767
+ return s;
1768
+ }
1769
+ function parseInnerArgs(raw) {
1770
+ if (raw === void 0 || raw === null) return {};
1771
+ if (typeof raw === "object" && !Array.isArray(raw)) return raw;
1772
+ if (typeof raw === "string") {
1773
+ let s = raw.trim();
1774
+ if (s.startsWith("\"") && s.endsWith("\"") || s.startsWith("'") && s.endsWith("'")) try {
1775
+ const unquoted = JSON.parse(s);
1776
+ if (typeof unquoted === "string") s = unquoted.trim();
1777
+ } catch {}
1778
+ try {
1779
+ const parsed = JSON.parse(s);
1780
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) return parsed;
1781
+ return { value: parsed };
1782
+ } catch {
1783
+ return { value: raw };
1784
+ }
1785
+ }
1786
+ return { value: raw };
1787
+ }
1788
+ function cleanResultText(text) {
1789
+ const trimmed = text.trim();
1790
+ if (trimmed.startsWith("{") && trimmed.endsWith("}")) try {
1791
+ const obj = JSON.parse(trimmed);
1792
+ if (Array.isArray(obj?.content)) {
1793
+ const parts = [];
1794
+ for (const item of obj.content) {
1795
+ const blk = item;
1796
+ if (blk?.type === "text" && typeof blk.text === "string") parts.push(blk.text);
1797
+ }
1798
+ if (parts.length > 0) return parts.join("\n");
1799
+ }
1800
+ } catch {}
1801
+ return text;
1802
+ }
1763
1803
  function mirrorInfo(block) {
1764
1804
  const a = parseArgs(block);
1765
1805
  if (a === null) return null;
1766
- const tool = typeof a.tool === "string" ? a.tool : "";
1806
+ let tool = typeof a.tool === "string" ? a.tool : "";
1767
1807
  if (tool === "") return null;
1768
1808
  let input = {};
1769
1809
  const raw = a.input;
@@ -1775,9 +1815,27 @@ window.__ModuleLoader__.load({
1775
1815
  } catch {
1776
1816
  input = { value: raw };
1777
1817
  }
1818
+ let server = typeof a.server === "string" && a.server !== "" ? cleanString(a.server) : void 0;
1819
+ if (/^(call_mcp_tool|callMcpTool|call_mcp|mcp_call)$/i.test(tool)) {
1820
+ const s = pick(input, "ServerName", "server_name", "serverName", "server");
1821
+ if (s) server = cleanString(s);
1822
+ const innerTool = pick(input, "ToolName", "tool_name", "toolName", "name", "tool");
1823
+ const rawInner = input.Arguments ?? input.arguments ?? input.args ?? input.parameters ?? input.params ?? input.input;
1824
+ if (innerTool) {
1825
+ tool = cleanString(innerTool);
1826
+ input = parseInnerArgs(rawInner);
1827
+ }
1828
+ } else if (tool.startsWith("mcp__")) {
1829
+ const parts = tool.slice(5).split("__");
1830
+ if (parts.length >= 2) {
1831
+ server = parts[0];
1832
+ tool = parts.slice(1).join("__");
1833
+ }
1834
+ }
1778
1835
  return {
1779
1836
  tool,
1780
- input
1837
+ input,
1838
+ ...server ? { server } : {}
1781
1839
  };
1782
1840
  }
1783
1841
  function pick(input, ...keys) {
@@ -1797,7 +1855,7 @@ window.__ModuleLoader__.load({
1797
1855
  if (!Array.isArray(settled.content)) return "";
1798
1856
  const parts = [];
1799
1857
  for (const b of settled.content) if (b && typeof b === "object" && b.type === "text" && typeof b.text === "string") parts.push(b.text);
1800
- return parts.join("\n");
1858
+ return cleanResultText(parts.join("\n"));
1801
1859
  }
1802
1860
  function isSettled(block) {
1803
1861
  return block.kind === "tool-result" || "content" in block;
@@ -1809,7 +1867,10 @@ window.__ModuleLoader__.load({
1809
1867
  const TERMINAL_TOOLS = /* @__PURE__ */ new Set([
1810
1868
  "run_command",
1811
1869
  "bash",
1812
- "execute_command"
1870
+ "execute_command",
1871
+ "ops_bash",
1872
+ "sh",
1873
+ "shell"
1813
1874
  ]);
1814
1875
  const DIFF_TOOLS = /* @__PURE__ */ new Set([
1815
1876
  "replace_file_content",
@@ -1829,9 +1890,11 @@ window.__ModuleLoader__.load({
1829
1890
  const SEARCH_TOOLS = /* @__PURE__ */ new Set([
1830
1891
  "find_by_name",
1831
1892
  "glob",
1893
+ "ops_glob",
1832
1894
  "search_files",
1833
1895
  "grep_search",
1834
1896
  "search",
1897
+ "ops_grep",
1835
1898
  "search_file_content",
1836
1899
  "grep",
1837
1900
  "search_web",
@@ -1867,10 +1930,12 @@ window.__ModuleLoader__.load({
1867
1930
  if (QUESTION_TOOLS.has(tool)) {
1868
1931
  const questionsRaw = input.questions ?? input.Questions;
1869
1932
  const questions = Array.isArray(questionsRaw) ? questionsRaw : [];
1933
+ const qTitle = questions[0]?.question ?? desc ?? "Ask Question";
1870
1934
  return {
1871
1935
  kind: "question",
1872
1936
  tool,
1873
- title: questions[0]?.question ?? desc ?? "Ask Question",
1937
+ server: info.server,
1938
+ title: qTitle,
1874
1939
  output: out,
1875
1940
  questions,
1876
1941
  raw: parsedArgsRaw(block)
@@ -1883,6 +1948,7 @@ window.__ModuleLoader__.load({
1883
1948
  return {
1884
1949
  kind: "image",
1885
1950
  tool,
1951
+ server: info.server,
1886
1952
  title: desc ?? `Generate Image · ${name}`,
1887
1953
  prompt,
1888
1954
  imageName: name,
@@ -1892,12 +1958,14 @@ window.__ModuleLoader__.load({
1892
1958
  };
1893
1959
  }
1894
1960
  if (TERMINAL_TOOLS.has(tool)) {
1895
- const command = pick(input, "CommandLine", "command_line", "command", "cmd", "Cmd") ?? JSON.stringify(input);
1896
- const cwdVal = pick(input, "Cwd", "cwd", "WorkingDirectory", "working_directory") ?? cwd;
1961
+ const command = pick(input, "CommandLine", "command_line", "command", "cmd", "Cmd") ?? (desc && desc.startsWith("$ ") ? desc.replace(/\s*·\s*.*$/, "").replace(/^\$\s*/, "") : void 0) ?? JSON.stringify(input);
1962
+ const cwdVal = pick(input, "Cwd", "cwd", "WorkingDirectory", "working_directory", "workdir", "WorkDir") ?? cwd;
1963
+ const rowTitle = desc !== void 0 && !desc.startsWith("$ ") && desc !== command ? desc + " · " + command : command;
1897
1964
  return {
1898
1965
  kind: "terminal",
1899
1966
  tool,
1900
- title: desc !== void 0 ? desc + " · " + command : command,
1967
+ server: info.server,
1968
+ title: rowTitle,
1901
1969
  command,
1902
1970
  ...cwdVal !== void 0 ? { cwd: cwdVal } : {},
1903
1971
  output: out
@@ -1910,10 +1978,12 @@ window.__ModuleLoader__.load({
1910
1978
  const newText = pick(input, "ReplacementContent", "replacement_content", "new_string", "newText", "content", "NewString", "NewText", "Content", "replacementContent", "CodeContent", "code_content", "contents", "FileContents", "codeContent") ?? "";
1911
1979
  const action = tool === "write_to_file" || tool === "write_file" || tool === "create_file" ? "Write" : "Edit";
1912
1980
  const isGenericDesc = desc !== void 0 && /^(file edit|editing file|write file|writing file|file write|edit file|editing|writing|file create|creating file)$/i.test(desc.trim());
1981
+ const title = desc !== void 0 && !isGenericDesc && !desc.includes(path) ? `${action} ${path} · ${desc}` : `${action} ${path}`;
1913
1982
  return {
1914
1983
  kind: "diff",
1915
1984
  tool,
1916
- title: desc !== void 0 && !isGenericDesc && !desc.includes(path) ? `${action} ${path} · ${desc}` : `${action} ${path}`,
1985
+ server: info.server,
1986
+ title,
1917
1987
  path: rawPath,
1918
1988
  oldText,
1919
1989
  newText,
@@ -1928,6 +1998,7 @@ window.__ModuleLoader__.load({
1928
1998
  return {
1929
1999
  kind: isImg ? "image" : "read",
1930
2000
  tool,
2001
+ server: info.server,
1931
2002
  title: desc ? `${desc} · ${path}` : path !== "" ? "Read " + path : "Read",
1932
2003
  path,
1933
2004
  output: out,
@@ -1942,10 +2013,12 @@ window.__ModuleLoader__.load({
1942
2013
  };
1943
2014
  }
1944
2015
  if (SEARCH_TOOLS.has(tool)) {
1945
- const q = pick(input, "query", "Query", "pattern", "Pattern", "regex", "Regex", "QueryString") ?? "";
2016
+ const rawPat = input.query ?? input.Query ?? input.pattern ?? input.Pattern ?? input.regex ?? input.Regex ?? input.QueryString;
2017
+ const q = Array.isArray(rawPat) ? rawPat.join(", ") : typeof rawPat === "string" ? rawPat : pick(input, "query", "Query", "pattern", "Pattern", "regex", "Regex", "QueryString") ?? "";
1946
2018
  return {
1947
2019
  kind: "search",
1948
2020
  tool,
2021
+ server: info.server,
1949
2022
  title: desc ?? (q !== "" ? "Search " + q : "Search"),
1950
2023
  output: out
1951
2024
  };
@@ -1955,6 +2028,7 @@ window.__ModuleLoader__.load({
1955
2028
  return {
1956
2029
  kind: "list",
1957
2030
  tool,
2031
+ server: info.server,
1958
2032
  title: desc ?? (path !== "" ? "List " + path : "List directory"),
1959
2033
  output: out
1960
2034
  };
@@ -1964,14 +2038,18 @@ window.__ModuleLoader__.load({
1964
2038
  return {
1965
2039
  kind: "delete",
1966
2040
  tool,
2041
+ server: info.server,
1967
2042
  title: desc ?? "Delete " + path,
1968
2043
  output: out
1969
2044
  };
1970
2045
  }
2046
+ const defaultTitle = info.server ? `${info.server}: ${tool}` : tool !== "" ? tool : "agy_tool";
2047
+ const title = desc ?? defaultTitle;
1971
2048
  return {
1972
2049
  kind: "generic",
1973
2050
  tool,
1974
- title: desc ?? (tool !== "" ? tool : "agy_tool"),
2051
+ server: info.server,
2052
+ title,
1975
2053
  output: out,
1976
2054
  raw: parsedArgsRaw(block)
1977
2055
  };
@@ -2030,7 +2108,9 @@ window.__ModuleLoader__.load({
2030
2108
  case "delete": return tr(t, "tv.delete", "Delete");
2031
2109
  case "question": return tr(t, "tv.question", "Question");
2032
2110
  case "image": return tr(t, "tv.image", "Image");
2033
- default: return model.tool ? model.tool.replace(/_/g, " ") : tr(t, "tv.tool", "Tool");
2111
+ default:
2112
+ if (model.tool && model.tool !== "agy_tool") return model.server ? `${model.server}: ${model.tool}` : model.tool.replace(/_/g, " ");
2113
+ return tr(t, "tv.tool", "Tool");
2034
2114
  }
2035
2115
  }
2036
2116
  function displaySummary(model, cwd, home) {
@@ -2044,6 +2124,7 @@ window.__ModuleLoader__.load({
2044
2124
  if (model.kind === "list") return model.title.replace(/^List\s*(directory\s*)?/i, "") || model.title;
2045
2125
  if (model.kind === "question") return model.title;
2046
2126
  if (model.kind === "image") return model.prompt || model.title;
2127
+ if (model.server && model.title.startsWith(`${model.server}: `)) return model.title.slice(model.server.length + 2);
2047
2128
  return model.title;
2048
2129
  }
2049
2130
  function diffStat(model) {
@@ -2282,7 +2363,7 @@ window.__ModuleLoader__.load({
2282
2363
  default: {
2283
2364
  const copyText = model.output !== void 0 && model.output !== "" ? model.output : model.raw ?? "";
2284
2365
  const rawBody = model.output !== void 0 && model.output !== "" ? trimTrailingBlankLines(model.output) : model.raw !== void 0 && model.raw !== "" ? clip(model.raw, 4e3) : tr(t, "tv.noDetail", "(no detail)");
2285
- return h("div", { className: "agy-tv-card" }, h("div", { className: "agy-tv-card-header" }, h("div", { className: "agy-tv-card-header-left" }, IconCodeOutline16(13), h("span", { className: "agy-tv-card-path" }, model.tool || "Tool")), h(CopyButton, {
2366
+ return h("div", { className: "agy-tv-card" }, h("div", { className: "agy-tv-card-header" }, h("div", { className: "agy-tv-card-header-left" }, IconCodeOutline16(13), h("span", { className: "agy-tv-card-path" }, model.server ? `${model.server}: ${model.tool}` : model.title || model.tool || "Tool")), h(CopyButton, {
2286
2367
  text: copyText,
2287
2368
  t
2288
2369
  })), h("pre", { className: "agy-tv-card-content" }, clip(rawBody, 16e3)), inspectNode);
@@ -2476,8 +2557,14 @@ window.__ModuleLoader__.load({
2476
2557
  function AgyRunCodeToolView(props) {
2477
2558
  const typed = props;
2478
2559
  const block = typed?.block;
2479
- const mirror = parseAgyMirrorFromCode(block !== void 0 ? parsedArgsRaw(block) : "{}");
2560
+ const raw = block !== void 0 ? parsedArgsRaw(block) : "{}";
2561
+ const mirror = parseAgyMirrorFromCode(raw);
2480
2562
  if (mirror === null) return AgyCodeToolView(typed);
2563
+ let description;
2564
+ try {
2565
+ const parsed = JSON.parse(raw);
2566
+ if (typeof parsed?.description === "string" && parsed.description !== "") description = parsed.description;
2567
+ } catch {}
2481
2568
  return AgyMirrorToolView({
2482
2569
  block: {
2483
2570
  ...block,
@@ -2487,7 +2574,8 @@ window.__ModuleLoader__.load({
2487
2574
  argsRaw: JSON.stringify({
2488
2575
  run: mirror.run,
2489
2576
  step: mirror.step,
2490
- ...mirror.tool !== void 0 ? { tool: mirror.tool } : {}
2577
+ ...mirror.tool !== void 0 ? { tool: mirror.tool } : {},
2578
+ ...description !== void 0 ? { input: { description } } : {}
2491
2579
  })
2492
2580
  }
2493
2581
  },
package/dist/index.js CHANGED
@@ -1147,8 +1147,11 @@ function buildMirrorRunCode(runId, eventIndex, toolName, brief) {
1147
1147
  };
1148
1148
  }
1149
1149
  /** Short human preview for a recorded tool step (used in Code Mode titles). */
1150
- function toolStepBrief(toolName, args) {
1151
- const a = args !== null && typeof args === "object" ? args : {};
1150
+ function toolStepBrief(toolName, args, server) {
1151
+ const unwrapped = unwrapMcpTool(toolName, args);
1152
+ const effTool = unwrapped.tool;
1153
+ const a = unwrapped.input;
1154
+ const effServer = server ?? unwrapped.server;
1152
1155
  const pickStr = (...keys) => {
1153
1156
  for (const k of keys) {
1154
1157
  const v = a[k];
@@ -1156,39 +1159,43 @@ function toolStepBrief(toolName, args) {
1156
1159
  }
1157
1160
  return "";
1158
1161
  };
1159
- if (toolName === "run_command" || toolName === "execute_command") {
1162
+ if (effTool === "run_command" || effTool === "execute_command" || effTool === "ops_bash" || effTool === "bash" || effTool === "sh" || effTool === "shell") {
1160
1163
  const cmd = pickStr("CommandLine", "command_line", "Command", "command", "Cmd", "cmd");
1161
1164
  return cmd !== "" ? "$ " + cmd.slice(0, 80) : "run command";
1162
1165
  }
1163
- if (toolName === "view_file" || toolName === "read_file") return "read " + (pickStr("AbsolutePath", "absolute_path", "Path", "path", "TargetFile", "File") || "file");
1164
- if (toolName === "write_to_file" || toolName === "create_file") return "write " + (pickStr("TargetFile", "target_file", "Path", "path", "AbsolutePath", "File") || "file");
1165
- if (toolName === "replace_file_content" || toolName === "edit_file") return "edit " + (pickStr("TargetFile", "target_file", "Path", "path", "AbsolutePath", "File") || "file");
1166
- if (toolName === "grep_search" || toolName === "search") return "search " + (pickStr("Query", "query", "SearchPattern") || "");
1167
- if (toolName === "search_web" || toolName === "web_search") return "search web " + (pickStr("query", "Query", "search_query", "q") || "");
1168
- if (toolName === "read_url_content" || toolName === "web_fetch" || toolName === "fetch_web_page") return "fetch " + (pickStr("Url", "url", "target_url", "targetUrl") || "url");
1169
- if (toolName === "list_dir" || toolName === "list_directory") return "ls " + (pickStr("DirectoryPath", "directory_path", "Path", "path", "AbsolutePath") || ".");
1170
- if (toolName === "manage_task") {
1166
+ if (effTool === "view_file" || effTool === "read_file" || effTool === "read") return "read " + (pickStr("AbsolutePath", "absolute_path", "Path", "path", "TargetFile", "File") || "file");
1167
+ if (effTool === "write_to_file" || effTool === "create_file" || effTool === "write_file") return "write " + (pickStr("TargetFile", "target_file", "Path", "path", "AbsolutePath", "File") || "file");
1168
+ if (effTool === "replace_file_content" || effTool === "edit_file" || effTool === "edit") return "edit " + (pickStr("TargetFile", "target_file", "Path", "path", "AbsolutePath", "File") || "file");
1169
+ if (effTool === "grep_search" || effTool === "search" || effTool === "ops_grep" || effTool === "ops_glob" || effTool === "glob" || effTool === "find_by_name" || effTool === "search_files" || effTool === "search_file_content" || effTool === "grep") {
1170
+ const rawPat = a.pattern ?? a.Pattern ?? a.query ?? a.Query ?? a.SearchPattern;
1171
+ const pat = Array.isArray(rawPat) ? rawPat.join(", ") : typeof rawPat === "string" ? rawPat.trim() : "";
1172
+ return pat !== "" ? "search " + pat.slice(0, 80) : "search";
1173
+ }
1174
+ if (effTool === "search_web" || effTool === "web_search") return "search web " + (pickStr("query", "Query", "search_query", "q") || "");
1175
+ if (effTool === "read_url_content" || effTool === "web_fetch" || effTool === "fetch_web_page") return "fetch " + (pickStr("Url", "url", "target_url", "targetUrl") || "url");
1176
+ if (effTool === "list_dir" || effTool === "list_directory" || effTool === "ls") return "ls " + (pickStr("DirectoryPath", "directory_path", "Path", "path", "AbsolutePath") || ".");
1177
+ if (effTool === "manage_task") {
1171
1178
  const action = pickStr("Action", "action") || "manage";
1172
1179
  const id = pickStr("TaskId", "taskId", "task_id");
1173
1180
  return id !== "" ? "task " + action + " " + id : "task " + action;
1174
1181
  }
1175
- if (toolName === "schedule") {
1182
+ if (effTool === "schedule") {
1176
1183
  const prompt = pickStr("Prompt", "prompt");
1177
1184
  const cron = pickStr("CronExpression", "cron_expression");
1178
1185
  const dur = pickStr("DurationSeconds", "duration_seconds");
1179
1186
  const timing = cron ? "cron " + cron : dur ? dur + "s" : "";
1180
1187
  return timing ? "schedule " + timing : prompt ? "schedule " + prompt.slice(0, 40) : "schedule";
1181
1188
  }
1182
- if (toolName === "invoke_subagent") {
1189
+ if (effTool === "invoke_subagent") {
1183
1190
  const subs = a.Subagents ?? a.subagents;
1184
1191
  const firstRole = Array.isArray(subs) && subs.length > 0 && typeof subs[0].Role === "string" ? subs[0].Role : "";
1185
1192
  return firstRole ? "subagent: " + firstRole : "invoke subagent";
1186
1193
  }
1187
- if (toolName === "send_message") {
1194
+ if (effTool === "send_message") {
1188
1195
  const recipient = pickStr("Recipient", "recipient", "to");
1189
1196
  return recipient ? "msg " + recipient : "send message";
1190
1197
  }
1191
- return toolName;
1198
+ return effServer ? effServer + ": " + effTool : effTool;
1192
1199
  }
1193
1200
  /** agy serializes some tool args as a JSON string; presenters get an object. */
1194
1201
  function toolInput(args) {
@@ -1203,6 +1210,77 @@ function toolInput(args) {
1203
1210
  }
1204
1211
  return { value: raw };
1205
1212
  }
1213
+ function cleanString(val) {
1214
+ if (typeof val !== "string") return "";
1215
+ let s = val.trim();
1216
+ if (s.startsWith("\"") && s.endsWith("\"") || s.startsWith("'") && s.endsWith("'")) s = s.slice(1, -1).trim();
1217
+ return s;
1218
+ }
1219
+ function parseInnerArgs(raw) {
1220
+ if (raw === void 0 || raw === null) return {};
1221
+ if (typeof raw === "object" && !Array.isArray(raw)) return raw;
1222
+ if (typeof raw === "string") {
1223
+ let s = raw.trim();
1224
+ if (s.startsWith("\"") && s.endsWith("\"") || s.startsWith("'") && s.endsWith("'")) try {
1225
+ const unquoted = JSON.parse(s);
1226
+ if (typeof unquoted === "string") s = unquoted.trim();
1227
+ } catch {}
1228
+ try {
1229
+ const parsed = JSON.parse(s);
1230
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) return parsed;
1231
+ return { value: parsed };
1232
+ } catch {
1233
+ return { value: raw };
1234
+ }
1235
+ }
1236
+ return { value: raw };
1237
+ }
1238
+ function unwrapMcpTool(toolName, rawArgs) {
1239
+ const input = toolInput({ input: rawArgs });
1240
+ if (/^(call_mcp_tool|callMcpTool|call_mcp|mcp_call)$/i.test(toolName)) {
1241
+ const server = cleanString(pick$1(input, "ServerName", "server_name", "serverName", "server"));
1242
+ const innerTool = cleanString(pick$1(input, "ToolName", "tool_name", "toolName", "name", "tool"));
1243
+ const innerInput = parseInnerArgs(input.Arguments ?? input.arguments ?? input.args ?? input.parameters ?? input.params ?? input.input);
1244
+ if (innerTool !== "") return {
1245
+ tool: innerTool,
1246
+ input: innerInput,
1247
+ ...server !== "" ? { server } : {},
1248
+ isMcp: true
1249
+ };
1250
+ }
1251
+ if (toolName.startsWith("mcp__")) {
1252
+ const parts = toolName.slice(5).split("__");
1253
+ if (parts.length >= 2) {
1254
+ const server = parts[0];
1255
+ return {
1256
+ tool: parts.slice(1).join("__"),
1257
+ input,
1258
+ ...server ? { server } : {},
1259
+ isMcp: true
1260
+ };
1261
+ }
1262
+ }
1263
+ return {
1264
+ tool: toolName,
1265
+ input,
1266
+ isMcp: false
1267
+ };
1268
+ }
1269
+ function cleanResultText(text) {
1270
+ const trimmed = text.trim();
1271
+ if (trimmed.startsWith("{") && trimmed.endsWith("}")) try {
1272
+ const obj = JSON.parse(trimmed);
1273
+ if (Array.isArray(obj?.content)) {
1274
+ const parts = [];
1275
+ for (const item of obj.content) {
1276
+ const blk = item;
1277
+ if (blk?.type === "text" && typeof blk.text === "string") parts.push(blk.text);
1278
+ }
1279
+ if (parts.length > 0) return parts.join("\n");
1280
+ }
1281
+ } catch {}
1282
+ return text;
1283
+ }
1206
1284
  /**
1207
1285
  * agy serializes tool args with PascalCase keys (CommandLine, AbsolutePath,
1208
1286
  * SearchDirectory, TargetFile, TargetContent, ReplacementContent, CodeContent…);
@@ -1219,15 +1297,20 @@ function pick$1(input, ...keys) {
1219
1297
  /** Native pending-card projection for one mirrored agy tool call. */
1220
1298
  function presentMirrorCall(args) {
1221
1299
  const a = args;
1222
- const name = typeof a?.tool === "string" ? a.tool : "";
1223
- const input = toolInput(a);
1300
+ const unwrapped = unwrapMcpTool(typeof a?.tool === "string" ? a.tool : "", a?.input);
1301
+ const name = unwrapped.tool;
1302
+ const input = unwrapped.input;
1303
+ const server = typeof a?.server === "string" && a.server !== "" ? a.server : unwrapped.server;
1224
1304
  switch (name) {
1225
1305
  case "run_command":
1226
1306
  case "bash":
1227
- case "execute_command": {
1307
+ case "execute_command":
1308
+ case "ops_bash":
1309
+ case "sh":
1310
+ case "shell": {
1228
1311
  const command = pick$1(input, "CommandLine", "command_line", "command", "cmd", "Cmd") ?? JSON.stringify(input);
1229
1312
  const desc = pick$1(input, "Description", "description", "toolAction", "toolSummary");
1230
- const cwd = pick$1(input, "Cwd", "cwd", "WorkingDirectory", "working_directory");
1313
+ const cwd = pick$1(input, "Cwd", "cwd", "WorkingDirectory", "working_directory", "workdir", "WorkDir");
1231
1314
  return {
1232
1315
  card: "terminal",
1233
1316
  title: command,
@@ -1291,8 +1374,10 @@ function presentMirrorCall(args) {
1291
1374
  }
1292
1375
  case "find_by_name":
1293
1376
  case "glob":
1377
+ case "ops_glob":
1294
1378
  case "search_files": {
1295
- const q = pick$1(input, "pattern", "Pattern", "query", "Query", "regex", "Regex", "QueryString") ?? "";
1379
+ const rawPat = input.pattern ?? input.Pattern ?? input.query ?? input.Query ?? input.regex ?? input.Regex ?? input.QueryString;
1380
+ const q = Array.isArray(rawPat) ? rawPat.join(", ") : typeof rawPat === "string" ? rawPat : pick$1(input, "pattern", "Pattern", "query", "Query", "regex", "Regex", "QueryString") ?? "";
1296
1381
  return {
1297
1382
  card: "generic",
1298
1383
  title: pick$1(input, "Description", "description", "toolAction", "toolSummary") ?? (q !== "" ? "Search " + q : "Search"),
@@ -1301,9 +1386,11 @@ function presentMirrorCall(args) {
1301
1386
  }
1302
1387
  case "grep_search":
1303
1388
  case "search":
1389
+ case "ops_grep":
1304
1390
  case "search_file_content":
1305
1391
  case "grep": {
1306
- const q = pick$1(input, "query", "Query", "pattern", "Pattern", "regex", "Regex", "QueryString") ?? "";
1392
+ const rawPat = input.query ?? input.Query ?? input.pattern ?? input.Pattern ?? input.regex ?? input.Regex ?? input.QueryString;
1393
+ const q = Array.isArray(rawPat) ? rawPat.join(", ") : typeof rawPat === "string" ? rawPat : pick$1(input, "query", "Query", "pattern", "Pattern", "regex", "Regex", "QueryString") ?? "";
1307
1394
  return {
1308
1395
  card: "generic",
1309
1396
  title: pick$1(input, "Description", "description", "toolAction", "toolSummary") ?? (q !== "" ? "Search " + q : "Search"),
@@ -1408,26 +1495,33 @@ function presentMirrorCall(args) {
1408
1495
  title: prompt ? `Generate Image: ${prompt}` : "Generate Image"
1409
1496
  };
1410
1497
  }
1411
- default: return {
1412
- card: "generic",
1413
- title: pick$1(input, "Description", "description", "toolAction", "toolSummary") ?? (name !== "" ? name : "agy tool"),
1414
- rawInput: input
1415
- };
1498
+ default: {
1499
+ const desc = pick$1(input, "Description", "description", "toolAction", "toolSummary");
1500
+ const fallbackTitle = server ? `${server}: ${name}` : name !== "" ? name : "agy tool";
1501
+ return {
1502
+ card: "generic",
1503
+ title: desc ?? fallbackTitle,
1504
+ rawInput: input
1505
+ };
1506
+ }
1416
1507
  }
1417
1508
  }
1418
1509
  /** Native completed-card projection for one mirrored agy tool call. */
1419
1510
  function presentMirrorResult(args, result) {
1420
1511
  const a = args;
1421
- const name = typeof a?.tool === "string" ? a.tool : "";
1422
- const text = resultText$1(result.content);
1512
+ const name = unwrapMcpTool(typeof a?.tool === "string" ? a.tool : "", a?.input).tool;
1513
+ const text = cleanResultText(resultText$1(result.content));
1423
1514
  switch (name) {
1424
1515
  case "run_command":
1425
1516
  case "bash":
1426
- case "execute_command": {
1517
+ case "execute_command":
1518
+ case "ops_bash":
1519
+ case "sh":
1520
+ case "shell": {
1427
1521
  let exitCode;
1428
- const m = /The command exited with code (\d+)/i.exec(text);
1522
+ const m = /The command exited with code (\d+)/i.exec(text) ?? /\[exit code (\d+)\]/i.exec(text);
1429
1523
  if (m && m[1]) exitCode = parseInt(m[1], 10);
1430
- else if (result.isError) exitCode = 1;
1524
+ else if (/\[command timed out/i.test(text) || result.isError) exitCode = 1;
1431
1525
  return {
1432
1526
  card: "terminal",
1433
1527
  output: text,
@@ -1486,15 +1580,24 @@ function recordingUnavailable(step, toolName, input, reason) {
1486
1580
  }
1487
1581
  function defineAgyMirrorTool(deps) {
1488
1582
  const enrichArgs = (args) => {
1489
- if (typeof args.tool === "string" && args.tool !== "") return args;
1490
- const runId = typeof args.run === "string" ? args.run : "";
1491
- const step = typeof args.step === "number" ? args.step : -1;
1492
- const t = deps.runs.get(runId)?.toolEventAt(step) ?? null;
1493
- if (t === null) return args;
1583
+ let tool = typeof args.tool === "string" ? args.tool : "";
1584
+ let input = args.input;
1585
+ let server = typeof args.server === "string" ? args.server : void 0;
1586
+ if (tool === "" || /^(call_mcp_tool|callMcpTool|call_mcp|mcp_call)$/i.test(tool)) {
1587
+ const runId = typeof args.run === "string" ? args.run : "";
1588
+ const step = typeof args.step === "number" ? args.step : -1;
1589
+ const t = deps.runs.get(runId)?.toolEventAt(step) ?? null;
1590
+ if (t !== null) {
1591
+ if (tool === "") tool = t.name;
1592
+ input ??= t.args;
1593
+ }
1594
+ }
1595
+ const unwrapped = unwrapMcpTool(tool, input);
1494
1596
  return {
1495
1597
  ...args,
1496
- tool: t.name,
1497
- ...args.input === void 0 && t.args !== void 0 ? { input: t.args } : {}
1598
+ tool: unwrapped.tool,
1599
+ input: unwrapped.input,
1600
+ ...unwrapped.server ? { server: unwrapped.server } : server ? { server } : {}
1498
1601
  };
1499
1602
  };
1500
1603
  return defineTool({
@@ -1962,7 +2065,9 @@ var EventMapper = class {
1962
2065
  if (this.opts.cutOnTool && !this.finished && ev.state === "ACTIVE" && !this.pendingAnnounced.has(ev.stepKey)) {
1963
2066
  this.pendingAnnounced.add(ev.stepKey);
1964
2067
  yield* this.ensureBlock("reasoning");
1965
- const d = this.appendDelta("[agy tool running: " + ev.tool.name + " — the result card streams when it finishes]\n");
2068
+ const unwrapped = unwrapMcpTool(ev.tool.name, ev.tool.args);
2069
+ const label = unwrapped.server ? `${unwrapped.tool} (${unwrapped.server})` : unwrapped.tool;
2070
+ const d = this.appendDelta("[agy tool running: " + label + " — the result card streams when it finishes]\n");
1966
2071
  if (d) yield d;
1967
2072
  }
1968
2073
  return;
@@ -1980,11 +2085,14 @@ var EventMapper = class {
1980
2085
  ...fullArgs,
1981
2086
  ...typeof ev.tool.args === "object" ? ev.tool.args : {}
1982
2087
  } : ev.tool.args;
1983
- const argumentsJson = useCode ? JSON.stringify(buildMirrorRunCode(this.opts.runId, absIndex, ev.tool.name, toolStepBrief(ev.tool.name, effectiveArgs))) : JSON.stringify({
2088
+ const unwrapped = unwrapMcpTool(ev.tool.name, effectiveArgs);
2089
+ const brief = toolStepBrief(unwrapped.tool, unwrapped.input, unwrapped.server);
2090
+ const argumentsJson = useCode ? JSON.stringify(buildMirrorRunCode(this.opts.runId, absIndex, unwrapped.tool, brief)) : JSON.stringify({
1984
2091
  run: this.opts.runId,
1985
2092
  step: absIndex,
1986
- tool: ev.tool.name,
1987
- ...effectiveArgs !== void 0 ? { input: effectiveArgs } : {}
2093
+ tool: unwrapped.tool,
2094
+ ...unwrapped.server !== void 0 ? { server: unwrapped.server } : {},
2095
+ ...unwrapped.input !== void 0 ? { input: unwrapped.input } : {}
1988
2096
  });
1989
2097
  const rawCallId = mirrorCallId(this.opts.runId, absIndex);
1990
2098
  const assignedCallId = rememberToolCallId(this.toolCallStates, rawCallId, toolName);
@@ -31801,9 +31909,10 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
31801
31909
  rec.setFullArgs(i, full.args);
31802
31910
  }
31803
31911
  } catch {}
31804
- const toolName = ev.tool.name;
31912
+ const unwrapped = unwrapMcpTool(ev.tool.name, resolved.get(i) ?? ev.tool.args);
31913
+ const toolName = unwrapped.tool;
31805
31914
  if (toolName === "write_to_file" || toolName === "write_file" || toolName === "create_file") {
31806
- const currentArgs = resolved.get(i) ?? (typeof ev.tool.args === "object" && ev.tool.args !== null ? ev.tool.args : {});
31915
+ const currentArgs = unwrapped.input;
31807
31916
  const targetFile = currentArgs.TargetFile ?? currentArgs.target_file ?? currentArgs.path ?? currentArgs.AbsolutePath;
31808
31917
  if (targetFile && typeof targetFile === "string" && !currentArgs.oldText && !currentArgs.old_string && !currentArgs.TargetContent) {
31809
31918
  const head = getGitHeadContent(targetFile);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agy-link",
3
- "version": "0.4.98",
3
+ "version": "0.4.99",
4
4
  "description": "Google Antigravity (agy CLI) models for DeepSeek Harness — stream Gemini/Claude/GPT-OSS subscriptions into DSH with thinking, tool activity, token usage and in-GUI Google OAuth login.",
5
5
  "type": "module",
6
6
  "license": "MIT",