@posthog/wizard 2.70.1 → 2.72.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/{add-mcp-server-to-clients-BCnjUqnW.js → add-mcp-server-to-clients-QZyr6NuZ.js} +4 -4
  2. package/dist/{add-mcp-server-to-clients-BCnjUqnW.js.map → add-mcp-server-to-clients-QZyr6NuZ.js.map} +1 -1
  3. package/dist/{agent-interface-Lu7tnLr0.js → agent-interface-Yjknz6Al.js} +476 -383
  4. package/dist/agent-interface-Yjknz6Al.js.map +1 -0
  5. package/dist/{agent-prompt-loader-y5GxgEkc.js → agent-prompt-loader-CDXm4C35.js} +5 -5
  6. package/dist/{agent-prompt-loader-y5GxgEkc.js.map → agent-prompt-loader-CDXm4C35.js.map} +1 -1
  7. package/dist/{agent-runner-vKtpgqVI.js → agent-runner-CL7rCY0G.js} +3213 -20
  8. package/dist/agent-runner-CL7rCY0G.js.map +1 -0
  9. package/dist/analytics-CkNv3N4o.js +2 -0
  10. package/dist/{analytics-DTyJClPr.js → analytics-DjCPD6u-.js} +3 -3
  11. package/dist/{analytics-DTyJClPr.js.map → analytics-DjCPD6u-.js.map} +1 -1
  12. package/dist/{api-j-OfJ8Dz.js → api-xwQeBMcX.js} +23 -4
  13. package/dist/{api-j-OfJ8Dz.js.map → api-xwQeBMcX.js.map} +1 -1
  14. package/dist/bin.js +85 -75
  15. package/dist/bin.js.map +1 -1
  16. package/dist/{bounded-fs-BWX25ixc.js → bounded-fs-BtxN0nYO.js} +3 -3
  17. package/dist/{bounded-fs-BWX25ixc.js.map → bounded-fs-BtxN0nYO.js.map} +1 -1
  18. package/dist/{ci-install-zNWgp1TL.js → ci-install-BVzTnIBw.js} +5 -5
  19. package/dist/{ci-install-zNWgp1TL.js.map → ci-install-BVzTnIBw.js.map} +1 -1
  20. package/dist/{debug-xr2Pq5VA.js → debug-BoadIH6Q.js} +1 -1
  21. package/dist/{debug-BM0fZaGl.js → debug-D0T44879.js} +4 -3
  22. package/dist/debug-D0T44879.js.map +1 -0
  23. package/dist/{env-api-key-DlxCZWU0.js → env-api-key-Bj9butHX.js} +2 -2
  24. package/dist/{env-api-key-DlxCZWU0.js.map → env-api-key-Bj9butHX.js.map} +1 -1
  25. package/dist/{environment-o-bTOuzK.js → environment-vpmKreMf.js} +4 -4
  26. package/dist/{environment-o-bTOuzK.js.map → environment-vpmKreMf.js.map} +1 -1
  27. package/dist/{errors-BSdz2lsl.js → errors-u8z27V-x.js} +4 -2
  28. package/dist/errors-u8z27V-x.js.map +1 -0
  29. package/dist/{file-watcher-D7G4f5sP.js → file-watcher-BPH4wR8R.js} +2 -2
  30. package/dist/{file-watcher-D7G4f5sP.js.map → file-watcher-BPH4wR8R.js.map} +1 -1
  31. package/dist/{headless-ui-C46DctKG.js → headless-ui-vA7lv8m2.js} +2 -2
  32. package/dist/{headless-ui-C46DctKG.js.map → headless-ui-vA7lv8m2.js.map} +1 -1
  33. package/dist/{interactive-B5zy3Gxk.js → interactive-jk3IGgns.js} +2 -2
  34. package/dist/{interactive-B5zy3Gxk.js.map → interactive-jk3IGgns.js.map} +1 -1
  35. package/dist/{mcp-lJRwE-YW.js → mcp-DE2AonGF.js} +2 -2
  36. package/dist/{mcp-lJRwE-YW.js.map → mcp-DE2AonGF.js.map} +1 -1
  37. package/dist/{mcp-prompt-streaming-Dsos09hT.js → mcp-prompt-streaming-pPEIwc78.js} +5 -4
  38. package/dist/mcp-prompt-streaming-pPEIwc78.js.map +1 -0
  39. package/dist/{non-interactive-qcCCtiYQ.js → non-interactive-CEGz0nDY.js} +3 -3
  40. package/dist/{non-interactive-qcCCtiYQ.js.map → non-interactive-CEGz0nDY.js.map} +1 -1
  41. package/dist/{orchestrator-tools-ezFTbAIp.js → orchestrator-tools-BZ4Nzw6a.js} +21 -13
  42. package/dist/orchestrator-tools-BZ4Nzw6a.js.map +1 -0
  43. package/dist/{package-manager-CGfN9UhH.js → package-manager-BZjKEDO2.js} +2 -2
  44. package/dist/{package-manager-CGfN9UhH.js.map → package-manager-BZjKEDO2.js.map} +1 -1
  45. package/dist/{pi-DzQLHIcQ.js → pi-D48qAwlf.js} +18 -15
  46. package/dist/pi-D48qAwlf.js.map +1 -0
  47. package/dist/{playground-DLN31BPV.js → playground-DYGJwugo.js} +43 -8
  48. package/dist/playground-DYGJwugo.js.map +1 -0
  49. package/dist/{posthog-Dxr8XK4x.js → posthog-BTvVhvBY.js} +2 -2
  50. package/dist/{posthog-Dxr8XK4x.js.map → posthog-BTvVhvBY.js.map} +1 -1
  51. package/dist/posthog-integration-BQh-YQAP.js +1475 -0
  52. package/dist/posthog-integration-BQh-YQAP.js.map +1 -0
  53. package/dist/{provisioning-Di5GNV9k.js → provisioning-Dw3B2T_b.js} +14 -5
  54. package/dist/provisioning-Dw3B2T_b.js.map +1 -0
  55. package/dist/{queue-tools-KosDptd6.js → queue-tools-DEbzMDrF.js} +108 -44
  56. package/dist/queue-tools-DEbzMDrF.js.map +1 -0
  57. package/dist/{registry-BBdaIFWq.js → registry-Dv6JVm5r.js} +5 -5
  58. package/dist/{registry-BBdaIFWq.js.map → registry-Dv6JVm5r.js.map} +1 -1
  59. package/dist/{security-BwOvjMaq.js → security-BaggjIE4.js} +5 -5
  60. package/dist/{security-BwOvjMaq.js.map → security-BaggjIE4.js.map} +1 -1
  61. package/dist/{setup-utils-Bo3WZt3a.js → setup-utils-CnW0Zsu8.js} +42 -11
  62. package/dist/setup-utils-CnW0Zsu8.js.map +1 -0
  63. package/dist/{start-tui-B1LrB7k1.js → start-tui-SpyGz7wM.js} +279 -24
  64. package/dist/start-tui-SpyGz7wM.js.map +1 -0
  65. package/dist/{steps-BMrQJpQh.js → steps-ClfUajTv.js} +7 -7
  66. package/dist/{steps-BMrQJpQh.js.map → steps-ClfUajTv.js.map} +1 -1
  67. package/dist/{store-DhNTBWQR.js → store-Cmy0pN1R.js} +24 -6
  68. package/dist/store-Cmy0pN1R.js.map +1 -0
  69. package/dist/{subagent-q6M-mBHo.js → subagent-tYlbbkJt.js} +2 -2
  70. package/dist/{subagent-q6M-mBHo.js.map → subagent-tYlbbkJt.js.map} +1 -1
  71. package/dist/{task-CgAOxod7.js → task-B8QfEVcu.js} +13 -13
  72. package/dist/{task-CgAOxod7.js.map → task-B8QfEVcu.js.map} +1 -1
  73. package/dist/{task-stream-rxR1IsdJ.js → task-stream-BRSWhbXQ.js} +6 -6
  74. package/dist/{task-stream-rxR1IsdJ.js.map → task-stream-BRSWhbXQ.js.map} +1 -1
  75. package/dist/{tasks-lzvWF__k.js → tasks-DjEvyWQJ.js} +2 -2
  76. package/dist/{tasks-lzvWF__k.js.map → tasks-DjEvyWQJ.js.map} +1 -1
  77. package/dist/{telemetry-CickTk_7.js → telemetry-EPB2n_f6.js} +3 -3
  78. package/dist/{telemetry-CickTk_7.js.map → telemetry-EPB2n_f6.js.map} +1 -1
  79. package/dist/{terminal-BjUFxn_x.js → terminal-DJ4Gaupr.js} +107 -61
  80. package/dist/terminal-DJ4Gaupr.js.map +1 -0
  81. package/dist/{tools-MKXGXFSk.js → tools-CB0Vfc6r.js} +6 -6
  82. package/dist/{tools-MKXGXFSk.js.map → tools-CB0Vfc6r.js.map} +1 -1
  83. package/dist/{wizard-abort-CW_C2EXr.js → wizard-abort-DD-kkQaq.js} +1 -1
  84. package/dist/{wizard-abort-CooWEh9N.js → wizard-abort-Db_YNkB2.js} +5 -5
  85. package/dist/{wizard-abort-CooWEh9N.js.map → wizard-abort-Db_YNkB2.js.map} +1 -1
  86. package/dist/{wizard-session-gbYCXdBf.js → wizard-session-BWAQoi9q.js} +1 -1
  87. package/dist/{wizard-session-Bki7dQhv.js → wizard-session-GdDN_aMS.js} +4 -1
  88. package/dist/wizard-session-GdDN_aMS.js.map +1 -0
  89. package/dist/{yara-hooks-BpngckdZ.js → yara-hooks-BvyFD2Nb.js} +4 -4
  90. package/dist/{yara-hooks-BpngckdZ.js.map → yara-hooks-BvyFD2Nb.js.map} +1 -1
  91. package/dist/yara-hooks-CuW_b30M.js +2 -0
  92. package/package.json +2 -1
  93. package/dist/agent-interface-Lu7tnLr0.js.map +0 -1
  94. package/dist/agent-runner-vKtpgqVI.js.map +0 -1
  95. package/dist/analytics-D-bMEYjD.js +0 -2
  96. package/dist/debug-BM0fZaGl.js.map +0 -1
  97. package/dist/errors-BSdz2lsl.js.map +0 -1
  98. package/dist/mcp-prompt-streaming-Dsos09hT.js.map +0 -1
  99. package/dist/orchestrator-tools-ezFTbAIp.js.map +0 -1
  100. package/dist/pi-DzQLHIcQ.js.map +0 -1
  101. package/dist/playground-DLN31BPV.js.map +0 -1
  102. package/dist/posthog-integration-MDfRO911.js +0 -4618
  103. package/dist/posthog-integration-MDfRO911.js.map +0 -1
  104. package/dist/provisioning-Di5GNV9k.js.map +0 -1
  105. package/dist/queue-tools-KosDptd6.js.map +0 -1
  106. package/dist/setup-utils-Bo3WZt3a.js.map +0 -1
  107. package/dist/start-tui-B1LrB7k1.js.map +0 -1
  108. package/dist/store-DhNTBWQR.js.map +0 -1
  109. package/dist/terminal-BjUFxn_x.js.map +0 -1
  110. package/dist/wizard-session-Bki7dQhv.js.map +0 -1
  111. package/dist/yara-hooks-C-qG6EJt.js +0 -2
