@pushary/agent-hooks 1.9.25 → 1.9.27

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 (103) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/data/SKILL.md +1 -1
  3. package/data/cursor-plugin/skills/pushary/SKILL.md +1 -1
  4. package/data/vscode-plugin/skills/pushary/SKILL.md +1 -1
  5. package/dist/bin/pushary-bell-hook.js +25 -25
  6. package/dist/bin/pushary-bell.js +9 -9
  7. package/dist/bin/pushary-claude.js +24 -24
  8. package/dist/bin/pushary-clean.js +29 -29
  9. package/dist/bin/pushary-codex-bridge.js +17 -17
  10. package/dist/bin/pushary-codex-hook.js +32 -32
  11. package/dist/bin/pushary-codex.js +12 -12
  12. package/dist/bin/pushary-connect.js +24 -24
  13. package/dist/bin/pushary-cowork.js +5 -5
  14. package/dist/bin/pushary-daemon.js +36 -32
  15. package/dist/bin/pushary-disconnect.js +24 -24
  16. package/dist/bin/pushary-doctor.js +35 -35
  17. package/dist/bin/pushary-elicitation-hook.js +25 -25
  18. package/dist/bin/pushary-gemini-bridge.js +13 -13
  19. package/dist/bin/pushary-gemini-hook.js +29 -29
  20. package/dist/bin/pushary-hook.js +29 -29
  21. package/dist/bin/pushary-login.js +12 -12
  22. package/dist/bin/pushary-logout.js +24 -24
  23. package/dist/bin/pushary-mcp.js +9 -9
  24. package/dist/bin/pushary-mode.js +12 -12
  25. package/dist/bin/pushary-notification-hook.js +24 -24
  26. package/dist/bin/pushary-opencode-hook.js +26 -26
  27. package/dist/bin/pushary-permission-denied-hook.js +29 -29
  28. package/dist/bin/pushary-permission-hook.js +28 -28
  29. package/dist/bin/pushary-post-hook.js +24 -24
  30. package/dist/bin/pushary-prompt-hook.js +24 -24
  31. package/dist/bin/pushary-session-end-hook.js +24 -24
  32. package/dist/bin/pushary-session-start-hook.js +28 -28
  33. package/dist/bin/pushary-setup.js +35 -35
  34. package/dist/bin/pushary-stats.js +5 -5
  35. package/dist/bin/pushary-status.js +26 -26
  36. package/dist/bin/pushary-stop-hook.js +24 -24
  37. package/dist/bin/pushary-stopfailure-hook.js +24 -24
  38. package/dist/bin/pushary-suggestions.js +12 -12
  39. package/dist/bin/pushary-transcript-register.js +17 -17
  40. package/dist/bin/pushary-transcripts.js +7 -7
  41. package/dist/bin/pushary-upgrade.js +30 -30
  42. package/dist/bin/pushary-wait.js +12 -12
  43. package/dist/bin/pushary.js +6 -6
  44. package/dist/{chunk-TLUSUDRU.js → chunk-2NQHGDK5.js} +1 -1
  45. package/dist/{chunk-GC5HJE3T.js → chunk-4LIOV4YP.js} +3 -3
  46. package/dist/{chunk-PM2WJSUH.js → chunk-4LO6OQZ4.js} +1 -1
  47. package/dist/{chunk-FLC4TVXH.js → chunk-5LLH2TBR.js} +1 -1
  48. package/dist/{chunk-FJKV64M7.js → chunk-5SKHXKIF.js} +5 -5
  49. package/dist/{chunk-2J2WFX7X.js → chunk-5ZR7XFTB.js} +4 -4
  50. package/dist/{chunk-LDNKGG5G.js → chunk-6CBKIF3S.js} +3 -3
  51. package/dist/{chunk-NFH2H7PD.js → chunk-AT4URLSU.js} +5 -5
  52. package/dist/{chunk-KZLOVLA6.js → chunk-BZYYTJ65.js} +4 -4
  53. package/dist/{chunk-A3QQWXIE.js → chunk-CSXWXXFJ.js} +1 -1
  54. package/dist/{chunk-N3ACK3YA.js → chunk-DY6AKR4W.js} +32 -22
  55. package/dist/{chunk-BHRMHDOO.js → chunk-E4NITECV.js} +2 -2
  56. package/dist/{chunk-VN5Q4KOD.js → chunk-GORB726L.js} +2 -2
  57. package/dist/{chunk-3UYMOWX6.js → chunk-H2ZHGK4F.js} +2 -2
  58. package/dist/{chunk-WKEP4JAW.js → chunk-HFGTWPAD.js} +2 -2
  59. package/dist/{chunk-WEKXYS2F.js → chunk-IOTR2VQN.js} +4 -4
  60. package/dist/{chunk-EJJNZYDS.js → chunk-JK42X2VL.js} +2 -2
  61. package/dist/{chunk-KP4BIZLP.js → chunk-JXOCD4MG.js} +2 -2
  62. package/dist/{chunk-KM7AEGKF.js → chunk-KN5ULH4O.js} +3 -3
  63. package/dist/{chunk-SGGR5MN2.js → chunk-LOVDPKUU.js} +1 -1
  64. package/dist/{chunk-2CUE3XXS.js → chunk-LUJAURFP.js} +1 -1
  65. package/dist/{chunk-FCXYDR62.js → chunk-LY3KHTHS.js} +1 -1
  66. package/dist/{chunk-HEJMZVJI.js → chunk-M463H5LN.js} +2 -2
  67. package/dist/{chunk-BGJDOHNF.js → chunk-MDAJO2MP.js} +5 -5
  68. package/dist/{chunk-4KZP4YMV.js → chunk-MRMIGVUI.js} +1 -1
  69. package/dist/{chunk-VEGS4NYF.js → chunk-MSKJRRHY.js} +3 -3
  70. package/dist/{chunk-ZNT4ZZXJ.js → chunk-MTODICDT.js} +1 -1
  71. package/dist/{chunk-OWOSNGEQ.js → chunk-NK2URK5A.js} +2 -2
  72. package/dist/{chunk-RSENVGBQ.js → chunk-O2SMA3JN.js} +4 -4
  73. package/dist/{chunk-UUOC7A7M.js → chunk-OPSLFAKF.js} +7 -7
  74. package/dist/{chunk-Q37XFSPO.js → chunk-OXOT3CGW.js} +4 -4
  75. package/dist/{chunk-PSNF27BC.js → chunk-PQAA37YV.js} +8 -7
  76. package/dist/{chunk-7UZD2F4Y.js → chunk-QMMOVPUP.js} +8 -8
  77. package/dist/{chunk-UJB6HHP4.js → chunk-RZNJGCPR.js} +5 -5
  78. package/dist/{chunk-2XHBYMVN.js → chunk-SLW45RGY.js} +11 -11
  79. package/dist/{chunk-5WTEKIAS.js → chunk-TQE5VIDJ.js} +4 -4
  80. package/dist/{chunk-ZLY7BHN4.js → chunk-TWCWRHNK.js} +5 -5
  81. package/dist/{chunk-PAMW5M53.js → chunk-TYPQUHIS.js} +5 -5
  82. package/dist/{chunk-ZLGCNHJG.js → chunk-U4Q3AKLU.js} +1 -1
  83. package/dist/{chunk-UK7OY3EJ.js → chunk-UQTQVH5X.js} +1 -1
  84. package/dist/{chunk-EJMXZH5E.js → chunk-UWEDDQHU.js} +2 -2
  85. package/dist/{chunk-OFHSTCXK.js → chunk-V6HQFOBS.js} +3 -3
  86. package/dist/{chunk-AXB4ABUD.js → chunk-VGVMBY4V.js} +8 -8
  87. package/dist/{chunk-YD3DIFIU.js → chunk-VWTCGKMU.js} +1 -1
  88. package/dist/{chunk-5ETE7F45.js → chunk-W4DFSUZG.js} +2 -2
  89. package/dist/{chunk-ZV3262AA.js → chunk-W4LNR7LP.js} +3 -3
  90. package/dist/{chunk-VFF7ZBIS.js → chunk-WGTD4NZV.js} +32 -4
  91. package/dist/{chunk-PPGLIWOR.js → chunk-XESMYZLU.js} +1 -1
  92. package/dist/{chunk-5Q2QJ2AL.js → chunk-XTTMUQ4Z.js} +1 -1
  93. package/dist/{chunk-2VQZC6DW.js → chunk-YTTPPJZW.js} +4 -4
  94. package/dist/{chunk-G446AVR5.js → chunk-YZ7D3P3M.js} +2 -2
  95. package/dist/{chunk-OOKIWOMK.js → chunk-Z5AAPX3O.js} +1 -1
  96. package/dist/{chunk-KGSN2SOL.js → chunk-ZQZRBPTP.js} +356 -33
  97. package/dist/{chunk-7V6PJFDF.js → chunk-ZWDXBLEZ.js} +3 -3
  98. package/dist/{global-upgrade-4M4TJKQR.js → global-upgrade-FKQPJL5P.js} +6 -6
  99. package/dist/{paths-6JY6J56N.js → paths-TU47TCRS.js} +2 -2
  100. package/dist/{reapply-LFEQ5GF6.js → reapply-CTJZBUJY.js} +20 -20
  101. package/dist/src/index.js +19 -19
  102. package/dist/{upgrade-lock-CZRCHYVU.js → upgrade-lock-2SQCRMDL.js} +3 -3
  103. package/package.json +1 -1
