@arizeai/phoenix-cli 1.5.2 → 1.6.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/build/pxi/App.d.ts +22 -0
- package/build/pxi/App.d.ts.map +1 -0
- package/build/pxi/App.js +268 -0
- package/build/pxi/App.js.map +1 -0
- package/build/pxi/client.d.ts +77 -0
- package/build/pxi/client.d.ts.map +1 -0
- package/build/pxi/client.js +170 -0
- package/build/pxi/client.js.map +1 -0
- package/build/pxi/index.d.ts +14 -0
- package/build/pxi/index.d.ts.map +1 -0
- package/build/pxi/index.js +36 -0
- package/build/pxi/index.js.map +1 -0
- package/build/pxi/inkMarkdown.d.ts +17 -0
- package/build/pxi/inkMarkdown.d.ts.map +1 -0
- package/build/pxi/inkMarkdown.js +22 -0
- package/build/pxi/inkMarkdown.js.map +1 -0
- package/build/pxi/markdown.d.ts +24 -0
- package/build/pxi/markdown.d.ts.map +1 -0
- package/build/pxi/markdown.js +115 -0
- package/build/pxi/markdown.js.map +1 -0
- package/build/pxi/options.d.ts +64 -0
- package/build/pxi/options.d.ts.map +1 -0
- package/build/pxi/options.js +148 -0
- package/build/pxi/options.js.map +1 -0
- package/build/pxi/preflight.d.ts +88 -0
- package/build/pxi/preflight.d.ts.map +1 -0
- package/build/pxi/preflight.js +215 -0
- package/build/pxi/preflight.js.map +1 -0
- package/build/pxi/toolProgress.d.ts +37 -0
- package/build/pxi/toolProgress.d.ts.map +1 -0
- package/build/pxi/toolProgress.js +71 -0
- package/build/pxi/toolProgress.js.map +1 -0
- package/build/pxi/types.d.ts +123 -0
- package/build/pxi/types.d.ts.map +1 -0
- package/build/pxi/types.js +2 -0
- package/build/pxi/types.js.map +1 -0
- package/package.json +13 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inkMarkdown.d.ts","sourceRoot":"","sources":["../../src/pxi/inkMarkdown.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,cAAc,GACf,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,qBAMA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from "ink";
|
|
3
|
+
import { formatMarkdownForTerminal } from "./markdown.js";
|
|
4
|
+
/**
|
|
5
|
+
* Renders markdown text as styled terminal output inside an Ink `<Text>`.
|
|
6
|
+
*
|
|
7
|
+
* Modeled on the `ink-markdown` component
|
|
8
|
+
* (https://github.com/cameronhunter/ink-markdown, MIT). That package is
|
|
9
|
+
* published as CommonJS and `require()`s Ink internally, which is incompatible
|
|
10
|
+
* with Ink 6 (pure ESM with top-level await — `require()` throws
|
|
11
|
+
* `ERR_REQUIRE_ASYNC_MODULE`). We keep its API — `<Markdown>{text}</Markdown>` —
|
|
12
|
+
* but render through {@link formatMarkdownForTerminal}, which uses the current
|
|
13
|
+
* `marked` + `marked-terminal` API and preserves our width-aware table layout.
|
|
14
|
+
*/
|
|
15
|
+
export function Markdown({ children, phoenixBaseUrl, }) {
|
|
16
|
+
const rendered = formatMarkdownForTerminal({
|
|
17
|
+
text: children,
|
|
18
|
+
phoenixBaseUrl,
|
|
19
|
+
});
|
|
20
|
+
return _jsx(Text, { children: rendered || " " });
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=inkMarkdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inkMarkdown.js","sourceRoot":"","sources":["../../src/pxi/inkMarkdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAG3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,QAAQ,CAAC,EACvB,QAAQ,EACR,cAAc,GAIf;IACC,MAAM,QAAQ,GAAG,yBAAyB,CAAC;QACzC,IAAI,EAAE,QAAQ;QACd,cAAc;KACf,CAAC,CAAC;IACH,OAAO,KAAC,IAAI,cAAE,QAAQ,IAAI,GAAG,GAAQ,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a markdown link/image href against the Phoenix base URL.
|
|
3
|
+
*
|
|
4
|
+
* Absolute, fragment, and protocol-relative hrefs pass through unchanged, as
|
|
5
|
+
* does any href when no (valid) base URL is configured. Root-relative paths
|
|
6
|
+
* (`/foo`) are joined onto the base URL's path prefix so a Phoenix deployed
|
|
7
|
+
* under a sub-path still produces correct links; other relative paths resolve
|
|
8
|
+
* against the base path as usual.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolvePhoenixMarkdownHref({ href, phoenixBaseUrl, }: {
|
|
11
|
+
href: string;
|
|
12
|
+
phoenixBaseUrl?: string;
|
|
13
|
+
}): string;
|
|
14
|
+
/**
|
|
15
|
+
* Render markdown to terminal-styled text. The main entry point for callers:
|
|
16
|
+
* defaults `maxWidth` to the current terminal column count and absolutizes
|
|
17
|
+
* relative links against `phoenixBaseUrl` when provided.
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatMarkdownForTerminal({ text, maxWidth, phoenixBaseUrl, }: {
|
|
20
|
+
text: string;
|
|
21
|
+
maxWidth?: number;
|
|
22
|
+
phoenixBaseUrl?: string;
|
|
23
|
+
}): string;
|
|
24
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/pxi/markdown.ts"],"names":[],"mappings":"AAmDA;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,IAAI,EACJ,cAAc,GACf,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,MAAM,CAkBT;AA2DD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,IAAI,EACJ,QAA6C,EAC7C,cAAc,GACf,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,MAAM,CAET"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Marked } from "marked";
|
|
2
|
+
import { markedTerminal } from "marked-terminal";
|
|
3
|
+
/**
|
|
4
|
+
* Render assistant markdown for the terminal.
|
|
5
|
+
*
|
|
6
|
+
* Wraps `marked` + `marked-terminal` to turn markdown into ANSI-styled text
|
|
7
|
+
* that fits the current terminal width. It also rewrites relative links against
|
|
8
|
+
* the Phoenix base URL so links the agent emits (e.g. `/projects/123`) become
|
|
9
|
+
* clickable absolute URLs pointing at the right Phoenix instance.
|
|
10
|
+
*/
|
|
11
|
+
// There is only ever one terminal width in play at a time, so a single cached
|
|
12
|
+
// renderer is enough to avoid re-registering the marked-terminal extension on
|
|
13
|
+
// every render. Rebuild it only when the width actually changes (e.g. resize),
|
|
14
|
+
// which keeps this bounded instead of accumulating an entry per resize.
|
|
15
|
+
let cachedRenderer = null;
|
|
16
|
+
/**
|
|
17
|
+
* Whether an href should be left untouched: fragment (`#`), protocol-relative
|
|
18
|
+
* (`//`), or already carrying a scheme (`https:`, `mailto:`, …). Only truly
|
|
19
|
+
* relative paths get resolved against the Phoenix base URL.
|
|
20
|
+
*/
|
|
21
|
+
function isAbsoluteOrSpecialHref(href) {
|
|
22
|
+
return (href.startsWith("#") ||
|
|
23
|
+
href.startsWith("//") ||
|
|
24
|
+
/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(href));
|
|
25
|
+
}
|
|
26
|
+
function getPhoenixBaseUrl(phoenixBaseUrl) {
|
|
27
|
+
const trimmedBaseUrl = phoenixBaseUrl?.trim();
|
|
28
|
+
if (!trimmedBaseUrl) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
return new URL(trimmedBaseUrl);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function getOrigin(url) {
|
|
39
|
+
return `${url.protocol}//${url.host}`;
|
|
40
|
+
}
|
|
41
|
+
function getNormalizedBasePath(url) {
|
|
42
|
+
return url.pathname === "/" ? "" : url.pathname.replace(/\/+$/, "");
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Resolve a markdown link/image href against the Phoenix base URL.
|
|
46
|
+
*
|
|
47
|
+
* Absolute, fragment, and protocol-relative hrefs pass through unchanged, as
|
|
48
|
+
* does any href when no (valid) base URL is configured. Root-relative paths
|
|
49
|
+
* (`/foo`) are joined onto the base URL's path prefix so a Phoenix deployed
|
|
50
|
+
* under a sub-path still produces correct links; other relative paths resolve
|
|
51
|
+
* against the base path as usual.
|
|
52
|
+
*/
|
|
53
|
+
export function resolvePhoenixMarkdownHref({ href, phoenixBaseUrl, }) {
|
|
54
|
+
const trimmedHref = href.trim();
|
|
55
|
+
if (!trimmedHref || isAbsoluteOrSpecialHref(trimmedHref)) {
|
|
56
|
+
return href;
|
|
57
|
+
}
|
|
58
|
+
const baseUrl = getPhoenixBaseUrl(phoenixBaseUrl);
|
|
59
|
+
if (!baseUrl) {
|
|
60
|
+
return href;
|
|
61
|
+
}
|
|
62
|
+
const origin = getOrigin(baseUrl);
|
|
63
|
+
const basePath = getNormalizedBasePath(baseUrl);
|
|
64
|
+
if (trimmedHref.startsWith("/")) {
|
|
65
|
+
return new URL(`${basePath}${trimmedHref}`, origin).toString();
|
|
66
|
+
}
|
|
67
|
+
return new URL(trimmedHref, `${origin}${basePath}/`).toString();
|
|
68
|
+
}
|
|
69
|
+
function absolutizeMarkdownLinkToken({ token, phoenixBaseUrl, }) {
|
|
70
|
+
if (token.type !== "link" && token.type !== "image") {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
token.href = resolvePhoenixMarkdownHref({
|
|
74
|
+
href: token.href,
|
|
75
|
+
phoenixBaseUrl,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get a `marked` renderer configured for the given terminal width, reusing the
|
|
80
|
+
* cached one when the width is unchanged (see {@link cachedRenderer}). Text
|
|
81
|
+
* reflow is disabled so the agent's own line breaks are preserved.
|
|
82
|
+
*/
|
|
83
|
+
function getMarkedRenderer(width) {
|
|
84
|
+
if (cachedRenderer?.width === width) {
|
|
85
|
+
return cachedRenderer.renderer;
|
|
86
|
+
}
|
|
87
|
+
const renderer = new Marked();
|
|
88
|
+
renderer.use(markedTerminal(Number.isFinite(width) ? { width, reflowText: false } : {}));
|
|
89
|
+
cachedRenderer = { width, renderer };
|
|
90
|
+
return renderer;
|
|
91
|
+
}
|
|
92
|
+
function renderMarkdownBlock({ text, maxWidth, phoenixBaseUrl, }) {
|
|
93
|
+
if (text.trim() === "") {
|
|
94
|
+
return "";
|
|
95
|
+
}
|
|
96
|
+
const renderer = getMarkedRenderer(maxWidth);
|
|
97
|
+
// The marked-terminal extension renders synchronously, so `parse` returns a
|
|
98
|
+
// string (marked's types don't narrow this from the `async: false` option).
|
|
99
|
+
const rendered = renderer.parse(text, {
|
|
100
|
+
async: false,
|
|
101
|
+
walkTokens: (token) => {
|
|
102
|
+
absolutizeMarkdownLinkToken({ token, phoenixBaseUrl });
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
return rendered.replace(/\n+$/, "");
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Render markdown to terminal-styled text. The main entry point for callers:
|
|
109
|
+
* defaults `maxWidth` to the current terminal column count and absolutizes
|
|
110
|
+
* relative links against `phoenixBaseUrl` when provided.
|
|
111
|
+
*/
|
|
112
|
+
export function formatMarkdownForTerminal({ text, maxWidth = process.stdout.columns ?? Infinity, phoenixBaseUrl, }) {
|
|
113
|
+
return renderMarkdownBlock({ text, maxWidth, phoenixBaseUrl });
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/pxi/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;;;GAOG;AAEH,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,wEAAwE;AACxE,IAAI,cAAc,GAA+C,IAAI,CAAC;AAEtE;;;;GAIG;AACH,SAAS,uBAAuB,CAAC,IAAY;IAC3C,OAAO,CACL,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QACrB,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,CACtC,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,cAAuB;IAChD,MAAM,cAAc,GAAG,cAAc,EAAE,IAAI,EAAE,CAAC;IAC9C,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,GAAQ;IACzB,OAAO,GAAG,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,qBAAqB,CAAC,GAAQ;IACrC,OAAO,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,C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XI_PROVIDER: BuiltInProvider;
|
|
4
|
+
export declare const DEFAULT_PXI_MODEL = "claude-opus-4-8";
|
|
5
|
+
export declare const BUILT_IN_PROVIDERS: readonly ["ANTHROPIC", "AWS", "AZURE_OPENAI", "CEREBRAS", "DEEPSEEK", "FIREWORKS", "GOOGLE", "GROQ", "MOONSHOT", "OLLAMA", "OPENAI", "PERPLEXITY", "TOGETHER", "XAI"];
|
|
6
|
+
type RawPxiOptions = {
|
|
7
|
+
endpoint?: string;
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
profile?: string;
|
|
10
|
+
provider?: string;
|
|
11
|
+
model?: string;
|
|
12
|
+
customProviderId?: string;
|
|
13
|
+
skipModelPreflight?: boolean;
|
|
14
|
+
enableWebAccess?: boolean;
|
|
15
|
+
enableSubagents?: boolean;
|
|
16
|
+
enableGraphqlMutations?: boolean;
|
|
17
|
+
bypassEdits?: boolean;
|
|
18
|
+
ingestTraces?: boolean;
|
|
19
|
+
exportRemoteTraces?: boolean;
|
|
20
|
+
attachUserId?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type ResolvePxiRuntimeOptionsInput = {
|
|
23
|
+
cliOptions: RawPxiOptions;
|
|
24
|
+
sessionId?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Turn the raw `--provider` / `--model` / `--custom-provider-id` flags into a
|
|
28
|
+
* normalized {@link ModelSelection}.
|
|
29
|
+
*
|
|
30
|
+
* Passing `--custom-provider-id` selects a custom provider and requires an
|
|
31
|
+
* explicit `--model`. Otherwise a built-in provider is used: its name is
|
|
32
|
+
* upper-cased and validated against {@link BUILT_IN_PROVIDERS}, and the model
|
|
33
|
+
* falls back to {@link DEFAULT_PXI_MODEL}. Throws {@link InvalidArgumentError}
|
|
34
|
+
* for an unknown provider or a custom provider missing its model.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveModelSelection({ provider, model, customProviderId, }: {
|
|
37
|
+
provider?: string;
|
|
38
|
+
model?: string;
|
|
39
|
+
customProviderId?: string;
|
|
40
|
+
}): ModelSelection;
|
|
41
|
+
/**
|
|
42
|
+
* Build the fully-resolved {@link PxiRuntimeOptions} for a session from parsed
|
|
43
|
+
* CLI flags. This layers the endpoint/api-key/profile through
|
|
44
|
+
* {@link resolveConfig}, resolves the model selection, and coerces the boolean
|
|
45
|
+
* feature flags into their final shape. A fresh `sessionId` is generated unless
|
|
46
|
+
* one is supplied (tests pass a fixed id for determinism).
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolvePxiRuntimeOptions({ cliOptions, sessionId, }: ResolvePxiRuntimeOptionsInput): PxiRuntimeOptions;
|
|
49
|
+
/**
|
|
50
|
+
* Define the `pxi` Commander program: its flags, defaults, and help text.
|
|
51
|
+
* Kept separate from parsing so tests can introspect the command definition
|
|
52
|
+
* without executing it.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createPxiProgram(): Command;
|
|
55
|
+
/**
|
|
56
|
+
* Parse `argv` with the `pxi` program and resolve it into runtime options. This
|
|
57
|
+
* is the one-call path used by the entry point; `createPxiProgram` and
|
|
58
|
+
* `resolvePxiRuntimeOptions` are exposed separately for finer-grained testing.
|
|
59
|
+
*/
|
|
60
|
+
export declare function parsePxiRuntimeOptions({ argv, }?: {
|
|
61
|
+
argv?: string[];
|
|
62
|
+
}): Promise<PxiRuntimeOptions>;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/pxi/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAEd,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,oBAAoB,EAAE,eAA6B,CAAC;AACjE,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD,eAAO,MAAM,kBAAkB,uKAegB,C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lC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { resolveConfig } from "../config.js";
|
|
3
|
+
import { InvalidArgumentError } from "../exitCodes.js";
|
|
4
|
+
export const DEFAULT_PXI_PROVIDER = "ANTHROPIC";
|
|
5
|
+
export const DEFAULT_PXI_MODEL = "claude-opus-4-8";
|
|
6
|
+
export const BUILT_IN_PROVIDERS = [
|
|
7
|
+
"ANTHROPIC",
|
|
8
|
+
"AWS",
|
|
9
|
+
"AZURE_OPENAI",
|
|
10
|
+
"CEREBRAS",
|
|
11
|
+
"DEEPSEEK",
|
|
12
|
+
"FIREWORKS",
|
|
13
|
+
"GOOGLE",
|
|
14
|
+
"GROQ",
|
|
15
|
+
"MOONSHOT",
|
|
16
|
+
"OLLAMA",
|
|
17
|
+
"OPENAI",
|
|
18
|
+
"PERPLEXITY",
|
|
19
|
+
"TOGETHER",
|
|
20
|
+
"XAI",
|
|
21
|
+
];
|
|
22
|
+
function getExpectedProviderMessage() {
|
|
23
|
+
return `Expected one of: ${BUILT_IN_PROVIDERS.join(", ")}.`;
|
|
24
|
+
}
|
|
25
|
+
function isBuiltInProvider(provider) {
|
|
26
|
+
return BUILT_IN_PROVIDERS.includes(provider);
|
|
27
|
+
}
|
|
28
|
+
function normalizeBuiltInProvider({ provider }) {
|
|
29
|
+
return provider.toUpperCase();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Turn the raw `--provider` / `--model` / `--custom-provider-id` flags into a
|
|
33
|
+
* normalized {@link ModelSelection}.
|
|
34
|
+
*
|
|
35
|
+
* Passing `--custom-provider-id` selects a custom provider and requires an
|
|
36
|
+
* explicit `--model`. Otherwise a built-in provider is used: its name is
|
|
37
|
+
* upper-cased and validated against {@link BUILT_IN_PROVIDERS}, and the model
|
|
38
|
+
* falls back to {@link DEFAULT_PXI_MODEL}. Throws {@link InvalidArgumentError}
|
|
39
|
+
* for an unknown provider or a custom provider missing its model.
|
|
40
|
+
*/
|
|
41
|
+
export function resolveModelSelection({ provider, model, customProviderId, }) {
|
|
42
|
+
const trimmedModel = model?.trim();
|
|
43
|
+
const trimmedCustomProviderId = customProviderId?.trim();
|
|
44
|
+
if (trimmedCustomProviderId) {
|
|
45
|
+
if (!trimmedModel) {
|
|
46
|
+
throw new InvalidArgumentError("Missing required flag --model when --custom-provider-id is provided. Expected a non-empty model name.");
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
providerType: "custom",
|
|
50
|
+
providerId: trimmedCustomProviderId,
|
|
51
|
+
modelName: trimmedModel,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const rawSelectedProvider = (provider ?? DEFAULT_PXI_PROVIDER).trim();
|
|
55
|
+
const selectedProvider = normalizeBuiltInProvider({
|
|
56
|
+
provider: rawSelectedProvider,
|
|
57
|
+
});
|
|
58
|
+
if (!isBuiltInProvider(selectedProvider)) {
|
|
59
|
+
throw new InvalidArgumentError(`Invalid value for --provider: ${rawSelectedProvider}. ${getExpectedProviderMessage()}`);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
providerType: "builtin",
|
|
63
|
+
provider: selectedProvider,
|
|
64
|
+
modelName: trimmedModel || DEFAULT_PXI_MODEL,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Build the fully-resolved {@link PxiRuntimeOptions} for a session from parsed
|
|
69
|
+
* CLI flags. This layers the endpoint/api-key/profile through
|
|
70
|
+
* {@link resolveConfig}, resolves the model selection, and coerces the boolean
|
|
71
|
+
* feature flags into their final shape. A fresh `sessionId` is generated unless
|
|
72
|
+
* one is supplied (tests pass a fixed id for determinism).
|
|
73
|
+
*/
|
|
74
|
+
export function resolvePxiRuntimeOptions({ cliOptions, sessionId = crypto.randomUUID(), }) {
|
|
75
|
+
const config = resolveConfig({
|
|
76
|
+
cliOptions: {
|
|
77
|
+
endpoint: cliOptions.endpoint,
|
|
78
|
+
apiKey: cliOptions.apiKey,
|
|
79
|
+
},
|
|
80
|
+
profileName: cliOptions.profile,
|
|
81
|
+
});
|
|
82
|
+
const modelSelection = resolveModelSelection({
|
|
83
|
+
provider: cliOptions.provider,
|
|
84
|
+
model: cliOptions.model,
|
|
85
|
+
customProviderId: cliOptions.customProviderId,
|
|
86
|
+
});
|
|
87
|
+
const editPermission = cliOptions.bypassEdits
|
|
88
|
+
? "bypass"
|
|
89
|
+
: "manual";
|
|
90
|
+
return {
|
|
91
|
+
sessionId,
|
|
92
|
+
config,
|
|
93
|
+
modelSelection,
|
|
94
|
+
skipModelPreflight: Boolean(cliOptions.skipModelPreflight),
|
|
95
|
+
enableWebAccess: Boolean(cliOptions.enableWebAccess),
|
|
96
|
+
enableSubagents: Boolean(cliOptions.enableSubagents),
|
|
97
|
+
enableGraphqlMutations: Boolean(cliOptions.enableGraphqlMutations),
|
|
98
|
+
editPermission,
|
|
99
|
+
ingestTraces: Boolean(cliOptions.ingestTraces),
|
|
100
|
+
exportRemoteTraces: Boolean(cliOptions.exportRemoteTraces),
|
|
101
|
+
attachUserId: Boolean(cliOptions.attachUserId),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Define the `pxi` Commander program: its flags, defaults, and help text.
|
|
106
|
+
* Kept separate from parsing so tests can introspect the command definition
|
|
107
|
+
* without executing it.
|
|
108
|
+
*/
|
|
109
|
+
export function createPxiProgram() {
|
|
110
|
+
const program = new Command();
|
|
111
|
+
program
|
|
112
|
+
.name("pxi")
|
|
113
|
+
.description("Open an interactive Phoenix PXI terminal chat.")
|
|
114
|
+
.option("--endpoint <url>", "Phoenix endpoint URL")
|
|
115
|
+
.option("--api-key <key>", "Phoenix API key")
|
|
116
|
+
.option("--profile <name>", "Phoenix CLI profile name")
|
|
117
|
+
.option("--provider <provider>", `Built-in model provider (${BUILT_IN_PROVIDERS.join("|")})`, DEFAULT_PXI_PROVIDER)
|
|
118
|
+
.option("--model <model>", `Model name (defaults to ${DEFAULT_PXI_MODEL} for built-in providers)`)
|
|
119
|
+
.option("--custom-provider-id <id>", "Custom provider ID")
|
|
120
|
+
.option("--skip-model-preflight", "Skip Phoenix model catalog and credential checks before launch")
|
|
121
|
+
.option("--enable-web-access", "Enable PXI web access context")
|
|
122
|
+
.option("--enable-subagents", "Enable PXI subagent context")
|
|
123
|
+
.option("--enable-graphql-mutations", "Allow server-agent GraphQL mutation tools")
|
|
124
|
+
.option("--bypass-edits", "Bypass manual edit approvals when supported")
|
|
125
|
+
.option("--ingest-traces", "Persist local PXI traces in Phoenix")
|
|
126
|
+
.option("--export-remote-traces", "Export PXI traces remotely")
|
|
127
|
+
.option("--attach-user-id", "Attach the authenticated Phoenix user to PXI traces")
|
|
128
|
+
.addHelpText("after", `
|
|
129
|
+
Examples:
|
|
130
|
+
pxi
|
|
131
|
+
pxi --endpoint http://localhost:6006 --provider OPENAI --model gpt-5.4
|
|
132
|
+
pxi --custom-provider-id provider-id --model custom-agent-model
|
|
133
|
+
`);
|
|
134
|
+
return program;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Parse `argv` with the `pxi` program and resolve it into runtime options. This
|
|
138
|
+
* is the one-call path used by the entry point; `createPxiProgram` and
|
|
139
|
+
* `resolvePxiRuntimeOptions` are exposed separately for finer-grained testing.
|
|
140
|
+
*/
|
|
141
|
+
export async function parsePxiRuntimeOptions({ argv = process.argv, } = {}) {
|
|
142
|
+
const program = createPxiProgram();
|
|
143
|
+
await program.parseAsync(argv);
|
|
144
|
+
return resolvePxiRuntimeOptions({
|
|
145
|
+
cliOptions: program.opts(),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/pxi/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAA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AAO,CAAC,IAAI,MAGjB,EAAE;IACJ,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IACnC,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,wBAAwB,CAAC;QAC9B,UAAU,EAAE,OAAO,CAAC,IAAI,EAAiB;KAC1C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { PhoenixConfig } from "../config.js";
|
|
2
|
+
import type { ModelSelection, PxiRuntimeOptions } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Pre-launch validation of the selected model.
|
|
5
|
+
*
|
|
6
|
+
* Before the chat UI opens, PXI asks the Phoenix server which providers and
|
|
7
|
+
* models are actually installed and credentialed, then checks the user's
|
|
8
|
+
* `--provider`/`--model` selection against that catalog. Catching a bad or
|
|
9
|
+
* unconfigured model here turns what would be a cryptic mid-stream failure into
|
|
10
|
+
* a clear, actionable startup error. The whole check can be skipped with
|
|
11
|
+
* `--skip-model-preflight`.
|
|
12
|
+
*/
|
|
13
|
+
/** GraphQL query fetching the server's provider catalog, credential state, and known models. */
|
|
14
|
+
export declare const PXI_MODEL_PREFLIGHT_QUERY = "\n query PxiModelPreflightQuery {\n modelProviders {\n key\n name\n dependenciesInstalled\n credentialsSet\n credentialRequirements {\n envVarName\n isRequired\n }\n }\n playgroundModels {\n providerKey\n name\n }\n generativeModelCustomProviders(first: 50) {\n edges {\n node {\n id\n name\n sdk\n modelNames\n }\n }\n }\n }\n";
|
|
15
|
+
type PxiModelProvider = {
|
|
16
|
+
key: string;
|
|
17
|
+
name: string;
|
|
18
|
+
dependenciesInstalled: boolean;
|
|
19
|
+
credentialsSet: boolean;
|
|
20
|
+
credentialRequirements: Array<{
|
|
21
|
+
envVarName: string;
|
|
22
|
+
isRequired: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
type PxiPlaygroundModel = {
|
|
26
|
+
providerKey: string;
|
|
27
|
+
name: string;
|
|
28
|
+
};
|
|
29
|
+
type PxiCustomProvider = {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
sdk: string;
|
|
33
|
+
modelNames: string[];
|
|
34
|
+
};
|
|
35
|
+
type PxiModelPreflightData = {
|
|
36
|
+
modelProviders: PxiModelProvider[];
|
|
37
|
+
playgroundModels: PxiPlaygroundModel[];
|
|
38
|
+
generativeModelCustomProviders: {
|
|
39
|
+
edges: Array<{
|
|
40
|
+
node: PxiCustomProvider;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Fetch the provider/model catalog from Phoenix via GraphQL. Requires a
|
|
46
|
+
* configured endpoint and turns non-2xx responses into errors that include the
|
|
47
|
+
* HTTP status and any response body. `fetchImpl` is injectable for testing.
|
|
48
|
+
*/
|
|
49
|
+
export declare function fetchPxiModelPreflight({ config, fetchImpl, }: {
|
|
50
|
+
config: PhoenixConfig;
|
|
51
|
+
fetchImpl?: typeof globalThis.fetch;
|
|
52
|
+
}): Promise<PxiModelPreflightData>;
|
|
53
|
+
/**
|
|
54
|
+
* Check a model selection against the fetched catalog, throwing
|
|
55
|
+
* {@link InvalidArgumentError} with a helpful message on the first problem.
|
|
56
|
+
*
|
|
57
|
+
* For custom providers: the provider id must exist, and the model must be one of
|
|
58
|
+
* its configured names (when it advertises any). For built-in providers: the
|
|
59
|
+
* provider must be available, have its dependencies installed and credentials
|
|
60
|
+
* set, and — if the server publishes a model catalog for it — the model must be
|
|
61
|
+
* in that catalog. A provider with no published catalog accepts any model name.
|
|
62
|
+
*/
|
|
63
|
+
export declare function validatePxiModelSelection({ data, modelSelection, }: {
|
|
64
|
+
data: PxiModelPreflightData;
|
|
65
|
+
modelSelection: ModelSelection;
|
|
66
|
+
}): void;
|
|
67
|
+
/**
|
|
68
|
+
* Run the full preflight for a session: fetch the catalog and validate the
|
|
69
|
+
* selected model, unless `--skip-model-preflight` was passed. This is the single
|
|
70
|
+
* call the entry point makes before rendering the UI.
|
|
71
|
+
*/
|
|
72
|
+
export declare function runPxiModelPreflight({ options, fetchImpl, }: {
|
|
73
|
+
options: PxiRuntimeOptions;
|
|
74
|
+
fetchImpl?: typeof globalThis.fetch;
|
|
75
|
+
}): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Wrap an error thrown while talking to PXI into a single message that names the
|
|
78
|
+
* model and appends a tailored next step — pointing custom providers at their
|
|
79
|
+
* Phoenix settings and built-in providers at credential configuration or
|
|
80
|
+
* choosing a different model. Used for failures that surface after the preflight
|
|
81
|
+
* has already passed.
|
|
82
|
+
*/
|
|
83
|
+
export declare function formatPxiRuntimeError({ error, modelSelection, }: {
|
|
84
|
+
error: unknown;
|
|
85
|
+
modelSelection: ModelSelection;
|
|
86
|
+
}): Error;
|
|
87
|
+
export {};
|
|
88
|
+
//# sourceMappingURL=preflight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/pxi/preflight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjE;;;;;;;;;GASG;AAEH,gGAAgG;AAChG,eAAO,MAAM,yBAAyB,kdA2BrC,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,EAAE,OAAO,CAAC;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,sBAAsB,EAAE,KAAK,CAAC;QAC5B,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC,CAAC;CACJ,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CAC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