@@ -1,22 +1,24 @@
1
- import { l as ErrorCodes } from "./errors-BSdz2lsl.js";
2
- import { $ as REMOTE_SKILLS_BASE_URL, K as POSTHOG_ORG_AI_SETTINGS_URL, L as Integration, R as OAUTH_PORTS, U as POSTHOG_DOCS_URL, Z as POSTHOG_TERMS_URL, d as relativeToInstallDir, g as SIGNUP_WIZARD_READINESS_CONFIG, l as WIZARD_LOG_FILE, p as setUI, q as POSTHOG_PRIVACY_URL, s as logToFile, v as getBlockingServiceKeys, z as OAUTH_TIMEOUT_MS } from "./debug-BM0fZaGl.js";
3
- import { t as ADDITIONAL_FEATURE_LABELS } from "./wizard-session-Bki7dQhv.js";
4
- import { n as analytics } from "./analytics-DTyJClPr.js";
5
- import { i as readProjectFile, t as IGNORED_DIRS } from "./bounded-fs-BWX25ixc.js";
6
- import { o as extractOAuthCode, t as getOrAskForProjectData } from "./setup-utils-Bo3WZt3a.js";
7
- import { t as ApiError } from "./api-j-OfJ8Dz.js";
8
- import { i as wizardAbort } from "./wizard-abort-CooWEh9N.js";
9
- import { a as formatCostUsd, o as formatTokenCount } from "./agent-runner-vKtpgqVI.js";
10
- import { O as downloadSkill, k as fetchSkillMenu } from "./agent-interface-Lu7tnLr0.js";
11
- import { _ as AUDIT_CHECKS_KEY, b as coerceAuditChecks, g as AUDIT_CHECKS_FILE, x as getAuditChecks, y as AUDIT_SEVERITY_STYLE } from "./yara-hooks-BpngckdZ.js";
12
- import { t as FRAMEWORK_REGISTRY } from "./registry-BBdaIFWq.js";
13
- import { T as detectProjectsWithAgent, h as Icons, m as Colors, t as SETUP_REPORT_FILE, x as getDetectedWarehouseSources } from "./posthog-integration-MDfRO911.js";
14
- import { A as STRIPE_SDKS, C as MANUAL_SDK_VARIANTS, D as fetchHealthIssues, O as getContentBlocks, S as MANUAL_SDK_INSTALL, T as SOURCE_MAPS_CONTEXT_KEYS, _ as detectSelfDrivingIntegrationProjects, a as useStdoutDimensions, b as DISPLAY_NAME, f as Program, g as PRICING_SHORT, h as PRICING_LONG, k as POSTHOG_SDKS, m as NO_DEFAULT_LIMIT, n as useKeyBindings, p as getProgramConfig, t as PickerMenu, v as SELF_DRIVING_INTEGRATE_PATH_KEY, y as AUTOMATABLE_VARIANTS } from "./bin.js";
15
- import { r as totalTokenCount, t as WizardStore } from "./store-DhNTBWQR.js";
16
- import { A as EventPlanViewer, C as VisualizerTab, D as HNViewer, F as ConfirmationInput, L as ProgressList, M as LinkText, N as extractUrls, O as TabContainer, P as ModalOverlay, R as LoadingBox, S as ServiceHealthList, T as LearnCard, a as useSkillEntry, b as SEVERITY_LABEL, c as SlackConnectScreen, d as AuditChecksViewer, f as seedDemoEvents, g as probeProjectData, i as SkillSourceInfo, j as LogViewer, k as ScreenContainer, l as AUDIT_AREA_SLIDES, m as McpSuggestedPromptsScreen, n as releaseTerminal, o as OutroScreen, r as AiOptInRequiredScreen, s as useDismissOnAnyKey, t as enterDarkTerminal, u as VisualBox, v as McpScreen, w as TipsCard, x as SEVERITY_ORDER, y as IssueTable, z as SplitView } from "./terminal-BjUFxn_x.js";
1
+ import { l as ErrorCodes } from "./errors-u8z27V-x.js";
2
+ import { $ as REMOTE_SKILLS_BASE_URL, K as POSTHOG_ORG_AI_SETTINGS_URL, L as Integration, R as OAUTH_PORTS, U as POSTHOG_DOCS_URL, Z as POSTHOG_TERMS_URL, d as relativeToInstallDir, g as SIGNUP_WIZARD_READINESS_CONFIG, l as WIZARD_LOG_FILE, p as setUI, q as POSTHOG_PRIVACY_URL, s as logToFile, v as getBlockingServiceKeys, z as OAUTH_TIMEOUT_MS } from "./debug-D0T44879.js";
3
+ import { t as ADDITIONAL_FEATURE_LABELS } from "./wizard-session-GdDN_aMS.js";
4
+ import { n as analytics } from "./analytics-DjCPD6u-.js";
5
+ import { n as openTrackedLink } from "./telemetry-EPB2n_f6.js";
6
+ import { i as readProjectFile, t as IGNORED_DIRS } from "./bounded-fs-BtxN0nYO.js";
7
+ import { o as extractOAuthCode, t as getOrAskForProjectData } from "./setup-utils-CnW0Zsu8.js";
8
+ import { c as getIntegrationAuthorizeUrl, i as requestDeepLink } from "./provisioning-Dw3B2T_b.js";
9
+ import { r as fetchGithubConnected, t as ApiError } from "./api-xwQeBMcX.js";
10
+ import { i as wizardAbort } from "./wizard-abort-Db_YNkB2.js";
11
+ import { M as downloadSkill, N as fetchSkillMenu } from "./agent-interface-Yjknz6Al.js";
12
+ import { a as formatCostUsd, f as getDetectedWarehouseSources, m as detectProjectsWithAgent, o as formatTokenCount } from "./agent-runner-CL7rCY0G.js";
13
+ import { t as FRAMEWORK_REGISTRY } from "./registry-Dv6JVm5r.js";
14
+ import { _ as AUDIT_CHECKS_KEY, b as coerceAuditChecks, g as AUDIT_CHECKS_FILE, x as getAuditChecks, y as AUDIT_SEVERITY_STYLE } from "./yara-hooks-BvyFD2Nb.js";
15
+ import { h as Icons, m as Colors, t as SETUP_REPORT_FILE } from "./posthog-integration-BQh-YQAP.js";
16
+ import { A as getContentBlocks, D as SOURCE_MAPS_CONTEXT_KEYS, M as STRIPE_SDKS, S as DISPLAY_NAME, T as MANUAL_SDK_VARIANTS, _ as detectSelfDrivingIntegrationProjects, a as useStdoutDimensions, b as SELF_DRIVING_INTEGRATE_PATH_KEY, f as Program, g as PRICING_SHORT, h as PRICING_LONG, j as POSTHOG_SDKS, k as fetchHealthIssues, m as NO_DEFAULT_LIMIT, n as useKeyBindings, p as getProgramConfig, t as PickerMenu, v as GITHUB_REQUIRED_BODY, w as MANUAL_SDK_INSTALL, x as AUTOMATABLE_VARIANTS, y as GITHUB_REQUIRED_MESSAGE } from "./bin.js";
17
+ import { r as totalTokenCount, t as WizardStore } from "./store-Cmy0pN1R.js";
18
+ import { B as SplitView, C as VisualizerTab, D as HNViewer, F as ModalOverlay, I as ConfirmationInput, M as LogViewer, N as LinkText, O as TabContainer, P as extractUrls, R as ProgressList, S as ServiceHealthList, T as LearnCard, a as useSkillEntry, b as SEVERITY_LABEL, c as SlackConnectScreen, d as AuditChecksViewer, f as seedDemoEvents, g as probeProjectData, i as SkillSourceInfo, j as EventPlanViewer, k as ScreenContainer, l as AUDIT_AREA_SLIDES, m as McpSuggestedPromptsScreen, n as releaseTerminal, o as OutroScreen, r as AiOptInRequiredScreen, s as useDismissOnAnyKey, t as enterDarkTerminal, u as VisualBox, v as McpScreen, w as TipsCard, x as SEVERITY_ORDER, y as IssueTable, z as LoadingBox } from "./terminal-DJ4Gaupr.js";
17
19
  import { c as namesWithStatus, d as toClientResult, l as redactSecrets, t as ALL_FEATURE_VALUES } from "./defaults-DI642M3n.js";
