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,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __returnValue = (v) => v;
3
- function __exportSetter(name, newValue) {
4
- this[name] = __returnValue.bind(null, newValue);
5
- }
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true,
11
- configurable: true,
12
- set: __exportSetter.bind(all, name)
13
- });
14
- };
15
-
16
1
  // ../../../../telemetry-core/src/activity-state.ts
17
2
  import { existsSync, mkdirSync as mkdirSync2, readFileSync } from "node:fs";
18
3
  import { basename, join } from "node:path";
@@ -23,9 +8,12 @@ import {
23
8
  fsyncSync,
24
9
  openSync,
25
10
  renameSync,
11
+ rmSync,
26
12
  unlinkSync,
27
13
  writeFileSync
28
14
  } from "node:fs";
15
+ import { randomUUID } from "node:crypto";
16
+ import { dirname } from "node:path";
29
17
  var TOLERATED_FSYNC_CODES = new Set([
30
18
  "EPERM",
31
19
  "EACCES",
@@ -47,24 +35,36 @@ function tolerantFsyncSync(fileDescriptor, fsyncImpl) {
47
35
  }
48
36
  }
49
37
  function writeFileAtomically(filePath, content, options = {}) {
50
- const tempPath = `${filePath}.tmp`;
51
- writeFileSync(tempPath, content, "utf-8");
52
- const tempFileDescriptor = openSync(tempPath, "r+");
53
- try {
54
- tolerantFsyncSync(tempFileDescriptor, options.fsyncSync ?? fsyncSync);
55
- } finally {
56
- closeSync(tempFileDescriptor);
57
- }
38
+ const platform = options.platform ?? process.platform;
39
+ const fsyncImpl = options.fsyncSync ?? fsyncSync;
40
+ const tempPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
58
41
  try {
59
- renameSync(tempPath, filePath);
60
- } catch (error) {
61
- const isPermissionError = error instanceof Error && (error.message.includes("EPERM") || error.message.includes("EACCES"));
62
- if ((options.platform ?? process.platform) === "win32" && isPermissionError) {
42
+ writeFileSync(tempPath, content, "utf-8");
43
+ const tempFileDescriptor = openSync(tempPath, "r+");
44
+ try {
45
+ tolerantFsyncSync(tempFileDescriptor, fsyncImpl);
46
+ } finally {
47
+ closeSync(tempFileDescriptor);
48
+ }
49
+ try {
50
+ renameSync(tempPath, filePath);
51
+ } catch (error) {
52
+ const isPermissionError = error instanceof Error && (error.message.includes("EPERM") || error.message.includes("EACCES"));
53
+ if (platform !== "win32" || !isPermissionError)
54
+ throw error;
63
55
  unlinkSync(filePath);
64
56
  renameSync(tempPath, filePath);
57
+ }
58
+ if (platform === "win32")
65
59
  return;
60
+ const directoryFileDescriptor = openSync(dirname(filePath), "r");
61
+ try {
62
+ tolerantFsyncSync(directoryFileDescriptor, fsyncImpl);
63
+ } finally {
64
+ closeSync(directoryFileDescriptor);
66
65
  }
67
- throw error;
66
+ } finally {
67
+ rmSync(tempPath, { force: true });
68
68
  }
69
69
  }
70
70
 
@@ -334,8 +334,8 @@ function getTelemetryHost(env = process.env, defaultHost = DEFAULT_POSTHOG_HOST)
334
334
  return env["POSTHOG_HOST"]?.trim() || defaultHost;
335
335
  }
336
336
 
337
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
338
- import { dirname, posix, sep } from "path";
337
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
338
+ import { dirname as dirname2, posix, sep } from "path";
339
339
  function createModulerModifier() {
340
340
  const getModuleFromFileName = createGetModuleFromFilename();
341
341
  return async (frames) => {
@@ -344,7 +344,7 @@ function createModulerModifier() {
344
344
  return frames;
345
345
  };
346
346
  }
347
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname(process.argv[1]) : process.cwd(), isWindows = sep === "\\") {
347
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname2(process.argv[1]) : process.cwd(), isWindows = sep === "\\") {
348
348
  const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
349
349
  return (filename) => {
350
350
  if (!filename)
@@ -366,11 +366,11 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname(proces
366
366
  return decodedFile;
367
367
  };
368
368
  }
369
- function normalizeWindowsPath(path2) {
370
- return path2.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
369
+ function normalizeWindowsPath(path) {
370
+ return path.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
371
371
  }
372
372
 
373
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/featureFlagUtils.mjs
373
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/featureFlagUtils.mjs
374
374
  var normalizeFlagsResponse = (flagsResponse) => {
375
375
  if ("flags" in flagsResponse) {
376
376
  const featureFlags = getFlagValuesFromFlags(flagsResponse.flags);
@@ -440,8 +440,69 @@ var parsePayload = (response) => {
440
440
  return response;
441
441
  }
442
442
  };
443
+ var MINIMAL_FLAG_CALLED_EVENT_CAMPAIGN_PROPERTIES = [
444
+ "utm_source",
445
+ "utm_medium",
446
+ "utm_campaign",
447
+ "utm_content",
448
+ "utm_term",
449
+ "gad_source",
450
+ "mc_cid",
451
+ "gclid",
452
+ "gclsrc",
453
+ "dclid",
454
+ "gbraid",
455
+ "wbraid",
456
+ "fbclid",
457
+ "msclkid",
458
+ "twclid",
459
+ "li_fat_id",
460
+ "igshid",
461
+ "ttclid",
462
+ "rdt_cid",
463
+ "epik",
464
+ "qclid",
465
+ "sccid",
466
+ "irclid",
467
+ "_kx"
468
+ ];
469
+ var MINIMAL_FLAG_CALLED_EVENT_PROPERTIES = [
470
+ "$feature_flag",
471
+ "$feature_flag_response",
472
+ "$feature_flag_has_experiment",
473
+ "$feature_flag_id",
474
+ "$feature_flag_version",
475
+ "$feature_flag_reason",
476
+ "$feature_flag_request_id",
477
+ "$feature_flag_evaluated_at",
478
+ "$feature_flag_error",
479
+ "locally_evaluated",
480
+ "$groups",
481
+ "$process_person_profile",
482
+ "$geoip_disable",
483
+ "$current_url",
484
+ "$pathname",
485
+ "$referring_domain",
486
+ ...MINIMAL_FLAG_CALLED_EVENT_CAMPAIGN_PROPERTIES,
487
+ "$session_id",
488
+ "$window_id",
489
+ "$lib",
490
+ "$lib_version",
491
+ "$device_id",
492
+ "$is_server"
493
+ ];
494
+ var minimizeFlagCalledEventProperties = (properties, transportKeys = []) => {
495
+ const minimal = {};
496
+ const copyKey = (key) => {
497
+ if (properties[key] !== undefined)
498
+ minimal[key] = properties[key];
499
+ };
500
+ MINIMAL_FLAG_CALLED_EVENT_PROPERTIES.forEach(copyKey);
501
+ transportKeys.forEach(copyKey);
502
+ return minimal;
503
+ };
443
504
 
444
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/types.mjs
505
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/types.mjs
445
506
  var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedProperty) {
446
507
  PostHogPersistedProperty["AnonymousId"] = "anonymous_id";
447
508
  PostHogPersistedProperty["DistinctId"] = "distinct_id";
@@ -456,6 +517,8 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
456
517
  PostHogPersistedProperty["BootstrapFeatureFlagPayloads"] = "bootstrap_feature_flag_payloads";
457
518
  PostHogPersistedProperty["OverrideFeatureFlags"] = "override_feature_flags";
458
519
  PostHogPersistedProperty["Queue"] = "queue";
520
+ PostHogPersistedProperty["AiQueue"] = "ai_queue";
521
+ PostHogPersistedProperty["AiCaptureQueue"] = "ai_capture_queue";
459
522
  PostHogPersistedProperty["LogsQueue"] = "logs_queue";
460
523
  PostHogPersistedProperty["OptedOut"] = "opted_out";
461
524
  PostHogPersistedProperty["SessionId"] = "session_id";
@@ -466,6 +529,8 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
466
529
  PostHogPersistedProperty["InstalledAppBuild"] = "installed_app_build";
467
530
  PostHogPersistedProperty["InstalledAppVersion"] = "installed_app_version";
468
531
  PostHogPersistedProperty["SessionReplay"] = "session_replay";
532
+ PostHogPersistedProperty["PushRegistered"] = "push_registered";
533
+ PostHogPersistedProperty["SessionReplayEventTriggerActivatedSession"] = "session_replay_event_trigger_activated_session";
469
534
  PostHogPersistedProperty["SurveyLastSeenDate"] = "survey_last_seen_date";
470
535
  PostHogPersistedProperty["SurveysSeen"] = "surveys_seen";
471
536
  PostHogPersistedProperty["Surveys"] = "surveys";
@@ -475,7 +540,7 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
475
540
  return PostHogPersistedProperty;
476
541
  }({});
477
542
 
478
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/gzip.mjs
543
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/gzip.mjs
479
544
  function isGzipSupported() {
480
545
  return "CompressionStream" in globalThis && "TextEncoder" in globalThis && "Response" in globalThis && typeof Response.prototype.blob == "function";
481
546
  }
@@ -525,7 +590,7 @@ var validateNativeGzip = async (compressed, inputBytes) => {
525
590
  async function gzipCompress(input, isDebug = true, options) {
526
591
  try {
527
592
  const inputBytes = new TextEncoder().encode(input);
528
- const compressedStream = new CompressionStream("gzip");
593
+ const compressedStream = new globalThis.CompressionStream("gzip");
529
594
  const writer = compressedStream.writable.getWriter();
530
595
  const writePromise = writer.write(inputBytes).then(() => writer.close()).catch(async (err) => {
531
596
  try {
@@ -549,7 +614,34 @@ async function gzipCompress(input, isDebug = true, options) {
549
614
  }
550
615
  }
551
616
 
552
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/bot-detection.mjs
617
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/json-utils.mjs
618
+ var MAX_JSON_SAFE_VALUE_DEPTH = 20;
619
+ var MAX_JSON_SAFE_VALUE_ITEMS = 1000;
620
+ var MAX_JSON_SAFE_VALUE_NODES = 1e4;
621
+ var CIRCULAR_VALUE = "[Circular]";
622
+ var TRUNCATED_VALUE = "[Truncated]";
623
+ var UNSERIALIZABLE_VALUE = "[Unserializable]";
624
+ var FUNCTION_VALUE = "[Function]";
625
+ var dateGetTime = Date.prototype.getTime;
626
+ var dateToISOString = Date.prototype.toISOString;
627
+ function sanitizeString(value) {
628
+ let output = "";
629
+ for (let index = 0;index < value.length; index++) {
630
+ const codeUnit = value.charCodeAt(index);
631
+ if (codeUnit >= 55296 && codeUnit <= 56319) {
632
+ const nextCodeUnit = value.charCodeAt(index + 1);
633
+ if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
634
+ output += value[index] + value[index + 1];
635
+ index++;
636
+ } else
637
+ output += "�";
638
+ } else
639
+ output += codeUnit >= 56320 && codeUnit <= 57343 ? "�" : value[index];
640
+ }
641
+ return output;
642
+ }
643
+
644
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/bot-detection.mjs
553
645
  var DEFAULT_BLOCKED_UA_STRS = [
554
646
  "amazonbot",
555
647
  "amazonproductbot",
@@ -638,7 +730,31 @@ var isBlockedUA = function(ua, customBlockedUserAgents = []) {
638
730
  return uaLower.indexOf(blockedUaLower) !== -1;
639
731
  });
640
732
  };
641
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/type-utils.mjs
733
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/string-utils.mjs
734
+ function safeJsonStringify(value) {
735
+ const ancestors = [];
736
+ return JSON.stringify(value, function(_key, replacementValue) {
737
+ if (typeof replacementValue == "bigint")
738
+ return replacementValue.toString();
739
+ if (typeof replacementValue == "function" || typeof replacementValue == "symbol")
740
+ return;
741
+ if (replacementValue instanceof Error)
742
+ return {
743
+ name: replacementValue.name,
744
+ message: replacementValue.message,
745
+ stack: replacementValue.stack
746
+ };
747
+ if (replacementValue && typeof replacementValue == "object") {
748
+ while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this)
749
+ ancestors.pop();
750
+ if (ancestors.includes(replacementValue))
751
+ return "[Circular]";
752
+ ancestors.push(replacementValue);
753
+ }
754
+ return replacementValue;
755
+ }) ?? "null";
756
+ }
757
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/type-utils.mjs
642
758
  var nativeIsArray = Array.isArray;
643
759
  var ObjProto = Object.prototype;
644
760
  var type_utils_hasOwnProperty = ObjProto.hasOwnProperty;
@@ -650,16 +766,27 @@ var isObject = (x) => x === Object(x) && !isArray(x);
650
766
  var isUndefined = (x) => x === undefined;
651
767
  var isString = (x) => type_utils_toString.call(x) == "[object String]";
652
768
  var isEmptyString = (x) => isString(x) && x.trim().length === 0;
769
+ var isNull = (x) => x === null;
770
+ var isNullish = (x) => isUndefined(x) || isNull(x);
653
771
  var isNumber = (x) => type_utils_toString.call(x) == "[object Number]" && x === x;
654
- var isPlainError = (x) => x instanceof Error;
772
+ var isBoolean = (x) => type_utils_toString.call(x) === "[object Boolean]";
655
773
  function isPrimitive(value) {
656
774
  return value === null || typeof value != "object";
657
775
  }
658
776
  function isBuiltin(candidate, className) {
659
777
  return Object.prototype.toString.call(candidate) === `[object ${className}]`;
660
778
  }
661
- function isErrorEvent(event) {
662
- return isBuiltin(event, "ErrorEvent");
779
+ function isError(candidate) {
780
+ switch (Object.prototype.toString.call(candidate)) {
781
+ case "[object Error]":
782
+ case "[object Exception]":
783
+ case "[object DOMException]":
784
+ case "[object DOMError]":
785
+ case "[object WebAssembly.Exception]":
786
+ return true;
787
+ default:
788
+ return isInstanceOf(candidate, Error);
789
+ }
663
790
  }
664
791
  function isEvent(candidate) {
665
792
  return typeof Event != "undefined" && isInstanceOf(candidate, Event);
@@ -675,7 +802,7 @@ function isInstanceOf(candidate, base) {
675
802
  }
676
803
  }
677
804
 
678
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/number-utils.mjs
805
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/number-utils.mjs
679
806
  function clampToRange(value, min, max, logger, fallbackValue) {
680
807
  if (min > max) {
681
808
  logger.warn("min cannot be greater than max.");
@@ -695,8 +822,16 @@ function clampToRange(value, min, max, logger, fallbackValue) {
695
822
  return clampToRange(fallbackValue || max, min, max, logger);
696
823
  }
697
824
 
698
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
825
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
699
826
  var ONE_DAY_IN_MS = 86400000;
827
+ var DEFAULT_EXCEPTION_RATE_LIMITER_REFILL_RATE = 1;
828
+ var DEFAULT_EXCEPTION_RATE_LIMITER_BUCKET_SIZE = 10;
829
+ function resolveExceptionRateLimiterConfig(config = {}) {
830
+ return {
831
+ refillRate: config.exceptionRateLimiterRefillRate ?? config.__exceptionRateLimiterRefillRate ?? DEFAULT_EXCEPTION_RATE_LIMITER_REFILL_RATE,
832
+ bucketSize: config.exceptionRateLimiterBucketSize ?? config.__exceptionRateLimiterBucketSize ?? DEFAULT_EXCEPTION_RATE_LIMITER_BUCKET_SIZE
833
+ };
834
+ }
700
835
 
701
836
  class BucketedRateLimiter {
702
837
  constructor(options) {
@@ -739,7 +874,7 @@ class BucketedRateLimiter {
739
874
  this._buckets = {};
740
875
  }
741
876
  }
742
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
877
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
743
878
  /*! For license information please see uuidv7.mjs.LICENSE.txt */
744
879
  var DIGITS = "0123456789abcdef";
745
880
 
@@ -917,33 +1052,45 @@ var defaultGenerator;
917
1052
  var uuidv7 = () => uuidv7obj().toString();
918
1053
  var uuidv7obj = () => (defaultGenerator || (defaultGenerator = new V7Generator)).generate();
919
1054
 
920
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/promise-queue.mjs
1055
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/promise-queue.mjs
921
1056
  class PromiseQueue {
922
1057
  add(promise) {
923
1058
  const promiseUUID = uuidv7();
924
- this.promiseByIds[promiseUUID] = promise;
1059
+ const id = ++this.nextId;
1060
+ this.promiseByIds[promiseUUID] = {
1061
+ id,
1062
+ promise
1063
+ };
925
1064
  promise.catch(() => {}).finally(() => {
926
1065
  delete this.promiseByIds[promiseUUID];
927
1066
  });
928
1067
  return promise;
929
1068
  }
930
1069
  async join() {
931
- let promises = Object.values(this.promiseByIds);
1070
+ let promises = Object.values(this.promiseByIds).map((item) => item.promise);
932
1071
  let length = promises.length;
933
1072
  while (length > 0) {
934
1073
  await Promise.all(promises);
935
- promises = Object.values(this.promiseByIds);
1074
+ promises = Object.values(this.promiseByIds).map((item) => item.promise);
936
1075
  length = promises.length;
937
1076
  }
938
1077
  }
1078
+ getPromises(ignoredPromises = [], maxId = this.nextId) {
1079
+ const ignoredPromiseSet = new Set(ignoredPromises);
1080
+ return Object.values(this.promiseByIds).filter((item) => item.id <= maxId && !ignoredPromiseSet.has(item.promise)).map((item) => item.promise);
1081
+ }
1082
+ get maxId() {
1083
+ return this.nextId;
1084
+ }
939
1085
  get length() {
940
1086
  return Object.keys(this.promiseByIds).length;
941
1087
  }
942
1088
  constructor() {
943
1089
  this.promiseByIds = {};
1090
+ this.nextId = 0;
944
1091
  }
945
1092
  }
946
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/logger.mjs
1093
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/logger.mjs
947
1094
  function createConsole(consoleLike = console) {
948
1095
  const lockedMethods = {
949
1096
  log: consoleLike.log.bind(consoleLike),
@@ -984,7 +1131,7 @@ var passThrough = (fn) => fn();
984
1131
  function createLogger(prefix, maybeCall = passThrough) {
985
1132
  return _createLogger(prefix, maybeCall, createConsole());
986
1133
  }
987
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
1134
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
988
1135
  var MOBILE = "Mobile";
989
1136
  var IOS = "iOS";
990
1137
  var ANDROID = "Android";
@@ -1027,6 +1174,7 @@ var DUCKDUCKGO = "DuckDuckGo";
1027
1174
  var PALE_MOON = "Pale Moon";
1028
1175
  var WATERFOX = "Waterfox";
1029
1176
  var BRAVE = "Brave";
1177
+ var GOOGLE_SEARCH_APP = "Google Search App";
1030
1178
  var BROWSER_VERSION_REGEX_SUFFIX = "(\\d+(\\.\\d+)?)";
1031
1179
  var DEFAULT_BROWSER_VERSION_REGEX = new RegExp("Version/" + BROWSER_VERSION_REGEX_SUFFIX);
1032
1180
  var XBOX_REGEX = new RegExp(XBOX, "i");
@@ -1114,6 +1262,9 @@ var versionRegexes = {
1114
1262
  [WATERFOX]: [
1115
1263
  new RegExp(WATERFOX + "\\/" + BROWSER_VERSION_REGEX_SUFFIX)
1116
1264
  ],
1265
+ [GOOGLE_SEARCH_APP]: [
1266
+ new RegExp("GSA\\/" + BROWSER_VERSION_REGEX_SUFFIX)
1267
+ ],
1117
1268
  [INTERNET_EXPLORER]: [
1118
1269
  new RegExp("(rv:|MSIE )" + BROWSER_VERSION_REGEX_SUFFIX)
1119
1270
  ],
@@ -1273,8 +1424,15 @@ var osMatchers = [
1273
1424
  ]
1274
1425
  ];
1275
1426
 
1276
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/index.mjs
1427
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/index.mjs
1277
1428
  var STRING_FORMAT = "utf8";
1429
+ var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1430
+ function isValidUUID(value) {
1431
+ return typeof value == "string" && UUID_REGEX.test(value);
1432
+ }
1433
+ function getEventUuid(uuid, generateUuid) {
1434
+ return isValidUUID(uuid) ? uuid : generateUuid();
1435
+ }
1278
1436
  function removeTrailingSlash(url) {
1279
1437
  return url?.replace(/\/+$/, "");
1280
1438
  }
@@ -1302,7 +1460,26 @@ function safeSetTimeout(fn, timeout) {
1302
1460
  t?.unref && t?.unref();
1303
1461
  return t;
1304
1462
  }
1305
- var isError = (x) => x instanceof Error;
1463
+ async function raceWithTimeout(promise, timeoutMs, onTimeout) {
1464
+ let timeoutHandle;
1465
+ try {
1466
+ return await Promise.race([
1467
+ promise,
1468
+ new Promise((resolve, reject) => {
1469
+ timeoutHandle = safeSetTimeout(() => {
1470
+ try {
1471
+ onTimeout?.();
1472
+ resolve();
1473
+ } catch (error) {
1474
+ reject(error);
1475
+ }
1476
+ }, timeoutMs);
1477
+ })
1478
+ ]);
1479
+ } finally {
1480
+ clearTimeout(timeoutHandle);
1481
+ }
1482
+ }
1306
1483
  function allSettled(promises) {
1307
1484
  return Promise.all(promises.map((p) => (p ?? Promise.resolve()).then((value) => ({
1308
1485
  status: "fulfilled",
@@ -1313,7 +1490,7 @@ function allSettled(promises) {
1313
1490
  }))));
1314
1491
  }
1315
1492
 
1316
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/logs/logs-utils.mjs
1493
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/logs/logs-utils.mjs
1317
1494
  var OTLP_SEVERITY_MAP = {
1318
1495
  trace: {
1319
1496
  text: "TRACE",
@@ -1341,7 +1518,570 @@ var OTLP_SEVERITY_MAP = {
1341
1518
  }
1342
1519
  };
1343
1520
  var DEFAULT_OTLP_SEVERITY = OTLP_SEVERITY_MAP.info;
1344
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/eventemitter.mjs
1521
+ var INT64_RANGE_LIMIT = 9223372036854776000;
1522
+ var propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
1523
+ function newState() {
1524
+ return {
1525
+ ancestors: new WeakSet,
1526
+ remainingNodes: MAX_JSON_SAFE_VALUE_NODES
1527
+ };
1528
+ }
1529
+ function toOtlpKeyValueList(attrs, logger) {
1530
+ try {
1531
+ return encodeKeyValueList(attrs, logger, newState(), 0);
1532
+ } catch {
1533
+ return [];
1534
+ }
1535
+ }
1536
+ function encodeAnyValue(value, logger, state, depth) {
1537
+ if (state.remainingNodes <= 0)
1538
+ return {
1539
+ stringValue: TRUNCATED_VALUE
1540
+ };
1541
+ state.remainingNodes--;
1542
+ if (isBoolean(value))
1543
+ return {
1544
+ boolValue: value
1545
+ };
1546
+ if (typeof value == "number") {
1547
+ if (!Number.isFinite(value))
1548
+ return {
1549
+ stringValue: String(value)
1550
+ };
1551
+ if (Number.isInteger(value)) {
1552
+ if (Number.isSafeInteger(value))
1553
+ return {
1554
+ intValue: String(value)
1555
+ };
1556
+ if (typeof BigInt == "undefined")
1557
+ return {
1558
+ stringValue: String(value)
1559
+ };
1560
+ const decimal = BigInt(value).toString();
1561
+ if (value >= INT64_RANGE_LIMIT || value < -INT64_RANGE_LIMIT) {
1562
+ logger?.debug(`Attribute ${decimal} is outside the int64 range; encoding it as a string`);
1563
+ return {
1564
+ stringValue: decimal
1565
+ };
1566
+ }
1567
+ return {
1568
+ intValue: decimal
1569
+ };
1570
+ }
1571
+ return {
1572
+ doubleValue: value
1573
+ };
1574
+ }
1575
+ if (typeof value == "string")
1576
+ return {
1577
+ stringValue: sanitizeString(value)
1578
+ };
1579
+ if (typeof value == "function")
1580
+ return {
1581
+ stringValue: FUNCTION_VALUE
1582
+ };
1583
+ if (typeof value == "symbol")
1584
+ return {
1585
+ stringValue: String(value)
1586
+ };
1587
+ if (typeof value == "object" && value !== null) {
1588
+ if (state.ancestors.has(value))
1589
+ return {
1590
+ stringValue: CIRCULAR_VALUE
1591
+ };
1592
+ if (depth >= MAX_JSON_SAFE_VALUE_DEPTH)
1593
+ return {
1594
+ stringValue: TRUNCATED_VALUE
1595
+ };
1596
+ if (value instanceof Date) {
1597
+ const time = value.getTime();
1598
+ const iso = Number.isFinite(time) ? value.toISOString() : String(value);
1599
+ return {
1600
+ stringValue: typeof iso == "string" ? sanitizeString(iso) : String(iso)
1601
+ };
1602
+ }
1603
+ state.ancestors.add(value);
1604
+ try {
1605
+ try {
1606
+ const toJSON = value.toJSON;
1607
+ if (typeof toJSON == "function")
1608
+ return encodeAnyValue(toJSON.call(value), logger, state, depth + 1);
1609
+ } catch {}
1610
+ if (isArray(value))
1611
+ return {
1612
+ arrayValue: {
1613
+ values: encodeArrayValues(value, logger, state, depth + 1)
1614
+ }
1615
+ };
1616
+ return {
1617
+ kvlistValue: {
1618
+ values: encodeKeyValueList(value, logger, state, depth + 1)
1619
+ }
1620
+ };
1621
+ } finally {
1622
+ state.ancestors.delete(value);
1623
+ }
1624
+ }
1625
+ return {
1626
+ stringValue: sanitizeString(String(value))
1627
+ };
1628
+ }
1629
+ function encodeArrayValues(values, logger, state, depth) {
1630
+ const result = [];
1631
+ const itemCount = Math.min(values.length, MAX_JSON_SAFE_VALUE_ITEMS);
1632
+ let index = 0;
1633
+ for (;index < itemCount && state.remainingNodes > 0; index++)
1634
+ try {
1635
+ const element = index in values ? values[index] : undefined;
1636
+ if (isNullish(element))
1637
+ continue;
1638
+ result.push(encodeAnyValue(element, logger, state, depth));
1639
+ } catch {
1640
+ result.push({
1641
+ stringValue: UNSERIALIZABLE_VALUE
1642
+ });
1643
+ }
1644
+ if (values.length > index)
1645
+ result.push({
1646
+ stringValue: TRUNCATED_VALUE
1647
+ });
1648
+ return result;
1649
+ }
1650
+ function encodeKeyValueList(attrs, logger, state, depth) {
1651
+ const result = [];
1652
+ for (const key in attrs)
1653
+ if (propertyIsEnumerable.call(attrs, key)) {
1654
+ if (result.length >= MAX_JSON_SAFE_VALUE_ITEMS || state.remainingNodes <= 0) {
1655
+ logger?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");
1656
+ break;
1657
+ }
1658
+ try {
1659
+ const value = attrs[key];
1660
+ if (isNull(value) || isUndefined(value))
1661
+ continue;
1662
+ result.push({
1663
+ key: sanitizeString(key),
1664
+ value: encodeAnyValue(value, logger, state, depth)
1665
+ });
1666
+ } catch {
1667
+ result.push({
1668
+ key: sanitizeString(key),
1669
+ value: {
1670
+ stringValue: UNSERIALIZABLE_VALUE
1671
+ }
1672
+ });
1673
+ }
1674
+ }
1675
+ return result;
1676
+ }
1677
+
1678
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/metrics-utils.mjs
1679
+ var DEFAULT_HISTOGRAM_BOUNDS = [
1680
+ 0,
1681
+ 5,
1682
+ 10,
1683
+ 25,
1684
+ 50,
1685
+ 75,
1686
+ 100,
1687
+ 250,
1688
+ 500,
1689
+ 750,
1690
+ 1000,
1691
+ 2500,
1692
+ 5000,
1693
+ 7500,
1694
+ 1e4
1695
+ ];
1696
+ function msToUnixNano(ms) {
1697
+ return String(ms) + "000000";
1698
+ }
1699
+ function seriesKey(type, name, unit, attributes) {
1700
+ let attrsKey = "";
1701
+ if (attributes) {
1702
+ const keys = Object.keys(attributes).sort();
1703
+ attrsKey = keys.map((k) => `${JSON.stringify(k)}:${JSON.stringify(attributes[k])}`).join(",");
1704
+ }
1705
+ return `${type}\x00${name}\x00${unit ?? ""}\x00${attrsKey}`;
1706
+ }
1707
+ function bucketIndexFor(value, bounds) {
1708
+ for (let i = 0;i < bounds.length; i++)
1709
+ if (value <= bounds[i])
1710
+ return i;
1711
+ return bounds.length;
1712
+ }
1713
+ function buildMetricsResourceAttributes(config, scopeName, scopeVersion) {
1714
+ return {
1715
+ ...config.resourceAttributes,
1716
+ "service.name": config.serviceName || "unknown_service",
1717
+ ...config.environment && {
1718
+ "deployment.environment": config.environment
1719
+ },
1720
+ ...config.serviceVersion && {
1721
+ "service.version": config.serviceVersion
1722
+ },
1723
+ "telemetry.sdk.name": scopeName,
1724
+ "telemetry.sdk.version": scopeVersion
1725
+ };
1726
+ }
1727
+ function buildOtlpMetricsPayload(metrics, resourceAttributes, scopeName, scopeVersion) {
1728
+ return {
1729
+ resourceMetrics: [
1730
+ {
1731
+ resource: {
1732
+ attributes: toOtlpKeyValueList(resourceAttributes)
1733
+ },
1734
+ scopeMetrics: [
1735
+ {
1736
+ scope: {
1737
+ name: scopeName,
1738
+ version: scopeVersion
1739
+ },
1740
+ metrics
1741
+ }
1742
+ ]
1743
+ }
1744
+ ]
1745
+ };
1746
+ }
1747
+
1748
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/config.mjs
1749
+ var DEFAULT_FLUSH_INTERVAL_MS = 1e4;
1750
+ var DEFAULT_MAX_SERIES_PER_FLUSH = 1000;
1751
+ function resolveMetricsConfig(config) {
1752
+ const resourceAttributes = config?.resourceAttributes;
1753
+ return {
1754
+ serviceName: resourceAttributes?.["service.name"] ?? config?.serviceName,
1755
+ serviceVersion: resourceAttributes?.["service.version"] ?? config?.serviceVersion,
1756
+ environment: resourceAttributes?.["deployment.environment"] ?? config?.environment,
1757
+ resourceAttributes,
1758
+ beforeSend: config?.beforeSend,
1759
+ flushIntervalMs: config?.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS,
1760
+ maxSeriesPerFlush: config?.maxSeriesPerFlush ?? DEFAULT_MAX_SERIES_PER_FLUSH
1761
+ };
1762
+ }
1763
+
1764
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/index.mjs
1765
+ var OTLP_TEMPORALITY_DELTA = 1;
1766
+
1767
+ class PostHogMetrics {
1768
+ constructor(_instance, _config, _logger) {
1769
+ this._instance = _instance;
1770
+ this._config = _config;
1771
+ this._logger = _logger;
1772
+ this._series = new Map;
1773
+ this._flushPromise = null;
1774
+ this._seriesCapWarned = false;
1775
+ this._typeByName = new Map;
1776
+ this._typeCollisionWarned = new Set;
1777
+ this._generation = 0;
1778
+ }
1779
+ count(name, value = 1, options) {
1780
+ this._capture({
1781
+ name,
1782
+ type: "count",
1783
+ value,
1784
+ unit: options?.unit,
1785
+ attributes: options?.attributes
1786
+ });
1787
+ }
1788
+ gauge(name, value, options) {
1789
+ this._capture({
1790
+ name,
1791
+ type: "gauge",
1792
+ value,
1793
+ unit: options?.unit,
1794
+ attributes: options?.attributes
1795
+ });
1796
+ }
1797
+ histogram(name, value, options) {
1798
+ this._capture({
1799
+ name,
1800
+ type: "histogram",
1801
+ value,
1802
+ unit: options?.unit,
1803
+ attributes: options?.attributes
1804
+ });
1805
+ }
1806
+ flush() {
1807
+ const prev = this._flushPromise;
1808
+ const run = async () => {
1809
+ if (prev)
1810
+ await prev.catch(() => {});
1811
+ await this._doFlush();
1812
+ };
1813
+ const p = run().finally(() => {
1814
+ if (this._flushPromise === p)
1815
+ this._flushPromise = null;
1816
+ });
1817
+ this._flushPromise = p;
1818
+ return p;
1819
+ }
1820
+ drainWindow() {
1821
+ if (this._series.size === 0)
1822
+ return null;
1823
+ const window = this._series;
1824
+ this._series = new Map;
1825
+ this._seriesCapWarned = false;
1826
+ this._typeByName = new Map;
1827
+ this._typeCollisionWarned = new Set;
1828
+ return this._buildPayload(window);
1829
+ }
1830
+ reset() {
1831
+ this._generation++;
1832
+ this._clearFlushTimer();
1833
+ this._series = new Map;
1834
+ this._flushPromise = null;
1835
+ this._seriesCapWarned = false;
1836
+ this._typeByName = new Map;
1837
+ this._typeCollisionWarned = new Set;
1838
+ }
1839
+ _capture(sample) {
1840
+ if (this._instance.isDisabled || this._instance.optedOut)
1841
+ return;
1842
+ const filtered = this._runBeforeSend(sample);
1843
+ if (filtered === null)
1844
+ return;
1845
+ if (!filtered.name || typeof filtered.name != "string")
1846
+ return void this._logger.warn("Dropping metric with empty name");
1847
+ if (typeof filtered.value != "number" || !Number.isFinite(filtered.value))
1848
+ return void this._logger.warn(`Dropping metric '${filtered.name}': value must be a finite number`);
1849
+ if (filtered.type === "count" && filtered.value < 0)
1850
+ return void this._logger.warn(`Dropping count '${filtered.name}': counters are monotonic, value must be >= 0`);
1851
+ let attributes;
1852
+ let key;
1853
+ try {
1854
+ attributes = filtered.attributes ? {
1855
+ ...filtered.attributes
1856
+ } : undefined;
1857
+ key = seriesKey(filtered.type, filtered.name, filtered.unit, attributes);
1858
+ } catch (e) {
1859
+ this._logger.warn(`Dropping metric '${filtered.name}': attributes could not be serialized`, e);
1860
+ return;
1861
+ }
1862
+ let state = this._series.get(key);
1863
+ if (!state) {
1864
+ if (!this._admitNewSeries())
1865
+ return;
1866
+ state = {
1867
+ name: filtered.name,
1868
+ type: filtered.type,
1869
+ unit: filtered.unit,
1870
+ attributes,
1871
+ windowStartMs: Date.now()
1872
+ };
1873
+ this._series.set(key, state);
1874
+ }
1875
+ const seenType = this._typeByName.get(filtered.name);
1876
+ if (seenType === undefined)
1877
+ this._typeByName.set(filtered.name, filtered.type);
1878
+ else if (seenType !== filtered.type && !this._typeCollisionWarned.has(filtered.name)) {
1879
+ this._typeCollisionWarned.add(filtered.name);
1880
+ 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.`);
1881
+ }
1882
+ this._fold(state, filtered.value);
1883
+ this._armFlushTimer();
1884
+ }
1885
+ _admitNewSeries() {
1886
+ if (this._series.size < this._config.maxSeriesPerFlush)
1887
+ return true;
1888
+ if (!this._seriesCapWarned) {
1889
+ this._seriesCapWarned = true;
1890
+ this._logger.warn(`Metric series cap reached (${this._config.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`);
1891
+ }
1892
+ return false;
1893
+ }
1894
+ _fold(state, value) {
1895
+ switch (state.type) {
1896
+ case "count":
1897
+ state.total = (state.total ?? 0) + value;
1898
+ break;
1899
+ case "gauge":
1900
+ state.last = value;
1901
+ break;
1902
+ case "histogram": {
1903
+ if (!state.hist)
1904
+ state.hist = {
1905
+ count: 0,
1906
+ sum: 0,
1907
+ min: value,
1908
+ max: value,
1909
+ bucketCounts: new Array(DEFAULT_HISTOGRAM_BOUNDS.length + 1).fill(0)
1910
+ };
1911
+ const hist = state.hist;
1912
+ hist.count += 1;
1913
+ hist.sum += value;
1914
+ hist.min = Math.min(hist.min, value);
1915
+ hist.max = Math.max(hist.max, value);
1916
+ hist.bucketCounts[bucketIndexFor(value, DEFAULT_HISTOGRAM_BOUNDS)] += 1;
1917
+ break;
1918
+ }
1919
+ }
1920
+ }
1921
+ _runBeforeSend(sample) {
1922
+ const beforeSend = this._config.beforeSend;
1923
+ if (!beforeSend)
1924
+ return sample;
1925
+ const fns = isArray(beforeSend) ? beforeSend : [
1926
+ beforeSend
1927
+ ];
1928
+ let result = sample;
1929
+ for (const fn of fns)
1930
+ try {
1931
+ const next = fn(result);
1932
+ if (!next) {
1933
+ this._logger.info("Metric was rejected in beforeSend function");
1934
+ return null;
1935
+ }
1936
+ result = next;
1937
+ } catch (e) {
1938
+ this._logger.error("Error in beforeSend function for metric:", e);
1939
+ return null;
1940
+ }
1941
+ return result;
1942
+ }
1943
+ _armFlushTimer() {
1944
+ if (this._flushTimer)
1945
+ return;
1946
+ this._flushTimer = safeSetTimeout(() => {
1947
+ this._flushTimer = undefined;
1948
+ this.flush().catch((e) => {
1949
+ this._logger.error("Metrics flush failed:", e);
1950
+ });
1951
+ }, this._config.flushIntervalMs);
1952
+ }
1953
+ _clearFlushTimer() {
1954
+ if (this._flushTimer) {
1955
+ clearTimeout(this._flushTimer);
1956
+ this._flushTimer = undefined;
1957
+ }
1958
+ }
1959
+ async _doFlush() {
1960
+ if (this._series.size === 0)
1961
+ return;
1962
+ const window = this._series;
1963
+ this._series = new Map;
1964
+ this._seriesCapWarned = false;
1965
+ this._typeByName = new Map;
1966
+ this._typeCollisionWarned = new Set;
1967
+ const generation = this._generation;
1968
+ const outcome = await this._instance._sendMetricsBatch(this._buildPayload(window));
1969
+ if (generation !== this._generation)
1970
+ return;
1971
+ switch (outcome.kind) {
1972
+ case "ok":
1973
+ return;
1974
+ case "retry-later":
1975
+ this._mergeWindowBack(window);
1976
+ this._armFlushTimer();
1977
+ return;
1978
+ case "too-large":
1979
+ this._logger.warn("Metrics batch exceeded the server size limit and was dropped");
1980
+ return;
1981
+ case "fatal":
1982
+ this._logger.error("Failed to send metrics batch:", outcome.error);
1983
+ return;
1984
+ }
1985
+ }
1986
+ _buildPayload(window) {
1987
+ return buildOtlpMetricsPayload(this._buildMetrics(window), buildMetricsResourceAttributes(this._config, this._instance.getLibraryId(), this._instance.getLibraryVersion()), this._instance.getLibraryId(), this._instance.getLibraryVersion());
1988
+ }
1989
+ _buildMetrics(window) {
1990
+ const nowNano = msToUnixNano(Date.now());
1991
+ const byMetric = new Map;
1992
+ for (const state of window.values()) {
1993
+ const metricKey = seriesKey(state.type, state.name, state.unit, undefined);
1994
+ let metric = byMetric.get(metricKey);
1995
+ if (!metric) {
1996
+ metric = {
1997
+ name: state.name,
1998
+ ...state.unit && {
1999
+ unit: state.unit
2000
+ }
2001
+ };
2002
+ if (state.type === "count")
2003
+ metric.sum = {
2004
+ aggregationTemporality: OTLP_TEMPORALITY_DELTA,
2005
+ isMonotonic: true,
2006
+ dataPoints: []
2007
+ };
2008
+ else if (state.type === "gauge")
2009
+ metric.gauge = {
2010
+ dataPoints: []
2011
+ };
2012
+ else
2013
+ metric.histogram = {
2014
+ aggregationTemporality: OTLP_TEMPORALITY_DELTA,
2015
+ dataPoints: []
2016
+ };
2017
+ byMetric.set(metricKey, metric);
2018
+ }
2019
+ const attributes = toOtlpKeyValueList(state.attributes ?? {}, this._logger);
2020
+ const startNano = msToUnixNano(state.windowStartMs);
2021
+ if (state.type === "count") {
2022
+ const dp = {
2023
+ attributes,
2024
+ startTimeUnixNano: startNano,
2025
+ timeUnixNano: nowNano,
2026
+ asDouble: state.total ?? 0
2027
+ };
2028
+ metric.sum.dataPoints.push(dp);
2029
+ } else if (state.type === "gauge") {
2030
+ const dp = {
2031
+ attributes,
2032
+ timeUnixNano: nowNano,
2033
+ asDouble: state.last ?? 0
2034
+ };
2035
+ metric.gauge.dataPoints.push(dp);
2036
+ } else if (state.hist) {
2037
+ const dp = {
2038
+ attributes,
2039
+ startTimeUnixNano: startNano,
2040
+ timeUnixNano: nowNano,
2041
+ count: state.hist.count,
2042
+ sum: state.hist.sum,
2043
+ min: state.hist.min,
2044
+ max: state.hist.max,
2045
+ bucketCounts: state.hist.bucketCounts,
2046
+ explicitBounds: DEFAULT_HISTOGRAM_BOUNDS
2047
+ };
2048
+ metric.histogram.dataPoints.push(dp);
2049
+ }
2050
+ }
2051
+ return Array.from(byMetric.values());
2052
+ }
2053
+ _mergeWindowBack(window) {
2054
+ for (const [key, old] of window) {
2055
+ const current = this._series.get(key);
2056
+ if (!current) {
2057
+ if (this._admitNewSeries())
2058
+ this._series.set(key, old);
2059
+ continue;
2060
+ }
2061
+ current.windowStartMs = Math.min(current.windowStartMs, old.windowStartMs);
2062
+ switch (current.type) {
2063
+ case "count":
2064
+ current.total = (current.total ?? 0) + (old.total ?? 0);
2065
+ break;
2066
+ case "gauge":
2067
+ break;
2068
+ case "histogram":
2069
+ if (old.hist)
2070
+ if (current.hist) {
2071
+ current.hist.count += old.hist.count;
2072
+ current.hist.sum += old.hist.sum;
2073
+ current.hist.min = Math.min(current.hist.min, old.hist.min);
2074
+ current.hist.max = Math.max(current.hist.max, old.hist.max);
2075
+ for (let i = 0;i < current.hist.bucketCounts.length; i++)
2076
+ current.hist.bucketCounts[i] += old.hist.bucketCounts[i];
2077
+ } else
2078
+ current.hist = old.hist;
2079
+ break;
2080
+ }
2081
+ }
2082
+ }
2083
+ }
2084
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/eventemitter.mjs
1345
2085
  class SimpleEventEmitter {
1346
2086
  constructor() {
1347
2087
  this.events = {};
@@ -1363,37 +2103,7 @@ class SimpleEventEmitter {
1363
2103
  }
1364
2104
  }
1365
2105
 
1366
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/index.mjs
1367
- var exports_error_tracking = {};
1368
- __export(exports_error_tracking, {
1369
- winjsStackLineParser: () => winjsStackLineParser,
1370
- stripReservedExceptionStepFields: () => stripReservedExceptionStepFields,
1371
- reverseAndStripFrames: () => reverseAndStripFrames,
1372
- resolveExceptionStepsConfig: () => resolveExceptionStepsConfig,
1373
- opera11StackLineParser: () => opera11StackLineParser,
1374
- opera10StackLineParser: () => opera10StackLineParser,
1375
- nodeStackLineParser: () => nodeStackLineParser,
1376
- getUtf8ByteLength: () => getUtf8ByteLength,
1377
- geckoStackLineParser: () => geckoStackLineParser,
1378
- createStackParser: () => createStackParser,
1379
- createDefaultStackParser: () => createDefaultStackParser,
1380
- chromeStackLineParser: () => chromeStackLineParser,
1381
- StringCoercer: () => StringCoercer,
1382
- ReduceableCache: () => ReduceableCache,
1383
- PromiseRejectionEventCoercer: () => PromiseRejectionEventCoercer,
1384
- PrimitiveCoercer: () => PrimitiveCoercer,
1385
- ObjectCoercer: () => ObjectCoercer,
1386
- ExceptionStepsBuffer: () => ExceptionStepsBuffer,
1387
- EventCoercer: () => EventCoercer,
1388
- ErrorPropertiesBuilder: () => ErrorPropertiesBuilder,
1389
- ErrorEventCoercer: () => ErrorEventCoercer,
1390
- ErrorCoercer: () => ErrorCoercer,
1391
- EXCEPTION_STEP_INTERNAL_FIELDS: () => EXCEPTION_STEP_INTERNAL_FIELDS,
1392
- DOMExceptionCoercer: () => DOMExceptionCoercer,
1393
- DEFAULT_EXCEPTION_STEPS_CONFIG: () => DEFAULT_EXCEPTION_STEPS_CONFIG
1394
- });
1395
-
1396
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
2106
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
1397
2107
  var parsedStackResults;
1398
2108
  var lastKeysCount;
1399
2109
  var cachedFilenameChunkIds;
@@ -1432,7 +2142,7 @@ function getFilenameToChunkIdMap(stackParser) {
1432
2142
  return cachedFilenameChunkIds;
1433
2143
  }
1434
2144
 
1435
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
2145
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
1436
2146
  var MAX_CAUSE_RECURSION = 4;
1437
2147
 
1438
2148
  class ErrorPropertiesBuilder {
@@ -1536,11 +2246,11 @@ class ErrorPropertiesBuilder {
1536
2246
  return context;
1537
2247
  }
1538
2248
  buildCoercingContext(mechanism, hint, depth = 0) {
1539
- const coerce = (input, depth2) => {
1540
- if (!(depth2 <= MAX_CAUSE_RECURSION))
2249
+ const coerce = (input, depth) => {
2250
+ if (!(depth <= MAX_CAUSE_RECURSION))
1541
2251
  return;
1542
2252
  {
1543
- const ctx = this.buildCoercingContext(mechanism, hint, depth2);
2253
+ const ctx = this.buildCoercingContext(mechanism, hint, depth);
1544
2254
  return this.applyCoercers(input, ctx);
1545
2255
  }
1546
2256
  };
@@ -1554,14 +2264,16 @@ class ErrorPropertiesBuilder {
1554
2264
  return context;
1555
2265
  }
1556
2266
  }
1557
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
2267
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
1558
2268
  var UNKNOWN_FUNCTION = "?";
2269
+ var MASKED_URL_PREFIX = "webkit-masked-url://";
2270
+ var ANONYMOUS_FILENAME = "<anonymous>";
1559
2271
  function createFrame(platform, filename, func, lineno, colno) {
1560
2272
  const frame = {
1561
2273
  platform,
1562
2274
  filename,
1563
2275
  function: func === "<anonymous>" ? UNKNOWN_FUNCTION : func,
1564
- in_app: true
2276
+ in_app: !filename?.startsWith(MASKED_URL_PREFIX) && filename !== ANONYMOUS_FILENAME
1565
2277
  };
1566
2278
  if (!isUndefined(lineno))
1567
2279
  frame.lineno = lineno;
@@ -1570,7 +2282,7 @@ function createFrame(platform, filename, func, lineno, colno) {
1570
2282
  return frame;
1571
2283
  }
1572
2284
 
1573
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
2285
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
1574
2286
  var extractSafariExtensionDetails = (func, filename) => {
1575
2287
  const isSafariExtension = func.indexOf("safari-extension") !== -1;
1576
2288
  const isSafariWebExtension = func.indexOf("safari-web-extension") !== -1;
@@ -1583,15 +2295,15 @@ var extractSafariExtensionDetails = (func, filename) => {
1583
2295
  ];
1584
2296
  };
1585
2297
 
1586
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
2298
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
1587
2299
  var chromeRegexNoFnName = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i;
1588
2300
  var chromeRegex = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
1589
2301
  var chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
1590
2302
  var chromeStackLineParser = (line, platform) => {
1591
2303
  const noFnParts = chromeRegexNoFnName.exec(line);
1592
2304
  if (noFnParts) {
1593
- const [, filename, line2, col] = noFnParts;
1594
- return createFrame(platform, filename, UNKNOWN_FUNCTION, +line2, +col);
2305
+ const [, filename, line, col] = noFnParts;
2306
+ return createFrame(platform, filename, UNKNOWN_FUNCTION, +line, +col);
1595
2307
  }
1596
2308
  const parts = chromeRegex.exec(line);
1597
2309
  if (parts) {
@@ -1609,7 +2321,7 @@ var chromeStackLineParser = (line, platform) => {
1609
2321
  }
1610
2322
  };
1611
2323
 
1612
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
2324
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
1613
2325
  var geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
1614
2326
  var geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
1615
2327
  var geckoStackLineParser = (line, platform) => {
@@ -1632,28 +2344,12 @@ var geckoStackLineParser = (line, platform) => {
1632
2344
  }
1633
2345
  };
1634
2346
 
1635
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/winjs.mjs
1636
- var winjsRegex = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
1637
- var winjsStackLineParser = (line, platform) => {
1638
- const parts = winjsRegex.exec(line);
1639
- return parts ? createFrame(platform, parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined) : undefined;
1640
- };
1641
-
1642
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/opera.mjs
1643
- var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
1644
- var opera10StackLineParser = (line, platform) => {
1645
- const parts = opera10Regex.exec(line);
1646
- return parts ? createFrame(platform, parts[2], parts[3] || UNKNOWN_FUNCTION, +parts[1]) : undefined;
1647
- };
1648
- var opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;
1649
- var opera11StackLineParser = (line, platform) => {
1650
- const parts = opera11Regex.exec(line);
1651
- return parts ? createFrame(platform, parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined;
1652
- };
1653
-
1654
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
2347
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
1655
2348
  var FILENAME_MATCH = /^\s*[-]{4,}$/;
1656
2349
  var FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
2350
+ var PROMISE_COMBINATOR = /^Promise\.(?:all|any)$/;
2351
+ var PROMISE_INDEX = /^index \d+$/;
2352
+ var PROMISE_FRAME_FILENAME = "node:internal/promise";
1657
2353
  var nodeStackLineParser = (line, platform) => {
1658
2354
  const lineMatch = line.match(FULL_MATCH);
1659
2355
  if (lineMatch) {
@@ -1696,6 +2392,8 @@ var nodeStackLineParser = (line, platform) => {
1696
2392
  filename = filename.slice(1);
1697
2393
  if (!filename && lineMatch[5] && !isNative)
1698
2394
  filename = lineMatch[5];
2395
+ if (PROMISE_COMBINATOR.test(functionName) && PROMISE_INDEX.test(filename || ""))
2396
+ filename = PROMISE_FRAME_FILENAME;
1699
2397
  return {
1700
2398
  filename: filename ? decodeURI(filename) : undefined,
1701
2399
  module: undefined,
@@ -1720,7 +2418,7 @@ function _parseIntOrUndefined(input) {
1720
2418
  return parseInt(input || "", 10) || undefined;
1721
2419
  }
1722
2420
 
1723
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
2421
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
1724
2422
  var WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
1725
2423
  var STACKTRACE_FRAME_LIMIT = 50;
1726
2424
  function reverseAndStripFrames(stack) {
@@ -1765,48 +2463,20 @@ function createStackParser(platform, ...parsers) {
1765
2463
  return reverseAndStripFrames(frames);
1766
2464
  };
1767
2465
  }
1768
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/dom-exception-coercer.mjs
1769
- class DOMExceptionCoercer {
1770
- match(err) {
1771
- return this.isDOMException(err) || this.isDOMError(err);
1772
- }
1773
- coerce(err, ctx) {
1774
- const hasStack = isString(err.stack);
1775
- return {
1776
- type: this.getType(err),
1777
- value: this.getValue(err),
1778
- stack: hasStack ? err.stack : undefined,
1779
- cause: err.cause ? ctx.next(err.cause) : undefined,
1780
- synthetic: false
1781
- };
1782
- }
1783
- getType(candidate) {
1784
- return this.isDOMError(candidate) ? "DOMError" : "DOMException";
1785
- }
1786
- getValue(err) {
1787
- const name = err.name || (this.isDOMError(err) ? "DOMError" : "DOMException");
1788
- const message = err.message ? `${name}: ${err.message}` : name;
1789
- return message;
1790
- }
1791
- isDOMException(err) {
1792
- return isBuiltin(err, "DOMException");
1793
- }
1794
- isDOMError(err) {
1795
- return isBuiltin(err, "DOMError");
1796
- }
1797
- }
1798
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
2466
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
1799
2467
  class ErrorCoercer {
1800
2468
  match(err) {
1801
- return isPlainError(err);
2469
+ return isError(err);
1802
2470
  }
1803
2471
  coerce(err, ctx) {
2472
+ const stack = this.getStack(err);
2473
+ const synthetic = stack === undefined;
1804
2474
  return {
1805
2475
  type: this.getType(err),
1806
2476
  value: this.getMessage(err, ctx),
1807
- stack: this.getStack(err),
2477
+ stack: stack ?? ctx.syntheticException?.stack,
1808
2478
  cause: err.cause ? ctx.next(err.cause) : undefined,
1809
- synthetic: false
2479
+ synthetic
1810
2480
  };
1811
2481
  }
1812
2482
  getType(err) {
@@ -1822,25 +2492,7 @@ class ErrorCoercer {
1822
2492
  return err.stacktrace || err.stack || undefined;
1823
2493
  }
1824
2494
  }
1825
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/error-event-coercer.mjs
1826
- class ErrorEventCoercer {
1827
- constructor() {}
1828
- match(err) {
1829
- return isErrorEvent(err) && err.error != null;
1830
- }
1831
- coerce(err, ctx) {
1832
- const exceptionLike = ctx.apply(err.error);
1833
- if (!exceptionLike)
1834
- return {
1835
- type: "ErrorEvent",
1836
- value: err.message,
1837
- stack: ctx.syntheticException?.stack,
1838
- synthetic: true
1839
- };
1840
- return exceptionLike;
1841
- }
1842
- }
1843
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
2495
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
1844
2496
  var ERROR_TYPES_PATTERN = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
1845
2497
 
1846
2498
  class StringCoercer {
@@ -1870,7 +2522,7 @@ class StringCoercer {
1870
2522
  ];
1871
2523
  }
1872
2524
  }
1873
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/types.mjs
2525
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/types.mjs
1874
2526
  var severityLevels = [
1875
2527
  "fatal",
1876
2528
  "error",
@@ -1880,7 +2532,7 @@ var severityLevels = [
1880
2532
  "debug"
1881
2533
  ];
1882
2534
 
1883
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
2535
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
1884
2536
  function extractExceptionKeysForMessage(err, maxLength = 40) {
1885
2537
  const keys = Object.keys(err);
1886
2538
  keys.sort();
@@ -1897,7 +2549,7 @@ function extractExceptionKeysForMessage(err, maxLength = 40) {
1897
2549
  return "";
1898
2550
  }
1899
2551
 
1900
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
2552
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
1901
2553
  class ObjectCoercer {
1902
2554
  match(candidate) {
1903
2555
  return typeof candidate == "object" && candidate !== null;
@@ -1909,13 +2561,16 @@ class ObjectCoercer {
1909
2561
  return {
1910
2562
  type: this.getType(candidate),
1911
2563
  value: this.getValue(candidate),
1912
- stack: ctx.syntheticException?.stack,
2564
+ stack: this.getStack(candidate) ?? ctx.syntheticException?.stack,
1913
2565
  level: this.isSeverityLevel(candidate.level) ? candidate.level : "error",
1914
2566
  synthetic: true
1915
2567
  };
1916
2568
  }
1917
2569
  getType(err) {
1918
- return isEvent(err) ? err.constructor.name : "Error";
2570
+ if (isEvent(err))
2571
+ return err.constructor.name;
2572
+ const name = "name" in err ? err.name : undefined;
2573
+ return isString(name) && !isEmptyString(name) ? name : "Error";
1919
2574
  }
1920
2575
  getValue(err) {
1921
2576
  if ("name" in err && typeof err.name == "string") {
@@ -1933,6 +2588,15 @@ class ObjectCoercer {
1933
2588
  isSeverityLevel(x) {
1934
2589
  return isString(x) && !isEmptyString(x) && severityLevels.indexOf(x) >= 0;
1935
2590
  }
2591
+ getStack(candidate) {
2592
+ try {
2593
+ if (isString(candidate.stacktrace) && candidate.stacktrace.length > 0)
2594
+ return candidate.stacktrace;
2595
+ return isString(candidate.stack) && candidate.stack.length > 0 ? candidate.stack : undefined;
2596
+ } catch {
2597
+ return;
2598
+ }
2599
+ }
1936
2600
  getErrorPropertyFromObject(obj) {
1937
2601
  for (const prop in obj)
1938
2602
  if (Object.prototype.hasOwnProperty.call(obj, prop)) {
@@ -1950,7 +2614,7 @@ class ObjectCoercer {
1950
2614
  }
1951
2615
  }
1952
2616
  }
1953
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
2617
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
1954
2618
  class EventCoercer {
1955
2619
  match(err) {
1956
2620
  return isEvent(err);
@@ -1965,7 +2629,7 @@ class EventCoercer {
1965
2629
  };
1966
2630
  }
1967
2631
  }
1968
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
2632
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
1969
2633
  class PrimitiveCoercer {
1970
2634
  match(candidate) {
1971
2635
  return isPrimitive(candidate);
@@ -1979,43 +2643,7 @@ class PrimitiveCoercer {
1979
2643
  };
1980
2644
  }
1981
2645
  }
1982
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/promise-rejection-event.mjs
1983
- class PromiseRejectionEventCoercer {
1984
- match(err) {
1985
- return isBuiltin(err, "PromiseRejectionEvent") || this.isCustomEventWrappingRejection(err);
1986
- }
1987
- isCustomEventWrappingRejection(err) {
1988
- if (!isEvent(err))
1989
- return false;
1990
- try {
1991
- const detail = err.detail;
1992
- return detail != null && typeof detail == "object" && "reason" in detail;
1993
- } catch {
1994
- return false;
1995
- }
1996
- }
1997
- coerce(err, ctx) {
1998
- const reason = this.getUnhandledRejectionReason(err);
1999
- if (isPrimitive(reason))
2000
- return {
2001
- type: "UnhandledRejection",
2002
- value: `Non-Error promise rejection captured with value: ${String(reason)}`,
2003
- stack: ctx.syntheticException?.stack,
2004
- synthetic: true
2005
- };
2006
- return ctx.apply(reason);
2007
- }
2008
- getUnhandledRejectionReason(error) {
2009
- try {
2010
- if ("reason" in error)
2011
- return error.reason;
2012
- if ("detail" in error && error.detail != null && typeof error.detail == "object" && "reason" in error.detail)
2013
- return error.detail.reason;
2014
- } catch {}
2015
- return error;
2016
- }
2017
- }
2018
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/utils.mjs
2646
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/utils.mjs
2019
2647
  class ReduceableCache {
2020
2648
  constructor(_maxSize) {
2021
2649
  this._maxSize = _maxSize;
@@ -2040,7 +2668,7 @@ class ReduceableCache {
2040
2668
  }
2041
2669
  }
2042
2670
  }
2043
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
2671
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
2044
2672
  var EXCEPTION_STEP_INTERNAL_FIELDS = {
2045
2673
  MESSAGE: "$message",
2046
2674
  TIMESTAMP: "$timestamp"
@@ -2049,167 +2677,65 @@ var RESERVED_EXCEPTION_STEP_KEYS = new Set([
2049
2677
  EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE,
2050
2678
  EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP
2051
2679
  ]);
2052
- var DEFAULT_EXCEPTION_STEPS_CONFIG = {
2053
- enabled: true,
2054
- max_bytes: 32768
2055
- };
2056
- function resolveExceptionStepsConfig(config) {
2057
- if (!config)
2058
- return {
2059
- ...DEFAULT_EXCEPTION_STEPS_CONFIG
2060
- };
2061
- return {
2062
- enabled: config.enabled ?? DEFAULT_EXCEPTION_STEPS_CONFIG.enabled,
2063
- max_bytes: normalizePositiveInteger(config.max_bytes, DEFAULT_EXCEPTION_STEPS_CONFIG.max_bytes)
2064
- };
2065
- }
2066
- function stripReservedExceptionStepFields(properties) {
2067
- if (!properties)
2068
- return {
2069
- sanitizedProperties: {},
2070
- droppedKeys: []
2071
- };
2072
- const droppedKeys = [];
2073
- const sanitizedProperties = Object.keys(properties).reduce((acc, key) => {
2074
- if (RESERVED_EXCEPTION_STEP_KEYS.has(key)) {
2075
- droppedKeys.push(key);
2076
- return acc;
2077
- }
2078
- acc[key] = properties[key];
2079
- return acc;
2080
- }, {});
2081
- return {
2082
- sanitizedProperties,
2083
- droppedKeys
2084
- };
2680
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/release.mjs
2681
+ function getInjectedReleaseId() {
2682
+ const injected = globalThis._posthogReleaseId;
2683
+ return typeof injected == "string" && injected.length > 0 ? injected : undefined;
2085
2684
  }
2086
-
2087
- class ExceptionStepsBuffer {
2088
- constructor(config) {
2089
- this._entries = [];
2090
- this._totalBytes = 0;
2091
- this._config = resolveExceptionStepsConfig(config);
2092
- }
2093
- setConfig(config) {
2094
- this._config = resolveExceptionStepsConfig(config);
2095
- this._trimToMaxBytes();
2096
- }
2097
- add(step) {
2098
- const serialized = normalizeAndSerializeStep(step);
2099
- if (!serialized)
2100
- return;
2101
- const bytes = getUtf8ByteLength(serialized.json);
2102
- if (bytes > this._config.max_bytes)
2103
- return;
2104
- this._entries.push({
2105
- step: serialized.step,
2106
- bytes
2107
- });
2108
- this._totalBytes += bytes;
2109
- this._trimToMaxBytes();
2110
- }
2111
- getAttachable() {
2112
- return this._entries.map((e) => e.step);
2113
- }
2114
- clear() {
2115
- this._entries = [];
2116
- this._totalBytes = 0;
2117
- }
2118
- size() {
2119
- return this._entries.length;
2120
- }
2121
- _trimToMaxBytes() {
2122
- while (this._totalBytes > this._config.max_bytes && this._entries.length > 0) {
2123
- const evicted = this._entries.shift();
2124
- if (evicted)
2125
- this._totalBytes -= evicted.bytes;
2126
- }
2127
- }
2128
- }
2129
- function normalizePositiveInteger(input, fallback) {
2130
- if (!isNumber(input) || input === 1 / 0 || input === -1 / 0)
2131
- return fallback;
2132
- const normalized = Math.floor(input);
2133
- if (normalized < 0)
2134
- return fallback;
2135
- return normalized;
2136
- }
2137
- function normalizeAndSerializeStep(step) {
2138
- const json = safeStringify(step);
2139
- if (!json)
2140
- return;
2141
- try {
2142
- const parsed = JSON.parse(json);
2143
- if (!isObject(parsed))
2144
- return;
2145
- const parsedStep = parsed;
2146
- const message = parsedStep[EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE];
2147
- const timestamp = parsedStep[EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP];
2148
- if (!isString(message) || message.trim().length === 0)
2149
- return;
2150
- if (!isString(timestamp) && !isNumber(timestamp))
2151
- return;
2152
- return {
2153
- step: parsedStep,
2154
- json
2155
- };
2156
- } catch {
2157
- return;
2158
- }
2159
- }
2160
- function safeStringify(value) {
2161
- const seen = new WeakSet;
2162
- try {
2163
- return JSON.stringify(value, (_key, replacementValue) => {
2164
- if (typeof replacementValue == "bigint")
2165
- return replacementValue.toString();
2166
- if (typeof replacementValue == "function" || typeof replacementValue == "symbol")
2167
- return;
2168
- if (replacementValue instanceof Date)
2169
- return replacementValue.toISOString();
2170
- if (replacementValue instanceof Error)
2171
- return {
2172
- name: replacementValue.name,
2173
- message: replacementValue.message,
2174
- stack: replacementValue.stack
2175
- };
2176
- if (replacementValue && typeof replacementValue == "object") {
2177
- if (seen.has(replacementValue))
2178
- return "[Circular]";
2179
- seen.add(replacementValue);
2180
- }
2181
- return replacementValue;
2182
- });
2183
- } catch {
2184
- return;
2185
- }
2186
- }
2187
- function getUtf8ByteLength(value) {
2188
- if (typeof TextEncoder != "undefined")
2189
- return new TextEncoder().encode(value).length;
2190
- const encoded = encodeURIComponent(value);
2191
- let byteLength = 0;
2192
- for (let i = 0;i < encoded.length; i++)
2193
- if (encoded[i] === "%") {
2194
- byteLength += 1;
2195
- i += 2;
2196
- } else
2197
- byteLength += 1;
2198
- return byteLength;
2199
- }
2200
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
2685
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
2201
2686
  class PostHogFetchHttpError extends Error {
2202
- constructor(response, reqByteLength) {
2203
- super("HTTP error while fetching PostHog: status=" + response.status + ", reqByteLength=" + reqByteLength), this.response = response, this.reqByteLength = reqByteLength, this.name = "PostHogFetchHttpError";
2687
+ constructor(response, reqByteLength, responseBodyDeadline, abortController) {
2688
+ 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;
2204
2689
  }
2205
2690
  get status() {
2206
2691
  return this.response.status;
2207
2692
  }
2693
+ get bodyReadTimedOut() {
2694
+ return this._bodyReadTimedOut;
2695
+ }
2208
2696
  get text() {
2209
- return this.response.text();
2697
+ if (!this.responseBodyTextPromise)
2698
+ if (Date.now() >= this.responseBodyDeadline) {
2699
+ this._bodyReadTimedOut = true;
2700
+ const timeoutError = new Error("Response body read timed out");
2701
+ timeoutError.name = "AbortError";
2702
+ this.cancelResponseBody(timeoutError);
2703
+ this.responseBodyTextPromise = Promise.reject(timeoutError);
2704
+ } else {
2705
+ const responseBodyTimeout = new Promise((_resolve, reject) => {
2706
+ this.responseBodyTimer = safeSetTimeout(() => {
2707
+ this._bodyReadTimedOut = true;
2708
+ const timeoutError = new Error("Response body read timed out");
2709
+ timeoutError.name = "AbortError";
2710
+ reject(timeoutError);
2711
+ this.cancelResponseBody(timeoutError);
2712
+ }, this.responseBodyDeadline - Date.now());
2713
+ });
2714
+ let responseBodyText;
2715
+ try {
2716
+ responseBodyText = Promise.resolve(this.response.text());
2717
+ } catch (error) {
2718
+ responseBodyText = Promise.reject(error);
2719
+ }
2720
+ this.responseBodyTextPromise = Promise.race([
2721
+ responseBodyText,
2722
+ responseBodyTimeout
2723
+ ]).finally(() => clearTimeout(this.responseBodyTimer));
2724
+ }
2725
+ return this.responseBodyTextPromise;
2210
2726
  }
2211
2727
  get json() {
2212
- return this.response.json();
2728
+ return this.text.then((text) => JSON.parse(text));
2729
+ }
2730
+ cancelResponseBody(reason) {
2731
+ clearTimeout(this.responseBodyTimer);
2732
+ if (!this.abortController.signal.aborted)
2733
+ this.abortController.abort(reason);
2734
+ (async () => {
2735
+ try {
2736
+ await this.response.body?.cancel();
2737
+ } catch {}
2738
+ })();
2213
2739
  }
2214
2740
  }
2215
2741
 
@@ -2220,12 +2746,20 @@ class PostHogFetchNetworkError extends Error {
2220
2746
  } : {}), this.error = error, this.name = "PostHogFetchNetworkError";
2221
2747
  }
2222
2748
  }
2749
+ var applyCallerFeatureFlagOverrides = (target, callerProperties) => {
2750
+ for (const key of Object.keys(callerProperties))
2751
+ if (key.startsWith("$feature/") || key === "$active_feature_flags")
2752
+ target[key] = callerProperties[key];
2753
+ };
2223
2754
  async function logFlushError(err) {
2224
2755
  if (err instanceof PostHogFetchHttpError) {
2225
2756
  let text = "";
2226
2757
  try {
2227
2758
  text = await err.text;
2228
- } catch {}
2759
+ } catch {
2760
+ if (err.bodyReadTimedOut)
2761
+ text = "<response body read timed out>";
2762
+ }
2229
2763
  console.error(`Error while flushing PostHog: message=${err.message}, response body=${text}`, err);
2230
2764
  } else
2231
2765
  console.error("Error while flushing PostHog", err);
@@ -2237,9 +2771,28 @@ function isPostHogFetchError(err) {
2237
2771
  function isPostHogFetchNetworkError(err) {
2238
2772
  return err instanceof PostHogFetchNetworkError;
2239
2773
  }
2774
+ function isRetryableFlagsFetchError(err) {
2775
+ if (err instanceof PostHogFetchHttpError)
2776
+ return err.status === 502 || err.status === 504;
2777
+ if (!(err instanceof PostHogFetchNetworkError))
2778
+ return false;
2779
+ const cause = err.error;
2780
+ const code = cause?.code ?? cause?.cause?.code;
2781
+ return code !== "ECONNREFUSED";
2782
+ }
2240
2783
  function isPostHogFetchContentTooLargeError(err) {
2241
2784
  return typeof err == "object" && err instanceof PostHogFetchHttpError && err.status === 413;
2242
2785
  }
2786
+ function isPostHogFetchRetryableError(err) {
2787
+ if (err instanceof PostHogFetchHttpError)
2788
+ return err.status === 408 || err.status === 429 || err.status >= 500;
2789
+ return isPostHogFetchNetworkError(err);
2790
+ }
2791
+ function isPostHogEventProperties(value) {
2792
+ return value !== null && typeof value == "object" && !Array.isArray(value);
2793
+ }
2794
+ var DEFAULT_QUEUE_ROUTE = "default";
2795
+
2243
2796
  class PostHogCoreStateless {
2244
2797
  getErrorPropertiesBuilder() {
2245
2798
  if (!this._errorPropertiesBuilder)
@@ -2256,6 +2809,9 @@ class PostHogCoreStateless {
2256
2809
  }
2257
2810
  constructor(apiKey, options = {}) {
2258
2811
  this.flushPromise = null;
2812
+ this.pendingFlushPromise = null;
2813
+ this.flushPromises = new Set;
2814
+ this._dequeuedMessagesCount = 0;
2259
2815
  this.shutdownPromise = null;
2260
2816
  this.promiseQueue = new PromiseQueue;
2261
2817
  this._events = new SimpleEventEmitter;
@@ -2278,10 +2834,11 @@ class PostHogCoreStateless {
2278
2834
  this._retryOptions = {
2279
2835
  retryCount: options.fetchRetryCount ?? 3,
2280
2836
  retryDelay: options.fetchRetryDelay ?? 3000,
2281
- retryCheck: isPostHogFetchError
2837
+ retryCheck: isPostHogFetchRetryableError
2282
2838
  };
2283
2839
  this.requestTimeout = options.requestTimeout ?? 1e4;
2284
2840
  this.featureFlagsRequestTimeoutMs = options.featureFlagsRequestTimeoutMs ?? 3000;
2841
+ this.featureFlagsRequestMaxRetries = options.featureFlagsRequestMaxRetries ?? 1;
2285
2842
  this.remoteConfigRequestTimeoutMs = options.remoteConfigRequestTimeoutMs ?? 3000;
2286
2843
  this.disableGeoip = options.disableGeoip ?? true;
2287
2844
  this.disabled = (options.disabled ?? false) || missingApiKey;
@@ -2343,15 +2900,23 @@ class PostHogCoreStateless {
2343
2900
  return this.disabled;
2344
2901
  }
2345
2902
  buildPayload(payload) {
2903
+ const userProperties = payload.properties || {};
2904
+ let properties = {
2905
+ ...userProperties,
2906
+ ...this.getCommonEventProperties()
2907
+ };
2908
+ applyCallerFeatureFlagOverrides(properties, userProperties);
2909
+ if (payload.event === "$feature_flag_called" && properties.$feature_flag_has_experiment === false && this.isMinimalFlagCalledEventsEnabled())
2910
+ properties = minimizeFlagCalledEventProperties(properties);
2346
2911
  return {
2347
2912
  distinct_id: payload.distinct_id,
2348
2913
  event: payload.event,
2349
- properties: {
2350
- ...payload.properties || {},
2351
- ...this.getCommonEventProperties()
2352
- }
2914
+ properties
2353
2915
  };
2354
2916
  }
2917
+ isMinimalFlagCalledEventsEnabled() {
2918
+ return false;
2919
+ }
2355
2920
  addPendingPromise(promise) {
2356
2921
  return this.promiseQueue.add(promise);
2357
2922
  }
@@ -2436,6 +3001,19 @@ class PostHogCoreStateless {
2436
3001
  this.enqueue("capture", payload, options);
2437
3002
  });
2438
3003
  }
3004
+ async groupIdentifyStatelessImmediate(groupType, groupKey, groupProperties, options, distinctId, eventProperties) {
3005
+ const payload = this.buildPayload({
3006
+ distinct_id: distinctId || `$${groupType}_${groupKey}`,
3007
+ event: "$groupidentify",
3008
+ properties: {
3009
+ $group_type: groupType,
3010
+ $group_key: groupKey,
3011
+ $group_set: groupProperties || {},
3012
+ ...eventProperties || {}
3013
+ }
3014
+ });
3015
+ await this.sendImmediate("capture", payload, options);
3016
+ }
2439
3017
  async getRemoteConfig() {
2440
3018
  await this._initPromise;
2441
3019
  let host = this.host;
@@ -2452,8 +3030,11 @@ class PostHogCoreStateless {
2452
3030
  }
2453
3031
  };
2454
3032
  return this.fetchWithRetry(url, fetchOptions, {
3033
+ type: "required",
3034
+ consume: (response) => response.json()
3035
+ }, {
2455
3036
  retryCount: 0
2456
- }, this.remoteConfigRequestTimeoutMs).then((response) => response.json()).catch((error) => {
3037
+ }, this.remoteConfigRequestTimeoutMs).catch((error) => {
2457
3038
  this._logger.error("Remote config could not be loaded", error);
2458
3039
  this._events.emit("error", error);
2459
3040
  });
@@ -2484,8 +3065,12 @@ class PostHogCoreStateless {
2484
3065
  };
2485
3066
  this._logger.info("Flags URL", url);
2486
3067
  return this.fetchWithRetry(url, fetchOptions, {
2487
- retryCount: 0
2488
- }, this.featureFlagsRequestTimeoutMs).then((response) => response.json()).then((response) => ({
3068
+ type: "required",
3069
+ consume: (response) => response.json()
3070
+ }, {
3071
+ retryCount: this.featureFlagsRequestMaxRetries,
3072
+ retryCheck: isRetryableFlagsFetchError
3073
+ }, this.featureFlagsRequestTimeoutMs).then((response) => ({
2489
3074
  success: true,
2490
3075
  response: normalizeFlagsResponse(response)
2491
3076
  })).catch((error) => {
@@ -2585,9 +3170,9 @@ class PostHogCoreStateless {
2585
3170
  }
2586
3171
  async getFeatureFlagDetailsStateless(distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip, flagKeysToEvaluate) {
2587
3172
  await this._initPromise;
2588
- const extraPayload = {};
2589
- if (disableGeoip ?? this.disableGeoip)
2590
- extraPayload["geoip_disable"] = true;
3173
+ const extraPayload = {
3174
+ geoip_disable: disableGeoip ?? this.disableGeoip
3175
+ };
2591
3176
  if (flagKeysToEvaluate)
2592
3177
  extraPayload["flag_keys_to_evaluate"] = flagKeysToEvaluate;
2593
3178
  const result = await this.getFlags(distinctId, groups, personProperties, groupProperties, extraPayload);
@@ -2624,15 +3209,18 @@ class PostHogCoreStateless {
2624
3209
  "Content-Type": "application/json"
2625
3210
  }
2626
3211
  };
2627
- const response = await this.fetchWithRetry(url, fetchOptions).then((response2) => {
2628
- if (response2.status !== 200 || !response2.json) {
2629
- const msg = `Surveys API could not be loaded: ${response2.status}`;
2630
- const error = new Error(msg);
2631
- this._logger.error(error);
2632
- this._events.emit("error", new Error(msg));
2633
- return;
3212
+ const response = await this.fetchWithRetry(url, fetchOptions, {
3213
+ type: "required",
3214
+ consume: (response) => {
3215
+ if (response.status !== 200 || !response.json) {
3216
+ const msg = `Surveys API could not be loaded: ${response.status}`;
3217
+ const error = new Error(msg);
3218
+ this._logger.error(error);
3219
+ this._events.emit("error", new Error(msg));
3220
+ return Promise.resolve(undefined);
3221
+ }
3222
+ return response.json();
2634
3223
  }
2635
- return response2.json();
2636
3224
  }).catch((error) => {
2637
3225
  this._logger.error("Surveys API could not be loaded", error);
2638
3226
  this._events.emit("error", error);
@@ -2669,23 +3257,39 @@ class PostHogCoreStateless {
2669
3257
  return message;
2670
3258
  }
2671
3259
  async flushStorage() {}
2672
- enqueue(type, _message, options) {
3260
+ getQueueRouteKey(_message) {
3261
+ return DEFAULT_QUEUE_ROUTE;
3262
+ }
3263
+ persistedQueueKeyForRoute(_route) {
3264
+ return types_PostHogPersistedProperty.Queue;
3265
+ }
3266
+ getActiveQueueRoutes() {
3267
+ return [
3268
+ DEFAULT_QUEUE_ROUTE
3269
+ ];
3270
+ }
3271
+ getRouteQueue(route) {
3272
+ return this.getPersistedProperty(this.persistedQueueKeyForRoute(route)) || [];
3273
+ }
3274
+ enqueue(type, _message, options, explicitRoute) {
2673
3275
  this.wrap(() => {
2674
3276
  if (this.optedOut)
2675
3277
  return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
2676
- let message = this.prepareMessage(type, _message, options);
3278
+ let message = this.prepareMessage(_message, options);
2677
3279
  message = this.processBeforeEnqueue(message);
2678
3280
  if (message === null)
2679
3281
  return;
2680
- const queue = this.getPersistedProperty(types_PostHogPersistedProperty.Queue) || [];
3282
+ message = this.normalizeMessage(message);
3283
+ const queueKey = this.persistedQueueKeyForRoute(explicitRoute ?? this.getQueueRouteKey(message));
3284
+ const queue = this.getPersistedProperty(queueKey) || [];
2681
3285
  if (queue.length >= this.maxQueueSize) {
2682
3286
  queue.shift();
2683
- this._logger.info("Queue is full, the oldest event is dropped.");
3287
+ this._logger.warn("Queue is full, the oldest event is dropped.");
2684
3288
  }
2685
3289
  queue.push({
2686
3290
  message
2687
3291
  });
2688
- this.setPersistedProperty(types_PostHogPersistedProperty.Queue, queue);
3292
+ this.setPersistedProperty(queueKey, queue);
2689
3293
  this._events.emit(type, message);
2690
3294
  if (queue.length >= this.flushAt)
2691
3295
  this.flushBackground();
@@ -2693,61 +3297,63 @@ class PostHogCoreStateless {
2693
3297
  this._flushTimer = safeSetTimeout(() => this.flushBackground(), this.flushInterval);
2694
3298
  });
2695
3299
  }
2696
- async sendImmediate(type, _message, options) {
3300
+ async sendImmediate(type, _message, options, explicitRoute) {
2697
3301
  if (this.disabled)
2698
3302
  return void this._logger.warn("The client is disabled");
2699
3303
  if (!this._isInitialized)
2700
3304
  await this._initPromise;
2701
3305
  if (this.optedOut)
2702
3306
  return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
2703
- let message = this.prepareMessage(type, _message, options);
3307
+ let message = this.prepareMessage(_message, options);
2704
3308
  message = this.processBeforeEnqueue(message);
2705
3309
  if (message === null)
2706
3310
  return;
2707
- const data = {
2708
- api_key: this.apiKey,
2709
- batch: [
2710
- message
2711
- ],
2712
- sent_at: currentISOTime()
2713
- };
2714
- if (this.historicalMigration)
2715
- data.historical_migration = true;
2716
- const payload = JSON.stringify(data);
2717
- const url = `${this.host}/batch/`;
2718
- const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
2719
- const fetchOptions = {
2720
- method: "POST",
2721
- headers: {
2722
- ...this.getCustomHeaders(),
2723
- "Content-Type": "application/json",
2724
- ...gzippedPayload !== null && {
2725
- "Content-Encoding": "gzip"
2726
- }
2727
- },
2728
- body: gzippedPayload || payload
2729
- };
3311
+ message = this.normalizeMessage(message);
2730
3312
  try {
2731
- const response = await this.fetchWithRetry(url, fetchOptions);
2732
- await response.body?.cancel()?.catch(() => {});
3313
+ await this.sendBatch([
3314
+ message
3315
+ ], undefined, explicitRoute ?? this.getQueueRouteKey(message));
2733
3316
  } catch (err) {
2734
3317
  this._events.emit("error", err);
2735
3318
  }
2736
3319
  }
2737
- prepareMessage(type, _message, options) {
3320
+ normalizeMessage(message) {
3321
+ const { type: _type, library, library_version, ...sanitizedMessage } = message;
3322
+ let properties = isPostHogEventProperties(sanitizedMessage.properties) ? sanitizedMessage.properties : undefined;
3323
+ if (library !== undefined && properties?.$lib === undefined)
3324
+ properties = {
3325
+ ...properties || {},
3326
+ $lib: library
3327
+ };
3328
+ if (library_version !== undefined && properties?.$lib_version === undefined)
3329
+ properties = {
3330
+ ...properties || {},
3331
+ $lib_version: library_version
3332
+ };
3333
+ if (properties)
3334
+ sanitizedMessage.properties = properties;
3335
+ sanitizedMessage.uuid = getEventUuid(sanitizedMessage.uuid, uuidv7);
3336
+ return sanitizedMessage;
3337
+ }
3338
+ normalizeTimestampForWire(timestamp) {
3339
+ const parsedTimestamp = timestamp instanceof Date ? timestamp : typeof timestamp == "string" ? new Date(timestamp) : null;
3340
+ if (!parsedTimestamp || Number.isNaN(parsedTimestamp.getTime()))
3341
+ return timestamp;
3342
+ const normalized = parsedTimestamp.toISOString();
3343
+ const fractionalSeconds = typeof timestamp == "string" ? timestamp.match(/\.(\d+)(?:Z|[+-]\d{2}:?\d{2})?$/i)?.[1] : undefined;
3344
+ return fractionalSeconds && fractionalSeconds.length > 3 ? normalized.replace(/\.\d{3}Z$/, `.${fractionalSeconds}Z`) : normalized;
3345
+ }
3346
+ prepareMessage(_message, options) {
2738
3347
  const message = {
2739
3348
  ..._message,
2740
- type,
2741
- library: this.getLibraryId(),
2742
- library_version: this.getLibraryVersion(),
2743
3349
  timestamp: options?.timestamp ? options?.timestamp : currentISOTime(),
2744
- uuid: options?.uuid ? options.uuid : uuidv7()
3350
+ uuid: getEventUuid(options?.uuid, uuidv7)
2745
3351
  };
2746
3352
  const addGeoipDisableProperty = options?.disableGeoip ?? this.disableGeoip;
2747
3353
  if (addGeoipDisableProperty) {
2748
- if (!message.properties)
3354
+ if (!isPostHogEventProperties(message.properties))
2749
3355
  message.properties = {};
2750
- message["properties"]["$geoip_disable"] = true;
3356
+ message.properties["$geoip_disable"] = true;
2751
3357
  }
2752
3358
  if (message.distinctId) {
2753
3359
  message.distinct_id = message.distinctId;
@@ -2762,21 +3368,64 @@ class PostHogCoreStateless {
2762
3368
  }
2763
3369
  }
2764
3370
  flushBackground() {
3371
+ if (this.pendingFlushPromise)
3372
+ return;
2765
3373
  this.flush().catch(async (err) => {
2766
3374
  await logFlushError(err);
2767
3375
  });
2768
3376
  }
2769
- async flush() {
3377
+ async waitForPendingPromises(maxPromiseId, ignoredPromises = []) {
3378
+ const ignoredPendingPromises = ignoredPromises.filter((promise) => !!promise);
3379
+ let iteration = 0;
3380
+ while (true) {
3381
+ const promises = this.promiseQueue.getPromises([
3382
+ ...ignoredPendingPromises,
3383
+ ...this.flushPromises
3384
+ ], maxPromiseId);
3385
+ if (promises.length === 0)
3386
+ return;
3387
+ if (iteration > 0)
3388
+ this._logger.debug(`flush() re-checking ${promises.length} pending promise(s) before flushing`);
3389
+ await Promise.all(promises.map((promise) => promise.catch(() => {})));
3390
+ iteration++;
3391
+ }
3392
+ }
3393
+ flushWithPendingPromises() {
3394
+ return this.flushInternal(true);
3395
+ }
3396
+ flush() {
3397
+ return this.flushInternal(false);
3398
+ }
3399
+ flushInternal(waitForPendingPromises) {
2770
3400
  if (this.disabled)
2771
- return;
2772
- const nextFlushPromise = allSettled([
2773
- this.flushPromise
2774
- ]).then(() => this._flush());
3401
+ return Promise.resolve();
3402
+ if (!waitForPendingPromises && this.pendingFlushPromise)
3403
+ return this.pendingFlushPromise;
3404
+ const previousFlushPromise = this.flushPromise;
3405
+ const maxPromiseId = this.promiseQueue.maxId;
3406
+ const nextFlushPromise = Promise.resolve().then(() => {
3407
+ if (waitForPendingPromises)
3408
+ return this.waitForPendingPromises(maxPromiseId, [
3409
+ previousFlushPromise,
3410
+ nextFlushPromise
3411
+ ]);
3412
+ }).then(() => allSettled([
3413
+ previousFlushPromise
3414
+ ])).then(() => {
3415
+ if (this.pendingFlushPromise === nextFlushPromise)
3416
+ this.pendingFlushPromise = null;
3417
+ return this._flush();
3418
+ });
3419
+ this.pendingFlushPromise = nextFlushPromise;
2775
3420
  this.flushPromise = nextFlushPromise;
3421
+ this.flushPromises.add(nextFlushPromise);
2776
3422
  this.addPendingPromise(nextFlushPromise);
2777
3423
  allSettled([
2778
3424
  nextFlushPromise
2779
3425
  ]).then(() => {
3426
+ this.flushPromises.delete(nextFlushPromise);
3427
+ if (this.pendingFlushPromise === nextFlushPromise)
3428
+ this.pendingFlushPromise = null;
2780
3429
  if (this.flushPromise === nextFlushPromise)
2781
3430
  this.flushPromise = null;
2782
3431
  });
@@ -2789,55 +3438,102 @@ class PostHogCoreStateless {
2789
3438
  headers["User-Agent"] = customUserAgent;
2790
3439
  return headers;
2791
3440
  }
3441
+ compressPayload(payload) {
3442
+ return gzipCompress(payload, this.isDebug);
3443
+ }
3444
+ getBatchEndpointPath(_route) {
3445
+ return "/batch/";
3446
+ }
3447
+ async sendBatch(batchMessages, retryOptions, route = DEFAULT_QUEUE_ROUTE) {
3448
+ const data = {
3449
+ api_key: this.apiKey,
3450
+ batch: batchMessages.map((message) => {
3451
+ if (!message)
3452
+ return message;
3453
+ const timestamp = this.normalizeTimestampForWire(message.timestamp);
3454
+ return timestamp === message.timestamp ? message : {
3455
+ ...message,
3456
+ timestamp
3457
+ };
3458
+ }),
3459
+ sent_at: currentISOTime()
3460
+ };
3461
+ if (this.historicalMigration)
3462
+ data.historical_migration = true;
3463
+ const payload = safeJsonStringify(data);
3464
+ const url = `${this.host}${this.getBatchEndpointPath(route)}`;
3465
+ const gzippedPayload = this.disableCompression ? null : await this.compressPayload(payload);
3466
+ const fetchOptions = {
3467
+ method: "POST",
3468
+ headers: {
3469
+ ...this.getCustomHeaders(),
3470
+ "Content-Type": "application/json",
3471
+ ...gzippedPayload !== null && {
3472
+ "Content-Encoding": "gzip"
3473
+ }
3474
+ },
3475
+ body: gzippedPayload || payload
3476
+ };
3477
+ await this.fetchWithRetry(url, fetchOptions, {
3478
+ type: "successful-write"
3479
+ }, retryOptions);
3480
+ }
2792
3481
  async _flush() {
2793
3482
  this.clearFlushTimer();
2794
3483
  await this._initPromise;
2795
- let queue = this.getPersistedProperty(types_PostHogPersistedProperty.Queue) || [];
2796
- if (!queue.length)
3484
+ const routes = this.getActiveQueueRoutes();
3485
+ if (!routes.some((route) => this.getRouteQueue(route).length > 0))
2797
3486
  return;
2798
3487
  const sentMessages = [];
3488
+ let firstError;
3489
+ for (const route of routes)
3490
+ try {
3491
+ await this._flushRoute(route, sentMessages);
3492
+ } catch (err) {
3493
+ if (firstError === undefined)
3494
+ firstError = err;
3495
+ }
3496
+ if (firstError !== undefined)
3497
+ throw firstError;
3498
+ this._events.emit("flush", sentMessages);
3499
+ }
3500
+ async _flushRoute(route, sentMessages) {
3501
+ const queueKey = this.persistedQueueKeyForRoute(route);
3502
+ let queue = this.getPersistedProperty(queueKey) || [];
3503
+ if (!queue.length)
3504
+ return;
2799
3505
  const originalQueueLength = queue.length;
2800
- while (queue.length > 0 && sentMessages.length < originalQueueLength) {
3506
+ let sentFromRoute = 0;
3507
+ while (queue.length > 0 && sentFromRoute < originalQueueLength) {
2801
3508
  const batchItems = queue.slice(0, this.maxBatchSize);
2802
- const batchMessages = batchItems.map((item) => item.message);
3509
+ const batchMessages = batchItems.map((item) => item.message === undefined ? item.message : this.normalizeMessage(item.message));
2803
3510
  const persistQueueChange = async () => {
2804
- const refreshedQueue = this.getPersistedProperty(types_PostHogPersistedProperty.Queue) || [];
2805
- const newQueue = refreshedQueue.slice(batchItems.length);
2806
- this.setPersistedProperty(types_PostHogPersistedProperty.Queue, newQueue);
3511
+ const refreshedQueue = this.getPersistedProperty(queueKey) || [];
3512
+ const remainingBatchItems = [
3513
+ ...batchItems
3514
+ ];
3515
+ const newQueue = refreshedQueue.filter((item) => {
3516
+ const itemUuid = item.message?.uuid;
3517
+ const batchItemIndex = remainingBatchItems.findIndex((batchItem) => batchItem === item || typeof itemUuid == "string" && itemUuid.length > 0 && batchItem.message?.uuid === itemUuid);
3518
+ if (batchItemIndex === -1)
3519
+ return true;
3520
+ remainingBatchItems.splice(batchItemIndex, 1);
3521
+ return false;
3522
+ });
3523
+ this.setPersistedProperty(queueKey, newQueue);
2807
3524
  queue = newQueue;
3525
+ this._dequeuedMessagesCount += batchItems.length;
2808
3526
  await this.flushStorage();
2809
3527
  };
2810
- const data = {
2811
- api_key: this.apiKey,
2812
- batch: batchMessages,
2813
- sent_at: currentISOTime()
2814
- };
2815
- if (this.historicalMigration)
2816
- data.historical_migration = true;
2817
- const payload = JSON.stringify(data);
2818
- const url = `${this.host}/batch/`;
2819
- const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
2820
- const fetchOptions = {
2821
- method: "POST",
2822
- headers: {
2823
- ...this.getCustomHeaders(),
2824
- "Content-Type": "application/json",
2825
- ...gzippedPayload !== null && {
2826
- "Content-Encoding": "gzip"
2827
- }
2828
- },
2829
- body: gzippedPayload || payload
2830
- };
2831
3528
  const retryOptions = {
2832
3529
  retryCheck: (err) => {
2833
3530
  if (isPostHogFetchContentTooLargeError(err))
2834
3531
  return false;
2835
- return isPostHogFetchError(err);
3532
+ return isPostHogFetchRetryableError(err);
2836
3533
  }
2837
3534
  };
2838
3535
  try {
2839
- const response = await this.fetchWithRetry(url, fetchOptions, retryOptions);
2840
- await response.body?.cancel()?.catch(() => {});
3536
+ await this.sendBatch(batchMessages, retryOptions, route);
2841
3537
  } catch (err) {
2842
3538
  if (isPostHogFetchContentTooLargeError(err) && batchMessages.length > 1) {
2843
3539
  this.maxBatchSize = Math.max(1, Math.floor(batchMessages.length / 2));
@@ -2851,8 +3547,8 @@ class PostHogCoreStateless {
2851
3547
  }
2852
3548
  await persistQueueChange();
2853
3549
  sentMessages.push(...batchMessages);
3550
+ sentFromRoute += batchMessages.length;
2854
3551
  }
2855
- this._events.emit("flush", sentMessages);
2856
3552
  }
2857
3553
  async _sendLogsBatch(payload) {
2858
3554
  if (this.disabled)
@@ -2862,7 +3558,7 @@ class PostHogCoreStateless {
2862
3558
  };
2863
3559
  const serialized = JSON.stringify(payload);
2864
3560
  const url = `${this.host}/i/v1/logs?token=${encodeURIComponent(this.apiKey)}`;
2865
- const gzippedPayload = this.disableCompression ? null : await gzipCompress(serialized, this.isDebug);
3561
+ const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
2866
3562
  const fetchOptions = {
2867
3563
  method: "POST",
2868
3564
  headers: {
@@ -2876,10 +3572,12 @@ class PostHogCoreStateless {
2876
3572
  };
2877
3573
  try {
2878
3574
  await this.fetchWithRetry(url, fetchOptions, {
3575
+ type: "successful-write"
3576
+ }, {
2879
3577
  retryCheck: (err) => {
2880
3578
  if (isPostHogFetchContentTooLargeError(err))
2881
3579
  return false;
2882
- return isPostHogFetchError(err);
3580
+ return isPostHogFetchRetryableError(err);
2883
3581
  }
2884
3582
  });
2885
3583
  return {
@@ -2901,41 +3599,155 @@ class PostHogCoreStateless {
2901
3599
  };
2902
3600
  }
2903
3601
  }
2904
- async fetchWithRetry(url, options, retryOptions, requestTimeout) {
3602
+ async _sendMetricsBatch(payload) {
3603
+ if (this.disabled)
3604
+ return {
3605
+ kind: "fatal",
3606
+ error: new Error("The client is disabled")
3607
+ };
3608
+ const serialized = JSON.stringify(payload);
3609
+ const url = `${this.host}/i/v1/metrics?token=${encodeURIComponent(this.apiKey)}`;
3610
+ const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
3611
+ const fetchOptions = {
3612
+ method: "POST",
3613
+ headers: {
3614
+ ...this.getCustomHeaders(),
3615
+ "Content-Type": "application/json",
3616
+ ...gzippedPayload !== null && {
3617
+ "Content-Encoding": "gzip"
3618
+ }
3619
+ },
3620
+ body: gzippedPayload || serialized
3621
+ };
3622
+ try {
3623
+ await this.fetchWithRetry(url, fetchOptions, {
3624
+ type: "successful-write"
3625
+ }, {
3626
+ retryCheck: (err) => {
3627
+ if (isPostHogFetchContentTooLargeError(err))
3628
+ return false;
3629
+ return isPostHogFetchRetryableError(err);
3630
+ }
3631
+ });
3632
+ return {
3633
+ kind: "ok"
3634
+ };
3635
+ } catch (err) {
3636
+ if (isPostHogFetchContentTooLargeError(err))
3637
+ return {
3638
+ kind: "too-large"
3639
+ };
3640
+ if (isPostHogFetchRetryableError(err))
3641
+ return {
3642
+ kind: "retry-later",
3643
+ error: err
3644
+ };
3645
+ return {
3646
+ kind: "fatal",
3647
+ error: err
3648
+ };
3649
+ }
3650
+ }
3651
+ async fetchWithRetry(url, options, responseHandling, retryOptions, requestTimeout) {
2905
3652
  const body = options.body ? options.body : "";
2906
3653
  let reqByteLength = -1;
2907
3654
  try {
2908
- reqByteLength = body instanceof Blob ? body.size : Buffer.byteLength(body, STRING_FORMAT);
3655
+ reqByteLength = body instanceof Blob ? body.size : body instanceof Uint8Array ? body.byteLength : Buffer.byteLength(body, STRING_FORMAT);
2909
3656
  } catch {
2910
3657
  if (body instanceof Blob)
2911
3658
  reqByteLength = body.size;
3659
+ else if (body instanceof Uint8Array)
3660
+ reqByteLength = body.byteLength;
2912
3661
  else {
2913
3662
  const encoded = new TextEncoder().encode(body);
2914
3663
  reqByteLength = encoded.length;
2915
3664
  }
2916
3665
  }
3666
+ const retriableOptions = {
3667
+ ...this._retryOptions,
3668
+ ...retryOptions
3669
+ };
3670
+ let attempt = 0;
2917
3671
  return await retriable(async () => {
3672
+ attempt++;
2918
3673
  const ctrl = new AbortController;
2919
3674
  const timeoutMs = requestTimeout ?? this.requestTimeout;
2920
- const timer = safeSetTimeout(() => ctrl.abort(), timeoutMs);
2921
- let res = null;
3675
+ const requestDeadline = Date.now() + timeoutMs;
3676
+ let timer;
3677
+ const deadline = new Promise((_resolve, reject) => {
3678
+ timer = safeSetTimeout(() => {
3679
+ const timeoutError = new Error(`Request timed out after ${timeoutMs}ms`);
3680
+ timeoutError.name = "AbortError";
3681
+ reject(timeoutError);
3682
+ ctrl.abort(timeoutError);
3683
+ }, timeoutMs);
3684
+ });
3685
+ let res;
3686
+ let responseAccepted = false;
3687
+ let cancellation;
3688
+ const cancelBody = () => cancellation ??= (async () => {
3689
+ try {
3690
+ await res?.body?.cancel();
3691
+ } catch {}
3692
+ })();
2922
3693
  try {
2923
- res = await this.fetch(url, {
2924
- signal: ctrl.signal,
2925
- ...options
2926
- });
2927
- } catch (e) {
2928
- throw new PostHogFetchNetworkError(e);
3694
+ let fetchPromise;
3695
+ try {
3696
+ fetchPromise = this.fetch(url, {
3697
+ signal: ctrl.signal,
3698
+ ...options
3699
+ });
3700
+ } catch (e) {
3701
+ throw new PostHogFetchNetworkError(e);
3702
+ }
3703
+ fetchPromise.then((lateResponse) => {
3704
+ if (ctrl.signal.aborted && !responseAccepted)
3705
+ Promise.resolve(lateResponse.body?.cancel()).catch(() => {});
3706
+ }).catch(() => {});
3707
+ try {
3708
+ res = await Promise.race([
3709
+ fetchPromise,
3710
+ deadline
3711
+ ]);
3712
+ responseAccepted = true;
3713
+ } catch (e) {
3714
+ throw new PostHogFetchNetworkError(e);
3715
+ }
3716
+ const isNoCors = options.mode === "no-cors";
3717
+ if (!isNoCors && (res.status < 200 || res.status >= 400))
3718
+ throw new PostHogFetchHttpError(res, reqByteLength, requestDeadline, ctrl);
3719
+ if (responseHandling.type === "successful-write") {
3720
+ try {
3721
+ await Promise.race([
3722
+ cancelBody(),
3723
+ deadline
3724
+ ]);
3725
+ } catch {}
3726
+ return;
3727
+ }
3728
+ try {
3729
+ return await Promise.race([
3730
+ responseHandling.consume(res),
3731
+ deadline
3732
+ ]);
3733
+ } catch (e) {
3734
+ if (ctrl.signal.aborted)
3735
+ throw new PostHogFetchNetworkError(e);
3736
+ throw e;
3737
+ }
2929
3738
  } finally {
2930
3739
  clearTimeout(timer);
3740
+ if (ctrl.signal.aborted && res)
3741
+ cancelBody();
2931
3742
  }
2932
- const isNoCors = options.mode === "no-cors";
2933
- if (!isNoCors && (res.status < 200 || res.status >= 400))
2934
- throw new PostHogFetchHttpError(res, reqByteLength);
2935
- return res;
2936
3743
  }, {
2937
- ...this._retryOptions,
2938
- ...retryOptions
3744
+ ...retriableOptions,
3745
+ retryCheck: (error) => {
3746
+ const shouldRetry = retriableOptions.retryCheck(error);
3747
+ if (shouldRetry && attempt <= retriableOptions.retryCount && error instanceof PostHogFetchHttpError)
3748
+ error.cancelResponseBody();
3749
+ return shouldRetry;
3750
+ }
2939
3751
  });
2940
3752
  }
2941
3753
  async _shutdown(shutdownTimeoutMs = 30000) {
@@ -2948,12 +3760,17 @@ class PostHogCoreStateless {
2948
3760
  try {
2949
3761
  await this.promiseQueue.join();
2950
3762
  while (true) {
2951
- const queue = this.getPersistedProperty(types_PostHogPersistedProperty.Queue) || [];
2952
- if (queue.length === 0)
3763
+ const hasQueuedEvents = this.getActiveQueueRoutes().some((route) => this.getRouteQueue(route).length > 0);
3764
+ if (!hasQueuedEvents)
2953
3765
  break;
3766
+ const dequeuedBeforeFlush = this._dequeuedMessagesCount;
2954
3767
  await this.flush();
2955
3768
  if (hasTimedOut)
2956
3769
  break;
3770
+ if (this._dequeuedMessagesCount === dequeuedBeforeFlush) {
3771
+ this._logger.warn("Shutdown flush completed but did not send any queued events. Stopping drain to avoid a loop.");
3772
+ break;
3773
+ }
2957
3774
  }
2958
3775
  } catch (e) {
2959
3776
  if (!isPostHogFetchError(e))
@@ -2961,21 +3778,12 @@ class PostHogCoreStateless {
2961
3778
  await logFlushError(e);
2962
3779
  }
2963
3780
  };
2964
- let timeoutHandle;
2965
- try {
2966
- return await Promise.race([
2967
- new Promise((_, reject) => {
2968
- timeoutHandle = safeSetTimeout(() => {
2969
- this._logger.error("Timed out while shutting down PostHog");
2970
- hasTimedOut = true;
2971
- reject("Timeout while shutting down PostHog. Some events may not have been sent.");
2972
- }, shutdownTimeoutMs);
2973
- }),
2974
- doShutdown()
2975
- ]);
2976
- } finally {
2977
- clearTimeout(timeoutHandle);
2978
- }
3781
+ return raceWithTimeout(doShutdown(), shutdownTimeoutMs, () => {
3782
+ this._logger.critical("Timeout while shutting down PostHog. Some events may not have been sent.", {
3783
+ shutdownTimeoutMs
3784
+ });
3785
+ hasTimedOut = true;
3786
+ });
2979
3787
  }
2980
3788
  async shutdown(shutdownTimeoutMs = 30000) {
2981
3789
  if (this.shutdownPromise)
@@ -2987,21 +3795,30 @@ class PostHogCoreStateless {
2987
3795
  return this.shutdownPromise;
2988
3796
  }
2989
3797
  }
2990
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
2991
- import { createReadStream } from "node:fs";
3798
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
3799
+ import { constants as constants2 } from "node:fs";
3800
+ import { open as promises_open } from "node:fs/promises";
3801
+ import { isAbsolute } from "node:path";
2992
3802
  import { createInterface } from "node:readline";
2993
- var LRU_FILE_CONTENTS_CACHE = new exports_error_tracking.ReduceableCache(25);
2994
- var LRU_FILE_CONTENTS_FS_READ_FAILED = new exports_error_tracking.ReduceableCache(20);
3803
+ var LRU_FILE_CONTENTS_CACHE = new ReduceableCache(25);
3804
+ var LRU_FILE_CONTENTS_FS_READ_FAILED = new ReduceableCache(20);
2995
3805
  var DEFAULT_LINES_OF_CONTEXT = 7;
2996
3806
  var MAX_CONTEXTLINES_COLNO = 1000;
2997
3807
  var MAX_CONTEXTLINES_LINENO = 1e4;
2998
- async function addSourceContext(frames) {
3808
+ var MAX_CONTEXTLINES_FILE_SIZE = 10485760;
3809
+ async function addSourceContext(frames, openSourceFile = promises_open, logger) {
2999
3810
  const filesToLines = {};
3811
+ let basePath;
3812
+ try {
3813
+ basePath = process.cwd();
3814
+ } catch {}
3000
3815
  for (let i = frames.length - 1;i >= 0; i--) {
3001
3816
  const frame = frames[i];
3002
3817
  const filename = frame?.filename;
3003
3818
  if (!frame || typeof filename != "string" || typeof frame.lineno != "number" || shouldSkipContextLinesForFile(filename) || shouldSkipContextLinesForFrame(frame))
3004
3819
  continue;
3820
+ if (!isAbsolute(filename) && basePath === undefined)
3821
+ continue;
3005
3822
  const filesToLinesOutput = filesToLines[filename];
3006
3823
  if (!filesToLinesOutput)
3007
3824
  filesToLines[filename] = [];
@@ -3012,50 +3829,98 @@ async function addSourceContext(frames) {
3012
3829
  return frames;
3013
3830
  const readlinePromises = [];
3014
3831
  for (const file of files) {
3015
- if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(file))
3832
+ const cacheKey = makeSourceCacheKey(file, basePath);
3833
+ if (cacheKey === undefined)
3834
+ continue;
3835
+ if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(cacheKey))
3016
3836
  continue;
3017
3837
  const filesToLineRanges = filesToLines[file];
3018
3838
  if (!filesToLineRanges)
3019
3839
  continue;
3020
3840
  filesToLineRanges.sort((a, b) => a - b);
3021
3841
  const ranges = makeLineReaderRanges(filesToLineRanges);
3022
- if (ranges.every((r) => rangeExistsInContentCache(file, r)))
3842
+ if (ranges.every((r) => rangeExistsInContentCache(cacheKey, r)))
3023
3843
  continue;
3024
- const cache = emplace(LRU_FILE_CONTENTS_CACHE, file, {});
3025
- readlinePromises.push(getContextLinesFromFile(file, ranges, cache));
3844
+ const cache = emplace(LRU_FILE_CONTENTS_CACHE, cacheKey, {});
3845
+ readlinePromises.push(getContextLinesFromFile(file, ranges, cache, cacheKey, openSourceFile, logger));
3026
3846
  }
3027
3847
  await Promise.all(readlinePromises).catch(() => {});
3028
3848
  if (frames && frames.length > 0)
3029
- addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE);
3849
+ addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE, basePath);
3030
3850
  LRU_FILE_CONTENTS_CACHE.reduce();
3031
3851
  return frames;
3032
3852
  }
3033
- function getContextLinesFromFile(path2, ranges, output) {
3853
+ async function openRegularSourceFile(path, openSourceFile, logger) {
3854
+ let fileHandle;
3855
+ let isValid = false;
3856
+ try {
3857
+ fileHandle = await openSourceFile(path, constants2.O_RDONLY | constants2.O_NONBLOCK);
3858
+ const fileStat = await fileHandle.stat();
3859
+ if (!fileStat.isFile())
3860
+ return;
3861
+ if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE)
3862
+ return void logger?.debug(`Skipping source context for oversized file ${path}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
3863
+ isValid = true;
3864
+ return fileHandle;
3865
+ } catch {
3866
+ return;
3867
+ } finally {
3868
+ if (fileHandle && !isValid)
3869
+ await fileHandle.close().catch(() => {});
3870
+ }
3871
+ }
3872
+ async function getContextLinesFromFile(path, ranges, output, cacheKey, openSourceFile, logger) {
3873
+ const fileHandle = await openRegularSourceFile(path, openSourceFile, logger);
3874
+ if (fileHandle === undefined)
3875
+ return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
3876
+ const openedFileHandle = fileHandle;
3034
3877
  return new Promise((resolve) => {
3035
- const stream = createReadStream(path2);
3036
- const lineReaded = createInterface({
3037
- input: stream
3038
- });
3039
- function destroyStreamAndResolve() {
3040
- stream.destroy();
3041
- resolve();
3878
+ let finished = false;
3879
+ function destroyStreamAndResolve(stream) {
3880
+ if (finished)
3881
+ return;
3882
+ finished = true;
3883
+ stream?.destroy();
3884
+ openedFileHandle.close().then(resolve, resolve);
3885
+ }
3886
+ let stream;
3887
+ try {
3888
+ stream = openedFileHandle.createReadStream({
3889
+ autoClose: false,
3890
+ start: 0,
3891
+ end: MAX_CONTEXTLINES_FILE_SIZE - 1
3892
+ });
3893
+ } catch {
3894
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
3895
+ destroyStreamAndResolve();
3896
+ return;
3897
+ }
3898
+ let lineReaded;
3899
+ try {
3900
+ lineReaded = createInterface({
3901
+ input: stream
3902
+ });
3903
+ } catch {
3904
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
3905
+ destroyStreamAndResolve(stream);
3906
+ return;
3042
3907
  }
3043
3908
  let lineNumber = 0;
3044
3909
  let currentRangeIndex = 0;
3045
3910
  const range = ranges[currentRangeIndex];
3046
3911
  if (range === undefined)
3047
- return void destroyStreamAndResolve();
3912
+ return void destroyStreamAndResolve(stream);
3048
3913
  let rangeStart = range[0];
3049
3914
  let rangeEnd = range[1];
3050
3915
  function onStreamError() {
3051
- LRU_FILE_CONTENTS_FS_READ_FAILED.set(path2, 1);
3916
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
3052
3917
  lineReaded.close();
3053
3918
  lineReaded.removeAllListeners();
3054
- destroyStreamAndResolve();
3919
+ destroyStreamAndResolve(stream);
3055
3920
  }
3056
3921
  stream.on("error", onStreamError);
3057
3922
  lineReaded.on("error", onStreamError);
3058
- lineReaded.on("close", destroyStreamAndResolve);
3923
+ lineReaded.on("close", () => destroyStreamAndResolve(stream));
3059
3924
  lineReaded.on("line", (line) => {
3060
3925
  lineNumber++;
3061
3926
  if (lineNumber < rangeStart)
@@ -3068,22 +3933,23 @@ function getContextLinesFromFile(path2, ranges, output) {
3068
3933
  return;
3069
3934
  }
3070
3935
  currentRangeIndex++;
3071
- const range2 = ranges[currentRangeIndex];
3072
- if (range2 === undefined) {
3936
+ const range = ranges[currentRangeIndex];
3937
+ if (range === undefined) {
3073
3938
  lineReaded.close();
3074
3939
  lineReaded.removeAllListeners();
3075
3940
  return;
3076
3941
  }
3077
- rangeStart = range2[0];
3078
- rangeEnd = range2[1];
3942
+ rangeStart = range[0];
3943
+ rangeEnd = range[1];
3079
3944
  }
3080
3945
  });
3081
3946
  });
3082
3947
  }
3083
- function addSourceContextToFrames(frames, cache) {
3948
+ function addSourceContextToFrames(frames, cache, basePath) {
3084
3949
  for (const frame of frames)
3085
3950
  if (frame.filename && frame.context_line === undefined && typeof frame.lineno == "number") {
3086
- const contents = cache.get(frame.filename);
3951
+ const cacheKey = makeSourceCacheKey(frame.filename, basePath);
3952
+ const contents = cacheKey === undefined ? undefined : cache.get(cacheKey);
3087
3953
  if (contents === undefined)
3088
3954
  continue;
3089
3955
  addContextToFrame(frame.lineno, frame, contents);
@@ -3116,8 +3982,8 @@ function clearLineContext(frame) {
3116
3982
  delete frame.context_line;
3117
3983
  delete frame.post_context;
3118
3984
  }
3119
- function shouldSkipContextLinesForFile(path2) {
3120
- return path2.startsWith("node:") || path2.endsWith(".min.js") || path2.endsWith(".min.cjs") || path2.endsWith(".min.mjs") || path2.startsWith("data:");
3985
+ function shouldSkipContextLinesForFile(path) {
3986
+ return path.startsWith("node:") || path.endsWith(".min.js") || path.endsWith(".min.cjs") || path.endsWith(".min.mjs") || path.startsWith("data:");
3121
3987
  }
3122
3988
  function shouldSkipContextLinesForFrame(frame) {
3123
3989
  if (frame.lineno !== undefined && frame.lineno > MAX_CONTEXTLINES_LINENO)
@@ -3126,8 +3992,19 @@ function shouldSkipContextLinesForFrame(frame) {
3126
3992
  return true;
3127
3993
  return false;
3128
3994
  }
3129
- function rangeExistsInContentCache(file, range) {
3130
- const contents = LRU_FILE_CONTENTS_CACHE.get(file);
3995
+ function makeSourceCacheKey(path, basePath) {
3996
+ if (isAbsolute(path))
3997
+ return JSON.stringify([
3998
+ null,
3999
+ path
4000
+ ]);
4001
+ return basePath === undefined ? undefined : JSON.stringify([
4002
+ basePath,
4003
+ path
4004
+ ]);
4005
+ }
4006
+ function rangeExistsInContentCache(cacheKey, range) {
4007
+ const contents = LRU_FILE_CONTENTS_CACHE.get(cacheKey);
3131
4008
  if (contents === undefined)
3132
4009
  return false;
3133
4010
  for (let i = range[0];i <= range[1]; i++)
@@ -3205,8 +4082,8 @@ function snipLine(line, colno) {
3205
4082
  return newLine;
3206
4083
  }
3207
4084
 
3208
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
3209
- import { isAbsolute, relative, sep as sep2 } from "path";
4085
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
4086
+ import { isAbsolute as isAbsolute2, relative, sep as sep2 } from "path";
3210
4087
  function createRelativePathModifier(basePath = process.cwd()) {
3211
4088
  const isWindows = sep2 === "\\";
3212
4089
  const toUnix = (p) => isWindows ? p.replace(/\\/g, "/") : p;
@@ -3214,17 +4091,17 @@ function createRelativePathModifier(basePath = process.cwd()) {
3214
4091
  return async (frames) => {
3215
4092
  for (const frame of frames)
3216
4093
  if (!(!frame.filename || frame.filename.startsWith("node:") || frame.filename.startsWith("data:"))) {
3217
- if (isAbsolute(frame.filename))
4094
+ if (isAbsolute2(frame.filename))
3218
4095
  frame.filename = toUnix(relative(normalizedBase, toUnix(frame.filename)));
3219
4096
  }
3220
4097
  return frames;
3221
4098
  };
3222
4099
  }
3223
4100
 
3224
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/version.mjs
3225
- var version = "5.35.12";
4101
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/version.mjs
4102
+ var version = "5.51.1";
3226
4103
 
3227
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/types.mjs
4104
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/types.mjs
3228
4105
  var FeatureFlagError2 = {
3229
4106
  ERRORS_WHILE_COMPUTING: "errors_while_computing_flags",
3230
4107
  FLAG_MISSING: "flag_missing",
@@ -3232,7 +4109,7 @@ var FeatureFlagError2 = {
3232
4109
  UNKNOWN_ERROR: "unknown_error"
3233
4110
  };
3234
4111
 
3235
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/feature-flag-evaluations.mjs
4112
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/feature-flag-evaluations.mjs
3236
4113
  class FeatureFlagEvaluations {
3237
4114
  constructor(init) {
3238
4115
  this._host = init.host;
@@ -3248,10 +4125,10 @@ class FeatureFlagEvaluations {
3248
4125
  this._accessed = init.accessed ?? new Set;
3249
4126
  this._isSlice = init.isSlice ?? false;
3250
4127
  }
3251
- isEnabled(key) {
4128
+ isEnabled(key, options = {}) {
3252
4129
  const flag = this._flags[key];
3253
4130
  this._recordAccess(key);
3254
- return flag?.enabled ?? false;
4131
+ return flag?.enabled ?? options.defaultValue ?? false;
3255
4132
  }
3256
4133
  getFlag(key) {
3257
4134
  const flag = this._flags[key];
@@ -3341,6 +4218,8 @@ class FeatureFlagEvaluations {
3341
4218
  $feature_flag_request_id: this._requestId,
3342
4219
  $feature_flag_evaluated_at: flag?.locallyEvaluated ? Date.now() : this._evaluatedAt
3343
4220
  };
4221
+ if (flag?.hasExperiment !== undefined)
4222
+ properties.$feature_flag_has_experiment = flag.hasExperiment;
3344
4223
  if (flag?.locallyEvaluated && this._flagDefinitionsLoadedAt !== undefined)
3345
4224
  properties.$feature_flag_definitions_loaded_at = this._flagDefinitionsLoadedAt;
3346
4225
  const errors = [];
@@ -3363,7 +4242,7 @@ class FeatureFlagEvaluations {
3363
4242
  }
3364
4243
  }
3365
4244
 
3366
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
4245
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
3367
4246
  async function hashSHA1(text) {
3368
4247
  const subtle = globalThis.crypto?.subtle;
3369
4248
  if (!subtle)
@@ -3373,7 +4252,7 @@ async function hashSHA1(text) {
3373
4252
  return hashArray.map((byte) => byte.toString(16).padStart(2, "0")).join("");
3374
4253
  }
3375
4254
 
3376
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
4255
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
3377
4256
  var SIXTY_SECONDS = 60000;
3378
4257
  var LONG_SCALE = 1152921504606847000;
3379
4258
  var NULL_VALUES_ALLOWED_OPERATORS = [
@@ -3390,22 +4269,23 @@ class ClientError extends Error {
3390
4269
  Object.setPrototypeOf(this, ClientError.prototype);
3391
4270
  }
3392
4271
  }
4272
+ function setCustomErrorPrototype(error, constructor) {
4273
+ error.name = constructor.name;
4274
+ Error.captureStackTrace(error, constructor);
4275
+ Object.setPrototypeOf(error, constructor.prototype);
4276
+ }
3393
4277
 
3394
4278
  class InconclusiveMatchError extends Error {
3395
4279
  constructor(message) {
3396
4280
  super(message);
3397
- this.name = this.constructor.name;
3398
- Error.captureStackTrace(this, this.constructor);
3399
- Object.setPrototypeOf(this, InconclusiveMatchError.prototype);
4281
+ setCustomErrorPrototype(this, InconclusiveMatchError);
3400
4282
  }
3401
4283
  }
3402
4284
 
3403
4285
  class RequiresServerEvaluation extends Error {
3404
4286
  constructor(message) {
3405
4287
  super(message);
3406
- this.name = this.constructor.name;
3407
- Error.captureStackTrace(this, this.constructor);
3408
- Object.setPrototypeOf(this, RequiresServerEvaluation.prototype);
4288
+ setCustomErrorPrototype(this, RequiresServerEvaluation);
3409
4289
  }
3410
4290
  }
3411
4291
 
@@ -3414,6 +4294,7 @@ class FeatureFlagsPoller {
3414
4294
  this.debugMode = false;
3415
4295
  this.shouldBeginExponentialBackoff = false;
3416
4296
  this.backOffCount = 0;
4297
+ this.pollerStopped = false;
3417
4298
  this.pollingInterval = pollingInterval;
3418
4299
  this.personalApiKey = personalApiKey;
3419
4300
  this.featureFlags = [];
@@ -3429,6 +4310,7 @@ class FeatureFlagsPoller {
3429
4310
  this.onError = options.onError;
3430
4311
  this.customHeaders = customHeaders;
3431
4312
  this.onLoad = options.onLoad;
4313
+ this.onMinimalFlagCalledEvents = options.onMinimalFlagCalledEvents;
3432
4314
  this.cacheProvider = options.cacheProvider;
3433
4315
  this.strictLocalEvaluation = options.strictLocalEvaluation ?? false;
3434
4316
  this.loadFeatureFlags();
@@ -3626,6 +4508,7 @@ class FeatureFlagsPoller {
3626
4508
  const flagFilters = flag.filters || {};
3627
4509
  const flagConditions = flagFilters.groups || [];
3628
4510
  const flagAggregation = flagFilters.aggregation_group_type_index;
4511
+ const earlyExitEnabled = flagFilters.early_exit ?? false;
3629
4512
  const { groups, groupProperties } = evaluationContext;
3630
4513
  let isInconclusive = false;
3631
4514
  let result;
@@ -3649,12 +4532,15 @@ class FeatureFlagsPoller {
3649
4532
  effectiveBucketingValue = groups[groupName];
3650
4533
  }
3651
4534
  }
3652
- if (await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext)) {
4535
+ const matchResult = await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext);
4536
+ if (matchResult === "match") {
3653
4537
  const variantOverride = condition.variant;
3654
4538
  const flagVariants = flagFilters.multivariate?.variants || [];
3655
4539
  result = variantOverride && flagVariants.some((variant) => variant.key === variantOverride) ? variantOverride : await this.getMatchingVariant(flag, effectiveBucketingValue) || true;
3656
4540
  break;
3657
4541
  }
4542
+ if (earlyExitEnabled && matchResult === "out_of_rollout_bound")
4543
+ return false;
3658
4544
  } catch (e) {
3659
4545
  if (e instanceof RequiresServerEvaluation)
3660
4546
  throw e;
@@ -3678,16 +4564,20 @@ class FeatureFlagsPoller {
3678
4564
  for (const prop of condition.properties) {
3679
4565
  const propertyType = prop.type;
3680
4566
  let matches = false;
3681
- 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);
4567
+ if (propertyType === "cohort") {
4568
+ const inCohort = await matchCohort(prop, properties, this.cohorts, this.debugMode, (depProp) => this.evaluateFlagDependency(depProp, properties, evaluationContext));
4569
+ matches = prop.operator === "not_in" ? !inCohort : inCohort;
4570
+ } else
4571
+ matches = propertyType === "flag" ? await this.evaluateFlagDependency(prop, properties, evaluationContext) : matchProperty(prop, properties, warnFunction);
3682
4572
  if (!matches)
3683
- return false;
4573
+ return "no_match";
3684
4574
  }
3685
4575
  if (rolloutPercentage == undefined)
3686
- return true;
4576
+ return "match";
3687
4577
  }
3688
4578
  if (rolloutPercentage != null && await _hash(flag.key, bucketingValue) > rolloutPercentage / 100)
3689
- return false;
3690
- return true;
4579
+ return "out_of_rollout_bound";
4580
+ return "match";
3691
4581
  }
3692
4582
  async getMatchingVariant(flag, bucketingValue) {
3693
4583
  const hashValue = await _hash(flag.key, bucketingValue, "variant");
@@ -3718,6 +4608,7 @@ class FeatureFlagsPoller {
3718
4608
  this.groupTypeMapping = flagData.groupTypeMapping;
3719
4609
  this.cohorts = flagData.cohorts;
3720
4610
  this.loadedSuccessfullyOnce = true;
4611
+ this.onMinimalFlagCalledEvents?.(flagData.minimalFlagCalledEvents === true);
3721
4612
  }
3722
4613
  warnAboutExperienceContinuityFlags(flags) {
3723
4614
  if (this.strictLocalEvaluation)
@@ -3781,7 +4672,6 @@ class FeatureFlagsPoller {
3781
4672
  clearTimeout(this.poller);
3782
4673
  this.poller = undefined;
3783
4674
  }
3784
- this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
3785
4675
  try {
3786
4676
  let shouldFetch = true;
3787
4677
  if (this.cacheProvider)
@@ -3809,17 +4699,18 @@ class FeatureFlagsPoller {
3809
4699
  return;
3810
4700
  case 401:
3811
4701
  this.beginBackoff();
3812
- 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`);
4702
+ 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`);
3813
4703
  case 402:
3814
4704
  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");
3815
4705
  this.featureFlags = [];
3816
4706
  this.featureFlagsByKey = {};
3817
4707
  this.groupTypeMapping = {};
3818
4708
  this.cohorts = {};
4709
+ this.onMinimalFlagCalledEvents?.(false);
3819
4710
  return;
3820
4711
  case 403:
3821
4712
  this.beginBackoff();
3822
- 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`);
4713
+ 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`);
3823
4714
  case 429:
3824
4715
  this.beginBackoff();
3825
4716
  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`);
@@ -3831,7 +4722,8 @@ class FeatureFlagsPoller {
3831
4722
  const flagData = {
3832
4723
  flags: responseJson.flags ?? [],
3833
4724
  groupTypeMapping: responseJson.group_type_mapping || {},
3834
- cohorts: responseJson.cohorts || {}
4725
+ cohorts: responseJson.cohorts || {},
4726
+ minimalFlagCalledEvents: responseJson.minimal_flag_called_events === true
3835
4727
  };
3836
4728
  this.updateFlagState(flagData);
3837
4729
  this.flagDefinitionsLoadedAt = Date.now();
@@ -3852,6 +4744,9 @@ class FeatureFlagsPoller {
3852
4744
  } catch (err) {
3853
4745
  if (err instanceof ClientError)
3854
4746
  this.onError?.(err);
4747
+ } finally {
4748
+ if (!this.pollerStopped)
4749
+ this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
3855
4750
  }
3856
4751
  }
3857
4752
  getPersonalApiKeyRequestOptions(method = "GET", etag) {
@@ -3867,7 +4762,7 @@ class FeatureFlagsPoller {
3867
4762
  headers
3868
4763
  };
3869
4764
  }
3870
- _requestFeatureFlagDefinitions() {
4765
+ async _requestFeatureFlagDefinitions() {
3871
4766
  const url = `${this.host}/flags/definitions?token=${this.projectApiKey}&send_cohorts`;
3872
4767
  const options = this.getPersonalApiKeyRequestOptions("GET", this.flagsEtag);
3873
4768
  let abortTimeout = null;
@@ -3878,23 +4773,49 @@ class FeatureFlagsPoller {
3878
4773
  }, this.timeout);
3879
4774
  options.signal = controller.signal;
3880
4775
  }
4776
+ const clearAbortTimeout = () => clearTimeout(abortTimeout);
3881
4777
  try {
3882
4778
  const fetch1 = this.fetch;
3883
- return fetch1(url, options);
3884
- } finally {
3885
- clearTimeout(abortTimeout);
4779
+ const res = await fetch1(url, options);
4780
+ if (res.status !== 200) {
4781
+ clearAbortTimeout();
4782
+ return res;
4783
+ }
4784
+ return {
4785
+ status: res.status,
4786
+ headers: res.headers,
4787
+ body: res.body,
4788
+ text: async () => {
4789
+ try {
4790
+ return await res.text();
4791
+ } finally {
4792
+ clearAbortTimeout();
4793
+ }
4794
+ },
4795
+ json: async () => {
4796
+ try {
4797
+ return await res.json();
4798
+ } finally {
4799
+ clearAbortTimeout();
4800
+ }
4801
+ }
4802
+ };
4803
+ } catch (err) {
4804
+ clearAbortTimeout();
4805
+ throw err;
3886
4806
  }
3887
4807
  }
3888
4808
  async stopPoller(timeoutMs = 30000) {
4809
+ this.pollerStopped = true;
3889
4810
  clearTimeout(this.poller);
4811
+ this.poller = undefined;
3890
4812
  if (this.cacheProvider)
3891
4813
  try {
3892
4814
  const shutdownResult = this.cacheProvider.shutdown();
3893
4815
  if (shutdownResult instanceof Promise)
3894
- await Promise.race([
3895
- shutdownResult,
3896
- new Promise((_, reject) => setTimeout(() => reject(new Error(`Cache shutdown timeout after ${timeoutMs}ms`)), timeoutMs))
3897
- ]);
4816
+ await raceWithTimeout(shutdownResult, timeoutMs, () => {
4817
+ throw new Error(`Cache shutdown timeout after ${timeoutMs}ms`);
4818
+ });
3898
4819
  } catch (err) {
3899
4820
  this.onError?.(new Error(`Error during cache shutdown: ${err}`));
3900
4821
  }
@@ -3922,21 +4843,21 @@ function matchProperty(property, propertyValues, warnFunction) {
3922
4843
  warnFunction(`Property ${key} cannot have a value of null/undefined with the ${operator} operator`);
3923
4844
  return false;
3924
4845
  }
3925
- function computeExactMatch(value2, overrideValue2) {
3926
- if (Array.isArray(value2))
3927
- return value2.map((val) => String(val).toLowerCase()).includes(String(overrideValue2).toLowerCase());
3928
- return String(value2).toLowerCase() === String(overrideValue2).toLowerCase();
4846
+ function computeExactMatch(value, overrideValue) {
4847
+ if (Array.isArray(value))
4848
+ return value.map((val) => String(val).toLowerCase()).includes(String(overrideValue).toLowerCase());
4849
+ return String(value).toLowerCase() === String(overrideValue).toLowerCase();
3929
4850
  }
3930
- function compare(lhs, rhs, operator2) {
3931
- if (operator2 === "gt")
4851
+ function compare(lhs, rhs, operator) {
4852
+ if (operator === "gt")
3932
4853
  return lhs > rhs;
3933
- if (operator2 === "gte")
4854
+ if (operator === "gte")
3934
4855
  return lhs >= rhs;
3935
- if (operator2 === "lt")
4856
+ if (operator === "lt")
3936
4857
  return lhs < rhs;
3937
- if (operator2 === "lte")
4858
+ if (operator === "lte")
3938
4859
  return lhs <= rhs;
3939
- throw new Error(`Invalid operator: ${operator2}`);
4860
+ throw new Error(`Invalid operator: ${operator}`);
3940
4861
  }
3941
4862
  switch (operator) {
3942
4863
  case "exact":
@@ -3949,6 +4870,14 @@ function matchProperty(property, propertyValues, warnFunction) {
3949
4870
  return String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
3950
4871
  case "not_icontains":
3951
4872
  return !String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
4873
+ case "starts_with":
4874
+ return String(overrideValue).toLowerCase().startsWith(String(value).toLowerCase());
4875
+ case "not_starts_with":
4876
+ return !String(overrideValue).toLowerCase().startsWith(String(value).toLowerCase());
4877
+ case "ends_with":
4878
+ return String(overrideValue).toLowerCase().endsWith(String(value).toLowerCase());
4879
+ case "not_ends_with":
4880
+ return !String(overrideValue).toLowerCase().endsWith(String(value).toLowerCase());
3952
4881
  case "regex":
3953
4882
  return isValidRegex(String(value)) && String(overrideValue).match(String(value)) !== null;
3954
4883
  case "not_regex":
@@ -4275,19 +5204,75 @@ function relativeDateParseForFeatureFlagMatching(value) {
4275
5204
  }
4276
5205
  }
4277
5206
 
4278
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
5207
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
5208
+ var UNHANDLED_REJECTION_OPTION_NAMES = [
5209
+ "--unhandled-rejections",
5210
+ "--unhandled_rejections"
5211
+ ];
5212
+ var UNHANDLED_REJECTION_MODES = new Set([
5213
+ "throw",
5214
+ "strict",
5215
+ "warn",
5216
+ "warn-with-error-code",
5217
+ "none"
5218
+ ]);
5219
+ var STARTUP_EXEC_ARGV = [
5220
+ ...globalThis.process?.execArgv ?? []
5221
+ ];
5222
+ var STARTUP_NODE_OPTIONS = globalThis.process?.env?.NODE_OPTIONS;
5223
+ function splitNodeOptions(nodeOptions) {
5224
+ const args = [];
5225
+ let current = "";
5226
+ let isInString = false;
5227
+ for (let index = 0;index < nodeOptions.length; index++) {
5228
+ const character = nodeOptions[index];
5229
+ if (character === "\\" && isInString && index + 1 < nodeOptions.length)
5230
+ current += nodeOptions[++index];
5231
+ else if (character !== " " || isInString)
5232
+ if (character === '"')
5233
+ isInString = !isInString;
5234
+ else
5235
+ current += character;
5236
+ else if (current) {
5237
+ args.push(current);
5238
+ current = "";
5239
+ }
5240
+ }
5241
+ if (current)
5242
+ args.push(current);
5243
+ return args;
5244
+ }
5245
+ function findUnhandledRejectionMode(args) {
5246
+ let mode;
5247
+ for (let index = 0;index < args.length; index++) {
5248
+ const argument = args[index];
5249
+ const optionName = UNHANDLED_REJECTION_OPTION_NAMES.find((name) => argument === name || argument.startsWith(`${name}=`));
5250
+ if (!optionName)
5251
+ continue;
5252
+ const value = argument === optionName ? args[++index] : argument.slice(optionName.length + 1);
5253
+ if (UNHANDLED_REJECTION_MODES.has(value))
5254
+ mode = value;
5255
+ }
5256
+ return mode;
5257
+ }
5258
+ function getUnhandledRejectionMode(execArgv = STARTUP_EXEC_ARGV, nodeOptions = STARTUP_NODE_OPTIONS) {
5259
+ return findUnhandledRejectionMode(execArgv) ?? findUnhandledRejectionMode(splitNodeOptions(nodeOptions ?? "")) ?? "throw";
5260
+ }
5261
+ var STARTUP_UNHANDLED_REJECTION_MODE = getUnhandledRejectionMode();
5262
+ function captureUncaughtException(captureFn, error, origin) {
5263
+ captureFn(error, {
5264
+ mechanism: {
5265
+ type: origin === "unhandledRejection" ? "onunhandledrejection" : "onuncaughtexception",
5266
+ handled: false
5267
+ }
5268
+ });
5269
+ }
4279
5270
  function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
4280
5271
  let calledFatalError = false;
4281
- return Object.assign((error) => {
5272
+ return Object.assign((error, origin) => {
4282
5273
  const userProvidedListenersCount = global.process.listeners("uncaughtException").filter((listener) => listener.name !== "domainUncaughtExceptionClear" && listener._posthogErrorHandler !== true).length;
4283
- const processWouldExit = userProvidedListenersCount === 0;
4284
- captureFn(error, {
4285
- mechanism: {
4286
- type: "onuncaughtexception",
4287
- handled: false
4288
- }
4289
- });
4290
- if (!calledFatalError && processWouldExit) {
5274
+ captureUncaughtException(captureFn, error, origin);
5275
+ if (!calledFatalError && userProvidedListenersCount === 0) {
4291
5276
  calledFatalError = true;
4292
5277
  onFatalFn(error);
4293
5278
  }
@@ -4295,29 +5280,38 @@ function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
4295
5280
  _posthogErrorHandler: true
4296
5281
  });
4297
5282
  }
4298
- function addUncaughtExceptionListener(captureFn, onFatalFn) {
4299
- globalThis.process?.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
5283
+ function addUncaughtExceptionListener(captureFn, onFatalFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
5284
+ const process2 = globalThis.process;
5285
+ if (!process2)
5286
+ return;
5287
+ if (mode === "strict")
5288
+ return void process2.on("uncaughtExceptionMonitor", (error, origin) => captureUncaughtException(captureFn, error, origin));
5289
+ process2.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
4300
5290
  }
4301
- function addUnhandledRejectionListener(captureFn) {
4302
- globalThis.process?.on("unhandledRejection", (reason) => captureFn(reason, {
4303
- mechanism: {
4304
- type: "onunhandledrejection",
4305
- handled: false
4306
- }
4307
- }));
5291
+ function addUnhandledRejectionListener(captureFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
5292
+ const process2 = globalThis.process;
5293
+ if (!process2 || mode === "throw" || mode === "strict" || mode === "warn-with-error-code")
5294
+ return;
5295
+ process2.on("unhandledRejection", (reason) => {
5296
+ captureFn(reason, {
5297
+ mechanism: {
5298
+ type: "onunhandledrejection",
5299
+ handled: false
5300
+ }
5301
+ });
5302
+ });
4308
5303
  }
4309
5304
 
4310
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
5305
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
4311
5306
  var SHUTDOWN_TIMEOUT = 2000;
4312
5307
 
4313
- class ErrorTracking {
5308
+ class error_tracking_ErrorTracking {
4314
5309
  constructor(client, options, _logger) {
4315
5310
  this.client = client;
4316
5311
  this._exceptionAutocaptureEnabled = options.enableExceptionAutocapture || false;
4317
5312
  this._logger = _logger;
4318
5313
  this._rateLimiter = new BucketedRateLimiter({
4319
- refillRate: 1,
4320
- bucketSize: 10,
5314
+ ...resolveExceptionRateLimiterConfig(options),
4321
5315
  refillInterval: 1e4,
4322
5316
  _logger: this._logger
4323
5317
  });
@@ -4332,6 +5326,9 @@ class ErrorTracking {
4332
5326
  };
4333
5327
  const exceptionProperties = builder.buildFromUnknown(error, hint);
4334
5328
  exceptionProperties.$exception_list = await builder.modifyFrames(exceptionProperties.$exception_list);
5329
+ const injectedReleaseId = getInjectedReleaseId();
5330
+ if (injectedReleaseId)
5331
+ properties.$release_id = injectedReleaseId;
4335
5332
  return {
4336
5333
  event: "$exception",
4337
5334
  distinctId,
@@ -4350,8 +5347,8 @@ class ErrorTracking {
4350
5347
  }
4351
5348
  onException(exception, hint) {
4352
5349
  this.client.addPendingPromise((async () => {
4353
- if (!ErrorTracking.isPreviouslyCapturedError(exception)) {
4354
- const eventMessage = await ErrorTracking.buildEventMessage(this.client.getErrorPropertiesBuilder(), exception, hint);
5350
+ if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(exception)) {
5351
+ const eventMessage = await error_tracking_ErrorTracking.buildEventMessage(this.client.getErrorPropertiesBuilder(), exception, hint);
4355
5352
  const exceptionProperties = eventMessage.properties;
4356
5353
  const exceptionType = exceptionProperties?.$exception_list[0]?.type ?? "Exception";
4357
5354
  const isRateLimited = this._rateLimiter.consumeRateLimit(exceptionType);
@@ -4359,14 +5356,14 @@ class ErrorTracking {
4359
5356
  return void this._logger.info("Skipping exception capture because of client rate limiting.", {
4360
5357
  exception: exceptionType
4361
5358
  });
4362
- return this.client.capture(eventMessage);
5359
+ return this.client._capturePreparedEvent(eventMessage, false);
4363
5360
  }
4364
5361
  })());
4365
5362
  }
4366
5363
  async onFatalError(exception) {
4367
5364
  console.error(exception);
4368
5365
  await this.client.shutdown(SHUTDOWN_TIMEOUT);
4369
- process.exit(1);
5366
+ globalThis.process.exit(1);
4370
5367
  }
4371
5368
  isEnabled() {
4372
5369
  return !this.client.isDisabled && this._exceptionAutocaptureEnabled;
@@ -4376,7 +5373,7 @@ class ErrorTracking {
4376
5373
  }
4377
5374
  }
4378
5375
 
4379
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/storage-memory.mjs
5376
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/storage-memory.mjs
4380
5377
  class PostHogMemoryStorage {
4381
5378
  getProperty(key) {
4382
5379
  return this._memoryStorage[key];
@@ -4389,7 +5386,452 @@ class PostHogMemoryStorage {
4389
5386
  }
4390
5387
  }
4391
5388
 
4392
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/client.mjs
5389
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/config.mjs
5390
+ function isCaptureMode(value) {
5391
+ return value === "v0" || value === "v1";
5392
+ }
5393
+ function resolveCaptureMode() {
5394
+ const envMode = typeof process != "undefined" ? process.env?.POSTHOG_CAPTURE_MODE : undefined;
5395
+ return isCaptureMode(envMode) ? envMode : "v0";
5396
+ }
5397
+
5398
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/routing.mjs
5399
+ var AI_EVENT_PREFIX = "$ai_";
5400
+ var ANALYTICS_ROUTE = "analytics";
5401
+ var AI_ROUTE = "ai";
5402
+ function isLegacyOnlyEvent(message) {
5403
+ return typeof message.event == "string" && message.event.startsWith(AI_EVENT_PREFIX);
5404
+ }
5405
+
5406
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/errors.mjs
5407
+ class CaptureV1Error extends Error {
5408
+ constructor({ requestId, drops, retryExhausted, cause }) {
5409
+ super(CaptureV1Error.buildMessage(requestId, drops, retryExhausted, cause)), this.name = "CaptureV1Error";
5410
+ this.requestId = requestId;
5411
+ this.drops = drops;
5412
+ this.retryExhausted = retryExhausted;
5413
+ this.cause = cause;
5414
+ }
5415
+ static buildMessage(requestId, drops, retryExhausted, cause) {
5416
+ let message = `Capture V1 batch ${requestId} did not fully deliver: ${drops.length} dropped, ${retryExhausted.length} undelivered`;
5417
+ if (cause instanceof Error)
5418
+ message += ` (${cause.message})`;
5419
+ return message;
5420
+ }
5421
+ }
5422
+
5423
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/transform.mjs
5424
+ function coerceBool(value) {
5425
+ if (typeof value == "boolean")
5426
+ return value;
5427
+ if (typeof value == "number")
5428
+ return value !== 0;
5429
+ if (typeof value == "string") {
5430
+ const normalized = value.trim().toLowerCase();
5431
+ if (normalized === "true" || normalized === "1")
5432
+ return true;
5433
+ if (normalized === "false" || normalized === "0")
5434
+ return false;
5435
+ }
5436
+ }
5437
+ function coerceString(value) {
5438
+ return typeof value == "string" ? value : undefined;
5439
+ }
5440
+ var OPTION_SENTINELS = [
5441
+ {
5442
+ property: "$cookieless_mode",
5443
+ optionKey: "cookieless_mode",
5444
+ coerce: coerceBool
5445
+ },
5446
+ {
5447
+ property: "$ignore_sent_at",
5448
+ optionKey: "disable_skew_correction",
5449
+ coerce: coerceBool
5450
+ },
5451
+ {
5452
+ property: "$process_person_profile",
5453
+ optionKey: "process_person_profile",
5454
+ coerce: coerceBool
5455
+ },
5456
+ {
5457
+ property: "$product_tour_id",
5458
+ optionKey: "product_tour_id",
5459
+ coerce: coerceString
5460
+ }
5461
+ ];
5462
+ var TOPLEVEL_SENTINELS = [
5463
+ {
5464
+ property: "$session_id",
5465
+ field: "session_id"
5466
+ },
5467
+ {
5468
+ property: "$window_id",
5469
+ field: "window_id"
5470
+ }
5471
+ ];
5472
+ function isRecord2(value) {
5473
+ return typeof value == "object" && value !== null && !Array.isArray(value);
5474
+ }
5475
+ function toRfc3339(timestamp) {
5476
+ if (typeof timestamp == "string") {
5477
+ const asDate = new Date(timestamp);
5478
+ if (Number.isNaN(asDate.getTime()))
5479
+ return new Date().toISOString();
5480
+ const normalized = asDate.toISOString();
5481
+ const fractionalSeconds = timestamp.match(/\.(\d+)(?:Z|[+-]\d{2}:?\d{2})?$/i)?.[1];
5482
+ return fractionalSeconds && fractionalSeconds.length > 3 ? normalized.replace(/\.\d{3}Z$/, `.${fractionalSeconds}Z`) : normalized;
5483
+ }
5484
+ if (timestamp instanceof Date)
5485
+ return Number.isNaN(timestamp.getTime()) ? new Date().toISOString() : timestamp.toISOString();
5486
+ const asDate = timestamp == null ? new Date : new Date(timestamp);
5487
+ return Number.isNaN(asDate.getTime()) ? new Date().toISOString() : asDate.toISOString();
5488
+ }
5489
+ function relocateInto(properties, key, value) {
5490
+ if (value !== undefined && !(key in properties))
5491
+ properties[key] = value;
5492
+ }
5493
+ function buildV1Event(message) {
5494
+ const sourceProperties = isRecord2(message.properties) ? message.properties : {};
5495
+ const properties = {
5496
+ ...sourceProperties
5497
+ };
5498
+ const options = {};
5499
+ for (const { property, optionKey, coerce } of OPTION_SENTINELS)
5500
+ if (property in properties) {
5501
+ const coerced = coerce(properties[property]);
5502
+ if (coerced !== undefined)
5503
+ options[optionKey] = coerced;
5504
+ delete properties[property];
5505
+ }
5506
+ const topLevel = {};
5507
+ for (const { property, field } of TOPLEVEL_SENTINELS)
5508
+ if (property in properties) {
5509
+ const value = properties[property];
5510
+ if (typeof value == "string")
5511
+ topLevel[field] = value;
5512
+ delete properties[property];
5513
+ }
5514
+ delete properties.$lib;
5515
+ delete properties.$lib_version;
5516
+ relocateInto(properties, "$set", message.$set);
5517
+ relocateInto(properties, "$set_once", message.$set_once);
5518
+ return {
5519
+ event: String(message.event ?? ""),
5520
+ uuid: String(message.uuid ?? ""),
5521
+ distinct_id: String(message.distinct_id ?? ""),
5522
+ timestamp: toRfc3339(message.timestamp),
5523
+ ...topLevel,
5524
+ options,
5525
+ properties
5526
+ };
5527
+ }
5528
+ function buildV1Batch(messages, { createdAt, historicalMigration }) {
5529
+ const batch = {
5530
+ created_at: createdAt,
5531
+ batch: messages.map(buildV1Event)
5532
+ };
5533
+ if (historicalMigration)
5534
+ batch.historical_migration = true;
5535
+ return batch;
5536
+ }
5537
+
5538
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/sender.mjs
5539
+ var V1_ANALYTICS_PATH = "/i/v1/analytics/events";
5540
+ var DEFAULT_MAX_BACKOFF_MS = 30000;
5541
+ var RETRYABLE_STATUSES = new Set([
5542
+ 408,
5543
+ 500,
5544
+ 502,
5545
+ 503,
5546
+ 504
5547
+ ]);
5548
+
5549
+ class V1CaptureSender {
5550
+ constructor(config, hooks) {
5551
+ this.config = config;
5552
+ this.maxBackoffMs = config.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS;
5553
+ this.fetchFn = hooks.fetch;
5554
+ this.onError = hooks.onError;
5555
+ this.now = hooks.now ?? Date.now;
5556
+ this.sleep = hooks.sleep ?? ((ms) => new Promise((resolve) => safeSetTimeout(resolve, ms)));
5557
+ this.generateRequestId = hooks.generateRequestId ?? uuidv7;
5558
+ this.compress = hooks.compress ?? gzipCompress;
5559
+ }
5560
+ async sendV1Batch(messages) {
5561
+ if (messages.length === 0)
5562
+ return;
5563
+ const requestId = this.generateRequestId();
5564
+ const createdAt = new Date(this.now()).toISOString();
5565
+ const { batch } = buildV1Batch(messages, {
5566
+ createdAt,
5567
+ historicalMigration: this.config.historicalMigration
5568
+ });
5569
+ const url = `${this.config.host}${V1_ANALYTICS_PATH}`;
5570
+ const drops = [];
5571
+ let pending = batch;
5572
+ const maxAttempts = Math.max(1, this.config.maxAttempts);
5573
+ for (let attempt = 1;attempt <= maxAttempts; attempt++) {
5574
+ const isLastAttempt = attempt === maxAttempts;
5575
+ const payload = safeJsonStringify({
5576
+ created_at: createdAt,
5577
+ ...this.config.historicalMigration ? {
5578
+ historical_migration: true
5579
+ } : {},
5580
+ batch: pending
5581
+ });
5582
+ let captureAttempt;
5583
+ let retryDelayMs;
5584
+ try {
5585
+ captureAttempt = await this.sendOnce(url, payload, attempt, requestId);
5586
+ const { response, signal } = captureAttempt;
5587
+ const { status } = response;
5588
+ if (status < 200 || status >= 300)
5589
+ if (!isLastAttempt && RETRYABLE_STATUSES.has(status)) {
5590
+ const retryAfterMs = this.parseRetryAfter(response);
5591
+ await captureAttempt.waitFor(captureAttempt.cancelBody()).catch(() => {});
5592
+ retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
5593
+ } else {
5594
+ const httpError = await this.buildHttpError(response, status, captureAttempt.waitFor);
5595
+ return this.surfaceBatchFailure(requestId, drops, pending, httpError);
5596
+ }
5597
+ else {
5598
+ let parsed;
5599
+ try {
5600
+ parsed = await captureAttempt.waitFor(this.parseResponse(response));
5601
+ } catch (error) {
5602
+ if (signal.aborted)
5603
+ throw error;
5604
+ return this.surfaceBatchFailure(requestId, drops, pending, new Error(`Capture V1 returned an unparseable ${status} response body`));
5605
+ }
5606
+ const retryable = this.classify(pending, parsed, drops);
5607
+ if (retryable.length === 0)
5608
+ return this.surfacePartialDrops(requestId, drops);
5609
+ if (isLastAttempt)
5610
+ return void this.onError(new CaptureV1Error({
5611
+ requestId,
5612
+ drops,
5613
+ retryExhausted: retryable.map((event) => event.uuid)
5614
+ }));
5615
+ pending = retryable;
5616
+ const retryAfterMs = this.parseRetryAfter(response);
5617
+ retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
5618
+ }
5619
+ } catch (transportError) {
5620
+ if (captureAttempt && !captureAttempt.signal.aborted)
5621
+ throw transportError;
5622
+ if (isLastAttempt)
5623
+ return this.surfaceBatchFailure(requestId, drops, pending, transportError);
5624
+ retryDelayMs = this.backoffDelay(attempt);
5625
+ } finally {
5626
+ captureAttempt?.cleanup();
5627
+ }
5628
+ if (retryDelayMs !== undefined)
5629
+ await this.sleep(retryDelayMs);
5630
+ }
5631
+ }
5632
+ async sendOnce(url, payload, attempt, requestId) {
5633
+ const headers = this.buildHeaders(attempt, requestId);
5634
+ let body = payload;
5635
+ if (this.config.compressionEnabled) {
5636
+ const compressed = await this.compress(payload, this.config.isDebug);
5637
+ if (compressed !== null) {
5638
+ body = compressed;
5639
+ headers["Content-Encoding"] = "gzip";
5640
+ }
5641
+ }
5642
+ const controller = new AbortController;
5643
+ let timeoutPhase = "waiting for response headers";
5644
+ let timer;
5645
+ const deadline = new Promise((_resolve, reject) => {
5646
+ timer = safeSetTimeout(() => {
5647
+ const timeoutError = new Error(`Capture V1 request timed out ${timeoutPhase} after ${this.config.requestTimeoutMs}ms`);
5648
+ timeoutError.name = "AbortError";
5649
+ reject(timeoutError);
5650
+ controller.abort(timeoutError);
5651
+ }, this.config.requestTimeoutMs);
5652
+ });
5653
+ try {
5654
+ const fetchPromise = this.fetchFn(url, {
5655
+ method: "POST",
5656
+ headers,
5657
+ body,
5658
+ signal: controller.signal
5659
+ });
5660
+ let responseAccepted = false;
5661
+ fetchPromise.then((lateResponse) => {
5662
+ if (controller.signal.aborted && !responseAccepted)
5663
+ this.cancelBody(lateResponse);
5664
+ }).catch(() => {});
5665
+ const response = await Promise.race([
5666
+ fetchPromise,
5667
+ deadline
5668
+ ]);
5669
+ responseAccepted = true;
5670
+ timeoutPhase = "while reading the response body";
5671
+ let cleanedUp = false;
5672
+ let cancellation;
5673
+ const cancelBody = () => cancellation ??= this.cancelBody(response);
5674
+ return {
5675
+ response,
5676
+ signal: controller.signal,
5677
+ waitFor: (operation) => Promise.race([
5678
+ operation,
5679
+ deadline
5680
+ ]),
5681
+ cancelBody,
5682
+ cleanup: () => {
5683
+ if (cleanedUp)
5684
+ return;
5685
+ cleanedUp = true;
5686
+ clearTimeout(timer);
5687
+ if (controller.signal.aborted)
5688
+ cancelBody();
5689
+ }
5690
+ };
5691
+ } catch (error) {
5692
+ clearTimeout(timer);
5693
+ throw error;
5694
+ }
5695
+ }
5696
+ buildHeaders(attempt, requestId) {
5697
+ const sdkInfo = `${this.config.libraryId}/${this.config.libraryVersion}`;
5698
+ const headers = {
5699
+ "Content-Type": "application/json",
5700
+ Authorization: `Bearer ${this.config.apiKey}`,
5701
+ "PostHog-Sdk-Info": sdkInfo,
5702
+ "PostHog-Attempt": String(attempt),
5703
+ "PostHog-Request-Id": requestId,
5704
+ "PostHog-Request-Timestamp": new Date(this.now()).toISOString()
5705
+ };
5706
+ if (this.config.userAgent)
5707
+ headers["User-Agent"] = this.config.userAgent;
5708
+ return headers;
5709
+ }
5710
+ classify(pending, parsed, drops) {
5711
+ const results = parsed.results ?? {};
5712
+ const retryable = [];
5713
+ for (const event of pending) {
5714
+ const result = results[event.uuid];
5715
+ if (result) {
5716
+ if (result.result === "drop")
5717
+ drops.push({
5718
+ uuid: event.uuid,
5719
+ details: result.details ?? undefined
5720
+ });
5721
+ else if (result.result === "retry")
5722
+ retryable.push(event);
5723
+ }
5724
+ }
5725
+ return retryable;
5726
+ }
5727
+ backoffDelay(attempt, retryAfterMs) {
5728
+ const exponential = Math.min(this.config.initialRetryDelayMs * 2 ** (attempt - 1), this.maxBackoffMs);
5729
+ if (retryAfterMs === undefined)
5730
+ return exponential;
5731
+ return Math.max(exponential, Math.min(retryAfterMs, this.maxBackoffMs));
5732
+ }
5733
+ parseRetryAfter(response) {
5734
+ const raw = response.headers?.get("Retry-After");
5735
+ if (!raw)
5736
+ return;
5737
+ const trimmed = raw.trim();
5738
+ if (/^\d+$/.test(trimmed)) {
5739
+ const seconds = parseInt(trimmed, 10);
5740
+ return Number.isFinite(seconds) && seconds > 0 ? 1000 * seconds : undefined;
5741
+ }
5742
+ const dateMs = Date.parse(trimmed);
5743
+ if (Number.isNaN(dateMs))
5744
+ return;
5745
+ const delta = dateMs - this.now();
5746
+ return delta > 0 ? delta : undefined;
5747
+ }
5748
+ async parseResponse(response) {
5749
+ const text = await response.text();
5750
+ const parsed = JSON.parse(text);
5751
+ if (typeof parsed != "object" || parsed === null || Array.isArray(parsed))
5752
+ throw new Error("unexpected response shape");
5753
+ const results = parsed.results;
5754
+ if (results !== undefined && (typeof results != "object" || results === null || Array.isArray(results)))
5755
+ throw new Error("unexpected results shape");
5756
+ return {
5757
+ results: results ?? {}
5758
+ };
5759
+ }
5760
+ async buildHttpError(response, status, waitFor) {
5761
+ let bodyText = "";
5762
+ try {
5763
+ bodyText = (await waitFor(response.text())).slice(0, 512);
5764
+ } catch {}
5765
+ const suffix = bodyText ? `: ${bodyText}` : "";
5766
+ return new Error(`Capture V1 request failed with HTTP ${status}${suffix}`);
5767
+ }
5768
+ surfaceBatchFailure(requestId, drops, pending, cause) {
5769
+ this.onError(new CaptureV1Error({
5770
+ requestId,
5771
+ drops,
5772
+ retryExhausted: pending.map((event) => event.uuid),
5773
+ cause
5774
+ }));
5775
+ }
5776
+ surfacePartialDrops(requestId, drops) {
5777
+ if (drops.length > 0)
5778
+ this.onError(new CaptureV1Error({
5779
+ requestId,
5780
+ drops,
5781
+ retryExhausted: []
5782
+ }));
5783
+ }
5784
+ async cancelBody(response) {
5785
+ try {
5786
+ await response.body?.cancel();
5787
+ } catch {}
5788
+ }
5789
+ }
5790
+
5791
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/ai-capture/routing.mjs
5792
+ var AI_CAPTURE_ROUTE = "ai-capture";
5793
+ var AI_CAPTURE_ENDPOINT_PATH = "/i/v0/ai/batch/";
5794
+ var AI_MAX_EVENT_BYTES = 8388608;
5795
+ var AI_BATCH_TARGET_BYTES = 5242880;
5796
+
5797
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/ai-capture/batching.mjs
5798
+ var encoder = new TextEncoder;
5799
+ function eventByteSize(message) {
5800
+ return encoder.encode(safeJsonStringify(message)).length;
5801
+ }
5802
+ function partitionAiBatch(messages, maxEventBytes = AI_MAX_EVENT_BYTES, targetBatchBytes = AI_BATCH_TARGET_BYTES) {
5803
+ const batches = [];
5804
+ const dropped = [];
5805
+ let current = [];
5806
+ let currentBytes = 0;
5807
+ for (const message of messages) {
5808
+ if (message === undefined)
5809
+ continue;
5810
+ const bytes = eventByteSize(message);
5811
+ if (bytes > maxEventBytes) {
5812
+ dropped.push({
5813
+ event: typeof message.event == "string" ? message.event : "unknown",
5814
+ bytes
5815
+ });
5816
+ continue;
5817
+ }
5818
+ if (current.length > 0 && currentBytes + bytes > targetBatchBytes) {
5819
+ batches.push(current);
5820
+ current = [];
5821
+ currentBytes = 0;
5822
+ }
5823
+ current.push(message);
5824
+ currentBytes += bytes;
5825
+ }
5826
+ if (current.length > 0)
5827
+ batches.push(current);
5828
+ return {
5829
+ batches,
5830
+ dropped
5831
+ };
5832
+ }
5833
+
5834
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/client.mjs
4393
5835
  var MINIMUM_POLLING_INTERVAL = 100;
4394
5836
  var THIRTY_SECONDS = 30000;
4395
5837
  var MAX_CACHE_SIZE = 50000;
@@ -4414,6 +5856,12 @@ function normalizeHost(value) {
4414
5856
  const normalizedValue = typeof value == "string" ? value.trim() : "";
4415
5857
  return normalizedValue || DEFAULT_NODE_HOST;
4416
5858
  }
5859
+ function normalizeUnsetPersonProperties(value) {
5860
+ const propertyNames = Array.isArray(value) ? value : [
5861
+ value
5862
+ ];
5863
+ return propertyNames.filter((propertyName) => typeof propertyName == "string" && propertyName.trim().length > 0);
5864
+ }
4417
5865
  function buildFlagEventProperties(flagValues) {
4418
5866
  if (!flagValues)
4419
5867
  return {};
@@ -4431,11 +5879,15 @@ class PostHogBackendClient extends PostHogCoreStateless {
4431
5879
  const normalizedApiKey = normalizeApiKey(apiKey);
4432
5880
  const normalizedOptions = {
4433
5881
  ...options,
5882
+ maxQueueSize: options.maxQueueSize ?? 1e4,
5883
+ flushInterval: options.flushInterval ?? 5000,
4434
5884
  host: normalizeHost(options.host),
4435
- personalApiKey: normalizePersonalApiKey(options.personalApiKey)
5885
+ personalApiKey: normalizePersonalApiKey(options.secretKey ?? options.personalApiKey)
4436
5886
  };
4437
- super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage;
5887
+ super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage, this._aiCaptureRouteActive = false, this._minimalFlagCalledEvents = false;
4438
5888
  this.options = normalizedOptions;
5889
+ this.captureMode = resolveCaptureMode();
5890
+ this.enableFullAiCapture = normalizedOptions.enableFullAiCapture === true;
4439
5891
  this.context = this.initializeContext();
4440
5892
  this.options.featureFlagsPollingInterval = typeof normalizedOptions.featureFlagsPollingInterval == "number" ? Math.max(normalizedOptions.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL) : THIRTY_SECONDS;
4441
5893
  if (typeof normalizedOptions.waitUntilDebounceMs == "number")
@@ -4460,21 +5912,24 @@ class PostHogBackendClient extends PostHogCoreStateless {
4460
5912
  onLoad: (count) => {
4461
5913
  this._events.emit("localEvaluationFlagsLoaded", count);
4462
5914
  },
5915
+ onMinimalFlagCalledEvents: (enabled) => {
5916
+ this._minimalFlagCalledEvents = enabled;
5917
+ },
4463
5918
  customHeaders: this.getCustomHeaders(),
4464
5919
  cacheProvider: normalizedOptions.flagDefinitionCacheProvider,
4465
5920
  strictLocalEvaluation: normalizedOptions.strictLocalEvaluation
4466
5921
  });
4467
5922
  }
4468
- this.errorTracking = new ErrorTracking(this, normalizedOptions, this._logger);
5923
+ this.errorTracking = new error_tracking_ErrorTracking(this, normalizedOptions, this._logger);
4469
5924
  this.distinctIdHasSentFlagCalls = {};
4470
5925
  this.maxCacheSize = normalizedOptions.maxCacheSize || MAX_CACHE_SIZE;
4471
5926
  }
4472
- enqueue(type, message, options) {
4473
- super.enqueue(type, message, options);
5927
+ enqueue(type, message, options, explicitRoute) {
5928
+ super.enqueue(type, message, options, explicitRoute);
4474
5929
  this.scheduleDebouncedFlush();
4475
5930
  }
4476
5931
  async flush() {
4477
- const flushPromise = super.flush();
5932
+ const flushPromise = this.flushWithPendingPromises();
4478
5933
  const waitUntil = this.options.waitUntil;
4479
5934
  if (waitUntil && !this._waitUntilCycle)
4480
5935
  try {
@@ -4527,7 +5982,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4527
5982
  async resolveWaitUntilFlush() {
4528
5983
  const resolve = this._consumeWaitUntilCycle();
4529
5984
  try {
4530
- await super.flush();
5985
+ await this.flushWithPendingPromises();
4531
5986
  } catch {} finally {
4532
5987
  resolve?.();
4533
5988
  }
@@ -4541,12 +5996,103 @@ class PostHogBackendClient extends PostHogCoreStateless {
4541
5996
  fetch(url, options) {
4542
5997
  return this.options.fetch ? this.options.fetch(url, options) : fetch(url, options);
4543
5998
  }
5999
+ getQueueRouteKey(message) {
6000
+ return this.captureMode === "v1" && isLegacyOnlyEvent(message) ? AI_ROUTE : ANALYTICS_ROUTE;
6001
+ }
6002
+ persistedQueueKeyForRoute(route) {
6003
+ if (route === AI_CAPTURE_ROUTE)
6004
+ return types_PostHogPersistedProperty.AiCaptureQueue;
6005
+ return route === AI_ROUTE ? types_PostHogPersistedProperty.AiQueue : types_PostHogPersistedProperty.Queue;
6006
+ }
6007
+ getActiveQueueRoutes() {
6008
+ const routes = this.captureMode === "v1" ? [
6009
+ ANALYTICS_ROUTE,
6010
+ AI_ROUTE
6011
+ ] : [
6012
+ ANALYTICS_ROUTE
6013
+ ];
6014
+ if (this._aiCaptureRouteActive)
6015
+ routes.push(AI_CAPTURE_ROUTE);
6016
+ return routes;
6017
+ }
6018
+ getBatchEndpointPath(route) {
6019
+ return route === AI_CAPTURE_ROUTE ? AI_CAPTURE_ENDPOINT_PATH : super.getBatchEndpointPath(route);
6020
+ }
6021
+ async sendBatch(batchMessages, retryOptions, route = ANALYTICS_ROUTE) {
6022
+ if (route === AI_CAPTURE_ROUTE)
6023
+ return this.sendAiCaptureBatch(batchMessages, retryOptions);
6024
+ if (this.captureMode !== "v1" || route === AI_ROUTE)
6025
+ return super.sendBatch(batchMessages, retryOptions, route);
6026
+ const v1Events = batchMessages.filter((message) => message !== undefined);
6027
+ await this.getV1Sender().sendV1Batch(v1Events);
6028
+ }
6029
+ async sendAiCaptureBatch(batchMessages, retryOptions) {
6030
+ const { batches, dropped } = partitionAiBatch(batchMessages);
6031
+ for (const { event, bytes } of dropped) {
6032
+ const message = `Event ${event} (${bytes} bytes) exceeds the ${AI_MAX_EVENT_BYTES / 1048576}MiB limit for ${AI_CAPTURE_ENDPOINT_PATH}, dropping.`;
6033
+ this._logger.error(message);
6034
+ this._events.emit("error", new Error(message));
6035
+ }
6036
+ for (const batch of batches)
6037
+ await this.sendAiSubBatch(batch, retryOptions);
6038
+ }
6039
+ async sendAiSubBatch(batch, retryOptions) {
6040
+ try {
6041
+ await super.sendBatch(batch, retryOptions, AI_CAPTURE_ROUTE);
6042
+ } catch (err) {
6043
+ if (!isPostHogFetchContentTooLargeError(err))
6044
+ throw err;
6045
+ if (batch.length === 1) {
6046
+ const [event] = batch;
6047
+ const eventName = typeof event.event == "string" ? event.event : "unknown";
6048
+ const message = `Event ${eventName} (${eventByteSize(event)} bytes) was rejected with 413 by ${AI_CAPTURE_ENDPOINT_PATH} on its own, dropping.`;
6049
+ this._logger.error(message);
6050
+ this._events.emit("error", new Error(message));
6051
+ return;
6052
+ }
6053
+ const mid = Math.ceil(batch.length / 2);
6054
+ await this.sendAiSubBatch(batch.slice(0, mid), retryOptions);
6055
+ await this.sendAiSubBatch(batch.slice(mid), retryOptions);
6056
+ }
6057
+ }
6058
+ getV1Sender() {
6059
+ if (!this._v1Sender)
6060
+ this._v1Sender = new V1CaptureSender({
6061
+ host: this.host,
6062
+ apiKey: this.apiKey,
6063
+ libraryId: this.getLibraryId(),
6064
+ libraryVersion: this.getLibraryVersion(),
6065
+ userAgent: this.getCustomUserAgent() || undefined,
6066
+ historicalMigration: this.historicalMigration,
6067
+ compressionEnabled: !this.disableCompression,
6068
+ requestTimeoutMs: this.requestTimeout,
6069
+ maxAttempts: (this.options.fetchRetryCount ?? 3) + 1,
6070
+ initialRetryDelayMs: this.options.fetchRetryDelay ?? 3000,
6071
+ isDebug: this.isDebug
6072
+ }, {
6073
+ fetch: (url, fetchOptions) => this.fetch(url, fetchOptions),
6074
+ onError: (error) => this._events.emit("error", error),
6075
+ compress: (payload) => this.compressPayload(payload)
6076
+ });
6077
+ return this._v1Sender;
6078
+ }
4544
6079
  getLibraryVersion() {
4545
6080
  return version;
4546
6081
  }
6082
+ get metrics() {
6083
+ if (!this._metrics)
6084
+ this._metrics = new PostHogMetrics(this, resolveMetricsConfig(this.options.metrics), this._logger);
6085
+ return this._metrics;
6086
+ }
4547
6087
  getCustomUserAgent() {
4548
6088
  return `${this.getLibraryId()}/${this.getLibraryVersion()}`;
4549
6089
  }
6090
+ getCommonEventProperties() {
6091
+ const commonProperties = super.getCommonEventProperties();
6092
+ if (this.options.isServer ?? true)
6093
+ commonProperties.$is_server = true;
6094
+ return commonProperties;
6095
+ }
4550
6096
  enable() {
4551
6097
  return super.optIn();
4552
6098
  }
@@ -4557,33 +6103,69 @@ class PostHogBackendClient extends PostHogCoreStateless {
4557
6103
  super.debug(enabled);
4558
6104
  this.featureFlagsPoller?.debug(enabled);
4559
6105
  }
4560
- capture(props) {
6106
+ _warnIfInvalidCapture(props, stringArgumentWarning, exceptionCaptureWarning) {
4561
6107
  if (typeof props == "string")
4562
- this._logger.warn("Called capture() with a string as the first argument when an object was expected.");
6108
+ this._logger.warn(stringArgumentWarning);
4563
6109
  if (props.event === "$exception" && !props._originatedFromCaptureException)
4564
- 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.");
4565
- this.addPendingPromise(this.prepareEventMessage(props).then(({ distinctId, event, properties, options }) => super.captureStateless(distinctId, event, properties, {
4566
- timestamp: options.timestamp,
4567
- disableGeoip: options.disableGeoip,
4568
- uuid: options.uuid
4569
- })).catch((err) => {
6110
+ this._logger.warn(exceptionCaptureWarning);
6111
+ }
6112
+ _sendPreparedEvent(type, props, immediate, prepareOptions, explicitRoute) {
6113
+ return this.addPendingPromise(this._prepareEventMessage(props, prepareOptions).then(({ distinctId, event, properties, options }) => {
6114
+ const captureOptions = {
6115
+ timestamp: options.timestamp,
6116
+ disableGeoip: options.disableGeoip,
6117
+ uuid: options.uuid
6118
+ };
6119
+ const message = {
6120
+ distinctId,
6121
+ event,
6122
+ properties: {
6123
+ ...properties,
6124
+ ...this.getCommonEventProperties()
6125
+ }
6126
+ };
6127
+ return immediate ? this.sendImmediate(type, message, captureOptions, explicitRoute) : this.enqueue(type, message, captureOptions, explicitRoute);
6128
+ }).catch((err) => {
4570
6129
  if (err)
4571
6130
  console.error(err);
4572
6131
  }));
4573
6132
  }
6133
+ _capturePreparedEvent(props, immediate) {
6134
+ return this._sendPreparedEvent("capture", props, immediate);
6135
+ }
6136
+ capture(props) {
6137
+ 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.");
6138
+ this._capturePreparedEvent(props, false);
6139
+ }
4574
6140
  async captureImmediate(props) {
4575
- if (typeof props == "string")
4576
- this._logger.warn("Called captureImmediate() with a string as the first argument when an object was expected.");
4577
- if (props.event === "$exception" && !props._originatedFromCaptureException)
4578
- 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.");
4579
- return this.addPendingPromise(this.prepareEventMessage(props).then(({ distinctId, event, properties, options }) => super.captureStatelessImmediate(distinctId, event, properties, {
4580
- timestamp: options.timestamp,
4581
- disableGeoip: options.disableGeoip,
4582
- uuid: options.uuid
4583
- })).catch((err) => {
4584
- if (err)
4585
- console.error(err);
4586
- }));
6141
+ 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.");
6142
+ return this._capturePreparedEvent(props, true);
6143
+ }
6144
+ captureAi(props) {
6145
+ if (this.disabled)
6146
+ return;
6147
+ const uuid = getEventUuid(props.uuid, uuidv7);
6148
+ this._sendPreparedAiEvent({
6149
+ ...props,
6150
+ uuid
6151
+ }, false);
6152
+ return uuid;
6153
+ }
6154
+ async captureAiImmediate(props) {
6155
+ if (this.disabled)
6156
+ return;
6157
+ const uuid = getEventUuid(props.uuid, uuidv7);
6158
+ await this._sendPreparedAiEvent({
6159
+ ...props,
6160
+ uuid
6161
+ }, true);
6162
+ return uuid;
6163
+ }
6164
+ _sendPreparedAiEvent(props, immediate) {
6165
+ if (typeof props?.event == "string" && !props.event.startsWith("$ai_"))
6166
+ this._logger.debug(`captureAi called with non-AI event ${props.event}; routing it to the AI endpoint anyway.`);
6167
+ this._aiCaptureRouteActive = true;
6168
+ return this._sendPreparedEvent("capture", props, immediate, undefined, AI_CAPTURE_ROUTE);
4587
6169
  }
4588
6170
  identify({ distinctId, properties = {}, disableGeoip }) {
4589
6171
  const { $set, $set_once, $anon_distinct_id, ...rest } = properties;
@@ -4594,8 +6176,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
4594
6176
  $set_once: setOnceProps,
4595
6177
  $anon_distinct_id: $anon_distinct_id ?? undefined
4596
6178
  };
4597
- super.identifyStateless(distinctId, eventProperties, {
6179
+ this._sendPreparedEvent("identify", {
6180
+ distinctId,
6181
+ event: "$identify",
6182
+ properties: eventProperties,
4598
6183
  disableGeoip
6184
+ }, false, {
6185
+ includeContextProperties: false
4599
6186
  });
4600
6187
  }
4601
6188
  async identifyImmediate({ distinctId, properties = {}, disableGeoip }) {
@@ -4607,18 +6194,65 @@ class PostHogBackendClient extends PostHogCoreStateless {
4607
6194
  $set_once: setOnceProps,
4608
6195
  $anon_distinct_id: $anon_distinct_id ?? undefined
4609
6196
  };
4610
- await super.identifyStatelessImmediate(distinctId, eventProperties, {
6197
+ await this._sendPreparedEvent("identify", {
6198
+ distinctId,
6199
+ event: "$identify",
6200
+ properties: eventProperties,
4611
6201
  disableGeoip
6202
+ }, true, {
6203
+ includeContextProperties: false
6204
+ });
6205
+ }
6206
+ setPersonProperties({ distinctId, properties = {}, propertiesOnce = {} }) {
6207
+ if (Object.keys(properties).length === 0 && Object.keys(propertiesOnce).length === 0)
6208
+ return;
6209
+ const eventProperties = {};
6210
+ if (Object.keys(properties).length > 0)
6211
+ eventProperties.$set = properties;
6212
+ if (Object.keys(propertiesOnce).length > 0)
6213
+ eventProperties.$set_once = propertiesOnce;
6214
+ this.capture({
6215
+ distinctId,
6216
+ event: "$set",
6217
+ properties: eventProperties
6218
+ });
6219
+ }
6220
+ unsetPersonProperties({ distinctId, properties }) {
6221
+ const propertyNames = normalizeUnsetPersonProperties(properties);
6222
+ if (propertyNames.length === 0)
6223
+ return;
6224
+ this.capture({
6225
+ distinctId,
6226
+ event: "$set",
6227
+ properties: {
6228
+ $unset: propertyNames
6229
+ }
4612
6230
  });
4613
6231
  }
4614
6232
  alias(data) {
4615
- super.aliasStateless(data.alias, data.distinctId, undefined, {
6233
+ this._sendPreparedEvent("alias", {
6234
+ distinctId: data.distinctId,
6235
+ event: "$create_alias",
6236
+ properties: {
6237
+ distinct_id: data.distinctId,
6238
+ alias: data.alias
6239
+ },
4616
6240
  disableGeoip: data.disableGeoip
6241
+ }, false, {
6242
+ includeContextProperties: false
4617
6243
  });
4618
6244
  }
4619
6245
  async aliasImmediate(data) {
4620
- await super.aliasStatelessImmediate(data.alias, data.distinctId, undefined, {
6246
+ await this._sendPreparedEvent("alias", {
6247
+ distinctId: data.distinctId,
6248
+ event: "$create_alias",
6249
+ properties: {
6250
+ distinct_id: data.distinctId,
6251
+ alias: data.alias
6252
+ },
4621
6253
  disableGeoip: data.disableGeoip
6254
+ }, true, {
6255
+ includeContextProperties: false
4622
6256
  });
4623
6257
  }
4624
6258
  isLocalEvaluationReady() {
@@ -4673,7 +6307,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4673
6307
  const adjustedProperties = this.addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties);
4674
6308
  personProperties = adjustedProperties.allPersonProperties;
4675
6309
  groupProperties = adjustedProperties.allGroupProperties;
4676
- const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties);
6310
+ const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, this.personPropertiesForLocalEvaluation(distinctId, personProperties), groupProperties);
4677
6311
  if (onlyEvaluateLocally == undefined)
4678
6312
  onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
4679
6313
  let result;
@@ -4684,6 +6318,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4684
6318
  let flagId;
4685
6319
  let flagVersion;
4686
6320
  let flagReason;
6321
+ let flagHasExperiment;
4687
6322
  const localEvaluationEnabled = this.featureFlagsPoller !== undefined;
4688
6323
  if (localEvaluationEnabled) {
4689
6324
  await this.featureFlagsPoller?.loadFeatureFlags();
@@ -4698,6 +6333,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4698
6333
  const value = localResult.value;
4699
6334
  flagId = flag.id;
4700
6335
  flagReason = "Evaluated locally";
6336
+ flagHasExperiment = flag.has_experiment;
4701
6337
  result = {
4702
6338
  key,
4703
6339
  enabled: value !== false,
@@ -4713,12 +6349,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
4713
6349
  }
4714
6350
  }
4715
6351
  if (!flagWasLocallyEvaluated && !onlyEvaluateLocally) {
4716
- const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, [
6352
+ const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, [
4717
6353
  key
4718
6354
  ]);
4719
6355
  if (flagsResponse === undefined)
4720
6356
  featureFlagError = FeatureFlagError2.UNKNOWN_ERROR;
4721
6357
  else {
6358
+ this._minimalFlagCalledEvents = flagsResponse.minimalFlagCalledEvents === true;
4722
6359
  requestId = flagsResponse.requestId;
4723
6360
  evaluatedAt = flagsResponse.evaluatedAt;
4724
6361
  const errors = [];
@@ -4733,6 +6370,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4733
6370
  flagId = flagDetail.metadata?.id;
4734
6371
  flagVersion = flagDetail.metadata?.version;
4735
6372
  flagReason = flagDetail.reason?.description ?? flagDetail.reason?.code;
6373
+ flagHasExperiment = flagDetail.metadata?.has_experiment;
4736
6374
  let parsedPayload;
4737
6375
  if (flagDetail.metadata?.payload !== undefined)
4738
6376
  try {
@@ -4743,7 +6381,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4743
6381
  result = {
4744
6382
  key,
4745
6383
  enabled: flagDetail.enabled,
4746
- variant: flagDetail.variant,
6384
+ variant: flagDetail.variant ?? undefined,
4747
6385
  payload: parsedPayload
4748
6386
  };
4749
6387
  }
@@ -4764,6 +6402,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
4764
6402
  $feature_flag_request_id: requestId,
4765
6403
  $feature_flag_evaluated_at: flagWasLocallyEvaluated ? Date.now() : evaluatedAt
4766
6404
  };
6405
+ if (flagHasExperiment !== undefined)
6406
+ properties.$feature_flag_has_experiment = flagHasExperiment;
4767
6407
  if (flagWasLocallyEvaluated && this.featureFlagsPoller) {
4768
6408
  const flagDefinitionsLoadedAt = this.featureFlagsPoller.getFlagDefinitionsLoadedAt();
4769
6409
  if (flagDefinitionsLoadedAt !== undefined)
@@ -4878,7 +6518,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4878
6518
  const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
4879
6519
  personProperties = adjustedProperties.allPersonProperties;
4880
6520
  groupProperties = adjustedProperties.allGroupProperties;
4881
- const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
6521
+ const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
4882
6522
  if (onlyEvaluateLocally == undefined)
4883
6523
  onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
4884
6524
  const localEvaluationResult = await this.featureFlagsPoller?.getAllFlagsAndPayloads(evaluationContext, flagKeys);
@@ -4891,7 +6531,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4891
6531
  fallbackToFlags = localEvaluationResult.fallbackToFlags;
4892
6532
  }
4893
6533
  if (fallbackToFlags && !onlyEvaluateLocally) {
4894
- const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, flagKeys);
6534
+ const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
4895
6535
  featureFlags = {
4896
6536
  ...featureFlags,
4897
6537
  ...remoteEvaluationResult.flags || {}
@@ -4939,9 +6579,10 @@ class PostHogBackendClient extends PostHogCoreStateless {
4939
6579
  const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
4940
6580
  personProperties = adjustedProperties.allPersonProperties;
4941
6581
  groupProperties = adjustedProperties.allGroupProperties;
4942
- const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
6582
+ const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
4943
6583
  if (onlyEvaluateLocally == undefined)
4944
6584
  onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
6585
+ const requestedFlagKeys = flagKeys ? new Set(flagKeys) : undefined;
4945
6586
  const records = {};
4946
6587
  let requestId;
4947
6588
  let evaluatedAt;
@@ -4960,14 +6601,17 @@ class PostHogBackendClient extends PostHogCoreStateless {
4960
6601
  id: flagDef?.id,
4961
6602
  version: undefined,
4962
6603
  reason: "Evaluated locally",
4963
- locallyEvaluated: true
6604
+ locallyEvaluated: true,
6605
+ hasExperiment: flagDef?.has_experiment
4964
6606
  };
4965
6607
  locallyEvaluatedKeys.add(key);
4966
6608
  }
4967
- const fallbackToFlags = localResult ? localResult.fallbackToFlags : true;
6609
+ const requestedFlagMissingLocally = requestedFlagKeys !== undefined && Array.from(requestedFlagKeys).some((key) => this.featureFlagsPoller?.featureFlagsByKey[key] === undefined);
6610
+ const fallbackToFlags = localResult ? localResult.fallbackToFlags || requestedFlagMissingLocally : true;
4968
6611
  if (fallbackToFlags && !onlyEvaluateLocally) {
4969
- const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, flagKeys);
6612
+ const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
4970
6613
  if (details) {
6614
+ this._minimalFlagCalledEvents = details.minimalFlagCalledEvents === true;
4971
6615
  requestId = details.requestId;
4972
6616
  evaluatedAt = details.evaluatedAt;
4973
6617
  errorsWhileComputing = Boolean(details.errorsWhileComputingFlags);
@@ -4990,7 +6634,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
4990
6634
  id: detail.metadata?.id,
4991
6635
  version: detail.metadata?.version,
4992
6636
  reason: detail.reason?.description ?? detail.reason?.code,
4993
- locallyEvaluated: false
6637
+ locallyEvaluated: false,
6638
+ hasExperiment: detail.metadata?.has_experiment
4994
6639
  };
4995
6640
  }
4996
6641
  }
@@ -5010,7 +6655,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
5010
6655
  id: existing?.id,
5011
6656
  version: existing?.version,
5012
6657
  reason: existing?.reason,
5013
- locallyEvaluated: existing?.locallyEvaluated ?? false
6658
+ locallyEvaluated: existing?.locallyEvaluated ?? false,
6659
+ hasExperiment: existing?.hasExperiment
5014
6660
  };
5015
6661
  }
5016
6662
  if (this._payloadOverrides !== undefined)
@@ -5022,6 +6668,11 @@ class PostHogBackendClient extends PostHogCoreStateless {
5022
6668
  payload
5023
6669
  };
5024
6670
  }
6671
+ if (requestedFlagKeys !== undefined) {
6672
+ for (const key of Object.keys(records))
6673
+ if (!requestedFlagKeys.has(key))
6674
+ delete records[key];
6675
+ }
5025
6676
  return new FeatureFlagEvaluations({
5026
6677
  host: this._getFeatureFlagEvaluationsHost(),
5027
6678
  distinctId: resolvedDistinctId,
@@ -5035,6 +6686,9 @@ class PostHogBackendClient extends PostHogCoreStateless {
5035
6686
  quotaLimited
5036
6687
  });
5037
6688
  }
6689
+ _shouldSendMinimalFlagCalledEvent(event, properties) {
6690
+ return event === "$feature_flag_called" && this._minimalFlagCalledEvents && properties.$feature_flag_has_experiment === false;
6691
+ }
5038
6692
  _captureFlagCalledEventIfNeeded(params) {
5039
6693
  const { distinctId, key, response, groups, disableGeoip, properties } = params;
5040
6694
  const groupSuffix = groups && Object.keys(groups).length > 0 ? `_${JSON.stringify(Object.entries(groups).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0))}` : "";
@@ -5069,9 +6723,32 @@ class PostHogBackendClient extends PostHogCoreStateless {
5069
6723
  return this._featureFlagEvaluationsHost;
5070
6724
  }
5071
6725
  groupIdentify({ groupType, groupKey, properties, distinctId, disableGeoip }) {
5072
- super.groupIdentifyStateless(groupType, groupKey, properties, {
6726
+ this._sendPreparedEvent("capture", {
6727
+ distinctId: distinctId || `$${groupType}_${groupKey}`,
6728
+ event: "$groupidentify",
6729
+ properties: {
6730
+ $group_type: groupType,
6731
+ $group_key: groupKey,
6732
+ $group_set: properties || {}
6733
+ },
6734
+ disableGeoip
6735
+ }, false, {
6736
+ includeContextProperties: false
6737
+ });
6738
+ }
6739
+ async groupIdentifyImmediate({ groupType, groupKey, properties, distinctId, disableGeoip }) {
6740
+ await this._sendPreparedEvent("capture", {
6741
+ distinctId: distinctId || `$${groupType}_${groupKey}`,
6742
+ event: "$groupidentify",
6743
+ properties: {
6744
+ $group_type: groupType,
6745
+ $group_key: groupKey,
6746
+ $group_set: properties || {}
6747
+ },
5073
6748
  disableGeoip
5074
- }, distinctId);
6749
+ }, true, {
6750
+ includeContextProperties: false
6751
+ });
5075
6752
  }
5076
6753
  async reloadFeatureFlags() {
5077
6754
  await this.featureFlagsPoller?.loadFeatureFlags(true);
@@ -5143,12 +6820,18 @@ class PostHogBackendClient extends PostHogCoreStateless {
5143
6820
  this.context?.enter(data, options);
5144
6821
  }
5145
6822
  async _shutdown(shutdownTimeoutMs) {
6823
+ const shutdownDeadlineMs = Date.now() + (shutdownTimeoutMs ?? 30000);
5146
6824
  const resolve = this._consumeWaitUntilCycle();
5147
6825
  await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
5148
6826
  this.errorTracking.shutdown();
6827
+ if (this._metrics) {
6828
+ await raceWithTimeout(this._metrics.flush().catch(() => {}), Math.max(0, shutdownDeadlineMs - Date.now()));
6829
+ this._metrics.reset();
6830
+ }
5149
6831
  try {
5150
- return await super._shutdown(shutdownTimeoutMs);
6832
+ return await super._shutdown(Math.max(0, shutdownDeadlineMs - Date.now()));
5151
6833
  } finally {
6834
+ this.distinctIdHasSentFlagCalls = {};
5152
6835
  resolve?.();
5153
6836
  }
5154
6837
  }
@@ -5243,7 +6926,6 @@ class PostHogBackendClient extends PostHogCoreStateless {
5243
6926
  }
5244
6927
  addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties) {
5245
6928
  const allPersonProperties = {
5246
- distinct_id: distinctId,
5247
6929
  ...personProperties || {}
5248
6930
  };
5249
6931
  const allGroupProperties = {};
@@ -5258,6 +6940,12 @@ class PostHogBackendClient extends PostHogCoreStateless {
5258
6940
  allGroupProperties
5259
6941
  };
5260
6942
  }
6943
+ personPropertiesForLocalEvaluation(distinctId, personProperties) {
6944
+ return {
6945
+ distinct_id: distinctId,
6946
+ ...personProperties || {}
6947
+ };
6948
+ }
5261
6949
  createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties) {
5262
6950
  return {
5263
6951
  distinctId,
@@ -5268,21 +6956,21 @@ class PostHogBackendClient extends PostHogCoreStateless {
5268
6956
  };
5269
6957
  }
5270
6958
  captureException(error, distinctId, additionalProperties, uuid, flags) {
5271
- if (!ErrorTracking.isPreviouslyCapturedError(error)) {
6959
+ if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
5272
6960
  const syntheticException = new Error("PostHog syntheticException");
5273
- this.addPendingPromise(ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
6961
+ this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
5274
6962
  syntheticException
5275
- }, distinctId, additionalProperties).then((msg) => this.capture({
6963
+ }, distinctId, additionalProperties).then((msg) => this._capturePreparedEvent({
5276
6964
  ...msg,
5277
6965
  uuid,
5278
6966
  flags
5279
- })));
6967
+ }, false)));
5280
6968
  }
5281
6969
  }
5282
6970
  async captureExceptionImmediate(error, distinctId, additionalProperties, flags) {
5283
- if (!ErrorTracking.isPreviouslyCapturedError(error)) {
6971
+ if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
5284
6972
  const syntheticException = new Error("PostHog syntheticException");
5285
- return this.addPendingPromise(ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
6973
+ return this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
5286
6974
  syntheticException
5287
6975
  }, distinctId, additionalProperties).then((msg) => this.captureImmediate({
5288
6976
  ...msg,
@@ -5291,24 +6979,31 @@ class PostHogBackendClient extends PostHogCoreStateless {
5291
6979
  }
5292
6980
  }
5293
6981
  async prepareEventMessage(props) {
6982
+ return this._prepareEventMessage(props);
6983
+ }
6984
+ async _prepareEventMessage(props, options = {}) {
5294
6985
  const { distinctId, event, properties, groups, flags, sendFeatureFlags, timestamp, disableGeoip, uuid } = props;
5295
6986
  const contextData = this.context?.get();
6987
+ const includeContextProperties = options.includeContextProperties ?? true;
5296
6988
  let mergedDistinctId = distinctId || contextData?.distinctId;
5297
- const mergedProperties = {
6989
+ const mergedProperties = includeContextProperties ? {
5298
6990
  ...this.props,
5299
6991
  ...contextData?.properties || {},
5300
6992
  ...properties || {}
6993
+ } : {
6994
+ ...properties || {}
5301
6995
  };
5302
6996
  if (!mergedDistinctId) {
5303
6997
  mergedDistinctId = uuidv7();
5304
6998
  mergedProperties.$process_person_profile = false;
5305
6999
  }
5306
- if (contextData?.sessionId && !mergedProperties.$session_id)
7000
+ if (includeContextProperties && contextData?.sessionId && !mergedProperties.$session_id)
5307
7001
  mergedProperties.$session_id = contextData.sessionId;
7002
+ const finalProperties = this._shouldSendMinimalFlagCalledEvent(event, mergedProperties) ? minimizeFlagCalledEventProperties(mergedProperties) : mergedProperties;
5308
7003
  const eventMessage = this._runBeforeSend({
5309
7004
  distinctId: mergedDistinctId,
5310
7005
  event,
5311
- properties: mergedProperties,
7006
+ properties: finalProperties,
5312
7007
  groups,
5313
7008
  flags,
5314
7009
  sendFeatureFlags,
@@ -5332,12 +7027,14 @@ class PostHogBackendClient extends PostHogCoreStateless {
5332
7027
  }
5333
7028
  return {};
5334
7029
  }).catch(() => ({})).then((additionalProperties) => {
5335
- const props2 = {
7030
+ const resolvedGroups = eventMessage.groups || groups;
7031
+ return {
5336
7032
  ...additionalProperties,
5337
7033
  ...eventMessage.properties || {},
5338
- $groups: eventMessage.groups || groups
7034
+ ...resolvedGroups !== undefined && Object.keys(resolvedGroups).length > 0 ? {
7035
+ $groups: resolvedGroups
7036
+ } : {}
5339
7037
  };
5340
- return props2;
5341
7038
  });
5342
7039
  if (eventMessage.event === "$pageview" && this.options.__preview_capture_bot_pageviews && typeof eventProperties.$raw_user_agent == "string") {
5343
7040
  if (isBlockedUA(eventProperties.$raw_user_agent, this.options.custom_blocked_useragents || [])) {
@@ -5364,22 +7061,26 @@ class PostHogBackendClient extends PostHogCoreStateless {
5364
7061
  beforeSend
5365
7062
  ];
5366
7063
  let result = eventMessage;
5367
- for (const fn of fns) {
5368
- result = fn(result);
5369
- if (!result) {
5370
- this._logger.info(`Event '${eventMessage.event}' was rejected in beforeSend function`);
7064
+ for (const fn of fns)
7065
+ try {
7066
+ result = fn(result);
7067
+ if (!result) {
7068
+ this._logger.info(`Event '${eventMessage.event}' was rejected in beforeSend function`);
7069
+ return null;
7070
+ }
7071
+ if (!result.properties || Object.keys(result.properties).length === 0) {
7072
+ const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`;
7073
+ this._logger.warn(message);
7074
+ }
7075
+ } catch (error) {
7076
+ this._logger.error(`Error in before_send function for event '${eventMessage.event}':`, error);
5371
7077
  return null;
5372
7078
  }
5373
- if (!result.properties || Object.keys(result.properties).length === 0) {
5374
- const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`;
5375
- this._logger.warn(message);
5376
- }
5377
- }
5378
7079
  return result;
5379
7080
  }
5380
7081
  }
5381
7082
 
5382
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/context/context.mjs
7083
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/context/context.mjs
5383
7084
  import { AsyncLocalStorage } from "node:async_hooks";
5384
7085
 
5385
7086
  class PostHogContext {
@@ -5410,7 +7111,22 @@ class PostHogContext {
5410
7111
  }
5411
7112
  }
5412
7113
 
5413
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
7114
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/gzip.node.mjs
7115
+ import { gzip } from "node:zlib";
7116
+ import { promisify } from "node:util";
7117
+ var gzipAsync = promisify(gzip);
7118
+ async function gzipCompress2(input, isDebug = true) {
7119
+ try {
7120
+ const compressed = await gzipAsync(input);
7121
+ return new Uint8Array(compressed);
7122
+ } catch (error) {
7123
+ if (isDebug)
7124
+ console.error("Failed to gzip compress data", error);
7125
+ return null;
7126
+ }
7127
+ }
7128
+
7129
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
5414
7130
  var NAME = "posthog-node";
5415
7131
  function createEventProcessor(_posthog, { organization, projectId, prefix, severityAllowList = [
5416
7132
  "error"
@@ -5450,6 +7166,9 @@ function createEventProcessor(_posthog, { organization, projectId, prefix, sever
5450
7166
  $sentry_exception_type: exceptions[0]?.type,
5451
7167
  $sentry_tags: event.tags
5452
7168
  };
7169
+ const injectedReleaseId = getInjectedReleaseId();
7170
+ if (injectedReleaseId)
7171
+ properties.$release_id = injectedReleaseId;
5453
7172
  if (organization && projectId)
5454
7173
  properties["$sentry_url"] = (prefix || "https://sentry.io/organizations/") + organization + "/issues/?project=" + projectId + "&query=" + event.event_id;
5455
7174
  if (sendExceptionsToPostHog)
@@ -5478,24 +7197,27 @@ class PostHogSentryIntegration {
5478
7197
  };
5479
7198
  }
5480
7199
  }
5481
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/entrypoints/index.node.mjs
7200
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/entrypoints/index.node.mjs
5482
7201
  class PostHog extends PostHogBackendClient {
5483
7202
  getLibraryId() {
5484
7203
  return "posthog-node";
5485
7204
  }
7205
+ compressPayload(payload) {
7206
+ return gzipCompress2(payload, this.isDebug);
7207
+ }
5486
7208
  initializeContext() {
5487
7209
  return new PostHogContext;
5488
7210
  }
5489
7211
  createErrorPropertiesBuilder() {
5490
- return new exports_error_tracking.ErrorPropertiesBuilder([
5491
- new exports_error_tracking.EventCoercer,
5492
- new exports_error_tracking.ErrorCoercer,
5493
- new exports_error_tracking.ObjectCoercer,
5494
- new exports_error_tracking.StringCoercer,
5495
- new exports_error_tracking.PrimitiveCoercer
5496
- ], exports_error_tracking.createStackParser("node:javascript", exports_error_tracking.nodeStackLineParser), [
7212
+ return new ErrorPropertiesBuilder([
7213
+ new EventCoercer,
7214
+ new ErrorCoercer,
7215
+ new ObjectCoercer,
7216
+ new StringCoercer,
7217
+ new PrimitiveCoercer
7218
+ ], createStackParser("node:javascript", nodeStackLineParser), [
5497
7219
  createModulerModifier(),
5498
- addSourceContext,
7220
+ (frames) => addSourceContext(frames, undefined, this._logger),
5499
7221
  createRelativePathModifier()
5500
7222
  ]);
5501
7223
  }
@@ -5816,11 +7538,11 @@ function getPostHogDistinctIdForTesting(osProvider) {
5816
7538
  return getTelemetryDistinctId(MACHINE_ID_PREFIX, osProvider);
5817
7539
  }
5818
7540
  export {
5819
- getPostHogDistinctIdForTesting,
5820
- getPostHogDistinctId,
5821
- getComponentVersion,
5822
- createPluginPostHog,
5823
- __createPluginPostHogForTesting,
7541
+ DEFAULT_POSTHOG_API_KEY,
5824
7542
  DEFAULT_POSTHOG_HOST,
5825
- DEFAULT_POSTHOG_API_KEY
7543
+ __createPluginPostHogForTesting,
7544
+ createPluginPostHog,
7545
+ getComponentVersion,
7546
+ getPostHogDistinctId,
7547
+ getPostHogDistinctIdForTesting
5826
7548
  };