@posthog/wizard 2.76.1 → 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.
- package/README.md +30 -15
- package/dist/README.md +16 -15
- package/dist/{add-mcp-server-to-clients-4yHaRvOo.js → add-mcp-server-to-clients-JMv8LP-O.js} +429 -114
- package/dist/add-mcp-server-to-clients-JMv8LP-O.js.map +1 -0
- package/dist/agent-bCZ3i3fh.js +3085 -0
- package/dist/agent-bCZ3i3fh.js.map +1 -0
- package/dist/{agent-interface-DPaPdIjS.js → agent-interface-BAOIHuXS.js} +452 -377
- package/dist/agent-interface-BAOIHuXS.js.map +1 -0
- package/dist/{agent-prompt-loader-BlhabNM2.js → agent-prompt-loader-7Pd4CfZO.js} +24 -8
- package/dist/agent-prompt-loader-7Pd4CfZO.js.map +1 -0
- package/dist/analytics-BcV-WCM4.js +2 -0
- package/dist/{analytics-DSVyjIVF.js → analytics-CHCZ_qUR.js} +10 -6
- package/dist/analytics-CHCZ_qUR.js.map +1 -0
- package/dist/{api-Ci0dZWLR.js → api-Diy_2fp8.js} +4 -17
- package/dist/api-Diy_2fp8.js.map +1 -0
- package/dist/bin.js +410 -68
- package/dist/bin.js.map +1 -1
- package/dist/{bounded-fs-FbZJ_vJ_.js → bounded-fs-Bx9zTe6m.js} +4 -4
- package/dist/bounded-fs-Bx9zTe6m.js.map +1 -0
- package/dist/check-screens.tsx +1 -1
- package/dist/{ci-install-CEVCqahf.js → ci-install-CDdQYsPe.js} +6 -5
- package/dist/ci-install-CDdQYsPe.js.map +1 -0
- package/dist/constants-jFI2SaE1.js +260 -0
- package/dist/constants-jFI2SaE1.js.map +1 -0
- package/dist/debug-Ch4BDOtD.js +171 -0
- package/dist/debug-Ch4BDOtD.js.map +1 -0
- package/dist/{debug-C6KWXbQi.js → debug-M2gV2iDq.js} +1 -1
- package/dist/{defaults-DulzMJpN.js → defaults-C6J7yL4O.js} +26 -3
- package/dist/defaults-C6J7yL4O.js.map +1 -0
- package/dist/endpoints-DCVbM06L.js +108 -0
- package/dist/endpoints-DCVbM06L.js.map +1 -0
- package/dist/{env-api-key-DwmkB3fm.js → env-api-key-Qx8NnYHm.js} +3 -3
- package/dist/env-api-key-Qx8NnYHm.js.map +1 -0
- package/dist/{environment-1wA7uwAS.js → environment-B07Bmxae.js} +6 -6
- package/dist/environment-B07Bmxae.js.map +1 -0
- package/dist/{errors--OqLxmWR.js → errors-CQ9kttJD.js} +30 -35
- package/dist/errors-CQ9kttJD.js.map +1 -0
- package/dist/{file-C3HGL1IM.js → file-BcLTjU16.js} +2 -2
- package/dist/{file-C3HGL1IM.js.map → file-BcLTjU16.js.map} +1 -1
- package/dist/{file-watcher-D8s0b-VT.js → file-watcher-DWc_bTs6.js} +2 -2
- package/dist/{file-watcher-D8s0b-VT.js.map → file-watcher-DWc_bTs6.js.map} +1 -1
- package/dist/{gateway-session-OqzCMpZ9.js → gateway-CjoShdLa.js} +175 -20
- package/dist/gateway-CjoShdLa.js.map +1 -0
- package/dist/generate-version.cjs +1 -1
- package/dist/{headless-ui-DRGWDg9Z.js → headless-ui-BFFmYC4v.js} +13 -2
- package/dist/headless-ui-BFFmYC4v.js.map +1 -0
- package/dist/{interactive-B6OlvhSf.js → interactive-D6zV7brJ.js} +2 -2
- package/dist/{interactive-B6OlvhSf.js.map → interactive-D6zV7brJ.js.map} +1 -1
- package/dist/{local-dev-DPZiIPCK.js → local-dev-McsurOC-.js} +2 -2
- package/dist/local-dev-McsurOC-.js.map +1 -0
- package/dist/logging-ui-_TwoMNbG.js +226 -0
- package/dist/logging-ui-_TwoMNbG.js.map +1 -0
- package/dist/mcp-DAgaoGk5.js +97 -0
- package/dist/mcp-DAgaoGk5.js.map +1 -0
- package/dist/{mcp-prompt-streaming-E1d8DJcX.js → mcp-prompt-streaming-I2U_X7BC.js} +7 -6
- package/dist/mcp-prompt-streaming-I2U_X7BC.js.map +1 -0
- package/dist/{mint-failure-C82j0RMC.js → mint-failure-D4nd2XmZ.js} +134 -48
- package/dist/mint-failure-D4nd2XmZ.js.map +1 -0
- package/dist/models-DDdBJKwT.js +83 -0
- package/dist/models-DDdBJKwT.js.map +1 -0
- package/dist/{non-interactive-DGT2H_n4.js → non-interactive-Dzow7YKY.js} +3 -3
- package/dist/non-interactive-Dzow7YKY.js.map +1 -0
- package/dist/oauth-session-DJ8h6GFa.js +74 -0
- package/dist/oauth-session-DJ8h6GFa.js.map +1 -0
- package/dist/{orchestrator-tools-BBBNV1z5.js → orchestrator-tools-szcdscwn.js} +5 -5
- package/dist/orchestrator-tools-szcdscwn.js.map +1 -0
- package/dist/{package-json-xt3eeyBI.js → package-json-DY70kkNp.js} +2 -2
- package/dist/package-json-DY70kkNp.js.map +1 -0
- package/dist/{pi-fG5fT50Y.js → pi-D3h5Ok0i.js} +329 -65
- package/dist/pi-D3h5Ok0i.js.map +1 -0
- package/dist/{playground-UFSHP-Yn.js → playground-5AB4WgNF.js} +18 -10
- package/dist/playground-5AB4WgNF.js.map +1 -0
- package/dist/{posthog-O9kKcnda.js → posthog-DNn574nW.js} +8 -3
- package/dist/posthog-DNn574nW.js.map +1 -0
- package/dist/{provisioning-B-tzjG4r.js → provisioning-B8uSqRZk.js} +6 -5
- package/dist/provisioning-B8uSqRZk.js.map +1 -0
- package/dist/{queue-tools-7Oso-fpt.js → queue-tools-9OOVx5TE.js} +11 -86
- package/dist/queue-tools-9OOVx5TE.js.map +1 -0
- package/dist/{registry-D1L5e-WQ.js → registry-8YG-kuXk.js} +265 -6
- package/dist/registry-8YG-kuXk.js.map +1 -0
- package/dist/run-agent-legacy-d7rWlzQR.js +3739 -0
- package/dist/run-agent-legacy-d7rWlzQR.js.map +1 -0
- package/dist/{security-n3-xdINN.js → security-Cg_4a7vB.js} +6 -6
- package/dist/security-Cg_4a7vB.js.map +1 -0
- package/dist/{setup-utils-Bj0gejEf.js → setup-utils-CmTCTPkX.js} +46 -18
- package/dist/setup-utils-CmTCTPkX.js.map +1 -0
- package/dist/smoke-test.sh +1 -1
- package/dist/{start-tui-BowrTPXm.js → start-tui-CB2PZs1x.js} +42 -48
- package/dist/start-tui-CB2PZs1x.js.map +1 -0
- package/dist/{steps-CpNTGu9N.js → steps-BZcXRJNY.js} +7 -7
- package/dist/{steps-CpNTGu9N.js.map → steps-BZcXRJNY.js.map} +1 -1
- package/dist/{store-CVkJKlny.js → store-UN7c-ASf.js} +18 -55
- package/dist/store-UN7c-ASf.js.map +1 -0
- package/dist/{subagent-SxmvfDfp.js → subagent-BofIDK-O.js} +8 -3
- package/dist/subagent-BofIDK-O.js.map +1 -0
- package/dist/{task-nF7Ry8ff.js → task-r9t1UhQP.js} +124 -36
- package/dist/task-r9t1UhQP.js.map +1 -0
- package/dist/{task-stream-C9BLiAhz.js → task-stream-CMUilu54.js} +45 -15
- package/dist/task-stream-CMUilu54.js.map +1 -0
- package/dist/{tasks-BEEVIBcT.js → tasks-Bbv_lOBG.js} +17 -13
- package/dist/tasks-Bbv_lOBG.js.map +1 -0
- package/dist/{telemetry-PD7bhcda.js → telemetry-D6ruCtnv.js} +5 -5
- package/dist/telemetry-D6ruCtnv.js.map +1 -0
- package/dist/{terminal-NhNl-BIA.js → terminal-DrGyci_a.js} +63 -94
- package/dist/terminal-DrGyci_a.js.map +1 -0
- package/dist/{tools-BBdpgcIf.js → tools-Dyfh9aCD.js} +11 -11
- package/dist/tools-Dyfh9aCD.js.map +1 -0
- package/dist/ui-BBVuTM1v.js +15 -0
- package/dist/ui-BBVuTM1v.js.map +1 -0
- package/dist/version-aXxpgRKx.js +6 -0
- package/dist/version-aXxpgRKx.js.map +1 -0
- package/dist/warlock-smoke-test.ts +2 -2
- package/dist/{wizard-abort-hqHF-9xD.js → wizard-abort-BBkiUxfS.js} +23 -20
- package/dist/wizard-abort-BBkiUxfS.js.map +1 -0
- package/dist/wizard-abort-BU4aLyvh.js +3 -0
- package/dist/{wizard-session-FSJCkTcP.js → wizard-session-2w4Ru-Wz.js} +12 -16
- package/dist/wizard-session-2w4Ru-Wz.js.map +1 -0
- package/dist/wizard-session-DGaUHOF3.js +2 -0
- package/dist/wizard-ui-DoyOZxK8.js +16 -0
- package/dist/wizard-ui-DoyOZxK8.js.map +1 -0
- package/dist/{yara-hooks-BaPKsm-B.js → yara-hooks-DCeMDd1o.js} +19 -68
- package/dist/yara-hooks-DCeMDd1o.js.map +1 -0
- package/dist/yara-hooks-DSGuCU9A.js +2 -0
- package/package.json +8 -1
- package/dist/add-mcp-server-to-clients-4yHaRvOo.js.map +0 -1
- package/dist/agent-interface-DPaPdIjS.js.map +0 -1
- package/dist/agent-prompt-loader-BlhabNM2.js.map +0 -1
- package/dist/agent-runner-JFwQQj2k.js +0 -6100
- package/dist/agent-runner-JFwQQj2k.js.map +0 -1
- package/dist/analytics-CcHoyhE_.js +0 -2
- package/dist/analytics-DSVyjIVF.js.map +0 -1
- package/dist/api-Ci0dZWLR.js.map +0 -1
- package/dist/bounded-fs-FbZJ_vJ_.js.map +0 -1
- package/dist/ci-install-CEVCqahf.js.map +0 -1
- package/dist/debug-DWYDVp0B.js +0 -750
- package/dist/debug-DWYDVp0B.js.map +0 -1
- package/dist/defaults-DulzMJpN.js.map +0 -1
- package/dist/env-api-key-DwmkB3fm.js.map +0 -1
- package/dist/environment-1wA7uwAS.js.map +0 -1
- package/dist/errors--OqLxmWR.js.map +0 -1
- package/dist/gateway-session-OqzCMpZ9.js.map +0 -1
- package/dist/gateway-session-s1xr8b48.js +0 -2
- package/dist/headless-ui-DRGWDg9Z.js.map +0 -1
- package/dist/local-dev-DPZiIPCK.js.map +0 -1
- package/dist/mcp-BprhJJ2c.js +0 -64
- package/dist/mcp-BprhJJ2c.js.map +0 -1
- package/dist/mcp-prompt-streaming-E1d8DJcX.js.map +0 -1
- package/dist/mint-failure-C82j0RMC.js.map +0 -1
- package/dist/non-interactive-DGT2H_n4.js.map +0 -1
- package/dist/orchestrator-tools-BBBNV1z5.js.map +0 -1
- package/dist/package-json-xt3eeyBI.js.map +0 -1
- package/dist/package-manager-DU3aVif4.js +0 -290
- package/dist/package-manager-DU3aVif4.js.map +0 -1
- package/dist/pi-fG5fT50Y.js.map +0 -1
- package/dist/playground-UFSHP-Yn.js.map +0 -1
- package/dist/posthog-O9kKcnda.js.map +0 -1
- package/dist/provisioning-B-tzjG4r.js.map +0 -1
- package/dist/queue-tools-7Oso-fpt.js.map +0 -1
- package/dist/registry-D1L5e-WQ.js.map +0 -1
- package/dist/security-n3-xdINN.js.map +0 -1
- package/dist/setup-utils-Bj0gejEf.js.map +0 -1
- package/dist/start-tui-BowrTPXm.js.map +0 -1
- package/dist/store-CVkJKlny.js.map +0 -1
- package/dist/subagent-SxmvfDfp.js.map +0 -1
- package/dist/task-nF7Ry8ff.js.map +0 -1
- package/dist/task-stream-C9BLiAhz.js.map +0 -1
- package/dist/tasks-BEEVIBcT.js.map +0 -1
- package/dist/telemetry-PD7bhcda.js.map +0 -1
- package/dist/terminal-NhNl-BIA.js.map +0 -1
- package/dist/tools-BBdpgcIf.js.map +0 -1
- package/dist/wizard-abort-D3YA1hXX.js +0 -2
- package/dist/wizard-abort-hqHF-9xD.js.map +0 -1
- package/dist/wizard-session-CYvyYnti.js +0 -2
- package/dist/wizard-session-FSJCkTcP.js.map +0 -1
- package/dist/yara-hooks-BaPKsm-B.js.map +0 -1
- package/dist/yara-hooks-CwfQuEl3.js +0 -2
package/dist/debug-DWYDVp0B.js
DELETED
|
@@ -1,750 +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.76.1";
|
|
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
|
-
const WIZARD_FLAG_KEYS = [
|
|
280
|
-
WIZARD_ORCHESTRATOR_FLAG_KEY,
|
|
281
|
-
WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY,
|
|
282
|
-
WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY,
|
|
283
|
-
WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY,
|
|
284
|
-
WIZARD_BASIC_INTEGRATION_AGENTIC_DETECTION_FLAG_KEY
|
|
285
|
-
];
|
|
286
|
-
/** User-Agent for wizard HTTP requests and MCP server identification. */
|
|
287
|
-
const WIZARD_USER_AGENT = `posthog/wizard; version: ${VERSION}`;
|
|
288
|
-
/**
|
|
289
|
-
* User-Agent for a specific program's MCP calls, tagged with `program: <id>` so the
|
|
290
|
-
* backend can attribute work per program (e.g. the `self-driving` program's warehouse
|
|
291
|
-
* sources are recorded as `created_via=self_driving` rather than plain `wizard`). The
|
|
292
|
-
* base `posthog/wizard` token is preserved, so anything keying only on that still matches.
|
|
293
|
-
*/
|
|
294
|
-
function wizardUserAgentForProgram(programId) {
|
|
295
|
-
return programId ? `${WIZARD_USER_AGENT}; program: ${programId}` : WIZARD_USER_AGENT;
|
|
296
|
-
}
|
|
297
|
-
/** Timeout for framework / project detection probes (ms). */
|
|
298
|
-
const DETECTION_TIMEOUT_MS = 1e4;
|
|
299
|
-
/** Timeout for the agentic project scan (ms); past it the run falls back to root detection. */
|
|
300
|
-
const AGENTIC_DETECTION_TIMEOUT_MS = 6e4;
|
|
301
|
-
/**
|
|
302
|
-
* Timeout for the OAuth authorization flow (ms).
|
|
303
|
-
*
|
|
304
|
-
* How long the user has to complete the browser login. The authorization
|
|
305
|
-
* code is minted at approval and exchanged immediately on callback, so the
|
|
306
|
-
* server-side code expiry (`AUTHORIZATION_CODE_EXPIRE_SECONDS`, 5 minutes)
|
|
307
|
-
* bounds only the approval→exchange gap — manual-paste users have 5 minutes
|
|
308
|
-
* from approval to submit the code — not how long this window may stay open.
|
|
309
|
-
*/
|
|
310
|
-
const OAUTH_TIMEOUT_MS = 18e5;
|
|
311
|
-
//#endregion
|
|
312
|
-
//#region src/ui/wizard-ui.ts
|
|
313
|
-
let TaskStatus = /* @__PURE__ */ function(TaskStatus) {
|
|
314
|
-
TaskStatus["Pending"] = "pending";
|
|
315
|
-
TaskStatus["InProgress"] = "in_progress";
|
|
316
|
-
TaskStatus["Completed"] = "completed";
|
|
317
|
-
TaskStatus["Skipped"] = "skipped";
|
|
318
|
-
return TaskStatus;
|
|
319
|
-
}({});
|
|
320
|
-
function isTaskStatus(value) {
|
|
321
|
-
return Object.values(TaskStatus).includes(value);
|
|
322
|
-
}
|
|
323
|
-
//#endregion
|
|
324
|
-
//#region src/lib/health-checks/endpoints.ts
|
|
325
|
-
function noConnectionResult(error, attempts) {
|
|
326
|
-
return {
|
|
327
|
-
status: "no-connection",
|
|
328
|
-
error,
|
|
329
|
-
rawIndicator: attempts > 1 ? `attempts=${attempts}` : void 0
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
function downResult(error) {
|
|
333
|
-
return {
|
|
334
|
-
status: "down",
|
|
335
|
-
error
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
const RETRY_BACKOFFS_MS = [500, 2e3];
|
|
339
|
-
async function attemptFetch(url, timeoutMs, redirect) {
|
|
340
|
-
const controller = new AbortController();
|
|
341
|
-
const tid = setTimeout(() => controller.abort(), timeoutMs);
|
|
342
|
-
try {
|
|
343
|
-
const res = await fetch(url, {
|
|
344
|
-
signal: controller.signal,
|
|
345
|
-
redirect
|
|
346
|
-
});
|
|
347
|
-
clearTimeout(tid);
|
|
348
|
-
return {
|
|
349
|
-
kind: "response",
|
|
350
|
-
res
|
|
351
|
-
};
|
|
352
|
-
} catch (e) {
|
|
353
|
-
clearTimeout(tid);
|
|
354
|
-
const err = e instanceof Error ? e : /* @__PURE__ */ new Error("Unknown error");
|
|
355
|
-
return {
|
|
356
|
-
kind: "error",
|
|
357
|
-
error: err,
|
|
358
|
-
timedOut: err.name === "AbortError"
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
async function fetchEndpointHealth(url, timeoutMs = 5e3, isExpectedStatus = (s) => s === 200, redirect = "follow") {
|
|
363
|
-
let lastHttpStatus = null;
|
|
364
|
-
let lastError = "Unknown error";
|
|
365
|
-
let attempts = 0;
|
|
366
|
-
for (let i = 0; i <= RETRY_BACKOFFS_MS.length; i++) {
|
|
367
|
-
if (i > 0) {
|
|
368
|
-
const wait = RETRY_BACKOFFS_MS[i - 1];
|
|
369
|
-
logToFile(`[health-checks] retry ${i}/${RETRY_BACKOFFS_MS.length} for ${url} in ${wait}ms (last: ${lastError})`);
|
|
370
|
-
await new Promise((r) => setTimeout(r, wait));
|
|
371
|
-
}
|
|
372
|
-
attempts++;
|
|
373
|
-
const outcome = await attemptFetch(url, timeoutMs, redirect);
|
|
374
|
-
if (outcome.kind === "response") {
|
|
375
|
-
const res = outcome.res;
|
|
376
|
-
if (isExpectedStatus(res.status)) {
|
|
377
|
-
const result = {
|
|
378
|
-
status: "healthy",
|
|
379
|
-
rawIndicator: attempts > 1 ? `HTTP ${res.status} (attempts=${attempts})` : `HTTP ${res.status}`
|
|
380
|
-
};
|
|
381
|
-
logToFile(`[health-checks] GET ${url} -> ${result.status} (${result.rawIndicator})`);
|
|
382
|
-
return result;
|
|
383
|
-
}
|
|
384
|
-
lastHttpStatus = res.status;
|
|
385
|
-
lastError = `HTTP ${res.status}`;
|
|
386
|
-
continue;
|
|
387
|
-
}
|
|
388
|
-
lastError = outcome.timedOut ? `Request timed out after ${timeoutMs}ms` : outcome.error.message;
|
|
389
|
-
}
|
|
390
|
-
const result = lastHttpStatus !== null ? downResult(`HTTP ${lastHttpStatus} (attempts=${attempts})`) : noConnectionResult(lastError, attempts);
|
|
391
|
-
logToFile(`[health-checks] GET ${url} -> ${result.status} (attempts=${attempts}, ${result.error})`);
|
|
392
|
-
return result;
|
|
393
|
-
}
|
|
394
|
-
const checkLlmGatewayHealth = (gatewayUrl) => fetchEndpointHealth(new URL("/readyz", gatewayUrl).href);
|
|
395
|
-
/**
|
|
396
|
-
* Skills are published to two origins under the same filenames and
|
|
397
|
-
* `fetchWithRetry` fails over between them, so the run is only blocked when
|
|
398
|
-
* neither answers. Probed in parallel — sequential probes would double the
|
|
399
|
-
* worst case past `READINESS_TIMEOUT_MS`.
|
|
400
|
-
*/
|
|
401
|
-
const checkSkillsOriginHealth = async () => {
|
|
402
|
-
const [github, aws] = await Promise.all([fetchEndpointHealth(`${GITHUB_SKILLS_BASE_URL}/skill-menu.json`), fetchEndpointHealth(`${AWS_SKILLS_BASE_URL}/skill-menu.json`)]);
|
|
403
|
-
return combineOriginHealth(github, aws);
|
|
404
|
-
};
|
|
405
|
-
/**
|
|
406
|
-
* Mirrors `fetchWithRetry`: a download tries GitHub, then AWS, so the run is
|
|
407
|
-
* only blocked when neither origin answers. Whichever failure the probes saw,
|
|
408
|
-
* one origin serving means skills are reachable.
|
|
409
|
-
*/
|
|
410
|
-
function combineOriginHealth(github, aws) {
|
|
411
|
-
if (github.status === "healthy") return aws.status === "healthy" ? github : withIndicatorSuffix(github, "aws unavailable");
|
|
412
|
-
if (aws.status === "healthy") return withIndicatorSuffix(aws, "via aws, github unavailable");
|
|
413
|
-
const error = `github: ${github.error ?? "unknown"} | aws: ${aws.error ?? "unknown"}`;
|
|
414
|
-
return {
|
|
415
|
-
status: github.status === "down" || aws.status === "down" ? "down" : "no-connection",
|
|
416
|
-
error,
|
|
417
|
-
rawIndicator: github.rawIndicator ?? aws.rawIndicator
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
function withIndicatorSuffix(result, suffix) {
|
|
421
|
-
return {
|
|
422
|
-
...result,
|
|
423
|
-
rawIndicator: result.rawIndicator ? `${result.rawIndicator} (${suffix})` : suffix
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
//#endregion
|
|
427
|
-
//#region src/lib/health-checks/readiness.ts
|
|
428
|
-
const SERVICE_LABELS = { skillsOrigin: "Skills download" };
|
|
429
|
-
const DEFAULT_WIZARD_READINESS_CONFIG = { downBlocksRun: ["skillsOrigin"] };
|
|
430
|
-
const SIGNUP_WIZARD_READINESS_CONFIG = DEFAULT_WIZARD_READINESS_CONFIG;
|
|
431
|
-
async function checkAllExternalServices() {
|
|
432
|
-
return { skillsOrigin: await checkSkillsOriginHealth() };
|
|
433
|
-
}
|
|
434
|
-
function describeResult(label, h) {
|
|
435
|
-
const parts = [`${label}: ${h.status}`];
|
|
436
|
-
if (h.rawIndicator) parts.push(`indicator=${h.rawIndicator}`);
|
|
437
|
-
if (h.error) parts.push(h.error);
|
|
438
|
-
return parts.join(" — ");
|
|
439
|
-
}
|
|
440
|
-
const READINESS_TIMEOUT_MS = 2e4;
|
|
441
|
-
async function evaluateWizardReadiness(config = DEFAULT_WIZARD_READINESS_CONFIG) {
|
|
442
|
-
try {
|
|
443
|
-
const health = await Promise.race([checkAllExternalServices(), new Promise((resolve) => setTimeout(() => resolve(allUnknown("Health check timed out")), READINESS_TIMEOUT_MS))]);
|
|
444
|
-
const blockingKeys = getBlockingServiceKeys(health, config);
|
|
445
|
-
const reasons = blockingKeys.map((key) => describeResult(SERVICE_LABELS[key], health[key]));
|
|
446
|
-
if (blockingKeys.length > 0) {
|
|
447
|
-
logToFile(`[health-checks] blocked by: ${blockingKeys.map((key) => {
|
|
448
|
-
const h = health[key];
|
|
449
|
-
return `${key} (${h.status}${h.error ? ` — ${h.error}` : ""})`;
|
|
450
|
-
}).join(", ")}`);
|
|
451
|
-
return {
|
|
452
|
-
decision: "no",
|
|
453
|
-
health,
|
|
454
|
-
reasons
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
return {
|
|
458
|
-
decision: "yes",
|
|
459
|
-
health,
|
|
460
|
-
reasons
|
|
461
|
-
};
|
|
462
|
-
} catch (err) {
|
|
463
|
-
logToFile(`[health-checks] error: ${err instanceof Error ? err.message : err}`);
|
|
464
|
-
return {
|
|
465
|
-
decision: "yes",
|
|
466
|
-
health: allUnknown("Unexpected error"),
|
|
467
|
-
reasons: []
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
function getBlockingServiceKeys(health, config = DEFAULT_WIZARD_READINESS_CONFIG) {
|
|
472
|
-
return Object.keys(health).filter((key) => {
|
|
473
|
-
const result = health[key];
|
|
474
|
-
if (config.downBlocksRun.includes(key) && (result.status === "down" || result.status === "no-connection")) return true;
|
|
475
|
-
if ((config.degradedBlocksRun ?? []).includes(key) && result.status !== "healthy") return true;
|
|
476
|
-
return false;
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
/** Build an AllServicesHealth where every service is Degraded with the given error. */
|
|
480
|
-
function allUnknown(error) {
|
|
481
|
-
return { skillsOrigin: {
|
|
482
|
-
status: "degraded",
|
|
483
|
-
error
|
|
484
|
-
} };
|
|
485
|
-
}
|
|
486
|
-
//#endregion
|
|
487
|
-
//#region src/ui/logging-ui.ts
|
|
488
|
-
var LoggingUI = class {
|
|
489
|
-
intro(message) {
|
|
490
|
-
console.log(`┌ ${message}`);
|
|
491
|
-
}
|
|
492
|
-
outro(message) {
|
|
493
|
-
console.log(`└ ${message}`);
|
|
494
|
-
}
|
|
495
|
-
outroError(data) {
|
|
496
|
-
console.log(`✖ ${data.message ?? "Wizard aborted"}`);
|
|
497
|
-
if (data.body) console.log(`│ ${data.body}`);
|
|
498
|
-
if (data.docsUrl) console.log(`│ Docs: ${data.docsUrl}`);
|
|
499
|
-
}
|
|
500
|
-
waitForOutroDismissed() {
|
|
501
|
-
return Promise.resolve();
|
|
502
|
-
}
|
|
503
|
-
waitForAiOptIn() {
|
|
504
|
-
return Promise.resolve();
|
|
505
|
-
}
|
|
506
|
-
cancel(message) {
|
|
507
|
-
console.log(`■ ${message}`);
|
|
508
|
-
}
|
|
509
|
-
log = {
|
|
510
|
-
info(message) {
|
|
511
|
-
console.log(`│ ${message}`);
|
|
512
|
-
},
|
|
513
|
-
warn(message) {
|
|
514
|
-
console.log(`▲ ${message}`);
|
|
515
|
-
},
|
|
516
|
-
error(message) {
|
|
517
|
-
console.log(`✖ ${message}`);
|
|
518
|
-
},
|
|
519
|
-
success(message) {
|
|
520
|
-
console.log(`✔ ${message}`);
|
|
521
|
-
},
|
|
522
|
-
step(message) {
|
|
523
|
-
console.log(`◇ ${message}`);
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
|
-
note(message) {
|
|
527
|
-
console.log(`│ ${message}`);
|
|
528
|
-
}
|
|
529
|
-
spinner() {
|
|
530
|
-
return {
|
|
531
|
-
start(message) {
|
|
532
|
-
if (message) console.log(`◌ ${message}`);
|
|
533
|
-
},
|
|
534
|
-
stop(message) {
|
|
535
|
-
if (message) console.log(`● ${message}`);
|
|
536
|
-
},
|
|
537
|
-
message(msg) {
|
|
538
|
-
if (msg) console.log(`◌ ${msg}`);
|
|
539
|
-
}
|
|
540
|
-
};
|
|
541
|
-
}
|
|
542
|
-
pushStatus(message) {
|
|
543
|
-
console.log(`◇ ${message}`);
|
|
544
|
-
}
|
|
545
|
-
setDetectedFramework(label) {
|
|
546
|
-
console.log(`✔ Framework: ${label}`);
|
|
547
|
-
}
|
|
548
|
-
onEnterScreen(_screen, _fn) {}
|
|
549
|
-
setLoginUrl(url) {
|
|
550
|
-
if (url) {
|
|
551
|
-
console.log(`│ If the browser didn't open automatically, use this link:`);
|
|
552
|
-
console.log(`│ ${url}`);
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
setAuthorizeUrl(_url) {}
|
|
556
|
-
showBlockingOutage(result) {
|
|
557
|
-
console.log(`▲ Service health issues detected.`);
|
|
558
|
-
const blockingKeys = getBlockingServiceKeys(result.health);
|
|
559
|
-
if (blockingKeys.length > 0) {
|
|
560
|
-
console.log(`│`);
|
|
561
|
-
console.log(`│ Blocking services:`);
|
|
562
|
-
for (const key of blockingKeys) {
|
|
563
|
-
const status = result.health[key].status;
|
|
564
|
-
const error = result.health[key].error;
|
|
565
|
-
const label = SERVICE_LABELS[key];
|
|
566
|
-
const detail = error ? ` — ${error}` : "";
|
|
567
|
-
console.log(`│ ✖ ${label}: ${status}${detail}`);
|
|
568
|
-
}
|
|
569
|
-
console.log(`│`);
|
|
570
|
-
}
|
|
571
|
-
for (const reason of result.reasons) console.log(`│ ${reason}`);
|
|
572
|
-
console.log(`│ Continuing anyway — health checks are advisory in non-interactive runs.`);
|
|
573
|
-
return Promise.resolve();
|
|
574
|
-
}
|
|
575
|
-
setReadinessWarnings(result) {
|
|
576
|
-
console.log(`▲ Service health warnings detected.`);
|
|
577
|
-
for (const reason of result.reasons) console.log(`│ ${reason}`);
|
|
578
|
-
}
|
|
579
|
-
showPortConflict(_processInfo) {
|
|
580
|
-
return Promise.resolve();
|
|
581
|
-
}
|
|
582
|
-
waitForManualAuthCode() {
|
|
583
|
-
return new Promise(() => {});
|
|
584
|
-
}
|
|
585
|
-
showTaskNotice(_notice) {
|
|
586
|
-
return Promise.resolve(false);
|
|
587
|
-
}
|
|
588
|
-
cancelTaskNotice() {}
|
|
589
|
-
showSettingsOverride(_conflicts, _backupAndFix) {
|
|
590
|
-
return Promise.resolve();
|
|
591
|
-
}
|
|
592
|
-
requestQuestion(_question) {
|
|
593
|
-
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."));
|
|
594
|
-
}
|
|
595
|
-
cancelPendingQuestion() {}
|
|
596
|
-
showAuthError(detail) {
|
|
597
|
-
console.log(`✖ Authentication failed (401)`);
|
|
598
|
-
if (detail?.hasSettingsConflict) {
|
|
599
|
-
console.log(`│ Claude Code auth is conflicting with the wizard. Please try again after logging out:`);
|
|
600
|
-
console.log(`│ claude auth logout`);
|
|
601
|
-
} else {
|
|
602
|
-
console.log(`│ The PostHog LLM Gateway rejected the API key. Common causes:`);
|
|
603
|
-
console.log(`│ - Wrong key type: pass a personal API key (phx_xxx). pha_ is an OAuth access token, phc_ is a project key.`);
|
|
604
|
-
console.log(`│ - Missing scope: the personal API key needs the "llm_gateway:read" scope.`);
|
|
605
|
-
console.log(`│ - Expired or revoked key.`);
|
|
606
|
-
console.log(`│ - Region mismatch: --region must match the region the key was issued in (us vs eu).`);
|
|
607
|
-
}
|
|
608
|
-
if (detail?.logFilePath) console.log(`│ Verbose log: ${detail.logFilePath}`);
|
|
609
|
-
}
|
|
610
|
-
showSessionTimeout() {
|
|
611
|
-
const minutes = Math.round(OAUTH_TIMEOUT_MS / 6e4);
|
|
612
|
-
console.log(`✖ Login timed out. The OAuth link timed out after ${minutes} minutes.`);
|
|
613
|
-
console.log(`│ Re-run the wizard to get a fresh link and try again.`);
|
|
614
|
-
}
|
|
615
|
-
startRun() {}
|
|
616
|
-
setCredentials(_credentials) {}
|
|
617
|
-
setAccessToken(_credentials) {}
|
|
618
|
-
setRoleAtOrganization(_role) {}
|
|
619
|
-
setApiUser(_user) {}
|
|
620
|
-
lastTodoLine = "";
|
|
621
|
-
syncTodos(todos) {
|
|
622
|
-
const completed = todos.filter((t) => t.status === "completed").length;
|
|
623
|
-
const active = todos.filter((t) => t.status === "in_progress");
|
|
624
|
-
if (active.length === 0) return;
|
|
625
|
-
const labels = active.map((t) => t.activeForm || t.content).join(" · ");
|
|
626
|
-
const line = `◌ [${completed}/${todos.length}] ${labels}`;
|
|
627
|
-
if (line === this.lastTodoLine) return;
|
|
628
|
-
this.lastTodoLine = line;
|
|
629
|
-
console.log(line);
|
|
630
|
-
}
|
|
631
|
-
setEventPlan(_events) {}
|
|
632
|
-
setDashboardUrl(_url) {}
|
|
633
|
-
setStage(_stage) {}
|
|
634
|
-
setNotebookUrl(_url) {}
|
|
635
|
-
setHandoffText(_text) {}
|
|
636
|
-
addTokenUsage(_delta) {}
|
|
637
|
-
setFinalTokenCostUsd(_costUsd) {}
|
|
638
|
-
setOutroData(_data) {}
|
|
639
|
-
setFrameworkContext(_key, _value) {}
|
|
640
|
-
getFrameworkContext(_key) {}
|
|
641
|
-
waitForGate(_stepId) {
|
|
642
|
-
return Promise.resolve();
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
//#endregion
|
|
646
|
-
//#region src/ui/index.ts
|
|
647
|
-
let currentUI = new LoggingUI();
|
|
648
|
-
function getUI() {
|
|
649
|
-
return currentUI;
|
|
650
|
-
}
|
|
651
|
-
function setUI(ui) {
|
|
652
|
-
currentUI = ui;
|
|
653
|
-
}
|
|
654
|
-
//#endregion
|
|
655
|
-
//#region src/utils/paths.ts
|
|
656
|
-
const TMP = process.platform === "win32" ? tmpdir() : "/tmp";
|
|
657
|
-
const WIZARD_LOG_FILE = join$1(TMP, "posthog-wizard.log");
|
|
658
|
-
const WIZARD_BENCHMARK_FILE = join$1(TMP, "posthog-wizard-benchmark.json");
|
|
659
|
-
/** Default target of `--task-stream-log`. Dev builds only. */
|
|
660
|
-
const WIZARD_TASK_STREAM_FILE = join$1(TMP, "posthog-wizard-task-stream.jsonl");
|
|
661
|
-
const WIZARD_YARA_REPORT_FILE = join$1(TMP, "posthog-wizard-yara-report.json");
|
|
662
|
-
/**
|
|
663
|
-
* Strip an absolute installDir prefix off a project file path so the UI
|
|
664
|
-
* renders `index.js:12` instead of `/Users/.../index.js:12`. Defends
|
|
665
|
-
* against false matches like `/Users/foo` ⊂ `/Users/foobar/x.js` by
|
|
666
|
-
* normalizing to a trailing path separator before the prefix check.
|
|
667
|
-
*/
|
|
668
|
-
function relativeToInstallDir(file, installDir) {
|
|
669
|
-
const prefix = installDir.endsWith(sep$1) ? installDir : installDir + sep$1;
|
|
670
|
-
return file.startsWith(prefix) ? file.slice(prefix.length) : file;
|
|
671
|
-
}
|
|
672
|
-
//#endregion
|
|
673
|
-
//#region src/utils/debug.ts
|
|
674
|
-
let logFilePath = WIZARD_LOG_FILE;
|
|
675
|
-
let fileLoggingEnabled = true;
|
|
676
|
-
let consoleLoggingEnabled = false;
|
|
677
|
-
function stringify(value) {
|
|
678
|
-
if (typeof value === "string") return value;
|
|
679
|
-
if (value instanceof Error) return value.stack ?? String(value);
|
|
680
|
-
try {
|
|
681
|
-
return JSON.stringify(value, null, 2) ?? inspect(value, { depth: 3 });
|
|
682
|
-
} catch {
|
|
683
|
-
return inspect(value, { depth: 3 });
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
function renderLine(args) {
|
|
687
|
-
return args.map(stringify).join(" ");
|
|
688
|
-
}
|
|
689
|
-
function getLogFilePath() {
|
|
690
|
-
return logFilePath;
|
|
691
|
-
}
|
|
692
|
-
function configureLogFile(opts) {
|
|
693
|
-
if (opts.path !== void 0) {
|
|
694
|
-
logFilePath = opts.path;
|
|
695
|
-
ensuredLogDir = false;
|
|
696
|
-
}
|
|
697
|
-
if (opts.enabled !== void 0) fileLoggingEnabled = opts.enabled;
|
|
698
|
-
}
|
|
699
|
-
let ensuredLogDir = false;
|
|
700
|
-
let reportedLogFailure = false;
|
|
701
|
-
function reportLogFailureOnce(err) {
|
|
702
|
-
if (reportedLogFailure) return;
|
|
703
|
-
reportedLogFailure = true;
|
|
704
|
-
import("./analytics-CcHoyhE_.js").then(({ analytics }) => analytics.captureException(err instanceof Error ? err : new Error(String(err)), {
|
|
705
|
-
source: "log-file-write",
|
|
706
|
-
log_path: logFilePath,
|
|
707
|
-
platform: process.platform
|
|
708
|
-
})).catch(() => {});
|
|
709
|
-
}
|
|
710
|
-
function appendLine(text) {
|
|
711
|
-
try {
|
|
712
|
-
appendFileSync(logFilePath, text);
|
|
713
|
-
} catch (err) {
|
|
714
|
-
if (ensuredLogDir) {
|
|
715
|
-
reportLogFailureOnce(err);
|
|
716
|
-
return;
|
|
717
|
-
}
|
|
718
|
-
ensuredLogDir = true;
|
|
719
|
-
try {
|
|
720
|
-
mkdirSync(path.dirname(logFilePath), { recursive: true });
|
|
721
|
-
appendFileSync(logFilePath, text);
|
|
722
|
-
} catch (retryErr) {
|
|
723
|
-
reportLogFailureOnce(retryErr);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
function configureLogFileFromEnvironment() {
|
|
728
|
-
const dir = runtimeEnv("POSTHOG_WIZARD_LOG_DIR");
|
|
729
|
-
if (dir) configureLogFile({ path: path.join(dir, "posthog-wizard.log") });
|
|
730
|
-
}
|
|
731
|
-
function initLogFile() {
|
|
732
|
-
if (!fileLoggingEnabled) return;
|
|
733
|
-
const divider = "=".repeat(60);
|
|
734
|
-
appendLine(`\n${divider}\nPostHog Wizard Run: ${(/* @__PURE__ */ new Date()).toISOString()}\n${divider}\n`);
|
|
735
|
-
}
|
|
736
|
-
function logToFile(...args) {
|
|
737
|
-
if (!fileLoggingEnabled) return;
|
|
738
|
-
appendLine(`[${(/* @__PURE__ */ new Date()).toISOString()}] ${renderLine(args)}\n`);
|
|
739
|
-
}
|
|
740
|
-
function debug(...args) {
|
|
741
|
-
if (!consoleLoggingEnabled) return;
|
|
742
|
-
getUI().log.info(renderLine(args));
|
|
743
|
-
}
|
|
744
|
-
function enableDebugLogs() {
|
|
745
|
-
consoleLoggingEnabled = true;
|
|
746
|
-
}
|
|
747
|
-
//#endregion
|
|
748
|
-
export { POSTHOG_US_CLIENT_ID as $, DEFAULT_AGENT_MODEL as A, ISSUES_URL as B, AGENTIC_DETECTION_TIMEOUT_MS as C, isHeadless as Ct, AWS_SKILLS_BASE_URL as D, ANALYTICS_TEAM_TAG as E, GPT5_6_SOL_MODEL as F, POSTHOG_DEV_CLIENT_ID as G, OAUTH_PORTS as H, GPT5_6_TERRA_MODEL as I, POSTHOG_ORG_AI_SETTINGS_URL as J, POSTHOG_DOCS_URL as K, HAIKU_MODEL as L, DUMMY_PROJECT_API_KEY as M, GITHUB_SKILLS_BASE_URL as N, CONTEXT_MILL_RELEASES_URL as O, GPT5_6_LUNA_MODEL as P, POSTHOG_TERMS_URL as Q, HAIKU_TRIAGE_MODEL as R, isTaskStatus as S, headlessOption as St, ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY as T, OAUTH_TIMEOUT_MS as U, Integration as V, POSTHOG_APP_URL as W, POSTHOG_PROXY_CLIENT_ID as X, POSTHOG_PRIVACY_URL as Y, POSTHOG_STATUS_PAGE_URL as Z, SIGNUP_WIZARD_READINESS_CONFIG as _, NODE_ENV as _t, getLogFilePath as a, WIZARD_INTERACTION_EVENT_NAME as at, checkLlmGatewayHealth as b, TASK_RUN_ID as bt, WIZARD_BENCHMARK_FILE as c, WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY as ct, WIZARD_YARA_REPORT_FILE as d, WIZARD_REMARK_EVENT_NAME as dt, SONNET_5_MODEL as et, relativeToInstallDir as f, WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY as ft, SERVICE_LABELS as g, VERSION as gt, LoggingUI as h, wizardUserAgentForProgram as ht, enableDebugLogs as i, WIZARD_FLAG_KEYS as it, DETECTION_TIMEOUT_MS as j, CONTEXT_MILL_URL as k, WIZARD_LOG_FILE as l, WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY as lt, setUI as m, getSkillsBaseUrl as mt, configureLogFileFromEnvironment as n, WIZARD_BASIC_INTEGRATION_AGENTIC_DETECTION_FLAG_KEY as nt, initLogFile as o, WIZARD_OAUTH_SCOPES as ot, getUI as p, WIZARD_USER_AGENT as pt, POSTHOG_EU_CLIENT_ID as q, debug as r, WIZARD_CONTACT_EMAIL as rt, logToFile as s, WIZARD_ORCHESTRATOR_FLAG_KEY as st, configureLogFile as t, Sequence as tt, WIZARD_TASK_STREAM_FILE as u, WIZARD_PROVISIONING_SCOPES as ut, evaluateWizardReadiness as v, RUN_SURFACE as vt, ANALYTICS_HOST_URL as w, regionOption as wt, TaskStatus as x, runtimeEnv as xt, getBlockingServiceKeys as y, TASK_ID as yt, Harness as z };
|
|
749
|
-
|
|
750
|
-
//# sourceMappingURL=debug-DWYDVp0B.js.map
|