@pushary/agent-hooks 1.9.10 → 1.9.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 (102) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/dist/bin/pushary-bell-hook.js +25 -21
  4. package/dist/bin/pushary-bell.js +9 -9
  5. package/dist/bin/pushary-claude.js +31 -34
  6. package/dist/bin/pushary-clean.js +35 -37
  7. package/dist/bin/pushary-codex-bridge.js +20 -22
  8. package/dist/bin/pushary-codex-hook.js +33 -36
  9. package/dist/bin/pushary-codex.js +12 -14
  10. package/dist/bin/pushary-connect.js +25 -27
  11. package/dist/bin/pushary-cowork.js +5 -5
  12. package/dist/bin/pushary-daemon.js +42 -39
  13. package/dist/bin/pushary-disconnect.js +33 -33
  14. package/dist/bin/pushary-doctor.js +39 -41
  15. package/dist/bin/pushary-elicitation-hook.js +26 -26
  16. package/dist/bin/pushary-gemini-bridge.js +13 -13
  17. package/dist/bin/pushary-gemini-hook.js +30 -33
  18. package/dist/bin/pushary-hook.js +31 -33
  19. package/dist/bin/pushary-login.js +12 -12
  20. package/dist/bin/pushary-logout.js +10 -10
  21. package/dist/bin/pushary-mcp.js +9 -9
  22. package/dist/bin/pushary-mode.js +12 -12
  23. package/dist/bin/pushary-notification-hook.js +24 -26
  24. package/dist/bin/pushary-opencode-hook.js +29 -32
  25. package/dist/bin/pushary-permission-denied-hook.js +29 -31
  26. package/dist/bin/pushary-permission-hook.js +28 -30
  27. package/dist/bin/pushary-post-hook.js +24 -26
  28. package/dist/bin/pushary-prompt-hook.js +24 -26
  29. package/dist/bin/pushary-session-end-hook.js +24 -26
  30. package/dist/bin/pushary-session-start-hook.js +28 -30
  31. package/dist/bin/pushary-setup.js +47 -44
  32. package/dist/bin/pushary-stats.js +5 -5
  33. package/dist/bin/pushary-status.js +27 -29
  34. package/dist/bin/pushary-stop-hook.js +24 -26
  35. package/dist/bin/pushary-stopfailure-hook.js +24 -26
  36. package/dist/bin/pushary-suggestions.js +12 -12
  37. package/dist/bin/pushary-transcript-register.js +17 -17
  38. package/dist/bin/pushary-transcripts.js +7 -7
  39. package/dist/bin/pushary-upgrade.js +30 -32
  40. package/dist/bin/pushary-wait.js +12 -12
  41. package/dist/bin/pushary.js +6 -6
  42. package/dist/{chunk-XKMGHVXW.js → chunk-2GBUL4NP.js} +6 -6
  43. package/dist/{chunk-H4F5O3RE.js → chunk-2NKTEA42.js} +1 -1
  44. package/dist/{chunk-RPQLZLKC.js → chunk-2QJ6K2SR.js} +7 -6
  45. package/dist/{chunk-GTZ4HIHU.js → chunk-3VPS7JPH.js} +2 -2
  46. package/dist/{chunk-AKPHYSEL.js → chunk-4DWQNP52.js} +4 -4
  47. package/dist/{chunk-SMVMLWCD.js → chunk-5HPC3RNE.js} +1 -1
  48. package/dist/{chunk-Z2Q2VH43.js → chunk-5VUB6VVO.js} +15 -3
  49. package/dist/{chunk-LDQGURCF.js → chunk-7U26QSMF.js} +514 -313
  50. package/dist/{chunk-C6QTMWJZ.js → chunk-A2DW2RNT.js} +4 -4
  51. package/dist/{chunk-UJZ7AGSC.js → chunk-AWD2SLNA.js} +4 -4
  52. package/dist/{chunk-2HXG2QDI.js → chunk-BNQKHPEC.js} +4 -4
  53. package/dist/{chunk-7HGR5GNY.js → chunk-BOHDM4T7.js} +46 -21
  54. package/dist/{chunk-PNC5ZQFS.js → chunk-BX2R7SIY.js} +6 -6
  55. package/dist/{chunk-I3W7GJ5R.js → chunk-CATIBZQH.js} +3 -3
  56. package/dist/{chunk-SJDMULE7.js → chunk-CKUACXAX.js} +5 -5
  57. package/dist/{chunk-XXLCYKVS.js → chunk-CMZ4CW5J.js} +3 -3
  58. package/dist/{chunk-5OP5MQI7.js → chunk-CPUEZAE2.js} +1 -1
  59. package/dist/{chunk-DWO4RLYK.js → chunk-CXKY5FGY.js} +8 -8
  60. package/dist/{chunk-ZSGJYSF2.js → chunk-DWHCF4RH.js} +136 -8
  61. package/dist/{chunk-BTFUSQFB.js → chunk-DYQ5QIDN.js} +2 -2
  62. package/dist/{chunk-CJYM4ZHV.js → chunk-E2FGVADR.js} +3 -5
  63. package/dist/{chunk-EVC765EO.js → chunk-EYLQVCME.js} +2 -2
  64. package/dist/{chunk-YUQHUGTH.js → chunk-FLPXTN3Q.js} +1 -1
  65. package/dist/{chunk-BVPPYR7B.js → chunk-FSCWOYK6.js} +3 -3
  66. package/dist/{chunk-2S34OPHS.js → chunk-GP44LTXN.js} +1 -1
  67. package/dist/{chunk-2HFSKYLN.js → chunk-GTM7C36Y.js} +2 -2
  68. package/dist/{chunk-U5FP5JIS.js → chunk-J5XCHLP4.js} +2 -2
  69. package/dist/{chunk-MD4SVNT6.js → chunk-JKGTASA2.js} +1 -1
  70. package/dist/{chunk-GQYX24UC.js → chunk-JNDELCH5.js} +1 -1
  71. package/dist/{chunk-PR2VDVCP.js → chunk-KXCWWHYO.js} +3 -3
  72. package/dist/{chunk-OL2Z7WI4.js → chunk-LBDMCNQY.js} +2 -2
  73. package/dist/{chunk-QGRENWJL.js → chunk-M2P3HQA3.js} +1 -1
  74. package/dist/{chunk-DAOQT4WK.js → chunk-MEHDBT5H.js} +2 -2
  75. package/dist/{chunk-ZGADIZDS.js → chunk-NDZKDJQU.js} +1 -1
  76. package/dist/{chunk-S2DAKKQQ.js → chunk-OBGZUD73.js} +3 -3
  77. package/dist/{chunk-APP43AW7.js → chunk-PKQ435Z2.js} +1 -1
  78. package/dist/{chunk-BVSIM4EF.js → chunk-PMUOEEUE.js} +2 -2
  79. package/dist/{chunk-DL6QHS7V.js → chunk-PNBJAYSL.js} +1 -1
  80. package/dist/{chunk-5RGA636G.js → chunk-QOBOIFGG.js} +231 -17
  81. package/dist/{chunk-IIVZZMSO.js → chunk-RBBMGCSZ.js} +1 -1
  82. package/dist/{chunk-TCXL5FQQ.js → chunk-RYBAJXV4.js} +1 -1
  83. package/dist/{chunk-SIHYBIEN.js → chunk-SJ7M37RL.js} +5 -5
  84. package/dist/{chunk-LXA236ZQ.js → chunk-SQJUXVLW.js} +2 -2
  85. package/dist/{chunk-6KNC6KLL.js → chunk-TSGQYARU.js} +4 -4
  86. package/dist/{chunk-BOSXFI7L.js → chunk-TZCHW6KR.js} +4 -4
  87. package/dist/{chunk-T6ZN4TEF.js → chunk-UEQWLVJB.js} +1 -1
  88. package/dist/{chunk-5MQYA3YL.js → chunk-VDPU4YQN.js} +19 -16
  89. package/dist/{chunk-UM5WXBKN.js → chunk-WBSL4FBX.js} +3 -3
  90. package/dist/{chunk-Q3UMWSE4.js → chunk-WKP2KRTU.js} +2 -2
  91. package/dist/{chunk-Y7JM47CI.js → chunk-YZWUTWDG.js} +2 -2
  92. package/dist/{chunk-QAGWWDXQ.js → chunk-Z6VYZSVA.js} +5 -5
  93. package/dist/{chunk-2M52CFVO.js → chunk-ZC6EVOX6.js} +1 -1
  94. package/dist/{chunk-MISUKJGW.js → chunk-ZHF4JDVE.js} +1 -1
  95. package/dist/{global-upgrade-PUM44JUH.js → global-upgrade-OCZWEF3A.js} +6 -6
  96. package/dist/{paths-U2MJGNBT.js → paths-SOGZJICO.js} +2 -2
  97. package/dist/{reapply-PRKV4EO7.js → reapply-DFG5IE6N.js} +20 -22
  98. package/dist/src/index.js +19 -21
  99. package/dist/{upgrade-lock-QZSVLEM7.js → upgrade-lock-XLE5GVWS.js} +3 -3
  100. package/package.json +1 -1
  101. package/dist/chunk-N6IOSZOE.js +0 -185
  102. package/dist/chunk-NQ67AF3V.js +0 -142
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  pusharyDir
3
- } from "./chunk-UJZ7AGSC.js";
3
+ } from "./chunk-AWD2SLNA.js";
4
4
  import {
5
5
  readJsonSafe,
6
6
  writeFileAtomic
7
7
  } from "./chunk-T7E75EKA.js";
