@posthog/wizard 2.61.0 → 2.63.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 (102) hide show
  1. package/README.md +48 -6
  2. package/dist/{add-mcp-server-to-clients-KNIHRN_m.js → add-mcp-server-to-clients-Bsyb6MUB.js} +4 -4
  3. package/dist/{add-mcp-server-to-clients-KNIHRN_m.js.map → add-mcp-server-to-clients-Bsyb6MUB.js.map} +1 -1
  4. package/dist/{agent-interface-Bm4ZNGGV.js → agent-interface-C4CV7p0L.js} +24 -16
  5. package/dist/agent-interface-C4CV7p0L.js.map +1 -0
  6. package/dist/{agent-prompt-loader-CsHNQXsY.js → agent-prompt-loader-DiM8xfSZ.js} +13 -6
  7. package/dist/agent-prompt-loader-DiM8xfSZ.js.map +1 -0
  8. package/dist/{agent-runner-DLAvB67P.js → agent-runner-X3JWS2WK.js} +230 -40
  9. package/dist/agent-runner-X3JWS2WK.js.map +1 -0
  10. package/dist/analytics-F6z7o3N2.js +2 -0
  11. package/dist/{analytics-CkIyBHfd.js → analytics-YLZKudpE.js} +2 -2
  12. package/dist/{analytics-CkIyBHfd.js.map → analytics-YLZKudpE.js.map} +1 -1
  13. package/dist/{api-XHQTOfIi.js → api-DlRJAFI2.js} +3 -3
  14. package/dist/{api-XHQTOfIi.js.map → api-DlRJAFI2.js.map} +1 -1
  15. package/dist/bin.js +101 -42
  16. package/dist/bin.js.map +1 -1
  17. package/dist/{bounded-fs-B-qlKB0h.js → bounded-fs-CYxETRCt.js} +3 -3
  18. package/dist/{bounded-fs-B-qlKB0h.js.map → bounded-fs-CYxETRCt.js.map} +1 -1
  19. package/dist/{ci-install-C9BAoO2n.js → ci-install-Cyqj_i3I.js} +4 -4
  20. package/dist/{ci-install-C9BAoO2n.js.map → ci-install-Cyqj_i3I.js.map} +1 -1
  21. package/dist/{debug-npp6DzBK.js → debug-2W78IhFE.js} +1 -1
  22. package/dist/{debug-8-IIHr5f.js → debug-BYIoy1Oz.js} +19 -9
  23. package/dist/debug-BYIoy1Oz.js.map +1 -0
  24. package/dist/{env-api-key-cjD4yfGT.js → env-api-key-B7kiHT3h.js} +4 -7
  25. package/dist/env-api-key-B7kiHT3h.js.map +1 -0
  26. package/dist/{environment-BffaZJRI.js → environment-Br-oy8cq.js} +4 -4
  27. package/dist/{environment-BffaZJRI.js.map → environment-Br-oy8cq.js.map} +1 -1
  28. package/dist/{file-watcher-BreVxzh0.js → file-watcher-HaK4IrJ5.js} +2 -2
  29. package/dist/{file-watcher-BreVxzh0.js.map → file-watcher-HaK4IrJ5.js.map} +1 -1
  30. package/dist/{headless-ui-Dy_l8hCT.js → headless-ui-Dd7Ty4Ul.js} +2 -2
  31. package/dist/{headless-ui-Dy_l8hCT.js.map → headless-ui-Dd7Ty4Ul.js.map} +1 -1
  32. package/dist/{interactive-C9vepji1.js → interactive-CYv97Lgg.js} +2 -2
  33. package/dist/{interactive-C9vepji1.js.map → interactive-CYv97Lgg.js.map} +1 -1
  34. package/dist/{mcp-C5Zheplw.js → mcp-D6cJWFPn.js} +2 -2
  35. package/dist/{mcp-C5Zheplw.js.map → mcp-D6cJWFPn.js.map} +1 -1
  36. package/dist/{mcp-prompt-streaming-DEerU5M3.js → mcp-prompt-streaming-DYX7vQ3q.js} +3 -3
  37. package/dist/{mcp-prompt-streaming-DEerU5M3.js.map → mcp-prompt-streaming-DYX7vQ3q.js.map} +1 -1
  38. package/dist/{non-interactive-C9vQaJF2.js → non-interactive-BR4kmPE5.js} +2 -2
  39. package/dist/{non-interactive-C9vQaJF2.js.map → non-interactive-BR4kmPE5.js.map} +1 -1
  40. package/dist/{orchestrator-tools-Bw97ahf6.js → orchestrator-tools-CTP6l34W.js} +13 -10
  41. package/dist/orchestrator-tools-CTP6l34W.js.map +1 -0
  42. package/dist/{package-manager-Cm5vbUDR.js → package-manager-FyJmIsqr.js} +2 -2
  43. package/dist/{package-manager-Cm5vbUDR.js.map → package-manager-FyJmIsqr.js.map} +1 -1
  44. package/dist/{pi-BocAqBQZ.js → pi-DeF8mWlb.js} +11 -11
  45. package/dist/{pi-BocAqBQZ.js.map → pi-DeF8mWlb.js.map} +1 -1
  46. package/dist/{playground-DmGHAiON.js → playground-BSMgOp3k.js} +6 -6
  47. package/dist/{playground-DmGHAiON.js.map → playground-BSMgOp3k.js.map} +1 -1
  48. package/dist/{posthog-BitL59Wc.js → posthog-ZWC-083a.js} +2 -2
  49. package/dist/{posthog-BitL59Wc.js.map → posthog-ZWC-083a.js.map} +1 -1
  50. package/dist/{posthog-integration-DbZ2oza2.js → posthog-integration-CoAID6XW.js} +53 -23
  51. package/dist/{posthog-integration-DbZ2oza2.js.map → posthog-integration-CoAID6XW.js.map} +1 -1
  52. package/dist/{provisioning-CzRepu4H.js → provisioning-xirriYQJ.js} +3 -3
  53. package/dist/{provisioning-CzRepu4H.js.map → provisioning-xirriYQJ.js.map} +1 -1
  54. package/dist/{queue-tools-OynU-m2F.js → queue-tools-BtJ7_fEW.js} +119 -20
  55. package/dist/queue-tools-BtJ7_fEW.js.map +1 -0
  56. package/dist/{registry-eXzDlt51.js → registry-B-whj8SQ.js} +5 -5
  57. package/dist/{registry-eXzDlt51.js.map → registry-B-whj8SQ.js.map} +1 -1
  58. package/dist/{security-DqByFEpl.js → security-CPtn_dUW.js} +5 -5
  59. package/dist/{security-DqByFEpl.js.map → security-CPtn_dUW.js.map} +1 -1
  60. package/dist/{setup-utils-C2rGcUFv.js → setup-utils-e78zkZoW.js} +71 -18
  61. package/dist/setup-utils-e78zkZoW.js.map +1 -0
  62. package/dist/{start-tui-BYTQwgvK.js → start-tui-B08PfE0V.js} +21 -18
  63. package/dist/start-tui-B08PfE0V.js.map +1 -0
  64. package/dist/{steps-CMIyEySI.js → steps-Dpd8UTJX.js} +7 -7
  65. package/dist/{steps-CMIyEySI.js.map → steps-Dpd8UTJX.js.map} +1 -1
  66. package/dist/{store-pBYMaEuj.js → store-B-ctPH7O.js} +5 -4
  67. package/dist/store-B-ctPH7O.js.map +1 -0
  68. package/dist/{subagent-ZDD6XCmm.js → subagent-B18BesIW.js} +2 -2
  69. package/dist/{subagent-ZDD6XCmm.js.map → subagent-B18BesIW.js.map} +1 -1
  70. package/dist/{task-1KHCdViK.js → task-D1RaGg3b.js} +12 -12
  71. package/dist/{task-1KHCdViK.js.map → task-D1RaGg3b.js.map} +1 -1
  72. package/dist/{task-stream-DAU6Z6u6.js → task-stream-DvTf1NOr.js} +4 -4
  73. package/dist/{task-stream-DAU6Z6u6.js.map → task-stream-DvTf1NOr.js.map} +1 -1
  74. package/dist/{tasks-BBo0_AZG.js → tasks-CvHNNFB1.js} +2 -2
  75. package/dist/{tasks-BBo0_AZG.js.map → tasks-CvHNNFB1.js.map} +1 -1
  76. package/dist/{telemetry-DSzPCPtQ.js → telemetry-C72C8V6q.js} +3 -3
  77. package/dist/{telemetry-DSzPCPtQ.js.map → telemetry-C72C8V6q.js.map} +1 -1
  78. package/dist/{terminal-DW8x0UNT.js → terminal-BJms6G77.js} +16 -13
  79. package/dist/terminal-BJms6G77.js.map +1 -0
  80. package/dist/{tools-DCH7Ji4V.js → tools-BcXOgEvh.js} +6 -6
  81. package/dist/{tools-DCH7Ji4V.js.map → tools-BcXOgEvh.js.map} +1 -1
  82. package/dist/{wizard-abort-B_Sa9K3g.js → wizard-abort-BUpx4qnK.js} +1 -1
  83. package/dist/{wizard-abort-Cz916Qq5.js → wizard-abort-DRscjUOg.js} +3 -3
  84. package/dist/{wizard-abort-Cz916Qq5.js.map → wizard-abort-DRscjUOg.js.map} +1 -1
  85. package/dist/wizard-session-BUhlJ1b8.js.map +1 -1
  86. package/dist/{yara-hooks-DgScuNrT.js → yara-hooks-DKRsn0lN.js} +4 -4
  87. package/dist/{yara-hooks-DgScuNrT.js.map → yara-hooks-DKRsn0lN.js.map} +1 -1
  88. package/dist/yara-hooks-fHntXaFu.js +2 -0
  89. package/package.json +1 -1
  90. package/dist/agent-interface-Bm4ZNGGV.js.map +0 -1
  91. package/dist/agent-prompt-loader-CsHNQXsY.js.map +0 -1
  92. package/dist/agent-runner-DLAvB67P.js.map +0 -1
  93. package/dist/analytics-kxgLEv7U.js +0 -2
  94. package/dist/debug-8-IIHr5f.js.map +0 -1
  95. package/dist/env-api-key-cjD4yfGT.js.map +0 -1
  96. package/dist/orchestrator-tools-Bw97ahf6.js.map +0 -1
  97. package/dist/queue-tools-OynU-m2F.js.map +0 -1
  98. package/dist/setup-utils-C2rGcUFv.js.map +0 -1
  99. package/dist/start-tui-BYTQwgvK.js.map +0 -1
  100. package/dist/store-pBYMaEuj.js.map +0 -1
  101. package/dist/terminal-DW8x0UNT.js.map +0 -1
  102. package/dist/yara-hooks-BVEBOdMu.js +0 -2
