@arizeai/phoenix-cli 0.12.0 → 1.0.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 (69) hide show
  1. package/README.md +70 -55
  2. package/build/cli.d.ts.map +1 -1
  3. package/build/cli.js +3 -8
  4. package/build/cli.js.map +1 -1
  5. package/build/commands/auth.d.ts +16 -0
  6. package/build/commands/auth.d.ts.map +1 -1
  7. package/build/commands/auth.js +94 -9
  8. package/build/commands/auth.js.map +1 -1
  9. package/build/commands/dataset.d.ts +6 -1
  10. package/build/commands/dataset.d.ts.map +1 -1
  11. package/build/commands/dataset.js +93 -4
  12. package/build/commands/dataset.js.map +1 -1
  13. package/build/commands/experiment.d.ts +3 -1
  14. package/build/commands/experiment.d.ts.map +1 -1
  15. package/build/commands/experiment.js +175 -8
  16. package/build/commands/experiment.js.map +1 -1
  17. package/build/commands/index.d.ts +2 -7
  18. package/build/commands/index.d.ts.map +1 -1
  19. package/build/commands/index.js +2 -7
  20. package/build/commands/index.js.map +1 -1
  21. package/build/commands/project.d.ts +7 -0
  22. package/build/commands/project.d.ts.map +1 -0
  23. package/build/commands/{projects.js → project.js} +15 -16
  24. package/build/commands/project.js.map +1 -0
  25. package/build/commands/prompt.d.ts +3 -1
  26. package/build/commands/prompt.d.ts.map +1 -1
  27. package/build/commands/prompt.js +90 -4
  28. package/build/commands/prompt.js.map +1 -1
  29. package/build/commands/session.d.ts +3 -1
  30. package/build/commands/session.d.ts.map +1 -1
  31. package/build/commands/session.js +124 -10
  32. package/build/commands/session.js.map +1 -1
  33. package/build/commands/span.d.ts +10 -0
  34. package/build/commands/span.d.ts.map +1 -0
  35. package/build/commands/{spans.js → span.js} +15 -8
  36. package/build/commands/span.js.map +1 -0
  37. package/build/commands/trace.d.ts +3 -1
  38. package/build/commands/trace.d.ts.map +1 -1
  39. package/build/commands/trace.js +259 -8
  40. package/build/commands/trace.js.map +1 -1
  41. package/build/config.js +1 -1
  42. package/build/config.js.map +1 -1
  43. package/package.json +6 -6
  44. package/build/commands/datasets.d.ts +0 -6
  45. package/build/commands/datasets.d.ts.map +0 -1
  46. package/build/commands/datasets.js +0 -98
  47. package/build/commands/datasets.js.map +0 -1
  48. package/build/commands/experiments.d.ts +0 -6
  49. package/build/commands/experiments.d.ts.map +0 -1
  50. package/build/commands/experiments.js +0 -202
  51. package/build/commands/experiments.js.map +0 -1
  52. package/build/commands/projects.d.ts +0 -6
  53. package/build/commands/projects.d.ts.map +0 -1
  54. package/build/commands/projects.js.map +0 -1
  55. package/build/commands/prompts.d.ts +0 -6
  56. package/build/commands/prompts.d.ts.map +0 -1
  57. package/build/commands/prompts.js +0 -98
  58. package/build/commands/prompts.js.map +0 -1
  59. package/build/commands/sessions.d.ts +0 -6
  60. package/build/commands/sessions.d.ts.map +0 -1
  61. package/build/commands/sessions.js +0 -127
  62. package/build/commands/sessions.js.map +0 -1
  63. package/build/commands/spans.d.ts +0 -6
  64. package/build/commands/spans.d.ts.map +0 -1
  65. package/build/commands/spans.js.map +0 -1
  66. package/build/commands/traces.d.ts +0 -6
  67. package/build/commands/traces.d.ts.map +0 -1
  68. package/build/commands/traces.js +0 -278
  69. package/build/commands/traces.js.map +0 -1
package/README.md CHANGED
@@ -67,16 +67,16 @@ px self update --check # show current/latest without installing
67
67
  Automatic updates are supported for global `npm`, `pnpm`, `bun`, and standard
68
68
  `deno install -g` wrapper installs.
69
69
 
