@posthog/wizard 2.25.0 → 2.26.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 (60) hide show
  1. package/dist/{add-mcp-server-to-clients-t0xe8gn1.js → add-mcp-server-to-clients-C58l_KpV.js} +4 -4
  2. package/dist/{add-mcp-server-to-clients-t0xe8gn1.js.map → add-mcp-server-to-clients-C58l_KpV.js.map} +1 -1
  3. package/dist/{agent-interface-BsuUUPle.js → agent-interface-Dq_4h2eN.js} +39 -12
  4. package/dist/agent-interface-Dq_4h2eN.js.map +1 -0
  5. package/dist/{agent-runner-L_-kJ3y3.js → agent-runner-BNGW3osc.js} +176 -167
  6. package/dist/agent-runner-BNGW3osc.js.map +1 -0
  7. package/dist/{analytics-CDOujOSQ.js → analytics-BX3LKPch.js} +2 -2
  8. package/dist/{analytics-CDOujOSQ.js.map → analytics-BX3LKPch.js.map} +1 -1
  9. package/dist/{api-DNS-L-1U.js → api-DCHci5SD.js} +9 -5
  10. package/dist/api-DCHci5SD.js.map +1 -0
  11. package/dist/bin.js +583 -119
  12. package/dist/bin.js.map +1 -1
  13. package/dist/{ci-install-_9A7tL36.js → ci-install-CHIbwXio.js} +5 -5
  14. package/dist/{ci-install-_9A7tL36.js.map → ci-install-CHIbwXio.js.map} +1 -1
  15. package/dist/{debug-BwC7UkGH.js → debug-BizeRFR0.js} +3 -2
  16. package/dist/{debug-BwC7UkGH.js.map → debug-BizeRFR0.js.map} +1 -1
  17. package/dist/{debug-CZQcMAJT.js → debug-fg4BAKKA.js} +1 -1
  18. package/dist/{environment-DQPoj9sU.js → environment-DS5Pq9Wm.js} +3 -3
  19. package/dist/{environment-DQPoj9sU.js.map → environment-DS5Pq9Wm.js.map} +1 -1
  20. package/dist/{interactive-DT5dLd7N.js → interactive-DE3WDjk7.js} +3 -3
  21. package/dist/{interactive-DT5dLd7N.js.map → interactive-DE3WDjk7.js.map} +1 -1
  22. package/dist/{mcp-prompt-streaming-CBMr458Q.js → mcp-prompt-streaming-zsYd1zJx.js} +4 -4
  23. package/dist/{mcp-prompt-streaming-CBMr458Q.js.map → mcp-prompt-streaming-zsYd1zJx.js.map} +1 -1
  24. package/dist/{non-interactive-csP4yGdA.js → non-interactive-DNah9u3t.js} +2 -2
  25. package/dist/{non-interactive-csP4yGdA.js.map → non-interactive-DNah9u3t.js.map} +1 -1
  26. package/dist/{package-manager-CB4c2euf.js → package-manager-Dma9-zGs.js} +2 -2
  27. package/dist/{package-manager-CB4c2euf.js.map → package-manager-Dma9-zGs.js.map} +1 -1
  28. package/dist/{playground-C-lpKoKC.js → playground-Cwe0Q9HW.js} +145 -48
  29. package/dist/playground-Cwe0Q9HW.js.map +1 -0
  30. package/dist/{posthog-integration-BL8-vC0V.js → posthog-integration-CAYZdk0r.js} +11 -11
  31. package/dist/{posthog-integration-BL8-vC0V.js.map → posthog-integration-CAYZdk0r.js.map} +1 -1
  32. package/dist/{provisioning-DLOiFSM9.js → provisioning-BmL4ro-o.js} +10 -6
  33. package/dist/{provisioning-DLOiFSM9.js.map → provisioning-BmL4ro-o.js.map} +1 -1
  34. package/dist/{registry-BbRzCV5l.js → registry-C3wcDM3X.js} +4 -4
  35. package/dist/{registry-BbRzCV5l.js.map → registry-C3wcDM3X.js.map} +1 -1
  36. package/dist/{setup-utils-D87CyNkw.js → setup-utils-CNWIMZ-d.js} +71 -16
  37. package/dist/setup-utils-CNWIMZ-d.js.map +1 -0
  38. package/dist/{start-tui-DnAG57vY.js → start-tui-CS802Ww9.js} +311 -54
  39. package/dist/start-tui-CS802Ww9.js.map +1 -0
  40. package/dist/{steps-JaxH6u0f.js → steps-BX44xr30.js} +6 -6
  41. package/dist/{steps-JaxH6u0f.js.map → steps-BX44xr30.js.map} +1 -1
  42. package/dist/{telemetry-DL28cCwY.js → telemetry-BH-MgWPT.js} +3 -3
  43. package/dist/{telemetry-DL28cCwY.js.map → telemetry-BH-MgWPT.js.map} +1 -1
  44. package/dist/{AiOptInRequiredScreen-C-D9tN6r.js → terminal-BSiupnOQ.js} +1047 -85
  45. package/dist/terminal-BSiupnOQ.js.map +1 -0
  46. package/dist/{urls-vkJ5c0ix.js → urls-BuEABcmF.js} +2 -2
  47. package/dist/{urls-vkJ5c0ix.js.map → urls-BuEABcmF.js.map} +1 -1
  48. package/dist/{wizard-abort-BRXKRL4F.js → wizard-abort-CR3w2Efg.js} +1 -1
  49. package/dist/{wizard-abort-CLGgMAEe.js → wizard-abort-Dl2MJOP9.js} +3 -3
  50. package/dist/{wizard-abort-CLGgMAEe.js.map → wizard-abort-Dl2MJOP9.js.map} +1 -1
  51. package/dist/wizard-session-G3VWD6hv.js.map +1 -1
  52. package/dist/wizard-ui-WZ48rUgr.js.map +1 -1
  53. package/package.json +1 -1
  54. package/dist/AiOptInRequiredScreen-C-D9tN6r.js.map +0 -1
  55. package/dist/agent-interface-BsuUUPle.js.map +0 -1
  56. package/dist/agent-runner-L_-kJ3y3.js.map +0 -1
  57. package/dist/api-DNS-L-1U.js.map +0 -1
  58. package/dist/playground-C-lpKoKC.js.map +0 -1
  59. package/dist/setup-utils-D87CyNkw.js.map +0 -1
  60. package/dist/start-tui-DnAG57vY.js.map +0 -1
