@arizeai/phoenix-cli 0.12.0 → 0.12.1

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 CHANGED
@@ -291,6 +291,21 @@ px session my-session-id --include-annotations --format raw | jq '.traces'
291
291
 
292
292
  ---
293
293
 
294
+ ### `px annotation-config`
295
+
296
+ List annotation configurations defined in your Phoenix instance.
297
+
298
+ ```bash
299
+ px annotation-config --format raw --no-progress | jq '.[].name'
300
+ ```
301
+
302
+ | Option | Description | Default |
303
+ | ------------------- | -------------------------- | -------- |
304
+ | `--format <format>` | `pretty`, `json`, or `raw` | `pretty` |
305
+ | `--no-progress` | Suppress progress output | — |
306
+
307
+ ---
308
+
294
309
  ### `px auth status`
295
310
 
296
311
  Show current Phoenix authentication status, including the configured endpoint, whether you are authenticated or anonymous, and an obscured API key.
@@ -1,11 +1,27 @@
1
+ import type { componentsV1 } from "@arizeai/phoenix-client";
1
2
  import { Command } from "commander";
3
+ type ViewerUser = componentsV1["schemas"]["GetViewerResponseBody"]["data"];
2
4
  /**
3
5
  * Obscure an API key for display using asterisks.
4
6
  * Shows a fixed number of asterisks regardless of key length for security.
5
7
  */
6
8
  export declare function obscureApiKey(apiKey: string): string;
9
+ interface FetchViewerSuccess {
10
+ status: "success";
11
+ user: ViewerUser;
12
+ }
13
+ interface FetchViewerError {
14
+ status: "network_error" | "auth_error" | "not_found" | "unknown_error";
15
+ message: string;
16
+ }
17
+ export type FetchViewerResult = FetchViewerSuccess | FetchViewerError;
18
+ /**
19
+ * Format auth status output in gh-style format.
20
+ */
21
+ export declare function formatAuthStatus(endpoint: string, result: FetchViewerResult, apiKey?: string): string;
7
22
  /**
8
23
  * Create the auth command with subcommands
9
24
  */
10
25
  export declare function createAuthCommand(): Command;
26
+ export {};
11
27
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKpD;AA8CD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAS3C"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,KAAK,UAAU,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAO3E;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKpD;AAED,UAAU,kBAAkB;IAC1B,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,UAAU,gBAAgB;IACxB,MAAM,EAAE,eAAe,GAAG,YAAY,GAAG,WAAW,GAAG,eAAe,CAAC;IACvE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;AAuCtE;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,iBAAiB,EACzB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAiCR;AA6DD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAS3C"}
@@ -1,8 +1,8 @@
1
1
  import { Command } from "commander";
2
+ import { createPhoenixClient } from "../client.js";
2
3
  import { resolveConfig } from "../config.js";
3
4
  import { ExitCode } from "../exitCodes.js";
4
5
  import { writeError, writeOutput } from "../io.js";