18
- import { t as startFileWatcher } from "./file-watcher-D7G4f5sP.js";
19
- import { a as getSupportedClients, c as removeMCPServer, i as getInstalledClients, o as getSupportedPluginClients, s as installPlugins, u as isPluginCapable } from "./add-mcp-server-to-clients-BCnjUqnW.js";
20
+ import { t as startFileWatcher } from "./file-watcher-BPH4wR8R.js";
21
+ import { a as getSupportedClients, c as removeMCPServer, i as getInstalledClients, o as getSupportedPluginClients, s as installPlugins, u as isPluginCapable } from "./add-mcp-server-to-clients-QZyr6NuZ.js";
20
22
  import { existsSync, readFileSync, readdirSync } from "fs";
21
23
  import path, { join } from "path";
22
24
  import { join as join$1 } from "node:path";
@@ -67,6 +69,9 @@ var InkUI = class {
67
69
  setCredentials(credentials) {
68
70
  this.store.setCredentials(credentials);
69
71
  }
72
+ setAccessToken(credentials) {
73
+ this.store.setAccessToken(credentials);
74
+ }
70
75
  setRoleAtOrganization(role) {
71
76
  this.store.setRoleAtOrganization(role);
72
77
  }
@@ -1288,7 +1293,7 @@ const FrameworkPicker = ({ store, onComplete }) => {
1288
1293
  })),