8
8
  import {
9
9
  DECLINED_AGENTS_FILE,
10
- HOOK_SOURCES,
10
+ DISCONNECT_AGENT_IDS,
11
11
  normalizeAgentId,
12
12
  parseDeclinedAgents,
13
13
  serializeDeclinedAgents,
14
14
  withDeclinedAgent,
15
15
  withoutDeclinedAgent
16
- } from "./chunk-5RGA636G.js";
16
+ } from "./chunk-QOBOIFGG.js";
17
17
 
18
18
  // src/declined-agents-file.ts
19
19
  import { join } from "path";
@@ -36,7 +36,7 @@ var changeDeclinedAgents = (file, applies, next) => {
36
36
  };
37
37
  var recordDeclinedAgent = (agent, file = declinedAgentsFile()) => changeDeclinedAgents(file, (current) => !current.includes(agent), (current) => withDeclinedAgent(current, agent));
38
38
  var clearDeclinedAgent = (agent, file = declinedAgentsFile()) => changeDeclinedAgents(file, (current) => current.includes(agent), (current) => withoutDeclinedAgent(current, agent));
39
- var declinedAgentForSetupChoice = (choice) => normalizeAgentId(choice, HOOK_SOURCES);
39
+ var declinedAgentForSetupChoice = (choice) => normalizeAgentId(choice, DISCONNECT_AGENT_IDS);
40
40
 
