@posthog/wizard 2.84.0 → 2.84.1
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/dist/{agent-interface-BNssNetq.js → agent-interface-D8mrarFD.js} +10 -10
- package/dist/{agent-interface-BNssNetq.js.map → agent-interface-D8mrarFD.js.map} +1 -1
- package/dist/{agent-prompt-loader-iV11XVEF.js → agent-prompt-loader-Bt6mrV7q.js} +6 -6
- package/dist/{agent-prompt-loader-iV11XVEF.js.map → agent-prompt-loader-Bt6mrV7q.js.map} +1 -1
- package/dist/{analytics-Drox5LSW.js → analytics-CX2kvq0R.js} +2 -2
- package/dist/{analytics-Drox5LSW.js.map → analytics-CX2kvq0R.js.map} +1 -1
- package/dist/analytics-DgLAjlIK.js +2 -0
- package/dist/{api-Dfu655Qt.js → api-BOP8gF35.js} +2 -2
- package/dist/{api-Dfu655Qt.js.map → api-BOP8gF35.js.map} +1 -1
- package/dist/api-BphZo4f2.js +2 -0
- package/dist/api-key-login-BEi3wymJ.js +2 -0
- package/dist/{api-key-login-BgwfAXfv.js → api-key-login-DbrZknHp.js} +5 -5
- package/dist/{api-key-login-BgwfAXfv.js.map → api-key-login-DbrZknHp.js.map} +1 -1
- package/dist/bin.js +1 -1
- package/dist/{bounded-fs-TRL6IsoU.js → bounded-fs-BENh-Jzc.js} +3 -3
- package/dist/{bounded-fs-TRL6IsoU.js.map → bounded-fs-BENh-Jzc.js.map} +1 -1
- package/dist/{ci-install-nc1IKuX2.js → ci-install-DnjuAl1l.js} +4 -4
- package/dist/{ci-install-nc1IKuX2.js.map → ci-install-DnjuAl1l.js.map} +1 -1
- package/dist/{debug-BfO_Txo8.js → debug-C_9xDg9j.js} +3 -3
- package/dist/{debug-BfO_Txo8.js.map → debug-C_9xDg9j.js.map} +1 -1
- package/dist/{gateway-CLQQb96F.js → gateway-C6_zPLyx.js} +5 -5
- package/dist/{gateway-CLQQb96F.js.map → gateway-C6_zPLyx.js.map} +1 -1
- package/dist/{headless-DMO8N_FD.js → headless-BIQpNAHc.js} +2 -2
- package/dist/{headless-DMO8N_FD.js.map → headless-BIQpNAHc.js.map} +1 -1
- package/dist/{headless-CHGNEzO3.js → headless-sWzDbxAu.js} +1 -1
- package/dist/{host-resolution-DftfSjJD.js → host-resolution-C3ctTKNg.js} +4 -4
- package/dist/{host-resolution-DftfSjJD.js.map → host-resolution-C3ctTKNg.js.map} +1 -1
- package/dist/{install-MWoo1hXL.js → install-CDhljVka.js} +1 -1
- package/dist/{install-C9FPM37m.js → install-Dayhuaun.js} +5 -5
- package/dist/{install-C9FPM37m.js.map → install-Dayhuaun.js.map} +1 -1
- package/dist/{interactive-DOnolJHB.js → interactive-CjbttghI.js} +3 -3
- package/dist/{interactive-DOnolJHB.js.map → interactive-CjbttghI.js.map} +1 -1
- package/dist/{links-CatXPRxH.js → links-BOOGSL_G.js} +3 -3
- package/dist/{links-CatXPRxH.js.map → links-BOOGSL_G.js.map} +1 -1
- package/dist/{main-CINmZtoW.js → main-MzQaWN8w.js} +20 -20
- package/dist/{main-CINmZtoW.js.map → main-MzQaWN8w.js.map} +1 -1
- package/dist/{mcp-KVV6Z_bq.js → mcp-BwlD260T.js} +3 -3
- package/dist/{mcp-KVV6Z_bq.js.map → mcp-BwlD260T.js.map} +1 -1
- package/dist/{mcp-prompt-streaming-M6UnLgGX.js → mcp-prompt-streaming-CoplNPI8.js} +5 -5
- package/dist/{mcp-prompt-streaming-M6UnLgGX.js.map → mcp-prompt-streaming-CoplNPI8.js.map} +1 -1
- package/dist/{models-B0huHItG.js → models-HwzgIr2E.js} +2 -2
- package/dist/{models-B0huHItG.js.map → models-HwzgIr2E.js.map} +1 -1
- package/dist/{oauth-session-9EU3ky0v.js → oauth-session-C4JV-yA9.js} +2 -2
- package/dist/{oauth-session-9EU3ky0v.js.map → oauth-session-C4JV-yA9.js.map} +1 -1
- package/dist/{orchestrator-tools-QWyDLu_7.js → orchestrator-tools-Dr4w80Tn.js} +3 -3
- package/dist/{orchestrator-tools-QWyDLu_7.js.map → orchestrator-tools-Dr4w80Tn.js.map} +1 -1
- package/dist/{package-manager-B-9I_fAT.js → package-manager-Zw0JN1Kh.js} +4 -4
- package/dist/{package-manager-B-9I_fAT.js.map → package-manager-Zw0JN1Kh.js.map} +1 -1
- package/dist/{pi-BSnSk6rv.js → pi-qzRJcTgu.js} +12 -12
- package/dist/{pi-BSnSk6rv.js.map → pi-qzRJcTgu.js.map} +1 -1
- package/dist/{playground-Drz1qszs.js → playground-B0SpcGYQ.js} +4 -4
- package/dist/{playground-Drz1qszs.js.map → playground-B0SpcGYQ.js.map} +1 -1
- package/dist/{posthog-integration-mIQGBc1f.js → posthog-integration-4vQjbU-f.js} +21 -21
- package/dist/{posthog-integration-mIQGBc1f.js.map → posthog-integration-4vQjbU-f.js.map} +1 -1
- package/dist/{programs-mxhRXwP-.js → programs-7aIrstFy.js} +15 -15
- package/dist/{programs-mxhRXwP-.js.map → programs-7aIrstFy.js.map} +1 -1
- package/dist/programs-B9Iu3Mye.js +3 -0
- package/dist/provisioning-BG_lh4hk.js +2 -0
- package/dist/{provisioning-CHUjae9V.js → provisioning-BMJ3J0Vb.js} +4 -4
- package/dist/{provisioning-CHUjae9V.js.map → provisioning-BMJ3J0Vb.js.map} +1 -1
- package/dist/{queue-tools-PFG6H93Q.js → queue-tools-D8HPaGck.js} +4 -4
- package/dist/{queue-tools-PFG6H93Q.js.map → queue-tools-D8HPaGck.js.map} +1 -1
- package/dist/{results-5yCKf2cI.js → results-8xNiBbaP.js} +2 -2
- package/dist/{results-5yCKf2cI.js.map → results-8xNiBbaP.js.map} +1 -1
- package/dist/{run-D5TKJuSL.js → run-DUcJFhzP.js} +7 -7
- package/dist/{run-D5TKJuSL.js.map → run-DUcJFhzP.js.map} +1 -1
- package/dist/{run-W03b6jNM.js → run-Dte7AuRg.js} +10 -10
- package/dist/{run-W03b6jNM.js.map → run-Dte7AuRg.js.map} +1 -1
- package/dist/run-tool-BXpuefYa.js +2 -0
- package/dist/{run-tool-DTQF8mmI.js → run-tool-sdhoPp9H.js} +13 -13
- package/dist/{run-tool-DTQF8mmI.js.map → run-tool-sdhoPp9H.js.map} +1 -1
- package/dist/{runners-B_84kPyf.js → runners-DxbNGuKH.js} +8 -8
- package/dist/{runners-B_84kPyf.js.map → runners-DxbNGuKH.js.map} +1 -1
- package/dist/{security-pApVawYb.js → security-BMqK129i.js} +5 -5
- package/dist/{security-pApVawYb.js.map → security-BMqK129i.js.map} +1 -1
- package/dist/{setup-utils-CQY8PHjR.js → setup-utils-DBOw3lnu.js} +3 -3
- package/dist/{setup-utils-CQY8PHjR.js.map → setup-utils-DBOw3lnu.js.map} +1 -1
- package/dist/{start-playground-DAw1GbLt.js → start-playground-Uf3nte-P.js} +7 -7
- package/dist/{start-playground-DAw1GbLt.js.map → start-playground-Uf3nte-P.js.map} +1 -1
- package/dist/{subagent-YLGSvgoZ.js → subagent-DYza5kN6.js} +3 -3
- package/dist/{subagent-YLGSvgoZ.js.map → subagent-DYza5kN6.js.map} +1 -1
- package/dist/{task-3hRSovmK.js → task-CiStV2CD.js} +14 -14
- package/dist/{task-3hRSovmK.js.map → task-CiStV2CD.js.map} +1 -1
- package/dist/{telemetry-BPBzqsb_.js → telemetry-DLLuQiCt.js} +2 -2
- package/dist/{telemetry-BPBzqsb_.js.map → telemetry-DLLuQiCt.js.map} +1 -1
- package/dist/{terminal-DZsYFbm9.js → terminal-B4EXuZra.js} +18 -18
- package/dist/{terminal-DZsYFbm9.js.map → terminal-B4EXuZra.js.map} +1 -1
- package/dist/{tools-D_AtrhbO.js → tools-BTAi_RrA.js} +13 -13
- package/dist/{tools-D_AtrhbO.js.map → tools-BTAi_RrA.js.map} +1 -1
- package/dist/{tools-DyzRi_dQ.js → tools-M5ENAiPc.js} +8 -8
- package/dist/{tools-DyzRi_dQ.js.map → tools-M5ENAiPc.js.map} +1 -1
- package/dist/{tui-UI6ctBQJ.js → tui-DU9MmsAK.js} +1 -1
- package/dist/{tui-CRp0iCuT.js → tui-DigZ-Q1i.js} +4 -4
- package/dist/{tui-CRp0iCuT.js.map → tui-DigZ-Q1i.js.map} +1 -1
- package/dist/{upload-step-DrYXnpzI.js → upload-step-VNWq-3aL.js} +3 -3
- package/dist/{upload-step-DrYXnpzI.js.map → upload-step-VNWq-3aL.js.map} +1 -1
- package/dist/{urls-WeqfBLP4.js → urls-Bgngk5HI.js} +2 -2
- package/dist/{urls-WeqfBLP4.js.map → urls-Bgngk5HI.js.map} +1 -1
- package/dist/{wizard-abort-BwEefm6P.js → wizard-abort-CdKk1lpi.js} +4 -4
- package/dist/{wizard-abort-BwEefm6P.js.map → wizard-abort-CdKk1lpi.js.map} +1 -1
- package/dist/{yara-hooks-MDtFbuoM.js → yara-hooks-DCgSsXFP.js} +1 -1
- package/dist/{yara-hooks-aDbdsitJ.js → yara-hooks-DPqy6eVo.js} +4 -4
- package/dist/{yara-hooks-aDbdsitJ.js.map → yara-hooks-DPqy6eVo.js.map} +1 -1
- package/package.json +6 -1
- package/dist/analytics-Ix9HEra3.js +0 -2
- package/dist/api-H2UaPgjv.js +0 -2
- package/dist/api-key-login-Cow3UDAN.js +0 -2
- package/dist/programs-Bv0_YHzE.js +0 -3
- package/dist/provisioning-BVsxSNve.js +0 -2
- package/dist/run-tool-DjERhu7G.js +0 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { a as initLogFile, f as VERSION, o as logToFile } from "./debug-
|
|
2
|
-
import { n as analytics } from "./analytics-
|
|
3
|
-
import { A as getProgramConfig, a as PostHogDestination, c as buildSession, i as createWizardRunSync, o as createFileDestination, ot as getAuditChecks, r as TaskStreamPush, s as storeInteraction, u as runProgram } from "./programs-
|
|
1
|
+
import { a as initLogFile, f as VERSION, o as logToFile } from "./debug-C_9xDg9j.js";
|
|
2
|
+
import { n as analytics } from "./analytics-CX2kvq0R.js";
|
|
3
|
+
import { A as getProgramConfig, a as PostHogDestination, c as buildSession, i as createWizardRunSync, o as createFileDestination, ot as getAuditChecks, r as TaskStreamPush, s as storeInteraction, u as runProgram } from "./programs-7aIrstFy.js";
|
|
4
4
|
import { t as classifyRunFailure } from "./errors-BXlWujEw.js";
|
|
5
5
|
import { n as printAbortOutro } from "./console-log-BMhBoX-o.js";
|
|
6
|
-
import { m as runCleanups } from "./agent-interface-
|
|
7
|
-
import { C as loadWizardFlags, i as ProgramAbort } from "./posthog-integration-
|
|
8
|
-
import { c as flushAnalytics } from "./tools-
|
|
9
|
-
import { n as startHostExit, r as wizardAbort, t as registerShutdown } from "./wizard-abort-
|
|
10
|
-
import { O as displayProgress, _ as getTuiTool, m as isRunFailure, x as abortOnScreens } from "./terminal-
|
|
11
|
-
import { a as startTUI, n as localServicesError, o as oauthCredentials, r as reportFatal, t as driveTuiTool } from "./run-tool-
|
|
6
|
+
import { m as runCleanups } from "./agent-interface-D8mrarFD.js";
|
|
7
|
+
import { C as loadWizardFlags, i as ProgramAbort } from "./posthog-integration-4vQjbU-f.js";
|
|
8
|
+
import { c as flushAnalytics } from "./tools-BTAi_RrA.js";
|
|
9
|
+
import { n as startHostExit, r as wizardAbort, t as registerShutdown } from "./wizard-abort-CdKk1lpi.js";
|
|
10
|
+
import { O as displayProgress, _ as getTuiTool, m as isRunFailure, x as abortOnScreens } from "./terminal-B4EXuZra.js";
|
|
11
|
+
import { a as startTUI, n as localServicesError, o as oauthCredentials, r as reportFatal, t as driveTuiTool } from "./run-tool-sdhoPp9H.js";
|
|
12
12
|
import { join } from "node:path";
|
|
13
13
|
//#region src/tui/workflow.ts
|
|
14
14
|
function tuiWorkflow(store, programId) {
|
|
@@ -261,4 +261,4 @@ async function runProgramOnScreens(config, store, { credentials, signal }) {
|
|
|
261
261
|
//#endregion
|
|
262
262
|
export { runTui };
|
|
263
263
|
|
|
264
|
-
//# sourceMappingURL=run-
|
|
264
|
+
//# sourceMappingURL=run-Dte7AuRg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-W03b6jNM.js","names":[],"sources":["../src/tui/workflow.ts","../src/tui/run.ts"],"sourcesContent":["/** The TUI's answers to the steps `runProgram` waits on: its screens, gates and overlays. */\nimport { RunOutcome } from '@programs';\nimport type { ProgramId, ProgramWorkflowConnector } from '@programs/types';\nimport type { WizardStore } from './store.js';\n\nexport function tuiWorkflow(\n store: WizardStore,\n programId: ProgramId,\n): ProgramWorkflowConnector {\n return {\n async confirmStep(step) {\n switch (step.kind) {\n case 'ai-approval':\n // AiOptInRequiredScreen holds here, before any source leaves the machine.\n await store.getGate('ai-opt-in');\n return true;\n case 'service-outage':\n // The health-check screen shows the outage; the run stops.\n store.setReadinessResult(step.readiness);\n return false;\n case 'settings-conflict':\n await store.showSettingsOverride(step.conflicts, step.fix);\n return true;\n case 'run':\n // Each screen before the run's step settles first; a hidden step doesn't run.\n return store.reachStep(step.stepId);\n }\n },\n finishStep(step, result) {\n // Only a composed sub-run that succeeded completes its step; a failed one keeps its tasks for the outro and the stream. The program's run step follows its phase.\n if (\n step.programId !== programId &&\n result.outcome === RunOutcome.Success\n ) {\n store.completeRunStep(step.stepId);\n }\n },\n };\n}\n","/**\n * The TUI host: the full-screen wizard. It renders its screens over its own\n * store, settles the intro, and calls `runProgram` once with the OAuth login,\n * the WizardAsk screen as the answerer and its screens as the workflow. An\n * intro that hands off to a tool drives the tool's screens instead. The CLI\n * builds the launch values, owns the signals and applies the exit code.\n */\nimport { join } from 'node:path';\nimport {\n buildSession,\n createFileDestination,\n createWizardRunSync,\n getAuditChecks,\n getProgramConfig,\n loadWizardFlags,\n PostHogDestination,\n ProgramAbort,\n RunOutcome,\n runProgram,\n storeInteraction,\n TaskStreamPush,\n} from '@programs';\nimport type { CredentialsProvider, ProgramConfig } from '@programs/types';\nimport { classifyRunFailure } from '@shared/errors';\nimport { OutroKind } from '@shared/outro';\nimport { RunPhase } from '@shared/run-state';\nimport { VERSION } from '@shared/version';\nimport { analytics } from '@utils/analytics';\nimport { runCleanups } from '@utils/cleanup';\nimport { initLogFile, logToFile } from '@utils/debug';\nimport { flushAnalytics } from '@utils/flush-analytics';\nimport {\n registerShutdown,\n startHostExit,\n wizardAbort,\n} from '@host/wizard-abort';\nimport { printAbortOutro } from '@shared/console-log';\nimport { getTuiTool } from '@tui/tools/index';\nimport { abortOnScreens } from './abort.js';\nimport { displayProgress } from './agent-progress.js';\nimport { oauthCredentials } from './auth/login.js';\nimport { isRunFailure } from './mint-failure.js';\nimport { driveTuiTool, localServicesError, reportFatal } from './run-tool.js';\nimport { startTUI } from './start-tui.js';\nimport type { WizardStore } from './store.js';\nimport type { TuiLaunch } from './launch.js';\nimport { tuiWorkflow } from './workflow.js';\n\n/** How long a screen's exit request waits for analytics before it exits anyway. */\nconst EXIT_REPORT_BUDGET_MS = 2000;\n\n/**\n * Run `config` in the TUI. Resolves with the exit code: the run's, a screen's\n * exit request, a decided failure's through `wizardAbort`, or 130 or 143 on a signal.\n */\nexport async function runTui(\n config: ProgramConfig,\n launch: TuiLaunch,\n): Promise<number> {\n const exit = startHostExit();\n let tui: ReturnType<typeof startTUI> | null = null;\n let stream: TaskStreamPush | null = null;\n let unregisterShutdown: (() => void) | undefined;\n // A signal cancels the run and any pending question before the exit.\n const runAbort = new AbortController();\n let exitInProgress = false;\n let signalled = false;\n // A tool the intro handed off to ends the run once its analytics flush.\n let handedOff = false;\n\n // Flush a terminal-phase push so the web app sees the run ended in error\n // rather than hanging on the last \"running\" snapshot. Registered before the\n // stream exists: Ctrl-C on the intro must still restore the terminal and run\n // the cleanups, and there is no run to report yet.\n const onSignal = (signal: 'SIGINT' | 'SIGTERM'): void => {\n if (signalled || exitInProgress || exit.ended) return;\n signalled = true;\n runAbort.abort();\n logToFile('[run-wizard] signal received, flushing task stream');\n // Settings restore is sync fs work, so it runs before a flush that may time out.\n runCleanups();\n if (tui?.store.session.runPhase === RunPhase.Running) {\n tui.store.setRunPhase(RunPhase.Error);\n }\n void Promise.all([\n stream?.shutdown(2000, 'cancelled'),\n analytics.shutdown('cancelled'),\n ])\n .catch(() => logToFile('[run-wizard] cancellation shutdown failed'))\n .finally(() => {\n unregisterShutdown?.();\n try {\n tui?.unmount();\n } catch {\n // terminal may already be torn down\n }\n exit.end(signal === 'SIGTERM' ? 143 : 130);\n });\n };\n const onAbort = () =>\n onSignal(launch.signal.reason === 'SIGTERM' ? 'SIGTERM' : 'SIGINT');\n // A signal that landed before this host subscribed ends the run too.\n if (launch.signal.aborted) onAbort();\n else launch.signal.addEventListener('abort', onAbort, { once: true });\n\n // Before the TUI mounts: once Ink owns the alt screen, anything written\n // to it is wiped on unmount (see the catch block below), so an abort here\n // would leave the user on a loading screen with no message.\n const localError = await localServicesError(launch.session.baseUrl);\n if (signalled) return exit.exited;\n if (localError) {\n wizardAbort(\n { present: printAbortOutro, exit },\n { message: localError },\n ).catch((error: unknown) => exit.fail(error));\n return exit.exited;\n }\n\n const main = async (): Promise<void> => {\n // Ink handles Ctrl-C itself in raw mode; it arrives here as an interrupt.\n tui = startTUI(VERSION, config.id, () => onSignal('SIGINT'));\n const activeTui = tui;\n const { store } = activeTui;\n // A screen's exit request unmounts, reports the run's end within a bounded wait, then exits with no stream shutdown.\n store.subscribe(() => {\n const code = store.exitRequest;\n if (code === null || handedOff || exitInProgress || signalled) return;\n exitInProgress = true;\n launch.signal.removeEventListener('abort', onAbort);\n activeTui.unmount();\n const report = async (): Promise<void> => {\n try {\n await analytics.shutdown(code === 0 ? 'cancelled' : 'error');\n } catch {\n logToFile('[run-wizard] exit request shutdown failed');\n }\n await flushAnalytics();\n };\n void Promise.race([\n report(),\n new Promise((resolve) => setTimeout(resolve, EXIT_REPORT_BUDGET_MS)),\n ]).then(() => exit.end(code));\n });\n\n const session = buildSession(launch.session);\n if (launch.skillId) {\n session.skillId = launch.skillId;\n } else if (config.skillId) {\n session.skillId = config.skillId;\n }\n store.launch(session, launch.session, config.id);\n\n const credentials = launch.credentials ?? oauthCredentials(store);\n launch.onStore?.(store);\n\n // Detection, then the intro, where the user may switch program.\n for (;;) {\n try {\n await store.runReadyHooks();\n } catch (error) {\n if (!(error instanceof ProgramAbort)) throw error;\n await abortOnScreens(store, {\n code: error.code,\n message: error.message,\n outroData: error.outroData,\n });\n }\n await store.getGate('intro');\n const active = store.router.activeProgram;\n if (active === config.id) break;\n const tool = getTuiTool(active);\n if (tool) {\n handedOff = true;\n const code = await driveTuiTool(store, tool, {\n toolId: active,\n signal: runAbort.signal,\n });\n if (signalled || exit.ended) return;\n exitInProgress = true;\n launch.signal.removeEventListener('abort', onAbort);\n activeTui.unmount();\n await flushAnalytics();\n exit.end(code);\n return;\n }\n config = getProgramConfig(active);\n }\n\n // After the switch loop, not before: the stream bakes its program id,\n // session id, and event-plan path in at construction, so a stream built\n // for the launch program would report the whole run under a program the\n // user left on the intro screen. Nothing before this point produces a\n // task to push.\n // Consent gates the push, not the dump: `--no-telemetry` still logs.\n const fileDestination = createFileDestination(launch.taskStreamLog);\n const destinations = [\n ...(session.noTelemetry\n ? []\n : [\n new PostHogDestination({\n getCredentials: () => store.session.credentials,\n onError: (err) => logToFile('[task-stream-push]', err.message),\n }),\n ]),\n ...(fileDestination ? [fileDestination] : []),\n ];\n const programConfig = config;\n const activeStream = new TaskStreamPush({\n store: store.sessions,\n getFlags: () => analytics.getCachedWizardFlags(),\n programId: programConfig.streamWorkflowId ?? programConfig.id,\n runSync: createWizardRunSync({\n mode: 'local',\n programId: programConfig.id,\n assignedId: launch.runId,\n noTelemetry: session.noTelemetry,\n getSession: () => store.session,\n }),\n destinations,\n eventPlanPath: programConfig.eventPlanFile\n ? join(session.installDir, programConfig.eventPlanFile)\n : undefined,\n auditChecks: programConfig.auditLedgerFile\n ? () => getAuditChecks(store.session)\n : undefined,\n enabled: destinations.length > 0,\n });\n stream = activeStream;\n activeStream.attach();\n unregisterShutdown = registerShutdown((outcome) => {\n if (store.session.runPhase === RunPhase.Running) {\n store.setRunPhase(RunPhase.Error);\n }\n return activeStream.shutdown(2000, outcome);\n });\n\n await store.getGate('integration-check');\n await store.getGate('health-check');\n\n try {\n await runProgramOnScreens(programConfig, store, {\n credentials,\n signal: runAbort.signal,\n });\n } catch (error) {\n // The run threw before its own error handling rendered an outro.\n // Show the handoff screen and let the user's agent take over.\n const failure = classifyRunFailure(error);\n logToFile('[run-wizard] run failed, handing off:', error);\n runCleanups();\n analytics.captureException(\n error instanceof Error ? error : new Error(String(error)),\n { error_code: failure.code },\n );\n store.showOutroError({\n kind: OutroKind.Error,\n errorCode: failure.code,\n message: failure.message,\n });\n }\n\n if (signalled) return;\n const runFailed = isRunFailure(store.session);\n await activeStream.finishRun(runFailed ? 'failed' : 'completed');\n await store.waitUntil((s) => s.mintHandoff === 'exit' || s.skillsComplete);\n // A screen already ended the run (KeepSkills after a success): start no flush it would cut off.\n if (exit.ended || exitInProgress) return;\n\n exitInProgress = true;\n await activeStream.shutdown(2000);\n unregisterShutdown?.();\n launch.signal.removeEventListener('abort', onAbort);\n if (runFailed) await analytics.shutdown('error');\n activeTui.unmount();\n exit.end(runFailed ? 1 : 0);\n };\n\n main().catch(async (err: unknown) => {\n if (signalled || exit.ended) return;\n // File-log first — the cleanup below can throw or exit.\n logToFile('[run-wizard] FATAL:', err);\n // Run cleanups before anything async so settings are restored even if\n // the stream shutdown hangs.\n runCleanups();\n // The task-stream debounce timer keeps the event loop alive, so\n // we have to drain it before exiting on the error path.\n exitInProgress = true;\n launch.signal.removeEventListener('abort', onAbort);\n try {\n await stream?.shutdown(2000, 'failed');\n } catch {\n // ignore\n }\n unregisterShutdown?.();\n try {\n tui?.unmount();\n } catch {\n // ignore\n }\n reportFatal(err);\n exit.end(1);\n });\n\n return exit.exited;\n}\n\n/**\n * The program's run, answered by the screens: `credentials` logs in, the\n * WizardAsk screen answers, and the flow's screens settle each step. A failure\n * shows its outro and ends the run through `wizardAbort`.\n */\nexport async function runProgramOnScreens(\n config: ProgramConfig,\n store: WizardStore,\n {\n credentials,\n signal,\n }: { credentials: CredentialsProvider; signal?: AbortSignal },\n): Promise<void> {\n initLogFile();\n logToFile(`[agent-runner] START ${config.id} build=${analytics.build}`);\n\n // runProgram turns a throwing capability into a failed run; the TUI shows\n // the handoff for those, so the throw is kept and rethrown.\n let capabilityFailure: { error: unknown } | undefined;\n const keepFailure = <T>(work: Promise<T>): Promise<T> =>\n work.catch((error: unknown) => {\n capabilityFailure ??= { error };\n throw error;\n });\n const result = await runProgram(\n config.id,\n { store: store.sessions, config },\n {\n credentials: {\n resolve: (programId, context) =>\n keepFailure(credentials.resolve(programId, context)),\n },\n interaction: storeInteraction(store.sessions),\n workflow: tuiWorkflow(store, config.id),\n onProgress: displayProgress(store),\n featureFlags: () => keepFailure(loadWizardFlags()),\n signal,\n },\n );\n if (capabilityFailure) throw capabilityFailure.error;\n // A signal cancelled the run; the handler that aborted it settles.\n if (signal?.aborted) return;\n\n if (result.outcome === RunOutcome.Crashed) throw result.failure?.error;\n if (result.outcome !== RunOutcome.Success) {\n if (result.failure?.authErrorDetail) {\n store.showAuthError(result.failure.authErrorDetail);\n }\n // The terminal status follows how the run ended, not whether an Error came back.\n await abortOnScreens(store, {\n ...result.failure,\n status: result.outcome === RunOutcome.Aborted ? 'cancelled' : 'error',\n });\n return;\n }\n // The run already succeeded: a failed flush is logged, never the outcome.\n try {\n await analytics.shutdown('success');\n } catch (error) {\n logToFile('[agent-runner] analytics shutdown failed:', error);\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAKA,SAAgB,YACd,OACA,WAC0B;AAC1B,QAAO;EACL,MAAM,YAAY,MAAM;AACtB,WAAQ,KAAK,MAAb;IACE,KAAK;AAEH,WAAM,MAAM,QAAQ,YAAY;AAChC,YAAO;IACT,KAAK;AAEH,WAAM,mBAAmB,KAAK,UAAU;AACxC,YAAO;IACT,KAAK;AACH,WAAM,MAAM,qBAAqB,KAAK,WAAW,KAAK,IAAI;AAC1D,YAAO;IACT,KAAK,MAEH,QAAO,MAAM,UAAU,KAAK,OAAO;;;EAGzC,WAAW,MAAM,QAAQ;AAEvB,OACE,KAAK,cAAc,aACnB,OAAO,YAAA,UAEP,OAAM,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B,MAAM;EAClC,oBAAoB,YAAY,iBAAiB,CAAC;EAClD;EACD,CACF;AACD,KAAI,kBAAmB,OAAM,kBAAkB;AAE/C,KAAI,QAAQ,QAAS;AAErB,KAAI,OAAO,YAAA,UAAgC,OAAM,OAAO,SAAS;AACjE,KAAI,OAAO,YAAA,WAAgC;AACzC,MAAI,OAAO,SAAS,gBAClB,OAAM,cAAc,OAAO,QAAQ,gBAAgB;AAGrD,QAAM,eAAe,OAAO;GAC1B,GAAG,OAAO;GACV,QAAQ,OAAO,YAAA,YAAiC,cAAc;GAC/D,CAAC;AACF;;AAGF,KAAI;AACF,QAAM,UAAU,SAAS,UAAU;UAC5B,OAAO;AACd,YAAU,6CAA6C,MAAM"}
|
|
1
|
+
{"version":3,"file":"run-Dte7AuRg.js","names":[],"sources":["../src/tui/workflow.ts","../src/tui/run.ts"],"sourcesContent":["/** The TUI's answers to the steps `runProgram` waits on: its screens, gates and overlays. */\nimport { RunOutcome } from '@programs';\nimport type { ProgramId, ProgramWorkflowConnector } from '@programs/types';\nimport type { WizardStore } from './store.js';\n\nexport function tuiWorkflow(\n store: WizardStore,\n programId: ProgramId,\n): ProgramWorkflowConnector {\n return {\n async confirmStep(step) {\n switch (step.kind) {\n case 'ai-approval':\n // AiOptInRequiredScreen holds here, before any source leaves the machine.\n await store.getGate('ai-opt-in');\n return true;\n case 'service-outage':\n // The health-check screen shows the outage; the run stops.\n store.setReadinessResult(step.readiness);\n return false;\n case 'settings-conflict':\n await store.showSettingsOverride(step.conflicts, step.fix);\n return true;\n case 'run':\n // Each screen before the run's step settles first; a hidden step doesn't run.\n return store.reachStep(step.stepId);\n }\n },\n finishStep(step, result) {\n // Only a composed sub-run that succeeded completes its step; a failed one keeps its tasks for the outro and the stream. The program's run step follows its phase.\n if (\n step.programId !== programId &&\n result.outcome === RunOutcome.Success\n ) {\n store.completeRunStep(step.stepId);\n }\n },\n };\n}\n","/**\n * The TUI host: the full-screen wizard. It renders its screens over its own\n * store, settles the intro, and calls `runProgram` once with the OAuth login,\n * the WizardAsk screen as the answerer and its screens as the workflow. An\n * intro that hands off to a tool drives the tool's screens instead. The CLI\n * builds the launch values, owns the signals and applies the exit code.\n */\nimport { join } from 'node:path';\nimport {\n buildSession,\n createFileDestination,\n createWizardRunSync,\n getAuditChecks,\n getProgramConfig,\n loadWizardFlags,\n PostHogDestination,\n ProgramAbort,\n RunOutcome,\n runProgram,\n storeInteraction,\n TaskStreamPush,\n} from '@programs';\nimport type { CredentialsProvider, ProgramConfig } from '@programs/types';\nimport { classifyRunFailure } from '@shared/errors';\nimport { OutroKind } from '@shared/outro';\nimport { RunPhase } from '@shared/run-state';\nimport { VERSION } from '@shared/version';\nimport { analytics } from '@utils/analytics';\nimport { runCleanups } from '@utils/cleanup';\nimport { initLogFile, logToFile } from '@utils/debug';\nimport { flushAnalytics } from '@utils/flush-analytics';\nimport {\n registerShutdown,\n startHostExit,\n wizardAbort,\n} from '@host/wizard-abort';\nimport { printAbortOutro } from '@shared/console-log';\nimport { getTuiTool } from '@tui/tools/index';\nimport { abortOnScreens } from './abort.js';\nimport { displayProgress } from './agent-progress.js';\nimport { oauthCredentials } from './auth/login.js';\nimport { isRunFailure } from './mint-failure.js';\nimport { driveTuiTool, localServicesError, reportFatal } from './run-tool.js';\nimport { startTUI } from './start-tui.js';\nimport type { WizardStore } from './store.js';\nimport type { TuiLaunch } from './launch.js';\nimport { tuiWorkflow } from './workflow.js';\n\n/** How long a screen's exit request waits for analytics before it exits anyway. */\nconst EXIT_REPORT_BUDGET_MS = 2000;\n\n/**\n * Run `config` in the TUI. Resolves with the exit code: the run's, a screen's\n * exit request, a decided failure's through `wizardAbort`, or 130 or 143 on a signal.\n */\nexport async function runTui(\n config: ProgramConfig,\n launch: TuiLaunch,\n): Promise<number> {\n const exit = startHostExit();\n let tui: ReturnType<typeof startTUI> | null = null;\n let stream: TaskStreamPush | null = null;\n let unregisterShutdown: (() => void) | undefined;\n // A signal cancels the run and any pending question before the exit.\n const runAbort = new AbortController();\n let exitInProgress = false;\n let signalled = false;\n // A tool the intro handed off to ends the run once its analytics flush.\n let handedOff = false;\n\n // Flush a terminal-phase push so the web app sees the run ended in error\n // rather than hanging on the last \"running\" snapshot. Registered before the\n // stream exists: Ctrl-C on the intro must still restore the terminal and run\n // the cleanups, and there is no run to report yet.\n const onSignal = (signal: 'SIGINT' | 'SIGTERM'): void => {\n if (signalled || exitInProgress || exit.ended) return;\n signalled = true;\n runAbort.abort();\n logToFile('[run-wizard] signal received, flushing task stream');\n // Settings restore is sync fs work, so it runs before a flush that may time out.\n runCleanups();\n if (tui?.store.session.runPhase === RunPhase.Running) {\n tui.store.setRunPhase(RunPhase.Error);\n }\n void Promise.all([\n stream?.shutdown(2000, 'cancelled'),\n analytics.shutdown('cancelled'),\n ])\n .catch(() => logToFile('[run-wizard] cancellation shutdown failed'))\n .finally(() => {\n unregisterShutdown?.();\n try {\n tui?.unmount();\n } catch {\n // terminal may already be torn down\n }\n exit.end(signal === 'SIGTERM' ? 143 : 130);\n });\n };\n const onAbort = () =>\n onSignal(launch.signal.reason === 'SIGTERM' ? 'SIGTERM' : 'SIGINT');\n // A signal that landed before this host subscribed ends the run too.\n if (launch.signal.aborted) onAbort();\n else launch.signal.addEventListener('abort', onAbort, { once: true });\n\n // Before the TUI mounts: once Ink owns the alt screen, anything written\n // to it is wiped on unmount (see the catch block below), so an abort here\n // would leave the user on a loading screen with no message.\n const localError = await localServicesError(launch.session.baseUrl);\n if (signalled) return exit.exited;\n if (localError) {\n wizardAbort(\n { present: printAbortOutro, exit },\n { message: localError },\n ).catch((error: unknown) => exit.fail(error));\n return exit.exited;\n }\n\n const main = async (): Promise<void> => {\n // Ink handles Ctrl-C itself in raw mode; it arrives here as an interrupt.\n tui = startTUI(VERSION, config.id, () => onSignal('SIGINT'));\n const activeTui = tui;\n const { store } = activeTui;\n // A screen's exit request unmounts, reports the run's end within a bounded wait, then exits with no stream shutdown.\n store.subscribe(() => {\n const code = store.exitRequest;\n if (code === null || handedOff || exitInProgress || signalled) return;\n exitInProgress = true;\n launch.signal.removeEventListener('abort', onAbort);\n activeTui.unmount();\n const report = async (): Promise<void> => {\n try {\n await analytics.shutdown(code === 0 ? 'cancelled' : 'error');\n } catch {\n logToFile('[run-wizard] exit request shutdown failed');\n }\n await flushAnalytics();\n };\n void Promise.race([\n report(),\n new Promise((resolve) => setTimeout(resolve, EXIT_REPORT_BUDGET_MS)),\n ]).then(() => exit.end(code));\n });\n\n const session = buildSession(launch.session);\n if (launch.skillId) {\n session.skillId = launch.skillId;\n } else if (config.skillId) {\n session.skillId = config.skillId;\n }\n store.launch(session, launch.session, config.id);\n\n const credentials = launch.credentials ?? oauthCredentials(store);\n launch.onStore?.(store);\n\n // Detection, then the intro, where the user may switch program.\n for (;;) {\n try {\n await store.runReadyHooks();\n } catch (error) {\n if (!(error instanceof ProgramAbort)) throw error;\n await abortOnScreens(store, {\n code: error.code,\n message: error.message,\n outroData: error.outroData,\n });\n }\n await store.getGate('intro');\n const active = store.router.activeProgram;\n if (active === config.id) break;\n const tool = getTuiTool(active);\n if (tool) {\n handedOff = true;\n const code = await driveTuiTool(store, tool, {\n toolId: active,\n signal: runAbort.signal,\n });\n if (signalled || exit.ended) return;\n exitInProgress = true;\n launch.signal.removeEventListener('abort', onAbort);\n activeTui.unmount();\n await flushAnalytics();\n exit.end(code);\n return;\n }\n config = getProgramConfig(active);\n }\n\n // After the switch loop, not before: the stream bakes its program id,\n // session id, and event-plan path in at construction, so a stream built\n // for the launch program would report the whole run under a program the\n // user left on the intro screen. Nothing before this point produces a\n // task to push.\n // Consent gates the push, not the dump: `--no-telemetry` still logs.\n const fileDestination = createFileDestination(launch.taskStreamLog);\n const destinations = [\n ...(session.noTelemetry\n ? []\n : [\n new PostHogDestination({\n getCredentials: () => store.session.credentials,\n onError: (err) => logToFile('[task-stream-push]', err.message),\n }),\n ]),\n ...(fileDestination ? [fileDestination] : []),\n ];\n const programConfig = config;\n const activeStream = new TaskStreamPush({\n store: store.sessions,\n getFlags: () => analytics.getCachedWizardFlags(),\n programId: programConfig.streamWorkflowId ?? programConfig.id,\n runSync: createWizardRunSync({\n mode: 'local',\n programId: programConfig.id,\n assignedId: launch.runId,\n noTelemetry: session.noTelemetry,\n getSession: () => store.session,\n }),\n destinations,\n eventPlanPath: programConfig.eventPlanFile\n ? join(session.installDir, programConfig.eventPlanFile)\n : undefined,\n auditChecks: programConfig.auditLedgerFile\n ? () => getAuditChecks(store.session)\n : undefined,\n enabled: destinations.length > 0,\n });\n stream = activeStream;\n activeStream.attach();\n unregisterShutdown = registerShutdown((outcome) => {\n if (store.session.runPhase === RunPhase.Running) {\n store.setRunPhase(RunPhase.Error);\n }\n return activeStream.shutdown(2000, outcome);\n });\n\n await store.getGate('integration-check');\n await store.getGate('health-check');\n\n try {\n await runProgramOnScreens(programConfig, store, {\n credentials,\n signal: runAbort.signal,\n });\n } catch (error) {\n // The run threw before its own error handling rendered an outro.\n // Show the handoff screen and let the user's agent take over.\n const failure = classifyRunFailure(error);\n logToFile('[run-wizard] run failed, handing off:', error);\n runCleanups();\n analytics.captureException(\n error instanceof Error ? error : new Error(String(error)),\n { error_code: failure.code },\n );\n store.showOutroError({\n kind: OutroKind.Error,\n errorCode: failure.code,\n message: failure.message,\n });\n }\n\n if (signalled) return;\n const runFailed = isRunFailure(store.session);\n await activeStream.finishRun(runFailed ? 'failed' : 'completed');\n await store.waitUntil((s) => s.mintHandoff === 'exit' || s.skillsComplete);\n // A screen already ended the run (KeepSkills after a success): start no flush it would cut off.\n if (exit.ended || exitInProgress) return;\n\n exitInProgress = true;\n await activeStream.shutdown(2000);\n unregisterShutdown?.();\n launch.signal.removeEventListener('abort', onAbort);\n if (runFailed) await analytics.shutdown('error');\n activeTui.unmount();\n exit.end(runFailed ? 1 : 0);\n };\n\n main().catch(async (err: unknown) => {\n if (signalled || exit.ended) return;\n // File-log first — the cleanup below can throw or exit.\n logToFile('[run-wizard] FATAL:', err);\n // Run cleanups before anything async so settings are restored even if\n // the stream shutdown hangs.\n runCleanups();\n // The task-stream debounce timer keeps the event loop alive, so\n // we have to drain it before exiting on the error path.\n exitInProgress = true;\n launch.signal.removeEventListener('abort', onAbort);\n try {\n await stream?.shutdown(2000, 'failed');\n } catch {\n // ignore\n }\n unregisterShutdown?.();\n try {\n tui?.unmount();\n } catch {\n // ignore\n }\n reportFatal(err);\n exit.end(1);\n });\n\n return exit.exited;\n}\n\n/**\n * The program's run, answered by the screens: `credentials` logs in, the\n * WizardAsk screen answers, and the flow's screens settle each step. A failure\n * shows its outro and ends the run through `wizardAbort`.\n */\nexport async function runProgramOnScreens(\n config: ProgramConfig,\n store: WizardStore,\n {\n credentials,\n signal,\n }: { credentials: CredentialsProvider; signal?: AbortSignal },\n): Promise<void> {\n initLogFile();\n logToFile(`[agent-runner] START ${config.id} build=${analytics.build}`);\n\n // runProgram turns a throwing capability into a failed run; the TUI shows\n // the handoff for those, so the throw is kept and rethrown.\n let capabilityFailure: { error: unknown } | undefined;\n const keepFailure = <T>(work: Promise<T>): Promise<T> =>\n work.catch((error: unknown) => {\n capabilityFailure ??= { error };\n throw error;\n });\n const result = await runProgram(\n config.id,\n { store: store.sessions, config },\n {\n credentials: {\n resolve: (programId, context) =>\n keepFailure(credentials.resolve(programId, context)),\n },\n interaction: storeInteraction(store.sessions),\n workflow: tuiWorkflow(store, config.id),\n onProgress: displayProgress(store),\n featureFlags: () => keepFailure(loadWizardFlags()),\n signal,\n },\n );\n if (capabilityFailure) throw capabilityFailure.error;\n // A signal cancelled the run; the handler that aborted it settles.\n if (signal?.aborted) return;\n\n if (result.outcome === RunOutcome.Crashed) throw result.failure?.error;\n if (result.outcome !== RunOutcome.Success) {\n if (result.failure?.authErrorDetail) {\n store.showAuthError(result.failure.authErrorDetail);\n }\n // The terminal status follows how the run ended, not whether an Error came back.\n await abortOnScreens(store, {\n ...result.failure,\n status: result.outcome === RunOutcome.Aborted ? 'cancelled' : 'error',\n });\n return;\n }\n // The run already succeeded: a failed flush is logged, never the outcome.\n try {\n await analytics.shutdown('success');\n } catch (error) {\n logToFile('[agent-runner] analytics shutdown failed:', error);\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAKA,SAAgB,YACd,OACA,WAC0B;AAC1B,QAAO;EACL,MAAM,YAAY,MAAM;AACtB,WAAQ,KAAK,MAAb;IACE,KAAK;AAEH,WAAM,MAAM,QAAQ,YAAY;AAChC,YAAO;IACT,KAAK;AAEH,WAAM,mBAAmB,KAAK,UAAU;AACxC,YAAO;IACT,KAAK;AACH,WAAM,MAAM,qBAAqB,KAAK,WAAW,KAAK,IAAI;AAC1D,YAAO;IACT,KAAK,MAEH,QAAO,MAAM,UAAU,KAAK,OAAO;;;EAGzC,WAAW,MAAM,QAAQ;AAEvB,OACE,KAAK,cAAc,aACnB,OAAO,YAAA,UAEP,OAAM,gBAAgB,KAAK,OAAO;;EAGvC;;;;;;;;;;;;ACYH,MAAM,wBAAwB;;;;;AAM9B,eAAsB,OACpB,QACA,QACiB;CACjB,MAAM,OAAO,eAAe;CAC5B,IAAI,MAA0C;CAC9C,IAAI,SAAgC;CACpC,IAAI;CAEJ,MAAM,WAAW,IAAI,iBAAiB;CACtC,IAAI,iBAAiB;CACrB,IAAI,YAAY;CAEhB,IAAI,YAAY;CAMhB,MAAM,YAAY,WAAuC;AACvD,MAAI,aAAa,kBAAkB,KAAK,MAAO;AAC/C,cAAY;AACZ,WAAS,OAAO;AAChB,YAAU,qDAAqD;AAE/D,eAAa;AACb,MAAI,KAAK,MAAM,QAAQ,aAAA,UACrB,KAAI,MAAM,YAAA,QAA2B;AAElC,UAAQ,IAAI,CACf,QAAQ,SAAS,KAAM,YAAY,EACnC,UAAU,SAAS,YAAY,CAChC,CAAC,CACC,YAAY,UAAU,4CAA4C,CAAC,CACnE,cAAc;AACb,yBAAsB;AACtB,OAAI;AACF,SAAK,SAAS;WACR;AAGR,QAAK,IAAI,WAAW,YAAY,MAAM,IAAI;IAC1C;;CAEN,MAAM,gBACJ,SAAS,OAAO,OAAO,W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,OAAK,IAAI,EAAE;GACX;AAEF,QAAO,KAAK;;;;;;;AAQd,eAAsB,oBACpB,QACA,OACA,EACE,aACA,UAEa;AACf,cAAa;AACb,WAAU,wBAAwB,OAAO,GAAG,SAAS,UAAU,QAAQ;CAIvE,IAAI;CACJ,MAAM,eAAkB,SACtB,KAAK,OAAO,UAAmB;AAC7B,wBAAsB,EAAE,OAAO;AAC/B,QAAM;GACN;CACJ,MAAM,SAAS,MAAM,WACnB,OAAO,IACP;EAAE,OAAO,MAAM;EAAU;EAAQ,EACjC;EACE,aAAa,EACX,UAAU,WAAW,YACnB,YAAY,YAAY,QAAQ,WAAW,QAAQ,CAAC,EACvD;EACD,aAAa,iBAAiB,MAAM,SAAS;EAC7C,UAAU,YAAY,OAAO,OAAO,GAAG;EACvC,YAAY,gBAAgB,MAAM;EAClC,oBAAoB,YAAY,iBAAiB,CAAC;EAClD;EACD,CACF;AACD,KAAI,kBAAmB,OAAM,kBAAkB;AAE/C,KAAI,QAAQ,QAAS;AAErB,KAAI,OAAO,YAAA,UAAgC,OAAM,OAAO,SAAS;AACjE,KAAI,OAAO,YAAA,WAAgC;AACzC,MAAI,OAAO,SAAS,gBAClB,OAAM,cAAc,OAAO,QAAQ,gBAAgB;AAGrD,QAAM,eAAe,OAAO;GAC1B,GAAG,OAAO;GACV,QAAQ,OAAO,YAAA,YAAiC,cAAc;GAC/D,CAAC;AACF;;AAGF,KAAI;AACF,QAAM,UAAU,SAAS,UAAU;UAC5B,OAAO;AACd,YAAU,6CAA6C,MAAM"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { n as ErrorCodes, t as emitWizardError } from "./emit-BqLCdV8Y.js";
|
|
2
|
-
import { f as VERSION, i as getLogFilePath, o as logToFile } from "./debug-
|
|
3
|
-
import { A as OAUTH_PORTS, P as POSTHOG_DOCS_URL, at as getSkillsBaseUrl, b as GITHUB_SKILLS_BASE_URL, j as OAUTH_TIMEOUT_MS, lt as checkLocalServices, n as analytics, ut as getLocalDev } from "./analytics-
|
|
4
|
-
import { A as getProgramConfig, c as buildSession, ct as SIGNUP_WIZARD_READINESS_CONFIG, m as logIn, ut as getBlockingServiceKeys } from "./programs-
|
|
2
|
+
import { f as VERSION, i as getLogFilePath, o as logToFile } from "./debug-C_9xDg9j.js";
|
|
3
|
+
import { A as OAUTH_PORTS, P as POSTHOG_DOCS_URL, at as getSkillsBaseUrl, b as GITHUB_SKILLS_BASE_URL, j as OAUTH_TIMEOUT_MS, lt as checkLocalServices, n as analytics, ut as getLocalDev } from "./analytics-CX2kvq0R.js";
|
|
4
|
+
import { A as getProgramConfig, c as buildSession, ct as SIGNUP_WIZARD_READINESS_CONFIG, m as logIn, ut as getBlockingServiceKeys } from "./programs-7aIrstFy.js";
|
|
5
5
|
import { a as WizardError, t as classifyRunFailure } from "./errors-BXlWujEw.js";
|
|
6
|
-
import { r as readFileHead } from "./bounded-fs-
|
|
6
|
+
import { r as readFileHead } from "./bounded-fs-BENh-Jzc.js";
|
|
7
7
|
import { n as printAbortOutro } from "./console-log-BMhBoX-o.js";
|
|
8
|
-
import { C as readNeedsAttention, S as NEEDS_ATTENTION_HEADING, m as runCleanups } from "./agent-interface-
|
|
9
|
-
import { F as formatTokenCount, P as formatCostUsd, k as scanInstalledSkill } from "./posthog-integration-
|
|
10
|
-
import { b as fetchSkillMenu, v as downloadSkill } from "./yara-hooks-
|
|
11
|
-
import { n as namesWithStatus, r as redactSecrets, s as toClientResult } from "./results-
|
|
12
|
-
import { c as flushAnalytics } from "./tools-
|
|
8
|
+
import { C as readNeedsAttention, S as NEEDS_ATTENTION_HEADING, m as runCleanups } from "./agent-interface-D8mrarFD.js";
|
|
9
|
+
import { F as formatTokenCount, P as formatCostUsd, k as scanInstalledSkill } from "./posthog-integration-4vQjbU-f.js";
|
|
10
|
+
import { b as fetchSkillMenu, v as downloadSkill } from "./yara-hooks-DPqy6eVo.js";
|
|
11
|
+
import { n as namesWithStatus, r as redactSecrets, s as toClientResult } from "./results-8xNiBbaP.js";
|
|
12
|
+
import { c as flushAnalytics } from "./tools-BTAi_RrA.js";
|
|
13
13
|
import { t as ALL_FEATURE_VALUES } from "./defaults-BWLIffh5.js";
|
|
14
|
-
import { n as startHostExit, r as wizardAbort } from "./wizard-abort-
|
|
15
|
-
import { a as installPlugins, i as getSupportedPluginClients, n as getInstalledClients, o as removeMCPServer, r as getSupportedClients, s as isPluginCapable } from "./install-
|
|
14
|
+
import { n as startHostExit, r as wizardAbort } from "./wizard-abort-CdKk1lpi.js";
|
|
15
|
+
import { a as installPlugins, i as getSupportedPluginClients, n as getInstalledClients, o as removeMCPServer, r as getSupportedClients, s as isPluginCapable } from "./install-Dayhuaun.js";
|
|
16
16
|
import { a as useStdoutDimensions, h as Icons, m as Colors, n as useKeyBindings, t as PickerMenu } from "./PickerMenu-BtheKi1o.js";
|
|
17
|
-
import { B as totalTokenCount, G as ModalOverlay, H as LogViewer, I as HNViewer, J as ProgressList, K as ConfirmationInput, L as TabContainer, M as IntroScreenLayout, N as PRIVACY_PANEL_LABEL, P as PrivacyPanel, Q as getContentBlocks, R as ScreenContainer, T as McpScreen, U as LinkText, V as EventPlanViewer, W as extractUrls, X as SplitView, Y as LoadingBox, _ as getTuiTool, a as SlackConnectScreen, b as extractOAuthCode, c as LearnCard, d as MINT_FAILURE_BODY, f as MINT_FAILURE_CONTACT, g as listFlowOwners, h as flowOwner, i as OutroScreen, k as useDismissOnAnyKey, l as AiOptInRequiredScreen, m as isRunFailure, n as releaseTerminal, o as TipsCard, p as MINT_FAILURE_MESSAGE, r as WizardStore, s as VisualizerTab, t as enterDarkTerminal, u as ServiceHealthList, x as abortOnScreens, y as getOrAskForProjectData } from "./terminal-
|
|
17
|
+
import { B as totalTokenCount, G as ModalOverlay, H as LogViewer, I as HNViewer, J as ProgressList, K as ConfirmationInput, L as TabContainer, M as IntroScreenLayout, N as PRIVACY_PANEL_LABEL, P as PrivacyPanel, Q as getContentBlocks, R as ScreenContainer, T as McpScreen, U as LinkText, V as EventPlanViewer, W as extractUrls, X as SplitView, Y as LoadingBox, _ as getTuiTool, a as SlackConnectScreen, b as extractOAuthCode, c as LearnCard, d as MINT_FAILURE_BODY, f as MINT_FAILURE_CONTACT, g as listFlowOwners, h as flowOwner, i as OutroScreen, k as useDismissOnAnyKey, l as AiOptInRequiredScreen, m as isRunFailure, n as releaseTerminal, o as TipsCard, p as MINT_FAILURE_MESSAGE, r as WizardStore, s as VisualizerTab, t as enterDarkTerminal, u as ServiceHealthList, x as abortOnScreens, y as getOrAskForProjectData } from "./terminal-B4EXuZra.js";
|
|
18
18
|
import path, { join } from "path";
|
|
19
19
|
import { tmpdir } from "node:os";
|
|
20
20
|
import path$1, { join as join$1 } from "node:path";
|
|
@@ -2433,4 +2433,4 @@ function reportFatal(error) {
|
|
|
2433
2433
|
//#endregion
|
|
2434
2434
|
export { startTUI as a, runTuiTool as i, localServicesError as n, oauthCredentials as o, reportFatal as r, driveTuiTool as t };
|
|
2435
2435
|
|
|
2436
|
-
//# sourceMappingURL=run-tool-
|
|
2436
|
+
//# sourceMappingURL=run-tool-sdhoPp9H.js.map
|