oh-my-opencode 5.0.0-beta.8 → 5.0.0-beta.80

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 (1229) hide show
  1. package/.agents/command/publish.md +59 -23
  2. package/.agents/command/remove-deadcode.md +1 -1
  3. package/.agents/skills/codex-qa/scripts/lsp-e2e.sh +1 -3
  4. package/.agents/skills/hyperplan/SKILL.md +5 -5
  5. package/.agents/skills/opencode-qa/scripts/lsp-e2e.sh +1 -1
  6. package/.agents/skills/pre-publish-review/SKILL.md +9 -12
  7. package/.agents/skills/publish/SKILL.md +59 -23
  8. package/.agents/skills/remove-deadcode/SKILL.md +1 -1
  9. package/.agents/skills/security-research/SKILL.md +4 -4
  10. package/.agents/skills/senpi-qa/SKILL.md +80 -0
  11. package/.agents/skills/senpi-qa/scripts/resolve-evidence-dir.mjs +65 -0
  12. package/.agents/skills/senpi-qa/scripts/resolve-evidence-dir.test.mjs +171 -0
  13. package/.agents/skills/tech-debt-audit/SKILL.md +6 -76
  14. package/.opencode/command/publish.md +59 -23
  15. package/.opencode/skills/pre-publish-review/SKILL.md +9 -12
  16. package/README.ja.md +66 -61
  17. package/README.ko.md +67 -62
  18. package/README.md +108 -182
  19. package/README.ru.md +63 -61
  20. package/README.zh-cn.md +62 -61
  21. package/THIRD-PARTY-NOTICES.md +35 -105
  22. package/dist/agents/atlas/agent.d.ts +0 -1
  23. package/dist/agents/gpt-prompt-identity.d.ts +1 -1
  24. package/dist/agents/sisyphus-runtime-prompt-reconciler.d.ts +15 -4
  25. package/dist/agents/types.d.ts +4 -2
  26. package/dist/cli/config-manager/parse-opencode-config-file.d.ts +2 -1
  27. package/dist/cli/doctor/checks/browser-provider.d.ts +2 -0
  28. package/dist/cli/doctor/checks/index.d.ts +2 -0
  29. package/dist/cli/doctor/checks/latest-version.d.ts +11 -0
  30. package/dist/cli/doctor/checks/system-plugin.d.ts +4 -3
  31. package/dist/cli/doctor/framework/constants.d.ts +5 -0
  32. package/dist/cli/doctor/framework/types.d.ts +2 -0
  33. package/dist/cli/fallback-lane-policy.d.ts +1 -0
  34. package/dist/cli/index.js +50191 -58043
  35. package/dist/cli/install-codex/install-codex-test-fixtures.d.ts +1 -1
  36. package/dist/cli/run/on-complete-hook.d.ts +2 -0
  37. package/dist/cli/runtime-commands.d.ts +1 -1
  38. package/dist/cli/worktree-sweep/classify.d.ts +16 -0
  39. package/dist/cli/worktree-sweep/format.d.ts +8 -0
  40. package/dist/cli/worktree-sweep/git.d.ts +19 -0
  41. package/dist/cli/worktree-sweep/index.d.ts +7 -0
  42. package/dist/cli/worktree-sweep/options.d.ts +2 -0
  43. package/dist/cli/worktree-sweep/parse-worktree-list.d.ts +8 -0
  44. package/dist/cli/worktree-sweep/sweep.d.ts +2 -0
  45. package/dist/cli/worktree-sweep/types.d.ts +65 -0
  46. package/dist/cli/worktree-sweep/worktree-sweep.d.ts +2 -0
  47. package/dist/cli-node/index.js +51708 -59537
  48. package/dist/config/index.d.ts +1 -1
  49. package/dist/config/schema/agent-names.d.ts +0 -1
  50. package/dist/config/schema/background-task.d.ts +1 -0
  51. package/dist/config/schema/browser-automation.d.ts +0 -2
  52. package/dist/config/schema/commands.d.ts +1 -1
  53. package/dist/config/schema/hooks.d.ts +1 -2
  54. package/dist/config/schema/oh-my-opencode-config.d.ts +5 -12
  55. package/dist/config/schema/ulw-execute.d.ts +5 -0
  56. package/dist/config/schema.d.ts +0 -1
  57. package/dist/config/validate.d.ts +2 -0
  58. package/dist/config-migration/category-deep-split.d.ts +3 -0
  59. package/dist/config-migration/migration-plans.d.ts +1 -0
  60. package/dist/create-hooks.d.ts +3 -2
  61. package/dist/features/background-agent/compaction-aware-message-resolver.d.ts +1 -0
  62. package/dist/features/background-agent/constants.d.ts +0 -7
  63. package/dist/features/background-agent/error-classifier.d.ts +1 -0
  64. package/dist/features/background-agent/manager.d.ts +9 -1
  65. package/dist/features/background-agent/parent-wake-dispatched-tracker.d.ts +0 -1
  66. package/dist/features/background-agent/parent-wake-notifier-types.d.ts +1 -1
  67. package/dist/features/background-agent/parent-wake-prompt-dispatch.d.ts +1 -1
  68. package/dist/features/background-agent/parent-wake-session-inspector.d.ts +1 -1
  69. package/dist/features/background-agent/subagent-spawn-limits.d.ts +8 -0
  70. package/dist/features/background-agent/types.d.ts +4 -0
  71. package/dist/features/boulder-state/storage.d.ts +1 -1
  72. package/dist/features/btw-side/btw-command-draft.d.ts +7 -0
  73. package/dist/features/btw-side/context-injector.d.ts +15 -0
  74. package/dist/features/btw-side/index.d.ts +8 -0
  75. package/dist/features/btw-side/metadata.d.ts +15 -0
  76. package/dist/features/btw-side/parent-context-budget.d.ts +9 -0
  77. package/dist/features/btw-side/server-session-registry.d.ts +8 -0
  78. package/dist/features/btw-side/tui-adoption-cache.d.ts +13 -0
  79. package/dist/features/btw-side/tui-adoption-guard.d.ts +5 -0
  80. package/dist/features/btw-side/tui-controller-types.d.ts +68 -0
  81. package/dist/features/btw-side/tui-controller.d.ts +19 -0
  82. package/dist/features/btw-side/tui-escape-return.d.ts +12 -0
  83. package/dist/features/btw-side/tui-keymap.d.ts +17 -0
  84. package/dist/features/btw-side/tui-parent-validator.d.ts +6 -0
  85. package/dist/features/btw-side/tui-picker-options.d.ts +20 -0
  86. package/dist/features/btw-side/tui-picker.d.ts +9 -0
  87. package/dist/features/btw-side/tui-prompt-queue.d.ts +8 -0
  88. package/dist/features/btw-side/tui-session-bridge.d.ts +11 -0
  89. package/dist/features/btw-side/tui-session-catalog.d.ts +35 -0
  90. package/dist/features/btw-side/tui-side-removal.d.ts +11 -0
  91. package/dist/features/btw-side/tui-side-start.d.ts +9 -0
  92. package/dist/features/btw-side/tui-wiring.d.ts +8 -0
  93. package/dist/features/builtin-commands/templates/hyperplan.d.ts +1 -1
  94. package/dist/features/builtin-commands/templates/refactor-sections/team-mode-addendum.d.ts +1 -1
  95. package/dist/features/builtin-commands/templates/remove-ai-slops.d.ts +1 -1
  96. package/dist/features/builtin-commands/templates/ulw-execute.d.ts +1 -0
  97. package/dist/features/builtin-commands/types.d.ts +1 -1
  98. package/dist/features/claude-tasks/storage.d.ts +7 -2
  99. package/dist/features/hook-message-injector/index.d.ts +1 -0
  100. package/dist/features/hook-message-injector/sdk-message-lookup.d.ts +1 -0
  101. package/dist/features/monitor/manager-internals.d.ts +1 -1
  102. package/dist/features/monitor/output-injector-types.d.ts +1 -1
  103. package/dist/features/opengateway-provider/index.d.ts +13 -0
  104. package/dist/features/task-toast-manager/manager.d.ts +0 -24
  105. package/dist/features/team-mode/tools/messaging-fallback-wake.d.ts +17 -0
  106. package/dist/features/team-mode/tools/messaging-live-delivery-recipient.d.ts +3 -0
  107. package/dist/features/team-mode/tools/messaging-runtime.d.ts +7 -0
  108. package/dist/hooks/anthropic-context-window-limit-recovery/message-storage-directory.d.ts +0 -3
  109. package/dist/hooks/anthropic-context-window-limit-recovery/state.d.ts +1 -0
  110. package/dist/hooks/anthropic-context-window-limit-recovery/storage/empty-messages.d.ts +0 -1
  111. package/dist/hooks/anthropic-context-window-limit-recovery/tool-result-storage.d.ts +11 -0
  112. package/dist/hooks/atlas/atlas-hook.d.ts +1 -0
  113. package/dist/hooks/atlas/atlas-lifecycle-store.d.ts +50 -0
  114. package/dist/hooks/atlas/event-handler.d.ts +1 -0
  115. package/dist/hooks/atlas/final-wave-approval-gate.test-support.d.ts +50 -0
  116. package/dist/hooks/atlas/system-reminder-templates.d.ts +0 -1
  117. package/dist/hooks/atlas/tool-execute-before.d.ts +3 -0
  118. package/dist/hooks/atlas/types.d.ts +1 -0
  119. package/dist/hooks/claude-code-hooks/session-hook-state.d.ts +1 -0
  120. package/dist/hooks/claude-code-hooks/stop.d.ts +2 -0
  121. package/dist/hooks/claude-code-hooks/todo.d.ts +0 -1
  122. package/dist/hooks/claude-code-hooks/transcript.d.ts +2 -0
  123. package/dist/hooks/comment-checker/__fixtures__/download-probe.fixture.d.ts +1 -0
  124. package/dist/hooks/compaction-context-injector/validated-model.d.ts +2 -0
  125. package/dist/hooks/fsync-skip-warning/index.d.ts +4 -0
  126. package/dist/hooks/hashline-edit-diff-enhancer/hook.d.ts +1 -0
  127. package/dist/hooks/hashline-edit-diff-enhancer/pending-captures.d.ts +13 -0
  128. package/dist/hooks/index.d.ts +1 -2
  129. package/dist/hooks/keyword-detector/hook.d.ts +9 -0
  130. package/dist/hooks/keyword-detector/ultrawork/index.d.ts +2 -0
  131. package/dist/hooks/keyword-detector/ultrawork/source-detector.d.ts +0 -1
  132. package/dist/hooks/model-fallback/hook.d.ts +1 -1
  133. package/dist/hooks/plan-format-validator/hook.d.ts +19 -0
  134. package/dist/hooks/prometheus-md-only/agent-resolution.d.ts +2 -2
  135. package/dist/hooks/runtime-fallback/chat-message-handler.d.ts +2 -0
  136. package/dist/hooks/runtime-fallback/retry-model-payload.d.ts +1 -0
  137. package/dist/hooks/runtime-fallback/runtime-model-settings.d.ts +6 -0
  138. package/dist/hooks/runtime-fallback/session-status-handler.d.ts +1 -1
  139. package/dist/hooks/runtime-fallback/types.d.ts +3 -1
  140. package/dist/hooks/sisyphus-junior-notepad/constants.d.ts +1 -1
  141. package/dist/hooks/todo-continuation-enforcer/types.d.ts +1 -0
  142. package/dist/hooks/{start-work → ulw-execute}/context-info-builder.d.ts +1 -1
  143. package/dist/hooks/{start-work → ulw-execute}/index.d.ts +1 -1
  144. package/dist/hooks/ulw-execute/ulw-execute-hook.d.ts +23 -0
  145. package/dist/hooks/unstable-agent-babysitter/task-message-analyzer.d.ts +1 -0
  146. package/dist/index.js +30870 -27341
  147. package/dist/mcp/index.d.ts +0 -4
  148. package/dist/mcp/types.d.ts +0 -1
  149. package/dist/oh-my-opencode.schema.json +25 -52
  150. package/dist/plugin/chat-message/types.d.ts +6 -4
  151. package/dist/plugin/chat-message/ulw-execute-message.d.ts +5 -0
  152. package/dist/plugin/event-session-lifecycle.d.ts +1 -0
  153. package/dist/plugin/hooks/create-core-hooks.d.ts +2 -2
  154. package/dist/plugin/hooks/create-session-hooks.d.ts +2 -3
  155. package/dist/plugin/hooks/create-transform-hooks.d.ts +2 -0
  156. package/dist/plugin/messages-transform.d.ts +1 -0
  157. package/dist/plugin/stop-continuation.d.ts +3 -0
  158. package/dist/plugin/system-transform.d.ts +5 -1
  159. package/dist/plugin-config/omo-config-chain.d.ts +1 -0
  160. package/dist/plugin-dispose.d.ts +3 -0
  161. package/dist/shared/agent-tool-restrictions.d.ts +0 -1
  162. package/dist/shared/compaction-agent-config-checkpoint.d.ts +1 -0
  163. package/dist/shared/index.d.ts +2 -0
  164. package/dist/shared/legacy-plugin-warning.d.ts +2 -1
  165. package/dist/shared/omo-process-sweep.d.ts +2 -4
  166. package/dist/shared/plugin-entry-migrator.d.ts +4 -3
  167. package/dist/shared/plugin-entry-shape.d.ts +6 -0
  168. package/dist/shared/runtime-fallback-retry-marker.d.ts +16 -0
  169. package/dist/shared/shell-env.d.ts +1 -1
  170. package/dist/skills/ast-grep/AGENTS.md +51 -0
  171. package/dist/skills/ast-grep/SKILL.md +13 -1
  172. package/dist/skills/coding-agent-sessions/AGENTS.md +62 -0
  173. package/dist/skills/coding-agent-sessions/SKILL.md +1 -1
  174. package/dist/skills/data-scientist/SKILL.md +99 -239
  175. package/dist/skills/data-scientist/references/execution-surfaces.md +91 -0
  176. package/dist/skills/data-scientist/references/placement.md +74 -0
  177. package/dist/skills/data-scientist/references/polars-lane.md +95 -0
  178. package/dist/skills/data-scientist/references/uv-setup.md +1 -1
  179. package/dist/skills/data-scientist/references/visualization.md +64 -0
  180. package/dist/skills/data-scientist/scripts/ensure-js-deps.sh +28 -0
  181. package/dist/skills/data-scientist/scripts/ensure-py-deps.sh +37 -0
  182. package/dist/skills/debugging/SKILL.md +3 -1
  183. package/dist/skills/debugging/references/methodology/00-setup.md +12 -0
  184. package/dist/skills/debugging/references/methodology/02-investigate.md +26 -5
  185. package/dist/skills/debugging/references/runtimes/go.md +15 -1
  186. package/dist/skills/debugging/references/runtimes/native-binary.md +38 -0
  187. package/dist/skills/debugging/references/runtimes/node.md +25 -0
  188. package/dist/skills/debugging/references/runtimes/python.md +13 -0
  189. package/dist/skills/debugging/references/runtimes/rust.md +41 -0
  190. package/dist/skills/debugging/references/scripts/dap.mjs +267 -0
  191. package/dist/skills/debugging/references/scripts/dap.test.ts +86 -0
  192. package/dist/skills/debugging/references/scripts/fixture-adapter.mjs +59 -0
  193. package/dist/skills/debugging/references/tools/dap.md +103 -0
  194. package/dist/skills/debugging/references/tools/frida.md +193 -0
  195. package/dist/skills/debugging/references/tools/playwright-cli.md +79 -161
  196. package/dist/skills/frontend/ATTRIBUTION.md +10 -0
  197. package/dist/skills/frontend/SKILL.md +7 -3
  198. package/dist/skills/frontend/references/design/README.md +10 -2
  199. package/dist/skills/frontend/references/design/_INDEX.md +1 -0
  200. package/dist/skills/frontend/references/design/ambience-skill.md +145 -0
  201. package/dist/skills/frontend/references/design/aside.md +1 -1
  202. package/dist/skills/frontend/references/design/clone-from-url.md +1 -1
  203. package/dist/skills/frontend/references/design/interaction-skill.md +2 -0
  204. package/dist/skills/frontend/references/design/print-paged-media.md +76 -0
  205. package/dist/skills/frontend/references/designpowers/README.md +1 -1
  206. package/dist/skills/frontend/references/designpowers/lane-a-direction.md +1 -1
  207. package/dist/skills/frontend/references/designpowers/lane-b-execution.md +11 -11
  208. package/dist/skills/frontend/references/designpowers/lane-d-memory.md +3 -3
  209. package/dist/skills/frontend/references/designpowers/orchestration.md +1 -1
  210. package/dist/skills/frontend/references/designpowers/routing.md +5 -5
  211. package/dist/skills/frontend/scripts/perfection/lighthouse-audit.py +2 -2
  212. package/dist/skills/git-master/SKILL.md +1 -1
  213. package/dist/skills/init-deep/SKILL.md +14 -14
  214. package/dist/skills/lsp-setup/SKILL.md +1 -1
  215. package/dist/skills/programming/SKILL.md +1 -1
  216. package/dist/skills/refactor/SKILL.md +5 -5
  217. package/dist/skills/remove-ai-slops/SKILL.md +5 -5
  218. package/dist/skills/review-work/SKILL.md +101 -419
  219. package/dist/skills/ultimate-browsing/ATTRIBUTION.md +32 -86
  220. package/dist/skills/ultimate-browsing/SKILL.md +32 -27
  221. package/dist/skills/ultimate-browsing/engine/AGENTS.md +111 -0
  222. package/dist/skills/ultimate-browsing/engine/templates/package.json +2 -2
  223. package/dist/skills/ultimate-browsing/engine/templates/playwright_mobile_chrome.js +5 -2
  224. package/dist/skills/ultimate-browsing/engine/templates/playwright_real_chrome.js +8 -6
  225. package/dist/skills/ultimate-browsing/engine/tests/test_playwright_stealth.py +86 -0
  226. package/dist/skills/ultimate-browsing/engine/tests/test_playwright_templates.py +4 -7
  227. package/dist/skills/ultimate-browsing/references/chrome-stealth.md +86 -95
  228. package/dist/skills/ultimate-browsing/references/insane-search/README.md +18 -5
  229. package/dist/skills/ultimate-browsing/references/insane-search/playwright.md +16 -13
  230. package/dist/skills/ultimate-browsing/scripts/extract_cookies.py +3 -3
  231. package/dist/skills/{start-work → ulw-execute}/SKILL.md +24 -22
  232. package/dist/skills/ulw-plan/SKILL.md +5 -6
  233. package/dist/skills/ulw-plan/references/full-workflow.md +6 -5
  234. package/dist/skills/ulw-plan/references/intent-unclear.md +2 -2
  235. package/dist/skills/ulw-plan/scripts/scaffold-plan.mjs +2 -1
  236. package/dist/skills/ulw-research/SKILL.md +10 -5
  237. package/dist/skills/visual-qa/AGENTS.md +58 -0
  238. package/dist/skills/visual-qa/SKILL.md +4 -3
  239. package/dist/skills/visual-qa/references/browser-setup.md +75 -0
  240. package/dist/tools/delegate-task/builtin-categories.d.ts +3 -1
  241. package/dist/tools/delegate-task/builtin-category-definition.d.ts +2 -1
  242. package/dist/tools/delegate-task/constants.d.ts +2 -2
  243. package/dist/tools/delegate-task/openai-categories.d.ts +10 -3
  244. package/dist/tools/delegate-task/sync-session-cleanup.d.ts +3 -0
  245. package/dist/tools/delegate-task/sync-session-poller.d.ts +1 -0
  246. package/dist/tools/delegate-task/tool-description.d.ts +3 -1
  247. package/dist/tools/delegate-task/types.d.ts +4 -0
  248. package/dist/tools/session-manager/directory-filter.d.ts +2 -0
  249. package/dist/tui.d.ts +12 -0
  250. package/dist/tui.js +37073 -46672
  251. package/package.json +44 -45
  252. package/packages/git-bash-mcp/dist/cli.js +6 -1
  253. package/packages/git-bash-mcp/package.json +1 -1
  254. package/packages/lsp-core/src/index.ts +1 -0
  255. package/packages/lsp-core/src/lsp/client-diagnostics-concurrency.integration.test.ts +9 -1
  256. package/packages/lsp-core/src/lsp/client-diagnostics-freshness.integration.test.ts +100 -28
  257. package/packages/lsp-core/src/lsp/client-diagnostics-pull-timeout.test.ts +64 -0
  258. package/packages/lsp-core/src/lsp/client-wrapper-outside-cwd.test.ts +78 -0
  259. package/packages/lsp-core/src/lsp/client-wrapper.test.ts +103 -6
  260. package/packages/lsp-core/src/lsp/client-wrapper.ts +50 -16
  261. package/packages/lsp-core/src/lsp/client.ts +32 -3
  262. package/packages/lsp-core/src/lsp/connection.ts +16 -0
  263. package/packages/lsp-core/src/lsp/constants.ts +6 -0
  264. package/packages/lsp-core/src/lsp/controlled-clock-test-support.ts +90 -0
  265. package/packages/lsp-core/src/lsp/errors.ts +15 -0
  266. package/packages/lsp-core/src/lsp/fixtures/workspace-edit-server.mjs +10 -3
  267. package/packages/lsp-core/src/lsp/format-document.test.ts +143 -0
  268. package/packages/lsp-core/src/lsp/format-document.ts +90 -0
  269. package/packages/lsp-core/src/lsp/json-rpc-connection.ts +11 -6
  270. package/packages/lsp-core/src/lsp/manager-lifecycle.test.ts +262 -0
  271. package/packages/lsp-core/src/lsp/manager-max-clients.test.ts +151 -0
  272. package/packages/lsp-core/src/lsp/manager.ts +138 -12
  273. package/packages/lsp-core/src/lsp/outside-context-workspace.ts +33 -0
  274. package/packages/lsp-core/src/lsp/server-definitions.ts +29 -0
  275. package/packages/lsp-core/src/lsp/server-installation.test.ts +376 -0
  276. package/packages/lsp-core/src/lsp/server-installation.ts +200 -27
  277. package/packages/lsp-core/src/lsp/server-resolution-local-binary.test.ts +170 -0
  278. package/packages/lsp-core/src/lsp/server-resolution.ts +18 -5
  279. package/packages/lsp-core/src/lsp/timer-provider.ts +13 -0
  280. package/packages/lsp-core/src/lsp/transport-request-timeout.test.ts +73 -0
  281. package/packages/lsp-core/src/lsp/transport.ts +16 -2
  282. package/packages/lsp-core/src/lsp/types.ts +8 -0
  283. package/packages/lsp-core/src/lsp/workspace-apply-edit-test-support.ts +29 -1
  284. package/packages/lsp-core/src/lsp/workspace-document-state.test.ts +84 -1
  285. package/packages/lsp-core/src/lsp/workspace-document-state.ts +35 -11
  286. package/packages/lsp-core/src/lsp/workspace-markers.ts +18 -0
  287. package/packages/lsp-core/src/mcp.ts +3 -0
  288. package/packages/lsp-core/src/request-context.test.ts +29 -0
  289. package/packages/lsp-core/src/request-context.ts +1 -1
  290. package/packages/lsp-core/src/tool-surface.test.ts +13 -1
  291. package/packages/lsp-core/src/tools/definitions.ts +14 -0
  292. package/packages/lsp-core/src/tools/format.test.ts +56 -0
  293. package/packages/lsp-core/src/tools/format.ts +56 -0
  294. package/packages/lsp-core/src/tools/index.ts +1 -0
  295. package/packages/lsp-core/src/tools/parameters.test.ts +51 -0
  296. package/packages/lsp-core/src/tools/types.ts +10 -0
  297. package/packages/lsp-daemon/dist/cli.js +904 -479
  298. package/packages/lsp-daemon/dist/client.d.ts +10 -0
  299. package/packages/lsp-daemon/dist/client.js +922 -493
  300. package/packages/lsp-daemon/dist/daemon-client.d.ts +1 -0
  301. package/packages/lsp-daemon/dist/daemon-client.js +3 -0
  302. package/packages/lsp-daemon/dist/ensure-daemon.d.ts +6 -1
  303. package/packages/lsp-daemon/dist/ensure-daemon.js +10 -2
  304. package/packages/lsp-daemon/dist/index.js +826 -402
  305. package/packages/lsp-daemon/dist/ownership.js +2 -2
  306. package/packages/lsp-daemon/dist/proxy.js +3 -0
  307. package/packages/lsp-daemon/dist/version-reap.js +1 -1
  308. package/packages/lsp-daemon/package.json +1 -1
  309. package/packages/lsp-tools-mcp/dist/cli.js +764 -341
  310. package/packages/lsp-tools-mcp/dist/lsp/manager.js +274 -138
  311. package/packages/lsp-tools-mcp/dist/mcp.js +789 -368
  312. package/packages/lsp-tools-mcp/dist/request-context.js +12 -13
  313. package/packages/lsp-tools-mcp/dist/tools.js +719 -302
  314. package/packages/lsp-tools-mcp/package.json +1 -1
  315. package/packages/omo-codex/THIRD-PARTY-NOTICES.md +4 -21
  316. package/packages/omo-codex/plugin/.codex-plugin/plugin.json +4 -6
  317. package/packages/omo-codex/plugin/.mcp.json +0 -6
  318. package/packages/omo-codex/plugin/AGENTS.md +47 -0
  319. package/packages/omo-codex/plugin/README.md +6 -2
  320. package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +7175 -408
  321. package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
  322. package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
  323. package/packages/omo-codex/plugin/components/bootstrap/src/hook.ts +1 -0
  324. package/packages/omo-codex/plugin/components/bootstrap/src/setup.ts +7 -1
  325. package/packages/omo-codex/plugin/components/comment-checker/AGENTS.md +9 -0
  326. package/packages/omo-codex/plugin/components/comment-checker/biome.json +2 -2
  327. package/packages/omo-codex/plugin/components/comment-checker/dist/cli.js +2 -1
  328. package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
  329. package/packages/omo-codex/plugin/components/comment-checker/package.json +5 -5
  330. package/packages/omo-codex/plugin/components/comment-checker/src/apply-patch.ts +2 -8
  331. package/packages/omo-codex/plugin/components/comment-checker/src/core.ts +1 -2
  332. package/packages/omo-codex/plugin/components/comment-checker/src/request-extractor.ts +1 -1
  333. package/packages/omo-codex/plugin/components/comment-checker/src/runner.ts +1 -0
  334. package/packages/omo-codex/plugin/components/git-bash/AGENTS.md +1 -1
  335. package/packages/omo-codex/plugin/components/git-bash/dist/cli.js +1 -1
  336. package/packages/omo-codex/plugin/components/git-bash/dist/codex-hook.js +2 -1
  337. package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
  338. package/packages/omo-codex/plugin/components/git-bash/package.json +3 -4
  339. package/packages/omo-codex/plugin/components/git-bash/src/codex-hook.ts +2 -1
  340. package/packages/omo-codex/plugin/components/git-bash/test/codex-hook.test.ts +6 -7
  341. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/AGENTS.md +2 -2
  342. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/biome.json +2 -2
  343. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/directive.md +2 -0
  344. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/cli.js +36 -29
  345. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/codex-hook.js +32 -26
  346. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/types.d.ts +3 -0
  347. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
  348. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +5 -5
  349. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/src/codex-hook.ts +32 -28
  350. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/src/types.ts +3 -0
  351. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/test/cli.test.ts +1 -1
  352. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/test/codex-hook.test.ts +137 -28
  353. package/packages/omo-codex/plugin/components/lcx/skills/lcx-doctor/SKILL.md +4 -2
  354. package/packages/omo-codex/plugin/components/lsp/AGENTS.md +30 -15
  355. package/packages/omo-codex/plugin/components/lsp/biome.json +2 -2
  356. package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +4 -4
  357. package/packages/omo-codex/plugin/components/lsp/dist/cli.js +943 -540
  358. package/packages/omo-codex/plugin/components/lsp/dist/daemon-cli-path.js +1 -1
  359. package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
  360. package/packages/omo-codex/plugin/components/lsp/package.json +5 -5
  361. package/packages/omo-codex/plugin/components/lsp/src/cli.ts +1 -1
  362. package/packages/omo-codex/plugin/components/lsp/src/codex-hook.ts +1 -1
  363. package/packages/omo-codex/plugin/components/lsp/src/daemon-cli-path.ts +1 -5
  364. package/packages/omo-codex/plugin/components/lsp/test/codex-hook-unavailable.test.ts +6 -7
  365. package/packages/omo-codex/plugin/components/lsp/test/codex-hook.test.ts +1 -2
  366. package/packages/omo-codex/plugin/components/lsp/test/package-smoke.test.ts +11 -1
  367. package/packages/omo-codex/plugin/components/rules/AGENTS.md +12 -0
  368. package/packages/omo-codex/plugin/components/rules/README.md +2 -0
  369. package/packages/omo-codex/plugin/components/rules/biome.json +2 -2
  370. package/packages/omo-codex/plugin/components/rules/bundled-rules/hephaestus/gpt-6.md +123 -0
  371. package/packages/omo-codex/plugin/components/rules/dist/cli.js +91 -68
  372. package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
  373. package/packages/omo-codex/plugin/components/rules/package.json +7 -7
  374. package/packages/omo-codex/plugin/components/rules/src/config.ts +1 -2
  375. package/packages/omo-codex/plugin/components/rules/src/persistent-cache.ts +1 -2
  376. package/packages/omo-codex/plugin/components/rules/src/post-compact-budget.ts +15 -5
  377. package/packages/omo-codex/plugin/components/rules/src/rules-engine-factory.ts +1 -4
  378. package/packages/omo-codex/plugin/components/rules/src/static-injection.ts +4 -9
  379. package/packages/omo-codex/plugin/components/rules/test/bundled-rules-priority.test.ts +11 -16
  380. package/packages/omo-codex/plugin/components/rules/test/bundled-rules.test.ts +17 -25
  381. package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-budget.test.ts +9 -7
  382. package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-context.test.ts +0 -6
  383. package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-dedup.test.ts +6 -4
  384. package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-directive.test.ts +12 -9
  385. package/packages/omo-codex/plugin/components/rules/test/codex-hook.test.ts +28 -37
  386. package/packages/omo-codex/plugin/components/rules/test/dynamic-target-fingerprints.test.ts +1 -2
  387. package/packages/omo-codex/plugin/components/rules/test/engine.test.ts +7 -4
  388. package/packages/omo-codex/plugin/components/rules/test/finder.test.ts +2 -3
  389. package/packages/omo-codex/plugin/components/rules/test/formatter.test.ts +39 -72
  390. package/packages/omo-codex/plugin/components/rules/test/hephaestus-model-variant.test.ts +38 -3
  391. package/packages/omo-codex/plugin/components/rules/test/hook-output.test.ts +2 -3
  392. package/packages/omo-codex/plugin/components/rules/test/matcher.test.ts +2 -3
  393. package/packages/omo-codex/plugin/components/rules/test/package-smoke.test.ts +1 -1
  394. package/packages/omo-codex/plugin/components/rules/test/parser.test.ts +1 -2
  395. package/packages/omo-codex/plugin/components/rules/test/post-compact-budget.test.ts +29 -6
  396. package/packages/omo-codex/plugin/components/rules/test/rules-engine-consumption.test.ts +3 -6
  397. package/packages/omo-codex/plugin/components/rules/test/scanner.test.ts +1 -2
  398. package/packages/omo-codex/plugin/components/rules/test/sources.test.ts +2 -5
  399. package/packages/omo-codex/plugin/components/rules/test/windows-git-bash-bundled-rule.test.ts +2 -17
  400. package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
  401. package/packages/omo-codex/plugin/components/teammode/package.json +5 -5
  402. package/packages/omo-codex/plugin/components/teammode/test/thread-title-hook.test.ts +4 -10
  403. package/packages/omo-codex/plugin/components/telemetry/AGENTS.md +8 -0
  404. package/packages/omo-codex/plugin/components/telemetry/biome.json +2 -2
  405. package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +2470 -701
  406. package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +2488 -720
  407. package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
  408. package/packages/omo-codex/plugin/components/telemetry/package.json +5 -5
  409. package/packages/omo-codex/plugin/components/telemetry/src/codex-hook.ts +1 -4
  410. package/packages/omo-codex/plugin/components/telemetry/src/posthog.ts +4 -14
  411. package/packages/omo-codex/plugin/components/telemetry/src/product-identity.ts +1 -1
  412. package/packages/omo-codex/plugin/components/telemetry/test/diagnostics.test.ts +2 -5
  413. package/packages/omo-codex/plugin/components/ultrawork/AGENTS.md +10 -4
  414. package/packages/omo-codex/plugin/components/ultrawork/README.md +2 -0
  415. package/packages/omo-codex/plugin/components/ultrawork/agents/explorer.toml +1 -1
  416. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-clone-fidelity-reviewer.toml +1 -1
  417. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-code-reviewer.toml +1 -1
  418. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-gate-reviewer.toml +1 -1
  419. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-qa-executor.toml +1 -1
  420. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-worker-high.toml +1 -1
  421. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-worker-low.toml +1 -1
  422. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-worker-medium.toml +1 -1
  423. package/packages/omo-codex/plugin/components/ultrawork/agents/librarian.toml +1 -1
  424. package/packages/omo-codex/plugin/components/ultrawork/agents/metis.toml +1 -1
  425. package/packages/omo-codex/plugin/components/ultrawork/agents/momus.toml +1 -1
  426. package/packages/omo-codex/plugin/components/ultrawork/agents/plan.toml +4 -4
  427. package/packages/omo-codex/plugin/components/ultrawork/biome.json +2 -2
  428. package/packages/omo-codex/plugin/components/ultrawork/dist/cli.js +500 -4
  429. package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
  430. package/packages/omo-codex/plugin/components/ultrawork/package.json +5 -6
  431. package/packages/omo-codex/plugin/components/ultrawork/scripts/sync-directive.mjs +30 -14
  432. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/SKILL.md +4 -5
  433. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/full-workflow.md +5 -5
  434. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/intent-unclear.md +2 -2
  435. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/scripts/scaffold-plan.mjs +1 -0
  436. package/packages/omo-codex/plugin/components/ultrawork/src/directive-content.ts +4 -0
  437. package/packages/omo-codex/plugin/components/ultrawork/src/directive.ts +5 -2
  438. package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook-trigger-policy.test.ts +9 -1
  439. package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook.test.ts +0 -136
  440. package/packages/omo-codex/plugin/components/ultrawork/test/directive-source.test.ts +14 -8
  441. package/packages/omo-codex/plugin/components/ultrawork/test/package-smoke.test.ts +12 -1
  442. package/packages/omo-codex/plugin/components/ultrawork/test/skill-pointer.test.ts +0 -2
  443. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/AGENTS.md +4 -4
  444. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/NOTICE +1 -1
  445. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/README.md +6 -6
  446. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/biome.json +2 -2
  447. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/directive.md +11 -11
  448. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/dist/cli.js +16 -16
  449. package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +16 -0
  450. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/package.json +12 -12
  451. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/boulder-reader.ts +1 -1
  452. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/cli.ts +1 -1
  453. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/codex-hook.ts +4 -4
  454. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/directive.ts +1 -1
  455. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/index.ts +1 -1
  456. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/types.ts +1 -1
  457. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/boulder-reader.test.ts +3 -3
  458. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/cli.test.ts +4 -11
  459. package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/codex-hook.test.ts +24 -22
  460. package/packages/omo-codex/plugin/components/ulw-loop/AGENTS.md +19 -0
  461. package/packages/omo-codex/plugin/components/ulw-loop/CHANGELOG.md +17 -1
  462. package/packages/omo-codex/plugin/components/ulw-loop/README.md +12 -1
  463. package/packages/omo-codex/plugin/components/ulw-loop/biome.json +2 -2
  464. package/packages/omo-codex/plugin/components/ulw-loop/directive.md +44 -27
  465. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-codex-validation.d.ts +18 -0
  466. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-codex-validation.js +30 -0
  467. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-continuation.js +10 -4
  468. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-reconciliation.d.ts +2 -5
  469. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-reconciliation.js +5 -78
  470. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-template.d.ts +12 -0
  471. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-template.js +114 -0
  472. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.d.ts +7 -1
  473. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.js +57 -46
  474. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-arg-parser.js +2 -2
  475. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-commands.js +21 -8
  476. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.d.ts +2 -1
  477. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.js +12 -1
  478. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-subcommands.d.ts +1 -1
  479. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-subcommands.js +40 -37
  480. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +2191 -737
  481. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-instruction.d.ts +2 -0
  482. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-instruction.js +28 -8
  483. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-snapshot.d.ts +8 -5
  484. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-snapshot.js +35 -23
  485. package/packages/omo-codex/plugin/components/ulw-loop/dist/constants.d.ts +1 -0
  486. package/packages/omo-codex/plugin/components/ulw-loop/dist/constants.js +1 -0
  487. package/packages/omo-codex/plugin/components/ulw-loop/dist/domain-types.d.ts +25 -9
  488. package/packages/omo-codex/plugin/components/ulw-loop/dist/driver-objective-ack.d.ts +4 -0
  489. package/packages/omo-codex/plugin/components/ulw-loop/dist/driver-objective-ack.js +18 -0
  490. package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence-artifacts.d.ts +1 -0
  491. package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence-artifacts.js +37 -0
  492. package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence.d.ts +1 -0
  493. package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence.js +24 -12
  494. package/packages/omo-codex/plugin/components/ulw-loop/dist/ledger.d.ts +4 -0
  495. package/packages/omo-codex/plugin/components/ulw-loop/dist/ledger.js +39 -0
  496. package/packages/omo-codex/plugin/components/ulw-loop/dist/paths.d.ts +2 -0
  497. package/packages/omo-codex/plugin/components/ulw-loop/dist/paths.js +19 -4
  498. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-commit.d.ts +19 -0
  499. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-commit.js +108 -0
  500. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-crud.d.ts +6 -2
  501. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-crud.js +54 -25
  502. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-goal-factory.d.ts +10 -3
  503. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-goal-factory.js +38 -31
  504. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-io.d.ts +10 -7
  505. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-io.js +121 -100
  506. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-log.d.ts +16 -0
  507. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-log.js +115 -0
  508. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-missing-recovery.d.ts +18 -0
  509. package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-missing-recovery.js +41 -0
  510. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-aggregate.d.ts +7 -0
  511. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-aggregate.js +9 -0
  512. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-artifacts.d.ts +12 -0
  513. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-artifacts.js +104 -0
  514. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-fields.d.ts +13 -1
  515. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-fields.js +65 -9
  516. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-verdicts.js +5 -1
  517. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate.d.ts +4 -2
  518. package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate.js +72 -117
  519. package/packages/omo-codex/plugin/components/ulw-loop/dist/review-blockers.d.ts +2 -0
  520. package/packages/omo-codex/plugin/components/ulw-loop/dist/review-blockers.js +25 -13
  521. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/factory.d.ts +2 -0
  522. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/factory.js +157 -0
  523. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/manifest.d.ts +381 -0
  524. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/manifest.js +127 -0
  525. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/types.d.ts +130 -0
  526. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/types.js +1 -0
  527. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk.d.ts +3 -0
  528. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk.js +3 -0
  529. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-budget-io.d.ts +5 -0
  530. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-budget-io.js +67 -0
  531. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-guard.d.ts +7 -1
  532. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-guard.js +188 -59
  533. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-role-guard.d.ts +2 -0
  534. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-role-guard.js +22 -0
  535. package/packages/omo-codex/plugin/components/ulw-loop/dist/state-lock.d.ts +19 -0
  536. package/packages/omo-codex/plugin/components/ulw-loop/dist/state-lock.js +259 -0
  537. package/packages/omo-codex/plugin/components/ulw-loop/dist/status-next-actions.d.ts +7 -0
  538. package/packages/omo-codex/plugin/components/ulw-loop/dist/status-next-actions.js +41 -0
  539. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-batch.js +4 -4
  540. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-mutations.d.ts +3 -2
  541. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-mutations.js +4 -4
  542. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-types.d.ts +9 -1
  543. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering.d.ts +3 -2
  544. package/packages/omo-codex/plugin/components/ulw-loop/dist/steering.js +11 -11
  545. package/packages/omo-codex/plugin/components/ulw-loop/dist/stop-resume-hook.js +28 -23
  546. package/packages/omo-codex/plugin/components/ulw-loop/dist/success-criteria-input.d.ts +9 -0
  547. package/packages/omo-codex/plugin/components/ulw-loop/dist/success-criteria-input.js +41 -0
  548. package/packages/omo-codex/plugin/components/ulw-loop/dist/surface.d.ts +19 -0
  549. package/packages/omo-codex/plugin/components/ulw-loop/dist/surface.js +83 -0
  550. package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +18 -5
  551. package/packages/omo-codex/plugin/components/ulw-loop/package.json +6 -6
  552. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/SKILL.md +7 -2
  553. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +33 -10
  554. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-codex-validation.ts +52 -0
  555. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-continuation.ts +8 -6
  556. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-reconciliation.ts +5 -98
  557. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-template.ts +134 -0
  558. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint.ts +59 -77
  559. package/packages/omo-codex/plugin/components/ulw-loop/src/cli-arg-parser.ts +10 -4
  560. package/packages/omo-codex/plugin/components/ulw-loop/src/cli-commands.ts +24 -8
  561. package/packages/omo-codex/plugin/components/ulw-loop/src/cli-output.ts +14 -1
  562. package/packages/omo-codex/plugin/components/ulw-loop/src/cli-subcommands.ts +52 -46
  563. package/packages/omo-codex/plugin/components/ulw-loop/src/cli.ts +8 -6
  564. package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-instruction.ts +35 -7
  565. package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-snapshot.ts +51 -33
  566. package/packages/omo-codex/plugin/components/ulw-loop/src/codex-hook.ts +3 -1
  567. package/packages/omo-codex/plugin/components/ulw-loop/src/constants.ts +1 -0
  568. package/packages/omo-codex/plugin/components/ulw-loop/src/domain-types.ts +27 -9
  569. package/packages/omo-codex/plugin/components/ulw-loop/src/driver-objective-ack.ts +20 -0
  570. package/packages/omo-codex/plugin/components/ulw-loop/src/evidence-artifacts.ts +45 -0
  571. package/packages/omo-codex/plugin/components/ulw-loop/src/evidence.ts +23 -16
  572. package/packages/omo-codex/plugin/components/ulw-loop/src/ledger.ts +38 -0
  573. package/packages/omo-codex/plugin/components/ulw-loop/src/paths.ts +32 -4
  574. package/packages/omo-codex/plugin/components/ulw-loop/src/plan-commit.ts +132 -0
  575. package/packages/omo-codex/plugin/components/ulw-loop/src/plan-crud.ts +67 -54
  576. package/packages/omo-codex/plugin/components/ulw-loop/src/plan-goal-factory.ts +63 -31
  577. package/packages/omo-codex/plugin/components/ulw-loop/src/plan-io.ts +140 -119
  578. package/packages/omo-codex/plugin/components/ulw-loop/src/plan-log.ts +112 -0
  579. package/packages/omo-codex/plugin/components/ulw-loop/src/plan-missing-recovery.ts +61 -0
  580. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-aggregate.ts +11 -0
  581. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-artifacts.ts +123 -0
  582. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-fields.ts +71 -15
  583. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-verdicts.ts +6 -1
  584. package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate.ts +92 -136
  585. package/packages/omo-codex/plugin/components/ulw-loop/src/review-blockers.ts +38 -13
  586. package/packages/omo-codex/plugin/components/ulw-loop/src/sdk/factory.ts +218 -0
  587. package/packages/omo-codex/plugin/components/ulw-loop/src/sdk/manifest.ts +156 -0
  588. package/packages/omo-codex/plugin/components/ulw-loop/src/sdk/types.ts +143 -0
  589. package/packages/omo-codex/plugin/components/ulw-loop/src/sdk.ts +3 -0
  590. package/packages/omo-codex/plugin/components/ulw-loop/src/spawn-budget-io.ts +59 -0
  591. package/packages/omo-codex/plugin/components/ulw-loop/src/spawn-guard.ts +196 -52
  592. package/packages/omo-codex/plugin/components/ulw-loop/src/spawn-role-guard.ts +22 -0
  593. package/packages/omo-codex/plugin/components/ulw-loop/src/state-lock.ts +257 -0
  594. package/packages/omo-codex/plugin/components/ulw-loop/src/status-next-actions.ts +45 -0
  595. package/packages/omo-codex/plugin/components/ulw-loop/src/steering-batch.ts +4 -4
  596. package/packages/omo-codex/plugin/components/ulw-loop/src/steering-mutations.ts +5 -4
  597. package/packages/omo-codex/plugin/components/ulw-loop/src/steering-types.ts +13 -1
  598. package/packages/omo-codex/plugin/components/ulw-loop/src/steering.ts +12 -10
  599. package/packages/omo-codex/plugin/components/ulw-loop/src/stop-resume-hook.ts +27 -22
  600. package/packages/omo-codex/plugin/components/ulw-loop/src/success-criteria-input.ts +56 -0
  601. package/packages/omo-codex/plugin/components/ulw-loop/src/surface.ts +115 -0
  602. package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-continuation.test.ts +0 -1
  603. package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-final.test.ts +131 -82
  604. package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-template.test.ts +147 -0
  605. package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint.test.ts +16 -22
  606. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-checkpoint-continuation.test.ts +4 -2
  607. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-checkpoint.test.ts +31 -2
  608. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-commands.test.ts +2 -0
  609. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-complete-goals.test.ts +3 -1
  610. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-create-goals.test.ts +35 -8
  611. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-entrypoint.test.ts +38 -4
  612. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-json-errors.test.ts +27 -0
  613. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-scope-required.test.ts +144 -0
  614. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-status-next-actions.test.ts +185 -0
  615. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-steering-batch.test.ts +8 -3
  616. package/packages/omo-codex/plugin/components/ulw-loop/test/cli-validation-batch.test.ts +6 -0
  617. package/packages/omo-codex/plugin/components/ulw-loop/test/codex-goal-instruction.test.ts +37 -2
  618. package/packages/omo-codex/plugin/components/ulw-loop/test/codex-goal-snapshot.test.ts +88 -11
  619. package/packages/omo-codex/plugin/components/ulw-loop/test/codex-hook.test.ts +0 -3
  620. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/barrier.ts +13 -0
  621. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/cli-session.ts +4 -0
  622. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-child.ts +65 -0
  623. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-cli-qa.mjs +76 -0
  624. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-crash.ts +23 -0
  625. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-mutations.mjs +58 -0
  626. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-writer.ts +65 -0
  627. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/lease-clock.ts +23 -0
  628. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/quality-gate-builder.ts +9 -4
  629. package/packages/omo-codex/plugin/components/ulw-loop/test/guided-recovery.test.ts +67 -0
  630. package/packages/omo-codex/plugin/components/ulw-loop/test/package-smoke.test.ts +5 -37
  631. package/packages/omo-codex/plugin/components/ulw-loop/test/paths.test.ts +9 -0
  632. package/packages/omo-codex/plugin/components/ulw-loop/test/plan-commit-log.test.ts +252 -0
  633. package/packages/omo-codex/plugin/components/ulw-loop/test/plan-commit-recovery.test.ts +190 -0
  634. package/packages/omo-codex/plugin/components/ulw-loop/test/plan-io-cross-process.test.ts +106 -0
  635. package/packages/omo-codex/plugin/components/ulw-loop/test/plan-io.test.ts +74 -25
  636. package/packages/omo-codex/plugin/components/ulw-loop/test/plan-log-legacy-projection.test.ts +228 -0
  637. package/packages/omo-codex/plugin/components/ulw-loop/test/plan-log-newest.test.ts +72 -0
  638. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-aggregate-basics.test.ts +258 -0
  639. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-cap-and-dedupe.test.ts +22 -0
  640. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-fields-messages.test.ts +98 -0
  641. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-lazycodex-surface.test.ts +93 -0
  642. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-poisoning-cascades.test.ts +97 -0
  643. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-roles.test.ts +51 -2
  644. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-senpi-surface.test.ts +131 -0
  645. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-single-report.test.ts +241 -0
  646. package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate.test.ts +58 -3
  647. package/packages/omo-codex/plugin/components/ulw-loop/test/review-blockers.test.ts +9 -7
  648. package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-completed-plan.test.ts +43 -0
  649. package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-contract.test.ts +137 -0
  650. package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-driver-states.test.ts +174 -0
  651. package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-dx.test.ts +219 -0
  652. package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-session-context.test.ts +169 -0
  653. package/packages/omo-codex/plugin/components/ulw-loop/test/spawn-guard.test.ts +450 -7
  654. package/packages/omo-codex/plugin/components/ulw-loop/test/spawn-role-matrix.test.ts +113 -0
  655. package/packages/omo-codex/plugin/components/ulw-loop/test/state-lock.test.ts +310 -0
  656. package/packages/omo-codex/plugin/components/ulw-loop/test/status-next-actions-surface.test.ts +133 -0
  657. package/packages/omo-codex/plugin/components/ulw-loop/test/steering-batch.test.ts +12 -12
  658. package/packages/omo-codex/plugin/components/ulw-loop/test/steering.test.ts +12 -6
  659. package/packages/omo-codex/plugin/components/ulw-loop/test/stop-resume-hook.test.ts +1 -1
  660. package/packages/omo-codex/plugin/components/ulw-loop/test/surface.test.ts +74 -0
  661. package/packages/omo-codex/plugin/components/ulw-loop/test/ultrawork-directive.test.ts +13 -8
  662. package/packages/omo-codex/plugin/components/ulw-loop/vitest.config.ts +1 -0
  663. package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
  664. package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
  665. package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
  666. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
  667. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
  668. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
  669. package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
  670. package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +18 -0
  671. package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
  672. package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
  673. package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
  674. package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
  675. package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
  676. package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
  677. package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
  678. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +17 -0
  679. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
  680. package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
  681. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
  682. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
  683. package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
  684. package/packages/omo-codex/plugin/model-catalog.json +16 -7
  685. package/packages/omo-codex/plugin/package-lock.json +676 -524
  686. package/packages/omo-codex/plugin/package.json +2 -3
  687. package/packages/omo-codex/plugin/scripts/AGENTS.md +39 -0
  688. package/packages/omo-codex/plugin/scripts/auto-update-plan.mjs +1 -2
  689. package/packages/omo-codex/plugin/scripts/auto-update.mjs +0 -9
  690. package/packages/omo-codex/plugin/scripts/canonical-ultrawork-directive.mjs +17 -0
  691. package/packages/omo-codex/plugin/scripts/hook-status-message.mjs +0 -1
  692. package/packages/omo-codex/plugin/scripts/migrate-codex-config/catalog.mjs +16 -7
  693. package/packages/omo-codex/plugin/scripts/migrate-codex-config/multi-agent-v2-guard.mjs +8 -4
  694. package/packages/omo-codex/plugin/scripts/migrate-codex-config/subagent-limit-guard.mjs +19 -90
  695. package/packages/omo-codex/plugin/scripts/migrate-codex-config/toml-section-editor.mjs +1 -1
  696. package/packages/omo-codex/plugin/scripts/sync-skills.d.mts +4 -0
  697. package/packages/omo-codex/plugin/scripts/sync-skills.mjs +111 -64
  698. package/packages/omo-codex/plugin/shared/package.json +3 -4
  699. package/packages/omo-codex/plugin/shared/src/config-loader.ts +2 -102
  700. package/packages/omo-codex/plugin/shared/src/config-migration.ts +0 -1
  701. package/packages/omo-codex/plugin/shared/test/config-loader.test.ts +41 -130
  702. package/packages/omo-codex/plugin/skills/ast-grep/AGENTS.md +51 -0
  703. package/packages/omo-codex/plugin/skills/ast-grep/SKILL.md +13 -1
  704. package/packages/omo-codex/plugin/skills/coding-agent-sessions/AGENTS.md +62 -0
  705. package/packages/omo-codex/plugin/skills/coding-agent-sessions/SKILL.md +1 -1
  706. package/packages/omo-codex/plugin/skills/data-scientist/SKILL.md +99 -239
  707. package/packages/omo-codex/plugin/skills/data-scientist/references/execution-surfaces.md +91 -0
  708. package/packages/omo-codex/plugin/skills/data-scientist/references/placement.md +74 -0
  709. package/packages/omo-codex/plugin/skills/data-scientist/references/polars-lane.md +95 -0
  710. package/packages/omo-codex/plugin/skills/data-scientist/references/uv-setup.md +1 -1
  711. package/packages/omo-codex/plugin/skills/data-scientist/references/visualization.md +64 -0
  712. package/packages/omo-codex/plugin/skills/data-scientist/scripts/ensure-js-deps.sh +28 -0
  713. package/packages/omo-codex/plugin/skills/data-scientist/scripts/ensure-py-deps.sh +37 -0
  714. package/packages/omo-codex/plugin/skills/debugging/SKILL.md +3 -1
  715. package/packages/omo-codex/plugin/skills/debugging/references/methodology/00-setup.md +12 -0
  716. package/packages/omo-codex/plugin/skills/debugging/references/methodology/02-investigate.md +26 -5
  717. package/packages/omo-codex/plugin/skills/debugging/references/runtimes/go.md +15 -1
  718. package/packages/omo-codex/plugin/skills/debugging/references/runtimes/native-binary.md +38 -0
  719. package/packages/omo-codex/plugin/skills/debugging/references/runtimes/node.md +25 -0
  720. package/packages/omo-codex/plugin/skills/debugging/references/runtimes/python.md +13 -0
  721. package/packages/omo-codex/plugin/skills/debugging/references/runtimes/rust.md +41 -0
  722. package/packages/omo-codex/plugin/skills/debugging/references/scripts/dap.mjs +267 -0
  723. package/packages/omo-codex/plugin/skills/debugging/references/scripts/fixture-adapter.mjs +59 -0
  724. package/packages/omo-codex/plugin/skills/debugging/references/tools/dap.md +103 -0
  725. package/packages/omo-codex/plugin/skills/debugging/references/tools/frida.md +193 -0
  726. package/packages/omo-codex/plugin/skills/debugging/references/tools/playwright-cli.md +79 -161
  727. package/packages/omo-codex/plugin/skills/frontend/ATTRIBUTION.md +10 -0
  728. package/packages/omo-codex/plugin/skills/frontend/SKILL.md +7 -3
  729. package/packages/omo-codex/plugin/skills/frontend/references/design/README.md +10 -2
  730. package/packages/omo-codex/plugin/skills/frontend/references/design/_INDEX.md +1 -0
  731. package/packages/omo-codex/plugin/skills/frontend/references/design/ambience-skill.md +145 -0
  732. package/packages/omo-codex/plugin/skills/frontend/references/design/aside.md +1 -1
  733. package/packages/omo-codex/plugin/skills/frontend/references/design/clone-from-url.md +1 -1
  734. package/packages/omo-codex/plugin/skills/frontend/references/design/interaction-skill.md +2 -0
  735. package/packages/omo-codex/plugin/skills/frontend/references/design/print-paged-media.md +76 -0
  736. package/packages/omo-codex/plugin/skills/frontend/references/designpowers/README.md +1 -1
  737. package/packages/omo-codex/plugin/skills/frontend/references/designpowers/lane-a-direction.md +1 -1
  738. package/packages/omo-codex/plugin/skills/frontend/references/designpowers/lane-b-execution.md +11 -11
  739. package/packages/omo-codex/plugin/skills/frontend/references/designpowers/lane-d-memory.md +3 -3
  740. package/packages/omo-codex/plugin/skills/frontend/references/designpowers/orchestration.md +1 -1
  741. package/packages/omo-codex/plugin/skills/frontend/references/designpowers/routing.md +5 -5
  742. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/lighthouse-audit.py +2 -2
  743. package/packages/omo-codex/plugin/skills/git-master/SKILL.md +1 -1
  744. package/packages/omo-codex/plugin/skills/init-deep/SKILL.md +20 -18
  745. package/packages/omo-codex/plugin/skills/lcx-doctor/SKILL.md +4 -2
  746. package/packages/omo-codex/plugin/skills/lsp-setup/SKILL.md +1 -1
  747. package/packages/omo-codex/plugin/skills/programming/SKILL.md +1 -1
  748. package/packages/omo-codex/plugin/skills/refactor/SKILL.md +11 -9
  749. package/packages/omo-codex/plugin/skills/remove-ai-slops/SKILL.md +11 -9
  750. package/packages/omo-codex/plugin/skills/review-work/SKILL.md +116 -424
  751. package/packages/omo-codex/plugin/skills/ultimate-browsing/ATTRIBUTION.md +32 -86
  752. package/packages/omo-codex/plugin/skills/ultimate-browsing/SKILL.md +32 -27
  753. package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/AGENTS.md +111 -0
  754. package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/templates/package.json +2 -2
  755. package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/templates/playwright_mobile_chrome.js +5 -2
  756. package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/templates/playwright_real_chrome.js +8 -6
  757. package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/test_playwright_stealth.py +86 -0
  758. package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/test_playwright_templates.py +4 -7
  759. package/packages/omo-codex/plugin/skills/ultimate-browsing/references/chrome-stealth.md +86 -95
  760. package/packages/omo-codex/plugin/skills/ultimate-browsing/references/insane-search/README.md +18 -5
  761. package/packages/omo-codex/plugin/skills/ultimate-browsing/references/insane-search/playwright.md +16 -13
  762. package/packages/omo-codex/plugin/skills/ultimate-browsing/scripts/extract_cookies.py +3 -3
  763. package/packages/omo-codex/plugin/skills/ultrawork/SKILL.md +44 -27
  764. package/packages/omo-codex/plugin/skills/{start-work → ulw-execute}/SKILL.md +35 -36
  765. package/packages/omo-codex/plugin/skills/ulw-execute/agents/openai.yaml +2 -0
  766. package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +31 -2
  767. package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +33 -10
  768. package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +4 -5
  769. package/packages/omo-codex/plugin/skills/ulw-plan/references/full-workflow.md +5 -5
  770. package/packages/omo-codex/plugin/skills/ulw-plan/references/intent-unclear.md +2 -2
  771. package/packages/omo-codex/plugin/skills/ulw-plan/scripts/scaffold-plan.mjs +1 -0
  772. package/packages/omo-codex/plugin/skills/ulw-research/SKILL.md +16 -9
  773. package/packages/omo-codex/plugin/skills/visual-qa/AGENTS.md +58 -0
  774. package/packages/omo-codex/plugin/skills/visual-qa/SKILL.md +10 -7
  775. package/packages/omo-codex/plugin/skills/visual-qa/references/browser-setup.md +75 -0
  776. package/packages/omo-codex/plugin/test/AGENTS.md +47 -0
  777. package/packages/omo-codex/plugin/test/aggregate-agents.test.mjs +19 -173
  778. package/packages/omo-codex/plugin/test/aggregate-hooks.test.mjs +16 -51
  779. package/packages/omo-codex/plugin/test/aggregate-manifest.test.mjs +2 -3
  780. package/packages/omo-codex/plugin/test/aggregate-mcp.test.mjs +2 -7
  781. package/packages/omo-codex/plugin/test/aggregate-model-catalog.test.mjs +14 -4
  782. package/packages/omo-codex/plugin/test/aggregate-plugin-fixture.mjs +175 -13
  783. package/packages/omo-codex/plugin/test/aggregate.test.mjs +78 -2
  784. package/packages/omo-codex/plugin/test/auto-update-release-notes.test.mjs +19 -33
  785. package/packages/omo-codex/plugin/test/auto-update.test.mjs +4 -29
  786. package/packages/omo-codex/plugin/test/bootstrap-default-role.test.mjs +66 -0
  787. package/packages/omo-codex/plugin/test/bootstrap-setup.test.mjs +0 -31
  788. package/packages/omo-codex/plugin/test/canonical-ultrawork-directive.test.mjs +53 -0
  789. package/packages/omo-codex/plugin/test/component-bin-names.test.mjs +2 -2
  790. package/packages/omo-codex/plugin/test/component-bundled-cli.test.mjs +1 -51
  791. package/packages/omo-codex/plugin/test/component-hook-contract-cases.mjs +100 -2
  792. package/packages/omo-codex/plugin/test/hook-status-message.test.mjs +5 -6
  793. package/packages/omo-codex/plugin/test/lcx-contribute-bug-fix-template.test.mjs +21 -27
  794. package/packages/omo-codex/plugin/test/mcp-research-servers.test.mjs +1 -3
  795. package/packages/omo-codex/plugin/test/migrate-codex-config.test.mjs +35 -35
  796. package/packages/omo-codex/plugin/test/multi-agent-v2-regression.test.mjs +1 -1
  797. package/packages/omo-codex/plugin/test/scaffold-plan.test.mjs +0 -36
  798. package/packages/omo-codex/plugin/test/subagent-limit-migration.test.mjs +107 -15
  799. package/packages/omo-codex/plugin/test/sync-skills-codex-compatibility.test.mjs +168 -0
  800. package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +54 -24
  801. package/packages/omo-codex/plugin/test/sync-skills.test.mjs +18 -119
  802. package/packages/omo-codex/plugin/test/teammode-archive-ambiguity.test.mjs +0 -40
  803. package/packages/omo-codex/plugin/test/teammode-communication.test.mjs +6 -62
  804. package/packages/omo-codex/plugin/test/teammode-thread-links.test.mjs +3 -36
  805. package/packages/omo-codex/plugin/test/teammode-transport.test.mjs +0 -44
  806. package/packages/omo-codex/plugin/test/teammode-worktree.test.mjs +2 -6
  807. package/packages/omo-codex/plugin/test/ultrawork-skill-pointer.test.mjs +5 -5
  808. package/packages/omo-codex/plugin/test/ulw-plan-review-state-contract.test.mjs +0 -3
  809. package/packages/omo-codex/scripts/AGENTS.md +36 -0
  810. package/packages/omo-codex/scripts/check-model-catalog-parity.mjs +42 -0
  811. package/packages/omo-codex/scripts/install-cache-copy.test.mjs +27 -1
  812. package/packages/omo-codex/scripts/install-config-autonomous-features.test.mjs +1 -1
  813. package/packages/omo-codex/scripts/install-config-autonomous.test.mjs +2 -1
  814. package/packages/omo-codex/scripts/install-config-git-bash.test.mjs +0 -23
  815. package/packages/omo-codex/scripts/install-config-reasoning.test.mjs +5 -5
  816. package/packages/omo-codex/scripts/install-config.test.mjs +15 -17
  817. package/packages/omo-codex/scripts/install-dist/install-local.mjs +9832 -1445
  818. package/packages/omo-codex/scripts/install-generated-bundle.test.mjs +3 -4
  819. package/packages/omo-codex/scripts/install-git-bash-mcp-env.test.mjs +1 -25
  820. package/packages/omo-codex/scripts/install-lazycodex-version-stamp.test.mjs +7 -2
  821. package/packages/omo-codex/scripts/install-mcp-runtime.test.mjs +0 -36
  822. package/packages/omo-codex/scripts/install-packaged-local.test.mjs +1 -6
  823. package/packages/{omo-codex/plugin/components/ultrawork/skills/ultrawork/SKILL.md → prompts-core/prompts/ultrawork/codex.md} +44 -34
  824. package/packages/shared-skills/package.json +7 -1
  825. package/packages/shared-skills/skill-source-filter.d.ts +16 -0
  826. package/packages/shared-skills/skill-source-filter.mjs +44 -0
  827. package/packages/shared-skills/skills/ast-grep/AGENTS.md +51 -0
  828. package/packages/shared-skills/skills/ast-grep/SKILL.md +13 -1
  829. package/packages/shared-skills/skills/coding-agent-sessions/AGENTS.md +62 -0
  830. package/packages/shared-skills/skills/coding-agent-sessions/SKILL.md +1 -1
  831. package/packages/shared-skills/skills/data-scientist/SKILL.md +99 -239
  832. package/packages/shared-skills/skills/data-scientist/references/execution-surfaces.md +91 -0
  833. package/packages/shared-skills/skills/data-scientist/references/placement.md +74 -0
  834. package/packages/shared-skills/skills/data-scientist/references/polars-lane.md +95 -0
  835. package/packages/shared-skills/skills/data-scientist/references/uv-setup.md +1 -1
  836. package/packages/shared-skills/skills/data-scientist/references/visualization.md +64 -0
  837. package/packages/shared-skills/skills/data-scientist/scripts/ensure-js-deps.sh +28 -0
  838. package/packages/shared-skills/skills/data-scientist/scripts/ensure-py-deps.sh +37 -0
  839. package/packages/shared-skills/skills/debugging/SKILL.md +3 -1
  840. package/packages/shared-skills/skills/debugging/references/methodology/00-setup.md +12 -0
  841. package/packages/shared-skills/skills/debugging/references/methodology/02-investigate.md +26 -5
  842. package/packages/shared-skills/skills/debugging/references/runtimes/go.md +15 -1
  843. package/packages/shared-skills/skills/debugging/references/runtimes/native-binary.md +38 -0
  844. package/packages/shared-skills/skills/debugging/references/runtimes/node.md +25 -0
  845. package/packages/shared-skills/skills/debugging/references/runtimes/python.md +13 -0
  846. package/packages/shared-skills/skills/debugging/references/runtimes/rust.md +41 -0
  847. package/packages/shared-skills/skills/debugging/references/scripts/dap.mjs +267 -0
  848. package/packages/shared-skills/skills/debugging/references/scripts/dap.test.ts +86 -0
  849. package/packages/shared-skills/skills/debugging/references/scripts/fixture-adapter.mjs +59 -0
  850. package/packages/shared-skills/skills/debugging/references/tools/dap.md +103 -0
  851. package/packages/shared-skills/skills/debugging/references/tools/frida.md +193 -0
  852. package/packages/shared-skills/skills/debugging/references/tools/playwright-cli.md +79 -161
  853. package/packages/shared-skills/skills/frontend/ATTRIBUTION.md +10 -0
  854. package/packages/shared-skills/skills/frontend/SKILL.md +7 -3
  855. package/packages/shared-skills/skills/frontend/references/design/README.md +10 -2
  856. package/packages/shared-skills/skills/frontend/references/design/_INDEX.md +1 -0
  857. package/packages/shared-skills/skills/frontend/references/design/ambience-skill.md +145 -0
  858. package/packages/shared-skills/skills/frontend/references/design/aside.md +1 -1
  859. package/packages/shared-skills/skills/frontend/references/design/clone-from-url.md +1 -1
  860. package/packages/shared-skills/skills/frontend/references/design/interaction-skill.md +2 -0
  861. package/packages/shared-skills/skills/frontend/references/design/print-paged-media.md +76 -0
  862. package/packages/shared-skills/skills/frontend/references/designpowers/README.md +1 -1
  863. package/packages/shared-skills/skills/frontend/references/designpowers/lane-a-direction.md +1 -1
  864. package/packages/shared-skills/skills/frontend/references/designpowers/lane-b-execution.md +11 -11
  865. package/packages/shared-skills/skills/frontend/references/designpowers/lane-d-memory.md +3 -3
  866. package/packages/shared-skills/skills/frontend/references/designpowers/orchestration.md +1 -1
  867. package/packages/shared-skills/skills/frontend/references/designpowers/routing.md +5 -5
  868. package/packages/shared-skills/skills/frontend/scripts/perfection/lighthouse-audit.py +2 -2
  869. package/packages/shared-skills/skills/git-master/SKILL.md +1 -1
  870. package/packages/shared-skills/skills/init-deep/SKILL.md +14 -14
  871. package/packages/shared-skills/skills/lsp-setup/SKILL.md +1 -1
  872. package/packages/shared-skills/skills/programming/SKILL.md +1 -1
  873. package/packages/shared-skills/skills/refactor/SKILL.md +5 -5
  874. package/packages/shared-skills/skills/remove-ai-slops/SKILL.md +5 -5
  875. package/packages/shared-skills/skills/review-work/SKILL.md +101 -419
  876. package/packages/shared-skills/skills/ultimate-browsing/ATTRIBUTION.md +32 -86
  877. package/packages/shared-skills/skills/ultimate-browsing/SKILL.md +32 -27
  878. package/packages/shared-skills/skills/ultimate-browsing/engine/AGENTS.md +111 -0
  879. package/packages/shared-skills/skills/ultimate-browsing/engine/templates/package.json +2 -2
  880. package/packages/shared-skills/skills/ultimate-browsing/engine/templates/playwright_mobile_chrome.js +5 -2
  881. package/packages/shared-skills/skills/ultimate-browsing/engine/templates/playwright_real_chrome.js +8 -6
  882. package/packages/shared-skills/skills/ultimate-browsing/engine/tests/test_playwright_stealth.py +86 -0
  883. package/packages/shared-skills/skills/ultimate-browsing/engine/tests/test_playwright_templates.py +4 -7
  884. package/packages/shared-skills/skills/ultimate-browsing/references/chrome-stealth.md +86 -95
  885. package/packages/shared-skills/skills/ultimate-browsing/references/insane-search/README.md +18 -5
  886. package/packages/shared-skills/skills/ultimate-browsing/references/insane-search/playwright.md +16 -13
  887. package/packages/shared-skills/skills/ultimate-browsing/scripts/extract_cookies.py +3 -3
  888. package/packages/shared-skills/skills/{start-work → ulw-execute}/SKILL.md +24 -22
  889. package/packages/shared-skills/skills/ulw-plan/SKILL.md +5 -6
  890. package/packages/shared-skills/skills/ulw-plan/references/full-workflow.md +6 -5
  891. package/packages/shared-skills/skills/ulw-plan/references/intent-unclear.md +2 -2
  892. package/packages/shared-skills/skills/ulw-plan/scripts/scaffold-plan.mjs +2 -1
  893. package/packages/shared-skills/skills/ulw-research/SKILL.md +10 -5
  894. package/packages/shared-skills/skills/visual-qa/AGENTS.md +58 -0
  895. package/packages/shared-skills/skills/visual-qa/SKILL.md +4 -3
  896. package/packages/shared-skills/skills/visual-qa/references/browser-setup.md +75 -0
  897. package/postinstall.mjs +2 -0
  898. package/script/qa/web-terminal-visual-qa.mjs +2 -0
  899. package/script/qa/xterm-live-terminal.mjs +18 -2
  900. package/.agents/skills/work-with-pr-workspace/evals/evals.json +0 -76
  901. package/.agents/skills/work-with-pr-workspace/iteration-1/benchmark.json +0 -138
  902. package/.agents/skills/work-with-pr-workspace/iteration-1/benchmark.md +0 -42
  903. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/eval_metadata.json +0 -57
  904. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/grading.json +0 -15
  905. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/code-changes.md +0 -454
  906. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/execution-plan.md +0 -136
  907. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/pr-description.md +0 -47
  908. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/verification-strategy.md +0 -163
  909. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/timing.json +0 -1
  910. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/grading.json +0 -15
  911. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/code-changes.md +0 -615
  912. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/execution-plan.md +0 -99
  913. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/pr-description.md +0 -50
  914. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/verification-strategy.md +0 -111
  915. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/timing.json +0 -1
  916. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/eval_metadata.json +0 -37
  917. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/grading.json +0 -11
  918. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/code-changes.md +0 -205
  919. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/execution-plan.md +0 -78
  920. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/pr-description.md +0 -42
  921. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/verification-strategy.md +0 -87
  922. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/timing.json +0 -1
  923. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/grading.json +0 -11
  924. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/code-changes.md +0 -334
  925. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/execution-plan.md +0 -86
  926. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/pr-description.md +0 -23
  927. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/verification-strategy.md +0 -119
  928. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/timing.json +0 -1
  929. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/eval_metadata.json +0 -32
  930. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/grading.json +0 -10
  931. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/code-changes.md +0 -221
  932. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/execution-plan.md +0 -104
  933. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/pr-description.md +0 -41
  934. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/verification-strategy.md +0 -84
  935. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/timing.json +0 -1
  936. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/grading.json +0 -10
  937. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/code-changes.md +0 -342
  938. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/execution-plan.md +0 -131
  939. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/pr-description.md +0 -39
  940. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/verification-strategy.md +0 -128
  941. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/timing.json +0 -1
  942. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/eval_metadata.json +0 -32
  943. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/grading.json +0 -10
  944. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/code-changes.md +0 -143
  945. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/execution-plan.md +0 -82
  946. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/pr-description.md +0 -51
  947. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/verification-strategy.md +0 -69
  948. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/timing.json +0 -1
  949. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/grading.json +0 -10
  950. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/code-changes.md +0 -252
  951. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/execution-plan.md +0 -83
  952. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/pr-description.md +0 -33
  953. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/verification-strategy.md +0 -101
  954. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/timing.json +0 -1
  955. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/eval_metadata.json +0 -32
  956. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/grading.json +0 -10
  957. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/code-changes.md +0 -387
  958. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/execution-plan.md +0 -112
  959. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/pr-description.md +0 -51
  960. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/verification-strategy.md +0 -75
  961. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/timing.json +0 -1
  962. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/grading.json +0 -10
  963. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/code-changes.md +0 -529
  964. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/execution-plan.md +0 -127
  965. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/pr-description.md +0 -42
  966. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/verification-strategy.md +0 -120
  967. package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/timing.json +0 -1
  968. package/.agents/skills/work-with-pr-workspace/iteration-1/review.html +0 -1326
  969. package/.opencode/skills/work-with-pr-workspace/evals/evals.json +0 -76
  970. package/.opencode/skills/work-with-pr-workspace/iteration-1/benchmark.json +0 -138
  971. package/.opencode/skills/work-with-pr-workspace/iteration-1/benchmark.md +0 -42
  972. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/eval_metadata.json +0 -57
  973. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/grading.json +0 -15
  974. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/code-changes.md +0 -454
  975. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/execution-plan.md +0 -136
  976. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/pr-description.md +0 -47
  977. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/verification-strategy.md +0 -163
  978. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/timing.json +0 -1
  979. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/grading.json +0 -15
  980. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/code-changes.md +0 -615
  981. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/execution-plan.md +0 -99
  982. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/pr-description.md +0 -50
  983. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/verification-strategy.md +0 -111
  984. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/timing.json +0 -1
  985. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/eval_metadata.json +0 -37
  986. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/grading.json +0 -11
  987. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/code-changes.md +0 -205
  988. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/execution-plan.md +0 -78
  989. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/pr-description.md +0 -42
  990. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/verification-strategy.md +0 -87
  991. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/timing.json +0 -1
  992. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/grading.json +0 -11
  993. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/code-changes.md +0 -334
  994. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/execution-plan.md +0 -86
  995. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/pr-description.md +0 -23
  996. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/verification-strategy.md +0 -119
  997. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/timing.json +0 -1
  998. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/eval_metadata.json +0 -32
  999. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/grading.json +0 -10
  1000. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/code-changes.md +0 -221
  1001. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/execution-plan.md +0 -104
  1002. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/pr-description.md +0 -41
  1003. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/verification-strategy.md +0 -84
  1004. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/timing.json +0 -1
  1005. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/grading.json +0 -10
  1006. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/code-changes.md +0 -342
  1007. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/execution-plan.md +0 -131
  1008. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/pr-description.md +0 -39
  1009. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/verification-strategy.md +0 -128
  1010. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/timing.json +0 -1
  1011. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/eval_metadata.json +0 -32
  1012. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/grading.json +0 -10
  1013. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/code-changes.md +0 -143
  1014. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/execution-plan.md +0 -82
  1015. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/pr-description.md +0 -51
  1016. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/verification-strategy.md +0 -69
  1017. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/timing.json +0 -1
  1018. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/grading.json +0 -10
  1019. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/code-changes.md +0 -252
  1020. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/execution-plan.md +0 -83
  1021. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/pr-description.md +0 -33
  1022. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/verification-strategy.md +0 -101
  1023. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/timing.json +0 -1
  1024. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/eval_metadata.json +0 -32
  1025. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/grading.json +0 -10
  1026. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/code-changes.md +0 -387
  1027. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/execution-plan.md +0 -112
  1028. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/pr-description.md +0 -51
  1029. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/verification-strategy.md +0 -75
  1030. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/timing.json +0 -1
  1031. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/grading.json +0 -10
  1032. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/code-changes.md +0 -529
  1033. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/execution-plan.md +0 -127
  1034. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/pr-description.md +0 -42
  1035. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/verification-strategy.md +0 -120
  1036. package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/timing.json +0 -1
  1037. package/.opencode/skills/work-with-pr-workspace/iteration-1/review.html +0 -1326
  1038. package/dist/config/schema/codegraph.d.ts +0 -12
  1039. package/dist/config/schema/start-work.d.ts +0 -5
  1040. package/dist/features/builtin-commands/templates/start-work.d.ts +0 -1
  1041. package/dist/features/builtin-skills/index.d.ts +0 -1
  1042. package/dist/features/builtin-skills/skill-file-loader.d.ts +0 -1
  1043. package/dist/features/builtin-skills/skills/agent-browser-skill.d.ts +0 -1
  1044. package/dist/features/builtin-skills/skills/agent-browser-template.d.ts +0 -1
  1045. package/dist/features/builtin-skills/skills/debugging.d.ts +0 -1
  1046. package/dist/features/builtin-skills/skills/dev-browser.d.ts +0 -1
  1047. package/dist/features/builtin-skills/skills/frontend.d.ts +0 -1
  1048. package/dist/features/builtin-skills/skills/git-master-sections/commit-atomic-planning.d.ts +0 -1
  1049. package/dist/features/builtin-skills/skills/git-master-sections/commit-context-analysis.d.ts +0 -1
  1050. package/dist/features/builtin-skills/skills/git-master-sections/commit-execution-verification.d.ts +0 -1
  1051. package/dist/features/builtin-skills/skills/git-master-sections/commit-workflow.d.ts +0 -1
  1052. package/dist/features/builtin-skills/skills/git-master-sections/history-search-workflow.d.ts +0 -1
  1053. package/dist/features/builtin-skills/skills/git-master-sections/overview.d.ts +0 -1
  1054. package/dist/features/builtin-skills/skills/git-master-sections/quick-reference.d.ts +0 -1
  1055. package/dist/features/builtin-skills/skills/git-master-sections/rebase-workflow.d.ts +0 -1
  1056. package/dist/features/builtin-skills/skills/git-master-skill-metadata.d.ts +0 -1
  1057. package/dist/features/builtin-skills/skills/git-master.d.ts +0 -1
  1058. package/dist/features/builtin-skills/skills/index.d.ts +0 -1
  1059. package/dist/features/builtin-skills/skills/init-deep.d.ts +0 -1
  1060. package/dist/features/builtin-skills/skills/playwright-cli.d.ts +0 -1
  1061. package/dist/features/builtin-skills/skills/playwright-mcp-skill.d.ts +0 -1
  1062. package/dist/features/builtin-skills/skills/playwright.d.ts +0 -1
  1063. package/dist/features/builtin-skills/skills/remove-ai-slops.d.ts +0 -1
  1064. package/dist/features/builtin-skills/skills/review-work.d.ts +0 -1
  1065. package/dist/features/builtin-skills/skills/security-research.d.ts +0 -1
  1066. package/dist/features/builtin-skills/skills/security-review.d.ts +0 -1
  1067. package/dist/features/builtin-skills/skills/team-mode.d.ts +0 -1
  1068. package/dist/features/builtin-skills/skills/visual-qa.d.ts +0 -1
  1069. package/dist/features/builtin-skills/skills.d.ts +0 -1
  1070. package/dist/features/builtin-skills/types.d.ts +0 -1
  1071. package/dist/features/claude-code-plugin-loader/agent-loader.d.ts +0 -1
  1072. package/dist/features/claude-code-plugin-loader/command-loader.d.ts +0 -1
  1073. package/dist/features/claude-code-plugin-loader/discovery-core.d.ts +0 -1
  1074. package/dist/features/claude-code-plugin-loader/discovery-paths.d.ts +0 -1
  1075. package/dist/features/claude-code-plugin-loader/discovery.d.ts +0 -1
  1076. package/dist/features/claude-code-plugin-loader/hook-loader.d.ts +0 -1
  1077. package/dist/features/claude-code-plugin-loader/index.d.ts +0 -1
  1078. package/dist/features/claude-code-plugin-loader/install-path-resolver.d.ts +0 -1
  1079. package/dist/features/claude-code-plugin-loader/installed-plugin-database.d.ts +0 -1
  1080. package/dist/features/claude-code-plugin-loader/loaded-plugin.d.ts +0 -1
  1081. package/dist/features/claude-code-plugin-loader/loader.d.ts +0 -1
  1082. package/dist/features/claude-code-plugin-loader/mcp-server-loader.d.ts +0 -1
  1083. package/dist/features/claude-code-plugin-loader/plugin-key.d.ts +0 -1
  1084. package/dist/features/claude-code-plugin-loader/plugin-manifest.d.ts +0 -1
  1085. package/dist/features/claude-code-plugin-loader/plugin-path-resolver.d.ts +0 -1
  1086. package/dist/features/claude-code-plugin-loader/plugin-settings.d.ts +0 -1
  1087. package/dist/features/claude-code-plugin-loader/scope-filter.d.ts +0 -1
  1088. package/dist/features/claude-code-plugin-loader/skill-loader.d.ts +0 -1
  1089. package/dist/features/claude-code-plugin-loader/types.d.ts +0 -1
  1090. package/dist/hooks/codegraph-bootstrap/command-runner.d.ts +0 -17
  1091. package/dist/hooks/codegraph-bootstrap/hook.d.ts +0 -35
  1092. package/dist/hooks/codegraph-bootstrap/index.d.ts +0 -1
  1093. package/dist/hooks/codegraph-bootstrap/project-root.d.ts +0 -1
  1094. package/dist/hooks/codegraph-bootstrap/status.d.ts +0 -11
  1095. package/dist/hooks/ralph-loop/completion-promise-detector-test-input.d.ts +0 -11
  1096. package/dist/hooks/ralph-loop/loop-session-recovery.d.ts +0 -7
  1097. package/dist/hooks/start-work/start-work-hook.d.ts +0 -23
  1098. package/dist/mcp/codegraph.d.ts +0 -16
  1099. package/dist/plugin/chat-message/start-work-message.d.ts +0 -5
  1100. package/dist/shared/prompt-async-gate/message-inspection-error.d.ts +0 -1
  1101. package/dist/shared/prompt-async-gate/pending-tool-turn.d.ts +0 -1
  1102. package/dist/shared/prompt-async-gate/prompt-message-state.d.ts +0 -1
  1103. package/dist/shared/prompt-async-gate/queue.d.ts +0 -1
  1104. package/dist/shared/prompt-async-gate/recent-dispatches.d.ts +0 -1
  1105. package/dist/shared/prompt-async-gate/reservations.d.ts +0 -1
  1106. package/dist/shared/prompt-async-gate/semantic-dedupe.d.ts +0 -1
  1107. package/dist/shared/prompt-async-gate/session-idle-dispatch.d.ts +0 -1
  1108. package/dist/shared/prompt-async-gate/timing.d.ts +0 -1
  1109. package/dist/shared/prompt-async-gate/types.d.ts +0 -1
  1110. package/dist/skills/data-scientist/references/common-scenarios.md +0 -176
  1111. package/dist/skills/data-scientist/references/execution-templates.md +0 -197
  1112. package/dist/skills/data-scientist/references/integration-patterns.md +0 -153
  1113. package/dist/skills/data-scientist/references/performance-benchmarks.md +0 -37
  1114. package/dist/skills/visual-qa/references/agent-browser-setup.md +0 -45
  1115. package/dist/tools/call-omo-agent/background-agent-executor.d.ts +0 -5
  1116. package/dist/tools/call-omo-agent/message-storage-directory.d.ts +0 -1
  1117. package/dist/tools/delegate-task/anthropic-categories.d.ts +0 -2
  1118. package/dist/tools/delegate-task/model-string-parser.d.ts +0 -1
  1119. package/packages/lsp-tools-mcp/dist/lsp/cleanup-errors.d.ts +0 -1
  1120. package/packages/lsp-tools-mcp/dist/lsp/constants.d.ts +0 -1
  1121. package/packages/lsp-tools-mcp/dist/lsp/language-mappings.d.ts +0 -1
  1122. package/packages/lsp-tools-mcp/dist/lsp/process-signal-cleanup.d.ts +0 -1
  1123. package/packages/lsp-tools-mcp/dist/missing-dependency-result.d.ts +0 -1
  1124. package/packages/omo-codex/plugin/components/codegraph/AGENTS.md +0 -58
  1125. package/packages/omo-codex/plugin/components/codegraph/NODE-RUNTIME-LICENSES.md +0 -2951
  1126. package/packages/omo-codex/plugin/components/codegraph/NOTICE +0 -16
  1127. package/packages/omo-codex/plugin/components/codegraph/dist/cli.js +0 -12244
  1128. package/packages/omo-codex/plugin/components/codegraph/dist/serve.js +0 -9842
  1129. package/packages/omo-codex/plugin/components/codegraph/package.json +0 -33
  1130. package/packages/omo-codex/plugin/components/codegraph/src/cache-gc.ts +0 -29
  1131. package/packages/omo-codex/plugin/components/codegraph/src/cli.ts +0 -79
  1132. package/packages/omo-codex/plugin/components/codegraph/src/hook-input.ts +0 -33
  1133. package/packages/omo-codex/plugin/components/codegraph/src/hook-sweep.ts +0 -25
  1134. package/packages/omo-codex/plugin/components/codegraph/src/hook-types.ts +0 -131
  1135. package/packages/omo-codex/plugin/components/codegraph/src/hook.ts +0 -258
  1136. package/packages/omo-codex/plugin/components/codegraph/src/mcp-bridge.ts +0 -309
  1137. package/packages/omo-codex/plugin/components/codegraph/src/mcp-unavailable.ts +0 -80
  1138. package/packages/omo-codex/plugin/components/codegraph/src/post-tool-use-hook.ts +0 -34
  1139. package/packages/omo-codex/plugin/components/codegraph/src/serve-invocation.ts +0 -29
  1140. package/packages/omo-codex/plugin/components/codegraph/src/serve.ts +0 -263
  1141. package/packages/omo-codex/plugin/components/codegraph/src/session-start-command.ts +0 -106
  1142. package/packages/omo-codex/plugin/components/codegraph/src/session-start-cooldown.ts +0 -145
  1143. package/packages/omo-codex/plugin/components/codegraph/src/session-start-hook-runtime.ts +0 -21
  1144. package/packages/omo-codex/plugin/components/codegraph/src/session-start-lock.ts +0 -139
  1145. package/packages/omo-codex/plugin/components/codegraph/src/session-start-outcome.ts +0 -15
  1146. package/packages/omo-codex/plugin/components/codegraph/src/session-start-paths.ts +0 -32
  1147. package/packages/omo-codex/plugin/components/codegraph/src/session-start-project.ts +0 -109
  1148. package/packages/omo-codex/plugin/components/codegraph/src/session-start-worker-result.ts +0 -148
  1149. package/packages/omo-codex/plugin/components/codegraph/src/session-start-worker.ts +0 -175
  1150. package/packages/omo-codex/plugin/components/codegraph/src/sweep-cli.ts +0 -81
  1151. package/packages/omo-codex/plugin/components/codegraph/test/cache-gc.test.ts +0 -34
  1152. package/packages/omo-codex/plugin/components/codegraph/test/hook-exclusion.test.ts +0 -112
  1153. package/packages/omo-codex/plugin/components/codegraph/test/hook-registration.test.ts +0 -26
  1154. package/packages/omo-codex/plugin/components/codegraph/test/hook-session-start-guard.test.ts +0 -160
  1155. package/packages/omo-codex/plugin/components/codegraph/test/hook-store-upgrade.test.ts +0 -50
  1156. package/packages/omo-codex/plugin/components/codegraph/test/hook-sweep.test.ts +0 -29
  1157. package/packages/omo-codex/plugin/components/codegraph/test/hook.test.ts +0 -320
  1158. package/packages/omo-codex/plugin/components/codegraph/test/mcp-bridge-fixtures.ts +0 -172
  1159. package/packages/omo-codex/plugin/components/codegraph/test/package-runtime.test.ts +0 -91
  1160. package/packages/omo-codex/plugin/components/codegraph/test/provisioned-node-guard.test.ts +0 -100
  1161. package/packages/omo-codex/plugin/components/codegraph/test/serve-built-wrapper.test.ts +0 -76
  1162. package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-bridge-lifecycle.test.ts +0 -133
  1163. package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-bridge.test.ts +0 -245
  1164. package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-facade.test.ts +0 -69
  1165. package/packages/omo-codex/plugin/components/codegraph/test/serve-node-support.test.ts +0 -43
  1166. package/packages/omo-codex/plugin/components/codegraph/test/serve-provision.test.ts +0 -147
  1167. package/packages/omo-codex/plugin/components/codegraph/test/serve-unavailable.test.ts +0 -175
  1168. package/packages/omo-codex/plugin/components/codegraph/test/serve.test.ts +0 -385
  1169. package/packages/omo-codex/plugin/components/codegraph/test/session-start-node-support.test.ts +0 -206
  1170. package/packages/omo-codex/plugin/components/codegraph/test/session-start-project.test.ts +0 -58
  1171. package/packages/omo-codex/plugin/components/codegraph/test/session-start-state.test.ts +0 -104
  1172. package/packages/omo-codex/plugin/components/codegraph/test/session-start-trust-boundary.test.ts +0 -65
  1173. package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-availability.test.ts +0 -106
  1174. package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-cooldown.test.ts +0 -116
  1175. package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-flow.test.ts +0 -258
  1176. package/packages/omo-codex/plugin/components/codegraph/test/sweep-cli.test.ts +0 -56
  1177. package/packages/omo-codex/plugin/components/codegraph/tsconfig.build.json +0 -13
  1178. package/packages/omo-codex/plugin/components/codegraph/tsconfig.json +0 -25
  1179. package/packages/omo-codex/plugin/components/start-work-continuation/LICENSE +0 -21
  1180. package/packages/omo-codex/plugin/components/start-work-continuation/hooks/hooks.json +0 -28
  1181. package/packages/omo-codex/plugin/components/ultrawork/directive.md +0 -477
  1182. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-codegraph-init-guidance.json +0 -18
  1183. package/packages/omo-codex/plugin/hooks/session-start-checking-codegraph-bootstrap.json +0 -17
  1184. package/packages/omo-codex/plugin/hooks/stop-checking-start-work-continuation.json +0 -17
  1185. package/packages/omo-codex/plugin/hooks/subagent-stop-checking-start-work-continuation.json +0 -17
  1186. package/packages/omo-codex/plugin/scripts/migrate-omo-sot/editor.mjs +0 -125
  1187. package/packages/omo-codex/plugin/scripts/migrate-omo-sot/jsonc.mjs +0 -43
  1188. package/packages/omo-codex/plugin/scripts/migrate-omo-sot/scaffold.mjs +0 -29
  1189. package/packages/omo-codex/plugin/scripts/migrate-omo-sot.mjs +0 -121
  1190. package/packages/omo-codex/plugin/skills/data-scientist/references/common-scenarios.md +0 -176
  1191. package/packages/omo-codex/plugin/skills/data-scientist/references/execution-templates.md +0 -197
  1192. package/packages/omo-codex/plugin/skills/data-scientist/references/integration-patterns.md +0 -153
  1193. package/packages/omo-codex/plugin/skills/data-scientist/references/performance-benchmarks.md +0 -37
  1194. package/packages/omo-codex/plugin/skills/start-work/agents/openai.yaml +0 -2
  1195. package/packages/omo-codex/plugin/skills/visual-qa/references/agent-browser-setup.md +0 -45
  1196. package/packages/omo-codex/plugin/test/aggregate-skills.test.mjs +0 -92
  1197. package/packages/omo-codex/plugin/test/component-codegraph-mcp-smoke.test.mjs +0 -76
  1198. package/packages/omo-codex/plugin/test/migrate-omo-sot.test.mjs +0 -179
  1199. package/packages/omo-codex/plugin/test/sync-skills-orchestration.test.mjs +0 -314
  1200. package/packages/omo-codex/plugin/test/ulw-plan-scope-contract.test.mjs +0 -24
  1201. package/packages/shared-skills/skills/data-scientist/references/common-scenarios.md +0 -176
  1202. package/packages/shared-skills/skills/data-scientist/references/execution-templates.md +0 -197
  1203. package/packages/shared-skills/skills/data-scientist/references/integration-patterns.md +0 -153
  1204. package/packages/shared-skills/skills/data-scientist/references/performance-benchmarks.md +0 -37
  1205. package/packages/shared-skills/skills/visual-qa/references/agent-browser-setup.md +0 -45
  1206. /package/dist/hooks/{start-work → ulw-execute}/context-info-formatters.d.ts +0 -0
  1207. /package/dist/hooks/{start-work → ulw-execute}/explicit-plan-context.d.ts +0 -0
  1208. /package/dist/hooks/{start-work → ulw-execute}/notepad-scaffold.d.ts +0 -0
  1209. /package/dist/hooks/{start-work → ulw-execute}/parse-user-request.d.ts +0 -0
  1210. /package/dist/hooks/{start-work → ulw-execute}/plan-discovery-context.d.ts +0 -0
  1211. /package/dist/hooks/{start-work → ulw-execute}/plan-selection.d.ts +0 -0
  1212. /package/dist/hooks/{start-work → ulw-execute}/session-plan-affinity.d.ts +0 -0
  1213. /package/dist/hooks/{start-work → ulw-execute}/work-initializer.d.ts +0 -0
  1214. /package/dist/hooks/{start-work → ulw-execute}/worktree-block.d.ts +0 -0
  1215. /package/dist/hooks/{start-work → ulw-execute}/worktree-detector.d.ts +0 -0
  1216. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/.gitattributes +0 -0
  1217. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/CHANGELOG.md +0 -0
  1218. /package/packages/omo-codex/plugin/components/{codegraph → ulw-execute-continuation}/LICENSE +0 -0
  1219. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/plan-checklist.ts +0 -0
  1220. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/boulder-completed.json +0 -0
  1221. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/boulder-mixed-platforms.json +0 -0
  1222. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/boulder-single-codex-work.json +0 -0
  1223. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/plan-all-done.md +0 -0
  1224. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/plan-scaffold.md +0 -0
  1225. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/plan-with-nested-checkboxes.md +0 -0
  1226. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/plan-with-unchecked.md +0 -0
  1227. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/tsconfig.build.json +0 -0
  1228. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/tsconfig.json +0 -0
  1229. /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/vitest.config.ts +0 -0