@@ -1,16 +1,16 @@
1
- import { $ as getSkillsBaseUrl, _ as SIGNUP_WIZARD_READINESS_CONFIG, a as getLogFilePath, c as WIZARD_BENCHMARK_FILE, g as SERVICE_LABELS, i as enableDebugLogs, l as WIZARD_LOG_FILE, nt as runtimeEnv, o as initLogFile, p as getUI, s as logToFile, t as configureLogFile, v as evaluateWizardReadiness, y as getBlockingServiceKeys } from "./debug-BwC7UkGH.js";
2
- import { i as ciExcludedTaskTypes, n as groupsFromUser, t as analytics } from "./analytics-CDOujOSQ.js";
3
- import { t as getOrAskForProjectData } from "./setup-utils-D87CyNkw.js";
4
- import { n as getCloudUrlFromRegion } from "./urls-vkJ5c0ix.js";
5
- import { i as wizardAbort, n as registerCleanup, t as WizardError } from "./wizard-abort-CLGgMAEe.js";
6
- import { n as isNonInteractiveEnvironment } from "./environment-DQPoj9sU.js";
7
- import { _ as QUEUE_DIR_NAME, a as runAgent$1, d as formatScanReport, f as writeScanReport, g as installSkillById, h as fetchSkillMenu, i as isOrchestratorEnabled, l as restoreClaudeSettings, n as buildWizardMetadata, o as backupAndFixClaudeSettings, r as initializeAgent, s as checkAllSettingsConflicts, u as AgentSignals, v as QueueStore, y as TaskStatus } from "./agent-interface-BsuUUPle.js";
8
- import { r as detectNodePackageManagers } from "./package-manager-CB4c2euf.js";
1
+ import { $ as getSkillsBaseUrl, _ as SIGNUP_WIZARD_READINESS_CONFIG, a as getLogFilePath, c as WIZARD_BENCHMARK_FILE, g as SERVICE_LABELS, i as enableDebugLogs, l as WIZARD_LOG_FILE, nt as runtimeEnv, o as initLogFile, p as getUI, s as logToFile, t as configureLogFile, v as evaluateWizardReadiness, y as getBlockingServiceKeys } from "./debug-BizeRFR0.js";
2
+ import { i as ciExcludedTaskTypes, n as groupsFromUser, t as analytics } from "./analytics-BX3LKPch.js";
3
+ import { t as getOrAskForProjectData } from "./setup-utils-CNWIMZ-d.js";
4
+ import { n as getCloudUrlFromRegion } from "./urls-BuEABcmF.js";
5
+ import { i as wizardAbort, n as registerCleanup, t as WizardError } from "./wizard-abort-Dl2MJOP9.js";
6
+ import { n as isNonInteractiveEnvironment } from "./environment-DS5Pq9Wm.js";
7
+ import { _ as QUEUE_DIR_NAME, a as runAgent$1, d as formatScanReport, f as writeScanReport, g as installSkillById, h as fetchSkillMenu, i as isOrchestratorEnabled, l as restoreClaudeSettings, n as buildWizardMetadata, o as backupAndFixClaudeSettings, r as initializeAgent, s as checkAllSettingsConflicts, u as AgentSignals, v as QueueStore, y as TaskStatus } from "./agent-interface-Dq_4h2eN.js";
8
+ import { r as detectNodePackageManagers } from "./package-manager-Dma9-zGs.js";
9
9
  import fs, { existsSync, rmSync } from "fs";
