pushary 1.9.125 → 1.9.127

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 (44) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/bin/pushary-bell-hook.js +3 -3
  3. package/dist/bin/pushary-claude.js +2 -2
  4. package/dist/bin/pushary-clean.js +7 -7
  5. package/dist/bin/pushary-codex-hook.js +7 -7
  6. package/dist/bin/pushary-codex.js +1 -1
  7. package/dist/bin/pushary-connect.js +4 -4
  8. package/dist/bin/pushary-daemon.js +73 -11
  9. package/dist/bin/pushary-disconnect.js +4 -4
  10. package/dist/bin/pushary-doctor.js +5 -5
  11. package/dist/bin/pushary-elicitation-hook.js +4 -4
  12. package/dist/bin/pushary-gemini-hook.js +5 -5
  13. package/dist/bin/pushary-hook.js +7 -7
  14. package/dist/bin/pushary-logout.js +5 -5
  15. package/dist/bin/pushary-notification-hook.js +3 -3
  16. package/dist/bin/pushary-opencode-hook.js +5 -5
  17. package/dist/bin/pushary-permission-denied-hook.js +7 -7
  18. package/dist/bin/pushary-permission-hook.js +7 -7
  19. package/dist/bin/pushary-post-hook.js +3 -3
  20. package/dist/bin/pushary-prompt-hook.js +3 -3
  21. package/dist/bin/pushary-session-end-hook.js +3 -3
  22. package/dist/bin/pushary-session-start-hook.js +5 -5
  23. package/dist/bin/pushary-setup.js +7 -7
  24. package/dist/bin/pushary-status.js +4 -4
  25. package/dist/bin/pushary-stop-hook.js +3 -3
  26. package/dist/bin/pushary-stopfailure-hook.js +3 -3
  27. package/dist/bin/pushary-upgrade.js +5 -5
  28. package/dist/{chunk-MIO2IWCZ.js → chunk-4HDFEBPU.js} +2 -2
  29. package/dist/{chunk-ZBKM5V6B.js → chunk-5WF4NBHQ.js} +2 -2
  30. package/dist/{chunk-GM26OJG6.js → chunk-6IL3DQY6.js} +6 -6
  31. package/dist/{chunk-2WGP6QE7.js → chunk-6MFX5NIX.js} +1 -1
  32. package/dist/{chunk-ZAYXOSEP.js → chunk-BLBK7VV7.js} +1 -1
  33. package/dist/{chunk-44SXI642.js → chunk-FN77IVAI.js} +1 -1
  34. package/dist/{chunk-WLC3AX6F.js → chunk-I365OPWV.js} +75 -26
  35. package/dist/{chunk-OJPHNITI.js → chunk-JW6JSBGS.js} +1 -1
  36. package/dist/{chunk-NPAEVCTN.js → chunk-LAPXXS6K.js} +1 -1
  37. package/dist/{chunk-6DG7PKY5.js → chunk-MBSM6GX5.js} +1 -1
  38. package/dist/{chunk-AVSHVOFB.js → chunk-OPBPSPMU.js} +1 -1
  39. package/dist/{chunk-X6WYICTL.js → chunk-S7QATB3I.js} +1 -1
  40. package/dist/{chunk-RKXSWF62.js → chunk-YT47T5TM.js} +2 -2
  41. package/dist/{chunk-SBPVEVLZ.js → chunk-YZ74AFIU.js} +1 -1
  42. package/dist/{reapply-H6ETJ2QP.js → reapply-6AMFTGQY.js} +4 -4
  43. package/dist/src/index.js +7 -7
  44. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  readHookInput
4
- } from "../chunk-6DG7PKY5.js";
4
+ } from "../chunk-MBSM6GX5.js";
5
5
  import "../chunk-C2L477NM.js";
6
6
  import "../chunk-QPS5STKF.js";
7
7
  import "../chunk-HXBQTPKC.js";
@@ -11,13 +11,13 @@ import {
11
11
  activeIdentity,
12
12
  normalizeToolCall,
13
13
  profileFromArgv
14
- } from "../chunk-ZAYXOSEP.js";
14
+ } from "../chunk-BLBK7VV7.js";
15
15
  import {
16
16
  emitHookOutput,
17
17
  handleCompaction,
18
18
  handlePostToolUse,
19
19
  isCompactionEvent
20
- } from "../chunk-WLC3AX6F.js";
20
+ } from "../chunk-I365OPWV.js";
21
21
  import "../chunk-UXGGVCH5.js";
22
22
  import "../chunk-Q3KKA5IZ.js";
23
23
  import "../chunk-7OSBFMRV.js";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  readHookInput
4
- } from "../chunk-6DG7PKY5.js";
4
+ } from "../chunk-MBSM6GX5.js";
5
5
  import "../chunk-C2L477NM.js";