41
41
  export {
42
42
  declinedAgentsFile,
@@ -13,7 +13,7 @@ import {
13
13
  isReleaseVersion,
14
14
  ownPackageName,
15
15
  withHookHoldBudget
16
- } from "./chunk-5RGA636G.js";
16
+ } from "./chunk-QOBOIFGG.js";
17
17
 
18
18
  // src/setup/paths.ts
19
19
  import { homedir as homedir2 } from "os";
@@ -365,9 +365,9 @@ var installGlobally = (options) => {
365
365
  }
366
366
  const started = (async () => {
367
367
  if (!npmIsOnPath()) throw new NpmMissingError();
368
- const { withUpgradeLock } = await import("./global-upgrade-PUM44JUH.js");
369
- const { installWithUpgradeLock, ownsUpgradeLock } = await import("./upgrade-lock-QZSVLEM7.js");
370
- const { autoUpdateLock: autoUpdateLock2 } = await import("./paths-U2MJGNBT.js");
368
+ const { withUpgradeLock } = await import("./global-upgrade-OCZWEF3A.js");
369
+ const { installWithUpgradeLock, ownsUpgradeLock } = await import("./upgrade-lock-XLE5GVWS.js");
370
+ const { autoUpdateLock: autoUpdateLock2 } = await import("./paths-SOGZJICO.js");
371
371
  let result = "skipped";
372
372
  const install = async () => {
373
373
  const platform = process.platform;
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  MCP_BRIDGE_BINARY
3
- } from "./chunk-OL2Z7WI4.js";
3
+ } from "./chunk-LBDMCNQY.js";
4
4
  import {
5
5
  KEY_FILE_MODE
6
- } from "./chunk-GTZ4HIHU.js";
6
+ } from "./chunk-3VPS7JPH.js";
7
7
  import {
8
8
  NpmMissingError
9
- } from "./chunk-UJZ7AGSC.js";
9
+ } from "./chunk-AWD2SLNA.js";
10
10
  import {
11
11
  readJsonSafe,
12
12
  writeFileAtomic,
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-T7E75EKA.js";
15
15
  import {
16
16
  NPX_LATEST_COMMAND
17
- } from "./chunk-TCXL5FQQ.js";
17
+ } from "./chunk-RYBAJXV4.js";
18
18
 
19
19
  // src/instruction-file.ts
20
20
  import { existsSync, readFileSync, writeFileSync, mkdirSync, rmSync } from "fs";
@@ -3,17 +3,17 @@ import {
3
3
  addGeminiMcpServer,
4
4
  removeGeminiMcpServer,
5
5
  supportedClaudeEvents
6
- } from "./chunk-PR2VDVCP.js";
6
+ } from "./chunk-KXCWWHYO.js";
7
7
  import {
8
8
  CLAUDE_CODE_AGENT,
9
9
  parseApplyPatchFiles
10
- } from "./chunk-LDQGURCF.js";
10
+ } from "./chunk-7U26QSMF.js";
11
11
  import {
12
12
  guardBinary,
13
13
  holdBudgetOf,
14
14
  isProtectedByScope,
15
15
  registerHookEntry
16
- } from "./chunk-UJZ7AGSC.js";
16
+ } from "./chunk-AWD2SLNA.js";
17
17
  import {
18
18
  HOOK_LOCATOR_BINARY,
19
19
  PHONE_ANSWERED_TOOLS,
@@ -21,7 +21,7 @@ import {
21
21
  hookCompatibleProfileBySource,
22
22
  toToolLookup,
23
23
  withHookHoldBudget
24
- } from "./chunk-5RGA636G.js";
24
+ } from "./chunk-QOBOIFGG.js";
25
25
 
26
26
  // src/claude-config.ts
27
27
  import { join } from "path";
@@ -197,7 +197,10 @@ import { homedir } from "os";
197
197
  import { isAbsolute, join as join2, resolve } from "path";
198
198
  var AGENT_FLAG = "--agent";
199
199
  var SOURCE_FLAG = "--source";
200
+ var EVENT_FLAG = "--event";
200
201
  var agentArgument = (profile) => `${AGENT_FLAG}=${profile.agentType}`;
