@getrift/rift 0.1.0-beta.21 → 0.1.0-beta.23

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 (320) hide show
  1. package/README.md +7 -3
  2. package/dist/src/capture/auto-capture.d.ts +105 -4
  3. package/dist/src/capture/auto-capture.d.ts.map +1 -1
  4. package/dist/src/capture/auto-capture.js +313 -34
  5. package/dist/src/capture/auto-capture.js.map +1 -1
  6. package/dist/src/capture/claude-cli-triage-provider.d.ts +28 -0
  7. package/dist/src/capture/claude-cli-triage-provider.d.ts.map +1 -0
  8. package/dist/src/capture/claude-cli-triage-provider.js +88 -0
  9. package/dist/src/capture/claude-cli-triage-provider.js.map +1 -0
  10. package/dist/src/capture/codex-cli-triage-provider.d.ts.map +1 -1
  11. package/dist/src/capture/codex-cli-triage-provider.js +1 -33
  12. package/dist/src/capture/codex-cli-triage-provider.js.map +1 -1
  13. package/dist/src/capture/cursor-capture.d.ts +89 -0
  14. package/dist/src/capture/cursor-capture.d.ts.map +1 -0
  15. package/dist/src/capture/cursor-capture.js +121 -0
  16. package/dist/src/capture/cursor-capture.js.map +1 -0
  17. package/dist/src/capture/observability.d.ts +30 -0
  18. package/dist/src/capture/observability.d.ts.map +1 -1
  19. package/dist/src/capture/observability.js +29 -0
  20. package/dist/src/capture/observability.js.map +1 -1
  21. package/dist/src/capture/recover-quarantine.d.ts +4 -4
  22. package/dist/src/capture/sources.d.ts +41 -3
  23. package/dist/src/capture/sources.d.ts.map +1 -1
  24. package/dist/src/capture/sources.js +43 -1
  25. package/dist/src/capture/sources.js.map +1 -1
  26. package/dist/src/capture/triage-classification.d.ts +69 -0
  27. package/dist/src/capture/triage-classification.d.ts.map +1 -0
  28. package/dist/src/capture/triage-classification.js +62 -0
  29. package/dist/src/capture/triage-classification.js.map +1 -0
  30. package/dist/src/capture/triage-provider-factory.d.ts +36 -0
  31. package/dist/src/capture/triage-provider-factory.d.ts.map +1 -0
  32. package/dist/src/capture/triage-provider-factory.js +55 -0
  33. package/dist/src/capture/triage-provider-factory.js.map +1 -0
  34. package/dist/src/capture/triage.d.ts +1 -1
  35. package/dist/src/capture/triage.d.ts.map +1 -1
  36. package/dist/src/capture/triage.js +8 -6
  37. package/dist/src/capture/triage.js.map +1 -1
  38. package/dist/src/cli/commands/capture.d.ts.map +1 -1
  39. package/dist/src/cli/commands/capture.js +79 -17
  40. package/dist/src/cli/commands/capture.js.map +1 -1
  41. package/dist/src/cli/commands/chunk-backfill.d.ts +13 -0
  42. package/dist/src/cli/commands/chunk-backfill.d.ts.map +1 -0
  43. package/dist/src/cli/commands/chunk-backfill.js +157 -0
  44. package/dist/src/cli/commands/chunk-backfill.js.map +1 -0
  45. package/dist/src/cli/commands/cursor-probe.d.ts +20 -0
  46. package/dist/src/cli/commands/cursor-probe.d.ts.map +1 -0
  47. package/dist/src/cli/commands/cursor-probe.js +162 -0
  48. package/dist/src/cli/commands/cursor-probe.js.map +1 -0
  49. package/dist/src/cli/commands/menubar.d.ts +3 -1
  50. package/dist/src/cli/commands/menubar.d.ts.map +1 -1
  51. package/dist/src/cli/commands/menubar.js +36 -12
  52. package/dist/src/cli/commands/menubar.js.map +1 -1
  53. package/dist/src/cli/commands/onboard.d.ts +22 -2
  54. package/dist/src/cli/commands/onboard.d.ts.map +1 -1
  55. package/dist/src/cli/commands/onboard.js +160 -32
  56. package/dist/src/cli/commands/onboard.js.map +1 -1
  57. package/dist/src/cli/commands/status.d.ts.map +1 -1
  58. package/dist/src/cli/commands/status.js +12 -0
  59. package/dist/src/cli/commands/status.js.map +1 -1
  60. package/dist/src/cli/commands/update.d.ts +34 -1
  61. package/dist/src/cli/commands/update.d.ts.map +1 -1
  62. package/dist/src/cli/commands/update.js +166 -1
  63. package/dist/src/cli/commands/update.js.map +1 -1
  64. package/dist/src/cli/index.d.ts.map +1 -1
  65. package/dist/src/cli/index.js +4 -0
  66. package/dist/src/cli/index.js.map +1 -1
  67. package/dist/src/cli/postinstall-menubar.d.ts +20 -13
  68. package/dist/src/cli/postinstall-menubar.d.ts.map +1 -1
  69. package/dist/src/cli/postinstall-menubar.js +56 -1
  70. package/dist/src/cli/postinstall-menubar.js.map +1 -1
  71. package/dist/src/cli/status/friend-header.d.ts +16 -3
  72. package/dist/src/cli/status/friend-header.d.ts.map +1 -1
  73. package/dist/src/cli/status/friend-header.js +186 -10
  74. package/dist/src/cli/status/friend-header.js.map +1 -1
  75. package/dist/src/cli/status/local-signals.d.ts +42 -4
  76. package/dist/src/cli/status/local-signals.d.ts.map +1 -1
  77. package/dist/src/cli/status/local-signals.js +52 -1
  78. package/dist/src/cli/status/local-signals.js.map +1 -1
  79. package/dist/src/config/schema.d.ts +220 -14
  80. package/dist/src/config/schema.d.ts.map +1 -1
  81. package/dist/src/config/schema.js +82 -7
  82. package/dist/src/config/schema.js.map +1 -1
  83. package/dist/src/diagnostics/claude-preflight.d.ts +35 -0
  84. package/dist/src/diagnostics/claude-preflight.d.ts.map +1 -0
  85. package/dist/src/diagnostics/claude-preflight.js +90 -0
  86. package/dist/src/diagnostics/claude-preflight.js.map +1 -0
  87. package/dist/src/diagnostics/codex-preflight.d.ts +1 -1
  88. package/dist/src/diagnostics/codex-preflight.d.ts.map +1 -1
  89. package/dist/src/diagnostics/codex-preflight.js +24 -0
  90. package/dist/src/diagnostics/codex-preflight.js.map +1 -1
  91. package/dist/src/diagnostics/doctor.d.ts +7 -4
  92. package/dist/src/diagnostics/doctor.d.ts.map +1 -1
  93. package/dist/src/diagnostics/doctor.js +70 -11
  94. package/dist/src/diagnostics/doctor.js.map +1 -1
  95. package/dist/src/diagnostics/memory-coverage.d.ts +54 -0
  96. package/dist/src/diagnostics/memory-coverage.d.ts.map +1 -0
  97. package/dist/src/diagnostics/memory-coverage.js +272 -0
  98. package/dist/src/diagnostics/memory-coverage.js.map +1 -0
  99. package/dist/src/diagnostics/notify.d.ts +20 -3
  100. package/dist/src/diagnostics/notify.d.ts.map +1 -1
  101. package/dist/src/diagnostics/notify.js +54 -14
  102. package/dist/src/diagnostics/notify.js.map +1 -1
  103. package/dist/src/ingestion/chunk-meta.d.ts +85 -0
  104. package/dist/src/ingestion/chunk-meta.d.ts.map +1 -0
  105. package/dist/src/ingestion/chunk-meta.js +167 -0
  106. package/dist/src/ingestion/chunk-meta.js.map +1 -0
  107. package/dist/src/ingestion/chunk-text.d.ts +39 -0
  108. package/dist/src/ingestion/chunk-text.d.ts.map +1 -0
  109. package/dist/src/ingestion/chunk-text.js +114 -0
  110. package/dist/src/ingestion/chunk-text.js.map +1 -0
  111. package/dist/src/ingestion/cursor/cursor-store.d.ts +177 -0
  112. package/dist/src/ingestion/cursor/cursor-store.d.ts.map +1 -0
  113. package/dist/src/ingestion/cursor/cursor-store.js +243 -0
  114. package/dist/src/ingestion/cursor/cursor-store.js.map +1 -0
  115. package/dist/src/ingestion/cursor/enrich-roots.d.ts +16 -0
  116. package/dist/src/ingestion/cursor/enrich-roots.d.ts.map +1 -0
  117. package/dist/src/ingestion/cursor/enrich-roots.js +22 -0
  118. package/dist/src/ingestion/cursor/enrich-roots.js.map +1 -0
  119. package/dist/src/ingestion/cursor/vscdb-reader.d.ts +32 -0
  120. package/dist/src/ingestion/cursor/vscdb-reader.d.ts.map +1 -0
  121. package/dist/src/ingestion/cursor/vscdb-reader.js +113 -0
  122. package/dist/src/ingestion/cursor/vscdb-reader.js.map +1 -0
  123. package/dist/src/ingestion/cursor/workspace-root.d.ts +96 -0
  124. package/dist/src/ingestion/cursor/workspace-root.d.ts.map +1 -0
  125. package/dist/src/ingestion/cursor/workspace-root.js +187 -0
  126. package/dist/src/ingestion/cursor/workspace-root.js.map +1 -0
  127. package/dist/src/ingestion/indexer.d.ts.map +1 -1
  128. package/dist/src/ingestion/indexer.js +41 -32
  129. package/dist/src/ingestion/indexer.js.map +1 -1
  130. package/dist/src/jobs/handlers/compact.d.ts.map +1 -1
  131. package/dist/src/jobs/handlers/compact.js +9 -4
  132. package/dist/src/jobs/handlers/compact.js.map +1 -1
  133. package/dist/src/jobs/handlers/ingest.d.ts.map +1 -1
  134. package/dist/src/jobs/handlers/ingest.js +60 -30
  135. package/dist/src/jobs/handlers/ingest.js.map +1 -1
  136. package/dist/src/jobs/handlers/reconcile.d.ts.map +1 -1
  137. package/dist/src/jobs/handlers/reconcile.js +128 -45
  138. package/dist/src/jobs/handlers/reconcile.js.map +1 -1
  139. package/dist/src/jobs/handlers/save.d.ts.map +1 -1
  140. package/dist/src/jobs/handlers/save.js +122 -72
  141. package/dist/src/jobs/handlers/save.js.map +1 -1
  142. package/dist/src/jobs/types.d.ts +1 -1
  143. package/dist/src/main.js +27 -16
  144. package/dist/src/main.js.map +1 -1
  145. package/dist/src/mcp/capture-diagnostics.d.ts +51 -0
  146. package/dist/src/mcp/capture-diagnostics.d.ts.map +1 -0
  147. package/dist/src/mcp/capture-diagnostics.js +127 -0
  148. package/dist/src/mcp/capture-diagnostics.js.map +1 -0
  149. package/dist/src/mcp/memory-diagnostics.d.ts +6 -0
  150. package/dist/src/mcp/memory-diagnostics.d.ts.map +1 -0
  151. package/dist/src/mcp/memory-diagnostics.js +51 -0
  152. package/dist/src/mcp/memory-diagnostics.js.map +1 -0
  153. package/dist/src/mcp/server.d.ts.map +1 -1
  154. package/dist/src/mcp/server.js +10 -3
  155. package/dist/src/mcp/server.js.map +1 -1
  156. package/dist/src/mcp/tools/context-pack.d.ts.map +1 -1
  157. package/dist/src/mcp/tools/context-pack.js +7 -1
  158. package/dist/src/mcp/tools/context-pack.js.map +1 -1
  159. package/dist/src/mcp/tools/conversations-search.d.ts +1 -1
  160. package/dist/src/mcp/tools/conversations-search.d.ts.map +1 -1
  161. package/dist/src/mcp/tools/conversations-search.js +7 -1
  162. package/dist/src/mcp/tools/conversations-search.js.map +1 -1
  163. package/dist/src/mcp/tools/evidence-feedback.d.ts +60 -0
  164. package/dist/src/mcp/tools/evidence-feedback.d.ts.map +1 -0
  165. package/dist/src/mcp/tools/evidence-feedback.js +62 -0
  166. package/dist/src/mcp/tools/evidence-feedback.js.map +1 -0
  167. package/dist/src/mcp/tools/log-outcome.d.ts +72 -0
  168. package/dist/src/mcp/tools/log-outcome.d.ts.map +1 -0
  169. package/dist/src/mcp/tools/log-outcome.js +59 -0
  170. package/dist/src/mcp/tools/log-outcome.js.map +1 -0
  171. package/dist/src/mcp/tools/open-evidence.d.ts +37 -0
  172. package/dist/src/mcp/tools/open-evidence.d.ts.map +1 -0
  173. package/dist/src/mcp/tools/open-evidence.js +72 -0
  174. package/dist/src/mcp/tools/open-evidence.js.map +1 -0
  175. package/dist/src/mcp/tools/save.d.ts +7 -2
  176. package/dist/src/mcp/tools/save.d.ts.map +1 -1
  177. package/dist/src/mcp/tools/save.js +7 -2
  178. package/dist/src/mcp/tools/save.js.map +1 -1
  179. package/dist/src/mcp/tools/search.d.ts.map +1 -1
  180. package/dist/src/mcp/tools/search.js +7 -1
  181. package/dist/src/mcp/tools/search.js.map +1 -1
  182. package/dist/src/mcp/tools/status.d.ts +15 -1
  183. package/dist/src/mcp/tools/status.d.ts.map +1 -1
  184. package/dist/src/mcp/tools/status.js +53 -2
  185. package/dist/src/mcp/tools/status.js.map +1 -1
  186. package/dist/src/observability/retrieval-feedback.d.ts +82 -0
  187. package/dist/src/observability/retrieval-feedback.d.ts.map +1 -0
  188. package/dist/src/observability/retrieval-feedback.js +231 -0
  189. package/dist/src/observability/retrieval-feedback.js.map +1 -0
  190. package/dist/src/observability/rift-context.d.ts.map +1 -1
  191. package/dist/src/observability/rift-context.js +3 -0
  192. package/dist/src/observability/rift-context.js.map +1 -1
  193. package/dist/src/observability/tool-usage-stats.d.ts +13 -0
  194. package/dist/src/observability/tool-usage-stats.d.ts.map +1 -1
  195. package/dist/src/observability/tool-usage-stats.js +15 -0
  196. package/dist/src/observability/tool-usage-stats.js.map +1 -1
  197. package/dist/src/observability/tool-usage.d.ts +56 -0
  198. package/dist/src/observability/tool-usage.d.ts.map +1 -1
  199. package/dist/src/observability/tool-usage.js +86 -0
  200. package/dist/src/observability/tool-usage.js.map +1 -1
  201. package/dist/src/providers/claude-cli-metadata-extraction.d.ts +47 -0
  202. package/dist/src/providers/claude-cli-metadata-extraction.d.ts.map +1 -0
  203. package/dist/src/providers/claude-cli-metadata-extraction.js +120 -0
  204. package/dist/src/providers/claude-cli-metadata-extraction.js.map +1 -0
  205. package/dist/src/providers/claude-cli-runner.d.ts +92 -0
  206. package/dist/src/providers/claude-cli-runner.d.ts.map +1 -0
  207. package/dist/src/providers/claude-cli-runner.js +598 -0
  208. package/dist/src/providers/claude-cli-runner.js.map +1 -0
  209. package/dist/src/providers/codex-cli-metadata-extraction.d.ts.map +1 -1
  210. package/dist/src/providers/codex-cli-metadata-extraction.js +1 -40
  211. package/dist/src/providers/codex-cli-metadata-extraction.js.map +1 -1
  212. package/dist/src/providers/codex-cli-runner.d.ts +7 -0
  213. package/dist/src/providers/codex-cli-runner.d.ts.map +1 -1
  214. package/dist/src/providers/codex-cli-runner.js +131 -5
  215. package/dist/src/providers/codex-cli-runner.js.map +1 -1
  216. package/dist/src/providers/conversation-generation.d.ts +10 -0
  217. package/dist/src/providers/conversation-generation.d.ts.map +1 -1
  218. package/dist/src/providers/conversation-generation.js +54 -13
  219. package/dist/src/providers/conversation-generation.js.map +1 -1
  220. package/dist/src/providers/openai-metadata-extraction.d.ts +48 -1
  221. package/dist/src/providers/openai-metadata-extraction.d.ts.map +1 -1
  222. package/dist/src/providers/openai-metadata-extraction.js +51 -2
  223. package/dist/src/providers/openai-metadata-extraction.js.map +1 -1
  224. package/dist/src/providers/types.d.ts +1 -1
  225. package/dist/src/providers/types.d.ts.map +1 -1
  226. package/dist/src/providers/types.js +4 -0
  227. package/dist/src/providers/types.js.map +1 -1
  228. package/dist/src/retrieval/canonical-files.d.ts +48 -0
  229. package/dist/src/retrieval/canonical-files.d.ts.map +1 -0
  230. package/dist/src/retrieval/canonical-files.js +210 -0
  231. package/dist/src/retrieval/canonical-files.js.map +1 -0
  232. package/dist/src/retrieval/compact.d.ts +95 -0
  233. package/dist/src/retrieval/compact.d.ts.map +1 -1
  234. package/dist/src/retrieval/compact.js +254 -8
  235. package/dist/src/retrieval/compact.js.map +1 -1
  236. package/dist/src/retrieval/context-pack.d.ts.map +1 -1
  237. package/dist/src/retrieval/context-pack.js +65 -15
  238. package/dist/src/retrieval/context-pack.js.map +1 -1
  239. package/dist/src/retrieval/conversation-dedup.d.ts +40 -0
  240. package/dist/src/retrieval/conversation-dedup.d.ts.map +1 -0
  241. package/dist/src/retrieval/conversation-dedup.js +141 -0
  242. package/dist/src/retrieval/conversation-dedup.js.map +1 -0
  243. package/dist/src/retrieval/evidence-key.d.ts +48 -0
  244. package/dist/src/retrieval/evidence-key.d.ts.map +1 -0
  245. package/dist/src/retrieval/evidence-key.js +131 -0
  246. package/dist/src/retrieval/evidence-key.js.map +1 -0
  247. package/dist/src/retrieval/feedback-ranking.d.ts +49 -0
  248. package/dist/src/retrieval/feedback-ranking.d.ts.map +1 -0
  249. package/dist/src/retrieval/feedback-ranking.js +138 -0
  250. package/dist/src/retrieval/feedback-ranking.js.map +1 -0
  251. package/dist/src/retrieval/git-state.d.ts +9 -0
  252. package/dist/src/retrieval/git-state.d.ts.map +1 -1
  253. package/dist/src/retrieval/git-state.js +18 -0
  254. package/dist/src/retrieval/git-state.js.map +1 -1
  255. package/dist/src/retrieval/group-by-parent.d.ts +38 -0
  256. package/dist/src/retrieval/group-by-parent.d.ts.map +1 -0
  257. package/dist/src/retrieval/group-by-parent.js +40 -0
  258. package/dist/src/retrieval/group-by-parent.js.map +1 -0
  259. package/dist/src/retrieval/lexical.d.ts.map +1 -1
  260. package/dist/src/retrieval/lexical.js +1 -3
  261. package/dist/src/retrieval/lexical.js.map +1 -1
  262. package/dist/src/retrieval/receipt.d.ts +57 -0
  263. package/dist/src/retrieval/receipt.d.ts.map +1 -0
  264. package/dist/src/retrieval/receipt.js +119 -0
  265. package/dist/src/retrieval/receipt.js.map +1 -0
  266. package/dist/src/retrieval/reranker.d.ts +49 -2
  267. package/dist/src/retrieval/reranker.d.ts.map +1 -1
  268. package/dist/src/retrieval/reranker.js +64 -4
  269. package/dist/src/retrieval/reranker.js.map +1 -1
  270. package/dist/src/retrieval/stitch-chunks.d.ts +73 -0
  271. package/dist/src/retrieval/stitch-chunks.d.ts.map +1 -0
  272. package/dist/src/retrieval/stitch-chunks.js +106 -0
  273. package/dist/src/retrieval/stitch-chunks.js.map +1 -0
  274. package/dist/src/server/app.d.ts +1 -1
  275. package/dist/src/server/app.d.ts.map +1 -1
  276. package/dist/src/server/app.js +20 -3
  277. package/dist/src/server/app.js.map +1 -1
  278. package/dist/src/server/routes/conversations-search.d.ts.map +1 -1
  279. package/dist/src/server/routes/conversations-search.js +22 -3
  280. package/dist/src/server/routes/conversations-search.js.map +1 -1
  281. package/dist/src/server/routes/friend-status.d.ts +64 -6
  282. package/dist/src/server/routes/friend-status.d.ts.map +1 -1
  283. package/dist/src/server/routes/friend-status.js +114 -18
  284. package/dist/src/server/routes/friend-status.js.map +1 -1
  285. package/dist/src/server/routes/mcp-usage.d.ts +9 -6
  286. package/dist/src/server/routes/mcp-usage.d.ts.map +1 -1
  287. package/dist/src/server/routes/mcp-usage.js.map +1 -1
  288. package/dist/src/server/routes/retrieval-feedback.d.ts +3 -0
  289. package/dist/src/server/routes/retrieval-feedback.d.ts.map +1 -0
  290. package/dist/src/server/routes/retrieval-feedback.js +290 -0
  291. package/dist/src/server/routes/retrieval-feedback.js.map +1 -0
  292. package/dist/src/server/routes/save.d.ts +3 -3
  293. package/dist/src/server/routes/save.d.ts.map +1 -1
  294. package/dist/src/server/routes/save.js +6 -2
  295. package/dist/src/server/routes/save.js.map +1 -1
  296. package/dist/src/server/routes/search.d.ts +1 -1
  297. package/dist/src/server/routes/search.d.ts.map +1 -1
  298. package/dist/src/server/routes/search.js +55 -8
  299. package/dist/src/server/routes/search.js.map +1 -1
  300. package/dist/src/server/serving-marker.d.ts +85 -0
  301. package/dist/src/server/serving-marker.d.ts.map +1 -0
  302. package/dist/src/server/serving-marker.js +226 -0
  303. package/dist/src/server/serving-marker.js.map +1 -0
  304. package/dist/src/storage/chunk-backfill.d.ts +39 -0
  305. package/dist/src/storage/chunk-backfill.d.ts.map +1 -0
  306. package/dist/src/storage/chunk-backfill.js +295 -0
  307. package/dist/src/storage/chunk-backfill.js.map +1 -0
  308. package/dist/src/storage/filter.d.ts +42 -0
  309. package/dist/src/storage/filter.d.ts.map +1 -0
  310. package/dist/src/storage/filter.js +70 -0
  311. package/dist/src/storage/filter.js.map +1 -0
  312. package/dist/src/storage/rebuild.d.ts.map +1 -1
  313. package/dist/src/storage/rebuild.js +44 -27
  314. package/dist/src/storage/rebuild.js.map +1 -1
  315. package/dist/src/storage/tables.d.ts +41 -0
  316. package/dist/src/storage/tables.d.ts.map +1 -1
  317. package/dist/src/storage/tables.js +64 -1
  318. package/dist/src/storage/tables.js.map +1 -1
  319. package/operator/swiftbar/render-menu.py +60 -18
  320. package/package.json +6 -4