6
6
  import "../chunk-QPS5STKF.js";
7
7
  import "../chunk-HXBQTPKC.js";
@@ -9,11 +9,11 @@ import "../chunk-G66WIAST.js";
9
9
  import {
10
10
  activeHookSource,
11
11
  activeIdentity
12
- } from "../chunk-ZAYXOSEP.js";
12
+ } from "../chunk-BLBK7VV7.js";
13
13
  import {
14
14
  emitHookOutput,
15
15
  handleUserPrompt
16
- } from "../chunk-WLC3AX6F.js";
16
+ } from "../chunk-I365OPWV.js";
17
17
  import "../chunk-UXGGVCH5.js";
18
18
  import "../chunk-Q3KKA5IZ.js";
19
19
  import "../chunk-7OSBFMRV.js";
@@ -5,7 +5,7 @@ import {
5
5
  import "../chunk-ROVLRXBI.js";
6
6
  import {
7
7
  readHookInput
8
- } from "../chunk-6DG7PKY5.js";
8
+ } from "../chunk-MBSM6GX5.js";
9
9
  import "../chunk-C2L477NM.js";
10
10
  import "../chunk-QPS5STKF.js";
11
11
  import "../chunk-HXBQTPKC.js";
@@ -13,10 +13,10 @@ import "../chunk-G66WIAST.js";
13
13
  import {
14
14
  activeHookSource,
15
15
  activeIdentity
16
- } from "../chunk-ZAYXOSEP.js";
16
+ } from "../chunk-BLBK7VV7.js";
17
17
  import {
18
18
  handleSessionEnd
19
- } from "../chunk-WLC3AX6F.js";
19
+ } from "../chunk-I365OPWV.js";
20
20
  import "../chunk-UXGGVCH5.js";
21
21
  import "../chunk-Q3KKA5IZ.js";
22
22
  import "../chunk-7OSBFMRV.js";
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  reapplyClaudeForVersion
4
- } from "../chunk-ZBKM5V6B.js";
4
+ } from "../chunk-5WF4NBHQ.js";
5
5
  import "../chunk-27FILS44.js";
6
6
  import "../chunk-7LZQK7EB.js";
7
7
  import "../chunk-SNF3OTPB.js";
8
8
  import "../chunk-MKUFVNZL.js";
9
9
  import "../chunk-PO5Z73HT.js";
10
- import "../chunk-SBPVEVLZ.js";
10
+ import "../chunk-YZ74AFIU.js";
11
11
  import "../chunk-P2WA3YY2.js";
12
12
  import "../chunk-ROVLRXBI.js";
13
13
  import {
@@ -15,7 +15,7 @@ import {
15
15
  } from "../chunk-STGEWWFW.js";
16
16
  import {
17
17
  readHookInput
18
- } from "../chunk-6DG7PKY5.js";
18
+ } from "../chunk-MBSM6GX5.js";
19
19
  import "../chunk-C2L477NM.js";
20
20
  import "../chunk-QPS5STKF.js";
21
21
  import "../chunk-HXBQTPKC.js";
@@ -23,11 +23,11 @@ import "../chunk-G66WIAST.js";
23
23
  import {
24
24
  activeHookSource,
25
25
  activeIdentity
26
- } from "../chunk-ZAYXOSEP.js";
26
+ } from "../chunk-BLBK7VV7.js";
27
27
  import {
28
28
  CLAUDE_CODE_AGENT,
29
29
  handleSessionStart
30
- } from "../chunk-WLC3AX6F.js";
30
+ } from "../chunk-I365OPWV.js";
31
31
  import "../chunk-UXGGVCH5.js";
32
32
  import "../chunk-Q3KKA5IZ.js";
33
33
  import "../chunk-7OSBFMRV.js";
@@ -44,7 +44,7 @@ import {
44
44
  import "../chunk-PUZZELE6.js";
45
45
  import {
46
46
  readCodexHooksOnDisk
47
- } from "../chunk-MIO2IWCZ.js";
47
+ } from "../chunk-4HDFEBPU.js";
48
48
  import "../chunk-PO6ECYXG.js";
49
49
  import {
50
50
  clearDeclinedAgent,
@@ -115,7 +115,7 @@ import {
115
115
  soleGateFile,
116
116
  soleGateReceipt,
117
117
  soleGateReceiptFile
118
- } from "../chunk-AVSHVOFB.js";
118
+ } from "../chunk-OPBPSPMU.js";
119
119
  import {
120
120
  describeDetection,
121
121
  detectAllAgents,
@@ -124,11 +124,11 @@ import {
124
124
  registerPluginLocation,
125
125
  shortenHome,
126
126
  vscodeSettingsTargets
127
- } from "../chunk-RKXSWF62.js";
127
+ } from "../chunk-YT47T5TM.js";
128
128
  import {
129
129
  mcpServerBearer,
130
130
  readMacAppAgentKey
131
- } from "../chunk-NPAEVCTN.js";
131
+ } from "../chunk-LAPXXS6K.js";
132
132
  import {
133
133
  keyScopeOf
134
134
  } from "../chunk-DK6R5IVR.js";