70
- ### `px traces [directory]`
70
+ ### `px trace list [directory]`
71
71
 
72
72
  Fetch recent traces from the configured project. All output is JSON.
73
73
 
74
74
  ```bash
75
- px traces --limit 10 # stdout (pretty)
76
- px traces --format raw --no-progress | jq # pipe-friendly compact JSON
77
- px traces ./my-traces --limit 50 # save as JSON files to directory
78
- px traces --last-n-minutes 60 --limit 20 # filter by time window
79
- px traces --since 2026-01-13T10:00:00Z # since ISO timestamp
75
+ px trace list --limit 10 # stdout (pretty)
76
+ px trace list --format raw --no-progress | jq # pipe-friendly compact JSON
77
+ px trace list ./my-traces --limit 50 # save as JSON files to directory
78
+ px trace list --last-n-minutes 60 --limit 20 # filter by time window
79
+ px trace list --since 2026-01-13T10:00:00Z # since ISO timestamp
80
80
  ```
81
81
 
82
82
  | Option | Description | Default |
@@ -91,42 +91,42 @@ px traces --since 2026-01-13T10:00:00Z # since ISO timestamp
91
91
 
92
92
  ```bash
93
93
  # Find ERROR traces
94
- px traces --limit 50 --format raw --no-progress | jq '.[] | select(.status == "ERROR")'
94
+ px trace list --limit 50 --format raw --no-progress | jq '.[] | select(.status == "ERROR")'
95
95
 
96
96
  # Sort by duration, take top 5 slowest
97
- px traces --limit 20 --format raw --no-progress | jq 'sort_by(-.duration) | .[0:5]'
97
+ px trace list --limit 20 --format raw --no-progress | jq 'sort_by(-.duration) | .[0:5]'
98
98
 
99
99
  # Extract LLM model names used
100
- px traces --limit 50 --format raw --no-progress | \
100
+ px trace list --limit 50 --format raw --no-progress | \
101
101
  jq -r '.[].spans[] | select(.span_kind == "LLM") | .attributes["llm.model_name"]' | sort -u
102
102
  ```
103
103
 
104
104
  ---
105
105
 
106
- ### `px trace <trace-id>`
106
+ ### `px trace get <trace-id>`
107
107
 
108
108
  Fetch a single trace by ID.
109
109
 
110
110
  ```bash
111
- px trace abc123def456
112
- px trace abc123def456 --format raw | jq '.spans[] | select(.status_code != "OK")'
113
- px trace abc123def456 --file trace.json
111
+ px trace get abc123def456
112
+ px trace get abc123def456 --format raw | jq '.spans[] | select(.status_code != "OK")'
113
+ px trace get abc123def456 --file trace.json
114
114
  ```
115
115
 
116
116
  ---
117
117
 
118
- ### `px spans [file]`
118
+ ### `px span list [file]`
119
119
 
120
120
  Fetch spans for the configured project with filtering options. Output is JSON.
121
121
 
122
122
  ```bash
123
- px spans --limit 50 # stdout (pretty)
124
- px spans --span-kind LLM --limit 20 # only LLM spans
125
- px spans --status-code ERROR --format raw --no-progress # pipe-friendly error spans
126
- px spans --name chat_completion --trace-id abc123 # filter by name and trace
127
- px spans --parent-id null # root spans only
128
- px spans spans.json --limit 100 --include-annotations # save to file with annotations
129
- px spans --last-n-minutes 30 --span-kind TOOL RETRIEVER # multiple span kinds
123
+ px span list --limit 50 # stdout (pretty)
124
+ px span list --span-kind LLM --limit 20 # only LLM spans
125
+ px span list --status-code ERROR --format raw --no-progress # pipe-friendly error spans
126
+ px span list --name chat_completion --trace-id abc123 # filter by name and trace
127
+ px span list --parent-id null # root spans only
128
+ px span list spans.json --limit 100 --include-annotations # save to file with annotations
129
+ px span list --last-n-minutes 30 --span-kind TOOL RETRIEVER # multiple span kinds
130
130
  ```
131
131
 
132
132
  | Option | Description | Default |
@@ -146,85 +146,85 @@ px spans --last-n-minutes 30 --span-kind TOOL RETRIEVER # multiple span kinds
146
146
 