@@ -0,0 +1,598 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { spawn } from "node:child_process";
5
+ /**
6
+ * Claude Code (`claude`) CLI runner — the structured-JSON sibling of
7
+ * codex-cli-runner.ts. It shells out to `claude -p` (headless/print mode) and
8
+ * returns a schema-validated object, so a Claude Code user can back triage
9
+ * without installing or authenticating Codex.
10
+ *
11
+ * Why the `claude` CLI and not the Anthropic API: same trust model as Codex —
12
+ * the run inherits the operator's own logged-in subscription, so Rift holds NO
13
+ * API key and content egress is on the user's own account.
14
+ *
15
+ * Isolation choices (parallel to Codex's clean CODEX_HOME), all verified
16
+ * against the installed `claude --help` contract:
17
+ * - `--safe-mode`: disables the user's CLAUDE.md, hooks, plugins, skills, MCP
18
+ * servers, custom agents — so captured content is classified by a CLEAN
19
+ * Claude, never one steered by the operator's personal config (which would
20
+ * pollute the decision and waste tokens). Crucially, auth/model/built-in
21
+ * tools still work normally, so it preserves the no-API-key subscription
22
+ * trust model — unlike `--bare`, which forces ANTHROPIC_API_KEY.
23
+ * - `--no-session-persistence`: the captured conversation is NOT written to
24
+ * `~/.claude` session history. Without it, triage would duplicate every
25
+ * captured conversation onto disk and risk re-capturing its own triage
26
+ * sessions (a feedback loop). Only valid with `--print`, which we use.
27
+ * - `--strict-mcp-config` with no `--mcp-config`: belt-and-suspenders with
28
+ * safe-mode — load ZERO MCP servers, so a triage subprocess never connects
29
+ * to (or sends content to) the user's MCP servers, nor pays their startup
30
+ * cost. (Loading them was observed to stall the process for tens of seconds.)
31
+ * - `--tools ""`: disable ALL built-in tools (the CLI's own "none" sentinel).
32
+ * A classification needs none; this keeps the run deterministic and is
33
+ * robust to tool renames — unlike a deny-list, which `claude` rejects when a
34
+ * listed name is not a known tool.
35
+ * - `--json-schema <inline JSON>`: the CLI validates structured output and
36
+ * re-prompts internally on mismatch. The schema is passed INLINE (the CLI's
37
+ * documented form; a file path is parsed as a literal schema and hangs).
38
+ * - prompt piped via STDIN (not argv): handles large conversations without
39
+ * hitting ARG_MAX, and avoids `claude -p`'s 3s "no stdin data" stall.
40
+ */
41
+ let claudeVersionPromise = null;
42
+ let testFallbackDirs;
43
+ // Dirs searched in ADDITION to $PATH when resolving `claude`. The scheduled
44
+ // daemon runs under launchd with a minimal PATH (`/usr/bin:/bin:/usr/sbin:/sbin`)
45
+ // that contains neither Homebrew nor the official installer's `~/.local/bin`, so
46
+ // without these fallbacks the daemon could find no `claude` (or only an older
47
+ // Homebrew one). `~/.local/bin` is listed FIRST because the official installer
48
+ // puts the current build there — ahead of a possibly-stale `/opt/homebrew/bin`.
49
+ const CLAUDE_EXECUTABLE_FALLBACK_DIRS = [
50
+ path.join(os.homedir(), ".local", "bin"),
51
+ path.join(os.homedir(), ".claude", "local"),
52
+ path.join(os.homedir(), "bin"),
53
+ "/opt/homebrew/bin",
54
+ "/usr/local/bin",
55
+ ];
56
+ /**
57
+ * Default model for triage classification. A cheap, fast model is the right
58
+ * default for a background classifier that runs over every captured session;
59
+ * we pin it explicitly rather than inherit the user's interactive default
60
+ * (which could be Opus — slow and costly per session). An alias (not a dated
61
+ * id) so it tracks the current Haiku without code changes. Overridable per run.
62
+ */
63
+ export const DEFAULT_CLAUDE_TRIAGE_MODEL = "haiku";
64
+ /**
65
+ * Thrown ONLY when the runner's own timeout timer fires and kills the `claude`
66
+ * process. A signal termination we did NOT initiate is reported separately so
67
+ * it is never treated as a (retryable) timeout. Mirrors CodexCliTimeoutError.
68
+ */
69
+ export class ClaudeCliTimeoutError extends Error {
70
+ timeoutMs;
71
+ signal;
72
+ constructor(timeoutMs, signal, detail = "") {
73
+ const signalPart = signal ? ` by ${signal}` : "";
74
+ super(`Claude CLI timed out after ${timeoutMs}ms (process terminated${signalPart})${detail}`);
75
+ this.name = "ClaudeCliTimeoutError";
76
+ this.timeoutMs = timeoutMs;
77
+ this.signal = signal;
78
+ }
79
+ }
80
+ /** One bounded retry on timeout/termination — see runClaudeCliJson. */
81
+ const CLAUDE_TIMEOUT_RETRY_LIMIT = 1;
82
+ const CLAUDE_TIMEOUT_RETRY_BACKOFF_MS = 500;
83
+ function delay(ms) {
84
+ return new Promise((resolve) => setTimeout(resolve, ms));
85
+ }
86
+ export async function runClaudeCliJson(options) {
87
+ const timeoutMs = options.timeoutMs ?? 120_000;
88
+ const cwd = options.cwd ?? process.cwd();
89
+ const model = options.model ?? DEFAULT_CLAUDE_TRIAGE_MODEL;
90
+ // Resolve — and capability-probe — a COMPATIBLE headless `claude` BEFORE any
91
+ // captured content is sent. This throws an actionable, leak-free error when no
92
+ // candidate can run our headless contract (too-old CLI missing `--safe-mode`,
93
+ // a PATH wrapper/PTY shim that can't pipe stdin, missing install). The probe
94
+ // uses only an innocuous fixed prompt, never conversation content.
95
+ const executable = await resolveCompatibleClaudeExecutable(cwd, model);
96
+ // One bounded retry, ONLY for timeout/termination — same rationale as the
97
+ // Codex runner: a SIGTERM'd headless call is overwhelmingly a transient cold
98
+ // start, and a single retry recovers it inside the same run. Auth/binary/
99
+ // malformed failures are NOT transient and are surfaced unretried.
100
+ let lastTimeout = null;
101
+ for (let attempt = 0; attempt <= CLAUDE_TIMEOUT_RETRY_LIMIT; attempt++) {
102
+ try {
103
+ const { stdout } = await runClaudeCommand(executable, [
104
+ "-p",
105
+ "--output-format",
106
+ "json",
107
+ // Schema is passed INLINE (the CLI's documented form); a file path is
108
+ // parsed as a literal schema string and stalls.
109
+ "--json-schema",
110
+ JSON.stringify(options.schema),
111
+ // Clean run: no personal config (CLAUDE.md/hooks/plugins/MCP), no
112
+ // session persistence of captured content. Auth/model still work.
113
+ "--safe-mode",
114
+ "--no-session-persistence",
115
+ "--strict-mcp-config",
116
+ "--model",
117
+ model,
118
+ // `--tools` is variadic — kept LAST so its single "" (the CLI's
119
+ // "disable all tools" sentinel) is the only value it consumes.
120
+ "--tools",
121
+ "",
122
+ ], { cwd, timeoutMs, stdinText: options.prompt });
123
+ const output = parseClaudeJsonEnvelope(stdout);
124
+ return { output, model, cliTag: await resolveClaudeCliTag(executable, cwd) };
125
+ }
126
+ catch (error) {
127
+ if (error instanceof ClaudeCliTimeoutError &&
128
+ attempt < CLAUDE_TIMEOUT_RETRY_LIMIT) {
129
+ lastTimeout = error;
130
+ await delay(CLAUDE_TIMEOUT_RETRY_BACKOFF_MS);
131
+ continue;
132
+ }
133
+ throw error;
134
+ }
135
+ }
136
+ // Unreachable: the loop either returns or throws on the final attempt.
137
+ throw lastTimeout ?? new Error("Claude CLI failed after retries");
138
+ }
139
+ /**
140
+ * Extract the schema-validated object from the `--output-format json` envelope.
141
+ *
142
+ * Defensive on purpose (I could not verify the exact envelope live from inside
143
+ * a nested Claude Code session): prefer `structured_output` (populated by
144
+ * `--json-schema`), and fall back to parsing the `result` text as JSON for any
145
+ * version that surfaces the object only there. Errors NEVER include model
146
+ * output or the prompt — only structural facts — so conversation content is
147
+ * never written to logs or error strings.
148
+ */
149
+ export function parseClaudeJsonEnvelope(stdout) {
150
+ const raw = stdout.trim();
151
+ if (raw.length === 0) {
152
+ throw new Error("Claude CLI returned empty output");
153
+ }
154
+ let envelope;
155
+ try {
156
+ envelope = JSON.parse(raw);
157
+ }
158
+ catch (error) {
159
+ throw new Error("Claude CLI returned a malformed JSON envelope", {
160
+ cause: error,
161
+ });
162
+ }
163
+ if (envelope.is_error === true) {
164
+ throw new Error(`Claude CLI reported an error (subtype: ${envelope.subtype ?? "unknown"})`);
165
+ }
166
+ if (envelope.subtype === "error_max_structured_output_retries") {
167
+ throw new Error("Claude CLI could not produce schema-valid output after retries");
168
+ }
169
+ if (envelope.structured_output != null) {
170
+ return envelope.structured_output;
171
+ }
172
+ // Fallback: object lives in the `result` text. Strip markdown fences and
173
+ // slice to the outermost object, mirroring the OpenAI provider's parser.
174
+ if (typeof envelope.result === "string") {
175
+ return parseJsonObjectFromText(envelope.result);
176
+ }
177
+ if (envelope.result != null && typeof envelope.result === "object") {
178
+ return envelope.result;
179
+ }
180
+ throw new Error("Claude CLI envelope had no structured_output or result");
181
+ }
182
+ function parseJsonObjectFromText(text) {
183
+ let cleaned = text
184
+ .replace(/^```json\s*/i, "")
185
+ .replace(/^```\s*/i, "")
186
+ .replace(/\s*```$/i, "")
187
+ .trim();
188
+ const start = cleaned.indexOf("{");
189
+ const end = cleaned.lastIndexOf("}");
190
+ if (start === -1 || end === -1) {
191
+ throw new Error("Claude CLI result contained no JSON object");
192
+ }
193
+ cleaned = cleaned.slice(start, end + 1);
194
+ try {
195
+ return JSON.parse(cleaned);
196
+ }
197
+ catch (error) {
198
+ throw new Error("Claude CLI result was not valid JSON", { cause: error });
199
+ }
200
+ }
201
+ /**
202
+ * Headless flags `runClaudeCliJson` depends on. A candidate `claude` whose
203
+ * `--help` does not advertise EVERY one of these is rejected structurally — for
204
+ * free, before any conversation content is sent. `--safe-mode` is the load-
205
+ * bearing discriminator: it was added in a later Claude Code build, so an older
206
+ * CLI (which lacks it; `--bare` is NOT an acceptable substitute because it forces
207
+ * ANTHROPIC_API_KEY, breaking the subscription trust model) is filtered here.
208
+ */
209
+ const REQUIRED_CLAUDE_FLAGS = [
210
+ "--safe-mode",
211
+ "--no-session-persistence",
212
+ "--output-format",
213
+ "--json-schema",
214
+ "--tools",
215
+ "--print",
216
+ ];
217
+ /**
218
+ * Innocuous probe payload — NEVER conversation content. Used by the behavioral
219
+ * probe to confirm a candidate can actually complete a headless `-p` run with
220
+ * piped stdin (the only reliable way to reject a wrapper/PTY shim that forwards
221
+ * `--help` faithfully but cannot pipe stdin to a real `-p` invocation).
222
+ */
223
+ const CLAUDE_PROBE_SCHEMA = {
224
+ type: "object",
225
+ additionalProperties: false,
226
+ required: ["ok"],
227
+ properties: { ok: { type: "boolean" } },
228
+ };
229
+ const CLAUDE_PROBE_PROMPT = 'Return the JSON {"ok": true} and nothing else.';
230
+ /**
231
+ * Cached SUCCESSFUL resolution — the path of a binary that passed both probe
232
+ * stages. We cache ONLY success, never failure: a probe can fail for transient
233
+ * reasons (not signed in yet, network blip, rate/usage limit, an overloaded
234
+ * model), and caching that would freeze the daemon at "Claude is broken" until
235
+ * restart, long after the user logged in or the network recovered. A successful
236
+ * binary, by contrast, stays valid for the process, so re-probing it per triage
237
+ * is pure waste. On failure we throw fresh each call and re-probe next time —
238
+ * structural rejects (e.g. missing `--safe-mode`) are cheap (no model call), and
239
+ * the only model-costing re-probe is a compatible-but-transiently-failing
240
+ * binary, which is exactly the case we WANT to retry.
241
+ */
242
+ let resolvedCompatibleClaude;
243
+ /** Test seam: replace the spawn-based per-candidate probe so selection +
244
+ * rejection-aggregation logic can be unit-tested without spawning `claude`.
245
+ * Returns null when the candidate is acceptable, else a leak-free reason. */
246
+ let claudeProbeOverride;
247
+ export function setClaudeProbeForTests(fn) {
248
+ claudeProbeOverride = fn;
249
+ resolvedCompatibleClaude = undefined;
250
+ }
251
+ /**
252
+ * Ordered, de-duplicated list of `claude` candidates to probe. An explicit
253
+ * `RIFT_CLAUDE_CLI_PATH` override is the SOLE candidate (an operator who names a
254
+ * binary expects that one used, or a clear error — never a silent fallback).
255
+ * Otherwise: every `$PATH` entry in order, then the install-location fallbacks.
256
+ * De-duped by realpath so the same binary reached via several PATH entries is
257
+ * probed once — but a wrapper and the real binary have different realpaths, so
258
+ * both are kept and the wrapper can be skipped in favour of the real one.
259
+ */
260
+ export function listClaudeCandidatePaths(pathEnv = process.env["PATH"], override = process.env["RIFT_CLAUDE_CLI_PATH"], fallbackDirs = testFallbackDirs ??
261
+ CLAUDE_EXECUTABLE_FALLBACK_DIRS) {
262
+ if (override && override.trim()) {
263
+ return [override.trim()];
264
+ }
265
+ const dirs = [
266
+ ...(pathEnv ? pathEnv.split(path.delimiter) : []),
267
+ ...fallbackDirs,
268
+ ];
269
+ const seenReal = new Set();
270
+ const out = [];
271
+ for (const dir of dirs) {
272
+ if (!dir)
273
+ continue;
274
+ const candidate = path.join(dir, "claude");
275
+ if (!fs.existsSync(candidate))
276
+ continue;
277
+ let real;
278
+ try {
279
+ real = fs.realpathSync(candidate);
280
+ }
281
+ catch {
282
+ real = candidate;
283
+ }
284
+ if (seenReal.has(real))
285
+ continue;
286
+ seenReal.add(real);
287
+ // Keep the stable entry, not the version-stamped realpath, so an upgrade
288
+ // that rotates the target is not pinned into a long-running daemon.
289
+ out.push(candidate);
290
+ }
291
+ return out;
292
+ }
293
+ /**
294
+ * Probe one candidate. Two stages, cheapest first:
295
+ * 1. Structural: `<bin> --help` must advertise every REQUIRED_CLAUDE_FLAG. No
296
+ * model call; filters too-old CLIs and bounds a hang via timeout.
297
+ * 2. Behavioral: run a headless `-p` classification on the innocuous probe
298
+ * prompt and require a parseable envelope. This is the only check that
299
+ * rejects a wrapper which passes (1) but cannot pipe stdin to `-p` — and it
300
+ * fails such a wrapper instantly, before any model call.
301
+ * Returns null when acceptable, else a leak-free rejection reason.
302
+ */
303
+ async function probeClaudeCandidate(bin, cwd, model) {
304
+ if (claudeProbeOverride)
305
+ return claudeProbeOverride(bin, cwd, model);
306
+ let help;
307
+ try {
308
+ ({ stdout: help } = await runClaudeCommand(bin, ["--help"], {
309
+ cwd,
310
+ timeoutMs: 15_000,
311
+ }));
312
+ }
313
+ catch (error) {
314
+ if (error instanceof ClaudeCliTimeoutError) {
315
+ return "did not respond to `--help` within 15s (unresponsive CLI or wrapper)";
316
+ }
317
+ return "could not run `--help` (not executable, or not the Claude CLI)";
318
+ }
319
+ const missing = REQUIRED_CLAUDE_FLAGS.filter((flag) => !help.includes(flag));
320
+ if (missing.length > 0) {
321
+ return `Claude CLI too old/incompatible — missing required flag(s): ${missing.join(", ")} (need a build with --safe-mode)`;
322
+ }
323
+ try {
324
+ const { stdout } = await runClaudeCommand(bin, [
325
+ "-p",
326
+ "--output-format",
327
+ "json",
328
+ "--json-schema",
329
+ JSON.stringify(CLAUDE_PROBE_SCHEMA),
330
+ "--safe-mode",
331
+ "--no-session-persistence",
332
+ "--strict-mcp-config",
333
+ "--model",
334
+ model,
335
+ "--tools",
336
+ "",
337
+ ], { cwd, timeoutMs: 60_000, stdinText: CLAUDE_PROBE_PROMPT });
338
+ parseClaudeJsonEnvelope(stdout);
339
+ return null;
340
+ }
341
+ catch (error) {
342
+ if (error instanceof ClaudeCliTimeoutError) {
343
+ return "timed out running a headless probe classification";
344
+ }
345
+ // runClaudeCommand errors are already leak-free (canned classification), so
346
+ // including the message cannot leak content; it carries the auth/network
347
+ // bucket when recognized, making the aggregate error actionable.
348
+ const detail = error instanceof Error ? error.message : String(error);
349
+ // When the underlying error already classified into a specific bucket
350
+ // (auth/network/rate/contract/wrapper), surface that reason AS-IS. Appending
351
+ // the generic "wrapper/PTY shim … or auth" hedge would otherwise let the
352
+ // preflight classifier — which matches `wrapper` before `auth` — misbucket a
353
+ // real auth failure as a wrapper and tell a logged-out user to set
354
+ // RIFT_CLAUDE_CLI_PATH instead of signing in. Only a genuinely unrecognized
355
+ // failure (a bare exit code, no classified summary) keeps the wrapper/auth
356
+ // hedge, where a wrapper is the honest best guess.
357
+ const recognized = /authentication failed|not (logged|signed) in|\bunauthorized\b|\b401\b|flag\/contract error|--safe-mode|wrapper\/pty shim|could not run headless|rate limited|usage limit|network error/.test(detail.toLowerCase());
358
+ if (recognized) {
359
+ return `could not complete a headless \`-p\` classification (${detail})`;
360
+ }
361
+ return `could not complete a headless \`-p\` classification (${detail}) — likely a wrapper/PTY shim that cannot pipe stdin, or auth is not set up`;
362
+ }
363
+ }
364
+ function buildNoCompatibleClaudeMessage(rejections) {
365
+ const lines = rejections.map((r) => ` • ${r.path}: ${r.reason}`).join("\n");
366
+ return ("No compatible Claude Code CLI found for headless triage. Each candidate was " +
367
+ "checked BEFORE any conversation content was sent:\n" +
368
+ lines +
369
+ "\nFix: upgrade Claude Code to a build that supports `--safe-mode`, set " +
370
+ "RIFT_CLAUDE_CLI_PATH to a compatible `claude`, or use the Codex worker " +
371
+ "(capture.triage.provider = codex_cli; enrichment.metadata.provider = codex_cli).");
372
+ }
373
+ /**
374
+ * Resolve a `claude` that can actually run our headless contract, caching only a
375
+ * SUCCESSFUL result (see `resolvedCompatibleClaude`). Throws an actionable,
376
+ * leak-free error when none can — without caching it, so a transient failure is
377
+ * retried on the next call. The winning binary is probed once per process; a
378
+ * failing resolution re-probes (cheaply, unless a compatible binary is the one
379
+ * transiently failing — which we deliberately retry).
380
+ */
381
+ async function resolveCompatibleClaudeExecutable(cwd, model) {
382
+ if (resolvedCompatibleClaude)
383
+ return resolvedCompatibleClaude;
384
+ const candidates = listClaudeCandidatePaths();
385
+ if (candidates.length === 0) {
386
+ throw new Error("Claude Code CLI (`claude`) was not found on PATH or in the usual install " +
387
+ "locations (~/.local/bin, /opt/homebrew/bin, …). Install it " +
388
+ "(https://claude.com/claude-code) and sign in once, set RIFT_CLAUDE_CLI_PATH " +
389
+ "to its path, or set capture.triage.provider = codex_cli.");
390
+ }
391
+ const rejections = [];
392
+ for (const candidate of candidates) {
393
+ const reason = await probeClaudeCandidate(candidate, cwd, model);
394
+ if (reason === null) {
395
+ resolvedCompatibleClaude = candidate;
396
+ return candidate;
397
+ }
398
+ rejections.push({ path: candidate, reason });
399
+ }
400
+ // NOT cached: every rejection here may be transient (auth/network/rate limit),
401
+ // so the next call re-probes and recovers without a daemon restart.
402
+ throw new Error(buildNoCompatibleClaudeMessage(rejections));
403
+ }
404
+ /**
405
+ * Cheap synchronous "is a `claude` CLI installed anywhere we'd look?" probe —
406
+ * the SAME candidate search the resolver uses, so it honors `RIFT_CLAUDE_CLI_PATH`
407
+ * and the broadened fallback dirs (`~/.local/bin`, …). Detects install only, NOT
408
+ * compatibility or auth: an old or wrapped `claude` passes here, and the real
409
+ * compatibility check (and the actionable error) happens in
410
+ * `resolveCompatibleClaudeExecutable` at call time. Used only as the coarse
411
+ * metadata-selection gate; a false positive degrades safely to Basic metadata.
412
+ *
413
+ * Using the resolver's candidate list (not a separate resolver) is what keeps
414
+ * the "one `RIFT_CLAUDE_CLI_PATH` override unblocks BOTH triage and metadata"
415
+ * promise true: an override that lets triage resolve must also let the metadata
416
+ * gate report available, instead of silently falling back to Basic.
417
+ */
418
+ export function isClaudeCliAvailable() {
419
+ return listClaudeCandidatePaths().length > 0;
420
+ }
421
+ export function resetClaudeCliRunnerCacheForTests() {
422
+ claudeVersionPromise = null;
423
+ testFallbackDirs = undefined;
424
+ resolvedCompatibleClaude = undefined;
425
+ }
426
+ /**
427
+ * Test seam: override the executable fallback dirs so a test can simulate
428
+ * "claude not installed" even on a dev machine that has it in /opt/homebrew/bin.
429
+ * Clears the resolution cache.
430
+ */
431
+ export function setClaudeFallbackDirsForTests(dirs) {
432
+ testFallbackDirs = dirs;
433
+ resolvedCompatibleClaude = undefined;
434
+ }
435
+ async function resolveClaudeCliTag(executable, cwd) {
436
+ if (claudeVersionPromise === null) {
437
+ claudeVersionPromise = runClaudeCommand(executable, ["--version"], {
438
+ cwd,
439
+ timeoutMs: 15_000,
440
+ })
441
+ .then(({ stdout }) => stdout.trim() || "claude-cli")
442
+ .catch(() => "claude-cli");
443
+ }
444
+ return claudeVersionPromise;
445
+ }
446
+ async function runClaudeCommand(executable, args, options) {
447
+ return new Promise((resolve, reject) => {
448
+ let stdinError = null;
449
+ let stdout = "";
450
+ let stderr = "";
451
+ // We own the timeout so a timeout-kill is distinguishable from any OTHER
452
+ // signal termination — only the timeout path is retryable upstream.
453
+ let timedOut = false;
454
+ let child;
455
+ try {
456
+ child = spawn(executable, args, {
457
+ cwd: options.cwd,
458
+ stdio: ["pipe", "pipe", "pipe"],
459
+ env: claudeCliEnv(),
460
+ });
461
+ }
462
+ catch (error) {
463
+ reject(new Error(`Claude CLI failed to spawn: ${error instanceof Error ? error.message : String(error)}`));
464
+ return;
465
+ }
466
+ const timer = setTimeout(() => {
467
+ timedOut = true;
468
+ child.kill("SIGTERM");
469
+ }, options.timeoutMs);
470
+ timer.unref?.();
471
+ child.on("error", (error) => {
472
+ clearTimeout(timer);
473
+ reject(new Error(`Claude CLI failed to start: ${error.message}`));
474
+ });
475
+ child.stdout?.setEncoding("utf-8");
476
+ child.stdout?.on("data", (chunk) => {
477
+ stdout += chunk;
478
+ });
479
+ child.stderr?.setEncoding("utf-8");
480
+ child.stderr?.on("data", (chunk) => {
481
+ stderr += chunk;
482
+ });
483
+ if (child.stdin) {
484
+ child.stdin.on("error", (error) => {
485
+ stdinError = error;
486
+ });
487
+ // Pipe the prompt as stdin and close it immediately so `claude -p` does
488
+ // not stall waiting for more input.
489
+ child.stdin.end(options.stdinText ?? "");
490
+ }
491
+ child.on("close", (code, signal) => {
492
+ clearTimeout(timer);
493
+ // Classify stderr into a SAFE, canned token — NEVER the raw bytes. The
494
+ // captured conversation is delivered via stdin (never echoed back) and
495
+ // the model output is the stdout JSON envelope (which we never surface),
496
+ // but stderr is third-party CLI output we don't control: a future
497
+ // `claude` could write prompt text, result text, a debug dump, or an API
498
+ // error body there. So we refuse to pass it through verbatim — a
499
+ // recognized failure mode yields a fixed phrase (carrying keywords the
500
+ // doctor/friend-status classifier recognizes), an unrecognized one yields
501
+ // only the exit code. This enforces the "no captured content/model output
502
+ // in errors" guarantee structurally instead of by assumption.
503
+ const summary = classifyClaudeStderr(stderr);
504
+ const detail = summary ? ` — ${summary}` : "";
505
+ if (code === null) {
506
+ if (timedOut) {
507
+ reject(new ClaudeCliTimeoutError(options.timeoutMs, signal, detail));
508
+ return;
509
+ }
510
+ reject(new Error(`Claude CLI was terminated by ${signal ?? "an unknown signal"} (not a timeout)${detail}`));
511
+ return;
512
+ }
513
+ if (code !== 0) {
514
+ reject(new Error(`Claude CLI failed (exit ${code})${detail}`));
515
+ return;
516
+ }
517
+ if (stdinError && !isIgnorableStdinError(stdinError)) {
518
+ reject(new Error(`Claude CLI stdin failed: ${stdinError.message}`));
519
+ return;
520
+ }
521
+ resolve({ stdout, stderr });
522
+ });
523
+ });
524
+ }
525
+ function isIgnorableStdinError(error) {
526
+ return ("code" in error &&
527
+ (error.code === "EPIPE" ||
528
+ error.code === "ECONNRESET" ||
529
+ error.code === "ERR_STREAM_DESTROYED"));
530
+ }
531
+ /**
532
+ * Map `claude` stderr to a SAFE, canned diagnostic token — never the raw text.
533
+ * The locked guarantee is that runner errors carry NO captured conversation or
534
+ * model output. Captured content travels via stdin (never echoed) and the
535
+ * model's output is the stdout JSON envelope (never surfaced); stderr is the
536
+ * only third-party stream we don't fully control, so we classify it into a
537
+ * fixed phrase and return ONLY that. A recognized failure mode never leaks the
538
+ * surrounding bytes; an unrecognized one returns "" (the caller surfaces just
539
+ * the exit code/signal). The phrases carry keywords `classifyCodexPreflightError`
540
+ * recognizes (auth/network) so the persisted error still buckets correctly.
541
+ * Mirrors codex-preflight's "deliberately canned" leak-free summaries.
542
+ */
543
+ export function classifyClaudeStderr(stderr) {
544
+ const text = stderr.toLowerCase();
545
+ // CLI-contract / version mismatch — an unknown/invalid flag means the resolved
546
+ // `claude` predates a flag we depend on (e.g. --safe-mode) or isn't the Claude
547
+ // CLI at all. Checked first: it is unambiguous and must not be misread as auth.
548
+ if (/unknown option|unknown argument|unknown command|invalid option|unrecognized option|--safe-mode|option .* not found/.test(text)) {
549
+ return "Claude CLI flag/contract error — CLI too old or incompatible (upgrade Claude Code or set RIFT_CLAUDE_CLI_PATH)";
550
+ }
551
+ // Headless / PTY-wrapper failure — a wrapper or shim intercepting `claude`
552
+ // cannot pipe stdin to a real `-p` run, so it complains about missing input or
553
+ // demands a terminal. Distinct from auth/network so doctor copy can point at
554
+ // the wrapper, not credentials.
555
+ if (/input must be provided|when using --print|requires? a (tty|terminal|interactive|raw mode)|not a tty|raw mode is not supported|\/dev\/tty|stdin is not/.test(text)) {
556
+ return "Claude CLI could not run headless — a PATH wrapper/PTY shim may be intercepting `claude` (set RIFT_CLAUDE_CLI_PATH to the real binary, or use codex_cli)";
557
+ }
558
+ if (/not authenticated|not (logged|signed) in|invalid api key|\bunauthorized\b|\b401\b|please (run|sign|log).{0,12}(login|in)|authentication failed|credentials? (expired|invalid)/.test(text)) {
559
+ return "authentication failed (run `claude` and sign in)";
560
+ }
561
+ if (/rate limit|\b429\b|too many requests/.test(text)) {
562
+ return "rate limited";
563
+ }
564
+ if (/usage limit|\bquota\b|out of credits|insufficient (credit|quota|balance)/.test(text)) {
565
+ return "usage limit reached";
566
+ }
567
+ if (/econnrefused|econnreset|enotfound|etimedout|getaddrinfo|socket hang up|connection (refused|reset)|failed to (connect|reach)|\bnetwork\b|http 5\d\d/.test(text)) {
568
+ return "network error";
569
+ }
570
+ return "";
571
+ }
572
+ /** Env vars that route `claude` to API-key auth instead of the subscription. */
573
+ const CLAUDE_API_KEY_ENV_VARS = [
574
+ "ANTHROPIC_API_KEY",
575
+ "ANTHROPIC_AUTH_TOKEN",
576
+ ];
577
+ /**
578
+ * Build the child env for the `claude` subprocess. We strip the API-key auth
579
+ * vars so triage ALWAYS runs on the operator's logged-in Claude Code
580
+ * subscription — never silently billing an ambient API key. This is what makes
581
+ * the "Rift holds no API key / runs on your own subscription" trust model true
582
+ * in practice rather than by assumption: a user who exported ANTHROPIC_API_KEY
583
+ * for some other tool would otherwise have every captured session billed to
584
+ * that key. The common subscription user (OAuth in `~/.claude`, no such var
585
+ * set) is unaffected — this is a no-op for them. A user whose ONLY claude auth
586
+ * is an API key gets the honest "authenticate claude or set
587
+ * capture.triage.provider = codex_cli" failure instead of surprise API spend.
588
+ * `--safe-mode` keeps auth/model/built-in tools working normally, so the
589
+ * subscription path is untouched.
590
+ */
591
+ function claudeCliEnv() {
592
+ const env = { ...process.env };
593
+ for (const key of CLAUDE_API_KEY_ENV_VARS) {
594
+ delete env[key];
595
+ }
596
+ return env;
597
+ }
598
+ //# sourceMappingURL=claude-cli-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-cli-runner.js","sourceRoot":"","sources":["../../../src/providers/claude-cli-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,IAAI,oBAAoB,GAA2B,IAAI,CAAC;AACxD,IAAI,gBAA+C,CAAC;AAEpD,4EAA4E;AAC5E,kFAAkF;AAClF,iFAAiF;AACjF,8EAA8E;AAC9E,+EAA+E;AAC/E,gFAAgF;AAChF,MAAM,+BAA+B,GAAG;IACtC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC;IACxC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC;IAC3C,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC;IAC9B,mBAAmB;IACnB,gBAAgB;CACR,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,OAAO,CAAC;AAmBnD;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACrC,SAAS,CAAS;IAClB,MAAM,CA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,CAAC;IACD,IACE,+KAA+K,CAAC,IAAI,CAClL,IAAI,CACL,EACD,CAAC;QACD,OAAO,kDAAkD,CAAC;IAC5D,CAAC;IACD,IAAI,sCAAsC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACtD,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,IACE,0EAA0E,CAAC,IAAI,CAC7E,IAAI,CACL,EACD,CAAC;QACD,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IACD,IACE,oJAAoJ,CAAC,IAAI,CACvJ,IAAI,CACL,EACD,CAAC;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,gFAAgF;AAChF,MAAM,uBAAuB,GAAG;IAC9B,mBAAmB;IACnB,sBAAsB;CACd,CAAC;AAEX;;;;;;;;;;;;;GAaG;AACH,SAAS,YAAY;IACnB,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC/B,KAAK,MAAM,GAAG,IAAI,uBAAuB,EAAE,CAAC;QAC1C,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"codex-cli-metadata-extraction.d.ts","sourceRoot":"","sources":["../../../src/providers/codex-cli-metadata-extraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,4BAA4B,EAC7B,MAAM,YAAY,CAAC;AAoDpB,qBAAa,yBAA0B,YAAW,iBAAiB;IAM/D,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,SAAS,CAAqB;gBAGnB,OAAO,GAAE;QACxB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;KACzB;IAKF,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmDlE,aAAa,IAAI,4BAA4B;CAU9C"}
1
+ {"version":3,"file":"codex-cli-metadata-extraction.d.ts","sourceRoot":"","sources":["../../../src/providers/codex-cli-metadata-extraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,4BAA4B,EAC7B,MAAM,YAAY,CAAC;AAapB,qBAAa,yBAA0B,YAAW,iBAAiB;IAM/D,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,SAAS,CAAqB;gBAGnB,OAAO,GAAE;QACxB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;KACzB;IAKF,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmDlE,aAAa,IAAI,4BAA4B;CAU9C"}