@ev-ai/agent-hook 1.4.1 → 1.4.2

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.
@@ -864,10 +864,36 @@ var require_skill_source_redaction = __commonJS({
864
864
  var URL_CREDENTIAL_PARAM_RE = /([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi;
865
865
  var PRIVATE_KEY_BEGIN_RE = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/;
866
866
  var PRIVATE_KEY_END_RE = /-----END [A-Z0-9 ]*PRIVATE KEY-----/;
867
+ var ANY_CASE_REFERENCE_OR_PLACEHOLDER_RE = new RegExp(`^(?:${[
868
+ // Empty password, as in `https://user:@host`.
869
+ "",
870
+ // Shell `${VAR}` and PowerShell `$env:VAR`. No `${VAR:-default}`: the default is a literal.
871
+ String.raw`\$\{[A-Za-z_][A-Za-z0-9_]*\}`,
872
+ String.raw`\$env:[A-Za-z_][A-Za-z0-9_]*`,
873
+ // Template placeholders: `{{ token }}`, `{token}` or an f-string expression such as
874
+ // `{quote_plus(pwd)}`, `<password>`, `[password]` (and the redaction marker itself, so a
875
+ // second pass is a no-op). Angle and square brackets hold letters only.
876
+ String.raw`\{\{\s*[\w.-]+\s*\}\}`,
877
+ String.raw`\{[A-Za-z_][^{}\s]*\}`,
878
+ String.raw`<[A-Za-z][A-Za-z_-]*>`,
879
+ String.raw`\[[A-Za-z][A-Za-z_-]*\]`,
880
+ // Documentation stand-ins.
881
+ String.raw`(?:pass(?:word|wd)?|pwd|secret|token|x+|\*+)`
882
+ ].join("|")})$`, "i");
883
+ var UPPER_CASE_REFERENCE_OR_PLACEHOLDER_RE = new RegExp(`^(?:${[
884
+ // Shell `$VAR` and cmd `%VAR%`, written as environment variable names.
885
+ String.raw`\$[A-Z_][A-Z0-9_]*`,
886
+ String.raw`%[A-Z_][A-Z0-9_]*%`,
887
+ // Upper-case placeholder names that say what they stand for: `YOUR_API_KEY`, `ACCESS_TOKEN`.
888
+ String.raw`(?=[A-Z_]*(?:TOKEN|KEY|SECRET|PASSWORD|PASSWD|PASS|PWD|CREDENTIALS?|YOUR))[A-Z]+(?:_[A-Z]+)+`
889
+ ].join("|")})$`);
890
+ function isReferenceOrPlaceholder(value) {
891
+ return ANY_CASE_REFERENCE_OR_PLACEHOLDER_RE.test(value) || UPPER_CASE_REFERENCE_OR_PLACEHOLDER_RE.test(value);
892
+ }
867
893
  function redactLine(line) {
868
- let redacted = line.replace(URL_USERINFO_RE, (_match, scheme) => `${scheme}${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);
869
- redacted = redacted.replace(URL_CREDENTIAL_PARAM_RE, (_match, prefix) => `${prefix}${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);
870
- redacted = redacted.replace(BEARER_RE, (_match, prefix) => `${prefix}${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);
894
+ let redacted = line.replace(URL_USERINFO_RE, (match, scheme, _user, password) => isReferenceOrPlaceholder(password) ? match : `${scheme}${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);
895
+ redacted = redacted.replace(URL_CREDENTIAL_PARAM_RE, (match, prefix) => isReferenceOrPlaceholder(match.slice(prefix.length)) ? match : `${prefix}${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);
896
+ redacted = redacted.replace(BEARER_RE, (match, prefix) => isReferenceOrPlaceholder(match.slice(prefix.length)) ? match : `${prefix}${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);
871
897
  for (const pattern of TOKEN_LITERAL_RES) {
872
898
  redacted = redacted.replace(pattern, exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);
873
899
  }
@@ -901,13 +927,1006 @@ var require_skill_source_redaction = __commonJS({
901
927
  }
902
928
  });
903
929
 
930
+ // ../composition-identity/dist/json.js
931
+ var require_json = __commonJS({
932
+ "../composition-identity/dist/json.js"(exports) {
933
+ "use strict";
934
+ Object.defineProperty(exports, "__esModule", { value: true });
935
+ exports.isRecord = isRecord2;
936
+ function isRecord2(value) {
937
+ return value !== null && typeof value === "object" && !Array.isArray(value);
938
+ }
939
+ }
940
+ });
941
+
942
+ // ../composition-identity/dist/command-tokens.js
943
+ var require_command_tokens = __commonJS({
944
+ "../composition-identity/dist/command-tokens.js"(exports) {
945
+ "use strict";
946
+ Object.defineProperty(exports, "__esModule", { value: true });
947
+ exports.tokenizeCommand = tokenizeCommand3;
948
+ function tokenizeCommand3(command) {
949
+ const tokens = [];
950
+ let current = "";
951
+ let quote = null;
952
+ for (const char of command) {
953
+ if (quote) {
954
+ if (char === quote) {
955
+ quote = null;
956
+ } else {
957
+ current += char;
958
+ }
959
+ continue;
960
+ }
961
+ if (char === '"' || char === "'") {
962
+ quote = char;
963
+ continue;
964
+ }
965
+ if (/\s/.test(char)) {
966
+ if (current.length > 0) {
967
+ tokens.push(current);
968
+ current = "";
969
+ }
970
+ continue;
971
+ }
972
+ current += char;
973
+ }
974
+ if (current.length > 0) {
975
+ tokens.push(current);
976
+ }
977
+ return tokens;
978
+ }
979
+ }
980
+ });
981
+
982
+ // ../composition-identity/dist/home-path.js
983
+ var require_home_path = __commonJS({
984
+ "../composition-identity/dist/home-path.js"(exports) {
985
+ "use strict";
986
+ Object.defineProperty(exports, "__esModule", { value: true });
987
+ exports.tildePath = tildePath2;
988
+ exports.tildeHomeInText = tildeHomeInText2;
989
+ function posixPath(value) {
990
+ return value.replace(/\\/g, "/");
991
+ }
992
+ function homePosix(home) {
993
+ const n = posixPath(home).replace(/\/+$/, "");
994
+ return n.length <= 1 ? "" : n;
995
+ }
996
+ function isWindowsHome(home) {
997
+ return /^[A-Za-z]:/.test(home) || home.includes("\\");
998
+ }
999
+ function tildePath2(value, home) {
1000
+ const n = posixPath(value);
1001
+ if (n === "~" || n.startsWith("~/")) {
1002
+ return n;
1003
+ }
1004
+ const h = homePosix(home);
1005
+ if (!h) {
1006
+ return n;
1007
+ }
1008
+ const head = n.slice(0, h.length);
1009
+ const matches = isWindowsHome(home) ? head.toLowerCase() === h.toLowerCase() : head === h;
1010
+ if (!matches) {
1011
+ return n;
1012
+ }
1013
+ const rest = n.slice(h.length);
1014
+ if (rest === "") {
1015
+ return "~";
1016
+ }
1017
+ return rest.startsWith("/") ? `~${rest}` : n;
1018
+ }
1019
+ var homeTextPatterns = /* @__PURE__ */ new Map();
1020
+ function homeTextPattern(home) {
1021
+ const cached = homeTextPatterns.get(home);
1022
+ if (cached !== void 0) {
1023
+ return cached;
1024
+ }
1025
+ const h = homePosix(home);
1026
+ let pattern = null;
1027
+ if (h) {
1028
+ const body = h.split("/").map((segment) => segment.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("[\\\\/]+");
1029
+ pattern = new RegExp(`(?<![\\w.-])${body}(?![\\w.-])`, isWindowsHome(home) ? "gi" : "g");
1030
+ }
1031
+ homeTextPatterns.set(home, pattern);
1032
+ return pattern;
1033
+ }
1034
+ function tildeHomeInText2(value, home) {
1035
+ const pattern = homeTextPattern(home);
1036
+ return pattern ? value.replace(pattern, "~") : value;
1037
+ }
1038
+ }
1039
+ });
1040
+
1041
+ // ../composition-identity/dist/mcp-redaction.js
1042
+ var require_mcp_redaction = __commonJS({
1043
+ "../composition-identity/dist/mcp-redaction.js"(exports) {
1044
+ "use strict";
1045
+ Object.defineProperty(exports, "__esModule", { value: true });
1046
+ exports.ENABLED_RAW_KEYS = exports.TOOL_LIST_RAW_KEYS = exports.OMITTED_VALUE = void 0;
1047
+ exports.isSecretShapedValue = isSecretShapedValue;
1048
+ exports.isAuthHeaderName = isAuthHeaderName;
1049
+ exports.redactCommandOrUrl = redactCommandOrUrl3;
1050
+ exports.isAuthKeyName = isAuthKeyName;
1051
+ exports.redactArgs = redactArgs4;
1052
+ exports.mcpServerEnabledFromJson = mcpServerEnabledFromJson2;
1053
+ var json_js_1 = require_json();
1054
+ exports.OMITTED_VALUE = "<omitted>";
1055
+ exports.TOOL_LIST_RAW_KEYS = [
1056
+ { raw: "tools", attr: "tools" },
1057
+ { raw: "autoApprove", attr: "auto_approve" },
1058
+ { raw: "auto_approve", attr: "auto_approve" },
1059
+ { raw: "alwaysAllow", attr: "always_allow" },
1060
+ { raw: "always_allow", attr: "always_allow" },
1061
+ { raw: "enabledTools", attr: "enabled_tools" },
1062
+ { raw: "enabled_tools", attr: "enabled_tools" },
1063
+ { raw: "disabledTools", attr: "disabled_tools" },
1064
+ { raw: "disabled_tools", attr: "disabled_tools" }
1065
+ ];
1066
+ exports.ENABLED_RAW_KEYS = ["enabled", "disabled"];
1067
+ var AUTH_KEY_RE = /^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i;
1068
+ var AUTH_KEY_SEGMENT_RE = /(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i;
1069
+ var SECRET_ARG_RE = /^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/;
1070
+ var BEARER_ARG_RE = /^bearer(?:\s+|$)/i;
1071
+ function isSecretShapedValue(value) {
1072
+ return SECRET_ARG_RE.test(value) || BEARER_ARG_RE.test(value);
1073
+ }
1074
+ var HEADER_FLAG_RE = /^(?:--headers?|-H)$/;
1075
+ var HEADER_LINE_RE = /^\s*([A-Za-z0-9-]+)\s*:([\s\S]*)$/;
1076
+ var AUTH_HEADER_NAME_RE = /auth|cookie|token|secret|key|passw|credential|session|signature/i;
1077
+ var ENV_REF_VALUE_RE = /^(?:(?:bearer|basic|token)\s+)?\$(?:\{\w+\}|\w+)$/i;
1078
+ function isAuthHeaderName(name) {
1079
+ return AUTH_HEADER_NAME_RE.test(name);
1080
+ }
1081
+ function redactCommandOrUrl3(value) {
1082
+ try {
1083
+ const parsed = new URL(value);
1084
+ return `${parsed.origin}${parsed.pathname}`;
1085
+ } catch {
1086
+ return value;
1087
+ }
1088
+ }
1089
+ function redactSecretShapedValue(value) {
1090
+ if (isSecretShapedValue(value)) {
1091
+ return "<redacted>";
1092
+ }
1093
+ if (value.includes("://")) {
1094
+ return redactCommandOrUrl3(value);
1095
+ }
1096
+ return value;
1097
+ }
1098
+ function redactHeaderArg(value) {
1099
+ const match = HEADER_LINE_RE.exec(value);
1100
+ if (!match) {
1101
+ return redactArg(value);
1102
+ }
1103
+ const name = match[1] ?? "";
1104
+ const headerValue = (match[2] ?? "").trim();
1105
+ if (ENV_REF_VALUE_RE.test(headerValue)) {
1106
+ return value;
1107
+ }
1108
+ const secret = isAuthHeaderName(name) || isSecretShapedValue(headerValue);
1109
+ return secret ? `${name}: <redacted>` : value;
1110
+ }
1111
+ function redactArg(value) {
1112
+ if (/^https?:\/\//i.test(value)) {
1113
+ return redactCommandOrUrl3(value);
1114
+ }
1115
+ const eq = value.indexOf("=");
1116
+ if (eq > 0) {
1117
+ const key = value.slice(0, eq);
1118
+ const rest = value.slice(eq + 1);
1119
+ return `${key}=${HEADER_FLAG_RE.test(key) ? redactHeaderArg(rest) : redactArg(rest)}`;
1120
+ }
1121
+ return redactSecretShapedValue(value);
1122
+ }
1123
+ function isAuthKeyName(key) {
1124
+ return AUTH_KEY_RE.test(key) || AUTH_KEY_SEGMENT_RE.test(key);
1125
+ }
1126
+ function authArgKey(value) {
1127
+ const key = value.replace(/^-+/, "").split("=", 1)[0] ?? "";
1128
+ return isAuthKeyName(key);
1129
+ }
1130
+ function redactArgs4(values) {
1131
+ const sanitized = [];
1132
+ let redactNext = false;
1133
+ let headerNext = false;
1134
+ for (const value of values) {
1135
+ if (redactNext) {
1136
+ sanitized.push("<redacted>");
1137
+ redactNext = false;
1138
+ continue;
1139
+ }
1140
+ if (headerNext) {
1141
+ headerNext = false;
1142
+ if (HEADER_LINE_RE.test(value)) {
1143
+ sanitized.push(redactHeaderArg(value));
1144
+ continue;
1145
+ }
1146
+ }
1147
+ if (HEADER_FLAG_RE.test(value)) {
1148
+ sanitized.push(value);
1149
+ headerNext = true;
1150
+ continue;
1151
+ }
1152
+ if (authArgKey(value)) {
1153
+ sanitized.push("<redacted>");
1154
+ redactNext = !value.includes("=");
1155
+ continue;
1156
+ }
1157
+ sanitized.push(redactArg(value));
1158
+ }
1159
+ return sanitized;
1160
+ }
1161
+ function mcpServerEnabledFromJson2(server) {
1162
+ if (!(0, json_js_1.isRecord)(server)) {
1163
+ return true;
1164
+ }
1165
+ if (server.enabled === false) {
1166
+ return false;
1167
+ }
1168
+ return server.disabled !== true;
1169
+ }
1170
+ }
1171
+ });
1172
+
1173
+ // ../composition-identity/dist/mcp-config-file.js
1174
+ var require_mcp_config_file = __commonJS({
1175
+ "../composition-identity/dist/mcp-config-file.js"(exports) {
1176
+ "use strict";
1177
+ Object.defineProperty(exports, "__esModule", { value: true });
1178
+ exports.MCP_CONFIG_SERVER_KEY_TREATMENT = exports.MCP_CONFIG_VSCODE_INPUT_TABLE = exports.MCP_CONFIG_SANDBOX_TABLE = exports.MCP_CONFIG_TRANSPORT_TYPES = exports.REDACTED_VALUE = void 0;
1179
+ exports.sanitizeVariableReference = sanitizeVariableReference;
1180
+ exports.mcpConfigFormatOf = mcpConfigFormatOf2;
1181
+ exports.mcpConfigServersKey = mcpConfigServersKey2;
1182
+ exports.sanitizeMcpConfigFile = sanitizeMcpConfigFile2;
1183
+ var node_path_1 = __require("node:path");
1184
+ var command_tokens_js_1 = require_command_tokens();
1185
+ var home_path_js_1 = require_home_path();
1186
+ var json_js_1 = require_json();
1187
+ var mcp_redaction_js_1 = require_mcp_redaction();
1188
+ exports.REDACTED_VALUE = "<redacted>";
1189
+ exports.MCP_CONFIG_TRANSPORT_TYPES = /* @__PURE__ */ new Set([
1190
+ "stdio",
1191
+ "http",
1192
+ "sse",
1193
+ "ws",
1194
+ "sdk",
1195
+ "streamable-http",
1196
+ "streamableHttp",
1197
+ "local",
1198
+ "remote"
1199
+ ]);
1200
+ var AUTH_TABLE = {
1201
+ CLIENT_ID: "keep",
1202
+ CLIENT_SECRET: "secret",
1203
+ scopes: "string_list",
1204
+ redirectPort: "keep"
1205
+ // source-only
1206
+ };
1207
+ var OAUTH_TABLE = {
1208
+ clientId: "keep",
1209
+ client_id: "keep",
1210
+ clientSecret: "secret",
1211
+ client_secret: "secret",
1212
+ callbackPort: "keep",
1213
+ callback_port: "keep",
1214
+ // source-only
1215
+ callback_url: "url",
1216
+ // source-only
1217
+ redirectUri: "url",
1218
+ // source-only
1219
+ redirect_uri: "url",
1220
+ // source-only
1221
+ authServerMetadataUrl: "url",
1222
+ auth_server_metadata_url: "url",
1223
+ // source-only
1224
+ authorizationUrl: "url",
1225
+ tokenUrl: "url",
1226
+ issuer: "url",
1227
+ // source-only
1228
+ registrationUrl: "url",
1229
+ // source-only
1230
+ clientMetadataUrl: "url",
1231
+ // source-only
1232
+ scopes: { by: { string: "keep", array: "string_list" } },
1233
+ scope: "keep",
1234
+ // source-only
1235
+ oauthScopes: "string_list",
1236
+ // source-only
1237
+ audiences: "string_list",
1238
+ enabled: "keep",
1239
+ allowPrivateNetwork: "keep",
1240
+ // source-only
1241
+ authorizationResponseIssParameterSupported: "keep",
1242
+ // source-only
1243
+ tokenParamName: "keep"
1244
+ };
1245
+ exports.MCP_CONFIG_SANDBOX_TABLE = {
1246
+ filesystem: {
1247
+ object: {
1248
+ allowWrite: "path",
1249
+ denyRead: "path",
1250
+ denyWrite: "path"
1251
+ }
1252
+ },
1253
+ network: {
1254
+ object: {
1255
+ allowedDomains: "string_list",
1256
+ deniedDomains: "string_list"
1257
+ }
1258
+ }
1259
+ };
1260
+ var DEV_TABLE = {
1261
+ watch: "path",
1262
+ debug: { object: { type: "keep", debugpyPath: "path" } }
1263
+ };
1264
+ var REQUEST_OPTIONS_TABLE = {
1265
+ headers: "secret_map",
1266
+ proxy: "url",
1267
+ caBundlePath: "path",
1268
+ timeout: "keep",
1269
+ verifySsl: "keep",
1270
+ noProxy: "string_list",
1271
+ extraBodyProperties: "omit",
1272
+ clientCertificate: { object: { cert: "omit", key: "omit", passphrase: "secret" } }
1273
+ };
1274
+ var TIMEOUT_TABLE = { startup: "keep", catalog: "keep", execution: "keep" };
1275
+ var CODEX_TOOL_TABLE = { approval_mode: "keep", output_token_limit: "keep" };
1276
+ exports.MCP_CONFIG_VSCODE_INPUT_TABLE = {
1277
+ id: "keep",
1278
+ type: "keep",
1279
+ password: "keep",
1280
+ command: "keep",
1281
+ serverName: "keep",
1282
+ description: "omit",
1283
+ options: "omit",
1284
+ args: "omit",
1285
+ default: "secret"
1286
+ };
1287
+ var TRANSPORT_TABLE = {
1288
+ type: "transport_type",
1289
+ command: "command",
1290
+ args: "args",
1291
+ cwd: "path",
1292
+ env: "secret_map",
1293
+ url: "url",
1294
+ headers: "secret_map"
1295
+ };
1296
+ var TOOL_LIST_ALIASES = Object.fromEntries(mcp_redaction_js_1.TOOL_LIST_RAW_KEYS.map(({ raw }) => [raw, "tool_list"]));
1297
+ exports.MCP_CONFIG_SERVER_KEY_TREATMENT = {
1298
+ ...TOOL_LIST_ALIASES,
1299
+ // Identity / transport / enablement
1300
+ type: "transport_type",
1301
+ transportType: "keep",
1302
+ // source-only
1303
+ transport: { by: { string: "keep", object: { object: TRANSPORT_TABLE } } },
1304
+ disabled: "keep",
1305
+ enabled: "keep",
1306
+ required: "keep",
1307
+ remote: "keep",
1308
+ // source-only
1309
+ remoteConfigured: "keep",
1310
+ // source-only
1311
+ source: "keep",
1312
+ // source-only
1313
+ version: "keep",
1314
+ gallery: { by: { boolean: "keep", string: "url" } },
1315
+ description: "omit",
1316
+ name: "keep",
1317
+ serverName: "keep",
1318
+ // source-only
1319
+ faviconUrl: "url",
1320
+ // source-only
1321
+ sourceFile: "path",
1322
+ sourceSlug: "keep",
1323
+ environment_id: "keep",
1324
+ protocol: "keep",
1325
+ pool: "keep",
1326
+ codemode: "keep",
1327
+ trust: "keep",
1328
+ alwaysLoad: "keep",
1329
+ deferTools: "keep",
1330
+ // source-only
1331
+ supports_parallel_tool_calls: "keep",
1332
+ tool_input_schema_max_bytes: "keep",
1333
+ startup_readiness: "keep",
1334
+ extension: "omit",
1335
+ // source-only
1336
+ metadata: "omit",
1337
+ // source-only
1338
+ settings: "omit",
1339
+ // source-only
1340
+ // stdio / process
1341
+ command: {
1342
+ by: {
1343
+ string: "command",
1344
+ array: "args",
1345
+ // Zed legacy `command: { path, args, env }`.
1346
+ object: { object: { path: "command", args: "args", env: "secret_map" } }
1347
+ }
1348
+ },
1349
+ args: "args",
1350
+ env: "secret_map",
1351
+ environment: "secret_map",
1352
+ env_vars: {
1353
+ list: {
1354
+ by: { string: "env_name", object: { object: { name: "env_name", source: "keep" } } }
1355
+ }
1356
+ },
1357
+ envVars: "secret_map",
1358
+ envFile: "path",
1359
+ cwd: "path",
1360
+ watchPaths: "path",
1361
+ dev: { object: DEV_TABLE },
1362
+ sandboxEnabled: "keep",
1363
+ sandbox: { object: exports.MCP_CONFIG_SANDBOX_TABLE },
1364
+ // Remote / HTTP
1365
+ url: "url",
1366
+ serverUrl: "url",
1367
+ httpUrl: "url",
1368
+ // Google Antigravity: load tools at startup, and per-server request timeout.
1369
+ eager: "keep",
1370
+ timeoutSeconds: "keep",
1371
+ tcp: "url",
1372
+ // source-only
1373
+ headers: "secret_map",
1374
+ http_headers: "secret_map",
1375
+ env_http_headers: "env_name_map",
1376
+ bearer_token_env_var: "env_name",
1377
+ headersHelper: "helper_command",
1378
+ http_headers_helper: "helper_command",
1379
+ apiKey: "secret",
1380
+ // source-only
1381
+ requestOptions: { object: REQUEST_OPTIONS_TABLE },
1382
+ // source-only
1383
+ auth: { by: { string: "mode", object: { object: AUTH_TABLE } } },
1384
+ oauth: { by: { boolean: "keep", object: { object: OAUTH_TABLE } } },
1385
+ oauthClientId: "keep",
1386
+ oauthClientSecret: "secret",
1387
+ oauthResource: "url",
1388
+ oauth_resource: "url",
1389
+ oauthScopes: "string_list",
1390
+ scopes: { by: { string: "keep", array: "string_list" } },
1391
+ oauthPublicClient: "keep",
1392
+ // source-only
1393
+ oauthGrantType: "keep",
1394
+ // source-only
1395
+ authProviderType: "keep",
1396
+ targetAudience: "keep",
1397
+ targetServiceAccount: "keep",
1398
+ // Tool filtering / approval
1399
+ tools: {
1400
+ by: {
1401
+ array: "tool_list",
1402
+ boolean: "tool_list",
1403
+ string: "tool_list",
1404
+ object: { map: { object: CODEX_TOOL_TABLE } }
1405
+ }
1406
+ },
1407
+ includeTools: "tool_list",
1408
+ excludeTools: "tool_list",
1409
+ omit_tools_from: "tool_list",
1410
+ default_tools_approval_mode: "keep",
1411
+ defaultToolsApprovalMode: "keep",
1412
+ // Timeouts
1413
+ timeout: { by: { number: "keep", object: { object: TIMEOUT_TABLE } } },
1414
+ startup_timeout_sec: "keep",
1415
+ startup_timeout_ms: "keep",
1416
+ tool_timeout_sec: "keep",
1417
+ connectionTimeout: "keep"
1418
+ // source-only
1419
+ };
1420
+ function shapeOf(value) {
1421
+ if (value === null) {
1422
+ return "null";
1423
+ }
1424
+ if (Array.isArray(value)) {
1425
+ return "array";
1426
+ }
1427
+ switch (typeof value) {
1428
+ case "string":
1429
+ return "string";
1430
+ case "number":
1431
+ return "number";
1432
+ case "boolean":
1433
+ return "boolean";
1434
+ case "object":
1435
+ return "object";
1436
+ default:
1437
+ return void 0;
1438
+ }
1439
+ }
1440
+ var ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
1441
+ var REFERENCE_PATTERNS = [
1442
+ /\$\{(?:env|input|command):[A-Za-z0-9_.-]+\}/y,
1443
+ /\$\{file:[^}\s]+\}/y,
1444
+ /\$\{\{\s*secrets\.[A-Za-z0-9_]+\s*\}\}/y,
1445
+ /\$\{\/\}/y,
1446
+ /\$\{[A-Za-z_][A-Za-z0-9_.]*\}/y,
1447
+ /\$[A-Z_][A-Z0-9_]*/y,
1448
+ /%[A-Z_][A-Z0-9_]*%/y,
1449
+ /\{(?:env:[A-Za-z_][A-Za-z0-9_]*|file:[^}\s]+)\}/y
1450
+ ];
1451
+ var DEFAULTED_REFERENCE = /\$\{([A-Za-z_][A-Za-z0-9_]*):-[^}]*\}/y;
1452
+ function referencesOnly(value) {
1453
+ let out = "";
1454
+ let index = 0;
1455
+ while (index < value.length) {
1456
+ DEFAULTED_REFERENCE.lastIndex = index;
1457
+ const defaulted = DEFAULTED_REFERENCE.exec(value);
1458
+ if (defaulted) {
1459
+ out += `\${${defaulted[1] ?? ""}:-${exports.REDACTED_VALUE}}`;
1460
+ index = DEFAULTED_REFERENCE.lastIndex;
1461
+ continue;
1462
+ }
1463
+ let matched = false;
1464
+ for (const pattern of REFERENCE_PATTERNS) {
1465
+ pattern.lastIndex = index;
1466
+ const match = pattern.exec(value);
1467
+ if (match) {
1468
+ out += match[0];
1469
+ index = pattern.lastIndex;
1470
+ matched = true;
1471
+ break;
1472
+ }
1473
+ }
1474
+ if (!matched) {
1475
+ return null;
1476
+ }
1477
+ }
1478
+ return out.length > 0 ? out : null;
1479
+ }
1480
+ function sanitizeVariableReference(value) {
1481
+ const scheme = /^(bearer|basic|token)(\s+)(.+)$/i.exec(value);
1482
+ if (scheme) {
1483
+ const rest = referencesOnly(scheme[3] ?? "");
1484
+ return rest === null ? null : `${scheme[1] ?? ""}${scheme[2] ?? ""}${rest}`;
1485
+ }
1486
+ return referencesOnly(value);
1487
+ }
1488
+ function tildeText(value, options) {
1489
+ return options.home ? (0, home_path_js_1.tildeHomeInText)(value, options.home) : value;
1490
+ }
1491
+ function containsSecretShapedToken(value) {
1492
+ return (0, mcp_redaction_js_1.isSecretShapedValue)(value) || value.split(/[\s=,;:'"]+/).some(mcp_redaction_js_1.isSecretShapedValue);
1493
+ }
1494
+ function keepString(value, options) {
1495
+ if (containsSecretShapedToken(value)) {
1496
+ return exports.REDACTED_VALUE;
1497
+ }
1498
+ if (value.includes("://")) {
1499
+ return sanitizeUrl(value, options);
1500
+ }
1501
+ return tildeText(value, options);
1502
+ }
1503
+ var MODE_WORD_RE = /^[A-Za-z][A-Za-z_-]{0,31}$/;
1504
+ function sanitizeMode(value) {
1505
+ if (typeof value !== "string") {
1506
+ return mcp_redaction_js_1.OMITTED_VALUE;
1507
+ }
1508
+ return MODE_WORD_RE.test(value) && !(0, mcp_redaction_js_1.isSecretShapedValue)(value) ? value : exports.REDACTED_VALUE;
1509
+ }
1510
+ function keepScalar(value, options) {
1511
+ if (typeof value === "string") {
1512
+ return keepString(value, options);
1513
+ }
1514
+ if (typeof value === "number") {
1515
+ return Number.isFinite(value) ? value : mcp_redaction_js_1.OMITTED_VALUE;
1516
+ }
1517
+ if (typeof value === "boolean" || value === null) {
1518
+ return value;
1519
+ }
1520
+ return mcp_redaction_js_1.OMITTED_VALUE;
1521
+ }
1522
+ function toolName(entry) {
1523
+ if (typeof entry !== "string") {
1524
+ return mcp_redaction_js_1.OMITTED_VALUE;
1525
+ }
1526
+ return /[\s=]/.test(entry) || containsSecretShapedToken(entry) ? exports.REDACTED_VALUE : entry;
1527
+ }
1528
+ function sanitizeToolList(value) {
1529
+ if (typeof value === "boolean") {
1530
+ return value;
1531
+ }
1532
+ if (typeof value === "string") {
1533
+ return toolName(value);
1534
+ }
1535
+ if (!Array.isArray(value)) {
1536
+ return mcp_redaction_js_1.OMITTED_VALUE;
1537
+ }
1538
+ return value.map((entry) => toolName(entry));
1539
+ }
1540
+ function sanitizeStringList(value, options) {
1541
+ if (!Array.isArray(value)) {
1542
+ return mcp_redaction_js_1.OMITTED_VALUE;
1543
+ }
1544
+ return value.map((entry) => typeof entry === "string" ? keepString(entry, options) : mcp_redaction_js_1.OMITTED_VALUE);
1545
+ }
1546
+ function isCredentialHeaderName(name) {
1547
+ return (0, mcp_redaction_js_1.isAuthHeaderName)(name) || (0, mcp_redaction_js_1.isAuthKeyName)(name);
1548
+ }
1549
+ var HEADER_LABEL_RE = /(^|[\s"'=,;])([A-Za-z][A-Za-z0-9_-]*)(\s*:\s*)/g;
1550
+ function redactCredentialHeaders(text) {
1551
+ let out = "";
1552
+ let cursor = 0;
1553
+ HEADER_LABEL_RE.lastIndex = 0;
1554
+ let match;
1555
+ while ((match = HEADER_LABEL_RE.exec(text)) !== null) {
1556
+ const name = match[2] ?? "";
1557
+ const valueStart = match.index + match[0].length;
1558
+ if (!isCredentialHeaderName(name)) {
1559
+ continue;
1560
+ }
1561
+ const quote = text.slice(valueStart).search(/["'\n]/);
1562
+ const valueEnd = quote === -1 ? text.length : valueStart + quote;
1563
+ const value = text.slice(valueStart, valueEnd).trim();
1564
+ if (value.length === 0) {
1565
+ continue;
1566
+ }
1567
+ out += text.slice(cursor, valueStart);
1568
+ out += sanitizeVariableReference(value) ?? exports.REDACTED_VALUE;
1569
+ cursor = valueEnd;
1570
+ HEADER_LABEL_RE.lastIndex = valueEnd;
1571
+ }
1572
+ return out + text.slice(cursor);
1573
+ }
1574
+ var AUTH_SCHEME_CREDENTIAL_RE = /\b(bearer|basic|token)(\s+)([^\s"']+)/gi;
1575
+ function hasLiteralAuthScheme(text) {
1576
+ for (const match of text.matchAll(AUTH_SCHEME_CREDENTIAL_RE)) {
1577
+ if (sanitizeVariableReference(match[3] ?? "") === null) {
1578
+ return true;
1579
+ }
1580
+ }
1581
+ return false;
1582
+ }
1583
+ function redactCredentialArg(value) {
1584
+ const headers = redactCredentialHeaders(value);
1585
+ return hasLiteralAuthScheme(headers) ? exports.REDACTED_VALUE : headers;
1586
+ }
1587
+ function redactCredentialCommandLine(value) {
1588
+ return redactCredentialHeaders(value).replace(AUTH_SCHEME_CREDENTIAL_RE, (whole, scheme, space, credential) => sanitizeVariableReference(credential) === null ? `${scheme}${space}${exports.REDACTED_VALUE}` : whole);
1589
+ }
1590
+ function joinCommandTokens(tokens) {
1591
+ return tokens.map((token) => {
1592
+ if (!/\s/.test(token)) {
1593
+ return token;
1594
+ }
1595
+ return token.includes('"') && !token.includes("'") ? `'${token}'` : `"${token}"`;
1596
+ }).join(" ");
1597
+ }
1598
+ function sanitizeCommand(value, options) {
1599
+ if (typeof value !== "string") {
1600
+ return mcp_redaction_js_1.OMITTED_VALUE;
1601
+ }
1602
+ const tokens = (0, command_tokens_js_1.tokenizeCommand)(redactCredentialCommandLine(value));
1603
+ if (tokens.length === 0) {
1604
+ return value;
1605
+ }
1606
+ return tildeText(joinCommandTokens((0, mcp_redaction_js_1.redactArgs)(tokens)), options);
1607
+ }
1608
+ function sanitizeHelperCommand(value, options) {
1609
+ if (typeof value === "string") {
1610
+ const reference = sanitizeVariableReference(value);
1611
+ if (reference !== null) {
1612
+ return reference;
1613
+ }
1614
+ const tokens = (0, command_tokens_js_1.tokenizeCommand)(value);
1615
+ const [executable] = tokens;
1616
+ if (executable === void 0) {
1617
+ return value;
1618
+ }
1619
+ const kept = sanitizeCommand(executable, options);
1620
+ return tokens.length > 1 ? `${String(kept)} ${exports.REDACTED_VALUE}` : kept;
1621
+ }
1622
+ if (Array.isArray(value)) {
1623
+ return value.map((entry, index) => index === 0 ? sanitizeCommand(entry, options) : exports.REDACTED_VALUE);
1624
+ }
1625
+ return mcp_redaction_js_1.OMITTED_VALUE;
1626
+ }
1627
+ function sanitizeArgs(value, options) {
1628
+ if (!Array.isArray(value)) {
1629
+ return mcp_redaction_js_1.OMITTED_VALUE;
1630
+ }
1631
+ const stringIndexes = [];
1632
+ const strings = [];
1633
+ value.forEach((entry, index) => {
1634
+ if (typeof entry === "string") {
1635
+ stringIndexes.push(index);
1636
+ strings.push(entry);
1637
+ }
1638
+ });
1639
+ const redacted = (0, mcp_redaction_js_1.redactArgs)(strings);
1640
+ const out = value.map(() => mcp_redaction_js_1.OMITTED_VALUE);
1641
+ stringIndexes.forEach((index, position) => {
1642
+ out[index] = tildeText(redactCredentialArg(redacted[position] ?? exports.REDACTED_VALUE), options);
1643
+ });
1644
+ return out;
1645
+ }
1646
+ function canParseUrl(value) {
1647
+ try {
1648
+ return new URL(value).href.length > 0;
1649
+ } catch {
1650
+ return false;
1651
+ }
1652
+ }
1653
+ function redactSecretPathSegments(value) {
1654
+ return value.split("/").map((segment) => containsSecretShapedToken(segment) ? exports.REDACTED_VALUE : segment).join("/");
1655
+ }
1656
+ function sanitizeUrl(value, options) {
1657
+ if (typeof value !== "string") {
1658
+ return mcp_redaction_js_1.OMITTED_VALUE;
1659
+ }
1660
+ const reference = sanitizeVariableReference(value);
1661
+ if (reference !== null) {
1662
+ return reference;
1663
+ }
1664
+ if (/^(?:unix|pipe):/i.test(value)) {
1665
+ const hash = value.indexOf("#");
1666
+ const beforeHash = hash === -1 ? value : value.slice(0, hash);
1667
+ const fragment = hash === -1 ? "" : value.slice(hash);
1668
+ const withoutQuery2 = beforeHash.split("?", 1)[0] ?? "";
1669
+ return tildeText(redactSecretPathSegments(`${withoutQuery2}${fragment}`), options);
1670
+ }
1671
+ if (/^(?:https?|wss?):/i.test(value) && canParseUrl(value)) {
1672
+ return redactSecretPathSegments((0, mcp_redaction_js_1.redactCommandOrUrl)(value));
1673
+ }
1674
+ const withoutQuery = value.split(/[?#]/, 1)[0] ?? "";
1675
+ const scheme = /^[A-Za-z][A-Za-z0-9+.-]*:\/\//.exec(withoutQuery)?.[0] ?? "";
1676
+ const afterScheme = withoutQuery.slice(scheme.length);
1677
+ const slash = afterScheme.indexOf("/");
1678
+ const authority = slash === -1 ? afterScheme : afterScheme.slice(0, slash);
1679
+ const at = authority.lastIndexOf("@");
1680
+ const cleaned = `${scheme}${at === -1 ? afterScheme : afterScheme.slice(at + 1)}`;
1681
+ return tildeText(redactSecretPathSegments(cleaned), options);
1682
+ }
1683
+ function sanitizeSecret(value) {
1684
+ if (value === null) {
1685
+ return null;
1686
+ }
1687
+ if (typeof value === "string") {
1688
+ return sanitizeVariableReference(value) ?? exports.REDACTED_VALUE;
1689
+ }
1690
+ return exports.REDACTED_VALUE;
1691
+ }
1692
+ function envName(value) {
1693
+ if (typeof value !== "string") {
1694
+ return mcp_redaction_js_1.OMITTED_VALUE;
1695
+ }
1696
+ return ENV_NAME_RE.test(value) && !(0, mcp_redaction_js_1.isSecretShapedValue)(value) ? value : exports.REDACTED_VALUE;
1697
+ }
1698
+ function sanitizeSecretMap(value) {
1699
+ if (Array.isArray(value)) {
1700
+ return value.map((entry) => {
1701
+ if (typeof entry !== "string") {
1702
+ return mcp_redaction_js_1.OMITTED_VALUE;
1703
+ }
1704
+ const eq = entry.indexOf("=");
1705
+ if (eq === -1) {
1706
+ return envName(entry);
1707
+ }
1708
+ const name = entry.slice(0, eq);
1709
+ if (envName(name) !== name) {
1710
+ return exports.REDACTED_VALUE;
1711
+ }
1712
+ return `${name}=${sanitizeVariableReference(entry.slice(eq + 1)) ?? exports.REDACTED_VALUE}`;
1713
+ });
1714
+ }
1715
+ if (!(0, json_js_1.isRecord)(value)) {
1716
+ return mcp_redaction_js_1.OMITTED_VALUE;
1717
+ }
1718
+ const out = {};
1719
+ for (const [key, entry] of Object.entries(value)) {
1720
+ out[key] = sanitizeSecret(entry);
1721
+ }
1722
+ return out;
1723
+ }
1724
+ function sanitizeEnvNameMap(value) {
1725
+ if (!(0, json_js_1.isRecord)(value)) {
1726
+ return mcp_redaction_js_1.OMITTED_VALUE;
1727
+ }
1728
+ const out = {};
1729
+ for (const [key, entry] of Object.entries(value)) {
1730
+ out[key] = envName(entry);
1731
+ }
1732
+ return out;
1733
+ }
1734
+ function pathString(value, options) {
1735
+ if (containsSecretShapedToken(value)) {
1736
+ return exports.REDACTED_VALUE;
1737
+ }
1738
+ return options.home ? (0, home_path_js_1.tildePath)(value, options.home) : value;
1739
+ }
1740
+ function sanitizePath(value, options) {
1741
+ if (typeof value === "string") {
1742
+ return pathString(value, options);
1743
+ }
1744
+ if (Array.isArray(value)) {
1745
+ return value.map((entry) => typeof entry === "string" ? pathString(entry, options) : mcp_redaction_js_1.OMITTED_VALUE);
1746
+ }
1747
+ return mcp_redaction_js_1.OMITTED_VALUE;
1748
+ }
1749
+ function sanitizeObject(value, table, options) {
1750
+ const out = {};
1751
+ for (const [key, entry] of Object.entries(value)) {
1752
+ const treatment = Object.hasOwn(table, key) ? table[key] : void 0;
1753
+ out[key] = treatment === void 0 ? mcp_redaction_js_1.OMITTED_VALUE : applyTreatment(entry, treatment, options);
1754
+ }
1755
+ return out;
1756
+ }
1757
+ function applyLeaf(value, treatment, options) {
1758
+ switch (treatment) {
1759
+ case "keep":
1760
+ return keepScalar(value, options);
1761
+ case "transport_type":
1762
+ return typeof value === "string" && exports.MCP_CONFIG_TRANSPORT_TYPES.has(value) ? value : mcp_redaction_js_1.OMITTED_VALUE;
1763
+ case "mode":
1764
+ return sanitizeMode(value);
1765
+ case "string_list":
1766
+ return sanitizeStringList(value, options);
1767
+ case "tool_list":
1768
+ return sanitizeToolList(value);
1769
+ case "command":
1770
+ return sanitizeCommand(value, options);
1771
+ case "helper_command":
1772
+ return sanitizeHelperCommand(value, options);
1773
+ case "args":
1774
+ return sanitizeArgs(value, options);
1775
+ case "url":
1776
+ return sanitizeUrl(value, options);
1777
+ case "secret":
1778
+ return sanitizeSecret(value);
1779
+ case "secret_map":
1780
+ return sanitizeSecretMap(value);
1781
+ case "env_name":
1782
+ return envName(value);
1783
+ case "env_name_map":
1784
+ return sanitizeEnvNameMap(value);
1785
+ case "path":
1786
+ return sanitizePath(value, options);
1787
+ case "omit":
1788
+ return mcp_redaction_js_1.OMITTED_VALUE;
1789
+ }
1790
+ }
1791
+ function applyTreatment(value, treatment, options) {
1792
+ if (typeof treatment === "string") {
1793
+ return applyLeaf(value, treatment, options);
1794
+ }
1795
+ if ("object" in treatment) {
1796
+ return (0, json_js_1.isRecord)(value) ? sanitizeObject(value, treatment.object, options) : mcp_redaction_js_1.OMITTED_VALUE;
1797
+ }
1798
+ if ("map" in treatment) {
1799
+ if (!(0, json_js_1.isRecord)(value)) {
1800
+ return mcp_redaction_js_1.OMITTED_VALUE;
1801
+ }
1802
+ const out = {};
1803
+ for (const [key, entry] of Object.entries(value)) {
1804
+ out[key] = applyTreatment(entry, treatment.map, options);
1805
+ }
1806
+ return out;
1807
+ }
1808
+ if ("list" in treatment) {
1809
+ return Array.isArray(value) ? value.map((entry) => applyTreatment(entry, treatment.list, options)) : mcp_redaction_js_1.OMITTED_VALUE;
1810
+ }
1811
+ const shape = shapeOf(value);
1812
+ const branch = shape === void 0 ? void 0 : treatment.by[shape];
1813
+ return branch === void 0 ? mcp_redaction_js_1.OMITTED_VALUE : applyTreatment(value, branch, options);
1814
+ }
1815
+ function sanitizeServers(value, options) {
1816
+ if (!(0, json_js_1.isRecord)(value)) {
1817
+ return mcp_redaction_js_1.OMITTED_VALUE;
1818
+ }
1819
+ const out = {};
1820
+ for (const [name, server] of Object.entries(value)) {
1821
+ out[name] = (0, json_js_1.isRecord)(server) ? sanitizeObject(server, exports.MCP_CONFIG_SERVER_KEY_TREATMENT, options) : mcp_redaction_js_1.OMITTED_VALUE;
1822
+ }
1823
+ return out;
1824
+ }
1825
+ function isVsCodeMcpJson(filePath) {
1826
+ return /(?:^|[\\/])\.vscode[\\/]mcp\.json$/i.test(filePath);
1827
+ }
1828
+ function mcpConfigFormatOf2(filePath) {
1829
+ if (isVsCodeMcpJson(filePath)) {
1830
+ return "vscode_mcp_json";
1831
+ }
1832
+ return (0, node_path_1.basename)(filePath) === ".claude.json" ? "claude_json_slice" : "mcp_json";
1833
+ }
1834
+ function mcpConfigServersKey2(format) {
1835
+ return format === "vscode_mcp_json" ? "servers" : "mcpServers";
1836
+ }
1837
+ function sanitizeMcpConfigFile2(parsed, format, options = {}) {
1838
+ if (!(0, json_js_1.isRecord)(parsed)) {
1839
+ return {};
1840
+ }
1841
+ const serversKey = mcpConfigServersKey2(format);
1842
+ if (format === "claude_json_slice") {
1843
+ return Object.hasOwn(parsed, serversKey) ? { [serversKey]: sanitizeServers(parsed[serversKey], options) } : {};
1844
+ }
1845
+ const out = {};
1846
+ for (const [key, entry] of Object.entries(parsed)) {
1847
+ if (key === serversKey) {
1848
+ out[key] = sanitizeServers(entry, options);
1849
+ } else if (format === "vscode_mcp_json" && key === "inputs") {
1850
+ out[key] = applyTreatment(entry, { list: { object: exports.MCP_CONFIG_VSCODE_INPUT_TABLE } }, options);
1851
+ } else if (format === "vscode_mcp_json" && key === "sandbox") {
1852
+ out[key] = applyTreatment(entry, { object: exports.MCP_CONFIG_SANDBOX_TABLE }, options);
1853
+ } else {
1854
+ out[key] = mcp_redaction_js_1.OMITTED_VALUE;
1855
+ }
1856
+ }
1857
+ return out;
1858
+ }
1859
+ }
1860
+ });
1861
+
1862
+ // ../composition-identity/dist/mcp-config-parse.js
1863
+ var require_mcp_config_parse = __commonJS({
1864
+ "../composition-identity/dist/mcp-config-parse.js"(exports) {
1865
+ "use strict";
1866
+ Object.defineProperty(exports, "__esModule", { value: true });
1867
+ exports.sanitizeMcpConfig = sanitizeMcpConfig;
1868
+ exports.parseMcpConfig = parseMcpConfig;
1869
+ var node_crypto_1 = __require("node:crypto");
1870
+ var json_js_1 = require_json();
1871
+ var mcp_config_file_js_1 = require_mcp_config_file();
1872
+ var mcp_redaction_js_1 = require_mcp_redaction();
1873
+ function sanitizeMcpConfig(body, format) {
1874
+ const parsed = JSON.parse(body);
1875
+ return JSON.stringify((0, mcp_config_file_js_1.sanitizeMcpConfigFile)(parsed, format), null, 2);
1876
+ }
1877
+ function parseMcpConfig(body, format) {
1878
+ const parsed = JSON.parse(body);
1879
+ if (!(0, json_js_1.isRecord)(parsed)) {
1880
+ return [];
1881
+ }
1882
+ const servers = parsed[(0, mcp_config_file_js_1.mcpConfigServersKey)(format)];
1883
+ if (!(0, json_js_1.isRecord)(servers)) {
1884
+ return [];
1885
+ }
1886
+ return Object.entries(servers).flatMap(([key, block]) => (0, json_js_1.isRecord)(block) ? [parsedServer(key, block)] : []);
1887
+ }
1888
+ function parsedServer(key, block) {
1889
+ return {
1890
+ key,
1891
+ enabled: (0, mcp_redaction_js_1.mcpServerEnabledFromJson)(block),
1892
+ block,
1893
+ launch: launchOf(key, block),
1894
+ contentHash: (0, node_crypto_1.createHash)("sha256").update(canonicalJson(block)).digest("hex")
1895
+ };
1896
+ }
1897
+ function launchOf(key, block) {
1898
+ if (typeof block.command === "string" && block.command.length > 0) {
1899
+ const args = Array.isArray(block.args) ? block.args.filter((arg) => typeof arg === "string") : [];
1900
+ return { kind: "command", command: block.command, arguments: args };
1901
+ }
1902
+ const url = [block.url, block.serverUrl, block.httpUrl].find((value) => typeof value === "string" && value.length > 0);
1903
+ if (url !== void 0) {
1904
+ return { kind: "url", url };
1905
+ }
1906
+ return { kind: "unknown", installationRootExternalKey: "", sourcePath: "", nativeKey: key };
1907
+ }
1908
+ function canonicalJson(value) {
1909
+ if (Array.isArray(value)) {
1910
+ return `[${value.map(canonicalJson).join(",")}]`;
1911
+ }
1912
+ if ((0, json_js_1.isRecord)(value)) {
1913
+ const entries = Object.keys(value).sort().map((entryKey) => `${JSON.stringify(entryKey)}:${canonicalJson(value[entryKey])}`);
1914
+ return `{${entries.join(",")}}`;
1915
+ }
1916
+ return JSON.stringify(value) ?? "null";
1917
+ }
1918
+ }
1919
+ });
1920
+
904
1921
  // ../composition-identity/dist/index.js
905
1922
  var require_dist = __commonJS({
906
1923
  "../composition-identity/dist/index.js"(exports) {
907
1924
  "use strict";
908
1925
  Object.defineProperty(exports, "__esModule", { value: true });
909
- exports.redactComponentSource = exports.prepareComponentInspectionText = exports.fitSnapshotInspectionTextBudget = exports.componentSourceContainsRedactableSecret = exports.capComponentTextBytes = exports.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES = exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER = exports.COMPONENT_INSPECTION_TEXT_MAX_BYTES = exports.usableCatalogText = exports.parseFrontmatterField = exports.parseFrontmatterDescription = exports.mcpServerToolSegmentForms = exports.mcpServerNameMatchesToolSegment = exports.isNpmRegistryPublisher = exports.EMPTY_NPM_PUBLISHER = exports.displayPublisherName = exports.classifyMcpProvenance = exports.resolveMcpPackageIdentity = exports.resolveLocalBinPackageIdentity = exports.McpPackageEcosystem = exports.pinnedPackageVersionFromSpec = exports.pinnedPackageVersionFromNpx = exports.packageNameFromSpec = exports.npxPackageSpecs = exports.npxExecBin = exports.isNodeModulesBinCommand = exports.isExactNpmVersion = exports.LOCAL_BIN_PACKAGE_VERSION_SOURCE = exports.PACKAGE_FIELD_MAX = exports.serializeMcpLaunchIdentity = exports.projectMcpMissingLaunchIdentity = exports.projectMcpLaunchIdentity = exports.normalizeMcpToolNames = exports.MCP_MISSING_LAUNCH_SERIALIZED = exports.MCP_LAUNCH_IDENTITY_ALGORITHM = exports.maskMcpLaunchForDisplay = exports.launchContainsCredentials = exports.hashMcpLaunchIdentity = exports.foldMcpName = exports.buildMcpFamilyCanonicalKey = exports.ComponentKind = void 0;
1926
+ exports.mcpServerEnabledFromJson = exports.isSecretShapedValue = exports.isAuthKeyName = exports.isAuthHeaderName = exports.ENABLED_RAW_KEYS = exports.tildePath = exports.tildeHomeInText = exports.tokenizeCommand = exports.isRecord = exports.redactComponentSource = exports.prepareComponentInspectionText = exports.fitSnapshotInspectionTextBudget = exports.componentSourceContainsRedactableSecret = exports.capComponentTextBytes = exports.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES = exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER = exports.COMPONENT_INSPECTION_TEXT_MAX_BYTES = exports.usableCatalogText = exports.parseFrontmatterField = exports.parseFrontmatterDescription = exports.mcpServerToolSegmentForms = exports.mcpServerNameMatchesToolSegment = exports.isNpmRegistryPublisher = exports.EMPTY_NPM_PUBLISHER = exports.displayPublisherName = exports.classifyMcpProvenance = exports.resolveMcpPackageIdentity = exports.resolveLocalBinPackageIdentity = exports.McpPackageEcosystem = exports.pinnedPackageVersionFromSpec = exports.pinnedPackageVersionFromNpx = exports.packageNameFromSpec = exports.npxPackageSpecs = exports.npxExecBin = exports.isNodeModulesBinCommand = exports.isExactNpmVersion = exports.LOCAL_BIN_PACKAGE_VERSION_SOURCE = exports.PACKAGE_FIELD_MAX = exports.serializeMcpLaunchIdentity = exports.projectMcpMissingLaunchIdentity = exports.projectMcpLaunchIdentity = exports.normalizeMcpToolNames = exports.MCP_MISSING_LAUNCH_SERIALIZED = exports.MCP_LAUNCH_IDENTITY_ALGORITHM = exports.maskMcpLaunchForDisplay = exports.launchContainsCredentials = exports.hashMcpLaunchIdentity = exports.foldMcpName = exports.buildMcpFamilyCanonicalKey = exports.ComponentKind = void 0;
1927
+ exports.sanitizeMcpConfig = exports.parseMcpConfig = exports.sanitizeVariableReference = exports.sanitizeMcpConfigFile = exports.REDACTED_VALUE = exports.mcpConfigServersKey = exports.mcpConfigFormatOf = exports.MCP_CONFIG_VSCODE_INPUT_TABLE = exports.MCP_CONFIG_TRANSPORT_TYPES = exports.MCP_CONFIG_SERVER_KEY_TREATMENT = exports.MCP_CONFIG_SANDBOX_TABLE = exports.TOOL_LIST_RAW_KEYS = exports.redactCommandOrUrl = exports.redactArgs = exports.OMITTED_VALUE = void 0;
910
1928
  exports.userConfigRootFromPath = userConfigRootFromPath;
1929
+ exports.repositoryConfigRootExternalKeyFromPath = repositoryConfigRootExternalKeyFromPath;
911
1930
  exports.installationRootExternalKey = installationRootExternalKey;
912
1931
  exports.normalizeRepositoryRelativePath = normalizeRepositoryRelativePath;
913
1932
  exports.nativeKeyForSkillPath = nativeKeyForSkillPath;
@@ -921,11 +1940,11 @@ var require_dist = __commonJS({
921
1940
  var REFERENCE_PREFIX = "cmp1_";
922
1941
  var REFERENCE_PATTERN = /^cmp1_[A-Za-z0-9_-]{43}$/;
923
1942
  var SKILLS_DIR_MARKERS = ["/skills/", "/skills-cursor/"];
924
- var RULE_PATH_RE = /(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i;
1943
+ var RULE_PATH_RE = /(?:^|\/)(?:\.(?:cursor|claude|codex)|\.gemini\/config)\/rules\/(.+)$/i;
925
1944
  var COMMAND_PATH_RE = /(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i;
926
1945
  var COPILOT_INSTRUCTION_PATH_RE = /(?:^|\/)\.(?:github|copilot)\/instructions\/(.+)$/i;
927
1946
  var COPILOT_PROMPT_PATH_RE = /(?:^|\/)\.github\/prompts\/(.+)$/i;
928
- var USER_CONFIG_ROOTS = [".cursor", ".claude", ".codex", ".copilot"];
1947
+ var USER_CONFIG_ROOTS = [".cursor", ".claude", ".codex", ".copilot", ".gemini"];
929
1948
  var USER_CONFIG_ROOT_ALIASES = {
930
1949
  ".claude.json": ".claude",
931
1950
  ".agents": ".codex",
@@ -949,6 +1968,27 @@ var require_dist = __commonJS({
949
1968
  const aliasedRoot = segments.map((segment) => USER_CONFIG_ROOT_ALIASES[segment]).find((root) => root !== void 0);
950
1969
  return aliasedRoot ?? "unknown";
951
1970
  }
1971
+ var REPOSITORY_CONFIG_ROOT_MARKERS = /* @__PURE__ */ new Set([
1972
+ ".claude",
1973
+ ".cursor",
1974
+ ".codex",
1975
+ ".opencode",
1976
+ ".github"
1977
+ ]);
1978
+ var REPOSITORY_AGENTS_DIR = ".agents";
1979
+ var REPOSITORY_AGENTS_DIR_ROOT = ".codex";
1980
+ function repositoryConfigRootExternalKeyFromPath(repoSlug, repoRelativeSourcePath) {
1981
+ const segments = repoRelativeSourcePath.replaceAll("\\", "/").split("/").filter(Boolean);
1982
+ const markerIndex = segments.findIndex((segment) => REPOSITORY_CONFIG_ROOT_MARKERS.has(segment));
1983
+ if (markerIndex >= 0) {
1984
+ return `${repoSlug}:${segments.slice(0, markerIndex + 1).join("/")}`;
1985
+ }
1986
+ const agentsIndex = segments.indexOf(REPOSITORY_AGENTS_DIR);
1987
+ if (agentsIndex < 0) {
1988
+ return null;
1989
+ }
1990
+ return `${repoSlug}:${[...segments.slice(0, agentsIndex), REPOSITORY_AGENTS_DIR_ROOT].join("/")}`;
1991
+ }
952
1992
  function installationRootExternalKey(installationId, configRoot) {
953
1993
  return `runtime-install:${installationId}/${configRoot}`;
954
1994
  }
@@ -1148,6 +2188,84 @@ var require_dist = __commonJS({
1148
2188
  Object.defineProperty(exports, "redactComponentSource", { enumerable: true, get: function() {
1149
2189
  return skill_source_redaction_js_1.redactComponentSource;
1150
2190
  } });
2191
+ var json_js_1 = require_json();
2192
+ Object.defineProperty(exports, "isRecord", { enumerable: true, get: function() {
2193
+ return json_js_1.isRecord;
2194
+ } });
2195
+ var command_tokens_js_1 = require_command_tokens();
2196
+ Object.defineProperty(exports, "tokenizeCommand", { enumerable: true, get: function() {
2197
+ return command_tokens_js_1.tokenizeCommand;
2198
+ } });
2199
+ var home_path_js_1 = require_home_path();
2200
+ Object.defineProperty(exports, "tildeHomeInText", { enumerable: true, get: function() {
2201
+ return home_path_js_1.tildeHomeInText;
2202
+ } });
2203
+ Object.defineProperty(exports, "tildePath", { enumerable: true, get: function() {
2204
+ return home_path_js_1.tildePath;
2205
+ } });
2206
+ var mcp_redaction_js_1 = require_mcp_redaction();
2207
+ Object.defineProperty(exports, "ENABLED_RAW_KEYS", { enumerable: true, get: function() {
2208
+ return mcp_redaction_js_1.ENABLED_RAW_KEYS;
2209
+ } });
2210
+ Object.defineProperty(exports, "isAuthHeaderName", { enumerable: true, get: function() {
2211
+ return mcp_redaction_js_1.isAuthHeaderName;
2212
+ } });
2213
+ Object.defineProperty(exports, "isAuthKeyName", { enumerable: true, get: function() {
2214
+ return mcp_redaction_js_1.isAuthKeyName;
2215
+ } });
2216
+ Object.defineProperty(exports, "isSecretShapedValue", { enumerable: true, get: function() {
2217
+ return mcp_redaction_js_1.isSecretShapedValue;
2218
+ } });
2219
+ Object.defineProperty(exports, "mcpServerEnabledFromJson", { enumerable: true, get: function() {
2220
+ return mcp_redaction_js_1.mcpServerEnabledFromJson;
2221
+ } });
2222
+ Object.defineProperty(exports, "OMITTED_VALUE", { enumerable: true, get: function() {
2223
+ return mcp_redaction_js_1.OMITTED_VALUE;
2224
+ } });
2225
+ Object.defineProperty(exports, "redactArgs", { enumerable: true, get: function() {
2226
+ return mcp_redaction_js_1.redactArgs;
2227
+ } });
2228
+ Object.defineProperty(exports, "redactCommandOrUrl", { enumerable: true, get: function() {
2229
+ return mcp_redaction_js_1.redactCommandOrUrl;
2230
+ } });
2231
+ Object.defineProperty(exports, "TOOL_LIST_RAW_KEYS", { enumerable: true, get: function() {
2232
+ return mcp_redaction_js_1.TOOL_LIST_RAW_KEYS;
2233
+ } });
2234
+ var mcp_config_file_js_1 = require_mcp_config_file();
2235
+ Object.defineProperty(exports, "MCP_CONFIG_SANDBOX_TABLE", { enumerable: true, get: function() {
2236
+ return mcp_config_file_js_1.MCP_CONFIG_SANDBOX_TABLE;
2237
+ } });
2238
+ Object.defineProperty(exports, "MCP_CONFIG_SERVER_KEY_TREATMENT", { enumerable: true, get: function() {
2239
+ return mcp_config_file_js_1.MCP_CONFIG_SERVER_KEY_TREATMENT;
2240
+ } });
2241
+ Object.defineProperty(exports, "MCP_CONFIG_TRANSPORT_TYPES", { enumerable: true, get: function() {
2242
+ return mcp_config_file_js_1.MCP_CONFIG_TRANSPORT_TYPES;
2243
+ } });
2244
+ Object.defineProperty(exports, "MCP_CONFIG_VSCODE_INPUT_TABLE", { enumerable: true, get: function() {
2245
+ return mcp_config_file_js_1.MCP_CONFIG_VSCODE_INPUT_TABLE;
2246
+ } });
2247
+ Object.defineProperty(exports, "mcpConfigFormatOf", { enumerable: true, get: function() {
2248
+ return mcp_config_file_js_1.mcpConfigFormatOf;
2249
+ } });
2250
+ Object.defineProperty(exports, "mcpConfigServersKey", { enumerable: true, get: function() {
2251
+ return mcp_config_file_js_1.mcpConfigServersKey;
2252
+ } });
2253
+ Object.defineProperty(exports, "REDACTED_VALUE", { enumerable: true, get: function() {
2254
+ return mcp_config_file_js_1.REDACTED_VALUE;
2255
+ } });
2256
+ Object.defineProperty(exports, "sanitizeMcpConfigFile", { enumerable: true, get: function() {
2257
+ return mcp_config_file_js_1.sanitizeMcpConfigFile;
2258
+ } });
2259
+ Object.defineProperty(exports, "sanitizeVariableReference", { enumerable: true, get: function() {
2260
+ return mcp_config_file_js_1.sanitizeVariableReference;
2261
+ } });
2262
+ var mcp_config_parse_js_1 = require_mcp_config_parse();
2263
+ Object.defineProperty(exports, "parseMcpConfig", { enumerable: true, get: function() {
2264
+ return mcp_config_parse_js_1.parseMcpConfig;
2265
+ } });
2266
+ Object.defineProperty(exports, "sanitizeMcpConfig", { enumerable: true, get: function() {
2267
+ return mcp_config_parse_js_1.sanitizeMcpConfig;
2268
+ } });
1151
2269
  }
1152
2270
  });
1153
2271
 
@@ -4147,9 +5265,8 @@ var CLASSIFY_MAX = 64 * 1024;
4147
5265
  var HOOK_MJS_MAX = 4 * 1024 * 1024;
4148
5266
 
4149
5267
  // src/config/collector-url-resolve.ts
4150
- var DEFAULT_COLLECTOR_BASE_URL = "https://hooks.ev-ai.ai";
4151
5268
  var MAX_JSON_FILE_BYTES = 1024 * 1024;
4152
- function buildCollectorUrl(orgToken, baseUrl = DEFAULT_COLLECTOR_BASE_URL) {
5269
+ function buildCollectorUrl(orgToken, baseUrl) {
4153
5270
  const normalizedBase = baseUrl.replace(/\/+$/, "");
4154
5271
  const token = orgToken.trim();
4155
5272
  return `${normalizedBase}/${token}/hook`;
@@ -4271,6 +5388,53 @@ var RUNNER_LAYOUT = {
4271
5388
  // VS Code's workspace file keys servers under `servers`, not `mcpServers`.
4272
5389
  mcpJson: [".github/mcp.json", ".vscode/mcp.json"]
4273
5390
  }
5391
+ },
5392
+ // Google Antigravity (desktop app, `agy` CLI, IDE). Mirrors GOOGLE_ANTIGRAVITY in
5393
+ // common/platform-component-ownership: one layout under the workspace
5394
+ // `.agents/` and the personal `~/.gemini/config/`, plus legacy home skill dirs
5395
+ // the app and CLI still read. `dirs` cannot differ by scope, so both trees are
5396
+ // listed. There is no commands dir (slash commands are skills), and
5397
+ // `admin_settings.json` holds no customizations, so there is no `managed`.
5398
+ // `hooks.json` keys hooks by name with no `hooks{}` object: presence only.
5399
+ // Plugins (`~/.gemini/config/plugins/<plugin>/`) are expanded by
5400
+ // `collectAntigravityPlugins`. The `skills.json` / `rules.json` manifests are
5401
+ // not read yet.
5402
+ // Source: https://antigravity.google/docs/customization-discovery
5403
+ antigravity: {
5404
+ shared: {
5405
+ skillRoots: [],
5406
+ dirs: [
5407
+ { dir: ".agents/rules", kind: "RULE", extensions: [".md"] },
5408
+ { dir: ".agents/agents", kind: "SUBAGENT", extensions: [".md"] },
5409
+ { dir: ".gemini/config/rules", kind: "RULE", extensions: [".md"] },
5410
+ { dir: ".gemini/config/agents", kind: "SUBAGENT", extensions: [".md"] }
5411
+ ],
5412
+ memory: [],
5413
+ settings: []
5414
+ },
5415
+ homeOnly: {
5416
+ skillRoots: [
5417
+ ".gemini/config/skills",
5418
+ ".gemini/antigravity/skills",
5419
+ ".gemini/antigravity-cli/skills",
5420
+ ".gemini/skills"
5421
+ ],
5422
+ memory: [
5423
+ [".gemini/GEMINI.md"],
5424
+ [".gemini/AGENTS.md"],
5425
+ [".gemini/config/GEMINI.md"],
5426
+ [".gemini/config/AGENTS.md"]
5427
+ ],
5428
+ settings: [".gemini/config/hooks.json"],
5429
+ mcpJson: [".gemini/config/mcp_config.json"],
5430
+ plugins: "antigravity"
5431
+ },
5432
+ projectOnly: {
5433
+ skillRoots: [".agents/skills"],
5434
+ memory: [["AGENTS.md"], ["GEMINI.md"], [".agents/AGENTS.md"], [".agents/GEMINI.md"]],
5435
+ settings: [".agents/hooks.json"],
5436
+ mcpJson: [".agents/mcp_config.json"]
5437
+ }
4274
5438
  }
4275
5439
  };
4276
5440
  function concatOptional(shared, delta) {
@@ -4375,7 +5539,7 @@ var USER_SKILL_ROOTS = uniqueOrderedRoots(
4375
5539
  );
4376
5540
 
4377
5541
  // src/extract/rule-extract.ts
4378
- var import_composition_identity5 = __toESM(require_dist(), 1);
5542
+ var import_composition_identity8 = __toESM(require_dist(), 1);
4379
5543
 
4380
5544
  // src/shared/file-logger.ts
4381
5545
  var LOG_MAX_BYTES = 1024 * 1024;
@@ -4402,7 +5566,7 @@ var HOOK_INPUT_ALLOWLIST_MAX_BYTES = 4 * 1024;
4402
5566
  var HOOK_INPUT_FULL_MAX_BYTES = 256 * 1024;
4403
5567
  var HOOK_INPUT_MCP_MAX_BYTES = 4 * 1024;
4404
5568
  var GZIP_MIN_BYTES = 32 * 1024;
4405
- var PACKAGE_VERSION = "1.4.1";
5569
+ var PACKAGE_VERSION = "1.4.2";
4406
5570
  var NPX_PACKAGE_SPEC = `@ev-ai/agent-hook@${PACKAGE_VERSION}`;
4407
5571
  var HOOK_STATUS_MESSAGE = "ev-ai runtime report";
4408
5572
 
@@ -4441,19 +5605,7 @@ var NPX_PACKAGE_ATTRIBUTE_KEYS = [
4441
5605
  "package_version",
4442
5606
  "package_version_source"
4443
5607
  ];
4444
- var TOOL_LIST_RAW_KEYS = [
4445
- { raw: "tools", attr: "tools" },
4446
- { raw: "autoApprove", attr: "auto_approve" },
4447
- { raw: "auto_approve", attr: "auto_approve" },
4448
- { raw: "alwaysAllow", attr: "always_allow" },
4449
- { raw: "always_allow", attr: "always_allow" },
4450
- { raw: "enabledTools", attr: "enabled_tools" },
4451
- { raw: "enabled_tools", attr: "enabled_tools" },
4452
- { raw: "disabledTools", attr: "disabled_tools" },
4453
- { raw: "disabled_tools", attr: "disabled_tools" }
4454
- ];
4455
- var TOOL_LIST_ATTRS = new Set(TOOL_LIST_RAW_KEYS.map((entry) => entry.attr));
4456
- var ENABLED_RAW_KEYS = ["enabled", "disabled"];
5608
+ var TOOL_LIST_ATTRS = new Set(import_composition_identity.TOOL_LIST_RAW_KEYS.map((entry) => entry.attr));
4457
5609
  var SCALAR_RAW_KEYS = [
4458
5610
  "serverUrl",
4459
5611
  "auth",
@@ -4472,9 +5624,9 @@ var MCP_SERVER_READ_KEYS = /* @__PURE__ */ new Set([
4472
5624
  "env",
4473
5625
  "envVars",
4474
5626
  "headers",
4475
- ...ENABLED_RAW_KEYS,
5627
+ ...import_composition_identity.ENABLED_RAW_KEYS,
4476
5628
  ...SCALAR_RAW_KEYS,
4477
- ...TOOL_LIST_RAW_KEYS.map((entry) => entry.raw)
5629
+ ...import_composition_identity.TOOL_LIST_RAW_KEYS.map((entry) => entry.raw)
4478
5630
  ]);
4479
5631
  var DERIVED_KEYS = /* @__PURE__ */ new Set([
4480
5632
  "transport",
@@ -4491,225 +5643,8 @@ var DERIVED_KEYS = /* @__PURE__ */ new Set([
4491
5643
  ...[...TOOL_LIST_ATTRS].map((attr) => `${attr}_truncated`)
4492
5644
  ]);
4493
5645
 
4494
- // src/collectors/permission-key.ts
4495
- var PATH_PLACEHOLDER = "<path>";
4496
- var PATH_CONTINUATION_PATTERN = new RegExp(
4497
- `${PATH_PLACEHOLDER}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,
4498
- "g"
4499
- );
4500
-
4501
- // src/collectors/userSpec/settings.ts
4502
- var SETTINGS_JSON_MAX_BYTES = 16 * 1024;
4503
-
4504
- // src/collectors/userSpec/mcp-config-file.ts
4505
- var AUTH_TABLE = {
4506
- CLIENT_ID: "keep",
4507
- CLIENT_SECRET: "secret",
4508
- scopes: "string_list",
4509
- redirectPort: "keep"
4510
- // source-only
4511
- };
4512
- var OAUTH_TABLE = {
4513
- clientId: "keep",
4514
- client_id: "keep",
4515
- clientSecret: "secret",
4516
- client_secret: "secret",
4517
- callbackPort: "keep",
4518
- callback_port: "keep",
4519
- // source-only
4520
- callback_url: "url",
4521
- // source-only
4522
- redirectUri: "url",
4523
- // source-only
4524
- redirect_uri: "url",
4525
- // source-only
4526
- authServerMetadataUrl: "url",
4527
- auth_server_metadata_url: "url",
4528
- // source-only
4529
- authorizationUrl: "url",
4530
- tokenUrl: "url",
4531
- issuer: "url",
4532
- // source-only
4533
- registrationUrl: "url",
4534
- // source-only
4535
- clientMetadataUrl: "url",
4536
- // source-only
4537
- scopes: { by: { string: "keep", array: "string_list" } },
4538
- scope: "keep",
4539
- // source-only
4540
- oauthScopes: "string_list",
4541
- // source-only
4542
- audiences: "string_list",
4543
- enabled: "keep",
4544
- allowPrivateNetwork: "keep",
4545
- // source-only
4546
- authorizationResponseIssParameterSupported: "keep",
4547
- // source-only
4548
- tokenParamName: "keep"
4549
- };
4550
- var MCP_CONFIG_SANDBOX_TABLE = {
4551
- filesystem: {
4552
- object: {
4553
- allowWrite: "path",
4554
- denyRead: "path",
4555
- denyWrite: "path"
4556
- }
4557
- },
4558
- network: {
4559
- object: {
4560
- allowedDomains: "string_list",
4561
- deniedDomains: "string_list"
4562
- }
4563
- }
4564
- };
4565
- var DEV_TABLE = {
4566
- watch: "path",
4567
- debug: { object: { type: "keep", debugpyPath: "path" } }
4568
- };
4569
- var REQUEST_OPTIONS_TABLE = {
4570
- headers: "secret_map",
4571
- proxy: "url",
4572
- caBundlePath: "path",
4573
- timeout: "keep",
4574
- verifySsl: "keep",
4575
- noProxy: "string_list",
4576
- extraBodyProperties: "omit",
4577
- clientCertificate: { object: { cert: "omit", key: "omit", passphrase: "secret" } }
4578
- };
4579
- var TIMEOUT_TABLE = { startup: "keep", catalog: "keep", execution: "keep" };
4580
- var CODEX_TOOL_TABLE = { approval_mode: "keep", output_token_limit: "keep" };
4581
- var TRANSPORT_TABLE = {
4582
- type: "transport_type",
4583
- command: "command",
4584
- args: "args",
4585
- cwd: "path",
4586
- env: "secret_map",
4587
- url: "url",
4588
- headers: "secret_map"
4589
- };
4590
- var TOOL_LIST_ALIASES = Object.fromEntries(
4591
- TOOL_LIST_RAW_KEYS.map(({ raw }) => [raw, "tool_list"])
4592
- );
4593
- var MCP_CONFIG_SERVER_KEY_TREATMENT = {
4594
- ...TOOL_LIST_ALIASES,
4595
- // Identity / transport / enablement
4596
- type: "transport_type",
4597
- transportType: "keep",
4598
- // source-only
4599
- transport: { by: { string: "keep", object: { object: TRANSPORT_TABLE } } },
4600
- disabled: "keep",
4601
- enabled: "keep",
4602
- required: "keep",
4603
- remote: "keep",
4604
- // source-only
4605
- remoteConfigured: "keep",
4606
- // source-only
4607
- source: "keep",
4608
- // source-only
4609
- version: "keep",
4610
- gallery: { by: { boolean: "keep", string: "url" } },
4611
- description: "omit",
4612
- name: "keep",
4613
- serverName: "keep",
4614
- // source-only
4615
- faviconUrl: "url",
4616
- // source-only
4617
- sourceFile: "path",
4618
- sourceSlug: "keep",
4619
- environment_id: "keep",
4620
- protocol: "keep",
4621
- pool: "keep",
4622
- codemode: "keep",
4623
- trust: "keep",
4624
- alwaysLoad: "keep",
4625
- deferTools: "keep",
4626
- // source-only
4627
- supports_parallel_tool_calls: "keep",
4628
- tool_input_schema_max_bytes: "keep",
4629
- startup_readiness: "keep",
4630
- extension: "omit",
4631
- // source-only
4632
- metadata: "omit",
4633
- // source-only
4634
- settings: "omit",
4635
- // source-only
4636
- // stdio / process
4637
- command: {
4638
- by: {
4639
- string: "command",
4640
- array: "args",
4641
- // Zed legacy `command: { path, args, env }`.
4642
- object: { object: { path: "command", args: "args", env: "secret_map" } }
4643
- }
4644
- },
4645
- args: "args",
4646
- env: "secret_map",
4647
- environment: "secret_map",
4648
- env_vars: {
4649
- list: {
4650
- by: { string: "env_name", object: { object: { name: "env_name", source: "keep" } } }
4651
- }
4652
- },
4653
- envVars: "secret_map",
4654
- envFile: "path",
4655
- cwd: "path",
4656
- watchPaths: "path",
4657
- dev: { object: DEV_TABLE },
4658
- sandboxEnabled: "keep",
4659
- sandbox: { object: MCP_CONFIG_SANDBOX_TABLE },
4660
- // Remote / HTTP
4661
- url: "url",
4662
- serverUrl: "url",
4663
- httpUrl: "url",
4664
- tcp: "url",
4665
- // source-only
4666
- headers: "secret_map",
4667
- http_headers: "secret_map",
4668
- env_http_headers: "env_name_map",
4669
- bearer_token_env_var: "env_name",
4670
- headersHelper: "helper_command",
4671
- http_headers_helper: "helper_command",
4672
- apiKey: "secret",
4673
- // source-only
4674
- requestOptions: { object: REQUEST_OPTIONS_TABLE },
4675
- // source-only
4676
- auth: { by: { string: "mode", object: { object: AUTH_TABLE } } },
4677
- oauth: { by: { boolean: "keep", object: { object: OAUTH_TABLE } } },
4678
- oauthClientId: "keep",
4679
- oauthClientSecret: "secret",
4680
- oauthResource: "url",
4681
- oauth_resource: "url",
4682
- oauthScopes: "string_list",
4683
- scopes: { by: { string: "keep", array: "string_list" } },
4684
- oauthPublicClient: "keep",
4685
- // source-only
4686
- oauthGrantType: "keep",
4687
- // source-only
4688
- authProviderType: "keep",
4689
- targetAudience: "keep",
4690
- targetServiceAccount: "keep",
4691
- // Tool filtering / approval
4692
- tools: {
4693
- by: {
4694
- array: "tool_list",
4695
- boolean: "tool_list",
4696
- string: "tool_list",
4697
- object: { map: { object: CODEX_TOOL_TABLE } }
4698
- }
4699
- },
4700
- includeTools: "tool_list",
4701
- excludeTools: "tool_list",
4702
- omit_tools_from: "tool_list",
4703
- default_tools_approval_mode: "keep",
4704
- defaultToolsApprovalMode: "keep",
4705
- // Timeouts
4706
- timeout: { by: { number: "keep", object: { object: TIMEOUT_TABLE } } },
4707
- startup_timeout_sec: "keep",
4708
- startup_timeout_ms: "keep",
4709
- tool_timeout_sec: "keep",
4710
- connectionTimeout: "keep"
4711
- // source-only
4712
- };
5646
+ // src/collectors/userSpec/mcp.ts
5647
+ var import_composition_identity5 = __toESM(require_dist(), 1);
4713
5648
 
4714
5649
  // src/collectors/userSpec/npx-package.ts
4715
5650
  var import_composition_identity4 = __toESM(require_dist(), 1);
@@ -4729,6 +5664,20 @@ var MANIFEST_MAX_BYTES = 1024 * 1024;
4729
5664
  // src/collectors/userSpec/mcp.ts
4730
5665
  var MCP_CONFIG_TEXT_MAX_BYTES = 64 * 1024;
4731
5666
 
5667
+ // src/collectors/userSpec/hook-command.ts
5668
+ var import_composition_identity6 = __toESM(require_dist(), 1);
5669
+
5670
+ // src/collectors/permission-key.ts
5671
+ var PATH_PLACEHOLDER = "<path>";
5672
+ var PATH_CONTINUATION_PATTERN = new RegExp(
5673
+ `${PATH_PLACEHOLDER}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,
5674
+ "g"
5675
+ );
5676
+
5677
+ // src/collectors/userSpec/settings.ts
5678
+ var import_composition_identity7 = __toESM(require_dist(), 1);
5679
+ var SETTINGS_JSON_MAX_BYTES = 16 * 1024;
5680
+
4732
5681
  // src/collectors/userSpec/budget.ts
4733
5682
  var USER_SPEC_MAX_BYTES = 2 * 1024 * 1024;
4734
5683
 
@@ -4739,19 +5688,19 @@ var GIT_CONFIG_CACHE_TTL_MS = 60 * 60 * 1e3;
4739
5688
  var RULE_LAYOUT_ROOTS = userScopePathsFromLayouts(Object.values(PLATFORM_PROJECT_LAYOUT)).rules;
4740
5689
 
4741
5690
  // src/extract/command-extract.ts
4742
- var import_composition_identity6 = __toESM(require_dist(), 1);
5691
+ var import_composition_identity9 = __toESM(require_dist(), 1);
4743
5692
  var COMMAND_LAYOUT_ROOTS = userScopePathsFromLayouts(
4744
5693
  Object.values(PLATFORM_PROJECT_LAYOUT)
4745
5694
  ).commands;
4746
5695
 
4747
5696
  // src/hook/runner.ts
4748
- var import_composition_identity7 = __toESM(require_dist(), 1);
5697
+ var import_composition_identity10 = __toESM(require_dist(), 1);
4749
5698
  function isInProcessEvent(runnerEvent, platform) {
4750
5699
  const lower = runnerEvent.toLowerCase();
4751
5700
  if (lower === "sessionend" || lower === "stopfailure" || lower === "subagentstop") {
4752
5701
  return true;
4753
5702
  }
4754
- return lower === "stop" && platform === "codex";
5703
+ return lower === "stop" && (platform === "codex" || platform === "antigravity");
4755
5704
  }
4756
5705
 
4757
5706
  // src/config/hook-config.ts
@@ -4834,6 +5783,28 @@ function desiredCodexHookGroups(command) {
4834
5783
  SubagentStop: [commandHook()]
4835
5784
  };
4836
5785
  }
5786
+ var ANTIGRAVITY_WIRED_HOOK_EVENTS = [
5787
+ "SessionStart",
5788
+ "PreInvocation",
5789
+ "PreToolUse",
5790
+ "PostToolUse",
5791
+ "PostInvocation",
5792
+ "Stop"
5793
+ ];
5794
+ var ANTIGRAVITY_TOOL_EVENTS = /* @__PURE__ */ new Set(["PreToolUse", "PostToolUse"]);
5795
+ var ANTIGRAVITY_HOOK_NAME = "ev-ai-agent-hooks";
5796
+ function desiredAntigravityHooks(command, timeoutSeconds, hookName = ANTIGRAVITY_HOOK_NAME) {
5797
+ const entry = { enabled: true };
5798
+ for (const eventName of ANTIGRAVITY_WIRED_HOOK_EVENTS) {
5799
+ const handler = {
5800
+ type: "command",
5801
+ command: `${commandForEvent(eventName, command)} ${eventName}`,
5802
+ timeout: timeoutSeconds(eventName)
5803
+ };
5804
+ entry[eventName] = ANTIGRAVITY_TOOL_EVENTS.has(eventName) ? [{ matcher: "", hooks: [handler] }] : [handler];
5805
+ }
5806
+ return { [hookName]: entry };
5807
+ }
4837
5808
  var CURSOR_WIRED_HOOK_EVENTS = [
4838
5809
  "sessionStart",
4839
5810
  "beforeSubmitPrompt",
@@ -4875,6 +5846,516 @@ var MARKETPLACE_PLUGIN_DIRS = {
4875
5846
  codex: "plugins/codex",
4876
5847
  copilot: "plugins/copilot"
4877
5848
  };
5849
+ var ANTIGRAVITY_PAYLOAD_DIR = "plugins/antigravity";
5850
+ var MARKETPLACE_PAYLOAD_DIRS = [
5851
+ ...Object.values(MARKETPLACE_PLUGIN_DIRS),
5852
+ ANTIGRAVITY_PAYLOAD_DIR
5853
+ ];
5854
+
5855
+ // src/install/antigravity-mdm.ts
5856
+ var ANTIGRAVITY_OPERATING_SYSTEMS = ["macos", "linux", "windows"];
5857
+ var ANTIGRAVITY_ENTRY_MARKER = "--runner antigravity";
5858
+ var CMD_SAFE_URL = /^https?:\/\/[A-Za-z0-9._~:/?#[\]@&+,;=-]+$/;
5859
+ var PLUGIN_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
5860
+ var MARKETPLACE_REPO = /^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/;
5861
+ function assertPluginName(pluginName) {
5862
+ if (!PLUGIN_NAME.test(pluginName)) {
5863
+ throw new Error(`plugin name must be a lowercase slug: ${pluginName}`);
5864
+ }
5865
+ }
5866
+ function assertCollectorUrl(collectorUrl) {
5867
+ if (!CMD_SAFE_URL.test(collectorUrl)) {
5868
+ throw new Error(`collector URL is not safe to quote in a hook command: ${collectorUrl}`);
5869
+ }
5870
+ }
5871
+ function antigravityInstallRoot(pluginName, os) {
5872
+ assertPluginName(pluginName);
5873
+ switch (os) {
5874
+ case "macos":
5875
+ return `/Library/Application Support/${pluginName}`;
5876
+ case "linux":
5877
+ return `/opt/${pluginName}`;
5878
+ case "windows":
5879
+ return `C:\\ProgramData\\${pluginName}`;
5880
+ }
5881
+ }
5882
+ function joinPath(os, ...parts) {
5883
+ return parts.join(os === "windows" ? "\\" : "/");
5884
+ }
5885
+ function antigravityInstallDir(pluginName, os) {
5886
+ return joinPath(os, antigravityInstallRoot(pluginName, os), "antigravity");
5887
+ }
5888
+ function antigravityHookCommand(collectorUrl, os, pluginName, installDir = antigravityInstallDir(pluginName, os)) {
5889
+ assertCollectorUrl(collectorUrl);
5890
+ const launcher = joinPath(os, installDir, "dist", "launcher.mjs");
5891
+ return `node "${launcher}" ${ANTIGRAVITY_ENTRY_MARKER} --url "${collectorUrl}"`;
5892
+ }
5893
+ function antigravityHooksEntry(collectorUrl, options = {}) {
5894
+ const pluginName = options.pluginName ?? ANTIGRAVITY_HOOK_NAME;
5895
+ const os = options.os ?? "macos";
5896
+ const command = antigravityHookCommand(collectorUrl, os, pluginName, options.installDir);
5897
+ return desiredAntigravityHooks(
5898
+ command,
5899
+ (eventName) => isSessionStartEvent(eventName) ? CLAUDE_SESSION_START_TIMEOUT_SECONDS : CLAUDE_HOOK_TIMEOUT_SECONDS,
5900
+ pluginName
5901
+ );
5902
+ }
5903
+ var ANTIGRAVITY_MERGE_SCRIPT = [
5904
+ "const fs=require('fs'),os=require('os'),path=require('path');",
5905
+ "const args=process.argv.slice(1);",
5906
+ "const file=args.length>1?args[0]:path.join(os.userInfo().homedir,'.gemini','config','hooks.json');",
5907
+ "const entry=JSON.parse(Buffer.from(args[args.length-1],'base64').toString('utf8'));",
5908
+ "function isLink(p){try{return fs.lstatSync(p).isSymbolicLink();}catch(e){return false;}}",
5909
+ "function merge(){",
5910
+ "if([path.dirname(path.dirname(file)),path.dirname(file),file].some(isLink)){return 'symlink';}",
5911
+ "let hooks={};",
5912
+ "if(fs.existsSync(file)){try{hooks=JSON.parse(fs.readFileSync(file,'utf8'));}catch(e){hooks=null;}}",
5913
+ "if(Object.prototype.toString.call(hooks)==='[object Object]'===false){return 'not-json';}",
5914
+ "const name=Object.keys(entry)[0];",
5915
+ `const ours=Object.keys(hooks).filter(function(k){return JSON.stringify(hooks[k]).includes('${ANTIGRAVITY_ENTRY_MARKER}');});`,
5916
+ "if(ours.length===1&&ours[0]===name&&JSON.stringify(hooks[name])===JSON.stringify(entry[name])){return 'unchanged';}",
5917
+ "for(const k of ours){delete hooks[k];}",
5918
+ "Object.assign(hooks,entry);",
5919
+ "fs.mkdirSync(path.dirname(file),{recursive:true});",
5920
+ "fs.writeFileSync(file,JSON.stringify(hooks,null,2)+'\\n');",
5921
+ "return ours.length>0?'updated':'added';",
5922
+ "}",
5923
+ "const result=merge();",
5924
+ "console.log(result);",
5925
+ "process.exitCode=result==='symlink'||result==='not-json'?3:0;"
5926
+ ].join("");
5927
+ function base64(text) {
5928
+ return Buffer.from(text, "utf8").toString("base64");
5929
+ }
5930
+ function antigravityMergeCommand(hooksJson) {
5931
+ return `node -e "${ANTIGRAVITY_MERGE_SCRIPT}" ${base64(hooksJson)}`;
5932
+ }
5933
+ function antigravityReleaseAssets(pluginName) {
5934
+ assertPluginName(pluginName);
5935
+ const base = `${pluginName}-antigravity`;
5936
+ return { tarball: `${base}.tar.gz`, zip: `${base}.zip`, checksums: `${base}.sha256` };
5937
+ }
5938
+ function assertMarketplaceRepo(marketplaceRepo) {
5939
+ if (!MARKETPLACE_REPO.test(marketplaceRepo)) {
5940
+ throw new Error(`marketplace repo must be owner/name: ${marketplaceRepo}`);
5941
+ }
5942
+ }
5943
+ function antigravityLatestReleaseBaseUrl(marketplaceRepo) {
5944
+ assertMarketplaceRepo(marketplaceRepo);
5945
+ return `https://github.com/${marketplaceRepo}/releases/latest/download`;
5946
+ }
5947
+ function scriptValues(collectorUrl, options, testing) {
5948
+ const { os, pluginName, marketplaceRepo } = options;
5949
+ assertPluginName(pluginName);
5950
+ assertMarketplaceRepo(marketplaceRepo);
5951
+ assertCollectorUrl(collectorUrl);
5952
+ const installRoot = testing?.installRoot ?? antigravityInstallRoot(pluginName, os);
5953
+ const installDir = joinPath(os, installRoot, "antigravity");
5954
+ const assets = antigravityReleaseAssets(pluginName);
5955
+ const releaseBaseUrl = testing?.releaseBaseUrl ?? antigravityLatestReleaseBaseUrl(marketplaceRepo);
5956
+ const archiveName = os === "windows" ? assets.zip : assets.tarball;
5957
+ const entry = antigravityHooksEntry(collectorUrl, { os, pluginName, installDir });
5958
+ return {
5959
+ pluginName,
5960
+ marketplaceRepo,
5961
+ installRoot,
5962
+ installDir,
5963
+ shaUrl: `${releaseBaseUrl}/${assets.checksums}`,
5964
+ archiveUrl: `${releaseBaseUrl}/${archiveName}`,
5965
+ archiveName,
5966
+ entryBase64: base64(JSON.stringify(entry))
5967
+ };
5968
+ }
5969
+ function posixHeader(v, osLabel, runAs) {
5970
+ return [
5971
+ "#!/bin/sh",
5972
+ `# Google Antigravity agent hooks (${v.pluginName}) for ${osLabel}.`,
5973
+ "# Generated for your organization: every value is already filled in, do not edit it.",
5974
+ `# Run it as ${runAs} once a day on every device. Each run:`,
5975
+ `# 1. installs or updates the hook from the latest stable release of https://github.com/${v.marketplaceRepo}`,
5976
+ `# into ${v.installDir} (only when that release changed);`,
5977
+ "# 2. adds or repairs the hook entry in ~/.gemini/config/hooks.json for every user,",
5978
+ "# keeping each user's own hooks.",
5979
+ "# Running it again changes nothing that is already in place."
5980
+ ].join("\n");
5981
+ }
5982
+ function posixMdmScript(collectorUrl, options, testing) {
5983
+ const v = scriptValues(collectorUrl, options, testing);
5984
+ const macos = options.os === "macos";
5985
+ const header = posixHeader(v, macos ? "macOS" : "Linux", "root");
5986
+ const path = "/usr/bin:/bin:/usr/sbin:/sbin";
5987
+ const nodeCandidates = testing ? `"${testing.node}"` : macos ? "/usr/local/bin/node /opt/homebrew/bin/node /usr/bin/node" : "/usr/local/bin/node /usr/bin/node /snap/bin/node";
5988
+ const sha256 = macos ? "shasum -a 256 -c -" : "sha256sum -c -";
5989
+ const owner = macos ? "root:wheel" : "root:root";
5990
+ const rootCheck = testing ? "" : String.raw`if [ "$(id -u)" -ne 0 ]; then
5991
+ log "run this script as root"
5992
+ exit 1
5993
+ fi
5994
+ `;
5995
+ const secureDir = testing ? String.raw`secure_dir() {
5996
+ chmod -R u=rwX,go=rX "$1"
5997
+ }` : String.raw`secure_dir() {
5998
+ chown -R ${owner} "$1" && chmod -R u=rwX,go=rX "$1"
5999
+ }`;
6000
+ const ownerUid = macos ? "stat -f %u" : "stat -c %u";
6001
+ const prepareRoot = String.raw`untrusted() {
6002
+ [ -L "$1" ] || { [ -e "$1" ] && [ "$(${ownerUid} "$1")" != "$(id -u)" ]; }
6003
+ }
6004
+ prepare_root() {
6005
+ if untrusted "${v.installRoot}"; then
6006
+ rm -rf "${v.installRoot}" || return 1
6007
+ fi
6008
+ mkdir -p "${v.installRoot}" && secure_dir "${v.installRoot}" || return 1
6009
+ for path in "${v.installDir}" "${v.installDir}.new" "${v.installDir}.old"; do
6010
+ if untrusted "$path"; then rm -rf "$path" || return 1; fi
6011
+ done
6012
+ }`;
6013
+ let listUsers;
6014
+ if (testing) {
6015
+ listUsers = String.raw`list_users() {
6016
+ printf '%s:%s\n' "$(id -un)" "${testing.home}"
6017
+ }`;
6018
+ } else if (macos) {
6019
+ listUsers = String.raw`list_users() {
6020
+ dscl . list /Users UniqueID | awk '$2 >= 501 {print $1}' | while read -r name; do
6021
+ home="$(dscl . read "/Users/$name" NFSHomeDirectory 2>/dev/null | sed -n 's/^NFSHomeDirectory: //p')"
6022
+ if [ -n "$home" ] && [ -d "$home" ]; then printf '%s:%s\n' "$name" "$home"; fi
6023
+ done
6024
+ }`;
6025
+ } else {
6026
+ listUsers = String.raw`list_users() {
6027
+ getent passwd | awk -F: '$3 >= 1000 && $3 < 60000 {print $1 ":" $6}' | while IFS=: read -r name home; do
6028
+ if [ -n "$home" ] && [ -d "$home" ]; then printf '%s:%s\n' "$name" "$home"; fi
6029
+ done
6030
+ }`;
6031
+ }
6032
+ let runAsUser;
6033
+ if (testing) {
6034
+ runAsUser = String.raw`run_as_user() {
6035
+ shift
6036
+ "$@"
6037
+ }`;
6038
+ } else if (macos) {
6039
+ runAsUser = String.raw`run_as_user() {
6040
+ user="$1"
6041
+ shift
6042
+ sudo -u "$user" -H "$@"
6043
+ }`;
6044
+ } else {
6045
+ runAsUser = String.raw`run_as_user() {
6046
+ user="$1"
6047
+ shift
6048
+ if command -v runuser >/dev/null 2>&1; then
6049
+ runuser -u "$user" -- "$@"
6050
+ else
6051
+ sudo -u "$user" -H "$@"
6052
+ fi
6053
+ }`;
6054
+ }
6055
+ const dir = v.installDir;
6056
+ return `${header}
6057
+ set -u
6058
+ cd / || exit 1
6059
+ PATH="${path}"
6060
+ export PATH
6061
+
6062
+ log() {
6063
+ echo "${v.pluginName}: $*"
6064
+ }
6065
+
6066
+ ${rootCheck}# Node runs only as each user (run_as_user below), never as root.
6067
+ NODE=""
6068
+ for candidate in ${nodeCandidates}; do
6069
+ if [ -x "$candidate" ]; then NODE="$candidate"; break; fi
6070
+ done
6071
+ if [ -z "$NODE" ]; then
6072
+ log "node not found, skipped: install Node.js 18 or later"
6073
+ exit 0
6074
+ fi
6075
+
6076
+ WORK="$(mktemp -d)" || exit 1
6077
+ trap 'rm -rf "$WORK"' EXIT
6078
+
6079
+ ${secureDir}
6080
+
6081
+ ${prepareRoot}
6082
+
6083
+ ${listUsers}
6084
+
6085
+ ${runAsUser}
6086
+
6087
+ installed_version() {
6088
+ sed -n 's/.*"version": *"\\([^"]*\\)".*/\\1/p' "${dir}/package.json" | head -n 1
6089
+ }
6090
+
6091
+ # 1. Install or update the hook from the latest stable release.
6092
+ prepare_root || { log "could not prepare ${v.installRoot}"; exit 1; }
6093
+ if ! curl -fsSL --retry 3 --connect-timeout 20 -o "$WORK/release.sha256" "${v.shaUrl}"; then
6094
+ log "could not download ${v.shaUrl}; keeping the installed version"
6095
+ elif [ -f "${dir}/dist/launcher.mjs" ] && cmp -s "$WORK/release.sha256" "${dir}/.release.sha256"; then
6096
+ log "up to date ($(installed_version))"
6097
+ elif ! curl -fsSL --retry 3 --connect-timeout 20 -o "$WORK/${v.archiveName}" "${v.archiveUrl}"; then
6098
+ log "could not download ${v.archiveUrl}; keeping the installed version"
6099
+ elif ! (cd "$WORK" && grep " ${v.archiveName}\\$" release.sha256 | ${sha256} >/dev/null 2>&1); then
6100
+ log "checksum mismatch for ${v.archiveName}; keeping the installed version"
6101
+ exit 1
6102
+ else
6103
+ rm -rf "${dir}.new"
6104
+ if mkdir "${dir}.new" &&
6105
+ tar -xzf "$WORK/${v.archiveName}" -C "${dir}.new" &&
6106
+ [ -f "${dir}.new/dist/launcher.mjs" ] &&
6107
+ cp "$WORK/release.sha256" "${dir}.new/.release.sha256" &&
6108
+ secure_dir "${dir}.new"; then
6109
+ rm -rf "${dir}.old"
6110
+ if [ -d "${dir}" ] && ! mv "${dir}" "${dir}.old"; then
6111
+ rm -rf "${dir}.new"
6112
+ log "could not replace ${dir}; keeping the installed version"
6113
+ exit 1
6114
+ fi
6115
+ if mv "${dir}.new" "${dir}"; then
6116
+ log "installed $(installed_version) in ${dir}"
6117
+ else
6118
+ # Put the previous version back so existing hook entries keep working.
6119
+ if [ -d "${dir}.old" ]; then mv "${dir}.old" "${dir}"; fi
6120
+ rm -rf "${dir}.new"
6121
+ log "could not activate the new release; keeping the installed version"
6122
+ exit 1
6123
+ fi
6124
+ else
6125
+ rm -rf "${dir}.new"
6126
+ log "could not unpack ${v.archiveName}; keeping the installed version"
6127
+ exit 1
6128
+ fi
6129
+ fi
6130
+
6131
+ if [ ! -f "${dir}/dist/launcher.mjs" ]; then
6132
+ log "not installed yet, so no hook entries were written"
6133
+ exit 1
6134
+ fi
6135
+
6136
+ # 2. Add or repair the hook entry for every user on this device.
6137
+ list_users | while IFS=: read -r name home; do
6138
+ result="$(run_as_user "$name" "$NODE" -e "${ANTIGRAVITY_MERGE_SCRIPT}" "$home/.gemini/config/hooks.json" "${v.entryBase64}" 2>&1)"
6139
+ case "$result" in
6140
+ added) log "hook entry added for $name" ;;
6141
+ updated) log "hook entry updated for $name" ;;
6142
+ unchanged) log "hook entry already set for $name" ;;
6143
+ not-json) log "skipped $name: $home/.gemini/config/hooks.json is not valid JSON" ;;
6144
+ symlink) log "skipped $name: $home/.gemini/config is a symbolic link" ;;
6145
+ *) log "skipped $name: $result" ;;
6146
+ esac
6147
+ done
6148
+ exit 0
6149
+ `;
6150
+ }
6151
+ function windowsMdmScript(collectorUrl, options, testing) {
6152
+ const v = scriptValues(collectorUrl, options, testing);
6153
+ const dir = v.installDir;
6154
+ const taskScript = `${v.installRoot}\\antigravity-setup.ps1`;
6155
+ const adminCheck = testing ? "" : String.raw`$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
6156
+ if (-not ([Security.Principal.WindowsPrincipal]$identity).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
6157
+ Write-Log 'run this script as SYSTEM or as an administrator'
6158
+ exit 1
6159
+ }
6160
+ `;
6161
+ const protectFolder = testing ? String.raw`function Protect-Folder([string]$Path) { }` : String.raw`# Only SYSTEM and Administrators can change the folder; users can read and run it.
6162
+ function Protect-Folder([string]$Path) {
6163
+ $acl = New-Object System.Security.AccessControl.DirectorySecurity
6164
+ $acl.SetAccessRuleProtection($true, $false)
6165
+ $acl.SetOwner((New-Object System.Security.Principal.SecurityIdentifier 'S-1-5-32-544'))
6166
+ foreach ($grant in @(@('S-1-5-18', 'FullControl'), @('S-1-5-32-544', 'FullControl'), @('S-1-5-32-545', 'ReadAndExecute'))) {
6167
+ $sid = New-Object System.Security.Principal.SecurityIdentifier $grant[0]
6168
+ $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($sid, $grant[1], 'ContainerInherit, ObjectInherit', 'None', 'Allow')
6169
+ $acl.AddAccessRule($rule)
6170
+ }
6171
+ Set-Acl -LiteralPath $Path -AclObject $acl
6172
+ }`;
6173
+ const trustCheck = testing ? String.raw`function Test-Trusted([string]$Path) { $true }` : String.raw`# A folder is ours only when it is a real folder (not a junction or link) owned by
6174
+ # SYSTEM or Administrators. Users can create folders under C:\ProgramData before
6175
+ # the first run, and SYSTEM must never act on one of theirs.
6176
+ function Test-Trusted([string]$Path) {
6177
+ $item = Get-Item -LiteralPath $Path -Force
6178
+ if ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) { return $false }
6179
+ $owner = (Get-Acl -LiteralPath $Path).GetOwner([System.Security.Principal.SecurityIdentifier]).Value
6180
+ return ($owner -eq 'S-1-5-18' -or $owner -eq 'S-1-5-32-544')
6181
+ }`;
6182
+ const rootHelpers = String.raw`${trustCheck}
6183
+
6184
+ # Deletes a folder without following junctions: Remove-Item -Recurse in Windows
6185
+ # PowerShell 5.1 follows them and would delete what they point to.
6186
+ function Remove-Tree([string]$Path) {
6187
+ if (-not (Test-Path -LiteralPath $Path)) { return }
6188
+ if ((Get-Item -LiteralPath $Path -Force).PSIsContainer) {
6189
+ cmd.exe /d /c rmdir /s /q "$Path" | Out-Null
6190
+ } else {
6191
+ Remove-Item -LiteralPath $Path -Force
6192
+ }
6193
+ }
6194
+
6195
+ # Creates (or takes back) the install root and drops anything inside it that is
6196
+ # not ours, so SYSTEM only ever touches folders it created.
6197
+ function Initialize-Root {
6198
+ if ((Test-Path -LiteralPath '${v.installRoot}') -and -not (Test-Trusted '${v.installRoot}')) {
6199
+ Remove-Tree '${v.installRoot}'
6200
+ }
6201
+ New-Item -ItemType Directory -Force -Path '${v.installRoot}' | Out-Null
6202
+ Protect-Folder '${v.installRoot}'
6203
+ foreach ($child in @(Get-ChildItem -LiteralPath '${v.installRoot}' -Force)) {
6204
+ if (-not (Test-Trusted $child.FullName)) { Remove-Tree $child.FullName }
6205
+ }
6206
+ }`;
6207
+ const userSetupScript = `${v.installRoot}\\antigravity-user-setup.ps1`;
6208
+ const findNode = String.raw`$node = Get-Command node.exe -CommandType Application -All -ErrorAction SilentlyContinue |
6209
+ Where-Object { $_.Source -notlike '*\WindowsApps\*' } |
6210
+ Select-Object -First 1 -ExpandProperty Source
6211
+ if (-not $node -and (Test-Path -LiteralPath 'C:\Program Files\nodejs\node.exe')) {
6212
+ $node = 'C:\Program Files\nodejs\node.exe'
6213
+ }`;
6214
+ const userSteps = testing ? `$ErrorActionPreference = 'Continue'
6215
+ $result = (& '${testing.node}' -e "${ANTIGRAVITY_MERGE_SCRIPT}" '${testing.home}\\.gemini\\config\\hooks.json' '${v.entryBase64}' 2>&1 | Out-String).Trim()
6216
+ $ErrorActionPreference = 'Stop'
6217
+ Write-Log ('hook entry: ' + $result)` : `$userSetup = @'
6218
+ # Adds or repairs the Google Antigravity hook entry (${v.pluginName}) in the signed-in
6219
+ # user's %USERPROFILE%\\.gemini\\config\\hooks.json, keeping their own hooks.
6220
+ # Written by the ${v.pluginName} MDM script; runs as each user at sign-in and once a day.
6221
+ ${findNode}
6222
+ if (-not $node) { exit 0 }
6223
+ & $node -e "${ANTIGRAVITY_MERGE_SCRIPT}" '${v.entryBase64}' | Out-Null
6224
+ exit 0
6225
+ '@
6226
+ Set-Content -LiteralPath '${userSetupScript}' -Value $userSetup -Encoding UTF8
6227
+ $userAction = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File "${userSetupScript}"'
6228
+ $userTriggers = @((New-ScheduledTaskTrigger -AtLogOn), (New-ScheduledTaskTrigger -Daily -At '09:30'))
6229
+ $userSettings = New-ScheduledTaskSettingsSet -StartWhenAvailable -ExecutionTimeLimit (New-TimeSpan -Minutes 5)
6230
+ $userPrincipal = New-ScheduledTaskPrincipal -GroupId 'S-1-5-32-545' -RunLevel Limited
6231
+ Register-ScheduledTask -TaskName '${v.pluginName} Antigravity user setup' -Action $userAction -Trigger $userTriggers -Settings $userSettings -Principal $userPrincipal -Force | Out-Null
6232
+ try { Start-ScheduledTask -TaskName '${v.pluginName} Antigravity user setup' } catch { }
6233
+ Write-Log 'the user setup task adds or repairs the hook entry for each user at sign-in and once a day'`;
6234
+ const header = [
6235
+ `# Google Antigravity agent hooks (${v.pluginName}) for Windows.`,
6236
+ "# Generated for your organization: every value is already filled in, do not edit it.",
6237
+ "# Run it as SYSTEM once a day on every device. Each run:",
6238
+ `# 1. installs or updates the hook from the latest stable release of https://github.com/${v.marketplaceRepo}`,
6239
+ `# into ${dir} (only when that release changed);`,
6240
+ "# 2. registers a task that runs as each signed-in user (at sign-in and daily) and adds or",
6241
+ "# repairs the hook entry in that user's %USERPROFILE%\\.gemini\\config\\hooks.json,",
6242
+ "# keeping the user's own hooks. SYSTEM never writes inside a user profile.",
6243
+ "# Running it again changes nothing that is already in place.",
6244
+ "# -RegisterDailyTask also registers a daily SYSTEM scheduled task that runs this script."
6245
+ ].join("\n");
6246
+ return `${header}
6247
+ param([switch]$RegisterDailyTask)
6248
+ $ErrorActionPreference = 'Stop'
6249
+ $ProgressPreference = 'SilentlyContinue'
6250
+ [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
6251
+
6252
+ function Write-Log([string]$Message) {
6253
+ Write-Output ('${v.pluginName}: ' + $Message)
6254
+ }
6255
+
6256
+ ${protectFolder}
6257
+
6258
+ ${rootHelpers}
6259
+
6260
+ function Get-InstalledVersion {
6261
+ (Get-Content -Raw -LiteralPath '${dir}\\package.json' | ConvertFrom-Json).version
6262
+ }
6263
+
6264
+ ${adminCheck}if ($RegisterDailyTask) {
6265
+ Initialize-Root
6266
+ Copy-Item -LiteralPath $PSCommandPath -Destination '${taskScript}' -Force
6267
+ $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-NoProfile -ExecutionPolicy Bypass -File "${taskScript}"'
6268
+ $triggers = @((New-ScheduledTaskTrigger -Daily -At '09:00'), (New-ScheduledTaskTrigger -AtStartup))
6269
+ $settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -ExecutionTimeLimit (New-TimeSpan -Minutes 30)
6270
+ $principal = New-ScheduledTaskPrincipal -UserId 'S-1-5-18' -LogonType ServiceAccount -RunLevel Highest
6271
+ Register-ScheduledTask -TaskName '${v.pluginName} Antigravity' -Action $action -Trigger $triggers -Settings $settings -Principal $principal -Force | Out-Null
6272
+ Write-Log 'registered the daily scheduled task'
6273
+ }
6274
+
6275
+ ${findNode}
6276
+ if (-not $node) {
6277
+ Write-Log 'node not found, skipped: install Node.js 18 or later'
6278
+ exit 0
6279
+ }
6280
+
6281
+ Initialize-Root
6282
+
6283
+ $work = Join-Path ([IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
6284
+ New-Item -ItemType Directory -Path $work | Out-Null
6285
+ try {
6286
+ # 1. Install or update the hook from the latest stable release.
6287
+ $shaFile = Join-Path $work 'release.sha256'
6288
+ $archive = Join-Path $work '${v.archiveName}'
6289
+ $installed = Test-Path -LiteralPath '${dir}\\dist\\launcher.mjs'
6290
+ $current = ''
6291
+ if (Test-Path -LiteralPath '${dir}\\.release.sha256') {
6292
+ $current = Get-Content -Raw -LiteralPath '${dir}\\.release.sha256'
6293
+ }
6294
+ $downloaded = $true
6295
+ try {
6296
+ Invoke-WebRequest -UseBasicParsing -Uri '${v.shaUrl}' -OutFile $shaFile
6297
+ } catch {
6298
+ $downloaded = $false
6299
+ Write-Log 'could not download ${v.shaUrl}; keeping the installed version'
6300
+ }
6301
+ if ($downloaded -and $installed -and ((Get-Content -Raw -LiteralPath $shaFile) -eq $current)) {
6302
+ Write-Log ('up to date (' + (Get-InstalledVersion) + ')')
6303
+ } elseif ($downloaded) {
6304
+ try {
6305
+ Invoke-WebRequest -UseBasicParsing -Uri '${v.archiveUrl}' -OutFile $archive
6306
+ } catch {
6307
+ $downloaded = $false
6308
+ Write-Log 'could not download ${v.archiveUrl}; keeping the installed version'
6309
+ }
6310
+ }
6311
+ if ($downloaded -and -not ($installed -and ((Get-Content -Raw -LiteralPath $shaFile) -eq $current))) {
6312
+ $expected = Get-Content -LiteralPath $shaFile |
6313
+ Where-Object { ($_.Trim() -split '\\s+')[-1].TrimStart('*') -eq '${v.archiveName}' } |
6314
+ ForEach-Object { ($_.Trim() -split '\\s+')[0] } |
6315
+ Select-Object -First 1
6316
+ if (-not $expected -or $expected -ne (Get-FileHash -Algorithm SHA256 -LiteralPath $archive).Hash) {
6317
+ Write-Log 'checksum mismatch for ${v.archiveName}; keeping the installed version'
6318
+ exit 1
6319
+ }
6320
+ try {
6321
+ Remove-Tree '${dir}.new'
6322
+ Expand-Archive -LiteralPath $archive -DestinationPath '${dir}.new' -Force
6323
+ if (-not (Test-Path -LiteralPath '${dir}.new\\dist\\launcher.mjs')) { throw 'the release has no dist\\launcher.mjs' }
6324
+ Copy-Item -LiteralPath $shaFile -Destination '${dir}.new\\.release.sha256'
6325
+ Remove-Tree '${dir}.old'
6326
+ if (Test-Path -LiteralPath '${dir}') { Rename-Item -LiteralPath '${dir}' -NewName 'antigravity.old' }
6327
+ Rename-Item -LiteralPath '${dir}.new' -NewName 'antigravity'
6328
+ Write-Log ('installed ' + (Get-InstalledVersion) + ' in ${dir}')
6329
+ } catch {
6330
+ # Put the previous version back so existing hook entries keep working.
6331
+ if (-not (Test-Path -LiteralPath '${dir}') -and (Test-Path -LiteralPath '${dir}.old')) {
6332
+ Rename-Item -LiteralPath '${dir}.old' -NewName 'antigravity'
6333
+ }
6334
+ Remove-Tree '${dir}.new'
6335
+ Write-Log ('could not install the release, keeping the installed version: ' + $_.Exception.Message)
6336
+ }
6337
+ }
6338
+
6339
+ if (-not (Test-Path -LiteralPath '${dir}\\dist\\launcher.mjs')) {
6340
+ Write-Log 'not installed yet, so no hook entries were written'
6341
+ exit 1
6342
+ }
6343
+
6344
+ # 2. Add or repair the hook entry for every user on this device.
6345
+ ${userSteps}
6346
+ } finally {
6347
+ Remove-Tree $work
6348
+ }
6349
+ exit 0
6350
+ `;
6351
+ }
6352
+ function managedAntigravityMdmScript(collectorUrl, options, testing) {
6353
+ return options.os === "windows" ? windowsMdmScript(collectorUrl, options, testing) : posixMdmScript(collectorUrl, options, testing);
6354
+ }
6355
+ function antigravityMdmScriptFileName(pluginName, os) {
6356
+ assertPluginName(pluginName);
6357
+ return `${pluginName}-antigravity-${os}.${os === "windows" ? "ps1" : "sh"}`;
6358
+ }
4878
6359
 
4879
6360
  // src/install/managed-hooks-snippet.ts
4880
6361
  var CLAUDE_MANAGED_HOOK_TIMEOUT_SECONDS = CLAUDE_HOOK_TIMEOUT_SECONDS;
@@ -4952,8 +6433,14 @@ hooks = true
4952
6433
 
4953
6434
  ${hooks}`;
4954
6435
  }
6436
+ function managedAntigravityHooksJson(collectorUrl, options = {}) {
6437
+ return JSON.stringify(antigravityHooksEntry(collectorUrl, options), null, 2);
6438
+ }
4955
6439
  var COPILOT_ENTERPRISE_MARKETPLACE_REPO = "ORG/.github-private";
4956
6440
  function managedCopilotPluginSettings(collectorUrl, options) {
6441
+ const marketplaceName = options.marketplaceName ?? MARKETPLACE_NAME;
6442
+ const pluginName = options.pluginName ?? MARKETPLACE_PLUGIN_NAME;
6443
+ const ownerName = options.ownerName ?? "ev-ai";
4957
6444
  const mcpServer = {
4958
6445
  command: "node",
4959
6446
  args: [`\${PLUGIN_ROOT}/${PLUGIN_COLLECTOR_URL_MCP_SCRIPT}`, collectorUrl],
@@ -4961,39 +6448,48 @@ function managedCopilotPluginSettings(collectorUrl, options) {
4961
6448
  env: { COLLECTOR_URL: collectorUrl }
4962
6449
  };
4963
6450
  const marketplace = {
4964
- name: MARKETPLACE_NAME,
4965
- owner: { name: "ev-ai" },
6451
+ name: marketplaceName,
6452
+ owner: { name: ownerName },
4966
6453
  plugins: [
4967
6454
  {
4968
- name: MARKETPLACE_PLUGIN_NAME,
6455
+ name: pluginName,
4969
6456
  description: "Runtime telemetry hooks for GitHub Copilot (observe-only, fail-open).",
4970
6457
  source: {
4971
6458
  source: "github",
4972
6459
  repo: options.sourceRepo,
4973
6460
  path: MARKETPLACE_PLUGIN_DIRS.copilot
4974
6461
  },
4975
- mcpServers: { [MARKETPLACE_PLUGIN_NAME]: mcpServer }
6462
+ mcpServers: { [pluginName]: mcpServer }
4976
6463
  }
4977
6464
  ]
4978
6465
  };
4979
6466
  return {
4980
6467
  marketplaceJson: JSON.stringify(marketplace, null, 2),
4981
6468
  extraKnownMarketplaces: {
4982
- [MARKETPLACE_NAME]: {
6469
+ [marketplaceName]: {
4983
6470
  source: { source: "github", repo: COPILOT_ENTERPRISE_MARKETPLACE_REPO },
4984
6471
  autoUpdate: true
4985
6472
  }
4986
6473
  },
4987
- enabledPlugins: { [`${MARKETPLACE_PLUGIN_NAME}@${MARKETPLACE_NAME}`]: true },
4988
- mcpAllowlistEntry: { serverName: MARKETPLACE_PLUGIN_NAME }
6474
+ enabledPlugins: { [`${pluginName}@${marketplaceName}`]: true },
6475
+ mcpAllowlistEntry: { serverName: pluginName }
4989
6476
  };
4990
6477
  }
4991
6478
  export {
6479
+ ANTIGRAVITY_HOOK_NAME,
6480
+ ANTIGRAVITY_MERGE_SCRIPT,
6481
+ ANTIGRAVITY_OPERATING_SYSTEMS,
4992
6482
  CLAUDE_MANAGED_HOOK_TIMEOUT_SECONDS,
4993
6483
  CLAUDE_MANAGED_SESSION_START_TIMEOUT_SECONDS,
4994
6484
  COPILOT_ENTERPRISE_MARKETPLACE_REPO,
4995
6485
  NPX_PACKAGE_SPEC,
6486
+ antigravityInstallDir,
6487
+ antigravityMdmScriptFileName,
6488
+ antigravityMergeCommand,
6489
+ antigravityReleaseAssets,
4996
6490
  buildCollectorUrl,
6491
+ managedAntigravityHooksJson,
6492
+ managedAntigravityMdmScript,
4997
6493
  managedCodexConfigTomlSnippet,
4998
6494
  managedCopilotPluginSettings,
4999
6495
  managedHooksSnippet,