@agent-watch-ai/edge 0.6.0 → 0.7.1

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 (309) hide show
  1. package/CHANGELOG.md +288 -9
  2. package/README.md +307 -5
  3. package/dist/billing/billing-mode.d.ts +37 -5
  4. package/dist/billing/billing-mode.js +28 -19
  5. package/dist/billing/constants/billing.constants.d.ts +0 -2
  6. package/dist/billing/constants/billing.constants.js +0 -2
  7. package/dist/billing/index.d.ts +2 -1
  8. package/dist/billing/index.js +1 -1
  9. package/dist/billing/session-billing.d.ts +7 -3
  10. package/dist/billing/session-billing.js +34 -13
  11. package/dist/billing/types/billing.types.d.ts +7 -0
  12. package/dist/capture/capture-env.d.ts +147 -0
  13. package/dist/capture/capture-env.js +301 -0
  14. package/dist/capture/captured-step.d.ts +88 -0
  15. package/dist/capture/captured-step.js +503 -0
  16. package/dist/capture/constants/capture.constants.d.ts +85 -0
  17. package/dist/capture/constants/capture.constants.js +87 -0
  18. package/dist/capture/launched-runs.d.ts +43 -0
  19. package/dist/capture/launched-runs.js +157 -0
  20. package/dist/capture/node.cjs +697 -0
  21. package/dist/capture/node.d.cts +32 -0
  22. package/dist/capture/python/sitecustomize.py +832 -0
  23. package/dist/capture/schemas/capture.schema.d.ts +35 -0
  24. package/dist/capture/schemas/capture.schema.js +31 -0
  25. package/dist/capture/types/capture.types.d.ts +20 -0
  26. package/dist/capture/venv-loader.d.ts +68 -0
  27. package/dist/capture/venv-loader.js +189 -0
  28. package/dist/cli/constants/cli.constants.d.ts +23 -6
  29. package/dist/cli/constants/cli.constants.js +24 -7
  30. package/dist/cli/context.d.ts +19 -22
  31. package/dist/cli/context.js +23 -54
  32. package/dist/cli/doctor-run-capture.d.ts +21 -0
  33. package/dist/cli/doctor-run-capture.js +33 -0
  34. package/dist/cli/doctor.js +21 -68
  35. package/dist/cli/hook-check.d.ts +7 -2
  36. package/dist/cli/hook-check.js +30 -15
  37. package/dist/cli/hook.d.ts +14 -0
  38. package/dist/cli/hook.js +82 -1
  39. package/dist/cli/index.d.ts +1 -1
  40. package/dist/cli/index.js +1 -1
  41. package/dist/cli/misc.js +10 -2
  42. package/dist/cli/npm-global.d.ts +24 -0
  43. package/dist/cli/npm-global.js +77 -0
  44. package/dist/cli/npx-install.js +22 -6
  45. package/dist/cli/replay.d.ts +33 -0
  46. package/dist/cli/replay.js +228 -0
  47. package/dist/cli/setup.d.ts +10 -2
  48. package/dist/cli/setup.js +200 -31
  49. package/dist/cli/status.js +45 -5
  50. package/dist/cli/toggle.js +10 -0
  51. package/dist/cli/types/cli.types.d.ts +15 -1
  52. package/dist/cli/uninstall.js +42 -23
  53. package/dist/cli/update.js +3 -2
  54. package/dist/cli.js +104 -17
  55. package/dist/config/config-store.d.ts +15 -4
  56. package/dist/config/config-store.js +31 -7
  57. package/dist/config/config.d.ts +0 -2
  58. package/dist/config/config.js +0 -1
  59. package/dist/config/constants/config.constants.d.ts +8 -1
  60. package/dist/config/constants/config.constants.js +10 -1
  61. package/dist/config/events-transport.d.ts +15 -0
  62. package/dist/config/events-transport.js +29 -0
  63. package/dist/config/index.d.ts +2 -1
  64. package/dist/config/index.js +1 -0
  65. package/dist/config/root-config.d.ts +12 -0
  66. package/dist/config/root-config.js +24 -0
  67. package/dist/config/schemas/config.schema.d.ts +15 -2
  68. package/dist/config/schemas/config.schema.js +52 -8
  69. package/dist/config/types/config.types.d.ts +7 -0
  70. package/dist/core/index.d.ts +1 -1
  71. package/dist/core/index.js +1 -1
  72. package/dist/core/version.d.ts +9 -0
  73. package/dist/core/version.js +14 -0
  74. package/dist/core/which.d.ts +11 -0
  75. package/dist/core/which.js +18 -0
  76. package/dist/credentials/cloud-claim.d.ts +34 -0
  77. package/dist/credentials/cloud-claim.js +61 -0
  78. package/dist/credentials/constants/credentials.constants.d.ts +16 -1
  79. package/dist/credentials/constants/credentials.constants.js +17 -2
  80. package/dist/credentials/credential-status.js +1 -1
  81. package/dist/credentials/credentials.d.ts +3 -3
  82. package/dist/credentials/credentials.js +26 -12
  83. package/dist/credentials/device-api.d.ts +15 -1
  84. package/dist/credentials/device-api.js +12 -1
  85. package/dist/credentials/identity.d.ts +2 -2
  86. package/dist/credentials/identity.js +2 -2
  87. package/dist/credentials/install-key.d.ts +31 -0
  88. package/dist/credentials/install-key.js +58 -0
  89. package/dist/credentials/migration.d.ts +9 -7
  90. package/dist/credentials/migration.js +58 -18
  91. package/dist/credentials/secret-store.d.ts +12 -0
  92. package/dist/credentials/secret-store.js +18 -1
  93. package/dist/credentials/sign-in.d.ts +27 -0
  94. package/dist/credentials/sign-in.js +31 -1
  95. package/dist/credentials/token-refresher.d.ts +5 -1
  96. package/dist/credentials/token-refresher.js +10 -2
  97. package/dist/enforcement/enforcement.js +1 -1
  98. package/dist/events/constants/events.constants.d.ts +5 -2
  99. package/dist/events/constants/events.constants.js +4 -1
  100. package/dist/events/enrich.d.ts +14 -0
  101. package/dist/events/enrich.js +1 -1
  102. package/dist/events/index.d.ts +1 -0
  103. package/dist/events/product-event.d.ts +6 -3
  104. package/dist/events/types/events.types.d.ts +6 -0
  105. package/dist/events/types/replay-progress.types.d.ts +26 -0
  106. package/dist/events/types/replay-progress.types.js +1 -0
  107. package/dist/events/types/repo-tree.types.d.ts +2 -1
  108. package/dist/feature/ticket-candidates.d.ts +1 -1
  109. package/dist/git/checkout-root.d.ts +15 -0
  110. package/dist/git/checkout-root.js +18 -0
  111. package/dist/git/code-state.d.ts +2 -16
  112. package/dist/git/code-state.js +11 -12
  113. package/dist/git/constants/git.constants.d.ts +33 -11
  114. package/dist/git/constants/git.constants.js +45 -12
  115. package/dist/git/fingerprint.d.ts +3 -6
  116. package/dist/git/fingerprint.js +5 -8
  117. package/dist/git/git-context.js +5 -1
  118. package/dist/git/index.d.ts +1 -2
  119. package/dist/git/index.js +1 -1
  120. package/dist/git/repo-snapshot.d.ts +13 -4
  121. package/dist/git/repo-snapshot.js +53 -9
  122. package/dist/git/types/snapshot.types.d.ts +6 -0
  123. package/dist/pipeline/constants/pipeline.constants.d.ts +3 -0
  124. package/dist/pipeline/constants/pipeline.constants.js +3 -0
  125. package/dist/pipeline/hook-pipeline.js +82 -57
  126. package/dist/privacy/product-capture.js +2 -0
  127. package/dist/providers/antigravity/antigravity.capture.d.ts +2 -0
  128. package/dist/providers/antigravity/antigravity.capture.js +5 -0
  129. package/dist/providers/antigravity/antigravity.detect.js +8 -22
  130. package/dist/providers/antigravity/antigravity.provider.js +10 -3
  131. package/dist/providers/antigravity/constants/antigravity.constants.d.ts +1 -0
  132. package/dist/providers/antigravity/constants/antigravity.constants.js +1 -0
  133. package/dist/providers/claude/claude.adapter.js +9 -6
  134. package/dist/providers/claude/claude.detect.js +2 -17
  135. package/dist/providers/claude/claude.otel.d.ts +21 -3
  136. package/dist/providers/claude/claude.otel.js +216 -61
  137. package/dist/providers/claude/claude.provider.js +21 -1
  138. package/dist/providers/claude/claude.version.d.ts +9 -0
  139. package/dist/providers/claude/claude.version.js +28 -0
  140. package/dist/providers/claude/constants/claude.constants.d.ts +27 -0
  141. package/dist/providers/claude/constants/claude.constants.js +27 -0
  142. package/dist/providers/claude/constants/claude.otel.constants.d.ts +27 -0
  143. package/dist/providers/claude/constants/claude.otel.constants.js +45 -5
  144. package/dist/providers/claude/types/claude.types.d.ts +13 -0
  145. package/dist/providers/codex/codex.capture.d.ts +76 -0
  146. package/dist/providers/codex/codex.capture.js +454 -0
  147. package/dist/providers/codex/codex.detect.js +2 -4
  148. package/dist/providers/codex/codex.otel.d.ts +38 -2
  149. package/dist/providers/codex/codex.otel.js +50 -6
  150. package/dist/providers/codex/codex.provider.js +8 -0
  151. package/dist/providers/codex/codex.surface.d.ts +9 -0
  152. package/dist/{turns/codex-originator.js → providers/codex/codex.surface.js} +17 -3
  153. package/dist/providers/codex/codex.titles.d.ts +14 -0
  154. package/dist/providers/codex/codex.titles.js +35 -0
  155. package/dist/providers/codex/constants/codex.constants.d.ts +4 -0
  156. package/dist/providers/codex/constants/codex.constants.js +4 -0
  157. package/dist/providers/cursor/constants/cursor.constants.d.ts +17 -4
  158. package/dist/providers/cursor/constants/cursor.constants.js +25 -5
  159. package/dist/providers/cursor/cursor-mcp-memo.d.ts +34 -0
  160. package/dist/providers/cursor/cursor-mcp-memo.js +94 -0
  161. package/dist/providers/cursor/cursor.adapter.js +20 -82
  162. package/dist/providers/cursor/cursor.capture.d.ts +1 -0
  163. package/dist/providers/cursor/cursor.capture.js +4 -0
  164. package/dist/providers/cursor/cursor.detect.d.ts +5 -1
  165. package/dist/providers/cursor/cursor.detect.js +11 -26
  166. package/dist/providers/cursor/cursor.hooks.js +2 -2
  167. package/dist/providers/cursor/cursor.provider.js +16 -7
  168. package/dist/providers/cursor/cursor.titles.d.ts +14 -0
  169. package/dist/providers/cursor/cursor.titles.js +20 -0
  170. package/dist/providers/cursor/schemas/cursor.schema.d.ts +3 -3
  171. package/dist/providers/cursor/schemas/cursor.schema.js +5 -3
  172. package/dist/providers/gemini/constants/gemini.constants.d.ts +16 -0
  173. package/dist/providers/gemini/constants/gemini.constants.js +17 -0
  174. package/dist/providers/gemini/gemini.capture.d.ts +81 -0
  175. package/dist/providers/gemini/gemini.capture.js +210 -0
  176. package/dist/providers/gemini/gemini.detect.js +57 -24
  177. package/dist/providers/gemini/gemini.otel.d.ts +38 -2
  178. package/dist/providers/gemini/gemini.otel.js +56 -125
  179. package/dist/providers/gemini/gemini.provider.js +5 -0
  180. package/dist/providers/index.d.ts +1 -0
  181. package/dist/providers/index.js +1 -0
  182. package/dist/providers/provider.d.ts +8 -0
  183. package/dist/providers/provider.js +9 -0
  184. package/dist/providers/registry.d.ts +14 -0
  185. package/dist/providers/registry.js +14 -0
  186. package/dist/providers/shared/constants/hook-config.constants.d.ts +2 -0
  187. package/dist/providers/shared/constants/hook-config.constants.js +2 -0
  188. package/dist/providers/shared/constants/terminal-capture.constants.d.ts +6 -0
  189. package/dist/providers/shared/constants/terminal-capture.constants.js +6 -0
  190. package/dist/providers/shared/editor-paths.d.ts +8 -0
  191. package/dist/providers/shared/editor-paths.js +18 -0
  192. package/dist/providers/shared/hook-config.d.ts +5 -0
  193. package/dist/providers/shared/hook-config.js +39 -1
  194. package/dist/providers/shared/hooks-marker.d.ts +14 -0
  195. package/dist/providers/shared/hooks-marker.js +23 -0
  196. package/dist/providers/shared/install-record.d.ts +29 -0
  197. package/dist/providers/shared/install-record.js +52 -0
  198. package/dist/providers/shared/session-title-store.d.ts +23 -0
  199. package/dist/providers/shared/session-title-store.js +50 -0
  200. package/dist/providers/shared/terminal-capture.d.ts +41 -0
  201. package/dist/providers/shared/terminal-capture.js +109 -0
  202. package/dist/providers/shared/tooling.d.ts +21 -0
  203. package/dist/providers/shared/tooling.js +36 -1
  204. package/dist/providers/types/provider.types.d.ts +57 -4
  205. package/dist/replay/checkout-resolver.d.ts +56 -0
  206. package/dist/replay/checkout-resolver.js +173 -0
  207. package/dist/replay/codex-turns.d.ts +24 -0
  208. package/dist/replay/codex-turns.js +221 -0
  209. package/dist/replay/constants/replay.constants.d.ts +99 -0
  210. package/dist/replay/constants/replay.constants.js +102 -0
  211. package/dist/replay/describe.d.ts +10 -0
  212. package/dist/replay/describe.js +31 -0
  213. package/dist/replay/gemini-turns.d.ts +36 -0
  214. package/dist/replay/gemini-turns.js +192 -0
  215. package/dist/replay/machine.d.ts +34 -0
  216. package/dist/replay/machine.js +68 -0
  217. package/dist/replay/progress-event.d.ts +21 -0
  218. package/dist/replay/progress-event.js +45 -0
  219. package/dist/replay/replay-runner.d.ts +60 -0
  220. package/dist/replay/replay-runner.js +581 -0
  221. package/dist/replay/replay-scan.d.ts +84 -0
  222. package/dist/replay/replay-scan.js +182 -0
  223. package/dist/replay/replay-state.d.ts +108 -0
  224. package/dist/replay/replay-state.js +199 -0
  225. package/dist/replay/resume.d.ts +18 -0
  226. package/dist/replay/resume.js +34 -0
  227. package/dist/replay/start.d.ts +23 -0
  228. package/dist/replay/start.js +39 -0
  229. package/dist/replay/throttle.d.ts +36 -0
  230. package/dist/replay/throttle.js +44 -0
  231. package/dist/replay/transcript-turns.d.ts +35 -0
  232. package/dist/replay/transcript-turns.js +241 -0
  233. package/dist/replay/turn-event.d.ts +40 -0
  234. package/dist/replay/turn-event.js +127 -0
  235. package/dist/replay/types/replay.types.d.ts +198 -0
  236. package/dist/replay/types/replay.types.js +1 -0
  237. package/dist/replay/window.d.ts +28 -0
  238. package/dist/replay/window.js +41 -0
  239. package/dist/replay/worktree-map.d.ts +42 -0
  240. package/dist/replay/worktree-map.js +134 -0
  241. package/dist/snapshot/branch-selection.d.ts +40 -23
  242. package/dist/snapshot/branch-selection.js +71 -41
  243. package/dist/snapshot/constants/snapshot-stages.constants.d.ts +3 -1
  244. package/dist/snapshot/constants/snapshot-stages.constants.js +3 -1
  245. package/dist/snapshot/constants/snapshot.constants.d.ts +34 -7
  246. package/dist/snapshot/constants/snapshot.constants.js +34 -7
  247. package/dist/snapshot/index.d.ts +2 -2
  248. package/dist/snapshot/index.js +1 -1
  249. package/dist/snapshot/snapshot-pipeline.js +100 -26
  250. package/dist/snapshot/snapshot-state.js +6 -2
  251. package/dist/snapshot/tree-pipeline.d.ts +1 -1
  252. package/dist/snapshot/tree-pipeline.js +34 -15
  253. package/dist/snapshot/types/snapshot.types.d.ts +22 -3
  254. package/dist/storage/schemas/storage.schema.d.ts +2 -0
  255. package/dist/storage/schemas/storage.schema.js +6 -0
  256. package/dist/transport/delivery-stats.d.ts +13 -1
  257. package/dist/transport/delivery-stats.js +18 -2
  258. package/dist/transport/delivery.d.ts +4 -3
  259. package/dist/transport/delivery.js +21 -7
  260. package/dist/transport/identity-delivery.d.ts +20 -0
  261. package/dist/transport/identity-delivery.js +41 -0
  262. package/dist/transport/index.d.ts +2 -0
  263. package/dist/transport/index.js +1 -0
  264. package/dist/transport/types/delivery-flow.types.d.ts +7 -0
  265. package/dist/turns/claude-transcript.js +4 -12
  266. package/dist/turns/codex-transcript.d.ts +9 -0
  267. package/dist/turns/codex-transcript.js +27 -19
  268. package/dist/turns/constants/turns.constants.d.ts +29 -12
  269. package/dist/turns/constants/turns.constants.js +31 -19
  270. package/dist/turns/gemini-transcript.d.ts +19 -1
  271. package/dist/turns/gemini-transcript.js +29 -18
  272. package/dist/turns/index.d.ts +3 -4
  273. package/dist/turns/index.js +2 -3
  274. package/dist/turns/run-state.d.ts +71 -0
  275. package/dist/turns/run-state.js +114 -0
  276. package/dist/turns/tool-events.d.ts +11 -1
  277. package/dist/turns/tool-events.js +32 -9
  278. package/dist/turns/transcript.d.ts +15 -14
  279. package/dist/turns/transcript.js +23 -4
  280. package/dist/turns/turn-state.d.ts +82 -7
  281. package/dist/turns/turn-state.js +157 -10
  282. package/dist/turns/turn-summary.js +7 -2
  283. package/dist/turns/turn-tracker.d.ts +9 -16
  284. package/dist/turns/turn-tracker.js +163 -87
  285. package/dist/turns/types/transcript.types.d.ts +11 -1
  286. package/dist/turns/types/turn-provider.types.d.ts +33 -0
  287. package/dist/turns/types/turn-provider.types.js +1 -0
  288. package/dist/turns/types/turn-state.types.d.ts +9 -0
  289. package/dist/turns/types/turn-summary.types.d.ts +17 -1
  290. package/dist/turns/types/turn-tracker.types.d.ts +3 -1
  291. package/dist/turns/work-checkout.js +1 -2
  292. package/docs/AUDIT_PROMPT.md +10 -0
  293. package/docs/DATA_HANDLING.md +201 -13
  294. package/docs/ENTERPRISE_DEPLOYMENT.md +3 -3
  295. package/docs/PERFORMANCE.md +10 -0
  296. package/package.json +3 -2
  297. package/dist/events/canonical-event.d.ts +0 -10
  298. package/dist/events/canonical-event.js +0 -9
  299. package/dist/git/repository-root.d.ts +0 -39
  300. package/dist/git/repository-root.js +0 -131
  301. package/dist/git/types/repository-root.types.d.ts +0 -11
  302. package/dist/transport/transport.d.ts +0 -6
  303. package/dist/turns/codex-originator.d.ts +0 -11
  304. package/dist/turns/cursor-transcript.d.ts +0 -21
  305. package/dist/turns/cursor-transcript.js +0 -66
  306. package/dist/turns/native-session-titles.d.ts +0 -26
  307. package/dist/turns/native-session-titles.js +0 -102
  308. /package/dist/{git/types/repository-root.types.js → billing/types/billing.types.js} +0 -0
  309. /package/dist/{transport/transport.js → capture/types/capture.types.js} +0 -0
