token-goat 2.9.29 → 2.9.30
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/README.md +34 -40
- package/SECURITY.md +28 -10
- package/THIRD_PARTY_NOTICES.md +40 -3
- package/dist/native/linux-arm64/tg-hook +0 -0
- package/dist/native/linux-x64/tg-hook +0 -0
- package/dist/ort-wasm-simd-threaded.mjs +59 -0
- package/dist/token-goat-chunk-3CHUNJ2O.mjs +53 -0
- package/dist/token-goat-chunk-3Z5S4KGM.mjs +918 -0
- package/dist/token-goat-chunk-4FVIAHSI.mjs +211 -0
- package/dist/{token-goat-chunk-PGTH2U4C.mjs → token-goat-chunk-4JJS54TR.mjs} +4 -3
- package/dist/token-goat-chunk-4LCCNRTG.mjs +313 -0
- package/dist/{token-goat-chunk-L7H3U27L.mjs → token-goat-chunk-54K3EUV3.mjs} +1 -1
- package/dist/token-goat-chunk-56EIMS3E.mjs +159 -0
- package/dist/token-goat-chunk-5BCIJXMO.mjs +609 -0
- package/dist/token-goat-chunk-5KDMCMF2.mjs +362 -0
- package/dist/token-goat-chunk-5RG5SBL6.mjs +221 -0
- package/dist/{token-goat-chunk-RRNZMM3A.mjs → token-goat-chunk-5Y6ZYL6U.mjs} +21 -2
- package/dist/{token-goat-chunk-GLXRTTLE.mjs → token-goat-chunk-64FBPDTK.mjs} +12 -8
- package/dist/{token-goat-chunk-G23DWHV4.mjs → token-goat-chunk-664RTTUV.mjs} +28 -15
- package/dist/token-goat-chunk-67TQJ76B.mjs +57 -0
- package/dist/token-goat-chunk-6QMAS7AB.mjs +42 -0
- package/dist/token-goat-chunk-7BXSNBY5.mjs +253 -0
- package/dist/{token-goat-chunk-IVWI2OCK.mjs → token-goat-chunk-7F2UBPD3.mjs} +40 -11
- package/dist/{token-goat-chunk-TGOXNAHW.mjs → token-goat-chunk-7IN2MKDS.mjs} +682 -501
- package/dist/token-goat-chunk-7NADEDKJ.mjs +124 -0
- package/dist/{token-goat-chunk-KOPIR3KZ.mjs → token-goat-chunk-A3CK6N5Z.mjs} +618 -72
- package/dist/{token-goat-chunk-O6I2XU4P.mjs → token-goat-chunk-AFLYLHDH.mjs} +44 -31
- package/dist/{token-goat-chunk-TCQANXYC.mjs → token-goat-chunk-AM5V6GSX.mjs} +18 -2
- package/dist/{token-goat-chunk-E4ZOJIZK.mjs → token-goat-chunk-APGZXSPS.mjs} +39 -146
- package/dist/{token-goat-chunk-D4ETHJD6.mjs → token-goat-chunk-ARDNEC2U.mjs} +9 -7
- package/dist/token-goat-chunk-ATCPY7EQ.mjs +134 -0
- package/dist/token-goat-chunk-B2RZZCSS.mjs +354 -0
- package/dist/{token-goat-chunk-BGYOZ6DO.mjs → token-goat-chunk-B45VMIIH.mjs} +6 -7
- package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
- package/dist/{token-goat-chunk-TDUT2CL6.mjs → token-goat-chunk-C63JQV5K.mjs} +45 -6
- package/dist/{token-goat-chunk-ZER6EAXZ.mjs → token-goat-chunk-COBQGL5S.mjs} +2661 -2440
- package/dist/token-goat-chunk-COTXZHTS.mjs +39 -0
- package/dist/{token-goat-chunk-RQGGMPCR.mjs → token-goat-chunk-CYCEYAEO.mjs} +76 -16
- package/dist/token-goat-chunk-CZ3LUXYZ.mjs +4115 -0
- package/dist/{token-goat-chunk-ASLWOQ3I.mjs → token-goat-chunk-DZX2YDPT.mjs} +2 -1
- package/dist/token-goat-chunk-E3OQX2XT.mjs +824 -0
- package/dist/token-goat-chunk-EFHMMIGP.mjs +68 -0
- package/dist/token-goat-chunk-ETBHVDB6.mjs +328 -0
- package/dist/token-goat-chunk-EVMZJ27Z.mjs +147 -0
- package/dist/token-goat-chunk-EXKGNHEG.mjs +2096 -0
- package/dist/{token-goat-chunk-RTMVLHWX.mjs → token-goat-chunk-FBNQNSJK.mjs} +2555 -5127
- package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
- package/dist/{token-goat-chunk-RLP6J7WR.mjs → token-goat-chunk-FZ3NEW5O.mjs} +33 -19
- package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
- package/dist/{token-goat-chunk-DNRPXHYH.mjs → token-goat-chunk-GFBSN7BD.mjs} +29 -401
- package/dist/{token-goat-chunk-XYWPOSCN.mjs → token-goat-chunk-GOLEOXZP.mjs} +763 -211
- package/dist/token-goat-chunk-H2K3QP6H.mjs +24 -0
- package/dist/token-goat-chunk-H2PHHGM5.mjs +188 -0
- package/dist/token-goat-chunk-HAVAOB3S.mjs +87 -0
- package/dist/token-goat-chunk-HG45AF2B.mjs +2228 -0
- package/dist/{token-goat-chunk-HUYUHODZ.mjs → token-goat-chunk-HOJLCGDP.mjs} +12965 -11748
- package/dist/{token-goat-chunk-435UQTKD.mjs → token-goat-chunk-HYBFA5X3.mjs} +118 -19
- package/dist/token-goat-chunk-IVALLT3S.mjs +48 -0
- package/dist/{token-goat-chunk-UXSXQQIY.mjs → token-goat-chunk-IVKIZWAB.mjs} +3 -3
- package/dist/{token-goat-chunk-52NSDWYY.mjs → token-goat-chunk-JB6QN6VF.mjs} +6 -4
- package/dist/{token-goat-chunk-HNFZZHFW.mjs → token-goat-chunk-JDHE26RP.mjs} +10 -3
- package/dist/{token-goat-chunk-FTP4U4QA.mjs → token-goat-chunk-JDU3EXSU.mjs} +12 -11
- package/dist/token-goat-chunk-JDWCRD6M.mjs +253 -0
- package/dist/{token-goat-chunk-6AK46ZT7.mjs → token-goat-chunk-JN4XMLSD.mjs} +5 -1
- package/dist/token-goat-chunk-JTQQGXZH.mjs +733 -0
- package/dist/token-goat-chunk-KKUFXAPD.mjs +25 -0
- package/dist/token-goat-chunk-KQNZDCBD.mjs +47 -0
- package/dist/{token-goat-chunk-2WOUYWLM.mjs → token-goat-chunk-KWPNJBDH.mjs} +27 -3
- package/dist/{token-goat-chunk-DPNLUJWB.mjs → token-goat-chunk-LOBGHXPB.mjs} +30 -8
- package/dist/token-goat-chunk-MKPF4CL5.mjs +37 -0
- package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
- package/dist/{token-goat-chunk-DNSPXQXQ.mjs → token-goat-chunk-N2NMER56.mjs} +25 -15
- package/dist/token-goat-chunk-NYKZLXMK.mjs +218 -0
- package/dist/token-goat-chunk-OJBNYTJP.mjs +3087 -0
- package/dist/token-goat-chunk-P4QMM4WK.mjs +295 -0
- package/dist/token-goat-chunk-PD5VKH46.mjs +184 -0
- package/dist/token-goat-chunk-PEPTHRFF.mjs +129 -0
- package/dist/{token-goat-chunk-NMBWLRHW.mjs → token-goat-chunk-PU7V3FD6.mjs} +8721 -11104
- package/dist/token-goat-chunk-PY533T7F.mjs +46 -0
- package/dist/token-goat-chunk-Q5VTGRH7.mjs +761 -0
- package/dist/{token-goat-chunk-67BNIKKO.mjs → token-goat-chunk-QCLDAQTS.mjs} +31 -20
- package/dist/{token-goat-chunk-SE6E4BKJ.mjs → token-goat-chunk-QSBRTGM2.mjs} +9 -2
- package/dist/{token-goat-chunk-VZQEWRVH.mjs → token-goat-chunk-RC35RBUL.mjs} +4 -4
- package/dist/{token-goat-chunk-VMFWNHGR.mjs → token-goat-chunk-RHXKCZX3.mjs} +873 -504
- package/dist/{token-goat-chunk-PYSUADX4.mjs → token-goat-chunk-RZRTDST7.mjs} +17 -7
- package/dist/{token-goat-chunk-ONXH6NZ5.mjs → token-goat-chunk-SJHWVNDQ.mjs} +15 -21
- package/dist/token-goat-chunk-SMVRN2HU.mjs +188 -0
- package/dist/{token-goat-chunk-QO3LXVVR.mjs → token-goat-chunk-SQSSNQPE.mjs} +2295 -1718
- package/dist/{token-goat-chunk-2AWQ2R5X.mjs → token-goat-chunk-T4FK7VOV.mjs} +2 -2
- package/dist/token-goat-chunk-U4N3BN2W.mjs +92 -0
- package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
- package/dist/{token-goat-chunk-UA5BKWWQ.mjs → token-goat-chunk-UQ5UK2T7.mjs} +15 -4
- package/dist/token-goat-chunk-USILZ3T3.mjs +53 -0
- package/dist/{token-goat-chunk-MELOKFDJ.mjs → token-goat-chunk-VES7EL7O.mjs} +7 -1
- package/dist/{token-goat-chunk-7CPMDFGB.mjs → token-goat-chunk-VL3YIFHZ.mjs} +389 -14
- package/dist/{token-goat-chunk-E5TK5DNO.mjs → token-goat-chunk-VPBBTSJR.mjs} +356 -129
- package/dist/{token-goat-chunk-YOOVFPTP.mjs → token-goat-chunk-W3QCJS6G.mjs} +10 -2
- package/dist/{token-goat-chunk-LZNBQTDK.mjs → token-goat-chunk-WY3L4DVT.mjs} +11 -7
- package/dist/token-goat-chunk-XKI4SEMX.mjs +66 -0
- package/dist/token-goat-chunk-XU4P6Z24.mjs +133 -0
- package/dist/{token-goat-chunk-H5J3C56Q.mjs → token-goat-chunk-Y776AENC.mjs} +112 -26
- package/dist/token-goat-chunk-YARZFCZS.mjs +359 -0
- package/dist/{token-goat-chunk-S4VSXURL.mjs → token-goat-chunk-Z44YO3QZ.mjs} +4 -0
- package/dist/token-goat-chunk-Z57YODA2.mjs +35 -0
- package/dist/{token-goat-chunk-PQ53BSCF.mjs → token-goat-chunk-ZCDTCVIS.mjs} +48 -29
- package/dist/token-goat-chunk-ZEJVMUQH.mjs +48 -0
- package/dist/{token-goat-chunk-BGHSSJUA.mjs → token-goat-chunk-ZFOBKUWH.mjs} +1 -1
- package/dist/token-goat-chunk-ZMBL6UVV.mjs +110 -0
- package/dist/{token-goat-chunk-PKRWMHVP.mjs → token-goat-chunk-ZQSJMO2R.mjs} +338 -170
- package/dist/token-goat-hook-client.cjs +87 -23
- package/dist/token-goat-hook-client.mjs +3 -3
- package/dist/token-goat-hook.mjs +46 -30
- package/dist/token-goat.core.mjs +6 -6
- package/docs/C4_RUNTIME_ARCHITECTURE.md +1 -1
- package/docs/cli.md +80 -46
- package/docs/install.md +47 -14
- package/docs/security.md +7 -7
- package/package.json +17 -7
- package/scripts/verify-native-dist.mjs +386 -0
- package/dist/token-goat-chunk-2NNUA2LR.mjs +0 -143
- package/dist/token-goat-chunk-44BM7DDQ.mjs +0 -294
- package/dist/token-goat-chunk-C5YPNZKQ.mjs +0 -318
- package/dist/token-goat-chunk-CIQ2FTY3.mjs +0 -1990
- package/dist/token-goat-chunk-EUSDXRXU.mjs +0 -1429
- package/dist/token-goat-chunk-G7IWXCFF.mjs +0 -456
- package/dist/token-goat-chunk-JTKCQMQA.mjs +0 -418
- package/dist/token-goat-chunk-ORNFMIER.mjs +0 -295
- package/dist/token-goat-chunk-VQ6F6T7X.mjs +0 -36
- package/dist/token-goat-chunk-YAGLESS3.mjs +0 -23
- package/dist/token-goat-chunk-YKSRAWUU.mjs +0 -33
- package/dist/token-goat-chunk-Z6KBMOBI.mjs +0 -53
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
2
|
const require = __cjsRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
readCopilotMcpTools
|
|
7
|
-
} from "./token-goat-chunk-EUSDXRXU.mjs";
|
|
4
|
+
estimateTokensFromLength
|
|
5
|
+
} from "./token-goat-chunk-JB6QN6VF.mjs";
|
|
8
6
|
import {
|
|
9
|
-
countRedactionPlaceholders,
|
|
10
7
|
recordStat,
|
|
11
8
|
savedTokensFromBytes
|
|
12
|
-
} from "./token-goat-chunk-
|
|
9
|
+
} from "./token-goat-chunk-3Z5S4KGM.mjs";
|
|
10
|
+
import {
|
|
11
|
+
countRedactionPlaceholders
|
|
12
|
+
} from "./token-goat-chunk-4FVIAHSI.mjs";
|
|
13
13
|
import {
|
|
14
|
-
detectHarness,
|
|
15
14
|
loadConfig,
|
|
16
15
|
ownGet
|
|
17
|
-
} from "./token-goat-chunk-
|
|
16
|
+
} from "./token-goat-chunk-7IN2MKDS.mjs";
|
|
17
|
+
import {
|
|
18
|
+
detectHarness
|
|
19
|
+
} from "./token-goat-chunk-U4N3BN2W.mjs";
|
|
18
20
|
import {
|
|
19
21
|
registerReset
|
|
20
22
|
} from "./token-goat-chunk-YZAAZU2S.mjs";
|
|
21
|
-
import {
|
|
22
|
-
escapesOntoNetworkThroughLinks,
|
|
23
|
-
foldPathForContainment,
|
|
24
|
-
isInsideRoot
|
|
25
|
-
} from "./token-goat-chunk-TCQANXYC.mjs";
|
|
26
23
|
import {
|
|
27
24
|
displaySafeText,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} from "./token-goat-chunk-
|
|
25
|
+
neutralizeOutsideFences,
|
|
26
|
+
resolveToolPath
|
|
27
|
+
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
31
28
|
import {
|
|
32
29
|
init_define_import_meta_env
|
|
33
30
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -37,6 +34,148 @@ init_define_import_meta_env();
|
|
|
37
34
|
|
|
38
35
|
// src/copilot_mcp_names.ts
|
|
39
36
|
init_define_import_meta_env();
|
|
37
|
+
|
|
38
|
+
// src/copilot_mcp_tools.ts
|
|
39
|
+
init_define_import_meta_env();
|
|
40
|
+
import fs from "node:fs";
|
|
41
|
+
import path2 from "node:path";
|
|
42
|
+
|
|
43
|
+
// src/copilot_home.ts
|
|
44
|
+
init_define_import_meta_env();
|
|
45
|
+
import * as os from "node:os";
|
|
46
|
+
import * as path from "node:path";
|
|
47
|
+
function copilotCliUserRoot(homeDir = os.homedir()) {
|
|
48
|
+
const override = process.env["COPILOT_HOME"];
|
|
49
|
+
if (override !== void 0 && override.trim() !== "") return path.resolve(override);
|
|
50
|
+
return path.join(homeDir, ".copilot");
|
|
51
|
+
}
|
|
52
|
+
function copilotCliCacheRoot() {
|
|
53
|
+
const override = process.env["COPILOT_CACHE_HOME"];
|
|
54
|
+
if (override !== void 0 && override.trim() !== "") return path.resolve(override);
|
|
55
|
+
const home = os.homedir();
|
|
56
|
+
if (process.platform === "darwin") return path.join(home, "Library", "Caches", "copilot");
|
|
57
|
+
if (process.platform === "win32") {
|
|
58
|
+
const local = process.env["LOCALAPPDATA"];
|
|
59
|
+
const base2 = local !== void 0 && local.trim() !== "" ? local : path.join(home, ".cache");
|
|
60
|
+
return path.join(base2, "copilot");
|
|
61
|
+
}
|
|
62
|
+
const xdg = process.env["XDG_CACHE_HOME"];
|
|
63
|
+
const base = xdg !== void 0 && xdg.trim() !== "" ? xdg : path.join(home, ".cache");
|
|
64
|
+
return path.join(base, "copilot");
|
|
65
|
+
}
|
|
66
|
+
function copilotCliMcpToolsDir() {
|
|
67
|
+
return path.join(copilotCliCacheRoot(), "mcp-tools");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/copilot_mcp_tools.ts
|
|
71
|
+
var COPILOT_BUILTIN_MCP_SERVERS = ["github-mcp-server"];
|
|
72
|
+
function readCopilotDisabledMcpServers(userRoot = copilotCliUserRoot()) {
|
|
73
|
+
const disabled = /* @__PURE__ */ new Set();
|
|
74
|
+
const settingsPath = path2.join(userRoot, "settings.json");
|
|
75
|
+
try {
|
|
76
|
+
if (!fs.existsSync(settingsPath)) return disabled;
|
|
77
|
+
const raw = fs.readFileSync(settingsPath, "utf8");
|
|
78
|
+
const parsed = JSON.parse(raw);
|
|
79
|
+
if (typeof parsed !== "object" || parsed === null) return disabled;
|
|
80
|
+
if (parsed["disableBuiltinMcps"] === true) {
|
|
81
|
+
for (const builtin of COPILOT_BUILTIN_MCP_SERVERS) {
|
|
82
|
+
disabled.add(builtin);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const disabledList = parsed["disabledMcpServers"];
|
|
86
|
+
if (Array.isArray(disabledList)) {
|
|
87
|
+
for (const item of disabledList) {
|
|
88
|
+
if (typeof item === "string" && item.trim() !== "") {
|
|
89
|
+
disabled.add(item.trim());
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const singleOrList = parsed["disableMcpServer"];
|
|
94
|
+
if (Array.isArray(singleOrList)) {
|
|
95
|
+
for (const item of singleOrList) {
|
|
96
|
+
if (typeof item === "string" && item.trim() !== "") {
|
|
97
|
+
disabled.add(item.trim());
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} else if (typeof singleOrList === "string" && singleOrList.trim() !== "") {
|
|
101
|
+
disabled.add(singleOrList.trim());
|
|
102
|
+
}
|
|
103
|
+
} catch {
|
|
104
|
+
}
|
|
105
|
+
return disabled;
|
|
106
|
+
}
|
|
107
|
+
function wireShapeLength(tools) {
|
|
108
|
+
const wire = tools.map((tool) => {
|
|
109
|
+
const out = {};
|
|
110
|
+
if (typeof tool.name === "string") out["name"] = tool.name;
|
|
111
|
+
if (typeof tool.description === "string") out["description"] = tool.description;
|
|
112
|
+
if (tool.inputSchema !== void 0) out["inputSchema"] = tool.inputSchema;
|
|
113
|
+
return out;
|
|
114
|
+
});
|
|
115
|
+
return JSON.stringify(wire).length;
|
|
116
|
+
}
|
|
117
|
+
function readCopilotMcpTools(dir = copilotCliMcpToolsDir(), userRoot = copilotCliUserRoot()) {
|
|
118
|
+
let entries;
|
|
119
|
+
try {
|
|
120
|
+
entries = fs.readdirSync(dir);
|
|
121
|
+
} catch {
|
|
122
|
+
return { cacheFound: false, servers: [], disabledServers: [], unreadable: 0 };
|
|
123
|
+
}
|
|
124
|
+
const disabledSet = readCopilotDisabledMcpServers(userRoot);
|
|
125
|
+
const newest = /* @__PURE__ */ new Map();
|
|
126
|
+
let unreadable = 0;
|
|
127
|
+
for (const entry of entries) {
|
|
128
|
+
if (!entry.toLowerCase().endsWith(".json")) continue;
|
|
129
|
+
let parsed;
|
|
130
|
+
try {
|
|
131
|
+
parsed = JSON.parse(fs.readFileSync(path2.join(dir, entry), "utf8"));
|
|
132
|
+
} catch {
|
|
133
|
+
unreadable += 1;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
137
|
+
unreadable += 1;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const record = parsed;
|
|
141
|
+
const serverName = typeof record.serverName === "string" ? record.serverName.trim() : "";
|
|
142
|
+
if (serverName === "") {
|
|
143
|
+
unreadable += 1;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const tools = Array.isArray(record.tools) ? record.tools : [];
|
|
147
|
+
const updatedAt = typeof record.updatedAt === "string" ? record.updatedAt : "";
|
|
148
|
+
const definitionBytes = wireShapeLength(tools);
|
|
149
|
+
const candidate = {
|
|
150
|
+
serverName,
|
|
151
|
+
toolCount: tools.length,
|
|
152
|
+
definitionBytes,
|
|
153
|
+
estimatedTokens: estimateTokensFromLength(definitionBytes),
|
|
154
|
+
updatedAt,
|
|
155
|
+
// `tools` is an unchecked cast off a JSON array, so every element is
|
|
156
|
+
// treated as untrusted here rather than trusted to match CachedTool.
|
|
157
|
+
toolNames: tools.map((t) => t?.name).filter((n) => typeof n === "string" && n !== "")
|
|
158
|
+
};
|
|
159
|
+
const existing = newest.get(serverName);
|
|
160
|
+
if (existing === void 0 || candidate.updatedAt > existing.updatedAt) newest.set(serverName, candidate);
|
|
161
|
+
}
|
|
162
|
+
const activeCandidates = [];
|
|
163
|
+
const disabledServers = [];
|
|
164
|
+
for (const [name, candidate] of newest.entries()) {
|
|
165
|
+
if (disabledSet.has(name)) {
|
|
166
|
+
disabledServers.push(name);
|
|
167
|
+
} else {
|
|
168
|
+
activeCandidates.push(candidate);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
disabledServers.sort();
|
|
172
|
+
const servers = activeCandidates.sort(
|
|
173
|
+
(a, b) => b.definitionBytes - a.definitionBytes || a.serverName.localeCompare(b.serverName)
|
|
174
|
+
);
|
|
175
|
+
return { cacheFound: true, servers, disabledServers, unreadable };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// src/copilot_mcp_names.ts
|
|
40
179
|
var _cached = null;
|
|
41
180
|
function copilotMcpToolNameMap() {
|
|
42
181
|
if (_cached) return _cached;
|
|
@@ -60,6 +199,30 @@ function resetCopilotMcpToolNameCache() {
|
|
|
60
199
|
}
|
|
61
200
|
registerReset(resetCopilotMcpToolNameCache, { perRequest: true });
|
|
62
201
|
|
|
202
|
+
// src/copilot_tool_names.ts
|
|
203
|
+
init_define_import_meta_env();
|
|
204
|
+
var COPILOT_CLI_TOOL_NAME_MAP = {
|
|
205
|
+
bash: "Bash",
|
|
206
|
+
powershell: "Bash",
|
|
207
|
+
read_bash: "BashOutput",
|
|
208
|
+
read_powershell: "BashOutput",
|
|
209
|
+
view: "Read",
|
|
210
|
+
create: "Write",
|
|
211
|
+
edit: "Edit",
|
|
212
|
+
web_fetch: "WebFetch",
|
|
213
|
+
web_search: "WebSearch",
|
|
214
|
+
grep: "Grep",
|
|
215
|
+
glob: "Glob",
|
|
216
|
+
skill: "Skill",
|
|
217
|
+
exit_plan_mode: "ExitPlanMode"
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// src/tool_name_fold.ts
|
|
221
|
+
init_define_import_meta_env();
|
|
222
|
+
function foldToolName(name) {
|
|
223
|
+
return typeof name === "string" ? name.toLowerCase().replace(/[_-]/g, "") : "";
|
|
224
|
+
}
|
|
225
|
+
|
|
63
226
|
// src/hooks_cli.ts
|
|
64
227
|
var _LOG = {
|
|
65
228
|
warn: (msg, ...args) => console.warn(`[hooks_cli] ${msg}`, ...args),
|
|
@@ -151,14 +314,12 @@ var GEMINI_TOOL_NAME_MAP = {
|
|
|
151
314
|
grep_search: "Grep",
|
|
152
315
|
// 'search_file_content' was GREP_TOOL_NAME's value before gemini-cli renamed it to 'grep_search' (confirmed against gemini-cli's current base-declarations.ts, which now defines GREP_TOOL_NAME = 'grep_search'; some of gemini-cli's own docs pages still lag the rename). Kept as a backward-compat entry for older installed gemini-cli versions that still emit the pre-rename name -- not dead/hallucinated, just legacy.
|
|
153
316
|
search_file_content: "Grep",
|
|
154
|
-
// Gemini's real web-search tool is registered as 'google_web_search' (WEB_SEARCH_TOOL_NAME in gemini-cli's tool-names.ts) -- 'web_search' is not a tool name Gemini CLI ever emits, so the old entry here silently never matched a real invocation.
|
|
155
|
-
// Previously mapped to 'WebFetch' as a workaround for GEMINI_PRE_TOOLS/POST_TOOLS (gemini_install.ts) excluding 'WebSearch' -- that made the hook fire under the installer's matcher, but hooks_fetch.ts's preFetchHandler/postFetchHandler require a `url` tool-input key, which a search call never sends (it sends `query`), so every google_web_search call silently no-op'd through WebFetch's handler: no URL policy check ever applied to it (it has no URL to check) and no search-result dedup ever ran. Now mapped to the dedicated 'WebSearch' handler (hooks_websearch.ts), which reads `query` directly; the installer gate above was extended to include 'WebSearch' so the hook stays wired.
|
|
317
|
+
// Gemini's real web-search tool is registered as 'google_web_search' (WEB_SEARCH_TOOL_NAME in gemini-cli's tool-names.ts) -- 'web_search' is not a tool name Gemini CLI ever emits, so the old entry here silently never matched a real invocation. Previously mapped to 'WebFetch' as a workaround for GEMINI_PRE_TOOLS/POST_TOOLS (gemini_install.ts) excluding 'WebSearch' -- that made the hook fire under the installer's matcher, but hooks_fetch.ts's preFetchHandler/postFetchHandler require a `url` tool-input key, which a search call never sends (it sends `query`), so every google_web_search call silently no-op'd through WebFetch's handler: no URL policy check ever applied to it (it has no URL to check) and no search-result dedup ever ran. Now mapped to the dedicated 'WebSearch' handler (hooks_websearch.ts), which reads `query` directly; the installer gate above was extended to include 'WebSearch' so the hook stays wired.
|
|
156
318
|
google_web_search: "WebSearch",
|
|
157
319
|
web_fetch: "WebFetch"
|
|
158
320
|
};
|
|
159
321
|
var GEMINI_INPUT_KEY_MAP = {
|
|
160
|
-
// Gemini's real write_file/replace tool schemas already use 'file_path' (and replace's 'old_string'/'new_string') verbatim -- identical to token-goat's own canonical keys (see getFilePath() in hooks_common.ts, which reads event.toolInput['file_path']) -- confirmed against gemini-cli's own EditToolParams/WriteFileToolParams interfaces. No remap is needed for Write/Edit; the previous entries here actively renamed a key that was already correct (file_path -> path), which would have silently corrupted the path argument on every real Gemini Write/Edit call.
|
|
161
|
-
// 'Read' covers THREE distinct raw Gemini tools (see GEMINI_TOOL_NAME_MAP above), and they do NOT share one schema: read_file already uses 'file_path' verbatim, no remap needed; list_directory uses 'dir_path' (confirmed against gemini-cli's LSToolParams) -- remapped to 'file_path' below, exactly mirroring Grep's existing dir_path->path fix; read_many_files uses 'include' (confirmed against gemini-cli's ReadManyFilesParams), an ARRAY of glob patterns, not a single file path -- there is no single string to remap it to, so it is deliberately left unmapped. getFilePath() (hooks_common.ts) will return undefined for this call, and preReadHandler/postReadHandler already fall back to passOutput() on an undefined path (see preReadHandler's `if (filePath === undefined) return passOutput()`), so a real read_many_files call still succeeds normally; it just doesn't get session-dedup tracking or read-count hints. Accepted limitation, not a bug to force-fit.
|
|
322
|
+
// Gemini's real write_file/replace tool schemas already use 'file_path' (and replace's 'old_string'/'new_string') verbatim -- identical to token-goat's own canonical keys (see getFilePath() in hooks_common.ts, which reads event.toolInput['file_path']) -- confirmed against gemini-cli's own EditToolParams/WriteFileToolParams interfaces. No remap is needed for Write/Edit; the previous entries here actively renamed a key that was already correct (file_path -> path), which would have silently corrupted the path argument on every real Gemini Write/Edit call. 'Read' covers THREE distinct raw Gemini tools (see GEMINI_TOOL_NAME_MAP above), and they do NOT share one schema: read_file already uses 'file_path' verbatim, no remap needed; list_directory uses 'dir_path' (confirmed against gemini-cli's LSToolParams) -- remapped to 'file_path' below, exactly mirroring Grep's existing dir_path->path fix; read_many_files uses 'include' (confirmed against gemini-cli's ReadManyFilesParams), an ARRAY of glob patterns, not a single file path -- there is no single string to remap it to, so it is deliberately left unmapped. getFilePath() (hooks_common.ts) will return undefined for this call, and preReadHandler/postReadHandler already fall back to passOutput() on an undefined path (see preReadHandler's `if (filePath === undefined) return passOutput()`), so a real read_many_files call still succeeds normally; it just doesn't get session-dedup tracking or read-count hints. Accepted limitation, not a bug to force-fit.
|
|
162
323
|
Read: { dir_path: "file_path" },
|
|
163
324
|
// Grep's real tool (grep_search) calls its target-directory argument 'dir_path', which preReadHandler's Grep fallback (event.toolInput['path']) doesn't recognize, so that one remains remapped.
|
|
164
325
|
Grep: { dir_path: "path" }
|
|
@@ -226,7 +387,12 @@ var VSCODE_TOOL_NAME_MAP = {
|
|
|
226
387
|
replace_string_in_file: "Edit",
|
|
227
388
|
insert_edit_into_file: "Edit",
|
|
228
389
|
edit_notebook_file: "NotebookEdit",
|
|
229
|
-
run_in_terminal: "Bash"
|
|
390
|
+
run_in_terminal: "Bash",
|
|
391
|
+
multi_replace_string_in_file: "MultiEdit",
|
|
392
|
+
apply_patch: "Edit",
|
|
393
|
+
fetch_webpage: "WebFetch",
|
|
394
|
+
runSubagent: "Task",
|
|
395
|
+
get_terminal_output: "BashOutput"
|
|
230
396
|
};
|
|
231
397
|
var VSCODE_INPUT_KEY_MAP = {
|
|
232
398
|
read_file: { filePath: "file_path" },
|
|
@@ -238,7 +404,52 @@ var VSCODE_INPUT_KEY_MAP = {
|
|
|
238
404
|
replace_string_in_file: { filePath: "file_path", oldString: "old_string", newString: "new_string" },
|
|
239
405
|
insert_edit_into_file: { filePath: "file_path" },
|
|
240
406
|
edit_notebook_file: { filePath: "notebook_path" },
|
|
241
|
-
run_in_terminal: {}
|
|
407
|
+
run_in_terminal: {},
|
|
408
|
+
multi_replace_string_in_file: {},
|
|
409
|
+
apply_patch: {},
|
|
410
|
+
fetch_webpage: {},
|
|
411
|
+
runSubagent: {},
|
|
412
|
+
get_terminal_output: { id: "bash_id" }
|
|
413
|
+
};
|
|
414
|
+
function derivedPaths(paths) {
|
|
415
|
+
const unique = [...new Set(paths)];
|
|
416
|
+
if (unique.length === 0) return {};
|
|
417
|
+
return unique.length === 1 ? { file_paths: unique, file_path: unique[0] } : { file_paths: unique };
|
|
418
|
+
}
|
|
419
|
+
var PATCH_PATH_HEADERS = ["*** Add File: ", "*** Delete File: ", "*** Update File: ", "*** Move to: "];
|
|
420
|
+
function patchFilePaths(patch) {
|
|
421
|
+
const paths = [];
|
|
422
|
+
for (const line of patch.split(/\r?\n/)) {
|
|
423
|
+
const header = PATCH_PATH_HEADERS.find((h) => line.startsWith(h));
|
|
424
|
+
if (header === void 0) continue;
|
|
425
|
+
const target = line.slice(header.length).trim();
|
|
426
|
+
if (target !== "") paths.push(target);
|
|
427
|
+
}
|
|
428
|
+
return paths;
|
|
429
|
+
}
|
|
430
|
+
var VSCODE_DERIVED_INPUT = {
|
|
431
|
+
multi_replace_string_in_file: (input) => {
|
|
432
|
+
const replacements = Array.isArray(input["replacements"]) ? input["replacements"] : [];
|
|
433
|
+
const paths = [];
|
|
434
|
+
for (const r of replacements) {
|
|
435
|
+
const filePath = r !== null && typeof r === "object" ? r["filePath"] : void 0;
|
|
436
|
+
if (typeof filePath === "string" && filePath !== "") paths.push(filePath);
|
|
437
|
+
}
|
|
438
|
+
return derivedPaths(paths);
|
|
439
|
+
},
|
|
440
|
+
apply_patch: (input) => typeof input["input"] === "string" ? derivedPaths(patchFilePaths(input["input"])) : {},
|
|
441
|
+
fetch_webpage: (input) => {
|
|
442
|
+
const out = {};
|
|
443
|
+
const urls = Array.isArray(input["urls"]) ? input["urls"] : [];
|
|
444
|
+
if (urls.length === 1 && typeof urls[0] === "string" && urls[0] !== "") out["url"] = urls[0];
|
|
445
|
+
if (typeof input["query"] === "string") out["prompt"] = input["query"];
|
|
446
|
+
return out;
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
var VSCODE_DERIVED_KEYS = {
|
|
450
|
+
multi_replace_string_in_file: ["file_paths", "file_path"],
|
|
451
|
+
apply_patch: ["file_paths", "file_path"],
|
|
452
|
+
fetch_webpage: ["url", "prompt"]
|
|
242
453
|
};
|
|
243
454
|
var VSCODE_TOOL_NAME_KEY = "_tg_vscode_tool_name";
|
|
244
455
|
function vscodeNativeToolInput(vscodeToolName, canonicalInput) {
|
|
@@ -246,8 +457,63 @@ function vscodeNativeToolInput(vscodeToolName, canonicalInput) {
|
|
|
246
457
|
for (const [nativeKey, canonicalKey] of Object.entries(ownGet(VSCODE_INPUT_KEY_MAP, vscodeToolName) ?? {})) {
|
|
247
458
|
inverse[canonicalKey] = nativeKey;
|
|
248
459
|
}
|
|
460
|
+
const native = remapInputKeys(canonicalInput, inverse);
|
|
461
|
+
for (const key of ownGet(VSCODE_DERIVED_KEYS, vscodeToolName) ?? []) delete native[key];
|
|
462
|
+
return native;
|
|
463
|
+
}
|
|
464
|
+
var ANTIGRAVITY_TOOL_NAME_MAP = {
|
|
465
|
+
view_file: "Read",
|
|
466
|
+
list_dir: "Read",
|
|
467
|
+
list_directory: "Read",
|
|
468
|
+
run_command: "Bash",
|
|
469
|
+
grep_search: "Grep",
|
|
470
|
+
find_by_name: "Glob",
|
|
471
|
+
find: "Glob",
|
|
472
|
+
replace_file_content: "Edit",
|
|
473
|
+
multi_replace_file_content: "Edit",
|
|
474
|
+
file_change: "Edit",
|
|
475
|
+
write_to_file: "Write",
|
|
476
|
+
search_web: "WebSearch"
|
|
477
|
+
};
|
|
478
|
+
var AGY_EDIT_KEYS = { TargetFile: "file_path", TargetContent: "old_string", ReplacementContent: "new_string" };
|
|
479
|
+
var ANTIGRAVITY_INPUT_KEY_MAP = {
|
|
480
|
+
view_file: { AbsolutePath: "file_path", StartLine: "startLine", EndLine: "endLine" },
|
|
481
|
+
list_dir: { DirectoryPath: "file_path" },
|
|
482
|
+
list_directory: { DirectoryPath: "file_path" },
|
|
483
|
+
run_command: { CommandLine: "command" },
|
|
484
|
+
grep_search: { Query: "pattern", SearchPath: "path" },
|
|
485
|
+
find_by_name: { Pattern: "pattern", SearchDirectory: "path" },
|
|
486
|
+
find: { Pattern: "pattern", SearchDirectory: "path" },
|
|
487
|
+
replace_file_content: AGY_EDIT_KEYS,
|
|
488
|
+
multi_replace_file_content: AGY_EDIT_KEYS,
|
|
489
|
+
file_change: AGY_EDIT_KEYS,
|
|
490
|
+
write_to_file: { TargetFile: "file_path", CodeContent: "content" },
|
|
491
|
+
search_web: {}
|
|
492
|
+
};
|
|
493
|
+
var ANTIGRAVITY_TOOL_NAME_KEY = "_tg_antigravity_tool_name";
|
|
494
|
+
function antigravityNativeToolInput(agyToolName, canonicalInput) {
|
|
495
|
+
const inverse = {};
|
|
496
|
+
for (const [nativeKey, canonicalKey] of Object.entries(ownGet(ANTIGRAVITY_INPUT_KEY_MAP, agyToolName) ?? {})) {
|
|
497
|
+
inverse[canonicalKey] = nativeKey;
|
|
498
|
+
}
|
|
249
499
|
return remapInputKeys(canonicalInput, inverse);
|
|
250
500
|
}
|
|
501
|
+
function antigravityToCanonicalWire(obj) {
|
|
502
|
+
const wire = { ...obj };
|
|
503
|
+
const call = wire["toolCall"];
|
|
504
|
+
if (call !== null && typeof call === "object" && !Array.isArray(call)) {
|
|
505
|
+
const { name, args } = call;
|
|
506
|
+
if (typeof name === "string" && wire["tool_name"] === void 0) wire["tool_name"] = name;
|
|
507
|
+
if (args !== null && typeof args === "object" && !Array.isArray(args) && wire["tool_input"] === void 0) wire["tool_input"] = args;
|
|
508
|
+
}
|
|
509
|
+
if (typeof wire["conversationId"] === "string" && wire["session_id"] === void 0) wire["session_id"] = wire["conversationId"];
|
|
510
|
+
const workspaces = wire["workspacePaths"];
|
|
511
|
+
if (wire["cwd"] === void 0 && Array.isArray(workspaces) && typeof workspaces[0] === "string" && workspaces[0] !== "") wire["cwd"] = workspaces[0];
|
|
512
|
+
if (wire["tool_response"] === void 0 && typeof wire["result"] === "string") {
|
|
513
|
+
wire["tool_response"] = typeof wire["error"] === "string" && wire["error"] !== "" ? { output: wire["result"], error: wire["error"] } : { output: wire["result"] };
|
|
514
|
+
}
|
|
515
|
+
return wire;
|
|
516
|
+
}
|
|
251
517
|
function remapInputKeys(input, keyMap) {
|
|
252
518
|
const newInput = {};
|
|
253
519
|
for (const [k, v] of Object.entries(input)) {
|
|
@@ -305,7 +571,7 @@ function normalizePayload(payload, harness = "claude") {
|
|
|
305
571
|
return {};
|
|
306
572
|
}
|
|
307
573
|
const rawObj = payload;
|
|
308
|
-
const obj = harness === "grok" ? grokToCanonicalWire(rawObj) : rawObj;
|
|
574
|
+
const obj = harness === "grok" ? grokToCanonicalWire(rawObj) : harness === "antigravity" ? antigravityToCanonicalWire(rawObj) : rawObj;
|
|
309
575
|
const toolName = obj["tool_name"];
|
|
310
576
|
if (typeof toolName !== "string" || !toolName.trim()) {
|
|
311
577
|
_LOG.debug("normalizePayload: tool_name missing or invalid; received %s", toolName);
|
|
@@ -322,6 +588,11 @@ function normalizePayload(payload, harness = "claude") {
|
|
|
322
588
|
if (mapped) {
|
|
323
589
|
result2["tool_name"] = mapped;
|
|
324
590
|
}
|
|
591
|
+
const rawInput = obj["tool_input"];
|
|
592
|
+
const patch = toolName === "apply_patch" && typeof rawInput === "object" && rawInput !== null && !Array.isArray(rawInput) ? rawInput["command"] : void 0;
|
|
593
|
+
if (typeof patch === "string") {
|
|
594
|
+
result2["tool_input"] = { ...rawInput, ...derivedPaths(patchFilePaths(patch)) };
|
|
595
|
+
}
|
|
325
596
|
result2["_tg_harness"] = harness;
|
|
326
597
|
return result2;
|
|
327
598
|
}
|
|
@@ -338,12 +609,27 @@ function normalizePayload(payload, harness = "claude") {
|
|
|
338
609
|
const keyMap = ownGet(VSCODE_INPUT_KEY_MAP, toolName) ?? ownGet(VSCODE_INPUT_KEY_MAP, mapped);
|
|
339
610
|
const rawInput = obj["tool_input"];
|
|
340
611
|
if (keyMap && typeof rawInput === "object" && rawInput !== null && !Array.isArray(rawInput)) {
|
|
341
|
-
|
|
612
|
+
const renamed = remapInputKeys(rawInput, keyMap);
|
|
613
|
+
const derive = ownGet(VSCODE_DERIVED_INPUT, toolName);
|
|
614
|
+
result2["tool_input"] = derive === void 0 ? renamed : { ...renamed, ...derive(rawInput) };
|
|
342
615
|
}
|
|
343
616
|
result2[VSCODE_TOOL_NAME_KEY] = toolName;
|
|
344
617
|
result2["_tg_harness"] = harness;
|
|
345
618
|
return result2;
|
|
346
619
|
}
|
|
620
|
+
if (harness === "antigravity") {
|
|
621
|
+
const mapped = normalizeToolNameWithMap(toolName, ANTIGRAVITY_TOOL_NAME_MAP);
|
|
622
|
+
const result2 = { ...obj };
|
|
623
|
+
result2["tool_name"] = mapped;
|
|
624
|
+
const keyMap = ownGet(ANTIGRAVITY_INPUT_KEY_MAP, toolName);
|
|
625
|
+
const rawInput = obj["tool_input"];
|
|
626
|
+
if (keyMap && typeof rawInput === "object" && rawInput !== null && !Array.isArray(rawInput)) {
|
|
627
|
+
result2["tool_input"] = remapInputKeys(rawInput, keyMap);
|
|
628
|
+
}
|
|
629
|
+
result2[ANTIGRAVITY_TOOL_NAME_KEY] = toolName;
|
|
630
|
+
result2["_tg_harness"] = harness;
|
|
631
|
+
return result2;
|
|
632
|
+
}
|
|
347
633
|
if (harness === "kimi") {
|
|
348
634
|
const result2 = remapToolName(obj, toolName, KIMI_TOOL_NAME_MAP, KIMI_INPUT_KEY_MAP);
|
|
349
635
|
result2["_tg_harness"] = harness;
|
|
@@ -374,52 +660,6 @@ function normalizePayload(payload, harness = "claude") {
|
|
|
374
660
|
return result;
|
|
375
661
|
}
|
|
376
662
|
|
|
377
|
-
// src/hint_suggestion_guard.ts
|
|
378
|
-
init_define_import_meta_env();
|
|
379
|
-
function looksLikeSuggestion(slice) {
|
|
380
|
-
return slice.includes('"');
|
|
381
|
-
}
|
|
382
|
-
var SAFE_OUTSIDE_QUOTES = /^[A-Za-z0-9 \t_./=:,@+-]*$/;
|
|
383
|
-
var CONTROL_OR_BIDI = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\u200E\u200F\u202A-\u202E\u2066-\u2069\u061C\u200B-\u200D\u2028\u2029\uFE00-\uFE0F]|[\u{E0000}-\u{E007F}]/u;
|
|
384
|
-
function suggestionIsUnsafe(slice) {
|
|
385
|
-
if (slice.includes("$") || slice.includes("\n") || slice.includes("\r") || slice.includes("`")) return true;
|
|
386
|
-
if (CONTROL_OR_BIDI.test(slice)) return true;
|
|
387
|
-
const regions = slice.split('"');
|
|
388
|
-
if (regions.length % 2 === 0) return true;
|
|
389
|
-
for (let i = 2; i < regions.length; i += 2) {
|
|
390
|
-
if (!SAFE_OUTSIDE_QUOTES.test(regions[i] ?? "")) return true;
|
|
391
|
-
}
|
|
392
|
-
return false;
|
|
393
|
-
}
|
|
394
|
-
var OMITTED = "token-goat (command omitted: the path contains shell metacharacters)";
|
|
395
|
-
function stripUnsafeSuggestions(text) {
|
|
396
|
-
if (!text.includes("token-goat ")) return text;
|
|
397
|
-
let out = "";
|
|
398
|
-
let at = 0;
|
|
399
|
-
for (; ; ) {
|
|
400
|
-
const start = text.indexOf("token-goat ", at);
|
|
401
|
-
if (start === -1) return out + text.slice(at);
|
|
402
|
-
const lineBreak = text.slice(start).search(/[\r\n]/);
|
|
403
|
-
const line = lineBreak === -1 ? text.slice(start) : text.slice(start, start + lineBreak);
|
|
404
|
-
const firstTick = line.indexOf("`");
|
|
405
|
-
const narrow = firstTick === -1 ? line : line.slice(0, firstTick);
|
|
406
|
-
out += text.slice(at, start);
|
|
407
|
-
if (!looksLikeSuggestion(narrow) || !suggestionIsUnsafe(narrow)) {
|
|
408
|
-
out += narrow;
|
|
409
|
-
at = start + narrow.length;
|
|
410
|
-
continue;
|
|
411
|
-
}
|
|
412
|
-
const lastTick = line.lastIndexOf("`");
|
|
413
|
-
const wide = lastTick === -1 ? line : line.slice(0, lastTick);
|
|
414
|
-
out += OMITTED;
|
|
415
|
-
at = start + wide.length;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
function leadWithCommand(command, purpose = "", reason = "") {
|
|
419
|
-
const tail = reason.trim();
|
|
420
|
-
return "Run `" + command + "`" + (purpose === "" ? "" : " " + purpose) + "." + (tail === "" ? "" : (tail.includes("`") ? "\n" : " ") + tail);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
663
|
// src/hooks_common.ts
|
|
424
664
|
init_define_import_meta_env();
|
|
425
665
|
function getToolName(event) {
|
|
@@ -430,9 +670,26 @@ function getToolInput(event) {
|
|
|
430
670
|
}
|
|
431
671
|
function getFilePath(event) {
|
|
432
672
|
const value = event.toolInput["file_path"];
|
|
433
|
-
if (typeof value === "string" && value !== "") return value;
|
|
673
|
+
if (typeof value === "string" && value !== "") return resolveEventPath(event, value);
|
|
434
674
|
const notebookValue = event.toolInput["notebook_path"];
|
|
435
|
-
return typeof notebookValue === "string" && notebookValue !== "" ? notebookValue : void 0;
|
|
675
|
+
return typeof notebookValue === "string" && notebookValue !== "" ? resolveEventPath(event, notebookValue) : void 0;
|
|
676
|
+
}
|
|
677
|
+
function resolveEventPath(event, file) {
|
|
678
|
+
return resolveToolPath(file, getCwd(event));
|
|
679
|
+
}
|
|
680
|
+
function getFilePaths(event) {
|
|
681
|
+
const out = [];
|
|
682
|
+
const list = event.toolInput["file_paths"];
|
|
683
|
+
if (Array.isArray(list)) {
|
|
684
|
+
for (const entry of list) {
|
|
685
|
+
if (typeof entry !== "string" || entry === "") continue;
|
|
686
|
+
const resolved = resolveEventPath(event, entry);
|
|
687
|
+
if (!out.includes(resolved)) out.push(resolved);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
const single = getFilePath(event);
|
|
691
|
+
if (single !== void 0 && !out.includes(single)) out.push(single);
|
|
692
|
+
return out;
|
|
436
693
|
}
|
|
437
694
|
function getCwd(event) {
|
|
438
695
|
const value = event.raw && typeof event.raw === "object" ? event.raw["cwd"] : void 0;
|
|
@@ -447,15 +704,15 @@ function extractToolResponseField(raw, keys) {
|
|
|
447
704
|
if (typeof resp === "string") return resp;
|
|
448
705
|
if (resp !== null && typeof resp === "object") {
|
|
449
706
|
const r = resp;
|
|
450
|
-
const
|
|
451
|
-
if (
|
|
707
|
+
const path3 = resolveToolResponseFieldPath(r, keys);
|
|
708
|
+
if (path3 !== null) return readAtPath(r, path3);
|
|
452
709
|
}
|
|
453
710
|
return "";
|
|
454
711
|
}
|
|
455
712
|
var NESTED_TOOL_RESPONSE_PATHS = [["file", "content"]];
|
|
456
|
-
function readAtPath(resp,
|
|
713
|
+
function readAtPath(resp, path3) {
|
|
457
714
|
let cur = resp;
|
|
458
|
-
for (const seg of
|
|
715
|
+
for (const seg of path3) {
|
|
459
716
|
if (cur === null || typeof cur !== "object") return "";
|
|
460
717
|
cur = cur[seg];
|
|
461
718
|
}
|
|
@@ -465,25 +722,25 @@ function resolveToolResponseFieldPath(resp, keys) {
|
|
|
465
722
|
for (const key of keys) {
|
|
466
723
|
if (typeof resp[key] === "string" && resp[key] !== "") return [key];
|
|
467
724
|
}
|
|
468
|
-
for (const
|
|
469
|
-
if (readAtPath(resp,
|
|
725
|
+
for (const path3 of NESTED_TOOL_RESPONSE_PATHS) {
|
|
726
|
+
if (readAtPath(resp, path3) !== "") return path3;
|
|
470
727
|
}
|
|
471
728
|
return null;
|
|
472
729
|
}
|
|
473
730
|
function replaceToolResponseField(resp, keys, newText) {
|
|
474
|
-
const
|
|
475
|
-
if (
|
|
731
|
+
const path3 = resolveToolResponseFieldPath(resp, keys);
|
|
732
|
+
if (path3 === null) return null;
|
|
476
733
|
const root = { ...resp };
|
|
477
734
|
let cur = root;
|
|
478
|
-
for (let i = 0; i <
|
|
479
|
-
const seg =
|
|
735
|
+
for (let i = 0; i < path3.length - 1; i++) {
|
|
736
|
+
const seg = path3[i];
|
|
480
737
|
const child = cur[seg];
|
|
481
738
|
if (child === null || typeof child !== "object") return null;
|
|
482
739
|
const cloned = { ...child };
|
|
483
740
|
cur[seg] = cloned;
|
|
484
741
|
cur = cloned;
|
|
485
742
|
}
|
|
486
|
-
cur[
|
|
743
|
+
cur[path3[path3.length - 1]] = newText;
|
|
487
744
|
return root;
|
|
488
745
|
}
|
|
489
746
|
var OUTPUT_FIRST_TOOL_RESPONSE_KEYS = ["output", "content", "text", "body", "stdout", "stderr"];
|
|
@@ -590,6 +847,10 @@ function emitRewriteIfChanged(original, emitted, detail) {
|
|
|
590
847
|
if (emitted === original) return passOutput();
|
|
591
848
|
return emitRewrite(emitted, detail);
|
|
592
849
|
}
|
|
850
|
+
function emitRewriteWithContext(updatedOutput, context, detail, savings) {
|
|
851
|
+
const out = emitRewrite(updatedOutput, detail, { ...savings, originalBytes: savings.originalBytes - Buffer.byteLength(context, "utf-8") });
|
|
852
|
+
return out.hookType === "rewriteOutput" ? { ...out, context } : out;
|
|
853
|
+
}
|
|
593
854
|
function countNonEmptyLines(text) {
|
|
594
855
|
return text.split(/\r\n|\r|\n/).filter((line) => line.length > 0).length;
|
|
595
856
|
}
|
|
@@ -643,52 +904,16 @@ function makeDedupHintHandlers(opts) {
|
|
|
643
904
|
return { post, pre };
|
|
644
905
|
}
|
|
645
906
|
|
|
646
|
-
// src/vscode_path_gate.ts
|
|
647
|
-
init_define_import_meta_env();
|
|
648
|
-
import * as path from "node:path";
|
|
649
|
-
function resolvesToUncPath(target, cwd) {
|
|
650
|
-
try {
|
|
651
|
-
return isUncOrDevicePath(path.resolve(cwd ?? process.cwd(), target));
|
|
652
|
-
} catch {
|
|
653
|
-
return false;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
function vscodePathAllowed(filePath, workspace) {
|
|
657
|
-
if (isUncOrDevicePath(filePath)) return false;
|
|
658
|
-
if (workspace === void 0 || isUncOrDevicePath(workspace)) return false;
|
|
659
|
-
const resolvedRoot = path.resolve(workspace);
|
|
660
|
-
const resolvedTarget = path.resolve(workspace, filePath);
|
|
661
|
-
const root = foldPathForContainment(resolvedRoot.replace(/\\/g, "/"));
|
|
662
|
-
const target = foldPathForContainment(resolvedTarget.replace(/\\/g, "/"));
|
|
663
|
-
if (target !== root && !target.startsWith(root.endsWith("/") ? root : root + "/")) return false;
|
|
664
|
-
return isInsideRoot(resolvedTarget, resolvedRoot);
|
|
665
|
-
}
|
|
666
|
-
function isVscodeEvent(event) {
|
|
667
|
-
return event.raw["_tg_harness"] === "vscode" || event.raw[VSCODE_TOOL_NAME_KEY] !== void 0;
|
|
668
|
-
}
|
|
669
|
-
function preToolPathDeclined(event, target) {
|
|
670
|
-
if (target === void 0) return false;
|
|
671
|
-
const cwd = getCwd(event);
|
|
672
|
-
if (isUncOrDevicePath(target) || resolvesToUncPath(target, cwd)) return true;
|
|
673
|
-
if (isVscodeEvent(event)) return !vscodePathAllowed(target, cwd);
|
|
674
|
-
return escapesOntoNetworkThroughLinks(target, cwd);
|
|
675
|
-
}
|
|
676
|
-
function commandPathIsTouchable(filePath, event) {
|
|
677
|
-
if (event === void 0) return !escapesOntoNetworkThroughLinks(filePath);
|
|
678
|
-
return !preToolPathDeclined(event, filePath);
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
// src/delivering_deny.ts
|
|
682
|
-
init_define_import_meta_env();
|
|
683
|
-
var DELIVERS_CONTENT_RE = /is inlined below instead of the full body|headings below instead of the full body|in place of the full file/;
|
|
684
|
-
|
|
685
907
|
export {
|
|
686
908
|
getToolName,
|
|
687
909
|
getToolInput,
|
|
688
910
|
getFilePath,
|
|
911
|
+
resolveEventPath,
|
|
912
|
+
getFilePaths,
|
|
689
913
|
getCwd,
|
|
690
914
|
getTranscriptPath,
|
|
691
915
|
extractToolResponseField,
|
|
916
|
+
resolveToolResponseFieldPath,
|
|
692
917
|
replaceToolResponseField,
|
|
693
918
|
OUTPUT_FIRST_TOOL_RESPONSE_KEYS,
|
|
694
919
|
BODY_FIRST_TOOL_RESPONSE_KEYS,
|
|
@@ -702,17 +927,19 @@ export {
|
|
|
702
927
|
contextOutput,
|
|
703
928
|
emitRewrite,
|
|
704
929
|
emitRewriteIfChanged,
|
|
930
|
+
emitRewriteWithContext,
|
|
705
931
|
estimateResultCount,
|
|
706
932
|
structuredResultCount,
|
|
707
933
|
makeDedupHintHandlers,
|
|
934
|
+
copilotCliUserRoot,
|
|
935
|
+
copilotCliMcpToolsDir,
|
|
936
|
+
readCopilotMcpTools,
|
|
937
|
+
COPILOT_CLI_TOOL_NAME_MAP,
|
|
938
|
+
foldToolName,
|
|
708
939
|
GEMINI_TOOL_NAME_MAP,
|
|
709
940
|
VSCODE_TOOL_NAME_KEY,
|
|
710
941
|
vscodeNativeToolInput,
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
commandPathIsTouchable,
|
|
715
|
-
stripUnsafeSuggestions,
|
|
716
|
-
leadWithCommand,
|
|
717
|
-
DELIVERS_CONTENT_RE
|
|
942
|
+
ANTIGRAVITY_TOOL_NAME_KEY,
|
|
943
|
+
antigravityNativeToolInput,
|
|
944
|
+
normalizePayload
|
|
718
945
|
};
|
|
@@ -27,10 +27,18 @@ import {
|
|
|
27
27
|
reconstructLayout,
|
|
28
28
|
resolveDestPage,
|
|
29
29
|
withPdfDocument
|
|
30
|
-
} from "./token-goat-chunk-
|
|
30
|
+
} from "./token-goat-chunk-QSBRTGM2.mjs";
|
|
31
|
+
import "./token-goat-chunk-4FVIAHSI.mjs";
|
|
32
|
+
import "./token-goat-chunk-7IN2MKDS.mjs";
|
|
33
|
+
import "./token-goat-chunk-U4N3BN2W.mjs";
|
|
34
|
+
import "./token-goat-chunk-YZAAZU2S.mjs";
|
|
35
|
+
import "./token-goat-chunk-IVE6U7KV.mjs";
|
|
31
36
|
import "./token-goat-chunk-AH6QILZM.mjs";
|
|
32
37
|
import "./token-goat-chunk-Y4AFKTHK.mjs";
|
|
33
|
-
import "./token-goat-chunk-
|
|
38
|
+
import "./token-goat-chunk-GOLEOXZP.mjs";
|
|
39
|
+
import "./token-goat-chunk-AM5V6GSX.mjs";
|
|
40
|
+
import "./token-goat-chunk-FNFBKLRD.mjs";
|
|
41
|
+
import "./token-goat-chunk-VES7EL7O.mjs";
|
|
34
42
|
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
35
43
|
export {
|
|
36
44
|
MAX_LOCATE_CONTEXT_CHARS,
|