147
147
  ```bash
148
148
  # Find all ERROR spans
149
- px spans --status-code ERROR --format raw --no-progress | jq '.[] | {name, status_code}'
149
+ px span list --status-code ERROR --format raw --no-progress | jq '.[] | {name, status_code}'
150
150
 
151
151
  # Get LLM spans with token counts
152
- px spans --span-kind LLM --format raw --no-progress | \
152
+ px span list --span-kind LLM --format raw --no-progress | \
153
153
  jq '.[] | {name, model: .attributes["llm.model_name"], tokens: (.attributes["llm.token_count.prompt"] + .attributes["llm.token_count.completion"])}'
154
154
 
155
155
  # Root spans only, sorted by name
156
- px spans --parent-id null --format raw --no-progress | jq 'sort_by(.name)'
156
+ px span list --parent-id null --format raw --no-progress | jq 'sort_by(.name)'
157
157
  ```
158
158
 
159
159
  ---
160
160
 
161
- ### `px datasets`
161
+ ### `px dataset list`
162
162
 
163
163
  List all datasets.
164
164
 
165
165
  ```bash
166
- px datasets --format raw --no-progress | jq '.[].name'
166
+ px dataset list --format raw --no-progress | jq '.[].name'
167
167
  ```
168
168
 
169
169
  ---
170
170
 
171
- ### `px dataset <dataset-identifier>`
171
+ ### `px dataset get <dataset-identifier>`
172
172
 
173
173
  Fetch examples from a dataset.
174
174
 
175
175
  ```bash
176
- px dataset my-dataset --format raw | jq '.examples[].input'
177
- px dataset my-dataset --split train --split test
178
- px dataset my-dataset --version <version-id>
179
- px dataset my-dataset --file dataset.json
176
+ px dataset get my-dataset --format raw | jq '.examples[].input'
177
+ px dataset get my-dataset --split train --split test
178
+ px dataset get my-dataset --version <version-id>
179
+ px dataset get my-dataset --file dataset.json
180
180
  ```
181
181
 
182
182
  ---
183
183
 
184
- ### `px experiments --dataset <name-or-id>`
184
+ ### `px experiment list --dataset <name-or-id>`
185
185
 
186
186
  List experiments for a dataset.
187
187
 
188
188
  ```bash
189
- px experiments --dataset my-dataset --format raw --no-progress | \
189
+ px experiment list --dataset my-dataset --format raw --no-progress | \
190
190
  jq '.[] | {id, successful_run_count, failed_run_count}'
191
191
  ```
192
192
 
193
193
  ---
194
194
 
195
- ### `px experiment <experiment-id>`
195
+ ### `px experiment get <experiment-id>`
196
196
 
197
197
  Fetch a single experiment with all run data (inputs, outputs, evaluations, trace IDs).
198
198
 
199
199
  ```bash
200
200
  # Find failed runs
201
- px experiment RXhwZXJpbWVudDox --format raw --no-progress | \
201
+ px experiment get RXhwZXJpbWVudDox --format raw --no-progress | \
202
202
  jq '.[] | select(.error != null) | {input, error}'
203
203
 
204
204
  # Average latency
205
- px experiment RXhwZXJpbWVudDox --format raw --no-progress | \
205
+ px experiment get RXhwZXJpbWVudDox --format raw --no-progress | \
206
206
  jq '[.[].latency_ms] | add / length'
207
207
  ```
208
208
 
209
209
  ---
210
210
 
211
- ### `px prompts`
211
+ ### `px prompt list`
212
212
 
213
213
  List all prompts.
214
214
 
215
215
  ```bash
216
- px prompts --format raw --no-progress | jq '.[].name'
216
+ px prompt list --format raw --no-progress | jq '.[].name'
217
217
  ```
218
218
 
219
219
  ---
220
220
 
221
- ### `px prompt <prompt-identifier>`
221
+ ### `px prompt get <prompt-identifier>`
222
222
 
223
223
  Fetch a prompt. The `text` format is ideal for piping to AI assistants.
224
224
 
225
225
  ```bash
226
- px prompt my-evaluator --format text --no-progress | claude -p "Review this prompt"
227
- px prompt my-evaluator --tag production --format json | jq '.template'
226
+ px prompt get my-evaluator --format text --no-progress | claude -p "Review this prompt"
227
+ px prompt get my-evaluator --tag production --format json | jq '.template'
228
228
  ```
