@arizeai/phoenix-cli 0.10.0 → 0.11.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 +131 -0
- package/build/commands/api.d.ts +15 -0
- package/build/commands/api.d.ts.map +1 -1
- package/build/commands/api.js +58 -14
- package/build/commands/api.js.map +1 -1
- package/build/curl.d.ts +13 -0
- package/build/curl.d.ts.map +1 -0
- package/build/curl.js +49 -0
- package/build/curl.js.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -99,6 +99,49 @@ px trace abc123def456 --file trace.json
|
|
|
99
99
|
|
|
100
100
|
---
|
|
101
101
|
|
|
102
|
+
### `px spans [file]`
|
|
103
|
+
|
|
104
|
+
Fetch spans for the configured project with filtering options. Output is JSON.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
px spans --limit 50 # stdout (pretty)
|
|
108
|
+
px spans --span-kind LLM --limit 20 # only LLM spans
|
|
109
|
+
px spans --status-code ERROR --format raw --no-progress # pipe-friendly error spans
|
|
110
|
+
px spans --name chat_completion --trace-id abc123 # filter by name and trace
|
|
111
|
+
px spans --parent-id null # root spans only
|
|
112
|
+
px spans spans.json --limit 100 --include-annotations # save to file with annotations
|
|
113
|
+
px spans --last-n-minutes 30 --span-kind TOOL RETRIEVER # multiple span kinds
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
| Option | Description | Default |
|
|
117
|
+
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------- |
|
|
118
|
+
| `[file]` | Save spans as JSON to file | stdout |
|
|
119
|
+
| `-n, --limit <number>` | Maximum number of spans (newest first) | `100` |
|
|
120
|
+
| `--last-n-minutes <number>` | Only spans from the last N minutes | — |
|
|
121
|
+
| `--since <timestamp>` | Spans since ISO timestamp | — |
|
|
122
|
+
| `--span-kind <kinds...>` | Filter by span kind (`LLM`, `CHAIN`, `TOOL`, `RETRIEVER`, `EMBEDDING`, `AGENT`, `RERANKER`, `GUARDRAIL`, `EVALUATOR`, `UNKNOWN`) | — |
|
|
123
|
+
| `--status-code <codes...>` | Filter by status code (`OK`, `ERROR`, `UNSET`) | — |
|
|
124
|
+
| `--name <names...>` | Filter by span name(s) | — |
|
|
125
|
+
| `--trace-id <ids...>` | Filter by trace ID(s) | — |
|
|
126
|
+
| `--parent-id <id>` | Filter by parent span ID (use `"null"` for root spans only) | — |
|
|
127
|
+
| `--include-annotations` | Include span annotations in the output | — |
|
|
128
|
+
| `--format <format>` | `pretty`, `json`, or `raw` | `pretty` |
|
|
129
|
+
| `--no-progress` | Suppress progress output | — |
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Find all ERROR spans
|
|
133
|
+
px spans --status-code ERROR --format raw --no-progress | jq '.[] | {name, status_code}'
|
|
134
|
+
|
|
135
|
+
# Get LLM spans with token counts
|
|
136
|
+
px spans --span-kind LLM --format raw --no-progress | \
|
|
137
|
+
jq '.[] | {name, model: .attributes["llm.model_name"], tokens: (.attributes["llm.token_count.prompt"] + .attributes["llm.token_count.completion"])}'
|
|
138
|
+
|
|
139
|
+
# Root spans only, sorted by name
|
|
140
|
+
px spans --parent-id null --format raw --no-progress | jq 'sort_by(.name)'
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
102
145
|
### `px datasets`
|
|
103
146
|
|
|
104
147
|
List all datasets.
|
|
@@ -176,6 +219,78 @@ px prompt my-evaluator --tag production --format json | jq '.template'
|
|
|
176
219
|
|
|
177
220
|
---
|
|
178
221
|
|
|
222
|
+
### `px projects`
|
|
223
|
+
|
|
224
|
+
List all available Phoenix projects.
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
px projects # pretty output
|
|
228
|
+
px projects --format raw --no-progress | jq '.[].name'
|
|
229
|
+
px projects --limit 5
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
| Option | Description | Default |
|
|
233
|
+
| ------------------- | ----------------------------------- | -------- |
|
|
234
|
+
| `--limit <number>` | Maximum number of projects per page | — |
|
|
235
|
+
| `--format <format>` | `pretty`, `json`, or `raw` | `pretty` |
|
|
236
|
+
| `--no-progress` | Suppress progress output | — |
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
### `px sessions`
|
|
241
|
+
|
|
242
|
+
List sessions for a project.
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
px sessions # latest 10 sessions
|
|
246
|
+
px sessions --limit 20 --order asc # oldest first
|
|
247
|
+
px sessions --format raw --no-progress | jq '.[].session_id'
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
| Option | Description | Default |
|
|
251
|
+
| ---------------------- | --------------------------- | -------- |
|
|
252
|
+
| `-n, --limit <number>` | Maximum number of sessions | `10` |
|
|
253
|
+
| `--order <order>` | Sort order: `asc` or `desc` | `desc` |
|
|
254
|
+
| `--format <format>` | `pretty`, `json`, or `raw` | `pretty` |
|
|
255
|
+
| `--no-progress` | Suppress progress output | — |
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### `px session <session-id>`
|
|
260
|
+
|
|
261
|
+
View a session's conversation flow.
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
px session my-session-id
|
|
265
|
+
px session my-session-id --file session.json
|
|
266
|
+
px session my-session-id --include-annotations --format raw | jq '.traces'
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
| Option | Description | Default |
|
|
270
|
+
| ----------------------- | -------------------------------------- | -------- |
|
|
271
|
+
| `--file <path>` | Save session to file instead of stdout | — |
|
|
272
|
+
| `--include-annotations` | Include session annotations | — |
|
|
273
|
+
| `--format <format>` | `pretty`, `json`, or `raw` | `pretty` |
|
|
274
|
+
| `--no-progress` | Suppress progress output | — |
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
### `px auth status`
|
|
279
|
+
|
|
280
|
+
Show current Phoenix authentication status, including the configured endpoint, whether you are authenticated or anonymous, and an obscured API key.
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
px auth status
|
|
284
|
+
px auth status --endpoint http://localhost:6006
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
| Option | Description | Default |
|
|
288
|
+
| ------------------ | -------------------- | ------- |
|
|
289
|
+
| `--endpoint <url>` | Phoenix API endpoint | — |
|
|
290
|
+
| `--api-key <key>` | Phoenix API key | — |
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
179
294
|
### `px api graphql <query>`
|
|
180
295
|
|
|
181
296
|
Make authenticated GraphQL queries against the Phoenix API. Output is `{"data": {...}}` JSON — pipe with `jq '.data.<field>'` to extract values. Only queries are permitted; mutations and subscriptions are rejected.
|
|
@@ -184,6 +299,22 @@ Make authenticated GraphQL queries against the Phoenix API. Output is `{"data":
|
|
|
184
299
|
px api graphql '<query>' [--endpoint <url>] [--api-key <key>]
|
|
185
300
|
```
|
|
186
301
|
|
|
302
|
+
Preview the exact HTTP request as `curl` without executing it:
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
px api graphql '{ projects { edges { node { name } } } }' --curl
|
|
306
|
+
px api graphql '{ projects { edges { node { name } } } }' --curl --show-token
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
`--curl` prints the equivalent request to stdout and exits without making a network call. Authorization headers are masked by default, including values supplied through `PHOENIX_API_KEY` or `PHOENIX_CLIENT_HEADERS`. Use `--show-token` only when you explicitly need the raw credential in the generated command.
|
|
310
|
+
|
|
311
|
+
Current scope and behavior:
|
|
312
|
+
|
|
313
|
+
- `--curl` is currently implemented for `px api graphql` only.
|
|
314
|
+
- `--curl` prints the request without executing it.
|
|
315
|
+
- `--show-token` is only valid with `--curl`.
|
|
316
|
+
- Authorization masking and header normalization are designed to match the live request behavior used by `fetch`.
|
|
317
|
+
|
|
187
318
|
Use introspection to discover what fields are available:
|
|
188
319
|
|
|
189
320
|
```bash
|
package/build/commands/api.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
+
import type { PhoenixConfig } from "../config.js";
|
|
2
3
|
/**
|
|
3
4
|
* Returns true if the query string is a GraphQL mutation or subscription.
|
|
4
5
|
* Strips # comments first to avoid false positives.
|
|
@@ -6,5 +7,19 @@ import { Command } from "commander";
|
|
|
6
7
|
export declare function isNonQuery({ query }: {
|
|
7
8
|
query: string;
|
|
8
9
|
}): boolean;
|
|
10
|
+
export interface ApiGraphqlRequest {
|
|
11
|
+
url: string;
|
|
12
|
+
method: "POST";
|
|
13
|
+
headers: Record<string, string>;
|
|
14
|
+
body: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Builds the exact outbound GraphQL request used by both live execution and
|
|
18
|
+
* `--curl` preview mode so the two paths cannot drift apart.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildGraphqlRequest({ query, config, }: {
|
|
21
|
+
query: string;
|
|
22
|
+
config: PhoenixConfig;
|
|
23
|
+
}): ApiGraphqlRequest;
|
|
9
24
|
export declare function createApiCommand(): Command;
|
|
10
25
|
//# sourceMappingURL=api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM/C;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAGhE;AASD,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,MAAM,GACP,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,aAAa,CAAC;CACvB,GAAG,iBAAiB,CAepB;AA6ID,wBAAgB,gBAAgB,IAAI,OAAO,CAK1C"}
|
package/build/commands/api.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { getConfigErrorMessage, resolveConfig } from "../config.js";
|
|
3
|
+
import { renderCurlCommand } from "../curl.js";
|
|
3
4
|
import { ExitCode, getExitCodeForError } from "../exitCodes.js";
|
|
4
5
|
import { writeError, writeOutput } from "../io.js";
|
|
5
6
|
/**
|
|
@@ -10,8 +11,33 @@ export function isNonQuery({ query }) {
|
|
|
10
11
|
const stripped = query.replace(/#[^\n]*/g, "");
|
|
11
12
|
return /^\s*(mutation|subscription)[\s({]/m.test(stripped);
|
|
12
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Builds the exact outbound GraphQL request used by both live execution and
|
|
16
|
+
* `--curl` preview mode so the two paths cannot drift apart.
|
|
17
|
+
*/
|
|
18
|
+
export function buildGraphqlRequest({ query, config, }) {
|
|
19
|
+
const headers = {
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
...(config.headers ?? {}),
|
|
22
|
+
};
|
|
23
|
+
if (config.apiKey) {
|
|
24
|
+
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
url: `${config.endpoint?.replace(/\/$/, "")}/graphql`,
|
|
28
|
+
method: "POST",
|
|
29
|
+
headers,
|
|
30
|
+
body: JSON.stringify({ query }),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
13
33
|
async function apiGraphqlHandler(query, options) {
|
|
14
34
|
try {
|
|
35
|
+
if (options.showToken && !options.curl) {
|
|
36
|
+
writeError({
|
|
37
|
+
message: "Error: --show-token can only be used with --curl.",
|
|
38
|
+
});
|
|
39
|
+
process.exit(ExitCode.INVALID_ARGUMENT);
|
|
40
|
+
}
|
|
15
41
|
// 1. Reject mutations and subscriptions
|
|
16
42
|
if (isNonQuery({ query })) {
|
|
17
43
|
writeError({
|
|
@@ -33,24 +59,31 @@ async function apiGraphqlHandler(query, options) {
|
|
|
33
59
|
});
|
|
34
60
|
process.exit(ExitCode.INVALID_ARGUMENT);
|
|
35
61
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
62
|
+
const request = buildGraphqlRequest({
|
|
63
|
+
query,
|
|
64
|
+
config,
|
|
65
|
+
});
|
|
66
|
+
if (options.curl) {
|
|
67
|
+
writeOutput({
|
|
68
|
+
message: renderCurlCommand({
|
|
69
|
+
method: request.method,
|
|
70
|
+
url: request.url,
|
|
71
|
+
headers: request.headers,
|
|
72
|
+
body: request.body,
|
|
73
|
+
maskTokens: !options.showToken,
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
return;
|
|
44
77
|
}
|
|
45
78
|
// 4. POST using Node 22 built-in fetch
|
|
46
|
-
const response = await fetch(
|
|
47
|
-
method:
|
|
48
|
-
headers,
|
|
49
|
-
body:
|
|
79
|
+
const response = await fetch(request.url, {
|
|
80
|
+
method: request.method,
|
|
81
|
+
headers: request.headers,
|
|
82
|
+
body: request.body,
|
|
50
83
|
});
|
|
51
84
|
if (!response.ok) {
|
|
52
85
|
writeError({
|
|
53
|
-
message: `Error: HTTP ${response.status} ${response.statusText} from ${
|
|
86
|
+
message: `Error: HTTP ${response.status} ${response.statusText} from ${request.url}`,
|
|
54
87
|
});
|
|
55
88
|
if (response.status === 401 || response.status === 403) {
|
|
56
89
|
process.exit(ExitCode.AUTH_REQUIRED);
|
|
@@ -92,10 +125,21 @@ function createApiGraphqlCommand() {
|
|
|
92
125
|
"\n" +
|
|
93
126
|
" # Pipe to jq to extract fields\n" +
|
|
94
127
|
" px api graphql '{ projects { edges { node { name } } } }' | \\\n" +
|
|
95
|
-
" jq '.data.projects.edges[].node.name'"
|
|
128
|
+
" jq '.data.projects.edges[].node.name'\n" +
|
|
129
|
+
"\n" +
|
|
130
|
+
" # Print the equivalent curl command without executing it\n" +
|
|
131
|
+
" px api graphql '{ projects { edges { node { name } } } }' --curl\n" +
|
|
132
|
+
"\n" +
|
|
133
|
+
" # Reveal the raw token in curl output\n" +
|
|
134
|
+
" px api graphql '{ projects { edges { node { name } } } }' --curl --show-token\n" +
|
|
135
|
+
"\n" +
|
|
136
|
+
" Curl mode prints the request without executing it.\n" +
|
|
137
|
+
" Auth tokens are masked by default. Use --show-token with --curl to reveal them.")
|
|
96
138
|
.argument("<query>", "GraphQL query string")
|
|
97
139
|
.option("--endpoint <url>", "Phoenix API endpoint (or set PHOENIX_HOST)")
|
|
98
140
|
.option("--api-key <key>", "Phoenix API key (or set PHOENIX_API_KEY)")
|
|
141
|
+
.option("--curl", "Print the equivalent curl command instead of executing the request")
|
|
142
|
+
.option("--show-token", "Show the raw Authorization token in curl output (requires --curl)")
|
|
99
143
|
.action(apiGraphqlHandler);
|
|
100
144
|
}
|
|
101
145
|
export function createApiCommand() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,QAAQ,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,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;SAC5E,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB;IAC9B,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC;SAC1B,WAAW,CACV,oDAAoD;QAClD,IAAI;QACJ,0DAA0D;QAC1D,IAAI;QACJ,eAAe;QACf,IAAI;QACJ,4BAA4B;QAC5B,iEAAiE;QACjE,IAAI;QACJ,uBAAuB;QACvB,2EAA2E;QAC3E,IAAI;QACJ,sCAAsC;QACtC,sEAAsE;QACtE,+CAA+C;QAC/C,IAAI;QACJ,gEAAgE;QAChE,wEAAwE;QACxE,IAAI;QACJ,6CAA6C;QAC7C,qFAAqF;QACrF,IAAI;QACJ,wDAAwD;QACxD,mFAAmF,CACtF;SACA,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;SAC3C,MAAM,CAAC,kBAAkB,EAAE,4CAA4C,CAAC;SACxE,MAAM,CAAC,iBAAiB,EAAE,0CAA0C,CAAC;SACrE,MAAM,CACL,QAAQ,EACR,oEAAoE,CACrE;SACA,MAAM,CACL,cAAc,EACd,mEAAmE,CACpE;SACA,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,OAAO,CAAC,WAAW,CAAC,gDAAgD,CAAC,CAAC;IACtE,OAAO,CAAC,UAAU,CAAC,uBAAuB,EAAE,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/build/curl.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface RenderCurlCommandOptions {
|
|
2
|
+
method: string;
|
|
3
|
+
url: string;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
body?: string;
|
|
6
|
+
maskTokens: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Renders a pipe-friendly multiline curl command that matches the request
|
|
10
|
+
* Phoenix CLI would send over `fetch`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function renderCurlCommand({ method, url, headers, body, maskTokens, }: RenderCurlCommandOptions): string;
|
|
13
|
+
//# sourceMappingURL=curl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../src/curl.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;CACrB;AAqDD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,GAAG,EACH,OAAO,EACP,IAAI,EACJ,UAAU,GACX,EAAE,wBAAwB,GAAG,MAAM,CAkBnC"}
|
package/build/curl.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { obscureApiKey } from "./commands/auth.js";
|
|
2
|
+
function shellEscape(value) {
|
|
3
|
+
return "'" + value.replace(/'/g, "'\"'\"'") + "'";
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Normalize headers through the platform `Headers` implementation so curl
|
|
7
|
+
* output mirrors how `fetch` combines duplicate logical headers such as
|
|
8
|
+
* `authorization` + `Authorization`.
|
|
9
|
+
*/
|
|
10
|
+
function normalizeHeaders(headers) {
|
|
11
|
+
const normalizedHeaders = new Headers();
|
|
12
|
+
const headerNames = new Map();
|
|
13
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
14
|
+
normalizedHeaders.append(key, value);
|
|
15
|
+
headerNames.set(key.toLowerCase(), headerNames.get(key.toLowerCase()) ?? key);
|
|
16
|
+
}
|
|
17
|
+
return Array.from(normalizedHeaders.entries()).map(([key, value]) => [
|
|
18
|
+
headerNames.get(key) ?? key,
|
|
19
|
+
value,
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
function maskHeaderValue({ key, value, maskTokens, }) {
|
|
23
|
+
if (!maskTokens || key.toLowerCase() !== "authorization") {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
const match = value.match(/^(\S+)\s+(.+)$/);
|
|
27
|
+
if (match) {
|
|
28
|
+
const [, prefix, token] = match;
|
|
29
|
+
return `${prefix} ${obscureApiKey(token)}`;
|
|
30
|
+
}
|
|
31
|
+
return obscureApiKey(value);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Renders a pipe-friendly multiline curl command that matches the request
|
|
35
|
+
* Phoenix CLI would send over `fetch`.
|
|
36
|
+
*/
|
|
37
|
+
export function renderCurlCommand({ method, url, headers, body, maskTokens, }) {
|
|
38
|
+
const lines = ["curl \\"];
|
|
39
|
+
lines.push(` -X ${method.toUpperCase()} \\`);
|
|
40
|
+
for (const [key, value] of normalizeHeaders(headers)) {
|
|
41
|
+
lines.push(` -H ${shellEscape(`${key}: ${maskHeaderValue({ key, value, maskTokens })}`)} \\`);
|
|
42
|
+
}
|
|
43
|
+
if (body !== undefined) {
|
|
44
|
+
lines.push(` --data-raw ${shellEscape(body)} \\`);
|
|
45
|
+
}
|
|
46
|
+
lines.push(` ${shellEscape(url)}`);
|
|
47
|
+
return lines.join("\n");
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=curl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"curl.js","sourceRoot":"","sources":["../src/curl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAUhD,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,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GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,MAAM,EACN,GAAG,EACH,OAAO,EACP,IAAI,EACJ,UAAU,GACe;IACzB,MAAM,KAAK,GAAG,CAAC,SAAS,CAAC,CAAC;IAE1B,KAAK,CAAC,IAAI,CAAC,QAAQ,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAE9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;QACrD,KAAK,CAAC,IAAI,CACR,QAAQ,WAAW,CAAC,GAAG,GAAG,KAAK,eAAe,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,KAAK,CACnF,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,gBAAgB,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAK,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEpC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arizeai/phoenix-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "A command-line interface for Phoenix",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arize",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@arizeai/openinference-semantic-conventions": "^1.1.0",
|
|
34
34
|
"commander": "^12.1.0",
|
|
35
|
-
"@arizeai/phoenix-
|
|
36
|
-
"@arizeai/phoenix-
|
|
35
|
+
"@arizeai/phoenix-client": "6.5.2",
|
|
36
|
+
"@arizeai/phoenix-config": "0.1.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^18.19.0",
|