@ever-works/hermes-agent-plugin 1.0.10 → 1.0.12

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.
Files changed (3) hide show
  1. package/dist/index.cjs +178 -13
  2. package/dist/index.js +178 -13
  3. package/package.json +6 -6
package/dist/index.cjs CHANGED
@@ -504,6 +504,13 @@ var PLATFORM_DEFAULT_MERGE_POLICY = Object.freeze({
504
504
  allowedMergeMethods: ["squash"],
505
505
  protectedBranches: ["main", "master", "develop", "stage"]
506
506
  });
507
+ var MERGE_POLICY_PROTECTED_BRANCH_FLOOR = Object.freeze([
508
+ "main",
509
+ "master",
510
+ "develop",
511
+ "stage"
512
+ ]);
513
+ var MERGE_POLICY_ALWAYS_APPROVED_BRANCHES = Object.freeze(["main", "master"]);
507
514
  var MERGE_APPROVAL_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
508
515
  var TOOL_GRANT_SCOPE_PRECEDENCE = Object.freeze([
509
516
  "tenant",
@@ -1216,6 +1223,111 @@ var FLEET_HEALTH_DISK_CRITICAL_MARGIN_BYTES = 1024 ** 3;
1216
1223
  var FLEET_HEALTH_MAX_MIB = 2 ** 40;
1217
1224
  var FLEET_HEALTH_MAX_UPTIME_SEC = 100 * 365 * 24 * 60 * 60;
1218
1225
  var FLEET_HEALTH_BYTES_PER_MIB = 1024 * 1024;
1226
+ var FLEET_RUN_TOKEN_ROUTES = Object.freeze([
1227
+ // Works — reads, plus the settings update (its merge / check / command
1228
+ // fields are refused for run tokens by the Works controller).
1229
+ { method: "GET", pathPattern: "/api/works" },
1230
+ { method: "GET", pathPattern: "/api/works/{id}" },
1231
+ { method: "PUT", pathPattern: "/api/works/{id}" },
1232
+ { method: "GET", pathPattern: "/api/works/{id}/config" },
1233
+ { method: "GET", pathPattern: "/api/works/{id}/items" },
1234
+ { method: "GET", pathPattern: "/api/works/{id}/categories-tags" },
1235
+ { method: "GET", pathPattern: "/api/works/{id}/history" },
1236
+ { method: "GET", pathPattern: "/api/works/{id}/generator-form" },
1237
+ { method: "GET", pathPattern: "/api/works/{id}/schedule" },
1238
+ { method: "GET", pathPattern: "/api/works/{id}/comparisons" },
1239
+ { method: "GET", pathPattern: "/api/works/{id}/comparisons/{slug}" },
1240
+ // Knowledge Base (`apps/mcp/src/tools/kb`). A document a run token writes
1241
+ // lands `proposed` (review-gated), see the KB controller. No unlock.
1242
+ { method: "GET", pathPattern: "/api/works/{id}/kb/documents" },
1243
+ { method: "POST", pathPattern: "/api/works/{id}/kb/documents" },
1244
+ { method: "GET", pathPattern: "/api/works/{id}/kb/documents/{docIdOrPath}" },
1245
+ { method: "PATCH", pathPattern: "/api/works/{id}/kb/documents/{docId}" },
1246
+ { method: "POST", pathPattern: "/api/works/{id}/kb/documents/{docId}/lock" },
1247
+ // Deploy — reads and the capability check only.
1248
+ { method: "GET", pathPattern: "/api/deploy/works/{id}/domains" },
1249
+ { method: "GET", pathPattern: "/api/deploy/providers" },
1250
+ { method: "POST", pathPattern: "/api/deploy/works/{id}/check" },
1251
+ // Plugins — read only.
1252
+ { method: "GET", pathPattern: "/api/plugins" },
1253
+ { method: "GET", pathPattern: "/api/plugins/{pluginId}" },
1254
+ // Missions — reads, plus pause (the safe direction).
1255
+ { method: "GET", pathPattern: "/api/me/missions" },
1256
+ { method: "GET", pathPattern: "/api/me/missions/{id}" },
1257
+ { method: "GET", pathPattern: "/api/me/missions/{id}/budget" },
1258
+ { method: "GET", pathPattern: "/api/me/missions/{id}/works" },
1259
+ { method: "POST", pathPattern: "/api/me/missions/{id}/pause" },
1260
+ // Ideas — reads, plus filing a new Idea (a proposal a person builds).
1261
+ { method: "POST", pathPattern: "/api/me/work-proposals" },
1262
+ { method: "GET", pathPattern: "/api/me/work-proposals" },
1263
+ { method: "GET", pathPattern: "/api/me/work-proposals/status" },
1264
+ { method: "GET", pathPattern: "/api/me/work-proposals/preferences" },
1265
+ { method: "GET", pathPattern: "/api/me/work-proposals/{id}" },
1266
+ { method: "GET", pathPattern: "/api/me/work-proposals/{id}/budget" },
1267
+ // Account-wide usage.
1268
+ { method: "GET", pathPattern: "/api/me/usage/account-wide" },
1269
+ // Tasks — reads and collaboration writes. Create / update / transition /
1270
+ // assign / chat carry body refusals for run tokens in the Tasks
1271
+ // controller (no checks, no schedule, no force, no dispatch, no @agent).
1272
+ { method: "GET", pathPattern: "/api/tasks" },
1273
+ { method: "POST", pathPattern: "/api/tasks" },
1274
+ { method: "GET", pathPattern: "/api/tasks/{id}" },
1275
+ { method: "PATCH", pathPattern: "/api/tasks/{id}" },
1276
+ { method: "GET", pathPattern: "/api/tasks/{id}/subtasks" },
1277
+ { method: "GET", pathPattern: "/api/tasks/{id}/activity" },
1278
+ { method: "POST", pathPattern: "/api/tasks/{id}/transition" },
1279
+ { method: "GET", pathPattern: "/api/tasks/{id}/run-candidates" },
1280
+ { method: "GET", pathPattern: "/api/tasks/{id}/pr-status" },
1281
+ { method: "GET", pathPattern: "/api/tasks/{id}/diff" },
1282
+ { method: "POST", pathPattern: "/api/tasks/{id}/assignees" },
1283
+ { method: "POST", pathPattern: "/api/tasks/{id}/reviewers" },
1284
+ { method: "POST", pathPattern: "/api/tasks/{id}/approvers" },
1285
+ { method: "POST", pathPattern: "/api/tasks/{id}/relations" },
1286
+ { method: "GET", pathPattern: "/api/tasks/{id}/escalations" },
1287
+ { method: "GET", pathPattern: "/api/tasks/{id}/chat" },
1288
+ { method: "POST", pathPattern: "/api/tasks/{id}/chat" },
1289
+ { method: "GET", pathPattern: "/api/tasks/{id}/spend" },
1290
+ // Inbox — read only (no reply, no archive / delete / mark-read).
1291
+ { method: "GET", pathPattern: "/api/inbox" },
1292
+ { method: "GET", pathPattern: "/api/inbox/unread-count" },
1293
+ { method: "GET", pathPattern: "/api/inbox/{id}" },
1294
+ // Goals — reads, a draft create, field-limited update, pause, and the
1295
+ // ASKING side of the definition of done (propose, never approve).
1296
+ { method: "GET", pathPattern: "/api/me/goals" },
1297
+ { method: "POST", pathPattern: "/api/me/goals" },
1298
+ { method: "GET", pathPattern: "/api/me/goals/{id}" },
1299
+ { method: "PATCH", pathPattern: "/api/me/goals/{id}" },
1300
+ { method: "GET", pathPattern: "/api/me/goals/{id}/samples" },
1301
+ { method: "POST", pathPattern: "/api/me/goals/{id}/pause" },
1302
+ { method: "POST", pathPattern: "/api/me/goals/{id}/dod/propose" },
1303
+ // Fleet — reads only.
1304
+ { method: "GET", pathPattern: "/api/fleet/nodes" },
1305
+ { method: "GET", pathPattern: "/api/fleet/nodes/{id}" },
1306
+ { method: "GET", pathPattern: "/api/fleet/runner-status" },
1307
+ { method: "GET", pathPattern: "/api/fleet/execution-preferences" },
1308
+ { method: "GET", pathPattern: "/api/fleet/agents/{agentId}/node-affinity" },
1309
+ // Agents — reads, plus cancel and pause (the safe direction).
1310
+ { method: "GET", pathPattern: "/api/agents" },
1311
+ { method: "GET", pathPattern: "/api/agents/{id}" },
1312
+ { method: "GET", pathPattern: "/api/agents/{id}/runs" },
1313
+ { method: "GET", pathPattern: "/api/agents/{id}/runs/{runId}" },
1314
+ { method: "POST", pathPattern: "/api/agents/{id}/runs/{runId}/cancel" },
1315
+ { method: "POST", pathPattern: "/api/agents/{id}/pause" },
1316
+ { method: "GET", pathPattern: "/api/agents/{id}/budget" },
1317
+ // Agent Plugins — read only (installing a package installs instructions).
1318
+ { method: "GET", pathPattern: "/api/agent-plugins" },
1319
+ { method: "GET", pathPattern: "/api/agent-plugins/findings" },
1320
+ { method: "GET", pathPattern: "/api/agent-plugins/catalog" },
1321
+ { method: "GET", pathPattern: "/api/agent-plugins/updates" }
1322
+ ]);
1323
+ var MACHINE_PRINCIPAL_WORK_WRITABLE_FIELDS = Object.freeze(["name", "description"]);
1324
+ function splitSegments(normalizedPath) {
1325
+ return normalizedPath.split("/").filter((segment) => segment.length > 0);
1326
+ }
1327
+ var FLEET_RUN_TOKEN_ROUTE_SHAPES = FLEET_RUN_TOKEN_ROUTES.map((route) => ({
1328
+ method: route.method.toUpperCase(),
1329
+ shape: splitSegments(route.pathPattern).map((part) => /^\{[^}]+\}$/.test(part) ? "*" : part.toLowerCase())
1330
+ }));
1219
1331
  var EMAIL_INBOX_DEFAULT_DAILY_CAP = 100;
1220
1332
  var EMAIL_INBOX_BURST_SENDS = 10;
1221
1333
  var EMAIL_INBOX_BURST_RECIPIENTS = 20;
@@ -1757,9 +1869,15 @@ var INTEGRATION_SCOPES = [
1757
1869
  "email:write",
1758
1870
  "events:read",
1759
1871
  "webhooks:manage",
1760
- "links:write"
1872
+ "links:write",
1873
+ "merges:decide"
1874
+ ];
1875
+ var INTEGRATION_MERGE_DECISION_SCOPE = "merges:decide";
1876
+ var INTEGRATION_OPT_IN_SCOPES = [
1877
+ "org:write",
1878
+ "email:write",
1879
+ INTEGRATION_MERGE_DECISION_SCOPE
1761
1880
  ];
1762
- var INTEGRATION_OPT_IN_SCOPES = ["org:write", "email:write"];
1763
1881
  var EVER_GAUZY_PRESET_SCOPES = INTEGRATION_SCOPES.filter(
1764
1882
  (scope) => !INTEGRATION_OPT_IN_SCOPES.includes(scope)
1765
1883
  );
@@ -3655,6 +3773,7 @@ function isSafeWebhookUrl(rawUrl) {
3655
3773
  if (host.startsWith("[") && host.endsWith("]")) {
3656
3774
  host = host.slice(1, -1);
3657
3775
  }
3776
+ host = host.replace(/\.+$/, "");
3658
3777
  if (CLOUD_METADATA_HOSTNAMES.has(host)) {
3659
3778
  return false;
3660
3779
  }
@@ -3684,23 +3803,69 @@ function isPrivateIPv4(ip) {
3684
3803
  if (a === 172 && b >= 16 && b <= 31) return true;
3685
3804
  if (a === 192 && b === 168) return true;
3686
3805
  if (a === 192 && b === 0 && parts[2] === 0) return true;
3806
+ if (a === 198 && (b === 18 || b === 19)) return true;
3807
+ if (a === 192 && b === 0 && parts[2] === 2) return true;
3808
+ if (a === 198 && b === 51 && parts[2] === 100) return true;
3809
+ if (a === 203 && b === 0 && parts[2] === 113) return true;
3687
3810
  if (a === 100 && b >= 64 && b <= 127) return true;
3688
3811
  if (a >= 224) return true;
3689
3812
  return false;
3690
3813
  }
3691
- function isPrivateIPv6(ip) {
3692
- const lower = ip.toLowerCase();
3693
- if (lower === "::1" || lower === "::") return true;
3694
- if (lower.startsWith("fc") || lower.startsWith("fd")) return true;
3695
- const firstHextet = lower.split(":", 1)[0];
3696
- if (/^[0-9a-f]{1,4}$/.test(firstHextet)) {
3697
- const group0 = parseInt(firstHextet, 16);
3698
- if ((group0 & 65472) === 65152) return true;
3814
+ function parseIPv6Groups(ip) {
3815
+ let text = ip.trim().toLowerCase();
3816
+ const zone = text.indexOf("%");
3817
+ if (zone >= 0) text = text.slice(0, zone);
3818
+ if ((0, import_net.isIP)(text) !== 6) return null;
3819
+ const lastColon = text.lastIndexOf(":");
3820
+ const tail = text.slice(lastColon + 1);
3821
+ if (tail.includes(".")) {
3822
+ if ((0, import_net.isIP)(tail) !== 4) return null;
3823
+ const [a, b, c, d] = tail.split(".").map((part) => Number(part));
3824
+ text = `${text.slice(0, lastColon + 1)}${(a << 8 | b).toString(16)}:${(c << 8 | d).toString(16)}`;
3825
+ }
3826
+ const halves = text.split("::");
3827
+ if (halves.length > 2) return null;
3828
+ const head = halves[0] ? halves[0].split(":") : [];
3829
+ const rest = halves.length === 2 && halves[1] ? halves[1].split(":") : [];
3830
+ const fill = halves.length === 2 ? 8 - head.length - rest.length : 0;
3831
+ if (fill < 0) return null;
3832
+ const groups = [...head, ...new Array(fill).fill("0"), ...rest].map((group) => parseInt(group, 16));
3833
+ if (groups.length !== 8 || groups.some((group) => Number.isNaN(group) || group < 0 || group > 65535)) {
3834
+ return null;
3699
3835
  }
3700
- if (lower.startsWith("::ffff:")) {
3701
- const v4 = lower.slice("::ffff:".length);
3702
- if ((0, import_net.isIP)(v4) === 4) return isPrivateIPv4(v4);
3836
+ return groups;
3837
+ }
3838
+ function ipv4FromGroups(high, low) {
3839
+ return `${high >> 8}.${high & 255}.${low >> 8}.${low & 255}`;
3840
+ }
3841
+ function embeddedIPv4(ip) {
3842
+ const g = parseIPv6Groups(ip);
3843
+ if (!g) return null;
3844
+ const zeros = (from, to) => g.slice(from, to).every((group) => group === 0);
3845
+ if (zeros(0, 5) && g[5] === 65535) return ipv4FromGroups(g[6], g[7]);
3846
+ if (zeros(0, 4) && g[4] === 65535 && g[5] === 0) return ipv4FromGroups(g[6], g[7]);
3847
+ if (zeros(0, 6) && (g[6] !== 0 || g[7] > 1)) return ipv4FromGroups(g[6], g[7]);
3848
+ if (g[0] === 100 && g[1] === 65435 && zeros(2, 6)) return ipv4FromGroups(g[6], g[7]);
3849
+ if (g[0] === 8194) return ipv4FromGroups(g[1], g[2]);
3850
+ if (g[0] === 8193 && g[1] === 0) return ipv4FromGroups(g[6] ^ 65535, g[7] ^ 65535);
3851
+ return null;
3852
+ }
3853
+ function isPrivateIPv6(ip) {
3854
+ const g = parseIPv6Groups(ip);
3855
+ if (!g) {
3856
+ const lower = ip.toLowerCase();
3857
+ return lower === "::1" || lower === "::" || lower.startsWith("fc") || lower.startsWith("fd");
3703
3858
  }
3859
+ if (g.every((group) => group === 0)) return true;
3860
+ if (g.slice(0, 7).every((group) => group === 0) && g[7] === 1) return true;
3861
+ if ((g[0] & 65024) === 64512) return true;
3862
+ if ((g[0] & 65472) === 65152) return true;
3863
+ if ((g[0] & 65472) === 65216) return true;
3864
+ if ((g[0] & 65280) === 65280) return true;
3865
+ if (g[0] === 8193 && g[1] === 3512) return true;
3866
+ if (g[0] === 100 && g[1] === 65435 && g[2] === 1) return true;
3867
+ const v4 = embeddedIPv4(ip);
3868
+ if (v4 && isPrivateIPv4(v4)) return true;
3704
3869
  return false;
3705
3870
  }
3706
3871
 
package/dist/index.js CHANGED
@@ -465,6 +465,13 @@ var PLATFORM_DEFAULT_MERGE_POLICY = Object.freeze({
465
465
  allowedMergeMethods: ["squash"],
466
466
  protectedBranches: ["main", "master", "develop", "stage"]
467
467
  });
468
+ var MERGE_POLICY_PROTECTED_BRANCH_FLOOR = Object.freeze([
469
+ "main",
470
+ "master",
471
+ "develop",
472
+ "stage"
473
+ ]);
474
+ var MERGE_POLICY_ALWAYS_APPROVED_BRANCHES = Object.freeze(["main", "master"]);
468
475
  var MERGE_APPROVAL_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
469
476
  var TOOL_GRANT_SCOPE_PRECEDENCE = Object.freeze([
470
477
  "tenant",
@@ -1177,6 +1184,111 @@ var FLEET_HEALTH_DISK_CRITICAL_MARGIN_BYTES = 1024 ** 3;
1177
1184
  var FLEET_HEALTH_MAX_MIB = 2 ** 40;
1178
1185
  var FLEET_HEALTH_MAX_UPTIME_SEC = 100 * 365 * 24 * 60 * 60;
1179
1186
  var FLEET_HEALTH_BYTES_PER_MIB = 1024 * 1024;
1187
+ var FLEET_RUN_TOKEN_ROUTES = Object.freeze([
1188
+ // Works — reads, plus the settings update (its merge / check / command
1189
+ // fields are refused for run tokens by the Works controller).
1190
+ { method: "GET", pathPattern: "/api/works" },
1191
+ { method: "GET", pathPattern: "/api/works/{id}" },
1192
+ { method: "PUT", pathPattern: "/api/works/{id}" },
1193
+ { method: "GET", pathPattern: "/api/works/{id}/config" },
1194
+ { method: "GET", pathPattern: "/api/works/{id}/items" },
1195
+ { method: "GET", pathPattern: "/api/works/{id}/categories-tags" },
1196
+ { method: "GET", pathPattern: "/api/works/{id}/history" },
1197
+ { method: "GET", pathPattern: "/api/works/{id}/generator-form" },
1198
+ { method: "GET", pathPattern: "/api/works/{id}/schedule" },
1199
+ { method: "GET", pathPattern: "/api/works/{id}/comparisons" },
1200
+ { method: "GET", pathPattern: "/api/works/{id}/comparisons/{slug}" },
1201
+ // Knowledge Base (`apps/mcp/src/tools/kb`). A document a run token writes
1202
+ // lands `proposed` (review-gated), see the KB controller. No unlock.
1203
+ { method: "GET", pathPattern: "/api/works/{id}/kb/documents" },
1204
+ { method: "POST", pathPattern: "/api/works/{id}/kb/documents" },
1205
+ { method: "GET", pathPattern: "/api/works/{id}/kb/documents/{docIdOrPath}" },
1206
+ { method: "PATCH", pathPattern: "/api/works/{id}/kb/documents/{docId}" },
1207
+ { method: "POST", pathPattern: "/api/works/{id}/kb/documents/{docId}/lock" },
1208
+ // Deploy — reads and the capability check only.
1209
+ { method: "GET", pathPattern: "/api/deploy/works/{id}/domains" },
1210
+ { method: "GET", pathPattern: "/api/deploy/providers" },
1211
+ { method: "POST", pathPattern: "/api/deploy/works/{id}/check" },
1212
+ // Plugins — read only.
1213
+ { method: "GET", pathPattern: "/api/plugins" },
1214
+ { method: "GET", pathPattern: "/api/plugins/{pluginId}" },
1215
+ // Missions — reads, plus pause (the safe direction).
1216
+ { method: "GET", pathPattern: "/api/me/missions" },
1217
+ { method: "GET", pathPattern: "/api/me/missions/{id}" },
1218
+ { method: "GET", pathPattern: "/api/me/missions/{id}/budget" },
1219
+ { method: "GET", pathPattern: "/api/me/missions/{id}/works" },
1220
+ { method: "POST", pathPattern: "/api/me/missions/{id}/pause" },
1221
+ // Ideas — reads, plus filing a new Idea (a proposal a person builds).
1222
+ { method: "POST", pathPattern: "/api/me/work-proposals" },
1223
+ { method: "GET", pathPattern: "/api/me/work-proposals" },
1224
+ { method: "GET", pathPattern: "/api/me/work-proposals/status" },
1225
+ { method: "GET", pathPattern: "/api/me/work-proposals/preferences" },
1226
+ { method: "GET", pathPattern: "/api/me/work-proposals/{id}" },
1227
+ { method: "GET", pathPattern: "/api/me/work-proposals/{id}/budget" },
1228
+ // Account-wide usage.
1229
+ { method: "GET", pathPattern: "/api/me/usage/account-wide" },
1230
+ // Tasks — reads and collaboration writes. Create / update / transition /
1231
+ // assign / chat carry body refusals for run tokens in the Tasks
1232
+ // controller (no checks, no schedule, no force, no dispatch, no @agent).
1233
+ { method: "GET", pathPattern: "/api/tasks" },
1234
+ { method: "POST", pathPattern: "/api/tasks" },
1235
+ { method: "GET", pathPattern: "/api/tasks/{id}" },
1236
+ { method: "PATCH", pathPattern: "/api/tasks/{id}" },
1237
+ { method: "GET", pathPattern: "/api/tasks/{id}/subtasks" },
1238
+ { method: "GET", pathPattern: "/api/tasks/{id}/activity" },
1239
+ { method: "POST", pathPattern: "/api/tasks/{id}/transition" },
1240
+ { method: "GET", pathPattern: "/api/tasks/{id}/run-candidates" },
1241
+ { method: "GET", pathPattern: "/api/tasks/{id}/pr-status" },
1242
+ { method: "GET", pathPattern: "/api/tasks/{id}/diff" },
1243
+ { method: "POST", pathPattern: "/api/tasks/{id}/assignees" },
1244
+ { method: "POST", pathPattern: "/api/tasks/{id}/reviewers" },
1245
+ { method: "POST", pathPattern: "/api/tasks/{id}/approvers" },
1246
+ { method: "POST", pathPattern: "/api/tasks/{id}/relations" },
1247
+ { method: "GET", pathPattern: "/api/tasks/{id}/escalations" },
1248
+ { method: "GET", pathPattern: "/api/tasks/{id}/chat" },
1249
+ { method: "POST", pathPattern: "/api/tasks/{id}/chat" },
1250
+ { method: "GET", pathPattern: "/api/tasks/{id}/spend" },
1251
+ // Inbox — read only (no reply, no archive / delete / mark-read).
1252
+ { method: "GET", pathPattern: "/api/inbox" },
1253
+ { method: "GET", pathPattern: "/api/inbox/unread-count" },
1254
+ { method: "GET", pathPattern: "/api/inbox/{id}" },
1255
+ // Goals — reads, a draft create, field-limited update, pause, and the
1256
+ // ASKING side of the definition of done (propose, never approve).
1257
+ { method: "GET", pathPattern: "/api/me/goals" },
1258
+ { method: "POST", pathPattern: "/api/me/goals" },
1259
+ { method: "GET", pathPattern: "/api/me/goals/{id}" },
1260
+ { method: "PATCH", pathPattern: "/api/me/goals/{id}" },
1261
+ { method: "GET", pathPattern: "/api/me/goals/{id}/samples" },
1262
+ { method: "POST", pathPattern: "/api/me/goals/{id}/pause" },
1263
+ { method: "POST", pathPattern: "/api/me/goals/{id}/dod/propose" },
1264
+ // Fleet — reads only.
1265
+ { method: "GET", pathPattern: "/api/fleet/nodes" },
1266
+ { method: "GET", pathPattern: "/api/fleet/nodes/{id}" },
1267
+ { method: "GET", pathPattern: "/api/fleet/runner-status" },
1268
+ { method: "GET", pathPattern: "/api/fleet/execution-preferences" },
1269
+ { method: "GET", pathPattern: "/api/fleet/agents/{agentId}/node-affinity" },
1270
+ // Agents — reads, plus cancel and pause (the safe direction).
1271
+ { method: "GET", pathPattern: "/api/agents" },
1272
+ { method: "GET", pathPattern: "/api/agents/{id}" },
1273
+ { method: "GET", pathPattern: "/api/agents/{id}/runs" },
1274
+ { method: "GET", pathPattern: "/api/agents/{id}/runs/{runId}" },
1275
+ { method: "POST", pathPattern: "/api/agents/{id}/runs/{runId}/cancel" },
1276
+ { method: "POST", pathPattern: "/api/agents/{id}/pause" },
1277
+ { method: "GET", pathPattern: "/api/agents/{id}/budget" },
1278
+ // Agent Plugins — read only (installing a package installs instructions).
1279
+ { method: "GET", pathPattern: "/api/agent-plugins" },
1280
+ { method: "GET", pathPattern: "/api/agent-plugins/findings" },
1281
+ { method: "GET", pathPattern: "/api/agent-plugins/catalog" },
1282
+ { method: "GET", pathPattern: "/api/agent-plugins/updates" }
1283
+ ]);
1284
+ var MACHINE_PRINCIPAL_WORK_WRITABLE_FIELDS = Object.freeze(["name", "description"]);
1285
+ function splitSegments(normalizedPath) {
1286
+ return normalizedPath.split("/").filter((segment) => segment.length > 0);
1287
+ }
1288
+ var FLEET_RUN_TOKEN_ROUTE_SHAPES = FLEET_RUN_TOKEN_ROUTES.map((route) => ({
1289
+ method: route.method.toUpperCase(),
1290
+ shape: splitSegments(route.pathPattern).map((part) => /^\{[^}]+\}$/.test(part) ? "*" : part.toLowerCase())
1291
+ }));
1180
1292
  var EMAIL_INBOX_DEFAULT_DAILY_CAP = 100;
1181
1293
  var EMAIL_INBOX_BURST_SENDS = 10;
1182
1294
  var EMAIL_INBOX_BURST_RECIPIENTS = 20;
@@ -1718,9 +1830,15 @@ var INTEGRATION_SCOPES = [
1718
1830
  "email:write",
1719
1831
  "events:read",
1720
1832
  "webhooks:manage",
1721
- "links:write"
1833
+ "links:write",
1834
+ "merges:decide"
1835
+ ];
1836
+ var INTEGRATION_MERGE_DECISION_SCOPE = "merges:decide";
1837
+ var INTEGRATION_OPT_IN_SCOPES = [
1838
+ "org:write",
1839
+ "email:write",
1840
+ INTEGRATION_MERGE_DECISION_SCOPE
1722
1841
  ];
1723
- var INTEGRATION_OPT_IN_SCOPES = ["org:write", "email:write"];
1724
1842
  var EVER_GAUZY_PRESET_SCOPES = INTEGRATION_SCOPES.filter(
1725
1843
  (scope) => !INTEGRATION_OPT_IN_SCOPES.includes(scope)
1726
1844
  );
@@ -3616,6 +3734,7 @@ function isSafeWebhookUrl(rawUrl) {
3616
3734
  if (host.startsWith("[") && host.endsWith("]")) {
3617
3735
  host = host.slice(1, -1);
3618
3736
  }
3737
+ host = host.replace(/\.+$/, "");
3619
3738
  if (CLOUD_METADATA_HOSTNAMES.has(host)) {
3620
3739
  return false;
3621
3740
  }
@@ -3645,23 +3764,69 @@ function isPrivateIPv4(ip) {
3645
3764
  if (a === 172 && b >= 16 && b <= 31) return true;
3646
3765
  if (a === 192 && b === 168) return true;
3647
3766
  if (a === 192 && b === 0 && parts[2] === 0) return true;
3767
+ if (a === 198 && (b === 18 || b === 19)) return true;
3768
+ if (a === 192 && b === 0 && parts[2] === 2) return true;
3769
+ if (a === 198 && b === 51 && parts[2] === 100) return true;
3770
+ if (a === 203 && b === 0 && parts[2] === 113) return true;
3648
3771
  if (a === 100 && b >= 64 && b <= 127) return true;
3649
3772
  if (a >= 224) return true;
3650
3773
  return false;
3651
3774
  }
3652
- function isPrivateIPv6(ip) {
3653
- const lower = ip.toLowerCase();
3654
- if (lower === "::1" || lower === "::") return true;
3655
- if (lower.startsWith("fc") || lower.startsWith("fd")) return true;
3656
- const firstHextet = lower.split(":", 1)[0];
3657
- if (/^[0-9a-f]{1,4}$/.test(firstHextet)) {
3658
- const group0 = parseInt(firstHextet, 16);
3659
- if ((group0 & 65472) === 65152) return true;
3775
+ function parseIPv6Groups(ip) {
3776
+ let text = ip.trim().toLowerCase();
3777
+ const zone = text.indexOf("%");
3778
+ if (zone >= 0) text = text.slice(0, zone);
3779
+ if (isIP(text) !== 6) return null;
3780
+ const lastColon = text.lastIndexOf(":");
3781
+ const tail = text.slice(lastColon + 1);
3782
+ if (tail.includes(".")) {
3783
+ if (isIP(tail) !== 4) return null;
3784
+ const [a, b, c, d] = tail.split(".").map((part) => Number(part));
3785
+ text = `${text.slice(0, lastColon + 1)}${(a << 8 | b).toString(16)}:${(c << 8 | d).toString(16)}`;
3786
+ }
3787
+ const halves = text.split("::");
3788
+ if (halves.length > 2) return null;
3789
+ const head = halves[0] ? halves[0].split(":") : [];
3790
+ const rest = halves.length === 2 && halves[1] ? halves[1].split(":") : [];
3791
+ const fill = halves.length === 2 ? 8 - head.length - rest.length : 0;
3792
+ if (fill < 0) return null;
3793
+ const groups = [...head, ...new Array(fill).fill("0"), ...rest].map((group) => parseInt(group, 16));
3794
+ if (groups.length !== 8 || groups.some((group) => Number.isNaN(group) || group < 0 || group > 65535)) {
3795
+ return null;
3660
3796
  }
3661
- if (lower.startsWith("::ffff:")) {
3662
- const v4 = lower.slice("::ffff:".length);
3663
- if (isIP(v4) === 4) return isPrivateIPv4(v4);
3797
+ return groups;
3798
+ }
3799
+ function ipv4FromGroups(high, low) {
3800
+ return `${high >> 8}.${high & 255}.${low >> 8}.${low & 255}`;
3801
+ }
3802
+ function embeddedIPv4(ip) {
3803
+ const g = parseIPv6Groups(ip);
3804
+ if (!g) return null;
3805
+ const zeros = (from, to) => g.slice(from, to).every((group) => group === 0);
3806
+ if (zeros(0, 5) && g[5] === 65535) return ipv4FromGroups(g[6], g[7]);
3807
+ if (zeros(0, 4) && g[4] === 65535 && g[5] === 0) return ipv4FromGroups(g[6], g[7]);
3808
+ if (zeros(0, 6) && (g[6] !== 0 || g[7] > 1)) return ipv4FromGroups(g[6], g[7]);
3809
+ if (g[0] === 100 && g[1] === 65435 && zeros(2, 6)) return ipv4FromGroups(g[6], g[7]);
3810
+ if (g[0] === 8194) return ipv4FromGroups(g[1], g[2]);
3811
+ if (g[0] === 8193 && g[1] === 0) return ipv4FromGroups(g[6] ^ 65535, g[7] ^ 65535);
3812
+ return null;
3813
+ }
3814
+ function isPrivateIPv6(ip) {
3815
+ const g = parseIPv6Groups(ip);
3816
+ if (!g) {
3817
+ const lower = ip.toLowerCase();
3818
+ return lower === "::1" || lower === "::" || lower.startsWith("fc") || lower.startsWith("fd");
3664
3819
  }
3820
+ if (g.every((group) => group === 0)) return true;
3821
+ if (g.slice(0, 7).every((group) => group === 0) && g[7] === 1) return true;
3822
+ if ((g[0] & 65024) === 64512) return true;
3823
+ if ((g[0] & 65472) === 65152) return true;
3824
+ if ((g[0] & 65472) === 65216) return true;
3825
+ if ((g[0] & 65280) === 65280) return true;
3826
+ if (g[0] === 8193 && g[1] === 3512) return true;
3827
+ if (g[0] === 100 && g[1] === 65435 && g[2] === 1) return true;
3828
+ const v4 = embeddedIPv4(ip);
3829
+ if (v4 && isPrivateIPv4(v4)) return true;
3665
3830
  return false;
3666
3831
  }
3667
3832
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ever-works/hermes-agent-plugin",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Hermes Agent pipeline plugin for Ever Works",
5
5
  "author": {
6
6
  "name": "Ever Co. LTD",
@@ -33,10 +33,10 @@
33
33
  "test:coverage": "vitest run --coverage"
34
34
  },
35
35
  "peerDependencies": {
36
- "@ever-works/plugin": "^1.2.6"
36
+ "@ever-works/plugin": "^1.2.9"
37
37
  },
38
38
  "devDependencies": {
39
- "@ever-works/plugin": "^1.2.6",
39
+ "@ever-works/plugin": "^1.2.9",
40
40
  "@types/node": "^26.6.4",
41
41
  "tsup": "^8.0.0",
42
42
  "typescript": "^5.9.3",
@@ -73,8 +73,8 @@
73
73
  "url": "https://github.com/ever-works/ever-works/issues"
74
74
  },
75
75
  "everworksRelease": {
76
- "contentHash": "sha256:da6bf8bdb89fc2d7803dd7a159477d907d3f9045aedc384e38999e4e72188377",
77
- "commit": "eff002871bfd7f9f8e0f984907f45265ae8b01e0",
78
- "source": "https://github.com/ever-works/ever-works/tree/eff002871bfd7f9f8e0f984907f45265ae8b01e0/packages/plugins/hermes-agent"
76
+ "contentHash": "sha256:36d5a45a53d2a55ffd25bf420ef367c90aac6f33d10aea6a65b314d2f0039cfd",
77
+ "commit": "5b5a17e1cdc02e06383d508a6424a863521fc3e0",
78
+ "source": "https://github.com/ever-works/ever-works/tree/5b5a17e1cdc02e06383d508a6424a863521fc3e0/packages/plugins/hermes-agent"
79
79
  }
80
80
  }