@posthog/wizard 2.77.0 → 2.78.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 (173) hide show
  1. package/README.md +30 -15
  2. package/dist/{add-mcp-server-to-clients-BnRyE4pw.js → add-mcp-server-to-clients-JMv8LP-O.js} +6 -5
  3. package/dist/{add-mcp-server-to-clients-BnRyE4pw.js.map → add-mcp-server-to-clients-JMv8LP-O.js.map} +1 -1
  4. package/dist/agent-bCZ3i3fh.js +3085 -0
  5. package/dist/agent-bCZ3i3fh.js.map +1 -0
  6. package/dist/{agent-interface-Avtr_5M5.js → agent-interface-BAOIHuXS.js} +429 -378
  7. package/dist/agent-interface-BAOIHuXS.js.map +1 -0
  8. package/dist/{agent-prompt-loader-CHixNPgY.js → agent-prompt-loader-7Pd4CfZO.js} +6 -6
  9. package/dist/agent-prompt-loader-7Pd4CfZO.js.map +1 -0
  10. package/dist/analytics-BcV-WCM4.js +2 -0
  11. package/dist/{analytics-C67F2vee.js → analytics-CHCZ_qUR.js} +10 -6
  12. package/dist/analytics-CHCZ_qUR.js.map +1 -0
  13. package/dist/{api-Dj1yabTj.js → api-Diy_2fp8.js} +4 -17
  14. package/dist/api-Diy_2fp8.js.map +1 -0
  15. package/dist/bin.js +410 -68
  16. package/dist/bin.js.map +1 -1
  17. package/dist/{bounded-fs-CWRYuLAn.js → bounded-fs-Bx9zTe6m.js} +4 -4
  18. package/dist/bounded-fs-Bx9zTe6m.js.map +1 -0
  19. package/dist/check-screens.tsx +1 -1
  20. package/dist/{ci-install-CvXL5h13.js → ci-install-CDdQYsPe.js} +6 -5
  21. package/dist/ci-install-CDdQYsPe.js.map +1 -0
  22. package/dist/constants-jFI2SaE1.js +260 -0
  23. package/dist/constants-jFI2SaE1.js.map +1 -0
  24. package/dist/debug-Ch4BDOtD.js +171 -0
  25. package/dist/debug-Ch4BDOtD.js.map +1 -0
  26. package/dist/{debug-CziFS0cA.js → debug-M2gV2iDq.js} +1 -1
  27. package/dist/{defaults-4c4YwTmW.js → defaults-C6J7yL4O.js} +1 -1
  28. package/dist/{defaults-4c4YwTmW.js.map → defaults-C6J7yL4O.js.map} +1 -1
  29. package/dist/endpoints-DCVbM06L.js +108 -0
  30. package/dist/endpoints-DCVbM06L.js.map +1 -0
  31. package/dist/{env-api-key-BZ5wE3Y4.js → env-api-key-Qx8NnYHm.js} +3 -3
  32. package/dist/env-api-key-Qx8NnYHm.js.map +1 -0
  33. package/dist/{environment-BEvsey6i.js → environment-B07Bmxae.js} +6 -6
  34. package/dist/environment-B07Bmxae.js.map +1 -0
  35. package/dist/{errors-BoJvrdw8.js → errors-CQ9kttJD.js} +27 -34
  36. package/dist/errors-CQ9kttJD.js.map +1 -0
  37. package/dist/{file-BoD3REGB.js → file-BcLTjU16.js} +2 -2
  38. package/dist/{file-BoD3REGB.js.map → file-BcLTjU16.js.map} +1 -1
  39. package/dist/{file-watcher-BPFazvG_.js → file-watcher-DWc_bTs6.js} +2 -2
  40. package/dist/{file-watcher-BPFazvG_.js.map → file-watcher-DWc_bTs6.js.map} +1 -1
  41. package/dist/{gateway-session-xPFv6p5c.js → gateway-CjoShdLa.js} +175 -20
  42. package/dist/gateway-CjoShdLa.js.map +1 -0
  43. package/dist/generate-version.cjs +1 -1
  44. package/dist/{headless-ui-CsmQrDIl.js → headless-ui-BFFmYC4v.js} +13 -2
  45. package/dist/headless-ui-BFFmYC4v.js.map +1 -0
  46. package/dist/{interactive-Dej-sxvR.js → interactive-D6zV7brJ.js} +2 -2
  47. package/dist/{interactive-Dej-sxvR.js.map → interactive-D6zV7brJ.js.map} +1 -1
  48. package/dist/{local-dev-DPZiIPCK.js → local-dev-McsurOC-.js} +2 -2
  49. package/dist/local-dev-McsurOC-.js.map +1 -0
  50. package/dist/logging-ui-_TwoMNbG.js +226 -0
  51. package/dist/logging-ui-_TwoMNbG.js.map +1 -0
  52. package/dist/mcp-DAgaoGk5.js +97 -0
  53. package/dist/mcp-DAgaoGk5.js.map +1 -0
  54. package/dist/{mcp-prompt-streaming-BU_kuur_.js → mcp-prompt-streaming-I2U_X7BC.js} +7 -6
  55. package/dist/mcp-prompt-streaming-I2U_X7BC.js.map +1 -0
  56. package/dist/{mint-failure-BrleGqMd.js → mint-failure-D4nd2XmZ.js} +82 -25
  57. package/dist/mint-failure-D4nd2XmZ.js.map +1 -0
  58. package/dist/models-DDdBJKwT.js +83 -0
  59. package/dist/models-DDdBJKwT.js.map +1 -0
  60. package/dist/{non-interactive-DcOjH2fw.js → non-interactive-Dzow7YKY.js} +3 -3
  61. package/dist/non-interactive-Dzow7YKY.js.map +1 -0
  62. package/dist/oauth-session-DJ8h6GFa.js +74 -0
  63. package/dist/oauth-session-DJ8h6GFa.js.map +1 -0
  64. package/dist/{orchestrator-tools-DXwr8Sp3.js → orchestrator-tools-szcdscwn.js} +4 -4
  65. package/dist/orchestrator-tools-szcdscwn.js.map +1 -0
  66. package/dist/{package-json-xt3eeyBI.js → package-json-DY70kkNp.js} +2 -2
  67. package/dist/package-json-DY70kkNp.js.map +1 -0
  68. package/dist/{pi-mY8I2XkG.js → pi-D3h5Ok0i.js} +329 -65
  69. package/dist/pi-D3h5Ok0i.js.map +1 -0
  70. package/dist/{playground-CDUUKLkC.js → playground-5AB4WgNF.js} +11 -7
  71. package/dist/playground-5AB4WgNF.js.map +1 -0
  72. package/dist/{posthog-Hc_-9wrr.js → posthog-DNn574nW.js} +8 -3
  73. package/dist/posthog-DNn574nW.js.map +1 -0
  74. package/dist/{provisioning-xfdjhFtA.js → provisioning-B8uSqRZk.js} +6 -5
  75. package/dist/provisioning-B8uSqRZk.js.map +1 -0
  76. package/dist/{queue-tools-C8y_xZJi.js → queue-tools-9OOVx5TE.js} +7 -86
  77. package/dist/queue-tools-9OOVx5TE.js.map +1 -0
  78. package/dist/{registry-DTmREJ-f.js → registry-8YG-kuXk.js} +265 -6
  79. package/dist/registry-8YG-kuXk.js.map +1 -0
  80. package/dist/run-agent-legacy-d7rWlzQR.js +3739 -0
  81. package/dist/run-agent-legacy-d7rWlzQR.js.map +1 -0
  82. package/dist/{security-Dw2oFJjP.js → security-Cg_4a7vB.js} +6 -6
  83. package/dist/security-Cg_4a7vB.js.map +1 -0
  84. package/dist/{setup-utils-fjJTBhaB.js → setup-utils-CmTCTPkX.js} +46 -18
  85. package/dist/setup-utils-CmTCTPkX.js.map +1 -0
  86. package/dist/smoke-test.sh +1 -1
  87. package/dist/{start-tui-UNe2xQ0U.js → start-tui-CB2PZs1x.js} +38 -44
  88. package/dist/start-tui-CB2PZs1x.js.map +1 -0
  89. package/dist/{steps-C2yqOk_h.js → steps-BZcXRJNY.js} +7 -7
  90. package/dist/{steps-C2yqOk_h.js.map → steps-BZcXRJNY.js.map} +1 -1
  91. package/dist/{store-Bic4Cr3L.js → store-UN7c-ASf.js} +18 -28
  92. package/dist/store-UN7c-ASf.js.map +1 -0
  93. package/dist/{subagent-Dz41vV9j.js → subagent-BofIDK-O.js} +8 -3
  94. package/dist/subagent-BofIDK-O.js.map +1 -0
  95. package/dist/{task-5-fw_Vw3.js → task-r9t1UhQP.js} +124 -36
  96. package/dist/task-r9t1UhQP.js.map +1 -0
  97. package/dist/{task-stream-dVzl6b_q.js → task-stream-CMUilu54.js} +45 -15
  98. package/dist/task-stream-CMUilu54.js.map +1 -0
  99. package/dist/{tasks-D1c2z1aw.js → tasks-Bbv_lOBG.js} +17 -13
  100. package/dist/tasks-Bbv_lOBG.js.map +1 -0
  101. package/dist/{telemetry-BRnxBRWK.js → telemetry-D6ruCtnv.js} +5 -5
  102. package/dist/telemetry-D6ruCtnv.js.map +1 -0
  103. package/dist/{terminal-9bvRa4Qt.js → terminal-DrGyci_a.js} +39 -74
  104. package/dist/terminal-DrGyci_a.js.map +1 -0
  105. package/dist/{tools-Dp6i9k70.js → tools-Dyfh9aCD.js} +11 -11
  106. package/dist/tools-Dyfh9aCD.js.map +1 -0
  107. package/dist/ui-BBVuTM1v.js +15 -0
  108. package/dist/ui-BBVuTM1v.js.map +1 -0
  109. package/dist/version-aXxpgRKx.js +6 -0
  110. package/dist/version-aXxpgRKx.js.map +1 -0
  111. package/dist/warlock-smoke-test.ts +2 -2
  112. package/dist/{wizard-abort-lE6umflt.js → wizard-abort-BBkiUxfS.js} +23 -20
  113. package/dist/wizard-abort-BBkiUxfS.js.map +1 -0
  114. package/dist/wizard-abort-BU4aLyvh.js +3 -0
  115. package/dist/{wizard-session-FSJCkTcP.js → wizard-session-2w4Ru-Wz.js} +12 -16
  116. package/dist/wizard-session-2w4Ru-Wz.js.map +1 -0
  117. package/dist/wizard-session-DGaUHOF3.js +2 -0
  118. package/dist/wizard-ui-DoyOZxK8.js +16 -0
  119. package/dist/wizard-ui-DoyOZxK8.js.map +1 -0
  120. package/dist/{yara-hooks-BTNJ6MGW.js → yara-hooks-DCeMDd1o.js} +19 -68
  121. package/dist/yara-hooks-DCeMDd1o.js.map +1 -0
  122. package/dist/yara-hooks-DSGuCU9A.js +2 -0
  123. package/package.json +1 -1
  124. package/dist/agent-interface-Avtr_5M5.js.map +0 -1
  125. package/dist/agent-prompt-loader-CHixNPgY.js.map +0 -1
  126. package/dist/agent-runner-COOIUJCP.js +0 -6188
  127. package/dist/agent-runner-COOIUJCP.js.map +0 -1
  128. package/dist/analytics-C67F2vee.js.map +0 -1
  129. package/dist/analytics-CJA1uLlk.js +0 -2
  130. package/dist/api-Dj1yabTj.js.map +0 -1
  131. package/dist/bounded-fs-CWRYuLAn.js.map +0 -1
  132. package/dist/ci-install-CvXL5h13.js.map +0 -1
  133. package/dist/debug-B4kzIZPi.js +0 -754
  134. package/dist/debug-B4kzIZPi.js.map +0 -1
  135. package/dist/env-api-key-BZ5wE3Y4.js.map +0 -1
  136. package/dist/environment-BEvsey6i.js.map +0 -1
  137. package/dist/errors-BoJvrdw8.js.map +0 -1
  138. package/dist/gateway-session-C118uACz.js +0 -2
  139. package/dist/gateway-session-xPFv6p5c.js.map +0 -1
  140. package/dist/headless-ui-CsmQrDIl.js.map +0 -1
  141. package/dist/local-dev-DPZiIPCK.js.map +0 -1
  142. package/dist/mcp-Cbuw_xss.js +0 -64
  143. package/dist/mcp-Cbuw_xss.js.map +0 -1
  144. package/dist/mcp-prompt-streaming-BU_kuur_.js.map +0 -1
  145. package/dist/mint-failure-BrleGqMd.js.map +0 -1
  146. package/dist/non-interactive-DcOjH2fw.js.map +0 -1
  147. package/dist/orchestrator-tools-DXwr8Sp3.js.map +0 -1
  148. package/dist/package-json-xt3eeyBI.js.map +0 -1
  149. package/dist/package-manager-DR23m5Jg.js +0 -290
  150. package/dist/package-manager-DR23m5Jg.js.map +0 -1
  151. package/dist/pi-mY8I2XkG.js.map +0 -1
  152. package/dist/playground-CDUUKLkC.js.map +0 -1
  153. package/dist/posthog-Hc_-9wrr.js.map +0 -1
  154. package/dist/provisioning-xfdjhFtA.js.map +0 -1
  155. package/dist/queue-tools-C8y_xZJi.js.map +0 -1
  156. package/dist/registry-DTmREJ-f.js.map +0 -1
  157. package/dist/security-Dw2oFJjP.js.map +0 -1
  158. package/dist/setup-utils-fjJTBhaB.js.map +0 -1
  159. package/dist/start-tui-UNe2xQ0U.js.map +0 -1
  160. package/dist/store-Bic4Cr3L.js.map +0 -1
  161. package/dist/subagent-Dz41vV9j.js.map +0 -1
  162. package/dist/task-5-fw_Vw3.js.map +0 -1
  163. package/dist/task-stream-dVzl6b_q.js.map +0 -1
  164. package/dist/tasks-D1c2z1aw.js.map +0 -1
  165. package/dist/telemetry-BRnxBRWK.js.map +0 -1
  166. package/dist/terminal-9bvRa4Qt.js.map +0 -1
  167. package/dist/tools-Dp6i9k70.js.map +0 -1
  168. package/dist/wizard-abort-CAcInAxg.js +0 -2
  169. package/dist/wizard-abort-lE6umflt.js.map +0 -1
  170. package/dist/wizard-session-CYvyYnti.js +0 -2
  171. package/dist/wizard-session-FSJCkTcP.js.map +0 -1
  172. package/dist/yara-hooks-BTNJ6MGW.js.map +0 -1
  173. package/dist/yara-hooks-CFY4pGcW.js +0 -2