202
+ var eventArgument = (event) => `${EVENT_FLAG}=${event}`;
203
+ var payloadNamesItsEvent = (profile) => profile.payload === "claude";
201
204
  var profileFromArgv = (argv) => {
202
205
  const named = namedAgent(argv);
203
206
  if (named !== void 0) return hookCompatibleProfile(named);
@@ -212,6 +215,12 @@ var namedAgent = (argv) => {
212
215
  const prefix = `${AGENT_FLAG}=`;
213
216
  return argv.find((argument) => argument.startsWith(prefix))?.slice(prefix.length);
214
217
  };
218
+ var namedEvent = (argv) => {
219
+ const inline = argv.find((argument) => argument.startsWith(`${EVENT_FLAG}=`));
220
+ if (inline) return inline.slice(EVENT_FLAG.length + 1);
221
+ const index = argv.indexOf(EVENT_FLAG);
222
+ return index === -1 ? void 0 : argv[index + 1];
223
+ };
215
224
  var namedSource = (argv) => {
216
225
  const inline = argv.find((argument) => argument.startsWith(`${SOURCE_FLAG}=`));
217
226
  if (inline) return inline.slice(SOURCE_FLAG.length + 1);
@@ -264,12 +273,17 @@ var pruneEmptyMap = (config, keyPath) => {
264
273
  return true;
265
274
  };
266
275
  var aliasesFor = (profile, canonical) => Object.entries(profile.toolAliases).flatMap(([agentName, target]) => target === canonical ? [agentName] : []);
267
- var carriesPhoneAnswer = (profile, canonical) => profile.wire === "legacy_decision" && PHONE_ANSWERED_TOOLS.has(canonical);
276
+ var carriesPhoneAnswer = (profile, canonical) => profile.wire !== "permission_decision" && PHONE_ANSWERED_TOOLS.has(canonical);
268
277
  var translateMatcher = (profile, matcher) => {
269
278
  const spellings = matcher.split("|").filter((canonical) => !carriesPhoneAnswer(profile, canonical)).flatMap((canonical) => [canonical, ...aliasesFor(profile, canonical)]);
270
279
  return [.../* @__PURE__ */ new Set([...spellings, ...profile.extraMatchers])].join("|");
271
280
  };
272
281
  var TOOL_MATCHED_EVENTS = /* @__PURE__ */ new Set(["PreToolUse", "PostToolUse"]);
282
+ var isPusharyHandler = (entry2, scope) => {
283
+ const record = asRecord2(entry2);
284
+ return record !== void 0 && !Array.isArray(record.hooks) && isPusharyHook({ hooks: [record] }, scope);
285
+ };
286
+ var isPusharyCompatibleEntry = (entry2, scope) => isPusharyHook(entry2, scope) || isPusharyHandler(entry2, scope);
273
287
  var withoutMatcher = ({ matcher, ...hook }) => hook;
274
288
  var compatibleHookEvents = (profile) => CLAUDE_HOOK_EVENTS.filter((hook) => profile.events.includes(hook.event)).map((hook) => {
275
289
  if (!hook.matcher) return hook;
@@ -306,17 +320,20 @@ var addCompatibleToolPermissions = (config) => {
306
320
  addPusharyToolPermissions(config);
307
321
  return WRITTEN;
308
322
  };
309
- var entryFor = (profile, definition, resolve2) => ({
310
- ...definition.matcher ? { matcher: definition.matcher } : {},
311
- hooks: [{
312
- type: "command",
313
- command: withHookHoldBudget(
314
- `${resolve2(definition.binary)} ${agentArgument(profile)}`,
315
- holdBudgetOf(definition)
316
- ),
317
- timeout: definition.timeout
318
- }]
319
- });
323
+ var commandFor = (profile, definition, resolve2) => {
324
+ const named = `${resolve2(definition.binary)} ${agentArgument(profile)}`;
325
+ const command = payloadNamesItsEvent(profile) ? named : `${named} ${eventArgument(definition.event)}`;
326
+ return withHookHoldBudget(command, holdBudgetOf(definition));
327
+ };
328
+ var writesBareHandler = (profile, definition) => profile.nonToolEntries === "handler" && !TOOL_MATCHED_EVENTS.has(definition.event);
329
+ var entryFor = (profile, definition, resolve2) => {
330
+ const handler = { type: "command", command: commandFor(profile, definition, resolve2), timeout: definition.timeout };
331
+ if (writesBareHandler(profile, definition)) return handler;
332
+ return {
333
+ ...definition.matcher ? { matcher: definition.matcher } : {},
334
+ hooks: [handler]
335
+ };
336
+ };
320
337
  var addCompatibleHooks = (config, profile, binDir) => {
321
338
  const conflictAt = hooksShapeConflict(config, profile);
322
339
  if (conflictAt) return { ok: false, conflictAt };
@@ -327,10 +344,10 @@ var addCompatibleHooks = (config, profile, binDir) => {
327
344
  const current = Array.isArray(hooks[known.event]) ? hooks[known.event] : [];
328
345
  const definition = supported.get(known.event);
329
346
  if (definition) {
330
- hooks[known.event] = registerHookEntry(current, isPusharyHook, entryFor(profile, definition, resolve2));
347
+ hooks[known.event] = registerHookEntry(current, isPusharyCompatibleEntry, entryFor(profile, definition, resolve2));
331
348
  continue;
332
349
  }
333
- const others = current.filter((item) => !isPusharyHook(item));
350
+ const others = current.filter((item) => !isPusharyCompatibleEntry(item));
334
351
  if (others.length > 0) hooks[known.event] = others;
335
352
  else delete hooks[known.event];
336
353
  }
@@ -343,7 +360,7 @@ var removeCompatibleHooks = (config, profile, scope) => {
343
360
  for (const { event } of CLAUDE_HOOK_EVENTS) {
344
361
  const entries = hooks[event];
345
362
  if (!Array.isArray(entries)) continue;
346
- const kept = entries.filter((entry2) => !isPusharyHook(entry2, scope));
363
+ const kept = entries.filter((entry2) => !isPusharyCompatibleEntry(entry2, scope));
347
364
  if (kept.length === entries.length) continue;
348
365
  if (kept.length === 0) delete hooks[event];
349
366
  else hooks[event] = kept;
@@ -357,14 +374,14 @@ var hasCompatibleHooks = (config, profile) => {
357
374
  if (!hooks) return false;
358
375
  return compatibleHookEvents(profile).some(({ event }) => {
359
376
  const entries = hooks[event];
360
- return Array.isArray(entries) && entries.some((entry2) => isPusharyHook(entry2));
377
+ return Array.isArray(entries) && entries.some((entry2) => isPusharyCompatibleEntry(entry2));
361
378
  });
362
379
  };
363
380
  var missingCompatibleHookEvents = (config, profile) => {
364
381
  const hooks = findMap(config, profile.hooksKeyPath);
365
382
  return compatibleHookEvents(profile).filter(({ event }) => {
366
383
  const entries = hooks?.[event];
367
- return !Array.isArray(entries) || !entries.some((entry2) => isPusharyHook(entry2));
384
+ return !Array.isArray(entries) || !entries.some((entry2) => isPusharyCompatibleEntry(entry2));
368
385
  }).map(({ event }) => event);
369
386
  };
370
387
  var compatiblePermissionRuleFile = (profile, home) => profile.permissionRuleFile ? underHome(profile.permissionRuleFile, home) : null;
@@ -374,6 +391,13 @@ var addCompatibleMcpServer = (config, profile, apiKey) => {
374
391
  addGeminiMcpServer(config, apiKey);
375
392
  return;
376
393
  }
394
+ if (profile.mcp.shape === "antigravity_http") {
395
+ ensureRecord2(config, "mcpServers").pushary = {
396
+ serverUrl: PUSHARY_MCP_URL,
397
+ headers: { Authorization: `Bearer ${apiKey}` }
398
+ };
399
+ return;
400
+ }
377
401
  addClaudeMcpServer(config, apiKey);
378
402
  if (!profile.mcp.trusted) return;
379
403
  const server = asRecord2(asRecord2(config.mcpServers)?.pushary);
@@ -397,6 +421,7 @@ export {
397
421
  removePusharySettings,
398
422
  profileFromArgv,
399
423
  activeIdentity,
424
+ namedEvent,
400
425
  activeHookSource,
401
426
  normalizeToolCall,
402
427
  compatibleConfigFile,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ensureCodexTrustsPusharyHooks
3
- } from "./chunk-Y7JM47CI.js";
3
+ } from "./chunk-YZWUTWDG.js";
4
4
  import {
5
5
  detectClaudeVersion
6
6
  } from "./chunk-RIVNNBEK.js";
@@ -12,12 +12,12 @@ import {
12
12
  openCodeHookArgv,
13
13
  openCodePluginDir,
14
14
  openCodeWired
15
- } from "./chunk-QAGWWDXQ.js";
15
+ } from "./chunk-Z6VYZSVA.js";
16
16
  import {
17
17
  addClaudeMcpServer,
18
18
  addPusharyHooks,
19
19
  addPusharyToolPermissions
20
- } from "./chunk-7HGR5GNY.js";
20
+ } from "./chunk-BOHDM4T7.js";
21
21
  import {
22
22
  claudeUnprovenHolds,
23
23
  claudeWired,
@@ -25,7 +25,7 @@ import {
25
25
  codexWired,
26
26
  geminiWired,
27
27
  planHooks
28
- } from "./chunk-SIHYBIEN.js";
28
+ } from "./chunk-SJ7M37RL.js";
29
29
  import {
30
30
  CLAUDE_HOOK_BINARY,
31
31
  CLAUDE_HOOK_EVENTS,
@@ -36,7 +36,7 @@ import {
36
36
  needsReregistration,
37
37
  registrationSignatures,
38
38
  supportedClaudeEvents
39
- } from "./chunk-PR2VDVCP.js";
39
+ } from "./chunk-KXCWWHYO.js";
40
40
  import {
41
41
  formatVersion
42
42
  } from "./chunk-6ICPEJY5.js";
@@ -59,7 +59,7 @@ import {
59
59
  registrationHolderOf,
60
60
  resolveGlobalBinary,
61
61
  vscodePluginMcp
62
- } from "./chunk-UJZ7AGSC.js";
62
+ } from "./chunk-AWD2SLNA.js";
63
63
  import {
64
64
  readJsonSafe,
65
65
  writeFileAtomic,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  keyCheckFromResponse
3
- } from "./chunk-XXLCYKVS.js";
3
+ } from "./chunk-CMZ4CW5J.js";
4
4
  import {
5
5
  installNetworkDefaults
6
- } from "./chunk-UM5WXBKN.js";
6
+ } from "./chunk-WBSL4FBX.js";
7
7
  import {
8
8
  getBaseUrl
9
- } from "./chunk-2M52CFVO.js";
9
+ } from "./chunk-ZC6EVOX6.js";
10
10
 
