@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.
- package/README.md +30 -15
- package/dist/{add-mcp-server-to-clients-BnRyE4pw.js → add-mcp-server-to-clients-JMv8LP-O.js} +6 -5
- package/dist/{add-mcp-server-to-clients-BnRyE4pw.js.map → add-mcp-server-to-clients-JMv8LP-O.js.map} +1 -1
- package/dist/agent-bCZ3i3fh.js +3085 -0
- package/dist/agent-bCZ3i3fh.js.map +1 -0
- package/dist/{agent-interface-Avtr_5M5.js → agent-interface-BAOIHuXS.js} +429 -378
- package/dist/agent-interface-BAOIHuXS.js.map +1 -0
- package/dist/{agent-prompt-loader-CHixNPgY.js → agent-prompt-loader-7Pd4CfZO.js} +6 -6
- package/dist/agent-prompt-loader-7Pd4CfZO.js.map +1 -0
- package/dist/analytics-BcV-WCM4.js +2 -0
- package/dist/{analytics-C67F2vee.js → analytics-CHCZ_qUR.js} +10 -6
- package/dist/analytics-CHCZ_qUR.js.map +1 -0
- package/dist/{api-Dj1yabTj.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-CWRYuLAn.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-CvXL5h13.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-CziFS0cA.js → debug-M2gV2iDq.js} +1 -1
- package/dist/{defaults-4c4YwTmW.js → defaults-C6J7yL4O.js} +1 -1
- package/dist/{defaults-4c4YwTmW.js.map → defaults-C6J7yL4O.js.map} +1 -1
- package/dist/endpoints-DCVbM06L.js +108 -0
- package/dist/endpoints-DCVbM06L.js.map +1 -0
- package/dist/{env-api-key-BZ5wE3Y4.js → env-api-key-Qx8NnYHm.js} +3 -3
- package/dist/env-api-key-Qx8NnYHm.js.map +1 -0
- package/dist/{environment-BEvsey6i.js → environment-B07Bmxae.js} +6 -6
- package/dist/environment-B07Bmxae.js.map +1 -0
- package/dist/{errors-BoJvrdw8.js → errors-CQ9kttJD.js} +27 -34
- package/dist/errors-CQ9kttJD.js.map +1 -0
- package/dist/{file-BoD3REGB.js → file-BcLTjU16.js} +2 -2
- package/dist/{file-BoD3REGB.js.map → file-BcLTjU16.js.map} +1 -1
- package/dist/{file-watcher-BPFazvG_.js → file-watcher-DWc_bTs6.js} +2 -2
- package/dist/{file-watcher-BPFazvG_.js.map → file-watcher-DWc_bTs6.js.map} +1 -1
- package/dist/{gateway-session-xPFv6p5c.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-CsmQrDIl.js → headless-ui-BFFmYC4v.js} +13 -2
- package/dist/headless-ui-BFFmYC4v.js.map +1 -0
- package/dist/{interactive-Dej-sxvR.js → interactive-D6zV7brJ.js} +2 -2
- package/dist/{interactive-Dej-sxvR.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-BU_kuur_.js → mcp-prompt-streaming-I2U_X7BC.js} +7 -6
- package/dist/mcp-prompt-streaming-I2U_X7BC.js.map +1 -0
- package/dist/{mint-failure-BrleGqMd.js → mint-failure-D4nd2XmZ.js} +82 -25
- 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-DcOjH2fw.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-DXwr8Sp3.js → orchestrator-tools-szcdscwn.js} +4 -4
- 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-mY8I2XkG.js → pi-D3h5Ok0i.js} +329 -65
- package/dist/pi-D3h5Ok0i.js.map +1 -0
- package/dist/{playground-CDUUKLkC.js → playground-5AB4WgNF.js} +11 -7
- package/dist/playground-5AB4WgNF.js.map +1 -0
- package/dist/{posthog-Hc_-9wrr.js → posthog-DNn574nW.js} +8 -3
- package/dist/posthog-DNn574nW.js.map +1 -0
- package/dist/{provisioning-xfdjhFtA.js → provisioning-B8uSqRZk.js} +6 -5
- package/dist/provisioning-B8uSqRZk.js.map +1 -0
- package/dist/{queue-tools-C8y_xZJi.js → queue-tools-9OOVx5TE.js} +7 -86
- package/dist/queue-tools-9OOVx5TE.js.map +1 -0
- package/dist/{registry-DTmREJ-f.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-Dw2oFJjP.js → security-Cg_4a7vB.js} +6 -6
- package/dist/security-Cg_4a7vB.js.map +1 -0
- package/dist/{setup-utils-fjJTBhaB.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-UNe2xQ0U.js → start-tui-CB2PZs1x.js} +38 -44
- package/dist/start-tui-CB2PZs1x.js.map +1 -0
- package/dist/{steps-C2yqOk_h.js → steps-BZcXRJNY.js} +7 -7
- package/dist/{steps-C2yqOk_h.js.map → steps-BZcXRJNY.js.map} +1 -1
- package/dist/{store-Bic4Cr3L.js → store-UN7c-ASf.js} +18 -28
- package/dist/store-UN7c-ASf.js.map +1 -0
- package/dist/{subagent-Dz41vV9j.js → subagent-BofIDK-O.js} +8 -3
- package/dist/subagent-BofIDK-O.js.map +1 -0
- package/dist/{task-5-fw_Vw3.js → task-r9t1UhQP.js} +124 -36
- package/dist/task-r9t1UhQP.js.map +1 -0
- package/dist/{task-stream-dVzl6b_q.js → task-stream-CMUilu54.js} +45 -15
- package/dist/task-stream-CMUilu54.js.map +1 -0
- package/dist/{tasks-D1c2z1aw.js → tasks-Bbv_lOBG.js} +17 -13
- package/dist/tasks-Bbv_lOBG.js.map +1 -0
- package/dist/{telemetry-BRnxBRWK.js → telemetry-D6ruCtnv.js} +5 -5
- package/dist/telemetry-D6ruCtnv.js.map +1 -0
- package/dist/{terminal-9bvRa4Qt.js → terminal-DrGyci_a.js} +39 -74
- package/dist/terminal-DrGyci_a.js.map +1 -0
- package/dist/{tools-Dp6i9k70.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-lE6umflt.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-BTNJ6MGW.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 +1 -1
- package/dist/agent-interface-Avtr_5M5.js.map +0 -1
- package/dist/agent-prompt-loader-CHixNPgY.js.map +0 -1
- package/dist/agent-runner-COOIUJCP.js +0 -6188
- package/dist/agent-runner-COOIUJCP.js.map +0 -1
- package/dist/analytics-C67F2vee.js.map +0 -1
- package/dist/analytics-CJA1uLlk.js +0 -2
- package/dist/api-Dj1yabTj.js.map +0 -1
- package/dist/bounded-fs-CWRYuLAn.js.map +0 -1
- package/dist/ci-install-CvXL5h13.js.map +0 -1
- package/dist/debug-B4kzIZPi.js +0 -754
- package/dist/debug-B4kzIZPi.js.map +0 -1
- package/dist/env-api-key-BZ5wE3Y4.js.map +0 -1
- package/dist/environment-BEvsey6i.js.map +0 -1
- package/dist/errors-BoJvrdw8.js.map +0 -1
- package/dist/gateway-session-C118uACz.js +0 -2
- package/dist/gateway-session-xPFv6p5c.js.map +0 -1
- package/dist/headless-ui-CsmQrDIl.js.map +0 -1
- package/dist/local-dev-DPZiIPCK.js.map +0 -1
- package/dist/mcp-Cbuw_xss.js +0 -64
- package/dist/mcp-Cbuw_xss.js.map +0 -1
- package/dist/mcp-prompt-streaming-BU_kuur_.js.map +0 -1
- package/dist/mint-failure-BrleGqMd.js.map +0 -1
- package/dist/non-interactive-DcOjH2fw.js.map +0 -1
- package/dist/orchestrator-tools-DXwr8Sp3.js.map +0 -1
- package/dist/package-json-xt3eeyBI.js.map +0 -1
- package/dist/package-manager-DR23m5Jg.js +0 -290
- package/dist/package-manager-DR23m5Jg.js.map +0 -1
- package/dist/pi-mY8I2XkG.js.map +0 -1
- package/dist/playground-CDUUKLkC.js.map +0 -1
- package/dist/posthog-Hc_-9wrr.js.map +0 -1
- package/dist/provisioning-xfdjhFtA.js.map +0 -1
- package/dist/queue-tools-C8y_xZJi.js.map +0 -1
- package/dist/registry-DTmREJ-f.js.map +0 -1
- package/dist/security-Dw2oFJjP.js.map +0 -1
- package/dist/setup-utils-fjJTBhaB.js.map +0 -1
- package/dist/start-tui-UNe2xQ0U.js.map +0 -1
- package/dist/store-Bic4Cr3L.js.map +0 -1
- package/dist/subagent-Dz41vV9j.js.map +0 -1
- package/dist/task-5-fw_Vw3.js.map +0 -1
- package/dist/task-stream-dVzl6b_q.js.map +0 -1
- package/dist/tasks-D1c2z1aw.js.map +0 -1
- package/dist/telemetry-BRnxBRWK.js.map +0 -1
- package/dist/terminal-9bvRa4Qt.js.map +0 -1
- package/dist/tools-Dp6i9k70.js.map +0 -1
- package/dist/wizard-abort-CAcInAxg.js +0 -2
- package/dist/wizard-abort-lE6umflt.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-BTNJ6MGW.js.map +0 -1
- package/dist/yara-hooks-CFY4pGcW.js +0 -2
package/dist/bin.js
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { d as ErrorCodes,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import "./
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
2
|
+
import { d as ErrorCodes, t as classifyRunFailure, u as emitWizardError } from "./errors-CQ9kttJD.js";
|
|
3
|
+
import { a as getLogFilePath, b as isHeadless, s as logToFile, v as runtimeEnv, x as regionOption, y as headlessOption } from "./debug-Ch4BDOtD.js";
|
|
4
|
+
import { t as VERSION } from "./version-aXxpgRKx.js";
|
|
5
|
+
import { a as getLocalDev, i as checkLocalServices, o as initLocalDev, r as POSTHOG_LOCAL_URL, s as localMcpSkillsNotice } from "./local-dev-McsurOC-.js";
|
|
6
|
+
import { $ as getSkillsBaseUrl, k as POSTHOG_DOCS_URL } from "./constants-jFI2SaE1.js";
|
|
7
|
+
import "./wizard-session-2w4Ru-Wz.js";
|
|
8
|
+
import { n as analytics } from "./analytics-CHCZ_qUR.js";
|
|
9
|
+
import { r as setEntryCommand } from "./telemetry-D6ruCtnv.js";
|
|
10
|
+
import { t as LoggingUI } from "./logging-ui-_TwoMNbG.js";
|
|
11
|
+
import { n as setUI, t as getUI } from "./ui-BBVuTM1v.js";
|
|
12
|
+
import { n as registerShutdown, r as runCleanups } from "./wizard-abort-BBkiUxfS.js";
|
|
13
|
+
import { n as isNonInteractiveEnvironment } from "./environment-B07Bmxae.js";
|
|
14
|
+
import { a as getAuditChecks, s as maybeStampAiSdkDetected, t as runProgramAgent, x as authenticate } from "./run-agent-legacy-d7rWlzQR.js";
|
|
15
|
+
import { r as currentCredentials } from "./oauth-session-DJ8h6GFa.js";
|
|
16
|
+
import { I as WIZARD_TOOL_NAMES, et as fetchSkillMenu, m as isGrantRevoked, u as recoverOrphanedSettingsBackups } from "./agent-interface-BAOIHuXS.js";
|
|
17
|
+
import "./agent-bCZ3i3fh.js";
|
|
18
|
+
import { h as AUDIT_CHECKS_FILE } from "./yara-hooks-DCeMDd1o.js";
|
|
19
|
+
import { $ as wordWrap, A as installOrUpdatePostHogCli, B as webAnalyticsDoctorConfig, D as CLI_STEERING_TARGETS, E as errorTrackingUploadSourceMapsConfig, G as createSkillProgram, H as getKindMeta, K as warehouseSourceConfig, O as detectTargets, S as errorTrackingConfig, T as replayVisionConfig, U as fetchHealthIssues, V as posthogDoctorConfig, W as auditConfig, d as metricsConfig, f as aiObservabilityConfig, i as isRunFailure, it as Icons, j as installSteeringSnippet, k as findTarget, m as selfDrivingConfig, o as Program, p as mcpAnalyticsConfig, q as revenueAnalyticsConfig, rt as Colors, s as agentSkillConfig, u as getProgramConfig, z as migrationConfig } from "./mint-failure-D4nd2XmZ.js";
|
|
20
|
+
import { n as parseRetryAfter } from "./posthog-DNn574nW.js";
|
|
21
|
+
import { n as readApiKeyFromEnv } from "./env-api-key-Qx8NnYHm.js";
|
|
22
|
+
import { satisfies, valid } from "semver";
|
|
16
23
|
import { Agent, setGlobalDispatcher } from "undici";
|
|
17
24
|
import yargs from "yargs";
|
|
18
25
|
import { hideBin } from "yargs/helpers";
|
|
26
|
+
import { validate } from "uuid";
|
|
19
27
|
import * as path$1 from "node:path";
|
|
20
|
-
import { join } from "node:path";
|
|
28
|
+
import { basename, join, resolve } from "node:path";
|
|
29
|
+
import { randomUUID } from "node:crypto";
|
|
21
30
|
import { Box, Text, render, useInput, useStdout } from "ink";
|
|
22
31
|
import { createContext, createElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
23
32
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -93,6 +102,11 @@ const GLOBAL_OPTIONS = {
|
|
|
93
102
|
type: "string",
|
|
94
103
|
hidden: true
|
|
95
104
|
},
|
|
105
|
+
"run-id": {
|
|
106
|
+
describe: "Assigned cloud WizardRun UUID",
|
|
107
|
+
type: "string",
|
|
108
|
+
hidden: true
|
|
109
|
+
},
|
|
96
110
|
benchmark: {
|
|
97
111
|
default: false,
|
|
98
112
|
describe: "Run in benchmark mode with per-phase token tracking\nenv: POSTHOG_WIZARD_BENCHMARK",
|
|
@@ -230,7 +244,7 @@ function runProvision(argv) {
|
|
|
230
244
|
}
|
|
231
245
|
async function provision({ email, region, name, baseUrl, jsonMode }) {
|
|
232
246
|
try {
|
|
233
|
-
const { provisionNewAccount } = await import("./provisioning-
|
|
247
|
+
const { provisionNewAccount } = await import("./provisioning-B8uSqRZk.js").then((n) => n.r);
|
|
234
248
|
if (!jsonMode) getUI().log.info(`Provisioning account for ${email} in ${region}...`);
|
|
235
249
|
emitResult(await provisionNewAccount(email, name, region, { baseUrl }), jsonMode);
|
|
236
250
|
process.exit(0);
|
|
@@ -297,22 +311,22 @@ const basicIntegrationCommand = {
|
|
|
297
311
|
setEntryCommand("integrate");
|
|
298
312
|
(async () => {
|
|
299
313
|
if (isHeadless(argv)) {
|
|
300
|
-
const { runHeadlessInstall } = await import("./ci-install-
|
|
314
|
+
const { runHeadlessInstall } = await import("./ci-install-CDdQYsPe.js");
|
|
301
315
|
return runHeadlessInstall(argv);
|
|
302
316
|
}
|
|
303
317
|
if (argv.ci) {
|
|
304
|
-
const { runCIInstall } = await import("./ci-install-
|
|
318
|
+
const { runCIInstall } = await import("./ci-install-CDdQYsPe.js");
|
|
305
319
|
return runCIInstall(argv);
|
|
306
320
|
}
|
|
307
321
|
if (isNonInteractiveEnvironment()) {
|
|
308
|
-
const { failNonInteractive } = await import("./non-interactive-
|
|
322
|
+
const { failNonInteractive } = await import("./non-interactive-Dzow7YKY.js");
|
|
309
323
|
return failNonInteractive();
|
|
310
324
|
}
|
|
311
325
|
if (argv.playground) {
|
|
312
|
-
const { runPlayground } = await import("./playground-
|
|
326
|
+
const { runPlayground } = await import("./playground-5AB4WgNF.js");
|
|
313
327
|
return runPlayground();
|
|
314
328
|
}
|
|
315
|
-
const { runInteractive } = await import("./interactive-
|
|
329
|
+
const { runInteractive } = await import("./interactive-D6zV7brJ.js");
|
|
316
330
|
runInteractive(argv);
|
|
317
331
|
})();
|
|
318
332
|
}
|
|
@@ -354,7 +368,7 @@ const mcpAddCommand = {
|
|
|
354
368
|
function runMcpAdd(argv) {
|
|
355
369
|
const features = parseFeatures(argv.features);
|
|
356
370
|
(async () => {
|
|
357
|
-
const { readApiKeyFromEnv } = await import("./env-api-key-
|
|
371
|
+
const { readApiKeyFromEnv } = await import("./env-api-key-Qx8NnYHm.js").then((n) => n.t);
|
|
358
372
|
const apiKey = argv.apiKey || readApiKeyFromEnv();
|
|
359
373
|
const debug = argv.debug;
|
|
360
374
|
const localMcp = argv.local;
|
|
@@ -368,8 +382,8 @@ function runMcpAdd(argv) {
|
|
|
368
382
|
return;
|
|
369
383
|
}
|
|
370
384
|
try {
|
|
371
|
-
const { startTUI } = await import("./start-tui-
|
|
372
|
-
const { buildSession } = await import("./wizard-session-
|
|
385
|
+
const { startTUI } = await import("./start-tui-CB2PZs1x.js");
|
|
386
|
+
const { buildSession } = await import("./wizard-session-DGaUHOF3.js");
|
|
373
387
|
const tui = startTUI(VERSION, Program.McpAdd);
|
|
374
388
|
tui.store.session = buildSession({
|
|
375
389
|
debug,
|
|
@@ -386,7 +400,7 @@ function runMcpAdd(argv) {
|
|
|
386
400
|
}
|
|
387
401
|
async function runHeadlessAdd(args) {
|
|
388
402
|
setUI(new LoggingUI());
|
|
389
|
-
const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-
|
|
403
|
+
const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-JMv8LP-O.js").then((n) => n.r);
|
|
390
404
|
const { installed, failed } = await addMCPServerToClientsStep(args);
|
|
391
405
|
if (failed.length > 0 || installed.length === 0) process.exitCode = 1;
|
|
392
406
|
}
|
|
@@ -418,8 +432,8 @@ function runMcpRemove(argv) {
|
|
|
418
432
|
return;
|
|
419
433
|
}
|
|
420
434
|
try {
|
|
421
|
-
const { startTUI } = await import("./start-tui-
|
|
422
|
-
const { buildSession } = await import("./wizard-session-
|
|
435
|
+
const { startTUI } = await import("./start-tui-CB2PZs1x.js");
|
|
436
|
+
const { buildSession } = await import("./wizard-session-DGaUHOF3.js");
|
|
423
437
|
const tui = startTUI(VERSION, Program.McpRemove);
|
|
424
438
|
tui.store.session = buildSession({
|
|
425
439
|
debug,
|
|
@@ -435,7 +449,7 @@ function runMcpRemove(argv) {
|
|
|
435
449
|
/** No exit code on an empty result: nothing to remove is the requested end state. */
|
|
436
450
|
async function runHeadlessRemove(local) {
|
|
437
451
|
setUI(new LoggingUI());
|
|
438
|
-
const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-
|
|
452
|
+
const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-JMv8LP-O.js").then((n) => n.r);
|
|
439
453
|
await removeMCPServerFromClientsStep({ local });
|
|
440
454
|
}
|
|
441
455
|
//#endregion
|
|
@@ -455,8 +469,8 @@ function runMcpTutorial(argv) {
|
|
|
455
469
|
const debug = argv.debug;
|
|
456
470
|
const localMcp = argv.local;
|
|
457
471
|
try {
|
|
458
|
-
const { startTUI } = await import("./start-tui-
|
|
459
|
-
const { buildSession } = await import("./wizard-session-
|
|
472
|
+
const { startTUI } = await import("./start-tui-CB2PZs1x.js");
|
|
473
|
+
const { buildSession } = await import("./wizard-session-DGaUHOF3.js");
|
|
460
474
|
const tui = startTUI(VERSION, Program.McpTutorial);
|
|
461
475
|
tui.store.session = buildSession({
|
|
462
476
|
debug,
|
|
@@ -500,6 +514,270 @@ function resolveNoTelemetry(options) {
|
|
|
500
514
|
return norm !== "0" && norm !== "false";
|
|
501
515
|
}
|
|
502
516
|
//#endregion
|
|
517
|
+
//#region src/lib/task-stream/wizard-run-sync.ts
|
|
518
|
+
const STATUS = {
|
|
519
|
+
pending: "created",
|
|
520
|
+
in_progress: "running",
|
|
521
|
+
completed: "completed",
|
|
522
|
+
failed: "failed",
|
|
523
|
+
skipped: "completed"
|
|
524
|
+
};
|
|
525
|
+
var RunTaskNames = class {
|
|
526
|
+
names = /* @__PURE__ */ new Map();
|
|
527
|
+
used = /* @__PURE__ */ new Set();
|
|
528
|
+
snapshot(items) {
|
|
529
|
+
if (items.length > 100) throw new Error("task limit exceeded (100)");
|
|
530
|
+
const occurrences = /* @__PURE__ */ new Map();
|
|
531
|
+
const ids = /* @__PURE__ */ new Set();
|
|
532
|
+
return items.map((item) => {
|
|
533
|
+
const subject = item.label.trim();
|
|
534
|
+
if (!subject) throw new Error("blank task name");
|
|
535
|
+
const rawStatus = item.sourceStatus ?? item.status;
|
|
536
|
+
const status = STATUS[rawStatus];
|
|
537
|
+
if (!Object.hasOwn(STATUS, rawStatus)) throw new Error("invalid task status");
|
|
538
|
+
const occurrence = (occurrences.get(subject) ?? 0) + 1;
|
|
539
|
+
occurrences.set(subject, occurrence);
|
|
540
|
+
const id = item.id ? JSON.stringify([item.source, item.id]) : JSON.stringify([subject, occurrence]);
|
|
541
|
+
if (ids.has(id)) throw new Error("duplicate task identity");
|
|
542
|
+
ids.add(id);
|
|
543
|
+
let name = this.names.get(id);
|
|
544
|
+
if (!name) {
|
|
545
|
+
name = subject.slice(0, 255);
|
|
546
|
+
for (let n = 2; this.used.has(name); n++) {
|
|
547
|
+
const suffix = ` (${n})`;
|
|
548
|
+
name = subject.slice(0, 255 - suffix.length) + suffix;
|
|
549
|
+
}
|
|
550
|
+
this.names.set(id, name);
|
|
551
|
+
this.used.add(name);
|
|
552
|
+
}
|
|
553
|
+
return {
|
|
554
|
+
name,
|
|
555
|
+
status
|
|
556
|
+
};
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
function createWizardRunSync(options) {
|
|
561
|
+
if (options.noTelemetry || options.mode === "ci") return;
|
|
562
|
+
if (options.mode === "headless" && options.assignedId === void 0) return;
|
|
563
|
+
return new WizardRunSync({
|
|
564
|
+
...options,
|
|
565
|
+
mode: options.assignedId !== void 0 ? "cloud" : "local"
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
var WizardRunSync = class {
|
|
569
|
+
names = new RunTaskNames();
|
|
570
|
+
tasksAbort = new AbortController();
|
|
571
|
+
reported = /* @__PURE__ */ new Set();
|
|
572
|
+
context;
|
|
573
|
+
queue = Promise.resolve();
|
|
574
|
+
lastBody;
|
|
575
|
+
stopped = false;
|
|
576
|
+
tasksDisabled = false;
|
|
577
|
+
authDisabled = false;
|
|
578
|
+
closing;
|
|
579
|
+
constructor(options) {
|
|
580
|
+
this.options = options;
|
|
581
|
+
}
|
|
582
|
+
capture(items) {
|
|
583
|
+
if (this.stopped || this.tasksDisabled || !items) return;
|
|
584
|
+
if (this.options.mode === "cloud" && !validate(this.options.assignedId ?? "")) {
|
|
585
|
+
this.tasksDisabled = true;
|
|
586
|
+
this.report("invalid cloud run assignment");
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
const session = this.options.getSession();
|
|
590
|
+
if (session.runPhase === "idle") return;
|
|
591
|
+
if (!this.context) {
|
|
592
|
+
if (session.runPhase !== "running" || !session.credentials) return;
|
|
593
|
+
const { host, projectId } = session.credentials;
|
|
594
|
+
this.context = {
|
|
595
|
+
apiHost: host.appHost.replace(/\/$/, ""),
|
|
596
|
+
projectId,
|
|
597
|
+
programId: this.options.programId,
|
|
598
|
+
mode: this.options.mode,
|
|
599
|
+
id: this.options.assignedId
|
|
600
|
+
};
|
|
601
|
+
this.queue = this.initialize(session);
|
|
602
|
+
}
|
|
603
|
+
try {
|
|
604
|
+
const body = JSON.stringify({ tasks: this.names.snapshot(items) });
|
|
605
|
+
if (body === this.lastBody) return;
|
|
606
|
+
this.lastBody = body;
|
|
607
|
+
this.queue = this.queue.then(async () => {
|
|
608
|
+
if (this.tasksDisabled || this.tasksAbort.signal.aborted || !this.context?.id) return;
|
|
609
|
+
if (!await this.request("PUT", `${this.context.id}/tasks/`, body, this.tasksAbort.signal)) this.tasksDisabled = true;
|
|
610
|
+
});
|
|
611
|
+
} catch {
|
|
612
|
+
this.report("invalid task snapshot (names, statuses, identities or 100-task limit)");
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
shutdown(outcome, timeoutMs) {
|
|
616
|
+
if (this.closing) return this.closing;
|
|
617
|
+
this.stopped = true;
|
|
618
|
+
this.closing = this.finish(outcome, Math.max(0, timeoutMs));
|
|
619
|
+
return this.closing;
|
|
620
|
+
}
|
|
621
|
+
async initialize(session) {
|
|
622
|
+
const context = this.context;
|
|
623
|
+
if (!context || context.mode === "cloud") return;
|
|
624
|
+
const projectName = basename(resolve(session.installDir)).trim().slice(0, 255);
|
|
625
|
+
if (!projectName) {
|
|
626
|
+
this.tasksDisabled = true;
|
|
627
|
+
this.report("unsupported program or workspace configuration");
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
const body = JSON.stringify({
|
|
631
|
+
program_id: context.programId,
|
|
632
|
+
environment: "local",
|
|
633
|
+
workspace: {
|
|
634
|
+
type: "local_folder",
|
|
635
|
+
project_name: projectName
|
|
636
|
+
},
|
|
637
|
+
...valid("2.78.0") ? { wizard_version: VERSION } : {},
|
|
638
|
+
idempotency_key: randomUUID()
|
|
639
|
+
});
|
|
640
|
+
const result = await this.request("POST", "", body, this.tasksAbort.signal);
|
|
641
|
+
if (result && typeof result === "object" && "id" in result && typeof result.id === "string" && validate(result.id)) context.id = result.id;
|
|
642
|
+
else {
|
|
643
|
+
this.tasksDisabled = true;
|
|
644
|
+
this.report("local creation failed or returned an invalid ID; creation was not retried");
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
credentials(creds = this.options.getSession().credentials) {
|
|
648
|
+
const context = this.context;
|
|
649
|
+
if (!context) return;
|
|
650
|
+
if (!creds || creds.host.appHost.replace(/\/$/, "") !== context.apiHost || creds.projectId !== context.projectId) {
|
|
651
|
+
this.report("execution credentials changed host or project");
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
if (creds.missingScopes?.includes("wizard_run:write") || !creds.accessToken.startsWith("pha_")) {
|
|
655
|
+
this.authDisabled = true;
|
|
656
|
+
this.report("wizard_run:write OAuth grant required; authorize again");
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
return creds;
|
|
660
|
+
}
|
|
661
|
+
async request(method, suffix, body, signal) {
|
|
662
|
+
const context = this.context;
|
|
663
|
+
if (!context || this.authDisabled || signal.aborted) return;
|
|
664
|
+
let refreshed = false;
|
|
665
|
+
let rateLimited = false;
|
|
666
|
+
const attempts = method === "POST" ? 1 : 3;
|
|
667
|
+
for (let attempt = 0; attempt < attempts && !signal.aborted; attempt++) {
|
|
668
|
+
let retryMs = 500 * 2 ** attempt;
|
|
669
|
+
try {
|
|
670
|
+
const creds = this.credentials();
|
|
671
|
+
if (!creds) return;
|
|
672
|
+
const { res, data, current } = await this.bounded(async (requestSignal) => {
|
|
673
|
+
const current = this.credentials(await currentCredentials(creds));
|
|
674
|
+
if (!current) throw new Error("credentials unavailable");
|
|
675
|
+
const res = await (this.options.fetchImpl ?? fetch)(`${context.apiHost}/api/projects/${context.projectId}/wizard/runs/${suffix}`, {
|
|
676
|
+
method,
|
|
677
|
+
body,
|
|
678
|
+
signal: requestSignal,
|
|
679
|
+
headers: {
|
|
680
|
+
Authorization: `Bearer ${current.accessToken}`,
|
|
681
|
+
"Content-Type": "application/json"
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
return {
|
|
685
|
+
res,
|
|
686
|
+
data: method === "POST" && (res.status === 200 || res.status === 201) ? await res.json() : void 0,
|
|
687
|
+
current
|
|
688
|
+
};
|
|
689
|
+
}, signal, 5e3);
|
|
690
|
+
if (method === "POST" && [200, 201].includes(res.status) || method === "PUT" && res.status === 204 || method === "PATCH" && res.status === 200) return data ?? true;
|
|
691
|
+
if (res.status === 401 && current.refreshToken && !isGrantRevoked() && !refreshed && method !== "POST") {
|
|
692
|
+
refreshed = true;
|
|
693
|
+
if ((await this.bounded(() => currentCredentials(current, true), signal, 5e3)).accessToken === current.accessToken) {
|
|
694
|
+
this.authDisabled = true;
|
|
695
|
+
this.report("OAuth refresh could not recover the grant; authorize again");
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
if (res.status === 401 || res.status === 403) this.authDisabled = true;
|
|
701
|
+
if (res.status === 429 && !rateLimited) {
|
|
702
|
+
rateLimited = true;
|
|
703
|
+
retryMs = parseRetryAfter(res.headers.get("Retry-After"));
|
|
704
|
+
} else if (res.status < 500 || res.status >= 600) {
|
|
705
|
+
this.report(`${method} rejected (${res.status}); check assignment, grant and program configuration`);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
} catch {
|
|
709
|
+
if (signal.aborted) return;
|
|
710
|
+
}
|
|
711
|
+
if (attempt + 1 < attempts) try {
|
|
712
|
+
await this.sleep(retryMs, signal);
|
|
713
|
+
} catch {
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
this.report(`${method} delivery exhausted`);
|
|
718
|
+
}
|
|
719
|
+
async finish(outcome, timeoutMs) {
|
|
720
|
+
const deadline = Date.now() + timeoutMs;
|
|
721
|
+
try {
|
|
722
|
+
await this.bounded(() => this.queue, new AbortController().signal, Math.floor(timeoutMs * .75));
|
|
723
|
+
} catch {
|
|
724
|
+
this.report("task drain timed out");
|
|
725
|
+
}
|
|
726
|
+
this.tasksAbort.abort();
|
|
727
|
+
if (this.context?.mode !== "local" || !this.context.id || this.authDisabled) return;
|
|
728
|
+
if (Date.now() >= deadline) {
|
|
729
|
+
this.report("terminal update budget exhausted");
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
const finalAbort = new AbortController();
|
|
733
|
+
const timer = setTimeout(() => finalAbort.abort(), Math.max(0, deadline - Date.now()));
|
|
734
|
+
try {
|
|
735
|
+
await this.request("PATCH", `${this.context.id}/`, JSON.stringify({ status: outcome }), finalAbort.signal);
|
|
736
|
+
} finally {
|
|
737
|
+
clearTimeout(timer);
|
|
738
|
+
finalAbort.abort();
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
async bounded(operation, parent, ms) {
|
|
742
|
+
const controller = new AbortController();
|
|
743
|
+
const abort = () => controller.abort();
|
|
744
|
+
parent.addEventListener("abort", abort, { once: true });
|
|
745
|
+
if (parent.aborted) controller.abort();
|
|
746
|
+
const timer = setTimeout(abort, ms);
|
|
747
|
+
let onAbort = () => void 0;
|
|
748
|
+
const cancelled = new Promise((_, reject) => {
|
|
749
|
+
onAbort = () => reject(/* @__PURE__ */ new Error("request cancelled"));
|
|
750
|
+
controller.signal.addEventListener("abort", onAbort, { once: true });
|
|
751
|
+
if (controller.signal.aborted) onAbort();
|
|
752
|
+
});
|
|
753
|
+
try {
|
|
754
|
+
return await Promise.race([operation(controller.signal), cancelled]);
|
|
755
|
+
} finally {
|
|
756
|
+
clearTimeout(timer);
|
|
757
|
+
parent.removeEventListener("abort", abort);
|
|
758
|
+
controller.signal.removeEventListener("abort", onAbort);
|
|
759
|
+
controller.abort();
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
sleep(ms, signal) {
|
|
763
|
+
return new Promise((resolve) => {
|
|
764
|
+
const finish = () => {
|
|
765
|
+
clearTimeout(timer);
|
|
766
|
+
signal.removeEventListener("abort", finish);
|
|
767
|
+
resolve();
|
|
768
|
+
};
|
|
769
|
+
const timer = setTimeout(finish, ms);
|
|
770
|
+
signal.addEventListener("abort", finish, { once: true });
|
|
771
|
+
if (signal.aborted) finish();
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
report(message) {
|
|
775
|
+
if (this.reported.has(message)) return;
|
|
776
|
+
this.reported.add(message);
|
|
777
|
+
(this.options.onError ?? ((m) => logToFile(`[wizard-run-sync] ${m}`)))(message);
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
//#endregion
|
|
503
781
|
//#region src/lib/runners/run-wizard.ts
|
|
504
782
|
const WIZARD_VERSION = VERSION;
|
|
505
783
|
/** The session a run step's agent runs in: scoped to the step's target dir
|
|
@@ -527,7 +805,7 @@ async function advanceStep(step, store, config) {
|
|
|
527
805
|
} else if (step.run) {
|
|
528
806
|
await step.run(await prepareRunSession(step, store.session));
|
|
529
807
|
store.completeRunStep(step.id);
|
|
530
|
-
} else if (step.screenId === "run") await
|
|
808
|
+
} else if (step.screenId === "run") await runProgramAgent(config, await prepareRunSession(step, store.session));
|
|
531
809
|
else if (step.isComplete) await store.waitUntil(step.isComplete);
|
|
532
810
|
}
|
|
533
811
|
/**
|
|
@@ -540,25 +818,27 @@ function runWizard(config, options) {
|
|
|
540
818
|
let taskStream = null;
|
|
541
819
|
let onSignal = null;
|
|
542
820
|
let exitInProgress = false;
|
|
821
|
+
let signalled = false;
|
|
822
|
+
let unregisterShutdown;
|
|
543
823
|
(async () => {
|
|
544
824
|
try {
|
|
545
825
|
const installDir = options.installDir || process.cwd();
|
|
546
|
-
const { startTUI } = await import("./start-tui-
|
|
547
|
-
const { buildSession, RunPhase } = await import("./wizard-session-
|
|
548
|
-
const { TaskStreamPush } = await import("./task-stream-
|
|
549
|
-
const { PostHogDestination } = await import("./posthog-
|
|
550
|
-
const { createFileDestination } = await import("./file-
|
|
826
|
+
const { startTUI } = await import("./start-tui-CB2PZs1x.js");
|
|
827
|
+
const { buildSession, RunPhase } = await import("./wizard-session-DGaUHOF3.js");
|
|
828
|
+
const { TaskStreamPush } = await import("./task-stream-CMUilu54.js");
|
|
829
|
+
const { PostHogDestination } = await import("./posthog-DNn574nW.js").then((n) => n.r);
|
|
830
|
+
const { createFileDestination } = await import("./file-BcLTjU16.js");
|
|
551
831
|
const local = getLocalDev();
|
|
552
832
|
const localServicesError = await checkLocalServices({
|
|
553
833
|
...local,
|
|
554
834
|
localPosthog: local.localPosthog && !options.baseUrl
|
|
555
835
|
});
|
|
556
836
|
if (localServicesError) {
|
|
557
|
-
const { wizardAbort } = await import("./wizard-abort-
|
|
837
|
+
const { wizardAbort } = await import("./wizard-abort-BU4aLyvh.js");
|
|
558
838
|
await wizardAbort({ message: localServicesError });
|
|
559
839
|
return;
|
|
560
840
|
}
|
|
561
|
-
tui = startTUI(WIZARD_VERSION, config.id);
|
|
841
|
+
tui = startTUI(WIZARD_VERSION, config.id, () => onSignal?.());
|
|
562
842
|
const activeTui = tui;
|
|
563
843
|
const session = buildSession({
|
|
564
844
|
debug: options.debug,
|
|
@@ -585,7 +865,6 @@ function runWizard(config, options) {
|
|
|
585
865
|
if (options.skillId) session.skillId = options.skillId;
|
|
586
866
|
else if (config.skillId) session.skillId = config.skillId;
|
|
587
867
|
activeTui.store.session = session;
|
|
588
|
-
let signalled = false;
|
|
589
868
|
onSignal = () => {
|
|
590
869
|
if (signalled || exitInProgress) return;
|
|
591
870
|
signalled = true;
|
|
@@ -593,17 +872,17 @@ function runWizard(config, options) {
|
|
|
593
872
|
runCleanups();
|
|
594
873
|
if (activeTui.store.session.runPhase === RunPhase.Running) activeTui.store.setRunPhase(RunPhase.Error);
|
|
595
874
|
const teardown = () => {
|
|
875
|
+
unregisterShutdown?.();
|
|
876
|
+
if (onSignal) {
|
|
877
|
+
process.off("SIGINT", onSignal);
|
|
878
|
+
process.off("SIGTERM", onSignal);
|
|
879
|
+
}
|
|
596
880
|
try {
|
|
597
881
|
activeTui.unmount();
|
|
598
882
|
} catch {}
|
|
599
883
|
process.exit(130);
|
|
600
884
|
};
|
|
601
|
-
|
|
602
|
-
if (!stream) {
|
|
603
|
-
teardown();
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
stream.shutdown(2e3).catch((e) => logToFile("[run-wizard] task stream shutdown error on signal:", e)).finally(teardown);
|
|
885
|
+
Promise.all([taskStream?.shutdown(2e3, "cancelled"), analytics.shutdown("cancelled")]).catch(() => logToFile("[run-wizard] cancellation shutdown failed")).finally(teardown);
|
|
607
886
|
};
|
|
608
887
|
process.on("SIGINT", onSignal);
|
|
609
888
|
process.on("SIGTERM", onSignal);
|
|
@@ -622,7 +901,15 @@ function runWizard(config, options) {
|
|
|
622
901
|
const taskStreamEnabled = destinations.length > 0;
|
|
623
902
|
const activeStream = new TaskStreamPush({
|
|
624
903
|
store: activeTui.store,
|
|
904
|
+
getFlags: () => analytics.getCachedWizardFlags(),
|
|
625
905
|
programId: config.streamWorkflowId ?? config.id,
|
|
906
|
+
runSync: createWizardRunSync({
|
|
907
|
+
mode: "local",
|
|
908
|
+
programId: config.id,
|
|
909
|
+
assignedId: options.runId ?? runtimeEnv("POSTHOG_WIZARD_RUN_ID"),
|
|
910
|
+
noTelemetry: session.noTelemetry,
|
|
911
|
+
getSession: () => activeTui.store.session
|
|
912
|
+
}),
|
|
626
913
|
destinations,
|
|
627
914
|
eventPlanPath: config.eventPlanFile ? join(session.installDir, config.eventPlanFile) : void 0,
|
|
628
915
|
auditChecks: config.auditLedgerFile ? () => getAuditChecks(activeTui.store.session) : void 0,
|
|
@@ -630,6 +917,10 @@ function runWizard(config, options) {
|
|
|
630
917
|
});
|
|
631
918
|
taskStream = activeStream;
|
|
632
919
|
activeStream.attach();
|
|
920
|
+
unregisterShutdown = registerShutdown((outcome) => {
|
|
921
|
+
if (activeTui.store.session.runPhase === RunPhase.Running) activeTui.store.setRunPhase(RunPhase.Error);
|
|
922
|
+
return activeStream.shutdown(2e3, outcome);
|
|
923
|
+
});
|
|
633
924
|
await activeTui.store.getGate("integration-check");
|
|
634
925
|
await activeTui.store.getGate("health-check");
|
|
635
926
|
const skipAgent = config.run == null;
|
|
@@ -639,7 +930,7 @@ function runWizard(config, options) {
|
|
|
639
930
|
if (shown(step)) await advanceStep(step, activeTui.store, config);
|
|
640
931
|
}
|
|
641
932
|
else if (skipAgent) {
|
|
642
|
-
const { getOrAskForProjectData } = await import("./setup-utils-
|
|
933
|
+
const { getOrAskForProjectData } = await import("./setup-utils-CmTCTPkX.js").then((n) => n.r);
|
|
643
934
|
const { projectApiKey, host, accessToken, projectId } = await getOrAskForProjectData({
|
|
644
935
|
signup: session.signup,
|
|
645
936
|
ci: session.ci,
|
|
@@ -655,7 +946,7 @@ function runWizard(config, options) {
|
|
|
655
946
|
projectId
|
|
656
947
|
});
|
|
657
948
|
} else try {
|
|
658
|
-
await
|
|
949
|
+
await runProgramAgent(config, activeTui.store.session);
|
|
659
950
|
} catch (error) {
|
|
660
951
|
const failure = classifyRunFailure(error);
|
|
661
952
|
logToFile("[run-wizard] run failed, handing off:", error);
|
|
@@ -667,7 +958,9 @@ function runWizard(config, options) {
|
|
|
667
958
|
message: failure.message
|
|
668
959
|
});
|
|
669
960
|
}
|
|
961
|
+
if (signalled) return;
|
|
670
962
|
const runFailed = isRunFailure(activeTui.store.session);
|
|
963
|
+
await activeStream.finishRun(runFailed ? "failed" : "completed");
|
|
671
964
|
await activeTui.store.waitUntil((s) => {
|
|
672
965
|
if (s.mintHandoff === "exit") return true;
|
|
673
966
|
if (skipAgent && !runFailed) return s.outroDismissed;
|
|
@@ -675,12 +968,14 @@ function runWizard(config, options) {
|
|
|
675
968
|
});
|
|
676
969
|
exitInProgress = true;
|
|
677
970
|
await activeStream.shutdown(2e3);
|
|
971
|
+
unregisterShutdown?.();
|
|
678
972
|
process.off("SIGINT", onSignal);
|
|
679
973
|
process.off("SIGTERM", onSignal);
|
|
680
974
|
if (runFailed) await analytics.shutdown("error");
|
|
681
975
|
activeTui.unmount();
|
|
682
976
|
process.exit(runFailed ? 1 : 0);
|
|
683
977
|
} catch (err) {
|
|
978
|
+
if (signalled) return;
|
|
684
979
|
logToFile("[run-wizard] FATAL:", err);
|
|
685
980
|
runCleanups();
|
|
686
981
|
exitInProgress = true;
|
|
@@ -689,8 +984,9 @@ function runWizard(config, options) {
|
|
|
689
984
|
process.off("SIGTERM", onSignal);
|
|
690
985
|
}
|
|
691
986
|
if (taskStream) try {
|
|
692
|
-
await taskStream.shutdown(2e3);
|
|
987
|
+
await taskStream.shutdown(2e3, "failed");
|
|
693
988
|
} catch {}
|
|
989
|
+
unregisterShutdown?.();
|
|
694
990
|
if (tui) try {
|
|
695
991
|
tui.unmount();
|
|
696
992
|
} catch {}
|
|
@@ -707,6 +1003,30 @@ function runWizard(config, options) {
|
|
|
707
1003
|
})();
|
|
708
1004
|
}
|
|
709
1005
|
//#endregion
|
|
1006
|
+
//#region src/lib/programs/detect-map.ts
|
|
1007
|
+
const DETECT_CODES = {
|
|
1008
|
+
"bad-directory": ErrorCodes.DetectBadDirectory,
|
|
1009
|
+
"unsupported-platform": ErrorCodes.DetectUnsupportedPlatform,
|
|
1010
|
+
"no-project-files": ErrorCodes.DetectNoProjectFiles,
|
|
1011
|
+
"no-sources": ErrorCodes.DetectNoSources,
|
|
1012
|
+
"no-package-json": ErrorCodes.DetectNoPackageJson,
|
|
1013
|
+
"no-sdks": ErrorCodes.DetectNoSdks,
|
|
1014
|
+
"missing-stripe": ErrorCodes.DetectMissingStripe,
|
|
1015
|
+
"no-posthog-sdk": ErrorCodes.DetectNoPosthogSdk,
|
|
1016
|
+
"no-posthog": ErrorCodes.DetectNoPosthogSdk,
|
|
1017
|
+
"missing-posthog": ErrorCodes.DetectNoPosthogSdk
|
|
1018
|
+
};
|
|
1019
|
+
/**
|
|
1020
|
+
* `kind` arrives as a bare string — `frameworkContext.detectError` is untyped
|
|
1021
|
+
* storage — so the lookup can still miss. It falls back to a detect-group code
|
|
1022
|
+
* with `retry: 'no'`, never to `InternalUnhandled`: an unrecognized precondition
|
|
1023
|
+
* failure is still a precondition failure, and telling a sandbox to retry one
|
|
1024
|
+
* costs it the whole budget.
|
|
1025
|
+
*/
|
|
1026
|
+
function detectErrorCode(kind) {
|
|
1027
|
+
return DETECT_CODES[kind] ?? ErrorCodes.DetectUnclassified;
|
|
1028
|
+
}
|
|
1029
|
+
//#endregion
|
|
710
1030
|
//#region src/lib/runners/run-non-interactive.ts
|
|
711
1031
|
/** User-facing label for a non-interactive mode. */
|
|
712
1032
|
function modeLabel(mode) {
|
|
@@ -746,7 +1066,7 @@ function validateNonInteractiveOptions(options, mode) {
|
|
|
746
1066
|
* (`runWizardHeadless`) runs.
|
|
747
1067
|
*
|
|
748
1068
|
* Validates flags, builds a `ci:true` session, runs `config.ciPreRun` (or the
|
|
749
|
-
* program's `onReady` hooks by default), executes `
|
|
1069
|
+
* program's `onReady` hooks by default), executes `runProgramAgent`, and routes any
|
|
750
1070
|
* failure through `wizardAbort`. `wizardAbort` owns all exits — never add a
|
|
751
1071
|
* raw `process.exit` here.
|
|
752
1072
|
*
|
|
@@ -761,11 +1081,11 @@ function runNonInteractive(config, options, mode) {
|
|
|
761
1081
|
analytics.setTag("build", mode);
|
|
762
1082
|
(async () => {
|
|
763
1083
|
const path = await import("path");
|
|
764
|
-
const { buildSession, RunPhase, OutroKind } = await import("./wizard-session-
|
|
765
|
-
const { readEnvironment } = await import("./environment-
|
|
766
|
-
const { readApiKeyFromEnv } = await import("./env-api-key-
|
|
767
|
-
const { configureLogFileFromEnvironment, logToFile } = await import("./debug-
|
|
768
|
-
const { wizardAbort, WizardError } = await import("./wizard-abort-
|
|
1084
|
+
const { buildSession, RunPhase, OutroKind } = await import("./wizard-session-DGaUHOF3.js");
|
|
1085
|
+
const { readEnvironment } = await import("./environment-B07Bmxae.js").then((n) => n.t);
|
|
1086
|
+
const { readApiKeyFromEnv } = await import("./env-api-key-Qx8NnYHm.js").then((n) => n.t);
|
|
1087
|
+
const { configureLogFileFromEnvironment, logToFile } = await import("./debug-M2gV2iDq.js");
|
|
1088
|
+
const { wizardAbort, WizardError } = await import("./wizard-abort-BU4aLyvh.js");
|
|
769
1089
|
configureLogFileFromEnvironment();
|
|
770
1090
|
const env = readEnvironment();
|
|
771
1091
|
const apiKey = options.apiKey ?? readApiKeyFromEnv() ?? void 0;
|
|
@@ -812,12 +1132,12 @@ function runNonInteractive(config, options, mode) {
|
|
|
812
1132
|
let store = null;
|
|
813
1133
|
let taskStream = null;
|
|
814
1134
|
{
|
|
815
|
-
const { WizardStore } = await import("./store-
|
|
816
|
-
const { HeadlessUI } = await import("./headless-ui-
|
|
817
|
-
const { TaskStreamPush, PostHogDestination, createFileDestination } = await import("./task-stream-
|
|
1135
|
+
const { WizardStore } = await import("./store-UN7c-ASf.js").then((n) => n.n);
|
|
1136
|
+
const { HeadlessUI } = await import("./headless-ui-BFFmYC4v.js");
|
|
1137
|
+
const { TaskStreamPush, PostHogDestination, createFileDestination } = await import("./task-stream-CMUilu54.js");
|
|
818
1138
|
const fileDestination = createFileDestination(mode === "ci" ? options.taskStreamLog ?? "" : options.taskStreamLog);
|
|
819
1139
|
const posthogDestination = mode === "headless" && !session.noTelemetry ? new PostHogDestination({
|
|
820
|
-
getCredentials: () => session.credentials,
|
|
1140
|
+
getCredentials: () => store?.session.credentials ?? session.credentials,
|
|
821
1141
|
onError: (e) => logToFile("[headless task-stream]", e.message)
|
|
822
1142
|
}) : null;
|
|
823
1143
|
const destinations = [...posthogDestination ? [posthogDestination] : [], ...fileDestination ? [fileDestination] : []];
|
|
@@ -827,25 +1147,45 @@ function runNonInteractive(config, options, mode) {
|
|
|
827
1147
|
setUI(new HeadlessUI(headlessStore));
|
|
828
1148
|
taskStream = new TaskStreamPush({
|
|
829
1149
|
store: headlessStore,
|
|
1150
|
+
getFlags: () => analytics.getCachedWizardFlags(),
|
|
830
1151
|
programId: config.streamWorkflowId ?? config.id,
|
|
1152
|
+
runSync: createWizardRunSync({
|
|
1153
|
+
mode,
|
|
1154
|
+
programId: config.id,
|
|
1155
|
+
assignedId: options.runId ?? runtimeEnv("POSTHOG_WIZARD_RUN_ID"),
|
|
1156
|
+
noTelemetry: session.noTelemetry,
|
|
1157
|
+
getSession: () => headlessStore.session
|
|
1158
|
+
}),
|
|
831
1159
|
destinations,
|
|
832
1160
|
eventPlanPath: config.eventPlanFile ? join(session.installDir, config.eventPlanFile) : void 0,
|
|
833
1161
|
auditChecks: config.auditLedgerFile ? () => getAuditChecks(headlessStore.session) : void 0,
|
|
834
1162
|
enabled: destinations.length > 0
|
|
835
1163
|
});
|
|
836
1164
|
taskStream.attach();
|
|
837
|
-
headlessStore.setRunPhase(RunPhase.Running);
|
|
838
1165
|
if (fileDestination) logToFile(`[task-stream] ${mode} dump: ${fileDestination.path}`);
|
|
839
1166
|
}
|
|
840
|
-
const settleStream = async (phase, outroData) => {
|
|
1167
|
+
const settleStream = async (phase, outroData, outcome = phase === RunPhase.Completed ? "completed" : "failed") => {
|
|
841
1168
|
if (!store || !taskStream) return;
|
|
842
1169
|
if (outroData) store.setOutroData(outroData);
|
|
843
1170
|
store.setRunPhase(phase);
|
|
844
|
-
await taskStream.shutdown(2e3);
|
|
1171
|
+
await taskStream.shutdown(2e3, outcome);
|
|
1172
|
+
process.off("SIGINT", onSignal);
|
|
1173
|
+
process.off("SIGTERM", onSignal);
|
|
1174
|
+
unregisterShutdown();
|
|
1175
|
+
};
|
|
1176
|
+
const unregisterShutdown = registerShutdown((outcome) => settleStream(RunPhase.Error, void 0, outcome));
|
|
1177
|
+
let signalled = false;
|
|
1178
|
+
const onSignal = () => {
|
|
1179
|
+
if (signalled) return;
|
|
1180
|
+
signalled = true;
|
|
1181
|
+
runCleanups();
|
|
1182
|
+
settleStream(RunPhase.Error, void 0, "cancelled").then(() => wizardAbort({ exitCode: 130 }));
|
|
845
1183
|
};
|
|
1184
|
+
process.on("SIGINT", onSignal);
|
|
1185
|
+
process.on("SIGTERM", onSignal);
|
|
846
1186
|
try {
|
|
847
1187
|
if (mode === "ci") {
|
|
848
|
-
const { configureGatewayFromCIEnvironment } = await import("./
|
|
1188
|
+
const { configureGatewayFromCIEnvironment } = await import("./agent-bCZ3i3fh.js").then((n) => n.t);
|
|
849
1189
|
configureGatewayFromCIEnvironment(Number(session.projectId), session.region ?? "us");
|
|
850
1190
|
}
|
|
851
1191
|
if (config.ciPreRun) await config.ciPreRun(session);
|
|
@@ -910,10 +1250,12 @@ function runNonInteractive(config, options, mode) {
|
|
|
910
1250
|
});
|
|
911
1251
|
}
|
|
912
1252
|
}
|
|
913
|
-
const {
|
|
914
|
-
await
|
|
1253
|
+
const { runProgramAgent } = await import("./run-agent-legacy-d7rWlzQR.js").then((n) => n.n);
|
|
1254
|
+
await runProgramAgent(config, session);
|
|
1255
|
+
if (signalled) return;
|
|
915
1256
|
await settleStream(RunPhase.Completed);
|
|
916
1257
|
} catch (error) {
|
|
1258
|
+
if (signalled) return;
|
|
917
1259
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
918
1260
|
const errorStack = error instanceof Error && error.stack ? error.stack : void 0;
|
|
919
1261
|
logToFile(`[${mode}] ERROR: ${errorMessage}`);
|
|
@@ -2174,7 +2516,7 @@ async function runDoctorCI(options) {
|
|
|
2174
2516
|
getUI().intro("Welcome to the PostHog setup wizard");
|
|
2175
2517
|
getUI().log.info("Running posthog-doctor in CI mode");
|
|
2176
2518
|
try {
|
|
2177
|
-
const { getOrAskForProjectData } = await import("./setup-utils-
|
|
2519
|
+
const { getOrAskForProjectData } = await import("./setup-utils-CmTCTPkX.js").then((n) => n.r);
|
|
2178
2520
|
const { host, accessToken, projectId } = await getOrAskForProjectData({
|
|
2179
2521
|
signup: false,
|
|
2180
2522
|
ci: true,
|
|
@@ -2192,7 +2534,7 @@ async function runDoctorCI(options) {
|
|
|
2192
2534
|
for (const issue of sorted) getUI().log.info(` • [${issue.severity}] ${getKindMeta(issue.kind).title}`);
|
|
2193
2535
|
process.exit(1);
|
|
2194
2536
|
} catch (error) {
|
|
2195
|
-
const { ApiError } = await import("./api-
|
|
2537
|
+
const { ApiError } = await import("./api-Diy_2fp8.js").then((n) => n.n);
|
|
2196
2538
|
const message = error instanceof ApiError && error.statusCode === 401 ? "Your PostHog API key is invalid or expired." : error instanceof Error ? error.message : String(error);
|
|
2197
2539
|
getUI().log.error(`Doctor failed: ${message}`);
|
|
2198
2540
|
emitWizardError({
|
|
@@ -2278,8 +2620,8 @@ function runSlackConnect(argv) {
|
|
|
2278
2620
|
(async () => {
|
|
2279
2621
|
const debug = argv.debug;
|
|
2280
2622
|
try {
|
|
2281
|
-
const { startTUI } = await import("./start-tui-
|
|
2282
|
-
const { buildSession } = await import("./wizard-session-
|
|
2623
|
+
const { startTUI } = await import("./start-tui-CB2PZs1x.js");
|
|
2624
|
+
const { buildSession } = await import("./wizard-session-DGaUHOF3.js");
|
|
2283
2625
|
const tui = startTUI(VERSION, Program.SlackConnect);
|
|
2284
2626
|
tui.store.session = buildSession({
|
|
2285
2627
|
debug,
|