@@ -197,7 +197,7 @@ import {
197
197
  openCodePluginFile,
198
198
  openCodeWired,
199
199
  withOpenCodeAskRules
200
- } from "../chunk-SBPVEVLZ.js";
200
+ } from "../chunk-YZ74AFIU.js";
201
201
  import {
202
202
  ansiPainter,
203
203
  createIo,
@@ -238,10 +238,10 @@ import {
238
238
  compatibleRecord,
239
239
  compatibleTargetPaths,
240
240
  hasCompatibleHooks
241
- } from "../chunk-ZAYXOSEP.js";
241
+ } from "../chunk-BLBK7VV7.js";
242
242
  import {
243
243
  reportEvent
244
- } from "../chunk-WLC3AX6F.js";
244
+ } from "../chunk-I365OPWV.js";
245
245
  import {
246
246
  DAEMON_COLD_START_TIMEOUT_MS,
247
247
  clearDaemonNeedsLogin,
@@ -24,10 +24,10 @@ import {
24
24
  CONNECTED_THROUGH_MAC_APP,
25
25
  keyWrittenByMacApp,
26
26
  readMacAppConnectionWhenKeyless
27
- } from "../chunk-NPAEVCTN.js";
27
+ } from "../chunk-LAPXXS6K.js";
28
28
  import "../chunk-DK6R5IVR.js";
29
29
  import "../chunk-QCGNGEGE.js";
30
- import "../chunk-SBPVEVLZ.js";
30
+ import "../chunk-YZ74AFIU.js";
31
31
  import {
32
32
  createIo
33
33
  } from "../chunk-FO3MDD26.js";
@@ -37,8 +37,8 @@ import {
37
37
  import "../chunk-MXUQJIQS.js";
38
38
  import "../chunk-P2WA3YY2.js";
39
39
  import "../chunk-ROVLRXBI.js";
40
- import "../chunk-ZAYXOSEP.js";
41
- import "../chunk-WLC3AX6F.js";
40
+ import "../chunk-BLBK7VV7.js";
41
+ import "../chunk-I365OPWV.js";
42
42
  import "../chunk-UXGGVCH5.js";
43
43
  import "../chunk-Q3KKA5IZ.js";
44
44
  import "../chunk-7OSBFMRV.js";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  readHookInput
4
- } from "../chunk-6DG7PKY5.js";
4
+ } from "../chunk-MBSM6GX5.js";
5
5
  import "../chunk-C2L477NM.js";
6
6
  import "../chunk-QPS5STKF.js";
7
7
  import "../chunk-HXBQTPKC.js";
@@ -9,13 +9,13 @@ import "../chunk-G66WIAST.js";
9
9
  import {
10
10
  activeHookSource,
11
11
  activeIdentity
12
- } from "../chunk-ZAYXOSEP.js";
12
+ } from "../chunk-BLBK7VV7.js";
13
13
  import {
14
14
  emitHookOutput,
15
15
  handleStop,
16
16
  handleSubagentStop,
17
17
  isSubagentStop
18
- } from "../chunk-WLC3AX6F.js";
18
+ } from "../chunk-I365OPWV.js";
19
19
  import "../chunk-UXGGVCH5.js";
20
20
  import "../chunk-Q3KKA5IZ.js";
21
21
  import "../chunk-7OSBFMRV.js";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  readHookInput
4
- } from "../chunk-6DG7PKY5.js";
4
+ } from "../chunk-MBSM6GX5.js";
5
5
  import "../chunk-C2L477NM.js";
6
6
  import "../chunk-QPS5STKF.js";
7
7
  import "../chunk-HXBQTPKC.js";
@@ -9,10 +9,10 @@ import "../chunk-G66WIAST.js";
9
9
  import {
10
10
  activeHookSource,
11
11
  activeIdentity
12
- } from "../chunk-ZAYXOSEP.js";
12
+ } from "../chunk-BLBK7VV7.js";
13
13
  import {
14
14
  handleStopFailure
15
- } from "../chunk-WLC3AX6F.js";
15
+ } from "../chunk-I365OPWV.js";
16
16
  import "../chunk-UXGGVCH5.js";
17
17
  import "../chunk-Q3KKA5IZ.js";
18
18
  import "../chunk-7OSBFMRV.js";