11
11
  // src/retry.ts
12
12
  var isRetryable = (err) => {
@@ -4,7 +4,7 @@ import {
4
4
  forkFinishWithUpgradeLock,
5
5
  installWithUpgradeLock,
6
6
  releaseAutoUpdateLock
7
- } from "./chunk-DL6QHS7V.js";
7
+ } from "./chunk-PNBJAYSL.js";
8
8
  import {
9
9
  describeAutoUpdateCheck,
10
10
  globalInstallLocation,
@@ -14,7 +14,7 @@ import {
14
14
  readAutoUpdateState,
15
15
  updateAutoUpdateState,
16
16
  upgradeEntryFor
17
- } from "./chunk-U5FP5JIS.js";
17
+ } from "./chunk-J5XCHLP4.js";
18
18
  import {
19
19
  EXIT
20
20
  } from "./chunk-KZERVKTD.js";
@@ -27,10 +27,10 @@ import {
27
27
  npmErrorMessage,
28
28
  readGlobalCliInstallAt,
29
29
  readGlobalPrefix
30
- } from "./chunk-UJZ7AGSC.js";
30
+ } from "./chunk-AWD2SLNA.js";
31
31
  import {
32
32
  NPX_LATEST_COMMAND
33
- } from "./chunk-TCXL5FQQ.js";
33
+ } from "./chunk-RYBAJXV4.js";
34
34
  import {
35
35
  commandsPackage,
36
36
  globalUpgradeEntry,
@@ -39,7 +39,7 @@ import {
39
39
  isSameMajorVersion,
40
40
  ownPackageRoot,
41
41
  packageVersionAt
42
- } from "./chunk-5RGA636G.js";
42
+ } from "./chunk-QOBOIFGG.js";
43
43
 