@@ -1,11 +1,11 @@
1
- import fs from 'node:fs';
2
1
  import path from 'node:path';
3
2
  import { asRecord, compact } from '../../core/object.js';
4
3
  import { sha256Hex } from '../../events/event-id.js';
5
4
  import { resolvePaths } from '../../storage/paths.js';
6
5
  import { baseEvent, filePathPatch, promptPatch, responsePatch, toolCallEvidence, toolPatch, withPatch } from '../shared/event-builder.js';
7
6
  import { classifyTool, contentEvidence, mcpServerFromEndpoint, mcpToolKey, parseMcpToolName, shellCallOf, toolCompleteType, toolStartType } from '../shared/tooling.js';
8
- import { ATTACHMENT_FILE_PATH_KEY, CURSOR_DEDICATED_COMPLETION_KINDS, CURSOR_DISPLAY_NAME, CURSOR_EDIT_TOOL_NAME, CURSOR_EVENT_TYPE_MAP, CURSOR_PROVIDER_ID, CURSOR_READ_TOOL_NAME, CURSOR_GENERIC_TOOL_START_EVENT, CURSOR_SHELL_COMMAND_KEY, CURSOR_SHELL_EVENTS, CURSOR_SHELL_WORKDIR_KEY, CURSOR_SHELL_TOOL_NAME, CURSOR_TOOL_KINDS, CURSOR_UNKNOWN_EVENT, CURSOR_UNKNOWN_MCP_SERVER } from './constants/cursor.constants.js';
7
+ import { ATTACHMENT_FILE_PATH_KEY, CURSOR_DEDICATED_COMPLETION_KINDS, CURSOR_DISPLAY_NAME, CURSOR_DROPPED_EVENTS, CURSOR_EDIT_TOOL_NAME, CURSOR_EVENT_TYPE_MAP, CURSOR_PROVIDER_ID, CURSOR_READ_TOOL_NAME, CURSOR_GENERIC_TOOL_START_EVENT, CURSOR_SHELL_COMMAND_KEY, CURSOR_SHELL_EVENTS, CURSOR_SHELL_WORKDIR_KEY, CURSOR_SHELL_TOOL_NAME, CURSOR_TOOL_KINDS, CURSOR_UNKNOWN_EVENT, CURSOR_UNKNOWN_MCP_SERVER } from './constants/cursor.constants.js';
8
+ import { rememberedMcpServer, rememberMcpServer } from './cursor-mcp-memo.js';
9
9
  import { cursorPayloadSchema } from './schemas/cursor.schema.js';
