lazycodex-ai 5.0.0-beta.7 → 5.0.0-beta.71

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 (725) hide show
  1. package/README.ja.md +66 -61
  2. package/README.ko.md +67 -62
  3. package/README.md +108 -182
  4. package/README.ru.md +63 -61
  5. package/README.zh-cn.md +62 -61
  6. package/dist/cli/config-manager/parse-opencode-config-file.d.ts +2 -1
  7. package/dist/cli/doctor/checks/browser-provider.d.ts +2 -0
  8. package/dist/cli/doctor/checks/index.d.ts +2 -0
  9. package/dist/cli/doctor/checks/latest-version.d.ts +11 -0
  10. package/dist/cli/doctor/checks/system-plugin.d.ts +4 -3
  11. package/dist/cli/doctor/framework/constants.d.ts +5 -0
  12. package/dist/cli/doctor/framework/types.d.ts +2 -0
  13. package/dist/cli/fallback-lane-policy.d.ts +1 -0
  14. package/dist/cli/index.js +51933 -59845
  15. package/dist/cli/install-codex/install-codex-test-fixtures.d.ts +1 -1
  16. package/dist/cli/run/on-complete-hook.d.ts +2 -0
  17. package/dist/cli/runtime-commands.d.ts +1 -1
  18. package/dist/cli/worktree-sweep/classify.d.ts +16 -0
  19. package/dist/cli/worktree-sweep/format.d.ts +8 -0
  20. package/dist/cli/worktree-sweep/git.d.ts +19 -0
  21. package/dist/cli/worktree-sweep/index.d.ts +7 -0
  22. package/dist/cli/worktree-sweep/options.d.ts +2 -0
  23. package/dist/cli/worktree-sweep/parse-worktree-list.d.ts +8 -0
  24. package/dist/cli/worktree-sweep/sweep.d.ts +2 -0
  25. package/dist/cli/worktree-sweep/types.d.ts +65 -0
  26. package/dist/cli/worktree-sweep/worktree-sweep.d.ts +2 -0
  27. package/dist/cli-node/index.js +51915 -59804
  28. package/package.json +12 -14
  29. package/packages/git-bash-mcp/dist/cli.js +6 -1
  30. package/packages/lsp-daemon/dist/cli.js +904 -479
  31. package/packages/lsp-daemon/dist/client.d.ts +10 -0
  32. package/packages/lsp-daemon/dist/client.js +922 -493
  33. package/packages/lsp-daemon/dist/daemon-client.d.ts +1 -0
  34. package/packages/lsp-daemon/dist/daemon-client.js +3 -0
  35. package/packages/lsp-daemon/dist/ensure-daemon.d.ts +6 -1
  36. package/packages/lsp-daemon/dist/ensure-daemon.js +10 -2
  37. package/packages/lsp-daemon/dist/index.js +826 -402
  38. package/packages/lsp-daemon/dist/ownership.js +2 -2
  39. package/packages/lsp-daemon/dist/proxy.js +3 -0
  40. package/packages/lsp-daemon/dist/version-reap.js +1 -1
  41. package/packages/lsp-daemon/package.json +1 -1
  42. package/packages/lsp-tools-mcp/dist/cli.js +764 -341
  43. package/packages/lsp-tools-mcp/dist/lsp/manager.js +274 -138
  44. package/packages/lsp-tools-mcp/dist/mcp.js +789 -368
  45. package/packages/lsp-tools-mcp/dist/request-context.js +12 -13
  46. package/packages/lsp-tools-mcp/dist/tools.js +719 -302
  47. package/packages/lsp-tools-mcp/package.json +1 -1
  48. package/packages/omo-codex/plugin/.codex-plugin/plugin.json +4 -6
  49. package/packages/omo-codex/plugin/.mcp.json +0 -6
  50. package/packages/omo-codex/plugin/AGENTS.md +47 -0
  51. package/packages/omo-codex/plugin/README.md +6 -2
  52. package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +7100 -408
  53. package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
  54. package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
  55. package/packages/omo-codex/plugin/components/bootstrap/src/hook.ts +1 -0
  56. package/packages/omo-codex/plugin/components/bootstrap/src/setup.ts +7 -1
  57. package/packages/omo-codex/plugin/components/comment-checker/AGENTS.md +9 -0
  58. package/packages/omo-codex/plugin/components/comment-checker/biome.json +2 -2
  59. package/packages/omo-codex/plugin/components/comment-checker/dist/cli.js +2 -1
  60. package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
  61. package/packages/omo-codex/plugin/components/comment-checker/package.json +5 -5
  62. package/packages/omo-codex/plugin/components/comment-checker/src/apply-patch.ts +2 -8
  63. package/packages/omo-codex/plugin/components/comment-checker/src/core.ts +1 -2
  64. package/packages/omo-codex/plugin/components/comment-checker/src/request-extractor.ts +1 -1
  65. package/packages/omo-codex/plugin/components/comment-checker/src/runner.ts +1 -0
  66. package/packages/omo-codex/plugin/components/git-bash/AGENTS.md +1 -1
  67. package/packages/omo-codex/plugin/components/git-bash/dist/cli.js +1 -1
  68. package/packages/omo-codex/plugin/components/git-bash/dist/codex-hook.js +2 -1
  69. package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
  70. package/packages/omo-codex/plugin/components/git-bash/package.json +3 -4
  71. package/packages/omo-codex/plugin/components/git-bash/src/codex-hook.ts +2 -1
  72. package/packages/omo-codex/plugin/components/git-bash/test/codex-hook.test.ts +6 -7
  73. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/AGENTS.md +2 -2
  74. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/biome.json +2 -2
  75. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/directive.md +2 -0
  76. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/cli.js +36 -29
  77. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/codex-hook.js +32 -26
  78. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/types.d.ts +3 -0
  79. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
  80. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +5 -5
  81. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/src/codex-hook.ts +32 -28
  82. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/src/types.ts +3 -0
  83. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/test/cli.test.ts +1 -1
  84. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/test/codex-hook.test.ts +137 -28
  85. package/packages/omo-codex/plugin/components/lcx/skills/lcx-doctor/SKILL.md +4 -2
  86. package/packages/omo-codex/plugin/components/lsp/AGENTS.md +30 -15
  87. package/packages/omo-codex/plugin/components/lsp/biome.json +2 -2
  88. package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +4 -4
  89. package/packages/omo-codex/plugin/components/lsp/dist/cli.js +943 -540
  90. package/packages/omo-codex/plugin/components/lsp/dist/daemon-cli-path.js +1 -1
  91. package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
  92. package/packages/omo-codex/plugin/components/lsp/package.json +5 -5
  93. package/packages/omo-codex/plugin/components/lsp/src/cli.ts +1 -1
  94. package/packages/omo-codex/plugin/components/lsp/src/codex-hook.ts +1 -1
  95. package/packages/omo-codex/plugin/components/lsp/src/daemon-cli-path.ts +1 -5
  96. package/packages/omo-codex/plugin/components/lsp/test/codex-hook-unavailable.test.ts +6 -7
  97. package/packages/omo-codex/plugin/components/lsp/test/codex-hook.test.ts +1 -2
  98. package/packages/omo-codex/plugin/components/lsp/test/package-smoke.test.ts +11 -1
  99. package/packages/omo-codex/plugin/components/rules/AGENTS.md +12 -0
  100. package/packages/omo-codex/plugin/components/rules/README.md +2 -0
  101. package/packages/omo-codex/plugin/components/rules/biome.json +2 -2
  102. package/packages/omo-codex/plugin/components/rules/bundled-rules/hephaestus/gpt-6.md +123 -0
  103. package/packages/omo-codex/plugin/components/rules/dist/cli.js +91 -68
  104. package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
  105. package/packages/omo-codex/plugin/components/rules/package.json +7 -7
  106. package/packages/omo-codex/plugin/components/rules/src/config.ts +1 -2
  107. package/packages/omo-codex/plugin/components/rules/src/persistent-cache.ts +1 -2
  108. package/packages/omo-codex/plugin/components/rules/src/post-compact-budget.ts +15 -5
  109. package/packages/omo-codex/plugin/components/rules/src/rules-engine-factory.ts +1 -4
  110. package/packages/omo-codex/plugin/components/rules/src/static-injection.ts +4 -9
  111. package/packages/omo-codex/plugin/components/rules/test/bundled-rules-priority.test.ts +11 -16
  112. package/packages/omo-codex/plugin/components/rules/test/bundled-rules.test.ts +17 -25
  113. package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-budget.test.ts +9 -7
  114. package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-context.test.ts +0 -6
  115. package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-dedup.test.ts +6 -4
  116. package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-directive.test.ts +12 -9
  117. package/packages/omo-codex/plugin/components/rules/test/codex-hook.test.ts +28 -37
  118. package/packages/omo-codex/plugin/components/rules/test/dynamic-target-fingerprints.test.ts +1 -2
  119. package/packages/omo-codex/plugin/components/rules/test/engine.test.ts +7 -4
  120. package/packages/omo-codex/plugin/components/rules/test/finder.test.ts +2 -3
  121. package/packages/omo-codex/plugin/components/rules/test/formatter.test.ts +39 -72
  122. package/packages/omo-codex/plugin/components/rules/test/hephaestus-model-variant.test.ts +38 -3
  123. package/packages/omo-codex/plugin/components/rules/test/hook-output.test.ts +2 -3
  124. package/packages/omo-codex/plugin/components/rules/test/matcher.test.ts +2 -3
  125. package/packages/omo-codex/plugin/components/rules/test/package-smoke.test.ts +1 -1
  126. package/packages/omo-codex/plugin/components/rules/test/parser.test.ts +1 -2
  127. package/packages/omo-codex/plugin/components/rules/test/post-compact-budget.test.ts +29 -6
  128. package/packages/omo-codex/plugin/components/rules/test/rules-engine-consumption.test.ts +3 -6
  129. package/packages/omo-codex/plugin/components/rules/test/scanner.test.ts +1 -2
  130. package/packages/omo-codex/plugin/components/rules/test/sources.test.ts +2 -5
  131. package/packages/omo-codex/plugin/components/rules/test/windows-git-bash-bundled-rule.test.ts +2 -17
  132. package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
  133. package/packages/omo-codex/plugin/components/teammode/package.json +5 -5
  134. package/packages/omo-codex/plugin/components/teammode/test/thread-title-hook.test.ts +4 -10
  135. package/packages/omo-codex/plugin/components/telemetry/AGENTS.md +8 -0
  136. package/packages/omo-codex/plugin/components/telemetry/biome.json +2 -2
  137. package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +2407 -684
  138. package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +2411 -689
  139. package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
  140. package/packages/omo-codex/plugin/components/telemetry/package.json +5 -5
  141. package/packages/omo-codex/plugin/components/telemetry/src/codex-hook.ts +1 -4
  142. package/packages/omo-codex/plugin/components/telemetry/src/posthog.ts +4 -14
  143. package/packages/omo-codex/plugin/components/telemetry/src/product-identity.ts +1 -1
  144. package/packages/omo-codex/plugin/components/telemetry/test/diagnostics.test.ts +2 -5
  145. package/packages/omo-codex/plugin/components/ultrawork/AGENTS.md +10 -4
  146. package/packages/omo-codex/plugin/components/ultrawork/README.md +2 -0
  147. package/packages/omo-codex/plugin/components/ultrawork/agents/explorer.toml +1 -1
  148. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-clone-fidelity-reviewer.toml +1 -1
  149. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-code-reviewer.toml +1 -1
  150. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-gate-reviewer.toml +1 -1
  151. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-qa-executor.toml +1 -1
  152. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-worker-high.toml +1 -1
  153. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-worker-low.toml +1 -1
  154. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-worker-medium.toml +1 -1
  155. package/packages/omo-codex/plugin/components/ultrawork/agents/librarian.toml +1 -1
  156. package/packages/omo-codex/plugin/components/ultrawork/agents/metis.toml +1 -1
  157. package/packages/omo-codex/plugin/components/ultrawork/agents/momus.toml +1 -1
  158. package/packages/omo-codex/plugin/components/ultrawork/agents/plan.toml +4 -4
  159. package/packages/omo-codex/plugin/components/ultrawork/biome.json +2 -2
  160. package/packages/omo-codex/plugin/components/ultrawork/dist/cli.js +500 -4
  161. package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
  162. package/packages/omo-codex/plugin/components/ultrawork/package.json +5 -6
  163. package/packages/omo-codex/plugin/components/ultrawork/scripts/sync-directive.mjs +30 -14
  164. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/SKILL.md +6 -7
  165. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/full-workflow.md +31 -7
  166. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/intent-clear.md +2 -1
  167. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/intent-unclear.md +5 -5
  168. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/scripts/scaffold-plan.mjs +1 -0
  169. package/packages/omo-codex/plugin/components/ultrawork/src/directive-content.ts +4 -0
  170. package/packages/omo-codex/plugin/components/ultrawork/src/directive.ts +5 -2
  171. package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook-trigger-policy.test.ts +9 -1
  172. package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook.test.ts +0 -136
  173. package/packages/omo-codex/plugin/components/ultrawork/test/directive-source.test.ts +14 -8
  174. package/packages/omo-codex/plugin/components/ultrawork/test/package-smoke.test.ts +12 -1
  175. package/packages/omo-codex/plugin/components/ultrawork/test/skill-pointer.test.ts +0 -2
  176. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/AGENTS.md +4 -4
  177. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/NOTICE +1 -1
  178. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/README.md +6 -6
  179. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/biome.json +2 -2
  180. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/directive.md +11 -11
  181. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/dist/cli.js +16 -16
  182. package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +16 -0
  183. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/package.json +12 -12
  184. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/boulder-reader.ts +1 -1
  185. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/cli.ts +1 -1
  186. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/codex-hook.ts +4 -4
  187. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/directive.ts +1 -1
  188. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/index.ts +1 -1
  189. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/types.ts +1 -1
  190. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/boulder-reader.test.ts +3 -3
  191. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/cli.test.ts +4 -11
  192. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/codex-hook.test.ts +24 -22
  193. package/packages/omo-codex/plugin/components/ulw-loop/AGENTS.md +19 -0
  194. package/packages/omo-codex/plugin/components/ulw-loop/CHANGELOG.md +17 -1
  195. package/packages/omo-codex/plugin/components/ulw-loop/README.md +12 -1
  196. package/packages/omo-codex/plugin/components/ulw-loop/biome.json +2 -2
  197. package/packages/omo-codex/plugin/components/ulw-loop/directive.md +44 -27
  198. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-codex-validation.d.ts +18 -0
  199. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-codex-validation.js +30 -0
  200. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-continuation.js +10 -4
  201. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-reconciliation.d.ts +2 -5
  202. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-reconciliation.js +5 -78
  203. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-template.d.ts +12 -0
  204. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-template.js +114 -0
  205. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.d.ts +7 -1
  206. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.js +57 -46
  207. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-arg-parser.js +2 -2
  208. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-commands.js +21 -8
  209. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.d.ts +2 -1
  210. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.js +12 -1
  211. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-subcommands.d.ts +1 -1
  212. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-subcommands.js +40 -37
  213. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +2183 -737
  214. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-instruction.d.ts +2 -0
  215. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-instruction.js +28 -8
  216. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-snapshot.d.ts +8 -5
  217. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-snapshot.js +35 -23
  218. package/packages/omo-codex/plugin/components/ulw-loop/dist/constants.d.ts +1 -0
  219. package/packages/omo-codex/plugin/components/ulw-loop/dist/constants.js +1 -0
  220. package/packages/omo-codex/plugin/components/ulw-loop/dist/domain-types.d.ts +25 -9
  221. package/packages/omo-codex/plugin/components/ulw-loop/dist/driver-objective-ack.d.ts +4 -0
  222. package/packages/omo-codex/plugin/components/ulw-loop/dist/driver-objective-ack.js +18 -0
  223. package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence-artifacts.d.ts +1 -0
  224. package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence-artifacts.js +37 -0
  225. package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence.d.ts +1 -0
  226. package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence.js +24 -12
  227. package/packages/omo-codex/plugin/components/ulw-loop/dist/ledger.d.ts +4 -0
  228. package/packages/omo-codex/plugin/components/ulw-loop/dist/ledger.js +39 -0
  229. package/packages/omo-codex/plugin/components/ulw-loop/dist/paths.d.ts +2 -0
  230. package/packages/omo-codex/plugin/components/ulw-loop/dist/paths.js +19 -4
  231. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-commit.d.ts +19 -0
  232. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-commit.js +108 -0
  233. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-crud.d.ts +6 -2
  234. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-crud.js +54 -25
  235. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-goal-factory.d.ts +10 -3
  236. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-goal-factory.js +38 -31
  237. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-io.d.ts +10 -7
  238. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-io.js +121 -100
  239. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-log.d.ts +16 -0
  240. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-log.js +115 -0
  241. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-missing-recovery.d.ts +18 -0
  242. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-missing-recovery.js +41 -0
  243. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-aggregate.d.ts +7 -0
  244. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-aggregate.js +9 -0
  245. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-artifacts.d.ts +12 -0
  246. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-artifacts.js +104 -0
  247. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-fields.d.ts +13 -1
  248. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-fields.js +65 -9
  249. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-verdicts.js +5 -1
  250. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate.d.ts +4 -2
  251. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate.js +72 -117
  252. package/packages/omo-codex/plugin/components/ulw-loop/dist/review-blockers.d.ts +2 -0
  253. package/packages/omo-codex/plugin/components/ulw-loop/dist/review-blockers.js +25 -13
  254. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/factory.d.ts +2 -0
  255. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/factory.js +157 -0
  256. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/manifest.d.ts +381 -0
  257. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/manifest.js +127 -0
  258. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/types.d.ts +130 -0
  259. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/types.js +1 -0
  260. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk.d.ts +3 -0
  261. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk.js +3 -0
  262. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-budget-io.d.ts +5 -0
  263. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-budget-io.js +67 -0
  264. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-guard.d.ts +7 -1
  265. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-guard.js +188 -59
  266. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-role-guard.d.ts +2 -0
  267. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-role-guard.js +22 -0
  268. package/packages/omo-codex/plugin/components/ulw-loop/dist/state-lock.d.ts +19 -0
  269. package/packages/omo-codex/plugin/components/ulw-loop/dist/state-lock.js +259 -0
  270. package/packages/omo-codex/plugin/components/ulw-loop/dist/status-next-actions.d.ts +7 -0
  271. package/packages/omo-codex/plugin/components/ulw-loop/dist/status-next-actions.js +41 -0
  272. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-batch.js +4 -4
  273. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-mutations.d.ts +3 -2
  274. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-mutations.js +4 -4
  275. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-types.d.ts +9 -1
  276. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering.d.ts +3 -2
  277. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering.js +11 -11
  278. package/packages/omo-codex/plugin/components/ulw-loop/dist/stop-resume-hook.js +28 -23
  279. package/packages/omo-codex/plugin/components/ulw-loop/dist/success-criteria-input.d.ts +9 -0
  280. package/packages/omo-codex/plugin/components/ulw-loop/dist/success-criteria-input.js +41 -0
  281. package/packages/omo-codex/plugin/components/ulw-loop/dist/surface.d.ts +19 -0
  282. package/packages/omo-codex/plugin/components/ulw-loop/dist/surface.js +75 -0
  283. package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +18 -5
  284. package/packages/omo-codex/plugin/components/ulw-loop/package.json +6 -6
  285. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/SKILL.md +7 -2
  286. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/define-goal.md +5 -3
  287. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +34 -11
  288. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-codex-validation.ts +52 -0
  289. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-continuation.ts +8 -6
  290. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-reconciliation.ts +5 -98
  291. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-template.ts +134 -0
  292. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint.ts +59 -77
  293. package/packages/omo-codex/plugin/components/ulw-loop/src/cli-arg-parser.ts +10 -4
  294. package/packages/omo-codex/plugin/components/ulw-loop/src/cli-commands.ts +24 -8
  295. package/packages/omo-codex/plugin/components/ulw-loop/src/cli-output.ts +14 -1
  296. package/packages/omo-codex/plugin/components/ulw-loop/src/cli-subcommands.ts +52 -46
  297. package/packages/omo-codex/plugin/components/ulw-loop/src/cli.ts +8 -6
  298. package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-instruction.ts +35 -7
  299. package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-snapshot.ts +51 -33
  300. package/packages/omo-codex/plugin/components/ulw-loop/src/codex-hook.ts +3 -1
  301. package/packages/omo-codex/plugin/components/ulw-loop/src/constants.ts +1 -0
  302. package/packages/omo-codex/plugin/components/ulw-loop/src/domain-types.ts +27 -9
  303. package/packages/omo-codex/plugin/components/ulw-loop/src/driver-objective-ack.ts +20 -0
  304. package/packages/omo-codex/plugin/components/ulw-loop/src/evidence-artifacts.ts +45 -0
  305. package/packages/omo-codex/plugin/components/ulw-loop/src/evidence.ts +23 -16
  306. package/packages/omo-codex/plugin/components/ulw-loop/src/ledger.ts +38 -0
  307. package/packages/omo-codex/plugin/components/ulw-loop/src/paths.ts +32 -4
  308. package/packages/omo-codex/plugin/components/ulw-loop/src/plan-commit.ts +132 -0
  309. package/packages/omo-codex/plugin/components/ulw-loop/src/plan-crud.ts +67 -54
  310. package/packages/omo-codex/plugin/components/ulw-loop/src/plan-goal-factory.ts +63 -31
  311. package/packages/omo-codex/plugin/components/ulw-loop/src/plan-io.ts +140 -119
  312. package/packages/omo-codex/plugin/components/ulw-loop/src/plan-log.ts +112 -0
  313. package/packages/omo-codex/plugin/components/ulw-loop/src/plan-missing-recovery.ts +61 -0
  314. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-aggregate.ts +11 -0
  315. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-artifacts.ts +123 -0
  316. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-fields.ts +71 -15
  317. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-verdicts.ts +6 -1
  318. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate.ts +92 -136
  319. package/packages/omo-codex/plugin/components/ulw-loop/src/review-blockers.ts +38 -13
  320. package/packages/omo-codex/plugin/components/ulw-loop/src/sdk/factory.ts +218 -0
  321. package/packages/omo-codex/plugin/components/ulw-loop/src/sdk/manifest.ts +156 -0
  322. package/packages/omo-codex/plugin/components/ulw-loop/src/sdk/types.ts +143 -0
  323. package/packages/omo-codex/plugin/components/ulw-loop/src/sdk.ts +3 -0
  324. package/packages/omo-codex/plugin/components/ulw-loop/src/spawn-budget-io.ts +59 -0
  325. package/packages/omo-codex/plugin/components/ulw-loop/src/spawn-guard.ts +196 -52
  326. package/packages/omo-codex/plugin/components/ulw-loop/src/spawn-role-guard.ts +22 -0
  327. package/packages/omo-codex/plugin/components/ulw-loop/src/state-lock.ts +257 -0
  328. package/packages/omo-codex/plugin/components/ulw-loop/src/status-next-actions.ts +45 -0
  329. package/packages/omo-codex/plugin/components/ulw-loop/src/steering-batch.ts +4 -4
  330. package/packages/omo-codex/plugin/components/ulw-loop/src/steering-mutations.ts +5 -4
  331. package/packages/omo-codex/plugin/components/ulw-loop/src/steering-types.ts +13 -1
  332. package/packages/omo-codex/plugin/components/ulw-loop/src/steering.ts +12 -10
  333. package/packages/omo-codex/plugin/components/ulw-loop/src/stop-resume-hook.ts +27 -22
  334. package/packages/omo-codex/plugin/components/ulw-loop/src/success-criteria-input.ts +56 -0
  335. package/packages/omo-codex/plugin/components/ulw-loop/src/surface.ts +107 -0
  336. package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-continuation.test.ts +0 -1
  337. package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-final.test.ts +131 -82
  338. package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-template.test.ts +147 -0
  339. package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint.test.ts +16 -22
  340. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-checkpoint-continuation.test.ts +4 -2
  341. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-checkpoint.test.ts +31 -2
  342. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-commands.test.ts +2 -0
  343. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-complete-goals.test.ts +3 -1
  344. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-create-goals.test.ts +35 -8
  345. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-entrypoint.test.ts +38 -4
  346. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-json-errors.test.ts +27 -0
  347. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-scope-required.test.ts +144 -0
  348. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-status-next-actions.test.ts +185 -0
  349. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-steering-batch.test.ts +8 -3
  350. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-validation-batch.test.ts +6 -0
  351. package/packages/omo-codex/plugin/components/ulw-loop/test/codex-goal-instruction.test.ts +37 -2
  352. package/packages/omo-codex/plugin/components/ulw-loop/test/codex-goal-snapshot.test.ts +88 -11
  353. package/packages/omo-codex/plugin/components/ulw-loop/test/codex-hook.test.ts +0 -3
  354. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/barrier.ts +13 -0
  355. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/cli-session.ts +4 -0
  356. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-child.ts +65 -0
  357. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-cli-qa.mjs +76 -0
  358. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-crash.ts +23 -0
  359. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-mutations.mjs +58 -0
  360. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-writer.ts +65 -0
  361. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/lease-clock.ts +23 -0
  362. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/quality-gate-builder.ts +9 -4
  363. package/packages/omo-codex/plugin/components/ulw-loop/test/guided-recovery.test.ts +67 -0
  364. package/packages/omo-codex/plugin/components/ulw-loop/test/package-smoke.test.ts +5 -37
  365. package/packages/omo-codex/plugin/components/ulw-loop/test/paths.test.ts +9 -0
  366. package/packages/omo-codex/plugin/components/ulw-loop/test/plan-commit-log.test.ts +252 -0
  367. package/packages/omo-codex/plugin/components/ulw-loop/test/plan-commit-recovery.test.ts +190 -0
  368. package/packages/omo-codex/plugin/components/ulw-loop/test/plan-io-cross-process.test.ts +106 -0
  369. package/packages/omo-codex/plugin/components/ulw-loop/test/plan-io.test.ts +74 -25
  370. package/packages/omo-codex/plugin/components/ulw-loop/test/plan-log-legacy-projection.test.ts +228 -0
  371. package/packages/omo-codex/plugin/components/ulw-loop/test/plan-log-newest.test.ts +72 -0
  372. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-aggregate-basics.test.ts +258 -0
  373. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-cap-and-dedupe.test.ts +22 -0
  374. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-fields-messages.test.ts +98 -0
  375. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-lazycodex-surface.test.ts +93 -0
  376. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-poisoning-cascades.test.ts +97 -0
  377. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-roles.test.ts +51 -2
  378. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-senpi-surface.test.ts +131 -0
  379. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-single-report.test.ts +241 -0
  380. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate.test.ts +58 -3
  381. package/packages/omo-codex/plugin/components/ulw-loop/test/review-blockers.test.ts +9 -7
  382. package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-completed-plan.test.ts +43 -0
  383. package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-contract.test.ts +137 -0
  384. package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-driver-states.test.ts +174 -0
  385. package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-dx.test.ts +219 -0
  386. package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-session-context.test.ts +169 -0
  387. package/packages/omo-codex/plugin/components/ulw-loop/test/spawn-guard.test.ts +450 -7
  388. package/packages/omo-codex/plugin/components/ulw-loop/test/spawn-role-matrix.test.ts +113 -0
  389. package/packages/omo-codex/plugin/components/ulw-loop/test/state-lock.test.ts +310 -0
  390. package/packages/omo-codex/plugin/components/ulw-loop/test/status-next-actions-surface.test.ts +133 -0
  391. package/packages/omo-codex/plugin/components/ulw-loop/test/steering-batch.test.ts +12 -12
  392. package/packages/omo-codex/plugin/components/ulw-loop/test/steering.test.ts +12 -6
  393. package/packages/omo-codex/plugin/components/ulw-loop/test/stop-resume-hook.test.ts +1 -1
  394. package/packages/omo-codex/plugin/components/ulw-loop/test/surface.test.ts +74 -0
  395. package/packages/omo-codex/plugin/components/ulw-loop/test/ultrawork-directive.test.ts +13 -8
  396. package/packages/omo-codex/plugin/components/ulw-loop/vitest.config.ts +1 -0
  397. package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
  398. package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
  399. package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
  400. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
  401. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
  402. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
  403. package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
  404. package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +18 -0
  405. package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
  406. package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
  407. package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
  408. package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
  409. package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
  410. package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
  411. package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
  412. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +17 -0
  413. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
  414. package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
  415. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
  416. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
  417. package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
  418. package/packages/omo-codex/plugin/model-catalog.json +16 -7
  419. package/packages/omo-codex/plugin/package-lock.json +676 -524
  420. package/packages/omo-codex/plugin/package.json +2 -3
  421. package/packages/omo-codex/plugin/scripts/AGENTS.md +39 -0
  422. package/packages/omo-codex/plugin/scripts/auto-update-plan.mjs +1 -2
  423. package/packages/omo-codex/plugin/scripts/auto-update.mjs +0 -9
  424. package/packages/omo-codex/plugin/scripts/canonical-ultrawork-directive.mjs +17 -0
  425. package/packages/omo-codex/plugin/scripts/hook-status-message.mjs +0 -1
  426. package/packages/omo-codex/plugin/scripts/migrate-codex-config/catalog.mjs +16 -7
  427. package/packages/omo-codex/plugin/scripts/migrate-codex-config/multi-agent-v2-guard.mjs +8 -4
  428. package/packages/omo-codex/plugin/scripts/migrate-codex-config/subagent-limit-guard.mjs +19 -90
  429. package/packages/omo-codex/plugin/scripts/migrate-codex-config/toml-section-editor.mjs +1 -1
  430. package/packages/omo-codex/plugin/scripts/sync-skills.d.mts +4 -0
  431. package/packages/omo-codex/plugin/scripts/sync-skills.mjs +111 -64
  432. package/packages/omo-codex/plugin/shared/package.json +3 -4
  433. package/packages/omo-codex/plugin/shared/src/config-loader.ts +2 -102
  434. package/packages/omo-codex/plugin/shared/src/config-migration.ts +0 -1
  435. package/packages/omo-codex/plugin/shared/test/config-loader.test.ts +41 -130
  436. package/packages/omo-codex/plugin/skills/ast-grep/AGENTS.md +51 -0
  437. package/packages/omo-codex/plugin/skills/ast-grep/SKILL.md +13 -1
  438. package/packages/omo-codex/plugin/skills/coding-agent-sessions/AGENTS.md +62 -0
  439. package/packages/omo-codex/plugin/skills/coding-agent-sessions/SKILL.md +1 -1
  440. package/packages/omo-codex/plugin/skills/data-scientist/SKILL.md +99 -239
  441. package/packages/omo-codex/plugin/skills/data-scientist/references/execution-surfaces.md +91 -0
  442. package/packages/omo-codex/plugin/skills/data-scientist/references/placement.md +74 -0
  443. package/packages/omo-codex/plugin/skills/data-scientist/references/polars-lane.md +95 -0
  444. package/packages/omo-codex/plugin/skills/data-scientist/references/uv-setup.md +1 -1
  445. package/packages/omo-codex/plugin/skills/data-scientist/references/visualization.md +64 -0
  446. package/packages/omo-codex/plugin/skills/data-scientist/scripts/ensure-js-deps.sh +28 -0
  447. package/packages/omo-codex/plugin/skills/data-scientist/scripts/ensure-py-deps.sh +37 -0
  448. package/packages/omo-codex/plugin/skills/debugging/SKILL.md +3 -1
  449. package/packages/omo-codex/plugin/skills/debugging/references/methodology/00-setup.md +12 -0
  450. package/packages/omo-codex/plugin/skills/debugging/references/methodology/02-investigate.md +21 -0
  451. package/packages/omo-codex/plugin/skills/debugging/references/runtimes/go.md +15 -1
  452. package/packages/omo-codex/plugin/skills/debugging/references/runtimes/native-binary.md +38 -0
  453. package/packages/omo-codex/plugin/skills/debugging/references/runtimes/node.md +25 -0
  454. package/packages/omo-codex/plugin/skills/debugging/references/runtimes/python.md +13 -0
  455. package/packages/omo-codex/plugin/skills/debugging/references/runtimes/rust.md +41 -0
  456. package/packages/omo-codex/plugin/skills/debugging/references/scripts/dap.mjs +267 -0
  457. package/packages/omo-codex/plugin/skills/debugging/references/scripts/fixture-adapter.mjs +59 -0
  458. package/packages/omo-codex/plugin/skills/debugging/references/tools/dap.md +103 -0
  459. package/packages/omo-codex/plugin/skills/debugging/references/tools/frida.md +193 -0
  460. package/packages/omo-codex/plugin/skills/debugging/references/tools/playwright-cli.md +79 -161
  461. package/packages/omo-codex/plugin/skills/frontend/ATTRIBUTION.md +10 -0
  462. package/packages/omo-codex/plugin/skills/frontend/SKILL.md +16 -9
  463. package/packages/omo-codex/plugin/skills/frontend/references/design/README.md +10 -2
  464. package/packages/omo-codex/plugin/skills/frontend/references/design/_INDEX.md +2 -0
  465. package/packages/omo-codex/plugin/skills/frontend/references/design/ambience-skill.md +145 -0
  466. package/packages/omo-codex/plugin/skills/frontend/references/design/aside.md +1 -1
  467. package/packages/omo-codex/plugin/skills/frontend/references/design/clone-from-url.md +1 -1
  468. package/packages/omo-codex/plugin/skills/frontend/references/design/interaction-skill.md +2 -0
  469. package/packages/omo-codex/plugin/skills/frontend/references/design/print-paged-media.md +76 -0
  470. package/packages/omo-codex/plugin/skills/frontend/references/design/stylegallery.md +80 -0
  471. package/packages/omo-codex/plugin/skills/frontend/references/designpowers/README.md +1 -1
  472. package/packages/omo-codex/plugin/skills/frontend/references/designpowers/lane-a-direction.md +1 -1
  473. package/packages/omo-codex/plugin/skills/frontend/references/designpowers/lane-b-execution.md +11 -11
  474. package/packages/omo-codex/plugin/skills/frontend/references/designpowers/lane-d-memory.md +3 -3
  475. package/packages/omo-codex/plugin/skills/frontend/references/designpowers/orchestration.md +1 -1
  476. package/packages/omo-codex/plugin/skills/frontend/references/designpowers/routing.md +5 -5
  477. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/lighthouse-audit.py +2 -2
  478. package/packages/omo-codex/plugin/skills/git-master/SKILL.md +1 -1
  479. package/packages/omo-codex/plugin/skills/init-deep/SKILL.md +20 -18
  480. package/packages/omo-codex/plugin/skills/lcx-doctor/SKILL.md +4 -2
  481. package/packages/omo-codex/plugin/skills/lsp-setup/SKILL.md +1 -1
  482. package/packages/omo-codex/plugin/skills/programming/SKILL.md +1 -1
  483. package/packages/omo-codex/plugin/skills/refactor/SKILL.md +10 -8
  484. package/packages/omo-codex/plugin/skills/remove-ai-slops/SKILL.md +7 -5
  485. package/packages/omo-codex/plugin/skills/review-work/SKILL.md +116 -424
  486. package/packages/omo-codex/plugin/skills/ultimate-browsing/ATTRIBUTION.md +32 -86
  487. package/packages/omo-codex/plugin/skills/ultimate-browsing/SKILL.md +32 -27
  488. package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/AGENTS.md +111 -0
  489. package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/templates/package.json +2 -2
  490. package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/templates/playwright_mobile_chrome.js +5 -2
  491. package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/templates/playwright_real_chrome.js +8 -6
  492. package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/test_playwright_stealth.py +86 -0
  493. package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/test_playwright_templates.py +4 -7
  494. package/packages/omo-codex/plugin/skills/ultimate-browsing/references/chrome-stealth.md +86 -95
  495. package/packages/omo-codex/plugin/skills/ultimate-browsing/references/insane-search/README.md +18 -5
  496. package/packages/omo-codex/plugin/skills/ultimate-browsing/references/insane-search/playwright.md +16 -13
  497. package/packages/omo-codex/plugin/skills/ultimate-browsing/scripts/extract_cookies.py +3 -3
  498. package/packages/omo-codex/plugin/skills/ultrawork/SKILL.md +44 -27
  499. package/packages/omo-codex/plugin/skills/{start-work → ulw-execute}/SKILL.md +32 -34
  500. package/packages/omo-codex/plugin/skills/ulw-execute/agents/openai.yaml +2 -0
  501. package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +31 -2
  502. package/packages/omo-codex/plugin/skills/ulw-loop/references/define-goal.md +5 -3
  503. package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +34 -11
  504. package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +6 -7
  505. package/packages/omo-codex/plugin/skills/ulw-plan/references/full-workflow.md +31 -7
  506. package/packages/omo-codex/plugin/skills/ulw-plan/references/intent-clear.md +2 -1
  507. package/packages/omo-codex/plugin/skills/ulw-plan/references/intent-unclear.md +5 -5
  508. package/packages/omo-codex/plugin/skills/ulw-plan/scripts/scaffold-plan.mjs +1 -0
  509. package/packages/omo-codex/plugin/skills/ulw-research/SKILL.md +14 -7
  510. package/packages/omo-codex/plugin/skills/visual-qa/AGENTS.md +58 -0
  511. package/packages/omo-codex/plugin/skills/visual-qa/SKILL.md +10 -7
  512. package/packages/omo-codex/plugin/skills/visual-qa/references/browser-setup.md +75 -0
  513. package/packages/omo-codex/plugin/test/AGENTS.md +47 -0
  514. package/packages/omo-codex/plugin/test/aggregate-agents.test.mjs +19 -173
  515. package/packages/omo-codex/plugin/test/aggregate-hooks.test.mjs +16 -51
  516. package/packages/omo-codex/plugin/test/aggregate-manifest.test.mjs +2 -3
  517. package/packages/omo-codex/plugin/test/aggregate-mcp.test.mjs +2 -7
  518. package/packages/omo-codex/plugin/test/aggregate-model-catalog.test.mjs +14 -4
  519. package/packages/omo-codex/plugin/test/aggregate-plugin-fixture.mjs +175 -13
  520. package/packages/omo-codex/plugin/test/aggregate.test.mjs +78 -2
  521. package/packages/omo-codex/plugin/test/auto-update-release-notes.test.mjs +19 -33
  522. package/packages/omo-codex/plugin/test/auto-update.test.mjs +4 -29
  523. package/packages/omo-codex/plugin/test/bootstrap-default-role.test.mjs +66 -0
  524. package/packages/omo-codex/plugin/test/bootstrap-setup.test.mjs +0 -31
  525. package/packages/omo-codex/plugin/test/canonical-ultrawork-directive.test.mjs +53 -0
  526. package/packages/omo-codex/plugin/test/component-bin-names.test.mjs +2 -2
  527. package/packages/omo-codex/plugin/test/component-bundled-cli.test.mjs +1 -51
  528. package/packages/omo-codex/plugin/test/component-hook-contract-cases.mjs +100 -2
  529. package/packages/omo-codex/plugin/test/hook-status-message.test.mjs +5 -6
  530. package/packages/omo-codex/plugin/test/lcx-contribute-bug-fix-template.test.mjs +21 -27
  531. package/packages/omo-codex/plugin/test/mcp-research-servers.test.mjs +1 -3
  532. package/packages/omo-codex/plugin/test/migrate-codex-config.test.mjs +35 -35
  533. package/packages/omo-codex/plugin/test/multi-agent-v2-regression.test.mjs +1 -1
  534. package/packages/omo-codex/plugin/test/scaffold-plan.test.mjs +0 -36
  535. package/packages/omo-codex/plugin/test/subagent-limit-migration.test.mjs +107 -15
  536. package/packages/omo-codex/plugin/test/sync-skills-codex-compatibility.test.mjs +168 -0
  537. package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +54 -24
  538. package/packages/omo-codex/plugin/test/sync-skills.test.mjs +18 -119
  539. package/packages/omo-codex/plugin/test/teammode-archive-ambiguity.test.mjs +0 -40
  540. package/packages/omo-codex/plugin/test/teammode-communication.test.mjs +6 -62
  541. package/packages/omo-codex/plugin/test/teammode-thread-links.test.mjs +3 -36
  542. package/packages/omo-codex/plugin/test/teammode-transport.test.mjs +0 -44
  543. package/packages/omo-codex/plugin/test/teammode-worktree.test.mjs +2 -6
  544. package/packages/omo-codex/plugin/test/ultrawork-skill-pointer.test.mjs +5 -5
  545. package/packages/omo-codex/plugin/test/ulw-plan-review-state-contract.test.mjs +0 -3
  546. package/packages/omo-codex/scripts/install-dist/install-local.mjs +9659 -1394
  547. package/packages/{omo-codex/plugin/components/ultrawork/skills/ultrawork/SKILL.md → prompts-core/prompts/ultrawork/codex.md} +44 -34
  548. package/packages/shared-skills/package.json +7 -1
  549. package/packages/shared-skills/skill-source-filter.d.ts +16 -0
  550. package/packages/shared-skills/skill-source-filter.mjs +44 -0
  551. package/packages/shared-skills/skills/ast-grep/AGENTS.md +51 -0
  552. package/packages/shared-skills/skills/ast-grep/SKILL.md +13 -1
  553. package/packages/shared-skills/skills/coding-agent-sessions/AGENTS.md +62 -0
  554. package/packages/shared-skills/skills/coding-agent-sessions/SKILL.md +1 -1
  555. package/packages/shared-skills/skills/data-scientist/SKILL.md +99 -239
  556. package/packages/shared-skills/skills/data-scientist/references/execution-surfaces.md +91 -0
  557. package/packages/shared-skills/skills/data-scientist/references/placement.md +74 -0
  558. package/packages/shared-skills/skills/data-scientist/references/polars-lane.md +95 -0
  559. package/packages/shared-skills/skills/data-scientist/references/uv-setup.md +1 -1
  560. package/packages/shared-skills/skills/data-scientist/references/visualization.md +64 -0
  561. package/packages/shared-skills/skills/data-scientist/scripts/ensure-js-deps.sh +28 -0
  562. package/packages/shared-skills/skills/data-scientist/scripts/ensure-py-deps.sh +37 -0
  563. package/packages/shared-skills/skills/debugging/SKILL.md +3 -1
  564. package/packages/shared-skills/skills/debugging/references/methodology/00-setup.md +12 -0
  565. package/packages/shared-skills/skills/debugging/references/methodology/02-investigate.md +21 -0
  566. package/packages/shared-skills/skills/debugging/references/runtimes/go.md +15 -1
  567. package/packages/shared-skills/skills/debugging/references/runtimes/native-binary.md +38 -0
  568. package/packages/shared-skills/skills/debugging/references/runtimes/node.md +25 -0
  569. package/packages/shared-skills/skills/debugging/references/runtimes/python.md +13 -0
  570. package/packages/shared-skills/skills/debugging/references/runtimes/rust.md +41 -0
  571. package/packages/shared-skills/skills/debugging/references/scripts/dap.mjs +267 -0
  572. package/packages/shared-skills/skills/debugging/references/scripts/dap.test.ts +86 -0
  573. package/packages/shared-skills/skills/debugging/references/scripts/fixture-adapter.mjs +59 -0
  574. package/packages/shared-skills/skills/debugging/references/tools/dap.md +103 -0
  575. package/packages/shared-skills/skills/debugging/references/tools/frida.md +193 -0
  576. package/packages/shared-skills/skills/debugging/references/tools/playwright-cli.md +79 -161
  577. package/packages/shared-skills/skills/frontend/ATTRIBUTION.md +10 -0
  578. package/packages/shared-skills/skills/frontend/SKILL.md +16 -9
  579. package/packages/shared-skills/skills/frontend/references/design/README.md +10 -2
  580. package/packages/shared-skills/skills/frontend/references/design/_INDEX.md +2 -0
  581. package/packages/shared-skills/skills/frontend/references/design/ambience-skill.md +145 -0
  582. package/packages/shared-skills/skills/frontend/references/design/aside.md +1 -1
  583. package/packages/shared-skills/skills/frontend/references/design/clone-from-url.md +1 -1
  584. package/packages/shared-skills/skills/frontend/references/design/interaction-skill.md +2 -0
  585. package/packages/shared-skills/skills/frontend/references/design/print-paged-media.md +76 -0
  586. package/packages/shared-skills/skills/frontend/references/design/stylegallery.md +80 -0
  587. package/packages/shared-skills/skills/frontend/references/designpowers/README.md +1 -1
  588. package/packages/shared-skills/skills/frontend/references/designpowers/lane-a-direction.md +1 -1
  589. package/packages/shared-skills/skills/frontend/references/designpowers/lane-b-execution.md +11 -11
  590. package/packages/shared-skills/skills/frontend/references/designpowers/lane-d-memory.md +3 -3
  591. package/packages/shared-skills/skills/frontend/references/designpowers/orchestration.md +1 -1
  592. package/packages/shared-skills/skills/frontend/references/designpowers/routing.md +5 -5
  593. package/packages/shared-skills/skills/frontend/scripts/perfection/lighthouse-audit.py +2 -2
  594. package/packages/shared-skills/skills/git-master/SKILL.md +1 -1
  595. package/packages/shared-skills/skills/init-deep/SKILL.md +14 -14
  596. package/packages/shared-skills/skills/lsp-setup/SKILL.md +1 -1
  597. package/packages/shared-skills/skills/programming/SKILL.md +1 -1
  598. package/packages/shared-skills/skills/refactor/SKILL.md +4 -4
  599. package/packages/shared-skills/skills/remove-ai-slops/SKILL.md +1 -1
  600. package/packages/shared-skills/skills/review-work/SKILL.md +101 -419
  601. package/packages/shared-skills/skills/ultimate-browsing/ATTRIBUTION.md +32 -86
  602. package/packages/shared-skills/skills/ultimate-browsing/SKILL.md +32 -27
  603. package/packages/shared-skills/skills/ultimate-browsing/engine/AGENTS.md +111 -0
  604. package/packages/shared-skills/skills/ultimate-browsing/engine/templates/package.json +2 -2
  605. package/packages/shared-skills/skills/ultimate-browsing/engine/templates/playwright_mobile_chrome.js +5 -2
  606. package/packages/shared-skills/skills/ultimate-browsing/engine/templates/playwright_real_chrome.js +8 -6
  607. package/packages/shared-skills/skills/ultimate-browsing/engine/tests/test_playwright_stealth.py +86 -0
  608. package/packages/shared-skills/skills/ultimate-browsing/engine/tests/test_playwright_templates.py +4 -7
  609. package/packages/shared-skills/skills/ultimate-browsing/references/chrome-stealth.md +86 -95
  610. package/packages/shared-skills/skills/ultimate-browsing/references/insane-search/README.md +18 -5
  611. package/packages/shared-skills/skills/ultimate-browsing/references/insane-search/playwright.md +16 -13
  612. package/packages/shared-skills/skills/ultimate-browsing/scripts/extract_cookies.py +3 -3
  613. package/packages/shared-skills/skills/{start-work → ulw-execute}/SKILL.md +21 -20
  614. package/packages/shared-skills/skills/ulw-plan/SKILL.md +7 -8
  615. package/packages/shared-skills/skills/ulw-plan/references/full-workflow.md +32 -7
  616. package/packages/shared-skills/skills/ulw-plan/references/intent-clear.md +2 -1
  617. package/packages/shared-skills/skills/ulw-plan/references/intent-unclear.md +5 -5
  618. package/packages/shared-skills/skills/ulw-plan/scripts/scaffold-plan.mjs +2 -1
  619. package/packages/shared-skills/skills/ulw-research/SKILL.md +8 -3
  620. package/packages/shared-skills/skills/visual-qa/AGENTS.md +58 -0
  621. package/packages/shared-skills/skills/visual-qa/SKILL.md +4 -3
  622. package/packages/shared-skills/skills/visual-qa/references/browser-setup.md +75 -0
  623. package/script/qa/web-terminal-visual-qa.mjs +2 -0
  624. package/script/qa/xterm-live-terminal.mjs +18 -2
  625. package/packages/lsp-tools-mcp/dist/lsp/cleanup-errors.d.ts +0 -1
  626. package/packages/lsp-tools-mcp/dist/lsp/constants.d.ts +0 -1
  627. package/packages/lsp-tools-mcp/dist/lsp/language-mappings.d.ts +0 -1
  628. package/packages/lsp-tools-mcp/dist/lsp/process-signal-cleanup.d.ts +0 -1
  629. package/packages/lsp-tools-mcp/dist/missing-dependency-result.d.ts +0 -1
  630. package/packages/omo-codex/plugin/components/codegraph/AGENTS.md +0 -58
  631. package/packages/omo-codex/plugin/components/codegraph/NODE-RUNTIME-LICENSES.md +0 -2951
  632. package/packages/omo-codex/plugin/components/codegraph/NOTICE +0 -16
  633. package/packages/omo-codex/plugin/components/codegraph/dist/cli.js +0 -12222
  634. package/packages/omo-codex/plugin/components/codegraph/dist/serve.js +0 -9820
  635. package/packages/omo-codex/plugin/components/codegraph/package.json +0 -33
  636. package/packages/omo-codex/plugin/components/codegraph/src/cache-gc.ts +0 -29
  637. package/packages/omo-codex/plugin/components/codegraph/src/cli.ts +0 -79
  638. package/packages/omo-codex/plugin/components/codegraph/src/hook-input.ts +0 -33
  639. package/packages/omo-codex/plugin/components/codegraph/src/hook-sweep.ts +0 -25
  640. package/packages/omo-codex/plugin/components/codegraph/src/hook-types.ts +0 -131
  641. package/packages/omo-codex/plugin/components/codegraph/src/hook.ts +0 -258
  642. package/packages/omo-codex/plugin/components/codegraph/src/mcp-bridge.ts +0 -309
  643. package/packages/omo-codex/plugin/components/codegraph/src/mcp-unavailable.ts +0 -80
  644. package/packages/omo-codex/plugin/components/codegraph/src/post-tool-use-hook.ts +0 -34
  645. package/packages/omo-codex/plugin/components/codegraph/src/serve-invocation.ts +0 -29
  646. package/packages/omo-codex/plugin/components/codegraph/src/serve.ts +0 -263
  647. package/packages/omo-codex/plugin/components/codegraph/src/session-start-command.ts +0 -106
  648. package/packages/omo-codex/plugin/components/codegraph/src/session-start-cooldown.ts +0 -145
  649. package/packages/omo-codex/plugin/components/codegraph/src/session-start-hook-runtime.ts +0 -21
  650. package/packages/omo-codex/plugin/components/codegraph/src/session-start-lock.ts +0 -139
  651. package/packages/omo-codex/plugin/components/codegraph/src/session-start-outcome.ts +0 -15
  652. package/packages/omo-codex/plugin/components/codegraph/src/session-start-paths.ts +0 -32
  653. package/packages/omo-codex/plugin/components/codegraph/src/session-start-project.ts +0 -109
  654. package/packages/omo-codex/plugin/components/codegraph/src/session-start-worker-result.ts +0 -148
  655. package/packages/omo-codex/plugin/components/codegraph/src/session-start-worker.ts +0 -175
  656. package/packages/omo-codex/plugin/components/codegraph/src/sweep-cli.ts +0 -81
  657. package/packages/omo-codex/plugin/components/codegraph/test/cache-gc.test.ts +0 -34
  658. package/packages/omo-codex/plugin/components/codegraph/test/hook-exclusion.test.ts +0 -112
  659. package/packages/omo-codex/plugin/components/codegraph/test/hook-registration.test.ts +0 -26
  660. package/packages/omo-codex/plugin/components/codegraph/test/hook-session-start-guard.test.ts +0 -160
  661. package/packages/omo-codex/plugin/components/codegraph/test/hook-store-upgrade.test.ts +0 -50
  662. package/packages/omo-codex/plugin/components/codegraph/test/hook-sweep.test.ts +0 -29
  663. package/packages/omo-codex/plugin/components/codegraph/test/hook.test.ts +0 -320
  664. package/packages/omo-codex/plugin/components/codegraph/test/mcp-bridge-fixtures.ts +0 -172
  665. package/packages/omo-codex/plugin/components/codegraph/test/package-runtime.test.ts +0 -91
  666. package/packages/omo-codex/plugin/components/codegraph/test/provisioned-node-guard.test.ts +0 -100
  667. package/packages/omo-codex/plugin/components/codegraph/test/serve-built-wrapper.test.ts +0 -76
  668. package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-bridge-lifecycle.test.ts +0 -133
  669. package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-bridge.test.ts +0 -245
  670. package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-facade.test.ts +0 -69
  671. package/packages/omo-codex/plugin/components/codegraph/test/serve-node-support.test.ts +0 -43
  672. package/packages/omo-codex/plugin/components/codegraph/test/serve-provision.test.ts +0 -147
  673. package/packages/omo-codex/plugin/components/codegraph/test/serve-unavailable.test.ts +0 -175
  674. package/packages/omo-codex/plugin/components/codegraph/test/serve.test.ts +0 -385
  675. package/packages/omo-codex/plugin/components/codegraph/test/session-start-node-support.test.ts +0 -206
  676. package/packages/omo-codex/plugin/components/codegraph/test/session-start-project.test.ts +0 -58
  677. package/packages/omo-codex/plugin/components/codegraph/test/session-start-state.test.ts +0 -104
  678. package/packages/omo-codex/plugin/components/codegraph/test/session-start-trust-boundary.test.ts +0 -65
  679. package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-availability.test.ts +0 -106
  680. package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-cooldown.test.ts +0 -116
  681. package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-flow.test.ts +0 -258
  682. package/packages/omo-codex/plugin/components/codegraph/test/sweep-cli.test.ts +0 -56
  683. package/packages/omo-codex/plugin/components/codegraph/tsconfig.build.json +0 -13
  684. package/packages/omo-codex/plugin/components/codegraph/tsconfig.json +0 -25
  685. package/packages/omo-codex/plugin/components/start-work-continuation/LICENSE +0 -21
  686. package/packages/omo-codex/plugin/components/start-work-continuation/hooks/hooks.json +0 -28
  687. package/packages/omo-codex/plugin/components/ultrawork/directive.md +0 -477
  688. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-codegraph-init-guidance.json +0 -18
  689. package/packages/omo-codex/plugin/hooks/session-start-checking-codegraph-bootstrap.json +0 -17
  690. package/packages/omo-codex/plugin/hooks/stop-checking-start-work-continuation.json +0 -17
  691. package/packages/omo-codex/plugin/hooks/subagent-stop-checking-start-work-continuation.json +0 -17
  692. package/packages/omo-codex/plugin/scripts/migrate-omo-sot/editor.mjs +0 -125
  693. package/packages/omo-codex/plugin/scripts/migrate-omo-sot/jsonc.mjs +0 -43
  694. package/packages/omo-codex/plugin/scripts/migrate-omo-sot/scaffold.mjs +0 -29
  695. package/packages/omo-codex/plugin/scripts/migrate-omo-sot.mjs +0 -121
  696. package/packages/omo-codex/plugin/skills/data-scientist/references/common-scenarios.md +0 -176
  697. package/packages/omo-codex/plugin/skills/data-scientist/references/execution-templates.md +0 -197
  698. package/packages/omo-codex/plugin/skills/data-scientist/references/integration-patterns.md +0 -153
  699. package/packages/omo-codex/plugin/skills/data-scientist/references/performance-benchmarks.md +0 -37
  700. package/packages/omo-codex/plugin/skills/start-work/agents/openai.yaml +0 -2
  701. package/packages/omo-codex/plugin/skills/visual-qa/references/agent-browser-setup.md +0 -45
  702. package/packages/omo-codex/plugin/test/aggregate-skills.test.mjs +0 -92
  703. package/packages/omo-codex/plugin/test/component-codegraph-mcp-smoke.test.mjs +0 -76
  704. package/packages/omo-codex/plugin/test/migrate-omo-sot.test.mjs +0 -179
  705. package/packages/omo-codex/plugin/test/sync-skills-orchestration.test.mjs +0 -314
  706. package/packages/omo-codex/plugin/test/ulw-plan-scope-contract.test.mjs +0 -24
  707. package/packages/shared-skills/skills/data-scientist/references/common-scenarios.md +0 -176
  708. package/packages/shared-skills/skills/data-scientist/references/execution-templates.md +0 -197
  709. package/packages/shared-skills/skills/data-scientist/references/integration-patterns.md +0 -153
  710. package/packages/shared-skills/skills/data-scientist/references/performance-benchmarks.md +0 -37
  711. package/packages/shared-skills/skills/visual-qa/references/agent-browser-setup.md +0 -45
  712. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/.gitattributes +0 -0
  713. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/CHANGELOG.md +0 -0
  714. /package/packages/omo-codex/plugin/components/{codegraph → ulw-execute-continuation}/LICENSE +0 -0
  715. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/plan-checklist.ts +0 -0
  716. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/boulder-completed.json +0 -0
  717. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/boulder-mixed-platforms.json +0 -0
  718. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/boulder-single-codex-work.json +0 -0
  719. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/plan-all-done.md +0 -0
  720. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/plan-scaffold.md +0 -0
  721. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/plan-with-nested-checkboxes.md +0 -0
  722. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/plan-with-unchecked.md +0 -0
  723. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/tsconfig.build.json +0 -0
  724. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/tsconfig.json +0 -0
  725. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/vitest.config.ts +0 -0
