@posthog/wizard 2.80.0 → 2.81.0

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 (228) hide show
  1. package/README.md +204 -72
  2. package/dist/{PickerMenu-m4CCPX4f.js → PickerMenu-BGGeYqd-.js} +104 -4
  3. package/dist/PickerMenu-BGGeYqd-.js.map +1 -0
  4. package/dist/README.md +13 -8
  5. package/dist/{agent-interface-CzyCmp7q.js → agent-interface-BFzBnz10.js} +289 -361
  6. package/dist/agent-interface-BFzBnz10.js.map +1 -0
  7. package/dist/{agent-prompt-loader-4wMxlYSX.js → agent-prompt-loader-CbCW6YbP.js} +6 -5
  8. package/dist/agent-prompt-loader-CbCW6YbP.js.map +1 -0
  9. package/dist/analytics-CGGE7OSa.js +735 -0
  10. package/dist/analytics-CGGE7OSa.js.map +1 -0
  11. package/dist/analytics-D6NAIJxP.js +2 -0
  12. package/dist/api-DM4uMJ00.js +2 -0
  13. package/dist/{api-C3Dc4LFl.js → api-ZZhiRtbb.js} +3 -3
  14. package/dist/api-ZZhiRtbb.js.map +1 -0
  15. package/dist/api-key-login-C30LRht2.js +2 -0
  16. package/dist/api-key-login-D0KBr1dx.js +55 -0
  17. package/dist/api-key-login-D0KBr1dx.js.map +1 -0
  18. package/dist/bin.js +2 -2
  19. package/dist/bin.js.map +1 -1
  20. package/dist/{bounded-fs-CC_NDtoP.js → bounded-fs-DwL2Tasp.js} +3 -3
  21. package/dist/{bounded-fs-CC_NDtoP.js.map → bounded-fs-DwL2Tasp.js.map} +1 -1
  22. package/dist/{ci-install-DfcAMhlu.js → ci-install-DKXrt_ow.js} +21 -25
  23. package/dist/ci-install-DKXrt_ow.js.map +1 -0
  24. package/dist/console-log-DJiTqYT2.js +32 -0
  25. package/dist/console-log-DJiTqYT2.js.map +1 -0
  26. package/dist/{debug-DyARf5TF.js → debug-sB20p-Ek.js} +18 -52
  27. package/dist/debug-sB20p-Ek.js.map +1 -0
  28. package/dist/{defaults-DpfMnH2q.js → defaults-DDVl3tKN.js} +2 -51
  29. package/dist/defaults-DDVl3tKN.js.map +1 -0
  30. package/dist/{emit-BSetXzDV.js → emit-BqLCdV8Y.js} +2 -1
  31. package/dist/{emit-BSetXzDV.js.map → emit-BqLCdV8Y.js.map} +1 -1
  32. package/dist/{errors-C2domSkK.js → errors-DhFeR8Sp.js} +5 -5
  33. package/dist/{errors-C2domSkK.js.map → errors-DhFeR8Sp.js.map} +1 -1
  34. package/dist/family-picker-BKs-tTyu.js +46 -0
  35. package/dist/family-picker-BKs-tTyu.js.map +1 -0
  36. package/dist/{gateway-BmjYUSua.js → gateway-Dg4Fm-nC.js} +122 -11
  37. package/dist/gateway-Dg4Fm-nC.js.map +1 -0
  38. package/dist/headless-B3Ol1nkU.js +3 -0
  39. package/dist/headless-DhTDC9ga.js +10 -0
  40. package/dist/headless-DhTDC9ga.js.map +1 -0
  41. package/dist/{host-resolution-DVSb7kXb.js → host-resolution-DDYJXiAQ.js} +4 -4
  42. package/dist/{host-resolution-DVSb7kXb.js.map → host-resolution-DDYJXiAQ.js.map} +1 -1
  43. package/dist/install-CZeR38cD.js +2 -0
  44. package/dist/{install-Bk5TNk27.js → install-Dh8Z5R15.js} +62 -143
  45. package/dist/install-Dh8Z5R15.js.map +1 -0
  46. package/dist/interactive-hqHk6kz4.js +11 -0
  47. package/dist/interactive-hqHk6kz4.js.map +1 -0
  48. package/dist/{links-9LWZPSCq.js → links-rMot83W2.js} +3 -3
  49. package/dist/{links-9LWZPSCq.js.map → links-rMot83W2.js.map} +1 -1
  50. package/dist/{main-DKPjFHEV.js → main-DNIeasXx.js} +205 -470
  51. package/dist/main-DNIeasXx.js.map +1 -0
  52. package/dist/{mcp-Co8VRF62.js → mcp-SZcGfaOz.js} +3 -4
  53. package/dist/{mcp-Co8VRF62.js.map → mcp-SZcGfaOz.js.map} +1 -1
  54. package/dist/mcp-install-smoke-test.ts +2 -2
  55. package/dist/{mcp-prompt-streaming-ljCVoQ9I.js → mcp-prompt-streaming-BuRMBgbo.js} +12 -12
  56. package/dist/mcp-prompt-streaming-BuRMBgbo.js.map +1 -0
  57. package/dist/mode-label-DB3ol_sj.js +9 -0
  58. package/dist/mode-label-DB3ol_sj.js.map +1 -0
  59. package/dist/{models-Dba8ITeo.js → models-G1j-wgwe.js} +2 -2
  60. package/dist/{models-Dba8ITeo.js.map → models-G1j-wgwe.js.map} +1 -1
  61. package/dist/non-interactive-DkldwWDM.js +18 -0
  62. package/dist/non-interactive-DkldwWDM.js.map +1 -0
  63. package/dist/{oauth-session-D-RfcVmr.js → oauth-session-C2fVSGfr.js} +3 -3
  64. package/dist/{oauth-session-D-RfcVmr.js.map → oauth-session-C2fVSGfr.js.map} +1 -1
  65. package/dist/{orchestrator-tools-CVJ1F9Ub.js → orchestrator-tools-BchqG7Qi.js} +3 -3
  66. package/dist/{orchestrator-tools-CVJ1F9Ub.js.map → orchestrator-tools-BchqG7Qi.js.map} +1 -1
  67. package/dist/{package-json-Cowya9-3.js → package-json-2UrhE6kP.js} +1 -1
  68. package/dist/{package-json-Cowya9-3.js.map → package-json-2UrhE6kP.js.map} +1 -1
  69. package/dist/package-json-Dblip2_X.js +2 -0
  70. package/dist/package-manager-B3_qSybg.js +105 -0
  71. package/dist/package-manager-B3_qSybg.js.map +1 -0
  72. package/dist/{pi-B5YTBRDv.js → pi-Cw7CPXSl.js} +17 -19
  73. package/dist/pi-Cw7CPXSl.js.map +1 -0
  74. package/dist/playground-CPNrQfb3.js +12 -0
  75. package/dist/playground-CPNrQfb3.js.map +1 -0
  76. package/dist/posthog-integration-FAWfClH3.js +10304 -0
  77. package/dist/posthog-integration-FAWfClH3.js.map +1 -0
  78. package/dist/programs-DjCmEcxb.js +3 -0
  79. package/dist/programs-Ml6OLybj.js +5402 -0
  80. package/dist/programs-Ml6OLybj.js.map +1 -0
  81. package/dist/{provisioning-CLhuKqXH.js → provisioning-BTVL49jD.js} +4 -5
  82. package/dist/{provisioning-CLhuKqXH.js.map → provisioning-BTVL49jD.js.map} +1 -1
  83. package/dist/provisioning-DL0xCJXH.js +2 -0
  84. package/dist/{queue-tools-knnPQP0e.js → queue-tools-BQfRI_uD.js} +6 -8
  85. package/dist/queue-tools-BQfRI_uD.js.map +1 -0
  86. package/dist/results-ycm_Tf31.js +90 -0
  87. package/dist/results-ycm_Tf31.js.map +1 -0
  88. package/dist/run-Bgg-ctbA.js +264 -0
  89. package/dist/run-Bgg-ctbA.js.map +1 -0
  90. package/dist/run-C6Ei6vvb.js +246 -0
  91. package/dist/run-C6Ei6vvb.js.map +1 -0
  92. package/dist/run-tool-CrN2xWzU.js +2436 -0
  93. package/dist/run-tool-CrN2xWzU.js.map +1 -0
  94. package/dist/run-tool-tNjm8S-E.js +2 -0
  95. package/dist/runners-GGYJs0Ny.js +271 -0
  96. package/dist/runners-GGYJs0Ny.js.map +1 -0
  97. package/dist/{security-BvdSFDuM.js → security-C36p8lu6.js} +44 -52
  98. package/dist/security-C36p8lu6.js.map +1 -0
  99. package/dist/setup-utils-Dfgse6pY.js +118 -0
  100. package/dist/setup-utils-Dfgse6pY.js.map +1 -0
  101. package/dist/smoke-test.sh +1 -1
  102. package/dist/{playground-BLsCfHmQ.js → start-playground-D0TrdLmc.js} +44 -34
  103. package/dist/start-playground-D0TrdLmc.js.map +1 -0
  104. package/dist/{subagent-D_Sqak94.js → subagent-DR5caRzL.js} +7 -7
  105. package/dist/subagent-DR5caRzL.js.map +1 -0
  106. package/dist/{task-DiTI6Sak.js → task-C1qKgsAf.js} +18 -18
  107. package/dist/task-C1qKgsAf.js.map +1 -0
  108. package/dist/{tasks-ChZ_F1YP.js → tasks-BfJhVky2.js} +1 -1
  109. package/dist/tasks-BfJhVky2.js.map +1 -0
  110. package/dist/{telemetry-BNKsDxNS.js → telemetry-Ch9ZJvm7.js} +2 -2
  111. package/dist/{telemetry-BNKsDxNS.js.map → telemetry-Ch9ZJvm7.js.map} +1 -1
  112. package/dist/terminal-D20JFN3J.js +16188 -0
  113. package/dist/terminal-D20JFN3J.js.map +1 -0
  114. package/dist/tools-BZseGChD.js +544 -0
  115. package/dist/tools-BZseGChD.js.map +1 -0
  116. package/dist/{tools-C8LQ8QFz.js → tools-CmSMclOD.js} +9 -9
  117. package/dist/tools-CmSMclOD.js.map +1 -0
  118. package/dist/tui-BXe1D0tc.js +25 -0
  119. package/dist/tui-BXe1D0tc.js.map +1 -0
  120. package/dist/tui-DJf3ZPRh.js +2 -0
  121. package/dist/{steps-Hc28zVc_.js → upload-step-BlAN7MC5.js} +14 -16
  122. package/dist/upload-step-BlAN7MC5.js.map +1 -0
  123. package/dist/{urls-BI4kJ4qQ.js → urls-eFaChZ9d.js} +2 -2
  124. package/dist/{urls-BI4kJ4qQ.js.map → urls-eFaChZ9d.js.map} +1 -1
  125. package/dist/warlock-smoke-test.ts +1 -2
  126. package/dist/{wizard-abort-DBKtfnBR.js → wizard-abort-BX3O4Hg4.js} +40 -33
  127. package/dist/wizard-abort-BX3O4Hg4.js.map +1 -0
  128. package/dist/{yara-hooks-C3L6lBij.js → yara-hooks-C4HOysrM.js} +283 -21
  129. package/dist/yara-hooks-C4HOysrM.js.map +1 -0
  130. package/dist/yara-hooks-DV4EkkZY.js +2 -0
  131. package/package.json +7 -6
  132. package/dist/PickerMenu-m4CCPX4f.js.map +0 -1
  133. package/dist/agent-BkBbVuNq.js +0 -3189
  134. package/dist/agent-BkBbVuNq.js.map +0 -1
  135. package/dist/agent-QGK2YzlX.js +0 -6
  136. package/dist/agent-interface-CzyCmp7q.js.map +0 -1
  137. package/dist/agent-prompt-loader-4wMxlYSX.js.map +0 -1
  138. package/dist/analytics-B6q5PN7a.js +0 -301
  139. package/dist/analytics-B6q5PN7a.js.map +0 -1
  140. package/dist/analytics-BXtfK9o7.js +0 -2
  141. package/dist/api-C3Dc4LFl.js.map +0 -1
  142. package/dist/api-yNjrfZs2.js +0 -2
  143. package/dist/check-screens.tsx +0 -190
  144. package/dist/ci-install-DfcAMhlu.js.map +0 -1
  145. package/dist/constants-DO4X70po.js +0 -260
  146. package/dist/constants-DO4X70po.js.map +0 -1
  147. package/dist/debug-BueK5mRR.js +0 -2
  148. package/dist/debug-DyARf5TF.js.map +0 -1
  149. package/dist/defaults-DpfMnH2q.js.map +0 -1
  150. package/dist/endpoints-D-4KxZiB.js +0 -108
  151. package/dist/endpoints-D-4KxZiB.js.map +0 -1
  152. package/dist/env-api-key-CHGLe0iz.js +0 -2
  153. package/dist/env-api-key-COf0U-Au.js +0 -17
  154. package/dist/env-api-key-COf0U-Au.js.map +0 -1
  155. package/dist/environment-DrLaSsA8.js +0 -39
  156. package/dist/environment-DrLaSsA8.js.map +0 -1
  157. package/dist/environment-hBj7ngmO.js +0 -2
  158. package/dist/file-CVA9ocIC.js +0 -60
  159. package/dist/file-CVA9ocIC.js.map +0 -1
  160. package/dist/file-CmoKK_Pp.js +0 -2
  161. package/dist/file-watcher-C3Su8vXm.js +0 -123
  162. package/dist/file-watcher-C3Su8vXm.js.map +0 -1
  163. package/dist/gateway-BmjYUSua.js.map +0 -1
  164. package/dist/headless-ui-CUbv12Yx.js +0 -44
  165. package/dist/headless-ui-CUbv12Yx.js.map +0 -1
  166. package/dist/install-Bk5TNk27.js.map +0 -1
  167. package/dist/install-F4wm3RSl.js +0 -2
  168. package/dist/interactive-C5LNvDj6.js +0 -11
  169. package/dist/interactive-C5LNvDj6.js.map +0 -1
  170. package/dist/local-dev-McsurOC-.js +0 -135
  171. package/dist/local-dev-McsurOC-.js.map +0 -1
  172. package/dist/logging-ui-p6XKVmTx.js +0 -226
  173. package/dist/logging-ui-p6XKVmTx.js.map +0 -1
  174. package/dist/main-DKPjFHEV.js.map +0 -1
  175. package/dist/mcp-prompt-streaming-ljCVoQ9I.js.map +0 -1
  176. package/dist/mint-failure-C0HyvEwO.js +0 -6403
  177. package/dist/mint-failure-C0HyvEwO.js.map +0 -1
  178. package/dist/non-interactive-CLMJrj_7.js +0 -18
  179. package/dist/non-interactive-CLMJrj_7.js.map +0 -1
  180. package/dist/package-json--ppioh2F.js +0 -2
  181. package/dist/pi-B5YTBRDv.js.map +0 -1
  182. package/dist/playground-BLsCfHmQ.js.map +0 -1
  183. package/dist/posthog-B2E0hpZt.js +0 -2
  184. package/dist/posthog-B42rt_1S.js +0 -124
  185. package/dist/posthog-B42rt_1S.js.map +0 -1
  186. package/dist/project-data--L-WZyvj.js +0 -2
  187. package/dist/project-data-BO9IXn9y.js +0 -1131
  188. package/dist/project-data-BO9IXn9y.js.map +0 -1
  189. package/dist/provisioning-C01REIU2.js +0 -2
  190. package/dist/queue-tools-knnPQP0e.js.map +0 -1
  191. package/dist/registry-B3rC5U4b.js +0 -3464
  192. package/dist/registry-B3rC5U4b.js.map +0 -1
  193. package/dist/registry-BamsM7J9.js +0 -2
  194. package/dist/run-agent-legacy-CwUmPfQF.js +0 -2
  195. package/dist/run-agent-legacy-DWBajsMh.js +0 -3467
  196. package/dist/run-agent-legacy-DWBajsMh.js.map +0 -1
  197. package/dist/runners-D1PqqpjA.js +0 -834
  198. package/dist/runners-D1PqqpjA.js.map +0 -1
  199. package/dist/security-BvdSFDuM.js.map +0 -1
  200. package/dist/setup-utils-ChXXTi1m.js +0 -301
  201. package/dist/setup-utils-ChXXTi1m.js.map +0 -1
  202. package/dist/start-tui-DicLfgsj.js +0 -6964
  203. package/dist/start-tui-DicLfgsj.js.map +0 -1
  204. package/dist/steps-Hc28zVc_.js.map +0 -1
  205. package/dist/store-COCO6U0P.js +0 -5
  206. package/dist/store-D3509G87.js +0 -1030
  207. package/dist/store-D3509G87.js.map +0 -1
  208. package/dist/subagent-D_Sqak94.js.map +0 -1
  209. package/dist/task-DiTI6Sak.js.map +0 -1
  210. package/dist/task-status-CmrrR7zo.js +0 -16
  211. package/dist/task-status-CmrrR7zo.js.map +0 -1
  212. package/dist/task-stream-BckhG_cB.js +0 -363
  213. package/dist/task-stream-BckhG_cB.js.map +0 -1
  214. package/dist/tasks-ChZ_F1YP.js.map +0 -1
  215. package/dist/terminal-PK9bCLRi.js +0 -7222
  216. package/dist/terminal-PK9bCLRi.js.map +0 -1
  217. package/dist/tools-C8LQ8QFz.js.map +0 -1
  218. package/dist/ui-tPNpM6vj.js +0 -15
  219. package/dist/ui-tPNpM6vj.js.map +0 -1
  220. package/dist/version-5_ydHkM6.js +0 -6
  221. package/dist/version-5_ydHkM6.js.map +0 -1
  222. package/dist/wizard-abort-BVjqLyeA.js +0 -3
  223. package/dist/wizard-abort-DBKtfnBR.js.map +0 -1
  224. package/dist/wizard-session-B7BHnay0.js +0 -2
  225. package/dist/wizard-session-BYw6LzpS.js +0 -133
  226. package/dist/wizard-session-BYw6LzpS.js.map +0 -1
  227. package/dist/yara-hooks-C3L6lBij.js.map +0 -1
  228. package/dist/yara-hooks-CF_IsoaA.js +0 -2
