@raidiant/notifai 11.7.1 → 12.0.0-beta.5

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 (409) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/NOTICE +16 -0
  3. package/THIRD_PARTY_NOTICES +725 -0
  4. package/bin/notifai.mjs +11387 -0
  5. package/data/install.ps1 +318 -0
  6. package/data/release.json +1 -0
  7. package/inventory.json +1 -0
  8. package/npm-adapter-files.json +52 -0
  9. package/package.json +14 -44
  10. package/README.md +0 -168
  11. package/dist/agent-update-notice.d.ts +0 -7
  12. package/dist/agent-update-notice.js +0 -77
  13. package/dist/agent-update-notice.js.map +0 -1
  14. package/dist/atomic-file.d.ts +0 -30
  15. package/dist/atomic-file.js +0 -148
  16. package/dist/atomic-file.js.map +0 -1
  17. package/dist/attendant-update.d.ts +0 -15
  18. package/dist/attendant-update.js +0 -96
  19. package/dist/attendant-update.js.map +0 -1
  20. package/dist/claude-wake.d.ts +0 -108
  21. package/dist/claude-wake.js +0 -369
  22. package/dist/claude-wake.js.map +0 -1
  23. package/dist/cli-bin.d.ts +0 -26
  24. package/dist/cli-bin.js +0 -220
  25. package/dist/cli-bin.js.map +0 -1
  26. package/dist/cli-contract.d.ts +0 -16
  27. package/dist/cli-contract.js +0 -27
  28. package/dist/cli-contract.js.map +0 -1
  29. package/dist/cli-release.d.ts +0 -36
  30. package/dist/cli-release.js +0 -85
  31. package/dist/cli-release.js.map +0 -1
  32. package/dist/client.d.ts +0 -109
  33. package/dist/client.js +0 -217
  34. package/dist/client.js.map +0 -1
  35. package/dist/codex-answer-control.d.ts +0 -14
  36. package/dist/codex-answer-control.js +0 -41
  37. package/dist/codex-answer-control.js.map +0 -1
  38. package/dist/codex-answer-presentation.d.ts +0 -18
  39. package/dist/codex-answer-presentation.js +0 -113
  40. package/dist/codex-answer-presentation.js.map +0 -1
  41. package/dist/codex-input-lifecycle.d.ts +0 -10
  42. package/dist/codex-input-lifecycle.js +0 -63
  43. package/dist/codex-input-lifecycle.js.map +0 -1
  44. package/dist/codex-native-control.d.ts +0 -13
  45. package/dist/codex-native-control.js +0 -120
  46. package/dist/codex-native-control.js.map +0 -1
  47. package/dist/codex-native-turn.d.ts +0 -37
  48. package/dist/codex-native-turn.js +0 -155
  49. package/dist/codex-native-turn.js.map +0 -1
  50. package/dist/codex-question-bindings.d.ts +0 -76
  51. package/dist/codex-question-bindings.js +0 -151
  52. package/dist/codex-question-bindings.js.map +0 -1
  53. package/dist/codex-queue-control.d.ts +0 -21
  54. package/dist/codex-queue-control.js +0 -59
  55. package/dist/codex-queue-control.js.map +0 -1
  56. package/dist/codex-tool-messages.d.ts +0 -7
  57. package/dist/codex-tool-messages.js +0 -126
  58. package/dist/codex-tool-messages.js.map +0 -1
  59. package/dist/codex-wake.d.ts +0 -58
  60. package/dist/codex-wake.js +0 -135
  61. package/dist/codex-wake.js.map +0 -1
  62. package/dist/command-session.d.ts +0 -14
  63. package/dist/command-session.js +0 -31
  64. package/dist/command-session.js.map +0 -1
  65. package/dist/commands-acknowledge.d.ts +0 -13
  66. package/dist/commands-acknowledge.js +0 -116
  67. package/dist/commands-acknowledge.js.map +0 -1
  68. package/dist/commands-agent-sessions.d.ts +0 -6
  69. package/dist/commands-agent-sessions.js +0 -51
  70. package/dist/commands-agent-sessions.js.map +0 -1
  71. package/dist/commands-ask.d.ts +0 -62
  72. package/dist/commands-ask.js +0 -503
  73. package/dist/commands-ask.js.map +0 -1
  74. package/dist/commands-auth.d.ts +0 -76
  75. package/dist/commands-auth.js +0 -421
  76. package/dist/commands-auth.js.map +0 -1
  77. package/dist/commands-close.d.ts +0 -6
  78. package/dist/commands-close.js +0 -273
  79. package/dist/commands-close.js.map +0 -1
  80. package/dist/commands-config.d.ts +0 -31
  81. package/dist/commands-config.js +0 -272
  82. package/dist/commands-config.js.map +0 -1
  83. package/dist/commands-core.d.ts +0 -145
  84. package/dist/commands-core.js +0 -190
  85. package/dist/commands-core.js.map +0 -1
  86. package/dist/commands-devices.d.ts +0 -41
  87. package/dist/commands-devices.js +0 -144
  88. package/dist/commands-devices.js.map +0 -1
  89. package/dist/commands-doctor.d.ts +0 -25
  90. package/dist/commands-doctor.js +0 -1553
  91. package/dist/commands-doctor.js.map +0 -1
  92. package/dist/commands-guidance.d.ts +0 -27
  93. package/dist/commands-guidance.js +0 -150
  94. package/dist/commands-guidance.js.map +0 -1
  95. package/dist/commands-harness-context.d.ts +0 -57
  96. package/dist/commands-harness-context.js +0 -102
  97. package/dist/commands-harness-context.js.map +0 -1
  98. package/dist/commands-hook-attend.d.ts +0 -70
  99. package/dist/commands-hook-attend.js +0 -655
  100. package/dist/commands-hook-attend.js.map +0 -1
  101. package/dist/commands-hook-diagnostics.d.ts +0 -37
  102. package/dist/commands-hook-diagnostics.js +0 -136
  103. package/dist/commands-hook-diagnostics.js.map +0 -1
  104. package/dist/commands-hook-install.d.ts +0 -26
  105. package/dist/commands-hook-install.js +0 -784
  106. package/dist/commands-hook-install.js.map +0 -1
  107. package/dist/commands-hook-run.d.ts +0 -29
  108. package/dist/commands-hook-run.js +0 -933
  109. package/dist/commands-hook-run.js.map +0 -1
  110. package/dist/commands-hook-shape.d.ts +0 -19
  111. package/dist/commands-hook-shape.js +0 -48
  112. package/dist/commands-hook-shape.js.map +0 -1
  113. package/dist/commands-init.d.ts +0 -42
  114. package/dist/commands-init.js +0 -901
  115. package/dist/commands-init.js.map +0 -1
  116. package/dist/commands-io.d.ts +0 -2
  117. package/dist/commands-io.js +0 -117
  118. package/dist/commands-io.js.map +0 -1
  119. package/dist/commands-logs.d.ts +0 -30
  120. package/dist/commands-logs.js +0 -201
  121. package/dist/commands-logs.js.map +0 -1
  122. package/dist/commands-native-acknowledge.d.ts +0 -8
  123. package/dist/commands-native-acknowledge.js +0 -114
  124. package/dist/commands-native-acknowledge.js.map +0 -1
  125. package/dist/commands-project.d.ts +0 -4
  126. package/dist/commands-project.js +0 -41
  127. package/dist/commands-project.js.map +0 -1
  128. package/dist/commands-receive.d.ts +0 -3
  129. package/dist/commands-receive.js +0 -59
  130. package/dist/commands-receive.js.map +0 -1
  131. package/dist/commands-send-support.d.ts +0 -59
  132. package/dist/commands-send-support.js +0 -258
  133. package/dist/commands-send-support.js.map +0 -1
  134. package/dist/commands-send.d.ts +0 -34
  135. package/dist/commands-send.js +0 -900
  136. package/dist/commands-send.js.map +0 -1
  137. package/dist/commands-setup-proof.d.ts +0 -43
  138. package/dist/commands-setup-proof.js +0 -134
  139. package/dist/commands-setup-proof.js.map +0 -1
  140. package/dist/commands-skill.d.ts +0 -21
  141. package/dist/commands-skill.js +0 -199
  142. package/dist/commands-skill.js.map +0 -1
  143. package/dist/commands-sounds.d.ts +0 -12
  144. package/dist/commands-sounds.js +0 -35
  145. package/dist/commands-sounds.js.map +0 -1
  146. package/dist/commands-update-check.d.ts +0 -6
  147. package/dist/commands-update-check.js +0 -102
  148. package/dist/commands-update-check.js.map +0 -1
  149. package/dist/commands-update-resume.d.ts +0 -7
  150. package/dist/commands-update-resume.js +0 -143
  151. package/dist/commands-update-resume.js.map +0 -1
  152. package/dist/commands-update-skill.d.ts +0 -5
  153. package/dist/commands-update-skill.js +0 -36
  154. package/dist/commands-update-skill.js.map +0 -1
  155. package/dist/commands-update.d.ts +0 -11
  156. package/dist/commands-update.js +0 -286
  157. package/dist/commands-update.js.map +0 -1
  158. package/dist/commands.d.ts +0 -26
  159. package/dist/commands.js +0 -27
  160. package/dist/commands.js.map +0 -1
  161. package/dist/config-schema.d.ts +0 -62
  162. package/dist/config-schema.js +0 -302
  163. package/dist/config-schema.js.map +0 -1
  164. package/dist/config.d.ts +0 -181
  165. package/dist/config.js +0 -357
  166. package/dist/config.js.map +0 -1
  167. package/dist/credentials.d.ts +0 -96
  168. package/dist/credentials.js +0 -342
  169. package/dist/credentials.js.map +0 -1
  170. package/dist/file-lock.d.ts +0 -34
  171. package/dist/file-lock.js +0 -367
  172. package/dist/file-lock.js.map +0 -1
  173. package/dist/generated-session-label.d.ts +0 -2
  174. package/dist/generated-session-label.js +0 -152
  175. package/dist/generated-session-label.js.map +0 -1
  176. package/dist/guidance-content.d.ts +0 -53
  177. package/dist/guidance-content.js +0 -248
  178. package/dist/guidance-content.js.map +0 -1
  179. package/dist/guidance-render.d.ts +0 -25
  180. package/dist/guidance-render.js +0 -47
  181. package/dist/guidance-render.js.map +0 -1
  182. package/dist/guidance.d.ts +0 -69
  183. package/dist/guidance.js +0 -173
  184. package/dist/guidance.js.map +0 -1
  185. package/dist/harness-session-title.d.ts +0 -22
  186. package/dist/harness-session-title.js +0 -74
  187. package/dist/harness-session-title.js.map +0 -1
  188. package/dist/harnesses.d.ts +0 -65
  189. package/dist/harnesses.js +0 -159
  190. package/dist/harnesses.js.map +0 -1
  191. package/dist/hermes-attendant.d.ts +0 -38
  192. package/dist/hermes-attendant.js +0 -337
  193. package/dist/hermes-attendant.js.map +0 -1
  194. package/dist/hermes-plugin.d.ts +0 -11
  195. package/dist/hermes-plugin.js +0 -299
  196. package/dist/hermes-plugin.js.map +0 -1
  197. package/dist/hook-acknowledgements.d.ts +0 -70
  198. package/dist/hook-acknowledgements.js +0 -490
  199. package/dist/hook-acknowledgements.js.map +0 -1
  200. package/dist/hook-adapter.d.ts +0 -48
  201. package/dist/hook-adapter.js +0 -419
  202. package/dist/hook-adapter.js.map +0 -1
  203. package/dist/hook-events.d.ts +0 -105
  204. package/dist/hook-events.js +0 -130
  205. package/dist/hook-events.js.map +0 -1
  206. package/dist/hook-gates.d.ts +0 -7
  207. package/dist/hook-gates.js +0 -20
  208. package/dist/hook-gates.js.map +0 -1
  209. package/dist/hook-input.d.ts +0 -10
  210. package/dist/hook-input.js +0 -64
  211. package/dist/hook-input.js.map +0 -1
  212. package/dist/hook-lifecycle.d.ts +0 -112
  213. package/dist/hook-lifecycle.js +0 -2031
  214. package/dist/hook-lifecycle.js.map +0 -1
  215. package/dist/hook-project-sessions.d.ts +0 -28
  216. package/dist/hook-project-sessions.js +0 -141
  217. package/dist/hook-project-sessions.js.map +0 -1
  218. package/dist/hook-question-lock.d.ts +0 -29
  219. package/dist/hook-question-lock.js +0 -217
  220. package/dist/hook-question-lock.js.map +0 -1
  221. package/dist/hook-question-retirement.d.ts +0 -74
  222. package/dist/hook-question-retirement.js +0 -314
  223. package/dist/hook-question-retirement.js.map +0 -1
  224. package/dist/hook-question-state.d.ts +0 -58
  225. package/dist/hook-question-state.js +0 -239
  226. package/dist/hook-question-state.js.map +0 -1
  227. package/dist/hook-session-state.d.ts +0 -127
  228. package/dist/hook-session-state.js +0 -488
  229. package/dist/hook-session-state.js.map +0 -1
  230. package/dist/hook-types.d.ts +0 -476
  231. package/dist/hook-types.js +0 -4
  232. package/dist/hook-types.js.map +0 -1
  233. package/dist/injection-render.d.ts +0 -36
  234. package/dist/injection-render.js +0 -61
  235. package/dist/injection-render.js.map +0 -1
  236. package/dist/install-hooks.d.ts +0 -470
  237. package/dist/install-hooks.js +0 -1622
  238. package/dist/install-hooks.js.map +0 -1
  239. package/dist/integration-health.d.ts +0 -26
  240. package/dist/integration-health.js +0 -133
  241. package/dist/integration-health.js.map +0 -1
  242. package/dist/interactive.d.ts +0 -22
  243. package/dist/interactive.js +0 -644
  244. package/dist/interactive.js.map +0 -1
  245. package/dist/invocation-context.d.ts +0 -47
  246. package/dist/invocation-context.js +0 -164
  247. package/dist/invocation-context.js.map +0 -1
  248. package/dist/local-path.d.ts +0 -7
  249. package/dist/local-path.js +0 -27
  250. package/dist/local-path.js.map +0 -1
  251. package/dist/logging.d.ts +0 -157
  252. package/dist/logging.js +0 -599
  253. package/dist/logging.js.map +0 -1
  254. package/dist/main-run.d.ts +0 -1
  255. package/dist/main-run.js +0 -42
  256. package/dist/main-run.js.map +0 -1
  257. package/dist/main.d.ts +0 -2
  258. package/dist/main.js +0 -12
  259. package/dist/main.js.map +0 -1
  260. package/dist/native-answer-operation.d.ts +0 -70
  261. package/dist/native-answer-operation.js +0 -247
  262. package/dist/native-answer-operation.js.map +0 -1
  263. package/dist/native-skills.d.ts +0 -64
  264. package/dist/native-skills.js +0 -167
  265. package/dist/native-skills.js.map +0 -1
  266. package/dist/node-floor.d.ts +0 -19
  267. package/dist/node-floor.js +0 -32
  268. package/dist/node-floor.js.map +0 -1
  269. package/dist/npm-invocation.d.ts +0 -34
  270. package/dist/npm-invocation.js +0 -53
  271. package/dist/npm-invocation.js.map +0 -1
  272. package/dist/openclaw-continuation-bridge.d.ts +0 -7
  273. package/dist/openclaw-continuation-bridge.js +0 -64
  274. package/dist/openclaw-continuation-bridge.js.map +0 -1
  275. package/dist/openclaw-gateway-readiness.d.ts +0 -1
  276. package/dist/openclaw-gateway-readiness.js +0 -24
  277. package/dist/openclaw-gateway-readiness.js.map +0 -1
  278. package/dist/openclaw-generation.d.ts +0 -21
  279. package/dist/openclaw-generation.js +0 -115
  280. package/dist/openclaw-generation.js.map +0 -1
  281. package/dist/openclaw-message-bridge.d.ts +0 -8
  282. package/dist/openclaw-message-bridge.js +0 -93
  283. package/dist/openclaw-message-bridge.js.map +0 -1
  284. package/dist/openclaw-pending.d.ts +0 -8
  285. package/dist/openclaw-pending.js +0 -47
  286. package/dist/openclaw-pending.js.map +0 -1
  287. package/dist/openclaw-plugin.d.ts +0 -75
  288. package/dist/openclaw-plugin.js +0 -1353
  289. package/dist/openclaw-plugin.js.map +0 -1
  290. package/dist/openclaw-session-access.d.ts +0 -12
  291. package/dist/openclaw-session-access.js +0 -79
  292. package/dist/openclaw-session-access.js.map +0 -1
  293. package/dist/opencode-plugin.d.ts +0 -88
  294. package/dist/opencode-plugin.js +0 -286
  295. package/dist/opencode-plugin.js.map +0 -1
  296. package/dist/orca-session-title.d.ts +0 -11
  297. package/dist/orca-session-title.js +0 -111
  298. package/dist/orca-session-title.js.map +0 -1
  299. package/dist/pack-feedback-slice.d.ts +0 -35
  300. package/dist/pack-feedback-slice.js +0 -126
  301. package/dist/pack-feedback-slice.js.map +0 -1
  302. package/dist/pairing-qr.d.ts +0 -5
  303. package/dist/pairing-qr.js +0 -24
  304. package/dist/pairing-qr.js.map +0 -1
  305. package/dist/pending-pairing.d.ts +0 -38
  306. package/dist/pending-pairing.js +0 -70
  307. package/dist/pending-pairing.js.map +0 -1
  308. package/dist/platform.d.ts +0 -67
  309. package/dist/platform.js +0 -140
  310. package/dist/platform.js.map +0 -1
  311. package/dist/process-identity.d.ts +0 -26
  312. package/dist/process-identity.js +0 -82
  313. package/dist/process-identity.js.map +0 -1
  314. package/dist/program.d.ts +0 -59
  315. package/dist/program.js +0 -691
  316. package/dist/program.js.map +0 -1
  317. package/dist/project-enablement.d.ts +0 -21
  318. package/dist/project-enablement.js +0 -71
  319. package/dist/project-enablement.js.map +0 -1
  320. package/dist/question-settlement-process.d.ts +0 -17
  321. package/dist/question-settlement-process.js +0 -35
  322. package/dist/question-settlement-process.js.map +0 -1
  323. package/dist/question-timing.d.ts +0 -46
  324. package/dist/question-timing.js +0 -48
  325. package/dist/question-timing.js.map +0 -1
  326. package/dist/readiness.d.ts +0 -153
  327. package/dist/readiness.js +0 -149
  328. package/dist/readiness.js.map +0 -1
  329. package/dist/release.d.ts +0 -31
  330. package/dist/release.js +0 -52
  331. package/dist/release.js.map +0 -1
  332. package/dist/send-attempts.d.ts +0 -26
  333. package/dist/send-attempts.js +0 -139
  334. package/dist/send-attempts.js.map +0 -1
  335. package/dist/send.d.ts +0 -115
  336. package/dist/send.js +0 -421
  337. package/dist/send.js.map +0 -1
  338. package/dist/session-activation.d.ts +0 -13
  339. package/dist/session-activation.js +0 -64
  340. package/dist/session-activation.js.map +0 -1
  341. package/dist/session-attendant-probe.d.ts +0 -85
  342. package/dist/session-attendant-probe.js +0 -173
  343. package/dist/session-attendant-probe.js.map +0 -1
  344. package/dist/session-attendant-state.d.ts +0 -70
  345. package/dist/session-attendant-state.js +0 -256
  346. package/dist/session-attendant-state.js.map +0 -1
  347. package/dist/session-attendant.d.ts +0 -143
  348. package/dist/session-attendant.js +0 -520
  349. package/dist/session-attendant.js.map +0 -1
  350. package/dist/session-delivery.d.ts +0 -249
  351. package/dist/session-delivery.js +0 -576
  352. package/dist/session-delivery.js.map +0 -1
  353. package/dist/session-handoff.d.ts +0 -98
  354. package/dist/session-handoff.js +0 -118
  355. package/dist/session-handoff.js.map +0 -1
  356. package/dist/session-input-wakes.d.ts +0 -78
  357. package/dist/session-input-wakes.js +0 -239
  358. package/dist/session-input-wakes.js.map +0 -1
  359. package/dist/session-inputs.d.ts +0 -57
  360. package/dist/session-inputs.js +0 -434
  361. package/dist/session-inputs.js.map +0 -1
  362. package/dist/session-labels.d.ts +0 -56
  363. package/dist/session-labels.js +0 -396
  364. package/dist/session-labels.js.map +0 -1
  365. package/dist/session-message-handoff.d.ts +0 -39
  366. package/dist/session-message-handoff.js +0 -107
  367. package/dist/session-message-handoff.js.map +0 -1
  368. package/dist/setup-destinations.d.ts +0 -23
  369. package/dist/setup-destinations.js +0 -44
  370. package/dist/setup-destinations.js.map +0 -1
  371. package/dist/skill-integrity.d.ts +0 -54
  372. package/dist/skill-integrity.js +0 -164
  373. package/dist/skill-integrity.js.map +0 -1
  374. package/dist/skill-source/manifest.json +0 -40
  375. package/dist/skill-source/notifai/SKILL.md +0 -350
  376. package/dist/skill-source/notifai/references/diagnostics.md +0 -36
  377. package/dist/skill-source/notifai/references/harness-setup.md +0 -384
  378. package/dist/skill-source/notifai/references/native-questions.md +0 -51
  379. package/dist/skill-source/notifai/references/notes-and-edits.md +0 -54
  380. package/dist/skill-source/notifai/references/send-details.md +0 -14
  381. package/dist/skill-source/notifai/references/updates.md +0 -116
  382. package/dist/skill-source/notifai/references/writing-examples.md +0 -56
  383. package/dist/sound-ref.d.ts +0 -23
  384. package/dist/sound-ref.js +0 -28
  385. package/dist/sound-ref.js.map +0 -1
  386. package/dist/ui/banner.d.ts +0 -22
  387. package/dist/ui/banner.js +0 -87
  388. package/dist/ui/banner.js.map +0 -1
  389. package/dist/ui/config-view.d.ts +0 -30
  390. package/dist/ui/config-view.js +0 -108
  391. package/dist/ui/config-view.js.map +0 -1
  392. package/dist/ui/help.d.ts +0 -44
  393. package/dist/ui/help.js +0 -107
  394. package/dist/ui/help.js.map +0 -1
  395. package/dist/ui/theme.d.ts +0 -90
  396. package/dist/ui/theme.js +0 -244
  397. package/dist/ui/theme.js.map +0 -1
  398. package/dist/update-handoff.d.ts +0 -29
  399. package/dist/update-handoff.js +0 -69
  400. package/dist/update-handoff.js.map +0 -1
  401. package/dist/url-policy.d.ts +0 -85
  402. package/dist/url-policy.js +0 -369
  403. package/dist/url-policy.js.map +0 -1
  404. package/dist/version.d.ts +0 -40
  405. package/dist/version.js +0 -132
  406. package/dist/version.js.map +0 -1
  407. package/dist/wake-support.d.ts +0 -40
  408. package/dist/wake-support.js +0 -95
  409. package/dist/wake-support.js.map +0 -1