@@ -1,18 +1,4 @@
1
1
  #!/usr/bin/env node
2
- var __defProp = Object.defineProperty;
3
- var __returnValue = (v) => v;
4
- function __exportSetter(name, newValue) {
5
- this[name] = __returnValue.bind(null, newValue);
6
- }
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, {
10
- get: all[name],
11
- enumerable: true,
12
- configurable: true,
13
- set: __exportSetter.bind(all, name)
14
- });
15
- };
16
2
 
17
3
  // components/telemetry/src/cli.ts
18
4
  import { stdin as processStdin, stdout as processStdout } from "node:process";
@@ -27,9 +13,12 @@ import {
27
13
  fsyncSync,
28
14
  openSync,
29
15
  renameSync,
16
+ rmSync,
30
17
  unlinkSync,
31
18
  writeFileSync
32
19
  } from "node:fs";
20
+ import { randomUUID } from "node:crypto";
21
+ import { dirname } from "node:path";
33
22
  var TOLERATED_FSYNC_CODES = new Set([
34
23
  "EPERM",
35
24
  "EACCES",
@@ -51,24 +40,36 @@ function tolerantFsyncSync(fileDescriptor, fsyncImpl) {
51
40
  }
52
41
  }
53
42
  function writeFileAtomically(filePath, content, options = {}) {
54
- const tempPath = `${filePath}.tmp`;
55
- writeFileSync(tempPath, content, "utf-8");
56
- const tempFileDescriptor = openSync(tempPath, "r+");
57
- try {
58
- tolerantFsyncSync(tempFileDescriptor, options.fsyncSync ?? fsyncSync);
59
- } finally {
60
- closeSync(tempFileDescriptor);
61
- }
43
+ const platform = options.platform ?? process.platform;
44
+ const fsyncImpl = options.fsyncSync ?? fsyncSync;
45
+ const tempPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
62
46
  try {
63
- renameSync(tempPath, filePath);
64
- } catch (error) {
65
- const isPermissionError = error instanceof Error && (error.message.includes("EPERM") || error.message.includes("EACCES"));
66
- if ((options.platform ?? process.platform) === "win32" && isPermissionError) {
47
+ writeFileSync(tempPath, content, "utf-8");
48
+ const tempFileDescriptor = openSync(tempPath, "r+");
49
+ try {
50
+ tolerantFsyncSync(tempFileDescriptor, fsyncImpl);
51
+ } finally {
52
+ closeSync(tempFileDescriptor);
53
+ }
54
+ try {
55
+ renameSync(tempPath, filePath);
56
+ } catch (error) {
57
+ const isPermissionError = error instanceof Error && (error.message.includes("EPERM") || error.message.includes("EACCES"));
58
+ if (platform !== "win32" || !isPermissionError)
59
+ throw error;
67
60
  unlinkSync(filePath);
68
61
  renameSync(tempPath, filePath);
62
+ }
63
+ if (platform === "win32")
69
64
  return;
65
+ const directoryFileDescriptor = openSync(dirname(filePath), "r");
66
+ try {
67
+ tolerantFsyncSync(directoryFileDescriptor, fsyncImpl);
68
+ } finally {
69
+ closeSync(directoryFileDescriptor);
70
70
  }
71
- throw error;
71
+ } finally {
72
+ rmSync(tempPath, { force: true });
72
73
  }
73
74
  }
74
75
 
@@ -338,8 +339,8 @@ function getTelemetryHost(env = process.env, defaultHost = DEFAULT_POSTHOG_HOST)
338
339
  return env["POSTHOG_HOST"]?.trim() || defaultHost;
339
340
  }
340
341
 
341
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
342
- import { dirname, posix, sep } from "node:path";
342
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
343
+ import { dirname as dirname2, posix, sep } from "node:path";
343
344
  function createModulerModifier() {
344
345
  const getModuleFromFileName = createGetModuleFromFilename();
345
346
  return async (frames) => {
@@ -348,7 +349,7 @@ function createModulerModifier() {
348
349
  return frames;
349
350
  };
350
351
  }
351
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname(process.argv[1]) : process.cwd(), isWindows = sep === "\\") {
352
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname2(process.argv[1]) : process.cwd(), isWindows = sep === "\\") {
352
353
  const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
353
354
  return (filename) => {
354
355
  if (!filename)
@@ -370,11 +371,11 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname(proces
370
371
  return decodedFile;
371
372
  };
372
373
  }
373
- function normalizeWindowsPath(path2) {
374
- return path2.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
374
+ function normalizeWindowsPath(path) {
375
+ return path.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
375
376
  }
376
377
 
377
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/featureFlagUtils.mjs
378
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/featureFlagUtils.mjs
378
379
  var normalizeFlagsResponse = (flagsResponse) => {
379
380
  if ("flags" in flagsResponse) {
380
381
  const featureFlags = getFlagValuesFromFlags(flagsResponse.flags);
@@ -444,8 +445,69 @@ var parsePayload = (response) => {
444
445
  return response;
445
446
  }
446
447
  };
448
+ var MINIMAL_FLAG_CALLED_EVENT_CAMPAIGN_PROPERTIES = [
449
+ "utm_source",
450
+ "utm_medium",
451
+ "utm_campaign",
452
+ "utm_content",
453
+ "utm_term",
454
+ "gad_source",
455
+ "mc_cid",
456
+ "gclid",
457
+ "gclsrc",
458
+ "dclid",
459
+ "gbraid",
460
+ "wbraid",
461
+ "fbclid",
462
+ "msclkid",
463
+ "twclid",
464
+ "li_fat_id",
465
+ "igshid",
466
+ "ttclid",
467
+ "rdt_cid",
468
+ "epik",
469
+ "qclid",
470
+ "sccid",
471
+ "irclid",
472
+ "_kx"
473
+ ];
474
+ var MINIMAL_FLAG_CALLED_EVENT_PROPERTIES = [
475
+ "$feature_flag",
476
+ "$feature_flag_response",
477
+ "$feature_flag_has_experiment",
478
+ "$feature_flag_id",
479
+ "$feature_flag_version",
480
+ "$feature_flag_reason",
481
+ "$feature_flag_request_id",
482
+ "$feature_flag_evaluated_at",
483
+ "$feature_flag_error",
484
+ "locally_evaluated",
485
+ "$groups",
486
+ "$process_person_profile",
487
+ "$geoip_disable",
488
+ "$current_url",
489
+ "$pathname",
490
+ "$referring_domain",
491
+ ...MINIMAL_FLAG_CALLED_EVENT_CAMPAIGN_PROPERTIES,
492
+ "$session_id",
493
+ "$window_id",
494
+ "$lib",
495
+ "$lib_version",
496
+ "$device_id",
497
+ "$is_server"
498
+ ];
499
+ var minimizeFlagCalledEventProperties = (properties, transportKeys = []) => {
500
+ const minimal = {};
501
+ const copyKey = (key) => {
502
+ if (properties[key] !== undefined)
503
+ minimal[key] = properties[key];
504
+ };
505
+ MINIMAL_FLAG_CALLED_EVENT_PROPERTIES.forEach(copyKey);
506
+ transportKeys.forEach(copyKey);
507
+ return minimal;
508
+ };
447
509
 
448
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/types.mjs
510
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/types.mjs
449
511
  var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedProperty) {
450
512
  PostHogPersistedProperty["AnonymousId"] = "anonymous_id";
451
513
  PostHogPersistedProperty["DistinctId"] = "distinct_id";
@@ -460,6 +522,8 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
460
522
  PostHogPersistedProperty["BootstrapFeatureFlagPayloads"] = "bootstrap_feature_flag_payloads";
461
523
  PostHogPersistedProperty["OverrideFeatureFlags"] = "override_feature_flags";
462
524
  PostHogPersistedProperty["Queue"] = "queue";
525
+ PostHogPersistedProperty["AiQueue"] = "ai_queue";
526
+ PostHogPersistedProperty["AiCaptureQueue"] = "ai_capture_queue";
463
527
  PostHogPersistedProperty["LogsQueue"] = "logs_queue";
464
528
  PostHogPersistedProperty["OptedOut"] = "opted_out";
465
529
  PostHogPersistedProperty["SessionId"] = "session_id";
@@ -470,6 +534,8 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
470
534
  PostHogPersistedProperty["InstalledAppBuild"] = "installed_app_build";
471
535
  PostHogPersistedProperty["InstalledAppVersion"] = "installed_app_version";
472
536
  PostHogPersistedProperty["SessionReplay"] = "session_replay";
537
+ PostHogPersistedProperty["PushRegistered"] = "push_registered";
538
+ PostHogPersistedProperty["SessionReplayEventTriggerActivatedSession"] = "session_replay_event_trigger_activated_session";
473
539
  PostHogPersistedProperty["SurveyLastSeenDate"] = "survey_last_seen_date";
474
540
  PostHogPersistedProperty["SurveysSeen"] = "surveys_seen";
475
541
  PostHogPersistedProperty["Surveys"] = "surveys";
@@ -479,7 +545,7 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
479
545
  return PostHogPersistedProperty;
480
546
  }({});
481
547
 
482
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/gzip.mjs
548
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/gzip.mjs
483
549
  function isGzipSupported() {
484
550
  return "CompressionStream" in globalThis && "TextEncoder" in globalThis && "Response" in globalThis && typeof Response.prototype.blob == "function";
485
551
  }
@@ -529,7 +595,7 @@ var validateNativeGzip = async (compressed, inputBytes) => {
529
595
  async function gzipCompress(input, isDebug = true, options) {
530
596
  try {
531
597
  const inputBytes = new TextEncoder().encode(input);
532
- const compressedStream = new CompressionStream("gzip");
598
+ const compressedStream = new globalThis.CompressionStream("gzip");
533
599
  const writer = compressedStream.writable.getWriter();
534
600
  const writePromise = writer.write(inputBytes).then(() => writer.close()).catch(async (err) => {
535
601
  try {
@@ -553,7 +619,34 @@ async function gzipCompress(input, isDebug = true, options) {
553
619
  }
554
620
  }
555
621
 
556
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/bot-detection.mjs
622
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/json-utils.mjs
623
+ var MAX_JSON_SAFE_VALUE_DEPTH = 20;
624
+ var MAX_JSON_SAFE_VALUE_ITEMS = 1000;
625
+ var MAX_JSON_SAFE_VALUE_NODES = 1e4;
626
+ var CIRCULAR_VALUE = "[Circular]";
627
+ var TRUNCATED_VALUE = "[Truncated]";
628
+ var UNSERIALIZABLE_VALUE = "[Unserializable]";
629
+ var FUNCTION_VALUE = "[Function]";
630
+ var dateGetTime = Date.prototype.getTime;
631
+ var dateToISOString = Date.prototype.toISOString;
632
+ function sanitizeString(value) {
633
+ let output = "";
634
+ for (let index = 0;index < value.length; index++) {
635
+ const codeUnit = value.charCodeAt(index);
636
+ if (codeUnit >= 55296 && codeUnit <= 56319) {
637
+ const nextCodeUnit = value.charCodeAt(index + 1);
638
+ if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
639
+ output += value[index] + value[index + 1];
640
+ index++;
641
+ } else
642
+ output += "�";
643
+ } else
644
+ output += codeUnit >= 56320 && codeUnit <= 57343 ? "�" : value[index];
645
+ }
646
+ return output;
647
+ }
648
+
649
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/bot-detection.mjs
557
650
  var DEFAULT_BLOCKED_UA_STRS = [
558
651
  "amazonbot",
559
652
  "amazonproductbot",
@@ -642,7 +735,31 @@ var isBlockedUA = function(ua, customBlockedUserAgents = []) {
642
735
  return uaLower.indexOf(blockedUaLower) !== -1;
643
736
  });
644
737
  };
645
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/type-utils.mjs
738
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/string-utils.mjs
739
+ function safeJsonStringify(value) {
740
+ const ancestors = [];
741
+ return JSON.stringify(value, function(_key, replacementValue) {
742
+ if (typeof replacementValue == "bigint")
743
+ return replacementValue.toString();
744
+ if (typeof replacementValue == "function" || typeof replacementValue == "symbol")
745
+ return;
746
+ if (replacementValue instanceof Error)
747
+ return {
748
+ name: replacementValue.name,
749
+ message: replacementValue.message,
750
+ stack: replacementValue.stack
751
+ };
752
+ if (replacementValue && typeof replacementValue == "object") {
753
+ while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this)
754
+ ancestors.pop();
755
+ if (ancestors.includes(replacementValue))
756
+ return "[Circular]";
757
+ ancestors.push(replacementValue);
758
+ }
759
+ return replacementValue;
760
+ }) ?? "null";
761
+ }
762
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/type-utils.mjs
646
763
  var nativeIsArray = Array.isArray;
647
764
  var ObjProto = Object.prototype;
648
765
  var type_utils_hasOwnProperty = ObjProto.hasOwnProperty;
@@ -654,16 +771,27 @@ var isObject = (x) => x === Object(x) && !isArray(x);
654
771
  var isUndefined = (x) => x === undefined;
655
772
  var isString = (x) => type_utils_toString.call(x) == "[object String]";
656
773
  var isEmptyString = (x) => isString(x) && x.trim().length === 0;
774
+ var isNull = (x) => x === null;
775
+ var isNullish = (x) => isUndefined(x) || isNull(x);
657
776
  var isNumber = (x) => type_utils_toString.call(x) == "[object Number]" && x === x;
658
- var isPlainError = (x) => x instanceof Error;
777
+ var isBoolean = (x) => type_utils_toString.call(x) === "[object Boolean]";
659
778
  function isPrimitive(value) {
660
779
  return value === null || typeof value != "object";
661
780
  }
662
781
  function isBuiltin(candidate, className) {
663
782
  return Object.prototype.toString.call(candidate) === `[object ${className}]`;
664
783
  }
665
- function isErrorEvent(event) {
666
- return isBuiltin(event, "ErrorEvent");
784
+ function isError(candidate) {
785
+ switch (Object.prototype.toString.call(candidate)) {
786
+ case "[object Error]":
787
+ case "[object Exception]":
788
+ case "[object DOMException]":
789
+ case "[object DOMError]":
790
+ case "[object WebAssembly.Exception]":
791
+ return true;
792
+ default:
793
+ return isInstanceOf(candidate, Error);
794
+ }
667
795
  }
668
796
  function isEvent(candidate) {
669
797
  return typeof Event != "undefined" && isInstanceOf(candidate, Event);
@@ -679,7 +807,7 @@ function isInstanceOf(candidate, base) {
679
807
  }
680
808
  }
681
809
 
682
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/number-utils.mjs
810
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/number-utils.mjs
683
811
  function clampToRange(value, min, max, logger, fallbackValue) {
684
812
  if (min > max) {
685
813
  logger.warn("min cannot be greater than max.");
@@ -699,8 +827,16 @@ function clampToRange(value, min, max, logger, fallbackValue) {
699
827
  return clampToRange(fallbackValue || max, min, max, logger);
700
828
  }
701
829
 
702
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
830
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
703
831
  var ONE_DAY_IN_MS = 86400000;
832
+ var DEFAULT_EXCEPTION_RATE_LIMITER_REFILL_RATE = 1;
833
+ var DEFAULT_EXCEPTION_RATE_LIMITER_BUCKET_SIZE = 10;
834
+ function resolveExceptionRateLimiterConfig(config = {}) {
835
+ return {
836
+ refillRate: config.exceptionRateLimiterRefillRate ?? config.__exceptionRateLimiterRefillRate ?? DEFAULT_EXCEPTION_RATE_LIMITER_REFILL_RATE,
837
+ bucketSize: config.exceptionRateLimiterBucketSize ?? config.__exceptionRateLimiterBucketSize ?? DEFAULT_EXCEPTION_RATE_LIMITER_BUCKET_SIZE
838
+ };
839
+ }
704
840
 
705
841
  class BucketedRateLimiter {
706
842
  constructor(options) {
@@ -743,7 +879,7 @@ class BucketedRateLimiter {
743
879
  this._buckets = {};
744
880
  }
745
881
  }
746
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
882
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
747
883
  /*! For license information please see uuidv7.mjs.LICENSE.txt */
748
884
  var DIGITS = "0123456789abcdef";
749
885
 
@@ -921,33 +1057,45 @@ var defaultGenerator;
921
1057
  var uuidv7 = () => uuidv7obj().toString();
922
1058
  var uuidv7obj = () => (defaultGenerator || (defaultGenerator = new V7Generator)).generate();
923
1059
 
924
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/promise-queue.mjs
1060
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/promise-queue.mjs
925
1061
  class PromiseQueue {
926
1062
  add(promise) {
927
1063
  const promiseUUID = uuidv7();
928
- this.promiseByIds[promiseUUID] = promise;
1064
+ const id = ++this.nextId;
1065
+ this.promiseByIds[promiseUUID] = {
1066
+ id,
1067
+ promise
1068
+ };
929
1069
  promise.catch(() => {}).finally(() => {
930
1070
  delete this.promiseByIds[promiseUUID];
931
1071
  });
932
1072
  return promise;
933
1073
  }
934
1074
  async join() {
935
- let promises = Object.values(this.promiseByIds);
1075
+ let promises = Object.values(this.promiseByIds).map((item) => item.promise);
936
1076
  let length = promises.length;
937
1077
  while (length > 0) {
938
1078
  await Promise.all(promises);
939
- promises = Object.values(this.promiseByIds);
1079
+ promises = Object.values(this.promiseByIds).map((item) => item.promise);
940
1080
  length = promises.length;
941
1081
  }
942
1082
  }
1083
+ getPromises(ignoredPromises = [], maxId = this.nextId) {
1084
+ const ignoredPromiseSet = new Set(ignoredPromises);
1085
+ return Object.values(this.promiseByIds).filter((item) => item.id <= maxId && !ignoredPromiseSet.has(item.promise)).map((item) => item.promise);
1086
+ }
1087
+ get maxId() {
1088
+ return this.nextId;
1089
+ }
943
1090
  get length() {
944
1091
  return Object.keys(this.promiseByIds).length;
945
1092
  }
946
1093
  constructor() {
947
1094
  this.promiseByIds = {};
1095
+ this.nextId = 0;
948
1096
  }
949
1097
  }
950
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/logger.mjs
1098
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/logger.mjs
951
1099
  function createConsole(consoleLike = console) {
952
1100
  const lockedMethods = {
953
1101
  log: consoleLike.log.bind(consoleLike),
@@ -988,7 +1136,7 @@ var passThrough = (fn) => fn();
988
1136
  function createLogger(prefix, maybeCall = passThrough) {
989
1137
  return _createLogger(prefix, maybeCall, createConsole());
990
1138
  }
991
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
1139
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
992
1140
  var MOBILE = "Mobile";
993
1141
  var IOS = "iOS";
994
1142
  var ANDROID = "Android";
@@ -1031,6 +1179,7 @@ var DUCKDUCKGO = "DuckDuckGo";
1031
1179
  var PALE_MOON = "Pale Moon";
1032
1180
  var WATERFOX = "Waterfox";
1033
1181
  var BRAVE = "Brave";
1182
+ var GOOGLE_SEARCH_APP = "Google Search App";
1034
1183
  var BROWSER_VERSION_REGEX_SUFFIX = "(\\d+(\\.\\d+)?)";
1035
1184
  var DEFAULT_BROWSER_VERSION_REGEX = new RegExp("Version/" + BROWSER_VERSION_REGEX_SUFFIX);
1036
1185
  var XBOX_REGEX = new RegExp(XBOX, "i");
@@ -1118,6 +1267,9 @@ var versionRegexes = {
1118
1267
  [WATERFOX]: [
1119
1268
  new RegExp(WATERFOX + "\\/" + BROWSER_VERSION_REGEX_SUFFIX)
1120
1269
  ],
1270
+ [GOOGLE_SEARCH_APP]: [
1271
+ new RegExp("GSA\\/" + BROWSER_VERSION_REGEX_SUFFIX)
1272
+ ],
1121
1273
  [INTERNET_EXPLORER]: [
1122
1274
  new RegExp("(rv:|MSIE )" + BROWSER_VERSION_REGEX_SUFFIX)
1123
1275
  ],
@@ -1277,8 +1429,15 @@ var osMatchers = [
1277
1429
  ]
1278
1430
  ];
1279
1431
 
1280
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/index.mjs
1432
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/index.mjs
1281
1433
  var STRING_FORMAT = "utf8";
1434
+ var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1435
+ function isValidUUID(value) {
1436
+ return typeof value == "string" && UUID_REGEX.test(value);
1437
+ }
1438
+ function getEventUuid(uuid, generateUuid) {
1439
+ return isValidUUID(uuid) ? uuid : generateUuid();
1440
+ }
1282
1441
  function removeTrailingSlash(url) {
1283
1442
  return url?.replace(/\/+$/, "");
1284
1443
  }
@@ -1306,7 +1465,26 @@ function safeSetTimeout(fn, timeout) {
1306
1465
  t?.unref && t?.unref();
1307
1466
  return t;
1308
1467
  }
1309
- var isError = (x) => x instanceof Error;
1468
+ async function raceWithTimeout(promise, timeoutMs, onTimeout) {
1469
+ let timeoutHandle;
1470
+ try {
1471
+ return await Promise.race([
1472
+ promise,
1473
+ new Promise((resolve, reject) => {
1474
+ timeoutHandle = safeSetTimeout(() => {
1475
+ try {
1476
+ onTimeout?.();
1477
+ resolve();
1478
+ } catch (error) {
1479
+ reject(error);
1480
+ }
1481
+ }, timeoutMs);
1482
+ })
1483
+ ]);
1484
+ } finally {
1485
+ clearTimeout(timeoutHandle);
1486
+ }
1487
+ }
1310
1488
  function allSettled(promises) {
1311
1489
  return Promise.all(promises.map((p) => (p ?? Promise.resolve()).then((value) => ({
1312
1490
  status: "fulfilled",
@@ -1317,7 +1495,7 @@ function allSettled(promises) {
1317
1495
  }))));
1318
1496
  }
1319
1497
 
1320
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/logs/logs-utils.mjs
1498
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/logs/logs-utils.mjs
1321
1499
  var OTLP_SEVERITY_MAP = {
1322
1500
  trace: {
1323
1501
  text: "TRACE",
@@ -1345,7 +1523,570 @@ var OTLP_SEVERITY_MAP = {
1345
1523
  }
1346
1524
  };
1347
1525
  var DEFAULT_OTLP_SEVERITY = OTLP_SEVERITY_MAP.info;
1348
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/eventemitter.mjs
1526
+ var INT64_RANGE_LIMIT = 9223372036854776000;
1527
+ var propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
1528
+ function newState() {
1529
+ return {
1530
+ ancestors: new WeakSet,
1531
+ remainingNodes: MAX_JSON_SAFE_VALUE_NODES
1532
+ };
1533
+ }
1534
+ function toOtlpKeyValueList(attrs, logger) {
1535
+ try {
1536
+ return encodeKeyValueList(attrs, logger, newState(), 0);
1537
+ } catch {
1538
+ return [];
1539
+ }
1540
+ }
1541
+ function encodeAnyValue(value, logger, state, depth) {
1542
+ if (state.remainingNodes <= 0)
1543
+ return {
1544
+ stringValue: TRUNCATED_VALUE
1545
+ };
1546
+ state.remainingNodes--;
1547
+ if (isBoolean(value))
1548
+ return {
1549
+ boolValue: value
1550
+ };
1551
+ if (typeof value == "number") {
1552
+ if (!Number.isFinite(value))
1553
+ return {
1554
+ stringValue: String(value)
1555
+ };
1556
+ if (Number.isInteger(value)) {
1557
+ if (Number.isSafeInteger(value))
1558
+ return {
1559
+ intValue: String(value)
1560
+ };
1561
+ if (typeof BigInt == "undefined")
1562
+ return {
1563
+ stringValue: String(value)
1564
+ };
1565
+ const decimal = BigInt(value).toString();
1566
+ if (value >= INT64_RANGE_LIMIT || value < -INT64_RANGE_LIMIT) {
1567
+ logger?.debug(`Attribute ${decimal} is outside the int64 range; encoding it as a string`);
1568
+ return {
1569
+ stringValue: decimal
1570
+ };
1571
+ }
1572
+ return {
1573
+ intValue: decimal
1574
+ };
1575
+ }
1576
+ return {
1577
+ doubleValue: value
1578
+ };
1579
+ }
1580
+ if (typeof value == "string")
1581
+ return {
1582
+ stringValue: sanitizeString(value)
1583
+ };
1584
+ if (typeof value == "function")
1585
+ return {
1586
+ stringValue: FUNCTION_VALUE
1587
+ };
1588
+ if (typeof value == "symbol")
1589
+ return {
1590
+ stringValue: String(value)
1591
+ };
1592
+ if (typeof value == "object" && value !== null) {
1593
+ if (state.ancestors.has(value))
1594
+ return {
1595
+ stringValue: CIRCULAR_VALUE
1596
+ };
1597
+ if (depth >= MAX_JSON_SAFE_VALUE_DEPTH)
1598
+ return {
1599
+ stringValue: TRUNCATED_VALUE
1600
+ };
1601
+ if (value instanceof Date) {
1602
+ const time = value.getTime();
1603
+ const iso = Number.isFinite(time) ? value.toISOString() : String(value);
1604
+ return {
1605
+ stringValue: typeof iso == "string" ? sanitizeString(iso) : String(iso)
1606
+ };
1607
+ }
1608
+ state.ancestors.add(value);
1609
+ try {
1610
+ try {
1611
+ const toJSON = value.toJSON;
1612
+ if (typeof toJSON == "function")
1613
+ return encodeAnyValue(toJSON.call(value), logger, state, depth + 1);
1614
+ } catch {}
1615
+ if (isArray(value))
1616
+ return {
1617
+ arrayValue: {
1618
+ values: encodeArrayValues(value, logger, state, depth + 1)
1619
+ }
1620
+ };
1621
+ return {
1622
+ kvlistValue: {
1623
+ values: encodeKeyValueList(value, logger, state, depth + 1)
1624
+ }
1625
+ };
1626
+ } finally {
1627
+ state.ancestors.delete(value);
1628
+ }
1629
+ }
1630
+ return {
1631
+ stringValue: sanitizeString(String(value))
1632
+ };
1633
+ }
1634
+ function encodeArrayValues(values, logger, state, depth) {
1635
+ const result = [];
1636
+ const itemCount = Math.min(values.length, MAX_JSON_SAFE_VALUE_ITEMS);
1637
+ let index = 0;
1638
+ for (;index < itemCount && state.remainingNodes > 0; index++)
1639
+ try {
1640
+ const element = index in values ? values[index] : undefined;
1641
+ if (isNullish(element))
1642
+ continue;
1643
+ result.push(encodeAnyValue(element, logger, state, depth));
1644
+ } catch {
1645
+ result.push({
1646
+ stringValue: UNSERIALIZABLE_VALUE
1647
+ });
1648
+ }
1649
+ if (values.length > index)
1650
+ result.push({
1651
+ stringValue: TRUNCATED_VALUE
1652
+ });
1653
+ return result;
1654
+ }
1655
+ function encodeKeyValueList(attrs, logger, state, depth) {
1656
+ const result = [];
1657
+ for (const key in attrs)
1658
+ if (propertyIsEnumerable.call(attrs, key)) {
1659
+ if (result.length >= MAX_JSON_SAFE_VALUE_ITEMS || state.remainingNodes <= 0) {
1660
+ logger?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");
1661
+ break;
1662
+ }
1663
+ try {
1664
+ const value = attrs[key];
1665
+ if (isNull(value) || isUndefined(value))
1666
+ continue;
1667
+ result.push({
1668
+ key: sanitizeString(key),
1669
+ value: encodeAnyValue(value, logger, state, depth)
1670
+ });
1671
+ } catch {
1672
+ result.push({
1673
+ key: sanitizeString(key),
1674
+ value: {
1675
+ stringValue: UNSERIALIZABLE_VALUE
1676
+ }
1677
+ });
1678
+ }
1679
+ }
1680
+ return result;
1681
+ }
1682
+
1683
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/metrics-utils.mjs
1684
+ var DEFAULT_HISTOGRAM_BOUNDS = [
1685
+ 0,
1686
+ 5,
1687
+ 10,
1688
+ 25,
1689
+ 50,
1690
+ 75,
1691
+ 100,
1692
+ 250,
1693
+ 500,
1694
+ 750,
1695
+ 1000,
1696
+ 2500,
1697
+ 5000,
1698
+ 7500,
1699
+ 1e4
1700
+ ];
1701
+ function msToUnixNano(ms) {
1702
+ return String(ms) + "000000";
1703
+ }
1704
+ function seriesKey(type, name, unit, attributes) {
1705
+ let attrsKey = "";
1706
+ if (attributes) {
1707
+ const keys = Object.keys(attributes).sort();
1708
+ attrsKey = keys.map((k) => `${JSON.stringify(k)}:${JSON.stringify(attributes[k])}`).join(",");
1709
+ }
1710
+ return `${type}\x00${name}\x00${unit ?? ""}\x00${attrsKey}`;
1711
+ }
1712
+ function bucketIndexFor(value, bounds) {
1713
+ for (let i = 0;i < bounds.length; i++)
1714
+ if (value <= bounds[i])
1715
+ return i;
1716
+ return bounds.length;
1717
+ }
1718
+ function buildMetricsResourceAttributes(config, scopeName, scopeVersion) {
1719
+ return {
1720
+ ...config.resourceAttributes,
1721
+ "service.name": config.serviceName || "unknown_service",
1722
+ ...config.environment && {
1723
+ "deployment.environment": config.environment
1724
+ },
1725
+ ...config.serviceVersion && {
1726
+ "service.version": config.serviceVersion
1727
+ },
1728
+ "telemetry.sdk.name": scopeName,
1729
+ "telemetry.sdk.version": scopeVersion
1730
+ };
1731
+ }
1732
+ function buildOtlpMetricsPayload(metrics, resourceAttributes, scopeName, scopeVersion) {
1733
+ return {
1734
+ resourceMetrics: [
1735
+ {
1736
+ resource: {
1737
+ attributes: toOtlpKeyValueList(resourceAttributes)
1738
+ },
1739
+ scopeMetrics: [
1740
+ {
1741
+ scope: {
1742
+ name: scopeName,
1743
+ version: scopeVersion
1744
+ },
1745
+ metrics
1746
+ }
1747
+ ]
1748
+ }
1749
+ ]
1750
+ };
1751
+ }
1752
+
1753
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/config.mjs
1754
+ var DEFAULT_FLUSH_INTERVAL_MS = 1e4;
1755
+ var DEFAULT_MAX_SERIES_PER_FLUSH = 1000;
1756
+ function resolveMetricsConfig(config) {
1757
+ const resourceAttributes = config?.resourceAttributes;
1758
+ return {
1759
+ serviceName: resourceAttributes?.["service.name"] ?? config?.serviceName,
1760
+ serviceVersion: resourceAttributes?.["service.version"] ?? config?.serviceVersion,
1761
+ environment: resourceAttributes?.["deployment.environment"] ?? config?.environment,
1762
+ resourceAttributes,
1763
+ beforeSend: config?.beforeSend,
1764
+ flushIntervalMs: config?.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS,
1765
+ maxSeriesPerFlush: config?.maxSeriesPerFlush ?? DEFAULT_MAX_SERIES_PER_FLUSH
1766
+ };
1767
+ }
1768
+
1769
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/index.mjs
1770
+ var OTLP_TEMPORALITY_DELTA = 1;
1771
+
1772
+ class PostHogMetrics {
1773
+ constructor(_instance, _config, _logger) {
1774
+ this._instance = _instance;
1775
+ this._config = _config;
1776
+ this._logger = _logger;
1777
+ this._series = new Map;
1778
+ this._flushPromise = null;
1779
+ this._seriesCapWarned = false;
1780
+ this._typeByName = new Map;
1781
+ this._typeCollisionWarned = new Set;
1782
+ this._generation = 0;
1783
+ }
1784
+ count(name, value = 1, options) {
1785
+ this._capture({
1786
+ name,
1787
+ type: "count",
1788
+ value,
1789
+ unit: options?.unit,
1790
+ attributes: options?.attributes
1791
+ });
1792
+ }
1793
+ gauge(name, value, options) {
1794
+ this._capture({
1795
+ name,
1796
+ type: "gauge",
1797
+ value,
1798
+ unit: options?.unit,
1799
+ attributes: options?.attributes
1800
+ });
1801
+ }
1802
+ histogram(name, value, options) {
1803
+ this._capture({
1804
+ name,
1805
+ type: "histogram",
1806
+ value,
1807
+ unit: options?.unit,
1808
+ attributes: options?.attributes
1809
+ });
1810
+ }
1811
+ flush() {
1812
+ const prev = this._flushPromise;
1813
+ const run = async () => {
1814
+ if (prev)
1815
+ await prev.catch(() => {});
1816
+ await this._doFlush();
1817
+ };
1818
+ const p = run().finally(() => {
1819
+ if (this._flushPromise === p)
1820
+ this._flushPromise = null;
1821
+ });
1822
+ this._flushPromise = p;
1823
+ return p;
1824
+ }
1825
+ drainWindow() {
1826
+ if (this._series.size === 0)
1827
+ return null;
1828
+ const window = this._series;
1829
+ this._series = new Map;
1830
+ this._seriesCapWarned = false;
1831
+ this._typeByName = new Map;
1832
+ this._typeCollisionWarned = new Set;
1833
+ return this._buildPayload(window);
1834
+ }
1835
+ reset() {
1836
+ this._generation++;
1837
+ this._clearFlushTimer();
1838
+ this._series = new Map;
1839
+ this._flushPromise = null;
1840
+ this._seriesCapWarned = false;
1841
+ this._typeByName = new Map;
1842
+ this._typeCollisionWarned = new Set;
1843
+ }
1844
+ _capture(sample) {
1845
+ if (this._instance.isDisabled || this._instance.optedOut)
1846
+ return;
1847
+ const filtered = this._runBeforeSend(sample);
1848
+ if (filtered === null)
1849
+ return;
1850
+ if (!filtered.name || typeof filtered.name != "string")
1851
+ return void this._logger.warn("Dropping metric with empty name");
1852
+ if (typeof filtered.value != "number" || !Number.isFinite(filtered.value))
1853
+ return void this._logger.warn(`Dropping metric '${filtered.name}': value must be a finite number`);
1854
+ if (filtered.type === "count" && filtered.value < 0)
1855
+ return void this._logger.warn(`Dropping count '${filtered.name}': counters are monotonic, value must be >= 0`);
1856
+ let attributes;
1857
+ let key;
1858
+ try {
1859
+ attributes = filtered.attributes ? {
1860
+ ...filtered.attributes
1861
+ } : undefined;
1862
+ key = seriesKey(filtered.type, filtered.name, filtered.unit, attributes);
1863
+ } catch (e) {
1864
+ this._logger.warn(`Dropping metric '${filtered.name}': attributes could not be serialized`, e);
1865
+ return;
1866
+ }
1867
+ let state = this._series.get(key);
1868
+ if (!state) {
1869
+ if (!this._admitNewSeries())
1870
+ return;
1871
+ state = {
1872
+ name: filtered.name,
1873
+ type: filtered.type,
1874
+ unit: filtered.unit,
1875
+ attributes,
1876
+ windowStartMs: Date.now()
1877
+ };
1878
+ this._series.set(key, state);
1879
+ }
1880
+ const seenType = this._typeByName.get(filtered.name);
1881
+ if (seenType === undefined)
1882
+ this._typeByName.set(filtered.name, filtered.type);
1883
+ else if (seenType !== filtered.type && !this._typeCollisionWarned.has(filtered.name)) {
1884
+ this._typeCollisionWarned.add(filtered.name);
1885
+ this._logger.warn(`Metric name '${filtered.name}' is already used as a ${seenType}; recording it as a ${filtered.type} too will blend both series in charts. Use a distinct name.`);
1886
+ }
1887
+ this._fold(state, filtered.value);
1888
+ this._armFlushTimer();
1889
+ }
1890
+ _admitNewSeries() {
1891
+ if (this._series.size < this._config.maxSeriesPerFlush)
1892
+ return true;
1893
+ if (!this._seriesCapWarned) {
1894
+ this._seriesCapWarned = true;
1895
+ this._logger.warn(`Metric series cap reached (${this._config.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`);
1896
+ }
1897
+ return false;
1898
+ }
1899
+ _fold(state, value) {
1900
+ switch (state.type) {
1901
+ case "count":
1902
+ state.total = (state.total ?? 0) + value;
1903
+ break;
1904
+ case "gauge":
1905
+ state.last = value;
1906
+ break;
1907
+ case "histogram": {
1908
+ if (!state.hist)
1909
+ state.hist = {
1910
+ count: 0,
1911
+ sum: 0,
1912
+ min: value,
1913
+ max: value,
1914
+ bucketCounts: new Array(DEFAULT_HISTOGRAM_BOUNDS.length + 1).fill(0)
1915
+ };
1916
+ const hist = state.hist;
1917
+ hist.count += 1;
1918
+ hist.sum += value;
1919
+ hist.min = Math.min(hist.min, value);
1920
+ hist.max = Math.max(hist.max, value);
1921
+ hist.bucketCounts[bucketIndexFor(value, DEFAULT_HISTOGRAM_BOUNDS)] += 1;
1922
+ break;
1923
+ }
1924
+ }
1925
+ }
1926
+ _runBeforeSend(sample) {
1927
+ const beforeSend = this._config.beforeSend;
1928
+ if (!beforeSend)
1929
+ return sample;
1930
+ const fns = isArray(beforeSend) ? beforeSend : [
1931
+ beforeSend
1932
+ ];
1933
+ let result = sample;
1934
+ for (const fn of fns)
1935
+ try {
1936
+ const next = fn(result);
1937
+ if (!next) {
1938
+ this._logger.info("Metric was rejected in beforeSend function");
1939
+ return null;
1940
+ }
1941
+ result = next;
1942
+ } catch (e) {
1943
+ this._logger.error("Error in beforeSend function for metric:", e);
1944
+ return null;
1945
+ }
1946
+ return result;
1947
+ }
1948
+ _armFlushTimer() {
1949
+ if (this._flushTimer)
1950
+ return;
1951
+ this._flushTimer = safeSetTimeout(() => {
1952
+ this._flushTimer = undefined;
1953
+ this.flush().catch((e) => {
1954
+ this._logger.error("Metrics flush failed:", e);
1955
+ });
1956
+ }, this._config.flushIntervalMs);
1957
+ }
1958
+ _clearFlushTimer() {
1959
+ if (this._flushTimer) {
1960
+ clearTimeout(this._flushTimer);
1961
+ this._flushTimer = undefined;
1962
+ }
1963
+ }
1964
+ async _doFlush() {
1965
+ if (this._series.size === 0)
1966
+ return;
1967
+ const window = this._series;
1968
+ this._series = new Map;
1969
+ this._seriesCapWarned = false;
1970
+ this._typeByName = new Map;
1971
+ this._typeCollisionWarned = new Set;
1972
+ const generation = this._generation;
1973
+ const outcome = await this._instance._sendMetricsBatch(this._buildPayload(window));
1974
+ if (generation !== this._generation)
1975
+ return;
1976
+ switch (outcome.kind) {
1977
+ case "ok":
1978
+ return;
1979
+ case "retry-later":
1980
+ this._mergeWindowBack(window);
1981
+ this._armFlushTimer();
1982
+ return;
1983
+ case "too-large":
1984
+ this._logger.warn("Metrics batch exceeded the server size limit and was dropped");
1985
+ return;
1986
+ case "fatal":
1987
+ this._logger.error("Failed to send metrics batch:", outcome.error);
1988
+ return;
1989
+ }
1990
+ }
1991
+ _buildPayload(window) {
1992
+ return buildOtlpMetricsPayload(this._buildMetrics(window), buildMetricsResourceAttributes(this._config, this._instance.getLibraryId(), this._instance.getLibraryVersion()), this._instance.getLibraryId(), this._instance.getLibraryVersion());
1993
+ }
1994
+ _buildMetrics(window) {
1995
+ const nowNano = msToUnixNano(Date.now());
1996
+ const byMetric = new Map;
1997
+ for (const state of window.values()) {
1998
+ const metricKey = seriesKey(state.type, state.name, state.unit, undefined);
1999
+ let metric = byMetric.get(metricKey);
2000
+ if (!metric) {
2001
+ metric = {
2002
+ name: state.name,
2003
+ ...state.unit && {
2004
+ unit: state.unit
2005
+ }
2006
+ };
2007
+ if (state.type === "count")
2008
+ metric.sum = {
2009
+ aggregationTemporality: OTLP_TEMPORALITY_DELTA,
2010
+ isMonotonic: true,
2011
+ dataPoints: []
2012
+ };
2013
+ else if (state.type === "gauge")
2014
+ metric.gauge = {
2015
+ dataPoints: []
2016
+ };
2017
+ else
2018
+ metric.histogram = {
2019
+ aggregationTemporality: OTLP_TEMPORALITY_DELTA,
2020
+ dataPoints: []
2021
+ };
2022
+ byMetric.set(metricKey, metric);
2023
+ }
2024
+ const attributes = toOtlpKeyValueList(state.attributes ?? {}, this._logger);
2025
+ const startNano = msToUnixNano(state.windowStartMs);
2026
+ if (state.type === "count") {
2027
+ const dp = {
2028
+ attributes,
2029
+ startTimeUnixNano: startNano,
2030
+ timeUnixNano: nowNano,
2031
+ asDouble: state.total ?? 0
2032
+ };
2033
+ metric.sum.dataPoints.push(dp);
2034
+ } else if (state.type === "gauge") {
2035
+ const dp = {
2036
+ attributes,
2037
+ timeUnixNano: nowNano,
2038
+ asDouble: state.last ?? 0
2039
+ };
2040
+ metric.gauge.dataPoints.push(dp);
2041
+ } else if (state.hist) {
2042
+ const dp = {
2043
+ attributes,
2044
+ startTimeUnixNano: startNano,
2045
+ timeUnixNano: nowNano,
2046
+ count: state.hist.count,
2047
+ sum: state.hist.sum,
2048
+ min: state.hist.min,
2049
+ max: state.hist.max,
2050
+ bucketCounts: state.hist.bucketCounts,
2051
+ explicitBounds: DEFAULT_HISTOGRAM_BOUNDS
2052
+ };
2053
+ metric.histogram.dataPoints.push(dp);
2054
+ }
2055
+ }
2056
+ return Array.from(byMetric.values());
2057
+ }
2058
+ _mergeWindowBack(window) {
2059
+ for (const [key, old] of window) {
2060
+ const current = this._series.get(key);
2061
+ if (!current) {
2062
+ if (this._admitNewSeries())
2063
+ this._series.set(key, old);
2064
+ continue;
2065
+ }
2066
+ current.windowStartMs = Math.min(current.windowStartMs, old.windowStartMs);
2067
+ switch (current.type) {
2068
+ case "count":
2069
+ current.total = (current.total ?? 0) + (old.total ?? 0);
2070
+ break;
2071
+ case "gauge":
2072
+ break;
2073
+ case "histogram":
2074
+ if (old.hist)
2075
+ if (current.hist) {
2076
+ current.hist.count += old.hist.count;
2077
+ current.hist.sum += old.hist.sum;
2078
+ current.hist.min = Math.min(current.hist.min, old.hist.min);
2079
+ current.hist.max = Math.max(current.hist.max, old.hist.max);
2080
+ for (let i = 0;i < current.hist.bucketCounts.length; i++)
2081
+ current.hist.bucketCounts[i] += old.hist.bucketCounts[i];
2082
+ } else
2083
+ current.hist = old.hist;
2084
+ break;
2085
+ }
2086
+ }
2087
+ }
2088
+ }
2089
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/eventemitter.mjs
1349
2090
  class SimpleEventEmitter {
1350
2091
  constructor() {
1351
2092
  this.events = {};
@@ -1367,37 +2108,7 @@ class SimpleEventEmitter {
1367
2108
  }
1368
2109
  }
1369
2110
 
1370
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/index.mjs
1371
- var exports_error_tracking = {};
1372
- __export(exports_error_tracking, {
1373
- winjsStackLineParser: () => winjsStackLineParser,
1374
- stripReservedExceptionStepFields: () => stripReservedExceptionStepFields,
1375
- reverseAndStripFrames: () => reverseAndStripFrames,
1376
- resolveExceptionStepsConfig: () => resolveExceptionStepsConfig,
1377
- opera11StackLineParser: () => opera11StackLineParser,
1378
- opera10StackLineParser: () => opera10StackLineParser,
1379
- nodeStackLineParser: () => nodeStackLineParser,
1380
- getUtf8ByteLength: () => getUtf8ByteLength,
1381
- geckoStackLineParser: () => geckoStackLineParser,
1382
- createStackParser: () => createStackParser,
1383
- createDefaultStackParser: () => createDefaultStackParser,
1384
- chromeStackLineParser: () => chromeStackLineParser,
1385
- StringCoercer: () => StringCoercer,
1386
- ReduceableCache: () => ReduceableCache,
1387
- PromiseRejectionEventCoercer: () => PromiseRejectionEventCoercer,
1388
- PrimitiveCoercer: () => PrimitiveCoercer,
1389
- ObjectCoercer: () => ObjectCoercer,
1390
- ExceptionStepsBuffer: () => ExceptionStepsBuffer,
1391
- EventCoercer: () => EventCoercer,
1392
- ErrorPropertiesBuilder: () => ErrorPropertiesBuilder,
1393
- ErrorEventCoercer: () => ErrorEventCoercer,
1394
- ErrorCoercer: () => ErrorCoercer,
1395
- EXCEPTION_STEP_INTERNAL_FIELDS: () => EXCEPTION_STEP_INTERNAL_FIELDS,
1396
- DOMExceptionCoercer: () => DOMExceptionCoercer,
1397
- DEFAULT_EXCEPTION_STEPS_CONFIG: () => DEFAULT_EXCEPTION_STEPS_CONFIG
1398
- });
1399
-
1400
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
2111
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
1401
2112
  var parsedStackResults;
1402
2113
  var lastKeysCount;
1403
2114
  var cachedFilenameChunkIds;
@@ -1436,7 +2147,7 @@ function getFilenameToChunkIdMap(stackParser) {
1436
2147
  return cachedFilenameChunkIds;
1437
2148
  }
1438
2149
 
1439
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
2150
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
1440
2151
  var MAX_CAUSE_RECURSION = 4;
1441
2152
 
1442
2153
  class ErrorPropertiesBuilder {
@@ -1540,11 +2251,11 @@ class ErrorPropertiesBuilder {
1540
2251
  return context;
1541
2252
  }
1542
2253
  buildCoercingContext(mechanism, hint, depth = 0) {
1543
- const coerce = (input, depth2) => {
1544
- if (!(depth2 <= MAX_CAUSE_RECURSION))
2254
+ const coerce = (input, depth) => {
2255
+ if (!(depth <= MAX_CAUSE_RECURSION))
1545
2256
  return;
1546
2257
  {
1547
- const ctx = this.buildCoercingContext(mechanism, hint, depth2);
2258
+ const ctx = this.buildCoercingContext(mechanism, hint, depth);
1548
2259
  return this.applyCoercers(input, ctx);
1549
2260
  }
1550
2261
  };
@@ -1558,14 +2269,16 @@ class ErrorPropertiesBuilder {
1558
2269
  return context;
1559
2270
  }
1560
2271
  }
1561
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
2272
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
1562
2273
  var UNKNOWN_FUNCTION = "?";
2274
+ var MASKED_URL_PREFIX = "webkit-masked-url://";
2275
+ var ANONYMOUS_FILENAME = "<anonymous>";
1563
2276
  function createFrame(platform, filename, func, lineno, colno) {
1564
2277
  const frame = {
1565
2278
  platform,
1566
2279
  filename,
1567
2280
  function: func === "<anonymous>" ? UNKNOWN_FUNCTION : func,
1568
- in_app: true
2281
+ in_app: !filename?.startsWith(MASKED_URL_PREFIX) && filename !== ANONYMOUS_FILENAME
1569
2282
  };
1570
2283
  if (!isUndefined(lineno))
1571
2284
  frame.lineno = lineno;
@@ -1574,7 +2287,7 @@ function createFrame(platform, filename, func, lineno, colno) {
1574
2287
  return frame;
1575
2288
  }
1576
2289
 
1577
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
2290
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
1578
2291
  var extractSafariExtensionDetails = (func, filename) => {
1579
2292
  const isSafariExtension = func.indexOf("safari-extension") !== -1;
1580
2293
  const isSafariWebExtension = func.indexOf("safari-web-extension") !== -1;
@@ -1587,15 +2300,15 @@ var extractSafariExtensionDetails = (func, filename) => {
1587
2300
  ];
1588
2301
  };
1589
2302
 
1590
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
2303
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
1591
2304
  var chromeRegexNoFnName = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i;
1592
2305
  var chromeRegex = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
1593
2306
  var chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
1594
2307
  var chromeStackLineParser = (line, platform) => {
1595
2308
  const noFnParts = chromeRegexNoFnName.exec(line);
1596
2309
  if (noFnParts) {
1597
- const [, filename, line2, col] = noFnParts;
1598
- return createFrame(platform, filename, UNKNOWN_FUNCTION, +line2, +col);
2310
+ const [, filename, line, col] = noFnParts;
2311
+ return createFrame(platform, filename, UNKNOWN_FUNCTION, +line, +col);
1599
2312
  }
1600
2313
  const parts = chromeRegex.exec(line);
1601
2314
  if (parts) {
@@ -1613,7 +2326,7 @@ var chromeStackLineParser = (line, platform) => {
1613
2326
  }
1614
2327
  };
1615
2328
 
1616
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
2329
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
1617
2330
  var geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
1618
2331
  var geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
1619
2332
  var geckoStackLineParser = (line, platform) => {
@@ -1636,28 +2349,12 @@ var geckoStackLineParser = (line, platform) => {
1636
2349
  }
1637
2350
  };
1638
2351
 
1639
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/winjs.mjs
1640
- var winjsRegex = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
1641
- var winjsStackLineParser = (line, platform) => {
1642
- const parts = winjsRegex.exec(line);
1643
- return parts ? createFrame(platform, parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined) : undefined;
1644
- };
1645
-
1646
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/opera.mjs
1647
- var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
1648
- var opera10StackLineParser = (line, platform) => {
1649
- const parts = opera10Regex.exec(line);
1650
- return parts ? createFrame(platform, parts[2], parts[3] || UNKNOWN_FUNCTION, +parts[1]) : undefined;
1651
- };
1652
- var opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;
1653
- var opera11StackLineParser = (line, platform) => {
1654
- const parts = opera11Regex.exec(line);
1655
- return parts ? createFrame(platform, parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined;
1656
- };
1657
-
1658
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
2352
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
1659
2353
  var FILENAME_MATCH = /^\s*[-]{4,}$/;
1660
2354
  var FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
2355
+ var PROMISE_COMBINATOR = /^Promise\.(?:all|any)$/;
2356
+ var PROMISE_INDEX = /^index \d+$/;
2357
+ var PROMISE_FRAME_FILENAME = "node:internal/promise";
1661
2358
  var nodeStackLineParser = (line, platform) => {
1662
2359
  const lineMatch = line.match(FULL_MATCH);
1663
2360
  if (lineMatch) {
@@ -1700,6 +2397,8 @@ var nodeStackLineParser = (line, platform) => {
1700
2397
  filename = filename.slice(1);
1701
2398
  if (!filename && lineMatch[5] && !isNative)
1702
2399
  filename = lineMatch[5];
2400
+ if (PROMISE_COMBINATOR.test(functionName) && PROMISE_INDEX.test(filename || ""))
2401
+ filename = PROMISE_FRAME_FILENAME;
1703
2402
  return {
1704
2403
  filename: filename ? decodeURI(filename) : undefined,
1705
2404
  module: undefined,
@@ -1724,7 +2423,7 @@ function _parseIntOrUndefined(input) {
1724
2423
  return parseInt(input || "", 10) || undefined;
1725
2424
  }
1726
2425
 
1727
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
2426
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
1728
2427
  var WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
1729
2428
  var STACKTRACE_FRAME_LIMIT = 50;
1730
2429
  function reverseAndStripFrames(stack) {
@@ -1769,48 +2468,20 @@ function createStackParser(platform, ...parsers) {
1769
2468
  return reverseAndStripFrames(frames);
1770
2469
  };
1771
2470
  }
1772
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/dom-exception-coercer.mjs
1773
- class DOMExceptionCoercer {
1774
- match(err) {
1775
- return this.isDOMException(err) || this.isDOMError(err);
1776
- }
1777
- coerce(err, ctx) {
1778
- const hasStack = isString(err.stack);
1779
- return {
1780
- type: this.getType(err),
1781
- value: this.getValue(err),
1782
- stack: hasStack ? err.stack : undefined,
1783
- cause: err.cause ? ctx.next(err.cause) : undefined,
1784
- synthetic: false
1785
- };
1786
- }
1787
- getType(candidate) {
1788
- return this.isDOMError(candidate) ? "DOMError" : "DOMException";
1789
- }
1790
- getValue(err) {
1791
- const name = err.name || (this.isDOMError(err) ? "DOMError" : "DOMException");
1792
- const message = err.message ? `${name}: ${err.message}` : name;
1793
- return message;
1794
- }
1795
- isDOMException(err) {
1796
- return isBuiltin(err, "DOMException");
1797
- }
1798
- isDOMError(err) {
1799
- return isBuiltin(err, "DOMError");
1800
- }
1801
- }
1802
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
2471
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
1803
2472
  class ErrorCoercer {
1804
2473
  match(err) {
1805
- return isPlainError(err);
2474
+ return isError(err);
1806
2475
  }
1807
2476
  coerce(err, ctx) {
2477
+ const stack = this.getStack(err);
2478
+ const synthetic = stack === undefined;
1808
2479
  return {
1809
2480
  type: this.getType(err),
1810
2481
  value: this.getMessage(err, ctx),
1811
- stack: this.getStack(err),
2482
+ stack: stack ?? ctx.syntheticException?.stack,
1812
2483
  cause: err.cause ? ctx.next(err.cause) : undefined,
1813
- synthetic: false
2484
+ synthetic
1814
2485
  };
1815
2486
  }
1816
2487
  getType(err) {
@@ -1826,25 +2497,7 @@ class ErrorCoercer {
1826
2497
  return err.stacktrace || err.stack || undefined;
1827
2498
  }
1828
2499
  }
1829
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/error-event-coercer.mjs
1830
- class ErrorEventCoercer {
1831
- constructor() {}
1832
- match(err) {
1833
- return isErrorEvent(err) && err.error != null;
1834
- }
1835
- coerce(err, ctx) {
1836
- const exceptionLike = ctx.apply(err.error);
1837
- if (!exceptionLike)
1838
- return {
1839
- type: "ErrorEvent",
1840
- value: err.message,
1841
- stack: ctx.syntheticException?.stack,
1842
- synthetic: true
1843
- };
1844
- return exceptionLike;
1845
- }
1846
- }
1847
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
2500
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
1848
2501
  var ERROR_TYPES_PATTERN = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
1849
2502
 
1850
2503
  class StringCoercer {
@@ -1874,7 +2527,7 @@ class StringCoercer {
1874
2527
  ];
1875
2528
  }
1876
2529
  }
1877
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/types.mjs
2530
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/types.mjs
1878
2531
  var severityLevels = [
1879
2532
  "fatal",
1880
2533
  "error",
@@ -1884,7 +2537,7 @@ var severityLevels = [
1884
2537
  "debug"
1885
2538
  ];
1886
2539
 
1887
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
2540
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
1888
2541
  function extractExceptionKeysForMessage(err, maxLength = 40) {
1889
2542
  const keys = Object.keys(err);
1890
2543
  keys.sort();
@@ -1901,7 +2554,7 @@ function extractExceptionKeysForMessage(err, maxLength = 40) {
1901
2554
  return "";
1902
2555
  }
1903
2556
 
1904
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
2557
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
1905
2558
  class ObjectCoercer {
1906
2559
  match(candidate) {
1907
2560
  return typeof candidate == "object" && candidate !== null;
@@ -1913,13 +2566,16 @@ class ObjectCoercer {
1913
2566
  return {
1914
2567
  type: this.getType(candidate),
1915
2568
  value: this.getValue(candidate),
1916
- stack: ctx.syntheticException?.stack,
2569
+ stack: this.getStack(candidate) ?? ctx.syntheticException?.stack,
1917
2570
  level: this.isSeverityLevel(candidate.level) ? candidate.level : "error",
1918
2571
  synthetic: true
1919
2572
  };
1920
2573
  }
1921
2574
  getType(err) {
1922
- return isEvent(err) ? err.constructor.name : "Error";
2575
+ if (isEvent(err))
2576
+ return err.constructor.name;
2577
+ const name = "name" in err ? err.name : undefined;
2578
+ return isString(name) && !isEmptyString(name) ? name : "Error";
1923
2579
  }
1924
2580
  getValue(err) {
1925
2581
  if ("name" in err && typeof err.name == "string") {
@@ -1937,6 +2593,15 @@ class ObjectCoercer {
1937
2593
  isSeverityLevel(x) {
1938
2594
  return isString(x) && !isEmptyString(x) && severityLevels.indexOf(x) >= 0;
1939
2595
  }
2596
+ getStack(candidate) {
2597
+ try {
2598
+ if (isString(candidate.stacktrace) && candidate.stacktrace.length > 0)
2599
+ return candidate.stacktrace;
2600
+ return isString(candidate.stack) && candidate.stack.length > 0 ? candidate.stack : undefined;
2601
+ } catch {
2602
+ return;
2603
+ }
2604
+ }
1940
2605
  getErrorPropertyFromObject(obj) {
1941
2606
  for (const prop in obj)
1942
2607
  if (Object.prototype.hasOwnProperty.call(obj, prop)) {
@@ -1954,7 +2619,7 @@ class ObjectCoercer {
1954
2619
  }
1955
2620
  }
1956
2621
  }
1957
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
2622
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
1958
2623
  class EventCoercer {
1959
2624
  match(err) {
1960
2625
  return isEvent(err);
@@ -1969,7 +2634,7 @@ class EventCoercer {
1969
2634
  };
1970
2635
  }
1971
2636
  }
1972
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
2637
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
1973
2638
  class PrimitiveCoercer {
1974
2639
  match(candidate) {
1975
2640
  return isPrimitive(candidate);
@@ -1983,43 +2648,7 @@ class PrimitiveCoercer {
1983
2648
  };
1984
2649
  }
1985
2650
  }
1986
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/promise-rejection-event.mjs
1987
- class PromiseRejectionEventCoercer {
1988
- match(err) {
1989
- return isBuiltin(err, "PromiseRejectionEvent") || this.isCustomEventWrappingRejection(err);
1990
- }
1991
- isCustomEventWrappingRejection(err) {
1992
- if (!isEvent(err))
1993
- return false;
1994
- try {
1995
- const detail = err.detail;
1996
- return detail != null && typeof detail == "object" && "reason" in detail;
1997
- } catch {
1998
- return false;
1999
- }
2000
- }
2001
- coerce(err, ctx) {
2002
- const reason = this.getUnhandledRejectionReason(err);
2003
- if (isPrimitive(reason))
2004
- return {
2005
- type: "UnhandledRejection",
2006
- value: `Non-Error promise rejection captured with value: ${String(reason)}`,
2007
- stack: ctx.syntheticException?.stack,
2008
- synthetic: true
2009
- };
2010
- return ctx.apply(reason);
2011
- }
2012
- getUnhandledRejectionReason(error) {
2013
- try {
2014
- if ("reason" in error)
2015
- return error.reason;
2016
- if ("detail" in error && error.detail != null && typeof error.detail == "object" && "reason" in error.detail)
2017
- return error.detail.reason;
2018
- } catch {}
2019
- return error;
2020
- }
2021
- }
2022
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/utils.mjs
2651
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/utils.mjs
2023
2652
  class ReduceableCache {
2024
2653
  constructor(_maxSize) {
2025
2654
  this._maxSize = _maxSize;
@@ -2044,7 +2673,7 @@ class ReduceableCache {
2044
2673
  }
2045
2674
  }
2046
2675
  }
2047
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
2676
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
2048
2677
  var EXCEPTION_STEP_INTERNAL_FIELDS = {
2049
2678
  MESSAGE: "$message",
2050
2679
  TIMESTAMP: "$timestamp"
@@ -2053,167 +2682,65 @@ var RESERVED_EXCEPTION_STEP_KEYS = new Set([
2053
2682
  EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE,
2054
2683
  EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP
2055
2684
  ]);
2056
- var DEFAULT_EXCEPTION_STEPS_CONFIG = {
2057
- enabled: true,
2058
- max_bytes: 32768
2059
- };
2060
- function resolveExceptionStepsConfig(config) {
2061
- if (!config)
2062
- return {
2063
- ...DEFAULT_EXCEPTION_STEPS_CONFIG
2064
- };
2065
- return {
2066
- enabled: config.enabled ?? DEFAULT_EXCEPTION_STEPS_CONFIG.enabled,
2067
- max_bytes: normalizePositiveInteger(config.max_bytes, DEFAULT_EXCEPTION_STEPS_CONFIG.max_bytes)
2068
- };
2069
- }
2070
- function stripReservedExceptionStepFields(properties) {
2071
- if (!properties)
2072
- return {
2073
- sanitizedProperties: {},
2074
- droppedKeys: []
2075
- };
2076
- const droppedKeys = [];
2077
- const sanitizedProperties = Object.keys(properties).reduce((acc, key) => {
2078
- if (RESERVED_EXCEPTION_STEP_KEYS.has(key)) {
2079
- droppedKeys.push(key);
2080
- return acc;
2081
- }
2082
- acc[key] = properties[key];
2083
- return acc;
2084
- }, {});
2085
- return {
2086
- sanitizedProperties,
2087
- droppedKeys
2088
- };
2685
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/release.mjs
2686
+ function getInjectedReleaseId() {
2687
+ const injected = globalThis._posthogReleaseId;
2688
+ return typeof injected == "string" && injected.length > 0 ? injected : undefined;
2089
2689
  }
2090
-
2091
- class ExceptionStepsBuffer {
2092
- constructor(config) {
2093
- this._entries = [];
2094
- this._totalBytes = 0;
2095
- this._config = resolveExceptionStepsConfig(config);
2096
- }
2097
- setConfig(config) {
2098
- this._config = resolveExceptionStepsConfig(config);
2099
- this._trimToMaxBytes();
2100
- }
2101
- add(step) {
2102
- const serialized = normalizeAndSerializeStep(step);
2103
- if (!serialized)
2104
- return;
2105
- const bytes = getUtf8ByteLength(serialized.json);
2106
- if (bytes > this._config.max_bytes)
2107
- return;
2108
- this._entries.push({
2109
- step: serialized.step,
2110
- bytes
2111
- });
2112
- this._totalBytes += bytes;
2113
- this._trimToMaxBytes();
2114
- }
2115
- getAttachable() {
2116
- return this._entries.map((e) => e.step);
2117
- }
2118
- clear() {
2119
- this._entries = [];
2120
- this._totalBytes = 0;
2121
- }
2122
- size() {
2123
- return this._entries.length;
2124
- }
2125
- _trimToMaxBytes() {
2126
- while (this._totalBytes > this._config.max_bytes && this._entries.length > 0) {
2127
- const evicted = this._entries.shift();
2128
- if (evicted)
2129
- this._totalBytes -= evicted.bytes;
2130
- }
2131
- }
2132
- }
2133
- function normalizePositiveInteger(input, fallback) {
2134
- if (!isNumber(input) || input === 1 / 0 || input === -1 / 0)
2135
- return fallback;
2136
- const normalized = Math.floor(input);
2137
- if (normalized < 0)
2138
- return fallback;
2139
- return normalized;
2140
- }
2141
- function normalizeAndSerializeStep(step) {
2142
- const json = safeStringify(step);
2143
- if (!json)
2144
- return;
2145
- try {
2146
- const parsed = JSON.parse(json);
2147
- if (!isObject(parsed))
2148
- return;
2149
- const parsedStep = parsed;
2150
- const message = parsedStep[EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE];
2151
- const timestamp = parsedStep[EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP];
2152
- if (!isString(message) || message.trim().length === 0)
2153
- return;
2154
- if (!isString(timestamp) && !isNumber(timestamp))
2155
- return;
2156
- return {
2157
- step: parsedStep,
2158
- json
2159
- };
2160
- } catch {
2161
- return;
2162
- }
2163
- }
2164
- function safeStringify(value) {
2165
- const seen = new WeakSet;
2166
- try {
2167
- return JSON.stringify(value, (_key, replacementValue) => {
2168
- if (typeof replacementValue == "bigint")
2169
- return replacementValue.toString();
2170
- if (typeof replacementValue == "function" || typeof replacementValue == "symbol")
2171
- return;
2172
- if (replacementValue instanceof Date)
2173
- return replacementValue.toISOString();
2174
- if (replacementValue instanceof Error)
2175
- return {
2176
- name: replacementValue.name,
2177
- message: replacementValue.message,
2178
- stack: replacementValue.stack
2179
- };
2180
- if (replacementValue && typeof replacementValue == "object") {
2181
- if (seen.has(replacementValue))
2182
- return "[Circular]";
2183
- seen.add(replacementValue);
2184
- }
2185
- return replacementValue;
2186
- });
2187
- } catch {
2188
- return;
2189
- }
2190
- }
2191
- function getUtf8ByteLength(value) {
2192
- if (typeof TextEncoder != "undefined")
2193
- return new TextEncoder().encode(value).length;
2194
- const encoded = encodeURIComponent(value);
2195
- let byteLength = 0;
2196
- for (let i = 0;i < encoded.length; i++)
2197
- if (encoded[i] === "%") {
2198
- byteLength += 1;
2199
- i += 2;
2200
- } else
2201
- byteLength += 1;
2202
- return byteLength;
2203
- }
2204
- // ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
2690
+ // ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
2205
2691
  class PostHogFetchHttpError extends Error {
2206
- constructor(response, reqByteLength) {
2207
- super("HTTP error while fetching PostHog: status=" + response.status + ", reqByteLength=" + reqByteLength), this.response = response, this.reqByteLength = reqByteLength, this.name = "PostHogFetchHttpError";
2692
+ constructor(response, reqByteLength, responseBodyDeadline, abortController) {
2693
+ super("HTTP error while fetching PostHog: status=" + response.status + ", reqByteLength=" + reqByteLength), this.response = response, this.reqByteLength = reqByteLength, this.responseBodyDeadline = responseBodyDeadline, this.abortController = abortController, this.name = "PostHogFetchHttpError", this._bodyReadTimedOut = false;
2208
2694
  }
2209
2695
  get status() {
2210
2696
  return this.response.status;
2211
2697
  }
2698
+ get bodyReadTimedOut() {
2699
+ return this._bodyReadTimedOut;
2700
+ }
2212
2701
  get text() {
2213
- return this.response.text();
2702
+ if (!this.responseBodyTextPromise)
2703
+ if (Date.now() >= this.responseBodyDeadline) {
2704
+ this._bodyReadTimedOut = true;
2705
+ const timeoutError = new Error("Response body read timed out");
2706
+ timeoutError.name = "AbortError";
2707
+ this.cancelResponseBody(timeoutError);
2708
+ this.responseBodyTextPromise = Promise.reject(timeoutError);
2709
+ } else {
2710
+ const responseBodyTimeout = new Promise((_resolve, reject) => {
2711
+ this.responseBodyTimer = safeSetTimeout(() => {
2712
+ this._bodyReadTimedOut = true;
2713
+ const timeoutError = new Error("Response body read timed out");
2714
+ timeoutError.name = "AbortError";
2715
+ reject(timeoutError);
2716
+ this.cancelResponseBody(timeoutError);
2717
+ }, this.responseBodyDeadline - Date.now());
2718
+ });
2719
+ let responseBodyText;
2720
+ try {
2721
+ responseBodyText = Promise.resolve(this.response.text());
2722
+ } catch (error) {
2723
+ responseBodyText = Promise.reject(error);
2724
+ }
2725
+ this.responseBodyTextPromise = Promise.race([
2726
+ responseBodyText,
2727
+ responseBodyTimeout
2728
+ ]).finally(() => clearTimeout(this.responseBodyTimer));
2729
+ }
2730
+ return this.responseBodyTextPromise;
2214
2731
  }
2215
2732
  get json() {
2216
- return this.response.json();
2733
+ return this.text.then((text) => JSON.parse(text));
2734
+ }
2735
+ cancelResponseBody(reason) {
2736
+ clearTimeout(this.responseBodyTimer);
2737
+ if (!this.abortController.signal.aborted)
2738
+ this.abortController.abort(reason);
2739
+ (async () => {
2740
+ try {
2741
+ await this.response.body?.cancel();
2742
+ } catch {}
2743
+ })();
2217
2744
  }
2218
2745
  }
2219
2746
 
@@ -2224,12 +2751,20 @@ class PostHogFetchNetworkError extends Error {
2224
2751
  } : {}), this.error = error, this.name = "PostHogFetchNetworkError";
2225
2752
  }
2226
2753
  }
2754
+ var applyCallerFeatureFlagOverrides = (target, callerProperties) => {
2755
+ for (const key of Object.keys(callerProperties))
2756
+ if (key.startsWith("$feature/") || key === "$active_feature_flags")
2757
+ target[key] = callerProperties[key];
2758
+ };
2227
2759
  async function logFlushError(err) {
2228
2760
  if (err instanceof PostHogFetchHttpError) {
2229
2761
  let text = "";
2230
2762
  try {
2231
2763
  text = await err.text;
2232
- } catch {}
2764
+ } catch {
2765
+ if (err.bodyReadTimedOut)
2766
+ text = "<response body read timed out>";
2767
+ }
2233
2768
  console.error(`Error while flushing PostHog: message=${err.message}, response body=${text}`, err);
2234
2769
  } else
2235
2770
  console.error("Error while flushing PostHog", err);
@@ -2241,9 +2776,28 @@ function isPostHogFetchError(err) {
2241
2776
  function isPostHogFetchNetworkError(err) {
2242
2777
  return err instanceof PostHogFetchNetworkError;
2243
2778
  }
2779
+ function isRetryableFlagsFetchError(err) {
2780
+ if (err instanceof PostHogFetchHttpError)
2781
+ return err.status === 502 || err.status === 504;
2782
+ if (!(err instanceof PostHogFetchNetworkError))
2783
+ return false;
2784
+ const cause = err.error;
2785
+ const code = cause?.code ?? cause?.cause?.code;
2786
+ return code !== "ECONNREFUSED";
2787
+ }
2244
2788
  function isPostHogFetchContentTooLargeError(err) {
2245
2789
  return typeof err == "object" && err instanceof PostHogFetchHttpError && err.status === 413;
2246
2790
  }
2791
+ function isPostHogFetchRetryableError(err) {
2792
+ if (err instanceof PostHogFetchHttpError)
2793
+ return err.status === 408 || err.status === 429 || err.status >= 500;
2794
+ return isPostHogFetchNetworkError(err);
2795
+ }
2796
+ function isPostHogEventProperties(value) {
2797
+ return value !== null && typeof value == "object" && !Array.isArray(value);
2798
+ }
2799
+ var DEFAULT_QUEUE_ROUTE = "default";
2800
+
2247
2801
  class PostHogCoreStateless {
2248
2802
  getErrorPropertiesBuilder() {
2249
2803
  if (!this._errorPropertiesBuilder)
@@ -2260,6 +2814,9 @@ class PostHogCoreStateless {
2260
2814
  }
2261
2815
  constructor(apiKey, options = {}) {
2262
2816
  this.flushPromise = null;
2817
+ this.pendingFlushPromise = null;
2818
+ this.flushPromises = new Set;
2819
+ this._dequeuedMessagesCount = 0;
2263
2820
  this.shutdownPromise = null;
2264
2821
  this.promiseQueue = new PromiseQueue;
2265
2822
  this._events = new SimpleEventEmitter;
@@ -2282,10 +2839,11 @@ class PostHogCoreStateless {
2282
2839
  this._retryOptions = {
2283
2840
  retryCount: options.fetchRetryCount ?? 3,
2284
2841
  retryDelay: options.fetchRetryDelay ?? 3000,
2285
- retryCheck: isPostHogFetchError
2842
+ retryCheck: isPostHogFetchRetryableError
2286
2843
  };
2287
2844
  this.requestTimeout = options.requestTimeout ?? 1e4;
2288
2845
  this.featureFlagsRequestTimeoutMs = options.featureFlagsRequestTimeoutMs ?? 3000;
2846
+ this.featureFlagsRequestMaxRetries = options.featureFlagsRequestMaxRetries ?? 1;
2289
2847
  this.remoteConfigRequestTimeoutMs = options.remoteConfigRequestTimeoutMs ?? 3000;
2290
2848
  this.disableGeoip = options.disableGeoip ?? true;
2291
2849
  this.disabled = (options.disabled ?? false) || missingApiKey;
@@ -2347,15 +2905,23 @@ class PostHogCoreStateless {
2347
2905
  return this.disabled;
2348
2906
  }
2349
2907
  buildPayload(payload) {
2908
+ const userProperties = payload.properties || {};
2909
+ let properties = {
2910
+ ...userProperties,
2911
+ ...this.getCommonEventProperties()
2912
+ };
2913
+ applyCallerFeatureFlagOverrides(properties, userProperties);
2914
+ if (payload.event === "$feature_flag_called" && properties.$feature_flag_has_experiment === false && this.isMinimalFlagCalledEventsEnabled())
2915
+ properties = minimizeFlagCalledEventProperties(properties);
2350
2916
  return {
2351
2917
  distinct_id: payload.distinct_id,
2352
2918
  event: payload.event,
2353
- properties: {
2354
- ...payload.properties || {},
2355
- ...this.getCommonEventProperties()
2356
- }
2919
+ properties
2357
2920
  };
2358
2921
  }
2922
+ isMinimalFlagCalledEventsEnabled() {
2923
+ return false;
2924
+ }
2359
2925
  addPendingPromise(promise) {
2360
2926
  return this.promiseQueue.add(promise);
2361
2927
  }
@@ -2440,6 +3006,19 @@ class PostHogCoreStateless {
2440
3006
  this.enqueue("capture", payload, options);
2441
3007
  });
2442
3008
  }
3009
+ async groupIdentifyStatelessImmediate(groupType, groupKey, groupProperties, options, distinctId, eventProperties) {
3010
+ const payload = this.buildPayload({
3011
+ distinct_id: distinctId || `$${groupType}_${groupKey}`,
3012
+ event: "$groupidentify",
3013
+ properties: {
3014
+ $group_type: groupType,
3015
+ $group_key: groupKey,
3016
+ $group_set: groupProperties || {},
3017
+ ...eventProperties || {}
3018
+ }
3019
+ });
3020
+ await this.sendImmediate("capture", payload, options);
3021
+ }
2443
3022
  async getRemoteConfig() {
2444
3023
  await this._initPromise;
2445
3024
  let host = this.host;
@@ -2456,8 +3035,11 @@ class PostHogCoreStateless {
2456
3035
  }
2457
3036
  };
2458
3037
  return this.fetchWithRetry(url, fetchOptions, {
3038
+ type: "required",
3039
+ consume: (response) => response.json()
3040
+ }, {
2459
3041
  retryCount: 0
2460
- }, this.remoteConfigRequestTimeoutMs).then((response) => response.json()).catch((error) => {
3042
+ }, this.remoteConfigRequestTimeoutMs).catch((error) => {
2461
3043
  this._logger.error("Remote config could not be loaded", error);
2462
3044
  this._events.emit("error", error);
2463
3045
  });
@@ -2488,8 +3070,12 @@ class PostHogCoreStateless {
2488
3070
  };
2489
3071
  this._logger.info("Flags URL", url);
2490
3072
  return this.fetchWithRetry(url, fetchOptions, {
2491
- retryCount: 0
2492
- }, this.featureFlagsRequestTimeoutMs).then((response) => response.json()).then((response) => ({
3073
+ type: "required",
3074
+ consume: (response) => response.json()
3075
+ }, {
3076
+ retryCount: this.featureFlagsRequestMaxRetries,
3077
+ retryCheck: isRetryableFlagsFetchError
3078
+ }, this.featureFlagsRequestTimeoutMs).then((response) => ({
2493
3079
  success: true,
2494
3080
  response: normalizeFlagsResponse(response)
2495
3081
  })).catch((error) => {
@@ -2589,9 +3175,9 @@ class PostHogCoreStateless {
2589
3175
  }
2590
3176
  async getFeatureFlagDetailsStateless(distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip, flagKeysToEvaluate) {
2591
3177
  await this._initPromise;
2592
- const extraPayload = {};
2593
- if (disableGeoip ?? this.disableGeoip)
2594
- extraPayload["geoip_disable"] = true;
3178
+ const extraPayload = {
3179
+ geoip_disable: disableGeoip ?? this.disableGeoip
3180
+ };
2595
3181
  if (flagKeysToEvaluate)
2596
3182
  extraPayload["flag_keys_to_evaluate"] = flagKeysToEvaluate;
2597
3183
  const result = await this.getFlags(distinctId, groups, personProperties, groupProperties, extraPayload);
@@ -2628,15 +3214,18 @@ class PostHogCoreStateless {
2628
3214
  "Content-Type": "application/json"
2629
3215
  }
2630
3216
  };
2631
- const response = await this.fetchWithRetry(url, fetchOptions).then((response2) => {
2632
- if (response2.status !== 200 || !response2.json) {
2633
- const msg = `Surveys API could not be loaded: ${response2.status}`;
2634
- const error = new Error(msg);
2635
- this._logger.error(error);
2636
- this._events.emit("error", new Error(msg));
2637
- return;
3217
+ const response = await this.fetchWithRetry(url, fetchOptions, {
3218
+ type: "required",
3219
+ consume: (response) => {
3220
+ if (response.status !== 200 || !response.json) {
3221
+ const msg = `Surveys API could not be loaded: ${response.status}`;
3222
+ const error = new Error(msg);
3223
+ this._logger.error(error);
3224
+ this._events.emit("error", new Error(msg));
3225
+ return Promise.resolve(undefined);
3226
+ }
3227
+ return response.json();
2638
3228
  }
2639
- return response2.json();
2640
3229
  }).catch((error) => {
2641
3230
  this._logger.error("Surveys API could not be loaded", error);
2642
3231
  this._events.emit("error", error);
@@ -2673,23 +3262,39 @@ class PostHogCoreStateless {
2673
3262
  return message;
2674
3263
  }
2675
3264
  async flushStorage() {}
2676
- enqueue(type, _message, options) {
3265
+ getQueueRouteKey(_message) {
3266
+ return DEFAULT_QUEUE_ROUTE;
3267
+ }
3268
+ persistedQueueKeyForRoute(_route) {
3269
+ return types_PostHogPersistedProperty.Queue;
3270
+ }
3271
+ getActiveQueueRoutes() {
3272
+ return [
3273
+ DEFAULT_QUEUE_ROUTE
3274
+ ];
3275
+ }
3276
+ getRouteQueue(route) {
3277
+ return this.getPersistedProperty(this.persistedQueueKeyForRoute(route)) || [];
3278
+ }
3279
+ enqueue(type, _message, options, explicitRoute) {
2677
3280
  this.wrap(() => {
2678
3281
  if (this.optedOut)
2679
3282
  return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
2680
- let message = this.prepareMessage(type, _message, options);
3283
+ let message = this.prepareMessage(_message, options);
2681
3284
  message = this.processBeforeEnqueue(message);
2682
3285
  if (message === null)
2683
3286
  return;
2684
- const queue = this.getPersistedProperty(types_PostHogPersistedProperty.Queue) || [];
3287
+ message = this.normalizeMessage(message);
3288
+ const queueKey = this.persistedQueueKeyForRoute(explicitRoute ?? this.getQueueRouteKey(message));
3289
+ const queue = this.getPersistedProperty(queueKey) || [];
2685
3290
  if (queue.length >= this.maxQueueSize) {
2686
3291
  queue.shift();
2687
- this._logger.info("Queue is full, the oldest event is dropped.");
3292
+ this._logger.warn("Queue is full, the oldest event is dropped.");
2688
3293
  }
2689
3294
  queue.push({
2690
3295
  message
2691
3296
  });
2692
- this.setPersistedProperty(types_PostHogPersistedProperty.Queue, queue);
3297
+ this.setPersistedProperty(queueKey, queue);
2693
3298
  this._events.emit(type, message);
2694
3299
  if (queue.length >= this.flushAt)
2695
3300
  this.flushBackground();
@@ -2697,61 +3302,63 @@ class PostHogCoreStateless {
2697
3302
  this._flushTimer = safeSetTimeout(() => this.flushBackground(), this.flushInterval);
2698
3303
  });
2699
3304
  }
2700
- async sendImmediate(type, _message, options) {
3305
+ async sendImmediate(type, _message, options, explicitRoute) {
2701
3306
  if (this.disabled)
2702
3307
  return void this._logger.warn("The client is disabled");
2703
3308
  if (!this._isInitialized)
2704
3309
  await this._initPromise;
2705
3310
  if (this.optedOut)
2706
3311
  return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
2707
- let message = this.prepareMessage(type, _message, options);
3312
+ let message = this.prepareMessage(_message, options);
2708
3313
  message = this.processBeforeEnqueue(message);
2709
3314
  if (message === null)
2710
3315
  return;
2711
- const data = {
2712
- api_key: this.apiKey,
2713
- batch: [
2714
- message
2715
- ],
2716
- sent_at: currentISOTime()
2717
- };
2718
- if (this.historicalMigration)
2719
- data.historical_migration = true;
2720
- const payload = JSON.stringify(data);
2721
- const url = `${this.host}/batch/`;
2722
- const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
2723
- const fetchOptions = {
2724
- method: "POST",
2725
- headers: {
2726
- ...this.getCustomHeaders(),
2727
- "Content-Type": "application/json",
2728
- ...gzippedPayload !== null && {
2729
- "Content-Encoding": "gzip"
2730
- }
2731
- },
2732
- body: gzippedPayload || payload
2733
- };
3316
+ message = this.normalizeMessage(message);
2734
3317
  try {
2735
- const response = await this.fetchWithRetry(url, fetchOptions);
2736
- await response.body?.cancel()?.catch(() => {});
3318
+ await this.sendBatch([
3319
+ message
3320
+ ], undefined, explicitRoute ?? this.getQueueRouteKey(message));
2737
3321
  } catch (err) {
2738
3322
  this._events.emit("error", err);
2739
3323
  }
2740
3324
  }
2741
- prepareMessage(type, _message, options) {
3325
+ normalizeMessage(message) {
3326
+ const { type: _type, library, library_version, ...sanitizedMessage } = message;
3327
+ let properties = isPostHogEventProperties(sanitizedMessage.properties) ? sanitizedMessage.properties : undefined;
3328
+ if (library !== undefined && properties?.$lib === undefined)
3329
+ properties = {
3330
+ ...properties || {},
3331
+ $lib: library
3332
+ };
3333
+ if (library_version !== undefined && properties?.$lib_version === undefined)
3334
+ properties = {
3335
+ ...properties || {},
3336
+ $lib_version: library_version
3337
+ };
3338
+ if (properties)
3339
+ sanitizedMessage.properties = properties;
3340
+ sanitizedMessage.uuid = getEventUuid(sanitizedMessage.uuid, uuidv7);
3341
+ return sanitizedMessage;
3342
+ }
3343
+ normalizeTimestampForWire(timestamp) {
3344
+ const parsedTimestamp = timestamp instanceof Date ? timestamp : typeof timestamp == "string" ? new Date(timestamp) : null;
3345
+ if (!parsedTimestamp || Number.isNaN(parsedTimestamp.getTime()))
3346
+ return timestamp;
3347
+ const normalized = parsedTimestamp.toISOString();
3348
+ const fractionalSeconds = typeof timestamp == "string" ? timestamp.match(/\.(\d+)(?:Z|[+-]\d{2}:?\d{2})?$/i)?.[1] : undefined;
3349
+ return fractionalSeconds && fractionalSeconds.length > 3 ? normalized.replace(/\.\d{3}Z$/, `.${fractionalSeconds}Z`) : normalized;
3350
+ }
3351
+ prepareMessage(_message, options) {
2742
3352
  const message = {
2743
3353
  ..._message,
2744
- type,
2745
- library: this.getLibraryId(),
2746
- library_version: this.getLibraryVersion(),
2747
3354
  timestamp: options?.timestamp ? options?.timestamp : currentISOTime(),
2748
- uuid: options?.uuid ? options.uuid : uuidv7()
3355
+ uuid: getEventUuid(options?.uuid, uuidv7)
2749
3356
  };
2750
3357
  const addGeoipDisableProperty = options?.disableGeoip ?? this.disableGeoip;
2751
3358
  if (addGeoipDisableProperty) {
2752
- if (!message.properties)
3359
+ if (!isPostHogEventProperties(message.properties))
2753
3360
  message.properties = {};
2754
- message["properties"]["$geoip_disable"] = true;
3361
+ message.properties["$geoip_disable"] = true;
2755
3362
  }
2756
3363
  if (message.distinctId) {
2757
3364
  message.distinct_id = message.distinctId;
@@ -2766,21 +3373,64 @@ class PostHogCoreStateless {
2766
3373
  }
2767
3374
  }
2768
3375
  flushBackground() {
3376
+ if (this.pendingFlushPromise)
3377
+ return;
2769
3378
  this.flush().catch(async (err) => {
2770
3379
  await logFlushError(err);
2771
3380
  });
2772
3381
  }
2773
- async flush() {
3382
+ async waitForPendingPromises(maxPromiseId, ignoredPromises = []) {
3383
+ const ignoredPendingPromises = ignoredPromises.filter((promise) => !!promise);
3384
+ let iteration = 0;
3385
+ while (true) {
3386
+ const promises = this.promiseQueue.getPromises([
3387
+ ...ignoredPendingPromises,
3388
+ ...this.flushPromises
3389
+ ], maxPromiseId);
3390
+ if (promises.length === 0)
3391
+ return;
3392
+ if (iteration > 0)
3393
+ this._logger.debug(`flush() re-checking ${promises.length} pending promise(s) before flushing`);
3394
+ await Promise.all(promises.map((promise) => promise.catch(() => {})));
3395
+ iteration++;
3396
+ }
3397
+ }
3398
+ flushWithPendingPromises() {
3399
+ return this.flushInternal(true);
3400
+ }
3401
+ flush() {
3402
+ return this.flushInternal(false);
3403
+ }
3404
+ flushInternal(waitForPendingPromises) {
2774
3405
  if (this.disabled)
2775
- return;
2776
- const nextFlushPromise = allSettled([
2777
- this.flushPromise
2778
- ]).then(() => this._flush());
3406
+ return Promise.resolve();
3407
+ if (!waitForPendingPromises && this.pendingFlushPromise)
3408
+ return this.pendingFlushPromise;
3409
+ const previousFlushPromise = this.flushPromise;
3410
+ const maxPromiseId = this.promiseQueue.maxId;
3411
+ const nextFlushPromise = Promise.resolve().then(() => {
3412
+ if (waitForPendingPromises)
3413
+ return this.waitForPendingPromises(maxPromiseId, [
3414
+ previousFlushPromise,
3415
+ nextFlushPromise
3416
+ ]);
3417
+ }).then(() => allSettled([
3418
+ previousFlushPromise
3419
+ ])).then(() => {
3420
+ if (this.pendingFlushPromise === nextFlushPromise)
3421
+ this.pendingFlushPromise = null;
3422
+ return this._flush();
3423
+ });
3424
+ this.pendingFlushPromise = nextFlushPromise;
2779
3425
  this.flushPromise = nextFlushPromise;
3426
+ this.flushPromises.add(nextFlushPromise);
2780
3427
  this.addPendingPromise(nextFlushPromise);
2781
3428
  allSettled([
2782
3429
  nextFlushPromise
2783
3430
  ]).then(() => {
3431
+ this.flushPromises.delete(nextFlushPromise);
3432
+ if (this.pendingFlushPromise === nextFlushPromise)
3433
+ this.pendingFlushPromise = null;
2784
3434
  if (this.flushPromise === nextFlushPromise)
2785
3435
  this.flushPromise = null;
2786
3436
  });
@@ -2793,55 +3443,102 @@ class PostHogCoreStateless {
2793
3443
  headers["User-Agent"] = customUserAgent;
2794
3444
  return headers;
2795
3445
  }
3446
+ compressPayload(payload) {
3447
+ return gzipCompress(payload, this.isDebug);
3448
+ }
3449
+ getBatchEndpointPath(_route) {
3450
+ return "/batch/";
3451
+ }
3452
+ async sendBatch(batchMessages, retryOptions, route = DEFAULT_QUEUE_ROUTE) {
3453
+ const data = {
3454
+ api_key: this.apiKey,
3455
+ batch: batchMessages.map((message) => {
3456
+ if (!message)
3457
+ return message;
3458
+ const timestamp = this.normalizeTimestampForWire(message.timestamp);
3459
+ return timestamp === message.timestamp ? message : {
3460
+ ...message,
3461
+ timestamp
3462
+ };
3463
+ }),
3464
+ sent_at: currentISOTime()
3465
+ };
3466
+ if (this.historicalMigration)
3467
+ data.historical_migration = true;
3468
+ const payload = safeJsonStringify(data);
3469
+ const url = `${this.host}${this.getBatchEndpointPath(route)}`;
3470
+ const gzippedPayload = this.disableCompression ? null : await this.compressPayload(payload);
3471
+ const fetchOptions = {
3472
+ method: "POST",
3473
+ headers: {
3474
+ ...this.getCustomHeaders(),
3475
+ "Content-Type": "application/json",
3476
+ ...gzippedPayload !== null && {
3477
+ "Content-Encoding": "gzip"
3478
+ }
3479
+ },
3480
+ body: gzippedPayload || payload
3481
+ };
3482
+ await this.fetchWithRetry(url, fetchOptions, {
3483
+ type: "successful-write"
3484
+ }, retryOptions);
3485
+ }
2796
3486
  async _flush() {
2797
3487
  this.clearFlushTimer();
2798
3488
  await this._initPromise;
2799
- let queue = this.getPersistedProperty(types_PostHogPersistedProperty.Queue) || [];
2800
- if (!queue.length)
3489
+ const routes = this.getActiveQueueRoutes();
3490
+ if (!routes.some((route) => this.getRouteQueue(route).length > 0))
2801
3491
  return;
2802
3492
  const sentMessages = [];
3493
+ let firstError;
3494
+ for (const route of routes)
3495
+ try {
3496
+ await this._flushRoute(route, sentMessages);
3497
+ } catch (err) {
3498
+ if (firstError === undefined)
3499
+ firstError = err;
3500
+ }
3501
+ if (firstError !== undefined)
3502
+ throw firstError;
3503
+ this._events.emit("flush", sentMessages);
3504
+ }
3505
+ async _flushRoute(route, sentMessages) {
3506
+ const queueKey = this.persistedQueueKeyForRoute(route);
3507
+ let queue = this.getPersistedProperty(queueKey) || [];
3508
+ if (!queue.length)
3509
+ return;
2803
3510
  const originalQueueLength = queue.length;
2804
- while (queue.length > 0 && sentMessages.length < originalQueueLength) {
3511
+ let sentFromRoute = 0;
3512
+ while (queue.length > 0 && sentFromRoute < originalQueueLength) {
2805
3513
  const batchItems = queue.slice(0, this.maxBatchSize);
2806
- const batchMessages = batchItems.map((item) => item.message);
3514
+ const batchMessages = batchItems.map((item) => item.message === undefined ? item.message : this.normalizeMessage(item.message));
2807
3515
  const persistQueueChange = async () => {
2808
- const refreshedQueue = this.getPersistedProperty(types_PostHogPersistedProperty.Queue) || [];
2809
- const newQueue = refreshedQueue.slice(batchItems.length);
2810
- this.setPersistedProperty(types_PostHogPersistedProperty.Queue, newQueue);
3516
+ const refreshedQueue = this.getPersistedProperty(queueKey) || [];
3517
+ const remainingBatchItems = [
3518
+ ...batchItems
3519
+ ];
3520
+ const newQueue = refreshedQueue.filter((item) => {
3521
+ const itemUuid = item.message?.uuid;
3522
+ const batchItemIndex = remainingBatchItems.findIndex((batchItem) => batchItem === item || typeof itemUuid == "string" && itemUuid.length > 0 && batchItem.message?.uuid === itemUuid);
3523
+ if (batchItemIndex === -1)
3524
+ return true;
3525
+ remainingBatchItems.splice(batchItemIndex, 1);
3526
+ return false;
3527
+ });
3528
+ this.setPersistedProperty(queueKey, newQueue);
2811
3529
  queue = newQueue;
3530
+ this._dequeuedMessagesCount += batchItems.length;
2812
3531
  await this.flushStorage();
2813
3532
  };
2814
- const data = {
2815
- api_key: this.apiKey,
2816
- batch: batchMessages,
2817
- sent_at: currentISOTime()
2818
- };
2819
- if (this.historicalMigration)
2820
- data.historical_migration = true;
2821
- const payload = JSON.stringify(data);
2822
- const url = `${this.host}/batch/`;
2823
- const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
2824
- const fetchOptions = {
2825
- method: "POST",
2826
- headers: {
2827
- ...this.getCustomHeaders(),
2828
- "Content-Type": "application/json",
2829
- ...gzippedPayload !== null && {
2830
- "Content-Encoding": "gzip"
2831
- }
2832
- },
2833
- body: gzippedPayload || payload
2834
- };
2835
3533
  const retryOptions = {
2836
3534
  retryCheck: (err) => {
2837
3535
  if (isPostHogFetchContentTooLargeError(err))
2838
3536
  return false;
2839
- return isPostHogFetchError(err);
3537
+ return isPostHogFetchRetryableError(err);
2840
3538
  }
2841
3539
  };
2842
3540
  try {
2843
- const response = await this.fetchWithRetry(url, fetchOptions, retryOptions);
2844
- await response.body?.cancel()?.catch(() => {});
3541
+ await this.sendBatch(batchMessages, retryOptions, route);
2845
3542
  } catch (err) {
2846
3543
  if (isPostHogFetchContentTooLargeError(err) && batchMessages.length > 1) {
2847
3544
  this.maxBatchSize = Math.max(1, Math.floor(batchMessages.length / 2));
@@ -2855,8 +3552,8 @@ class PostHogCoreStateless {
2855
3552
  }
2856
3553
  await persistQueueChange();
2857
3554
  sentMessages.push(...batchMessages);
3555
+ sentFromRoute += batchMessages.length;
2858
3556
  }
2859
- this._events.emit("flush", sentMessages);
2860
3557
  }
2861
3558
  async _sendLogsBatch(payload) {
2862
3559
  if (this.disabled)
@@ -2866,7 +3563,7 @@ class PostHogCoreStateless {
2866
3563
  };
2867
3564
  const serialized = JSON.stringify(payload);
2868
3565
  const url = `${this.host}/i/v1/logs?token=${encodeURIComponent(this.apiKey)}`;
2869
- const gzippedPayload = this.disableCompression ? null : await gzipCompress(serialized, this.isDebug);
3566
+ const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
2870
3567
  const fetchOptions = {
2871
3568
  method: "POST",
2872
3569
  headers: {
@@ -2880,10 +3577,12 @@ class PostHogCoreStateless {
2880
3577
  };
2881
3578
  try {
2882
3579
  await this.fetchWithRetry(url, fetchOptions, {
3580
+ type: "successful-write"
3581
+ }, {
2883
3582
  retryCheck: (err) => {
2884
3583
  if (isPostHogFetchContentTooLargeError(err))
2885
3584
  return false;
2886
- return isPostHogFetchError(err);
3585
+ return isPostHogFetchRetryableError(err);
2887
3586
  }
2888
3587
  });
2889
3588
  return {
@@ -2905,41 +3604,155 @@ class PostHogCoreStateless {
2905
3604
  };
2906
3605
  }
2907
3606
  }
2908
- async fetchWithRetry(url, options, retryOptions, requestTimeout) {
3607
+ async _sendMetricsBatch(payload) {
3608
+ if (this.disabled)
3609
+ return {
3610
+ kind: "fatal",
3611
+ error: new Error("The client is disabled")
3612
+ };
3613
+ const serialized = JSON.stringify(payload);
3614
+ const url = `${this.host}/i/v1/metrics?token=${encodeURIComponent(this.apiKey)}`;
3615
+ const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
3616
+ const fetchOptions = {
3617
+ method: "POST",
3618
+ headers: {
3619
+ ...this.getCustomHeaders(),
3620
+ "Content-Type": "application/json",
3621
+ ...gzippedPayload !== null && {
3622
+ "Content-Encoding": "gzip"
3623
+ }
3624
+ },
3625
+ body: gzippedPayload || serialized
3626
+ };
3627
+ try {
3628
+ await this.fetchWithRetry(url, fetchOptions, {
3629
+ type: "successful-write"
3630
+ }, {
3631
+ retryCheck: (err) => {
3632
+ if (isPostHogFetchContentTooLargeError(err))
3633
+ return false;
3634
+ return isPostHogFetchRetryableError(err);
3635
+ }
3636
+ });
3637
+ return {
3638
+ kind: "ok"
3639
+ };
3640
+ } catch (err) {
3641
+ if (isPostHogFetchContentTooLargeError(err))
3642
+ return {
3643
+ kind: "too-large"
3644
+ };
3645
+ if (isPostHogFetchRetryableError(err))
3646
+ return {
3647
+ kind: "retry-later",
3648
+ error: err
3649
+ };
3650
+ return {
3651
+ kind: "fatal",
3652
+ error: err
3653
+ };
3654
+ }
3655
+ }
3656
+ async fetchWithRetry(url, options, responseHandling, retryOptions, requestTimeout) {
2909
3657
  const body = options.body ? options.body : "";
2910
3658
  let reqByteLength = -1;
2911
3659
  try {
2912
- reqByteLength = body instanceof Blob ? body.size : Buffer.byteLength(body, STRING_FORMAT);
3660
+ reqByteLength = body instanceof Blob ? body.size : body instanceof Uint8Array ? body.byteLength : Buffer.byteLength(body, STRING_FORMAT);
2913
3661
  } catch {
2914
3662
  if (body instanceof Blob)
2915
3663
  reqByteLength = body.size;
3664
+ else if (body instanceof Uint8Array)
3665
+ reqByteLength = body.byteLength;
2916
3666
  else {
2917
3667
  const encoded = new TextEncoder().encode(body);
2918
3668
  reqByteLength = encoded.length;
2919
3669
  }
2920
3670
  }
3671
+ const retriableOptions = {
3672
+ ...this._retryOptions,
3673
+ ...retryOptions
3674
+ };
3675
+ let attempt = 0;
2921
3676
  return await retriable(async () => {
3677
+ attempt++;
2922
3678
  const ctrl = new AbortController;
2923
3679
  const timeoutMs = requestTimeout ?? this.requestTimeout;
2924
- const timer = safeSetTimeout(() => ctrl.abort(), timeoutMs);
2925
- let res = null;
3680
+ const requestDeadline = Date.now() + timeoutMs;
3681
+ let timer;
3682
+ const deadline = new Promise((_resolve, reject) => {
3683
+ timer = safeSetTimeout(() => {
3684
+ const timeoutError = new Error(`Request timed out after ${timeoutMs}ms`);
3685
+ timeoutError.name = "AbortError";
3686
+ reject(timeoutError);
3687
+ ctrl.abort(timeoutError);
3688
+ }, timeoutMs);
3689
+ });
3690
+ let res;
3691
+ let responseAccepted = false;
3692
+ let cancellation;
3693
+ const cancelBody = () => cancellation ??= (async () => {
3694
+ try {
3695
+ await res?.body?.cancel();
3696
+ } catch {}
3697
+ })();
2926
3698
  try {
2927
- res = await this.fetch(url, {
2928
- signal: ctrl.signal,
2929
- ...options
2930
- });
2931
- } catch (e) {
2932
- throw new PostHogFetchNetworkError(e);
3699
+ let fetchPromise;
3700
+ try {
3701
+ fetchPromise = this.fetch(url, {
3702
+ signal: ctrl.signal,
3703
+ ...options
3704
+ });
3705
+ } catch (e) {
3706
+ throw new PostHogFetchNetworkError(e);
3707
+ }
3708
+ fetchPromise.then((lateResponse) => {
3709
+ if (ctrl.signal.aborted && !responseAccepted)
3710
+ Promise.resolve(lateResponse.body?.cancel()).catch(() => {});
3711
+ }).catch(() => {});
3712
+ try {
3713
+ res = await Promise.race([
3714
+ fetchPromise,
3715
+ deadline
3716
+ ]);
3717
+ responseAccepted = true;
3718
+ } catch (e) {
3719
+ throw new PostHogFetchNetworkError(e);
3720
+ }
3721
+ const isNoCors = options.mode === "no-cors";
3722
+ if (!isNoCors && (res.status < 200 || res.status >= 400))
3723
+ throw new PostHogFetchHttpError(res, reqByteLength, requestDeadline, ctrl);
3724
+ if (responseHandling.type === "successful-write") {
3725
+ try {
3726
+ await Promise.race([
3727
+ cancelBody(),
3728
+ deadline
3729
+ ]);
3730
+ } catch {}
3731
+ return;
3732
+ }
3733
+ try {
3734
+ return await Promise.race([
3735
+ responseHandling.consume(res),
3736
+ deadline
3737
+ ]);
3738
+ } catch (e) {
3739
+ if (ctrl.signal.aborted)
3740
+ throw new PostHogFetchNetworkError(e);
3741
+ throw e;
3742
+ }
2933
3743
  } finally {
2934
3744
  clearTimeout(timer);
3745
+ if (ctrl.signal.aborted && res)
3746
+ cancelBody();
2935
3747
  }
2936
- const isNoCors = options.mode === "no-cors";
2937
- if (!isNoCors && (res.status < 200 || res.status >= 400))
2938
- throw new PostHogFetchHttpError(res, reqByteLength);
2939
- return res;
2940
3748
  }, {
2941
- ...this._retryOptions,
2942
- ...retryOptions
3749
+ ...retriableOptions,
3750
+ retryCheck: (error) => {
3751
+ const shouldRetry = retriableOptions.retryCheck(error);
3752
+ if (shouldRetry && attempt <= retriableOptions.retryCount && error instanceof PostHogFetchHttpError)
3753
+ error.cancelResponseBody();
3754
+ return shouldRetry;
3755
+ }
2943
3756
  });
2944
3757
  }
2945
3758
  async _shutdown(shutdownTimeoutMs = 30000) {
@@ -2952,12 +3765,17 @@ class PostHogCoreStateless {
2952
3765
  try {
2953
3766
  await this.promiseQueue.join();
2954
3767
  while (true) {
2955
- const queue = this.getPersistedProperty(types_PostHogPersistedProperty.Queue) || [];
2956
- if (queue.length === 0)
3768
+ const hasQueuedEvents = this.getActiveQueueRoutes().some((route) => this.getRouteQueue(route).length > 0);
3769
+ if (!hasQueuedEvents)
2957
3770
  break;
3771
+ const dequeuedBeforeFlush = this._dequeuedMessagesCount;
2958
3772
  await this.flush();
2959
3773
  if (hasTimedOut)
2960
3774
  break;
3775
+ if (this._dequeuedMessagesCount === dequeuedBeforeFlush) {
3776
+ this._logger.warn("Shutdown flush completed but did not send any queued events. Stopping drain to avoid a loop.");
3777
+ break;
3778
+ }
2961
3779
  }
2962
3780
  } catch (e) {
2963
3781
  if (!isPostHogFetchError(e))
@@ -2965,21 +3783,12 @@ class PostHogCoreStateless {
2965
3783
  await logFlushError(e);
2966
3784
  }
2967
3785
  };
2968
- let timeoutHandle;
2969
- try {
2970
- return await Promise.race([
2971
- new Promise((_, reject) => {
2972
- timeoutHandle = safeSetTimeout(() => {
2973
- this._logger.error("Timed out while shutting down PostHog");
2974
- hasTimedOut = true;
2975
- reject("Timeout while shutting down PostHog. Some events may not have been sent.");
2976
- }, shutdownTimeoutMs);
2977
- }),
2978
- doShutdown()
2979
- ]);
2980
- } finally {
2981
- clearTimeout(timeoutHandle);
2982
- }
3786
+ return raceWithTimeout(doShutdown(), shutdownTimeoutMs, () => {
3787
+ this._logger.critical("Timeout while shutting down PostHog. Some events may not have been sent.", {
3788
+ shutdownTimeoutMs
3789
+ });
3790
+ hasTimedOut = true;
3791
+ });
2983
3792
  }
2984
3793
  async shutdown(shutdownTimeoutMs = 30000) {
2985
3794
  if (this.shutdownPromise)
@@ -2991,21 +3800,30 @@ class PostHogCoreStateless {
2991
3800
  return this.shutdownPromise;
2992
3801
  }
2993
3802
  }
2994
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
2995
- import { createReadStream } from "node:fs";
3803
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
3804
+ import { constants as constants2 } from "node:fs";
3805
+ import { open as promises_open } from "node:fs/promises";
3806
+ import { isAbsolute } from "node:path";
2996
3807
  import { createInterface } from "node:readline";
2997
- var LRU_FILE_CONTENTS_CACHE = new exports_error_tracking.ReduceableCache(25);
2998
- var LRU_FILE_CONTENTS_FS_READ_FAILED = new exports_error_tracking.ReduceableCache(20);
3808
+ var LRU_FILE_CONTENTS_CACHE = new ReduceableCache(25);
3809
+ var LRU_FILE_CONTENTS_FS_READ_FAILED = new ReduceableCache(20);
2999
3810
  var DEFAULT_LINES_OF_CONTEXT = 7;
3000
3811
  var MAX_CONTEXTLINES_COLNO = 1000;
3001
3812
  var MAX_CONTEXTLINES_LINENO = 1e4;
3002
- async function addSourceContext(frames) {
3813
+ var MAX_CONTEXTLINES_FILE_SIZE = 10485760;
3814
+ async function addSourceContext(frames, openSourceFile = promises_open, logger) {
3003
3815
  const filesToLines = {};
3816
+ let basePath;
3817
+ try {
3818
+ basePath = process.cwd();
3819
+ } catch {}
3004
3820
  for (let i = frames.length - 1;i >= 0; i--) {
3005
3821
  const frame = frames[i];
3006
3822
  const filename = frame?.filename;
3007
3823
  if (!frame || typeof filename != "string" || typeof frame.lineno != "number" || shouldSkipContextLinesForFile(filename) || shouldSkipContextLinesForFrame(frame))
3008
3824
  continue;
3825
+ if (!isAbsolute(filename) && basePath === undefined)
3826
+ continue;
3009
3827
  const filesToLinesOutput = filesToLines[filename];
3010
3828
  if (!filesToLinesOutput)
3011
3829
  filesToLines[filename] = [];
@@ -3016,50 +3834,98 @@ async function addSourceContext(frames) {
3016
3834
  return frames;
3017
3835
  const readlinePromises = [];
3018
3836
  for (const file of files) {
3019
- if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(file))
3837
+ const cacheKey = makeSourceCacheKey(file, basePath);
3838
+ if (cacheKey === undefined)
3839
+ continue;
3840
+ if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(cacheKey))
3020
3841
  continue;
3021
3842
  const filesToLineRanges = filesToLines[file];
3022
3843
  if (!filesToLineRanges)
3023
3844
  continue;
3024
3845
  filesToLineRanges.sort((a, b) => a - b);
3025
3846
  const ranges = makeLineReaderRanges(filesToLineRanges);
3026
- if (ranges.every((r) => rangeExistsInContentCache(file, r)))
3847
+ if (ranges.every((r) => rangeExistsInContentCache(cacheKey, r)))
3027
3848
  continue;
3028
- const cache = emplace(LRU_FILE_CONTENTS_CACHE, file, {});
3029
- readlinePromises.push(getContextLinesFromFile(file, ranges, cache));
3849
+ const cache = emplace(LRU_FILE_CONTENTS_CACHE, cacheKey, {});
3850
+ readlinePromises.push(getContextLinesFromFile(file, ranges, cache, cacheKey, openSourceFile, logger));
3030
3851
  }
3031
3852
  await Promise.all(readlinePromises).catch(() => {});
3032
3853
  if (frames && frames.length > 0)
3033
- addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE);
3854
+ addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE, basePath);
3034
3855
  LRU_FILE_CONTENTS_CACHE.reduce();
3035
3856
  return frames;
3036
3857
  }
3037
- function getContextLinesFromFile(path2, ranges, output) {
3858
+ async function openRegularSourceFile(path, openSourceFile, logger) {
3859
+ let fileHandle;
3860
+ let isValid = false;
3861
+ try {
3862
+ fileHandle = await openSourceFile(path, constants2.O_RDONLY | constants2.O_NONBLOCK);
3863
+ const fileStat = await fileHandle.stat();
3864
+ if (!fileStat.isFile())
3865
+ return;
3866
+ if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE)
3867
+ return void logger?.debug(`Skipping source context for oversized file ${path}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
3868
+ isValid = true;
3869
+ return fileHandle;
3870
+ } catch {
3871
+ return;
3872
+ } finally {
3873
+ if (fileHandle && !isValid)
3874
+ await fileHandle.close().catch(() => {});
3875
+ }
3876
+ }
3877
+ async function getContextLinesFromFile(path, ranges, output, cacheKey, openSourceFile, logger) {
3878
+ const fileHandle = await openRegularSourceFile(path, openSourceFile, logger);
3879
+ if (fileHandle === undefined)
3880
+ return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
3881
+ const openedFileHandle = fileHandle;
3038
3882
  return new Promise((resolve) => {
3039
- const stream = createReadStream(path2);
3040
- const lineReaded = createInterface({
3041
- input: stream
3042
- });
3043
- function destroyStreamAndResolve() {
3044
- stream.destroy();
3045
- resolve();
3883
+ let finished = false;
3884
+ function destroyStreamAndResolve(stream) {
3885
+ if (finished)
3886
+ return;
3887
+ finished = true;
3888
+ stream?.destroy();
3889
+ openedFileHandle.close().then(resolve, resolve);
3890
+ }
3891
+ let stream;
3892
+ try {
3893
+ stream = openedFileHandle.createReadStream({
3894
+ autoClose: false,
3895
+ start: 0,
3896
+ end: MAX_CONTEXTLINES_FILE_SIZE - 1
3897
+ });
3898
+ } catch {
3899
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
3900
+ destroyStreamAndResolve();
3901
+ return;
3902
+ }
3903
+ let lineReaded;
3904
+ try {
3905
+ lineReaded = createInterface({
3906
+ input: stream
3907
+ });
3908
+ } catch {
3909
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
3910
+ destroyStreamAndResolve(stream);
3911
+ return;
3046
3912
  }
3047
3913
  let lineNumber = 0;
3048
3914
  let currentRangeIndex = 0;
3049
3915
  const range = ranges[currentRangeIndex];
3050
3916
  if (range === undefined)
3051
- return void destroyStreamAndResolve();
3917
+ return void destroyStreamAndResolve(stream);
3052
3918
  let rangeStart = range[0];
3053
3919
  let rangeEnd = range[1];
3054
3920
  function onStreamError() {
3055
- LRU_FILE_CONTENTS_FS_READ_FAILED.set(path2, 1);
3921
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
3056
3922
  lineReaded.close();
3057
3923
  lineReaded.removeAllListeners();
3058
- destroyStreamAndResolve();
3924
+ destroyStreamAndResolve(stream);
3059
3925
  }
3060
3926
  stream.on("error", onStreamError);
3061
3927
  lineReaded.on("error", onStreamError);
3062
- lineReaded.on("close", destroyStreamAndResolve);
3928
+ lineReaded.on("close", () => destroyStreamAndResolve(stream));
3063
3929
  lineReaded.on("line", (line) => {
3064
3930
  lineNumber++;
3065
3931
  if (lineNumber < rangeStart)
@@ -3072,22 +3938,23 @@ function getContextLinesFromFile(path2, ranges, output) {
3072
3938
  return;
3073
3939
  }
3074
3940
  currentRangeIndex++;
3075
- const range2 = ranges[currentRangeIndex];
3076
- if (range2 === undefined) {
3941
+ const range = ranges[currentRangeIndex];
3942
+ if (range === undefined) {
3077
3943
  lineReaded.close();
3078
3944
  lineReaded.removeAllListeners();
3079
3945
  return;
3080
3946
  }
3081
- rangeStart = range2[0];
3082
- rangeEnd = range2[1];
3947
+ rangeStart = range[0];
3948
+ rangeEnd = range[1];
3083
3949
  }
3084
3950
  });
3085
3951
  });
3086
3952
  }
3087
- function addSourceContextToFrames(frames, cache) {
3953
+ function addSourceContextToFrames(frames, cache, basePath) {
3088
3954
  for (const frame of frames)
3089
3955
  if (frame.filename && frame.context_line === undefined && typeof frame.lineno == "number") {
3090
- const contents = cache.get(frame.filename);
3956
+ const cacheKey = makeSourceCacheKey(frame.filename, basePath);
3957
+ const contents = cacheKey === undefined ? undefined : cache.get(cacheKey);
3091
3958
  if (contents === undefined)
3092
3959
  continue;
3093
3960
  addContextToFrame(frame.lineno, frame, contents);
@@ -3120,8 +3987,8 @@ function clearLineContext(frame) {
3120
3987
  delete frame.context_line;
3121
3988
  delete frame.post_context;
3122
3989
  }
3123
- function shouldSkipContextLinesForFile(path2) {
3124
- return path2.startsWith("node:") || path2.endsWith(".min.js") || path2.endsWith(".min.cjs") || path2.endsWith(".min.mjs") || path2.startsWith("data:");
3990
+ function shouldSkipContextLinesForFile(path) {
3991
+ return path.startsWith("node:") || path.endsWith(".min.js") || path.endsWith(".min.cjs") || path.endsWith(".min.mjs") || path.startsWith("data:");
3125
3992
  }
3126
3993
  function shouldSkipContextLinesForFrame(frame) {
3127
3994
  if (frame.lineno !== undefined && frame.lineno > MAX_CONTEXTLINES_LINENO)
@@ -3130,8 +3997,19 @@ function shouldSkipContextLinesForFrame(frame) {
3130
3997
  return true;
3131
3998
  return false;
3132
3999
  }
3133
- function rangeExistsInContentCache(file, range) {
3134
- const contents = LRU_FILE_CONTENTS_CACHE.get(file);
4000
+ function makeSourceCacheKey(path, basePath) {
4001
+ if (isAbsolute(path))
4002
+ return JSON.stringify([
4003
+ null,
4004
+ path
4005
+ ]);
4006
+ return basePath === undefined ? undefined : JSON.stringify([
4007
+ basePath,
4008
+ path
4009
+ ]);
4010
+ }
4011
+ function rangeExistsInContentCache(cacheKey, range) {
4012
+ const contents = LRU_FILE_CONTENTS_CACHE.get(cacheKey);
3135
4013
  if (contents === undefined)
3136
4014
  return false;
3137
4015
  for (let i = range[0];i <= range[1]; i++)
@@ -3209,8 +4087,8 @@ function snipLine(line, colno) {
3209
4087
  return newLine;
3210
4088
  }
3211
4089
 
3212
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
3213
- import { isAbsolute, relative, sep as sep2 } from "node:path";
4090
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
4091
+ import { isAbsolute as isAbsolute2, relative, sep as sep2 } from "node:path";
3214
4092
  function createRelativePathModifier(basePath = process.cwd()) {
3215
4093
  const isWindows = sep2 === "\\";
3216
4094
  const toUnix = (p) => isWindows ? p.replace(/\\/g, "/") : p;
@@ -3218,17 +4096,17 @@ function createRelativePathModifier(basePath = process.cwd()) {
3218
4096
  return async (frames) => {
3219
4097
  for (const frame of frames)
3220
4098
  if (!(!frame.filename || frame.filename.startsWith("node:") || frame.filename.startsWith("data:"))) {
3221
- if (isAbsolute(frame.filename))
4099
+ if (isAbsolute2(frame.filename))
3222
4100
  frame.filename = toUnix(relative(normalizedBase, toUnix(frame.filename)));
3223
4101
  }
3224
4102
  return frames;
3225
4103
  };
3226
4104
  }
3227
4105
 
3228
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/version.mjs
3229
- var version = "5.35.12";
4106
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/version.mjs
4107
+ var version = "5.51.1";
3230
4108
 
3231
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/types.mjs
4109
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/types.mjs
3232
4110
  var FeatureFlagError2 = {
3233
4111
  ERRORS_WHILE_COMPUTING: "errors_while_computing_flags",
3234
4112
  FLAG_MISSING: "flag_missing",
@@ -3236,7 +4114,7 @@ var FeatureFlagError2 = {
3236
4114
  UNKNOWN_ERROR: "unknown_error"
3237
4115
  };
3238
4116
 
3239
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/feature-flag-evaluations.mjs
4117
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/feature-flag-evaluations.mjs
3240
4118
  class FeatureFlagEvaluations {
3241
4119
  constructor(init) {
3242
4120
  this._host = init.host;
@@ -3252,10 +4130,10 @@ class FeatureFlagEvaluations {
3252
4130
  this._accessed = init.accessed ?? new Set;
3253
4131
  this._isSlice = init.isSlice ?? false;
3254
4132
  }
3255
- isEnabled(key) {
4133
+ isEnabled(key, options = {}) {
3256
4134
  const flag = this._flags[key];
3257
4135
  this._recordAccess(key);
3258
- return flag?.enabled ?? false;
4136
+ return flag?.enabled ?? options.defaultValue ?? false;
3259
4137
  }
3260
4138
  getFlag(key) {
3261
4139
  const flag = this._flags[key];
@@ -3345,6 +4223,8 @@ class FeatureFlagEvaluations {
3345
4223
  $feature_flag_request_id: this._requestId,
3346
4224
  $feature_flag_evaluated_at: flag?.locallyEvaluated ? Date.now() : this._evaluatedAt
3347
4225
  };
4226
+ if (flag?.hasExperiment !== undefined)
4227
+ properties.$feature_flag_has_experiment = flag.hasExperiment;
3348
4228
  if (flag?.locallyEvaluated && this._flagDefinitionsLoadedAt !== undefined)
3349
4229
  properties.$feature_flag_definitions_loaded_at = this._flagDefinitionsLoadedAt;
3350
4230
  const errors = [];
@@ -3367,7 +4247,7 @@ class FeatureFlagEvaluations {
3367
4247
  }
3368
4248
  }
3369
4249
 
3370
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
4250
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
3371
4251
  async function hashSHA1(text) {
3372
4252
  const subtle = globalThis.crypto?.subtle;
3373
4253
  if (!subtle)
@@ -3377,7 +4257,7 @@ async function hashSHA1(text) {
3377
4257
  return hashArray.map((byte) => byte.toString(16).padStart(2, "0")).join("");
3378
4258
  }
3379
4259
 
3380
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
4260
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
3381
4261
  var SIXTY_SECONDS = 60000;
3382
4262
  var LONG_SCALE = 1152921504606847000;
3383
4263
  var NULL_VALUES_ALLOWED_OPERATORS = [
@@ -3394,22 +4274,23 @@ class ClientError extends Error {
3394
4274
  Object.setPrototypeOf(this, ClientError.prototype);
3395
4275
  }
3396
4276
  }
4277
+ function setCustomErrorPrototype(error, constructor) {
4278
+ error.name = constructor.name;
4279
+ Error.captureStackTrace(error, constructor);
4280
+ Object.setPrototypeOf(error, constructor.prototype);
4281
+ }
3397
4282
 
3398
4283
  class InconclusiveMatchError extends Error {
3399
4284
  constructor(message) {
3400
4285
  super(message);
3401
- this.name = this.constructor.name;
3402
- Error.captureStackTrace(this, this.constructor);
3403
- Object.setPrototypeOf(this, InconclusiveMatchError.prototype);
4286
+ setCustomErrorPrototype(this, InconclusiveMatchError);
3404
4287
  }
3405
4288
  }
3406
4289
 
3407
4290
  class RequiresServerEvaluation extends Error {
3408
4291
  constructor(message) {
3409
4292
  super(message);
3410
- this.name = this.constructor.name;
3411
- Error.captureStackTrace(this, this.constructor);
3412
- Object.setPrototypeOf(this, RequiresServerEvaluation.prototype);
4293
+ setCustomErrorPrototype(this, RequiresServerEvaluation);
3413
4294
  }
3414
4295
  }
3415
4296
 
@@ -3418,6 +4299,7 @@ class FeatureFlagsPoller {
3418
4299
  this.debugMode = false;
3419
4300
  this.shouldBeginExponentialBackoff = false;
3420
4301
  this.backOffCount = 0;
4302
+ this.pollerStopped = false;
3421
4303
  this.pollingInterval = pollingInterval;
3422
4304
  this.personalApiKey = personalApiKey;
3423
4305
  this.featureFlags = [];
@@ -3433,6 +4315,7 @@ class FeatureFlagsPoller {
3433
4315
  this.onError = options.onError;
3434
4316
  this.customHeaders = customHeaders;
3435
4317
  this.onLoad = options.onLoad;
4318
+ this.onMinimalFlagCalledEvents = options.onMinimalFlagCalledEvents;
3436
4319
  this.cacheProvider = options.cacheProvider;
3437
4320
  this.strictLocalEvaluation = options.strictLocalEvaluation ?? false;
3438
4321
  this.loadFeatureFlags();
@@ -3630,6 +4513,7 @@ class FeatureFlagsPoller {
3630
4513
  const flagFilters = flag.filters || {};
3631
4514
  const flagConditions = flagFilters.groups || [];
3632
4515
  const flagAggregation = flagFilters.aggregation_group_type_index;
4516
+ const earlyExitEnabled = flagFilters.early_exit ?? false;
3633
4517
  const { groups, groupProperties } = evaluationContext;
3634
4518
  let isInconclusive = false;
3635
4519
  let result;
@@ -3653,12 +4537,15 @@ class FeatureFlagsPoller {
3653
4537
  effectiveBucketingValue = groups[groupName];
3654
4538
  }
3655
4539
  }
3656
- if (await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext)) {
4540
+ const matchResult = await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext);
4541
+ if (matchResult === "match") {
3657
4542
  const variantOverride = condition.variant;
3658
4543
  const flagVariants = flagFilters.multivariate?.variants || [];
3659
4544
  result = variantOverride && flagVariants.some((variant) => variant.key === variantOverride) ? variantOverride : await this.getMatchingVariant(flag, effectiveBucketingValue) || true;
3660
4545
  break;
3661
4546
  }
4547
+ if (earlyExitEnabled && matchResult === "out_of_rollout_bound")
4548
+ return false;
3662
4549
  } catch (e) {
3663
4550
  if (e instanceof RequiresServerEvaluation)
3664
4551
  throw e;
@@ -3682,16 +4569,20 @@ class FeatureFlagsPoller {
3682
4569
  for (const prop of condition.properties) {
3683
4570
  const propertyType = prop.type;
3684
4571
  let matches = false;
3685
- matches = propertyType === "cohort" ? await matchCohort(prop, properties, this.cohorts, this.debugMode, (depProp) => this.evaluateFlagDependency(depProp, properties, evaluationContext)) : propertyType === "flag" ? await this.evaluateFlagDependency(prop, properties, evaluationContext) : matchProperty(prop, properties, warnFunction);
4572
+ if (propertyType === "cohort") {
4573
+ const inCohort = await matchCohort(prop, properties, this.cohorts, this.debugMode, (depProp) => this.evaluateFlagDependency(depProp, properties, evaluationContext));
4574
+ matches = prop.operator === "not_in" ? !inCohort : inCohort;
4575
+ } else
4576
+ matches = propertyType === "flag" ? await this.evaluateFlagDependency(prop, properties, evaluationContext) : matchProperty(prop, properties, warnFunction);
3686
4577
  if (!matches)
3687
- return false;
4578
+ return "no_match";
3688
4579
  }
3689
4580
  if (rolloutPercentage == undefined)
3690
- return true;
4581
+ return "match";
3691
4582
  }
3692
4583
  if (rolloutPercentage != null && await _hash(flag.key, bucketingValue) > rolloutPercentage / 100)
3693
- return false;
3694
- return true;
4584
+ return "out_of_rollout_bound";
4585
+ return "match";
3695
4586
  }
3696
4587
  async getMatchingVariant(flag, bucketingValue) {
3697
4588
  const hashValue = await _hash(flag.key, bucketingValue, "variant");
@@ -3722,6 +4613,7 @@ class FeatureFlagsPoller {
3722
4613
  this.groupTypeMapping = flagData.groupTypeMapping;
3723
4614
  this.cohorts = flagData.cohorts;
3724
4615
  this.loadedSuccessfullyOnce = true;
4616
+ this.onMinimalFlagCalledEvents?.(flagData.minimalFlagCalledEvents === true);
3725
4617
  }
3726
4618
  warnAboutExperienceContinuityFlags(flags) {
3727
4619
  if (this.strictLocalEvaluation)
@@ -3785,7 +4677,6 @@ class FeatureFlagsPoller {
3785
4677
  clearTimeout(this.poller);
3786
4678
  this.poller = undefined;
3787
4679
  }
3788
- this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
3789
4680
  try {
3790
4681
  let shouldFetch = true;
3791
4682
  if (this.cacheProvider)
@@ -3813,17 +4704,18 @@ class FeatureFlagsPoller {
3813
4704
  return;
3814
4705
  case 401:
3815
4706
  this.beginBackoff();
3816
- throw new ClientError(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);
4707
+ throw new ClientError(`Your project key or secret key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);
3817
4708
  case 402:
3818
4709
  console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts");
3819
4710
  this.featureFlags = [];
3820
4711
  this.featureFlagsByKey = {};
3821
4712
  this.groupTypeMapping = {};
3822
4713
  this.cohorts = {};
4714
+ this.onMinimalFlagCalledEvents?.(false);
3823
4715
  return;
3824
4716
  case 403:
3825
4717
  this.beginBackoff();
3826
- throw new ClientError(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);
4718
+ throw new ClientError(`Your secret key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct secret and Project API key pair? More information: https://posthog.com/docs/api/overview`);
3827
4719
  case 429:
3828
4720
  this.beginBackoff();
3829
4721
  throw new ClientError(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);
@@ -3835,7 +4727,8 @@ class FeatureFlagsPoller {
3835
4727
  const flagData = {
3836
4728
  flags: responseJson.flags ?? [],
3837
4729
  groupTypeMapping: responseJson.group_type_mapping || {},
3838
- cohorts: responseJson.cohorts || {}
4730
+ cohorts: responseJson.cohorts || {},
4731
+ minimalFlagCalledEvents: responseJson.minimal_flag_called_events === true
3839
4732
  };
3840
4733
  this.updateFlagState(flagData);
3841
4734
  this.flagDefinitionsLoadedAt = Date.now();
@@ -3856,6 +4749,9 @@ class FeatureFlagsPoller {
3856
4749
  } catch (err) {
3857
4750
  if (err instanceof ClientError)
3858
4751
  this.onError?.(err);
4752
+ } finally {
4753
+ if (!this.pollerStopped)
4754
+ this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
3859
4755
  }
3860
4756
  }
3861
4757
  getPersonalApiKeyRequestOptions(method = "GET", etag) {
@@ -3871,7 +4767,7 @@ class FeatureFlagsPoller {
3871
4767
  headers
3872
4768
  };
3873
4769
  }
3874
- _requestFeatureFlagDefinitions() {
4770
+ async _requestFeatureFlagDefinitions() {
3875
4771
  const url = `${this.host}/flags/definitions?token=${this.projectApiKey}&send_cohorts`;
3876
4772
  const options = this.getPersonalApiKeyRequestOptions("GET", this.flagsEtag);
3877
4773
  let abortTimeout = null;
@@ -3882,23 +4778,49 @@ class FeatureFlagsPoller {
3882
4778
  }, this.timeout);
3883
4779
  options.signal = controller.signal;
3884
4780
  }
4781
+ const clearAbortTimeout = () => clearTimeout(abortTimeout);
3885
4782
  try {
3886
4783
  const fetch1 = this.fetch;
3887
- return fetch1(url, options);
3888
- } finally {
3889
- clearTimeout(abortTimeout);
4784
+ const res = await fetch1(url, options);
4785
+ if (res.status !== 200) {
4786
+ clearAbortTimeout();
4787
+ return res;
4788
+ }
4789
+ return {
4790
+ status: res.status,
4791
+ headers: res.headers,
4792
+ body: res.body,
4793
+ text: async () => {
4794
+ try {
4795
+ return await res.text();
4796
+ } finally {
4797
+ clearAbortTimeout();
4798
+ }
4799
+ },
4800
+ json: async () => {
4801
+ try {
4802
+ return await res.json();
4803
+ } finally {
4804
+ clearAbortTimeout();
4805
+ }
4806
+ }
4807
+ };
4808
+ } catch (err) {
4809
+ clearAbortTimeout();
4810
+ throw err;
3890
4811
  }
3891
4812
  }
3892
4813
  async stopPoller(timeoutMs = 30000) {
4814
+ this.pollerStopped = true;
3893
4815
  clearTimeout(this.poller);
4816
+ this.poller = undefined;
3894
4817
  if (this.cacheProvider)
3895
4818
  try {
3896
4819
  const shutdownResult = this.cacheProvider.shutdown();
3897
4820
  if (shutdownResult instanceof Promise)
3898
- await Promise.race([
3899
- shutdownResult,
3900
- new Promise((_, reject) => setTimeout(() => reject(new Error(`Cache shutdown timeout after ${timeoutMs}ms`)), timeoutMs))
3901
- ]);
4821
+ await raceWithTimeout(shutdownResult, timeoutMs, () => {
4822
+ throw new Error(`Cache shutdown timeout after ${timeoutMs}ms`);
4823
+ });
3902
4824
  } catch (err) {
3903
4825
  this.onError?.(new Error(`Error during cache shutdown: ${err}`));
3904
4826
  }
@@ -3926,21 +4848,21 @@ function matchProperty(property, propertyValues, warnFunction) {
3926
4848
  warnFunction(`Property ${key} cannot have a value of null/undefined with the ${operator} operator`);
3927
4849
  return false;
3928
4850
  }
3929
- function computeExactMatch(value2, overrideValue2) {
3930
- if (Array.isArray(value2))
3931
- return value2.map((val) => String(val).toLowerCase()).includes(String(overrideValue2).toLowerCase());
3932
- return String(value2).toLowerCase() === String(overrideValue2).toLowerCase();
4851
+ function computeExactMatch(value, overrideValue) {
4852
+ if (Array.isArray(value))
4853
+ return value.map((val) => String(val).toLowerCase()).includes(String(overrideValue).toLowerCase());
4854
+ return String(value).toLowerCase() === String(overrideValue).toLowerCase();
3933
4855
  }
3934
- function compare(lhs, rhs, operator2) {
3935
- if (operator2 === "gt")
4856
+ function compare(lhs, rhs, operator) {
4857
+ if (operator === "gt")
3936
4858
  return lhs > rhs;
3937
- if (operator2 === "gte")
4859
+ if (operator === "gte")
3938
4860
  return lhs >= rhs;
3939
- if (operator2 === "lt")
4861
+ if (operator === "lt")
3940
4862
  return lhs < rhs;
3941
- if (operator2 === "lte")
4863
+ if (operator === "lte")
3942
4864
  return lhs <= rhs;
3943
- throw new Error(`Invalid operator: ${operator2}`);
4865
+ throw new Error(`Invalid operator: ${operator}`);
3944
4866
  }
3945
4867
  switch (operator) {
3946
4868
  case "exact":
@@ -3953,6 +4875,14 @@ function matchProperty(property, propertyValues, warnFunction) {
3953
4875
  return String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
3954
4876
  case "not_icontains":
3955
4877
  return !String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
4878
+ case "starts_with":
4879
+ return String(overrideValue).toLowerCase().startsWith(String(value).toLowerCase());
4880
+ case "not_starts_with":
4881
+ return !String(overrideValue).toLowerCase().startsWith(String(value).toLowerCase());
4882
+ case "ends_with":
4883
+ return String(overrideValue).toLowerCase().endsWith(String(value).toLowerCase());
4884
+ case "not_ends_with":
4885
+ return !String(overrideValue).toLowerCase().endsWith(String(value).toLowerCase());
3956
4886
  case "regex":
3957
4887
  return isValidRegex(String(value)) && String(overrideValue).match(String(value)) !== null;
3958
4888
  case "not_regex":
@@ -4279,19 +5209,75 @@ function relativeDateParseForFeatureFlagMatching(value) {
4279
5209
  }
4280
5210
  }
4281
5211
 
4282
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
5212
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
5213
+ var UNHANDLED_REJECTION_OPTION_NAMES = [
5214
+ "--unhandled-rejections",
5215
+ "--unhandled_rejections"
5216
+ ];
5217
+ var UNHANDLED_REJECTION_MODES = new Set([
5218
+ "throw",
5219
+ "strict",
5220
+ "warn",
5221
+ "warn-with-error-code",
5222
+ "none"
5223
+ ]);
5224
+ var STARTUP_EXEC_ARGV = [
5225
+ ...globalThis.process?.execArgv ?? []
5226
+ ];
5227
+ var STARTUP_NODE_OPTIONS = globalThis.process?.env?.NODE_OPTIONS;
5228
+ function splitNodeOptions(nodeOptions) {
5229
+ const args = [];
5230
+ let current = "";
5231
+ let isInString = false;
5232
+ for (let index = 0;index < nodeOptions.length; index++) {
5233
+ const character = nodeOptions[index];
5234
+ if (character === "\\" && isInString && index + 1 < nodeOptions.length)
5235
+ current += nodeOptions[++index];
5236
+ else if (character !== " " || isInString)
5237
+ if (character === '"')
5238
+ isInString = !isInString;
5239
+ else
5240
+ current += character;
5241
+ else if (current) {
5242
+ args.push(current);
5243
+ current = "";
5244
+ }
5245
+ }
5246
+ if (current)
5247
+ args.push(current);
5248
+ return args;
5249
+ }
5250
+ function findUnhandledRejectionMode(args) {
5251
+ let mode;
5252
+ for (let index = 0;index < args.length; index++) {
5253
+ const argument = args[index];
5254
+ const optionName = UNHANDLED_REJECTION_OPTION_NAMES.find((name) => argument === name || argument.startsWith(`${name}=`));
5255
+ if (!optionName)
5256
+ continue;
5257
+ const value = argument === optionName ? args[++index] : argument.slice(optionName.length + 1);
5258
+ if (UNHANDLED_REJECTION_MODES.has(value))
5259
+ mode = value;
5260
+ }
5261
+ return mode;
5262
+ }
5263
+ function getUnhandledRejectionMode(execArgv = STARTUP_EXEC_ARGV, nodeOptions = STARTUP_NODE_OPTIONS) {
5264
+ return findUnhandledRejectionMode(execArgv) ?? findUnhandledRejectionMode(splitNodeOptions(nodeOptions ?? "")) ?? "throw";
5265
+ }
5266
+ var STARTUP_UNHANDLED_REJECTION_MODE = getUnhandledRejectionMode();
5267
+ function captureUncaughtException(captureFn, error, origin) {
5268
+ captureFn(error, {
5269
+ mechanism: {
5270
+ type: origin === "unhandledRejection" ? "onunhandledrejection" : "onuncaughtexception",
5271
+ handled: false
5272
+ }
5273
+ });
5274
+ }
4283
5275
  function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
4284
5276
  let calledFatalError = false;
4285
- return Object.assign((error) => {
5277
+ return Object.assign((error, origin) => {
4286
5278
  const userProvidedListenersCount = global.process.listeners("uncaughtException").filter((listener) => listener.name !== "domainUncaughtExceptionClear" && listener._posthogErrorHandler !== true).length;
4287
- const processWouldExit = userProvidedListenersCount === 0;
4288
- captureFn(error, {
4289
- mechanism: {
4290
- type: "onuncaughtexception",
4291
- handled: false
4292
- }
4293
- });
4294
- if (!calledFatalError && processWouldExit) {
5279
+ captureUncaughtException(captureFn, error, origin);
5280
+ if (!calledFatalError && userProvidedListenersCount === 0) {
4295
5281
  calledFatalError = true;
4296
5282
  onFatalFn(error);
4297
5283
  }
@@ -4299,29 +5285,38 @@ function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
4299
5285
  _posthogErrorHandler: true
4300
5286
  });
4301
5287
  }
4302
- function addUncaughtExceptionListener(captureFn, onFatalFn) {
4303
- globalThis.process?.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
5288
+ function addUncaughtExceptionListener(captureFn, onFatalFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
5289
+ const process2 = globalThis.process;
5290
+ if (!process2)
5291
+ return;
5292
+ if (mode === "strict")
5293
+ return void process2.on("uncaughtExceptionMonitor", (error, origin) => captureUncaughtException(captureFn, error, origin));
5294
+ process2.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
4304
5295
  }
4305
- function addUnhandledRejectionListener(captureFn) {
4306
- globalThis.process?.on("unhandledRejection", (reason) => captureFn(reason, {
4307
- mechanism: {
4308
- type: "onunhandledrejection",
4309
- handled: false
4310
- }
4311
- }));
5296
+ function addUnhandledRejectionListener(captureFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
5297
+ const process2 = globalThis.process;
5298
+ if (!process2 || mode === "throw" || mode === "strict" || mode === "warn-with-error-code")
5299
+ return;
5300
+ process2.on("unhandledRejection", (reason) => {
5301
+ captureFn(reason, {
5302
+ mechanism: {
5303
+ type: "onunhandledrejection",
5304
+ handled: false
5305
+ }
5306
+ });
5307
+ });
4312
5308
  }
4313
5309
 
4314
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
5310
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
4315
5311
  var SHUTDOWN_TIMEOUT = 2000;
4316
5312
 
4317
- class ErrorTracking {
5313
+ class error_tracking_ErrorTracking {
4318
5314
  constructor(client, options, _logger) {
4319
5315
  this.client = client;
4320
5316
  this._exceptionAutocaptureEnabled = options.enableExceptionAutocapture || false;
4321
5317
  this._logger = _logger;
4322
5318
  this._rateLimiter = new BucketedRateLimiter({
4323
- refillRate: 1,
4324
- bucketSize: 10,
5319
+ ...resolveExceptionRateLimiterConfig(options),
4325
5320
  refillInterval: 1e4,
4326
5321
  _logger: this._logger
4327
5322
  });
@@ -4336,6 +5331,9 @@ class ErrorTracking {
4336
5331
  };
4337
5332
  const exceptionProperties = builder.buildFromUnknown(error, hint);
4338
5333
  exceptionProperties.$exception_list = await builder.modifyFrames(exceptionProperties.$exception_list);
5334
+ const injectedReleaseId = getInjectedReleaseId();
5335
+ if (injectedReleaseId)
5336
+ properties.$release_id = injectedReleaseId;
4339
5337
  return {
4340
5338
  event: "$exception",
4341
5339
  distinctId,
@@ -4354,8 +5352,8 @@ class ErrorTracking {
4354
5352
  }
4355
5353
  onException(exception, hint) {
4356
5354
  this.client.addPendingPromise((async () => {
4357
- if (!ErrorTracking.isPreviouslyCapturedError(exception)) {
4358
- const eventMessage = await ErrorTracking.buildEventMessage(this.client.getErrorPropertiesBuilder(), exception, hint);
5355
+ if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(exception)) {
5356
+ const eventMessage = await error_tracking_ErrorTracking.buildEventMessage(this.client.getErrorPropertiesBuilder(), exception, hint);
4359
5357
  const exceptionProperties = eventMessage.properties;
4360
5358
  const exceptionType = exceptionProperties?.$exception_list[0]?.type ?? "Exception";
4361
5359
  const isRateLimited = this._rateLimiter.consumeRateLimit(exceptionType);
@@ -4363,14 +5361,14 @@ class ErrorTracking {
4363
5361
  return void this._logger.info("Skipping exception capture because of client rate limiting.", {
4364
5362
  exception: exceptionType
4365
5363
  });
4366
- return this.client.capture(eventMessage);
5364
+ return this.client._capturePreparedEvent(eventMessage, false);
4367
5365
  }
4368
5366
  })());
4369
5367
  }
4370
5368
  async onFatalError(exception) {
4371
5369
  console.error(exception);
4372
5370
  await this.client.shutdown(SHUTDOWN_TIMEOUT);
4373
- process.exit(1);
5371
+ globalThis.process.exit(1);
4374
5372
  }
4375
5373
  isEnabled() {
4376
5374
  return !this.client.isDisabled && this._exceptionAutocaptureEnabled;
@@ -4380,7 +5378,7 @@ class ErrorTracking {
4380
5378
  }
4381
5379
  }
4382
5380
 
4383
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/storage-memory.mjs
5381
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/storage-memory.mjs
4384
5382
  class PostHogMemoryStorage {
4385
5383
  getProperty(key) {
4386
5384
  return this._memoryStorage[key];
@@ -4393,7 +5391,452 @@ class PostHogMemoryStorage {
4393
5391
  }
4394
5392
  }
4395
5393
 
4396
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/client.mjs
5394
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/config.mjs
5395
+ function isCaptureMode(value) {
5396
+ return value === "v0" || value === "v1";
5397
+ }
5398
+ function resolveCaptureMode() {
5399
+ const envMode = typeof process != "undefined" ? process.env?.POSTHOG_CAPTURE_MODE : undefined;
5400
+ return isCaptureMode(envMode) ? envMode : "v0";
5401
+ }
5402
+
5403
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/routing.mjs
5404
+ var AI_EVENT_PREFIX = "$ai_";
5405
+ var ANALYTICS_ROUTE = "analytics";
5406
+ var AI_ROUTE = "ai";
5407
+ function isLegacyOnlyEvent(message) {
5408
+ return typeof message.event == "string" && message.event.startsWith(AI_EVENT_PREFIX);
5409
+ }
5410
+
5411
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/errors.mjs
5412
+ class CaptureV1Error extends Error {
5413
+ constructor({ requestId, drops, retryExhausted, cause }) {
5414
+ super(CaptureV1Error.buildMessage(requestId, drops, retryExhausted, cause)), this.name = "CaptureV1Error";
5415
+ this.requestId = requestId;
5416
+ this.drops = drops;
5417
+ this.retryExhausted = retryExhausted;
5418
+ this.cause = cause;
5419
+ }
5420
+ static buildMessage(requestId, drops, retryExhausted, cause) {
5421
+ let message = `Capture V1 batch ${requestId} did not fully deliver: ${drops.length} dropped, ${retryExhausted.length} undelivered`;
5422
+ if (cause instanceof Error)
5423
+ message += ` (${cause.message})`;
5424
+ return message;
5425
+ }
5426
+ }
5427
+
5428
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/transform.mjs
5429
+ function coerceBool(value) {
5430
+ if (typeof value == "boolean")
5431
+ return value;
5432
+ if (typeof value == "number")
5433
+ return value !== 0;
5434
+ if (typeof value == "string") {
5435
+ const normalized = value.trim().toLowerCase();
5436
+ if (normalized === "true" || normalized === "1")
5437
+ return true;
5438
+ if (normalized === "false" || normalized === "0")
5439
+ return false;
5440
+ }
5441
+ }
5442
+ function coerceString(value) {
5443
+ return typeof value == "string" ? value : undefined;
5444
+ }
5445
+ var OPTION_SENTINELS = [
5446
+ {
5447
+ property: "$cookieless_mode",
5448
+ optionKey: "cookieless_mode",
5449
+ coerce: coerceBool
5450
+ },
5451
+ {
5452
+ property: "$ignore_sent_at",
5453
+ optionKey: "disable_skew_correction",
5454
+ coerce: coerceBool
5455
+ },
5456
+ {
5457
+ property: "$process_person_profile",
5458
+ optionKey: "process_person_profile",
5459
+ coerce: coerceBool
5460
+ },
5461
+ {
5462
+ property: "$product_tour_id",
5463
+ optionKey: "product_tour_id",
5464
+ coerce: coerceString
5465
+ }
5466
+ ];
5467
+ var TOPLEVEL_SENTINELS = [
5468
+ {
5469
+ property: "$session_id",
5470
+ field: "session_id"
5471
+ },
5472
+ {
5473
+ property: "$window_id",
5474
+ field: "window_id"
5475
+ }
5476
+ ];
5477
+ function isRecord2(value) {
5478
+ return typeof value == "object" && value !== null && !Array.isArray(value);
5479
+ }
5480
+ function toRfc3339(timestamp) {
5481
+ if (typeof timestamp == "string") {
5482
+ const asDate = new Date(timestamp);
5483
+ if (Number.isNaN(asDate.getTime()))
5484
+ return new Date().toISOString();
5485
+ const normalized = asDate.toISOString();
5486
+ const fractionalSeconds = timestamp.match(/\.(\d+)(?:Z|[+-]\d{2}:?\d{2})?$/i)?.[1];
5487
+ return fractionalSeconds && fractionalSeconds.length > 3 ? normalized.replace(/\.\d{3}Z$/, `.${fractionalSeconds}Z`) : normalized;
5488
+ }
5489
+ if (timestamp instanceof Date)
5490
+ return Number.isNaN(timestamp.getTime()) ? new Date().toISOString() : timestamp.toISOString();
5491
+ const asDate = timestamp == null ? new Date : new Date(timestamp);
5492
+ return Number.isNaN(asDate.getTime()) ? new Date().toISOString() : asDate.toISOString();
5493
+ }
5494
+ function relocateInto(properties, key, value) {
5495
+ if (value !== undefined && !(key in properties))
5496
+ properties[key] = value;
5497
+ }
5498
+ function buildV1Event(message) {
5499
+ const sourceProperties = isRecord2(message.properties) ? message.properties : {};
5500
+ const properties = {
5501
+ ...sourceProperties
5502
+ };
5503
+ const options = {};
5504
+ for (const { property, optionKey, coerce } of OPTION_SENTINELS)
5505
+ if (property in properties) {
5506
+ const coerced = coerce(properties[property]);
5507
+ if (coerced !== undefined)
5508
+ options[optionKey] = coerced;
5509
+ delete properties[property];
5510
+ }
5511
+ const topLevel = {};
5512
+ for (const { property, field } of TOPLEVEL_SENTINELS)
5513
+ if (property in properties) {
5514
+ const value = properties[property];
5515
+ if (typeof value == "string")
5516
+ topLevel[field] = value;
5517
+ delete properties[property];
5518
+ }
5519
+ delete properties.$lib;
5520
+ delete properties.$lib_version;
5521
+ relocateInto(properties, "$set", message.$set);
5522
+ relocateInto(properties, "$set_once", message.$set_once);
5523
+ return {
5524
+ event: String(message.event ?? ""),
5525
+ uuid: String(message.uuid ?? ""),
5526
+ distinct_id: String(message.distinct_id ?? ""),
5527
+ timestamp: toRfc3339(message.timestamp),
5528
+ ...topLevel,
5529
+ options,
5530
+ properties
5531
+ };
5532
+ }
5533
+ function buildV1Batch(messages, { createdAt, historicalMigration }) {
5534
+ const batch = {
5535
+ created_at: createdAt,
5536
+ batch: messages.map(buildV1Event)
5537
+ };
5538
+ if (historicalMigration)
5539
+ batch.historical_migration = true;
5540
+ return batch;
5541
+ }
5542
+
5543
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/sender.mjs
5544
+ var V1_ANALYTICS_PATH = "/i/v1/analytics/events";
5545
+ var DEFAULT_MAX_BACKOFF_MS = 30000;
5546
+ var RETRYABLE_STATUSES = new Set([
5547
+ 408,
5548
+ 500,
5549
+ 502,
5550
+ 503,
5551
+ 504
5552
+ ]);
5553
+
5554
+ class V1CaptureSender {
5555
+ constructor(config, hooks) {
5556
+ this.config = config;
5557
+ this.maxBackoffMs = config.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS;
5558
+ this.fetchFn = hooks.fetch;
5559
+ this.onError = hooks.onError;
5560
+ this.now = hooks.now ?? Date.now;
5561
+ this.sleep = hooks.sleep ?? ((ms) => new Promise((resolve) => safeSetTimeout(resolve, ms)));
5562
+ this.generateRequestId = hooks.generateRequestId ?? uuidv7;
5563
+ this.compress = hooks.compress ?? gzipCompress;
5564
+ }
5565
+ async sendV1Batch(messages) {
5566
+ if (messages.length === 0)
5567
+ return;
5568
+ const requestId = this.generateRequestId();
5569
+ const createdAt = new Date(this.now()).toISOString();
5570
+ const { batch } = buildV1Batch(messages, {
5571
+ createdAt,
5572
+ historicalMigration: this.config.historicalMigration
5573
+ });
5574
+ const url = `${this.config.host}${V1_ANALYTICS_PATH}`;
5575
+ const drops = [];
5576
+ let pending = batch;
5577
+ const maxAttempts = Math.max(1, this.config.maxAttempts);
5578
+ for (let attempt = 1;attempt <= maxAttempts; attempt++) {
5579
+ const isLastAttempt = attempt === maxAttempts;
5580
+ const payload = safeJsonStringify({
5581
+ created_at: createdAt,
5582
+ ...this.config.historicalMigration ? {
5583
+ historical_migration: true
5584
+ } : {},
5585
+ batch: pending
5586
+ });
5587
+ let captureAttempt;
5588
+ let retryDelayMs;
5589
+ try {
5590
+ captureAttempt = await this.sendOnce(url, payload, attempt, requestId);
5591
+ const { response, signal } = captureAttempt;
5592
+ const { status } = response;
5593
+ if (status < 200 || status >= 300)
5594
+ if (!isLastAttempt && RETRYABLE_STATUSES.has(status)) {
5595
+ const retryAfterMs = this.parseRetryAfter(response);
5596
+ await captureAttempt.waitFor(captureAttempt.cancelBody()).catch(() => {});
5597
+ retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
5598
+ } else {
5599
+ const httpError = await this.buildHttpError(response, status, captureAttempt.waitFor);
5600
+ return this.surfaceBatchFailure(requestId, drops, pending, httpError);
5601
+ }
5602
+ else {
5603
+ let parsed;
5604
+ try {
5605
+ parsed = await captureAttempt.waitFor(this.parseResponse(response));
5606
+ } catch (error) {
5607
+ if (signal.aborted)
5608
+ throw error;
5609
+ return this.surfaceBatchFailure(requestId, drops, pending, new Error(`Capture V1 returned an unparseable ${status} response body`));
5610
+ }
5611
+ const retryable = this.classify(pending, parsed, drops);
5612
+ if (retryable.length === 0)
5613
+ return this.surfacePartialDrops(requestId, drops);
5614
+ if (isLastAttempt)
5615
+ return void this.onError(new CaptureV1Error({
5616
+ requestId,
5617
+ drops,
5618
+ retryExhausted: retryable.map((event) => event.uuid)
5619
+ }));
5620
+ pending = retryable;
5621
+ const retryAfterMs = this.parseRetryAfter(response);
5622
+ retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
5623
+ }
5624
+ } catch (transportError) {
5625
+ if (captureAttempt && !captureAttempt.signal.aborted)
5626
+ throw transportError;
5627
+ if (isLastAttempt)
5628
+ return this.surfaceBatchFailure(requestId, drops, pending, transportError);
5629
+ retryDelayMs = this.backoffDelay(attempt);
5630
+ } finally {
5631
+ captureAttempt?.cleanup();
5632
+ }
5633
+ if (retryDelayMs !== undefined)
5634
+ await this.sleep(retryDelayMs);
5635
+ }
5636
+ }
5637
+ async sendOnce(url, payload, attempt, requestId) {
5638
+ const headers = this.buildHeaders(attempt, requestId);
5639
+ let body = payload;
5640
+ if (this.config.compressionEnabled) {
5641
+ const compressed = await this.compress(payload, this.config.isDebug);
5642
+ if (compressed !== null) {
5643
+ body = compressed;
5644
+ headers["Content-Encoding"] = "gzip";
5645
+ }
5646
+ }
5647
+ const controller = new AbortController;
5648
+ let timeoutPhase = "waiting for response headers";
5649
+ let timer;
5650
+ const deadline = new Promise((_resolve, reject) => {
5651
+ timer = safeSetTimeout(() => {
5652
+ const timeoutError = new Error(`Capture V1 request timed out ${timeoutPhase} after ${this.config.requestTimeoutMs}ms`);
5653
+ timeoutError.name = "AbortError";
5654
+ reject(timeoutError);
5655
+ controller.abort(timeoutError);
5656
+ }, this.config.requestTimeoutMs);
5657
+ });
5658
+ try {
5659
+ const fetchPromise = this.fetchFn(url, {
5660
+ method: "POST",
5661
+ headers,
5662
+ body,
5663
+ signal: controller.signal
5664
+ });
5665
+ let responseAccepted = false;
5666
+ fetchPromise.then((lateResponse) => {
5667
+ if (controller.signal.aborted && !responseAccepted)
5668
+ this.cancelBody(lateResponse);
5669
+ }).catch(() => {});
5670
+ const response = await Promise.race([
5671
+ fetchPromise,
5672
+ deadline
5673
+ ]);
5674
+ responseAccepted = true;
5675
+ timeoutPhase = "while reading the response body";
5676
+ let cleanedUp = false;
5677
+ let cancellation;
5678
+ const cancelBody = () => cancellation ??= this.cancelBody(response);
5679
+ return {
5680
+ response,
5681
+ signal: controller.signal,
5682
+ waitFor: (operation) => Promise.race([
5683
+ operation,
5684
+ deadline
5685
+ ]),
5686
+ cancelBody,
5687
+ cleanup: () => {
5688
+ if (cleanedUp)
5689
+ return;
5690
+ cleanedUp = true;
5691
+ clearTimeout(timer);
5692
+ if (controller.signal.aborted)
5693
+ cancelBody();
5694
+ }
5695
+ };
5696
+ } catch (error) {
5697
+ clearTimeout(timer);
5698
+ throw error;
5699
+ }
5700
+ }
5701
+ buildHeaders(attempt, requestId) {
5702
+ const sdkInfo = `${this.config.libraryId}/${this.config.libraryVersion}`;
5703
+ const headers = {
5704
+ "Content-Type": "application/json",
5705
+ Authorization: `Bearer ${this.config.apiKey}`,
5706
+ "PostHog-Sdk-Info": sdkInfo,
5707
+ "PostHog-Attempt": String(attempt),
5708
+ "PostHog-Request-Id": requestId,
5709
+ "PostHog-Request-Timestamp": new Date(this.now()).toISOString()
5710
+ };
5711
+ if (this.config.userAgent)
5712
+ headers["User-Agent"] = this.config.userAgent;
5713
+ return headers;
5714
+ }
5715
+ classify(pending, parsed, drops) {
5716
+ const results = parsed.results ?? {};
5717
+ const retryable = [];
5718
+ for (const event of pending) {
5719
+ const result = results[event.uuid];
5720
+ if (result) {
5721
+ if (result.result === "drop")
5722
+ drops.push({
5723
+ uuid: event.uuid,
5724
+ details: result.details ?? undefined
5725
+ });
5726
+ else if (result.result === "retry")
5727
+ retryable.push(event);
5728
+ }
5729
+ }
5730
+ return retryable;
5731
+ }
5732
+ backoffDelay(attempt, retryAfterMs) {
5733
+ const exponential = Math.min(this.config.initialRetryDelayMs * 2 ** (attempt - 1), this.maxBackoffMs);
5734
+ if (retryAfterMs === undefined)
5735
+ return exponential;
5736
+ return Math.max(exponential, Math.min(retryAfterMs, this.maxBackoffMs));
5737
+ }
5738
+ parseRetryAfter(response) {
5739
+ const raw = response.headers?.get("Retry-After");
5740
+ if (!raw)
5741
+ return;
5742
+ const trimmed = raw.trim();
5743
+ if (/^\d+$/.test(trimmed)) {
5744
+ const seconds = parseInt(trimmed, 10);
5745
+ return Number.isFinite(seconds) && seconds > 0 ? 1000 * seconds : undefined;
5746
+ }
5747
+ const dateMs = Date.parse(trimmed);
5748
+ if (Number.isNaN(dateMs))
5749
+ return;
5750
+ const delta = dateMs - this.now();
5751
+ return delta > 0 ? delta : undefined;
5752
+ }
5753
+ async parseResponse(response) {
5754
+ const text = await response.text();
5755
+ const parsed = JSON.parse(text);
5756
+ if (typeof parsed != "object" || parsed === null || Array.isArray(parsed))
5757
+ throw new Error("unexpected response shape");
5758
+ const results = parsed.results;
5759
+ if (results !== undefined && (typeof results != "object" || results === null || Array.isArray(results)))
5760
+ throw new Error("unexpected results shape");
5761
+ return {
5762
+ results: results ?? {}
5763
+ };
5764
+ }
5765
+ async buildHttpError(response, status, waitFor) {
5766
+ let bodyText = "";
5767
+ try {
5768
+ bodyText = (await waitFor(response.text())).slice(0, 512);
5769
+ } catch {}
5770
+ const suffix = bodyText ? `: ${bodyText}` : "";
5771
+ return new Error(`Capture V1 request failed with HTTP ${status}${suffix}`);
5772
+ }
5773
+ surfaceBatchFailure(requestId, drops, pending, cause) {
5774
+ this.onError(new CaptureV1Error({
5775
+ requestId,
5776
+ drops,
5777
+ retryExhausted: pending.map((event) => event.uuid),
5778
+ cause
5779
+ }));
5780
+ }
5781
+ surfacePartialDrops(requestId, drops) {
5782
+ if (drops.length > 0)
5783
+ this.onError(new CaptureV1Error({
5784
+ requestId,
5785
+ drops,
5786
+ retryExhausted: []
5787
+ }));
5788
+ }
5789
+ async cancelBody(response) {
5790
+ try {
5791
+ await response.body?.cancel();
5792
+ } catch {}
5793
+ }
5794
+ }
5795
+
5796
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/ai-capture/routing.mjs
5797
+ var AI_CAPTURE_ROUTE = "ai-capture";
5798
+ var AI_CAPTURE_ENDPOINT_PATH = "/i/v0/ai/batch/";
5799
+ var AI_MAX_EVENT_BYTES = 8388608;
5800
+ var AI_BATCH_TARGET_BYTES = 5242880;
5801
+
5802
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/ai-capture/batching.mjs
5803
+ var encoder = new TextEncoder;
5804
+ function eventByteSize(message) {
5805
+ return encoder.encode(safeJsonStringify(message)).length;
5806
+ }
5807
+ function partitionAiBatch(messages, maxEventBytes = AI_MAX_EVENT_BYTES, targetBatchBytes = AI_BATCH_TARGET_BYTES) {
5808
+ const batches = [];
5809
+ const dropped = [];
5810
+ let current = [];
5811
+ let currentBytes = 0;
5812
+ for (const message of messages) {
5813
+ if (message === undefined)
5814
+ continue;
5815
+ const bytes = eventByteSize(message);
5816
+ if (bytes > maxEventBytes) {
5817
+ dropped.push({
5818
+ event: typeof message.event == "string" ? message.event : "unknown",
5819
+ bytes
5820
+ });
5821
+ continue;
5822
+ }
5823
+ if (current.length > 0 && currentBytes + bytes > targetBatchBytes) {
5824
+ batches.push(current);
5825
+ current = [];
5826
+ currentBytes = 0;
5827
+ }
5828
+ current.push(message);
5829
+ currentBytes += bytes;
5830
+ }
5831
+ if (current.length > 0)
5832
+ batches.push(current);
5833
+ return {
5834
+ batches,
5835
+ dropped
5836
+ };
5837
+ }
5838
+
5839
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/client.mjs
4397
5840
  var MINIMUM_POLLING_INTERVAL = 100;
4398
5841
  var THIRTY_SECONDS = 30000;
4399
5842
  var MAX_CACHE_SIZE = 50000;
@@ -4418,6 +5861,12 @@ function normalizeHost(value) {
4418
5861
  const normalizedValue = typeof value == "string" ? value.trim() : "";
4419
5862
  return normalizedValue || DEFAULT_NODE_HOST;
4420
5863
  }
5864
+ function normalizeUnsetPersonProperties(value) {
5865
+ const propertyNames = Array.isArray(value) ? value : [
5866
+ value
5867
+ ];
5868
+ return propertyNames.filter((propertyName) => typeof propertyName == "string" && propertyName.trim().length > 0);
5869
+ }
4421
5870
  function buildFlagEventProperties(flagValues) {
4422
5871
  if (!flagValues)
4423
5872
  return {};
@@ -4435,11 +5884,15 @@ class PostHogBackendClient extends PostHogCoreStateless {
4435
5884
  const normalizedApiKey = normalizeApiKey(apiKey);
4436
5885
  const normalizedOptions = {
4437
5886
  ...options,
5887
+ maxQueueSize: options.maxQueueSize ?? 1e4,
5888
+ flushInterval: options.flushInterval ?? 5000,
4438
5889
  host: normalizeHost(options.host),
4439
- personalApiKey: normalizePersonalApiKey(options.personalApiKey)
5890
+ personalApiKey: normalizePersonalApiKey(options.secretKey ?? options.personalApiKey)
4440
5891
  };
4441
- super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage;
5892
+ super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage, this._aiCaptureRouteActive = false, this._minimalFlagCalledEvents = false;
4442
5893
  this.options = normalizedOptions;
5894
+ this.captureMode = resolveCaptureMode();
5895
+ this.enableFullAiCapture = normalizedOptions.enableFullAiCapture === true;
4443
5896
  this.context = this.initializeContext();
4444
5897
  this.options.featureFlagsPollingInterval = typeof normalizedOptions.featureFlagsPollingInterval == "number" ? Math.max(normalizedOptions.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL) : THIRTY_SECONDS;
4445
5898
  if (typeof normalizedOptions.waitUntilDebounceMs == "number")
@@ -4464,21 +5917,24 @@ class PostHogBackendClient extends PostHogCoreStateless {
4464
5917
  onLoad: (count) => {
4465
5918
  this._events.emit("localEvaluationFlagsLoaded", count);
4466
5919
  },
5920
+ onMinimalFlagCalledEvents: (enabled) => {
5921
+ this._minimalFlagCalledEvents = enabled;
5922
+ },
4467
5923
  customHeaders: this.getCustomHeaders(),
4468
5924
  cacheProvider: normalizedOptions.flagDefinitionCacheProvider,
4469
5925
  strictLocalEvaluation: normalizedOptions.strictLocalEvaluation
4470
5926
  });
4471
5927
  }
4472
- this.errorTracking = new ErrorTracking(this, normalizedOptions, this._logger);
5928
+ this.errorTracking = new error_tracking_ErrorTracking(this, normalizedOptions, this._logger);
4473
5929
  this.distinctIdHasSentFlagCalls = {};
4474
5930
  this.maxCacheSize = normalizedOptions.maxCacheSize || MAX_CACHE_SIZE;
4475
5931
  }
4476
- enqueue(type, message, options) {
4477
- super.enqueue(type, message, options);
5932
+ enqueue(type, message, options, explicitRoute) {
5933
+ super.enqueue(type, message, options, explicitRoute);
4478
5934
  this.scheduleDebouncedFlush();
4479
5935
  }
4480
5936
  async flush() {
4481
- const flushPromise = super.flush();
5937
+ const flushPromise = this.flushWithPendingPromises();
4482
5938
  const waitUntil = this.options.waitUntil;
4483
5939
  if (waitUntil && !this._waitUntilCycle)
4484
5940
  try {
@@ -4531,7 +5987,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4531
5987
  async resolveWaitUntilFlush() {
4532
5988
  const resolve = this._consumeWaitUntilCycle();
4533
5989
  try {
4534
- await super.flush();
5990
+ await this.flushWithPendingPromises();
4535
5991
  } catch {} finally {
4536
5992
  resolve?.();
4537
5993
  }
@@ -4545,12 +6001,103 @@ class PostHogBackendClient extends PostHogCoreStateless {
4545
6001
  fetch(url, options) {
4546
6002
  return this.options.fetch ? this.options.fetch(url, options) : fetch(url, options);
4547
6003
  }
6004
+ getQueueRouteKey(message) {
6005
+ return this.captureMode === "v1" && isLegacyOnlyEvent(message) ? AI_ROUTE : ANALYTICS_ROUTE;
6006
+ }
6007
+ persistedQueueKeyForRoute(route) {
6008
+ if (route === AI_CAPTURE_ROUTE)
6009
+ return types_PostHogPersistedProperty.AiCaptureQueue;
6010
+ return route === AI_ROUTE ? types_PostHogPersistedProperty.AiQueue : types_PostHogPersistedProperty.Queue;
6011
+ }
6012
+ getActiveQueueRoutes() {
6013
+ const routes = this.captureMode === "v1" ? [
6014
+ ANALYTICS_ROUTE,
6015
+ AI_ROUTE
6016
+ ] : [
6017
+ ANALYTICS_ROUTE
6018
+ ];
6019
+ if (this._aiCaptureRouteActive)
6020
+ routes.push(AI_CAPTURE_ROUTE);
6021
+ return routes;
6022
+ }
6023
+ getBatchEndpointPath(route) {
6024
+ return route === AI_CAPTURE_ROUTE ? AI_CAPTURE_ENDPOINT_PATH : super.getBatchEndpointPath(route);
6025
+ }
6026
+ async sendBatch(batchMessages, retryOptions, route = ANALYTICS_ROUTE) {
6027
+ if (route === AI_CAPTURE_ROUTE)
6028
+ return this.sendAiCaptureBatch(batchMessages, retryOptions);
6029
+ if (this.captureMode !== "v1" || route === AI_ROUTE)
6030
+ return super.sendBatch(batchMessages, retryOptions, route);
6031
+ const v1Events = batchMessages.filter((message) => message !== undefined);
6032
+ await this.getV1Sender().sendV1Batch(v1Events);
6033
+ }
6034
+ async sendAiCaptureBatch(batchMessages, retryOptions) {
6035
+ const { batches, dropped } = partitionAiBatch(batchMessages);
6036
+ for (const { event, bytes } of dropped) {
6037
+ const message = `Event ${event} (${bytes} bytes) exceeds the ${AI_MAX_EVENT_BYTES / 1048576}MiB limit for ${AI_CAPTURE_ENDPOINT_PATH}, dropping.`;
6038
+ this._logger.error(message);
6039
+ this._events.emit("error", new Error(message));
6040
+ }
6041
+ for (const batch of batches)
6042
+ await this.sendAiSubBatch(batch, retryOptions);
6043
+ }
6044
+ async sendAiSubBatch(batch, retryOptions) {
6045
+ try {
6046
+ await super.sendBatch(batch, retryOptions, AI_CAPTURE_ROUTE);
6047
+ } catch (err) {
6048
+ if (!isPostHogFetchContentTooLargeError(err))
6049
+ throw err;
6050
+ if (batch.length === 1) {
6051
+ const [event] = batch;
6052
+ const eventName = typeof event.event == "string" ? event.event : "unknown";
6053
+ const message = `Event ${eventName} (${eventByteSize(event)} bytes) was rejected with 413 by ${AI_CAPTURE_ENDPOINT_PATH} on its own, dropping.`;
6054
+ this._logger.error(message);
6055
+ this._events.emit("error", new Error(message));
6056
+ return;
6057
+ }
6058
+ const mid = Math.ceil(batch.length / 2);
6059
+ await this.sendAiSubBatch(batch.slice(0, mid), retryOptions);
6060
+ await this.sendAiSubBatch(batch.slice(mid), retryOptions);
6061
+ }
6062
+ }
6063
+ getV1Sender() {
6064
+ if (!this._v1Sender)
6065
+ this._v1Sender = new V1CaptureSender({
6066
+ host: this.host,
6067
+ apiKey: this.apiKey,
6068
+ libraryId: this.getLibraryId(),
6069
+ libraryVersion: this.getLibraryVersion(),
6070
+ userAgent: this.getCustomUserAgent() || undefined,
6071
+ historicalMigration: this.historicalMigration,
6072
+ compressionEnabled: !this.disableCompression,
6073
+ requestTimeoutMs: this.requestTimeout,
6074
+ maxAttempts: (this.options.fetchRetryCount ?? 3) + 1,
6075
+ initialRetryDelayMs: this.options.fetchRetryDelay ?? 3000,
6076
+ isDebug: this.isDebug
6077
+ }, {
6078
+ fetch: (url, fetchOptions) => this.fetch(url, fetchOptions),
6079
+ onError: (error) => this._events.emit("error", error),
6080
+ compress: (payload) => this.compressPayload(payload)
6081
+ });
6082
+ return this._v1Sender;
6083
+ }
4548
6084
  getLibraryVersion() {
4549
6085
  return version;
4550
6086
  }
6087
+ get metrics() {
6088
+ if (!this._metrics)
6089
+ this._metrics = new PostHogMetrics(this, resolveMetricsConfig(this.options.metrics), this._logger);
6090
+ return this._metrics;
6091
+ }
4551
6092
  getCustomUserAgent() {
4552
6093
  return `${this.getLibraryId()}/${this.getLibraryVersion()}`;
4553
6094
  }
6095
+ getCommonEventProperties() {
6096
+ const commonProperties = super.getCommonEventProperties();
6097
+ if (this.options.isServer ?? true)
6098
+ commonProperties.$is_server = true;
6099
+ return commonProperties;
6100
+ }
4554
6101
  enable() {
4555
6102
  return super.optIn();
4556
6103
  }
@@ -4561,33 +6108,69 @@ class PostHogBackendClient extends PostHogCoreStateless {
4561
6108
  super.debug(enabled);
4562
6109
  this.featureFlagsPoller?.debug(enabled);
4563
6110
  }
4564
- capture(props) {
6111
+ _warnIfInvalidCapture(props, stringArgumentWarning, exceptionCaptureWarning) {
4565
6112
  if (typeof props == "string")
4566
- this._logger.warn("Called capture() with a string as the first argument when an object was expected.");
6113
+ this._logger.warn(stringArgumentWarning);
4567
6114
  if (props.event === "$exception" && !props._originatedFromCaptureException)
4568
- this._logger.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically.");
4569
- this.addPendingPromise(this.prepareEventMessage(props).then(({ distinctId, event, properties, options }) => super.captureStateless(distinctId, event, properties, {
4570
- timestamp: options.timestamp,
4571
- disableGeoip: options.disableGeoip,
4572
- uuid: options.uuid
4573
- })).catch((err) => {
6115
+ this._logger.warn(exceptionCaptureWarning);
6116
+ }
6117
+ _sendPreparedEvent(type, props, immediate, prepareOptions, explicitRoute) {
6118
+ return this.addPendingPromise(this._prepareEventMessage(props, prepareOptions).then(({ distinctId, event, properties, options }) => {
6119
+ const captureOptions = {
6120
+ timestamp: options.timestamp,
6121
+ disableGeoip: options.disableGeoip,
6122
+ uuid: options.uuid
6123
+ };
6124
+ const message = {
6125
+ distinctId,
6126
+ event,
6127
+ properties: {
6128
+ ...properties,
6129
+ ...this.getCommonEventProperties()
6130
+ }
6131
+ };
6132
+ return immediate ? this.sendImmediate(type, message, captureOptions, explicitRoute) : this.enqueue(type, message, captureOptions, explicitRoute);
6133
+ }).catch((err) => {
4574
6134
  if (err)
4575
6135
  console.error(err);
4576
6136
  }));
4577
6137
  }
6138
+ _capturePreparedEvent(props, immediate) {
6139
+ return this._sendPreparedEvent("capture", props, immediate);
6140
+ }
6141
+ capture(props) {
6142
+ this._warnIfInvalidCapture(props, "Called capture() with a string as the first argument when an object was expected.", "Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically.");
6143
+ this._capturePreparedEvent(props, false);
6144
+ }
4578
6145
  async captureImmediate(props) {
4579
- if (typeof props == "string")
4580
- this._logger.warn("Called captureImmediate() with a string as the first argument when an object was expected.");
4581
- if (props.event === "$exception" && !props._originatedFromCaptureException)
4582
- this._logger.warn("Capturing a `$exception` event via `posthog.captureImmediate('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureExceptionImmediate(error)` instead, which attaches this metadata by default.");
4583
- return this.addPendingPromise(this.prepareEventMessage(props).then(({ distinctId, event, properties, options }) => super.captureStatelessImmediate(distinctId, event, properties, {
4584
- timestamp: options.timestamp,
4585
- disableGeoip: options.disableGeoip,
4586
- uuid: options.uuid
4587
- })).catch((err) => {
4588
- if (err)
4589
- console.error(err);
4590
- }));
6146
+ this._warnIfInvalidCapture(props, "Called captureImmediate() with a string as the first argument when an object was expected.", "Capturing a `$exception` event via `posthog.captureImmediate('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureExceptionImmediate(error)` instead, which attaches this metadata by default.");
6147
+ return this._capturePreparedEvent(props, true);
6148
+ }
6149
+ captureAi(props) {
6150
+ if (this.disabled)
6151
+ return;
6152
+ const uuid = getEventUuid(props.uuid, uuidv7);
6153
+ this._sendPreparedAiEvent({
6154
+ ...props,
6155
+ uuid
6156
+ }, false);
6157
+ return uuid;
6158
+ }
6159
+ async captureAiImmediate(props) {
6160
+ if (this.disabled)
6161
+ return;
6162
+ const uuid = getEventUuid(props.uuid, uuidv7);
6163
+ await this._sendPreparedAiEvent({
6164
+ ...props,
6165
+ uuid
6166
+ }, true);
6167
+ return uuid;
6168
+ }
6169
+ _sendPreparedAiEvent(props, immediate) {
6170
+ if (typeof props?.event == "string" && !props.event.startsWith("$ai_"))
6171
+ this._logger.debug(`captureAi called with non-AI event ${props.event}; routing it to the AI endpoint anyway.`);
6172
+ this._aiCaptureRouteActive = true;
6173
+ return this._sendPreparedEvent("capture", props, immediate, undefined, AI_CAPTURE_ROUTE);
4591
6174
  }
4592
6175
  identify({ distinctId, properties = {}, disableGeoip }) {
4593
6176
  const { $set, $set_once, $anon_distinct_id, ...rest } = properties;
@@ -4598,8 +6181,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
4598
6181
  $set_once: setOnceProps,
4599
6182
  $anon_distinct_id: $anon_distinct_id ?? undefined
4600
6183
  };
4601
- super.identifyStateless(distinctId, eventProperties, {
6184
+ this._sendPreparedEvent("identify", {
6185
+ distinctId,
6186
+ event: "$identify",
6187
+ properties: eventProperties,
4602
6188
  disableGeoip
6189
+ }, false, {
6190
+ includeContextProperties: false
4603
6191
  });
4604
6192
  }
4605
6193
  async identifyImmediate({ distinctId, properties = {}, disableGeoip }) {
@@ -4611,18 +6199,65 @@ class PostHogBackendClient extends PostHogCoreStateless {
4611
6199
  $set_once: setOnceProps,
4612
6200
  $anon_distinct_id: $anon_distinct_id ?? undefined
4613
6201
  };
4614
- await super.identifyStatelessImmediate(distinctId, eventProperties, {
6202
+ await this._sendPreparedEvent("identify", {
6203
+ distinctId,
6204
+ event: "$identify",
6205
+ properties: eventProperties,
4615
6206
  disableGeoip
6207
+ }, true, {
6208
+ includeContextProperties: false
6209
+ });
6210
+ }
6211
+ setPersonProperties({ distinctId, properties = {}, propertiesOnce = {} }) {
6212
+ if (Object.keys(properties).length === 0 && Object.keys(propertiesOnce).length === 0)
6213
+ return;
6214
+ const eventProperties = {};
6215
+ if (Object.keys(properties).length > 0)
6216
+ eventProperties.$set = properties;
6217
+ if (Object.keys(propertiesOnce).length > 0)
6218
+ eventProperties.$set_once = propertiesOnce;
6219
+ this.capture({
6220
+ distinctId,
6221
+ event: "$set",
6222
+ properties: eventProperties
6223
+ });
6224
+ }
6225
+ unsetPersonProperties({ distinctId, properties }) {
6226
+ const propertyNames = normalizeUnsetPersonProperties(properties);
6227
+ if (propertyNames.length === 0)
6228
+ return;
6229
+ this.capture({
6230
+ distinctId,
6231
+ event: "$set",
6232
+ properties: {
6233
+ $unset: propertyNames
6234
+ }
4616
6235
  });
4617
6236
  }
4618
6237
  alias(data) {
4619
- super.aliasStateless(data.alias, data.distinctId, undefined, {
6238
+ this._sendPreparedEvent("alias", {
6239
+ distinctId: data.distinctId,
6240
+ event: "$create_alias",
6241
+ properties: {
6242
+ distinct_id: data.distinctId,
6243
+ alias: data.alias
6244
+ },
4620
6245
  disableGeoip: data.disableGeoip
6246
+ }, false, {
6247
+ includeContextProperties: false
4621
6248
  });
4622
6249
  }
4623
6250
  async aliasImmediate(data) {
4624
- await super.aliasStatelessImmediate(data.alias, data.distinctId, undefined, {
6251
+ await this._sendPreparedEvent("alias", {
6252
+ distinctId: data.distinctId,
6253
+ event: "$create_alias",
6254
+ properties: {
6255
+ distinct_id: data.distinctId,
6256
+ alias: data.alias
6257
+ },
4625
6258
  disableGeoip: data.disableGeoip
6259
+ }, true, {
6260
+ includeContextProperties: false
4626
6261
  });
4627
6262
  }
4628
6263
  isLocalEvaluationReady() {
@@ -4677,7 +6312,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4677
6312
  const adjustedProperties = this.addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties);
4678
6313
  personProperties = adjustedProperties.allPersonProperties;
4679
6314
  groupProperties = adjustedProperties.allGroupProperties;
4680
- const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties);
6315
+ const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, this.personPropertiesForLocalEvaluation(distinctId, personProperties), groupProperties);
4681
6316
  if (onlyEvaluateLocally == undefined)
4682
6317
  onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
4683
6318
  let result;
@@ -4688,6 +6323,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4688
6323
  let flagId;
4689
6324
  let flagVersion;
4690
6325
  let flagReason;
6326
+ let flagHasExperiment;
4691
6327
  const localEvaluationEnabled = this.featureFlagsPoller !== undefined;
4692
6328
  if (localEvaluationEnabled) {
4693
6329
  await this.featureFlagsPoller?.loadFeatureFlags();
@@ -4702,6 +6338,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4702
6338
  const value = localResult.value;
4703
6339
  flagId = flag.id;
4704
6340
  flagReason = "Evaluated locally";
6341
+ flagHasExperiment = flag.has_experiment;
4705
6342
  result = {
4706
6343
  key,
4707
6344
  enabled: value !== false,
@@ -4717,12 +6354,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
4717
6354
  }
4718
6355
  }
4719
6356
  if (!flagWasLocallyEvaluated && !onlyEvaluateLocally) {
4720
- const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, [
6357
+ const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, [
4721
6358
  key
4722
6359
  ]);
4723
6360
  if (flagsResponse === undefined)
4724
6361
  featureFlagError = FeatureFlagError2.UNKNOWN_ERROR;
4725
6362
  else {
6363
+ this._minimalFlagCalledEvents = flagsResponse.minimalFlagCalledEvents === true;
4726
6364
  requestId = flagsResponse.requestId;
4727
6365
  evaluatedAt = flagsResponse.evaluatedAt;
4728
6366
  const errors = [];
@@ -4737,6 +6375,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4737
6375
  flagId = flagDetail.metadata?.id;
4738
6376
  flagVersion = flagDetail.metadata?.version;
4739
6377
  flagReason = flagDetail.reason?.description ?? flagDetail.reason?.code;
6378
+ flagHasExperiment = flagDetail.metadata?.has_experiment;
4740
6379
  let parsedPayload;
4741
6380
  if (flagDetail.metadata?.payload !== undefined)
4742
6381
  try {
@@ -4747,7 +6386,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4747
6386
  result = {
4748
6387
  key,
4749
6388
  enabled: flagDetail.enabled,
4750
- variant: flagDetail.variant,
6389
+ variant: flagDetail.variant ?? undefined,
4751
6390
  payload: parsedPayload
4752
6391
  };
4753
6392
  }
@@ -4768,6 +6407,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
4768
6407
  $feature_flag_request_id: requestId,
4769
6408
  $feature_flag_evaluated_at: flagWasLocallyEvaluated ? Date.now() : evaluatedAt
4770
6409
  };
6410
+ if (flagHasExperiment !== undefined)
6411
+ properties.$feature_flag_has_experiment = flagHasExperiment;
4771
6412
  if (flagWasLocallyEvaluated && this.featureFlagsPoller) {
4772
6413
  const flagDefinitionsLoadedAt = this.featureFlagsPoller.getFlagDefinitionsLoadedAt();
4773
6414
  if (flagDefinitionsLoadedAt !== undefined)
@@ -4882,7 +6523,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4882
6523
  const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
4883
6524
  personProperties = adjustedProperties.allPersonProperties;
4884
6525
  groupProperties = adjustedProperties.allGroupProperties;
4885
- const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
6526
+ const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
4886
6527
  if (onlyEvaluateLocally == undefined)
4887
6528
  onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
4888
6529
  const localEvaluationResult = await this.featureFlagsPoller?.getAllFlagsAndPayloads(evaluationContext, flagKeys);
@@ -4895,7 +6536,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4895
6536
  fallbackToFlags = localEvaluationResult.fallbackToFlags;
4896
6537
  }
4897
6538
  if (fallbackToFlags && !onlyEvaluateLocally) {
4898
- const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, flagKeys);
6539
+ const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
4899
6540
  featureFlags = {
4900
6541
  ...featureFlags,
4901
6542
  ...remoteEvaluationResult.flags || {}
@@ -4943,9 +6584,10 @@ class PostHogBackendClient extends PostHogCoreStateless {
4943
6584
  const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
4944
6585
  personProperties = adjustedProperties.allPersonProperties;
4945
6586
  groupProperties = adjustedProperties.allGroupProperties;
4946
- const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
6587
+ const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
4947
6588
  if (onlyEvaluateLocally == undefined)
4948
6589
  onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
6590
+ const requestedFlagKeys = flagKeys ? new Set(flagKeys) : undefined;
4949
6591
  const records = {};
4950
6592
  let requestId;
4951
6593
  let evaluatedAt;
@@ -4964,14 +6606,17 @@ class PostHogBackendClient extends PostHogCoreStateless {
4964
6606
  id: flagDef?.id,
4965
6607
  version: undefined,
4966
6608
  reason: "Evaluated locally",
4967
- locallyEvaluated: true
6609
+ locallyEvaluated: true,
6610
+ hasExperiment: flagDef?.has_experiment
4968
6611
  };
4969
6612
  locallyEvaluatedKeys.add(key);
4970
6613
  }
4971
- const fallbackToFlags = localResult ? localResult.fallbackToFlags : true;
6614
+ const requestedFlagMissingLocally = requestedFlagKeys !== undefined && Array.from(requestedFlagKeys).some((key) => this.featureFlagsPoller?.featureFlagsByKey[key] === undefined);
6615
+ const fallbackToFlags = localResult ? localResult.fallbackToFlags || requestedFlagMissingLocally : true;
4972
6616
  if (fallbackToFlags && !onlyEvaluateLocally) {
4973
- const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, flagKeys);
6617
+ const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
4974
6618
  if (details) {
6619
+ this._minimalFlagCalledEvents = details.minimalFlagCalledEvents === true;
4975
6620
  requestId = details.requestId;
4976
6621
  evaluatedAt = details.evaluatedAt;
4977
6622
  errorsWhileComputing = Boolean(details.errorsWhileComputingFlags);
@@ -4994,7 +6639,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
4994
6639
  id: detail.metadata?.id,
4995
6640
  version: detail.metadata?.version,
4996
6641
  reason: detail.reason?.description ?? detail.reason?.code,
4997
- locallyEvaluated: false
6642
+ locallyEvaluated: false,
6643
+ hasExperiment: detail.metadata?.has_experiment
4998
6644
  };
4999
6645
  }
5000
6646
  }
@@ -5014,7 +6660,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
5014
6660
  id: existing?.id,
5015
6661
  version: existing?.version,
5016
6662
  reason: existing?.reason,
5017
- locallyEvaluated: existing?.locallyEvaluated ?? false
6663
+ locallyEvaluated: existing?.locallyEvaluated ?? false,
6664
+ hasExperiment: existing?.hasExperiment
5018
6665
  };
5019
6666
  }
5020
6667
  if (this._payloadOverrides !== undefined)
@@ -5026,6 +6673,11 @@ class PostHogBackendClient extends PostHogCoreStateless {
5026
6673
  payload
5027
6674
  };
5028
6675
  }
6676
+ if (requestedFlagKeys !== undefined) {
6677
+ for (const key of Object.keys(records))
6678
+ if (!requestedFlagKeys.has(key))
6679
+ delete records[key];
6680
+ }
5029
6681
  return new FeatureFlagEvaluations({
5030
6682
  host: this._getFeatureFlagEvaluationsHost(),
5031
6683
  distinctId: resolvedDistinctId,
@@ -5039,6 +6691,9 @@ class PostHogBackendClient extends PostHogCoreStateless {
5039
6691
  quotaLimited
5040
6692
  });
5041
6693
  }
6694
+ _shouldSendMinimalFlagCalledEvent(event, properties) {
6695
+ return event === "$feature_flag_called" && this._minimalFlagCalledEvents && properties.$feature_flag_has_experiment === false;
6696
+ }
5042
6697
  _captureFlagCalledEventIfNeeded(params) {
5043
6698
  const { distinctId, key, response, groups, disableGeoip, properties } = params;
5044
6699
  const groupSuffix = groups && Object.keys(groups).length > 0 ? `_${JSON.stringify(Object.entries(groups).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0))}` : "";
@@ -5073,9 +6728,32 @@ class PostHogBackendClient extends PostHogCoreStateless {
5073
6728
  return this._featureFlagEvaluationsHost;
5074
6729
  }
5075
6730
  groupIdentify({ groupType, groupKey, properties, distinctId, disableGeoip }) {
5076
- super.groupIdentifyStateless(groupType, groupKey, properties, {
6731
+ this._sendPreparedEvent("capture", {
6732
+ distinctId: distinctId || `$${groupType}_${groupKey}`,
6733
+ event: "$groupidentify",
6734
+ properties: {
6735
+ $group_type: groupType,
6736
+ $group_key: groupKey,
6737
+ $group_set: properties || {}
6738
+ },
6739
+ disableGeoip
6740
+ }, false, {
6741
+ includeContextProperties: false
6742
+ });
6743
+ }
6744
+ async groupIdentifyImmediate({ groupType, groupKey, properties, distinctId, disableGeoip }) {
6745
+ await this._sendPreparedEvent("capture", {
6746
+ distinctId: distinctId || `$${groupType}_${groupKey}`,
6747
+ event: "$groupidentify",
6748
+ properties: {
6749
+ $group_type: groupType,
6750
+ $group_key: groupKey,
6751
+ $group_set: properties || {}
6752
+ },
5077
6753
  disableGeoip
5078
- }, distinctId);
6754
+ }, true, {
6755
+ includeContextProperties: false
6756
+ });
5079
6757
  }
5080
6758
  async reloadFeatureFlags() {
5081
6759
  await this.featureFlagsPoller?.loadFeatureFlags(true);
@@ -5147,12 +6825,18 @@ class PostHogBackendClient extends PostHogCoreStateless {
5147
6825
  this.context?.enter(data, options);
5148
6826
  }
5149
6827
  async _shutdown(shutdownTimeoutMs) {
6828
+ const shutdownDeadlineMs = Date.now() + (shutdownTimeoutMs ?? 30000);
5150
6829
  const resolve = this._consumeWaitUntilCycle();
5151
6830
  await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
5152
6831
  this.errorTracking.shutdown();
6832
+ if (this._metrics) {
6833
+ await raceWithTimeout(this._metrics.flush().catch(() => {}), Math.max(0, shutdownDeadlineMs - Date.now()));
6834
+ this._metrics.reset();
6835
+ }
5153
6836
  try {
5154
- return await super._shutdown(shutdownTimeoutMs);
6837
+ return await super._shutdown(Math.max(0, shutdownDeadlineMs - Date.now()));
5155
6838
  } finally {
6839
+ this.distinctIdHasSentFlagCalls = {};
5156
6840
  resolve?.();
5157
6841
  }
5158
6842
  }
@@ -5247,7 +6931,6 @@ class PostHogBackendClient extends PostHogCoreStateless {
5247
6931
  }
5248
6932
  addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties) {
5249
6933
  const allPersonProperties = {
5250
- distinct_id: distinctId,
5251
6934
  ...personProperties || {}
5252
6935
  };
5253
6936
  const allGroupProperties = {};
@@ -5262,6 +6945,12 @@ class PostHogBackendClient extends PostHogCoreStateless {
5262
6945
  allGroupProperties
5263
6946
  };
5264
6947
  }
6948
+ personPropertiesForLocalEvaluation(distinctId, personProperties) {
6949
+ return {
6950
+ distinct_id: distinctId,
6951
+ ...personProperties || {}
6952
+ };
6953
+ }
5265
6954
  createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties) {
5266
6955
  return {
5267
6956
  distinctId,
@@ -5272,21 +6961,21 @@ class PostHogBackendClient extends PostHogCoreStateless {
5272
6961
  };
5273
6962
  }
5274
6963
  captureException(error, distinctId, additionalProperties, uuid, flags) {
5275
- if (!ErrorTracking.isPreviouslyCapturedError(error)) {
6964
+ if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
5276
6965
  const syntheticException = new Error("PostHog syntheticException");
5277
- this.addPendingPromise(ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
6966
+ this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
5278
6967
  syntheticException
5279
- }, distinctId, additionalProperties).then((msg) => this.capture({
6968
+ }, distinctId, additionalProperties).then((msg) => this._capturePreparedEvent({
5280
6969
  ...msg,
5281
6970
  uuid,
5282
6971
  flags
5283
- })));
6972
+ }, false)));
5284
6973
  }
5285
6974
  }
5286
6975
  async captureExceptionImmediate(error, distinctId, additionalProperties, flags) {
5287
- if (!ErrorTracking.isPreviouslyCapturedError(error)) {
6976
+ if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
5288
6977
  const syntheticException = new Error("PostHog syntheticException");
5289
- return this.addPendingPromise(ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
6978
+ return this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
5290
6979
  syntheticException
5291
6980
  }, distinctId, additionalProperties).then((msg) => this.captureImmediate({
5292
6981
  ...msg,
@@ -5295,24 +6984,31 @@ class PostHogBackendClient extends PostHogCoreStateless {
5295
6984
  }
5296
6985
  }
5297
6986
  async prepareEventMessage(props) {
6987
+ return this._prepareEventMessage(props);
6988
+ }
6989
+ async _prepareEventMessage(props, options = {}) {
5298
6990
  const { distinctId, event, properties, groups, flags, sendFeatureFlags, timestamp, disableGeoip, uuid } = props;
5299
6991
  const contextData = this.context?.get();
6992
+ const includeContextProperties = options.includeContextProperties ?? true;
5300
6993
  let mergedDistinctId = distinctId || contextData?.distinctId;
5301
- const mergedProperties = {
6994
+ const mergedProperties = includeContextProperties ? {
5302
6995
  ...this.props,
5303
6996
  ...contextData?.properties || {},
5304
6997
  ...properties || {}
6998
+ } : {
6999
+ ...properties || {}
5305
7000
  };
5306
7001
  if (!mergedDistinctId) {
5307
7002
  mergedDistinctId = uuidv7();
5308
7003
  mergedProperties.$process_person_profile = false;
5309
7004
  }
5310
- if (contextData?.sessionId && !mergedProperties.$session_id)
7005
+ if (includeContextProperties && contextData?.sessionId && !mergedProperties.$session_id)
5311
7006
  mergedProperties.$session_id = contextData.sessionId;
7007
+ const finalProperties = this._shouldSendMinimalFlagCalledEvent(event, mergedProperties) ? minimizeFlagCalledEventProperties(mergedProperties) : mergedProperties;
5312
7008
  const eventMessage = this._runBeforeSend({
5313
7009
  distinctId: mergedDistinctId,
5314
7010
  event,
5315
- properties: mergedProperties,
7011
+ properties: finalProperties,
5316
7012
  groups,
5317
7013
  flags,
5318
7014
  sendFeatureFlags,
@@ -5336,12 +7032,14 @@ class PostHogBackendClient extends PostHogCoreStateless {
5336
7032
  }
5337
7033
  return {};
5338
7034
  }).catch(() => ({})).then((additionalProperties) => {
5339
- const props2 = {
7035
+ const resolvedGroups = eventMessage.groups || groups;
7036
+ return {
5340
7037
  ...additionalProperties,
5341
7038
  ...eventMessage.properties || {},
5342
- $groups: eventMessage.groups || groups
7039
+ ...resolvedGroups !== undefined && Object.keys(resolvedGroups).length > 0 ? {
7040
+ $groups: resolvedGroups
7041
+ } : {}
5343
7042
  };
5344
- return props2;
5345
7043
  });
5346
7044
  if (eventMessage.event === "$pageview" && this.options.__preview_capture_bot_pageviews && typeof eventProperties.$raw_user_agent == "string") {
5347
7045
  if (isBlockedUA(eventProperties.$raw_user_agent, this.options.custom_blocked_useragents || [])) {
@@ -5368,22 +7066,26 @@ class PostHogBackendClient extends PostHogCoreStateless {
5368
7066
  beforeSend
5369
7067
  ];
5370
7068
  let result = eventMessage;
5371
- for (const fn of fns) {
5372
- result = fn(result);
5373
- if (!result) {
5374
- this._logger.info(`Event '${eventMessage.event}' was rejected in beforeSend function`);
7069
+ for (const fn of fns)
7070
+ try {
7071
+ result = fn(result);
7072
+ if (!result) {
7073
+ this._logger.info(`Event '${eventMessage.event}' was rejected in beforeSend function`);
7074
+ return null;
7075
+ }
7076
+ if (!result.properties || Object.keys(result.properties).length === 0) {
7077
+ const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`;
7078
+ this._logger.warn(message);
7079
+ }
7080
+ } catch (error) {
7081
+ this._logger.error(`Error in before_send function for event '${eventMessage.event}':`, error);
5375
7082
  return null;
5376
7083
  }
5377
- if (!result.properties || Object.keys(result.properties).length === 0) {
5378
- const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`;
5379
- this._logger.warn(message);
5380
- }
5381
- }
5382
7084
  return result;
5383
7085
  }
5384
7086
  }
5385
7087
 
5386
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/context/context.mjs
7088
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/context/context.mjs
5387
7089
  import { AsyncLocalStorage } from "node:async_hooks";
5388
7090
 
5389
7091
  class PostHogContext {
@@ -5414,7 +7116,22 @@ class PostHogContext {
5414
7116
  }
5415
7117
  }
5416
7118
 
5417
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
7119
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/gzip.node.mjs
7120
+ import { gzip } from "node:zlib";
7121
+ import { promisify } from "node:util";
7122
+ var gzipAsync = promisify(gzip);
7123
+ async function gzipCompress2(input, isDebug = true) {
7124
+ try {
7125
+ const compressed = await gzipAsync(input);
7126
+ return new Uint8Array(compressed);
7127
+ } catch (error) {
7128
+ if (isDebug)
7129
+ console.error("Failed to gzip compress data", error);
7130
+ return null;
7131
+ }
7132
+ }
7133
+
7134
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
5418
7135
  var NAME = "posthog-node";
5419
7136
  function createEventProcessor(_posthog, { organization, projectId, prefix, severityAllowList = [
5420
7137
  "error"
@@ -5454,6 +7171,9 @@ function createEventProcessor(_posthog, { organization, projectId, prefix, sever
5454
7171
  $sentry_exception_type: exceptions[0]?.type,
5455
7172
  $sentry_tags: event.tags
5456
7173
  };
7174
+ const injectedReleaseId = getInjectedReleaseId();
7175
+ if (injectedReleaseId)
7176
+ properties.$release_id = injectedReleaseId;
5457
7177
  if (organization && projectId)
5458
7178
  properties["$sentry_url"] = (prefix || "https://sentry.io/organizations/") + organization + "/issues/?project=" + projectId + "&query=" + event.event_id;
5459
7179
  if (sendExceptionsToPostHog)
@@ -5482,24 +7202,27 @@ class PostHogSentryIntegration {
5482
7202
  };
5483
7203
  }
5484
7204
  }
5485
- // ../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/entrypoints/index.node.mjs
7205
+ // ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/entrypoints/index.node.mjs
5486
7206
  class PostHog extends PostHogBackendClient {
5487
7207
  getLibraryId() {
5488
7208
  return "posthog-node";
5489
7209
  }
7210
+ compressPayload(payload) {
7211
+ return gzipCompress2(payload, this.isDebug);
7212
+ }
5490
7213
  initializeContext() {
5491
7214
  return new PostHogContext;
5492
7215
  }
5493
7216
  createErrorPropertiesBuilder() {
5494
- return new exports_error_tracking.ErrorPropertiesBuilder([
5495
- new exports_error_tracking.EventCoercer,
5496
- new exports_error_tracking.ErrorCoercer,
5497
- new exports_error_tracking.ObjectCoercer,
5498
- new exports_error_tracking.StringCoercer,
5499
- new exports_error_tracking.PrimitiveCoercer
5500
- ], exports_error_tracking.createStackParser("node:javascript", exports_error_tracking.nodeStackLineParser), [
7217
+ return new ErrorPropertiesBuilder([
7218
+ new EventCoercer,
7219
+ new ErrorCoercer,
7220
+ new ObjectCoercer,
7221
+ new StringCoercer,
7222
+ new PrimitiveCoercer
7223
+ ], createStackParser("node:javascript", nodeStackLineParser), [
5501
7224
  createModulerModifier(),
5502
- addSourceContext,
7225
+ (frames) => addSourceContext(frames, undefined, this._logger),
5503
7226
  createRelativePathModifier()
5504
7227
  ]);
5505
7228
  }
@@ -5884,12 +7607,12 @@ function parseHookInput(raw) {
5884
7607
  }
5885
7608
  }
5886
7609
  function isCodexSessionStartInput(value) {
5887
- return isRecord2(value) && value["hook_event_name"] === "SessionStart" && typeof value["session_id"] === "string" && isStringOrNull(value["transcript_path"]) && typeof value["cwd"] === "string" && typeof value["model"] === "string" && typeof value["permission_mode"] === "string" && typeof value["source"] === "string";
7610
+ return isRecord3(value) && value["hook_event_name"] === "SessionStart" && typeof value["session_id"] === "string" && isStringOrNull(value["transcript_path"]) && typeof value["cwd"] === "string" && typeof value["model"] === "string" && typeof value["permission_mode"] === "string" && typeof value["source"] === "string";
5888
7611
  }
5889
7612
  function isStringOrNull(value) {
5890
7613
  return typeof value === "string" || value === null;
5891
7614
  }
5892
- function isRecord2(value) {
7615
+ function isRecord3(value) {
5893
7616
  return typeof value === "object" && value !== null && !Array.isArray(value);
5894
7617
  }
5895
7618
  function readStdin() {