@@ -989,6 +989,17 @@ var serializeDeclinedAgents = (agents) => `${JSON.stringify(declinedAgentsDocume
989
989
  var withDeclinedAgent = (agents, agent) => canonicalAgents([...agents, agent]);
990
990
  var withoutDeclinedAgent = (agents, agent) => agents.filter((candidate) => candidate !== agent);
991
991
 
992
+ // ../contracts/src/cli-version-standing.ts
993
+ var FIRST_AUTO_UPDATING_RELEASE = [1, 5, 0];
994
+ var MIN_SAFE_RELEASE = [1, 9, 26];
995
+ var formatReleaseVersion = (version) => version.join(".");
996
+ var FIRST_AUTO_UPDATING_CLI_VERSION = formatReleaseVersion(FIRST_AUTO_UPDATING_RELEASE);
997
+ var MIN_SAFE_CLI_VERSION = formatReleaseVersion(MIN_SAFE_RELEASE);
998
+
999
+ // ../contracts/src/auto-update-report.ts
1000
+ var AUTO_UPDATE_RESULTS = ["updated", "current", "needs_manual", "failed", "finish_pending", "finish_blocked"];
1001
+ var isAutoUpdateResult = (value) => typeof value === "string" && AUTO_UPDATE_RESULTS.includes(value);
1002
+
992
1003
  // ../contracts/src/index.ts
993
1004
  var KEY_SCOPES = ["full_access", "agent", "connector", "bound"];
994
1005
  var normalizeKeyScope = (value) => typeof value === "string" && KEY_SCOPES.includes(value) ? value : null;
@@ -1370,7 +1381,6 @@ var SAFE_SHELL_COMMANDS = /* @__PURE__ */ new Set([
1370
1381
  "whoami",
1371
1382
  "id",
1372
1383
  "uname",
1373
- "arch",
1374
1384
  "printenv",
1375
1385
  "locale",
1376
1386
  "tty",
@@ -1664,15 +1674,16 @@ var verdictForPolicy = (policy) => {
1664
1674
  return "requires_human";
1665
1675
  };
1666
1676
  var policyIntent = (policy) => isAutoApprove(policy) ? PATTERN_INTENT.grant : PATTERN_INTENT.restrict;
1667
- var selectGoverningRule = (policies, toolName, args, repoKey, sessionId) => {
1677
+ var restricts = (policy) => policyIntent(policy) === PATTERN_INTENT.restrict;
1678
+ var appliesToThisCall = (policy, repoKey, sessionId) => isRepoKeyMatch(policy.repoKey, repoKey) && (!policy.sessionId || policy.sessionId === sessionId);
1679
+ var selectGoverningRule = (policies, toolName, args, repoKey, sessionId, restrictedArgs = args) => {
1668
1680
  let best;
1669
1681
  let bestWeight = 0;
1670
1682
  let bestScoped = -1;
1671
1683
  let bestLength = -1;
1672
1684
  for (const candidate of policies) {
1673
- if (!isRepoKeyMatch(candidate.repoKey, repoKey)) continue;
1674
- if (candidate.sessionId && candidate.sessionId !== sessionId) continue;
1675
- const rank = matchToolPatternAny(candidate.tool, toolName, args, policyIntent(candidate));
1685
+ if (!appliesToThisCall(candidate, repoKey, sessionId)) continue;
1686
+ const rank = matchToolPatternAny(candidate.tool, toolName, restricts(candidate) ? restrictedArgs : args, policyIntent(candidate));
1676
1687
  if (rank === "none") continue;
1677
1688
  const weight = matchRankWeight(rank);
1678
1689
  const scoped = candidate.sessionId ? 2 : candidate.repoKey ? 1 : 0;
@@ -1721,6 +1732,7 @@ var COMMAND_RUNNERS = /* @__PURE__ */ new Set([
1721
1732
  "script",
1722
1733
  "su",
1723
1734
  "doas",
1735
+ "arch",
1724
1736
  "npx",
1725
1737
  "bunx",
1726
1738
  "pnpx",
@@ -2178,6 +2190,157 @@ var writesASecretFile = ({ program, args }) => {
2178
2190
  if (WRITES_EVERY_OPERAND.has(name)) return operands.some(namesASecretFile);
2179
2191
  return EDITS_IN_PLACE.has(name) && args.some((arg) => IN_PLACE_FLAG.test(arg.text)) && operands.some(namesASecretFile);
2180
2192
  };
2193
+ var GITHUB_RESOURCE_NOUNS = /* @__PURE__ */ new Set([
2194
+ "pr",
2195
+ "issue",
2196
+ "release",
2197
+ "repo",
2198
+ "gist",
2199
+ "label",
2200
+ "secret",
2201
+ "variable",
2202
+ "workflow",
2203
+ "run",
2204
+ "cache",
2205
+ "project",
2206
+ "ruleset",
2207
+ "codespace",
2208
+ "org",
2209
+ "discussion"
2210
+ ]);
2211
+ var GITHUB_READ_VERBS = /* @__PURE__ */ new Set([
2212
+ "view",
2213
+ "list",
2214
+ "ls",
2215
+ "status",
2216
+ "diff",
2217
+ "checks",
2218
+ "check",
2219
+ "watch",
2220
+ "browse",
2221
+ "download",
2222
+ "clone",
2223
+ "checkout",
2224
+ "get",
2225
+ "field-list",
2226
+ "item-list"
2227
+ ]);
2228
+ var GITHUB_OPTIONS_WITH_VALUES = /* @__PURE__ */ new Set(["-R", "--repo", "--hostname"]);
2229
+ var GITHUB_API_SUBCOMMAND = "api";
2230
+ var GITHUB_GRAPHQL_ENDPOINT = "graphql";
2231
+ var HTTP_METHOD_FLAGS = /* @__PURE__ */ new Set(["-X", "--method"]);
2232
+ var HTTP_METHOD_ATTACHED = /^(?:-X|--method=)(.+)$/;
2233
+ var HTTP_READ_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
2234
+ var GITHUB_API_BODY_FLAG = /^(?:-[fF]|--(?:field|raw-field|input)(?:=|$))/;
2235
+ var GITHUB_API_FILE_FIELD = /=@|^--input(?:=|$)/;
2236
+ var GRAPHQL_MUTATION = /\bmutation\b/i;
2237
+ var STRIPE_READ_COMMANDS = /* @__PURE__ */ new Set([
2238
+ "get",
2239
+ "listen",
2240
+ "logs",
2241
+ "status",
2242
+ "version",
2243
+ "help",
2244
+ "login",
2245
+ "logout",
2246
+ "config",
2247
+ "completion",
2248
+ "open",
2249
+ "resources"
2250
+ ]);
2251
+ var STRIPE_REQUEST_COMMANDS_THAT_WRITE = /* @__PURE__ */ new Set(["post", "delete", "trigger", "fixtures"]);
2252
+ var STRIPE_READ_OPERATIONS = /* @__PURE__ */ new Set(["list", "retrieve", "search"]);
2253
+ var STRIPE_OPTIONS_WITH_VALUES = /* @__PURE__ */ new Set([
2254
+ "--api-key",
2255
+ "--project-name",
2256
+ "-p",
2257
+ "--color",
2258
+ "--log-level",
2259
+ "--device-name",
2260
+ "--config",
2261
+ "--stripe-account"
2262
+ ]);
2263
+ var AWS_OPTIONS_WITH_VALUES = /* @__PURE__ */ new Set([
2264
+ "--region",
2265
+ "--profile",
2266
+ "--output",
2267
+ "--endpoint-url",
2268
+ "--query",
2269
+ "--color",
2270
+ "--ca-bundle",
2271
+ "--cli-read-timeout",
2272
+ "--cli-connect-timeout",
2273
+ "--cli-binary-format"
2274
+ ]);
2275
+ var AWS_LOCAL_COMMANDS = /* @__PURE__ */ new Set(["configure", "help", "history", "sso", "login", "logout"]);
2276
+ var AWS_READ_OPERATION = /^(?:describe|list|get|head|batch-get|lookup|search|filter|scan|query|select|wait|validate|estimate|simulate|tail|ls|presign|help)(?:-|$)/;
2277
+ var AWS_S3_SERVICE = "s3";
2278
+ var AWS_S3_COPIES = /* @__PURE__ */ new Set(["cp", "sync"]);
2279
+ var S3_URL_PREFIX = "s3://";
2280
+ var TWILIO_TOPIC_SEPARATOR = ":";
2281
+ var TWILIO_READ_ACTIONS = /* @__PURE__ */ new Set(["list", "fetch"]);
2282
+ var positionalWordsOf = (args, optionsWithValues) => {
2283
+ const endOfOptions = args.findIndex((arg) => arg.text === END_OF_OPTIONS);
2284
+ const options = endOfOptions === -1 ? args : args.slice(0, endOfOptions);
2285
+ const operands = endOfOptions === -1 ? [] : args.slice(endOfOptions + 1);
2286
+ const positional = options.filter((arg, index) => !arg.text.startsWith("-") && !optionsWithValues.has(options[index - 1]?.text ?? ""));
2287
+ return [...positional, ...operands];
2288
+ };
2289
+ var httpMethodOf = (args) => {
2290
+ for (const [index, arg] of args.entries()) {
2291
+ const attached = HTTP_METHOD_ATTACHED.exec(arg.text);
2292
+ if (attached) return arg.expands ? null : attached[1];
2293
+ if (HTTP_METHOD_FLAGS.has(arg.text)) {
2294
+ const value = args[index + 1];
2295
+ return value === void 0 || value.expands ? null : value.text;
2296
+ }
2297
+ }
2298
+ return void 0;
2299
+ };
2300
+ var graphqlRequestCanWrite = (args) => args.some((arg) => arg.expands || GRAPHQL_MUTATION.test(arg.text) || GITHUB_API_FILE_FIELD.test(arg.text));
2301
+ var githubApiRequestWrites = (args) => {
2302
+ const method = httpMethodOf(args);
2303
+ if (method !== void 0) return method === null || !HTTP_READ_METHODS.has(method.toUpperCase());
2304
+ if (args.some((arg) => arg.text === GITHUB_GRAPHQL_ENDPOINT)) return graphqlRequestCanWrite(args);
2305
+ return args.some((arg) => GITHUB_API_BODY_FLAG.test(arg.text));
2306
+ };
2307
+ var githubCliWrites = (args) => {
2308
+ const meaningful = argsAfterHarmlessGlobalFlags(args);
2309
+ const [noun, verb] = positionalWordsOf(meaningful, GITHUB_OPTIONS_WITH_VALUES);
2310
+ if (noun?.text === GITHUB_API_SUBCOMMAND) return githubApiRequestWrites(meaningful.slice(meaningful.indexOf(noun) + 1));
2311
+ return noun !== void 0 && GITHUB_RESOURCE_NOUNS.has(noun.text) && verb !== void 0 && !GITHUB_READ_VERBS.has(verb.text);
2312
+ };
2313
+ var stripeCliWrites = (args) => {
2314
+ const [command, operation] = positionalWordsOf(args, STRIPE_OPTIONS_WITH_VALUES);
2315
+ if (command === void 0 || STRIPE_READ_COMMANDS.has(command.text)) return false;
2316
+ if (STRIPE_REQUEST_COMMANDS_THAT_WRITE.has(command.text)) return true;
2317
+ return operation !== void 0 && !STRIPE_READ_OPERATIONS.has(operation.text);
2318
+ };
2319
+ var s3CommandWrites = (operation, operands) => !AWS_S3_COPIES.has(operation) ? !AWS_READ_OPERATION.test(operation) : operands.slice(1).some((operand) => operand.expands || operand.text.startsWith(S3_URL_PREFIX));
2320
+ var awsCliWrites = (args) => {
2321
+ const [service, operation, ...operands] = positionalWordsOf(args, AWS_OPTIONS_WITH_VALUES);
2322
+ if (service === void 0 || operation === void 0 || AWS_LOCAL_COMMANDS.has(service.text)) return false;
2323
+ return service.text === AWS_S3_SERVICE ? s3CommandWrites(operation.text, operands) : !AWS_READ_OPERATION.test(operation.text);
2324
+ };
2325
+ var twilioCliWrites = (args) => {
2326
+ const [topic] = positionalWordsOf(args, /* @__PURE__ */ new Set());
2327
+ if (topic === void 0 || !topic.text.includes(TWILIO_TOPIC_SEPARATOR)) return false;
2328
+ return !TWILIO_READ_ACTIONS.has(topic.text.split(TWILIO_TOPIC_SEPARATOR).at(-1) ?? "");
2329
+ };
2330
+ var REMOTE_API_CLI_WRITES = /* @__PURE__ */ new Map([
2331
+ ["gh", githubCliWrites],
2332
+ ["stripe", stripeCliWrites],
2333
+ ["aws", awsCliWrites],
2334
+ ["twilio", twilioCliWrites]
2335
+ ]);
2336
+ var invocationWritesThroughARemoteApi = ({ program, args }) => {
2337
+ const writes = program === void 0 ? void 0 : REMOTE_API_CLI_WRITES.get(basenameOf(program.text));
2338
+ return writes !== void 0 && writes(args);
2339
+ };
2340
+ var commandWritesThroughARemoteApi = (command) => {
2341
+ const segments = readableCommandSegments(command);
2342
+ return segments !== null && segments.some((segment) => invocationWritesThroughARemoteApi(invocationOf(segment)));
2343
+ };
2181
2344
  var segmentNeedsAPerson = (toolName, segment) => {
2182
2345
  const invocation = invocationOf(segment);
2183
2346
  const normalized = normalizedInvocation(invocation);
@@ -2297,15 +2460,14 @@ var replacesTheCrontab = ({ program, args }) => program !== void 0 && basenameOf
2297
2460
  var FIND_DELETE = "-delete";
2298
2461
  var FIND_RUNNERS = /* @__PURE__ */ new Set(["-exec", "-execdir", "-ok", "-okdir"]);
2299
2462
  var FIND_RUNNER_END = /* @__PURE__ */ new Set([";", "+"]);
2463
+ var FIND = "find";
2464
+ var commandsRunByFind = ({ program, args }) => program === void 0 || basenameOf(program.text) !== FIND ? [] : args.flatMap((arg, index) => FIND_RUNNERS.has(arg.text) ? [{ program: args[index + 1], args: args.slice(index + 2, findRunnerEnd(args, index + 2)) }] : []);
2300
2465
  var losesDataVisibly = (toolName, invocation, normalized, depth) => {
2301
2466
  const { program, args } = invocation;
2302
2467
  if (program === void 0) return false;
2303
2468
  const name = basenameOf(program.text);
2304
- if (name === "find") {
2305
- return args.some((arg) => arg.text === FIND_DELETE) || args.some((arg, index) => FIND_RUNNERS.has(arg.text) && invocationHasAVisibleConsequence(toolName, {
2306
- program: args[index + 1],
2307
- args: args.slice(index + 2, findRunnerEnd(args, index + 2))
2308
- }, depth + 1));
2469
+ if (name === FIND) {
2470
+ return args.some((arg) => arg.text === FIND_DELETE) || commandsRunByFind(invocation).some((run) => invocationHasAVisibleConsequence(toolName, run, depth + 1));
2309
2471
  }
2310
2472
  const destructiveArguments = destructiveArgumentsOf(name, args);
2311
2473
  return destructiveArguments !== void 0 && args.some((arg) => namesDestructiveArgument(arg.text, destructiveArguments)) || namesDestructiveWordInAnyCase(name, args.map((arg) => arg.text)) || gitDiscardsWork(invocation) || changesAService(invocation) || replacesTheCrontab(invocation) || isCoveredByPolicy(VISIBLE_DATA_LOSS_PATTERNS, toolName, normalized);
@@ -2345,6 +2507,7 @@ var WRAPPER_SYNTAX = /* @__PURE__ */ new Map([
2345
2507
  ["stdbuf", wrapperSyntax(["-i", "-o", "-e", "--input", "--output", "--error"])],
2346
2508
  ["flock", wrapperSyntax(["-w", "--wait", "--timeout", "-E", "--conflict-exit-code"], 1)],
2347
2509
  ["caffeinate", wrapperSyntax(["-t", "-w"])],
2510
+ ["arch", wrapperSyntax(["-arch", "-d", "-e"])],
2348
2511
  ["sudo", wrapperSyntax([
2349
2512
  "-u",
2350
2513
  "--user",
@@ -2467,7 +2630,8 @@ var runsADownloadedScript = (invocations) => {
2467
2630
  var pipedSegmentsOf = (command) => (shellSegmentsReadingAPipe(commandForReading(command)) ?? []).map((segment) => innermostInvocation(invocationOf(withoutShellGrouping(segment))));
2468
2631
  var pipesIntoASqlClient = (command) => pipedSegmentsOf(command).some((invocation) => sqlClientSyntaxOf(invocation) !== void 0);
2469
2632
  var pipesFetchedCodeIntoAnInterpreter = (command, invocations) => invocations.some(fetches) && pipedSegmentsOf(command).some(runsWhatItReads);
2470
- var SHELL_GROUPING_PREFIX = /^\s*(?:(?:if|then|elif|else|do|while|until|!)\s+|[({]\s*)+/;
2633
+ var WORDS_THAT_OPEN_A_COMMAND = String.raw`if|then|elif|else|do|while|until|!`;
2634
+ var SHELL_GROUPING_PREFIX = new RegExp(String.raw`^\s*(?:(?:${WORDS_THAT_OPEN_A_COMMAND})\s+|[({]\s*)+`);
2471
2635
  var GROUP_OPENER_BY_CLOSER = /* @__PURE__ */ new Map([[")", "("], ["}", "{"]]);
2472
2636
  var occurrencesOf = (text, character) => text.split(character).length - 1;
2473
2637
  var closesAGroupItDidNotOpen = (text) => {
@@ -2584,6 +2748,116 @@ var commandHasAVisibleConsequenceAt = (toolName, command, depth) => {
2584
2748
  return invocations.some((invocation) => invocationHasAVisibleConsequence(toolName, invocation, depth)) || pipesIntoASqlClient(command) || pipesFetchedCodeIntoAnInterpreter(command, invocations) || runsADownloadedScript(invocations);
2585
2749
  };
2586
2750
  var commandHasAVisibleConsequence = (toolName, command) => commandHasAVisibleConsequenceAt(toolName, command, 0);
2751
+ var MAX_SPELLING_DEPTH = 3;
2752
+ var GIT_GLOBAL_OPTIONS_WITH_A_VALUE = /* @__PURE__ */ new Set([
2753
+ "-C",
2754
+ "-c",
2755
+ "--git-dir",
2756
+ "--work-tree",
2757
+ "--namespace",
2758
+ "--super-prefix",
2759
+ "--config-env"
2760
+ ]);
2761
+ var GIT_GLOBAL_FLAGS = /* @__PURE__ */ new Set([
2762
+ "-p",
2763
+ "--paginate",
2764
+ "-P",
2765
+ "--no-pager",
2766
+ "--bare",
2767
+ "--exec-path",
2768
+ "--html-path",
2769
+ "--man-path",
2770
+ "--info-path",
2771
+ "--no-replace-objects",
2772
+ "--no-lazy-fetch",
2773
+ "--no-optional-locks",
2774
+ "--no-advice",
2775
+ "--literal-pathspecs",
2776
+ "--glob-pathspecs",
2777
+ "--noglob-pathspecs",
2778
+ "--icase-pathspecs"
2779
+ ]);
2780
+ var GIT_OPTION_AND_ITS_VALUE = 2;
2781
+ var GIT_OPTION_ALONE = 1;
2782
+ var NOT_A_GIT_GLOBAL_OPTION = 0;
2783
+ var gitGlobalOptionWidth = (text) => {
2784
+ if (GIT_GLOBAL_OPTIONS_WITH_A_VALUE.has(text)) return GIT_OPTION_AND_ITS_VALUE;
2785
+ const name = longOptionName(text);
2786
+ return GIT_GLOBAL_OPTIONS_WITH_A_VALUE.has(name) || GIT_GLOBAL_FLAGS.has(name) ? GIT_OPTION_ALONE : NOT_A_GIT_GLOBAL_OPTION;
2787
+ };
2788
+ var argsAfterGitGlobalOptions = (args) => {
2789
+ let index = 0;
2790
+ while (index < args.length) {
2791
+ const width = gitGlobalOptionWidth(args[index]?.text ?? "");
2792
+ if (width === NOT_A_GIT_GLOBAL_OPTION) break;
2793
+ index += width;
2794
+ }
2795
+ return args.slice(index);
2796
+ };
2797
+ var gitReadingsPastGlobalOptions = ({ program, args }) => {
2798
+ if (program === void 0 || basenameOf(program.text) !== GIT) return [];
2799
+ const rest = argsAfterGitGlobalOptions(args);
2800
+ return rest.length === args.length ? [] : [{ program, args: rest }];
2801
+ };
2802
+ var CURRENT_DIRECTORY_STEP = /\/\.(?=\/)/g;
2803
+ var LEADING_CURRENT_DIRECTORY = /^(?:\.\/+)+(?=[^/])/;
2804
+ var canonicalPathWord = (text) => text.replace(CURRENT_DIRECTORY_STEP, "").replace(LEADING_CURRENT_DIRECTORY, "");
2805
+ var verbatimInvocationText = (invocation) => wordsOfInvocation(invocation).map((word) => asOneShellWord(word.text)).join(" ");
2806
+ var canonicalInvocationText = (invocation) => invocationTextWith(invocation, (word) => asOneShellWord(canonicalPathWord(word.text)));
2807
+ var spellingsOfAnInvocation = (invocation, innermost) => [invocation, innermost, ...gitReadingsPastGlobalOptions(innermost), ...readingsPastGlobalFlags(innermost)].flatMap((reading) => [verbatimInvocationText(reading), canonicalInvocationText(reading)]);
2808
+ var NO_INLINE_SCRIPT = { kind: "none" };
2809
+ var HIDDEN_INLINE_SCRIPT = { kind: "hidden" };
2810
+ var passesAnInlineScript = ({ program, args }) => {
2811
+ const name = basenameOf(program?.text ?? "");
2812
+ return name === EVAL || SHELLS.has(name) && args.some((arg) => SCRIPT_FLAG_CLUSTER.test(arg.text));
2813
+ };
2814
+ var shellReadsItsScript = (invocation) => SHELLS.has(basenameOf(invocation.program?.text ?? "")) && runsWhatItReads(invocation);
2815
+ var inlineScriptsOf = (invocation, heredocs) => {
2816
+ const script = shellScriptOf(invocation);
2817
+ if (script !== null) return { kind: "readable", scripts: [script] };
2818
+ if (passesAnInlineScript(invocation)) return HIDDEN_INLINE_SCRIPT;
2819
+ if (!shellReadsItsScript(invocation)) return NO_INLINE_SCRIPT;
2820
+ return heredocs.length > 0 ? { kind: "readable", scripts: heredocs } : HIDDEN_INLINE_SCRIPT;
2821
+ };
2822
+ var programIsHidden = ({ program }) => program?.expands ?? false;
2823
+ var SUBSTITUTION_AS_A_PROGRAM = new RegExp(String.raw`(?:^|[;&|({\n]|(?:^|[\s;&|({])(?:${WORDS_THAT_OPEN_A_COMMAND})\s)\s*"?(?:\$\(|\`)`);
2824
+ var runsASubstitutionAsAProgram = (command) => {
2825
+ const visible = shellVisibleText(withHeredocBodiesSetAside(commandForReading(command)).text);
2826
+ return visible !== null && SUBSTITUTION_AS_A_PROGRAM.test(visible);
2827
+ };
2828
+ var parsedSpelledSegment = (segment) => {
2829
+ const text = withoutShellGrouping(segment);
2830
+ return { text, invocation: invocationOf(text), heredocs: [], feedsASubstitution: false };
2831
+ };
2832
+ var roughSpelledSegment = ({ invocation, heredocs, feedsASubstitution }) => ({ text: verbatimInvocationText(invocation), invocation, heredocs, feedsASubstitution });
2833
+ var segmentHidesWhatItRuns = (segment, innermost, scripts) => programIsHidden(innermost) || scripts.kind === "hidden" || segment.feedsASubstitution && passesAnInlineScript(innermost);
2834
+ var commandsNestedIn = (innermost, scripts) => [
2835
+ ...scripts.kind === "readable" ? scripts.scripts : [],
2836
+ ...commandsRunByFind(innermost).map(verbatimInvocationText)
2837
+ ];
2838
+ var spelledSegmentsOf = (command) => {
2839
+ const parsed = readableCommandSegments(command);
2840
+ return parsed === null ? roughSegmentsOf(command).map(roughSpelledSegment) : parsed.map(parsedSpelledSegment);
2841
+ };
2842
+ var SPELLINGS_OF_AN_UNREADABLE_COMMAND = { forms: [], hidesWhatItRuns: true };
2843
+ var commandSpellingsAt = (command, depth) => {
2844
+ if (depth > MAX_SPELLING_DEPTH) return SPELLINGS_OF_AN_UNREADABLE_COMMAND;
2845
+ const forms = [];
2846
+ let hidesWhatItRuns = runsASubstitutionAsAProgram(command);
2847
+ for (const segment of spelledSegmentsOf(command)) {
2848
+ const innermost = innermostInvocation(segment.invocation);
2849
+ const scripts = inlineScriptsOf(innermost, segment.heredocs);
2850
+ forms.push(segment.text, ...spellingsOfAnInvocation(segment.invocation, innermost));
2851
+ hidesWhatItRuns ||= segmentHidesWhatItRuns(segment, innermost, scripts);
2852
+ for (const nested of commandsNestedIn(innermost, scripts)) {
2853
+ const inner = commandSpellingsAt(nested, depth + 1);
2854
+ forms.push(nested, ...inner.forms);
2855
+ hidesWhatItRuns ||= inner.hidesWhatItRuns;
2856
+ }
2857
+ }
2858
+ return { forms, hidesWhatItRuns };
2859
+ };
2860
+ var commandSpellings = (command) => commandSpellingsAt(command, 0);
2587
2861
  var withoutSessionToolGrants = (config) => ({
2588
2862
  ...config,
2589
2863
  policies: config.policies.filter((policy) => !isSessionToolGrant(policy))
@@ -3144,9 +3418,10 @@ var findBestRoute = (routes, toolName, args, repoKey) => {
3144
3418
  let bestWeight = 0;
3145
3419
  let bestScoped = -1;
3146
3420
  let bestLength = -1;
3421
+ const { forms } = restrictionReadingOf(routes.map((route) => route.toolPattern), toolName, args);
3147
3422
  for (const candidate of routes) {
3148
3423
  if (!isRepoKeyMatch(candidate.repoKey, repoKey)) continue;
3149
- const rank = matchToolPatternAny(candidate.toolPattern, toolName, args, PATTERN_INTENT.restrict);
3424
+ const rank = matchToolPatternAny(candidate.toolPattern, toolName, forms, PATTERN_INTENT.restrict);
3150
3425
  if (rank === "none") continue;
3151
3426
  const weight = matchRankWeight(rank);
3152
3427
  const scoped = candidate.repoKey ? 1 : 0;
@@ -3178,10 +3453,35 @@ var isNamedByARule = (rank) => rank !== void 0 && rank !== "wildcard";
3178
3453
  var isSpecificArgumentRank = (rank) => rank === "exact" || rank === "prefix";
3179
3454
  var shellReadOnlyFloorApplies = (toolName, arg, rank) => !isSpecificArgumentRank(rank) && toolName === "Bash" && typeof arg === "string" && isSafeReadOnlyCommand(arg);
3180
3455
  var coordinationFloorApplies = (toolName, rank) => isCodexCoordinationTool(toolName) && !isNamedByARule(rank);
3456
+ var POSIX_SHELL_TOOLS = /* @__PURE__ */ new Set(["Bash", "Monitor"]);
3457
+ var argumentsAsWritten = (args) => ({ forms: args, hidesWhatItRuns: false });
3458
+ var namesAnArgumentOf = (pattern, toolName) => pattern.startsWith(`${toolName}(`);
3459
+ var isSpelledOut = (form) => form.length > 0;
3460
+ var restrictionReadingOf = (restrictingPatterns, toolName, args) => {
3461
+ const command = toolName in POLICY_COMMAND_KEYS ? args[0] : void 0;
3462
+ if (command === void 0 || !restrictingPatterns.some((pattern) => namesAnArgumentOf(pattern, toolName))) {
3463
+ return argumentsAsWritten(args);
3464
+ }
3465
+ const spellings = commandSpellings(command);
3466
+ return {
3467
+ forms: [.../* @__PURE__ */ new Set([...args, ...spellings.forms.filter(isSpelledOut)])],
3468
+ hidesWhatItRuns: POSIX_SHELL_TOOLS.has(toolName) && spellings.hidesWhatItRuns
3469
+ };
3470
+ };
3471
+ var restrictingPatternsOf = (policies) => policies.filter(restricts).map((policy) => policy.tool);
3472
+ var policyReadingOf = (policies, toolName, args) => restrictionReadingOf(restrictingPatternsOf(policies), toolName, args);
3473
+ var stricterRule = (current, challenger) => current !== void 0 && (challenger === void 0 || restraintRank(current.policy) > restraintRank(challenger.policy)) ? current : challenger;
3474
+ var restrictsAnArgumentOf = (policy, toolName) => restricts(policy) && namesAnArgumentOf(policy.tool, toolName);
3475
+ var strictestRuleNamingAnArgument = (pool, toolName, repoKey, sessionId) => pool.filter((policy) => restrictsAnArgumentOf(policy, toolName) && appliesToThisCall(policy, repoKey, sessionId)).reduce((strictest, policy) => stricterRule(strictest, { policy, rank: "prefix" }), void 0);
3476
+ var governingRuleForReading = (pool, toolName, args, reading, repoKey, sessionId) => {
3477
+ const selected = selectGoverningRule(pool, toolName, args, repoKey, sessionId, reading.forms);
3478
+ return reading.hidesWhatItRuns ? stricterRule(selected, strictestRuleNamingAnArgument(pool, toolName, repoKey, sessionId)) : selected;
3479
+ };
3181
3480
  var resolveAutoResolveOrigin = (config, toolName, toolInput, cwd, repoKey, sessionId) => {
3182
3481
  const args = toolInput ? policyArgForms(toolName, toolInput, cwd) : [];
3183
3482
  const arg = args[0];
3184
- const rank = selectGoverningRule(config.policies, toolName, args, repoKey, sessionId)?.rank;
3483
+ const reading = policyReadingOf(config.policies, toolName, args);
3484
+ const rank = governingRuleForReading(config.policies, toolName, args, reading, repoKey, sessionId)?.rank;
3185
3485
  if (shellReadOnlyFloorApplies(toolName, arg, rank) || coordinationFloorApplies(toolName, rank)) {
3186
3486
  return DECISION_ORIGIN.safeReadonly;
3187
3487
  }
@@ -3192,28 +3492,37 @@ var wildcardRuleOf = (pool) => {
3192
3492
  return wildcard ? { policy: wildcard, rank: "wildcard" } : void 0;
3193
3493
  };
3194
3494
  var withSiteDelivery = (rule, siteMode) => isAutoApprove(rule.policy) || isAutoDeny(rule.policy) ? rule : { ...rule, policy: { ...rule.policy, mode: siteMode.mode, pushFirstSeconds: siteMode.pushFirstSeconds } };
3195
- var resolvePolicy = (config, toolName, modeOverride, toolInput, cwd, repoKey, sessionId) => {
3196
- const args = toolInput ? policyArgForms(toolName, toolInput, cwd) : [];
3197
- const arg = args[0];
3198
- const specificRule = (pool) => pool.length === 0 ? void 0 : selectGoverningRule(pool, toolName, args, repoKey, sessionId);
3495
+ var layeredGoverningRule = (config, toolName, args, reading, repoKey, sessionId) => {
3496
+ const specificRule = (pool) => pool.length === 0 ? void 0 : governingRuleForReading(pool, toolName, args, reading, repoKey, sessionId);
3199
3497
  const written = config.policies.filter((p) => !p.origin);
3200
3498
  const presets = config.policies.filter((p) => p.origin === "preset");
3201
3499
  const builtins = config.policies.filter((p) => p.origin === "builtin");
3202
3500
  const siteMode = wildcardRuleOf(written);
3203
3501
  const presetRule = specificRule(presets);
3204
- const match = specificRule(written) ?? (presetRule && siteMode ? withSiteDelivery(presetRule, siteMode.policy) : presetRule) ?? siteMode ?? wildcardRuleOf(presets) ?? specificRule(builtins) ?? wildcardRuleOf(builtins);
3205
- let base = match?.policy ?? {
3206
- tool: toolName,
3207
- timeoutSeconds: config.defaultTimeoutSeconds,
3208
- timeoutAction: config.defaultTimeoutAction,
3209
- mode: config.defaultMode ?? "push_first",
3210
- pushFirstSeconds: config.defaultPushFirstSeconds ?? 20
3211
- };
3502
+ return specificRule(written) ?? (presetRule && siteMode ? withSiteDelivery(presetRule, siteMode.policy) : presetRule) ?? siteMode ?? wildcardRuleOf(presets) ?? specificRule(builtins) ?? wildcardRuleOf(builtins);
3503
+ };
3504
+ var unmatchedPolicyOf = (config, toolName) => ({
3505
+ tool: toolName,
3506
+ timeoutSeconds: config.defaultTimeoutSeconds,
3507
+ timeoutAction: config.defaultTimeoutAction,
3508
+ mode: config.defaultMode ?? "push_first",
3509
+ pushFirstSeconds: config.defaultPushFirstSeconds ?? 20
3510
+ });
3511
+ var stricterOfTheReadings = (asWritten, asSpelled, unmatched) => restraintRank(asWritten?.policy ?? unmatched) > restraintRank(asSpelled?.policy ?? unmatched) ? asWritten : asSpelled;
3512
+ var resolvePolicy = (config, toolName, modeOverride, toolInput, cwd, repoKey, sessionId) => {
3513
+ const args = toolInput ? policyArgForms(toolName, toolInput, cwd) : [];
3514
+ const arg = args[0];
3515
+ const unmatched = unmatchedPolicyOf(config, toolName);
3516
+ const asWritten = layeredGoverningRule(config, toolName, args, argumentsAsWritten(args), repoKey, sessionId);
3517
+ const asSpelled = layeredGoverningRule(config, toolName, args, policyReadingOf(config.policies, toolName, args), repoKey, sessionId);
3518
+ const match = stricterOfTheReadings(asWritten, asSpelled, unmatched);
3519
+ let base = match?.policy ?? unmatched;
3212
3520
  const governedBySpecificRule = isSpecificArgumentRank(match?.rank);
3213
3521
  const governedBySessionToolGrant = match?.rank === "tool" && isSessionToolGrant(match.policy);
3214
3522
  const governedByStandingShellAllow = match?.rank === "tool" && isStandingShellAllow(match.policy);
3215
3523
  const governingMode = base.mode;
3216
- const approvedByReadOnlyFloor = !isAutoDeny(base) && (shellReadOnlyFloorApplies(toolName, arg, match?.rank) || coordinationFloorApplies(toolName, match?.rank));
3524
+ const aRuleNamesASpelling = isSpecificArgumentRank(asSpelled?.rank);
3525
+ const approvedByReadOnlyFloor = !isAutoDeny(base) && (shellReadOnlyFloorApplies(toolName, arg, match?.rank) && !aRuleNamesASpelling || coordinationFloorApplies(toolName, match?.rank));
3217
3526
  if (governedBySessionToolGrant && !approvedByReadOnlyFloor && typeof arg === "string" && commandNeedsAPerson(toolName, arg)) {
3218
3527
  return resolvePolicy(withoutSessionToolGrants(config), toolName, modeOverride, toolInput, cwd, repoKey, sessionId);
3219
3528
  }
@@ -3398,9 +3707,16 @@ var scopeBreachReasonOf = (verdict) => verdict.kind === "gate" && isScopeReason(
3398
3707
  var onlyCodexPreToolUseCanAsk = (verdict, permissionMode) => verdict.kind === "gate" && (scopeBreachReasonOf(verdict) !== void 0 || !codexRaisesItsOwnPrompts(permissionMode));
3399
3708
  var runsACommandThatNeedsAPerson = ({ toolName, toolInputs }) => toolName === "Bash" && toolInputs.some((toolInput) => {
3400
3709
  const command = extractPolicyArg(toolName, toolInput);
3401
- return command !== void 0 && commandNeedsAPerson(toolName, command);
3710
+ return command !== void 0 && (commandNeedsAPerson(toolName, command) || commandWritesThroughARemoteApi(command));
3711
+ });
3712
+ var CI_WORKFLOW_FILE = /(?:^|\/)\.github\/workflows\/[^/]+$/;
3713
+ var FILE_WRITING_TOOLS = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
3714
+ var namesASecretOrWorkflowFile = (path) => SECRET_FILE_NAME.test(basenameOf(path)) || CI_WORKFLOW_FILE.test(normalizeSeparators(path));
3715
+ var writesASecretOrWorkflowFile = ({ toolName, toolInputs }) => FILE_WRITING_TOOLS.has(toolName) && toolInputs.some((toolInput) => {
3716
+ const path = extractPolicyArg(toolName, toolInput);
3717
+ return path !== void 0 && namesASecretOrWorkflowFile(path);
3402
3718
  });
3403
- var codexCallNeedsAPerson = (input, verdict, call) => onlyCodexPreToolUseCanAsk(verdict, call.permissionMode) || verdict.kind === "gate" && (aChosenRuleGoverns(input) || call.deletesFiles || runsACommandThatNeedsAPerson(input));
3719
+ var codexCallNeedsAPerson = (input, verdict, call) => onlyCodexPreToolUseCanAsk(verdict, call.permissionMode) || verdict.kind === "gate" && (aChosenRuleGoverns(input) || call.deletesFiles || runsACommandThatNeedsAPerson(input) || writesASecretOrWorkflowFile(input));
3404
3720
  var MAX_AGENT_PERMISSION_RULES_PER_KIND = 256;
3405
3721
  var MAX_AGENT_PERMISSION_RULE_LENGTH = 512;
3406
3722
  var isAgentPermissionRule = (value) => typeof value === "string" && value.length > 0 && value.length <= MAX_AGENT_PERMISSION_RULE_LENGTH;
@@ -3421,11 +3737,13 @@ var everyCommandSegmentGranted = (rules, toolName, command) => {
3421
3737
  const segments = readableCommandSegments(command);
3422
3738
  return segments !== null && segments.every((segment) => isSafeReadOnlyCommand(segment) || anyRuleGrants(rules, toolName, [segment]));
3423
3739
  };
3424
- var restrictionFormsOf = (toolName, args) => {
3740
+ var agentRuleReadingOf = (rules, toolName, args) => {
3741
+ const reading = restrictionReadingOf([...rules.ask, ...rules.deny], toolName, args);
3425
3742
  const command = toolName in POLICY_COMMAND_KEYS ? args[0] : void 0;
3426
3743
  const normalized = command === void 0 ? null : normalizedCommand(command);
3427
- return normalized === null ? args : [...args, normalized];
3744
+ return normalized === null ? reading : { ...reading, forms: [...reading.forms, normalized] };
3428
3745
  };
3746
+ var anyRuleRestrictsReading = (rules, toolName, reading) => anyRuleRestricts(rules, toolName, reading.forms) || reading.hidesWhatItRuns && rules.some((rule) => namesAnArgumentOf(rule, toolName));
3429
3747
  var allowRulesGrant = (rules, toolName, args) => {
3430
3748
  const command = args[0];
3431
3749
  return toolName in POLICY_COMMAND_KEYS && command !== void 0 ? everyCommandSegmentGranted(rules, toolName, command) : anyRuleGrants(rules, toolName, args);
@@ -3437,8 +3755,8 @@ var inputNeedsAPerson = (toolName, toolInput) => {
3437
3755
  };
3438
3756
  var agentRulesAllowEveryInput = (rules, toolName, toolInputs, cwd) => rules.allow.length > 0 && toolInputs.length > 0 && toolInputs.every((toolInput) => {
3439
3757
  const args = policyArgForms(toolName, toolInput, cwd);
3440
- const restrictionForms = restrictionFormsOf(toolName, args);
3441
- return allowRulesGrant(rules.allow, toolName, args) && !anyRuleRestricts(rules.ask, toolName, restrictionForms) && !anyRuleRestricts(rules.deny, toolName, restrictionForms) && !inputNeedsAPerson(toolName, toolInput);
3758
+ const reading = agentRuleReadingOf(rules, toolName, args);
3759
+ return allowRulesGrant(rules.allow, toolName, args) && !anyRuleRestrictsReading(rules.ask, toolName, reading) && !anyRuleRestrictsReading(rules.deny, toolName, reading) && !inputNeedsAPerson(toolName, toolInput);
3442
3760
  });
3443
3761
  var isDefaultRule = (policy) => policy.origin === "builtin" || policy.tool === WILDCARD_TOOL_PATTERN;
3444
3762
  var isApprovalRoutePattern = (value) => typeof value === "object" && value !== null && typeof value.toolPattern === "string" && ["string", "undefined"].includes(typeof value.repoKey);
@@ -3452,7 +3770,8 @@ var aChosenRuleGoverns = (input) => {
3452
3770
  if (routes === null) return true;
3453
3771
  return input.toolInputs.some((toolInput) => {
3454
3772
  const args = policyArgForms(input.toolName, toolInput, input.cwd);
3455
- return selectGoverningRule(chosen, input.toolName, args, input.repoKey, input.sessionId) !== void 0 || findBestRoute(routes, input.toolName, args, input.repoKey) !== void 0;
3773
+ const reading = policyReadingOf(chosen, input.toolName, args);
3774
+ return governingRuleForReading(chosen, input.toolName, args, reading, input.repoKey, input.sessionId) !== void 0 || findBestRoute(routes, input.toolName, args, input.repoKey) !== void 0;
3456
3775
  });
3457
3776
  };
3458
3777
  var claudeAllowlistOwnsCall = (input, verdict, permissionMode, rules) => rules !== null && verdict.kind === "gate" && !verdict.scopeReason && !aChosenRuleGoverns(input) && !isAskedInEveryMode(input.toolName) && claudeConsultsItsAllowlist(permissionMode) && agentRulesAllowEveryInput(rules, input.toolName, input.toolInputs, input.cwd);
@@ -3640,6 +3959,9 @@ var WITHDRAWN_APPROVAL_REASON = "The phone question was withdrawn. Approve in th
3640
3959
  var PLAN_DECLINED_REASON = "Plan declined from the phone. Ask what to change before coding.";
3641
3960
  var claudeStoppedPreToolUseOutput = (reason) => stoppedOutput(claudePreToolUseOutput("deny", reason), reason);
3642
3961
  var claudeStoppedPermissionRequestOutput = (reason) => stoppedOutput(claudePermissionRequestOutput("deny", reason), reason);
3962
+ var UNHEARD_PUSH_WINDOW_DAYS = 14;
3963
+ var DAY_MS = 24 * 60 * 60 * 1e3;
3964
+ var UNHEARD_PUSH_WINDOW_MS = UNHEARD_PUSH_WINDOW_DAYS * DAY_MS;
3643
3965
  var ELICITATION_ANSWERABLE_MODE = "form";
3644
3966
  var ELICITATION_MIN_OPTIONS = 2;
3645
3967
  var ELICITATION_MAX_MULTI_QUESTIONS = 4;
@@ -3971,6 +4293,7 @@ export {
3971
4293
  serializeDeclinedAgents,
3972
4294
  withDeclinedAgent,
3973
4295
  withoutDeclinedAgent,
4296
+ isAutoUpdateResult,
3974
4297
  normalizeKeyScope,
3975
4298
  isApprovalMode,
3976
4299
  approvalModeWithoutLocalPrompt,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  keyCheckFromResponse
3
- } from "./chunk-VEGS4NYF.js";
3
+ } from "./chunk-MSKJRRHY.js";
4
4
  import {
5
5
  installNetworkDefaults
6
- } from "./chunk-ZV3262AA.js";
6
+ } from "./chunk-W4LNR7LP.js";
7
7
  import {
8
8
  getBaseUrl
9
- } from "./chunk-5Q2QJ2AL.js";
9
+ } from "./chunk-XTTMUQ4Z.js";
10
10
 
11
11
  // src/retry.ts
12
12
  var isRetryable = (err) => {
@@ -5,15 +5,15 @@ import {
5
5
  readGlobalUpgradeSubject,
6
6
  upgradeInstalledPackage,
7
7
  withUpgradeLock
8
- } from "./chunk-BGJDOHNF.js";
9
- import "./chunk-PPGLIWOR.js";
10
- import "./chunk-VFF7ZBIS.js";
8
+ } from "./chunk-MDAJO2MP.js";
9
+ import "./chunk-XESMYZLU.js";
10
+ import "./chunk-WGTD4NZV.js";
11
11
  import "./chunk-POFBE6ZY.js";
12
12
  import "./chunk-KZERVKTD.js";
13
- import "./chunk-2VQZC6DW.js";
13
+ import "./chunk-YTTPPJZW.js";
14
14
  import "./chunk-AQFEP65J.js";
15
- import "./chunk-OOKIWOMK.js";
16
- import "./chunk-KGSN2SOL.js";
15
+ import "./chunk-Z5AAPX3O.js";
16
+ import "./chunk-ZQZRBPTP.js";
17
17
  export {
18
18
  finishGlobalUpgrade,
19
19
  finishUpgradeWithLock,
@@ -32,8 +32,8 @@ import {
32
32
  pusharyDir,
33
33
  vscodePluginDir,
34
34
  vscodePluginMcp
35
- } from "./chunk-2VQZC6DW.js";
36
- import "./chunk-KGSN2SOL.js";
35
+ } from "./chunk-YTTPPJZW.js";
36
+ import "./chunk-ZQZRBPTP.js";
37
37
  export {
38
38
  autoUpdateLock,
39
39
  autoUpdateLog,
@@ -10,34 +10,34 @@ import {
10
10
  reapplyOpenCodePlugin,
11
11
  reapplyVsCodePlugin,
12
12
  repairCodexHolds
13
- } from "./chunk-UUOC7A7M.js";
14
- import "./chunk-VN5Q4KOD.js";
13
+ } from "./chunk-OPSLFAKF.js";
14
+ import "./chunk-GORB726L.js";
15
15
  import "./chunk-RIVNNBEK.js";
16
16
  import "./chunk-XHKBHWLX.js";
17
- import "./chunk-FJKV64M7.js";
18
- import "./chunk-5WTEKIAS.js";
19
- import "./chunk-ZLY7BHN4.js";
20
- import "./chunk-KM7AEGKF.js";
21
- import "./chunk-4KZP4YMV.js";
22
- import "./chunk-ZNT4ZZXJ.js";
17
+ import "./chunk-5SKHXKIF.js";
18
+ import "./chunk-TQE5VIDJ.js";
19
+ import "./chunk-TWCWRHNK.js";
20
+ import "./chunk-KN5ULH4O.js";
21
+ import "./chunk-MRMIGVUI.js";
22
+ import "./chunk-MTODICDT.js";
23
23
  import "./chunk-GMXKITVA.js";
24
24
  import "./chunk-6ICPEJY5.js";
25
- import "./chunk-AXB4ABUD.js";
26
- import "./chunk-A3QQWXIE.js";
27
- import "./chunk-NFH2H7PD.js";
25
+ import "./chunk-VGVMBY4V.js";
26
+ import "./chunk-CSXWXXFJ.js";
27
+ import "./chunk-AT4URLSU.js";
28
28
  import "./chunk-POFBE6ZY.js";
29
- import "./chunk-7V6PJFDF.js";
30
- import "./chunk-VEGS4NYF.js";
31
- import "./chunk-ZV3262AA.js";
32
- import "./chunk-ZLGCNHJG.js";
29
+ import "./chunk-ZWDXBLEZ.js";
30
+ import "./chunk-MSKJRRHY.js";
31
+ import "./chunk-W4LNR7LP.js";
32
+ import "./chunk-U4Q3AKLU.js";
33
33
  import "./chunk-7QLSKOSU.js";
34
34
  import "./chunk-KZERVKTD.js";
35
- import "./chunk-EJMXZH5E.js";
36
- import "./chunk-2VQZC6DW.js";
35
+ import "./chunk-UWEDDQHU.js";
36
+ import "./chunk-YTTPPJZW.js";
37
37
  import "./chunk-AQFEP65J.js";
38
- import "./chunk-5Q2QJ2AL.js";
39
- import "./chunk-OOKIWOMK.js";
40
- import "./chunk-KGSN2SOL.js";
38
+ import "./chunk-XTTMUQ4Z.js";
39
+ import "./chunk-Z5AAPX3O.js";
40
+ import "./chunk-ZQZRBPTP.js";
41
41
  export {
42
42
  ensureCodexTrustAfterReapply,
43
43
  inspectConfiguredManagedProviders,