token-goat 2.9.28 → 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 +36 -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-66LODAUT.mjs → token-goat-chunk-4JJS54TR.mjs} +4 -3
- package/dist/token-goat-chunk-4LCCNRTG.mjs +313 -0
- package/dist/token-goat-chunk-54K3EUV3.mjs +35 -0
- 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-NILVK7XM.mjs → token-goat-chunk-64FBPDTK.mjs} +12 -6
- package/dist/{token-goat-chunk-LEG3JNJ6.mjs → token-goat-chunk-664RTTUV.mjs} +31 -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-F7QZRIWM.mjs → token-goat-chunk-7F2UBPD3.mjs} +42 -35
- package/dist/{token-goat-chunk-CC2PYJM7.mjs → token-goat-chunk-7IN2MKDS.mjs} +718 -595
- package/dist/token-goat-chunk-7NADEDKJ.mjs +124 -0
- package/dist/{token-goat-chunk-6SGLIPQB.mjs → token-goat-chunk-A3CK6N5Z.mjs} +621 -72
- package/dist/{token-goat-chunk-HXNAC4ZF.mjs → token-goat-chunk-AFLYLHDH.mjs} +48 -33
- package/dist/token-goat-chunk-AM5V6GSX.mjs +367 -0
- package/dist/{token-goat-chunk-I7CB3X4K.mjs → token-goat-chunk-APGZXSPS.mjs} +44 -148
- package/dist/{token-goat-chunk-BJBRGPBX.mjs → token-goat-chunk-ARDNEC2U.mjs} +11 -7
- package/dist/token-goat-chunk-ATCPY7EQ.mjs +134 -0
- package/dist/token-goat-chunk-B2RZZCSS.mjs +354 -0
- package/dist/{token-goat-chunk-QM76S6YS.mjs → token-goat-chunk-B45VMIIH.mjs} +6 -5
- package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
- package/dist/{token-goat-chunk-GGLEE35R.mjs → token-goat-chunk-C63JQV5K.mjs} +49 -10
- package/dist/{token-goat-chunk-RJH64KQH.mjs → token-goat-chunk-COBQGL5S.mjs} +2661 -2440
- package/dist/token-goat-chunk-COTXZHTS.mjs +39 -0
- package/dist/token-goat-chunk-CYCEYAEO.mjs +265 -0
- package/dist/token-goat-chunk-CZ3LUXYZ.mjs +4115 -0
- package/dist/token-goat-chunk-DZX2YDPT.mjs +15 -0
- 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-6Z5ULNE5.mjs → token-goat-chunk-FBNQNSJK.mjs} +2490 -4957
- package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
- package/dist/{token-goat-chunk-XI2VFAV6.mjs → token-goat-chunk-FZ3NEW5O.mjs} +33 -19
- package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
- package/dist/{token-goat-chunk-VE27HPIF.mjs → token-goat-chunk-GFBSN7BD.mjs} +30 -398
- package/dist/{token-goat-chunk-L45ZQRT7.mjs → token-goat-chunk-GOLEOXZP.mjs} +780 -786
- 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-CBMY2FGI.mjs → token-goat-chunk-HOJLCGDP.mjs} +17113 -15554
- package/dist/{token-goat-chunk-HUDC5GS5.mjs → token-goat-chunk-HYBFA5X3.mjs} +120 -19
- package/dist/token-goat-chunk-IVALLT3S.mjs +48 -0
- package/dist/token-goat-chunk-IVE6U7KV.mjs +53 -0
- package/dist/{token-goat-chunk-UBUKHVYW.mjs → token-goat-chunk-IVKIZWAB.mjs} +3 -3
- package/dist/{token-goat-chunk-4JMWPWCS.mjs → token-goat-chunk-JB6QN6VF.mjs} +6 -4
- package/dist/{token-goat-chunk-Q4S3UQGO.mjs → token-goat-chunk-JDHE26RP.mjs} +10 -3
- package/dist/{token-goat-chunk-7R2XYKC5.mjs → token-goat-chunk-JDU3EXSU.mjs} +14 -10
- package/dist/token-goat-chunk-JDWCRD6M.mjs +253 -0
- package/dist/{token-goat-chunk-XBESNWEX.mjs → token-goat-chunk-JN4XMLSD.mjs} +7 -4
- 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-4RN64ZND.mjs → token-goat-chunk-KWPNJBDH.mjs} +28 -3
- package/dist/token-goat-chunk-LOBGHXPB.mjs +242 -0
- package/dist/token-goat-chunk-MKPF4CL5.mjs +37 -0
- package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
- package/dist/{token-goat-chunk-YWSP6IU7.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-VWZKZPSR.mjs → token-goat-chunk-PU7V3FD6.mjs} +8752 -11098
- package/dist/token-goat-chunk-PY533T7F.mjs +46 -0
- package/dist/token-goat-chunk-Q5VTGRH7.mjs +761 -0
- package/dist/{token-goat-chunk-IHKZ3QNA.mjs → token-goat-chunk-QCLDAQTS.mjs} +33 -19
- package/dist/{token-goat-chunk-LKSXAMJB.mjs → token-goat-chunk-QSBRTGM2.mjs} +9 -2
- package/dist/{token-goat-chunk-4STDIGYC.mjs → token-goat-chunk-RC35RBUL.mjs} +7 -5
- package/dist/{token-goat-chunk-D5ICEPSB.mjs → token-goat-chunk-RHXKCZX3.mjs} +887 -507
- package/dist/{token-goat-chunk-RSS3TLXU.mjs → token-goat-chunk-RZRTDST7.mjs} +17 -7
- package/dist/{token-goat-chunk-MAMQPC43.mjs → token-goat-chunk-SJHWVNDQ.mjs} +15 -21
- package/dist/token-goat-chunk-SMVRN2HU.mjs +188 -0
- package/dist/{token-goat-chunk-EL7M26WP.mjs → token-goat-chunk-SQSSNQPE.mjs} +2100 -1442
- package/dist/{token-goat-chunk-OZRSREKR.mjs → token-goat-chunk-T4FK7VOV.mjs} +3 -3
- package/dist/token-goat-chunk-U4N3BN2W.mjs +92 -0
- package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
- package/dist/{token-goat-chunk-XKY4VKJ4.mjs → token-goat-chunk-UQ5UK2T7.mjs} +15 -4
- package/dist/token-goat-chunk-USILZ3T3.mjs +53 -0
- package/dist/token-goat-chunk-VES7EL7O.mjs +205 -0
- package/dist/{token-goat-chunk-M56BWPBN.mjs → token-goat-chunk-VL3YIFHZ.mjs} +550 -49
- package/dist/{token-goat-chunk-IZXKVT4A.mjs → token-goat-chunk-VPBBTSJR.mjs} +362 -128
- package/dist/{token-goat-chunk-F2ARFHLJ.mjs → token-goat-chunk-W3QCJS6G.mjs} +10 -2
- package/dist/{token-goat-chunk-FSTWAOW6.mjs → token-goat-chunk-WY3L4DVT.mjs} +11 -5
- package/dist/{token-goat-chunk-OSUFN2FV.mjs → token-goat-chunk-XB5KKOCG.mjs} +5 -25
- package/dist/token-goat-chunk-XKI4SEMX.mjs +66 -0
- package/dist/token-goat-chunk-XU4P6Z24.mjs +133 -0
- package/dist/{token-goat-chunk-6CCQDAYY.mjs → token-goat-chunk-Y776AENC.mjs} +138 -33
- package/dist/token-goat-chunk-YARZFCZS.mjs +359 -0
- package/dist/{token-goat-chunk-EEIDFMEM.mjs → token-goat-chunk-YZAAZU2S.mjs} +12 -3
- package/dist/{token-goat-chunk-E3K3BTEQ.mjs → token-goat-chunk-Z44YO3QZ.mjs} +12 -6
- package/dist/token-goat-chunk-Z57YODA2.mjs +35 -0
- package/dist/{token-goat-chunk-DA43OE7L.mjs → token-goat-chunk-ZCDTCVIS.mjs} +49 -30
- 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-SJEKA7Y2.mjs → token-goat-chunk-ZQSJMO2R.mjs} +381 -201
- package/dist/token-goat-hook-client.cjs +539 -0
- package/dist/token-goat-hook-client.mjs +26 -0
- package/dist/token-goat-hook.mjs +48 -28
- package/dist/token-goat.core.mjs +10 -45
- package/docs/C4_RUNTIME_ARCHITECTURE.md +3 -3
- package/docs/cli.md +82 -47
- package/docs/install.md +58 -23
- package/docs/security.md +7 -7
- package/package.json +17 -7
- package/scripts/verify-native-dist.mjs +386 -0
- package/dist/token-goat-chunk-4JJBFT7V.mjs +0 -20
- package/dist/token-goat-chunk-5NNYIUGV.mjs +0 -143
- package/dist/token-goat-chunk-6DQNNFJ6.mjs +0 -294
- package/dist/token-goat-chunk-7MAFDRVR.mjs +0 -47
- package/dist/token-goat-chunk-BCN2YQC6.mjs +0 -32
- package/dist/token-goat-chunk-D7GHQKQD.mjs +0 -30
- package/dist/token-goat-chunk-GMOUBOX4.mjs +0 -386
- package/dist/token-goat-chunk-IFORDBGC.mjs +0 -192
- package/dist/token-goat-chunk-JXK2HQXS.mjs +0 -318
- package/dist/token-goat-chunk-L7SDVGBT.mjs +0 -430
- package/dist/token-goat-chunk-MMLMALWK.mjs +0 -1381
- package/dist/token-goat-chunk-MVSWBNMD.mjs +0 -1985
|
@@ -1,30 +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-MMLMALWK.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
|
-
|
|
20
|
-
|
|
21
|
-
isInsideRoot
|
|
22
|
-
} from "./token-goat-chunk-L45ZQRT7.mjs";
|
|
21
|
+
registerReset
|
|
22
|
+
} from "./token-goat-chunk-YZAAZU2S.mjs";
|
|
23
23
|
import {
|
|
24
24
|
displaySafeText,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} from "./token-goat-chunk-
|
|
25
|
+
neutralizeOutsideFences,
|
|
26
|
+
resolveToolPath
|
|
27
|
+
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
28
28
|
import {
|
|
29
29
|
init_define_import_meta_env
|
|
30
30
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -34,6 +34,148 @@ init_define_import_meta_env();
|
|
|
34
34
|
|
|
35
35
|
// src/copilot_mcp_names.ts
|
|
36
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
|
|
37
179
|
var _cached = null;
|
|
38
180
|
function copilotMcpToolNameMap() {
|
|
39
181
|
if (_cached) return _cached;
|
|
@@ -52,6 +194,34 @@ function copilotMcpToolNameMap() {
|
|
|
52
194
|
function canonicalizeCopilotMcpToolName(toolName) {
|
|
53
195
|
return copilotMcpToolNameMap().get(toolName) ?? toolName;
|
|
54
196
|
}
|
|
197
|
+
function resetCopilotMcpToolNameCache() {
|
|
198
|
+
_cached = null;
|
|
199
|
+
}
|
|
200
|
+
registerReset(resetCopilotMcpToolNameCache, { perRequest: true });
|
|
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
|
+
}
|
|
55
225
|
|
|
56
226
|
// src/hooks_cli.ts
|
|
57
227
|
var _LOG = {
|
|
@@ -144,14 +314,12 @@ var GEMINI_TOOL_NAME_MAP = {
|
|
|
144
314
|
grep_search: "Grep",
|
|
145
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.
|
|
146
316
|
search_file_content: "Grep",
|
|
147
|
-
// 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.
|
|
148
|
-
// 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.
|
|
149
318
|
google_web_search: "WebSearch",
|
|
150
319
|
web_fetch: "WebFetch"
|
|
151
320
|
};
|
|
152
321
|
var GEMINI_INPUT_KEY_MAP = {
|
|
153
|
-
// 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.
|
|
154
|
-
// '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.
|
|
155
323
|
Read: { dir_path: "file_path" },
|
|
156
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.
|
|
157
325
|
Grep: { dir_path: "path" }
|
|
@@ -219,7 +387,12 @@ var VSCODE_TOOL_NAME_MAP = {
|
|
|
219
387
|
replace_string_in_file: "Edit",
|
|
220
388
|
insert_edit_into_file: "Edit",
|
|
221
389
|
edit_notebook_file: "NotebookEdit",
|
|
222
|
-
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"
|
|
223
396
|
};
|
|
224
397
|
var VSCODE_INPUT_KEY_MAP = {
|
|
225
398
|
read_file: { filePath: "file_path" },
|
|
@@ -231,7 +404,52 @@ var VSCODE_INPUT_KEY_MAP = {
|
|
|
231
404
|
replace_string_in_file: { filePath: "file_path", oldString: "old_string", newString: "new_string" },
|
|
232
405
|
insert_edit_into_file: { filePath: "file_path" },
|
|
233
406
|
edit_notebook_file: { filePath: "notebook_path" },
|
|
234
|
-
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"]
|
|
235
453
|
};
|
|
236
454
|
var VSCODE_TOOL_NAME_KEY = "_tg_vscode_tool_name";
|
|
237
455
|
function vscodeNativeToolInput(vscodeToolName, canonicalInput) {
|
|
@@ -239,8 +457,63 @@ function vscodeNativeToolInput(vscodeToolName, canonicalInput) {
|
|
|
239
457
|
for (const [nativeKey, canonicalKey] of Object.entries(ownGet(VSCODE_INPUT_KEY_MAP, vscodeToolName) ?? {})) {
|
|
240
458
|
inverse[canonicalKey] = nativeKey;
|
|
241
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
|
+
}
|
|
242
499
|
return remapInputKeys(canonicalInput, inverse);
|
|
243
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
|
+
}
|
|
244
517
|
function remapInputKeys(input, keyMap) {
|
|
245
518
|
const newInput = {};
|
|
246
519
|
for (const [k, v] of Object.entries(input)) {
|
|
@@ -298,7 +571,7 @@ function normalizePayload(payload, harness = "claude") {
|
|
|
298
571
|
return {};
|
|
299
572
|
}
|
|
300
573
|
const rawObj = payload;
|
|
301
|
-
const obj = harness === "grok" ? grokToCanonicalWire(rawObj) : rawObj;
|
|
574
|
+
const obj = harness === "grok" ? grokToCanonicalWire(rawObj) : harness === "antigravity" ? antigravityToCanonicalWire(rawObj) : rawObj;
|
|
302
575
|
const toolName = obj["tool_name"];
|
|
303
576
|
if (typeof toolName !== "string" || !toolName.trim()) {
|
|
304
577
|
_LOG.debug("normalizePayload: tool_name missing or invalid; received %s", toolName);
|
|
@@ -315,6 +588,11 @@ function normalizePayload(payload, harness = "claude") {
|
|
|
315
588
|
if (mapped) {
|
|
316
589
|
result2["tool_name"] = mapped;
|
|
317
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
|
+
}
|
|
318
596
|
result2["_tg_harness"] = harness;
|
|
319
597
|
return result2;
|
|
320
598
|
}
|
|
@@ -331,12 +609,27 @@ function normalizePayload(payload, harness = "claude") {
|
|
|
331
609
|
const keyMap = ownGet(VSCODE_INPUT_KEY_MAP, toolName) ?? ownGet(VSCODE_INPUT_KEY_MAP, mapped);
|
|
332
610
|
const rawInput = obj["tool_input"];
|
|
333
611
|
if (keyMap && typeof rawInput === "object" && rawInput !== null && !Array.isArray(rawInput)) {
|
|
334
|
-
|
|
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) };
|
|
335
615
|
}
|
|
336
616
|
result2[VSCODE_TOOL_NAME_KEY] = toolName;
|
|
337
617
|
result2["_tg_harness"] = harness;
|
|
338
618
|
return result2;
|
|
339
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
|
+
}
|
|
340
633
|
if (harness === "kimi") {
|
|
341
634
|
const result2 = remapToolName(obj, toolName, KIMI_TOOL_NAME_MAP, KIMI_INPUT_KEY_MAP);
|
|
342
635
|
result2["_tg_harness"] = harness;
|
|
@@ -367,52 +660,6 @@ function normalizePayload(payload, harness = "claude") {
|
|
|
367
660
|
return result;
|
|
368
661
|
}
|
|
369
662
|
|
|
370
|
-
// src/hint_suggestion_guard.ts
|
|
371
|
-
init_define_import_meta_env();
|
|
372
|
-
function looksLikeSuggestion(slice) {
|
|
373
|
-
return slice.includes('"');
|
|
374
|
-
}
|
|
375
|
-
var SAFE_OUTSIDE_QUOTES = /^[A-Za-z0-9 \t_./=:,@+-]*$/;
|
|
376
|
-
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;
|
|
377
|
-
function suggestionIsUnsafe(slice) {
|
|
378
|
-
if (slice.includes("$") || slice.includes("\n") || slice.includes("\r") || slice.includes("`")) return true;
|
|
379
|
-
if (CONTROL_OR_BIDI.test(slice)) return true;
|
|
380
|
-
const regions = slice.split('"');
|
|
381
|
-
if (regions.length % 2 === 0) return true;
|
|
382
|
-
for (let i = 2; i < regions.length; i += 2) {
|
|
383
|
-
if (!SAFE_OUTSIDE_QUOTES.test(regions[i] ?? "")) return true;
|
|
384
|
-
}
|
|
385
|
-
return false;
|
|
386
|
-
}
|
|
387
|
-
var OMITTED = "token-goat (command omitted: the path contains shell metacharacters)";
|
|
388
|
-
function stripUnsafeSuggestions(text) {
|
|
389
|
-
if (!text.includes("token-goat ")) return text;
|
|
390
|
-
let out = "";
|
|
391
|
-
let at = 0;
|
|
392
|
-
for (; ; ) {
|
|
393
|
-
const start = text.indexOf("token-goat ", at);
|
|
394
|
-
if (start === -1) return out + text.slice(at);
|
|
395
|
-
const lineBreak = text.slice(start).search(/[\r\n]/);
|
|
396
|
-
const line = lineBreak === -1 ? text.slice(start) : text.slice(start, start + lineBreak);
|
|
397
|
-
const firstTick = line.indexOf("`");
|
|
398
|
-
const narrow = firstTick === -1 ? line : line.slice(0, firstTick);
|
|
399
|
-
out += text.slice(at, start);
|
|
400
|
-
if (!looksLikeSuggestion(narrow) || !suggestionIsUnsafe(narrow)) {
|
|
401
|
-
out += narrow;
|
|
402
|
-
at = start + narrow.length;
|
|
403
|
-
continue;
|
|
404
|
-
}
|
|
405
|
-
const lastTick = line.lastIndexOf("`");
|
|
406
|
-
const wide = lastTick === -1 ? line : line.slice(0, lastTick);
|
|
407
|
-
out += OMITTED;
|
|
408
|
-
at = start + wide.length;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
function leadWithCommand(command, purpose = "", reason = "") {
|
|
412
|
-
const tail = reason.trim();
|
|
413
|
-
return "Run `" + command + "`" + (purpose === "" ? "" : " " + purpose) + "." + (tail === "" ? "" : (tail.includes("`") ? "\n" : " ") + tail);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
663
|
// src/hooks_common.ts
|
|
417
664
|
init_define_import_meta_env();
|
|
418
665
|
function getToolName(event) {
|
|
@@ -423,9 +670,26 @@ function getToolInput(event) {
|
|
|
423
670
|
}
|
|
424
671
|
function getFilePath(event) {
|
|
425
672
|
const value = event.toolInput["file_path"];
|
|
426
|
-
if (typeof value === "string" && value !== "") return value;
|
|
673
|
+
if (typeof value === "string" && value !== "") return resolveEventPath(event, value);
|
|
427
674
|
const notebookValue = event.toolInput["notebook_path"];
|
|
428
|
-
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;
|
|
429
693
|
}
|
|
430
694
|
function getCwd(event) {
|
|
431
695
|
const value = event.raw && typeof event.raw === "object" ? event.raw["cwd"] : void 0;
|
|
@@ -440,15 +704,15 @@ function extractToolResponseField(raw, keys) {
|
|
|
440
704
|
if (typeof resp === "string") return resp;
|
|
441
705
|
if (resp !== null && typeof resp === "object") {
|
|
442
706
|
const r = resp;
|
|
443
|
-
const
|
|
444
|
-
if (
|
|
707
|
+
const path3 = resolveToolResponseFieldPath(r, keys);
|
|
708
|
+
if (path3 !== null) return readAtPath(r, path3);
|
|
445
709
|
}
|
|
446
710
|
return "";
|
|
447
711
|
}
|
|
448
712
|
var NESTED_TOOL_RESPONSE_PATHS = [["file", "content"]];
|
|
449
|
-
function readAtPath(resp,
|
|
713
|
+
function readAtPath(resp, path3) {
|
|
450
714
|
let cur = resp;
|
|
451
|
-
for (const seg of
|
|
715
|
+
for (const seg of path3) {
|
|
452
716
|
if (cur === null || typeof cur !== "object") return "";
|
|
453
717
|
cur = cur[seg];
|
|
454
718
|
}
|
|
@@ -458,25 +722,25 @@ function resolveToolResponseFieldPath(resp, keys) {
|
|
|
458
722
|
for (const key of keys) {
|
|
459
723
|
if (typeof resp[key] === "string" && resp[key] !== "") return [key];
|
|
460
724
|
}
|
|
461
|
-
for (const
|
|
462
|
-
if (readAtPath(resp,
|
|
725
|
+
for (const path3 of NESTED_TOOL_RESPONSE_PATHS) {
|
|
726
|
+
if (readAtPath(resp, path3) !== "") return path3;
|
|
463
727
|
}
|
|
464
728
|
return null;
|
|
465
729
|
}
|
|
466
730
|
function replaceToolResponseField(resp, keys, newText) {
|
|
467
|
-
const
|
|
468
|
-
if (
|
|
731
|
+
const path3 = resolveToolResponseFieldPath(resp, keys);
|
|
732
|
+
if (path3 === null) return null;
|
|
469
733
|
const root = { ...resp };
|
|
470
734
|
let cur = root;
|
|
471
|
-
for (let i = 0; i <
|
|
472
|
-
const seg =
|
|
735
|
+
for (let i = 0; i < path3.length - 1; i++) {
|
|
736
|
+
const seg = path3[i];
|
|
473
737
|
const child = cur[seg];
|
|
474
738
|
if (child === null || typeof child !== "object") return null;
|
|
475
739
|
const cloned = { ...child };
|
|
476
740
|
cur[seg] = cloned;
|
|
477
741
|
cur = cloned;
|
|
478
742
|
}
|
|
479
|
-
cur[
|
|
743
|
+
cur[path3[path3.length - 1]] = newText;
|
|
480
744
|
return root;
|
|
481
745
|
}
|
|
482
746
|
var OUTPUT_FIRST_TOOL_RESPONSE_KEYS = ["output", "content", "text", "body", "stdout", "stderr"];
|
|
@@ -583,6 +847,10 @@ function emitRewriteIfChanged(original, emitted, detail) {
|
|
|
583
847
|
if (emitted === original) return passOutput();
|
|
584
848
|
return emitRewrite(emitted, detail);
|
|
585
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
|
+
}
|
|
586
854
|
function countNonEmptyLines(text) {
|
|
587
855
|
return text.split(/\r\n|\r|\n/).filter((line) => line.length > 0).length;
|
|
588
856
|
}
|
|
@@ -636,52 +904,16 @@ function makeDedupHintHandlers(opts) {
|
|
|
636
904
|
return { post, pre };
|
|
637
905
|
}
|
|
638
906
|
|
|
639
|
-
// src/vscode_path_gate.ts
|
|
640
|
-
init_define_import_meta_env();
|
|
641
|
-
import * as path from "node:path";
|
|
642
|
-
function resolvesToUncPath(target, cwd) {
|
|
643
|
-
try {
|
|
644
|
-
return isUncOrDevicePath(path.resolve(cwd ?? process.cwd(), target));
|
|
645
|
-
} catch {
|
|
646
|
-
return false;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
function vscodePathAllowed(filePath, workspace) {
|
|
650
|
-
if (isUncOrDevicePath(filePath)) return false;
|
|
651
|
-
if (workspace === void 0 || isUncOrDevicePath(workspace)) return false;
|
|
652
|
-
const resolvedRoot = path.resolve(workspace);
|
|
653
|
-
const resolvedTarget = path.resolve(workspace, filePath);
|
|
654
|
-
const root = foldPathForContainment(resolvedRoot.replace(/\\/g, "/"));
|
|
655
|
-
const target = foldPathForContainment(resolvedTarget.replace(/\\/g, "/"));
|
|
656
|
-
if (target !== root && !target.startsWith(root.endsWith("/") ? root : root + "/")) return false;
|
|
657
|
-
return isInsideRoot(resolvedTarget, resolvedRoot);
|
|
658
|
-
}
|
|
659
|
-
function isVscodeEvent(event) {
|
|
660
|
-
return event.raw["_tg_harness"] === "vscode" || event.raw[VSCODE_TOOL_NAME_KEY] !== void 0;
|
|
661
|
-
}
|
|
662
|
-
function preToolPathDeclined(event, target) {
|
|
663
|
-
if (target === void 0) return false;
|
|
664
|
-
const cwd = getCwd(event);
|
|
665
|
-
if (isUncOrDevicePath(target) || resolvesToUncPath(target, cwd)) return true;
|
|
666
|
-
if (isVscodeEvent(event)) return !vscodePathAllowed(target, cwd);
|
|
667
|
-
return escapesOntoNetworkThroughLinks(target, cwd);
|
|
668
|
-
}
|
|
669
|
-
function commandPathIsTouchable(filePath, event) {
|
|
670
|
-
if (event === void 0) return !escapesOntoNetworkThroughLinks(filePath);
|
|
671
|
-
return !preToolPathDeclined(event, filePath);
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
// src/delivering_deny.ts
|
|
675
|
-
init_define_import_meta_env();
|
|
676
|
-
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/;
|
|
677
|
-
|
|
678
907
|
export {
|
|
679
908
|
getToolName,
|
|
680
909
|
getToolInput,
|
|
681
910
|
getFilePath,
|
|
911
|
+
resolveEventPath,
|
|
912
|
+
getFilePaths,
|
|
682
913
|
getCwd,
|
|
683
914
|
getTranscriptPath,
|
|
684
915
|
extractToolResponseField,
|
|
916
|
+
resolveToolResponseFieldPath,
|
|
685
917
|
replaceToolResponseField,
|
|
686
918
|
OUTPUT_FIRST_TOOL_RESPONSE_KEYS,
|
|
687
919
|
BODY_FIRST_TOOL_RESPONSE_KEYS,
|
|
@@ -695,17 +927,19 @@ export {
|
|
|
695
927
|
contextOutput,
|
|
696
928
|
emitRewrite,
|
|
697
929
|
emitRewriteIfChanged,
|
|
930
|
+
emitRewriteWithContext,
|
|
698
931
|
estimateResultCount,
|
|
699
932
|
structuredResultCount,
|
|
700
933
|
makeDedupHintHandlers,
|
|
934
|
+
copilotCliUserRoot,
|
|
935
|
+
copilotCliMcpToolsDir,
|
|
936
|
+
readCopilotMcpTools,
|
|
937
|
+
COPILOT_CLI_TOOL_NAME_MAP,
|
|
938
|
+
foldToolName,
|
|
701
939
|
GEMINI_TOOL_NAME_MAP,
|
|
702
940
|
VSCODE_TOOL_NAME_KEY,
|
|
703
941
|
vscodeNativeToolInput,
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
commandPathIsTouchable,
|
|
708
|
-
stripUnsafeSuggestions,
|
|
709
|
-
leadWithCommand,
|
|
710
|
-
DELIVERS_CONTENT_RE
|
|
942
|
+
ANTIGRAVITY_TOOL_NAME_KEY,
|
|
943
|
+
antigravityNativeToolInput,
|
|
944
|
+
normalizePayload
|
|
711
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,
|