229
229
 
230
230
  | Option | Description | Default |
@@ -235,14 +235,14 @@ px prompt my-evaluator --tag production --format json | jq '.template'
235
235
 
236
236
  ---
237
237
 
238
- ### `px projects`
238
+ ### `px project list`
239
239
 
240
240
  List all available Phoenix projects.
241
241
 
242
242
  ```bash
243
- px projects # pretty output
244
- px projects --format raw --no-progress | jq '.[].name'
245
- px projects --limit 5
243
+ px project list # pretty output
244
+ px project list --format raw --no-progress | jq '.[].name'
245
+ px project list --limit 5
246
246
  ```
247
247
 
248
248
  | Option | Description | Default |
@@ -253,14 +253,14 @@ px projects --limit 5
253
253
 
254
254
  ---
255
255
 
256
- ### `px sessions`
256
+ ### `px session list`
257
257
 
258
258
  List sessions for a project.
259
259
 
260
260
  ```bash
261
- px sessions # latest 10 sessions
262
- px sessions --limit 20 --order asc # oldest first
263
- px sessions --format raw --no-progress | jq '.[].session_id'
261
+ px session list # latest 10 sessions
262
+ px session list --limit 20 --order asc # oldest first
263
+ px session list --format raw --no-progress | jq '.[].session_id'
264
264
  ```
265
265
 
266
266
  | Option | Description | Default |
@@ -272,14 +272,14 @@ px sessions --format raw --no-progress | jq '.[].session_id'
272
272
 
273
273
  ---
274
274
 
275
- ### `px session <session-id>`
275
+ ### `px session get <session-id>`
276
276
 
277
277
  View a session's conversation flow.
278
278
 
279
279
  ```bash
280
- px session my-session-id
281
- px session my-session-id --file session.json
282
- px session my-session-id --include-annotations --format raw | jq '.traces'
280
+ px session get my-session-id
281
+ px session get my-session-id --file session.json
282
+ px session get my-session-id --include-annotations --format raw | jq '.traces'
283
283
  ```
284
284
 
285
285
  | Option | Description | Default |
@@ -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 list`
295
+
296
+ List annotation configurations defined in your Phoenix instance.
297
+
298
+ ```bash
299
+ px annotation-config list --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.
@@ -431,8 +446,8 @@ px docs fetch --refresh # clear output dir and re-download
431
446
  All commands output JSON. Use `--format raw` for compact JSON and `--no-progress` to suppress stderr when piping:
432
447
 
433
448
  ```bash
434
- px traces --format raw --no-progress | jq ...
435
- px datasets --format raw --no-progress | jq ...
449
+ px trace list --format raw --no-progress | jq ...
450
+ px dataset list --format raw --no-progress | jq ...
436
451
  ```
437
452
 
438
453
  Trace JSON structure:
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwBpC,wBAAgB,aAAa,IAAI,OAAO,CA2BvC;AAGD,wBAAsB,IAAI,CAAC,EACzB,IAAmB,GACpB,GAAE;IACD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACZ,GAAG,OAAO,CAAC,IAAI,CAAC,CAWrB"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBpC,wBAAgB,aAAa,IAAI,OAAO,CAsBvC;AAGD,wBAAsB,IAAI,CAAC,EACzB,IAAmB,GACpB,GAAE;IACD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACZ,GAAG,OAAO,CAAC,IAAI,CAAC,CAWrB"}
package/build/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
3
  import { printBanner } from "./banner.js";
4
- import { createAnnotationConfigCommand, createApiCommand, createAuthCommand, createDatasetCommand, createDatasetsCommand, createDocsCommand, createExperimentCommand, createExperimentsCommand, createProjectsCommand, createPromptCommand, createPromptsCommand, createSessionCommand, createSessionsCommand, createSelfCommand, createSpansCommand, createTraceCommand, createTracesCommand, } from "./commands/index.js";
4
+ import { createAnnotationConfigCommand, createApiCommand, createAuthCommand, createDatasetCommand, createDocsCommand, createExperimentCommand, createProjectCommand, createPromptCommand, createSessionCommand, createSelfCommand, createSpanCommand, createTraceCommand, } from "./commands/index.js";
5
5
  import { CLI_VERSION } from "./version.js";