@@ -1,21 +1,6 @@
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
- import { existsSync, mkdirSync as mkdirSync2, readFileSync } from "node:fs";
18
- import { basename, join } from "node:path";
2
+ import { existsSync, mkdirSync as mkdirSync3, readFileSync } from "node:fs";
3
+ import { basename, join as join2 } from "node:path";
19
4
 
20
5
  // ../../../../utils/src/atomic-write.ts
21
6
  import {
@@ -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
 
@@ -92,36 +92,82 @@ function resolveWritableDirectory(preferredDir, fallbackSuffix, osProvider) {
92
92
  }
93
93
  }
94
94
 
95
+ // ../../../../telemetry-core/src/day-claim.ts
96
+ import { closeSync as closeSync2, mkdirSync as mkdirSync2, openSync as openSync2, readdirSync, rmSync as rmSync2 } from "node:fs";
97
+ import { join } from "node:path";
98
+ var CLAIM_PREFIX = "daily-active.";
99
+ var CLAIM_SUFFIX = ".claim";
100
+ function getTelemetryDayClaimFilePath(stateDir, dayUTC) {
101
+ return join(stateDir, `${CLAIM_PREFIX}${dayUTC}${CLAIM_SUFFIX}`);
102
+ }
103
+ function claimUtcDay(stateDir, dayUTC) {
104
+ try {
105
+ mkdirSync2(stateDir, { recursive: true });
106
+ closeSync2(openSync2(getTelemetryDayClaimFilePath(stateDir, dayUTC), "wx"));
107
+ } catch (error) {
108
+ return error.code === "EEXIST" ? "already-claimed" : "unavailable";
109
+ }
110
+ pruneSupersededClaims(stateDir, dayUTC);
111
+ return "claimed";
112
+ }
113
+ function pruneSupersededClaims(stateDir, dayUTC) {
114
+ const currentClaim = `${CLAIM_PREFIX}${dayUTC}${CLAIM_SUFFIX}`;
115
+ let entries;
116
+ try {
117
+ entries = readdirSync(stateDir);
118
+ } catch {
119
+ return;
120
+ }
121
+ for (const entry of entries) {
122
+ if (entry === currentClaim)
123
+ continue;
124
+ if (!entry.startsWith(CLAIM_PREFIX) || !entry.endsWith(CLAIM_SUFFIX))
125
+ continue;
126
+ try {
127
+ rmSync2(join(stateDir, entry), { force: true });
128
+ } catch {}
129
+ }
130
+ }
131
+
95
132
  // ../../../../telemetry-core/src/activity-state.ts