1289
1294
  onSelect: (value) => {
1290
1295
  const integration = Array.isArray(value) ? value[0] : value;
1291
- import("./registry-BBdaIFWq.js").then((n) => n.n).then(({ FRAMEWORK_REGISTRY }) => {
1296
+ import("./registry-Dv6JVm5r.js").then((n) => n.n).then(({ FRAMEWORK_REGISTRY }) => {
1292
1297
  const config = FRAMEWORK_REGISTRY[integration];
1293
1298
  store.setFrameworkConfig(integration, config);
1294
1299
  store.setDetectedFramework(config.metadata.name);
@@ -3432,7 +3437,7 @@ const SelfDrivingIntegrationDetectScreen = ({ store }) => {
3432
3437
  /* @__PURE__ */ jsx(Text, {
3433
3438
  bold: true,
3434
3439
  color: Colors.accent,
3435
- children: "Detecting your project..."
3440
+ children: "Detecting your project. Stick around, this will take a few seconds..."
3436
3441
  }),
3437
3442
  /* @__PURE__ */ jsx(Box, {
3438
3443
  marginY: 1,
@@ -3695,6 +3700,222 @@ const SelfDrivingHandoffScreen = ({ store }) => {
3695
3700
  });
3696
3701
  };
3697
3702
  //#endregion
3703
+ //#region src/ui/tui/hooks/useGithubConnection.ts
3704
+ /**
3705
+ * Polls `/integrations/` until the PostHog GitHub App shows up, writing the
3706
+ * result to the session so the Self-driving GitHub gate can advance.
3707
+ *
3708
+ * Installing the App is a manual browser step, so polling is what flips the
3709
+ * gate once the user comes back. The first tick also resolves the session's
3710
+ * unknown (`null`) state.
3711
+ */
3712
+ const POLL_INTERVAL_MS = 3e3;
3713
+ async function fetchLoginUrl(session) {
3714
+ if (!session.signup || !session.credentials) return null;
3715
+ return await requestDeepLink(session.credentials.accessToken, session.credentials.host) ?? `${session.credentials.host.appHost}/login`;
3716
+ }
3717
+ function useGithubConnection(store) {
3718
+ const credentials = store.session.credentials;
3719
+ const connected = store.session.githubConnected === true;
3720
+ useEffect(() => {
3721
+ if (!credentials || connected) return;
3722
+ const controller = new AbortController();
3723
+ let stopped = false;
3724
+ let timer;
3725
+ let errorReported = false;
3726
+ /** A check that came back "not connected" — including a failed one. */
3727
+ const settleUnknown = () => {
3728
+ if (store.session.githubConnected === null) store.setGithubConnected(false);
3729
+ };
3730
+ const wait = () => new Promise((resolve) => {
3731
+ timer = setTimeout(resolve, POLL_INTERVAL_MS);
3732
+ });
3733
+ (async () => {
3734
+ while (!stopped) {
3735
+ try {
3736
+ const isConnected = await fetchGithubConnected(credentials.accessToken, credentials.projectId, credentials.host.apiHost, controller.signal);
3737
+ if (stopped) return;
3738
+ if (isConnected) {
3739
+ if (store.session.githubConnected === false) analytics.wizardCapture("github connect completed");
3740
+ store.setGithubConnected(true);
3741
+ return;
3742
+ }
3743
+ settleUnknown();
3744
+ } catch (err) {
3745
+ if (stopped) return;
3746
+ if (!errorReported) {
3747
+ errorReported = true;
3748
+ analytics.captureException(err instanceof Error ? err : new Error(String(err)), { step: "github_connected_check" });
3749
+ }
3750
+ settleUnknown();
3751
+ }
3752
+ await wait();
3753
+ }
3754
+ })();
3755
+ return () => {
3756
+ stopped = true;
3757
+ if (timer) clearTimeout(timer);
3758
+ controller.abort();
3759
+ };
3760
+ }, [
3761
+ credentials,
3762
+ connected,
3763
+ store
3764
+ ]);
3765
+ }
3766
+ //#endregion
3767
+ //#region src/ui/tui/screens/SelfDrivingGitHubScreen.tsx
3768
+ /**
3769
+ * SelfDrivingGitHubScreen — the "Connect GitHub" gate, shown after the handoff
3770
+ * and before the Self-driving run.
3771
+ *
3772
+ * Self-driving cannot research findings or open fixes without code access, so
3773
+ * the GitHub App is a hard requirement. The agent used to ask for it mid-run
3774
+ * via `wizard_ask` and abort when the answer came back declined — but a
3775
+ * `wizard_ask` timeout resolves to the same cancelled value as a real decline,
3776
+ * so a user who stepped away had their run killed as if they had refused.
3777
+ * Gating here instead makes the requirement cheap (no agent has started),
3778
+ * unambiguous (declining is an explicit pick), and un-timeoutable (the screen
3779
+ * waits as long as the browser install takes).
3780
+ *
3781
+ * Unlike SlackConnectScreen this is not skippable: declining ends the run on
3782
+ * the outro rather than continuing without it. The connection poll lives in
3783
+ * {@link useGithubConnection}.
3784
+ */
3785
+ const SelfDrivingGitHubScreen = ({ store }) => {
3786
+ useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
3787
+ const credentials = store.session.credentials;
3788
+ const connectedState = store.session.githubConnected;
3789
+ const connected = connectedState === true;
3790
+ const authorizeUrl = credentials ? getIntegrationAuthorizeUrl(credentials.host.appHost, credentials.projectId, "github") : null;
3791
+ useGithubConnection(store);
3792
+ const [installOpened, setInstallOpened] = useState(false);
3793
+ const [loginUrl, setLoginUrl] = useState(null);
3794
+ const loginUrlRequested = useRef(false);
3795
+ useEffect(() => {
3796
+ if (loginUrlRequested.current) return;
3797
+ loginUrlRequested.current = true;
3798
+ fetchLoginUrl(store.session).then(setLoginUrl);
3799
+ }, [store]);
3800
+ const impressionFired = useRef(false);
3801
+ useEffect(() => {
3802
+ if (connectedState === null || impressionFired.current) return;
3803
+ impressionFired.current = true;
3804
+ analytics.wizardCapture("github connect shown", { already_connected: connected });
3805
+ }, [connectedState, connected]);
3806
+ const openInstall = () => {
3807
+ if (!authorizeUrl) return;
3808
+ analytics.wizardCapture("github connect opened");
3809
+ openTrackedLink(authorizeUrl, "self-driving-github-connect");
3810
+ setInstallOpened(true);
3811
+ };
3812
+ const decline = () => {
3813
+ analytics.wizardCapture("github connect declined", { install_opened: installOpened });
3814
+ store.declineGithub({
3815
+ kind: "cancel",
3816
+ message: GITHUB_REQUIRED_MESSAGE,
3817
+ body: GITHUB_REQUIRED_BODY
3818
+ });
3819
+ };
3820
+ const handleSelect = (value) => {
3821
+ if ((Array.isArray(value) ? value[0] : value) === "open") openInstall();
3822
+ else decline();
3823
+ };
3824
+ useKeyBindings("self-driving-github", [{
3825
+ match: "escape",
3826
+ label: "esc",
3827
+ action: connected ? "continue" : "end setup",
3828
+ handler: () => {
3829
+ if (!connected) decline();
3830
+ }
3831
+ }]);
3832
+ if (credentials && connectedState === null) return /* @__PURE__ */ jsx(Box, {
3833
+ flexDirection: "column",
3834
+ flexGrow: 1,
3835
+ marginTop: 1,
3836
+ children: /* @__PURE__ */ jsx(LoadingBox, { message: "Checking for an existing GitHub connection..." })
3837
+ });
3838
+ if (connected) return /* @__PURE__ */ jsxs(Box, {
3839
+ flexDirection: "column",
3840
+ flexGrow: 1,
3841
+ marginTop: 1,
3842
+ children: [
3843
+ /* @__PURE__ */ jsxs(Text, {
3844
+ bold: true,
3845
+ color: Colors.success,
3846
+ children: [Icons.check, " GitHub connected"]
3847
+ }),
3848
+ /* @__PURE__ */ jsx(Box, {
3849
+ marginTop: 1,
3850
+ children: /* @__PURE__ */ jsx(Text, { children: "Self-driving can research findings in your code and open fixes." })
3851
+ }),
3852
+ /* @__PURE__ */ jsx(Box, {
3853
+ marginTop: 1,
3854
+ children: /* @__PURE__ */ jsx(LoadingBox, { message: "Starting Self-driving setup..." })
3855
+ })
3856
+ ]
3857
+ });
3858
+ return /* @__PURE__ */ jsx(Box, {
3859
+ flexDirection: "column",
3860
+ flexGrow: 1,
3861
+ children: /* @__PURE__ */ jsxs(Box, {
3862
+ marginTop: 1,
3863
+ flexDirection: "column",
3864
+ children: [
3865
+ /* @__PURE__ */ jsx(Text, {
3866
+ bold: true,
3867
+ color: Colors.accent,
3868
+ children: installOpened ? "Finish connecting GitHub" : "Connect GitHub"
3869
+ }),
3870
+ /* @__PURE__ */ jsx(Box, {
3871
+ marginTop: 1,
3872
+ children: /* @__PURE__ */ jsx(Text, { children: installOpened ? "We've opened the PostHog GitHub App install in your browser. Approve access there — we'll detect it automatically and continue." : "Self-driving needs GitHub access to research findings in your code and open fixes, so setup cannot finish without it." })
3873
+ }),
3874
+ !installOpened && /* @__PURE__ */ jsx(Box, {
3875
+ marginTop: 1,
3876
+ children: /* @__PURE__ */ jsxs(Text, { children: [/* @__PURE__ */ jsxs(Text, {
3877
+ color: "cyan",
3878
+ children: [Icons.diamond, " "]
3879
+ }), "Grant it the repos you want Self-driving to work with — include this project's repo so it can also watch its issues."] })
3880
+ }),
3881
+ loginUrl && /* @__PURE__ */ jsx(Box, {
3882
+ marginTop: 1,
3883
+ children: /* @__PURE__ */ jsxs(Text, {
3884
+ dimColor: true,
3885
+ children: ["Log in to your new account first: ", /* @__PURE__ */ jsx(Text, {
3886
+ color: "cyan",
3887
+ children: loginUrl
3888
+ })]
3889
+ })
3890
+ }),
3891
+ authorizeUrl && /* @__PURE__ */ jsx(Box, {
3892
+ marginTop: 1,
3893
+ children: /* @__PURE__ */ jsxs(Text, {
3894
+ dimColor: true,
3895
+ children: [installOpened ? "Install page: " : "Install it: ", /* @__PURE__ */ jsx(Text, {
3896
+ color: "cyan",
3897
+ children: authorizeUrl
3898
+ })]
3899
+ })
3900
+ }),
3901
+ /* @__PURE__ */ jsx(Box, {
3902
+ marginTop: 1,
3903
+ children: /* @__PURE__ */ jsx(PickerMenu, {
3904
+ options: [{
3905
+ label: installOpened ? "Re-open GitHub App install" : "Open GitHub App install",
3906
+ value: "open"
3907
+ }, {
3908
+ label: "I can't connect right now",
3909
+ value: "decline"
3910
+ }],
3911
+ onSelect: handleSelect
3912
+ })
3913
+ })
3914
+ ]
3915
+ })
3916
+ });
3917
+ };
3918
+ //#endregion
3698
3919
  //#region src/ui/tui/screens/audit/AuditIntroScreen.tsx
3699
3920
  const AuditIntroScreen = ({ store }) => {
3700
3921
  useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
@@ -5227,7 +5448,10 @@ const ExitScreen = () => {
5227
5448
  /**
5228
5449
  * AuthErrorScreen — Shown when the PostHog LLM Gateway returns a 401.
5229
5450
  *
5230
- * Two distinct causes:
5451
+ * Distinct causes, most specific first:
5452
+ * 0. The OAuth grant is gone — a pre-run refresh already got `invalid_grant`
5453
+ * from the token endpoint. The only branch backed by a server verdict
5454
+ * rather than inference, so it wins; re-running is the whole fix.
5231
5455
  * 1. Claude Code settings.json / managed-settings overrides ANTHROPIC_*
5232
5456
  * env vars — auth conflict. Tell the user to log out of Claude Code.
5233
5457
  * 2. The PostHog API key itself was rejected — bad prefix, missing scope,
@@ -5241,6 +5465,7 @@ const AuthErrorScreen = ({ store }) => {
5241
5465
  const conflicts = detail?.conflicts ?? [];
5242
5466
  const usingManagedLogin = detail?.usingManagedLogin ?? false;
5243
5467
  const credentialPlaces = detail?.credentialPlaces ?? [];
5468
+ const sessionExpired = detail?.sessionExpired ?? false;
5244
5469
  const logFilePath = detail?.logFilePath;
5245
5470
  return /* @__PURE__ */ jsxs(Box, {
5246
5471
  flexDirection: "column",
@@ -5251,7 +5476,36 @@ const AuthErrorScreen = ({ store }) => {
5251
5476
  bold: true,
5252
5477
  children: ["✘", " Authentication error"]
5253
5478
  }),
5254
- usingManagedLogin ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
5479
+ sessionExpired ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
5480
+ /* @__PURE__ */ jsx(Box, {
5481
+ flexDirection: "column",
5482
+ marginTop: 1,
5483
+ children: /* @__PURE__ */ jsx(Text, { children: "Your PostHog login expired while the wizard was running, so the LLM Gateway rejected it (401). Nothing on this machine is misconfigured — the session simply ran out." })
5484
+ }),
5485
+ /* @__PURE__ */ jsx(Box, {
5486
+ marginTop: 1,
5487
+ children: /* @__PURE__ */ jsx(Text, {
5488
+ dimColor: true,
5489
+ children: "Re-run the wizard and log in again:"
5490
+ })
5491
+ }),
5492
+ /* @__PURE__ */ jsx(Box, {
5493
+ flexDirection: "column",
5494
+ marginTop: 1,
5495
+ paddingLeft: 2,
5496
+ children: /* @__PURE__ */ jsx(Text, {
5497
+ color: "cyan",
5498
+ children: "npx @posthog/wizard"
5499
+ })
5500
+ }),
5501
+ /* @__PURE__ */ jsx(Box, {
5502
+ marginTop: 1,
5503
+ children: /* @__PURE__ */ jsx(Text, {
5504
+ dimColor: true,
5505
+ children: "Any files the agent already wrote are still in your project."
5506
+ })
5507
+ })
5508
+ ] }) : usingManagedLogin ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
5255
5509
  /* @__PURE__ */ jsx(Box, {
5256
5510
  flexDirection: "column",
5257
5511
  marginTop: 1,
@@ -5794,7 +6048,7 @@ function createMcpSuggestedPromptsServices(store) {
5794
6048
  };
5795
6049
  }
5796
6050
  async function* runProductionPromptStreaming(args) {
5797
- const { runMcpPromptViaSdk } = await import("./mcp-prompt-streaming-Dsos09hT.js");
6051
+ const { runMcpPromptViaSdk } = await import("./mcp-prompt-streaming-pPEIwc78.js");
5798
6052
  yield* runMcpPromptViaSdk(args);
5799
6053
  }
5800
6054
  //#endregion
@@ -5829,6 +6083,7 @@ function createScreens(store, services) {
5829
6083
  ["self-driving-integration-check"]: /* @__PURE__ */ jsx(SelfDrivingIntegrationCheckScreen, { store }),
5830
6084
  ["self-driving-integration-detect"]: /* @__PURE__ */ jsx(SelfDrivingIntegrationDetectScreen, { store }),
5831
6085
  ["self-driving-handoff"]: /* @__PURE__ */ jsx(SelfDrivingHandoffScreen, { store }),
6086
+ ["self-driving-github"]: /* @__PURE__ */ jsx(SelfDrivingGitHubScreen, { store }),
5832
6087
  ["audit-intro"]: /* @__PURE__ */ jsx(AuditIntroScreen, { store }),
5833
6088
  ["audit-run"]: /* @__PURE__ */ jsx(AuditRunScreen, { store }),
5834
6089
  ["audit-outro"]: /* @__PURE__ */ jsx(AuditOutroScreen, { store }),
@@ -5987,4 +6242,4 @@ function startTUI(version, program = Program.PostHogIntegration) {
5987
6242
  //#endregion
5988
6243
  export { startTUI };
5989
6244
 
5990
- //# sourceMappingURL=start-tui-B1LrB7k1.js.map
6245
+ //# sourceMappingURL=start-tui-SpyGz7wM.js.map