6
6
  export function createProgram() {
7
7
  const program = new Command();
@@ -11,17 +11,12 @@ export function createProgram() {
11
11
  // Register commands
12
12
  program.addCommand(createAnnotationConfigCommand());
13
13
  program.addCommand(createAuthCommand());
14
- program.addCommand(createProjectsCommand());
15
- program.addCommand(createTracesCommand());
14
+ program.addCommand(createProjectCommand());
16
15
  program.addCommand(createTraceCommand());
17
- program.addCommand(createSpansCommand());
18
- program.addCommand(createDatasetsCommand());
16
+ program.addCommand(createSpanCommand());
19
17
  program.addCommand(createDatasetCommand());
20
- program.addCommand(createSessionsCommand());
21
18
  program.addCommand(createSessionCommand());
22
- program.addCommand(createExperimentsCommand());
23
19
  program.addCommand(createExperimentCommand());
24
- program.addCommand(createPromptsCommand());
25
20
  program.addCommand(createPromptCommand());
26
21
  program.addCommand(createApiCommand());
27
22
  program.addCommand(createDocsCommand());
package/build/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB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C,UAAU,CAAC,6BAA6B,EAAE,CAAC,CAAC;IACpD,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACzC,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,UAAU,CAAC,uBAAuB,EAAE,CAAC,CAAC;IAC9C,OAAO,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACvC,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAExC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,yBAAyB;AACzB,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EACzB,IAAI,GAAG,OAAO,CAAC,IAAI,MAGjB,EAAE;IACJ,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;IAEhC,8CAA8C;IAC9C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,WAAW,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IAED,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC"}
@@ -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,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAO5C;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,sCAAsC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,iBAAiB,CAAC,OAA0B;IACzD,wBAAwB;IACxB,MAAM,MAAM,GAAG,aAAa,CAAC;QAC3B,UAAU,EAAE;YACV,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB;KACF,CAAC,CAAC;IAEH,kCAAkC;IAClC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;Q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MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACxE,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAEjC,MAAM,IAAI,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,IAAI,KAAK,QAAQ,CAAC,OAAO,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB;IAC9B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEtC,OAAO;SACJ,WAAW,CAAC,4CAA4C,CAAC;SACzD,MAAM,CAAC,kBAAkB,EAAE,sBAAsB,CAAC;SAClD,MAAM,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"}
@@ -1,6 +1,11 @@
1
1
  import { Command } from "commander";
2
2
  /**
3
- * Create the dataset command
3
+ * Create the `dataset get` command
4
+ */
5
+ export declare function createDatasetGetCommand(): Command;
6
+ export declare function createDatasetListCommand(): Command;
7
+ /**
8
+ * Create the `dataset` command with subcommands
4
9
  */
5
10
  export declare function createDatasetCommand(): Command;
6
11
  //# sourceMappingURL=dataset.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dataset.d.ts","sourceRoot":"","sources":["../../src/commands/dataset.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsLpC;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAyB9C"}
1
+ {"version":3,"file":"dataset.d.ts","sourceRoot":"","sources":["../../src/commands/dataset.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsRpC;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAqBjD;AAED,wBAAgB,wBAAwB,IAAI,OAAO,CAalD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAM9C"}
@@ -5,6 +5,34 @@ import { getConfigErrorMessage, resolveConfig } from "../config.js";
5
5
  import { ExitCode, getExitCodeForError } from "../exitCodes.js";
6
6
  import { writeError, writeOutput, writeProgress } from "../io.js";
7
7
  import { formatDatasetExamplesOutput, } from "./formatDataset.js";
8
+ import { formatDatasetsOutput } from "./formatDatasets.js";
9
+ /**
10
+ * Fetch all datasets from Phoenix
11
+ */
12
+ async function fetchDatasets(client, options = {}) {
13
+ const allDatasets = [];
14
+ let cursor;
15
+ const pageLimit = options.limit || 100;
16
+ do {
17
+ const response = await client.GET("/v1/datasets", {
18
+ params: {
19
+ query: {
20
+ cursor,
21
+ limit: pageLimit,
22
+ },
23
+ },
24
+ });
25
+ if (response.error || !response.data) {
26
+ throw new Error(`Failed to fetch datasets: ${response.error}`);
27
+ }
28
+ allDatasets.push(...response.data.data);
29
+ cursor = response.data.next_cursor || undefined;
30
+ if (options.limit && allDatasets.length >= options.limit) {
31
+ break;
32
+ }
33
+ } while (cursor);
34
+ return allDatasets;
35
+ }
8
36
  /**
9
37
  * Fetch dataset examples from Phoenix
10
38
  */
@@ -127,6 +155,49 @@ async function datasetHandler(datasetIdentifier, options) {
127
155
  process.exit(getExitCodeForError(error));
128
156
  }
129
157
  }
158
+ /**
159
+ * Handler for `dataset list`
160
+ */
161
+ async function datasetListHandler(options) {
162
+ try {
163
+ const config = resolveConfig({
164
+ cliOptions: {
165
+ endpoint: options.endpoint,
166
+ apiKey: options.apiKey,
167
+ },
168
+ });
169
+ if (!config.endpoint) {
170
+ const errors = [
171
+ "Phoenix endpoint not configured. Set PHOENIX_HOST environment variable or use --endpoint flag.",
172
+ ];
173
+ writeError({ message: getConfigErrorMessage({ errors }) });
174
+ process.exit(ExitCode.INVALID_ARGUMENT);
175
+ }
176
+ const client = createPhoenixClient({ config });
177
+ writeProgress({
178
+ message: "Fetching datasets...",
179
+ noProgress: !options.progress,
180
+ });
181
+ const datasets = await fetchDatasets(client, {
182
+ limit: options.limit,
183
+ });
184
+ writeProgress({
185
+ message: `Found ${datasets.length} dataset(s)`,
186
+ noProgress: !options.progress,
187
+ });
188
+ const output = formatDatasetsOutput({
189
+ datasets,
190
+ format: options.format,
191
+ });
192
+ writeOutput({ message: output });
193
+ }
194
+ catch (error) {
195
+ writeError({
196
+ message: `Error fetching datasets: ${error instanceof Error ? error.message : String(error)}`,
197
+ });
198
+ process.exit(getExitCodeForError(error));
199
+ }
200
+ }
130
201
  /**
131
202
  * Collect multiple --split options into an array
132
203
  */
@@ -134,11 +205,10 @@ function collectSplits(value, previous) {
134
205
  return previous.concat([value]);
135
206
  }
136
207
  /**
137
- * Create the dataset command
208
+ * Create the `dataset get` command
138
209
  */
139
- export function createDatasetCommand() {
140
- const command = new Command("dataset");
141
- command
210
+ export function createDatasetGetCommand() {
211
+ return new Command("get")
142
212
  .description("Fetch examples from a dataset")
143
213
  .argument("<dataset-identifier>", "Dataset name or ID")
144
214
  .option("--endpoint <url>", "Phoenix API endpoint")
@@ -149,6 +219,25 @@ export function createDatasetCommand() {
149
219
  .option("--split <name>", "Filter by split name (can be used multiple times)", collectSplits, [])
150
220
  .option("--version <id>", "Fetch from a specific dataset version")
151
221
  .action(datasetHandler);
222
+ }
223
+ export function createDatasetListCommand() {
224
+ return new Command("list")
225
+ .description("List all available Phoenix datasets")
226
+ .option("--endpoint <url>", "Phoenix API endpoint")
227
+ .option("--api-key <key>", "Phoenix API key for authentication")
228
+ .option("--format <format>", "Output format: pretty, json, or raw", "pretty")
229
+ .option("--no-progress", "Disable progress indicators")
230
+ .option("--limit <number>", "Maximum number of datasets to fetch", parseInt)
231
+ .action(datasetListHandler);
232
+ }
233
+ /**
234
+ * Create the `dataset` command with subcommands
235
+ */
236
+ export function createDatasetCommand() {
237
+ const command = new Command("dataset");
238
+ command.description("Manage Phoenix datasets");
239
+ command.addCommand(createDatasetListCommand());
240
+ command.addCommand(createDatasetGetCommand());
152
241
  return command;
153
242
  }
154
243
  //# sourceMappingURL=dataset.js.map