96
133
  var POSTHOG_ACTIVITY_STATE_FILE = "posthog-activity.json";
134
+ var capturedDaysByStateDir = new Map;
97
135
  function resolveTelemetryStateDir(product, options = {}) {
98
136
  const dataDir = resolveXdgDataDir(product.cacheDirName, {
99
137
  env: options.env,
100
138
  osProvider: options.osProvider
101
139
  });
102
- const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined : join(options.env.XDG_DATA_HOME, product.cacheDirName);
140
+ const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined : join2(options.env.XDG_DATA_HOME, product.cacheDirName);
103
141
  if (dataDir === xdgStateDir || xdgStateDir === undefined && basename(dataDir) === product.cacheDirName) {
104
142
  return dataDir;
105
143
  }
106
- return join(dataDir, product.cacheDirName);
144
+ return join2(dataDir, product.cacheDirName);
107
145
  }
108
146
  function getTelemetryActivityStateFilePath(stateDir) {
109
- return join(stateDir, POSTHOG_ACTIVITY_STATE_FILE);
147
+ return join2(stateDir, POSTHOG_ACTIVITY_STATE_FILE);
110
148
  }
111
149
  function getDailyActiveCaptureState(input) {
112
- const state = readPostHogActivityState(input.stateDir, input.diagnostics);
113
150
  const dayUTC = getUtcDayString(input.now ?? new Date);
114
- const captureDaily = state.lastActiveDayUTC !== dayUTC;
115
- if (captureDaily) {
151
+ if (capturedDaysByStateDir.get(input.stateDir) === dayUTC) {
152
+ return { dayUTC, captureDaily: false };
153
+ }
154
+ const state = readPostHogActivityState(input.stateDir, input.diagnostics);
155
+ if (state.lastActiveDayUTC === dayUTC) {
156
+ capturedDaysByStateDir.set(input.stateDir, dayUTC);
157
+ return { dayUTC, captureDaily: false };
158
+ }
159
+ const claim = claimUtcDay(input.stateDir, dayUTC);
160
+ capturedDaysByStateDir.set(input.stateDir, dayUTC);
161
+ if (claim === "already-claimed") {
162
+ return { dayUTC, captureDaily: false };
163
+ }
164
+ if (claim === "claimed") {
116
165
  writePostHogActivityState(input.stateDir, {
117
166
  ...state,
118
167
  lastActiveDayUTC: dayUTC
119
168
  }, input.diagnostics);
120
169
  }
121
- return {
122
- dayUTC,
123
- captureDaily
124
- };
170
+ return { dayUTC, captureDaily: true };
125
171
  }
126
172
  function getUtcDayString(date) {
127
173
  return date.toISOString().slice(0, 10);
@@ -154,7 +200,7 @@ function readPostHogActivityState(stateDir, diagnostics) {
154
200
  function writePostHogActivityState(stateDir, nextState, diagnostics) {
155
201
  const stateFilePath = getTelemetryActivityStateFilePath(stateDir);
156
202
  try {
157
- mkdirSync2(stateDir, { recursive: true });
203
+ mkdirSync3(stateDir, { recursive: true });
158
204
  writeFileAtomically(stateFilePath, `${JSON.stringify(nextState, null, 2)}
159
205
  `);
160
206
  } catch (error) {
@@ -173,19 +219,19 @@ var DEFAULT_POSTHOG_API_KEY = "phc_CFJhj5HyvA62QPhvyaUCtaq23aUfznnijg5VaaGkNk74"
173
219
  var UNCONFIGURED_POSTHOG_API_KEY = "phc_REPLACE_ME_OMO_NATIVE";
174
220
 
175
221
  // ../../../../telemetry-core/src/diagnostics.ts
176
- import { appendFileSync, existsSync as existsSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync2 } from "node:fs";
177
- import { join as join2 } from "node:path";
222
+ import { appendFileSync, existsSync as existsSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync2 } from "node:fs";
223
+ import { join as join3 } from "node:path";
178
224
  var DIAGNOSTICS_FILE_NAME = "telemetry-diagnostics.jsonl";
179
225
  var DIAGNOSTICS_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
180
226
  var DIAGNOSTICS_MAX_BYTES = 256 * 1024;
181
227
  function getTelemetryDiagnosticsFilePath(diagnosticsDir) {
182
- return join2(diagnosticsDir, DIAGNOSTICS_FILE_NAME);
228
+ return join3(diagnosticsDir, DIAGNOSTICS_FILE_NAME);
183
229
  }
184
230
  function writeTelemetryDiagnostic(input, options) {
185
231
  const now = options.now ?? new Date;
186
232
  try {
187
233
  cleanupTelemetryDiagnostics({ diagnosticsDir: options.diagnosticsDir, now });
188
- mkdirSync3(options.diagnosticsDir, { recursive: true });
234
+ mkdirSync4(options.diagnosticsDir, { recursive: true });
189
235
  appendFileSync(getTelemetryDiagnosticsFilePath(options.diagnosticsDir), `${JSON.stringify(toDiagnosticRecord(input, now))}
190
236
  `, "utf-8");
191
237
  } catch (error) {
@@ -334,8 +380,8 @@ function getTelemetryHost(env = process.env, defaultHost = DEFAULT_POSTHOG_HOST)
334
380
  return env["POSTHOG_HOST"]?.trim() || defaultHost;
335
381
  }
336
382
 
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";
383
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
384
+ import { dirname as dirname2, posix, sep } from "path";
339
385
  function createModulerModifier() {
340
386
  const getModuleFromFileName = createGetModuleFromFilename();
341
387
  return async (frames) => {
@@ -344,7 +390,7 @@ function createModulerModifier() {
344
390
  return frames;
345
391
  };
346
392
  }
347
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname(process.argv[1]) : process.cwd(), isWindows = sep === "\\") {
393
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname2(process.argv[1]) : process.cwd(), isWindows = sep === "\\") {
348
394
  const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
349
395
  return (filename) => {
350
396
  if (!filename)
@@ -366,11 +412,11 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname(proces
366
412
  return decodedFile;
367
413
  };
368
414
  }
369
- function normalizeWindowsPath(path2) {
370
- return path2.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
415
+ function normalizeWindowsPath(path) {
416
+ return path.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
371
417
  }
372
418
 
373
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/featureFlagUtils.mjs
419
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/featureFlagUtils.mjs
374
420
  var normalizeFlagsResponse = (flagsResponse) => {
375
421
  if ("flags" in flagsResponse) {
376
422
  const featureFlags = getFlagValuesFromFlags(flagsResponse.flags);
@@ -440,8 +486,69 @@ var parsePayload = (response) => {
440
486
  return response;
441
487
  }
442
488
  };
489
+ var MINIMAL_FLAG_CALLED_EVENT_CAMPAIGN_PROPERTIES = [
490
+ "utm_source",
491
+ "utm_medium",
492
+ "utm_campaign",
493
+ "utm_content",
494
+ "utm_term",
495
+ "gad_source",
496
+ "mc_cid",
497
+ "gclid",
498
+ "gclsrc",
499
+ "dclid",
500
+ "gbraid",
501
+ "wbraid",
502
+ "fbclid",
503
+ "msclkid",
504
+ "twclid",
505
+ "li_fat_id",
506
+ "igshid",
507
+ "ttclid",
508
+ "rdt_cid",
509
+ "epik",
510
+ "qclid",
511
+ "sccid",
512
+ "irclid",
513
+ "_kx"
514
+ ];
515
+ var MINIMAL_FLAG_CALLED_EVENT_PROPERTIES = [
516
+ "$feature_flag",
517
+ "$feature_flag_response",
518
+ "$feature_flag_has_experiment",
519
+ "$feature_flag_id",
520
+ "$feature_flag_version",
521
+ "$feature_flag_reason",
522
+ "$feature_flag_request_id",
523
+ "$feature_flag_evaluated_at",
524
+ "$feature_flag_error",
525
+ "locally_evaluated",
526
+ "$groups",
527
+ "$process_person_profile",
528
+ "$geoip_disable",
529
+ "$current_url",
530
+ "$pathname",
531
+ "$referring_domain",
532
+ ...MINIMAL_FLAG_CALLED_EVENT_CAMPAIGN_PROPERTIES,
533
+ "$session_id",
534
+ "$window_id",
535
+ "$lib",
536
+ "$lib_version",
537
+ "$device_id",
538
+ "$is_server"
539
+ ];
540
+ var minimizeFlagCalledEventProperties = (properties, transportKeys = []) => {
541
+ const minimal = {};
542
+ const copyKey = (key) => {
543
+ if (properties[key] !== undefined)
544
+ minimal[key] = properties[key];
545
+ };
546
+ MINIMAL_FLAG_CALLED_EVENT_PROPERTIES.forEach(copyKey);
547
+ transportKeys.forEach(copyKey);
548
+ return minimal;
549
+ };
443
550
 
444
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/types.mjs
551
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/types.mjs
445
552
  var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedProperty) {
446
553
  PostHogPersistedProperty["AnonymousId"] = "anonymous_id";
447
554
  PostHogPersistedProperty["DistinctId"] = "distinct_id";
@@ -456,6 +563,8 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
456
563
  PostHogPersistedProperty["BootstrapFeatureFlagPayloads"] = "bootstrap_feature_flag_payloads";
457
564
  PostHogPersistedProperty["OverrideFeatureFlags"] = "override_feature_flags";
458
565
  PostHogPersistedProperty["Queue"] = "queue";
566
+ PostHogPersistedProperty["AiQueue"] = "ai_queue";
567
+ PostHogPersistedProperty["AiCaptureQueue"] = "ai_capture_queue";
459
568
  PostHogPersistedProperty["LogsQueue"] = "logs_queue";
460
569
  PostHogPersistedProperty["OptedOut"] = "opted_out";
461
570
  PostHogPersistedProperty["SessionId"] = "session_id";
@@ -466,6 +575,8 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
466
575
  PostHogPersistedProperty["InstalledAppBuild"] = "installed_app_build";
467
576
  PostHogPersistedProperty["InstalledAppVersion"] = "installed_app_version";
468
577
  PostHogPersistedProperty["SessionReplay"] = "session_replay";
578
+ PostHogPersistedProperty["PushRegistered"] = "push_registered";
579
+ PostHogPersistedProperty["SessionReplayEventTriggerActivatedSession"] = "session_replay_event_trigger_activated_session";
469
580
  PostHogPersistedProperty["SurveyLastSeenDate"] = "survey_last_seen_date";
470
581
  PostHogPersistedProperty["SurveysSeen"] = "surveys_seen";
471
582
  PostHogPersistedProperty["Surveys"] = "surveys";
@@ -475,7 +586,7 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
475
586
  return PostHogPersistedProperty;
476
587
  }({});
477
588
 
478
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/gzip.mjs
589
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/gzip.mjs
479
590
  function isGzipSupported() {
480
591
  return "CompressionStream" in globalThis && "TextEncoder" in globalThis && "Response" in globalThis && typeof Response.prototype.blob == "function";
481
592
  }
@@ -525,7 +636,7 @@ var validateNativeGzip = async (compressed, inputBytes) => {
525
636
  async function gzipCompress(input, isDebug = true, options) {
526
637
  try {
527
638
  const inputBytes = new TextEncoder().encode(input);
528
- const compressedStream = new CompressionStream("gzip");
639
+ const compressedStream = new globalThis.CompressionStream("gzip");
529
640
  const writer = compressedStream.writable.getWriter();
530
641
  const writePromise = writer.write(inputBytes).then(() => writer.close()).catch(async (err) => {
531
642
  try {
@@ -549,7 +660,34 @@ async function gzipCompress(input, isDebug = true, options) {
549
660
  }
550
661
  }
551
662
 
552
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/bot-detection.mjs
663
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/json-utils.mjs
664
+ var MAX_JSON_SAFE_VALUE_DEPTH = 20;
665
+ var MAX_JSON_SAFE_VALUE_ITEMS = 1000;
666
+ var MAX_JSON_SAFE_VALUE_NODES = 1e4;
667
+ var CIRCULAR_VALUE = "[Circular]";
668
+ var TRUNCATED_VALUE = "[Truncated]";
669
+ var UNSERIALIZABLE_VALUE = "[Unserializable]";
670
+ var FUNCTION_VALUE = "[Function]";
671
+ var dateGetTime = Date.prototype.getTime;
672
+ var dateToISOString = Date.prototype.toISOString;
673
+ function sanitizeString(value) {
674
+ let output = "";
675
+ for (let index = 0;index < value.length; index++) {
676
+ const codeUnit = value.charCodeAt(index);
677
+ if (codeUnit >= 55296 && codeUnit <= 56319) {
678
+ const nextCodeUnit = value.charCodeAt(index + 1);
679
+ if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
680
+ output += value[index] + value[index + 1];
681
+ index++;
682
+ } else
683
+ output += "�";
684
+ } else
685
+ output += codeUnit >= 56320 && codeUnit <= 57343 ? "�" : value[index];
686
+ }
687
+ return output;
688
+ }
689
+
690
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/bot-detection.mjs
553
691
  var DEFAULT_BLOCKED_UA_STRS = [
554
692
  "amazonbot",
555
693
  "amazonproductbot",
@@ -638,7 +776,31 @@ var isBlockedUA = function(ua, customBlockedUserAgents = []) {
638
776
  return uaLower.indexOf(blockedUaLower) !== -1;
639
777
  });
640
778
  };
641
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/type-utils.mjs
779
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/string-utils.mjs
780
+ function safeJsonStringify(value) {
781
+ const ancestors = [];
782
+ return JSON.stringify(value, function(_key, replacementValue) {
783
+ if (typeof replacementValue == "bigint")
784
+ return replacementValue.toString();
785
+ if (typeof replacementValue == "function" || typeof replacementValue == "symbol")
786
+ return;
787
+ if (replacementValue instanceof Error)
788
+ return {
789
+ name: replacementValue.name,
790
+ message: replacementValue.message,
791
+ stack: replacementValue.stack
792
+ };
793
+ if (replacementValue && typeof replacementValue == "object") {
794
+ while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this)
795
+ ancestors.pop();
796
+ if (ancestors.includes(replacementValue))
797
+ return "[Circular]";
798
+ ancestors.push(replacementValue);
799
+ }
800
+ return replacementValue;
801
+ }) ?? "null";
802
+ }
803
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/type-utils.mjs
642
804
  var nativeIsArray = Array.isArray;
643
805
  var ObjProto = Object.prototype;
644
806
  var type_utils_hasOwnProperty = ObjProto.hasOwnProperty;
@@ -650,16 +812,27 @@ var isObject = (x) => x === Object(x) && !isArray(x);
650
812
  var isUndefined = (x) => x === undefined;
651
813
  var isString = (x) => type_utils_toString.call(x) == "[object String]";
652
814
  var isEmptyString = (x) => isString(x) && x.trim().length === 0;
815
+ var isNull = (x) => x === null;
816
+ var isNullish = (x) => isUndefined(x) || isNull(x);
653
817
  var isNumber = (x) => type_utils_toString.call(x) == "[object Number]" && x === x;
654
- var isPlainError = (x) => x instanceof Error;
818
+ var isBoolean = (x) => type_utils_toString.call(x) === "[object Boolean]";
655
819
  function isPrimitive(value) {
656
820
  return value === null || typeof value != "object";
657
821
  }
658
822
  function isBuiltin(candidate, className) {
659
823
  return Object.prototype.toString.call(candidate) === `[object ${className}]`;
660
824
  }
661
- function isErrorEvent(event) {
662
- return isBuiltin(event, "ErrorEvent");
825
+ function isError(candidate) {
826
+ switch (Object.prototype.toString.call(candidate)) {
827
+ case "[object Error]":
828
+ case "[object Exception]":
829
+ case "[object DOMException]":
830
+ case "[object DOMError]":
831
+ case "[object WebAssembly.Exception]":
832
+ return true;
833
+ default:
834
+ return isInstanceOf(candidate, Error);
835
+ }
663
836
  }
664
837
  function isEvent(candidate) {
665
838
  return typeof Event != "undefined" && isInstanceOf(candidate, Event);
@@ -675,7 +848,7 @@ function isInstanceOf(candidate, base) {
675
848
  }
676
849
  }
677
850
 
678
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/number-utils.mjs
851
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/number-utils.mjs
679
852
  function clampToRange(value, min, max, logger, fallbackValue) {
680
853
  if (min > max) {
681
854
  logger.warn("min cannot be greater than max.");
@@ -695,8 +868,16 @@ function clampToRange(value, min, max, logger, fallbackValue) {
695
868
  return clampToRange(fallbackValue || max, min, max, logger);
696
869
  }
697
870
 
698
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
871
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
699
872
  var ONE_DAY_IN_MS = 86400000;
873
+ var DEFAULT_EXCEPTION_RATE_LIMITER_REFILL_RATE = 1;
874
+ var DEFAULT_EXCEPTION_RATE_LIMITER_BUCKET_SIZE = 10;
875
+ function resolveExceptionRateLimiterConfig(config = {}) {
876
+ return {
877
+ refillRate: config.exceptionRateLimiterRefillRate ?? config.__exceptionRateLimiterRefillRate ?? DEFAULT_EXCEPTION_RATE_LIMITER_REFILL_RATE,
878
+ bucketSize: config.exceptionRateLimiterBucketSize ?? config.__exceptionRateLimiterBucketSize ?? DEFAULT_EXCEPTION_RATE_LIMITER_BUCKET_SIZE
879
+ };
880
+ }
700
881
 
701
882
  class BucketedRateLimiter {
702
883
  constructor(options) {
@@ -739,7 +920,7 @@ class BucketedRateLimiter {
739
920
  this._buckets = {};
740
921
  }
741
922
  }
742
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
923
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
743
924
  /*! For license information please see uuidv7.mjs.LICENSE.txt */
744
925
  var DIGITS = "0123456789abcdef";
745
926
 
@@ -917,33 +1098,45 @@ var defaultGenerator;
917
1098
  var uuidv7 = () => uuidv7obj().toString();
918
1099
  var uuidv7obj = () => (defaultGenerator || (defaultGenerator = new V7Generator)).generate();
919
1100
 
920
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/promise-queue.mjs
1101
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/promise-queue.mjs
921
1102
  class PromiseQueue {
922
1103
  add(promise) {
923
1104
  const promiseUUID = uuidv7();
924
- this.promiseByIds[promiseUUID] = promise;
1105
+ const id = ++this.nextId;
1106
+ this.promiseByIds[promiseUUID] = {
1107
+ id,
1108
+ promise
1109
+ };
925
1110
  promise.catch(() => {}).finally(() => {
926
1111
  delete this.promiseByIds[promiseUUID];
927
1112
  });
928
1113
  return promise;
929
1114
  }
930
1115
  async join() {
931
- let promises = Object.values(this.promiseByIds);
1116
+ let promises = Object.values(this.promiseByIds).map((item) => item.promise);
932
1117
  let length = promises.length;
933
1118
  while (length > 0) {
934
1119
  await Promise.all(promises);
935
- promises = Object.values(this.promiseByIds);
1120
+ promises = Object.values(this.promiseByIds).map((item) => item.promise);
936
1121
  length = promises.length;
937
1122
  }
938
1123
  }
1124
+ getPromises(ignoredPromises = [], maxId = this.nextId) {
1125
+ const ignoredPromiseSet = new Set(ignoredPromises);
1126
+ return Object.values(this.promiseByIds).filter((item) => item.id <= maxId && !ignoredPromiseSet.has(item.promise)).map((item) => item.promise);
1127
+ }
1128
+ get maxId() {
1129
+ return this.nextId;
1130
+ }
939
1131
  get length() {
940
1132
  return Object.keys(this.promiseByIds).length;
941
1133
  }
942
1134
  constructor() {
943
1135
  this.promiseByIds = {};
1136
+ this.nextId = 0;
944
1137
  }
945
1138
  }
946
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/logger.mjs
1139
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/logger.mjs
947
1140
  function createConsole(consoleLike = console) {
948
1141
  const lockedMethods = {
949
1142
  log: consoleLike.log.bind(consoleLike),
@@ -984,7 +1177,7 @@ var passThrough = (fn) => fn();
984
1177
  function createLogger(prefix, maybeCall = passThrough) {
985
1178
  return _createLogger(prefix, maybeCall, createConsole());
986
1179
  }
987
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
1180
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
988
1181
  var MOBILE = "Mobile";
989
1182
  var IOS = "iOS";
990
1183
  var ANDROID = "Android";
@@ -1027,6 +1220,7 @@ var DUCKDUCKGO = "DuckDuckGo";
1027
1220
  var PALE_MOON = "Pale Moon";
1028
1221
  var WATERFOX = "Waterfox";
1029
1222
  var BRAVE = "Brave";
1223
+ var GOOGLE_SEARCH_APP = "Google Search App";
1030
1224
  var BROWSER_VERSION_REGEX_SUFFIX = "(\\d+(\\.\\d+)?)";
1031
1225
  var DEFAULT_BROWSER_VERSION_REGEX = new RegExp("Version/" + BROWSER_VERSION_REGEX_SUFFIX);
1032
1226
  var XBOX_REGEX = new RegExp(XBOX, "i");
@@ -1114,6 +1308,9 @@ var versionRegexes = {
1114
1308
  [WATERFOX]: [
1115
1309
  new RegExp(WATERFOX + "\\/" + BROWSER_VERSION_REGEX_SUFFIX)
1116
1310
  ],
1311
+ [GOOGLE_SEARCH_APP]: [
1312
+ new RegExp("GSA\\/" + BROWSER_VERSION_REGEX_SUFFIX)
1313
+ ],
1117
1314
  [INTERNET_EXPLORER]: [
1118
1315
  new RegExp("(rv:|MSIE )" + BROWSER_VERSION_REGEX_SUFFIX)
1119
1316
  ],
@@ -1273,8 +1470,15 @@ var osMatchers = [
1273
1470
  ]
1274
1471
  ];
1275
1472
 
1276
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/index.mjs
1473
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/index.mjs
1277
1474
  var STRING_FORMAT = "utf8";
1475
+ var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1476
+ function isValidUUID(value) {
1477
+ return typeof value == "string" && UUID_REGEX.test(value);
1478
+ }
1479
+ function getEventUuid(uuid, generateUuid) {
1480
+ return isValidUUID(uuid) ? uuid : generateUuid();
1481
+ }
1278
1482
  function removeTrailingSlash(url) {
1279
1483
  return url?.replace(/\/+$/, "");
1280
1484
  }
@@ -1302,7 +1506,26 @@ function safeSetTimeout(fn, timeout) {
1302
1506
  t?.unref && t?.unref();
1303
1507
  return t;
1304
1508
  }
1305
- var isError = (x) => x instanceof Error;
1509
+ async function raceWithTimeout(promise, timeoutMs, onTimeout) {
1510
+ let timeoutHandle;
1511
+ try {
1512
+ return await Promise.race([
1513
+ promise,
1514
+ new Promise((resolve, reject) => {
1515
+ timeoutHandle = safeSetTimeout(() => {
1516
+ try {
1517
+ onTimeout?.();
1518
+ resolve();
1519
+ } catch (error) {
1520
+ reject(error);
1521
+ }
1522
+ }, timeoutMs);
1523
+ })
1524
+ ]);
1525
+ } finally {
1526
+ clearTimeout(timeoutHandle);
1527
+ }
1528
+ }
1306
1529
  function allSettled(promises) {
1307
1530
  return Promise.all(promises.map((p) => (p ?? Promise.resolve()).then((value) => ({
1308
1531
  status: "fulfilled",
@@ -1313,7 +1536,7 @@ function allSettled(promises) {
1313
1536
  }))));
1314
1537
  }
1315
1538
 
1316
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/logs/logs-utils.mjs
1539
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/logs/logs-utils.mjs
1317
1540
  var OTLP_SEVERITY_MAP = {
1318
1541
  trace: {
1319
1542
  text: "TRACE",
@@ -1341,7 +1564,570 @@ var OTLP_SEVERITY_MAP = {
1341
1564
  }
1342
1565
  };
1343
1566
  var DEFAULT_OTLP_SEVERITY = OTLP_SEVERITY_MAP.info;
1344
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/eventemitter.mjs
1567
+ var INT64_RANGE_LIMIT = 9223372036854776000;
1568
+ var propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
1569
+ function newState() {
1570
+ return {
1571
+ ancestors: new WeakSet,
1572
+ remainingNodes: MAX_JSON_SAFE_VALUE_NODES
1573
+ };
1574
+ }
1575
+ function toOtlpKeyValueList(attrs, logger) {
1576
+ try {
1577
+ return encodeKeyValueList(attrs, logger, newState(), 0);
1578
+ } catch {
1579
+ return [];
1580
+ }
1581
+ }
1582
+ function encodeAnyValue(value, logger, state, depth) {
1583
+ if (state.remainingNodes <= 0)
1584
+ return {
1585
+ stringValue: TRUNCATED_VALUE
1586
+ };
1587
+ state.remainingNodes--;
1588
+ if (isBoolean(value))
1589
+ return {
1590
+ boolValue: value
1591
+ };
1592
+ if (typeof value == "number") {
1593
+ if (!Number.isFinite(value))
1594
+ return {
1595
+ stringValue: String(value)
1596
+ };
1597
+ if (Number.isInteger(value)) {
1598
+ if (Number.isSafeInteger(value))
1599
+ return {
1600
+ intValue: String(value)
1601
+ };
1602
+ if (typeof BigInt == "undefined")
1603
+ return {
1604
+ stringValue: String(value)
1605
+ };
1606
+ const decimal = BigInt(value).toString();
1607
+ if (value >= INT64_RANGE_LIMIT || value < -INT64_RANGE_LIMIT) {
1608
+ logger?.debug(`Attribute ${decimal} is outside the int64 range; encoding it as a string`);
1609
+ return {
1610
+ stringValue: decimal
1611
+ };
1612
+ }
1613
+ return {
1614
+ intValue: decimal
1615
+ };
1616
+ }
1617
+ return {
1618
+ doubleValue: value
1619
+ };
1620
+ }
1621
+ if (typeof value == "string")
1622
+ return {
1623
+ stringValue: sanitizeString(value)
1624
+ };
1625
+ if (typeof value == "function")
1626
+ return {
1627
+ stringValue: FUNCTION_VALUE
1628
+ };
1629
+ if (typeof value == "symbol")
1630
+ return {
1631
+ stringValue: String(value)
1632
+ };
1633
+ if (typeof value == "object" && value !== null) {
1634
+ if (state.ancestors.has(value))
1635
+ return {
1636
+ stringValue: CIRCULAR_VALUE
1637
+ };
1638
+ if (depth >= MAX_JSON_SAFE_VALUE_DEPTH)
1639
+ return {
1640
+ stringValue: TRUNCATED_VALUE
1641
+ };
1642
+ if (value instanceof Date) {
1643
+ const time = value.getTime();
1644
+ const iso = Number.isFinite(time) ? value.toISOString() : String(value);
1645
+ return {
1646
+ stringValue: typeof iso == "string" ? sanitizeString(iso) : String(iso)
1647
+ };
1648
+ }
1649
+ state.ancestors.add(value);
1650
+ try {
1651
+ try {
1652
+ const toJSON = value.toJSON;
1653
+ if (typeof toJSON == "function")
1654
+ return encodeAnyValue(toJSON.call(value), logger, state, depth + 1);
1655
+ } catch {}
1656
+ if (isArray(value))
1657
+ return {
1658
+ arrayValue: {
1659
+ values: encodeArrayValues(value, logger, state, depth + 1)
1660
+ }
1661
+ };
1662
+ return {
1663
+ kvlistValue: {
1664
+ values: encodeKeyValueList(value, logger, state, depth + 1)
1665
+ }
1666
+ };
1667
+ } finally {
1668
+ state.ancestors.delete(value);
1669
+ }
1670
+ }
1671
+ return {
1672
+ stringValue: sanitizeString(String(value))
1673
+ };
1674
+ }
1675
+ function encodeArrayValues(values, logger, state, depth) {
1676
+ const result = [];
1677
+ const itemCount = Math.min(values.length, MAX_JSON_SAFE_VALUE_ITEMS);
1678
+ let index = 0;
1679
+ for (;index < itemCount && state.remainingNodes > 0; index++)
1680
+ try {
1681
+ const element = index in values ? values[index] : undefined;
1682
+ if (isNullish(element))
1683
+ continue;
1684
+ result.push(encodeAnyValue(element, logger, state, depth));
1685
+ } catch {
1686
+ result.push({
1687
+ stringValue: UNSERIALIZABLE_VALUE
1688
+ });
1689
+ }
1690
+ if (values.length > index)
1691
+ result.push({
1692
+ stringValue: TRUNCATED_VALUE
1693
+ });
1694
+ return result;
1695
+ }
1696
+ function encodeKeyValueList(attrs, logger, state, depth) {
1697
+ const result = [];
1698
+ for (const key in attrs)
1699
+ if (propertyIsEnumerable.call(attrs, key)) {
1700
+ if (result.length >= MAX_JSON_SAFE_VALUE_ITEMS || state.remainingNodes <= 0) {
1701
+ logger?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");
1702
+ break;
1703
+ }
1704
+ try {
1705
+ const value = attrs[key];
1706
+ if (isNull(value) || isUndefined(value))
1707
+ continue;
1708
+ result.push({
1709
+ key: sanitizeString(key),
1710
+ value: encodeAnyValue(value, logger, state, depth)
1711
+ });
1712
+ } catch {
1713
+ result.push({
1714
+ key: sanitizeString(key),
1715
+ value: {
1716
+ stringValue: UNSERIALIZABLE_VALUE
1717
+ }
1718
+ });
1719
+ }
1720
+ }
1721
+ return result;
1722
+ }
1723
+
1724
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/metrics-utils.mjs
1725
+ var DEFAULT_HISTOGRAM_BOUNDS = [
1726
+ 0,
1727
+ 5,
1728
+ 10,
1729
+ 25,
1730
+ 50,
1731
+ 75,
1732
+ 100,
1733
+ 250,
1734
+ 500,
1735
+ 750,
1736
+ 1000,
1737
+ 2500,
1738
+ 5000,
1739
+ 7500,
1740
+ 1e4
1741
+ ];
1742
+ function msToUnixNano(ms) {
1743
+ return String(ms) + "000000";
1744
+ }
1745
+ function seriesKey(type, name, unit, attributes) {
1746
+ let attrsKey = "";
1747
+ if (attributes) {
1748
+ const keys = Object.keys(attributes).sort();
1749
+ attrsKey = keys.map((k) => `${JSON.stringify(k)}:${JSON.stringify(attributes[k])}`).join(",");
1750
+ }
1751
+ return `${type}\x00${name}\x00${unit ?? ""}\x00${attrsKey}`;
1752
+ }
1753
+ function bucketIndexFor(value, bounds) {
1754
+ for (let i = 0;i < bounds.length; i++)
1755
+ if (value <= bounds[i])
1756
+ return i;
1757
+ return bounds.length;
1758
+ }
1759
+ function buildMetricsResourceAttributes(config, scopeName, scopeVersion) {
1760
+ return {
1761
+ ...config.resourceAttributes,
1762
+ "service.name": config.serviceName || "unknown_service",
1763
+ ...config.environment && {
1764
+ "deployment.environment": config.environment
1765
+ },
1766
+ ...config.serviceVersion && {
1767
+ "service.version": config.serviceVersion
1768
+ },
1769
+ "telemetry.sdk.name": scopeName,
1770
+ "telemetry.sdk.version": scopeVersion
1771
+ };
1772
+ }
1773
+ function buildOtlpMetricsPayload(metrics, resourceAttributes, scopeName, scopeVersion) {
1774
+ return {
1775
+ resourceMetrics: [
1776
+ {
1777
+ resource: {
1778
+ attributes: toOtlpKeyValueList(resourceAttributes)
1779
+ },
1780
+ scopeMetrics: [
1781
+ {
1782
+ scope: {
1783
+ name: scopeName,
1784
+ version: scopeVersion
1785
+ },
1786
+ metrics
1787
+ }
1788
+ ]
1789
+ }
1790
+ ]
1791
+ };
1792
+ }
1793
+
1794
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/config.mjs
1795
+ var DEFAULT_FLUSH_INTERVAL_MS = 1e4;
1796
+ var DEFAULT_MAX_SERIES_PER_FLUSH = 1000;
1797
+ function resolveMetricsConfig(config) {
1798
+ const resourceAttributes = config?.resourceAttributes;
1799
+ return {
1800
+ serviceName: resourceAttributes?.["service.name"] ?? config?.serviceName,
1801
+ serviceVersion: resourceAttributes?.["service.version"] ?? config?.serviceVersion,
1802
+ environment: resourceAttributes?.["deployment.environment"] ?? config?.environment,
1803
+ resourceAttributes,
1804
+ beforeSend: config?.beforeSend,
1805
+ flushIntervalMs: config?.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS,
1806
+ maxSeriesPerFlush: config?.maxSeriesPerFlush ?? DEFAULT_MAX_SERIES_PER_FLUSH
1807
+ };
1808
+ }
1809
+
1810
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/index.mjs
1811
+ var OTLP_TEMPORALITY_DELTA = 1;
1812
+
1813
+ class PostHogMetrics {
1814
+ constructor(_instance, _config, _logger) {
1815
+ this._instance = _instance;
1816
+ this._config = _config;
1817
+ this._logger = _logger;
1818
+ this._series = new Map;
1819
+ this._flushPromise = null;
1820
+ this._seriesCapWarned = false;
1821
+ this._typeByName = new Map;
1822
+ this._typeCollisionWarned = new Set;
1823
+ this._generation = 0;
1824
+ }
1825
+ count(name, value = 1, options) {
1826
+ this._capture({
1827
+ name,
1828
+ type: "count",
1829
+ value,
1830
+ unit: options?.unit,
1831
+ attributes: options?.attributes
1832
+ });
1833
+ }
1834
+ gauge(name, value, options) {
1835
+ this._capture({
1836
+ name,
1837
+ type: "gauge",
1838
+ value,
1839
+ unit: options?.unit,
1840
+ attributes: options?.attributes
1841
+ });
1842
+ }
1843
+ histogram(name, value, options) {
1844
+ this._capture({
1845
+ name,
1846
+ type: "histogram",
1847
+ value,
1848
+ unit: options?.unit,
1849
+ attributes: options?.attributes
1850
+ });
1851
+ }
1852
+ flush() {
1853
+ const prev = this._flushPromise;
1854
+ const run = async () => {
1855
+ if (prev)
1856
+ await prev.catch(() => {});
1857
+ await this._doFlush();
1858
+ };
1859
+ const p = run().finally(() => {
1860
+ if (this._flushPromise === p)
1861
+ this._flushPromise = null;
1862
+ });
1863
+ this._flushPromise = p;
1864
+ return p;
1865
+ }
1866
+ drainWindow() {
1867
+ if (this._series.size === 0)
1868
+ return null;
1869
+ const window = this._series;
1870
+ this._series = new Map;
1871
+ this._seriesCapWarned = false;
1872
+ this._typeByName = new Map;
1873
+ this._typeCollisionWarned = new Set;
1874
+ return this._buildPayload(window);
1875
+ }
1876
+ reset() {
1877
+ this._generation++;
1878
+ this._clearFlushTimer();
1879
+ this._series = new Map;
1880
+ this._flushPromise = null;
1881
+ this._seriesCapWarned = false;
1882
+ this._typeByName = new Map;
1883
+ this._typeCollisionWarned = new Set;
1884
+ }
1885
+ _capture(sample) {
1886
+ if (this._instance.isDisabled || this._instance.optedOut)
1887
+ return;
1888
+ const filtered = this._runBeforeSend(sample);
1889
+ if (filtered === null)
1890
+ return;
1891
+ if (!filtered.name || typeof filtered.name != "string")
1892
+ return void this._logger.warn("Dropping metric with empty name");
1893
+ if (typeof filtered.value != "number" || !Number.isFinite(filtered.value))
1894
+ return void this._logger.warn(`Dropping metric '${filtered.name}': value must be a finite number`);
1895
+ if (filtered.type === "count" && filtered.value < 0)
1896
+ return void this._logger.warn(`Dropping count '${filtered.name}': counters are monotonic, value must be >= 0`);
1897
+ let attributes;
1898
+ let key;
1899
+ try {
1900
+ attributes = filtered.attributes ? {
1901
+ ...filtered.attributes
1902
+ } : undefined;
1903
+ key = seriesKey(filtered.type, filtered.name, filtered.unit, attributes);
1904
+ } catch (e) {
1905
+ this._logger.warn(`Dropping metric '${filtered.name}': attributes could not be serialized`, e);
1906
+ return;
1907
+ }
1908
+ let state = this._series.get(key);
1909
+ if (!state) {
1910
+ if (!this._admitNewSeries())
1911
+ return;
1912
+ state = {
1913
+ name: filtered.name,
1914
+ type: filtered.type,
1915
+ unit: filtered.unit,
1916
+ attributes,
1917
+ windowStartMs: Date.now()
1918
+ };
1919
+ this._series.set(key, state);
1920
+ }
1921
+ const seenType = this._typeByName.get(filtered.name);
1922
+ if (seenType === undefined)
1923
+ this._typeByName.set(filtered.name, filtered.type);
1924
+ else if (seenType !== filtered.type && !this._typeCollisionWarned.has(filtered.name)) {
1925
+ this._typeCollisionWarned.add(filtered.name);
1926
+ 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.`);
1927
+ }
1928
+ this._fold(state, filtered.value);
1929
+ this._armFlushTimer();
1930
+ }
1931
+ _admitNewSeries() {
1932
+ if (this._series.size < this._config.maxSeriesPerFlush)
1933
+ return true;
1934
+ if (!this._seriesCapWarned) {
1935
+ this._seriesCapWarned = true;
1936
+ this._logger.warn(`Metric series cap reached (${this._config.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`);
1937
+ }
1938
+ return false;
1939
+ }
1940
+ _fold(state, value) {
1941
+ switch (state.type) {
1942
+ case "count":
1943
+ state.total = (state.total ?? 0) + value;
1944
+ break;
1945
+ case "gauge":
1946
+ state.last = value;
1947
+ break;
1948
+ case "histogram": {
1949
+ if (!state.hist)
1950
+ state.hist = {
1951
+ count: 0,
1952
+ sum: 0,
1953
+ min: value,
1954
+ max: value,
1955
+ bucketCounts: new Array(DEFAULT_HISTOGRAM_BOUNDS.length + 1).fill(0)
1956
+ };
1957
+ const hist = state.hist;
1958
+ hist.count += 1;
1959
+ hist.sum += value;
1960
+ hist.min = Math.min(hist.min, value);
1961
+ hist.max = Math.max(hist.max, value);
1962
+ hist.bucketCounts[bucketIndexFor(value, DEFAULT_HISTOGRAM_BOUNDS)] += 1;
1963
+ break;
1964
+ }
1965
+ }
1966
+ }
1967
+ _runBeforeSend(sample) {
1968
+ const beforeSend = this._config.beforeSend;
1969
+ if (!beforeSend)
1970
+ return sample;
1971
+ const fns = isArray(beforeSend) ? beforeSend : [
1972
+ beforeSend
1973
+ ];
1974
+ let result = sample;
1975
+ for (const fn of fns)
1976
+ try {
1977
+ const next = fn(result);
1978
+ if (!next) {
1979
+ this._logger.info("Metric was rejected in beforeSend function");
1980
+ return null;
1981
+ }
1982
+ result = next;
1983
+ } catch (e) {
1984
+ this._logger.error("Error in beforeSend function for metric:", e);
1985
+ return null;
1986
+ }
1987
+ return result;
1988
+ }
1989
+ _armFlushTimer() {
1990
+ if (this._flushTimer)
1991
+ return;
1992
+ this._flushTimer = safeSetTimeout(() => {
1993
+ this._flushTimer = undefined;
1994
+ this.flush().catch((e) => {
1995
+ this._logger.error("Metrics flush failed:", e);
1996
+ });
1997
+ }, this._config.flushIntervalMs);
1998
+ }
1999
+ _clearFlushTimer() {
2000
+ if (this._flushTimer) {
2001
+ clearTimeout(this._flushTimer);
2002
+ this._flushTimer = undefined;
2003
+ }
2004
+ }
2005
+ async _doFlush() {
2006
+ if (this._series.size === 0)
2007
+ return;
2008
+ const window = this._series;
2009
+ this._series = new Map;
2010
+ this._seriesCapWarned = false;
2011
+ this._typeByName = new Map;
2012
+ this._typeCollisionWarned = new Set;
2013
+ const generation = this._generation;
2014
+ const outcome = await this._instance._sendMetricsBatch(this._buildPayload(window));
2015
+ if (generation !== this._generation)
2016
+ return;
2017
+ switch (outcome.kind) {
2018
+ case "ok":
2019
+ return;
2020
+ case "retry-later":
2021
+ this._mergeWindowBack(window);
2022
+ this._armFlushTimer();
2023
+ return;
2024
+ case "too-large":
2025
+ this._logger.warn("Metrics batch exceeded the server size limit and was dropped");
2026
+ return;
2027
+ case "fatal":
2028
+ this._logger.error("Failed to send metrics batch:", outcome.error);
2029
+ return;
2030
+ }
2031
+ }
2032
+ _buildPayload(window) {
2033
+ return buildOtlpMetricsPayload(this._buildMetrics(window), buildMetricsResourceAttributes(this._config, this._instance.getLibraryId(), this._instance.getLibraryVersion()), this._instance.getLibraryId(), this._instance.getLibraryVersion());
2034
+ }
2035
+ _buildMetrics(window) {
2036
+ const nowNano = msToUnixNano(Date.now());
2037
+ const byMetric = new Map;
2038
+ for (const state of window.values()) {
2039
+ const metricKey = seriesKey(state.type, state.name, state.unit, undefined);
2040
+ let metric = byMetric.get(metricKey);
2041
+ if (!metric) {
2042
+ metric = {
2043
+ name: state.name,
2044
+ ...state.unit && {
2045
+ unit: state.unit
2046
+ }
2047
+ };
2048
+ if (state.type === "count")
2049
+ metric.sum = {
2050
+ aggregationTemporality: OTLP_TEMPORALITY_DELTA,
2051
+ isMonotonic: true,
2052
+ dataPoints: []
2053
+ };
2054
+ else if (state.type === "gauge")
2055
+ metric.gauge = {
2056
+ dataPoints: []
2057
+ };
2058
+ else
2059
+ metric.histogram = {
2060
+ aggregationTemporality: OTLP_TEMPORALITY_DELTA,
2061
+ dataPoints: []
2062
+ };
2063
+ byMetric.set(metricKey, metric);
2064
+ }
2065
+ const attributes = toOtlpKeyValueList(state.attributes ?? {}, this._logger);
2066
+ const startNano = msToUnixNano(state.windowStartMs);
2067
+ if (state.type === "count") {
2068
+ const dp = {
2069
+ attributes,
2070
+ startTimeUnixNano: startNano,
2071
+ timeUnixNano: nowNano,
2072
+ asDouble: state.total ?? 0
2073
+ };
2074
+ metric.sum.dataPoints.push(dp);
2075
+ } else if (state.type === "gauge") {
2076
+ const dp = {
2077
+ attributes,
2078
+ timeUnixNano: nowNano,
2079
+ asDouble: state.last ?? 0
2080
+ };
2081
+ metric.gauge.dataPoints.push(dp);
2082
+ } else if (state.hist) {
2083
+ const dp = {
2084
+ attributes,
2085
+ startTimeUnixNano: startNano,
2086
+ timeUnixNano: nowNano,
2087
+ count: state.hist.count,
2088
+ sum: state.hist.sum,
2089
+ min: state.hist.min,
2090
+ max: state.hist.max,
2091
+ bucketCounts: state.hist.bucketCounts,
2092
+ explicitBounds: DEFAULT_HISTOGRAM_BOUNDS
2093
+ };
2094
+ metric.histogram.dataPoints.push(dp);
2095
+ }
2096
+ }
2097
+ return Array.from(byMetric.values());
2098
+ }
2099
+ _mergeWindowBack(window) {
2100
+ for (const [key, old] of window) {
2101
+ const current = this._series.get(key);
2102
+ if (!current) {
2103
+ if (this._admitNewSeries())
2104
+ this._series.set(key, old);
2105
+ continue;
2106
+ }
2107
+ current.windowStartMs = Math.min(current.windowStartMs, old.windowStartMs);
2108
+ switch (current.type) {
2109
+ case "count":
2110
+ current.total = (current.total ?? 0) + (old.total ?? 0);
2111
+ break;
2112
+ case "gauge":
2113
+ break;
2114
+ case "histogram":
2115
+ if (old.hist)
2116
+ if (current.hist) {
2117
+ current.hist.count += old.hist.count;
2118
+ current.hist.sum += old.hist.sum;
2119
+ current.hist.min = Math.min(current.hist.min, old.hist.min);
2120
+ current.hist.max = Math.max(current.hist.max, old.hist.max);
2121
+ for (let i = 0;i < current.hist.bucketCounts.length; i++)
2122
+ current.hist.bucketCounts[i] += old.hist.bucketCounts[i];
2123
+ } else
2124
+ current.hist = old.hist;
2125
+ break;
2126
+ }
2127
+ }
2128
+ }
2129
+ }
2130
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/eventemitter.mjs
1345
2131
  class SimpleEventEmitter {
1346
2132
  constructor() {
1347
2133
  this.events = {};
@@ -1363,37 +2149,7 @@ class SimpleEventEmitter {
1363
2149
  }
1364
2150
  }
1365
2151
 
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
2152
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
1397
2153
  var parsedStackResults;
1398
2154
  var lastKeysCount;
1399
2155
  var cachedFilenameChunkIds;
@@ -1432,7 +2188,7 @@ function getFilenameToChunkIdMap(stackParser) {
1432
2188
  return cachedFilenameChunkIds;
1433
2189
  }
1434
2190
 
1435
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
2191
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
1436
2192
  var MAX_CAUSE_RECURSION = 4;
1437
2193
 
1438
2194
  class ErrorPropertiesBuilder {
@@ -1536,11 +2292,11 @@ class ErrorPropertiesBuilder {
1536
2292
  return context;
1537
2293
  }
1538
2294
  buildCoercingContext(mechanism, hint, depth = 0) {
1539
- const coerce = (input, depth2) => {
1540
- if (!(depth2 <= MAX_CAUSE_RECURSION))
2295
+ const coerce = (input, depth) => {
2296
+ if (!(depth <= MAX_CAUSE_RECURSION))
1541
2297
  return;
1542
2298
  {
1543
- const ctx = this.buildCoercingContext(mechanism, hint, depth2);
2299
+ const ctx = this.buildCoercingContext(mechanism, hint, depth);
1544
2300
  return this.applyCoercers(input, ctx);
1545
2301
  }
1546
2302
  };
@@ -1554,14 +2310,16 @@ class ErrorPropertiesBuilder {
1554
2310
  return context;
1555
2311
  }
1556
2312
  }
1557
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
2313
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
1558
2314
  var UNKNOWN_FUNCTION = "?";
2315
+ var MASKED_URL_PREFIX = "webkit-masked-url://";
2316
+ var ANONYMOUS_FILENAME = "<anonymous>";
1559
2317
  function createFrame(platform, filename, func, lineno, colno) {
1560
2318
  const frame = {
1561
2319
  platform,
1562
2320
  filename,
1563
2321
  function: func === "<anonymous>" ? UNKNOWN_FUNCTION : func,
1564
- in_app: true
2322
+ in_app: !filename?.startsWith(MASKED_URL_PREFIX) && filename !== ANONYMOUS_FILENAME
1565
2323
  };
1566
2324
  if (!isUndefined(lineno))
1567
2325
  frame.lineno = lineno;
@@ -1570,7 +2328,7 @@ function createFrame(platform, filename, func, lineno, colno) {
1570
2328
  return frame;
1571
2329
  }
1572
2330
 
1573
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
2331
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
1574
2332
  var extractSafariExtensionDetails = (func, filename) => {
1575
2333
  const isSafariExtension = func.indexOf("safari-extension") !== -1;
1576
2334
  const isSafariWebExtension = func.indexOf("safari-web-extension") !== -1;
@@ -1583,15 +2341,15 @@ var extractSafariExtensionDetails = (func, filename) => {
1583
2341
  ];
1584
2342
  };
1585
2343
 
1586
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
2344
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
1587
2345
  var chromeRegexNoFnName = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i;
1588
2346
  var chromeRegex = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
1589
2347
  var chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
1590
2348
  var chromeStackLineParser = (line, platform) => {
1591
2349
  const noFnParts = chromeRegexNoFnName.exec(line);
1592
2350
  if (noFnParts) {
1593
- const [, filename, line2, col] = noFnParts;
1594
- return createFrame(platform, filename, UNKNOWN_FUNCTION, +line2, +col);
2351
+ const [, filename, line, col] = noFnParts;
2352
+ return createFrame(platform, filename, UNKNOWN_FUNCTION, +line, +col);
1595
2353
  }
1596
2354
  const parts = chromeRegex.exec(line);
1597
2355
  if (parts) {
@@ -1609,7 +2367,7 @@ var chromeStackLineParser = (line, platform) => {
1609
2367
  }
1610
2368
  };
1611
2369
 
1612
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
2370
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
1613
2371
  var geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
1614
2372
  var geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
1615
2373
  var geckoStackLineParser = (line, platform) => {
@@ -1632,28 +2390,12 @@ var geckoStackLineParser = (line, platform) => {
1632
2390
  }
1633
2391
  };
1634
2392
 
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
2393
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
1655
2394
  var FILENAME_MATCH = /^\s*[-]{4,}$/;
1656
2395
  var FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
2396
+ var PROMISE_COMBINATOR = /^Promise\.(?:all|any)$/;
2397
+ var PROMISE_INDEX = /^index \d+$/;
2398
+ var PROMISE_FRAME_FILENAME = "node:internal/promise";
1657
2399
  var nodeStackLineParser = (line, platform) => {
1658
2400
  const lineMatch = line.match(FULL_MATCH);
1659
2401
  if (lineMatch) {
@@ -1696,6 +2438,8 @@ var nodeStackLineParser = (line, platform) => {
1696
2438
  filename = filename.slice(1);
1697
2439
  if (!filename && lineMatch[5] && !isNative)
1698
2440
  filename = lineMatch[5];
2441
+ if (PROMISE_COMBINATOR.test(functionName) && PROMISE_INDEX.test(filename || ""))
2442
+ filename = PROMISE_FRAME_FILENAME;
1699
2443
  return {
1700
2444
  filename: filename ? decodeURI(filename) : undefined,
1701
2445
  module: undefined,
@@ -1720,7 +2464,7 @@ function _parseIntOrUndefined(input) {
1720
2464
  return parseInt(input || "", 10) || undefined;
1721
2465
  }
1722
2466
 
1723
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
2467
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
1724
2468
  var WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
1725
2469
  var STACKTRACE_FRAME_LIMIT = 50;
1726
2470
  function reverseAndStripFrames(stack) {
@@ -1765,48 +2509,20 @@ function createStackParser(platform, ...parsers) {
1765
2509
  return reverseAndStripFrames(frames);
1766
2510
  };
1767
2511
  }
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
2512
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
1799
2513
  class ErrorCoercer {
1800
2514
  match(err) {
1801
- return isPlainError(err);
2515
+ return isError(err);
1802
2516
  }
1803
2517
  coerce(err, ctx) {
2518
+ const stack = this.getStack(err);
2519
+ const synthetic = stack === undefined;
1804
2520
  return {
1805
2521
  type: this.getType(err),
1806
2522
  value: this.getMessage(err, ctx),
1807
- stack: this.getStack(err),
2523
+ stack: stack ?? ctx.syntheticException?.stack,
1808
2524
  cause: err.cause ? ctx.next(err.cause) : undefined,
1809
- synthetic: false
2525
+ synthetic
1810
2526
  };
1811
2527
  }
1812
2528
  getType(err) {
@@ -1822,25 +2538,7 @@ class ErrorCoercer {
1822
2538
  return err.stacktrace || err.stack || undefined;
1823
2539
  }
1824
2540
  }
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
2541
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
1844
2542
  var ERROR_TYPES_PATTERN = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
1845
2543
 
1846
2544
  class StringCoercer {
@@ -1870,7 +2568,7 @@ class StringCoercer {
1870
2568
  ];
1871
2569
  }
1872
2570
  }
1873
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/types.mjs
2571
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/types.mjs
1874
2572
  var severityLevels = [
1875
2573
  "fatal",
1876
2574
  "error",
@@ -1880,7 +2578,7 @@ var severityLevels = [
1880
2578
  "debug"
1881
2579
  ];
1882
2580
 
1883
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
2581
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
1884
2582
  function extractExceptionKeysForMessage(err, maxLength = 40) {
1885
2583
  const keys = Object.keys(err);
1886
2584
  keys.sort();
@@ -1897,7 +2595,7 @@ function extractExceptionKeysForMessage(err, maxLength = 40) {
1897
2595
  return "";
1898
2596
  }
1899
2597
 
1900
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
2598
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
1901
2599
  class ObjectCoercer {
1902
2600
  match(candidate) {
1903
2601
  return typeof candidate == "object" && candidate !== null;
@@ -1909,13 +2607,16 @@ class ObjectCoercer {
1909
2607
  return {
1910
2608
  type: this.getType(candidate),
1911
2609
  value: this.getValue(candidate),
1912
- stack: ctx.syntheticException?.stack,
2610
+ stack: this.getStack(candidate) ?? ctx.syntheticException?.stack,
1913
2611
  level: this.isSeverityLevel(candidate.level) ? candidate.level : "error",
1914
2612
  synthetic: true
1915
2613
  };
1916
2614
  }
1917
2615
  getType(err) {
1918
- return isEvent(err) ? err.constructor.name : "Error";
2616
+ if (isEvent(err))
2617
+ return err.constructor.name;
2618
+ const name = "name" in err ? err.name : undefined;
2619
+ return isString(name) && !isEmptyString(name) ? name : "Error";
1919
2620
  }
1920
2621
  getValue(err) {
1921
2622
  if ("name" in err && typeof err.name == "string") {
@@ -1933,6 +2634,15 @@ class ObjectCoercer {
1933
2634
  isSeverityLevel(x) {
1934
2635
  return isString(x) && !isEmptyString(x) && severityLevels.indexOf(x) >= 0;
1935
2636
  }
2637
+ getStack(candidate) {
2638
+ try {
2639
+ if (isString(candidate.stacktrace) && candidate.stacktrace.length > 0)
2640
+ return candidate.stacktrace;
2641
+ return isString(candidate.stack) && candidate.stack.length > 0 ? candidate.stack : undefined;
2642
+ } catch {
2643
+ return;
2644
+ }
2645
+ }
1936
2646
  getErrorPropertyFromObject(obj) {
1937
2647
  for (const prop in obj)
1938
2648
  if (Object.prototype.hasOwnProperty.call(obj, prop)) {
@@ -1950,7 +2660,7 @@ class ObjectCoercer {
1950
2660
  }
1951
2661
  }
1952
2662
  }
1953
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
2663
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
1954
2664
  class EventCoercer {
1955
2665
  match(err) {
1956
2666
  return isEvent(err);
@@ -1965,7 +2675,7 @@ class EventCoercer {
1965
2675
  };
1966
2676
  }
1967
2677
  }
1968
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
2678
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
1969
2679
  class PrimitiveCoercer {
1970
2680
  match(candidate) {
1971
2681
  return isPrimitive(candidate);
@@ -1979,43 +2689,7 @@ class PrimitiveCoercer {
1979
2689
  };
1980
2690
  }
1981
2691
  }
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
2692
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/utils.mjs
2019
2693
  class ReduceableCache {
2020
2694
  constructor(_maxSize) {
2021
2695
  this._maxSize = _maxSize;
@@ -2032,184 +2706,82 @@ class ReduceableCache {
2032
2706
  set(key, value) {
2033
2707
  this._cache.set(key, value);
2034
2708
  }
2035
- reduce() {
2036
- while (this._cache.size >= this._maxSize) {
2037
- const value = this._cache.keys().next().value;
2038
- if (value)
2039
- this._cache.delete(value);
2040
- }
2041
- }
2042
- }
2043
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
2044
- var EXCEPTION_STEP_INTERNAL_FIELDS = {
2045
- MESSAGE: "$message",
2046
- TIMESTAMP: "$timestamp"
2047
- };
2048
- var RESERVED_EXCEPTION_STEP_KEYS = new Set([
2049
- EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE,
2050
- EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP
2051
- ]);
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
- };
2085
- }
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;
2709
+ reduce() {
2710
+ while (this._cache.size >= this._maxSize) {
2711
+ const value = this._cache.keys().next().value;
2712
+ if (value)
2713
+ this._cache.delete(value);
2714
+ }
2185
2715
  }
2186
2716
  }
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;
2717
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
2718
+ var EXCEPTION_STEP_INTERNAL_FIELDS = {
2719
+ MESSAGE: "$message",
2720
+ TIMESTAMP: "$timestamp"
2721
+ };
2722
+ var RESERVED_EXCEPTION_STEP_KEYS = new Set([
2723
+ EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE,
2724
+ EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP
2725
+ ]);
2726
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/release.mjs
2727
+ function getInjectedReleaseId() {
2728
+ const injected = globalThis._posthogReleaseId;
2729
+ return typeof injected == "string" && injected.length > 0 ? injected : undefined;
2199
2730
  }
2200
- // ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
2731
+ // ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
2201
2732
  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";
2733
+ constructor(response, reqByteLength, responseBodyDeadline, abortController) {
2734
+ 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
2735
  }
2205
2736
  get status() {
2206
2737
  return this.response.status;
2207
2738
  }
2739
+ get bodyReadTimedOut() {
2740
+ return this._bodyReadTimedOut;
2741
+ }
2208
2742
  get text() {
2209
- return this.response.text();
2743
+ if (!this.responseBodyTextPromise)
2744
+ if (Date.now() >= this.responseBodyDeadline) {
2745
+ this._bodyReadTimedOut = true;
2746
+ const timeoutError = new Error("Response body read timed out");
2747
+ timeoutError.name = "AbortError";
2748
+ this.cancelResponseBody(timeoutError);
2749
+ this.responseBodyTextPromise = Promise.reject(timeoutError);
2750
+ } else {
2751
+ const responseBodyTimeout = new Promise((_resolve, reject) => {
2752
+ this.responseBodyTimer = safeSetTimeout(() => {
2753
+ this._bodyReadTimedOut = true;
2754
+ const timeoutError = new Error("Response body read timed out");
2755
+ timeoutError.name = "AbortError";
2756
+ reject(timeoutError);
2757
+ this.cancelResponseBody(timeoutError);
2758
+ }, this.responseBodyDeadline - Date.now());
2759
+ });
2760
+ let responseBodyText;
2761
+ try {
2762
+ responseBodyText = Promise.resolve(this.response.text());
2763
+ } catch (error) {
2764
+ responseBodyText = Promise.reject(error);
2765
+ }
2766
+ this.responseBodyTextPromise = Promise.race([
2767
+ responseBodyText,
2768
+ responseBodyTimeout
2769
+ ]).finally(() => clearTimeout(this.responseBodyTimer));
2770
+ }
2771
+ return this.responseBodyTextPromise;
2210
2772
  }
2211
2773
  get json() {
2212
- return this.response.json();
2774
+ return this.text.then((text) => JSON.parse(text));
2775
+ }
2776
+ cancelResponseBody(reason) {
2777
+ clearTimeout(this.responseBodyTimer);
2778
+ if (!this.abortController.signal.aborted)
2779
+ this.abortController.abort(reason);
2780
+ (async () => {
2781
+ try {
2782
+ await this.response.body?.cancel();
2783
+ } catch {}
2784
+ })();
2213
2785
  }
2214
2786
  }
2215
2787
 
@@ -2220,12 +2792,20 @@ class PostHogFetchNetworkError extends Error {
2220
2792
  } : {}), this.error = error, this.name = "PostHogFetchNetworkError";
2221
2793
  }
2222
2794
  }
2795
+ var applyCallerFeatureFlagOverrides = (target, callerProperties) => {
2796
+ for (const key of Object.keys(callerProperties))
2797
+ if (key.startsWith("$feature/") || key === "$active_feature_flags")
2798
+ target[key] = callerProperties[key];
2799
+ };
2223
2800
  async function logFlushError(err) {
2224
2801
  if (err instanceof PostHogFetchHttpError) {
2225
2802
  let text = "";
2226
2803
  try {
2227
2804
  text = await err.text;
2228
- } catch {}
2805
+ } catch {
2806
+ if (err.bodyReadTimedOut)
2807
+ text = "<response body read timed out>";
2808
+ }
2229
2809
  console.error(`Error while flushing PostHog: message=${err.message}, response body=${text}`, err);
2230
2810
  } else
2231
2811
  console.error("Error while flushing PostHog", err);
@@ -2237,9 +2817,28 @@ function isPostHogFetchError(err) {
2237
2817
  function isPostHogFetchNetworkError(err) {
2238
2818
  return err instanceof PostHogFetchNetworkError;
2239
2819
  }
2820
+ function isRetryableFlagsFetchError(err) {
2821
+ if (err instanceof PostHogFetchHttpError)
2822
+ return err.status === 502 || err.status === 504;
2823
+ if (!(err instanceof PostHogFetchNetworkError))
2824
+ return false;
2825
+ const cause = err.error;
2826
+ const code = cause?.code ?? cause?.cause?.code;
2827
+ return code !== "ECONNREFUSED";
2828
+ }
2240
2829
  function isPostHogFetchContentTooLargeError(err) {
2241
2830
  return typeof err == "object" && err instanceof PostHogFetchHttpError && err.status === 413;
2242
2831
  }
2832
+ function isPostHogFetchRetryableError(err) {
2833
+ if (err instanceof PostHogFetchHttpError)
2834
+ return err.status === 408 || err.status === 429 || err.status >= 500;
2835
+ return isPostHogFetchNetworkError(err);
2836
+ }
2837
+ function isPostHogEventProperties(value) {
2838
+ return value !== null && typeof value == "object" && !Array.isArray(value);
2839
+ }
2840
+ var DEFAULT_QUEUE_ROUTE = "default";
2841
+
2243
2842
  class PostHogCoreStateless {
2244
2843
  getErrorPropertiesBuilder() {
2245
2844
  if (!this._errorPropertiesBuilder)
@@ -2256,6 +2855,9 @@ class PostHogCoreStateless {
2256
2855
  }
2257
2856
  constructor(apiKey, options = {}) {
2258
2857
  this.flushPromise = null;
2858
+ this.pendingFlushPromise = null;
2859
+ this.flushPromises = new Set;
2860
+ this._dequeuedMessagesCount = 0;
2259
2861
  this.shutdownPromise = null;
2260
2862
  this.promiseQueue = new PromiseQueue;
2261
2863
  this._events = new SimpleEventEmitter;
@@ -2278,10 +2880,11 @@ class PostHogCoreStateless {
2278
2880
  this._retryOptions = {
2279
2881
  retryCount: options.fetchRetryCount ?? 3,
2280
2882
  retryDelay: options.fetchRetryDelay ?? 3000,
2281
- retryCheck: isPostHogFetchError
2883
+ retryCheck: isPostHogFetchRetryableError
2282
2884
  };
2283
2885
  this.requestTimeout = options.requestTimeout ?? 1e4;
2284
2886
  this.featureFlagsRequestTimeoutMs = options.featureFlagsRequestTimeoutMs ?? 3000;
2887
+ this.featureFlagsRequestMaxRetries = options.featureFlagsRequestMaxRetries ?? 1;
2285
2888
  this.remoteConfigRequestTimeoutMs = options.remoteConfigRequestTimeoutMs ?? 3000;
2286
2889
  this.disableGeoip = options.disableGeoip ?? true;
2287
2890
  this.disabled = (options.disabled ?? false) || missingApiKey;
@@ -2343,15 +2946,23 @@ class PostHogCoreStateless {
2343
2946
  return this.disabled;
2344
2947
  }
2345
2948
  buildPayload(payload) {
2949
+ const userProperties = payload.properties || {};
2950
+ let properties = {
2951
+ ...userProperties,
2952
+ ...this.getCommonEventProperties()
2953
+ };
2954
+ applyCallerFeatureFlagOverrides(properties, userProperties);
2955
+ if (payload.event === "$feature_flag_called" && properties.$feature_flag_has_experiment === false && this.isMinimalFlagCalledEventsEnabled())
2956
+ properties = minimizeFlagCalledEventProperties(properties);
2346
2957
  return {
2347
2958
  distinct_id: payload.distinct_id,
2348
2959
  event: payload.event,
2349
- properties: {
2350
- ...payload.properties || {},
2351
- ...this.getCommonEventProperties()
2352
- }
2960
+ properties
2353
2961
  };
2354
2962
  }
2963
+ isMinimalFlagCalledEventsEnabled() {
2964
+ return false;
2965
+ }
2355
2966
  addPendingPromise(promise) {
2356
2967
  return this.promiseQueue.add(promise);
2357
2968
  }
@@ -2436,6 +3047,19 @@ class PostHogCoreStateless {
2436
3047
  this.enqueue("capture", payload, options);
2437
3048
  });
2438
3049
  }
3050
+ async groupIdentifyStatelessImmediate(groupType, groupKey, groupProperties, options, distinctId, eventProperties) {
3051
+ const payload = this.buildPayload({
3052
+ distinct_id: distinctId || `$${groupType}_${groupKey}`,
3053
+ event: "$groupidentify",
3054
+ properties: {
3055
+ $group_type: groupType,
3056
+ $group_key: groupKey,
3057
+ $group_set: groupProperties || {},
3058
+ ...eventProperties || {}
3059
+ }
3060
+ });
3061
+ await this.sendImmediate("capture", payload, options);
3062
+ }
2439
3063
  async getRemoteConfig() {
2440
3064
  await this._initPromise;
2441
3065
  let host = this.host;
@@ -2452,8 +3076,11 @@ class PostHogCoreStateless {
2452
3076
  }
2453
3077
  };
2454
3078
  return this.fetchWithRetry(url, fetchOptions, {
3079
+ type: "required",
3080
+ consume: (response) => response.json()
3081
+ }, {
2455
3082
  retryCount: 0
2456
- }, this.remoteConfigRequestTimeoutMs).then((response) => response.json()).catch((error) => {
3083
+ }, this.remoteConfigRequestTimeoutMs).catch((error) => {
2457
3084
  this._logger.error("Remote config could not be loaded", error);
2458
3085
  this._events.emit("error", error);
2459
3086
  });
@@ -2484,8 +3111,12 @@ class PostHogCoreStateless {
2484
3111
  };
2485
3112
  this._logger.info("Flags URL", url);
2486
3113
  return this.fetchWithRetry(url, fetchOptions, {
2487
- retryCount: 0
2488
- }, this.featureFlagsRequestTimeoutMs).then((response) => response.json()).then((response) => ({
3114
+ type: "required",
3115
+ consume: (response) => response.json()
3116
+ }, {
3117
+ retryCount: this.featureFlagsRequestMaxRetries,
3118
+ retryCheck: isRetryableFlagsFetchError
3119
+ }, this.featureFlagsRequestTimeoutMs).then((response) => ({
2489
3120
  success: true,
2490
3121
  response: normalizeFlagsResponse(response)
2491
3122
  })).catch((error) => {
@@ -2585,9 +3216,9 @@ class PostHogCoreStateless {
2585
3216
  }
2586
3217
  async getFeatureFlagDetailsStateless(distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip, flagKeysToEvaluate) {
2587
3218
  await this._initPromise;
2588
- const extraPayload = {};
2589
- if (disableGeoip ?? this.disableGeoip)
2590
- extraPayload["geoip_disable"] = true;
3219
+ const extraPayload = {
3220
+ geoip_disable: disableGeoip ?? this.disableGeoip
3221
+ };
2591
3222
  if (flagKeysToEvaluate)
2592
3223
  extraPayload["flag_keys_to_evaluate"] = flagKeysToEvaluate;
2593
3224
  const result = await this.getFlags(distinctId, groups, personProperties, groupProperties, extraPayload);
@@ -2624,15 +3255,18 @@ class PostHogCoreStateless {
2624
3255
  "Content-Type": "application/json"
2625
3256
  }
2626
3257
  };
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;
3258
+ const response = await this.fetchWithRetry(url, fetchOptions, {
3259
+ type: "required",
3260
+ consume: (response) => {
3261
+ if (response.status !== 200 || !response.json) {
3262
+ const msg = `Surveys API could not be loaded: ${response.status}`;
3263
+ const error = new Error(msg);
3264
+ this._logger.error(error);
3265
+ this._events.emit("error", new Error(msg));
3266
+ return Promise.resolve(undefined);
3267
+ }
3268
+ return response.json();
2634
3269
  }
2635
- return response2.json();
2636
3270
  }).catch((error) => {
2637
3271
  this._logger.error("Surveys API could not be loaded", error);
2638
3272
  this._events.emit("error", error);
@@ -2669,23 +3303,39 @@ class PostHogCoreStateless {
2669
3303
  return message;
2670
3304
  }
2671
3305
  async flushStorage() {}
2672
- enqueue(type, _message, options) {
3306
+ getQueueRouteKey(_message) {
3307
+ return DEFAULT_QUEUE_ROUTE;
3308
+ }
3309
+ persistedQueueKeyForRoute(_route) {
3310
+ return types_PostHogPersistedProperty.Queue;
3311
+ }
3312
+ getActiveQueueRoutes() {
3313
+ return [
3314
+ DEFAULT_QUEUE_ROUTE
3315
+ ];
3316
+ }
3317
+ getRouteQueue(route) {
3318
+ return this.getPersistedProperty(this.persistedQueueKeyForRoute(route)) || [];
3319
+ }
3320
+ enqueue(type, _message, options, explicitRoute) {
2673
3321
  this.wrap(() => {
2674
3322
  if (this.optedOut)
2675
3323
  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);
3324
+ let message = this.prepareMessage(_message, options);
2677
3325
  message = this.processBeforeEnqueue(message);
2678
3326
  if (message === null)
2679
3327
  return;
2680
- const queue = this.getPersistedProperty(types_PostHogPersistedProperty.Queue) || [];
3328
+ message = this.normalizeMessage(message);
3329
+ const queueKey = this.persistedQueueKeyForRoute(explicitRoute ?? this.getQueueRouteKey(message));
3330
+ const queue = this.getPersistedProperty(queueKey) || [];
2681
3331
  if (queue.length >= this.maxQueueSize) {
2682
3332
  queue.shift();
2683
- this._logger.info("Queue is full, the oldest event is dropped.");
3333
+ this._logger.warn("Queue is full, the oldest event is dropped.");
2684
3334
  }
2685
3335
  queue.push({
2686
3336
  message
2687
3337
  });
2688
- this.setPersistedProperty(types_PostHogPersistedProperty.Queue, queue);
3338
+ this.setPersistedProperty(queueKey, queue);
2689
3339
  this._events.emit(type, message);
2690
3340
  if (queue.length >= this.flushAt)
2691
3341
  this.flushBackground();
@@ -2693,61 +3343,63 @@ class PostHogCoreStateless {
2693
3343
  this._flushTimer = safeSetTimeout(() => this.flushBackground(), this.flushInterval);
2694
3344
  });
2695
3345
  }
2696
- async sendImmediate(type, _message, options) {
3346
+ async sendImmediate(type, _message, options, explicitRoute) {
2697
3347
  if (this.disabled)
2698
3348
  return void this._logger.warn("The client is disabled");
2699
3349
  if (!this._isInitialized)
2700
3350
  await this._initPromise;
2701
3351
  if (this.optedOut)
2702
3352
  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);
3353
+ let message = this.prepareMessage(_message, options);
2704
3354
  message = this.processBeforeEnqueue(message);
2705
3355
  if (message === null)
2706
3356
  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
- };
3357
+ message = this.normalizeMessage(message);
2730
3358
  try {
2731
- const response = await this.fetchWithRetry(url, fetchOptions);
2732
- await response.body?.cancel()?.catch(() => {});
3359
+ await this.sendBatch([
3360
+ message
3361
+ ], undefined, explicitRoute ?? this.getQueueRouteKey(message));
2733
3362
  } catch (err) {
2734
3363
  this._events.emit("error", err);
2735
3364
  }
2736
3365
  }
2737
- prepareMessage(type, _message, options) {
3366
+ normalizeMessage(message) {
3367
+ const { type: _type, library, library_version, ...sanitizedMessage } = message;
3368
+ let properties = isPostHogEventProperties(sanitizedMessage.properties) ? sanitizedMessage.properties : undefined;
3369
+ if (library !== undefined && properties?.$lib === undefined)
3370
+ properties = {
3371
+ ...properties || {},
3372
+ $lib: library
3373
+ };
3374
+ if (library_version !== undefined && properties?.$lib_version === undefined)
3375
+ properties = {
3376
+ ...properties || {},
3377
+ $lib_version: library_version
3378
+ };
3379
+ if (properties)
3380
+ sanitizedMessage.properties = properties;
3381
+ sanitizedMessage.uuid = getEventUuid(sanitizedMessage.uuid, uuidv7);
3382
+ return sanitizedMessage;
3383
+ }
3384
+ normalizeTimestampForWire(timestamp) {
3385
+ const parsedTimestamp = timestamp instanceof Date ? timestamp : typeof timestamp == "string" ? new Date(timestamp) : null;
3386
+ if (!parsedTimestamp || Number.isNaN(parsedTimestamp.getTime()))
3387
+ return timestamp;
3388
+ const normalized = parsedTimestamp.toISOString();
3389
+ const fractionalSeconds = typeof timestamp == "string" ? timestamp.match(/\.(\d+)(?:Z|[+-]\d{2}:?\d{2})?$/i)?.[1] : undefined;
3390
+ return fractionalSeconds && fractionalSeconds.length > 3 ? normalized.replace(/\.\d{3}Z$/, `.${fractionalSeconds}Z`) : normalized;
3391
+ }
3392
+ prepareMessage(_message, options) {
2738
3393
  const message = {
2739
3394
  ..._message,
2740
- type,
2741
- library: this.getLibraryId(),
2742
- library_version: this.getLibraryVersion(),
2743
3395
  timestamp: options?.timestamp ? options?.timestamp : currentISOTime(),
2744
- uuid: options?.uuid ? options.uuid : uuidv7()
3396
+ uuid: getEventUuid(options?.uuid, uuidv7)
2745
3397
  };
2746
3398
  const addGeoipDisableProperty = options?.disableGeoip ?? this.disableGeoip;
2747
3399
  if (addGeoipDisableProperty) {
2748
- if (!message.properties)
3400
+ if (!isPostHogEventProperties(message.properties))
2749
3401
  message.properties = {};
2750
- message["properties"]["$geoip_disable"] = true;
3402
+ message.properties["$geoip_disable"] = true;
2751
3403
  }
2752
3404
  if (message.distinctId) {
2753
3405
  message.distinct_id = message.distinctId;
@@ -2762,21 +3414,64 @@ class PostHogCoreStateless {
2762
3414
  }
2763
3415
  }
2764
3416
  flushBackground() {
3417
+ if (this.pendingFlushPromise)
3418
+ return;
2765
3419
  this.flush().catch(async (err) => {
2766
3420
  await logFlushError(err);
2767
3421
  });
2768
3422
  }
2769
- async flush() {
3423
+ async waitForPendingPromises(maxPromiseId, ignoredPromises = []) {
3424
+ const ignoredPendingPromises = ignoredPromises.filter((promise) => !!promise);
3425
+ let iteration = 0;
3426
+ while (true) {
3427
+ const promises = this.promiseQueue.getPromises([
3428
+ ...ignoredPendingPromises,
3429
+ ...this.flushPromises
3430
+ ], maxPromiseId);
3431
+ if (promises.length === 0)
3432
+ return;
3433
+ if (iteration > 0)
3434
+ this._logger.debug(`flush() re-checking ${promises.length} pending promise(s) before flushing`);
3435
+ await Promise.all(promises.map((promise) => promise.catch(() => {})));
3436
+ iteration++;
3437
+ }
3438
+ }
3439
+ flushWithPendingPromises() {
3440
+ return this.flushInternal(true);
3441
+ }
3442
+ flush() {
3443
+ return this.flushInternal(false);
3444
+ }
3445
+ flushInternal(waitForPendingPromises) {
2770
3446
  if (this.disabled)
2771
- return;
2772
- const nextFlushPromise = allSettled([
2773
- this.flushPromise
2774
- ]).then(() => this._flush());
3447
+ return Promise.resolve();
3448
+ if (!waitForPendingPromises && this.pendingFlushPromise)
3449
+ return this.pendingFlushPromise;
3450
+ const previousFlushPromise = this.flushPromise;
3451
+ const maxPromiseId = this.promiseQueue.maxId;
3452
+ const nextFlushPromise = Promise.resolve().then(() => {
3453
+ if (waitForPendingPromises)
3454
+ return this.waitForPendingPromises(maxPromiseId, [
3455
+ previousFlushPromise,
3456
+ nextFlushPromise
3457
+ ]);
3458
+ }).then(() => allSettled([
3459
+ previousFlushPromise
3460
+ ])).then(() => {
3461
+ if (this.pendingFlushPromise === nextFlushPromise)
3462
+ this.pendingFlushPromise = null;
3463
+ return this._flush();
3464
+ });
3465
+ this.pendingFlushPromise = nextFlushPromise;
2775
3466
  this.flushPromise = nextFlushPromise;
3467
+ this.flushPromises.add(nextFlushPromise);
2776
3468
  this.addPendingPromise(nextFlushPromise);
2777
3469
  allSettled([
2778
3470
  nextFlushPromise
2779
3471
  ]).then(() => {
3472
+ this.flushPromises.delete(nextFlushPromise);
3473
+ if (this.pendingFlushPromise === nextFlushPromise)
3474
+ this.pendingFlushPromise = null;
2780
3475
  if (this.flushPromise === nextFlushPromise)
2781
3476
  this.flushPromise = null;
2782
3477
  });
@@ -2789,55 +3484,102 @@ class PostHogCoreStateless {
2789
3484
  headers["User-Agent"] = customUserAgent;
2790
3485
  return headers;
2791
3486
  }
3487
+ compressPayload(payload) {
3488
+ return gzipCompress(payload, this.isDebug);
3489
+ }
3490
+ getBatchEndpointPath(_route) {
3491
+ return "/batch/";
3492
+ }
3493
+ async sendBatch(batchMessages, retryOptions, route = DEFAULT_QUEUE_ROUTE) {
3494
+ const data = {
3495
+ api_key: this.apiKey,
3496
+ batch: batchMessages.map((message) => {
3497
+ if (!message)
3498
+ return message;
3499
+ const timestamp = this.normalizeTimestampForWire(message.timestamp);
3500
+ return timestamp === message.timestamp ? message : {
3501
+ ...message,
3502
+ timestamp
3503
+ };
3504
+ }),
3505
+ sent_at: currentISOTime()
3506
+ };
3507
+ if (this.historicalMigration)
3508
+ data.historical_migration = true;
3509
+ const payload = safeJsonStringify(data);
3510
+ const url = `${this.host}${this.getBatchEndpointPath(route)}`;
3511
+ const gzippedPayload = this.disableCompression ? null : await this.compressPayload(payload);
3512
+ const fetchOptions = {
3513
+ method: "POST",
3514
+ headers: {
3515
+ ...this.getCustomHeaders(),
3516
+ "Content-Type": "application/json",
3517
+ ...gzippedPayload !== null && {
3518
+ "Content-Encoding": "gzip"
3519
+ }
3520
+ },
3521
+ body: gzippedPayload || payload
3522
+ };
3523
+ await this.fetchWithRetry(url, fetchOptions, {
3524
+ type: "successful-write"
3525
+ }, retryOptions);
3526
+ }
2792
3527
  async _flush() {
2793
3528
  this.clearFlushTimer();
2794
3529
  await this._initPromise;
2795
- let queue = this.getPersistedProperty(types_PostHogPersistedProperty.Queue) || [];
2796
- if (!queue.length)
3530
+ const routes = this.getActiveQueueRoutes();
3531
+ if (!routes.some((route) => this.getRouteQueue(route).length > 0))
2797
3532
  return;
2798
3533
  const sentMessages = [];
3534
+ let firstError;
3535
+ for (const route of routes)
3536
+ try {
3537
+ await this._flushRoute(route, sentMessages);
3538
+ } catch (err) {
3539
+ if (firstError === undefined)
3540
+ firstError = err;
3541
+ }
3542
+ if (firstError !== undefined)
3543
+ throw firstError;
3544
+ this._events.emit("flush", sentMessages);
3545
+ }
3546
+ async _flushRoute(route, sentMessages) {
3547
+ const queueKey = this.persistedQueueKeyForRoute(route);
3548
+ let queue = this.getPersistedProperty(queueKey) || [];
3549
+ if (!queue.length)
3550
+ return;
2799
3551
  const originalQueueLength = queue.length;
2800
- while (queue.length > 0 && sentMessages.length < originalQueueLength) {
3552
+ let sentFromRoute = 0;
3553
+ while (queue.length > 0 && sentFromRoute < originalQueueLength) {
2801
3554
  const batchItems = queue.slice(0, this.maxBatchSize);
2802
- const batchMessages = batchItems.map((item) => item.message);
3555
+ const batchMessages = batchItems.map((item) => item.message === undefined ? item.message : this.normalizeMessage(item.message));
2803
3556
  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);
3557
+ const refreshedQueue = this.getPersistedProperty(queueKey) || [];
3558
+ const remainingBatchItems = [
3559
+ ...batchItems
3560
+ ];
3561
+ const newQueue = refreshedQueue.filter((item) => {
3562
+ const itemUuid = item.message?.uuid;
3563
+ const batchItemIndex = remainingBatchItems.findIndex((batchItem) => batchItem === item || typeof itemUuid == "string" && itemUuid.length > 0 && batchItem.message?.uuid === itemUuid);
3564
+ if (batchItemIndex === -1)
3565
+ return true;
3566
+ remainingBatchItems.splice(batchItemIndex, 1);
3567
+ return false;
3568
+ });
3569
+ this.setPersistedProperty(queueKey, newQueue);
2807
3570
  queue = newQueue;
3571
+ this._dequeuedMessagesCount += batchItems.length;
2808
3572
  await this.flushStorage();
2809
3573
  };
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
3574
  const retryOptions = {
2832
3575
  retryCheck: (err) => {
2833
3576
  if (isPostHogFetchContentTooLargeError(err))
2834
3577
  return false;
2835
- return isPostHogFetchError(err);
3578
+ return isPostHogFetchRetryableError(err);
2836
3579
  }
2837
3580
  };
2838
3581
  try {
2839
- const response = await this.fetchWithRetry(url, fetchOptions, retryOptions);
2840
- await response.body?.cancel()?.catch(() => {});
3582
+ await this.sendBatch(batchMessages, retryOptions, route);
2841
3583
  } catch (err) {
2842
3584
  if (isPostHogFetchContentTooLargeError(err) && batchMessages.length > 1) {
2843
3585
  this.maxBatchSize = Math.max(1, Math.floor(batchMessages.length / 2));
@@ -2851,8 +3593,8 @@ class PostHogCoreStateless {
2851
3593
  }
2852
3594
  await persistQueueChange();
2853
3595
  sentMessages.push(...batchMessages);
3596
+ sentFromRoute += batchMessages.length;
2854
3597
  }
2855
- this._events.emit("flush", sentMessages);
2856
3598
  }
2857
3599
  async _sendLogsBatch(payload) {
2858
3600
  if (this.disabled)
@@ -2862,7 +3604,7 @@ class PostHogCoreStateless {
2862
3604
  };
2863
3605
  const serialized = JSON.stringify(payload);
2864
3606
  const url = `${this.host}/i/v1/logs?token=${encodeURIComponent(this.apiKey)}`;
2865
- const gzippedPayload = this.disableCompression ? null : await gzipCompress(serialized, this.isDebug);
3607
+ const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
2866
3608
  const fetchOptions = {
2867
3609
  method: "POST",
2868
3610
  headers: {
@@ -2876,10 +3618,12 @@ class PostHogCoreStateless {
2876
3618
  };
2877
3619
  try {
2878
3620
  await this.fetchWithRetry(url, fetchOptions, {
3621
+ type: "successful-write"
3622
+ }, {
2879
3623
  retryCheck: (err) => {
2880
3624
  if (isPostHogFetchContentTooLargeError(err))
2881
3625
  return false;
2882
- return isPostHogFetchError(err);
3626
+ return isPostHogFetchRetryableError(err);
2883
3627
  }
2884
3628
  });
2885
3629
  return {
@@ -2901,41 +3645,155 @@ class PostHogCoreStateless {
2901
3645
  };
2902
3646
  }
2903
3647
  }
2904
- async fetchWithRetry(url, options, retryOptions, requestTimeout) {
3648
+ async _sendMetricsBatch(payload) {
3649
+ if (this.disabled)
3650
+ return {
3651
+ kind: "fatal",
3652
+ error: new Error("The client is disabled")
3653
+ };
3654
+ const serialized = JSON.stringify(payload);
3655
+ const url = `${this.host}/i/v1/metrics?token=${encodeURIComponent(this.apiKey)}`;
3656
+ const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
3657
+ const fetchOptions = {
3658
+ method: "POST",
3659
+ headers: {
3660
+ ...this.getCustomHeaders(),
3661
+ "Content-Type": "application/json",
3662
+ ...gzippedPayload !== null && {
3663
+ "Content-Encoding": "gzip"
3664
+ }
3665
+ },
3666
+ body: gzippedPayload || serialized
3667
+ };
3668
+ try {
3669
+ await this.fetchWithRetry(url, fetchOptions, {
3670
+ type: "successful-write"
3671
+ }, {
3672
+ retryCheck: (err) => {
3673
+ if (isPostHogFetchContentTooLargeError(err))
3674
+ return false;
3675
+ return isPostHogFetchRetryableError(err);
3676
+ }
3677
+ });
3678
+ return {
3679
+ kind: "ok"
3680
+ };
3681
+ } catch (err) {
3682
+ if (isPostHogFetchContentTooLargeError(err))
3683
+ return {
3684
+ kind: "too-large"
3685
+ };
3686
+ if (isPostHogFetchRetryableError(err))
3687
+ return {
3688
+ kind: "retry-later",
3689
+ error: err
3690
+ };
3691
+ return {
3692
+ kind: "fatal",
3693
+ error: err
3694
+ };
3695
+ }
3696
+ }
3697
+ async fetchWithRetry(url, options, responseHandling, retryOptions, requestTimeout) {
2905
3698
  const body = options.body ? options.body : "";
2906
3699
  let reqByteLength = -1;
2907
3700
  try {
2908
- reqByteLength = body instanceof Blob ? body.size : Buffer.byteLength(body, STRING_FORMAT);
3701
+ reqByteLength = body instanceof Blob ? body.size : body instanceof Uint8Array ? body.byteLength : Buffer.byteLength(body, STRING_FORMAT);
2909
3702
  } catch {
2910
3703
  if (body instanceof Blob)
2911
3704
  reqByteLength = body.size;
3705
+ else if (body instanceof Uint8Array)
3706
+ reqByteLength = body.byteLength;
2912
3707
  else {
2913
3708
  const encoded = new TextEncoder().encode(body);
2914
3709
  reqByteLength = encoded.length;
2915
3710
  }
2916
3711
  }
3712
+ const retriableOptions = {
3713
+ ...this._retryOptions,
3714
+ ...retryOptions
3715
+ };
3716
+ let attempt = 0;
2917
3717
  return await retriable(async () => {
3718
+ attempt++;
2918
3719
  const ctrl = new AbortController;
2919
3720
  const timeoutMs = requestTimeout ?? this.requestTimeout;
2920
- const timer = safeSetTimeout(() => ctrl.abort(), timeoutMs);
2921
- let res = null;
3721
+ const requestDeadline = Date.now() + timeoutMs;
3722
+ let timer;
3723
+ const deadline = new Promise((_resolve, reject) => {
3724
+ timer = safeSetTimeout(() => {
3725
+ const timeoutError = new Error(`Request timed out after ${timeoutMs}ms`);
3726
+ timeoutError.name = "AbortError";
3727
+ reject(timeoutError);
3728
+ ctrl.abort(timeoutError);
3729
+ }, timeoutMs);
3730
+ });
3731
+ let res;
3732
+ let responseAccepted = false;
3733
+ let cancellation;
3734
+ const cancelBody = () => cancellation ??= (async () => {
3735
+ try {
3736
+ await res?.body?.cancel();
3737
+ } catch {}
3738
+ })();
2922
3739
  try {
2923
- res = await this.fetch(url, {
2924
- signal: ctrl.signal,
2925
- ...options
2926
- });
2927
- } catch (e) {
2928
- throw new PostHogFetchNetworkError(e);
3740
+ let fetchPromise;
3741
+ try {
3742
+ fetchPromise = this.fetch(url, {
3743
+ signal: ctrl.signal,
3744
+ ...options
3745
+ });
3746
+ } catch (e) {
3747
+ throw new PostHogFetchNetworkError(e);
3748
+ }
3749
+ fetchPromise.then((lateResponse) => {
3750
+ if (ctrl.signal.aborted && !responseAccepted)
3751
+ Promise.resolve(lateResponse.body?.cancel()).catch(() => {});
3752
+ }).catch(() => {});
3753
+ try {
3754
+ res = await Promise.race([
3755
+ fetchPromise,
3756
+ deadline
3757
+ ]);
3758
+ responseAccepted = true;
3759
+ } catch (e) {
3760
+ throw new PostHogFetchNetworkError(e);
3761
+ }
3762
+ const isNoCors = options.mode === "no-cors";
3763
+ if (!isNoCors && (res.status < 200 || res.status >= 400))
3764
+ throw new PostHogFetchHttpError(res, reqByteLength, requestDeadline, ctrl);
3765
+ if (responseHandling.type === "successful-write") {
3766
+ try {
3767
+ await Promise.race([
3768
+ cancelBody(),
3769
+ deadline
3770
+ ]);
3771
+ } catch {}
3772
+ return;
3773
+ }
3774
+ try {
3775
+ return await Promise.race([
3776
+ responseHandling.consume(res),
3777
+ deadline
3778
+ ]);
3779
+ } catch (e) {
3780
+ if (ctrl.signal.aborted)
3781
+ throw new PostHogFetchNetworkError(e);
3782
+ throw e;
3783
+ }
2929
3784
  } finally {
2930
3785
  clearTimeout(timer);
3786
+ if (ctrl.signal.aborted && res)
3787
+ cancelBody();
2931
3788
  }
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
3789
  }, {
2937
- ...this._retryOptions,
2938
- ...retryOptions
3790
+ ...retriableOptions,
3791
+ retryCheck: (error) => {
3792
+ const shouldRetry = retriableOptions.retryCheck(error);
3793
+ if (shouldRetry && attempt <= retriableOptions.retryCount && error instanceof PostHogFetchHttpError)
3794
+ error.cancelResponseBody();
3795
+ return shouldRetry;
3796
+ }
2939
3797
  });
2940
3798
  }
2941
3799
  async _shutdown(shutdownTimeoutMs = 30000) {
@@ -2948,12 +3806,17 @@ class PostHogCoreStateless {
2948
3806
  try {
2949
3807
  await this.promiseQueue.join();
2950
3808
  while (true) {
2951
- const queue = this.getPersistedProperty(types_PostHogPersistedProperty.Queue) || [];
2952
- if (queue.length === 0)
3809
+ const hasQueuedEvents = this.getActiveQueueRoutes().some((route) => this.getRouteQueue(route).length > 0);
3810
+ if (!hasQueuedEvents)
2953
3811
  break;
3812
+ const dequeuedBeforeFlush = this._dequeuedMessagesCount;
2954
3813
  await this.flush();
2955
3814
  if (hasTimedOut)
2956
3815
  break;
3816
+ if (this._dequeuedMessagesCount === dequeuedBeforeFlush) {
3817
+ this._logger.warn("Shutdown flush completed but did not send any queued events. Stopping drain to avoid a loop.");
3818
+ break;
3819
+ }
2957
3820
  }
2958
3821
  } catch (e) {
2959
3822
  if (!isPostHogFetchError(e))
@@ -2961,21 +3824,12 @@ class PostHogCoreStateless {
2961
3824
  await logFlushError(e);
2962
3825
  }
2963
3826
  };
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
- }
3827
+ return raceWithTimeout(doShutdown(), shutdownTimeoutMs, () => {
3828
+ this._logger.critical("Timeout while shutting down PostHog. Some events may not have been sent.", {
3829
+ shutdownTimeoutMs
3830
+ });
3831
+ hasTimedOut = true;
3832
+ });
2979
3833
  }
2980
3834
  async shutdown(shutdownTimeoutMs = 30000) {
2981
3835
  if (this.shutdownPromise)
@@ -2987,21 +3841,30 @@ class PostHogCoreStateless {
2987
3841
  return this.shutdownPromise;
2988
3842
  }
2989
3843
  }
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";
3844
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
3845
+ import { constants as constants2 } from "node:fs";
3846
+ import { open as promises_open } from "node:fs/promises";
3847
+ import { isAbsolute } from "node:path";
2992
3848
  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);
3849
+ var LRU_FILE_CONTENTS_CACHE = new ReduceableCache(25);
3850
+ var LRU_FILE_CONTENTS_FS_READ_FAILED = new ReduceableCache(20);
2995
3851
  var DEFAULT_LINES_OF_CONTEXT = 7;
2996
3852
  var MAX_CONTEXTLINES_COLNO = 1000;
2997
3853
  var MAX_CONTEXTLINES_LINENO = 1e4;
2998
- async function addSourceContext(frames) {
3854
+ var MAX_CONTEXTLINES_FILE_SIZE = 10485760;
3855
+ async function addSourceContext(frames, openSourceFile = promises_open, logger) {
2999
3856
  const filesToLines = {};
3857
+ let basePath;
3858
+ try {
3859
+ basePath = process.cwd();
3860
+ } catch {}
3000
3861
  for (let i = frames.length - 1;i >= 0; i--) {
3001
3862
  const frame = frames[i];
3002
3863
  const filename = frame?.filename;
3003
3864
  if (!frame || typeof filename != "string" || typeof frame.lineno != "number" || shouldSkipContextLinesForFile(filename) || shouldSkipContextLinesForFrame(frame))
3004
3865
  continue;
3866
+ if (!isAbsolute(filename) && basePath === undefined)
3867
+ continue;
3005
3868
  const filesToLinesOutput = filesToLines[filename];
3006
3869
  if (!filesToLinesOutput)
3007
3870
  filesToLines[filename] = [];
@@ -3012,50 +3875,98 @@ async function addSourceContext(frames) {
3012
3875
  return frames;
3013
3876
  const readlinePromises = [];
3014
3877
  for (const file of files) {
3015
- if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(file))
3878
+ const cacheKey = makeSourceCacheKey(file, basePath);
3879
+ if (cacheKey === undefined)
3880
+ continue;
3881
+ if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(cacheKey))
3016
3882
  continue;
3017
3883
  const filesToLineRanges = filesToLines[file];
3018
3884
  if (!filesToLineRanges)
3019
3885
  continue;
3020
3886
  filesToLineRanges.sort((a, b) => a - b);
3021
3887
  const ranges = makeLineReaderRanges(filesToLineRanges);
3022
- if (ranges.every((r) => rangeExistsInContentCache(file, r)))
3888
+ if (ranges.every((r) => rangeExistsInContentCache(cacheKey, r)))
3023
3889
  continue;
3024
- const cache = emplace(LRU_FILE_CONTENTS_CACHE, file, {});
3025
- readlinePromises.push(getContextLinesFromFile(file, ranges, cache));
3890
+ const cache = emplace(LRU_FILE_CONTENTS_CACHE, cacheKey, {});
3891
+ readlinePromises.push(getContextLinesFromFile(file, ranges, cache, cacheKey, openSourceFile, logger));
3026
3892
  }
3027
3893
  await Promise.all(readlinePromises).catch(() => {});
3028
3894
  if (frames && frames.length > 0)
3029
- addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE);
3895
+ addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE, basePath);
3030
3896
  LRU_FILE_CONTENTS_CACHE.reduce();
3031
3897
  return frames;
3032
3898
  }
3033
- function getContextLinesFromFile(path2, ranges, output) {
3899
+ async function openRegularSourceFile(path, openSourceFile, logger) {
3900
+ let fileHandle;
3901
+ let isValid = false;
3902
+ try {
3903
+ fileHandle = await openSourceFile(path, constants2.O_RDONLY | constants2.O_NONBLOCK);
3904
+ const fileStat = await fileHandle.stat();
3905
+ if (!fileStat.isFile())
3906
+ return;
3907
+ if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE)
3908
+ return void logger?.debug(`Skipping source context for oversized file ${path}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
3909
+ isValid = true;
3910
+ return fileHandle;
3911
+ } catch {
3912
+ return;
3913
+ } finally {
3914
+ if (fileHandle && !isValid)
3915
+ await fileHandle.close().catch(() => {});
3916
+ }
3917
+ }
3918
+ async function getContextLinesFromFile(path, ranges, output, cacheKey, openSourceFile, logger) {
3919
+ const fileHandle = await openRegularSourceFile(path, openSourceFile, logger);
3920
+ if (fileHandle === undefined)
3921
+ return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
3922
+ const openedFileHandle = fileHandle;
3034
3923
  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();
3924
+ let finished = false;
3925
+ function destroyStreamAndResolve(stream) {
3926
+ if (finished)
3927
+ return;
3928
+ finished = true;
3929
+ stream?.destroy();
3930
+ openedFileHandle.close().then(resolve, resolve);
3931
+ }
3932
+ let stream;
3933
+ try {
3934
+ stream = openedFileHandle.createReadStream({
3935
+ autoClose: false,
3936
+ start: 0,
3937
+ end: MAX_CONTEXTLINES_FILE_SIZE - 1
3938
+ });
3939
+ } catch {
3940
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
3941
+ destroyStreamAndResolve();
3942
+ return;
3943
+ }
3944
+ let lineReaded;
3945
+ try {
3946
+ lineReaded = createInterface({
3947
+ input: stream
3948
+ });
3949
+ } catch {
3950
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
3951
+ destroyStreamAndResolve(stream);
3952
+ return;
3042
3953
  }
3043
3954
  let lineNumber = 0;
3044
3955
  let currentRangeIndex = 0;
3045
3956
  const range = ranges[currentRangeIndex];
3046
3957
  if (range === undefined)
3047
- return void destroyStreamAndResolve();
3958
+ return void destroyStreamAndResolve(stream);
3048
3959
  let rangeStart = range[0];
3049
3960
  let rangeEnd = range[1];
3050
3961
  function onStreamError() {
3051
- LRU_FILE_CONTENTS_FS_READ_FAILED.set(path2, 1);
3962
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
3052
3963
  lineReaded.close();
3053
3964
  lineReaded.removeAllListeners();
3054
- destroyStreamAndResolve();
3965
+ destroyStreamAndResolve(stream);
3055
3966
  }
3056
3967
  stream.on("error", onStreamError);
3057
3968
  lineReaded.on("error", onStreamError);
3058
- lineReaded.on("close", destroyStreamAndResolve);
3969
+ lineReaded.on("close", () => destroyStreamAndResolve(stream));
3059
3970
  lineReaded.on("line", (line) => {
3060
3971
  lineNumber++;
3061
3972
  if (lineNumber < rangeStart)
@@ -3068,22 +3979,23 @@ function getContextLinesFromFile(path2, ranges, output) {
3068
3979
  return;
3069
3980
  }
3070
3981
  currentRangeIndex++;
3071
- const range2 = ranges[currentRangeIndex];
3072
- if (range2 === undefined) {
3982
+ const range = ranges[currentRangeIndex];
3983
+ if (range === undefined) {
3073
3984
  lineReaded.close();
3074
3985
  lineReaded.removeAllListeners();
3075
3986
  return;
3076
3987
  }
3077
- rangeStart = range2[0];
3078
- rangeEnd = range2[1];
3988
+ rangeStart = range[0];
3989
+ rangeEnd = range[1];
3079
3990
  }
3080
3991
  });
3081
3992
  });
3082
3993
  }
3083
- function addSourceContextToFrames(frames, cache) {
3994
+ function addSourceContextToFrames(frames, cache, basePath) {
3084
3995
  for (const frame of frames)
3085
3996
  if (frame.filename && frame.context_line === undefined && typeof frame.lineno == "number") {
3086
- const contents = cache.get(frame.filename);
3997
+ const cacheKey = makeSourceCacheKey(frame.filename, basePath);
3998
+ const contents = cacheKey === undefined ? undefined : cache.get(cacheKey);
3087
3999
  if (contents === undefined)
3088
4000
  continue;
3089
4001
  addContextToFrame(frame.lineno, frame, contents);
@@ -3116,8 +4028,8 @@ function clearLineContext(frame) {
3116
4028
  delete frame.context_line;
3117
4029
  delete frame.post_context;
3118
4030
  }
3119
- function shouldSkipContextLinesForFile(path2) {
3120
- return path2.startsWith("node:") || path2.endsWith(".min.js") || path2.endsWith(".min.cjs") || path2.endsWith(".min.mjs") || path2.startsWith("data:");
4031
+ function shouldSkipContextLinesForFile(path) {
4032
+ return path.startsWith("node:") || path.endsWith(".min.js") || path.endsWith(".min.cjs") || path.endsWith(".min.mjs") || path.startsWith("data:");
3121
4033
  }
3122
4034
  function shouldSkipContextLinesForFrame(frame) {
3123
4035
  if (frame.lineno !== undefined && frame.lineno > MAX_CONTEXTLINES_LINENO)
@@ -3126,8 +4038,19 @@ function shouldSkipContextLinesForFrame(frame) {
3126
4038
  return true;
3127
4039
  return false;
3128
4040
  }
3129
- function rangeExistsInContentCache(file, range) {
3130
- const contents = LRU_FILE_CONTENTS_CACHE.get(file);
4041
+ function makeSourceCacheKey(path, basePath) {
4042
+ if (isAbsolute(path))
4043
+ return JSON.stringify([
4044
+ null,
4045
+ path
4046
+ ]);
4047
+ return basePath === undefined ? undefined : JSON.stringify([
4048
+ basePath,
4049
+ path
4050
+ ]);
4051
+ }
4052
+ function rangeExistsInContentCache(cacheKey, range) {
4053
+ const contents = LRU_FILE_CONTENTS_CACHE.get(cacheKey);
3131
4054
  if (contents === undefined)
3132
4055
  return false;
3133
4056
  for (let i = range[0];i <= range[1]; i++)
@@ -3205,8 +4128,8 @@ function snipLine(line, colno) {
3205
4128
  return newLine;
3206
4129
  }
3207
4130
 
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";
4131
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
4132
+ import { isAbsolute as isAbsolute2, relative, sep as sep2 } from "path";
3210
4133
  function createRelativePathModifier(basePath = process.cwd()) {
3211
4134
  const isWindows = sep2 === "\\";
3212
4135
  const toUnix = (p) => isWindows ? p.replace(/\\/g, "/") : p;
@@ -3214,17 +4137,17 @@ function createRelativePathModifier(basePath = process.cwd()) {
3214
4137
  return async (frames) => {
3215
4138
  for (const frame of frames)
3216
4139
  if (!(!frame.filename || frame.filename.startsWith("node:") || frame.filename.startsWith("data:"))) {
3217
- if (isAbsolute(frame.filename))
4140
+ if (isAbsolute2(frame.filename))
3218
4141
  frame.filename = toUnix(relative(normalizedBase, toUnix(frame.filename)));
3219
4142
  }
3220
4143
  return frames;
3221
4144
  };
3222
4145
  }
3223
4146
 
3224
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/version.mjs
3225
- var version = "5.35.12";
4147
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/version.mjs
4148
+ var version = "5.51.1";
3226
4149
 
3227
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/types.mjs
4150
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/types.mjs
3228
4151
  var FeatureFlagError2 = {
3229
4152
  ERRORS_WHILE_COMPUTING: "errors_while_computing_flags",
3230
4153
  FLAG_MISSING: "flag_missing",
@@ -3232,7 +4155,7 @@ var FeatureFlagError2 = {
3232
4155
  UNKNOWN_ERROR: "unknown_error"
3233
4156
  };
3234
4157
 
3235
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/feature-flag-evaluations.mjs
4158
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/feature-flag-evaluations.mjs
3236
4159
  class FeatureFlagEvaluations {
3237
4160
  constructor(init) {
3238
4161
  this._host = init.host;
@@ -3248,10 +4171,10 @@ class FeatureFlagEvaluations {
3248
4171
  this._accessed = init.accessed ?? new Set;
3249
4172
  this._isSlice = init.isSlice ?? false;
3250
4173
  }
3251
- isEnabled(key) {
4174
+ isEnabled(key, options = {}) {
3252
4175
  const flag = this._flags[key];
3253
4176
  this._recordAccess(key);
3254
- return flag?.enabled ?? false;
4177
+ return flag?.enabled ?? options.defaultValue ?? false;
3255
4178
  }
3256
4179
  getFlag(key) {
3257
4180
  const flag = this._flags[key];
@@ -3341,6 +4264,8 @@ class FeatureFlagEvaluations {
3341
4264
  $feature_flag_request_id: this._requestId,
3342
4265
  $feature_flag_evaluated_at: flag?.locallyEvaluated ? Date.now() : this._evaluatedAt
3343
4266
  };
4267
+ if (flag?.hasExperiment !== undefined)
4268
+ properties.$feature_flag_has_experiment = flag.hasExperiment;
3344
4269
  if (flag?.locallyEvaluated && this._flagDefinitionsLoadedAt !== undefined)
3345
4270
  properties.$feature_flag_definitions_loaded_at = this._flagDefinitionsLoadedAt;
3346
4271
  const errors = [];
@@ -3363,7 +4288,7 @@ class FeatureFlagEvaluations {
3363
4288
  }
3364
4289
  }
3365
4290
 
3366
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
4291
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
3367
4292
  async function hashSHA1(text) {
3368
4293
  const subtle = globalThis.crypto?.subtle;
3369
4294
  if (!subtle)
@@ -3373,7 +4298,7 @@ async function hashSHA1(text) {
3373
4298
  return hashArray.map((byte) => byte.toString(16).padStart(2, "0")).join("");
3374
4299
  }
3375
4300
 
3376
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
4301
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
3377
4302
  var SIXTY_SECONDS = 60000;
3378
4303
  var LONG_SCALE = 1152921504606847000;
3379
4304
  var NULL_VALUES_ALLOWED_OPERATORS = [
@@ -3390,22 +4315,23 @@ class ClientError extends Error {
3390
4315
  Object.setPrototypeOf(this, ClientError.prototype);
3391
4316
  }
3392
4317
  }
4318
+ function setCustomErrorPrototype(error, constructor) {
4319
+ error.name = constructor.name;
4320
+ Error.captureStackTrace(error, constructor);
4321
+ Object.setPrototypeOf(error, constructor.prototype);
4322
+ }
3393
4323
 
3394
4324
  class InconclusiveMatchError extends Error {
3395
4325
  constructor(message) {
3396
4326
  super(message);
3397
- this.name = this.constructor.name;
3398
- Error.captureStackTrace(this, this.constructor);
3399
- Object.setPrototypeOf(this, InconclusiveMatchError.prototype);
4327
+ setCustomErrorPrototype(this, InconclusiveMatchError);
3400
4328
  }
3401
4329
  }
3402
4330
 
3403
4331
  class RequiresServerEvaluation extends Error {
3404
4332
  constructor(message) {
3405
4333
  super(message);
3406
- this.name = this.constructor.name;
3407
- Error.captureStackTrace(this, this.constructor);
3408
- Object.setPrototypeOf(this, RequiresServerEvaluation.prototype);
4334
+ setCustomErrorPrototype(this, RequiresServerEvaluation);
3409
4335
  }
3410
4336
  }
3411
4337
 
@@ -3414,6 +4340,7 @@ class FeatureFlagsPoller {
3414
4340
  this.debugMode = false;
3415
4341
  this.shouldBeginExponentialBackoff = false;
3416
4342
  this.backOffCount = 0;
4343
+ this.pollerStopped = false;
3417
4344
  this.pollingInterval = pollingInterval;
3418
4345
  this.personalApiKey = personalApiKey;
3419
4346
  this.featureFlags = [];
@@ -3429,6 +4356,7 @@ class FeatureFlagsPoller {
3429
4356
  this.onError = options.onError;
3430
4357
  this.customHeaders = customHeaders;
3431
4358
  this.onLoad = options.onLoad;
4359
+ this.onMinimalFlagCalledEvents = options.onMinimalFlagCalledEvents;
3432
4360
  this.cacheProvider = options.cacheProvider;
3433
4361
  this.strictLocalEvaluation = options.strictLocalEvaluation ?? false;
3434
4362
  this.loadFeatureFlags();
@@ -3626,6 +4554,7 @@ class FeatureFlagsPoller {
3626
4554
  const flagFilters = flag.filters || {};
3627
4555
  const flagConditions = flagFilters.groups || [];
3628
4556
  const flagAggregation = flagFilters.aggregation_group_type_index;
4557
+ const earlyExitEnabled = flagFilters.early_exit ?? false;
3629
4558
  const { groups, groupProperties } = evaluationContext;
3630
4559
  let isInconclusive = false;
3631
4560
  let result;
@@ -3649,12 +4578,15 @@ class FeatureFlagsPoller {
3649
4578
  effectiveBucketingValue = groups[groupName];
3650
4579
  }
3651
4580
  }
3652
- if (await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext)) {
4581
+ const matchResult = await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext);
4582
+ if (matchResult === "match") {
3653
4583
  const variantOverride = condition.variant;
3654
4584
  const flagVariants = flagFilters.multivariate?.variants || [];
3655
4585
  result = variantOverride && flagVariants.some((variant) => variant.key === variantOverride) ? variantOverride : await this.getMatchingVariant(flag, effectiveBucketingValue) || true;
3656
4586
  break;
3657
4587
  }
4588
+ if (earlyExitEnabled && matchResult === "out_of_rollout_bound")
4589
+ return false;
3658
4590
  } catch (e) {
3659
4591
  if (e instanceof RequiresServerEvaluation)
3660
4592
  throw e;
@@ -3678,16 +4610,20 @@ class FeatureFlagsPoller {
3678
4610
  for (const prop of condition.properties) {
3679
4611
  const propertyType = prop.type;
3680
4612
  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);
4613
+ if (propertyType === "cohort") {
4614
+ const inCohort = await matchCohort(prop, properties, this.cohorts, this.debugMode, (depProp) => this.evaluateFlagDependency(depProp, properties, evaluationContext));
4615
+ matches = prop.operator === "not_in" ? !inCohort : inCohort;
4616
+ } else
4617
+ matches = propertyType === "flag" ? await this.evaluateFlagDependency(prop, properties, evaluationContext) : matchProperty(prop, properties, warnFunction);
3682
4618
  if (!matches)
3683
- return false;
4619
+ return "no_match";
3684
4620
  }
3685
4621
  if (rolloutPercentage == undefined)
3686
- return true;
4622
+ return "match";
3687
4623
  }
3688
4624
  if (rolloutPercentage != null && await _hash(flag.key, bucketingValue) > rolloutPercentage / 100)
3689
- return false;
3690
- return true;
4625
+ return "out_of_rollout_bound";
4626
+ return "match";
3691
4627
  }
3692
4628
  async getMatchingVariant(flag, bucketingValue) {
3693
4629
  const hashValue = await _hash(flag.key, bucketingValue, "variant");
@@ -3718,6 +4654,7 @@ class FeatureFlagsPoller {
3718
4654
  this.groupTypeMapping = flagData.groupTypeMapping;
3719
4655
  this.cohorts = flagData.cohorts;
3720
4656
  this.loadedSuccessfullyOnce = true;
4657
+ this.onMinimalFlagCalledEvents?.(flagData.minimalFlagCalledEvents === true);
3721
4658
  }
3722
4659
  warnAboutExperienceContinuityFlags(flags) {
3723
4660
  if (this.strictLocalEvaluation)
@@ -3781,7 +4718,6 @@ class FeatureFlagsPoller {
3781
4718
  clearTimeout(this.poller);
3782
4719
  this.poller = undefined;
3783
4720
  }
3784
- this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
3785
4721
  try {
3786
4722
  let shouldFetch = true;
3787
4723
  if (this.cacheProvider)
@@ -3809,17 +4745,18 @@ class FeatureFlagsPoller {
3809
4745
  return;
3810
4746
  case 401:
3811
4747
  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`);
4748
+ 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
4749
  case 402:
3814
4750
  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
4751
  this.featureFlags = [];
3816
4752
  this.featureFlagsByKey = {};
3817
4753
  this.groupTypeMapping = {};
3818
4754
  this.cohorts = {};
4755
+ this.onMinimalFlagCalledEvents?.(false);
3819
4756
  return;
3820
4757
  case 403:
3821
4758
  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`);
4759
+ 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
4760
  case 429:
3824
4761
  this.beginBackoff();
3825
4762
  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 +4768,8 @@ class FeatureFlagsPoller {
3831
4768
  const flagData = {
3832
4769
  flags: responseJson.flags ?? [],
3833
4770
  groupTypeMapping: responseJson.group_type_mapping || {},
3834
- cohorts: responseJson.cohorts || {}
4771
+ cohorts: responseJson.cohorts || {},
4772
+ minimalFlagCalledEvents: responseJson.minimal_flag_called_events === true
3835
4773
  };
3836
4774
  this.updateFlagState(flagData);
3837
4775
  this.flagDefinitionsLoadedAt = Date.now();
@@ -3852,6 +4790,9 @@ class FeatureFlagsPoller {
3852
4790
  } catch (err) {
3853
4791
  if (err instanceof ClientError)
3854
4792
  this.onError?.(err);
4793
+ } finally {
4794
+ if (!this.pollerStopped)
4795
+ this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
3855
4796
  }
3856
4797
  }
3857
4798
  getPersonalApiKeyRequestOptions(method = "GET", etag) {
@@ -3867,7 +4808,7 @@ class FeatureFlagsPoller {
3867
4808
  headers
3868
4809
  };
3869
4810
  }
3870
- _requestFeatureFlagDefinitions() {
4811
+ async _requestFeatureFlagDefinitions() {
3871
4812
  const url = `${this.host}/flags/definitions?token=${this.projectApiKey}&send_cohorts`;
3872
4813
  const options = this.getPersonalApiKeyRequestOptions("GET", this.flagsEtag);
3873
4814
  let abortTimeout = null;
@@ -3878,23 +4819,49 @@ class FeatureFlagsPoller {
3878
4819
  }, this.timeout);
3879
4820
  options.signal = controller.signal;
3880
4821
  }
4822
+ const clearAbortTimeout = () => clearTimeout(abortTimeout);
3881
4823
  try {
3882
4824
  const fetch1 = this.fetch;
3883
- return fetch1(url, options);
3884
- } finally {
3885
- clearTimeout(abortTimeout);
4825
+ const res = await fetch1(url, options);
4826
+ if (res.status !== 200) {
4827
+ clearAbortTimeout();
4828
+ return res;
4829
+ }
4830
+ return {
4831
+ status: res.status,
4832
+ headers: res.headers,
4833
+ body: res.body,
4834
+ text: async () => {
4835
+ try {
4836
+ return await res.text();
4837
+ } finally {
4838
+ clearAbortTimeout();
4839
+ }
4840
+ },
4841
+ json: async () => {
4842
+ try {
4843
+ return await res.json();
4844
+ } finally {
4845
+ clearAbortTimeout();
4846
+ }
4847
+ }
4848
+ };
4849
+ } catch (err) {
4850
+ clearAbortTimeout();
4851
+ throw err;
3886
4852
  }
3887
4853
  }
3888
4854
  async stopPoller(timeoutMs = 30000) {
4855
+ this.pollerStopped = true;
3889
4856
  clearTimeout(this.poller);
4857
+ this.poller = undefined;
3890
4858
  if (this.cacheProvider)
3891
4859
  try {
3892
4860
  const shutdownResult = this.cacheProvider.shutdown();
3893
4861
  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
- ]);
4862
+ await raceWithTimeout(shutdownResult, timeoutMs, () => {
4863
+ throw new Error(`Cache shutdown timeout after ${timeoutMs}ms`);
4864
+ });
3898
4865
  } catch (err) {
3899
4866
  this.onError?.(new Error(`Error during cache shutdown: ${err}`));
3900
4867
  }
@@ -3922,21 +4889,21 @@ function matchProperty(property, propertyValues, warnFunction) {
3922
4889
  warnFunction(`Property ${key} cannot have a value of null/undefined with the ${operator} operator`);
3923
4890
  return false;
3924
4891
  }
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();
4892
+ function computeExactMatch(value, overrideValue) {
4893
+ if (Array.isArray(value))
4894
+ return value.map((val) => String(val).toLowerCase()).includes(String(overrideValue).toLowerCase());
4895
+ return String(value).toLowerCase() === String(overrideValue).toLowerCase();
3929
4896
  }
3930
- function compare(lhs, rhs, operator2) {
3931
- if (operator2 === "gt")
4897
+ function compare(lhs, rhs, operator) {
4898
+ if (operator === "gt")
3932
4899
  return lhs > rhs;
3933
- if (operator2 === "gte")
4900
+ if (operator === "gte")
3934
4901
  return lhs >= rhs;
3935
- if (operator2 === "lt")
4902
+ if (operator === "lt")
3936
4903
  return lhs < rhs;
3937
- if (operator2 === "lte")
4904
+ if (operator === "lte")
3938
4905
  return lhs <= rhs;
3939
- throw new Error(`Invalid operator: ${operator2}`);
4906
+ throw new Error(`Invalid operator: ${operator}`);
3940
4907
  }
3941
4908
  switch (operator) {
3942
4909
  case "exact":
@@ -3949,6 +4916,14 @@ function matchProperty(property, propertyValues, warnFunction) {
3949
4916
  return String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
3950
4917
  case "not_icontains":
3951
4918
  return !String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
4919
+ case "starts_with":
4920
+ return String(overrideValue).toLowerCase().startsWith(String(value).toLowerCase());
4921
+ case "not_starts_with":
4922
+ return !String(overrideValue).toLowerCase().startsWith(String(value).toLowerCase());
4923
+ case "ends_with":
4924
+ return String(overrideValue).toLowerCase().endsWith(String(value).toLowerCase());
4925
+ case "not_ends_with":
4926
+ return !String(overrideValue).toLowerCase().endsWith(String(value).toLowerCase());
3952
4927
  case "regex":
3953
4928
  return isValidRegex(String(value)) && String(overrideValue).match(String(value)) !== null;
3954
4929
  case "not_regex":
@@ -4275,19 +5250,75 @@ function relativeDateParseForFeatureFlagMatching(value) {
4275
5250
  }
4276
5251
  }
4277
5252
 
4278
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
5253
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
5254
+ var UNHANDLED_REJECTION_OPTION_NAMES = [
5255
+ "--unhandled-rejections",
5256
+ "--unhandled_rejections"
5257
+ ];
5258
+ var UNHANDLED_REJECTION_MODES = new Set([
5259
+ "throw",
5260
+ "strict",
5261
+ "warn",
5262
+ "warn-with-error-code",
5263
+ "none"
5264
+ ]);
5265
+ var STARTUP_EXEC_ARGV = [
5266
+ ...globalThis.process?.execArgv ?? []
5267
+ ];
5268
+ var STARTUP_NODE_OPTIONS = globalThis.process?.env?.NODE_OPTIONS;
5269
+ function splitNodeOptions(nodeOptions) {
5270
+ const args = [];
5271
+ let current = "";
5272
+ let isInString = false;
5273
+ for (let index = 0;index < nodeOptions.length; index++) {
5274
+ const character = nodeOptions[index];
5275
+ if (character === "\\" && isInString && index + 1 < nodeOptions.length)
5276
+ current += nodeOptions[++index];
5277
+ else if (character !== " " || isInString)
5278
+ if (character === '"')
5279
+ isInString = !isInString;
5280
+ else
5281
+ current += character;
5282
+ else if (current) {
5283
+ args.push(current);
5284
+ current = "";
5285
+ }
5286
+ }
5287
+ if (current)
5288
+ args.push(current);
5289
+ return args;
5290
+ }
5291
+ function findUnhandledRejectionMode(args) {
5292
+ let mode;
5293
+ for (let index = 0;index < args.length; index++) {
5294
+ const argument = args[index];
5295
+ const optionName = UNHANDLED_REJECTION_OPTION_NAMES.find((name) => argument === name || argument.startsWith(`${name}=`));
5296
+ if (!optionName)
5297
+ continue;
5298
+ const value = argument === optionName ? args[++index] : argument.slice(optionName.length + 1);
5299
+ if (UNHANDLED_REJECTION_MODES.has(value))
5300
+ mode = value;
5301
+ }
5302
+ return mode;
5303
+ }
5304
+ function getUnhandledRejectionMode(execArgv = STARTUP_EXEC_ARGV, nodeOptions = STARTUP_NODE_OPTIONS) {
5305
+ return findUnhandledRejectionMode(execArgv) ?? findUnhandledRejectionMode(splitNodeOptions(nodeOptions ?? "")) ?? "throw";
5306
+ }
5307
+ var STARTUP_UNHANDLED_REJECTION_MODE = getUnhandledRejectionMode();
5308
+ function captureUncaughtException(captureFn, error, origin) {
5309
+ captureFn(error, {
5310
+ mechanism: {
5311
+ type: origin === "unhandledRejection" ? "onunhandledrejection" : "onuncaughtexception",
5312
+ handled: false
5313
+ }
5314
+ });
5315
+ }
4279
5316
  function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
4280
5317
  let calledFatalError = false;
4281
- return Object.assign((error) => {
5318
+ return Object.assign((error, origin) => {
4282
5319
  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) {
5320
+ captureUncaughtException(captureFn, error, origin);
5321
+ if (!calledFatalError && userProvidedListenersCount === 0) {
4291
5322
  calledFatalError = true;
4292
5323
  onFatalFn(error);
4293
5324
  }
@@ -4295,29 +5326,38 @@ function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
4295
5326
  _posthogErrorHandler: true
4296
5327
  });
4297
5328
  }
4298
- function addUncaughtExceptionListener(captureFn, onFatalFn) {
4299
- globalThis.process?.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
5329
+ function addUncaughtExceptionListener(captureFn, onFatalFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
5330
+ const process2 = globalThis.process;
5331
+ if (!process2)
5332
+ return;
5333
+ if (mode === "strict")
5334
+ return void process2.on("uncaughtExceptionMonitor", (error, origin) => captureUncaughtException(captureFn, error, origin));
5335
+ process2.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
4300
5336
  }
4301
- function addUnhandledRejectionListener(captureFn) {
4302
- globalThis.process?.on("unhandledRejection", (reason) => captureFn(reason, {
4303
- mechanism: {
4304
- type: "onunhandledrejection",
4305
- handled: false
4306
- }
4307
- }));
5337
+ function addUnhandledRejectionListener(captureFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
5338
+ const process2 = globalThis.process;
5339
+ if (!process2 || mode === "throw" || mode === "strict" || mode === "warn-with-error-code")
5340
+ return;
5341
+ process2.on("unhandledRejection", (reason) => {
5342
+ captureFn(reason, {
5343
+ mechanism: {
5344
+ type: "onunhandledrejection",
5345
+ handled: false
5346
+ }
5347
+ });
5348
+ });
4308
5349
  }
4309
5350
 
4310
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
5351
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
4311
5352
  var SHUTDOWN_TIMEOUT = 2000;
4312
5353
 
4313
- class ErrorTracking {
5354
+ class error_tracking_ErrorTracking {
4314
5355
  constructor(client, options, _logger) {
4315
5356
  this.client = client;
4316
5357
  this._exceptionAutocaptureEnabled = options.enableExceptionAutocapture || false;
4317
5358
  this._logger = _logger;
4318
5359
  this._rateLimiter = new BucketedRateLimiter({
4319
- refillRate: 1,
4320
- bucketSize: 10,
5360
+ ...resolveExceptionRateLimiterConfig(options),
4321
5361
  refillInterval: 1e4,
4322
5362
  _logger: this._logger
4323
5363
  });
@@ -4332,6 +5372,9 @@ class ErrorTracking {
4332
5372
  };
4333
5373
  const exceptionProperties = builder.buildFromUnknown(error, hint);
4334
5374
  exceptionProperties.$exception_list = await builder.modifyFrames(exceptionProperties.$exception_list);
5375
+ const injectedReleaseId = getInjectedReleaseId();
5376
+ if (injectedReleaseId)
5377
+ properties.$release_id = injectedReleaseId;
4335
5378
  return {
4336
5379
  event: "$exception",
4337
5380
  distinctId,
@@ -4350,8 +5393,8 @@ class ErrorTracking {
4350
5393
  }
4351
5394
  onException(exception, hint) {
4352
5395
  this.client.addPendingPromise((async () => {
4353
- if (!ErrorTracking.isPreviouslyCapturedError(exception)) {
4354
- const eventMessage = await ErrorTracking.buildEventMessage(this.client.getErrorPropertiesBuilder(), exception, hint);
5396
+ if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(exception)) {
5397
+ const eventMessage = await error_tracking_ErrorTracking.buildEventMessage(this.client.getErrorPropertiesBuilder(), exception, hint);
4355
5398
  const exceptionProperties = eventMessage.properties;
4356
5399
  const exceptionType = exceptionProperties?.$exception_list[0]?.type ?? "Exception";
4357
5400
  const isRateLimited = this._rateLimiter.consumeRateLimit(exceptionType);
@@ -4359,14 +5402,14 @@ class ErrorTracking {
4359
5402
  return void this._logger.info("Skipping exception capture because of client rate limiting.", {
4360
5403
  exception: exceptionType
4361
5404
  });
4362
- return this.client.capture(eventMessage);
5405
+ return this.client._capturePreparedEvent(eventMessage, false);
4363
5406
  }
4364
5407
  })());
4365
5408
  }
4366
5409
  async onFatalError(exception) {
4367
5410
  console.error(exception);
4368
5411
  await this.client.shutdown(SHUTDOWN_TIMEOUT);
4369
- process.exit(1);
5412
+ globalThis.process.exit(1);
4370
5413
  }
4371
5414
  isEnabled() {
4372
5415
  return !this.client.isDisabled && this._exceptionAutocaptureEnabled;
@@ -4376,7 +5419,7 @@ class ErrorTracking {
4376
5419
  }
4377
5420
  }
4378
5421
 
4379
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/storage-memory.mjs
5422
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/storage-memory.mjs
4380
5423
  class PostHogMemoryStorage {
4381
5424
  getProperty(key) {
4382
5425
  return this._memoryStorage[key];
@@ -4389,7 +5432,452 @@ class PostHogMemoryStorage {
4389
5432
  }
4390
5433
  }
4391
5434
 
4392
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/client.mjs
5435
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/config.mjs
5436
+ function isCaptureMode(value) {
5437
+ return value === "v0" || value === "v1";
5438
+ }
5439
+ function resolveCaptureMode() {
5440
+ const envMode = typeof process != "undefined" ? process.env?.POSTHOG_CAPTURE_MODE : undefined;
5441
+ return isCaptureMode(envMode) ? envMode : "v0";
5442
+ }
5443
+
5444
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/routing.mjs
5445
+ var AI_EVENT_PREFIX = "$ai_";
5446
+ var ANALYTICS_ROUTE = "analytics";
5447
+ var AI_ROUTE = "ai";
5448
+ function isLegacyOnlyEvent(message) {
5449
+ return typeof message.event == "string" && message.event.startsWith(AI_EVENT_PREFIX);
5450
+ }
5451
+
5452
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/errors.mjs
5453
+ class CaptureV1Error extends Error {
5454
+ constructor({ requestId, drops, retryExhausted, cause }) {
5455
+ super(CaptureV1Error.buildMessage(requestId, drops, retryExhausted, cause)), this.name = "CaptureV1Error";
5456
+ this.requestId = requestId;
5457
+ this.drops = drops;
5458
+ this.retryExhausted = retryExhausted;
5459
+ this.cause = cause;
5460
+ }
5461
+ static buildMessage(requestId, drops, retryExhausted, cause) {
5462
+ let message = `Capture V1 batch ${requestId} did not fully deliver: ${drops.length} dropped, ${retryExhausted.length} undelivered`;
5463
+ if (cause instanceof Error)
5464
+ message += ` (${cause.message})`;
5465
+ return message;
5466
+ }
5467
+ }
5468
+
5469
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/transform.mjs
5470
+ function coerceBool(value) {
5471
+ if (typeof value == "boolean")
5472
+ return value;
5473
+ if (typeof value == "number")
5474
+ return value !== 0;
5475
+ if (typeof value == "string") {
5476
+ const normalized = value.trim().toLowerCase();
5477
+ if (normalized === "true" || normalized === "1")
5478
+ return true;
5479
+ if (normalized === "false" || normalized === "0")
5480
+ return false;
5481
+ }
5482
+ }
5483
+ function coerceString(value) {
5484
+ return typeof value == "string" ? value : undefined;
5485
+ }
5486
+ var OPTION_SENTINELS = [
5487
+ {
5488
+ property: "$cookieless_mode",
5489
+ optionKey: "cookieless_mode",
5490
+ coerce: coerceBool
5491
+ },
5492
+ {
5493
+ property: "$ignore_sent_at",
5494
+ optionKey: "disable_skew_correction",
5495
+ coerce: coerceBool
5496
+ },
5497
+ {
5498
+ property: "$process_person_profile",
5499
+ optionKey: "process_person_profile",
5500
+ coerce: coerceBool
5501
+ },
5502
+ {
5503
+ property: "$product_tour_id",
5504
+ optionKey: "product_tour_id",
5505
+ coerce: coerceString
5506
+ }
5507
+ ];
5508
+ var TOPLEVEL_SENTINELS = [
5509
+ {
5510
+ property: "$session_id",
5511
+ field: "session_id"
5512
+ },
5513
+ {
5514
+ property: "$window_id",
5515
+ field: "window_id"
5516
+ }
5517
+ ];
5518
+ function isRecord2(value) {
5519
+ return typeof value == "object" && value !== null && !Array.isArray(value);
5520
+ }
5521
+ function toRfc3339(timestamp) {
5522
+ if (typeof timestamp == "string") {
5523
+ const asDate = new Date(timestamp);
5524
+ if (Number.isNaN(asDate.getTime()))
5525
+ return new Date().toISOString();
5526
+ const normalized = asDate.toISOString();
5527
+ const fractionalSeconds = timestamp.match(/\.(\d+)(?:Z|[+-]\d{2}:?\d{2})?$/i)?.[1];
5528
+ return fractionalSeconds && fractionalSeconds.length > 3 ? normalized.replace(/\.\d{3}Z$/, `.${fractionalSeconds}Z`) : normalized;
5529
+ }
5530
+ if (timestamp instanceof Date)
5531
+ return Number.isNaN(timestamp.getTime()) ? new Date().toISOString() : timestamp.toISOString();
5532
+ const asDate = timestamp == null ? new Date : new Date(timestamp);
5533
+ return Number.isNaN(asDate.getTime()) ? new Date().toISOString() : asDate.toISOString();
5534
+ }
5535
+ function relocateInto(properties, key, value) {
5536
+ if (value !== undefined && !(key in properties))
5537
+ properties[key] = value;
5538
+ }
5539
+ function buildV1Event(message) {
5540
+ const sourceProperties = isRecord2(message.properties) ? message.properties : {};
5541
+ const properties = {
5542
+ ...sourceProperties
5543
+ };
5544
+ const options = {};
5545
+ for (const { property, optionKey, coerce } of OPTION_SENTINELS)
5546
+ if (property in properties) {
5547
+ const coerced = coerce(properties[property]);
5548
+ if (coerced !== undefined)
5549
+ options[optionKey] = coerced;
5550
+ delete properties[property];
5551
+ }
5552
+ const topLevel = {};
5553
+ for (const { property, field } of TOPLEVEL_SENTINELS)
5554
+ if (property in properties) {
5555
+ const value = properties[property];
5556
+ if (typeof value == "string")
5557
+ topLevel[field] = value;
5558
+ delete properties[property];
5559
+ }
5560
+ delete properties.$lib;
5561
+ delete properties.$lib_version;
5562
+ relocateInto(properties, "$set", message.$set);
5563
+ relocateInto(properties, "$set_once", message.$set_once);
5564
+ return {
5565
+ event: String(message.event ?? ""),
5566
+ uuid: String(message.uuid ?? ""),
5567
+ distinct_id: String(message.distinct_id ?? ""),
5568
+ timestamp: toRfc3339(message.timestamp),
5569
+ ...topLevel,
5570
+ options,
5571
+ properties
5572
+ };
5573
+ }
5574
+ function buildV1Batch(messages, { createdAt, historicalMigration }) {
5575
+ const batch = {
5576
+ created_at: createdAt,
5577
+ batch: messages.map(buildV1Event)
5578
+ };
5579
+ if (historicalMigration)
5580
+ batch.historical_migration = true;
5581
+ return batch;
5582
+ }
5583
+
5584
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/sender.mjs
5585
+ var V1_ANALYTICS_PATH = "/i/v1/analytics/events";
5586
+ var DEFAULT_MAX_BACKOFF_MS = 30000;
5587
+ var RETRYABLE_STATUSES = new Set([
5588
+ 408,
5589
+ 500,
5590
+ 502,
5591
+ 503,
5592
+ 504
5593
+ ]);
5594
+
5595
+ class V1CaptureSender {
5596
+ constructor(config, hooks) {
5597
+ this.config = config;
5598
+ this.maxBackoffMs = config.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS;
5599
+ this.fetchFn = hooks.fetch;
5600
+ this.onError = hooks.onError;
5601
+ this.now = hooks.now ?? Date.now;
5602
+ this.sleep = hooks.sleep ?? ((ms) => new Promise((resolve) => safeSetTimeout(resolve, ms)));
5603
+ this.generateRequestId = hooks.generateRequestId ?? uuidv7;
5604
+ this.compress = hooks.compress ?? gzipCompress;
5605
+ }
5606
+ async sendV1Batch(messages) {
5607
+ if (messages.length === 0)
5608
+ return;
5609
+ const requestId = this.generateRequestId();
5610
+ const createdAt = new Date(this.now()).toISOString();
5611
+ const { batch } = buildV1Batch(messages, {
5612
+ createdAt,
5613
+ historicalMigration: this.config.historicalMigration
5614
+ });
5615
+ const url = `${this.config.host}${V1_ANALYTICS_PATH}`;
5616
+ const drops = [];
5617
+ let pending = batch;
5618
+ const maxAttempts = Math.max(1, this.config.maxAttempts);
5619
+ for (let attempt = 1;attempt <= maxAttempts; attempt++) {
5620
+ const isLastAttempt = attempt === maxAttempts;
5621
+ const payload = safeJsonStringify({
5622
+ created_at: createdAt,
5623
+ ...this.config.historicalMigration ? {
5624
+ historical_migration: true
5625
+ } : {},
5626
+ batch: pending
5627
+ });
5628
+ let captureAttempt;
5629
+ let retryDelayMs;
5630
+ try {
5631
+ captureAttempt = await this.sendOnce(url, payload, attempt, requestId);
5632
+ const { response, signal } = captureAttempt;
5633
+ const { status } = response;
5634
+ if (status < 200 || status >= 300)
5635
+ if (!isLastAttempt && RETRYABLE_STATUSES.has(status)) {
5636
+ const retryAfterMs = this.parseRetryAfter(response);
5637
+ await captureAttempt.waitFor(captureAttempt.cancelBody()).catch(() => {});
5638
+ retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
5639
+ } else {
5640
+ const httpError = await this.buildHttpError(response, status, captureAttempt.waitFor);
5641
+ return this.surfaceBatchFailure(requestId, drops, pending, httpError);
5642
+ }
5643
+ else {
5644
+ let parsed;
5645
+ try {
5646
+ parsed = await captureAttempt.waitFor(this.parseResponse(response));
5647
+ } catch (error) {
5648
+ if (signal.aborted)
5649
+ throw error;
5650
+ return this.surfaceBatchFailure(requestId, drops, pending, new Error(`Capture V1 returned an unparseable ${status} response body`));
5651
+ }
5652
+ const retryable = this.classify(pending, parsed, drops);
5653
+ if (retryable.length === 0)
5654
+ return this.surfacePartialDrops(requestId, drops);
5655
+ if (isLastAttempt)
5656
+ return void this.onError(new CaptureV1Error({
5657
+ requestId,
5658
+ drops,
5659
+ retryExhausted: retryable.map((event) => event.uuid)
5660
+ }));
5661
+ pending = retryable;
5662
+ const retryAfterMs = this.parseRetryAfter(response);
5663
+ retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
5664
+ }
5665
+ } catch (transportError) {
5666
+ if (captureAttempt && !captureAttempt.signal.aborted)
5667
+ throw transportError;
5668
+ if (isLastAttempt)
5669
+ return this.surfaceBatchFailure(requestId, drops, pending, transportError);
5670
+ retryDelayMs = this.backoffDelay(attempt);
5671
+ } finally {
5672
+ captureAttempt?.cleanup();
5673
+ }
5674
+ if (retryDelayMs !== undefined)
5675
+ await this.sleep(retryDelayMs);
5676
+ }
5677
+ }
5678
+ async sendOnce(url, payload, attempt, requestId) {
5679
+ const headers = this.buildHeaders(attempt, requestId);
5680
+ let body = payload;
5681
+ if (this.config.compressionEnabled) {
5682
+ const compressed = await this.compress(payload, this.config.isDebug);
5683
+ if (compressed !== null) {
5684
+ body = compressed;
5685
+ headers["Content-Encoding"] = "gzip";
5686
+ }
5687
+ }
5688
+ const controller = new AbortController;
5689
+ let timeoutPhase = "waiting for response headers";
5690
+ let timer;
5691
+ const deadline = new Promise((_resolve, reject) => {
5692
+ timer = safeSetTimeout(() => {
5693
+ const timeoutError = new Error(`Capture V1 request timed out ${timeoutPhase} after ${this.config.requestTimeoutMs}ms`);
5694
+ timeoutError.name = "AbortError";
5695
+ reject(timeoutError);
5696
+ controller.abort(timeoutError);
5697
+ }, this.config.requestTimeoutMs);
5698
+ });
5699
+ try {
5700
+ const fetchPromise = this.fetchFn(url, {
5701
+ method: "POST",
5702
+ headers,
5703
+ body,
5704
+ signal: controller.signal
5705
+ });
5706
+ let responseAccepted = false;
5707
+ fetchPromise.then((lateResponse) => {
5708
+ if (controller.signal.aborted && !responseAccepted)
5709
+ this.cancelBody(lateResponse);
5710
+ }).catch(() => {});
5711
+ const response = await Promise.race([
5712
+ fetchPromise,
5713
+ deadline
5714
+ ]);
5715
+ responseAccepted = true;
5716
+ timeoutPhase = "while reading the response body";
5717
+ let cleanedUp = false;
5718
+ let cancellation;
5719
+ const cancelBody = () => cancellation ??= this.cancelBody(response);
5720
+ return {
5721
+ response,
5722
+ signal: controller.signal,
5723
+ waitFor: (operation) => Promise.race([
5724
+ operation,
5725
+ deadline
5726
+ ]),
5727
+ cancelBody,
5728
+ cleanup: () => {
5729
+ if (cleanedUp)
5730
+ return;
5731
+ cleanedUp = true;
5732
+ clearTimeout(timer);
5733
+ if (controller.signal.aborted)
5734
+ cancelBody();
5735
+ }
5736
+ };
5737
+ } catch (error) {
5738
+ clearTimeout(timer);
5739
+ throw error;
5740
+ }
5741
+ }
5742
+ buildHeaders(attempt, requestId) {
5743
+ const sdkInfo = `${this.config.libraryId}/${this.config.libraryVersion}`;
5744
+ const headers = {
5745
+ "Content-Type": "application/json",
5746
+ Authorization: `Bearer ${this.config.apiKey}`,
5747
+ "PostHog-Sdk-Info": sdkInfo,
5748
+ "PostHog-Attempt": String(attempt),
5749
+ "PostHog-Request-Id": requestId,
5750
+ "PostHog-Request-Timestamp": new Date(this.now()).toISOString()
5751
+ };
5752
+ if (this.config.userAgent)
5753
+ headers["User-Agent"] = this.config.userAgent;
5754
+ return headers;
5755
+ }
5756
+ classify(pending, parsed, drops) {
5757
+ const results = parsed.results ?? {};
5758
+ const retryable = [];
5759
+ for (const event of pending) {
5760
+ const result = results[event.uuid];
5761
+ if (result) {
5762
+ if (result.result === "drop")
5763
+ drops.push({
5764
+ uuid: event.uuid,
5765
+ details: result.details ?? undefined
5766
+ });
5767
+ else if (result.result === "retry")
5768
+ retryable.push(event);
5769
+ }
5770
+ }
5771
+ return retryable;
5772
+ }
5773
+ backoffDelay(attempt, retryAfterMs) {
5774
+ const exponential = Math.min(this.config.initialRetryDelayMs * 2 ** (attempt - 1), this.maxBackoffMs);
5775
+ if (retryAfterMs === undefined)
5776
+ return exponential;
5777
+ return Math.max(exponential, Math.min(retryAfterMs, this.maxBackoffMs));
5778
+ }
5779
+ parseRetryAfter(response) {
5780
+ const raw = response.headers?.get("Retry-After");
5781
+ if (!raw)
5782
+ return;
5783
+ const trimmed = raw.trim();
5784
+ if (/^\d+$/.test(trimmed)) {
5785
+ const seconds = parseInt(trimmed, 10);
5786
+ return Number.isFinite(seconds) && seconds > 0 ? 1000 * seconds : undefined;
5787
+ }
5788
+ const dateMs = Date.parse(trimmed);
5789
+ if (Number.isNaN(dateMs))
5790
+ return;
5791
+ const delta = dateMs - this.now();
5792
+ return delta > 0 ? delta : undefined;
5793
+ }
5794
+ async parseResponse(response) {
5795
+ const text = await response.text();
5796
+ const parsed = JSON.parse(text);
5797
+ if (typeof parsed != "object" || parsed === null || Array.isArray(parsed))
5798
+ throw new Error("unexpected response shape");
5799
+ const results = parsed.results;
5800
+ if (results !== undefined && (typeof results != "object" || results === null || Array.isArray(results)))
5801
+ throw new Error("unexpected results shape");
5802
+ return {
5803
+ results: results ?? {}
5804
+ };
5805
+ }
5806
+ async buildHttpError(response, status, waitFor) {
5807
+ let bodyText = "";
5808
+ try {
5809
+ bodyText = (await waitFor(response.text())).slice(0, 512);
5810
+ } catch {}
5811
+ const suffix = bodyText ? `: ${bodyText}` : "";
5812
+ return new Error(`Capture V1 request failed with HTTP ${status}${suffix}`);
5813
+ }
5814
+ surfaceBatchFailure(requestId, drops, pending, cause) {
5815
+ this.onError(new CaptureV1Error({
5816
+ requestId,
5817
+ drops,
5818
+ retryExhausted: pending.map((event) => event.uuid),
5819
+ cause
5820
+ }));
5821
+ }
5822
+ surfacePartialDrops(requestId, drops) {
5823
+ if (drops.length > 0)
5824
+ this.onError(new CaptureV1Error({
5825
+ requestId,
5826
+ drops,
5827
+ retryExhausted: []
5828
+ }));
5829
+ }
5830
+ async cancelBody(response) {
5831
+ try {
5832
+ await response.body?.cancel();
5833
+ } catch {}
5834
+ }
5835
+ }
5836
+
5837
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/ai-capture/routing.mjs
5838
+ var AI_CAPTURE_ROUTE = "ai-capture";
5839
+ var AI_CAPTURE_ENDPOINT_PATH = "/i/v0/ai/batch/";
5840
+ var AI_MAX_EVENT_BYTES = 8388608;
5841
+ var AI_BATCH_TARGET_BYTES = 5242880;
5842
+
5843
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/ai-capture/batching.mjs
5844
+ var encoder = new TextEncoder;
5845
+ function eventByteSize(message) {
5846
+ return encoder.encode(safeJsonStringify(message)).length;
5847
+ }
5848
+ function partitionAiBatch(messages, maxEventBytes = AI_MAX_EVENT_BYTES, targetBatchBytes = AI_BATCH_TARGET_BYTES) {
5849
+ const batches = [];
5850
+ const dropped = [];
5851
+ let current = [];
5852
+ let currentBytes = 0;
5853
+ for (const message of messages) {
5854
+ if (message === undefined)
5855
+ continue;
5856
+ const bytes = eventByteSize(message);
5857
+ if (bytes > maxEventBytes) {
5858
+ dropped.push({
5859
+ event: typeof message.event == "string" ? message.event : "unknown",
5860
+ bytes
5861
+ });
5862
+ continue;
5863
+ }
5864
+ if (current.length > 0 && currentBytes + bytes > targetBatchBytes) {
5865
+ batches.push(current);
5866
+ current = [];
5867
+ currentBytes = 0;
5868
+ }
5869
+ current.push(message);
5870
+ currentBytes += bytes;
5871
+ }
5872
+ if (current.length > 0)
5873
+ batches.push(current);
5874
+ return {
5875
+ batches,
5876
+ dropped
5877
+ };
5878
+ }
5879
+
5880
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/client.mjs
4393
5881
  var MINIMUM_POLLING_INTERVAL = 100;
4394
5882
  var THIRTY_SECONDS = 30000;
4395
5883
  var MAX_CACHE_SIZE = 50000;
@@ -4414,6 +5902,12 @@ function normalizeHost(value) {
4414
5902
  const normalizedValue = typeof value == "string" ? value.trim() : "";
4415
5903
  return normalizedValue || DEFAULT_NODE_HOST;
4416
5904
  }
5905
+ function normalizeUnsetPersonProperties(value) {
5906
+ const propertyNames = Array.isArray(value) ? value : [
5907
+ value
5908
+ ];
5909
+ return propertyNames.filter((propertyName) => typeof propertyName == "string" && propertyName.trim().length > 0);
5910
+ }
4417
5911
  function buildFlagEventProperties(flagValues) {
4418
5912
  if (!flagValues)
4419
5913
  return {};
@@ -4431,11 +5925,15 @@ class PostHogBackendClient extends PostHogCoreStateless {
4431
5925
  const normalizedApiKey = normalizeApiKey(apiKey);
4432
5926
  const normalizedOptions = {
4433
5927
  ...options,
5928
+ maxQueueSize: options.maxQueueSize ?? 1e4,
5929
+ flushInterval: options.flushInterval ?? 5000,
4434
5930
  host: normalizeHost(options.host),
4435
- personalApiKey: normalizePersonalApiKey(options.personalApiKey)
5931
+ personalApiKey: normalizePersonalApiKey(options.secretKey ?? options.personalApiKey)
4436
5932
  };
4437
- super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage;
5933
+ super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage, this._aiCaptureRouteActive = false, this._minimalFlagCalledEvents = false;
4438
5934
  this.options = normalizedOptions;
5935
+ this.captureMode = resolveCaptureMode();
5936
+ this.enableFullAiCapture = normalizedOptions.enableFullAiCapture === true;
4439
5937
  this.context = this.initializeContext();
4440
5938
  this.options.featureFlagsPollingInterval = typeof normalizedOptions.featureFlagsPollingInterval == "number" ? Math.max(normalizedOptions.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL) : THIRTY_SECONDS;
4441
5939
  if (typeof normalizedOptions.waitUntilDebounceMs == "number")
@@ -4460,21 +5958,24 @@ class PostHogBackendClient extends PostHogCoreStateless {
4460
5958
  onLoad: (count) => {
4461
5959
  this._events.emit("localEvaluationFlagsLoaded", count);
4462
5960
  },
5961
+ onMinimalFlagCalledEvents: (enabled) => {
5962
+ this._minimalFlagCalledEvents = enabled;
5963
+ },
4463
5964
  customHeaders: this.getCustomHeaders(),
4464
5965
  cacheProvider: normalizedOptions.flagDefinitionCacheProvider,
4465
5966
  strictLocalEvaluation: normalizedOptions.strictLocalEvaluation
4466
5967
  });
4467
5968
  }
4468
- this.errorTracking = new ErrorTracking(this, normalizedOptions, this._logger);
5969
+ this.errorTracking = new error_tracking_ErrorTracking(this, normalizedOptions, this._logger);
4469
5970
  this.distinctIdHasSentFlagCalls = {};
4470
5971
  this.maxCacheSize = normalizedOptions.maxCacheSize || MAX_CACHE_SIZE;
4471
5972
  }
4472
- enqueue(type, message, options) {
4473
- super.enqueue(type, message, options);
5973
+ enqueue(type, message, options, explicitRoute) {
5974
+ super.enqueue(type, message, options, explicitRoute);
4474
5975
  this.scheduleDebouncedFlush();
4475
5976
  }
4476
5977
  async flush() {
4477
- const flushPromise = super.flush();
5978
+ const flushPromise = this.flushWithPendingPromises();
4478
5979
  const waitUntil = this.options.waitUntil;
4479
5980
  if (waitUntil && !this._waitUntilCycle)
4480
5981
  try {
@@ -4527,7 +6028,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4527
6028
  async resolveWaitUntilFlush() {
4528
6029
  const resolve = this._consumeWaitUntilCycle();
4529
6030
  try {
4530
- await super.flush();
6031
+ await this.flushWithPendingPromises();
4531
6032
  } catch {} finally {
4532
6033
  resolve?.();
4533
6034
  }
@@ -4541,12 +6042,103 @@ class PostHogBackendClient extends PostHogCoreStateless {
4541
6042
  fetch(url, options) {
4542
6043
  return this.options.fetch ? this.options.fetch(url, options) : fetch(url, options);
4543
6044
  }
6045
+ getQueueRouteKey(message) {
6046
+ return this.captureMode === "v1" && isLegacyOnlyEvent(message) ? AI_ROUTE : ANALYTICS_ROUTE;
6047
+ }
6048
+ persistedQueueKeyForRoute(route) {
6049
+ if (route === AI_CAPTURE_ROUTE)
6050
+ return types_PostHogPersistedProperty.AiCaptureQueue;
6051
+ return route === AI_ROUTE ? types_PostHogPersistedProperty.AiQueue : types_PostHogPersistedProperty.Queue;
6052
+ }
6053
+ getActiveQueueRoutes() {
6054
+ const routes = this.captureMode === "v1" ? [
6055
+ ANALYTICS_ROUTE,
6056
+ AI_ROUTE
6057
+ ] : [
6058
+ ANALYTICS_ROUTE
6059
+ ];
6060
+ if (this._aiCaptureRouteActive)
6061
+ routes.push(AI_CAPTURE_ROUTE);
6062
+ return routes;
6063
+ }
6064
+ getBatchEndpointPath(route) {
6065
+ return route === AI_CAPTURE_ROUTE ? AI_CAPTURE_ENDPOINT_PATH : super.getBatchEndpointPath(route);
6066
+ }
6067
+ async sendBatch(batchMessages, retryOptions, route = ANALYTICS_ROUTE) {
6068
+ if (route === AI_CAPTURE_ROUTE)
6069
+ return this.sendAiCaptureBatch(batchMessages, retryOptions);
6070
+ if (this.captureMode !== "v1" || route === AI_ROUTE)
6071
+ return super.sendBatch(batchMessages, retryOptions, route);
6072
+ const v1Events = batchMessages.filter((message) => message !== undefined);
6073
+ await this.getV1Sender().sendV1Batch(v1Events);
6074
+ }
6075
+ async sendAiCaptureBatch(batchMessages, retryOptions) {
6076
+ const { batches, dropped } = partitionAiBatch(batchMessages);
6077
+ for (const { event, bytes } of dropped) {
6078
+ const message = `Event ${event} (${bytes} bytes) exceeds the ${AI_MAX_EVENT_BYTES / 1048576}MiB limit for ${AI_CAPTURE_ENDPOINT_PATH}, dropping.`;
6079
+ this._logger.error(message);
6080
+ this._events.emit("error", new Error(message));
6081
+ }
6082
+ for (const batch of batches)
6083
+ await this.sendAiSubBatch(batch, retryOptions);
6084
+ }
6085
+ async sendAiSubBatch(batch, retryOptions) {
6086
+ try {
6087
+ await super.sendBatch(batch, retryOptions, AI_CAPTURE_ROUTE);
6088
+ } catch (err) {
6089
+ if (!isPostHogFetchContentTooLargeError(err))
6090
+ throw err;
6091
+ if (batch.length === 1) {
6092
+ const [event] = batch;
6093
+ const eventName = typeof event.event == "string" ? event.event : "unknown";
6094
+ const message = `Event ${eventName} (${eventByteSize(event)} bytes) was rejected with 413 by ${AI_CAPTURE_ENDPOINT_PATH} on its own, dropping.`;
6095
+ this._logger.error(message);
6096
+ this._events.emit("error", new Error(message));
6097
+ return;
6098
+ }
6099
+ const mid = Math.ceil(batch.length / 2);
6100
+ await this.sendAiSubBatch(batch.slice(0, mid), retryOptions);
6101
+ await this.sendAiSubBatch(batch.slice(mid), retryOptions);
6102
+ }
6103
+ }
6104
+ getV1Sender() {
6105
+ if (!this._v1Sender)
6106
+ this._v1Sender = new V1CaptureSender({
6107
+ host: this.host,
6108
+ apiKey: this.apiKey,
6109
+ libraryId: this.getLibraryId(),
6110
+ libraryVersion: this.getLibraryVersion(),
6111
+ userAgent: this.getCustomUserAgent() || undefined,
6112
+ historicalMigration: this.historicalMigration,
6113
+ compressionEnabled: !this.disableCompression,
6114
+ requestTimeoutMs: this.requestTimeout,
6115
+ maxAttempts: (this.options.fetchRetryCount ?? 3) + 1,
6116
+ initialRetryDelayMs: this.options.fetchRetryDelay ?? 3000,
6117
+ isDebug: this.isDebug
6118
+ }, {
6119
+ fetch: (url, fetchOptions) => this.fetch(url, fetchOptions),
6120
+ onError: (error) => this._events.emit("error", error),
6121
+ compress: (payload) => this.compressPayload(payload)
6122
+ });
6123
+ return this._v1Sender;
6124
+ }
4544
6125
  getLibraryVersion() {
4545
6126
  return version;
4546
6127
  }
6128
+ get metrics() {
6129
+ if (!this._metrics)
6130
+ this._metrics = new PostHogMetrics(this, resolveMetricsConfig(this.options.metrics), this._logger);
6131
+ return this._metrics;
6132
+ }
4547
6133
  getCustomUserAgent() {
4548
6134
  return `${this.getLibraryId()}/${this.getLibraryVersion()}`;
4549
6135
  }
6136
+ getCommonEventProperties() {
6137
+ const commonProperties = super.getCommonEventProperties();
6138
+ if (this.options.isServer ?? true)
6139
+ commonProperties.$is_server = true;
6140
+ return commonProperties;
6141
+ }
4550
6142
  enable() {
4551
6143
  return super.optIn();
4552
6144
  }
@@ -4557,33 +6149,69 @@ class PostHogBackendClient extends PostHogCoreStateless {
4557
6149
  super.debug(enabled);
4558
6150
  this.featureFlagsPoller?.debug(enabled);
4559
6151
  }
4560
- capture(props) {
6152
+ _warnIfInvalidCapture(props, stringArgumentWarning, exceptionCaptureWarning) {
4561
6153
  if (typeof props == "string")
4562
- this._logger.warn("Called capture() with a string as the first argument when an object was expected.");
6154
+ this._logger.warn(stringArgumentWarning);
4563
6155
  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) => {
6156
+ this._logger.warn(exceptionCaptureWarning);
6157
+ }
6158
+ _sendPreparedEvent(type, props, immediate, prepareOptions, explicitRoute) {
6159
+ return this.addPendingPromise(this._prepareEventMessage(props, prepareOptions).then(({ distinctId, event, properties, options }) => {
6160
+ const captureOptions = {
6161
+ timestamp: options.timestamp,
6162
+ disableGeoip: options.disableGeoip,
6163
+ uuid: options.uuid
6164
+ };
6165
+ const message = {
6166
+ distinctId,
6167
+ event,
6168
+ properties: {
6169
+ ...properties,
6170
+ ...this.getCommonEventProperties()
6171
+ }
6172
+ };
6173
+ return immediate ? this.sendImmediate(type, message, captureOptions, explicitRoute) : this.enqueue(type, message, captureOptions, explicitRoute);
6174
+ }).catch((err) => {
4570
6175
  if (err)
4571
6176
  console.error(err);
4572
6177
  }));
4573
6178
  }
6179
+ _capturePreparedEvent(props, immediate) {
6180
+ return this._sendPreparedEvent("capture", props, immediate);
6181
+ }
6182
+ capture(props) {
6183
+ 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.");
6184
+ this._capturePreparedEvent(props, false);
6185
+ }
4574
6186
  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
- }));
6187
+ 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.");
6188
+ return this._capturePreparedEvent(props, true);
6189
+ }
6190
+ captureAi(props) {
6191
+ if (this.disabled)
6192
+ return;
6193
+ const uuid = getEventUuid(props.uuid, uuidv7);
6194
+ this._sendPreparedAiEvent({
6195
+ ...props,
6196
+ uuid
6197
+ }, false);
6198
+ return uuid;
6199
+ }
6200
+ async captureAiImmediate(props) {
6201
+ if (this.disabled)
6202
+ return;
6203
+ const uuid = getEventUuid(props.uuid, uuidv7);
6204
+ await this._sendPreparedAiEvent({
6205
+ ...props,
6206
+ uuid
6207
+ }, true);
6208
+ return uuid;
6209
+ }
6210
+ _sendPreparedAiEvent(props, immediate) {
6211
+ if (typeof props?.event == "string" && !props.event.startsWith("$ai_"))
6212
+ this._logger.debug(`captureAi called with non-AI event ${props.event}; routing it to the AI endpoint anyway.`);
6213
+ this._aiCaptureRouteActive = true;
6214
+ return this._sendPreparedEvent("capture", props, immediate, undefined, AI_CAPTURE_ROUTE);
4587
6215
  }
4588
6216
  identify({ distinctId, properties = {}, disableGeoip }) {
4589
6217
  const { $set, $set_once, $anon_distinct_id, ...rest } = properties;
@@ -4594,8 +6222,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
4594
6222
  $set_once: setOnceProps,
4595
6223
  $anon_distinct_id: $anon_distinct_id ?? undefined
4596
6224
  };
4597
- super.identifyStateless(distinctId, eventProperties, {
6225
+ this._sendPreparedEvent("identify", {
6226
+ distinctId,
6227
+ event: "$identify",
6228
+ properties: eventProperties,
4598
6229
  disableGeoip
6230
+ }, false, {
6231
+ includeContextProperties: false
4599
6232
  });
4600
6233
  }
4601
6234
  async identifyImmediate({ distinctId, properties = {}, disableGeoip }) {
@@ -4607,18 +6240,65 @@ class PostHogBackendClient extends PostHogCoreStateless {
4607
6240
  $set_once: setOnceProps,
4608
6241
  $anon_distinct_id: $anon_distinct_id ?? undefined
4609
6242
  };
4610
- await super.identifyStatelessImmediate(distinctId, eventProperties, {
6243
+ await this._sendPreparedEvent("identify", {
6244
+ distinctId,
6245
+ event: "$identify",
6246
+ properties: eventProperties,
4611
6247
  disableGeoip
6248
+ }, true, {
6249
+ includeContextProperties: false
6250
+ });
6251
+ }
6252
+ setPersonProperties({ distinctId, properties = {}, propertiesOnce = {} }) {
6253
+ if (Object.keys(properties).length === 0 && Object.keys(propertiesOnce).length === 0)
6254
+ return;
6255
+ const eventProperties = {};
6256
+ if (Object.keys(properties).length > 0)
6257
+ eventProperties.$set = properties;
6258
+ if (Object.keys(propertiesOnce).length > 0)
6259
+ eventProperties.$set_once = propertiesOnce;
6260
+ this.capture({
6261
+ distinctId,
6262
+ event: "$set",
6263
+ properties: eventProperties
6264
+ });
6265
+ }
6266
+ unsetPersonProperties({ distinctId, properties }) {
6267
+ const propertyNames = normalizeUnsetPersonProperties(properties);
6268
+ if (propertyNames.length === 0)
6269
+ return;
6270
+ this.capture({
6271
+ distinctId,
6272
+ event: "$set",
6273
+ properties: {
6274
+ $unset: propertyNames
6275
+ }
4612
6276
  });
4613
6277
  }
4614
6278
  alias(data) {
4615
- super.aliasStateless(data.alias, data.distinctId, undefined, {
6279
+ this._sendPreparedEvent("alias", {
6280
+ distinctId: data.distinctId,
6281
+ event: "$create_alias",
6282
+ properties: {
6283
+ distinct_id: data.distinctId,
6284
+ alias: data.alias
6285
+ },
4616
6286
  disableGeoip: data.disableGeoip
6287
+ }, false, {
6288
+ includeContextProperties: false
4617
6289
  });
4618
6290
  }
4619
6291
  async aliasImmediate(data) {
4620
- await super.aliasStatelessImmediate(data.alias, data.distinctId, undefined, {
6292
+ await this._sendPreparedEvent("alias", {
6293
+ distinctId: data.distinctId,
6294
+ event: "$create_alias",
6295
+ properties: {
6296
+ distinct_id: data.distinctId,
6297
+ alias: data.alias
6298
+ },
4621
6299
  disableGeoip: data.disableGeoip
6300
+ }, true, {
6301
+ includeContextProperties: false
4622
6302
  });
4623
6303
  }
4624
6304
  isLocalEvaluationReady() {
@@ -4673,7 +6353,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4673
6353
  const adjustedProperties = this.addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties);
4674
6354
  personProperties = adjustedProperties.allPersonProperties;
4675
6355
  groupProperties = adjustedProperties.allGroupProperties;
4676
- const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties);
6356
+ const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, this.personPropertiesForLocalEvaluation(distinctId, personProperties), groupProperties);
4677
6357
  if (onlyEvaluateLocally == undefined)
4678
6358
  onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
4679
6359
  let result;
@@ -4684,6 +6364,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4684
6364
  let flagId;
4685
6365
  let flagVersion;
4686
6366
  let flagReason;
6367
+ let flagHasExperiment;
4687
6368
  const localEvaluationEnabled = this.featureFlagsPoller !== undefined;
4688
6369
  if (localEvaluationEnabled) {
4689
6370
  await this.featureFlagsPoller?.loadFeatureFlags();
@@ -4698,6 +6379,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4698
6379
  const value = localResult.value;
4699
6380
  flagId = flag.id;
4700
6381
  flagReason = "Evaluated locally";
6382
+ flagHasExperiment = flag.has_experiment;
4701
6383
  result = {
4702
6384
  key,
4703
6385
  enabled: value !== false,
@@ -4713,12 +6395,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
4713
6395
  }
4714
6396
  }
4715
6397
  if (!flagWasLocallyEvaluated && !onlyEvaluateLocally) {
4716
- const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, [
6398
+ const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, [
4717
6399
  key
4718
6400
  ]);
4719
6401
  if (flagsResponse === undefined)
4720
6402
  featureFlagError = FeatureFlagError2.UNKNOWN_ERROR;
4721
6403
  else {
6404
+ this._minimalFlagCalledEvents = flagsResponse.minimalFlagCalledEvents === true;
4722
6405
  requestId = flagsResponse.requestId;
4723
6406
  evaluatedAt = flagsResponse.evaluatedAt;
4724
6407
  const errors = [];
@@ -4733,6 +6416,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4733
6416
  flagId = flagDetail.metadata?.id;
4734
6417
  flagVersion = flagDetail.metadata?.version;
4735
6418
  flagReason = flagDetail.reason?.description ?? flagDetail.reason?.code;
6419
+ flagHasExperiment = flagDetail.metadata?.has_experiment;
4736
6420
  let parsedPayload;
4737
6421
  if (flagDetail.metadata?.payload !== undefined)
4738
6422
  try {
@@ -4743,7 +6427,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4743
6427
  result = {
4744
6428
  key,
4745
6429
  enabled: flagDetail.enabled,
4746
- variant: flagDetail.variant,
6430
+ variant: flagDetail.variant ?? undefined,
4747
6431
  payload: parsedPayload
4748
6432
  };
4749
6433
  }
@@ -4764,6 +6448,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
4764
6448
  $feature_flag_request_id: requestId,
4765
6449
  $feature_flag_evaluated_at: flagWasLocallyEvaluated ? Date.now() : evaluatedAt
4766
6450
  };
6451
+ if (flagHasExperiment !== undefined)
6452
+ properties.$feature_flag_has_experiment = flagHasExperiment;
4767
6453
  if (flagWasLocallyEvaluated && this.featureFlagsPoller) {
4768
6454
  const flagDefinitionsLoadedAt = this.featureFlagsPoller.getFlagDefinitionsLoadedAt();
4769
6455
  if (flagDefinitionsLoadedAt !== undefined)
@@ -4878,7 +6564,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4878
6564
  const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
4879
6565
  personProperties = adjustedProperties.allPersonProperties;
4880
6566
  groupProperties = adjustedProperties.allGroupProperties;
4881
- const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
6567
+ const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
4882
6568
  if (onlyEvaluateLocally == undefined)
4883
6569
  onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
4884
6570
  const localEvaluationResult = await this.featureFlagsPoller?.getAllFlagsAndPayloads(evaluationContext, flagKeys);
@@ -4891,7 +6577,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
4891
6577
  fallbackToFlags = localEvaluationResult.fallbackToFlags;
4892
6578
  }
4893
6579
  if (fallbackToFlags && !onlyEvaluateLocally) {
4894
- const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, flagKeys);
6580
+ const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
4895
6581
  featureFlags = {
4896
6582
  ...featureFlags,
4897
6583
  ...remoteEvaluationResult.flags || {}
@@ -4939,9 +6625,10 @@ class PostHogBackendClient extends PostHogCoreStateless {
4939
6625
  const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
4940
6626
  personProperties = adjustedProperties.allPersonProperties;
4941
6627
  groupProperties = adjustedProperties.allGroupProperties;
4942
- const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
6628
+ const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
4943
6629
  if (onlyEvaluateLocally == undefined)
4944
6630
  onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
6631
+ const requestedFlagKeys = flagKeys ? new Set(flagKeys) : undefined;
4945
6632
  const records = {};
4946
6633
  let requestId;
4947
6634
  let evaluatedAt;
@@ -4960,14 +6647,17 @@ class PostHogBackendClient extends PostHogCoreStateless {
4960
6647
  id: flagDef?.id,
4961
6648
  version: undefined,
4962
6649
  reason: "Evaluated locally",
4963
- locallyEvaluated: true
6650
+ locallyEvaluated: true,
6651
+ hasExperiment: flagDef?.has_experiment
4964
6652
  };
4965
6653
  locallyEvaluatedKeys.add(key);
4966
6654
  }
4967
- const fallbackToFlags = localResult ? localResult.fallbackToFlags : true;
6655
+ const requestedFlagMissingLocally = requestedFlagKeys !== undefined && Array.from(requestedFlagKeys).some((key) => this.featureFlagsPoller?.featureFlagsByKey[key] === undefined);
6656
+ const fallbackToFlags = localResult ? localResult.fallbackToFlags || requestedFlagMissingLocally : true;
4968
6657
  if (fallbackToFlags && !onlyEvaluateLocally) {
4969
- const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, flagKeys);
6658
+ const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
4970
6659
  if (details) {
6660
+ this._minimalFlagCalledEvents = details.minimalFlagCalledEvents === true;
4971
6661
  requestId = details.requestId;
4972
6662
  evaluatedAt = details.evaluatedAt;
4973
6663
  errorsWhileComputing = Boolean(details.errorsWhileComputingFlags);
@@ -4990,7 +6680,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
4990
6680
  id: detail.metadata?.id,
4991
6681
  version: detail.metadata?.version,
4992
6682
  reason: detail.reason?.description ?? detail.reason?.code,
4993
- locallyEvaluated: false
6683
+ locallyEvaluated: false,
6684
+ hasExperiment: detail.metadata?.has_experiment
4994
6685
  };
4995
6686
  }
4996
6687
  }
@@ -5010,7 +6701,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
5010
6701
  id: existing?.id,
5011
6702
  version: existing?.version,
5012
6703
  reason: existing?.reason,
5013
- locallyEvaluated: existing?.locallyEvaluated ?? false
6704
+ locallyEvaluated: existing?.locallyEvaluated ?? false,
6705
+ hasExperiment: existing?.hasExperiment
5014
6706
  };
5015
6707
  }
5016
6708
  if (this._payloadOverrides !== undefined)
@@ -5022,6 +6714,11 @@ class PostHogBackendClient extends PostHogCoreStateless {
5022
6714
  payload
5023
6715
  };
5024
6716
  }
6717
+ if (requestedFlagKeys !== undefined) {
6718
+ for (const key of Object.keys(records))
6719
+ if (!requestedFlagKeys.has(key))
6720
+ delete records[key];
6721
+ }
5025
6722
  return new FeatureFlagEvaluations({
5026
6723
  host: this._getFeatureFlagEvaluationsHost(),
5027
6724
  distinctId: resolvedDistinctId,
@@ -5035,6 +6732,9 @@ class PostHogBackendClient extends PostHogCoreStateless {
5035
6732
  quotaLimited
5036
6733
  });
5037
6734
  }
6735
+ _shouldSendMinimalFlagCalledEvent(event, properties) {
6736
+ return event === "$feature_flag_called" && this._minimalFlagCalledEvents && properties.$feature_flag_has_experiment === false;
6737
+ }
5038
6738
  _captureFlagCalledEventIfNeeded(params) {
5039
6739
  const { distinctId, key, response, groups, disableGeoip, properties } = params;
5040
6740
  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 +6769,32 @@ class PostHogBackendClient extends PostHogCoreStateless {
5069
6769
  return this._featureFlagEvaluationsHost;
5070
6770
  }
5071
6771
  groupIdentify({ groupType, groupKey, properties, distinctId, disableGeoip }) {
5072
- super.groupIdentifyStateless(groupType, groupKey, properties, {
6772
+ this._sendPreparedEvent("capture", {
6773
+ distinctId: distinctId || `$${groupType}_${groupKey}`,
6774
+ event: "$groupidentify",
6775
+ properties: {
6776
+ $group_type: groupType,
6777
+ $group_key: groupKey,
6778
+ $group_set: properties || {}
6779
+ },
6780
+ disableGeoip
6781
+ }, false, {
6782
+ includeContextProperties: false
6783
+ });
6784
+ }
6785
+ async groupIdentifyImmediate({ groupType, groupKey, properties, distinctId, disableGeoip }) {
6786
+ await this._sendPreparedEvent("capture", {
6787
+ distinctId: distinctId || `$${groupType}_${groupKey}`,
6788
+ event: "$groupidentify",
6789
+ properties: {
6790
+ $group_type: groupType,
6791
+ $group_key: groupKey,
6792
+ $group_set: properties || {}
6793
+ },
5073
6794
  disableGeoip
5074
- }, distinctId);
6795
+ }, true, {
6796
+ includeContextProperties: false
6797
+ });
5075
6798
  }
5076
6799
  async reloadFeatureFlags() {
5077
6800
  await this.featureFlagsPoller?.loadFeatureFlags(true);
@@ -5143,12 +6866,18 @@ class PostHogBackendClient extends PostHogCoreStateless {
5143
6866
  this.context?.enter(data, options);
5144
6867
  }
5145
6868
  async _shutdown(shutdownTimeoutMs) {
6869
+ const shutdownDeadlineMs = Date.now() + (shutdownTimeoutMs ?? 30000);
5146
6870
  const resolve = this._consumeWaitUntilCycle();
5147
6871
  await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
5148
6872
  this.errorTracking.shutdown();
6873
+ if (this._metrics) {
6874
+ await raceWithTimeout(this._metrics.flush().catch(() => {}), Math.max(0, shutdownDeadlineMs - Date.now()));
6875
+ this._metrics.reset();
6876
+ }
5149
6877
  try {
5150
- return await super._shutdown(shutdownTimeoutMs);
6878
+ return await super._shutdown(Math.max(0, shutdownDeadlineMs - Date.now()));
5151
6879
  } finally {
6880
+ this.distinctIdHasSentFlagCalls = {};
5152
6881
  resolve?.();
5153
6882
  }
5154
6883
  }
@@ -5243,7 +6972,6 @@ class PostHogBackendClient extends PostHogCoreStateless {
5243
6972
  }
5244
6973
  addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties) {
5245
6974
  const allPersonProperties = {
5246
- distinct_id: distinctId,
5247
6975
  ...personProperties || {}
5248
6976
  };
5249
6977
  const allGroupProperties = {};
@@ -5258,6 +6986,12 @@ class PostHogBackendClient extends PostHogCoreStateless {
5258
6986
  allGroupProperties
5259
6987
  };
5260
6988
  }
6989
+ personPropertiesForLocalEvaluation(distinctId, personProperties) {
6990
+ return {
6991
+ distinct_id: distinctId,
6992
+ ...personProperties || {}
6993
+ };
6994
+ }
5261
6995
  createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties) {
5262
6996
  return {
5263
6997
  distinctId,
@@ -5268,21 +7002,21 @@ class PostHogBackendClient extends PostHogCoreStateless {
5268
7002
  };
5269
7003
  }
5270
7004
  captureException(error, distinctId, additionalProperties, uuid, flags) {
5271
- if (!ErrorTracking.isPreviouslyCapturedError(error)) {
7005
+ if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
5272
7006
  const syntheticException = new Error("PostHog syntheticException");
5273
- this.addPendingPromise(ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
7007
+ this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
5274
7008
  syntheticException
5275
- }, distinctId, additionalProperties).then((msg) => this.capture({
7009
+ }, distinctId, additionalProperties).then((msg) => this._capturePreparedEvent({
5276
7010
  ...msg,
5277
7011
  uuid,
5278
7012
  flags
5279
- })));
7013
+ }, false)));
5280
7014
  }
5281
7015
  }
5282
7016
  async captureExceptionImmediate(error, distinctId, additionalProperties, flags) {
5283
- if (!ErrorTracking.isPreviouslyCapturedError(error)) {
7017
+ if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
5284
7018
  const syntheticException = new Error("PostHog syntheticException");
5285
- return this.addPendingPromise(ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
7019
+ return this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
5286
7020
  syntheticException
5287
7021
  }, distinctId, additionalProperties).then((msg) => this.captureImmediate({
5288
7022
  ...msg,
@@ -5291,24 +7025,31 @@ class PostHogBackendClient extends PostHogCoreStateless {
5291
7025
  }
5292
7026
  }
5293
7027
  async prepareEventMessage(props) {
7028
+ return this._prepareEventMessage(props);
7029
+ }
7030
+ async _prepareEventMessage(props, options = {}) {
5294
7031
  const { distinctId, event, properties, groups, flags, sendFeatureFlags, timestamp, disableGeoip, uuid } = props;
5295
7032
  const contextData = this.context?.get();
7033
+ const includeContextProperties = options.includeContextProperties ?? true;
5296
7034
  let mergedDistinctId = distinctId || contextData?.distinctId;
5297
- const mergedProperties = {
7035
+ const mergedProperties = includeContextProperties ? {
5298
7036
  ...this.props,
5299
7037
  ...contextData?.properties || {},
5300
7038
  ...properties || {}
7039
+ } : {
7040
+ ...properties || {}
5301
7041
  };
5302
7042
  if (!mergedDistinctId) {
5303
7043
  mergedDistinctId = uuidv7();
5304
7044
  mergedProperties.$process_person_profile = false;
5305
7045
  }
5306
- if (contextData?.sessionId && !mergedProperties.$session_id)
7046
+ if (includeContextProperties && contextData?.sessionId && !mergedProperties.$session_id)
5307
7047
  mergedProperties.$session_id = contextData.sessionId;
7048
+ const finalProperties = this._shouldSendMinimalFlagCalledEvent(event, mergedProperties) ? minimizeFlagCalledEventProperties(mergedProperties) : mergedProperties;
5308
7049
  const eventMessage = this._runBeforeSend({
5309
7050
  distinctId: mergedDistinctId,
5310
7051
  event,
5311
- properties: mergedProperties,
7052
+ properties: finalProperties,
5312
7053
  groups,
5313
7054
  flags,
5314
7055
  sendFeatureFlags,
@@ -5332,12 +7073,14 @@ class PostHogBackendClient extends PostHogCoreStateless {
5332
7073
  }
5333
7074
  return {};
5334
7075
  }).catch(() => ({})).then((additionalProperties) => {
5335
- const props2 = {
7076
+ const resolvedGroups = eventMessage.groups || groups;
7077
+ return {
5336
7078
  ...additionalProperties,
5337
7079
  ...eventMessage.properties || {},
5338
- $groups: eventMessage.groups || groups
7080
+ ...resolvedGroups !== undefined && Object.keys(resolvedGroups).length > 0 ? {
7081
+ $groups: resolvedGroups
7082
+ } : {}
5339
7083
  };
5340
- return props2;
5341
7084
  });
5342
7085
  if (eventMessage.event === "$pageview" && this.options.__preview_capture_bot_pageviews && typeof eventProperties.$raw_user_agent == "string") {
5343
7086
  if (isBlockedUA(eventProperties.$raw_user_agent, this.options.custom_blocked_useragents || [])) {
@@ -5364,22 +7107,26 @@ class PostHogBackendClient extends PostHogCoreStateless {
5364
7107
  beforeSend
5365
7108
  ];
5366
7109
  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`);
7110
+ for (const fn of fns)
7111
+ try {
7112
+ result = fn(result);
7113
+ if (!result) {
7114
+ this._logger.info(`Event '${eventMessage.event}' was rejected in beforeSend function`);
7115
+ return null;
7116
+ }
7117
+ if (!result.properties || Object.keys(result.properties).length === 0) {
7118
+ const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`;
7119
+ this._logger.warn(message);
7120
+ }
7121
+ } catch (error) {
7122
+ this._logger.error(`Error in before_send function for event '${eventMessage.event}':`, error);
5371
7123
  return null;
5372
7124
  }
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
7125
  return result;
5379
7126
  }
5380
7127
  }
5381
7128
 
5382
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/context/context.mjs
7129
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/context/context.mjs
5383
7130
  import { AsyncLocalStorage } from "node:async_hooks";
5384
7131
 
5385
7132
  class PostHogContext {
@@ -5410,7 +7157,22 @@ class PostHogContext {
5410
7157
  }
5411
7158
  }
5412
7159
 
5413
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
7160
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/gzip.node.mjs
7161
+ import { gzip } from "node:zlib";
7162
+ import { promisify } from "node:util";
7163
+ var gzipAsync = promisify(gzip);
7164
+ async function gzipCompress2(input, isDebug = true) {
7165
+ try {
7166
+ const compressed = await gzipAsync(input);
7167
+ return new Uint8Array(compressed);
7168
+ } catch (error) {
7169
+ if (isDebug)
7170
+ console.error("Failed to gzip compress data", error);
7171
+ return null;
7172
+ }
7173
+ }
7174
+
7175
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
5414
7176
  var NAME = "posthog-node";
5415
7177
  function createEventProcessor(_posthog, { organization, projectId, prefix, severityAllowList = [
5416
7178
  "error"
@@ -5450,6 +7212,9 @@ function createEventProcessor(_posthog, { organization, projectId, prefix, sever
5450
7212
  $sentry_exception_type: exceptions[0]?.type,
5451
7213
  $sentry_tags: event.tags
5452
7214
  };
7215
+ const injectedReleaseId = getInjectedReleaseId();
7216
+ if (injectedReleaseId)
7217
+ properties.$release_id = injectedReleaseId;
5453
7218
  if (organization && projectId)
5454
7219
  properties["$sentry_url"] = (prefix || "https://sentry.io/organizations/") + organization + "/issues/?project=" + projectId + "&query=" + event.event_id;
5455
7220
  if (sendExceptionsToPostHog)
@@ -5478,24 +7243,27 @@ class PostHogSentryIntegration {
5478
7243
  };
5479
7244
  }
5480
7245
  }
5481
- // ../../../../../node_modules/.bun/posthog-node@5.35.12/node_modules/posthog-node/dist/entrypoints/index.node.mjs
7246
+ // ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/entrypoints/index.node.mjs
5482
7247
  class PostHog extends PostHogBackendClient {
5483
7248
  getLibraryId() {
5484
7249
  return "posthog-node";
5485
7250
  }
7251
+ compressPayload(payload) {
7252
+ return gzipCompress2(payload, this.isDebug);
7253
+ }
5486
7254
  initializeContext() {
5487
7255
  return new PostHogContext;
5488
7256
  }
5489
7257
  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), [
7258
+ return new ErrorPropertiesBuilder([
7259
+ new EventCoercer,
7260
+ new ErrorCoercer,
7261
+ new ObjectCoercer,
7262
+ new StringCoercer,
7263
+ new PrimitiveCoercer
7264
+ ], createStackParser("node:javascript", nodeStackLineParser), [
5497
7265
  createModulerModifier(),
5498
- addSourceContext,
7266
+ (frames) => addSourceContext(frames, undefined, this._logger),
5499
7267
  createRelativePathModifier()
5500
7268
  ]);
5501
7269
  }
@@ -5816,11 +7584,11 @@ function getPostHogDistinctIdForTesting(osProvider) {
5816
7584
  return getTelemetryDistinctId(MACHINE_ID_PREFIX, osProvider);
5817
7585
  }
5818
7586
  export {
5819
- getPostHogDistinctIdForTesting,
5820
- getPostHogDistinctId,
5821
- getComponentVersion,
5822
- createPluginPostHog,
5823
- __createPluginPostHogForTesting,
7587
+ DEFAULT_POSTHOG_API_KEY,
5824
7588
  DEFAULT_POSTHOG_HOST,
5825
- DEFAULT_POSTHOG_API_KEY
7589
+ __createPluginPostHogForTesting,
7590
+ createPluginPostHog,
7591
+ getComponentVersion,
7592
+ getPostHogDistinctId,
7593
+ getPostHogDistinctIdForTesting
5826
7594
  };