@@ -1,4 +1,4 @@
1
- import { s as logToFile } from "./debug-8-IIHr5f.js";
1
+ import { s as logToFile } from "./debug-BYIoy1Oz.js";
2
2
  //#region src/lib/task-stream/destinations/posthog.ts
3
3
  const MAX_ATTEMPTS = 3;
4
4
  const BASE_BACKOFF_MS = 500;
@@ -121,4 +121,4 @@ var PostHogDestination = class {
121
121
  //#endregion
122
122
  export { PostHogDestination };
123
123
 
124
- //# sourceMappingURL=posthog-BitL59Wc.js.map
124
+ //# sourceMappingURL=posthog-ZWC-083a.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"posthog-BitL59Wc.js","names":[],"sources":["../src/lib/task-stream/destinations/posthog.ts"],"sourcesContent":["/**\n * PostHog destination — pushes wizard run state to the PostHog backend\n * via `POST /api/projects/{project_id}/wizard/sessions/`.\n *\n * The endpoint is an upsert keyed by `(team, session_id)`: 201 means\n * the row was created, 200 means it was updated. Both are success.\n *\n * Failure handling is fail-silent: never throws to the caller, never\n * writes to stdout/stderr, never blocks the agent. Errors flow through\n * the optional `onError` callback for the wizard's debug log.\n *\n * Retry policy:\n * 5xx / network → exponential backoff base 500ms cap 8s, max 3 attempts\n * 429 → honour `Retry-After` (seconds), single retry\n * 401 / 403 → disable for the rest of the run, no further pushes\n * 400 → give up for this push, do not disable\n * other 4xx → give up for this push, do not disable\n */\n\nimport type {\n TaskStreamDestination,\n TaskStreamUpdate,\n StreamEvent,\n} from '@lib/task-stream/types';\nimport type { Credentials } from '@lib/wizard-session';\nimport { logToFile } from '@utils/debug';\n\nexport interface PostHogDestinationOptions {\n /**\n * Lazy credential resolver — called on every send. Returns null\n * before authentication has completed; in that case the send is a\n * no-op (no HTTP request).\n */\n getCredentials: () => Credentials | null;\n /** Receives every error for the wizard's internal logfile. */\n onError?: (err: Error) => void;\n /** Override for tests. Defaults to global fetch. */\n fetchImpl?: typeof fetch;\n /** Override for tests. Defaults to setTimeout. */\n sleep?: (ms: number) => Promise<void>;\n}\n\nconst MAX_ATTEMPTS = 3;\nconst BASE_BACKOFF_MS = 500;\nconst MAX_BACKOFF_MS = 8000;\nconst DEFAULT_RETRY_AFTER_MS = 1000;\n// setTimeout silently clamps anything above 2^31-1 ms to fire\n// immediately, so any Retry-After-derived sleep must be capped.\nconst MAX_RETRY_AFTER_MS = 60_000;\n\nfunction defaultSleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction parseRetryAfter(value: string | null): number {\n if (!value) return DEFAULT_RETRY_AFTER_MS;\n const seconds = Number(value);\n if (Number.isFinite(seconds) && seconds >= 0) {\n return Math.min(Math.ceil(seconds * 1000), MAX_RETRY_AFTER_MS);\n }\n // HTTP-date form — best-effort.\n const date = Date.parse(value);\n if (Number.isFinite(date)) {\n return Math.min(Math.max(0, date - Date.now()), MAX_RETRY_AFTER_MS);\n }\n return DEFAULT_RETRY_AFTER_MS;\n}\n\n/**\n * Strip the internal-only `timestamp` field before sending. The\n * backend schema in the RFC does not define it.\n */\nfunction toWirePayload(\n payload: TaskStreamUpdate,\n): Omit<TaskStreamUpdate, 'timestamp'> {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { timestamp: _unused, ...rest } = payload;\n return rest;\n}\n\nexport class PostHogDestination implements TaskStreamDestination {\n readonly name = 'posthog';\n\n private readonly getCredentials: () => Credentials | null;\n private readonly onError: (err: Error) => void;\n private readonly fetchImpl: typeof fetch;\n private readonly sleep: (ms: number) => Promise<void>;\n\n private disabled = false;\n\n constructor(opts: PostHogDestinationOptions) {\n this.getCredentials = opts.getCredentials;\n this.onError = opts.onError ?? (() => undefined);\n this.fetchImpl = opts.fetchImpl ?? ((...args) => fetch(...args));\n this.sleep = opts.sleep ?? defaultSleep;\n }\n\n async send(_event: StreamEvent, payload: TaskStreamUpdate): Promise<void> {\n if (this.disabled) return;\n const creds = this.getCredentials();\n if (!creds) return;\n\n await this.postWithRetry(creds, toWirePayload(payload));\n }\n\n private buildRequest(\n creds: Credentials,\n body: object,\n ): { url: string; init: Parameters<typeof fetch>[1] } {\n const url = `${creds.host.apiHost.replace(/\\/$/, '')}/api/projects/${\n creds.projectId\n }/wizard/sessions/`;\n return {\n url,\n init: {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${creds.accessToken}`,\n },\n body: JSON.stringify(body),\n },\n };\n }\n\n private async postWithRetry(creds: Credentials, body: object): Promise<void> {\n const { url, init } = this.buildRequest(creds, body);\n let attempt = 0;\n let backoff = BASE_BACKOFF_MS;\n let retriedAfter429 = false;\n\n while (attempt < MAX_ATTEMPTS) {\n attempt += 1;\n let response: Response;\n try {\n response = await this.fetchImpl(url, init);\n } catch (err) {\n if (attempt >= MAX_ATTEMPTS) {\n this.onError(err instanceof Error ? err : new Error(String(err)));\n return;\n }\n await this.sleep(backoff);\n backoff = Math.min(backoff * 2, MAX_BACKOFF_MS);\n continue;\n }\n\n if (response.ok) {\n logToFile(`[task-stream] wizard/sessions push ok: ${response.status}`);\n return;\n }\n\n const status = response.status;\n\n if (status === 401 || status === 403) {\n this.disabled = true;\n this.onError(new Error(`wizard/sessions auth failed: ${status}`));\n return;\n }\n\n if (status === 429) {\n if (retriedAfter429) {\n this.onError(new Error('wizard/sessions rate limited'));\n return;\n }\n retriedAfter429 = true;\n const wait = parseRetryAfter(response.headers.get('Retry-After'));\n await this.sleep(wait);\n // Don't count this against the 5xx attempt budget.\n attempt -= 1;\n continue;\n }\n\n if (status >= 500) {\n if (attempt >= MAX_ATTEMPTS) {\n this.onError(new Error(`wizard/sessions server error: ${status}`));\n return;\n }\n await this.sleep(backoff);\n backoff = Math.min(backoff * 2, MAX_BACKOFF_MS);\n continue;\n }\n\n if (status === 400) {\n let detail = '';\n try {\n detail = await response.text();\n } catch {\n // ignore\n }\n this.onError(new Error(`wizard/sessions bad request (400): ${detail}`));\n return;\n }\n\n this.onError(new Error(`wizard/sessions unexpected status: ${status}`));\n return;\n }\n }\n}\n"],"mappings":";;AA0CA,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AACvB,MAAM,yBAAyB;AAG/B,MAAM,qBAAqB;AAE3B,SAAS,aAAa,IAA2B;AAC/C,QAAO,IAAI,SAAS,YAAY,WAAW,SAAS,GAAG,CAAC;;AAG1D,SAAS,gBAAgB,OAA8B;AACrD,KAAI,CAAC,MAAO,QAAO;CACnB,MAAM,UAAU,OAAO,MAAM;AAC7B,KAAI,OAAO,SAAS,QAAQ,IAAI,WAAW,EACzC,QAAO,KAAK,IAAI,KAAK,KAAK,UAAU,IAAK,EAAE,mBAAmB;CAGhE,MAAM,OAAO,KAAK,MAAM,MAAM;AAC9B,KAAI,OAAO,SAAS,KAAK,CACvB,QAAO,KAAK,IAAI,KAAK,IAAI,GAAG,OAAO,KAAK,KAAK,CAAC,EAAE,mBAAmB;AAErE,QAAO;;;;;;AAOT,SAAS,cACP,SACqC;CAErC,MAAM,EAAE,WAAW,SAAS,GAAG,SAAS;AACxC,QAAO;;AAGT,IAAa,qBAAb,MAAiE;CAC/D,OAAgB;CAEhB;CACA;CACA;CACA;CAEA,WAAmB;CAEnB,YAAY,MAAiC;AAC3C,OAAK,iBAAiB,KAAK;AAC3B,OAAK,UAAU,KAAK,kBAAkB,KAAA;AACtC,OAAK,YAAY,KAAK,eAAe,GAAG,SAAS,MA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BAAgB,SAAS,QAAQ,IAAI,cAAc,CAAC;AACjE,UAAM,KAAK,MAAM,KAAK;AAEtB,eAAW;AACX;;AAGF,OAAI,UAAU,KAAK;AACjB,QAAI,WAAW,cAAc;AAC3B,UAAK,wBAAQ,IAAI,MAAM,iCAAiC,SAAS,CAAC;AAClE;;AAEF,UAAM,KAAK,MAAM,QAAQ;AACzB,cAAU,KAAK,IAAI,UAAU,GAAG,eAAe;AAC/C;;AAGF,OAAI,WAAW,KAAK;IAClB,IAAI,SAAS;AACb,QAAI;AACF,cAAS,MAAM,SAAS,MAAM;YACxB;AAGR,SAAK,wBAAQ,IAAI,MAAM,sCAAsC,SAAS,CAAC;AACvE;;AAGF,QAAK,wBAAQ,IAAI,MAAM,sCAAsC,SAAS,CAAC;AACvE"}
1
+ {"version":3,"file":"posthog-ZWC-083a.js","names":[],"sources":["../src/lib/task-stream/destinations/posthog.ts"],"sourcesContent":["/**\n * PostHog destination — pushes wizard run state to the PostHog backend\n * via `POST /api/projects/{project_id}/wizard/sessions/`.\n *\n * The endpoint is an upsert keyed by `(team, session_id)`: 201 means\n * the row was created, 200 means it was updated. Both are success.\n *\n * Failure handling is fail-silent: never throws to the caller, never\n * writes to stdout/stderr, never blocks the agent. Errors flow through\n * the optional `onError` callback for the wizard's debug log.\n *\n * Retry policy:\n * 5xx / network → exponential backoff base 500ms cap 8s, max 3 attempts\n * 429 → honour `Retry-After` (seconds), single retry\n * 401 / 403 → disable for the rest of the run, no further pushes\n * 400 → give up for this push, do not disable\n * other 4xx → give up for this push, do not disable\n */\n\nimport type {\n TaskStreamDestination,\n TaskStreamUpdate,\n StreamEvent,\n} from '@lib/task-stream/types';\nimport type { Credentials } from '@lib/wizard-session';\nimport { logToFile } from '@utils/debug';\n\nexport interface PostHogDestinationOptions {\n /**\n * Lazy credential resolver — called on every send. Returns null\n * before authentication has completed; in that case the send is a\n * no-op (no HTTP request).\n */\n getCredentials: () => Credentials | null;\n /** Receives every error for the wizard's internal logfile. */\n onError?: (err: Error) => void;\n /** Override for tests. Defaults to global fetch. */\n fetchImpl?: typeof fetch;\n /** Override for tests. Defaults to setTimeout. */\n sleep?: (ms: number) => Promise<void>;\n}\n\nconst MAX_ATTEMPTS = 3;\nconst BASE_BACKOFF_MS = 500;\nconst MAX_BACKOFF_MS = 8000;\nconst DEFAULT_RETRY_AFTER_MS = 1000;\n// setTimeout silently clamps anything above 2^31-1 ms to fire\n// immediately, so any Retry-After-derived sleep must be capped.\nconst MAX_RETRY_AFTER_MS = 60_000;\n\nfunction defaultSleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction parseRetryAfter(value: string | null): number {\n if (!value) return DEFAULT_RETRY_AFTER_MS;\n const seconds = Number(value);\n if (Number.isFinite(seconds) && seconds >= 0) {\n return Math.min(Math.ceil(seconds * 1000), MAX_RETRY_AFTER_MS);\n }\n // HTTP-date form — best-effort.\n const date = Date.parse(value);\n if (Number.isFinite(date)) {\n return Math.min(Math.max(0, date - Date.now()), MAX_RETRY_AFTER_MS);\n }\n return DEFAULT_RETRY_AFTER_MS;\n}\n\n/**\n * Strip the internal-only `timestamp` field before sending. The\n * backend schema in the RFC does not define it.\n */\nfunction toWirePayload(\n payload: TaskStreamUpdate,\n): Omit<TaskStreamUpdate, 'timestamp'> {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { timestamp: _unused, ...rest } = payload;\n return rest;\n}\n\nexport class PostHogDestination implements TaskStreamDestination {\n readonly name = 'posthog';\n\n private readonly getCredentials: () => Credentials | null;\n private readonly onError: (err: Error) => void;\n private readonly fetchImpl: typeof fetch;\n private readonly sleep: (ms: number) => Promise<void>;\n\n private disabled = false;\n\n constructor(opts: PostHogDestinationOptions) {\n this.getCredentials = opts.getCredentials;\n this.onError = opts.onError ?? (() => undefined);\n this.fetchImpl = opts.fetchImpl ?? ((...args) => fetch(...args));\n this.sleep = opts.sleep ?? defaultSleep;\n }\n\n async send(_event: StreamEvent, payload: TaskStreamUpdate): Promise<void> {\n if (this.disabled) return;\n const creds = this.getCredentials();\n if (!creds) return;\n\n await this.postWithRetry(creds, toWirePayload(payload));\n }\n\n private buildRequest(\n creds: Credentials,\n body: object,\n ): { url: string; init: Parameters<typeof fetch>[1] } {\n const url = `${creds.host.apiHost.replace(/\\/$/, '')}/api/projects/${\n creds.projectId\n }/wizard/sessions/`;\n return {\n url,\n init: {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${creds.accessToken}`,\n },\n body: JSON.stringify(body),\n },\n };\n }\n\n private async postWithRetry(creds: Credentials, body: object): Promise<void> {\n const { url, init } = this.buildRequest(creds, body);\n let attempt = 0;\n let backoff = BASE_BACKOFF_MS;\n let retriedAfter429 = false;\n\n while (attempt < MAX_ATTEMPTS) {\n attempt += 1;\n let response: Response;\n try {\n response = await this.fetchImpl(url, init);\n } catch (err) {\n if (attempt >= MAX_ATTEMPTS) {\n this.onError(err instanceof Error ? err : new Error(String(err)));\n return;\n }\n await this.sleep(backoff);\n backoff = Math.min(backoff * 2, MAX_BACKOFF_MS);\n continue;\n }\n\n if (response.ok) {\n logToFile(`[task-stream] wizard/sessions push ok: ${response.status}`);\n return;\n }\n\n const status = response.status;\n\n if (status === 401 || status === 403) {\n this.disabled = true;\n this.onError(new Error(`wizard/sessions auth failed: ${status}`));\n return;\n }\n\n if (status === 429) {\n if (retriedAfter429) {\n this.onError(new Error('wizard/sessions rate limited'));\n return;\n }\n retriedAfter429 = true;\n const wait = parseRetryAfter(response.headers.get('Retry-After'));\n await this.sleep(wait);\n // Don't count this against the 5xx attempt budget.\n attempt -= 1;\n continue;\n }\n\n if (status >= 500) {\n if (attempt >= MAX_ATTEMPTS) {\n this.onError(new Error(`wizard/sessions server error: ${status}`));\n return;\n }\n await this.sleep(backoff);\n backoff = Math.min(backoff * 2, MAX_BACKOFF_MS);\n continue;\n }\n\n if (status === 400) {\n let detail = '';\n try {\n detail = await response.text();\n } catch {\n // ignore\n }\n this.onError(new Error(`wizard/sessions bad request (400): ${detail}`));\n return;\n }\n\n this.onError(new Error(`wizard/sessions unexpected status: ${status}`));\n return;\n }\n }\n}\n"],"mappings":";;AA0CA,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AACvB,MAAM,yBAAyB;AAG/B,MAAM,qBAAqB;AAE3B,SAAS,aAAa,IAA2B;AAC/C,QAAO,IAAI,SAAS,YAAY,WAAW,SAAS,GAAG,CAAC;;AAG1D,SAAS,gBAAgB,OAA8B;AACrD,KAAI,CAAC,MAAO,QAAO;CACnB,MAAM,UAAU,OAAO,MAAM;AAC7B,KAAI,OAAO,SAAS,QAAQ,IAAI,WAAW,EACzC,QAAO,KAAK,IAAI,KAAK,KAAK,UAAU,IAAK,EAAE,mBAAmB;CAGhE,MAAM,OAAO,KAAK,MAAM,MAAM;AAC9B,KAAI,OAAO,SAAS,KAAK,CACvB,QAAO,KAAK,IAAI,KAAK,IAAI,GAAG,OAAO,KAAK,KAAK,CAAC,EAAE,mBAAmB;AAErE,QAAO;;;;;;AAOT,SAAS,cACP,SACqC;CAErC,MAAM,EAAE,WAAW,SAAS,GAAG,SAAS;AACxC,QAAO;;AAGT,IAAa,qBAAb,MAAiE;CAC/D,OAAgB;CAEhB;CACA;CACA;CACA;CAEA,WAAmB;CAEnB,YAAY,MAAiC;AAC3C,OAAK,iBAAiB,KAAK;AAC3B,OAAK,UAAU,KAAK,kBAAkB,KAAA;AACtC,OAAK,YAAY,KAAK,eAAe,GAAG,SAAS,MAAM,GAAG,KAAK;AAC/D,OAAK,QAAQ,KAAK,SAAS;;CAG7B,MAAM,KAAK,QAAqB,SAA0C;AACxE,MAAI,KAAK,SAAU;EACnB,MAAM,QAAQ,KAAK,gBAAgB;AACnC,MAAI,CAAC,MAAO;AAEZ,QAAM,KAAK,cAAc,OAAO,cAAc,QAAQ,CAAC;;CAGzD,aACE,OACA,MACoD;AAIpD,SAAO;GACL,KAJU,GAAG,MAAM,KAAK,QAAQ,QAAQ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AW,KAAK;IAClB,IAAI,SAAS;AACb,QAAI;AACF,cAAS,MAAM,SAAS,MAAM;YACxB;AAGR,SAAK,wBAAQ,IAAI,MAAM,sCAAsC,SAAS,CAAC;AACvE;;AAGF,QAAK,wBAAQ,IAAI,MAAM,sCAAsC,SAAS,CAAC;AACvE"}
@@ -1,16 +1,16 @@
1
- import { L as Integration, N as HAIKU_MODEL, O as DETECTION_TIMEOUT_MS, _ as evaluateWizardReadiness, at as WIZARD_INTERACTION_EVENT_NAME, f as getUI, g as SIGNUP_WIZARD_READINESS_CONFIG, pt as getSkillsBaseUrl, s as logToFile, v as getBlockingServiceKeys, x as AGENTIC_DETECTION_TIMEOUT_MS } from "./debug-8-IIHr5f.js";
2
- import { n as analytics } from "./analytics-CkIyBHfd.js";
3
- import { i as withUtm, n as openTrackedLink } from "./telemetry-DSzPCPtQ.js";
4
- import { a as safeReadFile, i as readProjectFile, o as walkProjectFiles } from "./bounded-fs-B-qlKB0h.js";
5
- import { i as tryGetPackageJson, n as isUsingTypeScript } from "./setup-utils-C2rGcUFv.js";
6
- import { i as requestDeepLink } from "./provisioning-CzRepu4H.js";
1
+ import { L as Integration, N as HAIKU_MODEL, O as DETECTION_TIMEOUT_MS, _ as evaluateWizardReadiness, at as WIZARD_INTERACTION_EVENT_NAME, f as getUI, g as SIGNUP_WIZARD_READINESS_CONFIG, mt as getSkillsBaseUrl, s as logToFile, v as getBlockingServiceKeys, x as AGENTIC_DETECTION_TIMEOUT_MS } from "./debug-BYIoy1Oz.js";
2
+ import { n as analytics } from "./analytics-YLZKudpE.js";
3
+ import { i as withUtm, n as openTrackedLink } from "./telemetry-C72C8V6q.js";
4
+ import { a as safeReadFile, i as readProjectFile, o as walkProjectFiles } from "./bounded-fs-CYxETRCt.js";
5
+ import { i as tryGetPackageJson, n as isUsingTypeScript } from "./setup-utils-e78zkZoW.js";
6
+ import { i as requestDeepLink } from "./provisioning-xirriYQJ.js";
7
7
  import "./wizard-session-BUhlJ1b8.js";
8
- import { i as wizardAbort } from "./wizard-abort-Cz916Qq5.js";
9
- import { n as runAgent, r as shouldDisableAsk, s as authenticate } from "./agent-runner-DLAvB67P.js";
10
- import { S as WIZARD_TOOL_NAMES, i as runAgent$1, p as AgentSignals, r as initializeAgent } from "./agent-interface-Bm4ZNGGV.js";
11
- import { h as EVENT_PLAN_FILE } from "./yara-hooks-DgScuNrT.js";
12
- import { r as detectNodePackageManagers } from "./package-manager-Cm5vbUDR.js";
13
- import { i as SPINNER_MESSAGE, t as FRAMEWORK_REGISTRY } from "./registry-eXzDlt51.js";
8
+ import { i as wizardAbort } from "./wizard-abort-DRscjUOg.js";
9
+ import { n as runAgent, r as shouldDisableAsk, s as authenticate } from "./agent-runner-X3JWS2WK.js";
10
+ import { S as WIZARD_TOOL_NAMES, i as runAgent$1, p as AgentSignals, r as initializeAgent } from "./agent-interface-C4CV7p0L.js";
11
+ import { h as EVENT_PLAN_FILE } from "./yara-hooks-DKRsn0lN.js";
12
+ import { r as detectNodePackageManagers } from "./package-manager-FyJmIsqr.js";
13
+ import { i as SPINNER_MESSAGE, t as FRAMEWORK_REGISTRY } from "./registry-B-whj8SQ.js";
14
14
  import * as semver from "semver";
15
15
  import { existsSync, statSync } from "fs";
16
16
  import { isAbsolute, join, resolve, sep } from "path";
@@ -3643,24 +3643,48 @@ function resolveContinueUrl(sess, host, deepLink) {
3643
3643
  if (typeof deepLink === "string" && deepLink) return deepLink;
3644
3644
  return withUtm(`${host.appHost}/products?source=wizard`, "outro-continue");
3645
3645
  }
3646
+ /** Sources listed with their own link before the outro falls back to a summary line. */
3647
+ const WAREHOUSE_LINK_LIMIT = 3;
3648
+ /**
3649
+ * The app's new-source page, pre-selected to one source kind.
3650
+ *
3651
+ * `kind` is matched case-insensitively against the connector list, and a kind
3652
+ * the app cannot resolve lands on the source catalog rather than erroring. So a
3653
+ * source we detect but the app has not shipped a connector for still takes the
3654
+ * user somewhere useful.
3655
+ */
3656
+ function warehouseSourceUrl(host, projectId, kind) {
3657
+ return withUtm(`${host.appHost}/project/${projectId}/data-warehouse/new-source?kind=${encodeURIComponent(kind)}`, "outro-warehouse");
3658
+ }
3646
3659
  /**
3647
3660
  * Outro suggestion for data sources found in the project but not connected.
3648
3661
  *
3649
- * A pointer at `wizard warehouse`, not an inline flow. Connecting a source
3650
- * needs interactive credential collection, and chaining that as a second agent
3651
- * run before the outro would let any of its terminal failure paths
3652
- * `process.exit()` — costing the user the success outro and the post-outro
3653
- * MCP / Slack steps on a run where PostHog installed fine.
3662
+ * A pointer at the app, not an inline flow. Connecting a source needs
3663
+ * interactive credential collection, and chaining that as a second agent run
3664
+ * before the outro would let any of its terminal failure paths `process.exit()`
3665
+ * — costing the user the success outro and the post-outro MCP / Slack steps on
3666
+ * a run where PostHog installed fine.
3667
+ *
3668
+ * Each source gets its own pre-filled link, because the alternative we shipped
3669
+ * first — naming the `wizard warehouse` command — asks the user to start a
3670
+ * second CLI run before they can connect anything. A link opens the form for
3671
+ * that one source. The command line stays for anyone who wants every source in
3672
+ * one pass, and it is the only route offered once the list is too long to read.
3654
3673
  *
3655
3674
  * Returns undefined when nothing was detected, so the outro is unchanged for
3656
3675
  * projects with no connectable source.
3657
3676
  */
3658
- function buildWarehouseNextSteps(sess) {
3677
+ function buildWarehouseNextSteps(sess, host, projectId) {
3659
3678
  const sources = getDetectedWarehouseSources(sess);
3660
3679
  if (sources.length === 0) return void 0;
3680
+ const listed = sources.slice(0, WAREHOUSE_LINK_LIMIT);
3681
+ const items = listed.map((s) => `Connect ${s.label}: ${warehouseSourceUrl(host, projectId, s.kind)}`);
3682
+ const remaining = sources.length - listed.length;
3683
+ if (remaining > 0) items.push(`And ${remaining} more we found in this project.`);
3684
+ items.push("Connect them all at once with: npx @posthog/wizard warehouse");
3661
3685
  return {
3662
3686
  heading: "Query your other data in PostHog:",
3663
- items: [`Found in this project: ${sources.map((s) => s.label).join(", ")}`, "Import it into the data warehouse with: npx @posthog/wizard warehouse"]
3687
+ items
3664
3688
  };
3665
3689
  }
3666
3690
  /**
@@ -3685,6 +3709,11 @@ function warehouseReportInstruction(sess) {
3685
3709
  * the run is a fact about the project the wizard already scanned, so a model
3686
3710
  * can neither invent it nor forget it.
3687
3711
  *
3712
+ * It runs at the end of the queue, not the start. Where exactly is the agent
3713
+ * prompt's business (`dependsOn` in the warehouse agent's frontmatter, resolved
3714
+ * by `seeded-deps.ts` once the planner has run) — this file only decides whether
3715
+ * the task belongs in the run at all.
3716
+ *
3688
3717
  * Empty when nothing was detected, and in CI, signup, and any other run where
3689
3718
  * `wizard_ask` is disabled — a credential prompt nobody can answer would burn
3690
3719
  * the task's whole timeout and then fail the run.
@@ -3707,7 +3736,7 @@ const warehouseSeedTasks = (sess) => {
3707
3736
  })) },
3708
3737
  notice: {
3709
3738
  title: "Connect your data sources",
3710
- body: ["We detected some warehouse sources we can connect to enrich your PostHog data. To connect them, stick around, we'll prompt you to provide some credentials to setup warehouse sources.", "You can select [Skip] if you'd like to do this later in PostHog."],
3739
+ body: ["We detected some warehouse sources we can connect to enrich your PostHog data. This runs at the end, once your code changes are done — we’ll prompt you then for the credentials, so you can leave the setup to run until it asks.", "You can select [Skip] if you'd like to do this later in PostHog."],
3711
3740
  items: sources.map((s) => s.label),
3712
3741
  docsLabel: "Learn more about warehouse sources",
3713
3742
  docsUrl: WAREHOUSE_SOURCES_DOCS_URL,
@@ -3786,6 +3815,7 @@ const posthogIntegrationConfig = {
3786
3815
  docsUrl: config.metadata.docsUrl,
3787
3816
  errorMessage: "Integration failed",
3788
3817
  additionalFeatureQueue: session.additionalFeatureQueue,
3818
+ richLinks: true,
3789
3819
  customPrompt: (ctx) => {
3790
3820
  const additionalLines = config.prompts.getAdditionalContextLines ? config.prompts.getAdditionalContextLines(frameworkContext) : [];
3791
3821
  const additionalContext = additionalLines.length > 0 ? "\n" + additionalLines.map((line) => `- ${line}`).join("\n") : "";
@@ -3829,7 +3859,7 @@ ${warehouseReportInstruction(session)}
3829
3859
  postRun: async (sess, credentials) => {
3830
3860
  const envVars = config.environment.getEnvVars(credentials.projectApiKey, credentials.host.apiHost);
3831
3861
  if (config.environment.uploadToHosting) {
3832
- const { uploadEnvironmentVariablesStep } = await import("./steps-CMIyEySI.js");
3862
+ const { uploadEnvironmentVariablesStep } = await import("./steps-Dpd8UTJX.js");
3833
3863
  const uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {
3834
3864
  integration: config.metadata.integration,
3835
3865
  session: sess
@@ -3860,7 +3890,7 @@ ${warehouseReportInstruction(session)}
3860
3890
  changes: [...config.ui.getOutroChanges(frameworkContext), Object.keys(envVars).length > 0 ? "Added environment variables to .env file" : ""].filter(Boolean),
3861
3891
  docsUrl: config.metadata.docsUrl,
3862
3892
  continueUrl,
3863
- nextSteps: buildWarehouseNextSteps(sess),
3893
+ nextSteps: buildWarehouseNextSteps(sess, credentials.host, credentials.projectId),
3864
3894
  notebookUrl: sess.notebookUrl ?? void 0,
3865
3895
  handoffPrompt: sess.notebookUrl ? buildCodingAgentPrompt(sess.notebookUrl) : void 0
3866
3896
  };
@@ -3885,4 +3915,4 @@ const integrationRunStep = {
3885
3915
  //#endregion
3886
3916
  export { resolveProjectDir as C, detectProjectsWithAgent as S, WAREHOUSE_ABORT_CASES as _, LINE_CHART_BLOCK as a, detectWarehouseSources as b, TextBlock as c, isClearBlock as d, isLinesBlock as f, HEALTH_CHECK_STEP as g, Icons as h, FUNNEL_BLOCK as i, computeVisibleRange as l, Colors as m, integrationRunStep as n, PRODUCT_SUITE_BLOCK as o, isObjectBlock as p, posthogIntegrationConfig as r, StatusPeekTrigger as s, SETUP_REPORT_FILE as t, wordWrap as u, detectWarehousePrerequisites as v, gatherFrameworkContext as w, detectIntegrationProjects as x, getDetectedWarehouseSources as y };
3887
3917
 
3888
- //# sourceMappingURL=posthog-integration-DbZ2oza2.js.map
3918
+ //# sourceMappingURL=posthog-integration-CoAID6XW.js.map