44
44
  // src/global-upgrade.ts
45
45
  import { existsSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pusharyFetch
3
- } from "./chunk-UM5WXBKN.js";
3
+ } from "./chunk-WBSL4FBX.js";
4
4
  import {
5
5
  NetworkError
6
6
  } from "./chunk-7QLSKOSU.js";
@@ -9,11 +9,11 @@ import {
9
9
  } from "./chunk-KZERVKTD.js";
10
10
  import {
11
11
  getBaseUrl
12
- } from "./chunk-2M52CFVO.js";
12
+ } from "./chunk-ZC6EVOX6.js";
13
13
  import {
14
14
  isValidApiKey,
15
15
  normalizeKeyScope
16
- } from "./chunk-5RGA636G.js";
16
+ } from "./chunk-QOBOIFGG.js";
17
17
 
18
18
  // src/session.ts
19
19
  var samePusharyAccount = (left, right) => left.kind === "ok" && right.kind === "ok" && left.identity.workspaceId !== "" && left.identity.workspaceId === right.identity.workspaceId && left.identity.siteId === right.identity.siteId;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_SESSION
3
- } from "./chunk-N6IOSZOE.js";
3
+ } from "./chunk-7U26QSMF.js";
4
4
 
5
5
  // src/answer.ts
6
6
  var denyReasonFrom = (value, note) => {
@@ -6,38 +6,38 @@ import {
6
6
  } from "./chunk-SGZJ5LYH.js";
7
7
  import {
8
8
  ensureDaemonRunning
9
- } from "./chunk-RPQLZLKC.js";
9
+ } from "./chunk-2QJ6K2SR.js";
10
10
  import {
11
11
  buildTranscriptRecords,
12
12
  decodePublicKey,
13
13
  generateSessionKey,
14
14
  wrapSessionKey
15
- } from "./chunk-APP43AW7.js";
15
+ } from "./chunk-PKQ435Z2.js";
16
16
  import {
17
17
  fetchTranscriptRecipients,
18
18
  uploadTranscriptRecords
19
- } from "./chunk-MISUKJGW.js";
19
+ } from "./chunk-ZHF4JDVE.js";
20
20
  import {
21
21
  transcriptEnvironmentPreference,
22
22
  transcriptsEnabled
23
- } from "./chunk-QGRENWJL.js";
23
+ } from "./chunk-M2P3HQA3.js";
24
24
  import {
25
25
  hookOwnerOf
26
- } from "./chunk-SIHYBIEN.js";
26
+ } from "./chunk-SJ7M37RL.js";
27
27
  import {
28
28
  readTranscriptPreference
29
- } from "./chunk-GTZ4HIHU.js";
29
+ } from "./chunk-3VPS7JPH.js";
30
30
  import {
31
31
  codexHome,
32
32
  pusharyDir
33
- } from "./chunk-UJZ7AGSC.js";
33
+ } from "./chunk-AWD2SLNA.js";
34
34
  import {
35
35
  writeJsonAtomic
36
36
  } from "./chunk-T7E75EKA.js";
37
37
  import {
38
38
  getApiKey,
39
39
  getBaseUrl
40
- } from "./chunk-2M52CFVO.js";
40
+ } from "./chunk-ZC6EVOX6.js";
41
41
 