10
10
  import * as path$1 from "path";
11
11
  import path from "path";
12
12
  import { randomUUID } from "crypto";
13
- //#region src/lib/programs/orchestrator/executor.ts
13
+ //#region src/lib/agent/runner/orchestrator/executor.ts
14
14
  /**
15
15
  * The executor drains the queue. It starts every runnable task (dependencies
16
16
  * satisfied) as soon as it becomes runnable — parallelism is decided by the
@@ -66,7 +66,7 @@ async function drainQueue(store, runTask, opts = DEFAULT_DRAIN_OPTIONS) {
66
66
  }
67
67
  }
68
68
  //#endregion
69
- //#region src/lib/programs/orchestrator/run-metrics.ts
69
+ //#region src/lib/agent/runner/orchestrator/run-metrics.ts
70
70
  var RunMetrics = class {
71
71
  firstStartMs;
72
72
  lastStartMs;
@@ -332,7 +332,7 @@ function taskModel(registry, task) {
332
332
  return task.model ?? registry.get(task.type)?.model ?? DEFAULT_TASK_MODEL;
333
333
  }
334
334
  //#endregion
335
- //#region src/lib/programs/orchestrator/orchestrator-runner.ts
335
+ //#region src/lib/agent/runner/orchestrator/orchestrator-runner.ts
336
336
  /**
337
337
  * Experimental task-queue orchestrator runner.
338
338
  *
@@ -578,6 +578,118 @@ async function runOrchestrator(session, programConfig, boot) {
578
578
  await analytics.shutdown("success");
579
579
  }
580
580
  //#endregion
581
+ //#region src/lib/agent/runner/shared/bootstrap.ts
582
+ /**
583
+ * Decide whether the `wizard_ask` overlay should be wired for this run.
584
+ * Disabled in non-interactive modes (CI, signup) — there's no human to
585
+ * answer. Per-program disabling is done by adding WIZARD_ASK_TOOL_NAME to
586
+ * the program's `disallowedTools` so the SDK rejects calls outright.
587
+ * Extracted so the policy can be unit-tested directly.
588
+ */
589
+ function shouldDisableAsk(session) {
590
+ return session.ci || session.signup;
591
+ }
592
+ function sessionToOptions(session) {
593
+ return {
594
+ installDir: session.installDir,
595
+ debug: session.debug,
596
+ default: false,
597
+ signup: session.signup,
598
+ localMcp: session.localMcp,
599
+ ci: session.ci,
600
+ benchmark: session.benchmark,
601
+ projectId: session.projectId,
602
+ apiKey: session.apiKey,
603
+ yaraReport: session.yaraReport
604
+ };
605
+ }
606
+ /**
607
+ * Shared setup for both arms: logging, health check, settings conflicts, OAuth
608
+ * and credentials, then the feature flags, variant metadata, and MCP url. Sets
609
+ * `session.credentials`, role, and user as a side effect. Returns the values the
610
+ * arms still need.
611
+ */
612
+ async function bootstrapProgram(session, config, programConfig) {
613
+ initLogFile();
614
+ session.skillId = config.skillId ?? config.integrationLabel;
615
+ logToFile(`[agent-runner] START ${config.integrationLabel}`);
616
+ if (session.debug) enableDebugLogs();
617
+ const skillsBaseUrl = getSkillsBaseUrl(session.localMcp);
618
+ const hasHealthCheckScreen = programConfig.steps.some((s) => s.screenId === "health-check");
619
+ if (session.readinessResult) logToFile(`[agent-runner] readiness pre-computed by TUI: decision=${session.readinessResult.decision}${session.outageDismissed ? " (outage dismissed by user)" : ""} — skipping re-check`);
620
+ if (hasHealthCheckScreen && !session.readinessResult) {
621
+ logToFile("[agent-runner] evaluating wizard readiness");
622
+ const readinessConfig = session.signup ? SIGNUP_WIZARD_READINESS_CONFIG : void 0;
623
+ const readiness = await evaluateWizardReadiness(readinessConfig);
624
+ logToFile(`[agent-runner] readiness=${readiness.decision}`);
625
+ if (readiness.decision === "no") {
626
+ const blockingLabels = getBlockingServiceKeys(readiness.health, readinessConfig).map((k) => `${SERVICE_LABELS[k]} (${readiness.health[k].status})`);
627
+ logToFile(`[agent-runner] blocked by: ${blockingLabels.join(", ")}`);
628
+ await getUI().showBlockingOutage(readiness);
629
+ if (!isNonInteractiveEnvironment()) await wizardAbort({ message: "Cannot start — external services are down:\n" + blockingLabels.map((l) => ` - ${l}`).join("\n") + "\n\nPlease try again later." });
630
+ } else if (readiness.decision === "yes_with_warnings") getUI().setReadinessWarnings(readiness);
631
+ }
632
+ const settingsConflicts = checkAllSettingsConflicts(session.installDir);
633
+ logToFile(`[agent-runner] settings conflicts: ${settingsConflicts.length > 0 ? settingsConflicts.map((c) => `${c.source}(${c.keys.join(",")})`).join("; ") : "none"}`);
634
+ if (settingsConflicts.length > 0) {
635
+ for (const conflict of settingsConflicts) {
636
+ const level = conflict.source === "managed" ? "org" : conflict.source;
637
+ analytics.wizardCapture("settings conflict detected", {
638
+ level,
639
+ keys: conflict.keys
640
+ });
641
+ }
642
+ await getUI().showSettingsOverride(settingsConflicts, () => backupAndFixClaudeSettings(session.installDir));
643
+ logToFile("[agent-runner] settings override resolved");
644
+ }
645
+ analytics.wizardCapture("agent started", {
646
+ integration: config.integrationLabel,
647
+ program_id: programConfig.id,
648
+ skill_id: config.skillId ?? null
649
+ });
650
+ logToFile("[agent-runner] starting OAuth");
651
+ const { projectApiKey, host, accessToken, projectId, cloudRegion, roleAtOrganization, user, project } = await getOrAskForProjectData({
652
+ signup: session.signup,
653
+ ci: session.ci,
654
+ apiKey: session.apiKey,
655
+ projectId: session.projectId,
656
+ email: session.email,
657
+ region: session.region,
658
+ programId: programConfig.id
659
+ });
660
+ session.credentials = {
661
+ accessToken,
662
+ projectApiKey,
663
+ host,
664
+ projectId
665
+ };
666
+ session.roleAtOrganization = roleAtOrganization;
667
+ session.apiUser = user;
668
+ getUI().setCredentials(session.credentials);
669
+ getUI().setRoleAtOrganization(roleAtOrganization);
670
+ getUI().setApiUser(user);
671
+ if (user) analytics.identifyUser(user);
672
+ analytics.setGroups(groupsFromUser(user, host));
673
+ logToFile("[agent-runner] checking AI opt-in gate");
674
+ await getUI().waitForAiOptIn();
675
+ logToFile("[agent-runner] AI opt-in gate cleared");
676
+ const wizardFlags = await analytics.getAllFlagsForWizard();
677
+ const wizardMetadata = buildWizardMetadata(wizardFlags);
678
+ analytics.setTag("variant", wizardMetadata.VARIANT);
679
+ return {
680
+ skillsBaseUrl,
681
+ projectApiKey,
682
+ host,
683
+ accessToken,
684
+ projectId,
685
+ cloudRegion,
686
+ mcpUrl: session.localMcp ? "http://localhost:8787/mcp" : runtimeEnv("MCP_URL") || "https://mcp.posthog.com/mcp",
687
+ wizardFlags,
688
+ wizardMetadata,
689
+ project
690
+ };
691
+ }
692
+ //#endregion
581
693
  //#region src/lib/middleware/phase-detector.ts