@@ -28,7 +28,7 @@ import {
28
28
  import {
29
29
  ensureCodexTrustAfterReapply,
30
30
  reapplyAllAgents
31
- } from "../chunk-ZBKM5V6B.js";
31
+ } from "../chunk-5WF4NBHQ.js";
32
32
  import {
33
33
  HERMES_RESTART_COMMAND,
34
34
  describeCodexTrustConfirmation
@@ -40,7 +40,7 @@ import {
40
40
  import "../chunk-27FILS44.js";
41
41
  import {
42
42
  readMacAppAgentKey
43
- } from "../chunk-NPAEVCTN.js";
43
+ } from "../chunk-LAPXXS6K.js";
44
44
  import "../chunk-DK6R5IVR.js";
45
45
  import "../chunk-7LZQK7EB.js";
46
46
  import {
@@ -55,7 +55,7 @@ import {
55
55
  retryAgentCommand
56
56
  } from "../chunk-MKUFVNZL.js";
57
57
  import "../chunk-PO5Z73HT.js";
58
- import "../chunk-SBPVEVLZ.js";
58
+ import "../chunk-YZ74AFIU.js";
59
59
  import {
60
60
  exitOnHelpFlag
61
61
  } from "../chunk-IA3E675D.js";
@@ -77,8 +77,8 @@ import {
77
77
  readAutoUpdateState,
78
78
  updateAutoUpdateState
79
79
  } from "../chunk-STGEWWFW.js";
80
- import "../chunk-ZAYXOSEP.js";
81
- import "../chunk-WLC3AX6F.js";
80
+ import "../chunk-BLBK7VV7.js";
81
+ import "../chunk-I365OPWV.js";
82
82
  import {
83
83
  DAEMON_COLD_START_TIMEOUT_MS,
84
84
  daemonHasRemoteProof,
@@ -10,7 +10,7 @@ import {
10
10
  openCodeConfigDir,
11
11
  openCodePluginArgv,
12
12
  openCodePluginFile
13
- } from "./chunk-SBPVEVLZ.js";
13
+ } from "./chunk-YZ74AFIU.js";
14
14
  import {
15
15
  liveCursorGateCoverage
16
16
  } from "./chunk-C2L477NM.js";
@@ -19,7 +19,7 @@ import {
19
19
  compatibleHookEvents,
20
20
  grokHome,
21
21
  parseConfigDocument
22
- } from "./chunk-ZAYXOSEP.js";
22
+ } from "./chunk-BLBK7VV7.js";
23
23
  import {
24
24
  DEFAULT_HOOKS_KEY_PATH,
25
25
  GEMINI_HOOK_BINARY,
@@ -28,7 +28,7 @@ import {
28
28
  openCodePluginDir,
29
29
  openCodeWired,
30
30
  withOpenCodeAskRules
31
- } from "./chunk-SBPVEVLZ.js";
31
+ } from "./chunk-YZ74AFIU.js";
32
32
  import {
33
33
  detectClaudeVersion
34
34
  } from "./chunk-P2WA3YY2.js";
@@ -37,7 +37,7 @@ import {
37
37
  compatibleConfigFile,
38
38
  compatibleInstructionsFile,
39
39
  hasCompatibleHooks
40
- } from "./chunk-ZAYXOSEP.js";
40
+ } from "./chunk-BLBK7VV7.js";
41
41
  import {
42
42
  GEMINI_HOOK_BINARY,
43
43
  addGeminiHooks,
@@ -7,10 +7,10 @@ import {
7
7
  defersToNativeMode,
8
8
  outcomeOfFailedAsk,
9
9
  storedWaitDeadline
10
- } from "./chunk-X6WYICTL.js";
10
+ } from "./chunk-S7QATB3I.js";
11
11
  import {
12
12
  reportMachineDenial
13
- } from "./chunk-2WGP6QE7.js";
13
+ } from "./chunk-6MFX5NIX.js";
14
14
  import {
15
15
  isGatingMoment,
16
16
  recordKeylessMoment
@@ -18,16 +18,16 @@ import {
18
18
  import {
19
19
  isAdmitted,
20
20
  readAdmissionRules
21
- } from "./chunk-6DG7PKY5.js";
21
+ } from "./chunk-MBSM6GX5.js";
22
22
  import {
23
23
  isDeferAnswer,
24
24
  oncePerSession
25
- } from "./chunk-OJPHNITI.js";
25
+ } from "./chunk-JW6JSBGS.js";
26
26
  import {
27
27
  activeHookSource,
28
28
  activeIdentity,
29
29
  namedSource
30
- } from "./chunk-ZAYXOSEP.js";
30
+ } from "./chunk-BLBK7VV7.js";
31
31
  import {
32
32
  DEFAULT_SESSION,
33
33
  approvalAwaitingRetry,
@@ -48,7 +48,7 @@ import {
48
48
  settleQuestionsForToolUse,
49
49
  sweepFilesOlderThan,
50
50
  userScope
51
- } from "./chunk-WLC3AX6F.js";
51
+ } from "./chunk-I365OPWV.js";
52
52
  import {
53
53
  UNNAMED_ACTION,
54
54
  deriveAction,
@@ -4,7 +4,7 @@ import {
4
4
  claimThrottle,
5
5
  releaseThrottle,
6
6
  reportEvent
7
- } from "./chunk-WLC3AX6F.js";
7
+ } from "./chunk-I365OPWV.js";
8
8
  import {
9
9
  deriveToolTarget,
10
10
  permissionDeniedAction
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CLAUDE_CODE_AGENT
3
- } from "./chunk-WLC3AX6F.js";
3
+ } from "./chunk-I365OPWV.js";
4
4
  import {
5
5
  addGeminiMcpServer,
6
6
  removeGeminiMcpServer
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readMacAppAgentKey
3
- } from "./chunk-NPAEVCTN.js";
3
+ } from "./chunk-LAPXXS6K.js";
4
4
  import {
5
5
  API_KEYS_PATH
6
6
  } from "./chunk-DK6R5IVR.js";