42
42
  // src/transcript-registration.ts
43
43
  import { createHash } from "crypto";
@@ -1,23 +1,147 @@
1
+ import {
2
+ CLIENT_REPORT_DISABLE_ENV,
3
+ isDisabledByEnv
4
+ } from "./chunk-POFBE6ZY.js";
1
5
  import {
2
6
  SubscriptionRequiredError,
3
7
  callMcpTool
4
- } from "./chunk-I3W7GJ5R.js";
8
+ } from "./chunk-CATIBZQH.js";
5
9
  import {
6
- clientErrorKindOf,
7
- reportClientError
8
- } from "./chunk-NQ67AF3V.js";
10
+ installNetworkDefaults,
11
+ isNetworkFailure
12
+ } from "./chunk-WBSL4FBX.js";
9
13
  import {
10
- installNetworkDefaults
11
- } from "./chunk-UM5WXBKN.js";
14
+ clientReportClaims
15
+ } from "./chunk-AWD2SLNA.js";
12
16
  import {
17
+ getApiKey,
13
18
  getBaseUrl
14
- } from "./chunk-2M52CFVO.js";
19
+ } from "./chunk-ZC6EVOX6.js";
15
20
  import {
16
21
  ASK_AGENT_NAME_MAX,
17
22
  ASK_QUESTION_MAX,
23
+ CLIENT_REPORT_PATH,
18
24
  DECISION_LINE_MAX,
25
+ degradedLine,
19
26
  truncateLine
20
- } from "./chunk-5RGA636G.js";
27
+ } from "./chunk-QOBOIFGG.js";
28
+
29
+ // src/client-report-claim.ts
30
+ import { createHash } from "crypto";
31
+ import { closeSync, mkdirSync, openSync, readdirSync, unlinkSync } from "fs";
32
+ import { join } from "path";
33
+ var CLIENT_REPORT_WINDOW_MS = 6e4;
34
+ var CLAIM_DIRECTORY_MODE = 448;
35
+ var CLAIM_FILE_MODE = 384;
36
+ var CLAIM_KEY_HASH_LENGTH = 16;
37
+ var CLAIM_FILE_PATTERN = /^[0-9a-f]{16}-(\d+)$/;
38
+ var EXCLUSIVE_CREATE = "wx";
39
+ var ALREADY_EXISTS = "EEXIST";
40
+ var WINDOWS_KEPT_BEHIND = 1;
41
+ var reportWindowOf = (now) => Math.floor(now / CLIENT_REPORT_WINDOW_MS);
42
+ var claimFileName = (key, window) => `${createHash("sha256").update(key).digest("hex").slice(0, CLAIM_KEY_HASH_LENGTH)}-${window}`;
43
+ var errorCodeOf = (error) => typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : null;
44
+ var claimWindowOf = (fileName) => {
45
+ const match = CLAIM_FILE_PATTERN.exec(fileName);
46
+ return match ? Number(match[1]) : null;
47
+ };
48
+ var isStaleClaim = (fileName, window) => {
49
+ const claimedWindow = claimWindowOf(fileName);
50
+ return claimedWindow !== null && claimedWindow < window - WINDOWS_KEPT_BEHIND;
51
+ };
52
+ var removeQuietly = (filePath) => {
53
+ try {
54
+ unlinkSync(filePath);
55
+ } catch {
56
+ return;
57
+ }
58
+ };
59
+ var removeStaleClaims = (claimsDir, window) => {
60
+ try {
61
+ for (const fileName of readdirSync(claimsDir)) {
62
+ if (isStaleClaim(fileName, window)) removeQuietly(join(claimsDir, fileName));
63
+ }
64
+ } catch {
65
+ return;
66
+ }
67
+ };
68
+ var claimReportWindow = (claimsDir, key, now) => {
69
+ const window = reportWindowOf(now);
70
+ try {
71
+ mkdirSync(claimsDir, { recursive: true, mode: CLAIM_DIRECTORY_MODE });
72
+ closeSync(openSync(join(claimsDir, claimFileName(key, window)), EXCLUSIVE_CREATE, CLAIM_FILE_MODE));
73
+ } catch (error) {
74
+ return errorCodeOf(error) === ALREADY_EXISTS ? "already_claimed" : "unavailable";
75
+ }
76
+ removeStaleClaims(claimsDir, window);
77
+ return "claimed";
78
+ };
79
+
80
+ // src/client-report.ts
81
+ var CLIENT_REPORT_TIMEOUT_MS = 1e3;
82
+ var readApiKey = () => {
83
+ try {
84
+ return getApiKey();
85
+ } catch {
86
+ return null;
87
+ }
88
+ };
89
+ var defaultDeps = () => ({
90
+ disabled: () => isDisabledByEnv(process.env, CLIENT_REPORT_DISABLE_ENV),
91
+ fetchImpl: fetch,
92
+ apiKey: readApiKey,
93
+ baseUrl: getBaseUrl,
94
+ now: Date.now,
95
+ claimsDir: clientReportClaims()
96
+ });
97
+ var reportKey = (event) => `${event.kind}:${event.code}`;
98
+ var createClientErrorReporter = (deps) => {
99
+ const windowClaimedInProcess = /* @__PURE__ */ new Map();
100
+ const claimInProcess = (key, now) => {
101
+ if (windowClaimedInProcess.get(key) === reportWindowOf(now)) return false;
102
+ windowClaimedInProcess.set(key, reportWindowOf(now));
103
+ return true;
104
+ };
105
+ const claimReport = (key, now) => {
106
+ const claim = claimReportWindow(deps.claimsDir, key, now);
107
+ return claim === "unavailable" ? claimInProcess(key, now) : claim === "claimed";
108
+ };
109
+ return async (event) => {
110
+ try {
111
+ if (deps.disabled()) return;
112
+ const apiKey = deps.apiKey();
113
+ const now = deps.now();
114
+ if (!apiKey || !claimReport(reportKey(event), now)) return;
115
+ await deps.fetchImpl(`${deps.baseUrl()}${CLIENT_REPORT_PATH}`, {
116
+ method: "POST",
117
+ headers: { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json" },
118
+ body: JSON.stringify({ ...event, occurredAt: new Date(now).toISOString() }),
119
+ signal: AbortSignal.timeout(CLIENT_REPORT_TIMEOUT_MS)
120
+ });
121
+ } catch {
122
+ return;
123
+ }
124
+ };
125
+ };
126
+ var processReporter = null;
127
+ var inFlightReports = /* @__PURE__ */ new Set();
128
+ var reportClientError = (event) => {
129
+ processReporter ??= createClientErrorReporter(defaultDeps());
130
+ const report = processReporter(event);
131
+ inFlightReports.add(report);
132
+ void report.finally(() => inFlightReports.delete(report));
133
+ return report;
134
+ };
135
+ var exitAfterClientReports = async (code) => {
136
+ await Promise.all(inFlightReports);
137
+ return process.exit(code);
138
+ };
139
+ var clientErrorKindOf = (error) => isNetworkFailure(error) ? "network" : "unexpected";
140
+ var writeDegraded = (subsystem, report) => {
141
+ process.stderr.write(`${degradedLine(subsystem, report)}
142
+ `);
143
+ void reportClientError({ kind: "degraded", code: `${subsystem}:${report.reason}` });
144
+ };
21
145
 
22
146
  // src/api.ts
23
147
  import { randomUUID } from "crypto";
@@ -169,6 +293,10 @@ var claimBlockedAction = async (apiKey, request, timeoutMs) => {
169
293
  };
170
294
 
171
295
  export {
296
+ reportClientError,
297
+ exitAfterClientReports,
298
+ clientErrorKindOf,
299
+ writeDegraded,
172
300
  isPolicyConfig,
173
301
  isAskUserResponse,
174
302
  isWaitForAnswerResponse,
@@ -3,11 +3,11 @@ import {
3
3
  decodePublicKey,
4
4
  generateSessionKey,
5
5
  wrapSessionKey
6
- } from "./chunk-APP43AW7.js";
6
+ } from "./chunk-PKQ435Z2.js";
7
7
  import {
8
8
  fetchTranscriptRecipients,
9
9
  uploadTranscriptRecords
10
- } from "./chunk-MISUKJGW.js";
10
+ } from "./chunk-ZHF4JDVE.js";
11
11
 