582
694
  /** Phase transitions from [STATUS] in assistant text. Keep in sync with program "Status to report" bullets. */
583
695
  const PHASES_ORDER = [
@@ -1422,7 +1534,8 @@ function createWizardAskBridge(opts) {
1422
1534
  const pending = {
1423
1535
  id: randomUUID(),
1424
1536
  questions,
1425
- source: opts.getSource()
1537
+ source: opts.getSource(),
1538
+ richLinks: opts.richLinks ?? false
1426
1539
  };
1427
1540
  const startedAt = Date.now();
1428
1541
  let timer;
@@ -1482,147 +1595,27 @@ function assemblePrompt(runDef, ctx) {
1482
1595
  return parts.join("\n\n");
1483
1596
  }
1484
1597
  //#endregion
1485
- //#region src/lib/agent/agent-runner.ts
1486
- /**
1487
- * Decide whether the `wizard_ask` overlay should be wired for this run.
1488
- * Disabled in non-interactive modes (CI, signup) — there's no human to
1489
- * answer. Per-program disabling is done by adding WIZARD_ASK_TOOL_NAME to
1490
- * the program's `disallowedTools` so the SDK rejects calls outright.
1491
- * Extracted so the policy can be unit-tested directly.
1492
- */
1493
- function shouldDisableAsk(session) {
1494
- return session.ci || session.signup;
1495
- }
1496
- function sessionToOptions(session) {
1497
- return {
1498
- installDir: session.installDir,
1499
- debug: session.debug,
1500
- default: false,
1501
- signup: session.signup,
1502
- localMcp: session.localMcp,
1503
- ci: session.ci,
1504
- benchmark: session.benchmark,
1505
- projectId: session.projectId,
1506
- apiKey: session.apiKey,
1507
- yaraReport: session.yaraReport
1508
- };
1509
- }
1510
- /**
1511
- * Resolve a ProgramConfig's agent run definition and execute the pipeline.
1512
- * Entry point for bin.ts — handles buildRunConfig, bootstrap, and (future) run field.
1513
- */
1514
- async function runAgent(programConfig, session) {
1515
- if (!programConfig.run) throw new Error(`Program "${programConfig.id}" has no run configuration.`);
1516
- await runProgram(session, typeof programConfig.run === "function" ? await programConfig.run(session) : programConfig.run, programConfig);
1517
- }
1518
- /**
1519
- * Run a program's agent pipeline.
1520
- *
1521
- * Runs the shared bootstrap, then forks on the `wizard-variant` flag. The
1522
- * `orchestrator` variant routes to the experimental task-queue runner; every
1523
- * other variant runs the linear pipeline.
1524
- */
1525
- async function runProgram(session, config, programConfig) {
1526
- const boot = await bootstrapProgram(session, config, programConfig);
1527
- if (isOrchestratorEnabled(boot.wizardFlags)) {
1528
- getUI().log.info("Task-queue orchestrator enabled.");
1529
- return runOrchestrator(session, programConfig, boot);
1530
- }
1531
- return runLinearProgram(session, config, programConfig, boot);
1532
- }
1533
- /**
1534
- * Shared setup for both arms: logging, health check, settings conflicts, OAuth
1535
- * and credentials, then the feature flags, variant metadata, and MCP url. Sets
1536
- * `session.credentials`, role, and user as a side effect. Returns the values the
1537
- * arms still need.
1538
- */
1539
- async function bootstrapProgram(session, config, programConfig) {
1540
- initLogFile();
1541
- session.skillId = config.skillId ?? config.integrationLabel;
1542
- logToFile(`[agent-runner] START ${config.integrationLabel}`);
1543
- if (session.debug) enableDebugLogs();
1544
- const skillsBaseUrl = getSkillsBaseUrl(session.localMcp);
1545
- const hasHealthCheckScreen = programConfig.steps.some((s) => s.screenId === "health-check");
1546
- if (session.readinessResult) logToFile(`[agent-runner] readiness pre-computed by TUI: decision=${session.readinessResult.decision}${session.outageDismissed ? " (outage dismissed by user)" : ""} — skipping re-check`);
1547
- if (hasHealthCheckScreen && !session.readinessResult) {
1548
- logToFile("[agent-runner] evaluating wizard readiness");
1549
- const readinessConfig = session.signup ? SIGNUP_WIZARD_READINESS_CONFIG : void 0;
1550
- const readiness = await evaluateWizardReadiness(readinessConfig);
1551
- logToFile(`[agent-runner] readiness=${readiness.decision}`);
1552
- if (readiness.decision === "no") {
1553
- const blockingLabels = getBlockingServiceKeys(readiness.health, readinessConfig).map((k) => `${SERVICE_LABELS[k]} (${readiness.health[k].status})`);
1554
- logToFile(`[agent-runner] blocked by: ${blockingLabels.join(", ")}`);
1555
- await getUI().showBlockingOutage(readiness);
1556
- if (!isNonInteractiveEnvironment()) await wizardAbort({ message: "Cannot start — external services are down:\n" + blockingLabels.map((l) => ` - ${l}`).join("\n") + "\n\nPlease try again later." });
1557
- } else if (readiness.decision === "yes_with_warnings") getUI().setReadinessWarnings(readiness);
1558
- }
1559
- const settingsConflicts = checkAllSettingsConflicts(session.installDir);
1560
- logToFile(`[agent-runner] settings conflicts: ${settingsConflicts.length > 0 ? settingsConflicts.map((c) => `${c.source}(${c.keys.join(",")})`).join("; ") : "none"}`);
1561
- if (settingsConflicts.length > 0) {
1562
- for (const conflict of settingsConflicts) {
1563
- const level = conflict.source === "managed" ? "org" : conflict.source;
1564
- analytics.wizardCapture("settings conflict detected", {
1565
- level,
1566
- keys: conflict.keys
1567
- });
1568
- }
1569
- await getUI().showSettingsOverride(settingsConflicts, () => backupAndFixClaudeSettings(session.installDir));
1570
- logToFile("[agent-runner] settings override resolved");
1571
- }
1572
- analytics.wizardCapture("agent started", {
1573
- integration: config.integrationLabel,
1574
- program_id: programConfig.id,
1575
- skill_id: config.skillId ?? null
1576
- });
1577
- logToFile("[agent-runner] starting OAuth");
1578
- const { projectApiKey, host, accessToken, projectId, cloudRegion, roleAtOrganization, user } = await getOrAskForProjectData({
1579
- signup: session.signup,
1580
- ci: session.ci,
1581
- apiKey: session.apiKey,
1582
- projectId: session.projectId,
1583
- email: session.email,
1584
- region: session.region,
1585
- programId: programConfig.id
1598
+ //#region src/lib/agent/runner/shared/errors.ts
1599
+ async function abortOnInstallFailure(integrationLabel, result) {
1600
+ if (result.kind === "ok") return;
1601
+ await wizardAbort({
1602
+ message: (() => {
1603
+ switch (result.kind) {
1604
+ case "menu-fetch-failed": return "Could not fetch the skill menu from context-mill.\nCheck your network connection and try again.";
1605
+ case "skill-not-found": return `Could not find the "${result.skillId}" skill in the context-mill menu.\nPlease try again later.`;
1606
+ case "download-failed": return `Failed to install skill: ${result.message}\nPlease try again.`;
1607
+ }
1608
+ })(),
1609
+ error: new WizardError(`Skill install failed: ${result.kind}`, {
1610
+ integration: integrationLabel,
1611
+ error_type: result.kind
1612
+ })
1586
1613
  });
1587
- session.credentials = {
1588
- accessToken,
1589
- projectApiKey,
1590
- host,
1591
- projectId
1592
- };
1593
- session.roleAtOrganization = roleAtOrganization;
1594
- session.apiUser = user;
1595
- getUI().setCredentials(session.credentials);
1596
- getUI().setRoleAtOrganization(roleAtOrganization);
1597
- getUI().setApiUser(user);
1598
- if (user) analytics.identifyUser(user);
1599
- analytics.setGroups(groupsFromUser(user, host));
1600
- logToFile("[agent-runner] checking AI opt-in gate");
1601
- await getUI().waitForAiOptIn();
1602
- logToFile("[agent-runner] AI opt-in gate cleared");
1603
- const wizardFlags = await analytics.getAllFlagsForWizard();
1604
- const wizardMetadata = buildWizardMetadata(wizardFlags);
1605
- analytics.setTag("variant", wizardMetadata.VARIANT);
1606
- return {
1607
- skillsBaseUrl,
1608
- projectApiKey,
1609
- host,
1610
- accessToken,
1611
- projectId,
1612
- cloudRegion,
1613
- mcpUrl: session.localMcp ? "http://localhost:8787/mcp" : runtimeEnv("MCP_URL") || "https://mcp.posthog.com/mcp",
1614
- wizardFlags,
1615
- wizardMetadata
1616
- };
1617
1614
  }
1618
- /**
1619
- * The linear pipeline. Single execution path for all non-orchestrator programs,
1620
- * both skill-based (revenue analytics) and framework-based (core integration).
1621
- * The `ProgramRun` controls what varies between them; `programConfig` carries the
1622
- * program-level static metadata (tool allow/disallow lists, etc.).
1623
- */
1615
+ //#endregion
1616
+ //#region src/lib/agent/runner/linear.ts
1624
1617
  async function runLinearProgram(session, config, programConfig, boot) {
1625
- const { skillsBaseUrl, projectApiKey, host, accessToken, projectId, cloudRegion, mcpUrl, wizardFlags, wizardMetadata } = boot;
1618
+ const { skillsBaseUrl, projectApiKey, host, accessToken, projectId, cloudRegion, mcpUrl, wizardFlags, wizardMetadata, project } = boot;
1626
1619
  let skillPath;
1627
1620
  if (config.skillId) {
1628
1621
  logToFile(`[agent-runner] installing skill ${config.skillId}`);
@@ -1648,6 +1641,7 @@ async function runLinearProgram(session, config, programConfig, boot) {
1648
1641
  const askBridge = shouldDisableAsk(session) ? void 0 : createWizardAskBridge({
1649
1642
  getSource: () => session.skillId ?? config.integrationLabel,
1650
1643
  showQuestion: (q) => getUI().requestQuestion(q),
1644
+ richLinks: config.richLinks ?? false,
1651
1645
  timeoutMs: config.askTimeoutMs
1652
1646
  });
1653
1647
  getUI().log.step("Initializing Claude agent...");
@@ -1676,7 +1670,13 @@ async function runLinearProgram(session, config, programConfig, boot) {
1676
1670
  projectId,
1677
1671
  projectApiKey,
1678
1672
  host,
1679
- skillPath
1673
+ skillPath,
1674
+ orgAiDataProcessingApproved: session.apiUser?.organization?.is_ai_data_processing_approved ?? null,
1675
+ teamProductOptIns: project ? {
1676
+ sessionReplay: project.session_recording_opt_in ?? null,
1677
+ exceptionAutocapture: project.autocapture_exceptions_opt_in ?? null,
1678
+ surveys: project.surveys_opt_in ?? null
1679
+ } : null
1680
1680
  });
1681
1681
  logToFile(`[agent-runner] prompt assembled (${prompt.length} chars)`);
1682
1682
  const agentResult = await runAgent$1(agent, prompt, sessionToOptions(session), spinner, {
@@ -1783,23 +1783,32 @@ Please try again, or check the documentation:\n${config.docsUrl}`,
1783
1783
  getUI().outro(config.successMessage);
1784
1784
  await analytics.shutdown("success");
1785
1785
  }
1786
- async function abortOnInstallFailure(integrationLabel, result) {
1787
- if (result.kind === "ok") return;
1788
- await wizardAbort({
1789
- message: (() => {
1790
- switch (result.kind) {
1791
- case "menu-fetch-failed": return "Could not fetch the skill menu from context-mill.\nCheck your network connection and try again.";
1792
- case "skill-not-found": return `Could not find the "${result.skillId}" skill in the context-mill menu.\nPlease try again later.`;
1793
- case "download-failed": return `Failed to install skill: ${result.message}\nPlease try again.`;
1794
- }
1795
- })(),
1796
- error: new WizardError(`Skill install failed: ${result.kind}`, {
1797
- integration: integrationLabel,
1798
- error_type: result.kind
1799
- })
1800
- });
1786
+ //#endregion
1787
+ //#region src/lib/agent/runner/index.ts
1788
+ /**
1789
+ * Resolve a ProgramConfig's agent run definition and execute the pipeline.
1790
+ * Entry point for bin.ts — handles buildRunConfig, bootstrap, and (future) run field.
1791
+ */
1792
+ async function runAgent(programConfig, session) {
1793
+ if (!programConfig.run) throw new Error(`Program "${programConfig.id}" has no run configuration.`);
1794
+ await runProgram(session, typeof programConfig.run === "function" ? await programConfig.run(session) : programConfig.run, programConfig);
1795
+ }
1796
+ /**
1797
+ * Run a program's agent pipeline.
1798
+ *
1799
+ * Runs the shared bootstrap, then forks on the `wizard-variant` flag. The
1800
+ * `orchestrator` variant routes to the experimental task-queue runner; every
1801
+ * other variant runs the linear pipeline.
1802
+ */
1803
+ async function runProgram(session, config, programConfig) {
1804
+ const boot = await bootstrapProgram(session, config, programConfig);
1805
+ if (isOrchestratorEnabled(boot.wizardFlags)) {
1806
+ getUI().log.info("Task-queue orchestrator enabled.");
1807
+ return runOrchestrator(session, programConfig, boot);
1808
+ }
1809
+ return runLinearProgram(session, config, programConfig, boot);
1801
1810
  }
1802
1811
  //#endregion
1803
1812
  export { runAgent };
1804
1813
 
1805
- //# sourceMappingURL=agent-runner-L_-kJ3y3.js.map
1814
+ //# sourceMappingURL=agent-runner-BNGW3osc.js.map