5
- import { formatTable } from "./formatTable.js";
6
6
  /**
7
7
  * Obscure an API key for display using asterisks.
8
8
  * Shows a fixed number of asterisks regardless of key length for security.
@@ -13,30 +13,115 @@ export function obscureApiKey(apiKey) {
13
13
  }
14
14
  return "************************************";
15
15
  }
16
+ /**
17
+ * Extract an HTTP status code from the phoenix-client middleware error message.
18
+ * The middleware throws errors like: "https://example.org/api/v1/user: 401 Unauthorized"
19
+ */
20
+ function parseStatusCode(error) {
21
+ const match = error.message.match(/:\s*(\d{3})\s/);
22
+ return match ? parseInt(match[1], 10) : null;
23
+ }
24
+ /**
25
+ * Fetch the authenticated viewer from the Phoenix server.
26
+ * Gracefully handles network errors, auth failures, and missing endpoints.
27
+ */
28
+ async function fetchViewer(config) {
29
+ try {
30
+ const client = createPhoenixClient({ config });
31
+ const response = await client.GET("/v1/user");
32
+ return { status: "success", user: response.data.data };
33
+ }
34
+ catch (error) {
35
+ // TypeError is thrown by the Fetch API for network-level failures
36
+ if (error instanceof TypeError) {
37
+ return { status: "network_error", message: error.message };
38
+ }
39
+ if (error instanceof Error) {
40
+ const statusCode = parseStatusCode(error);
41
+ if (statusCode === 401 || statusCode === 403) {
42
+ return { status: "auth_error", message: error.message };
43
+ }
44
+ if (statusCode === 404) {
45
+ return { status: "not_found", message: error.message };
46
+ }
47
+ return { status: "unknown_error", message: error.message };
48
+ }
49
+ return { status: "unknown_error", message: String(error) };
50
+ }
51
+ }
52
+ /**
53
+ * Format auth status output in gh-style format.
54
+ */
55
+ export function formatAuthStatus(endpoint, result, apiKey) {
56
+ const lines = [endpoint];
57
+ if (result.status === "success") {
58
+ const user = result.user;
59
+ if (user.auth_method === "ANONYMOUS") {
60
+ lines.push(" \u2713 Authentication not required (anonymous)");
61
+ }
62
+ else {
63
+ lines.push(` \u2713 Logged in as ${user.username} (api key)`);
64
+ lines.push(` - Role: ${user.role}`);
65
+ }
66
+ }
67
+ else if (result.status === "auth_error") {
68
+ lines.push(" \u2717 Authentication failed (invalid or expired token)");
69
+ }
70
+ else if (result.status === "not_found") {
71
+ lines.push(" - Could not verify token (server does not support user endpoint)");
72
+ }
73
+ else {
74
+ // network_error or unknown_error
75
+ if (apiKey) {
76
+ lines.push(" \u2717 Token configured but could not verify (server unreachable)");
77
+ }
78
+ else {
79
+ lines.push(" \u2717 Could not connect to server");
80
+ }
81
+ }
82
+ if (apiKey) {
83
+ lines.push(` - Token: ${obscureApiKey(apiKey)}`);
84
+ }
85
+ return lines.join("\n");
86
+ }
87
+ function exitCodeForResult(result) {
88
+ switch (result.status) {
89
+ case "success":
90
+ // 404 means the server is an older version without /v1/user — the token
91
+ // may still be valid, we just can't verify it. Not a failure.
92
+ case "not_found":
93
+ return ExitCode.SUCCESS;
94
+ case "auth_error":
95
+ return ExitCode.AUTH_REQUIRED;
96
+ case "network_error":
97
+ return ExitCode.NETWORK_ERROR;
98
+ case "unknown_error":
99
+ return ExitCode.FAILURE;
100
+ }
101
+ }
16
102
  /**
17
103
  * Auth status command handler
18
104
  */
19
105
  async function authStatusHandler(options) {
20
- // Resolve configuration
21
106
  const config = resolveConfig({
22
107
  cliOptions: {
23
108
  endpoint: options.endpoint,
24
109
  apiKey: options.apiKey,
25
110
  },
26
111
  });
27
- // Check if endpoint is configured
28
112
  if (!config.endpoint) {
29
113
  writeError({
30
114
  message: "Configuration Error:\n - Phoenix endpoint not configured",
31
115
  });
32
116
  process.exit(ExitCode.INVALID_ARGUMENT);
33
117
  }
34
- const row = {
35
- endpoint: config.endpoint,
36
- status: config.apiKey ? "authenticated" : "anonymous",
37
- "api key": config.apiKey ? obscureApiKey(config.apiKey) : "not set",
38
- };
39
- writeOutput({ message: formatTable([row]) });
118
+ const result = await fetchViewer(config);
119
+ const output = formatAuthStatus(config.endpoint, result, config.apiKey);
120
+ writeOutput({ message: output });
121
+ const code = exitCodeForResult(result);
122
+ if (code !== ExitCode.SUCCESS) {
123
+ process.exit(code);
124
+ }
40
125
  }
41
126
  /**
42
127
  * Create the auth status subcommand
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,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CAAC,iBAAiB,EAAE,oCAAoC,CAAC;SAC/D,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAE7B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpC,OAAO,CAAC,WAAW,CAAC,+BAA+B,CAAC,CAAC;IAErD,kBAAkB;IAClB,OAAO,CAAC,UAAU,CAAC,uBAAuB,EAAE,CAAC,CAAC;IAE9C,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arizeai/phoenix-cli",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "A command-line interface for Phoenix",
5
5
  "keywords": [
6
6
  "arize",
@@ -32,18 +32,18 @@
32
32
  "dependencies": {
33
33
  "@arizeai/openinference-semantic-conventions": "^1.1.0",
34
34
  "commander": "^12.1.0",
35
- "@arizeai/phoenix-client": "6.5.3",
36
- "@arizeai/phoenix-config": "0.1.2"
35
+ "@arizeai/phoenix-client": "6.5.4",
36
+ "@arizeai/phoenix-config": "0.1.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@types/node": "^18.19.0",
39
+ "@types/node": "^22.12.0",
40
40
  "rimraf": "^6.1.3",
41
41
  "tsc-alias": "^1.8.11",
42
42
  "tsx": "^4.19.3",
43
- "vitest": "^2.1.9"
43
+ "vitest": "^4.1.0"
44
44
  },
45
45
  "engines": {
46
- "node": ">=18"
46
+ "node": ">=20"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "tsc && tsc-alias && chmod 755 build/index.js",