12
12
  // src/live-session.ts
13
13
  var MAX_TRANSCRIPT_QUEUE = 100;
@@ -1,19 +1,17 @@
1
1
  import {
2
2
  AUTO_DECISION_WINDOW_MS,
3
+ DEFAULT_SESSION,
3
4
  claimThrottle,
4
5
  deriveToolTarget,
5
6
  permissionDeniedAction,
6
7
  releaseThrottle,
7
8
  reportEvent
8
- } from "./chunk-LDQGURCF.js";
9
- import {
10
- DEFAULT_SESSION
11
- } from "./chunk-N6IOSZOE.js";
9
+ } from "./chunk-7U26QSMF.js";
12
10
  import {
13
11
  machineDecisionFor,
14
12
  shouldDeferToNativeMode,
15
13
  wireVerdictFor
16
- } from "./chunk-5RGA636G.js";
14
+ } from "./chunk-QOBOIFGG.js";
17
15
 
18
16
  // src/machine-decision-audit.ts
19
17
  import { basename } from "path";
@@ -10,10 +10,10 @@ import {
10
10
  resolvePackageVersionFromBinary,
11
11
  resolvePathBinary,
12
12
  resolvePathBinaryAsync
13
- } from "./chunk-UJZ7AGSC.js";
13
+ } from "./chunk-AWD2SLNA.js";
14
14
  import {
15
15
  MANAGED_PROVIDERS
16
- } from "./chunk-5RGA636G.js";
16
+ } from "./chunk-QOBOIFGG.js";
17
17
 
18
18
  // src/setup/codex-install.ts
19
19
  var NATIVE_BINARY_MIN_BYTES = 20 * 1024 * 1024;
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-3EGEA4KH.js";
10
10
  import {
11
11
  getBaseUrl
12
- } from "./chunk-2M52CFVO.js";
12
+ } from "./chunk-ZC6EVOX6.js";
13
13
 
14
14
  // src/cli/login-ui.ts
15
15
  import { hostname } from "os";