@@ -1,35 +0,0 @@
1
- import { type LogQuery, type LogRecord } from './logging.js';
2
- export declare const FEEDBACK_SLICE_UNCOMPRESSED_CAP: number;
3
- export declare const FEEDBACK_SLICE_COMPRESSED_CAP: number;
4
- export declare const FEEDBACK_SLICE_DEFAULT_WINDOW_MS: number;
5
- export interface PackFeedbackSliceOptions extends LogQuery {
6
- /** Epoch ms. Defaults to now. Tests freeze the window with this. */
7
- now?: number;
8
- }
9
- export interface PackedFeedbackSlice {
10
- records: LogRecord[];
11
- jsonl: string;
12
- gzip?: Buffer;
13
- uncompressed_bytes: number;
14
- compressed_bytes: number;
15
- record_count: number;
16
- truncated: boolean;
17
- since: number;
18
- until: number;
19
- schema_version: number;
20
- consentSummary: string;
21
- }
22
- export interface FeedbackSliceWire {
23
- encoding: 'gzip+base64';
24
- bytes: string;
25
- uncompressed_bytes: number;
26
- compressed_bytes: number;
27
- record_count: number;
28
- truncated: boolean;
29
- since: string;
30
- until: string;
31
- schema_version: number;
32
- }
33
- /** Wire form. Empty slices have nothing to encode. */
34
- export declare function encodeFeedbackSlice(slice: PackedFeedbackSlice): FeedbackSliceWire | undefined;
35
- export declare function packFeedbackSlice(env?: NodeJS.ProcessEnv, options?: PackFeedbackSliceOptions): PackedFeedbackSlice;
@@ -1,126 +0,0 @@
1
- /**
2
- * Consented, bounded slice of the local log for a later feedback send.
3
- *
4
- * This module packs. It does not upload. A caller that wants a report on
5
- * the wire asks here for the bytes and the consent copy, then decides
6
- * whether to send them.
7
- */
8
- import { gzipSync } from 'node:zlib';
9
- import { LOG_SCHEMA_VERSION, readLogRecords, } from './logging.js';
10
- export const FEEDBACK_SLICE_UNCOMPRESSED_CAP = 256 * 1024;
11
- export const FEEDBACK_SLICE_COMPRESSED_CAP = 128 * 1024;
12
- export const FEEDBACK_SLICE_DEFAULT_WINDOW_MS = 24 * 60 * 60 * 1000;
13
- /** High enough that on-disk rotation, not this number, bounds a full-window read. */
14
- const FULL_WINDOW_READ_LIMIT = 1_000_000;
15
- /** Wire form. Empty slices have nothing to encode. */
16
- export function encodeFeedbackSlice(slice) {
17
- if (slice.gzip === undefined)
18
- return undefined;
19
- return {
20
- encoding: 'gzip+base64',
21
- bytes: slice.gzip.toString('base64'),
22
- uncompressed_bytes: slice.uncompressed_bytes,
23
- compressed_bytes: slice.compressed_bytes,
24
- record_count: slice.record_count,
25
- truncated: slice.truncated,
26
- since: new Date(slice.since).toISOString(),
27
- until: new Date(slice.until).toISOString(),
28
- schema_version: slice.schema_version,
29
- };
30
- }
31
- export function packFeedbackSlice(env = process.env, options = {}) {
32
- const { now, since: sinceOption, limit, ...filters } = options;
33
- const until = now ?? Date.now();
34
- const since = sinceOption ?? until - FEEDBACK_SLICE_DEFAULT_WINDOW_MS;
35
- const { records } = readLogRecords(env, {
36
- ...filters,
37
- since,
38
- limit: limit ?? FULL_WINDOW_READ_LIMIT,
39
- });
40
- if (records.length === 0) {
41
- return emptySlice(since, until);
42
- }
43
- const packed = fitToCaps(records);
44
- if (packed === null) {
45
- return emptySlice(since, until);
46
- }
47
- return {
48
- records: packed.records,
49
- jsonl: packed.jsonl,
50
- gzip: packed.gzip,
51
- uncompressed_bytes: packed.uncompressedBytes,
52
- compressed_bytes: packed.gzip.length,
53
- record_count: packed.records.length,
54
- truncated: packed.truncated,
55
- since,
56
- until,
57
- schema_version: LOG_SCHEMA_VERSION,
58
- consentSummary: consentSummary({
59
- since,
60
- until,
61
- recordCount: packed.records.length,
62
- uncompressedBytes: packed.uncompressedBytes,
63
- compressedBytes: packed.gzip.length,
64
- }),
65
- };
66
- }
67
- function fitToCaps(records) {
68
- const lines = records.map((record) => JSON.stringify(record));
69
- let start = 0;
70
- let truncated = false;
71
- while (start < lines.length) {
72
- const jsonl = toJsonl(lines.slice(start));
73
- const uncompressedBytes = Buffer.byteLength(jsonl);
74
- if (uncompressedBytes > FEEDBACK_SLICE_UNCOMPRESSED_CAP) {
75
- start += 1;
76
- truncated = true;
77
- continue;
78
- }
79
- const gzip = gzipSync(jsonl);
80
- if (gzip.length <= FEEDBACK_SLICE_COMPRESSED_CAP) {
81
- return {
82
- records: records.slice(start),
83
- jsonl,
84
- gzip,
85
- uncompressedBytes,
86
- truncated,
87
- };
88
- }
89
- start += 1;
90
- truncated = true;
91
- }
92
- return null;
93
- }
94
- function emptySlice(since, until) {
95
- return {
96
- records: [],
97
- jsonl: '',
98
- uncompressed_bytes: 0,
99
- compressed_bytes: 0,
100
- record_count: 0,
101
- truncated: false,
102
- since,
103
- until,
104
- schema_version: LOG_SCHEMA_VERSION,
105
- consentSummary: consentSummary({
106
- since,
107
- until,
108
- recordCount: 0,
109
- uncompressedBytes: 0,
110
- compressedBytes: 0,
111
- }),
112
- };
113
- }
114
- function toJsonl(lines) {
115
- if (lines.length === 0)
116
- return '';
117
- return `${lines.join('\n')}\n`;
118
- }
119
- function consentSummary(input) {
120
- const from = new Date(input.since).toISOString();
121
- const to = new Date(input.until).toISOString();
122
- return (`About to send ${String(input.recordCount)} log records from ${from} to ${to} ` +
123
- `(${String(input.uncompressedBytes)} bytes uncompressed, ${String(input.compressedBytes)} bytes compressed). ` +
124
- 'Credentials are already removed. Notification titles and the user\'s answers are in the log.');
125
- }
126
- //# sourceMappingURL=pack-feed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e,EAAE,CAAC;SACnB,CAAC;KACH,CAAA;AACH,CAAC;AAED,SAAS,OAAO,CAAC,KAAe;IAC9B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IACjC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;AAChC,CAAC;AAED,SAAS,cAAc,CAAC,KAMvB;IACC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;IAChD,MAAM,EAAE,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;IAC9C,OAAO,CACL,iBAAiB,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,qBAAqB,IAAI,OAAO,EAAE,GAAG;QAC/E,IAAI,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,wBAAwB,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,sBAAsB;QAC9G,8FAA8F,CAC/F,CAAA;AACH,CAAC"}
@@ -1,5 +0,0 @@
1
- /** Approval proof stays local. Never attach this artifact to a Notification Request. */
2
- export declare function pairingQrPath(env: NodeJS.ProcessEnv): string;
3
- export declare function pairingQrTextPath(env: NodeJS.ProcessEnv): string;
4
- export declare function renderPairingQr(env: NodeJS.ProcessEnv, url: string): Promise<string>;
5
- export declare function terminalPairingQr(url: string, ansi?: boolean): Promise<string>;
@@ -1,24 +0,0 @@
1
- import path from 'node:path';
2
- import { atomicWriteFileSync } from './atomic-file.js';
3
- import { stateDir } from './config.js';
4
- /** Approval proof stays local. Never attach this artifact to a Notification Request. */
5
- export function pairingQrPath(env) {
6
- return path.join(stateDir(env), 'pairing-qr.png');
7
- }
8
- export function pairingQrTextPath(env) {
9
- return path.join(stateDir(env), 'pairing-qr.txt');
10
- }
11
- export async function renderPairingQr(env, url) {
12
- const file = pairingQrPath(env);
13
- const { default: QRCode } = await import('qrcode');
14
- const bytes = await QRCode.toBuffer(url, { type: 'png', errorCorrectionLevel: 'M', width: 512, margin: 4 });
15
- atomicWriteFileSync(file, bytes, { mode: 0o600, preserveMode: false, requireCurrentUserOwner: true });
16
- const text = await terminalPairingQr(url, false);
17
- atomicWriteFileSync(pairingQrTextPath(env), text, { mode: 0o600, preserveMode: false, requireCurrentUserOwner: true });
18
- return file;
19
- }
20
- export async function terminalPairingQr(url, ansi = true) {
21
- const { default: QRCode } = await import('qrcode');
22
- return QRCode.toString(url, { type: ansi ? 'terminal' : 'utf8', small: true, errorCorrectionLevel: 'M', margin: 4 });
23
- }
24
- //# sourceMappingURL=pairing-qr.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pairing-qr.js","sourceRoot":"","sources":["../src/pairing-qr.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,wFAAwF;AACxF,MAAM,UAAU,aAAa,CAAC,GAAsB;IAClD,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,gBAAgB,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAsB;IACtD,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,gBAAgB,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAsB,EAAE,GAAW;IACvE,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;IAC/B,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAA;IAClD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;IAC3G,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAA;IACrG,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAChD,mBAAmB,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAA;IACtH,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,GAAW,EAAE,IAAI,GAAG,IAAI;IAC9D,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAA;IAClD,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,oBAAoB,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;AACtH,CAAC"}
@@ -1,38 +0,0 @@
1
- /**
2
- * A machine approval this computer started and has not heard the end of.
3
- *
4
- * Approval happens in the User's browser, and the command that started it is
5
- * not always still running when they get there. An agent's shell tool times
6
- * out, a terminal is closed, a remote session drops — and the approval then
7
- * creates an Approved Machine whose credential nobody kept, so the next run
8
- * asks the User to approve a second computer that is the same computer.
9
- *
10
- * Keeping the handshake on disk between runs is what makes "approve it, then
11
- * run setup again" a true sentence. The file holds the credential-to-be, so
12
- * it lives in the private state directory with owner-only permissions, is
13
- * discarded the moment the pairing resolves, and is never read once the
14
- * service says it expired.
15
- */
16
- export interface PendingPairing {
17
- pairing_id: string;
18
- code: string;
19
- /** The approval page, confirmation secret included. Safe to show the User. */
20
- approve_url: string;
21
- base_url: string;
22
- machine_name: string;
23
- approval_email?: string;
24
- /** The machine credential the approval will activate. */
25
- secret: string;
26
- poll_verifier: string;
27
- expires_at: string;
28
- poll_interval_seconds: number;
29
- }
30
- export declare function pendingPairingPath(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string;
31
- /**
32
- * The handshake still worth asking about, or null. Anything unreadable, or
33
- * long past the point where an approval could still be pending, is removed
34
- * on the way out.
35
- */
36
- export declare function readPendingPairing(env: NodeJS.ProcessEnv, nowMs: number): PendingPairing | null;
37
- export declare function writePendingPairing(env: NodeJS.ProcessEnv, pairing: PendingPairing): void;
38
- export declare function clearPendingPairing(env: NodeJS.ProcessEnv): void;
@@ -1,70 +0,0 @@
1
- import { existsSync, readFileSync, unlinkSync } from 'node:fs';
2
- import path from 'node:path';
3
- import { atomicWriteFileSync } from './atomic-file.js';
4
- import { pairingQrPath, pairingQrTextPath } from './pairing-qr.js';
5
- import { stateDir } from './config.js';
6
- export function pendingPairingPath(env, platform = process.platform) {
7
- return path.join(stateDir(env, platform), 'pending-pairing.json');
8
- }
9
- function isPendingPairing(value) {
10
- if (typeof value !== 'object' || value === null)
11
- return false;
12
- const record = value;
13
- return (typeof record['pairing_id'] === 'string' &&
14
- typeof record['code'] === 'string' &&
15
- typeof record['approve_url'] === 'string' &&
16
- typeof record['base_url'] === 'string' &&
17
- typeof record['machine_name'] === 'string' &&
18
- (record['approval_email'] === undefined || typeof record['approval_email'] === 'string') &&
19
- typeof record['secret'] === 'string' &&
20
- typeof record['poll_verifier'] === 'string' &&
21
- typeof record['expires_at'] === 'string' &&
22
- typeof record['poll_interval_seconds'] === 'number');
23
- }
24
- /**
25
- * How long after its own expiry a handshake is still asked about. The
26
- * service answers `approved` for an approved pairing even after its expiry,
27
- * and the User who approved at minute nine and said so at minute twelve must
28
- * not be handed a second code. Only the service's answer — expired, denied,
29
- * unknown — discards a handshake; the local clock only stops asking about
30
- * files nobody could still be approving.
31
- */
32
- const RESUME_GRACE_MS = 24 * 60 * 60 * 1000;
33
- /**
34
- * The handshake still worth asking about, or null. Anything unreadable, or
35
- * long past the point where an approval could still be pending, is removed
36
- * on the way out.
37
- */
38
- export function readPendingPairing(env, nowMs) {
39
- const file = pendingPairingPath(env);
40
- if (!existsSync(file))
41
- return null;
42
- let parsed;
43
- try {
44
- parsed = JSON.parse(readFileSync(file, 'utf8'));
45
- }
46
- catch {
47
- clearPendingPairing(env);
48
- return null;
49
- }
50
- if (!isPendingPairing(parsed) || !(Date.parse(parsed.expires_at) + RESUME_GRACE_MS > nowMs)) {
51
- clearPendingPairing(env);
52
- return null;
53
- }
54
- return parsed;
55
- }
56
- export function writePendingPairing(env, pairing) {
57
- atomicWriteFileSync(pendingPairingPath(env), `${JSON.stringify(pairing, null, 2)}\n`, {
58
- mode: 0o600,
59
- requireCurrentUserOwner: true,
60
- });
61
- }
62
- export function clearPendingPairing(env) {
63
- for (const file of [pendingPairingPath(env), pairingQrPath(env), pairingQrTextPath(env)]) {
64
- try {
65
- unlinkSync(file);
66
- }
67
- catch { /* Already absent. */ }
68
- }
69
- }
70
- //# sourceMappingURL=pending-pairing.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pending-pairing.js","sourceRoot":"","sources":["../src/pending-pairing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAgCtC,MAAM,UAAU,kBAAkB,CAChC,GAAsB,EACtB,WAA4B,OAAO,CAAC,QA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AY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,mBAAmB,CAAC,GAAG,CAAC,CAAA;QACxB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,eAAe,GAAG,KAAK,CAAC,EAAE,CAAC;QAC5F,mBAAmB,CAAC,GAAG,CAAC,CAAA;QACxB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,GAAsB,EAAE,OAAuB;IACjF,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QACpF,IAAI,EAAE,KAAK;QACX,uBAAuB,EAAE,IAAI;KAC9B,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,GAAsB;IACxD,KAAK,MAAM,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QACzF,IAAI,CAAC;YAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC"}
@@ -1,67 +0,0 @@
1
- import { type SpawnOptions } from 'node:child_process';
2
- /**
3
- * How this process should launch one child. Tests inspect the plan instead of
4
- * opening a browser or running npx; production hands it to `spawn`.
5
- */
6
- export interface ProcessLaunch {
7
- file: string;
8
- args: string[];
9
- options: SpawnOptions;
10
- }
11
- /** Drive letter or UNC. MSYS `/c/Users/…` is not a Windows account home. */
12
- export declare function isWindowsAbsolute(value: string): boolean;
13
- /**
14
- * The account home used for Notifai's own defaults.
15
- *
16
- * On Windows, Git Bash and MSYS overwrite `HOME` with a POSIX path that is not
17
- * a usable NTFS root. Those values are ignored; a Windows-absolute
18
- * `USERPROFILE` or `os.homedir()` wins. A Windows-absolute `HOME` is still
19
- * honoured. POSIX keeps `HOME` as the override it has always been.
20
- */
21
- export declare function accountHome(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string;
22
- /**
23
- * Directory that contains the `notifai/` configuration folder.
24
- *
25
- * An explicit `XDG_CONFIG_HOME` always wins, including on Windows. Otherwise
26
- * Windows uses `%APPDATA%` and POSIX uses `~/.config`.
27
- */
28
- export declare function configHome(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string;
29
- /**
30
- * Directory that contains the `notifai/` machine-local state folder.
31
- *
32
- * An explicit `XDG_STATE_HOME` always wins. Otherwise Windows uses
33
- * `%LOCALAPPDATA%` and POSIX uses `~/.local/state`.
34
- */
35
- export declare function stateHome(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string;
36
- /**
37
- * Open a pairing or support URL.
38
- *
39
- * Windows goes through `rundll32` so the URL is one CreateProcess argument and
40
- * `cmd` never reparses `?a=1&b=2`. `windowsHide` keeps the helper from flashing
41
- * a console. macOS and Linux stay best-effort `open` / `xdg-open`.
42
- */
43
- export declare function urlOpenLaunch(url: string, platform?: NodeJS.Platform): ProcessLaunch;
44
- /** Best-effort browser open. Failure is silent: the URL is printed either way. */
45
- export declare function openUrl(url: string, platform?: NodeJS.Platform): void;
46
- /**
47
- * Resolve npm's JavaScript npx entry point when this Windows Node installation
48
- * exposes it. Invoking that file with the current Node runtime avoids the
49
- * cwd-sensitive relative paths embedded in some npx.cmd shims.
50
- */
51
- export declare function windowsNpxCli(nodeExecutable?: string): string | null;
52
- /**
53
- * Launch `npx` without making its resolution depend on the target project.
54
- *
55
- * Prefer npm's JavaScript entry point, which avoids both CreateProcess's
56
- * inability to run `.cmd` files and shims whose relative paths depend on the
57
- * working directory. A nonstandard Windows Node layout fails closed instead
58
- * of executing an environment-selected shell or command shim; POSIX can
59
- * execute `npx` directly without a shell.
60
- */
61
- export declare function npxLaunch(args: readonly string[], options: {
62
- cwd: string;
63
- env: NodeJS.ProcessEnv;
64
- nodeExecutable?: string;
65
- platform?: NodeJS.Platform;
66
- stdio?: SpawnOptions['stdio'];
67
- }): ProcessLaunch;
package/dist/platform.js DELETED
@@ -1,140 +0,0 @@
1
- import { spawn } from 'node:child_process';
2
- import { existsSync } from 'node:fs';
3
- import os from 'node:os';
4
- import path from 'node:path';
5
- /** Drive letter or UNC. MSYS `/c/Users/…` is not a Windows account home. */
6
- export function isWindowsAbsolute(value) {
7
- return /^[A-Za-z]:[\\/]/.test(value) || value.startsWith('\\\\');
8
- }
9
- /**
10
- * The account home used for Notifai's own defaults.
11
- *
12
- * On Windows, Git Bash and MSYS overwrite `HOME` with a POSIX path that is not
13
- * a usable NTFS root. Those values are ignored; a Windows-absolute
14
- * `USERPROFILE` or `os.homedir()` wins. A Windows-absolute `HOME` is still
15
- * honoured. POSIX keeps `HOME` as the override it has always been.
16
- */
17
- export function accountHome(env = process.env, platform = process.platform) {
18
- if (platform === 'win32') {
19
- const home = env['HOME'];
20
- if (typeof home === 'string' && isWindowsAbsolute(home))
21
- return home;
22
- const profile = env['USERPROFILE'];
23
- if (typeof profile === 'string' && isWindowsAbsolute(profile))
24
- return profile;
25
- return os.homedir();
26
- }
27
- const home = env['HOME'];
28
- if (typeof home === 'string' && home !== '')
29
- return home;
30
- return os.homedir();
31
- }
32
- /**
33
- * Directory that contains the `notifai/` configuration folder.
34
- *
35
- * An explicit `XDG_CONFIG_HOME` always wins, including on Windows. Otherwise
36
- * Windows uses `%APPDATA%` and POSIX uses `~/.config`.
37
- */
38
- export function configHome(env = process.env, platform = process.platform) {
39
- const xdg = env['XDG_CONFIG_HOME'];
40
- if (typeof xdg === 'string' && xdg !== '')
41
- return xdg;
42
- if (platform === 'win32') {
43
- const appdata = env['APPDATA'];
44
- if (typeof appdata === 'string' && appdata !== '')
45
- return appdata;
46
- }
47
- return path.join(accountHome(env, platform), '.config');
48
- }
49
- /**
50
- * Directory that contains the `notifai/` machine-local state folder.
51
- *
52
- * An explicit `XDG_STATE_HOME` always wins. Otherwise Windows uses
53
- * `%LOCALAPPDATA%` and POSIX uses `~/.local/state`.
54
- */
55
- export function stateHome(env = process.env, platform = process.platform) {
56
- const xdg = env['XDG_STATE_HOME'];
57
- if (typeof xdg === 'string' && xdg !== '')
58
- return xdg;
59
- if (platform === 'win32') {
60
- const local = env['LOCALAPPDATA'];
61
- if (typeof local === 'string' && local !== '')
62
- return local;
63
- }
64
- return path.join(accountHome(env, platform), '.local', 'state');
65
- }
66
- /**
67
- * Open a pairing or support URL.
68
- *
69
- * Windows goes through `rundll32` so the URL is one CreateProcess argument and
70
- * `cmd` never reparses `?a=1&b=2`. `windowsHide` keeps the helper from flashing
71
- * a console. macOS and Linux stay best-effort `open` / `xdg-open`.
72
- */
73
- export function urlOpenLaunch(url, platform = process.platform) {
74
- if (platform === 'darwin') {
75
- return { file: 'open', args: [url], options: { stdio: 'ignore', detached: true } };
76
- }
77
- if (platform === 'win32') {
78
- return {
79
- file: 'rundll32.exe',
80
- args: ['url.dll,FileProtocolHandler', url],
81
- options: { stdio: 'ignore', detached: true, windowsHide: true },
82
- };
83
- }
84
- return { file: 'xdg-open', args: [url], options: { stdio: 'ignore', detached: true } };
85
- }
86
- /** Best-effort browser open. Failure is silent: the URL is printed either way. */
87
- export function openUrl(url, platform = process.platform) {
88
- try {
89
- const launch = urlOpenLaunch(url, platform);
90
- spawn(launch.file, launch.args, launch.options).unref();
91
- }
92
- catch {
93
- // The caller already printed the URL.
94
- }
95
- }
96
- /**
97
- * Resolve npm's JavaScript npx entry point when this Windows Node installation
98
- * exposes it. Invoking that file with the current Node runtime avoids the
99
- * cwd-sensitive relative paths embedded in some npx.cmd shims.
100
- */
101
- export function windowsNpxCli(nodeExecutable = process.execPath) {
102
- const bundledWithNode = path.join(path.dirname(nodeExecutable), 'node_modules', 'npm', 'bin', 'npx-cli.js');
103
- return existsSync(bundledWithNode) ? bundledWithNode : null;
104
- }
105
- /**
106
- * Launch `npx` without making its resolution depend on the target project.
107
- *
108
- * Prefer npm's JavaScript entry point, which avoids both CreateProcess's
109
- * inability to run `.cmd` files and shims whose relative paths depend on the
110
- * working directory. A nonstandard Windows Node layout fails closed instead
111
- * of executing an environment-selected shell or command shim; POSIX can
112
- * execute `npx` directly without a shell.
113
- */
114
- export function npxLaunch(args, options) {
115
- const platform = options.platform ?? process.platform;
116
- const stdio = options.stdio ?? 'inherit';
117
- if (platform === 'win32') {
118
- const nodeExecutable = options.nodeExecutable ?? process.execPath;
119
- const npxCli = windowsNpxCli(nodeExecutable);
120
- if (npxCli === null) {
121
- throw new Error('this Windows Node.js installation is missing its bundled npm tools; repair or reinstall Node.js, then rerun setup');
122
- }
123
- return {
124
- file: nodeExecutable,
125
- args: [npxCli, ...args],
126
- options: {
127
- cwd: options.cwd,
128
- env: options.env,
129
- stdio,
130
- windowsHide: true,
131
- },
132
- };
133
- }
134
- return {
135
- file: 'npx',
136
- args: [...args],
137
- options: { cwd: options.cwd, env: options.env, stdio },
138
- };
139
- }
140
- //# sourceMappingURL=platform.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAY5B,4EAA4E;AAC5E,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;AAClE,CAAC;AAED;;;;;;;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B,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;YACvB,OAAO,EAAE;gBACP,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,KAAK;gBACL,WAAW,EAAE,IAAI;aAClB;SACF,CAAA;IACH,CAAC;IACD,OAAO;QACL,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;QACf,OAAO,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE;KACvD,CAAA;AACH,CAAC"}
@@ -1,26 +0,0 @@
1
- export interface ProcessIdentity {
2
- pid: number;
3
- /** Normalised UTC `ps -o lstart` text, the same clock Claude Code's descriptor uses. */
4
- start: string;
5
- }
6
- /**
7
- * The start time of a process, or null when it is gone or cannot be read.
8
- *
9
- * One clock source for every side of every comparison: `ps -o lstart` under
10
- * `TZ=UTC` and the C locale. Claude Code writes its session descriptor's
11
- * `procStart` the same way, so a harness start read here compares equal to it
12
- * as text. Whitespace is collapsed because `lstart` pads single-digit days.
13
- */
14
- export declare function processStartTime(pid: number): string | null;
15
- /** The executable name of a process (`ps -o comm`, without its directory), or null. */
16
- export declare function processExecutableName(pid: number): string | null;
17
- export declare function normalizeProcessStart(value: string): string;
18
- /** Signal 0 only asks whether the PID exists; EPERM still means it does. */
19
- export declare function pidExists(pid: number): boolean;
20
- export type ProcessLiveness = 'alive' | 'gone' | 'unknown';
21
- /**
22
- * Whether this exact process still runs. A PID that exists with a different
23
- * start time is a different process: the one we knew is gone.
24
- */
25
- export declare function processIdentityLiveness(identity: ProcessIdentity, readStart?: (pid: number) => string | null, exists?: (pid: number) => boolean): ProcessLiveness;
26
- export declare function currentProcessIdentity(): ProcessIdentity | null;
@@ -1,82 +0,0 @@
1
- /** A process named by PID *and* start time, so a reused PID is never mistaken for it. */
2
- import { execFileSync } from 'node:child_process';
3
- /**
4
- * The start time of a process, or null when it is gone or cannot be read.
5
- *
6
- * One clock source for every side of every comparison: `ps -o lstart` under
7
- * `TZ=UTC` and the C locale. Claude Code writes its session descriptor's
8
- * `procStart` the same way, so a harness start read here compares equal to it
9
- * as text. Whitespace is collapsed because `lstart` pads single-digit days.
10
- */
11
- export function processStartTime(pid) {
12
- if (!Number.isInteger(pid) || pid <= 0)
13
- return null;
14
- try {
15
- const output = execFileSync('ps', ['-o', 'lstart=', '-p', String(pid)], {
16
- encoding: 'utf8',
17
- env: { PATH: process.env['PATH'] ?? '/bin:/usr/bin', TZ: 'UTC', LC_ALL: 'C' },
18
- stdio: ['ignore', 'pipe', 'ignore'],
19
- timeout: 2_000,
20
- });
21
- const start = normalizeProcessStart(output);
22
- return start === '' ? null : start;
23
- }
24
- catch {
25
- // `ps` exits 1 for a PID that does not exist.
26
- return null;
27
- }
28
- }
29
- /** The executable name of a process (`ps -o comm`, without its directory), or null. */
30
- export function processExecutableName(pid) {
31
- if (!Number.isInteger(pid) || pid <= 0)
32
- return null;
33
- try {
34
- const output = execFileSync('ps', ['-o', 'comm=', '-p', String(pid)], {
35
- encoding: 'utf8',
36
- env: { PATH: process.env['PATH'] ?? '/bin:/usr/bin', LC_ALL: 'C' },
37
- stdio: ['ignore', 'pipe', 'ignore'],
38
- timeout: 2_000,
39
- }).trim();
40
- return output === '' ? null : output.slice(output.lastIndexOf('/') + 1);
41
- }
42
- catch {
43
- return null;
44
- }
45
- }
46
- export function normalizeProcessStart(value) {
47
- return value.trim().replace(/\s+/g, ' ');
48
- }
49
- /** Signal 0 only asks whether the PID exists; EPERM still means it does. */
50
- export function pidExists(pid) {
51
- if (!Number.isInteger(pid) || pid <= 0)
52
- return false;
53
- try {
54
- process.kill(pid, 0);
55
- return true;
56
- }
57
- catch (err) {
58
- return err.code === 'EPERM';
59
- }
60
- }
61
- /**
62
- * Whether this exact process still runs. A PID that exists with a different
63
- * start time is a different process: the one we knew is gone.
64
- */
65
- export function processIdentityLiveness(identity, readStart = processStartTime, exists = pidExists) {
66
- if (!exists(identity.pid))
67
- return 'gone';
68
- const start = readStart(identity.pid);
69
- if (start === null)
70
- return exists(identity.pid) ? 'unknown' : 'gone';
71
- return normalizeProcessStart(start) === normalizeProcessStart(identity.start) ? 'alive' : 'gone';
72
- }
73
- /** This process, read once: its start time never changes. */
74
- let selfIdentity;
75
- export function currentProcessIdentity() {
76
- if (selfIdentity === undefined) {
77
- const start = processStartTime(process.pid);
78
- selfIdentity = start === null ? null : { pid: process.pid, start };
79
- }
80
- return selfIdentity;
81
- }
82
- //# sourceMappingURL=process-identity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-identity.js","sourceRoot":"","sources":["../src/process-identity.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAQjD;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IACnD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;YACtE,QAAQ,EAAE,MAAM;YAChB,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,eAAe,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE;YAC7E,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;YACnC,OAAO,EAAE,KAAK;SACf,CAAC,CAAA;QACF,MAAM,KAAK,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAA;QAC3C,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,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