@arizeai/phoenix-cli 1.8.0 → 1.9.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 (249) hide show
  1. package/README.md +42 -0
  2. package/build/cli.d.ts.map +1 -1
  3. package/build/cli.js +2 -1
  4. package/build/cli.js.map +1 -1
  5. package/build/client.d.ts +5 -1
  6. package/build/client.d.ts.map +1 -1
  7. package/build/client.js +2 -1
  8. package/build/client.js.map +1 -1
  9. package/build/commands/annotationConfig.d.ts.map +1 -1
  10. package/build/commands/annotationConfig.js.map +1 -1
  11. package/build/commands/{annotationMutationUtils.d.ts → annotationMutations.d.ts} +1 -1
  12. package/build/commands/annotationMutations.d.ts.map +1 -0
  13. package/build/commands/{annotationMutationUtils.js → annotationMutations.js} +1 -1
  14. package/build/commands/annotationMutations.js.map +1 -0
  15. package/build/commands/api.d.ts.map +1 -1
  16. package/build/commands/api.js.map +1 -1
  17. package/build/commands/auth.d.ts +1 -1
  18. package/build/commands/auth.d.ts.map +1 -1
  19. package/build/commands/auth.js +6 -12
  20. package/build/commands/auth.js.map +1 -1
  21. package/build/commands/dataset.d.ts.map +1 -1
  22. package/build/commands/dataset.js.map +1 -1
  23. package/build/commands/docs.d.ts +51 -0
  24. package/build/commands/docs.d.ts.map +1 -1
  25. package/build/commands/docs.js +86 -37
  26. package/build/commands/docs.js.map +1 -1
  27. package/build/commands/experiment.d.ts.map +1 -1
  28. package/build/commands/experiment.js.map +1 -1
  29. package/build/commands/fetchSpanAnnotations.d.ts +14 -0
  30. package/build/commands/fetchSpanAnnotations.d.ts.map +1 -0
  31. package/build/commands/fetchSpanAnnotations.js +57 -0
  32. package/build/commands/fetchSpanAnnotations.js.map +1 -0
  33. package/build/commands/fetchTraceAnnotations.d.ts +14 -0
  34. package/build/commands/fetchTraceAnnotations.d.ts.map +1 -0
  35. package/build/commands/fetchTraceAnnotations.js +57 -0
  36. package/build/commands/fetchTraceAnnotations.js.map +1 -0
  37. package/build/commands/formatAnnotationMutation.d.ts +1 -1
  38. package/build/commands/formatAnnotationMutation.d.ts.map +1 -1
  39. package/build/commands/formatNoteMutation.d.ts +1 -1
  40. package/build/commands/formatNoteMutation.d.ts.map +1 -1
  41. package/build/commands/formatSetup.d.ts +50 -0
  42. package/build/commands/formatSetup.d.ts.map +1 -0
  43. package/build/commands/formatSetup.js +64 -0
  44. package/build/commands/formatSetup.js.map +1 -0
  45. package/build/commands/index.d.ts +4 -3
  46. package/build/commands/index.d.ts.map +1 -1
  47. package/build/commands/index.js +4 -3
  48. package/build/commands/index.js.map +1 -1
  49. package/build/commands/{noteMutationUtils.d.ts → noteMutations.d.ts} +1 -1
  50. package/build/commands/noteMutations.d.ts.map +1 -0
  51. package/build/commands/{noteMutationUtils.js → noteMutations.js} +1 -1
  52. package/build/commands/noteMutations.js.map +1 -0
  53. package/build/commands/options.d.ts +248 -0
  54. package/build/commands/options.d.ts.map +1 -0
  55. package/build/commands/options.js +16 -0
  56. package/build/commands/options.js.map +1 -0
  57. package/build/commands/profile.d.ts.map +1 -1
  58. package/build/commands/profile.js +3 -11
  59. package/build/commands/profile.js.map +1 -1
  60. package/build/commands/project.d.ts.map +1 -1
  61. package/build/commands/project.js +0 -1
  62. package/build/commands/project.js.map +1 -1
  63. package/build/commands/prompt.d.ts.map +1 -1
  64. package/build/commands/prompt.js.map +1 -1
  65. package/build/commands/self.d.ts.map +1 -1
  66. package/build/commands/self.js.map +1 -1
  67. package/build/commands/session.d.ts.map +1 -1
  68. package/build/commands/session.js +4 -4
  69. package/build/commands/session.js.map +1 -1
  70. package/build/commands/{sessionAnnotationsCommand.d.ts → sessionAnnotations.d.ts} +1 -1
  71. package/build/commands/sessionAnnotations.d.ts.map +1 -0
  72. package/build/commands/{sessionAnnotationsCommand.js → sessionAnnotations.js} +1 -1
  73. package/build/commands/sessionAnnotations.js.map +1 -0
  74. package/build/commands/setup.d.ts +19 -0
  75. package/build/commands/setup.d.ts.map +1 -0
  76. package/build/commands/setup.js +245 -0
  77. package/build/commands/setup.js.map +1 -0
  78. package/build/commands/span.d.ts.map +1 -1
  79. package/build/commands/span.js +5 -5
  80. package/build/commands/span.js.map +1 -1
  81. package/build/commands/spanAnnotations.d.ts +6 -13
  82. package/build/commands/spanAnnotations.d.ts.map +1 -1
  83. package/build/commands/spanAnnotations.js +154 -47
  84. package/build/commands/spanAnnotations.js.map +1 -1
  85. package/build/commands/trace.d.ts.map +1 -1
  86. package/build/commands/trace.js +6 -6
  87. package/build/commands/trace.js.map +1 -1
  88. package/build/commands/traceAnnotations.d.ts +6 -13
  89. package/build/commands/traceAnnotations.d.ts.map +1 -1
  90. package/build/commands/traceAnnotations.js +157 -47
  91. package/build/commands/traceAnnotations.js.map +1 -1
  92. package/build/config.d.ts +4 -1
  93. package/build/config.d.ts.map +1 -1
  94. package/build/config.js +67 -11
  95. package/build/config.js.map +1 -1
  96. package/build/curl.d.ts +17 -0
  97. package/build/curl.d.ts.map +1 -1
  98. package/build/curl.js.map +1 -1
  99. package/build/exitCodes.d.ts.map +1 -1
  100. package/build/optionParsers.d.ts +12 -0
  101. package/build/optionParsers.d.ts.map +1 -1
  102. package/build/optionParsers.js +15 -0
  103. package/build/optionParsers.js.map +1 -1
  104. package/build/pxi/App.d.ts.map +1 -1
  105. package/build/pxi/App.js +4 -0
  106. package/build/pxi/App.js.map +1 -1
  107. package/build/pxi/index.js.map +1 -1
  108. package/build/pxi/options.d.ts +98 -0
  109. package/build/pxi/options.d.ts.map +1 -1
  110. package/build/pxi/options.js.map +1 -1
  111. package/build/settings.d.ts.map +1 -1
  112. package/build/settings.js +4 -0
  113. package/build/settings.js.map +1 -1
  114. package/build/setup/agents/registry.d.ts +78 -0
  115. package/build/setup/agents/registry.d.ts.map +1 -0
  116. package/build/setup/agents/registry.js +129 -0
  117. package/build/setup/agents/registry.js.map +1 -0
  118. package/build/setup/copy.d.ts +167 -0
  119. package/build/setup/copy.d.ts.map +1 -0
  120. package/build/setup/copy.js +290 -0
  121. package/build/setup/copy.js.map +1 -0
  122. package/build/setup/deps/buildDefaultDeps.d.ts +13 -0
  123. package/build/setup/deps/buildDefaultDeps.d.ts.map +1 -0
  124. package/build/setup/deps/buildDefaultDeps.js +29 -0
  125. package/build/setup/deps/buildDefaultDeps.js.map +1 -0
  126. package/build/setup/deps/clipboard.d.ts +12 -0
  127. package/build/setup/deps/clipboard.d.ts.map +1 -0
  128. package/build/setup/deps/clipboard.js +30 -0
  129. package/build/setup/deps/clipboard.js.map +1 -0
  130. package/build/setup/deps/clock.d.ts +10 -0
  131. package/build/setup/deps/clock.d.ts.map +1 -0
  132. package/build/setup/deps/clock.js +11 -0
  133. package/build/setup/deps/clock.js.map +1 -0
  134. package/build/setup/deps/context.d.ts +28 -0
  135. package/build/setup/deps/context.d.ts.map +1 -0
  136. package/build/setup/deps/context.js +24 -0
  137. package/build/setup/deps/context.js.map +1 -0
  138. package/build/setup/deps/docs.d.ts +41 -0
  139. package/build/setup/deps/docs.d.ts.map +1 -0
  140. package/build/setup/deps/docs.js +33 -0
  141. package/build/setup/deps/docs.js.map +1 -0
  142. package/build/setup/deps/index.d.ts +42 -0
  143. package/build/setup/deps/index.d.ts.map +1 -0
  144. package/build/setup/deps/index.js +16 -0
  145. package/build/setup/deps/index.js.map +1 -0
  146. package/build/setup/deps/phoenixClient.d.ts +22 -0
  147. package/build/setup/deps/phoenixClient.d.ts.map +1 -0
  148. package/build/setup/deps/phoenixClient.js +17 -0
  149. package/build/setup/deps/phoenixClient.js.map +1 -0
  150. package/build/setup/deps/processes.d.ts +28 -0
  151. package/build/setup/deps/processes.d.ts.map +1 -0
  152. package/build/setup/deps/processes.js +58 -0
  153. package/build/setup/deps/processes.js.map +1 -0
  154. package/build/setup/deps/prompter.d.ts +42 -0
  155. package/build/setup/deps/prompter.d.ts.map +1 -0
  156. package/build/setup/deps/prompter.js +10 -0
  157. package/build/setup/deps/prompter.js.map +1 -0
  158. package/build/setup/errors.d.ts +27 -0
  159. package/build/setup/errors.d.ts.map +1 -0
  160. package/build/setup/errors.js +36 -0
  161. package/build/setup/errors.js.map +1 -0
  162. package/build/setup/options.d.ts +113 -0
  163. package/build/setup/options.d.ts.map +1 -0
  164. package/build/setup/options.js +63 -0
  165. package/build/setup/options.js.map +1 -0
  166. package/build/setup/prompts/instrumentationPrompt.d.ts +42 -0
  167. package/build/setup/prompts/instrumentationPrompt.d.ts.map +1 -0
  168. package/build/setup/prompts/instrumentationPrompt.js +64 -0
  169. package/build/setup/prompts/instrumentationPrompt.js.map +1 -0
  170. package/build/setup/runSetup.d.ts +45 -0
  171. package/build/setup/runSetup.d.ts.map +1 -0
  172. package/build/setup/runSetup.js +212 -0
  173. package/build/setup/runSetup.js.map +1 -0
  174. package/build/setup/steps/chooseEndpoint.d.ts +36 -0
  175. package/build/setup/steps/chooseEndpoint.d.ts.map +1 -0
  176. package/build/setup/steps/chooseEndpoint.js +125 -0
  177. package/build/setup/steps/chooseEndpoint.js.map +1 -0
  178. package/build/setup/steps/confirmGitSafety.d.ts +17 -0
  179. package/build/setup/steps/confirmGitSafety.d.ts.map +1 -0
  180. package/build/setup/steps/confirmGitSafety.js +73 -0
  181. package/build/setup/steps/confirmGitSafety.js.map +1 -0
  182. package/build/setup/steps/establishConnection.d.ts +29 -0
  183. package/build/setup/steps/establishConnection.d.ts.map +1 -0
  184. package/build/setup/steps/establishConnection.js +143 -0
  185. package/build/setup/steps/establishConnection.js.map +1 -0
  186. package/build/setup/steps/installTooling.d.ts +28 -0
  187. package/build/setup/steps/installTooling.d.ts.map +1 -0
  188. package/build/setup/steps/installTooling.js +79 -0
  189. package/build/setup/steps/installTooling.js.map +1 -0
  190. package/build/setup/steps/instrumentApp.d.ts +41 -0
  191. package/build/setup/steps/instrumentApp.d.ts.map +1 -0
  192. package/build/setup/steps/instrumentApp.js +131 -0
  193. package/build/setup/steps/instrumentApp.js.map +1 -0
  194. package/build/setup/steps/offerPxProfile.d.ts +20 -0
  195. package/build/setup/steps/offerPxProfile.d.ts.map +1 -0
  196. package/build/setup/steps/offerPxProfile.js +95 -0
  197. package/build/setup/steps/offerPxProfile.js.map +1 -0
  198. package/build/setup/steps/prefetchDocs.d.ts +24 -0
  199. package/build/setup/steps/prefetchDocs.d.ts.map +1 -0
  200. package/build/setup/steps/prefetchDocs.js +49 -0
  201. package/build/setup/steps/prefetchDocs.js.map +1 -0
  202. package/build/setup/steps/verifyTraces.d.ts +44 -0
  203. package/build/setup/steps/verifyTraces.d.ts.map +1 -0
  204. package/build/setup/steps/verifyTraces.js +119 -0
  205. package/build/setup/steps/verifyTraces.js.map +1 -0
  206. package/build/setup/steps/writeEnvFile.d.ts +19 -0
  207. package/build/setup/steps/writeEnvFile.d.ts.map +1 -0
  208. package/build/setup/steps/writeEnvFile.js +50 -0
  209. package/build/setup/steps/writeEnvFile.js.map +1 -0
  210. package/build/setup/ui/clackPrompter.d.ts +11 -0
  211. package/build/setup/ui/clackPrompter.d.ts.map +1 -0
  212. package/build/setup/ui/clackPrompter.js +107 -0
  213. package/build/setup/ui/clackPrompter.js.map +1 -0
  214. package/build/setup/ui/selectBoolean.d.ts +18 -0
  215. package/build/setup/ui/selectBoolean.d.ts.map +1 -0
  216. package/build/setup/ui/selectBoolean.js +14 -0
  217. package/build/setup/ui/selectBoolean.js.map +1 -0
  218. package/build/setup/util/gitignoreCoverage.d.ts +24 -0
  219. package/build/setup/util/gitignoreCoverage.d.ts.map +1 -0
  220. package/build/setup/util/gitignoreCoverage.js +43 -0
  221. package/build/setup/util/gitignoreCoverage.js.map +1 -0
  222. package/build/setup/util/paths.d.ts +6 -0
  223. package/build/setup/util/paths.d.ts.map +1 -0
  224. package/build/setup/util/paths.js +23 -0
  225. package/build/setup/util/paths.js.map +1 -0
  226. package/build/setup/util/redact.d.ts +12 -0
  227. package/build/setup/util/redact.d.ts.map +1 -0
  228. package/build/setup/util/redact.js +31 -0
  229. package/build/setup/util/redact.js.map +1 -0
  230. package/build/validation/endpoint.d.ts +19 -0
  231. package/build/validation/endpoint.d.ts.map +1 -0
  232. package/build/validation/endpoint.js +39 -0
  233. package/build/validation/endpoint.js.map +1 -0
  234. package/build/version.js.map +1 -1
  235. package/package.json +15 -12
  236. package/build/commands/annotationMutationUtils.d.ts.map +0 -1
  237. package/build/commands/annotationMutationUtils.js.map +0 -1
  238. package/build/commands/noteMutationUtils.d.ts.map +0 -1
  239. package/build/commands/noteMutationUtils.js.map +0 -1
  240. package/build/commands/sessionAnnotationsCommand.d.ts.map +0 -1
  241. package/build/commands/sessionAnnotationsCommand.js.map +0 -1
  242. package/build/commands/spanAnnotationsCommand.d.ts +0 -7
  243. package/build/commands/spanAnnotationsCommand.d.ts.map +0 -1
  244. package/build/commands/spanAnnotationsCommand.js +0 -164
  245. package/build/commands/spanAnnotationsCommand.js.map +0 -1
  246. package/build/commands/traceAnnotationsCommand.d.ts +0 -7
  247. package/build/commands/traceAnnotationsCommand.d.ts.map +0 -1
  248. package/build/commands/traceAnnotationsCommand.js +0 -167
  249. package/build/commands/traceAnnotationsCommand.js.map +0 -1
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The setup step sequence, and nothing else.
3
+ *
4
+ * All effects flow through `SetupDeps`; all strings live in `copy.ts`;
5
+ * cancellation unwinds via `SetupCancelledError` to the command handler.
6
+ *
7
+ * Three entry points, composed from the same steps:
8
+ * - `runSetup` — the whole flow (`px setup`)
9
+ * - `runInstrument` — register, then instrument and verify (`px setup instrument`)
10
+ * - `runSkills` — the tooling installs alone (`px setup skills`)
11
+ * Each returns a {@link SetupReport}, which the command layer renders in the
12
+ * requested `--format`.
13
+ */
14
+ import type { DocsPrefetchResult, SetupDeps } from "./deps/index.js";
15
+ import type { SetupInputs } from "./options.js";
16
+ import type { Connection } from "./steps/establishConnection.js";
17
+ import { type ToolingResult } from "./steps/installTooling.js";
18
+ import { type InstrumentationLane } from "./steps/instrumentApp.js";
19
+ /** Everything a run did, in the shape the summary and `--format json` print. */
20
+ export interface SetupReport {
21
+ connection: Connection;
22
+ authEnabled: boolean;
23
+ headless: boolean;
24
+ /** Files setup wrote into the repo. */
25
+ files: string[];
26
+ /** Paths appended to a .gitignore. */
27
+ gitignored: string[];
28
+ docs?: DocsPrefetchResult;
29
+ instrumentation?: InstrumentationLane;
30
+ /** True once the API confirmed a trace arrived after this run started. */
31
+ tracesVerified?: boolean;
32
+ tooling?: ToolingResult;
33
+ tracesUrl: string;
34
+ }
35
+ /** `px setup` — the whole flow. */
36
+ export declare function runSetup(deps: SetupDeps, inputs: SetupInputs): Promise<SetupReport>;
37
+ /**
38
+ * `px setup instrument` — the instrumentation slice, re-runnable on a repo that
39
+ * is already registered. Registration still runs: it is idempotent, and it is
40
+ * what produces the connection the agent and the verification step need.
41
+ */
42
+ export declare function runInstrument(deps: SetupDeps, resolved: SetupInputs): Promise<SetupReport>;
43
+ /** `px setup skills` — the tooling installs alone; no connection needed. */
44
+ export declare function runSkills(deps: SetupDeps, inputs: SetupInputs): Promise<ToolingResult>;
45
+ //# sourceMappingURL=runSetup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runSetup.d.ts","sourceRoot":"","sources":["../../src/setup/runSetup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,OAAO,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAI7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAiB,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAUhF,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,uCAAuC;IACvC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,sCAAsC;IACtC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC,0EAA0E;IAC1E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAeD,mCAAmC;AACnC,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,WAAW,CAAC,CA8CtB;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,WAAW,GACpB,OAAO,CAAC,WAAW,CAAC,CAetB;AAED,4EAA4E;AAC5E,wBAAsB,SAAS,CAC7B,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,aAAa,CAAC,CAexB"}
@@ -0,0 +1,212 @@
1
+ /**
2
+ * The setup step sequence, and nothing else.
3
+ *
4
+ * All effects flow through `SetupDeps`; all strings live in `copy.ts`;
5
+ * cancellation unwinds via `SetupCancelledError` to the command handler.
6
+ *
7
+ * Three entry points, composed from the same steps:
8
+ * - `runSetup` — the whole flow (`px setup`)
9
+ * - `runInstrument` — register, then instrument and verify (`px setup instrument`)
10
+ * - `runSkills` — the tooling installs alone (`px setup skills`)
11
+ * Each returns a {@link SetupReport}, which the command layer renders in the
12
+ * requested `--format`.
13
+ */
14
+ import { detectCodingAgents, probeGlobalBinary, } from "./agents/registry.js";
15
+ import * as COPY from "./copy.js";
16
+ import { SetupCancelledError } from "./errors.js";
17
+ import { assertAgentForHeadlessInstrument } from "./options.js";
18
+ import { chooseEndpoint } from "./steps/chooseEndpoint.js";
19
+ import { confirmGitSafety } from "./steps/confirmGitSafety.js";
20
+ import { establishConnection } from "./steps/establishConnection.js";
21
+ import { offerToolingInstalls, } from "./steps/installTooling.js";
22
+ import { instrumentApp } from "./steps/instrumentApp.js";
23
+ import { offerPxProfile } from "./steps/offerPxProfile.js";
24
+ import { prefetchDocs } from "./steps/prefetchDocs.js";
25
+ import { hasSpansInSkewWindow, waitForFirstTrace, tracesUrl, } from "./steps/verifyTraces.js";
26
+ import { ENV_FILE_NAME, writeEnvFile } from "./steps/writeEnvFile.js";
27
+ /**
28
+ * Detect the installed agents — but only when the lane is still open. `--agent`
29
+ * pins it, and the pinned agent probes its own binary, so the sweep's four
30
+ * subprocess spawns would be thrown away. Every headless instrumentation run
31
+ * names an agent, so that is exactly where the waste would land.
32
+ */
33
+ function detectAgentsUnlessPinned(deps, inputs) {
34
+ return inputs.agent ? Promise.resolve([]) : detectCodingAgents(deps);
35
+ }
36
+ /** `px setup` — the whole flow. */
37
+ export async function runSetup(deps, inputs) {
38
+ // Started before the first prompt so the probes finish behind it; awaited
39
+ // by the instrumentation and tooling steps.
40
+ const agentDetection = detectAgentsUnlessPinned(deps, inputs);
41
+ // Probed with package-runner bin dirs stripped from PATH — under
42
+ // `npx @arizeai/phoenix-cli setup`, the package's own `px` shim must not
43
+ // masquerade as a global install and suppress the CLI-install offer.
44
+ const pxOnPath = probeGlobalBinary(deps, "px");
45
+ if (!inputs.headless) {
46
+ deps.prompter.intro(COPY.INTRO);
47
+ }
48
+ const report = await registerAndInstrument(deps, inputs, { agentDetection });
49
+ // A headless run stops here: the tooling offers are prompts, and its stdout
50
+ // belongs to the summary.
51
+ if (inputs.headless) {
52
+ return report;
53
+ }
54
+ // Tooling opt-ins come after the verified-trace moment so nothing stands
55
+ // between launch and first trace: point px at this project, then install the
56
+ // CLI and skills so the user (and their coding agent) can look at the traces
57
+ // now flowing.
58
+ await offerPxProfile(deps, {
59
+ connection: report.connection,
60
+ settingsPath: deps.context.settingsPath,
61
+ });
62
+ const tooling = await offerToolingInstalls(deps, {
63
+ pxOnPath,
64
+ skills: inputs.skills,
65
+ canPrompt: true,
66
+ });
67
+ deps.prompter.note(report.authEnabled
68
+ ? COPY.PRODUCTION.bodyAuthOn
69
+ : COPY.PRODUCTION.bodyAuthOff, COPY.PRODUCTION.title);
70
+ // Untitled: the outro below already says it, and closes the rail.
71
+ deps.prompter.note(COPY.OUTRO_BODY);
72
+ deps.prompter.outro(COPY.OUTRO_TITLE);
73
+ return { ...report, tooling };
74
+ }
75
+ /**
76
+ * `px setup instrument` — the instrumentation slice, re-runnable on a repo that
77
+ * is already registered. Registration still runs: it is idempotent, and it is
78
+ * what produces the connection the agent and the verification step need.
79
+ */
80
+ export async function runInstrument(deps, resolved) {
81
+ // This lane instruments by definition, so it never passes `--instrument` for
82
+ // `resolveSetupInputs` to have guarded — check the headless rule here.
83
+ assertAgentForHeadlessInstrument(resolved);
84
+ const inputs = { ...resolved, instrument: true };
85
+ const agentDetection = detectAgentsUnlessPinned(deps, inputs);
86
+ if (!inputs.headless) {
87
+ deps.prompter.intro(COPY.INTRO_INSTRUMENT);
88
+ }
89
+ const report = await registerAndInstrument(deps, inputs, { agentDetection });
90
+ if (!inputs.headless) {
91
+ deps.prompter.outro(COPY.OUTRO_TITLE);
92
+ }
93
+ return report;
94
+ }
95
+ /** `px setup skills` — the tooling installs alone; no connection needed. */
96
+ export async function runSkills(deps, inputs) {
97
+ const pxOnPath = probeGlobalBinary(deps, "px");
98
+ if (!inputs.headless) {
99
+ deps.prompter.intro(COPY.INTRO_SKILLS);
100
+ }
101
+ const tooling = await offerToolingInstalls(deps, {
102
+ pxOnPath,
103
+ skills: inputs.skills,
104
+ canPrompt: !inputs.headless,
105
+ });
106
+ if (!inputs.headless) {
107
+ deps.prompter.outro(COPY.OUTRO_TITLE);
108
+ }
109
+ return tooling;
110
+ }
111
+ /**
112
+ * Register, then — when asked — prefetch docs, hand off to the agent, and
113
+ * verify traces. The shared spine of `px setup` and `px setup instrument`.
114
+ */
115
+ async function registerAndInstrument(deps, inputs, { agentDetection }) {
116
+ const registration = await register(deps, inputs);
117
+ const { connection, authEnabled, gitignoreAppended } = registration;
118
+ const base = {
119
+ connection,
120
+ authEnabled,
121
+ headless: inputs.headless,
122
+ files: [ENV_FILE_NAME],
123
+ gitignored: gitignoreAppended,
124
+ tracesUrl: tracesUrl(connection),
125
+ };
126
+ if (!inputs.instrument) {
127
+ return base;
128
+ }
129
+ // Only after registration's git-safety gate: the docs fetch writes into
130
+ // `.px/`, which an earlier download can make look like a pre-existing dirty
131
+ // tree in a fast or cached headless run.
132
+ const docs = await prefetchDocs(deps, {
133
+ docs: inputs.docs,
134
+ isGitRepository: registration.isGitRepository,
135
+ });
136
+ const startedAt = deps.clock.now();
137
+ // Any span already visible inside the clock-skew window predates this run —
138
+ // verification must then require spans strictly after the start time, or a
139
+ // pre-existing trace would falsely verify the hand-off.
140
+ const hadRecentSpans = await hasSpansInSkewWindow(deps, connection, {
141
+ sinceMs: startedAt,
142
+ });
143
+ const instrumentation = await instrumentApp(deps, connection, {
144
+ authEnabled,
145
+ agentDetection,
146
+ agent: inputs.agent,
147
+ languages: inputs.languages,
148
+ mode: {
149
+ background: inputs.background,
150
+ bypassPermissions: inputs.bypassPermissions,
151
+ },
152
+ ...(docs ? { docs } : {}),
153
+ });
154
+ // The return value is setup's definition of done — a trace the API confirmed
155
+ // arriving, not the agent's own claim that it finished. It is reported, not
156
+ // thrown on: the connection and hand-off files are real work worth keeping
157
+ // even when no trace showed up.
158
+ const tracesVerified = await waitForFirstTrace(deps, connection, {
159
+ sinceMs: startedAt,
160
+ allowClockSkew: !hadRecentSpans,
161
+ headless: inputs.headless,
162
+ });
163
+ return {
164
+ ...base,
165
+ ...(docs ? { docs } : {}),
166
+ // The docs step gitignores its own output dir, so the report has to fold
167
+ // those appends in or it under-states what setup touched.
168
+ gitignored: [...base.gitignored, ...(docs?.gitignoreAppended ?? [])],
169
+ instrumentation,
170
+ tracesVerified,
171
+ };
172
+ }
173
+ /**
174
+ * Git safety, endpoint, connection, env file — the part every lane shares, and
175
+ * all a registration-only run performs.
176
+ */
177
+ async function register(deps, inputs) {
178
+ const { headless } = inputs;
179
+ const git = await confirmGitSafety(deps, { headless });
180
+ if (!git.proceed) {
181
+ throw new SetupCancelledError();
182
+ }
183
+ // The hidden --api-url dev flag never reaches this endpoint — it is applied
184
+ // as the client's base URL in buildDefaultDeps, so API traffic is rerouted
185
+ // while hand-off files, the px profile, and traces URLs keep the endpoint
186
+ // resolved here.
187
+ const endpointChoice = await chooseEndpoint(deps, {
188
+ presetEndpoint: inputs.endpoint,
189
+ headless,
190
+ });
191
+ const connection = await establishConnection(deps, {
192
+ endpoint: endpointChoice.endpoint,
193
+ authEnabled: endpointChoice.authEnabled,
194
+ inputs,
195
+ });
196
+ const envFile = writeEnvFile(deps, connection, {
197
+ isGitRepository: git.isGitRepository,
198
+ });
199
+ if (!headless) {
200
+ deps.prompter.line(COPY.ENV_FILE.wrote([ENV_FILE_NAME]));
201
+ if (envFile.gitignoreAppended.length > 0) {
202
+ deps.prompter.line(COPY.ENV_FILE.gitignored(envFile.gitignoreAppended));
203
+ }
204
+ }
205
+ return {
206
+ connection,
207
+ authEnabled: endpointChoice.authEnabled,
208
+ gitignoreAppended: envFile.gitignoreAppended,
209
+ isGitRepository: git.isGitRepository,
210
+ };
211
+ }
212
+ //# sourceMappingURL=runSetup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runSetup.js","sourceRoot":"","sources":["../../src/setup/runSetup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAEL,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAE,gCAAgC,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CA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C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;IAED,OAAO;QACL,UAAU;QACV,WAAW,EAAE,cAAc,CAAC,WAAW;QACvC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;QAC5C,eAAe,EAAE,GAAG,CAAC,eAAe;KACrC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Choose the endpoint: where Phoenix is, and whether it wants an API key.
3
+ *
4
+ * Two options — Local or Remote ("paste your instance URL"). The probe is
5
+ * an unauthenticated
6
+ * `GET /v1/projects?limit=1`: 200 → auth off, 401/403 → auth on, anything
7
+ * else → troubleshoot copy and re-ask (max 3 attempts).
8
+ */
9
+ import type { SetupDeps } from "../deps/index.js";
10
+ export interface EndpointChoice {
11
+ /** Normalized origin, no trailing slash. */
12
+ endpoint: string;
13
+ authEnabled: boolean;
14
+ }
15
+ export type ProbeOutcome = {
16
+ kind: "authOff";
17
+ } | {
18
+ kind: "authOn";
19
+ } | {
20
+ kind: "unreachable";
21
+ detail: string;
22
+ } | {
23
+ kind: "notPhoenix";
24
+ detail: string;
25
+ };
26
+ /**
27
+ * Probe an endpoint to determine reachability and whether auth is enabled.
28
+ */
29
+ export declare function probeEndpoint(deps: Pick<SetupDeps, "createClient">, endpoint: string): Promise<ProbeOutcome>;
30
+ export interface ChooseEndpointArgs {
31
+ /** Pre-answered endpoint from --endpoint / env (skips the select). */
32
+ presetEndpoint?: string;
33
+ headless: boolean;
34
+ }
35
+ export declare function chooseEndpoint(deps: Pick<SetupDeps, "createClient" | "prompter">, { presetEndpoint, headless }: ChooseEndpointArgs): Promise<EndpointChoice>;
36
+ //# sourceMappingURL=chooseEndpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chooseEndpoint.d.ts","sourceRoot":"","sources":["../../../src/setup/steps/chooseEndpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAQzC,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB;AAMD,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3C;;GAEG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,EACrC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,CAAC,CAsBvB;AA+BD,MAAM,WAAW,kBAAkB;IACjC,sEAAsE;IACtE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,cAAc,GAAG,UAAU,CAAC,EAClD,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,kBAAkB,GAC/C,OAAO,CAAC,cAAc,CAAC,CA+DzB"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Choose the endpoint: where Phoenix is, and whether it wants an API key.
3
+ *
4
+ * Two options — Local or Remote ("paste your instance URL"). The probe is
5
+ * an unauthenticated
6
+ * `GET /v1/projects?limit=1`: 200 → auth off, 401/403 → auth on, anything
7
+ * else → troubleshoot copy and re-ask (max 3 attempts).
8
+ */
9
+ import { HttpError } from "@arizeai/phoenix-client";
10
+ import { isEndpointUrl, normalizeEndpoint } from "../../validation/endpoint.js";
11
+ import * as COPY from "../copy.js";
12
+ import { HeadlessInputError, SetupCancelledError, SetupFatalError, } from "../errors.js";
13
+ import { redactForDisplay } from "../util/redact.js";
14
+ const PROBE_TIMEOUT_MS = 10_000;
15
+ const MAX_ATTEMPTS = 3;
16
+ const DEFAULT_LOCAL_ENDPOINT = "http://localhost:6006";
17
+ /**
18
+ * Probe an endpoint to determine reachability and whether auth is enabled.
19
+ */
20
+ export async function probeEndpoint(deps, endpoint) {
21
+ const client = deps.createClient({ endpoint });
22
+ try {
23
+ await client.GET("/v1/projects", {
24
+ params: { query: { limit: 1 } },
25
+ signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),
26
+ });
27
+ return { kind: "authOff" };
28
+ }
29
+ catch (error) {
30
+ if (error instanceof HttpError) {
31
+ if (error.status === 401 || error.status === 403) {
32
+ return { kind: "authOn" };
33
+ }
34
+ return { kind: "notPhoenix", detail: `HTTP ${error.status}` };
35
+ }
36
+ // A 2xx whose body will not parse: something is listening, but it is not
37
+ // the Phoenix API.
38
+ if (error instanceof SyntaxError) {
39
+ return { kind: "notPhoenix", detail: COPY.ENDPOINT.unexpectedBody };
40
+ }
41
+ return { kind: "unreachable", detail: redactForDisplay(String(error)) };
42
+ }
43
+ }
44
+ async function promptForEndpoint(deps) {
45
+ const choice = await deps.prompter.select({
46
+ message: COPY.ENDPOINT.selectMessage,
47
+ options: [
48
+ {
49
+ value: "local",
50
+ label: COPY.ENDPOINT.localLabel,
51
+ hint: COPY.ENDPOINT.localHint,
52
+ },
53
+ {
54
+ value: "remote",
55
+ label: COPY.ENDPOINT.remoteLabel,
56
+ hint: COPY.ENDPOINT.remoteHint,
57
+ },
58
+ ],
59
+ });
60
+ if (choice === "local") {
61
+ return DEFAULT_LOCAL_ENDPOINT;
62
+ }
63
+ const url = await deps.prompter.textInput({
64
+ message: COPY.ENDPOINT.remoteUrlMessage,
65
+ validate: (value) => isEndpointUrl(value) ? undefined : COPY.ENDPOINT.remoteUrlInvalid,
66
+ });
67
+ return url;
68
+ }
69
+ export async function chooseEndpoint(deps, { presetEndpoint, headless }) {
70
+ let attempts = 0;
71
+ let candidate = presetEndpoint;
72
+ for (;;) {
73
+ if (candidate === undefined) {
74
+ if (headless) {
75
+ throw new HeadlessInputError(COPY.ENDPOINT.headlessNeedsEndpoint);
76
+ }
77
+ candidate = await promptForEndpoint(deps);
78
+ }
79
+ let endpoint;
80
+ try {
81
+ endpoint = normalizeEndpoint(candidate);
82
+ }
83
+ catch {
84
+ if (headless) {
85
+ throw new HeadlessInputError(COPY.ENDPOINT.remoteUrlInvalid);
86
+ }
87
+ deps.prompter.line(COPY.ENDPOINT.remoteUrlInvalid);
88
+ candidate = undefined;
89
+ continue;
90
+ }
91
+ deps.prompter.line(COPY.ENDPOINT.probing(endpoint));
92
+ const outcome = await probeEndpoint(deps, endpoint);
93
+ if (outcome.kind === "authOff") {
94
+ deps.prompter.line(COPY.ENDPOINT.authOff);
95
+ return { endpoint, authEnabled: false };
96
+ }
97
+ if (outcome.kind === "authOn") {
98
+ deps.prompter.line(COPY.ENDPOINT.authOn);
99
+ return { endpoint, authEnabled: true };
100
+ }
101
+ if (headless) {
102
+ throw new SetupFatalError(COPY.ENDPOINT.headlessUnreachable(endpoint));
103
+ }
104
+ attempts += 1;
105
+ deps.prompter.line(outcome.kind === "unreachable"
106
+ ? COPY.ENDPOINT.unreachable(endpoint)
107
+ : COPY.ENDPOINT.notPhoenix(endpoint, outcome.detail));
108
+ if (attempts >= MAX_ATTEMPTS) {
109
+ deps.prompter.line(COPY.ENDPOINT.gaveUp);
110
+ throw new SetupCancelledError();
111
+ }
112
+ const retry = await deps.prompter.select({
113
+ message: COPY.ENDPOINT.retryMessage,
114
+ options: [
115
+ { value: true, label: COPY.ENDPOINT.retryYes },
116
+ { value: false, label: COPY.ENDPOINT.retryNo },
117
+ ],
118
+ });
119
+ if (!retry) {
120
+ throw new SetupCancelledError();
121
+ }
122
+ candidate = undefined;
123
+ }
124
+ }
125
+ //# sourceMappingURL=chooseEndpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Confirm git can undo whatever setup is about to do.
3
+ *
4
+ * A coding agent may be about to edit files in this directory; git is the
5
+ * undo button. Both gates are opt-in selects with the safe option first.
6
+ * Headless mode proceeds only on a clean repo.
7
+ */
8
+ import type { SetupDeps } from "../deps/index.js";
9
+ export interface GitSafetyResult {
10
+ isGitRepository: boolean;
11
+ /** False when the user chose to stop at a gate. */
12
+ proceed: boolean;
13
+ }
14
+ export declare function confirmGitSafety(deps: Pick<SetupDeps, "context" | "processes" | "prompter">, { headless }: {
15
+ headless: boolean;
16
+ }): Promise<GitSafetyResult>;
17
+ //# sourceMappingURL=confirmGitSafety.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmGitSafety.d.ts","sourceRoot":"","sources":["../../../src/setup/steps/confirmGitSafety.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIzC,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,mDAAmD;IACnD,OAAO,EAAE,OAAO,CAAC;CAClB;AAID,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC,EAC3D,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,GAClC,OAAO,CAAC,eAAe,CAAC,CAmE1B"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Confirm git can undo whatever setup is about to do.
3
+ *
4
+ * A coding agent may be about to edit files in this directory; git is the
5
+ * undo button. Both gates are opt-in selects with the safe option first.
6
+ * Headless mode proceeds only on a clean repo.
7
+ */
8
+ import * as COPY from "../copy.js";
9
+ import { SetupFatalError } from "../errors.js";
10
+ import { selectBoolean } from "../ui/selectBoolean.js";
11
+ const MAX_LISTED_FILES = 20;
12
+ export async function confirmGitSafety(deps, { headless }) {
13
+ const repoCheck = await deps.processes.exec({
14
+ command: "git",
15
+ args: ["rev-parse", "--is-inside-work-tree"],
16
+ cwd: deps.context.cwd,
17
+ });
18
+ const isGitRepository = repoCheck.exitCode === 0 && repoCheck.stdout.trim() === "true";
19
+ if (!isGitRepository) {
20
+ // `git` missing entirely is treated the same as "not a repo".
21
+ if (headless) {
22
+ throw new SetupFatalError(COPY.GIT.headlessNotARepo);
23
+ }
24
+ const proceed = await selectBoolean({
25
+ prompter: deps.prompter,
26
+ message: COPY.GIT.notARepoMessage,
27
+ noFirst: true,
28
+ noLabel: COPY.GIT.notARepoNo,
29
+ noHint: COPY.GIT.notARepoNoHint,
30
+ yesLabel: COPY.GIT.notARepoYes,
31
+ yesHint: COPY.GIT.notARepoYesHint,
32
+ });
33
+ if (!proceed) {
34
+ deps.prompter.line(COPY.GIT.stopped);
35
+ }
36
+ return { isGitRepository, proceed };
37
+ }
38
+ const statusCheck = await deps.processes.exec({
39
+ command: "git",
40
+ args: ["status", "--porcelain=v1"],
41
+ cwd: deps.context.cwd,
42
+ });
43
+ const dirtyPaths = statusCheck.stdout
44
+ .split("\n")
45
+ .map((line) => line.trim())
46
+ .filter(Boolean);
47
+ if (dirtyPaths.length === 0) {
48
+ return { isGitRepository, proceed: true };
49
+ }
50
+ if (headless) {
51
+ throw new SetupFatalError(COPY.GIT.headlessDirty);
52
+ }
53
+ const shown = dirtyPaths.slice(0, MAX_LISTED_FILES);
54
+ const lines = [...shown];
55
+ if (dirtyPaths.length > MAX_LISTED_FILES) {
56
+ lines.push(COPY.GIT.andMore(dirtyPaths.length - MAX_LISTED_FILES));
57
+ }
58
+ deps.prompter.note(lines.join("\n"), COPY.GIT.dirtyFileListTitle);
59
+ const proceed = await selectBoolean({
60
+ prompter: deps.prompter,
61
+ message: COPY.GIT.dirtyMessage(dirtyPaths.length),
62
+ noFirst: true,
63
+ noLabel: COPY.GIT.dirtyNo,
64
+ noHint: COPY.GIT.dirtyNoHint,
65
+ yesLabel: COPY.GIT.dirtyYes,
66
+ yesHint: COPY.GIT.dirtyYesHint,
67
+ });
68
+ if (!proceed) {
69
+ deps.prompter.line(COPY.GIT.stopped);
70
+ }
71
+ return { isGitRepository, proceed };
72
+ }
73
+ //# sourceMappingURL=confirmGitSafety.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmGitSafety.js","sourceRoot":"","sources":["../../../src/setup/steps/confirmGitSafety.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAQpD,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAA2D,EAC3D,EAAE,QAAQ,EAAyB;IAEnC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QAC1C,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,CAAC,WAAW,EAAE,uBAAuB,CAAC;QAC5C,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG;KACtB,CAAC,CAAC;IACH,MAAM,eAAe,GACnB,SAAS,CAAC,QAAQ,KAAK,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC;IAEjE,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,8DAA8D;QAC9D,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QACvD,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;YAClC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,eAAe;YACjC,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI,CAAC,GAA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,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAElE,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;QAClC,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC;QACjD,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO;QACzB,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW;QAC5B,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ;QAC3B,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,YAAY;KAC/B,CAAC,CAAC;IACH,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Establish the connection.
3
+ *
4
+ * The project itself is never created here — Phoenix creates a project on
5
+ * first ingestion, so setup only needs to settle on a *name* and hand it
6
+ * to the app via `PHOENIX_PROJECT_NAME`. What remains is credential
7
+ * acquisition: the auth-on lanes verify the key with a read-only probe so a
8
+ * bad paste is caught here rather than at first trace. Future OAuth
9
+ * acquisition plugs into the auth-on interactive lane unchanged.
10
+ */
11
+ import type { SetupDeps } from "../deps/index.js";
12
+ import type { SetupInputs } from "../options.js";
13
+ export interface Connection {
14
+ /** Normalized origin, no trailing slash. */
15
+ endpoint: string;
16
+ projectName: string;
17
+ /** Present iff auth is enabled on the deployment. */
18
+ apiKey?: string;
19
+ }
20
+ /** Names are used as URL path identifiers; '/', '?', '#' are invalid. */
21
+ export declare function validateProjectName(value: string): string | undefined;
22
+ export declare function defaultProjectName(cwd: string): string;
23
+ export interface EstablishConnectionArgs {
24
+ endpoint: string;
25
+ authEnabled: boolean;
26
+ inputs: SetupInputs;
27
+ }
28
+ export declare function establishConnection(deps: Pick<SetupDeps, "context" | "createClient" | "prompter">, { endpoint, authEnabled, inputs }: EstablishConnectionArgs): Promise<Connection>;
29
+ //# sourceMappingURL=establishConnection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"establishConnection.d.ts","sourceRoot":"","sources":["../../../src/setup/steps/establishConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C,MAAM,WAAW,UAAU;IACzB,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAQD,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMrE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGtD;AA+ID,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,cAAc,GAAG,UAAU,CAAC,EAC9D,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,uBAAuB,GACzD,OAAO,CAAC,UAAU,CAAC,CAgBrB"}