10
10
  /**
11
11
  * Translate one Cursor hook payload into canonical events.
@@ -20,6 +20,9 @@ export function parseCursorHookEvent(rawPayload, context) {
20
20
  return [];
21
21
  const payload = parsed.data;
22
22
  const providerEventType = payload.hook_event_name ?? CURSOR_UNKNOWN_EVENT;
23
+ // Until a re-install sweeps it off, an old registration still fires on every Tab accept.
24
+ if (CURSOR_DROPPED_EVENTS.has(providerEventType))
25
+ return [];
23
26
  return [withPatch(cursorBaseEvent(payload, providerEventType), hookPatch(payload, providerEventType, context))];
24
27
  }
25
28
  /**
@@ -81,7 +84,7 @@ function cursorBaseEvent(payload, providerEventType) {
81
84
  const sessionId = payload.conversation_id ?? payload.session_id;
82
85
  // model_id is the structured identifier and supersedes the legacy slug.
83
86
  const model = (typeof payload.model_id === 'string' && payload.model_id.length > 0 ? payload.model_id : undefined) ?? payload.model;
84
- return baseEvent({
87
+ const event = baseEvent({
85
88
  provider: CURSOR_PROVIDER_ID,
86
89
  displayName: CURSOR_DISPLAY_NAME,
87
90
  providerEventType,
@@ -103,6 +106,9 @@ function cursorBaseEvent(payload, providerEventType) {
103
106
  },
104
107
  timestamp: new Date().toISOString()
105
108
  });
109
+ // On every hook, so the Stop that closes a turn carries it to the summary.
110
+ const accountEmail = typeof payload.user_email === 'string' ? payload.user_email.trim() : undefined;
111
+ return accountEmail ? { ...event, developer: { accountEmail } } : event;
106
112
  }
107
113
  /**
108
114
  * What this particular hook contributes on top of the base event.
@@ -115,7 +121,7 @@ function cursorBaseEvent(payload, providerEventType) {
115
121
  function hookPatch(payload, providerEventType, context) {
116
122
  const capture = context.config.capture;
117
123
  if (providerEventType === 'sessionStart') {
118
- return { metadata: { sessionSource: payload.composer_mode, isBackgroundAgent: payload.is_background_agent } };
124
+ return { session: compact({ mode: payload.composer_mode, isCloudAgent: payload.is_background_agent }) };
119
125
  }
120
126
  if (providerEventType === 'sessionEnd')
121
127
  return { metadata: { sessionEndReason: payload.reason } };
@@ -137,8 +143,8 @@ function hookPatch(payload, providerEventType, context) {
137
143
  ...filePathPatch(payload.file_path, capture)
138
144
  };
139
145
  }
140
- if (providerEventType === 'afterFileEdit' || providerEventType === 'afterTabFileEdit') {
141
- return fileEditPatch(payload, providerEventType, context);
146
+ if (providerEventType === 'afterFileEdit') {
147
+ return fileEditPatch(payload, context);
142
148
  }
143
149
  if (providerEventType === 'subagentStart' || providerEventType === 'subagentStop') {
144
150
  return subagentPatch(payload, providerEventType);
@@ -240,9 +246,12 @@ function mcpPatch(payload, providerEventType, context) {
240
246
  // An endpoint that names no server still gets a parseable key, so mcpNames:false folds it.
241
247
  const toolName = parsed.tool ?? payload.tool_name;
242
248
  const endpoint = parsed.server ?? mcpServerFromEndpoint(payload.url, payload.command);
243
- const server = endpoint ?? rememberedMcpServer(payload, toolName, context) ?? CURSOR_UNKNOWN_MCP_SERVER;
244
- if (endpoint && toolName)
245
- rememberMcpServer(payload, toolName, endpoint, context);
249
+ const dataDir = resolvePaths(context.env).dataDir;
250
+ const conversationId = payload.conversation_id;
251
+ const remembered = !endpoint && conversationId && toolName ? rememberedMcpServer(dataDir, conversationId, toolName) : undefined;
252
+ const server = endpoint ?? remembered ?? CURSOR_UNKNOWN_MCP_SERVER;
253
+ if (endpoint && toolName && conversationId)
254
+ rememberMcpServer(dataDir, conversationId, toolName, endpoint, context.env.now());
246
255
  return {
247
256
  tool: {
248
257
  name: toolName ? mcpToolKey(server, toolName) : payload.tool_name,
@@ -261,90 +270,19 @@ function mcpPatch(payload, providerEventType, context) {
261
270
  };
262
271
  }
263
272
  /**
264
- * Where a conversation's MCP servers are remembered between its hooks.
265
- *
266
- * `afterMCPExecution` carries neither url nor command, and only completions
267
- * become turn records, so the server the before-hook saw has to outlive it.
273
+ * File-edit fields for `afterFileEdit`, Cursor's dedicated edit hook.
268
274
  *
269
275
  * @param payload - Parsed hook payload.
270
- * @param context - Environment.
271
- * @returns The state file, or undefined without a conversation id.
272
- */
273
- function mcpMemoFile(payload, context) {
274
- if (!payload.conversation_id)
275
- return undefined;
276
- return path.join(resolvePaths(context.env).dataDir, 'cursor-mcp', `${sha256Hex(payload.conversation_id).slice(0, 32)}.json`);
277
- }
278
- /**
279
- * Remembers which server a tool resolved to, for the completion hook.
280
- *
281
- * ponytail: one tiny file per conversation, last write wins per tool name, never
282
- * pruned (the data dir is disposable); two servers exposing the same tool name
283
- * in one conversation share an entry. Upgrade: key by tool_use_id if Cursor sends it.
284
- *
285
- * @param payload - Parsed hook payload.
286
- * @param tool - Tool name.
287
- * @param server - Resolved server.
288
- * @param context - Environment.
289
- */
290
- function rememberMcpServer(payload, tool, server, context) {
291
- const file = mcpMemoFile(payload, context);
292
- if (!file)
293
- return;
294
- try {
295
- fs.mkdirSync(path.dirname(file), { recursive: true });
296
- fs.writeFileSync(file, JSON.stringify({ ...readMcpMemo(file), [tool]: server }), { mode: 0o600 });
297
- }
298
- catch {
299
- // Hooks never fail the agent; the completion just keys as unknown.
300
- }
301
- }
302
- /**
303
- * The server a tool resolved to in this conversation's before-hook.
304
- *
305
- * @param payload - Parsed hook payload.
306
- * @param tool - Tool name.
307
- * @param context - Environment.
308
- * @returns The server, or undefined when none was remembered.
309
- */
310
- function rememberedMcpServer(payload, tool, context) {
311
- const file = mcpMemoFile(payload, context);
312
- if (!file || !tool)
313
- return undefined;
314
- const server = readMcpMemo(file)[tool];
315
- return typeof server === 'string' ? server : undefined;
316
- }
317
- /**
318
- * Reads a conversation's MCP memo.
319
- *
320
- * @param file - Memo file.
321
- * @returns Its contents, empty when missing or unreadable.
322
- */
323
- function readMcpMemo(file) {
324
- try {
325
- return asRecord(JSON.parse(fs.readFileSync(file, 'utf8'))) ?? {};
326
- }
327
- catch {
328
- return {};
329
- }
330
- }
331
- /**
332
- * File-edit fields for Cursor's dedicated edit hooks.
333
- *
334
- * @param payload - Parsed hook payload.
335
- * @param providerEventType - Cursor's own name for this hook.
336
276
  * @param context - Environment and effective config.
337
277
  * @returns The patch.
338
278
  */