@@ -361,7 +361,7 @@ var emitHookOutput = async (render, write = writeOutput) => {
361
361
 
362
362
  // src/policy.ts
363
363
  import { createHash as createHash2 } from "crypto";
364
- import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
364
+ import { existsSync as existsSync2, lstatSync as lstatSync2, readFileSync as readFileSync2, readdirSync as readdirSync2, unlinkSync as unlinkSync2, utimesSync, writeFileSync as writeFileSync2 } from "fs";
365
365
  import { join as join2 } from "path";
366
366
  import { tmpdir as tmpdir2 } from "os";
367
367
  var CACHE_TTL_MS = 60 * 1e3;
@@ -371,10 +371,56 @@ var policyRequestFor = (agentType) => ({
371
371
  repoAware: REPO_AWARE_AGENTS.includes(agentType)
372
372
  });
373
373
  var POLICY_CACHE_FORMAT = "v3";
374
- var policyCacheFile = (apiKey, agent, repoAware = false) => {
375
- const parts = [apiKey, agent, repoAware ? "repoAware" : void 0, "sessionToolAware"].filter(Boolean);
374
+ var POLICY_CACHE_PREFIX = `pushary-policy-${POLICY_CACHE_FORMAT}-`;
375
+ var policyCacheFile = (apiKey, agent, repoAware = false, sessionId) => {
376
+ const parts = [apiKey, agent, repoAware ? "repoAware" : void 0, "sessionToolAware", sessionId ? `session:${sessionId}` : void 0].filter(Boolean);
376
377
  const hash = createHash2("sha256").update(parts.join(":")).digest("hex").slice(0, 12);
377
- return join2(tmpdir2(), `pushary-policy-${POLICY_CACHE_FORMAT}-${hash}.json`);
378
+ return join2(tmpdir2(), `${POLICY_CACHE_PREFIX}${hash}.json`);
379
+ };
380
+ var isAbsentOrNullableString = (value) => value === void 0 || value === null || typeof value === "string";
381
+ var isCachedPolicyRead = (value) => isPolicyConfig(value) && isRecord(value) && (value._cachedAt === void 0 || typeof value._cachedAt === "number") && isAbsentOrNullableString(value._policyVersion) && isAbsentOrNullableString(value._sessionId);
382
+ var isPolicyCacheName = (name) => name.startsWith(POLICY_CACHE_PREFIX) && name.endsWith(".json");
383
+ var policyCachePruneStamp = () => join2(tmpdir2(), `pushary-policy-prune-${POLICY_CACHE_FORMAT}-${process.getuid?.() ?? "user"}.stamp`);
384
+ var POLICY_CACHE_PRUNE_INTERVAL_MS = 60 * 60 * 1e3;
385
+ var prunedWithinTheInterval = (stampedAtMs, now) => {
386
+ const elapsed = now - stampedAtMs;
387
+ return elapsed >= 0 && elapsed < POLICY_CACHE_PRUNE_INTERVAL_MS;
388
+ };
389
+ var claimPolicyCachePrune = (now) => {
390
+ const stamp = policyCachePruneStamp();
391
+ try {
392
+ const stamped = lstatSync2(stamp);
393
+ if (!stamped.isFile() || prunedWithinTheInterval(stamped.mtimeMs, now)) return false;
394
+ utimesSync(stamp, now / 1e3, now / 1e3);
395
+ return true;
396
+ } catch {
397
+ try {
398
+ writeFileSync2(stamp, "", { flag: "wx", mode: 384 });
399
+ return true;
400
+ } catch {
401
+ return false;
402
+ }
403
+ }
404
+ };
405
+ var removePolicyCachesTooOldToServe = (now) => {
406
+ if (!claimPolicyCachePrune(now)) return;
407
+ try {
408
+ for (const name of readdirSync2(tmpdir2())) {
409
+ if (!isPolicyCacheName(name)) continue;
410
+ const path = join2(tmpdir2(), name);
411
+ try {
412
+ if (now - lstatSync2(path).mtimeMs >= STALE_CACHE_MAX_MS) unlinkSync2(path);
413
+ } catch {
414
+ }
415
+ }
416
+ } catch {
417
+ }
418
+ };
419
+ var writePolicyCache = (path, entry) => {
420
+ try {
421
+ writeFileSync2(path, JSON.stringify(entry), { encoding: "utf-8", mode: 384 });
422
+ } catch {
423
+ }
378
424
  };
379
425
  var POLICY_REQUEST_CAPABILITIES_VALUE = policyRequestCapabilitiesHeaderValue(CLI_POLICY_REQUEST_CAPABILITIES);
380
426
  var fetchPolicy = async (apiKey, agent, repoAware = false, sessionId, signal) => {
@@ -401,13 +447,15 @@ var fetchPolicy = async (apiKey, agent, repoAware = false, sessionId, signal) =>
401
447
  }, { maxAttempts: 2, shouldRetry: (error) => signal?.aborted !== true && isRetryable(error) });
402
448
  };
