@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.
- package/README.md +42 -0
- package/build/cli.d.ts.map +1 -1
- package/build/cli.js +2 -1
- package/build/cli.js.map +1 -1
- package/build/client.d.ts +5 -1
- package/build/client.d.ts.map +1 -1
- package/build/client.js +2 -1
- package/build/client.js.map +1 -1
- package/build/commands/annotationConfig.d.ts.map +1 -1
- package/build/commands/annotationConfig.js.map +1 -1
- package/build/commands/{annotationMutationUtils.d.ts → annotationMutations.d.ts} +1 -1
- package/build/commands/annotationMutations.d.ts.map +1 -0
- package/build/commands/{annotationMutationUtils.js → annotationMutations.js} +1 -1
- package/build/commands/annotationMutations.js.map +1 -0
- package/build/commands/api.d.ts.map +1 -1
- package/build/commands/api.js.map +1 -1
- package/build/commands/auth.d.ts +1 -1
- package/build/commands/auth.d.ts.map +1 -1
- package/build/commands/auth.js +6 -12
- package/build/commands/auth.js.map +1 -1
- package/build/commands/dataset.d.ts.map +1 -1
- package/build/commands/dataset.js.map +1 -1
- package/build/commands/docs.d.ts +51 -0
- package/build/commands/docs.d.ts.map +1 -1
- package/build/commands/docs.js +86 -37
- package/build/commands/docs.js.map +1 -1
- package/build/commands/experiment.d.ts.map +1 -1
- package/build/commands/experiment.js.map +1 -1
- package/build/commands/fetchSpanAnnotations.d.ts +14 -0
- package/build/commands/fetchSpanAnnotations.d.ts.map +1 -0
- package/build/commands/fetchSpanAnnotations.js +57 -0
- package/build/commands/fetchSpanAnnotations.js.map +1 -0
- package/build/commands/fetchTraceAnnotations.d.ts +14 -0
- package/build/commands/fetchTraceAnnotations.d.ts.map +1 -0
- package/build/commands/fetchTraceAnnotations.js +57 -0
- package/build/commands/fetchTraceAnnotations.js.map +1 -0
- package/build/commands/formatAnnotationMutation.d.ts +1 -1
- package/build/commands/formatAnnotationMutation.d.ts.map +1 -1
- package/build/commands/formatNoteMutation.d.ts +1 -1
- package/build/commands/formatNoteMutation.d.ts.map +1 -1
- package/build/commands/formatSetup.d.ts +50 -0
- package/build/commands/formatSetup.d.ts.map +1 -0
- package/build/commands/formatSetup.js +64 -0
- package/build/commands/formatSetup.js.map +1 -0
- package/build/commands/index.d.ts +4 -3
- package/build/commands/index.d.ts.map +1 -1
- package/build/commands/index.js +4 -3
- package/build/commands/index.js.map +1 -1
- package/build/commands/{noteMutationUtils.d.ts → noteMutations.d.ts} +1 -1
- package/build/commands/noteMutations.d.ts.map +1 -0
- package/build/commands/{noteMutationUtils.js → noteMutations.js} +1 -1
- package/build/commands/noteMutations.js.map +1 -0
- package/build/commands/options.d.ts +248 -0
- package/build/commands/options.d.ts.map +1 -0
- package/build/commands/options.js +16 -0
- package/build/commands/options.js.map +1 -0
- package/build/commands/profile.d.ts.map +1 -1
- package/build/commands/profile.js +3 -11
- package/build/commands/profile.js.map +1 -1
- package/build/commands/project.d.ts.map +1 -1
- package/build/commands/project.js +0 -1
- package/build/commands/project.js.map +1 -1
- package/build/commands/prompt.d.ts.map +1 -1
- package/build/commands/prompt.js.map +1 -1
- package/build/commands/self.d.ts.map +1 -1
- package/build/commands/self.js.map +1 -1
- package/build/commands/session.d.ts.map +1 -1
- package/build/commands/session.js +4 -4
- package/build/commands/session.js.map +1 -1
- package/build/commands/{sessionAnnotationsCommand.d.ts → sessionAnnotations.d.ts} +1 -1
- package/build/commands/sessionAnnotations.d.ts.map +1 -0
- package/build/commands/{sessionAnnotationsCommand.js → sessionAnnotations.js} +1 -1
- package/build/commands/sessionAnnotations.js.map +1 -0
- package/build/commands/setup.d.ts +19 -0
- package/build/commands/setup.d.ts.map +1 -0
- package/build/commands/setup.js +245 -0
- package/build/commands/setup.js.map +1 -0
- package/build/commands/span.d.ts.map +1 -1
- package/build/commands/span.js +5 -5
- package/build/commands/span.js.map +1 -1
- package/build/commands/spanAnnotations.d.ts +6 -13
- package/build/commands/spanAnnotations.d.ts.map +1 -1
- package/build/commands/spanAnnotations.js +154 -47
- package/build/commands/spanAnnotations.js.map +1 -1
- package/build/commands/trace.d.ts.map +1 -1
- package/build/commands/trace.js +6 -6
- package/build/commands/trace.js.map +1 -1
- package/build/commands/traceAnnotations.d.ts +6 -13
- package/build/commands/traceAnnotations.d.ts.map +1 -1
- package/build/commands/traceAnnotations.js +157 -47
- package/build/commands/traceAnnotations.js.map +1 -1
- package/build/config.d.ts +4 -1
- package/build/config.d.ts.map +1 -1
- package/build/config.js +67 -11
- package/build/config.js.map +1 -1
- package/build/curl.d.ts +17 -0
- package/build/curl.d.ts.map +1 -1
- package/build/curl.js.map +1 -1
- package/build/exitCodes.d.ts.map +1 -1
- package/build/optionParsers.d.ts +12 -0
- package/build/optionParsers.d.ts.map +1 -1
- package/build/optionParsers.js +15 -0
- package/build/optionParsers.js.map +1 -1
- package/build/pxi/App.d.ts.map +1 -1
- package/build/pxi/App.js +4 -0
- package/build/pxi/App.js.map +1 -1
- package/build/pxi/index.js.map +1 -1
- package/build/pxi/options.d.ts +98 -0
- package/build/pxi/options.d.ts.map +1 -1
- package/build/pxi/options.js.map +1 -1
- package/build/settings.d.ts.map +1 -1
- package/build/settings.js +4 -0
- package/build/settings.js.map +1 -1
- package/build/setup/agents/registry.d.ts +78 -0
- package/build/setup/agents/registry.d.ts.map +1 -0
- package/build/setup/agents/registry.js +129 -0
- package/build/setup/agents/registry.js.map +1 -0
- package/build/setup/copy.d.ts +167 -0
- package/build/setup/copy.d.ts.map +1 -0
- package/build/setup/copy.js +290 -0
- package/build/setup/copy.js.map +1 -0
- package/build/setup/deps/buildDefaultDeps.d.ts +13 -0
- package/build/setup/deps/buildDefaultDeps.d.ts.map +1 -0
- package/build/setup/deps/buildDefaultDeps.js +29 -0
- package/build/setup/deps/buildDefaultDeps.js.map +1 -0
- package/build/setup/deps/clipboard.d.ts +12 -0
- package/build/setup/deps/clipboard.d.ts.map +1 -0
- package/build/setup/deps/clipboard.js +30 -0
- package/build/setup/deps/clipboard.js.map +1 -0
- package/build/setup/deps/clock.d.ts +10 -0
- package/build/setup/deps/clock.d.ts.map +1 -0
- package/build/setup/deps/clock.js +11 -0
- package/build/setup/deps/clock.js.map +1 -0
- package/build/setup/deps/context.d.ts +28 -0
- package/build/setup/deps/context.d.ts.map +1 -0
- package/build/setup/deps/context.js +24 -0
- package/build/setup/deps/context.js.map +1 -0
- package/build/setup/deps/docs.d.ts +41 -0
- package/build/setup/deps/docs.d.ts.map +1 -0
- package/build/setup/deps/docs.js +33 -0
- package/build/setup/deps/docs.js.map +1 -0
- package/build/setup/deps/index.d.ts +42 -0
- package/build/setup/deps/index.d.ts.map +1 -0
- package/build/setup/deps/index.js +16 -0
- package/build/setup/deps/index.js.map +1 -0
- package/build/setup/deps/phoenixClient.d.ts +22 -0
- package/build/setup/deps/phoenixClient.d.ts.map +1 -0
- package/build/setup/deps/phoenixClient.js +17 -0
- package/build/setup/deps/phoenixClient.js.map +1 -0
- package/build/setup/deps/processes.d.ts +28 -0
- package/build/setup/deps/processes.d.ts.map +1 -0
- package/build/setup/deps/processes.js +58 -0
- package/build/setup/deps/processes.js.map +1 -0
- package/build/setup/deps/prompter.d.ts +42 -0
- package/build/setup/deps/prompter.d.ts.map +1 -0
- package/build/setup/deps/prompter.js +10 -0
- package/build/setup/deps/prompter.js.map +1 -0
- package/build/setup/errors.d.ts +27 -0
- package/build/setup/errors.d.ts.map +1 -0
- package/build/setup/errors.js +36 -0
- package/build/setup/errors.js.map +1 -0
- package/build/setup/options.d.ts +113 -0
- package/build/setup/options.d.ts.map +1 -0
- package/build/setup/options.js +63 -0
- package/build/setup/options.js.map +1 -0
- package/build/setup/prompts/instrumentationPrompt.d.ts +42 -0
- package/build/setup/prompts/instrumentationPrompt.d.ts.map +1 -0
- package/build/setup/prompts/instrumentationPrompt.js +64 -0
- package/build/setup/prompts/instrumentationPrompt.js.map +1 -0
- package/build/setup/runSetup.d.ts +45 -0
- package/build/setup/runSetup.d.ts.map +1 -0
- package/build/setup/runSetup.js +212 -0
- package/build/setup/runSetup.js.map +1 -0
- package/build/setup/steps/chooseEndpoint.d.ts +36 -0
- package/build/setup/steps/chooseEndpoint.d.ts.map +1 -0
- package/build/setup/steps/chooseEndpoint.js +125 -0
- package/build/setup/steps/chooseEndpoint.js.map +1 -0
- package/build/setup/steps/confirmGitSafety.d.ts +17 -0
- package/build/setup/steps/confirmGitSafety.d.ts.map +1 -0
- package/build/setup/steps/confirmGitSafety.js +73 -0
- package/build/setup/steps/confirmGitSafety.js.map +1 -0
- package/build/setup/steps/establishConnection.d.ts +29 -0
- package/build/setup/steps/establishConnection.d.ts.map +1 -0
- package/build/setup/steps/establishConnection.js +143 -0
- package/build/setup/steps/establishConnection.js.map +1 -0
- package/build/setup/steps/installTooling.d.ts +28 -0
- package/build/setup/steps/installTooling.d.ts.map +1 -0
- package/build/setup/steps/installTooling.js +79 -0
- package/build/setup/steps/installTooling.js.map +1 -0
- package/build/setup/steps/instrumentApp.d.ts +41 -0
- package/build/setup/steps/instrumentApp.d.ts.map +1 -0
- package/build/setup/steps/instrumentApp.js +131 -0
- package/build/setup/steps/instrumentApp.js.map +1 -0
- package/build/setup/steps/offerPxProfile.d.ts +20 -0
- package/build/setup/steps/offerPxProfile.d.ts.map +1 -0
- package/build/setup/steps/offerPxProfile.js +95 -0
- package/build/setup/steps/offerPxProfile.js.map +1 -0
- package/build/setup/steps/prefetchDocs.d.ts +24 -0
- package/build/setup/steps/prefetchDocs.d.ts.map +1 -0
- package/build/setup/steps/prefetchDocs.js +49 -0
- package/build/setup/steps/prefetchDocs.js.map +1 -0
- package/build/setup/steps/verifyTraces.d.ts +44 -0
- package/build/setup/steps/verifyTraces.d.ts.map +1 -0
- package/build/setup/steps/verifyTraces.js +119 -0
- package/build/setup/steps/verifyTraces.js.map +1 -0
- package/build/setup/steps/writeEnvFile.d.ts +19 -0
- package/build/setup/steps/writeEnvFile.d.ts.map +1 -0
- package/build/setup/steps/writeEnvFile.js +50 -0
- package/build/setup/steps/writeEnvFile.js.map +1 -0
- package/build/setup/ui/clackPrompter.d.ts +11 -0
- package/build/setup/ui/clackPrompter.d.ts.map +1 -0
- package/build/setup/ui/clackPrompter.js +107 -0
- package/build/setup/ui/clackPrompter.js.map +1 -0
- package/build/setup/ui/selectBoolean.d.ts +18 -0
- package/build/setup/ui/selectBoolean.d.ts.map +1 -0
- package/build/setup/ui/selectBoolean.js +14 -0
- package/build/setup/ui/selectBoolean.js.map +1 -0
- package/build/setup/util/gitignoreCoverage.d.ts +24 -0
- package/build/setup/util/gitignoreCoverage.d.ts.map +1 -0
- package/build/setup/util/gitignoreCoverage.js +43 -0
- package/build/setup/util/gitignoreCoverage.js.map +1 -0
- package/build/setup/util/paths.d.ts +6 -0
- package/build/setup/util/paths.d.ts.map +1 -0
- package/build/setup/util/paths.js +23 -0
- package/build/setup/util/paths.js.map +1 -0
- package/build/setup/util/redact.d.ts +12 -0
- package/build/setup/util/redact.d.ts.map +1 -0
- package/build/setup/util/redact.js +31 -0
- package/build/setup/util/redact.js.map +1 -0
- package/build/validation/endpoint.d.ts +19 -0
- package/build/validation/endpoint.d.ts.map +1 -0
- package/build/validation/endpoint.js +39 -0
- package/build/validation/endpoint.js.map +1 -0
- package/build/version.js.map +1 -1
- package/package.json +15 -12
- package/build/commands/annotationMutationUtils.d.ts.map +0 -1
- package/build/commands/annotationMutationUtils.js.map +0 -1
- package/build/commands/noteMutationUtils.d.ts.map +0 -1
- package/build/commands/noteMutationUtils.js.map +0 -1
- package/build/commands/sessionAnnotationsCommand.d.ts.map +0 -1
- package/build/commands/sessionAnnotationsCommand.js.map +0 -1
- package/build/commands/spanAnnotationsCommand.d.ts +0 -7
- package/build/commands/spanAnnotationsCommand.d.ts.map +0 -1
- package/build/commands/spanAnnotationsCommand.js +0 -164
- package/build/commands/spanAnnotationsCommand.js.map +0 -1
- package/build/commands/traceAnnotationsCommand.d.ts +0 -7
- package/build/commands/traceAnnotationsCommand.d.ts.map +0 -1
- package/build/commands/traceAnnotationsCommand.js +0 -167
- package/build/commands/traceAnnotationsCommand.js.map +0 -1
|
@@ -0,0 +1,143 @@
|
|
|
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 * as path from "node:path";
|
|
12
|
+
import { HttpError } from "@arizeai/phoenix-client";
|
|
13
|
+
import * as COPY from "../copy.js";
|
|
14
|
+
import { HeadlessInputError, SetupFatalError } from "../errors.js";
|
|
15
|
+
import { redactForDisplay } from "../util/redact.js";
|
|
16
|
+
const REST_TIMEOUT_MS = 10_000;
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Project name
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
/** Names are used as URL path identifiers; '/', '?', '#' are invalid. */
|
|
21
|
+
export function validateProjectName(value) {
|
|
22
|
+
const trimmed = value.trim();
|
|
23
|
+
if (!trimmed || /[/?#]/.test(trimmed)) {
|
|
24
|
+
return COPY.CONNECT.projectNameInvalid;
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
export function defaultProjectName(cwd) {
|
|
29
|
+
const base = path.basename(cwd).replace(/[/?#]/g, "-").trim();
|
|
30
|
+
return base || "default";
|
|
31
|
+
}
|
|
32
|
+
async function promptForProjectName(deps, inputs) {
|
|
33
|
+
const name = inputs.project ??
|
|
34
|
+
(await deps.prompter.textInput({
|
|
35
|
+
message: COPY.CONNECT.projectNameMessage,
|
|
36
|
+
defaultValue: defaultProjectName(deps.context.cwd),
|
|
37
|
+
validate: validateProjectName,
|
|
38
|
+
}));
|
|
39
|
+
return name.trim();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Read-only probe: list one project. Only the credential matters here — an
|
|
43
|
+
* instance with no projects yet still answers 200.
|
|
44
|
+
*/
|
|
45
|
+
async function checkApiKey(deps, endpoint, apiKey) {
|
|
46
|
+
const client = deps.createClient({ endpoint, apiKey });
|
|
47
|
+
try {
|
|
48
|
+
await client.GET("/v1/projects", {
|
|
49
|
+
params: { query: { limit: 1 } },
|
|
50
|
+
signal: AbortSignal.timeout(REST_TIMEOUT_MS),
|
|
51
|
+
});
|
|
52
|
+
return { kind: "ok" };
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error instanceof HttpError) {
|
|
56
|
+
if (error.status === 401 || error.status === 403) {
|
|
57
|
+
return { kind: "rejected", status: error.status };
|
|
58
|
+
}
|
|
59
|
+
return { kind: "error", detail: `HTTP ${error.status}` };
|
|
60
|
+
}
|
|
61
|
+
return { kind: "error", detail: redactForDisplay(String(error)) };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// Interactive lanes
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
async function connectAuthOff(deps, endpoint, inputs) {
|
|
68
|
+
const projectName = await promptForProjectName(deps, inputs);
|
|
69
|
+
deps.prompter.line(COPY.CONNECT.usingProject(projectName));
|
|
70
|
+
return { endpoint, projectName };
|
|
71
|
+
}
|
|
72
|
+
/** Prompt for an API key without echoing it to the terminal. */
|
|
73
|
+
async function promptForApiKey(deps) {
|
|
74
|
+
const apiKey = await deps.prompter.passwordInput({
|
|
75
|
+
message: COPY.API_KEY.pasteKeyMessage,
|
|
76
|
+
validate: (value) => value.trim() ? undefined : COPY.API_KEY.pasteKeyInvalid,
|
|
77
|
+
});
|
|
78
|
+
return apiKey.trim();
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A rejected key returns to the masked credential prompt without asking for
|
|
82
|
+
* the project name again.
|
|
83
|
+
*/
|
|
84
|
+
async function connectAuthOnInteractive(deps, endpoint, inputs) {
|
|
85
|
+
deps.prompter.note(COPY.API_KEY.instructions, COPY.API_KEY.instructionsTitle);
|
|
86
|
+
let apiKey = await promptForApiKey(deps);
|
|
87
|
+
const projectName = await promptForProjectName(deps, inputs);
|
|
88
|
+
for (;;) {
|
|
89
|
+
const result = await checkApiKey(deps, endpoint, apiKey);
|
|
90
|
+
if (result.kind === "ok") {
|
|
91
|
+
deps.prompter.line(COPY.CONNECT.usingProject(projectName));
|
|
92
|
+
return { endpoint, projectName, apiKey };
|
|
93
|
+
}
|
|
94
|
+
if (result.kind === "rejected") {
|
|
95
|
+
deps.prompter.line(COPY.API_KEY.pasteKeyRejected);
|
|
96
|
+
apiKey = await promptForApiKey(deps);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
throw new SetupFatalError(COPY.CONNECT.connectFailed(result.detail));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
// Headless lane
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
async function connectHeadless(deps, endpoint, authEnabled, inputs) {
|
|
106
|
+
if (!inputs.project) {
|
|
107
|
+
throw new HeadlessInputError(COPY.CONNECT.headlessNeedsProject);
|
|
108
|
+
}
|
|
109
|
+
const projectName = inputs.project.trim();
|
|
110
|
+
if (!authEnabled) {
|
|
111
|
+
return { endpoint, projectName };
|
|
112
|
+
}
|
|
113
|
+
const apiKey = inputs.apiKey;
|
|
114
|
+
if (!apiKey) {
|
|
115
|
+
throw new HeadlessInputError(COPY.CONNECT.headlessNeedsApiKey);
|
|
116
|
+
}
|
|
117
|
+
const result = await checkApiKey(deps, endpoint, apiKey);
|
|
118
|
+
if (result.kind === "rejected") {
|
|
119
|
+
throw new SetupFatalError(COPY.CONNECT.headlessAuthRejected);
|
|
120
|
+
}
|
|
121
|
+
if (result.kind === "error") {
|
|
122
|
+
throw new SetupFatalError(COPY.CONNECT.connectFailed(result.detail));
|
|
123
|
+
}
|
|
124
|
+
return { endpoint, projectName, apiKey };
|
|
125
|
+
}
|
|
126
|
+
export async function establishConnection(deps, { endpoint, authEnabled, inputs }) {
|
|
127
|
+
// A --project / env-provided name bypasses the prompt in every lane, so
|
|
128
|
+
// enforce here the same rule the prompt validates interactively.
|
|
129
|
+
if (inputs.project !== undefined) {
|
|
130
|
+
const nameError = validateProjectName(inputs.project);
|
|
131
|
+
if (nameError) {
|
|
132
|
+
throw new HeadlessInputError(nameError);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (inputs.headless) {
|
|
136
|
+
return connectHeadless(deps, endpoint, authEnabled, inputs);
|
|
137
|
+
}
|
|
138
|
+
if (!authEnabled) {
|
|
139
|
+
return connectAuthOff(deps, endpoint, inputs);
|
|
140
|
+
}
|
|
141
|
+
return connectAuthOnInteractive(deps, endpoint, inputs);
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=establishConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"establishConnection.js","sourceRoot":"","sources":["../../../src/setup/steps/establishConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAUlD,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E,yEAAyE;AACzE,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,OAAO,IAAI,OAAO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,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,wBAAwB,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install the tooling: the global `px` CLI, and the Phoenix skills.
|
|
3
|
+
*
|
|
4
|
+
* Runs after traces are verified — the peak-motivation moment — and offers
|
|
5
|
+
* the tooling that turns "traces are flowing" into "I can look at them":
|
|
6
|
+
* a global `px` install when setup is running without `px` on PATH
|
|
7
|
+
* (the `npx @arizeai/phoenix-cli setup` case), and the Phoenix skills for
|
|
8
|
+
* the user's coding agent via `npx skills add` (no `--skill` pins — the
|
|
9
|
+
* skills CLI's own picker lists the repo's skills and target agents). Both
|
|
10
|
+
* installs are spawned on the terminal so their own output and prompts show
|
|
11
|
+
* through; failures are non-fatal warnings with the command to retry by hand.
|
|
12
|
+
*/
|
|
13
|
+
import type { SetupDeps } from "../deps/index.js";
|
|
14
|
+
/** What an install offer did — reported in the setup summary. */
|
|
15
|
+
export type ToolingOutcome = "installed" | "failed" | "declined" | "skipped";
|
|
16
|
+
export interface ToolingResult {
|
|
17
|
+
cli: ToolingOutcome;
|
|
18
|
+
skills: ToolingOutcome;
|
|
19
|
+
}
|
|
20
|
+
export declare function offerToolingInstalls(deps: Pick<SetupDeps, "context" | "processes" | "prompter">, { pxOnPath, skills, canPrompt, }: {
|
|
21
|
+
/** Started at setup launch so the probe never blocks this prompt. */
|
|
22
|
+
pxOnPath: Promise<boolean>;
|
|
23
|
+
/** `--skills` / `--no-skills`; undefined means ask (when we can). */
|
|
24
|
+
skills?: boolean;
|
|
25
|
+
/** False in a headless run: there is no terminal to ask on. */
|
|
26
|
+
canPrompt: boolean;
|
|
27
|
+
}): Promise<ToolingResult>;
|
|
28
|
+
//# sourceMappingURL=installTooling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installTooling.d.ts","sourceRoot":"","sources":["../../../src/setup/steps/installTooling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,SAAS,CAAC;AAiCtD,iEAAiE;AACjE,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;AAE7E,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,cAAc,CAAC;IACpB,MAAM,EAAE,cAAc,CAAC;CACxB;AAiCD,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC,EAC3D,EACE,QAAQ,EACR,MAAM,EACN,SAAS,GACV,EAAE;IACD,qEAAqE;IACrE,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3B,qEAAqE;IACrE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,SAAS,EAAE,OAAO,CAAC;CACpB,GACA,OAAO,CAAC,aAAa,CAAC,CAoBxB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install the tooling: the global `px` CLI, and the Phoenix skills.
|
|
3
|
+
*
|
|
4
|
+
* Runs after traces are verified — the peak-motivation moment — and offers
|
|
5
|
+
* the tooling that turns "traces are flowing" into "I can look at them":
|
|
6
|
+
* a global `px` install when setup is running without `px` on PATH
|
|
7
|
+
* (the `npx @arizeai/phoenix-cli setup` case), and the Phoenix skills for
|
|
8
|
+
* the user's coding agent via `npx skills add` (no `--skill` pins — the
|
|
9
|
+
* skills CLI's own picker lists the repo's skills and target agents). Both
|
|
10
|
+
* installs are spawned on the terminal so their own output and prompts show
|
|
11
|
+
* through; failures are non-fatal warnings with the command to retry by hand.
|
|
12
|
+
*/
|
|
13
|
+
import * as COPY from "../copy.js";
|
|
14
|
+
import { selectBoolean } from "../ui/selectBoolean.js";
|
|
15
|
+
const CLI_INSTALL_SPEC = {
|
|
16
|
+
command: "npm",
|
|
17
|
+
args: ["install", "-g", "@arizeai/phoenix-cli"],
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* `npx skills add`, as spawned. The leading `-y` is npx's own — install the
|
|
21
|
+
* `skills` package without asking.
|
|
22
|
+
*
|
|
23
|
+
* Unattended, the skills CLI needs its `--yes` too: it is interactive by
|
|
24
|
+
* default (a skill picker, an agent picker, a final confirm) and a missing TTY
|
|
25
|
+
* does not suppress those prompts, so without the flag a headless run hangs on
|
|
26
|
+
* stdin. With it, the installer takes every skill in the repo for the agents it
|
|
27
|
+
* detects. Interactively we leave it off, so the user drives those pickers.
|
|
28
|
+
*/
|
|
29
|
+
function skillsAddSpec(unattended) {
|
|
30
|
+
return {
|
|
31
|
+
command: "npx",
|
|
32
|
+
args: [
|
|
33
|
+
"-y",
|
|
34
|
+
"skills",
|
|
35
|
+
"add",
|
|
36
|
+
COPY.SKILLS_SOURCE,
|
|
37
|
+
...(unattended ? ["--yes"] : []),
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Install, honoring a decision the caller already made. `decided` short-circuits
|
|
43
|
+
* the prompt: `true` installs (`--skills`), `false` skips (`--no-skills`), and
|
|
44
|
+
* `undefined` asks — so a headless run, which has no terminal to ask on, must
|
|
45
|
+
* arrive here already decided.
|
|
46
|
+
*/
|
|
47
|
+
async function offerInstall(deps, copy, spec, decided) {
|
|
48
|
+
const optedIn = decided ??
|
|
49
|
+
(await selectBoolean({
|
|
50
|
+
prompter: deps.prompter,
|
|
51
|
+
message: copy.message,
|
|
52
|
+
yesLabel: copy.yes,
|
|
53
|
+
noLabel: copy.no,
|
|
54
|
+
}));
|
|
55
|
+
if (!optedIn) {
|
|
56
|
+
return "declined";
|
|
57
|
+
}
|
|
58
|
+
const { exitCode } = await deps.processes.spawnInteractive({
|
|
59
|
+
...spec,
|
|
60
|
+
cwd: deps.context.cwd,
|
|
61
|
+
});
|
|
62
|
+
deps.prompter.line(exitCode === 0 ? copy.installed : copy.failed);
|
|
63
|
+
return exitCode === 0 ? "installed" : "failed";
|
|
64
|
+
}
|
|
65
|
+
export async function offerToolingInstalls(deps, { pxOnPath, skills, canPrompt, }) {
|
|
66
|
+
// The global CLI install is prompt-only — it is offered when `px` is missing
|
|
67
|
+
// (an `npx` run), and skipped outright when we cannot ask, because installing
|
|
68
|
+
// a global npm package is not something to do to an unattended caller.
|
|
69
|
+
const cli = !canPrompt || (await pxOnPath)
|
|
70
|
+
? "skipped"
|
|
71
|
+
: await offerInstall(deps, COPY.TOOLING.cli, CLI_INSTALL_SPEC);
|
|
72
|
+
// With no prompt to fall back on, an unflagged skills install defaults to
|
|
73
|
+
// going ahead: the only reason to invoke this lane unattended is to install.
|
|
74
|
+
// `--no-skills` still declines. This default lives here, next to `canPrompt`,
|
|
75
|
+
// rather than in each caller.
|
|
76
|
+
const skillsOutcome = await offerInstall(deps, COPY.TOOLING.skills, skillsAddSpec(!canPrompt), canPrompt ? skills : (skills ?? true));
|
|
77
|
+
return { cli, skills: skillsOutcome };
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=installTooling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installTooling.js","sourceRoot":"","sources":["../../../src/setup/steps/installTooling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,gBAAgB,GAA6B;IACjD,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,sBAAsB,CAAC;C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AuE;IACvE,MAAM,GAAG,GACP,CAAC,SAAS,IAAI,CAAC,MAAM,QAAQ,CAAC;QAC5B,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,MAAM,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAEnE,0EAA0E;IAC1E,6EAA6E;IAC7E,8EAA8E;IAC9E,8BAA8B;IAC9B,MAAM,aAAa,GAAG,MAAM,YAAY,CACtC,IAAI,EACJ,IAAI,CAAC,OAAO,CAAC,MAAM,EACnB,aAAa,CAAC,CAAC,SAAS,CAAC,EACzB,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,CACtC,CAAC;IACF,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instrumentation hand-off.
|
|
3
|
+
*
|
|
4
|
+
* Lanes, in order of preference: launch a detected coding agent directly
|
|
5
|
+
* (prompt pre-loaded, credentials injected via env), copy the prompt for an
|
|
6
|
+
* agent the user runs themselves, or manual via the quickstart docs. All
|
|
7
|
+
* lanes converge on the trace-verification step — setup's definition of
|
|
8
|
+
* done is API-verified data flow, not agent self-report.
|
|
9
|
+
*
|
|
10
|
+
* `--agent` pre-answers the lane, which is what makes an unattended run
|
|
11
|
+
* possible: with no TTY there is no prompt to pick a lane from, and the agent
|
|
12
|
+
* runs in background mode (no TUI to hand the terminal to).
|
|
13
|
+
*/
|
|
14
|
+
import { type AgentRunMode, type CodingAgent, type CodingAgentId } from "../agents/registry.js";
|
|
15
|
+
import type { DocsPrefetchResult, SetupDeps } from "../deps/index.js";
|
|
16
|
+
import type { Connection } from "./establishConnection.js";
|
|
17
|
+
export interface InstrumentAppArgs {
|
|
18
|
+
authEnabled: boolean;
|
|
19
|
+
/** Started at setup launch so the probes never block this prompt. */
|
|
20
|
+
agentDetection: Promise<CodingAgent[]>;
|
|
21
|
+
/** `--agent`: skip the lane prompt and launch this agent. */
|
|
22
|
+
agent?: CodingAgentId;
|
|
23
|
+
/** `--language`: passed through so the agent skips its own detection. */
|
|
24
|
+
languages: string[];
|
|
25
|
+
/** How to run the agent — see {@link AgentRunMode}. */
|
|
26
|
+
mode: AgentRunMode;
|
|
27
|
+
/** Where the prefetched docs landed, when the docs step ran. */
|
|
28
|
+
docs?: DocsPrefetchResult;
|
|
29
|
+
}
|
|
30
|
+
/** Which lane instrumentation actually took — reported in the summary. */
|
|
31
|
+
export type InstrumentationLane = {
|
|
32
|
+
kind: "agent";
|
|
33
|
+
agent: CodingAgentId;
|
|
34
|
+
exitCode: number;
|
|
35
|
+
} | {
|
|
36
|
+
kind: "clipboard";
|
|
37
|
+
} | {
|
|
38
|
+
kind: "manual";
|
|
39
|
+
};
|
|
40
|
+
export declare function instrumentApp(deps: Pick<SetupDeps, "context" | "processes" | "prompter" | "writeClipboard">, connection: Connection, args: InstrumentAppArgs): Promise<InstrumentationLane>;
|
|
41
|
+
//# sourceMappingURL=instrumentApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentApp.d.ts","sourceRoot":"","sources":["../../../src/setup/steps/instrumentApp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,kBAAkB,EAAgB,SAAS,EAAE,MAAM,SAAS,CAAC;AAG3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAQxD,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,qEAAqE;IACrE,cAAc,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACvC,6DAA6D;IAC7D,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,yEAAyE;IACzE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,uDAAuD;IACvD,IAAI,EAAE,YAAY,CAAC;IACnB,gEAAgE;IAChE,IAAI,CAAC,EAAE,kBAAkB,CAAC;CAC3B;AAED,0EAA0E;AAC1E,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvB,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,CACR,SAAS,EACT,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,gBAAgB,CACxD,EACD,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,mBAAmB,CAAC,CAgG9B"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instrumentation hand-off.
|
|
3
|
+
*
|
|
4
|
+
* Lanes, in order of preference: launch a detected coding agent directly
|
|
5
|
+
* (prompt pre-loaded, credentials injected via env), copy the prompt for an
|
|
6
|
+
* agent the user runs themselves, or manual via the quickstart docs. All
|
|
7
|
+
* lanes converge on the trace-verification step — setup's definition of
|
|
8
|
+
* done is API-verified data flow, not agent self-report.
|
|
9
|
+
*
|
|
10
|
+
* `--agent` pre-answers the lane, which is what makes an unattended run
|
|
11
|
+
* possible: with no TTY there is no prompt to pick a lane from, and the agent
|
|
12
|
+
* runs in background mode (no TUI to hand the terminal to).
|
|
13
|
+
*/
|
|
14
|
+
import { buildLaunchSpec, getCodingAgent, probeBinary, } from "../agents/registry.js";
|
|
15
|
+
import * as COPY from "../copy.js";
|
|
16
|
+
import { SetupFatalError } from "../errors.js";
|
|
17
|
+
import { buildInstrumentationPrompt } from "../prompts/instrumentationPrompt.js";
|
|
18
|
+
import { tracesUrl } from "./verifyTraces.js";
|
|
19
|
+
const DEFAULT_LOCAL_ENDPOINT = "http://localhost:6006";
|
|
20
|
+
export async function instrumentApp(deps, connection, args) {
|
|
21
|
+
const { authEnabled, agentDetection, languages, mode } = args;
|
|
22
|
+
const prompt = buildInstrumentationPrompt({
|
|
23
|
+
projectName: connection.projectName,
|
|
24
|
+
endpoint: connection.endpoint,
|
|
25
|
+
isDefaultEndpoint: connection.endpoint === DEFAULT_LOCAL_ENDPOINT,
|
|
26
|
+
docs: {
|
|
27
|
+
quickstartPython: COPY.DOCS.quickstartPython,
|
|
28
|
+
quickstartTypeScript: COPY.DOCS.quickstartTypeScript,
|
|
29
|
+
phoenixOtelSetup: COPY.DOCS.phoenixOtelSetup,
|
|
30
|
+
integrationsIndex: COPY.DOCS.integrationsIndex,
|
|
31
|
+
},
|
|
32
|
+
tracesUrl: tracesUrl(connection),
|
|
33
|
+
authEnabled,
|
|
34
|
+
languages,
|
|
35
|
+
// Only advertise the local docs dir when it holds pages — an empty one
|
|
36
|
+
// (docs site down, over-narrow workflow filter) would send the agent to
|
|
37
|
+
// read a directory with nothing in it instead of the web.
|
|
38
|
+
...(args.docs?.hasPagesOnDisk ? { localDocsDir: args.docs.outputDir } : {}),
|
|
39
|
+
});
|
|
40
|
+
// `--agent` short-circuits the lane prompt. The binary is probed rather
|
|
41
|
+
// than taken from the detection sweep so a named-but-missing agent fails
|
|
42
|
+
// with "not on your PATH" instead of silently dropping to another lane.
|
|
43
|
+
if (args.agent) {
|
|
44
|
+
const agent = getCodingAgent(args.agent);
|
|
45
|
+
if (!agent) {
|
|
46
|
+
throw new SetupFatalError(COPY.INSTRUMENTATION.unknownAgent(args.agent));
|
|
47
|
+
}
|
|
48
|
+
if (!(await probeBinary(deps, agent.binary))) {
|
|
49
|
+
throw new SetupFatalError(COPY.INSTRUMENTATION.agentNotFound(agent.label, agent.binary));
|
|
50
|
+
}
|
|
51
|
+
return launchAgent(deps, connection, { agent, prompt, mode });
|
|
52
|
+
}
|
|
53
|
+
const detectedAgents = await agentDetection;
|
|
54
|
+
const options = [
|
|
55
|
+
...detectedAgents.map((agent) => ({
|
|
56
|
+
value: `agent:${agent.id}`,
|
|
57
|
+
label: COPY.INSTRUMENTATION.launchLabel(agent.label),
|
|
58
|
+
hint: COPY.INSTRUMENTATION.launchHint,
|
|
59
|
+
})),
|
|
60
|
+
{
|
|
61
|
+
value: "clipboard",
|
|
62
|
+
label: COPY.INSTRUMENTATION.clipboardLabel,
|
|
63
|
+
hint: COPY.INSTRUMENTATION.clipboardHint,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: "manual",
|
|
67
|
+
label: COPY.INSTRUMENTATION.manualLabel,
|
|
68
|
+
hint: COPY.INSTRUMENTATION.manualHint,
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
const choice = await deps.prompter.select({
|
|
72
|
+
message: COPY.INSTRUMENTATION.modeMessage,
|
|
73
|
+
options,
|
|
74
|
+
});
|
|
75
|
+
const chosenAgent = detectedAgents.find((agent) => choice === `agent:${agent.id}`);
|
|
76
|
+
if (chosenAgent) {
|
|
77
|
+
return launchAgent(deps, connection, { agent: chosenAgent, prompt, mode });
|
|
78
|
+
}
|
|
79
|
+
if (choice === "clipboard") {
|
|
80
|
+
const copied = await deps.writeClipboard(prompt);
|
|
81
|
+
if (copied) {
|
|
82
|
+
deps.prompter.line(COPY.INSTRUMENTATION.promptCopied);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
deps.prompter.line(COPY.INSTRUMENTATION.promptCopyFailed);
|
|
86
|
+
deps.prompter.note(prompt);
|
|
87
|
+
}
|
|
88
|
+
await deps.prompter.select({
|
|
89
|
+
message: COPY.INSTRUMENTATION.clipboardDoneMessage,
|
|
90
|
+
options: [
|
|
91
|
+
{ value: true, label: COPY.INSTRUMENTATION.clipboardDoneLabel },
|
|
92
|
+
],
|
|
93
|
+
});
|
|
94
|
+
return { kind: "clipboard" };
|
|
95
|
+
}
|
|
96
|
+
deps.prompter.line(COPY.INSTRUMENTATION.manualDocs(COPY.DOCS.instrumentationIndex));
|
|
97
|
+
await deps.prompter.select({
|
|
98
|
+
message: COPY.INSTRUMENTATION.manualDoneMessage,
|
|
99
|
+
options: [{ value: true, label: COPY.INSTRUMENTATION.manualDoneLabel }],
|
|
100
|
+
});
|
|
101
|
+
return { kind: "manual" };
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Run the agent with the prompt pre-loaded. A non-zero exit is a warning, not
|
|
105
|
+
* a failure: the agent may have instrumented the app and then exited badly,
|
|
106
|
+
* and trace verification — not the agent's exit code — decides whether setup
|
|
107
|
+
* succeeded.
|
|
108
|
+
*/
|
|
109
|
+
async function launchAgent(deps, connection, { agent, prompt, mode, }) {
|
|
110
|
+
// Without its TUI *and* without permission bypass, an agent stalls on the
|
|
111
|
+
// first approval it wants, with no terminal to approve it on — the run then
|
|
112
|
+
// dies at the verification timeout with nothing to show. Say so up front.
|
|
113
|
+
if (mode.background && !mode.bypassPermissions) {
|
|
114
|
+
deps.prompter.line(COPY.INSTRUMENTATION.backgroundNeedsYolo(agent.label));
|
|
115
|
+
}
|
|
116
|
+
deps.prompter.line(mode.background
|
|
117
|
+
? COPY.INSTRUMENTATION.launchingBackground(agent.label)
|
|
118
|
+
: COPY.INSTRUMENTATION.launching(agent.label));
|
|
119
|
+
const spec = buildLaunchSpec(agent, {
|
|
120
|
+
prompt,
|
|
121
|
+
cwd: deps.context.cwd,
|
|
122
|
+
connection,
|
|
123
|
+
mode,
|
|
124
|
+
});
|
|
125
|
+
const { exitCode } = await deps.processes.spawnInteractive(spec);
|
|
126
|
+
if (exitCode !== 0) {
|
|
127
|
+
deps.prompter.line(COPY.INSTRUMENTATION.agentExitWarning(agent.label));
|
|
128
|
+
}
|
|
129
|
+
return { kind: "agent", agent: agent.id, exitCode };
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=instrumentApp.js.map
|
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IAAI,CAAC,CAAC;IACjE,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offer to point `px` at the project setup just connected.
|
|
3
|
+
*
|
|
4
|
+
* Because setup *is* px, everything here is in-process — the profile
|
|
5
|
+
* (including the API key, when auth is on) is written through px's own
|
|
6
|
+
* settings module (`~/.px/settings.json`, dir 0700, file 0600). No argv or
|
|
7
|
+
* subprocess ever carries the secret. Any failure is a non-fatal warning;
|
|
8
|
+
* setup proceeds regardless.
|
|
9
|
+
*/
|
|
10
|
+
import type { SetupDeps } from "../deps/index.js";
|
|
11
|
+
import type { Connection } from "./establishConnection.js";
|
|
12
|
+
/** `local` for localhost, else the host with dots and colons → dashes. */
|
|
13
|
+
export declare function profileNameForEndpoint(endpoint: string): string;
|
|
14
|
+
export interface PxProfileArgs {
|
|
15
|
+
connection: Connection;
|
|
16
|
+
/** Override the settings file path (tests). */
|
|
17
|
+
settingsPath?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function offerPxProfile(deps: Pick<SetupDeps, "prompter">, { connection, settingsPath }: PxProfileArgs): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=offerPxProfile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offerPxProfile.d.ts","sourceRoot":"","sources":["../../../src/setup/steps/offerPxProfile.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,0EAA0E;AAC1E,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAO/D;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EACjC,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,aAAa,GAC1C,OAAO,CAAC,IAAI,CAAC,CAoFf"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offer to point `px` at the project setup just connected.
|
|
3
|
+
*
|
|
4
|
+
* Because setup *is* px, everything here is in-process — the profile
|
|
5
|
+
* (including the API key, when auth is on) is written through px's own
|
|
6
|
+
* settings module (`~/.px/settings.json`, dir 0700, file 0600). No argv or
|
|
7
|
+
* subprocess ever carries the secret. Any failure is a non-fatal warning;
|
|
8
|
+
* setup proceeds regardless.
|
|
9
|
+
*/
|
|
10
|
+
import { getSettingsPath, getStoredActiveProfile, loadSettings, saveSettings, SettingsFileError, } from "../../settings.js";
|
|
11
|
+
import * as COPY from "../copy.js";
|
|
12
|
+
import { SetupCancelledError } from "../errors.js";
|
|
13
|
+
import { redactForDisplay } from "../util/redact.js";
|
|
14
|
+
/** `local` for localhost, else the host with dots and colons → dashes. */
|
|
15
|
+
export function profileNameForEndpoint(endpoint) {
|
|
16
|
+
// URL.hostname keeps the brackets on IPv6 literals (e.g. "[::1]").
|
|
17
|
+
const host = new URL(endpoint).hostname;
|
|
18
|
+
if (host === "localhost" || host === "127.0.0.1" || host === "[::1]") {
|
|
19
|
+
return "local";
|
|
20
|
+
}
|
|
21
|
+
return host.replace(/^\[|\]$/g, "").replace(/[.:]/g, "-");
|
|
22
|
+
}
|
|
23
|
+
export async function offerPxProfile(deps, { connection, settingsPath }) {
|
|
24
|
+
// Strict, and on its own: a settings file whose contents don't parse must not
|
|
25
|
+
// degrade to the empty profiles record a lenient load returns, which the save
|
|
26
|
+
// below would then write over whatever the user had. A file that is simply
|
|
27
|
+
// absent is not an error — the load returns fresh settings for it.
|
|
28
|
+
let settings;
|
|
29
|
+
try {
|
|
30
|
+
settings = loadSettings({ settingsPath, strict: true });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
// Only a file we can't parse gets sent here. `px profile create`, the
|
|
34
|
+
// remedy the generic failure suggests, loads the same file the same strict
|
|
35
|
+
// way — so for this one failure it is no remedy at all, and the file itself
|
|
36
|
+
// is what has to be dealt with.
|
|
37
|
+
if (error instanceof SettingsFileError) {
|
|
38
|
+
deps.prompter.line(COPY.PX_PROFILE.unreadableSettings(settingsPath ?? getSettingsPath(), redactForDisplay(error.message)));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
deps.prompter.line(COPY.PX_PROFILE.failed(redactForDisplay(String(error))));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const active = getStoredActiveProfile(settings);
|
|
46
|
+
// A fully-configured active profile pointing elsewhere is a conflict —
|
|
47
|
+
// ask before switching, never clobber silently. A partially configured
|
|
48
|
+
// profile (missing endpoint or project) is non-conflicting.
|
|
49
|
+
const conflicting = active !== undefined &&
|
|
50
|
+
Boolean(active.entry.endpoint) &&
|
|
51
|
+
Boolean(active.entry.project) &&
|
|
52
|
+
(active.entry.endpoint !== connection.endpoint ||
|
|
53
|
+
active.entry.project !== connection.projectName);
|
|
54
|
+
const optedIn = await deps.prompter.select(conflicting && active
|
|
55
|
+
? {
|
|
56
|
+
message: COPY.PX_PROFILE.conflictMessage(active.name, active.entry.endpoint ?? ""),
|
|
57
|
+
options: [
|
|
58
|
+
{ value: false, label: COPY.PX_PROFILE.conflictNo },
|
|
59
|
+
{ value: true, label: COPY.PX_PROFILE.conflictYes },
|
|
60
|
+
],
|
|
61
|
+
}
|
|
62
|
+
: {
|
|
63
|
+
message: COPY.PX_PROFILE.optInMessage,
|
|
64
|
+
options: [
|
|
65
|
+
{ value: true, label: COPY.PX_PROFILE.optInYes },
|
|
66
|
+
{ value: false, label: COPY.PX_PROFILE.optInNo },
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
if (!optedIn) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const profileName = profileNameForEndpoint(connection.endpoint);
|
|
73
|
+
const entry = {
|
|
74
|
+
endpoint: connection.endpoint,
|
|
75
|
+
project: connection.projectName,
|
|
76
|
+
};
|
|
77
|
+
if (connection.apiKey) {
|
|
78
|
+
entry.apiKey = connection.apiKey;
|
|
79
|
+
}
|
|
80
|
+
settings.profiles[profileName] = {
|
|
81
|
+
...settings.profiles[profileName],
|
|
82
|
+
...entry,
|
|
83
|
+
};
|
|
84
|
+
settings.activeProfile = profileName;
|
|
85
|
+
saveSettings(settings, { settingsPath });
|
|
86
|
+
deps.prompter.line(COPY.PX_PROFILE.created(profileName));
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (error instanceof SetupCancelledError) {
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
deps.prompter.line(COPY.PX_PROFILE.failed(redactForDisplay(String(error))));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=offerPxProfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offerPxProfile.js","sourceRoot":"","sources":["../../../src/setup/steps/offerPxProfile.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,YAAY,EACZ,iBAAiB,GAGlB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,gBAAgB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,GAAiB;YAC1B,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,OAAO,EAAE,UAAU,CAAC,WAAW;SAChC,CAAC;QACF,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACtB,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;QACnC,CAAC;QACD,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG;YAC/B,GAAG,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC;YACjC,GAAG,KAAK;SACT,CAAC;QACF,QAAQ,CAAC,aAAa,GAAG,WAAW,CAAC;QACrC,YAAY,CAAC,QAAQ,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,mBAAmB,EAAE,CAAC;YACzC,MAAM,KAAK,CAAC;QACd,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefetch the Phoenix docs into the repo, so the instrumentation agent reads
|
|
3
|
+
* package names and APIs from disk instead of fetching URLs mid-run.
|
|
4
|
+
*
|
|
5
|
+
* Runs only when instrumentation runs — the docs exist to serve the agent, so
|
|
6
|
+
* a registration-only run has no reason to write them. Never fatal: a docs
|
|
7
|
+
* site that is slow or down degrades to the agent fetching pages itself, which
|
|
8
|
+
* is what it did before this step existed.
|
|
9
|
+
*
|
|
10
|
+
* Must run after the git-safety gate: the download writes untracked files
|
|
11
|
+
* under `.px/`, which a fast headless run could otherwise mistake for
|
|
12
|
+
* pre-existing user changes.
|
|
13
|
+
*/
|
|
14
|
+
import { type DocsPrefetchOptions, type DocsPrefetchResult, type SetupDeps } from "../deps/index.js";
|
|
15
|
+
/**
|
|
16
|
+
* Download the docs and gitignore what they wrote. A failure is reported and
|
|
17
|
+
* dropped: the connection and hand-off files are real work worth keeping, and
|
|
18
|
+
* the agent can still read the docs from the web.
|
|
19
|
+
*/
|
|
20
|
+
export declare function prefetchDocs(deps: Pick<SetupDeps, "fetchDocs" | "prompter" | "context">, { docs, isGitRepository, }: {
|
|
21
|
+
docs: DocsPrefetchOptions;
|
|
22
|
+
isGitRepository: boolean;
|
|
23
|
+
}): Promise<DocsPrefetchResult | undefined>;
|
|
24
|
+
//# sourceMappingURL=prefetchDocs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefetchDocs.d.ts","sourceRoot":"","sources":["../../../src/setup/steps/prefetchDocs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACf,MAAM,SAAS,CAAC;AAMjB;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC,EAC3D,EACE,IAAI,EACJ,eAAe,GAChB,EAAE;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,GACzD,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CA6BzC"}
|