339
- function fileEditPatch(payload, providerEventType, context) {
279
+ function fileEditPatch(payload, context) {
340
280
  const capture = context.config.capture;
341
281
  const pathPatch = filePathPatch(payload.file_path, capture);
342
282
  return {
343
283
  tool: { name: payload.tool_name ?? CURSOR_EDIT_TOOL_NAME, status: 'completed' },
344
284
  metadata: compact({
345
285
  ...pathPatch.metadata,
346
- // Tab edits are the editor's inline completion, not an agent tool call.
347
- tab: providerEventType === 'afterTabFileEdit' ? true : undefined,
348
286
  toolOutput: capture.toolOutput && payload.edits !== undefined ? payload.edits : undefined
349
287
  })
350
288
  };
@@ -0,0 +1 @@
1
+ export declare const cursorCapture: import("../shared/terminal-capture.js").TerminalCapture;
@@ -0,0 +1,4 @@
1
+ import { terminalCapture } from '../shared/terminal-capture.js';
2
+ /** Flip to true, with the PR's verification done on the installed app. */
3
+ const CURSOR_ROUTE_VERIFIED = false;
4
+ export const cursorCapture = terminalCapture('Cursor', CURSOR_ROUTE_VERIFIED);
@@ -10,7 +10,11 @@ export declare function cursorHooksJsonPath(env: Env): string;
10
10
  /**
11
11
  * Whether Cursor is installed here, and whether our hooks are registered.
12
12
  *
13
- * @param env - Environment supplying HOME, cwd and PATH.
13
+ * A project's `.cursor` folder (rules, MCP config) is checked in and is there
14
+ * on machines without Cursor, so only its `hooks.json` counts: that is how a
15
+ * cloud agent, with no `~/.cursor` and no executable, runs our hooks.
16
+ *
17
+ * @param env - Environment supplying HOME, PATH and cwd (for a project `.cursor/hooks.json`).
14
18
  * @returns What was found.
15
19
  */
16
20
  export declare function detectCursor(env: Env): Promise<DetectionResult>;
@@ -1,8 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import { findExecutable } from '../../core/which.js';
4
- import { readJsonFile } from '../../storage/json-file.js';
5
- import { HOOK_COMMAND_MARKER } from '../constants/provider.constants.js';
3
+ import { findFirstExecutable } from '../../core/which.js';
4
+ import { hooksMarkerPresent } from '../shared/hooks-marker.js';
6
5
  import { CURSOR_EXECUTABLES, CURSOR_HOME_DIR, CURSOR_HOOKS_FILE } from './constants/cursor.constants.js';
7
6
  /**
8
7
  * Cursor's configuration root.
@@ -25,42 +24,28 @@ export function cursorHooksJsonPath(env) {
25
24
  /**
26
25
  * Whether Cursor is installed here, and whether our hooks are registered.
27
26
  *
28
- * @param env - Environment supplying HOME, cwd and PATH.
27
+ * A project's `.cursor` folder (rules, MCP config) is checked in and is there
28
+ * on machines without Cursor, so only its `hooks.json` counts: that is how a
29
+ * cloud agent, with no `~/.cursor` and no executable, runs our hooks.
30
+ *
31
+ * @param env - Environment supplying HOME, PATH and cwd (for a project `.cursor/hooks.json`).
29
32
  * @returns What was found.
30
33
  */
31
34
  export async function detectCursor(env) {
32
35
  const evidence = [];
33
36
  if (fs.existsSync(cursorHome(env)))
34
37
  evidence.push('~/.cursor directory exists');
35
- if (fs.existsSync(path.join(env.cwd, CURSOR_HOME_DIR)))
36
- evidence.push('.cursor directory in working tree');
37
- const executablePath = findFirstExecutable(env);
38
+ if (fs.existsSync(path.join(env.cwd, CURSOR_HOME_DIR, CURSOR_HOOKS_FILE)))
39
+ evidence.push('.cursor/hooks.json in working tree');
40
+ const executablePath = findFirstExecutable(env, CURSOR_EXECUTABLES);
38
41
  if (executablePath)
39
42
  evidence.push(`cursor executable on PATH (${executablePath})`);
40
43
  const hookConfigPath = cursorHooksJsonPath(env);
41
- const hooksFile = await readJsonFile(hookConfigPath);
42
44
  return {
43
45
  detected: evidence.length > 0,
44
46
  evidence,
45
47
  executablePath,
46
48
  hookConfigPath,
47
- hooksInstalled: hooksFile.state === 'ok' && JSON.stringify(hooksFile.value).includes(HOOK_COMMAND_MARKER)
49
+ hooksInstalled: await hooksMarkerPresent(hookConfigPath)
48
50
  };
49
51
  }
50
- /**
51
- * The first of Cursor's executable names found on PATH.
52
- *
53
- * The editor ships `cursor`; the CLI agent ships `cursor-agent`, and a machine
54
- * may have either.
55
- *
56
- * @param env - Environment supplying PATH.
57
- * @returns The path, or undefined when neither is installed.
58
- */
59
- function findFirstExecutable(env) {
60
- for (const name of CURSOR_EXECUTABLES) {
61
- const found = findExecutable(env, name);
62
- if (found)
63
- return found;
64
- }
65
- return undefined;
66
- }
@@ -4,7 +4,7 @@ import { readJsonFile } from '../../storage/json-file.js';
4
4
  import { registerOurHandlers, stripOurHandlers, sweepUnregisteredEvents, writeJsonValidated } from '../shared/hook-config.js';
5
5
  import { withHookInstall, withoutHookInstall } from '../shared/install-record.js';
6
6
  import { cursorHooksJsonPath } from './cursor.detect.js';
7
- import { CURSOR_HOOKS_VERSION, CURSOR_HOOK_EVENTS, CURSOR_HOOK_TIMEOUT_SECONDS, CURSOR_PROVIDER_ID, CURSOR_USAGE_NOTE, CURSOR_VERSION_KEY } from './constants/cursor.constants.js';
7
+ import { CURSOR_HOOKS_VERSION, CURSOR_HOOK_EVENTS, CURSOR_HOOK_TIMEOUT_SECONDS, CURSOR_PROVIDER_ID, CURSOR_VERSION_KEY } from './constants/cursor.constants.js';
8
8
  export { CURSOR_HOOK_EVENTS } from './constants/cursor.constants.js';
9
9
  /**
10
10
  * Register AgentWatch's hooks in `~/.cursor/hooks.json`.
@@ -43,7 +43,7 @@ export async function installCursorHooks(context) {
43
43
  return {
44
44
  ok: true,
45
45
  changed,
46
- messages: [changed ? `hooks registered in ${hooksPath}` : 'hooks already registered', CURSOR_USAGE_NOTE],
46
+ messages: [changed ? `hooks registered in ${hooksPath}` : 'hooks already registered'],
47
47
  installState: withHookInstall(context.installState, CURSOR_PROVIDER_ID, {
48
48
  hookConfigPath: hooksPath,
49
49
  hookEvents: CURSOR_HOOK_EVENTS,
@@ -1,14 +1,18 @@
1
+ import { IDE_SURFACE } from '../../turns/constants/turns.constants.js';
1
2
  import { hookRefusal } from '../shared/hook-refusal.js';
2
- import { CURSOR_PROMPT_SUBMIT_EVENTS } from './constants/cursor.constants.js';
3
+ import { CURSOR_CAVEATS, CURSOR_PROMPT_SUBMIT_EVENTS } from './constants/cursor.constants.js';
4
+ import { cursorCapture } from './cursor.capture.js';
3
5
  import { detectCursor } from './cursor.detect.js';
4
6
  import { installCursorHooks, uninstallCursorHooks } from './cursor.hooks.js';
7
+ import { readCursorSessionTitles } from './cursor.titles.js';
5
8
  import { cursorCwd, cursorShellCall, cursorWorkspaceRoots, parseCursorHookEvent } from './cursor.adapter.js';
6
9
  export const cursorProvider = {
7
10
  id: 'cursor',
8
11
  displayName: 'Cursor',
9
12
  detect: detectCursor,
10
- installHooks: installCursorHooks,
11
- uninstallHooks: uninstallCursorHooks,
13
+ installHooks: cursorCapture.install(installCursorHooks),
14
+ uninstallHooks: cursorCapture.uninstall(uninstallCursorHooks),
15
+ runCapture: cursorCapture.route,
12
16
  parseHookEvent: async (payload, context) => parseCursorHookEvent(payload, context),
13
17
  /**
14
18
  * Cursor's before* hooks fail open and treat an absent `permission` field
@@ -23,8 +27,13 @@ export const cursorProvider = {
23
27
  getBlockResponse: (payload, message) => hookRefusal(payload, CURSOR_PROMPT_SUBMIT_EVENTS, { continue: false, user_message: message }),
24
28
  resolveCwd: cursorCwd,
25
29
  shellCall: cursorShellCall,
26
- workspaceRoots: cursorWorkspaceRoots
27
- // No nativeTelemetry: Cursor has no OTel export, so there is no llm.call
28
- // ledger source. Turn summaries stay usage_status=pending until Cursor
29
- // enriches its transcripts with usage (see cursor-transcript.ts).
30
+ workspaceRoots: cursorWorkspaceRoots,
31
+ caveats: CURSOR_CAVEATS,
32
+ readSessionTitles: readCursorSessionTitles,
33
+ surface: async () => IDE_SURFACE,
34
+ /** `composer_mode` and `is_background_agent` come on sessionStart alone. */
35
+ namesSessionMode: true
36
+ // No nativeTelemetry and no readTurnUsage: Cursor has no OTel export and its
37
+ // transcripts carry no usage, so turn summaries stay usage_status=pending.
38
+ // Cursor cost comes from the Cursor Admin API connection in Integrations.
30
39
  };
@@ -0,0 +1,14 @@
1
+ import type { Env } from '../../core/types/core.types.js';
2
+ import type { SessionTitles } from '../../turns/types/transcript.types.js';
3
+ /**
4
+ * Read Cursor's generated conversation title from its local search index.
5
+ *
6
+ * Cursor exposes no title in hooks or transcripts. The desktop app's search
7
+ * index keys the same conversation id the hook sends; Cursor keeps custom and
8
+ * generated titles in one display field, so it maps to `session_title`.
9
+ *
10
+ * @param env - Environment locating Cursor's platform data directory.
11
+ * @param sessionId - Cursor conversation id from the hook payload.
12
+ * @returns Cursor's display title, or neither when unavailable.
13
+ */
14
+ export declare function readCursorSessionTitles(env: Env, sessionId: string): Promise<SessionTitles>;
@@ -0,0 +1,20 @@
1
+ import path from 'node:path';
2
+ import { readTitles, sqliteModule } from '../shared/session-title-store.js';
3
+ import { editorConfigRoot } from '../shared/editor-paths.js';
4
+ /**
5
+ * Read Cursor's generated conversation title from its local search index.
6
+ *
7
+ * Cursor exposes no title in hooks or transcripts. The desktop app's search
8
+ * index keys the same conversation id the hook sends; Cursor keeps custom and
9
+ * generated titles in one display field, so it maps to `session_title`.
10
+ *
11
+ * @param env - Environment locating Cursor's platform data directory.
12
+ * @param sessionId - Cursor conversation id from the hook payload.
13
+ * @returns Cursor's display title, or neither when unavailable.
14
+ */
15
+ export async function readCursorSessionTitles(env, sessionId) {
16
+ const sqlite = sqliteModule();
17
+ if (!sqlite)
18
+ return {};
19
+ return readTitles(sqlite, path.join(editorConfigRoot(env), 'Cursor', 'User', 'globalStorage', 'conversation-search.db'), "SELECT title FROM conversations WHERE source = 'local' AND scope = '' AND id = ?", sessionId);
20
+ }
@@ -18,9 +18,10 @@ export declare const cursorPayloadSchema: z.ZodObject<{
18
18
  workspace_roots: z.ZodOptional<z.ZodArray<z.ZodString>>;
19
19
  transcript_path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
20
  cwd: z.ZodOptional<z.ZodString>;
21
+ user_email: z.ZodOptional<z.ZodUnknown>;
21
22
  session_id: z.ZodOptional<z.ZodString>;
22
- is_background_agent: z.ZodOptional<z.ZodBoolean>;
23
- composer_mode: z.ZodOptional<z.ZodString>;
23
+ is_background_agent: z.ZodCatch<z.ZodOptional<z.ZodBoolean>>;
24
+ composer_mode: z.ZodCatch<z.ZodOptional<z.ZodString>>;
24
25
  reason: z.ZodOptional<z.ZodString>;
25
26
  prompt: z.ZodOptional<z.ZodString>;
26
27
  attachments: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
@@ -41,7 +42,6 @@ export declare const cursorPayloadSchema: z.ZodObject<{
41
42
  subagent_id: z.ZodOptional<z.ZodString>;
42
43
  subagent_type: z.ZodOptional<z.ZodString>;
43
44
  subagent_model: z.ZodOptional<z.ZodString>;
44
- parent_conversation_id: z.ZodOptional<z.ZodString>;
45
45
  task: z.ZodOptional<z.ZodString>;
46
46
  status: z.ZodOptional<z.ZodString>;
47
47
  text: z.ZodOptional<z.ZodString>;
@@ -21,10 +21,13 @@ export const cursorPayloadSchema = z
21
21
  workspace_roots: z.array(z.string()).optional(),
22
22
  transcript_path: z.string().nullable().optional(),
23
23
  cwd: z.string().optional(),
24
+ // Null when no one is signed in. Unknown, like model_id: a type change must never drop the event.
25
+ user_email: z.unknown().optional(),
24
26
  // sessionStart / sessionEnd
25
27
  session_id: z.string().optional(),
26
- is_background_agent: z.boolean().optional(),
27
- composer_mode: z.string().optional(),
28
+ // Dropped, not refused, when malformed: the session mode is optional context.
29
+ is_background_agent: z.boolean().optional().catch(undefined),
30
+ composer_mode: z.string().optional().catch(undefined),
28
31
  reason: z.string().optional(),
29
32
  // beforeSubmitPrompt
30
33
  prompt: z.string().optional(),
@@ -50,7 +53,6 @@ export const cursorPayloadSchema = z
50
53
  subagent_id: z.string().optional(),
51
54
  subagent_type: z.string().optional(),
52
55
  subagent_model: z.string().optional(),
53
- parent_conversation_id: z.string().optional(),
54
56
  task: z.string().optional(),
55
57
  status: z.string().optional(),
56
58
  // afterAgentResponse
@@ -8,6 +8,22 @@ export declare const GEMINI_SETTINGS_FILE = "settings.json";
8
8
  /** Gemini's own env file: it loads this at start, unlike the settings.json `env` block. */
9
9
  export declare const GEMINI_ENV_FILE = ".env";
10
10
  export declare const GEMINI_EXECUTABLES: readonly ["gemini", "gemini-cli"];
11
+ /**
12
+ * Entries of the Gemini home that only Gemini CLI creates: its per-project
13
+ * session directory and its install id.
14
+ *
15
+ * The home directory alone proves nothing: Antigravity shares `~/.gemini` for
16
+ * its hooks.json, its CLI, its app data and the Google sign-in files
17
+ * (`oauth_creds.json`, `google_accounts.json`), so a machine with only
18
+ * Antigravity has one too. `settings.json` is judged separately, because
19
+ * AgentWatch setup writes one itself.
20
+ */
21
+ export declare const GEMINI_HOME_EVIDENCE: readonly ["tmp", "installation_id"];
22
+ /**
23
+ * settings.json keys AgentWatch writes, now or in earlier releases. A file that
24
+ * holds nothing else was created by our setup, not by Gemini CLI.
25
+ */
26
+ export declare const GEMINI_SETTINGS_KEYS_WE_WRITE: ReadonlySet<string>;
11
27
  /** Hook events AgentWatch registers in Gemini CLI. */
12
28
  export declare const GEMINI_HOOK_EVENTS: readonly ["SessionStart", "SessionEnd", "BeforeAgent", "AfterAgent", "BeforeTool", "AfterTool", "Notification", "PreCompress"];
13
29
  /** Events that take a matcher; "*" observes everything. */
@@ -1,3 +1,4 @@
1
+ import { ENV_BLOCK_KEY, LEGACY_HELPER_KEY, TELEMETRY_BLOCK_KEY } from './gemini.otel.constants.js';
1
2
  export const GEMINI_PROVIDER_ID = 'gemini';
2
3
  export const GEMINI_DISPLAY_NAME = 'Gemini CLI';
3
4
  export const GEMINI_HOME_VAR = 'GEMINI_HOME';
@@ -7,6 +8,22 @@ export const GEMINI_SETTINGS_FILE = 'settings.json';
7
8
  /** Gemini's own env file: it loads this at start, unlike the settings.json `env` block. */
8
9
  export const GEMINI_ENV_FILE = '.env';
9
10
  export const GEMINI_EXECUTABLES = ['gemini', 'gemini-cli'];
11
+ /**
12
+ * Entries of the Gemini home that only Gemini CLI creates: its per-project
13
+ * session directory and its install id.
14
+ *
15
+ * The home directory alone proves nothing: Antigravity shares `~/.gemini` for
16
+ * its hooks.json, its CLI, its app data and the Google sign-in files
17
+ * (`oauth_creds.json`, `google_accounts.json`), so a machine with only
18
+ * Antigravity has one too. `settings.json` is judged separately, because
19
+ * AgentWatch setup writes one itself.
20
+ */
21
+ export const GEMINI_HOME_EVIDENCE = ['tmp', 'installation_id'];
22
+ /**
23
+ * settings.json keys AgentWatch writes, now or in earlier releases. A file that
24
+ * holds nothing else was created by our setup, not by Gemini CLI.
25
+ */
26
+ export const GEMINI_SETTINGS_KEYS_WE_WRITE = new Set(['hooks', TELEMETRY_BLOCK_KEY, ENV_BLOCK_KEY, LEGACY_HELPER_KEY]);
10
27
  /** Hook events AgentWatch registers in Gemini CLI. */
11
28
  export const GEMINI_HOOK_EVENTS = ['SessionStart', 'SessionEnd', 'BeforeAgent', 'AfterAgent', 'BeforeTool', 'AfterTool', 'Notification', 'PreCompress'];
12
29
  /** Events that take a matcher; "*" observes everything. */
@@ -0,0 +1,81 @@
1
+ import type { RunCaptureStatus, SetupContext, SetupOutcome } from '../types/provider.types.js';
2
+ /**
3
+ * The `.env` text.
4
+ *
5
+ * @param filePath - The file.
6
+ * @returns Its contents, undefined when there is none, or null when it cannot
7
+ * be read (so it is never replaced by a file holding only our lines).
8
+ */
9
+ export declare function readEnvFile(filePath: string): Promise<string | undefined | null>;
10
+ /**
11
+ * The `KEY=value` lines of a dotenv file, the last one winning as in Gemini's
12
+ * loader. Quotes around a value and a trailing comment are dropped, as dotenv does: a
13
+ * comment kept here would be merged into `NODE_OPTIONS` as a real option.
14
+ *
15
+ * @param raw - File contents.
16
+ * @returns Values by key.
17
+ */
18
+ export declare function parseEnv(raw: string): Readonly<Record<string, string>>;
19
+ /**
20
+ * The `.env` text with `set` written and `drop` removed; every other line,
21
+ * comments included, stays as it was.
22
+ *
23
+ * @param raw - Current contents.
24
+ * @param set - Whole lines by key: replacing that key's line where it stands,
25
+ * appended otherwise.
26
+ * @param drop - Keys to remove.
27
+ * @returns The next contents; `raw` itself when nothing changes.
28
+ */
29
+ export declare function rewriteEnv(raw: string, set: Readonly<Record<string, string>>, drop: ReadonlySet<string>): string;
30
+ /**
31
+ * A `.env` Gemini would load from this folder in place of ours.
32
+ *
33
+ * Mirrors Gemini's lookup for a trusted folder: walking up, `<dir>/.gemini/.env`
34
+ * then `<dir>/.env`, the first found wins. (In an untrusted folder Gemini skips
35
+ * ours anyway.)
36
+ *
37
+ * @param cwd - The folder Gemini starts in.
38
+ * @param ours - Our `.env`.
39
+ * @returns The shadowing file, or undefined when ours is the one loaded.
40
+ */
41
+ export declare function shadowingEnvFile(cwd: string, ours: string): string | undefined;
42
+ /**
43
+ * Merge the two keys into `~/.gemini/.env`, as owned as a key can be without being
44
+ * recorded: only our part of each ever goes.
45
+ *
46
+ * Only the file's own value moves in, not the ambient one. Gemini's loader never
47
+ * overrides what the shell set (`inspectGeminiCapture` says when that hides ours), so
48
+ * copying the shell's value here would only spread it to shells that do not have it.
49
+ *
50
+ * @param context - Environment and paths.
51
+ * @param source - The package's shims.
52
+ * @returns Whether the file changed, and what to tell the developer.
53
+ */
54
+ export declare function applyGeminiCapture(context: SetupContext, source?: {
55
+ node: string;
56
+ python: string;
57
+ }): Promise<SetupOutcome>;
58
+ /**
59
+ * Take our part of the two keys out, then the shared copy once nothing else needs it.
60
+ *
61
+ * @param context - Environment and paths.
62
+ * @returns Whether the file changed, and what to tell the developer.
63
+ */
64
+ export declare function removeGeminiCapture(context: SetupContext): Promise<SetupOutcome>;
65
+ /**
66
+ * Whether what Gemini's shell tool starts loads the shims, and when not, why.
67
+ *
68
+ * Gemini's loader (`loadEnvironment`, read in 0.46.0's bundle) reads the first `.env`
69
+ * found walking up and never overrides a variable the shell set, so either can hide ours.
70
+ *
71
+ * ponytail: it also skips these keys in a folder the developer has not trusted. That is
72
+ * per folder and lives in Gemini's own trust file, so it is not read here.
73
+ *
74
+ * @param context - Environment, paths and config.
75
+ * @param source - The package's shims.
76
+ * @returns On, or off with the reason.
77
+ */
78
+ export declare function inspectGeminiCapture(context: SetupContext, source?: {
79
+ node: string;
80
+ python: string;
81
+ }): Promise<RunCaptureStatus>;