@@ -1,754 +0,0 @@
1
- import { a as getLocalDev, t as CONTEXT_MILL_LOCAL_URL } from "./local-dev-DPZiIPCK.js";
2
- import { appendFileSync, mkdirSync } from "fs";
3
- import path from "path";
4
- import { inspect } from "node:util";
5
- import { tmpdir } from "node:os";
6
- import { join as join$1, sep as sep$1 } from "node:path";
7
- //#region src/lib/headless-mode.ts
8
- /**
9
- * The on-CLI flag name. Intentionally ugly + undocumented; do not surface it in
10
- * `--help`, the README, or user-facing error messages.
11
- */
12
- const HEADLESS_FLAG = "headless-DONOTUSE-EXPERIMENTAL";
13
- /**
14
- * The yargs option declaration for the headless flag. Commands opt in so that
15
- * unsupported commands reject headless execution instead of starting it.
16
- */
17
- const headlessOption = { [HEADLESS_FLAG]: {
18
- default: false,
19
- describe: "EXPERIMENTAL — do not use. Unstable, subject to breaking changes.",
20
- type: "boolean",
21
- hidden: true
22
- } };
23
- /**
24
- * Read the headless signal off a parsed argv / options bag. yargs always sets
25
- * the value under the declared key (`HEADLESS_FLAG`), so reading that key is
26
- * reliable regardless of camel-case expansion.
27
- */
28
- function isHeadless(options) {
29
- return options[HEADLESS_FLAG] === true;
30
- }
31
- const regionOption = { region: {
32
- describe: "PostHog cloud region\nenv: POSTHOG_WIZARD_REGION",
33
- choices: ["us", "eu"],
34
- type: "string",
35
- hidden: true
36
- } };
37
- //#endregion
38
- //#region src/env.ts
39
- /**
40
- * Central environment variable access for the PostHog wizard.
41
- *
42
- * ── Build-time constants ────────────────────────────────────────────
43
- * Inlined by tsdown's `env` option at compile time. After build, the
44
- * runtime value of these env vars has zero effect on the wizard.
45
- *
46
- * ── Runtime variables ───────────────────────────────────────────────
47
- * Read through `runtimeEnv()` with a typed allowlist. This makes every
48
- * runtime dependency on the environment explicit and grep-able.
49
- *
50
- * ── Direct process.env access ───────────────────────────────────────
51
- * Reserved for subprocess environment configuration (writes) and
52
- * vendored code. Production source outside those cases should use
53
- * this module instead.
54
- */
55
- const NODE_ENV = "production";
56
- /** 'cloud' when launched with the experimental headless flag, else 'local' — resolved once from argv at launch. */
57
- const RUN_SURFACE = process.argv.some((a) => a === `--headless-DONOTUSE-EXPERIMENTAL` || a.startsWith(`--headless-DONOTUSE-EXPERIMENTAL=`)) ? "cloud" : "local";
58
- /** Read a runtime environment variable. Only allowlisted keys compile. */
59
- function runtimeEnv(key) {
60
- return process.env[key];
61
- }
62
- /**
63
- * The PostHog task run that launched this wizard, when one did. A cloud run's
64
- * sandbox exports both ids into the wizard's environment; every local run
65
- * leaves them undefined. Resolved once at launch, like RUN_SURFACE above.
66
- */
67
- const TASK_RUN_ID = runtimeEnv("POSTHOG_TASK_RUN_ID") || void 0;
68
- const TASK_ID = runtimeEnv("POSTHOG_TASK_ID") || void 0;
69
- //#endregion
70
- //#region src/lib/version.ts
71
- const VERSION = "2.77.0";
72
- //#endregion
73
- //#region src/lib/constants.ts
74
- /**
75
- * Shared constants for the PostHog wizard.
76
- */
77
- /** Next sonnet generation (a `MODEL_FLAG_VARIANTS` key in the switchboard). */
78
- const SONNET_5_MODEL = "claude-sonnet-5";
79
- /**
80
- * Default model for agent runs. Bare model IDs (no `anthropic/` prefix) so the
81
- * LLM gateway's Bedrock fallback can match map_to_bedrock_model().
82
- */
83
- const DEFAULT_AGENT_MODEL = SONNET_5_MODEL;
84
- /** Undated haiku, for scan triage. The alias tracks the current 4.5 release rather than pinning one. */
85
- const HAIKU_TRIAGE_MODEL = "claude-haiku-4-5";
86
- /**
87
- * Cheaper, faster model for mechanical agent work (e.g. repo classification
88
- * during source-map detection). Passed via AgentConfig.modelOverride.
89
- */
90
- const HAIKU_MODEL = HAIKU_TRIAGE_MODEL;
91
- const GPT5_6_LUNA_MODEL = "openai/gpt-5.6-luna";
92
- const GPT5_6_TERRA_MODEL = "openai/gpt-5.6-terra";
93
- const GPT5_6_SOL_MODEL = "openai/gpt-5.6-sol";
94
- /**
95
- * The two agent runner routing axes: **harness** (which agent SDK drives the LLM)
96
- * and **sequence** (which pipeline shape orchestrates the work). Single source
97
- * of truth for yargs `choices`, session fields, the runner registry, and tests
98
- * — `Object.values(Harness)` gives an iterable of the values when an array is
99
- * needed. Adding a member is enough to pick it up everywhere.
100
- *
101
- * Naming matches the directory layout — see `src/lib/agent/runner/harness/`
102
- * and `src/lib/agent/runner/sequence/`.
103
- */
104
- let Harness = /* @__PURE__ */ function(Harness) {
105
- Harness["anthropic"] = "anthropic";
106
- Harness["pi"] = "pi";
107
- return Harness;
108
- }({});
109
- let Sequence = /* @__PURE__ */ function(Sequence) {
110
- Sequence["linear"] = "linear";
111
- Sequence["orchestrator"] = "orchestrator";
112
- return Sequence;
113
- }({});
114
- /**
115
- * Detection order matters: put framework-specific integrations BEFORE basic language fallbacks.
116
- */
117
- let Integration = /* @__PURE__ */ function(Integration) {
118
- Integration["nextjs"] = "nextjs";
119
- Integration["nuxt"] = "nuxt";
120
- Integration["vue"] = "vue";
121
- Integration["reactRouter"] = "react-router";
122
- Integration["tanstackStart"] = "tanstack-start";
123
- Integration["tanstackRouter"] = "tanstack-router";
124
- Integration["reactNative"] = "react-native";
125
- Integration["angular"] = "angular";
126
- Integration["astro"] = "astro";
127
- Integration["django"] = "django";
128
- Integration["flask"] = "flask";
129
- Integration["fastapi"] = "fastapi";
130
- Integration["laravel"] = "laravel";
131
- Integration["sveltekit"] = "sveltekit";
132
- Integration["flutter"] = "flutter";
133
- Integration["kmp"] = "kmp";
134
- Integration["swift"] = "swift";
135
- Integration["android"] = "android";
136
- Integration["rails"] = "rails";
137
- Integration["elixir"] = "elixir";
138
- Integration["go"] = "go";
139
- Integration["rust"] = "rust";
140
- Integration["java"] = "java";
141
- Integration["python"] = "python";
142
- Integration["ruby"] = "ruby";
143
- Integration["javascript_web"] = "javascript_web";
144
- Integration["javascriptNode"] = "javascript_node";
145
- return Integration;
146
- }({});
147
- /**
148
- * Region-agnostic PostHog app URL. Resolves to us.posthog.com or
149
- * eu.posthog.com server-side based on the signed-in user's profile.
150
- * Use this for share-with-user links (e.g. settings pages) so they
151
- * land on the right region without us needing to know it client-side.
152
- */
153
- const POSTHOG_APP_URL = "https://app.posthog.com";
154
- const ISSUES_URL = "https://github.com/posthog/wizard/issues";
155
- /** Public status page, linked from transient-failure guidance (e.g. OAuth server_error). */
156
- const POSTHOG_STATUS_PAGE_URL = "https://www.posthogstatus.com";
157
- const CONTEXT_MILL_URL = "https://github.com/PostHog/context-mill";
158
- /**
159
- * Latest context-mill release page — the BYOAI download link shown in
160
- * the privacy panel. Deliberately the release PAGE, not a direct asset
161
- * URL: asset URLs are ~89 chars and hard-wrap inside the 64-col panel,
162
- * which corrupts terminal copy/paste with a mid-URL line break. This
163
- * stays under one line; the panel names the exact asset to grab.
164
- */
165
- const CONTEXT_MILL_RELEASES_URL = "https://github.com/PostHog/context-mill/releases/latest";
166
- const POSTHOG_DOCS_URL = "https://posthog.com/docs";
167
- const POSTHOG_TERMS_URL = "https://posthog.com/terms";
168
- const POSTHOG_PRIVACY_URL = "https://posthog.com/privacy";
169
- const POSTHOG_ORG_AI_SETTINGS_URL = "https://app.posthog.com/settings/organization-details#setting=organization-ai-consent";
170
- const WIZARD_CONTACT_EMAIL = "wizard@posthog.com";
171
- /**
172
- * Two origins for the same release, same filenames. Interchangeable bases, so
173
- * making AWS primary is a `getSkillsBaseUrl` change, not a code change.
174
- */
175
- const GITHUB_SKILLS_BASE_URL = "https://github.com/PostHog/context-mill/releases/latest/download";
176
- const AWS_SKILLS_BASE_URL = "https://context-mill.posthog.com/latest";
177
- /** Alias of `@lib/local-dev`'s constant, kept for existing importers. */
178
- const LOCAL_SKILLS_BASE_URL = CONTEXT_MILL_LOCAL_URL;
179
- /**
180
- * Driven by `--local-context-mill`, NOT `--local-mcp` (which used to select
181
- * both). Takes no argument on purpose: callers can't pass the wrong flag.
182
- */
183
- function getSkillsBaseUrl() {
184
- return getLocalDev().localContextMill ? LOCAL_SKILLS_BASE_URL : GITHUB_SKILLS_BASE_URL;
185
- }
186
- const ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY = "sTMFPsFhdP1Ssg";
187
- const ANALYTICS_HOST_URL = "https://internal-j.posthog.com";
188
- const ANALYTICS_TEAM_TAG = "docs-and-wizard";
189
- const OAUTH_PORTS = [
190
- 8239,
191
- 8238,
192
- 8240,
193
- 8237,
194
- 8236,
195
- 8235
196
- ];
197
- const POSTHOG_US_CLIENT_ID = "c4Rdw8DIxgtQfA80IiSnGKlNX8QN00cFWF00QQhM";
198
- const POSTHOG_EU_CLIENT_ID = "bx2C5sZRN03TkdjraCcetvQFPGH6N2Y9vRLkcKEy";
199
- const POSTHOG_DEV_CLIENT_ID = "DC5uRLVbGI02YQ82grxgnK6Qn12SXWpCqdPb60oZ";
200
- const POSTHOG_PROXY_CLIENT_ID = POSTHOG_US_CLIENT_ID;
201
- const DUMMY_PROJECT_API_KEY = "_YOUR_POSTHOG_PROJECT_TOKEN_";
202
- /**
203
- * Scopes the wizard requests during the agentic provisioning signup flow.
204
- *
205
- * Each entry is justified by what the wizard's agent step does after signup:
206
- * - user:read identify the user for analytics + agent context
207
- * - project:read look up the freshly-provisioned project
208
- * - llm_gateway:read authenticate to gateway.{us,eu}.posthog.com/wizard
209
- * (the agent's LLM calls — without this scope, every
210
- * agent message returns 401)
211
- * - query:read run HogQL queries when the agent needs data
212
- * - dashboard:write create the onboarding dashboard during setup
213
- * - insight:write create the onboarding insights during setup
214
- * - notebook:write upload the events-audit report as a PostHog notebook
215
- * in step 6 of the events-audit skill (notebooks-create
216
- * MCP tool requires this scope)
217
- * - event_definition:write
218
- * create event definitions from the completed wizard
219
- * session's event plan
220
- *
221
- * Must be a subset of `ALLOWED_PROVISIONING_SCOPES` in
222
- * `ee/api/agentic_provisioning/views.py` on the backend.
223
- */
224
- const WIZARD_PROVISIONING_SCOPES = [
225
- "user:read",
226
- "project:read",
227
- "llm_gateway:read",
228
- "dashboard:write",
229
- "insight:write",
230
- "query:read",
231
- "notebook:write",
232
- "event_definition:write"
233
- ];
234
- /**
235
- * Scopes the wizard requests during the OAuth login flow. Superset of
236
- * `WIZARD_PROVISIONING_SCOPES` with scopes that only apply to the login
237
- * path and are not in the provisioning allowlist:
238
- * - health_issue:read used by `wizard doctor`
239
- * - wizard_session:read list / retrieve / stream sessions
240
- * - wizard_session:write stream run state to /api/projects/{id}/wizard/sessions/
241
- * - event_definition:write
242
- * create event definitions when a session completes
243
- * - organization:read read `organization.is_ai_data_processing_approved`
244
- * from /api/users/@me/ for the AI opt-in gate
245
- *
246
- * NOTE: every scope here must be within the wizard OAuth application's
247
- * server-side scope ceiling (`OAuthApplication.scopes` in posthog, set
248
- * via Django admin on BOTH prod regions). A scope outside the ceiling
249
- * does NOT fail the authorize request — the server silently clamps the
250
- * request to the ceiling (`clamp_scopes_to_ceiling` in posthog) and the
251
- * token comes back without it. Separately, the consent screen lets the
252
- * user deselect any scope the app doesn't mark required. Both paths
253
- * yield a granted `scope` narrower than requested, with no error, so
254
- * never assume the token carries this list — the token response's
255
- * `scope` field is the truth, and `missingOAuthScopes` (utils/oauth.ts)
256
- * diffs it at login. Ceiling procedure: the "scope-ceiling-invalid-scope"
257
- * runbook in PostHog/runbooks. Keep its worked example in sync when this
258
- * list changes.
259
- */
260
- const WIZARD_OAUTH_SCOPES = [
261
- ...WIZARD_PROVISIONING_SCOPES,
262
- "health_issue:read",
263
- "wizard_session:read",
264
- "wizard_session:write",
265
- "organization:read"
266
- ];
267
- const WIZARD_INTERACTION_EVENT_NAME = "wizard interaction";
268
- const WIZARD_REMARK_EVENT_NAME = "wizard remark";
269
- /** Boolean feature flag that routes a run to the experimental orchestrator runner. */
270
- const WIZARD_ORCHESTRATOR_FLAG_KEY = "wizard-orchestrator";
271
- /** Multivariate flag: per-stage orchestrator overrides ride each variant's JSON payload (`{stage: {model?, effort?}}`). */
272
- const WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY = "wizard-orchestrator-override";
273
- /** 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. */
274
- const WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY = "wizard-self-driving-use-pi-harness";
275
- /** Boolean flag: agentic project scoping for non-interactive basic-integration runs. */
276
- const WIZARD_BASIC_INTEGRATION_AGENTIC_DETECTION_FLAG_KEY = "wizard-basic-integration-agentic-detection";
277
- /** 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. */
278
- const WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY = "wizard-orchestrator-seeded-tasks";
279
- /** 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. */
280
- const WIZARD_DEFAULT_AIO_LOGS_FLAG_KEY = "wizard-default-aio-logs";
281
- const WIZARD_FLAG_KEYS = [
282
- WIZARD_ORCHESTRATOR_FLAG_KEY,
283
- WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY,
284
- WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY,
285
- WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY,
286
- WIZARD_BASIC_INTEGRATION_AGENTIC_DETECTION_FLAG_KEY,
287
- WIZARD_DEFAULT_AIO_LOGS_FLAG_KEY
288
- ];
289
- /** User-Agent for wizard HTTP requests and MCP server identification. */
290
- const WIZARD_USER_AGENT = `posthog/wizard; version: ${VERSION}`;
291
- /**
292
- * User-Agent for a specific program's MCP calls, tagged with `program: <id>` so the
293
- * backend can attribute work per program (e.g. the `self-driving` program's warehouse
294
- * sources are recorded as `created_via=self_driving` rather than plain `wizard`). The
295
- * base `posthog/wizard` token is preserved, so anything keying only on that still matches.
296
- */
297
- function wizardUserAgentForProgram(programId) {
298
- return programId ? `${WIZARD_USER_AGENT}; program: ${programId}` : WIZARD_USER_AGENT;
299
- }
300
- /** Timeout for framework / project detection probes (ms). */
301
- const DETECTION_TIMEOUT_MS = 1e4;
302
- /** Timeout for the agentic project scan (ms); past it the run falls back to root detection. */
303
- const AGENTIC_DETECTION_FIRST_ATTEMPT_TIMEOUT_MS = 6e4;
304
- const AGENTIC_DETECTION_RETRY_TIMEOUT_MS = 9e4;
305
- /**
306
- * Timeout for the OAuth authorization flow (ms).
307
- *
308
- * How long the user has to complete the browser login. The authorization
309
- * code is minted at approval and exchanged immediately on callback, so the
310
- * server-side code expiry (`AUTHORIZATION_CODE_EXPIRE_SECONDS`, 5 minutes)
311
- * bounds only the approval→exchange gap — manual-paste users have 5 minutes
312
- * from approval to submit the code — not how long this window may stay open.
313
- */
314
- const OAUTH_TIMEOUT_MS = 18e5;
315
- //#endregion
316
- //#region src/ui/wizard-ui.ts
317
- let TaskStatus = /* @__PURE__ */ function(TaskStatus) {
318
- TaskStatus["Pending"] = "pending";
319
- TaskStatus["InProgress"] = "in_progress";
320
- TaskStatus["Completed"] = "completed";
321
- TaskStatus["Skipped"] = "skipped";
322
- return TaskStatus;
323
- }({});
324
- function isTaskStatus(value) {
325
- return Object.values(TaskStatus).includes(value);
326
- }
327
- //#endregion
328
- //#region src/lib/health-checks/endpoints.ts
329
- function noConnectionResult(error, attempts) {
330
- return {
331
- status: "no-connection",
332
- error,
333
- rawIndicator: attempts > 1 ? `attempts=${attempts}` : void 0
334
- };
335
- }
336
- function downResult(error) {
337
- return {
338
- status: "down",
339
- error
340
- };
341
- }
342
- const RETRY_BACKOFFS_MS = [500, 2e3];
343
- async function attemptFetch(url, timeoutMs, redirect) {
344
- const controller = new AbortController();
345
- const tid = setTimeout(() => controller.abort(), timeoutMs);
346
- try {
347
- const res = await fetch(url, {
348
- signal: controller.signal,
349
- redirect
350
- });
351
- clearTimeout(tid);
352
- return {
353
- kind: "response",
354
- res
355
- };
356
- } catch (e) {
357
- clearTimeout(tid);
358
- const err = e instanceof Error ? e : /* @__PURE__ */ new Error("Unknown error");
359
- return {
360
- kind: "error",
361
- error: err,
362
- timedOut: err.name === "AbortError"
363
- };
364
- }
365
- }
366
- async function fetchEndpointHealth(url, timeoutMs = 5e3, isExpectedStatus = (s) => s === 200, redirect = "follow") {
367
- let lastHttpStatus = null;
368
- let lastError = "Unknown error";
369
- let attempts = 0;
370
- for (let i = 0; i <= RETRY_BACKOFFS_MS.length; i++) {
371
- if (i > 0) {
372
- const wait = RETRY_BACKOFFS_MS[i - 1];
373
- logToFile(`[health-checks] retry ${i}/${RETRY_BACKOFFS_MS.length} for ${url} in ${wait}ms (last: ${lastError})`);
374
- await new Promise((r) => setTimeout(r, wait));
375
- }
376
- attempts++;
377
- const outcome = await attemptFetch(url, timeoutMs, redirect);
378
- if (outcome.kind === "response") {
379
- const res = outcome.res;
380
- if (isExpectedStatus(res.status)) {
381
- const result = {
382
- status: "healthy",
383
- rawIndicator: attempts > 1 ? `HTTP ${res.status} (attempts=${attempts})` : `HTTP ${res.status}`
384
- };
385
- logToFile(`[health-checks] GET ${url} -> ${result.status} (${result.rawIndicator})`);
386
- return result;
387
- }
388
- lastHttpStatus = res.status;
389
- lastError = `HTTP ${res.status}`;
390
- continue;
391
- }
392
- lastError = outcome.timedOut ? `Request timed out after ${timeoutMs}ms` : outcome.error.message;
393
- }
394
- const result = lastHttpStatus !== null ? downResult(`HTTP ${lastHttpStatus} (attempts=${attempts})`) : noConnectionResult(lastError, attempts);
395
- logToFile(`[health-checks] GET ${url} -> ${result.status} (attempts=${attempts}, ${result.error})`);
396
- return result;
397
- }
398
- const checkLlmGatewayHealth = (gatewayUrl) => fetchEndpointHealth(new URL("/readyz", gatewayUrl).href);
399
- /**
400
- * Skills are published to two origins under the same filenames and
401
- * `fetchWithRetry` fails over between them, so the run is only blocked when
402
- * neither answers. Probed in parallel — sequential probes would double the
403
- * worst case past `READINESS_TIMEOUT_MS`.
404
- */
405
- const checkSkillsOriginHealth = async () => {
406
- const [github, aws] = await Promise.all([fetchEndpointHealth(`${GITHUB_SKILLS_BASE_URL}/skill-menu.json`), fetchEndpointHealth(`${AWS_SKILLS_BASE_URL}/skill-menu.json`)]);
407
- return combineOriginHealth(github, aws);
408
- };
409
- /**
410
- * Mirrors `fetchWithRetry`: a download tries GitHub, then AWS, so the run is
411
- * only blocked when neither origin answers. Whichever failure the probes saw,
412
- * one origin serving means skills are reachable.
413
- */
414
- function combineOriginHealth(github, aws) {
415
- if (github.status === "healthy") return aws.status === "healthy" ? github : withIndicatorSuffix(github, "aws unavailable");
416
- if (aws.status === "healthy") return withIndicatorSuffix(aws, "via aws, github unavailable");
417
- const error = `github: ${github.error ?? "unknown"} | aws: ${aws.error ?? "unknown"}`;
418
- return {
419
- status: github.status === "down" || aws.status === "down" ? "down" : "no-connection",
420
- error,
421
- rawIndicator: github.rawIndicator ?? aws.rawIndicator
422
- };
423
- }
424
- function withIndicatorSuffix(result, suffix) {
425
- return {
426
- ...result,
427
- rawIndicator: result.rawIndicator ? `${result.rawIndicator} (${suffix})` : suffix
428
- };
429
- }
430
- //#endregion
431
- //#region src/lib/health-checks/readiness.ts
432
- const SERVICE_LABELS = { skillsOrigin: "Skills download" };
433
- const DEFAULT_WIZARD_READINESS_CONFIG = { downBlocksRun: ["skillsOrigin"] };
434
- const SIGNUP_WIZARD_READINESS_CONFIG = DEFAULT_WIZARD_READINESS_CONFIG;
435
- async function checkAllExternalServices() {
436
- return { skillsOrigin: await checkSkillsOriginHealth() };
437
- }
438
- function describeResult(label, h) {
439
- const parts = [`${label}: ${h.status}`];
440
- if (h.rawIndicator) parts.push(`indicator=${h.rawIndicator}`);
441
- if (h.error) parts.push(h.error);
442
- return parts.join(" — ");
443
- }
444
- const READINESS_TIMEOUT_MS = 2e4;
445
- async function evaluateWizardReadiness(config = DEFAULT_WIZARD_READINESS_CONFIG) {
446
- try {
447
- const health = await Promise.race([checkAllExternalServices(), new Promise((resolve) => setTimeout(() => resolve(allUnknown("Health check timed out")), READINESS_TIMEOUT_MS))]);
448
- const blockingKeys = getBlockingServiceKeys(health, config);
449
- const reasons = blockingKeys.map((key) => describeResult(SERVICE_LABELS[key], health[key]));
450
- if (blockingKeys.length > 0) {
451
- logToFile(`[health-checks] blocked by: ${blockingKeys.map((key) => {
452
- const h = health[key];
453
- return `${key} (${h.status}${h.error ? ` — ${h.error}` : ""})`;
454
- }).join(", ")}`);
455
- return {
456
- decision: "no",
457
- health,
458
- reasons
459
- };
460
- }
461
- return {
462
- decision: "yes",
463
- health,
464
- reasons
465
- };
466
- } catch (err) {
467
- logToFile(`[health-checks] error: ${err instanceof Error ? err.message : err}`);
468
- return {
469
- decision: "yes",
470
- health: allUnknown("Unexpected error"),
471
- reasons: []
472
- };
473
- }
474
- }
475
- function getBlockingServiceKeys(health, config = DEFAULT_WIZARD_READINESS_CONFIG) {
476
- return Object.keys(health).filter((key) => {
477
- const result = health[key];
478
- if (config.downBlocksRun.includes(key) && (result.status === "down" || result.status === "no-connection")) return true;
479
- if ((config.degradedBlocksRun ?? []).includes(key) && result.status !== "healthy") return true;
480
- return false;
481
- });
482
- }
483
- /** Build an AllServicesHealth where every service is Degraded with the given error. */
484
- function allUnknown(error) {
485
- return { skillsOrigin: {
486
- status: "degraded",
487
- error
488
- } };
489
- }
490
- //#endregion
491
- //#region src/ui/logging-ui.ts
492
- var LoggingUI = class {
493
- intro(message) {
494
- console.log(`┌ ${message}`);
495
- }
496
- outro(message) {
497
- console.log(`└ ${message}`);
498
- }
499
- outroError(data) {
500
- console.log(`✖ ${data.message ?? "Wizard aborted"}`);
501
- if (data.body) console.log(`│ ${data.body}`);
502
- if (data.docsUrl) console.log(`│ Docs: ${data.docsUrl}`);
503
- }
504
- waitForOutroDismissed() {
505
- return Promise.resolve();
506
- }
507
- waitForAiOptIn() {
508
- return Promise.resolve();
509
- }
510
- cancel(message) {
511
- console.log(`■ ${message}`);
512
- }
513
- log = {
514
- info(message) {
515
- console.log(`│ ${message}`);
516
- },
517
- warn(message) {
518
- console.log(`▲ ${message}`);
519
- },
520
- error(message) {
521
- console.log(`✖ ${message}`);
522
- },
523
- success(message) {
524
- console.log(`✔ ${message}`);
525
- },
526
- step(message) {
527
- console.log(`◇ ${message}`);
528
- }
529
- };
530
- note(message) {
531
- console.log(`│ ${message}`);
532
- }
533
- spinner() {
534
- return {
535
- start(message) {
536
- if (message) console.log(`◌ ${message}`);
537
- },
538
- stop(message) {
539
- if (message) console.log(`● ${message}`);
540
- },
541
- message(msg) {
542
- if (msg) console.log(`◌ ${msg}`);
543
- }
544
- };
545
- }
546
- pushStatus(message) {
547
- console.log(`◇ ${message}`);
548
- }
549
- setDetectedFramework(label) {
550
- console.log(`✔ Framework: ${label}`);
551
- }
552
- onEnterScreen(_screen, _fn) {}
553
- setLoginUrl(url) {
554
- if (url) {
555
- console.log(`│ If the browser didn't open automatically, use this link:`);
556
- console.log(`│ ${url}`);
557
- }
558
- }
559
- setAuthorizeUrl(_url) {}
560
- showBlockingOutage(result) {
561
- console.log(`▲ Service health issues detected.`);
562
- const blockingKeys = getBlockingServiceKeys(result.health);
563
- if (blockingKeys.length > 0) {
564
- console.log(`│`);
565
- console.log(`│ Blocking services:`);
566
- for (const key of blockingKeys) {
567
- const status = result.health[key].status;
568
- const error = result.health[key].error;
569
- const label = SERVICE_LABELS[key];
570
- const detail = error ? ` — ${error}` : "";
571
- console.log(`│ ✖ ${label}: ${status}${detail}`);
572
- }
573
- console.log(`│`);
574
- }
575
- for (const reason of result.reasons) console.log(`│ ${reason}`);
576
- console.log(`│ Continuing anyway — health checks are advisory in non-interactive runs.`);
577
- return Promise.resolve();
578
- }
579
- setReadinessWarnings(result) {
580
- console.log(`▲ Service health warnings detected.`);
581
- for (const reason of result.reasons) console.log(`│ ${reason}`);
582
- }
583
- showPortConflict(_processInfo) {
584
- return Promise.resolve();
585
- }
586
- waitForManualAuthCode() {
587
- return new Promise(() => {});
588
- }
589
- showTaskNotice(_notice) {
590
- return Promise.resolve(false);
591
- }
592
- cancelTaskNotice() {}
593
- showSettingsOverride(_conflicts, _backupAndFix) {
594
- return Promise.resolve();
595
- }
596
- requestQuestion(_question) {
597
- return Promise.reject(/* @__PURE__ */ new Error("wizard_ask is not available in CI / non-interactive mode. Re-run the wizard without --ci to answer interactively."));
598
- }
599
- cancelPendingQuestion() {}
600
- showAuthError(detail) {
601
- console.log(`✖ Authentication failed (401)`);
602
- if (detail?.hasSettingsConflict) {
603
- console.log(`│ Claude Code auth is conflicting with the wizard. Please try again after logging out:`);
604
- console.log(`│ claude auth logout`);
605
- } else {
606
- console.log(`│ The PostHog LLM Gateway rejected the API key. Common causes:`);
607
- console.log(`│ - Wrong key type: pass a personal API key (phx_xxx). pha_ is an OAuth access token, phc_ is a project key.`);
608
- console.log(`│ - Missing scope: the personal API key needs the "llm_gateway:read" scope.`);
609
- console.log(`│ - Expired or revoked key.`);
610
- console.log(`│ - Region mismatch: --region must match the region the key was issued in (us vs eu).`);
611
- }
612
- if (detail?.logFilePath) console.log(`│ Verbose log: ${detail.logFilePath}`);
613
- }
614
- showSessionTimeout() {
615
- const minutes = Math.round(OAUTH_TIMEOUT_MS / 6e4);
616
- console.log(`✖ Login timed out. The OAuth link timed out after ${minutes} minutes.`);
617
- console.log(`│ Re-run the wizard to get a fresh link and try again.`);
618
- }
619
- startRun() {}
620
- setCredentials(_credentials) {}
621
- setAccessToken(_credentials) {}
622
- setRoleAtOrganization(_role) {}
623
- setApiUser(_user) {}
624
- lastTodoLine = "";
625
- syncTodos(todos) {
626
- const completed = todos.filter((t) => t.status === "completed").length;
627
- const active = todos.filter((t) => t.status === "in_progress");
628
- if (active.length === 0) return;
629
- const labels = active.map((t) => t.activeForm || t.content).join(" · ");
630
- const line = `◌ [${completed}/${todos.length}] ${labels}`;
631
- if (line === this.lastTodoLine) return;
632
- this.lastTodoLine = line;
633
- console.log(line);
634
- }
635
- setEventPlan(_events) {}
636
- setDashboardUrl(_url) {}
637
- setStage(_stage) {}
638
- setNotebookUrl(_url) {}
639
- setHandoffText(_text) {}
640
- addTokenUsage(_delta) {}
641
- setFinalTokenCostUsd(_costUsd) {}
642
- setOutroData(_data) {}
643
- setFrameworkContext(_key, _value) {}
644
- getFrameworkContext(_key) {}
645
- waitForGate(_stepId) {
646
- return Promise.resolve();
647
- }
648
- };
649
- //#endregion
650
- //#region src/ui/index.ts
651
- let currentUI = new LoggingUI();
652
- function getUI() {
653
- return currentUI;
654
- }
655
- function setUI(ui) {
656
- currentUI = ui;
657
- }
658
- //#endregion
659
- //#region src/utils/paths.ts
660
- const TMP = process.platform === "win32" ? tmpdir() : "/tmp";
661
- const WIZARD_LOG_FILE = join$1(TMP, "posthog-wizard.log");
662
- const WIZARD_BENCHMARK_FILE = join$1(TMP, "posthog-wizard-benchmark.json");
663
- /** Default target of `--task-stream-log`. Dev builds only. */
664
- const WIZARD_TASK_STREAM_FILE = join$1(TMP, "posthog-wizard-task-stream.jsonl");
665
- const WIZARD_YARA_REPORT_FILE = join$1(TMP, "posthog-wizard-yara-report.json");
666
- /**
667
- * Strip an absolute installDir prefix off a project file path so the UI
668
- * renders `index.js:12` instead of `/Users/.../index.js:12`. Defends
669
- * against false matches like `/Users/foo` ⊂ `/Users/foobar/x.js` by
670
- * normalizing to a trailing path separator before the prefix check.
671
- */
672
- function relativeToInstallDir(file, installDir) {
673
- const prefix = installDir.endsWith(sep$1) ? installDir : installDir + sep$1;
674
- return file.startsWith(prefix) ? file.slice(prefix.length) : file;
675
- }
676
- //#endregion
677
- //#region src/utils/debug.ts
678
- let logFilePath = WIZARD_LOG_FILE;
679
- let fileLoggingEnabled = true;
680
- let consoleLoggingEnabled = false;
681
- function stringify(value) {
682
- if (typeof value === "string") return value;
683
- if (value instanceof Error) return value.stack ?? String(value);
684
- try {
685
- return JSON.stringify(value, null, 2) ?? inspect(value, { depth: 3 });
686
- } catch {
687
- return inspect(value, { depth: 3 });
688
- }
689
- }
690
- function renderLine(args) {
691
- return args.map(stringify).join(" ");
692
- }
693
- function getLogFilePath() {
694
- return logFilePath;
695
- }
696
- function configureLogFile(opts) {
697
- if (opts.path !== void 0) {
698
- logFilePath = opts.path;
699
- ensuredLogDir = false;
700
- }
701
- if (opts.enabled !== void 0) fileLoggingEnabled = opts.enabled;
702
- }
703
- let ensuredLogDir = false;
704
- let reportedLogFailure = false;
705
- function reportLogFailureOnce(err) {
706
- if (reportedLogFailure) return;
707
- reportedLogFailure = true;
708
- import("./analytics-CJA1uLlk.js").then(({ analytics }) => analytics.captureException(err instanceof Error ? err : new Error(String(err)), {
709
- source: "log-file-write",
710
- log_path: logFilePath,
711
- platform: process.platform
712
- })).catch(() => {});
713
- }
714
- function appendLine(text) {
715
- try {
716
- appendFileSync(logFilePath, text);
717
- } catch (err) {
718
- if (ensuredLogDir) {
719
- reportLogFailureOnce(err);
720
- return;
721
- }
722
- ensuredLogDir = true;
723
- try {
724
- mkdirSync(path.dirname(logFilePath), { recursive: true });
725
- appendFileSync(logFilePath, text);
726
- } catch (retryErr) {
727
- reportLogFailureOnce(retryErr);
728
- }
729
- }
730
- }
731
- function configureLogFileFromEnvironment() {
732
- const dir = runtimeEnv("POSTHOG_WIZARD_LOG_DIR");
733
- if (dir) configureLogFile({ path: path.join(dir, "posthog-wizard.log") });
734
- }
735
- function initLogFile() {
736
- if (!fileLoggingEnabled) return;
737
- const divider = "=".repeat(60);
738
- appendLine(`\n${divider}\nPostHog Wizard Run: ${(/* @__PURE__ */ new Date()).toISOString()}\n${divider}\n`);
739
- }
740
- function logToFile(...args) {
741
- if (!fileLoggingEnabled) return;
742
- appendLine(`[${(/* @__PURE__ */ new Date()).toISOString()}] ${renderLine(args)}\n`);
743
- }
744
- function debug(...args) {
745
- if (!consoleLoggingEnabled) return;
746
- getUI().log.info(renderLine(args));
747
- }
748
- function enableDebugLogs() {
749
- consoleLoggingEnabled = true;
750
- }
751
- //#endregion
752
- export { POSTHOG_TERMS_URL as $, CONTEXT_MILL_URL as A, Harness as B, AGENTIC_DETECTION_FIRST_ATTEMPT_TIMEOUT_MS as C, runtimeEnv as Ct, ANALYTICS_TEAM_TAG as D, ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY as E, regionOption as Et, GPT5_6_LUNA_MODEL as F, POSTHOG_APP_URL as G, Integration as H, GPT5_6_SOL_MODEL as I, POSTHOG_EU_CLIENT_ID as J, POSTHOG_DEV_CLIENT_ID as K, GPT5_6_TERRA_MODEL as L, DETECTION_TIMEOUT_MS as M, DUMMY_PROJECT_API_KEY as N, AWS_SKILLS_BASE_URL as O, GITHUB_SKILLS_BASE_URL as P, POSTHOG_STATUS_PAGE_URL as Q, HAIKU_MODEL as R, isTaskStatus as S, TASK_RUN_ID as St, ANALYTICS_HOST_URL as T, isHeadless as Tt, OAUTH_PORTS as U, ISSUES_URL as V, OAUTH_TIMEOUT_MS as W, POSTHOG_PRIVACY_URL as X, POSTHOG_ORG_AI_SETTINGS_URL as Y, POSTHOG_PROXY_CLIENT_ID as Z, SIGNUP_WIZARD_READINESS_CONFIG as _, wizardUserAgentForProgram as _t, getLogFilePath as a, WIZARD_DEFAULT_AIO_LOGS_FLAG_KEY as at, checkLlmGatewayHealth as b, RUN_SURFACE as bt, WIZARD_BENCHMARK_FILE as c, WIZARD_OAUTH_SCOPES as ct, WIZARD_YARA_REPORT_FILE as d, WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY as dt, POSTHOG_US_CLIENT_ID as et, relativeToInstallDir as f, WIZARD_PROVISIONING_SCOPES as ft, SERVICE_LABELS as g, getSkillsBaseUrl as gt, LoggingUI as h, WIZARD_USER_AGENT as ht, enableDebugLogs as i, WIZARD_CONTACT_EMAIL as it, DEFAULT_AGENT_MODEL as j, CONTEXT_MILL_RELEASES_URL as k, WIZARD_LOG_FILE as l, WIZARD_ORCHESTRATOR_FLAG_KEY as lt, setUI as m, WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY as mt, configureLogFileFromEnvironment as n, Sequence as nt, initLogFile as o, WIZARD_FLAG_KEYS as ot, getUI as p, WIZARD_REMARK_EVENT_NAME as pt, POSTHOG_DOCS_URL as q, debug as r, WIZARD_BASIC_INTEGRATION_AGENTIC_DETECTION_FLAG_KEY as rt, logToFile as s, WIZARD_INTERACTION_EVENT_NAME as st, configureLogFile as t, SONNET_5_MODEL as tt, WIZARD_TASK_STREAM_FILE as u, WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY as ut, evaluateWizardReadiness as v, VERSION as vt, AGENTIC_DETECTION_RETRY_TIMEOUT_MS as w, headlessOption as wt, TaskStatus as x, TASK_ID as xt, getBlockingServiceKeys as y, NODE_ENV as yt, HAIKU_TRIAGE_MODEL as z };
753
-
754
- //# sourceMappingURL=debug-B4kzIZPi.js.map