403
449
  var getPolicy = async (apiKey, expectedVersion, agent, repoAware = false, sessionId, signal) => {
404
- const path = policyCacheFile(apiKey, agent, repoAware);
450
+ const path = policyCacheFile(apiKey, agent, repoAware, sessionId);
451
+ const sharedPath = policyCacheFile(apiKey, agent, repoAware);
452
+ const firstForThisSession = path !== sharedPath && !existsSync2(path);
453
+ const readPath = firstForThisSession ? sharedPath : path;
405
454
  let staleCache = null;
406
- if (existsSync2(path)) {
455
+ if (existsSync2(readPath)) {
407
456
  try {
408
- const stat = readFileSync2(path, "utf-8");
409
- const cached = JSON.parse(stat);
410
- if (!isPolicyConfig(cached)) throw new Error("Corrupted cache");
457
+ const cached = JSON.parse(readFileSync2(readPath, "utf-8"));
458
+ if (!isCachedPolicyRead(cached)) throw new Error("Corrupted cache");
411
459
  const versionStale = expectedVersion != null && (cached._policyVersion ?? null) !== expectedVersion;
412
460
  const sessionStale = (cached._sessionId ?? null) !== (sessionId ?? null);
413
461
  const age = cached._cachedAt ? Date.now() - cached._cachedAt : 0;
@@ -421,10 +469,11 @@ var getPolicy = async (apiKey, expectedVersion, agent, repoAware = false, sessio
421
469
  }
422
470
  try {
423
471
  const policy = await fetchPolicy(apiKey, agent, repoAware, sessionId, signal);
424
- try {
425
- writeFileSync2(path, JSON.stringify({ ...policy, _cachedAt: Date.now(), _policyVersion: expectedVersion ?? null, _sessionId: sessionId ?? null }), { encoding: "utf-8", mode: 384 });
426
- } catch {
427
- }
472
+ const cachedAt = Date.now();
473
+ const entry = { ...policy, _cachedAt: cachedAt, _policyVersion: expectedVersion ?? null, _sessionId: sessionId ?? null };
474
+ if (firstForThisSession) removePolicyCachesTooOldToServe(cachedAt);
475
+ writePolicyCache(path, entry);
476
+ if (path !== sharedPath) writePolicyCache(sharedPath, entry);
428
477
  return policy;
429
478
  } catch {
430
479
  if (staleCache) return staleCache;
@@ -434,10 +483,10 @@ var getPolicy = async (apiKey, expectedVersion, agent, repoAware = false, sessio
434
483
  var readFreshPolicyOfAnySession = (path, expectedVersion) => {
435
484
  try {
436
485
  const cached = JSON.parse(readFileSync2(path, "utf-8"));
437
- if (!isRecord(cached) || typeof cached._cachedAt !== "number") return null;
486
+ if (!isCachedPolicyRead(cached) || cached._cachedAt === void 0) return null;
438
487
  if (Date.now() - cached._cachedAt >= CACHE_TTL_MS) return null;
439
488
  if (expectedVersion != null && (cached._policyVersion ?? null) !== expectedVersion) return null;
440
- return isPolicyConfig(cached) ? cached : null;
489
+ return cached;
441
490
  } catch {
442
491
  return null;
443
492
  }
@@ -447,7 +496,7 @@ var readCachedPolicy = (apiKey, agent, repoAware = false) => {
447
496
  const path = policyCacheFile(apiKey, agent, repoAware);
448
497
  try {
449
498
  const cached = JSON.parse(readFileSync2(path, "utf-8"));
450
- if (!isPolicyConfig(cached)) return null;
499
+ if (!isCachedPolicyRead(cached)) return null;
451
500
  const age = cached._cachedAt ? Date.now() - cached._cachedAt : STALE_CACHE_MAX_MS;
452
501
  return age < STALE_CACHE_MAX_MS ? cached : null;
453
502
  } catch {
@@ -741,7 +790,7 @@ var permissionTimeoutDecision = (timeoutAction, paused) => {
741
790
 
742
791
  // src/codex-call-decision.ts
743
792
  import { createHash as createHash4 } from "crypto";
744
- import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, readdirSync as readdirSync2, rmSync as rmSync2, statSync as statSync3, writeFileSync as writeFileSync4 } from "fs";
793
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, readdirSync as readdirSync3, rmSync as rmSync2, statSync as statSync3, writeFileSync as writeFileSync4 } from "fs";
745
794
  import { tmpdir as tmpdir4, userInfo } from "os";
746
795
  import { join as join4 } from "path";
747
796
  var CODEX_DECISION_TTL_MS = 60 * 1e3;
@@ -793,7 +842,7 @@ var parseDecision = (raw) => {
793
842
  };
794
843
  var sweepExpired = (dir, nowMs) => {
795
844
  try {
796
- for (const name of readdirSync2(dir)) {
845
+ for (const name of readdirSync3(dir)) {
797
846
  const path = join4(dir, name);
798
847
  try {
799
848
  if (nowMs - statSync3(path).mtimeMs >= CODEX_DECISION_TTL_MS) rmSync2(path, { force: true });
@@ -862,7 +911,7 @@ var releaseThrottle = (key) => {
862
911
 
863
912
  // src/blocked-action-hint.ts
864
913
  import { createHash as createHash6 } from "crypto";
865
- import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync5, readdirSync as readdirSync3, rmSync as rmSync4, statSync as statSync5, utimesSync } from "fs";
914
+ import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync5, readdirSync as readdirSync4, rmSync as rmSync4, statSync as statSync5, utimesSync as utimesSync2 } from "fs";
866
915
  import { tmpdir as tmpdir6 } from "os";
867
916
  import { join as join6 } from "path";
868
917
  var BLOCKED_ACTION_HINT_TTL_MS = BLOCKED_ACTION_GRANT_TTL_SECONDS * 1e3;
@@ -886,7 +935,7 @@ var hintFile = (fingerprint) => join6(hintDir(), fingerprint);
886
935
  var isExpired = (mtimeMs, nowMs) => nowMs - mtimeMs >= BLOCKED_ACTION_HINT_TTL_MS;
887
936
  var sweepFilesOlderThan = (dir, ttlMs, nowMs) => {
888
937
  try {
889
- for (const name of readdirSync3(dir)) {
938
+ for (const name of readdirSync4(dir)) {
890
939
  const path = join6(dir, name);
891
940
  try {
892
941
  if (nowMs - statSync5(path).mtimeMs >= ttlMs) rmSync4(path, { force: true });
@@ -934,7 +983,7 @@ var approvalIn = (fingerprint, sessionId) => {
934
983
  var approvalAwaitingRetry = (sessionId) => {
935
984
  if (!sessionId) return null;
936
985
  try {
937
- for (const name of readdirSync3(hintDir())) {
986
+ for (const name of readdirSync4(hintDir())) {
938
987
  const approval = isFingerprint(name) ? approvalIn(name, sessionId) : null;
939
988
  if (approval) return approval;
940
989
  }
@@ -949,7 +998,7 @@ var markApprovalReminded = (approval) => {
949
998
  const { atime, mtime } = statSync5(path);
950
999
  const { fingerprint, sessionId, toolName } = approval;
951
1000
  writeFileAtomic(path, JSON.stringify({ fingerprint, sessionId, toolName, reminded: true }), 384);
952
- utimesSync(path, atime, mtime);
1001
+ utimesSync2(path, atime, mtime);
953
1002
  } catch {
954
1003
  return;
955
1004
  }
@@ -964,7 +1013,7 @@ var forgetBlockedActionHint = (fingerprint) => {
964
1013
  };
965
1014
 
966
1015
  // src/claude-session-record.ts
967
- import { readFileSync as readFileSync6, readdirSync as readdirSync4, statSync as statSync6 } from "fs";
1016
+ import { readFileSync as readFileSync6, readdirSync as readdirSync5, statSync as statSync6 } from "fs";
968
1017
  import { join as join7 } from "path";
969
1018
  var UNREADABLE = { kind: "unreadable" };
970
1019
  var OTHER_SESSION = { kind: "other_session" };
@@ -1000,7 +1049,7 @@ var readSessionFile = (path, sessionId) => {
1000
1049
  };
1001
1050
  var runningSessionFiles = (sessions) => {
1002
1051
  try {
1003
- return readdirSync4(sessions).filter((name) => name.endsWith(SESSION_FILE_SUFFIX)).map((name) => name.slice(0, -SESSION_FILE_SUFFIX.length)).filter((pid) => PROCESS_ID.test(pid) && isRunning(Number(pid))).map((pid) => join7(sessions, `${pid}${SESSION_FILE_SUFFIX}`));
1052
+ return readdirSync5(sessions).filter((name) => name.endsWith(SESSION_FILE_SUFFIX)).map((name) => name.slice(0, -SESSION_FILE_SUFFIX.length)).filter((pid) => PROCESS_ID.test(pid) && isRunning(Number(pid))).map((pid) => join7(sessions, `${pid}${SESSION_FILE_SUFFIX}`));
1004
1053
  } catch {
1005
1054
  return [];
1006
1055
  }
@@ -1141,10 +1190,10 @@ var CLAUDE_CODE_AGENT = { type: "claude_code", label: "Claude Code" };
1141
1190
  var POLICY_CACHE_TTL_MS = 5 * 60 * 1e3;
1142
1191
  var readFreshCachedPolicy = (apiKey, agentType, sessionId) => {
1143
1192
  const request = policyRequestFor(agentType);
1144
- const path = policyCacheFile(apiKey, request.agent, request.repoAware);
1193
+ const path = policyCacheFile(apiKey, request.agent, request.repoAware, sessionId);
1145
1194
  if (!existsSync6(path)) return null;
1146
1195
  const cached = JSON.parse(readFileSync7(path, "utf-8"));
1147
- if (!isPolicyConfig(cached)) return null;
1196
+ if (!isCachedPolicyRead(cached)) return null;
1148
1197
  if ((cached._sessionId ?? null) !== (sessionId ?? null)) return null;
1149
1198
  if (!cached._cachedAt || Date.now() - cached._cachedAt >= POLICY_CACHE_TTL_MS) return null;
1150
1199
  return cached;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_SESSION
3
- } from "./chunk-WLC3AX6F.js";
3
+ } from "./chunk-I365OPWV.js";
4
4
 
5
5
  // src/answer.ts
6
6
  var isDeferAnswer = (value) => value === "defer";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  macAppBridgeAvailable
3
- } from "./chunk-SBPVEVLZ.js";
3
+ } from "./chunk-YZ74AFIU.js";
4
4
  import {
5
5
  keyPrefix
6
6
  } from "./chunk-SZV5SLSD.js";
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-QPS5STKF.js";
8
8
  import {
9
9
  namedEvent
10
- } from "./chunk-ZAYXOSEP.js";
10
+ } from "./chunk-BLBK7VV7.js";
11
11
  import {
12
12
  writeDegraded
13
13
  } from "./chunk-7ZTVBYPE.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  compatibleConfigFile,
3
3
  hasCompatibleHooks
4
- } from "./chunk-ZAYXOSEP.js";
4
+ } from "./chunk-BLBK7VV7.js";
5
5
  import {
6
6
  pusharyHookExecutable
7
7
  } from "./chunk-Q3KKA5IZ.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  announceSubscriptionRequired,
3
3
  isDeferAnswer
4
- } from "./chunk-OJPHNITI.js";
4
+ } from "./chunk-JW6JSBGS.js";
5
5
  import {
6
6
  askUser,
7
7
  isDecisionStopped,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  openCodeConfigDirFrom
3
- } from "./chunk-SBPVEVLZ.js";
3
+ } from "./chunk-YZ74AFIU.js";
4
4
  import {
5
5
  nativeClaudeInstallPath
6
6
  } from "./chunk-ROVLRXBI.js";
7
7
  import {
8
8
  grokHome
9
- } from "./chunk-ZAYXOSEP.js";
9
+ } from "./chunk-BLBK7VV7.js";
10
10
  import {
11
11
  claudeConfigDir,
12
12
  clineDataDirectory,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  compatibleConfigFile
3
- } from "./chunk-ZAYXOSEP.js";
3
+ } from "./chunk-BLBK7VV7.js";
4
4
  import {
5
5
  hookOwnerOf,
6
6
  hookOwnerOfCommands