@@ -0,0 +1,735 @@
1
+ import { _ as TASK_RUN_ID, f as VERSION, g as TASK_ID, h as RUN_SURFACE, o as logToFile } from "./debug-sB20p-Ek.js";
2
+ import { a as WizardError } from "./errors-DhFeR8Sp.js";
3
+ import { PostHog } from "posthog-node";
4
+ import { v4 } from "uuid";
5
+ //#region src/shared/local-dev.ts
6
+ /**
7
+ * Local development targets: context-mill (skills), MCP, and PostHog. Each is
8
+ * independently switchable — CI runs local skills against the *production* MCP
9
+ * — with `--local-dev` as a shorthand for all three.
10
+ *
11
+ * `wizard mcp add --local` is unrelated: it writes a `posthog-local` entry into
12
+ * the user's editor config rather than retargeting this run. Hence no
13
+ * `--local` here.
14
+ */
15
+ const CONTEXT_MILL_LOCAL_URL = process.env.CONTEXT_MILL_URL || "http://localhost:8765";
16
+ const MCP_LOCAL_URL = "http://localhost:8787/mcp";
17
+ /** Pins the API, app, OAuth, and the LLM gateway derived from them. */
18
+ const POSTHOG_LOCAL_URL = "http://localhost:8010";
19
+ /**
20
+ * A specific flag beats `--local-dev` in both directions. `??` is load-bearing:
21
+ * it falls through only on `undefined`, so giving the specific flags a yargs
22
+ * `default: false` would silently break both the umbrella and `--no-local-mcp`.
23
+ */
24
+ function resolveLocalDev(flags) {
25
+ const umbrella = flags.localDev ?? false;
26
+ return {
27
+ localMcp: flags.localMcp ?? umbrella,
28
+ localContextMill: flags.localContextMill ?? umbrella,
29
+ localPosthog: flags.localPosthog ?? umbrella
30
+ };
31
+ }
32
+ /** yargs populates both spellings, so read either. */
33
+ function localDevFromArgv(argv) {
34
+ const read = (kebab, camel) => {
35
+ const value = argv[camel] ?? argv[kebab];
36
+ return typeof value === "boolean" ? value : void 0;
37
+ };
38
+ return resolveLocalDev({
39
+ localDev: read("local-dev", "localDev"),
40
+ localMcp: read("local-mcp", "localMcp"),
41
+ localContextMill: read("local-context-mill", "localContextMill"),
42
+ localPosthog: read("local-posthog", "localPosthog")
43
+ });
44
+ }
45
+ const PRODUCTION_TARGETS = {
46
+ localMcp: false,
47
+ localContextMill: false,
48
+ localPosthog: false
49
+ };
50
+ let resolved = null;
51
+ /**
52
+ * Resolve this process's targets. Called once from the yargs middleware, which
53
+ * covers every command and the env-var spellings alike.
54
+ */
55
+ function initLocalDev(argv) {
56
+ resolved = localDevFromArgv(argv);
57
+ return resolved;
58
+ }
59
+ /**
60
+ * Where this run points. Resolved once because the flags are parsed at startup
61
+ * and never change; threading them through state let call sites read whichever
62
+ * field they happened to have, which is how the intro screens ended up asking
63
+ * the MCP flag where to fetch skills.
64
+ *
65
+ * Uninitialized means no CLI parse ran (a direct-call test) — production.
66
+ */
67
+ function getLocalDev() {
68
+ return resolved ?? PRODUCTION_TARGETS;
69
+ }
70
+ const LOCAL_SERVICES = [
71
+ {
72
+ key: "localContextMill",
73
+ label: "context-mill",
74
+ flag: "--local-context-mill",
75
+ url: `${CONTEXT_MILL_LOCAL_URL}/skill-menu.json`,
76
+ startHint: "npm run dev (in the context-mill repo)"
77
+ },
78
+ {
79
+ key: "localMcp",
80
+ label: "MCP server",
81
+ flag: "--local-mcp",
82
+ url: MCP_LOCAL_URL,
83
+ startHint: "hogli start (or pnpm dev:local-resources in posthog/services/mcp)"
84
+ },
85
+ {
86
+ key: "localPosthog",
87
+ label: "PostHog",
88
+ flag: "--local-posthog",
89
+ url: POSTHOG_LOCAL_URL,
90
+ startHint: "./bin/start (in the posthog repo)"
91
+ }
92
+ ];
93
+ const PROBE_TIMEOUT_MS = 2e3;
94
+ const PROBE_ATTEMPTS = 3;
95
+ const PROBE_BACKOFF_MS = 250;
96
+ async function isReachable(url) {
97
+ for (let attempt = 1; attempt <= PROBE_ATTEMPTS; attempt++) try {
98
+ await fetch(url, { signal: AbortSignal.timeout(PROBE_TIMEOUT_MS) });
99
+ return true;
100
+ } catch {
101
+ if (attempt < PROBE_ATTEMPTS) await new Promise((r) => setTimeout(r, PROBE_BACKOFF_MS * 2 ** (attempt - 1)));
102
+ }
103
+ return false;
104
+ }
105
+ /**
106
+ * Probe every service the flags asked to be local. Returns one message naming
107
+ * each unreachable one, or undefined if all are up (or none were requested).
108
+ *
109
+ * Without this a dead local server surfaces late and badly: a missing
110
+ * context-mill looks like a registry outage, a missing MCP fails mid-run after
111
+ * the agent has already edited files.
112
+ */
113
+ async function checkLocalServices(resolved) {
114
+ const requested = LOCAL_SERVICES.filter((s) => resolved[s.key]);
115
+ if (requested.length === 0) return void 0;
116
+ const reachable = await Promise.all(requested.map((s) => isReachable(s.url)));
117
+ const dead = requested.filter((_, i) => !reachable[i]);
118
+ if (dead.length === 0) return void 0;
119
+ return [
120
+ `Local ${dead.length === 1 ? "service is" : "services are"} not running:`,
121
+ "",
122
+ ...dead.map((s) => ` ${s.label} — nothing listening at ${new URL(s.url).origin}\n requested by ${s.flag}\n start it with: ${s.startHint}`),
123
+ "",
124
+ "Start the missing services, or drop the flag to use production."
125
+ ].join("\n");
126
+ }
127
+ /**
128
+ * `--local-mcp` used to select local skills too; anyone still relying on that
129
+ * would silently get production skills. Temporary — drop after a release or two.
130
+ */
131
+ function localMcpSkillsNotice(flags) {
132
+ if (flags.localMcp !== true) return void 0;
133
+ if (flags.localContextMill !== void 0 || flags.localDev === true) return;
134
+ return "--local-mcp now points only at the local MCP server. For local skills, add --local-context-mill (or use --local-dev for both).";
135
+ }
136
+ //#endregion
137
+ //#region src/shared/constants.ts
138
+ /**
139
+ * Shared constants for the PostHog wizard.
140
+ */
141
+ /** Next sonnet generation (a `MODEL_FLAG_VARIANTS` key in the switchboard). */
142
+ const SONNET_5_MODEL = "claude-sonnet-5";
143
+ /**
144
+ * Default model for agent runs. Bare model IDs (no `anthropic/` prefix) so the
145
+ * LLM gateway's Bedrock fallback can match map_to_bedrock_model().
146
+ */
147
+ const DEFAULT_AGENT_MODEL = SONNET_5_MODEL;
148
+ /** Undated haiku, for scan triage. The alias tracks the current 4.5 release rather than pinning one. */
149
+ const HAIKU_TRIAGE_MODEL = "claude-haiku-4-5";
150
+ /**
151
+ * Cheaper, faster model for mechanical agent work (e.g. repo classification
152
+ * during source-map detection). Passed via AgentConfig.modelOverride.
153
+ */
154
+ const HAIKU_MODEL = HAIKU_TRIAGE_MODEL;
155
+ const GPT5_6_LUNA_MODEL = "openai/gpt-5.6-luna";
156
+ const GPT5_6_TERRA_MODEL = "openai/gpt-5.6-terra";
157
+ const GPT5_6_SOL_MODEL = "openai/gpt-5.6-sol";
158
+ /**
159
+ * The two agent runner routing axes: **harness** (which agent SDK drives the LLM)
160
+ * and **sequence** (which pipeline shape orchestrates the work). Single source
161
+ * of truth for yargs `choices`, session fields, the runner registry, and tests
162
+ * — `Object.values(Harness)` gives an iterable of the values when an array is
163
+ * needed. Adding a member is enough to pick it up everywhere.
164
+ *
165
+ * Naming matches the directory layout — see `src/agent/runner/harness/`
166
+ * and `src/agent/runner/sequence/`.
167
+ */
168
+ let Harness = /* @__PURE__ */ function(Harness) {
169
+ Harness["anthropic"] = "anthropic";
170
+ Harness["pi"] = "pi";
171
+ return Harness;
172
+ }({});
173
+ let Sequence = /* @__PURE__ */ function(Sequence) {
174
+ Sequence["linear"] = "linear";
175
+ Sequence["orchestrator"] = "orchestrator";
176
+ return Sequence;
177
+ }({});
178
+ /**
179
+ * Detection order matters: put framework-specific integrations BEFORE basic language fallbacks.
180
+ */
181
+ let Integration = /* @__PURE__ */ function(Integration) {
182
+ Integration["nextjs"] = "nextjs";
183
+ Integration["nuxt"] = "nuxt";
184
+ Integration["vue"] = "vue";
185
+ Integration["reactRouter"] = "react-router";
186
+ Integration["tanstackStart"] = "tanstack-start";
187
+ Integration["tanstackRouter"] = "tanstack-router";
188
+ Integration["reactNative"] = "react-native";
189
+ Integration["angular"] = "angular";
190
+ Integration["astro"] = "astro";
191
+ Integration["django"] = "django";
192
+ Integration["flask"] = "flask";
193
+ Integration["fastapi"] = "fastapi";
194
+ Integration["laravel"] = "laravel";
195
+ Integration["sveltekit"] = "sveltekit";
196
+ Integration["flutter"] = "flutter";
197
+ Integration["kmp"] = "kmp";
198
+ Integration["swift"] = "swift";
199
+ Integration["android"] = "android";
200
+ Integration["rails"] = "rails";
201
+ Integration["elixir"] = "elixir";
202
+ Integration["go"] = "go";
203
+ Integration["rust"] = "rust";
204
+ Integration["java"] = "java";
205
+ Integration["python"] = "python";
206
+ Integration["ruby"] = "ruby";
207
+ Integration["javascript_web"] = "javascript_web";
208
+ Integration["javascriptNode"] = "javascript_node";
209
+ return Integration;
210
+ }({});
211
+ /**
212
+ * The platforms session replay can actually record on. Replay vision watches
213
+ * recordings, so a platform with no recordings has nothing to set up — the
214
+ * run must stop before any work, not after a pointless agent run.
215
+ *
216
+ * Web frameworks record through posthog-js (server-rendered frameworks
217
+ * included — they serve pages), and the mobile SDKs with replay support are
218
+ * React Native, Android, iOS, and Flutter. Excluded: pure backend targets
219
+ * (`javascript_node`, `python`, `ruby`) and KMP, which has no replay support
220
+ * yet.
221
+ */
222
+ const REPLAY_VISION_SUPPORTED = new Set([
223
+ "nextjs",
224
+ "nuxt",
225
+ "vue",
226
+ "react-router",
227
+ "tanstack-start",
228
+ "tanstack-router",
229
+ "angular",
230
+ "astro",
231
+ "sveltekit",
232
+ "javascript_web",
233
+ "django",
234
+ "flask",
235
+ "fastapi",
236
+ "laravel",
237
+ "rails",
238
+ "react-native",
239
+ "android",
240
+ "swift",
241
+ "flutter"
242
+ ]);
243
+ /** The events-audit report. */
244
+ const EVENTS_AUDIT_REPORT_FILE = "posthog-events-audit-report.md";
245
+ const EVENT_INVENTORY_FILE = ".posthog-events-inventory.json";
246
+ /** Per-part filename pattern emitted by events-audit subagents (e.g. `.posthog-events-inventory.part-3.json`). */
247
+ const EVENT_INVENTORY_PART_PATTERN = /^\.posthog-events-inventory\.part-\d+\.json$/;
248
+ /** The integration program's event plan. */
249
+ const EVENT_PLAN_FILE = ".posthog-events.json";
250
+ /** The integration program's setup report; Self-driving reads it as a hint. */
251
+ const SETUP_REPORT_FILE = "posthog-setup-report.md";
252
+ /**
253
+ * Region-agnostic PostHog app URL. Resolves to us.posthog.com or
254
+ * eu.posthog.com server-side based on the signed-in user's profile.
255
+ * Use this for share-with-user links (e.g. settings pages) so they
256
+ * land on the right region without us needing to know it client-side.
257
+ */
258
+ const POSTHOG_APP_URL = "https://app.posthog.com";
259
+ const ISSUES_URL = "https://github.com/posthog/wizard/issues";
260
+ /** Public status page, linked from transient-failure guidance (e.g. OAuth server_error). */
261
+ const POSTHOG_STATUS_PAGE_URL = "https://www.posthogstatus.com";
262
+ const CONTEXT_MILL_URL = "https://github.com/PostHog/context-mill";
263
+ /**
264
+ * Latest context-mill release page — the BYOAI download link shown in
265
+ * the privacy panel. Deliberately the release PAGE, not a direct asset
266
+ * URL: asset URLs are ~89 chars and hard-wrap inside the 64-col panel,
267
+ * which corrupts terminal copy/paste with a mid-URL line break. This
268
+ * stays under one line; the panel names the exact asset to grab.
269
+ */
270
+ const CONTEXT_MILL_RELEASES_URL = "https://github.com/PostHog/context-mill/releases/latest";
271
+ const POSTHOG_DOCS_URL = "https://posthog.com/docs";
272
+ const POSTHOG_TERMS_URL = "https://posthog.com/terms";
273
+ const POSTHOG_PRIVACY_URL = "https://posthog.com/privacy";
274
+ const POSTHOG_ORG_AI_SETTINGS_URL = "https://app.posthog.com/settings/organization-details#setting=organization-ai-consent";
275
+ const WIZARD_CONTACT_EMAIL = "wizard@posthog.com";
276
+ /**
277
+ * Two origins for the same release, same filenames. Interchangeable bases, so
278
+ * making AWS primary is a `getSkillsBaseUrl` change, not a code change.
279
+ */
280
+ const GITHUB_SKILLS_BASE_URL = "https://github.com/PostHog/context-mill/releases/latest/download";
281
+ const AWS_SKILLS_BASE_URL = "https://context-mill.posthog.com/latest";
282
+ /** Alias of `@shared/local-dev`'s constant, kept for existing importers. */
283
+ const LOCAL_SKILLS_BASE_URL = CONTEXT_MILL_LOCAL_URL;
284
+ /**
285
+ * Driven by `--local-context-mill`, NOT `--local-mcp` (which used to select
286
+ * both). Takes no argument on purpose: callers can't pass the wrong flag.
287
+ */
288
+ function getSkillsBaseUrl() {
289
+ return getLocalDev().localContextMill ? LOCAL_SKILLS_BASE_URL : GITHUB_SKILLS_BASE_URL;
290
+ }
291
+ const ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY = "sTMFPsFhdP1Ssg";
292
+ const ANALYTICS_HOST_URL = "https://internal-j.posthog.com";
293
+ const ANALYTICS_TEAM_TAG = "docs-and-wizard";
294
+ const OAUTH_PORTS = [
295
+ 8239,
296
+ 8238,
297
+ 8240,
298
+ 8237,
299
+ 8236,
300
+ 8235
301
+ ];
302
+ const POSTHOG_US_CLIENT_ID = "c4Rdw8DIxgtQfA80IiSnGKlNX8QN00cFWF00QQhM";
303
+ const POSTHOG_EU_CLIENT_ID = "bx2C5sZRN03TkdjraCcetvQFPGH6N2Y9vRLkcKEy";
304
+ const POSTHOG_DEV_CLIENT_ID = "DC5uRLVbGI02YQ82grxgnK6Qn12SXWpCqdPb60oZ";
305
+ const POSTHOG_PROXY_CLIENT_ID = POSTHOG_US_CLIENT_ID;
306
+ const DUMMY_PROJECT_API_KEY = "_YOUR_POSTHOG_PROJECT_TOKEN_";
307
+ /**
308
+ * Scopes the wizard requests during the agentic provisioning signup flow.
309
+ *
310
+ * Each entry is justified by what the wizard's agent step does after signup:
311
+ * - user:read identify the user for analytics + agent context
312
+ * - project:read look up the freshly-provisioned project
313
+ * - llm_gateway:read authenticate to gateway.{us,eu}.posthog.com/wizard
314
+ * (the agent's LLM calls — without this scope, every
315
+ * agent message returns 401)
316
+ * - query:read run HogQL queries when the agent needs data
317
+ * - dashboard:write create the onboarding dashboard during setup
318
+ * - insight:write create the onboarding insights during setup
319
+ * - notebook:write upload the events-audit report as a PostHog notebook
320
+ * in step 6 of the events-audit skill (notebooks-create
321
+ * MCP tool requires this scope)
322
+ * - event_definition:write
323
+ * create event definitions from the completed wizard
324
+ * session's event plan
325
+ *
326
+ * Must be a subset of `ALLOWED_PROVISIONING_SCOPES` in
327
+ * `ee/api/agentic_provisioning/views.py` on the backend.
328
+ */
329
+ const WIZARD_PROVISIONING_SCOPES = [
330
+ "user:read",
331
+ "project:read",
332
+ "llm_gateway:read",
333
+ "dashboard:write",
334
+ "insight:write",
335
+ "query:read",
336
+ "notebook:write",
337
+ "event_definition:write"
338
+ ];
339
+ /**
340
+ * Scopes the wizard requests during the OAuth login flow. Superset of
341
+ * `WIZARD_PROVISIONING_SCOPES` with scopes that only apply to the login
342
+ * path and are not in the provisioning allowlist:
343
+ * - health_issue:read used by `wizard doctor`
344
+ * - wizard_session:read list / retrieve / stream sessions
345
+ * - wizard_session:write stream run state to /api/projects/{id}/wizard/sessions/
346
+ * - event_definition:write
347
+ * create event definitions when a session completes
348
+ * - organization:read read `organization.is_ai_data_processing_approved`
349
+ * from /api/users/@me/ for the AI opt-in gate
350
+ *
351
+ * NOTE: every scope here must be within the wizard OAuth application's
352
+ * server-side scope ceiling (`OAuthApplication.scopes` in posthog, set
353
+ * via Django admin on BOTH prod regions). A scope outside the ceiling
354
+ * does NOT fail the authorize request — the server silently clamps the
355
+ * request to the ceiling (`clamp_scopes_to_ceiling` in posthog) and the
356
+ * token comes back without it. Separately, the consent screen lets the
357
+ * user deselect any scope the app doesn't mark required. Both paths
358
+ * yield a granted `scope` narrower than requested, with no error, so
359
+ * never assume the token carries this list — the token response's
360
+ * `scope` field is the truth, and `missingOAuthScopes` (utils/oauth.ts)
361
+ * diffs it at login. Ceiling procedure: the "scope-ceiling-invalid-scope"
362
+ * runbook in PostHog/runbooks. Keep its worked example in sync when this
363
+ * list changes.
364
+ */
365
+ const WIZARD_OAUTH_SCOPES = [
366
+ ...WIZARD_PROVISIONING_SCOPES,
367
+ "health_issue:read",
368
+ "wizard_session:read",
369
+ "wizard_session:write",
370
+ "wizard_run:write",
371
+ "organization:read"
372
+ ];
373
+ const WIZARD_INTERACTION_EVENT_NAME = "wizard interaction";
374
+ const WIZARD_REMARK_EVENT_NAME = "wizard remark";
375
+ /** Multivariate flag: `wizard-run` publishes to WizardRun, anything else to WizardSession. */
376
+ const WIZARD_RUN_SYNC_FLAG_KEY = "wizard-run-sync";
377
+ /** Boolean feature flag that routes a run to the experimental orchestrator runner. */
378
+ const WIZARD_ORCHESTRATOR_FLAG_KEY = "wizard-orchestrator";
379
+ /** Multivariate flag: per-stage orchestrator overrides ride each variant's JSON payload (`{stage: {model?, effort?}}`). */
380
+ const WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY = "wizard-orchestrator-override";
381
+ /** Boolean flag: on → pi for self-driving. Payload carries `{model, effort?, harness?, sequence?}` (model = a `MODEL_FLAG_VARIANTS` key); missing/invalid payload keeps the non-flagged default. */
382
+ const WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY = "wizard-self-driving-use-pi-harness";
383
+ /** Boolean flag: agentic project scoping for non-interactive basic-integration runs. */
384
+ const WIZARD_BASIC_INTEGRATION_AGENTIC_DETECTION_FLAG_KEY = "wizard-basic-integration-agentic-detection";
385
+ /** Boolean flag: the orchestrator queues the program's runner-seeded tasks (the warehouse step). Off, no task is queued and the run is byte-identical to a no-sources project. */
386
+ const WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY = "wizard-orchestrator-seeded-tasks";
387
+ /** Kill switch over a shipped default: ONLY an explicit 'false' excludes the AI Observability and Logs tasks from default integration runs — absent or fetch-failed means include, so the default never vanishes on a network hiccup. */
388
+ const WIZARD_DEFAULT_AIO_LOGS_FLAG_KEY = "wizard-default-aio-logs";
389
+ const WIZARD_FLAG_KEYS = [
390
+ WIZARD_RUN_SYNC_FLAG_KEY,
391
+ WIZARD_ORCHESTRATOR_FLAG_KEY,
392
+ WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY,
393
+ WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY,
394
+ WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY,
395
+ WIZARD_BASIC_INTEGRATION_AGENTIC_DETECTION_FLAG_KEY,
396
+ WIZARD_DEFAULT_AIO_LOGS_FLAG_KEY
397
+ ];
398
+ /** User-Agent for wizard HTTP requests and MCP server identification. */
399
+ const WIZARD_USER_AGENT = `posthog/wizard; version: ${VERSION}`;
400
+ /**
401
+ * User-Agent for a specific program's MCP calls, tagged with `program: <id>` so the
402
+ * backend can attribute work per program (e.g. the `self-driving` program's warehouse
403
+ * sources are recorded as `created_via=self_driving` rather than plain `wizard`). The
404
+ * base `posthog/wizard` token is preserved, so anything keying only on that still matches.
405
+ */
406
+ function wizardUserAgentForProgram(programId) {
407
+ return programId ? `${WIZARD_USER_AGENT}; program: ${programId}` : WIZARD_USER_AGENT;
408
+ }
409
+ /** Timeout for framework / project detection probes (ms). */
410
+ const DETECTION_TIMEOUT_MS = 1e4;
411
+ /** Timeout for the agentic project scan (ms); past it the run falls back to root detection. */
412
+ const AGENTIC_DETECTION_FIRST_ATTEMPT_TIMEOUT_MS = 6e4;
413
+ const AGENTIC_DETECTION_RETRY_TIMEOUT_MS = 9e4;
414
+ /**
415
+ * Timeout for the OAuth authorization flow (ms).
416
+ *
417
+ * How long the user has to complete the browser login. The authorization
418
+ * code is minted at approval and exchanged immediately on callback, so the
419
+ * server-side code expiry (`AUTHORIZATION_CODE_EXPIRE_SECONDS`, 5 minutes)
420
+ * bounds only the approval→exchange gap — manual-paste users have 5 minutes
421
+ * from approval to submit the code — not how long this window may stay open.
422
+ */
423
+ const OAUTH_TIMEOUT_MS = 18e5;
424
+ //#endregion
425
+ //#region src/shared/run-state.ts
426
+ /** One place to ask, so a new consent state does not need three edits. */
427
+ function mayReportScanResults(session) {
428
+ return session.scanConsent === "granted";
429
+ }
430
+ /** Lives here so analytics infrastructure never learns what consent means. */
431
+ function reportableDiscoveredFeatures(session) {
432
+ return mayReportScanResults(session) ? session.discoveredFeatures : void 0;
433
+ }
434
+ /** Also a scan result, so it travels under the same consent as the rest. */
435
+ function reportablePosthogSdkDetected(session) {
436
+ return mayReportScanResults(session) ? session.posthogSdkDetected : void 0;
437
+ }
438
+ //#endregion
439
+ //#region src/shared/utils/ci-flag-overrides.ts
440
+ function applyCiFlagOverrides(flags, payloads = {}) {
441
+ return {
442
+ flags,
443
+ payloads
444
+ };
445
+ }
446
+ /**
447
+ * Task types excluded from this run. The exclusion env var (see the allowlist
448
+ * in `env.ts`) is a comma-separated list (e.g. `dashboard`), set by the CI
449
+ * harness that owns the policy — the wizard and the served content stay
450
+ * run-mode agnostic. CI-build only, same as the flag overrides: published
451
+ * builds strip this path.
452
+ */
453
+ function ciExcludedTaskTypes() {
454
+ return [];
455
+ }
456
+ //#endregion
457
+ //#region src/shared/utils/analytics.ts
458
+ /**
459
+ * The invocation, reduced to flag-safe strings: the command word (first
460
+ * positional, 'default' for the bare flow) and the sorted option NAMES.
461
+ * Option values never leave the machine — they carry paths, emails, keys.
462
+ */
463
+ function invocationProperties() {
464
+ const args = process.argv.slice(2);
465
+ return {
466
+ command: args.find((a) => !a.startsWith("-")) ?? "default",
467
+ cli_flags: [...new Set(args.filter((a) => a.startsWith("--")).map((a) => a.slice(2).split("=")[0]))].sort().join(",")
468
+ };
469
+ }
470
+ /**
471
+ * Extract a standard property bag from the current session.
472
+ * Used by store-level analytics and available for ad-hoc captures.
473
+ */
474
+ function sessionProperties(session) {
475
+ const discoveredFeatures = reportableDiscoveredFeatures(session);
476
+ const posthogSdkDetected = reportablePosthogSdkDetected(session);
477
+ return {
478
+ integration: session.integration,
479
+ skill_id: session.skillId,
480
+ detected_framework: session.detectedFrameworkLabel,
481
+ typescript: session.typescript,
482
+ project_id: session.credentials?.projectId,
483
+ ...discoveredFeatures !== void 0 ? { discovered_features: discoveredFeatures } : {},
484
+ scan_consent: session.scanConsent,
485
+ run_phase: session.runPhase,
486
+ ...posthogSdkDetected !== void 0 ? { posthog_sdk_detected: posthogSdkDetected } : {}
487
+ };
488
+ }
489
+ function groupsFromUser(user, host) {
490
+ const groups = { instance: host };
491
+ if (!user) return groups;
492
+ const organizationId = user.organization?.id;
493
+ if (organizationId) groups.organization = organizationId;
494
+ const customerId = user.organization?.customer_id;
495
+ if (customerId) groups.customer = customerId;
496
+ const projectUuid = user.team?.uuid;
497
+ if (projectUuid) groups.project = projectUuid;
498
+ return groups;
499
+ }
500
+ const WIZARD_FLAGS = new Set(WIZARD_FLAG_KEYS);
501
+ function flagResponseValue(value) {
502
+ if (value === "true") return true;
503
+ if (value === "false") return false;
504
+ return value;
505
+ }
506
+ var Analytics = class {
507
+ client;
508
+ tags = {};
509
+ distinctId;
510
+ anonymousId;
511
+ _runId;
512
+ sessionId = null;
513
+ appName = "wizard";
514
+ activeFlags = null;
515
+ activeFlagPayloads = {};
516
+ groups = {};
517
+ personProperties = {};
518
+ terminalEventSent = false;
519
+ constructor() {
520
+ this.client = new PostHog(ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY, {
521
+ host: ANALYTICS_HOST_URL,
522
+ flushAt: 1,
523
+ flushInterval: 0,
524
+ enableExceptionAutocapture: true,
525
+ before_send: (event) => {
526
+ if (!event) return event;
527
+ if (Object.keys(this.groups).length > 0) event.groups = {
528
+ ...this.groups,
529
+ ...event.groups
530
+ };
531
+ if (event.event === "$exception") {
532
+ event.distinctId = this.distinctId ?? this.anonymousId;
533
+ const { $process_person_profile, ...properties } = event.properties ?? {};
534
+ event.properties = {
535
+ ...this.tags,
536
+ ...properties
537
+ };
538
+ }
539
+ if (event.event === "$feature_flag_called") event.properties = {
540
+ ...this.tags,
541
+ ...event.properties ?? {}
542
+ };
543
+ return event;
544
+ }
545
+ });
546
+ this.tags = { $app_name: this.appName };
547
+ this.tags.build = "prod";
548
+ this.tags.run_surface = RUN_SURFACE;
549
+ this.tags.version = VERSION;
550
+ if (TASK_RUN_ID) this.tags.task_run_id = TASK_RUN_ID;
551
+ if (TASK_ID) this.tags.task_id = TASK_ID;
552
+ this.anonymousId = v4();
553
+ this._runId = v4();
554
+ this.tags.run_id = this._runId;
555
+ this.distinctId = void 0;
556
+ }
557
+ /** Per-process run id, tagged on every event and gateway trace. */
558
+ get runId() {
559
+ return this._runId;
560
+ }
561
+ /** Build type for this run ('prod' | 'dev' | 'ci' | 'headless') — the same value tagged on every analytics event. */
562
+ get build() {
563
+ return String(this.tags.build ?? "dev");
564
+ }
565
+ /**
566
+ * Associate the run with the logged-in user, once per id. Identifies them
567
+ * (email, name) and records those person properties so events carry them and
568
+ * feature flags can target the individual user — without the email here the
569
+ * wizard only sends `$app_name`, so email-targeted flags never match. Opens
570
+ * the analytics session on first login, then aliases the run's anonymous id
571
+ * onto the identified person so pre-login events merge in.
572
+ */
573
+ identifyUser(user) {
574
+ const distinctId = user.distinct_id;
575
+ if (this.distinctId === distinctId || distinctId === this.anonymousId) return;
576
+ this.distinctId = distinctId;
577
+ if (!this.sessionId) {
578
+ this.sessionId = v4();
579
+ this.tags.$session_id = this.sessionId;
580
+ }
581
+ const props = {};
582
+ if (user.email) props.email = user.email;
583
+ const name = [user.first_name, user.last_name].filter(Boolean).join(" ").trim();
584
+ if (name) props.name = name;
585
+ this.personProperties = props;
586
+ this.client.identify({
587
+ distinctId,
588
+ properties: { $set: props }
589
+ });
590
+ this.client.alias({
591
+ distinctId,
592
+ alias: this.anonymousId
593
+ });
594
+ this.activeFlags = null;
595
+ this.activeFlagPayloads = {};
596
+ }
597
+ /** Person properties sent with flag evaluation: app name plus the user's. */
598
+ flagPersonProperties() {
599
+ return {
600
+ $app_name: this.appName,
601
+ version: VERSION,
602
+ run_surface: RUN_SURFACE,
603
+ build: String(this.tags.build ?? "dev"),
604
+ os: process.platform,
605
+ node_major: process.versions.node.split(".")[0],
606
+ ...invocationProperties(),
607
+ ...this.personProperties
608
+ };
609
+ }
610
+ setTag(key, value) {
611
+ this.tags[key] = value;
612
+ }
613
+ setGroups(groups) {
614
+ this.groups = groups;
615
+ }
616
+ captureException(error, properties = {}) {
617
+ const code = error instanceof WizardError && error.code || (typeof properties.error_code === "string" ? properties.error_code : "");
618
+ this.client.captureException(error, this.distinctId ?? this.anonymousId, {
619
+ team: ANALYTICS_TEAM_TAG,
620
+ ...code ? { $exception_fingerprint: `wizard_${code}` } : {},
621
+ ...this.tags,
622
+ ...properties
623
+ });
624
+ }
625
+ capture(eventName, properties) {
626
+ this.client.capture({
627
+ distinctId: this.distinctId ?? this.anonymousId,
628
+ event: eventName,
629
+ properties: {
630
+ ...this.tags,
631
+ ...this.wizardFlagFeatureProperties(),
632
+ ...properties
633
+ }
634
+ });
635
+ }
636
+ groupIdentify(groupType, groupKey, properties) {
637
+ this.client.groupIdentify({
638
+ groupType,
639
+ groupKey,
640
+ properties
641
+ });
642
+ }
643
+ wizardFlagFeatureProperties() {
644
+ if (this.activeFlags === null) return {};
645
+ const props = {};
646
+ const active = [];
647
+ for (const [key, value] of Object.entries(this.activeFlags)) {
648
+ if (!WIZARD_FLAGS.has(key)) continue;
649
+ const resolved = flagResponseValue(value);
650
+ props[`$feature/${key}`] = resolved;
651
+ if (resolved !== false) active.push(key);
652
+ }
653
+ if (active.length > 0) props.$active_feature_flags = active.sort();
654
+ return props;
655
+ }
656
+ /**
657
+ * Capture a wizard-specific event. Automatically prepends "wizard: " to the event name.
658
+ * All new wizard analytics should use this method instead of capture() directly.
659
+ */
660
+ wizardCapture(eventName, properties) {
661
+ this.capture(`wizard: ${eventName}`, properties);
662
+ }
663
+ /**
664
+ * Flush pending events without firing the "setup wizard finished" terminal
665
+ * event. Use this from CLI error paths that exit before any wizard run
666
+ * starts — `shutdown()` would inflate the run count with a "finished" event
667
+ * for a parse error that never actually ran the wizard.
668
+ */
669
+ async flush() {
670
+ await this.client.shutdown();
671
+ }
672
+ /**
673
+ * Evaluate all feature flags for the current user at the start of a run.
674
+ * Result is cached; subsequent calls in the same run return the same map.
675
+ * Returns flag key -> string value (booleans become 'true'/'false').
676
+ */
677
+ async getAllFlagsForWizard() {
678
+ if (this.activeFlags !== null) return this.activeFlags;
679
+ const out = {};
680
+ const payloads = {};
681
+ try {
682
+ const distinctId = this.distinctId ?? this.anonymousId;
683
+ logToFile("[flags] evaluating as", {
684
+ distinctId,
685
+ identified: this.distinctId !== void 0,
686
+ personProperties: this.flagPersonProperties()
687
+ });
688
+ const evaluation = await this.client.evaluateFlags(distinctId, { personProperties: this.flagPersonProperties() });
689
+ for (const key of WIZARD_FLAG_KEYS) {
690
+ const value = evaluation.getFlag(key);
691
+ if (value === void 0) continue;
692
+ out[key] = String(value);
693
+ const payload = evaluation.getFlagPayload(key);
694
+ if (payload !== void 0) payloads[key] = payload;
695
+ }
696
+ } catch (error) {
697
+ logToFile("Failed to get all feature flags:", error);
698
+ this.captureException(error instanceof Error ? error : new Error(String(error)), { step: "get_all_flags" });
699
+ }
700
+ const merged = applyCiFlagOverrides(out, payloads);
701
+ this.activeFlags = merged.flags;
702
+ this.activeFlagPayloads = merged.payloads;
703
+ logToFile("[flags] evaluated", this.activeFlags);
704
+ return this.activeFlags;
705
+ }
706
+ getCachedWizardFlags() {
707
+ return this.activeFlags;
708
+ }
709
+ /** Flag payloads from the same snapshot; empty until the flags are fetched. */
710
+ getWizardFlagPayloads() {
711
+ return this.activeFlagPayloads;
712
+ }
713
+ async shutdown(status) {
714
+ if (Object.keys(this.tags).length === 0) return;
715
+ if (this.terminalEventSent) return;
716
+ this.terminalEventSent = true;
717
+ this.client.capture({
718
+ distinctId: this.distinctId ?? this.anonymousId,
719
+ event: "setup wizard finished",
720
+ properties: {
721
+ ...this.tags,
722
+ run_id: this._runId,
723
+ ...this.sessionId ? { $session_id: this.sessionId } : {},
724
+ status,
725
+ tags: this.tags
726
+ }
727
+ });
728
+ await this.client.shutdown();
729
+ }
730
+ };
731
+ const analytics = new Analytics();
732
+ //#endregion
733
+ export { WIZARD_REMARK_EVENT_NAME as $, POSTHOG_APP_URL as A, REPLAY_VISION_SUPPORTED as B, HAIKU_MODEL as C, Integration as D, ISSUES_URL as E, POSTHOG_PRIVACY_URL as F, WIZARD_CONTACT_EMAIL as G, SONNET_5_MODEL as H, POSTHOG_PROXY_CLIENT_ID as I, WIZARD_OAUTH_SCOPES as J, WIZARD_DEFAULT_AIO_LOGS_FLAG_KEY as K, POSTHOG_STATUS_PAGE_URL as L, POSTHOG_DOCS_URL as M, POSTHOG_EU_CLIENT_ID as N, OAUTH_PORTS as O, POSTHOG_ORG_AI_SETTINGS_URL as P, WIZARD_PROVISIONING_SCOPES as Q, POSTHOG_TERMS_URL as R, GPT5_6_TERRA_MODEL as S, Harness as T, Sequence as U, SETUP_REPORT_FILE as V, WIZARD_BASIC_INTEGRATION_AGENTIC_DETECTION_FLAG_KEY as W, WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY as X, WIZARD_ORCHESTRATOR_FLAG_KEY as Y, WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY as Z, EVENT_INVENTORY_PART_PATTERN as _, ciExcludedTaskTypes as a, MCP_LOCAL_URL as at, GPT5_6_LUNA_MODEL as b, AGENTIC_DETECTION_RETRY_TIMEOUT_MS as c, getLocalDev as ct, CONTEXT_MILL_URL as d, resolveLocalDev as dt, WIZARD_RUN_SYNC_FLAG_KEY as et, DEFAULT_AGENT_MODEL as f, EVENT_INVENTORY_FILE as g, EVENTS_AUDIT_REPORT_FILE as h, sessionProperties as i, wizardUserAgentForProgram as it, POSTHOG_DEV_CLIENT_ID as j, OAUTH_TIMEOUT_MS as k, AWS_SKILLS_BASE_URL as l, initLocalDev as lt, DUMMY_PROJECT_API_KEY as m, analytics as n, WIZARD_USER_AGENT as nt, mayReportScanResults as o, POSTHOG_LOCAL_URL as ot, DETECTION_TIMEOUT_MS as p, WIZARD_INTERACTION_EVENT_NAME as q, groupsFromUser as r, getSkillsBaseUrl as rt, AGENTIC_DETECTION_FIRST_ATTEMPT_TIMEOUT_MS as s, checkLocalServices as st, Analytics as t, WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY as tt, CONTEXT_MILL_RELEASES_URL as u, localMcpSkillsNotice as ut, EVENT_PLAN_FILE as v, HAIKU_TRIAGE_MODEL as w, GPT5_6_SOL_MODEL as x, GITHUB_SKILLS_BASE_URL as y, POSTHOG_US_CLIENT_ID as z };
734
+
735
+ //# sourceMappingURL=analytics-CGGE7OSa.js.map