@phantomcodes/cli 1.4.5 → 1.5.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 +1 -1
- package/dist/cli/commands.mjs +3 -4
- package/dist/cli/run.mjs +4 -2
- package/dist/cli/screens.d.mts +2 -3
- package/dist/cli/screens.mjs +1 -2
- package/dist/core/version.d.mts +1 -1
- package/dist/core/version.mjs +1 -1
- package/dist/models/list.d.mts +1 -1
- package/dist/models/list.mjs +1 -1
- package/dist/spend/command.mjs +11 -7
- package/dist/spend/lineup.d.mts +8 -2
- package/dist/spend/lineup.mjs +19 -2
- package/dist/workspace/command.mjs +4 -1
- package/package.json +1 -1
- package/skills/phantom-ai/SKILL.md +2 -2
package/README.md
CHANGED
|
@@ -127,7 +127,7 @@ Your key's lineup sets the model phantom-1 runs in each tier, and a fallback mod
|
|
|
127
127
|
|
|
128
128
|
```bash
|
|
129
129
|
phantom lineup --table
|
|
130
|
-
phantom lineup set --frontier <model> --
|
|
130
|
+
phantom lineup set --frontier <model> --standard-fallback <model>
|
|
131
131
|
phantom lineup reset
|
|
132
132
|
```
|
|
133
133
|
|
package/dist/cli/commands.mjs
CHANGED
|
@@ -179,10 +179,9 @@ export const COMMANDS = [
|
|
|
179
179
|
group: 'Routing', summary: 'the model phantom-1 runs in each tier',
|
|
180
180
|
help: ` lineup [get] the model phantom-1 runs in each tier, and the
|
|
181
181
|
models you can pick from
|
|
182
|
-
lineup set --
|
|
183
|
-
[--
|
|
184
|
-
[--
|
|
185
|
-
[--economy-fallback <model>] [--standard-fallback <model>]
|
|
182
|
+
lineup set --standard <model> pick the model for a tier; "default" puts the
|
|
183
|
+
[--frontier <model>] tier back to its default
|
|
184
|
+
[--standard-fallback <model>]
|
|
186
185
|
[--frontier-fallback <model>]
|
|
187
186
|
the model to try when a tier's model fails
|
|
188
187
|
lineup reset every tier back to its default`,
|
package/dist/cli/run.mjs
CHANGED
|
@@ -23,6 +23,8 @@ import { LEGACY_SETUP_HINT, legacySetupFound } from "../setup/legacy.mjs";
|
|
|
23
23
|
*/
|
|
24
24
|
/** Retired flags, accepted so the command can say what replaced them, and never suggested for a typo. */
|
|
25
25
|
const RETIRED_FLAGS = ['pay', 'mpp'];
|
|
26
|
+
/** Retired flags of one command: it refuses them with its own message, so they get past the unknown-flag check. */
|
|
27
|
+
const RETIRED_COMMAND_FLAGS = { lineup: ['economy', 'economy-fallback'] };
|
|
26
28
|
/** The flags every command takes, and the retired ones. */
|
|
27
29
|
const EVERY_COMMAND_FLAGS = ['table', 'json', 'help', 'all', 'version', 'mcp', ...RETIRED_FLAGS];
|
|
28
30
|
/**
|
|
@@ -34,7 +36,7 @@ const EVERY_COMMAND_FLAGS = ['table', 'json', 'help', 'all', 'version', 'mcp', .
|
|
|
34
36
|
*/
|
|
35
37
|
function flagsOf(command, subcommand) {
|
|
36
38
|
const helps = [command.help, COMMANDS.find((c) => c.name === subcommand)?.help ?? ''].join('\n');
|
|
37
|
-
return new Set([...[...helps.matchAll(/--([a-z][a-z0-9-]*)/g)].map((m) => m[1]), ...EVERY_COMMAND_FLAGS]);
|
|
39
|
+
return new Set([...[...helps.matchAll(/--([a-z][a-z0-9-]*)/g)].map((m) => m[1]), ...EVERY_COMMAND_FLAGS, ...(RETIRED_COMMAND_FLAGS[command.name] ?? [])]);
|
|
38
40
|
}
|
|
39
41
|
export async function run(argv = process.argv.slice(2), env = process.env, io = {
|
|
40
42
|
stdout: (s) => process.stdout.write(s),
|
|
@@ -111,7 +113,7 @@ export async function run(argv = process.argv.slice(2), env = process.env, io =
|
|
|
111
113
|
for (const name of passesArgs ? [] : Object.keys(ownFlags)) {
|
|
112
114
|
if (known.has(name))
|
|
113
115
|
continue;
|
|
114
|
-
const guess = closestCommand(name, [...known].filter((flag) => !RETIRED_FLAGS.includes(flag)));
|
|
116
|
+
const guess = closestCommand(name, [...known].filter((flag) => !RETIRED_FLAGS.includes(flag) && !(RETIRED_COMMAND_FLAGS[argv[0]] ?? []).includes(flag)));
|
|
115
117
|
die(`Unknown flag --${name} for phantom ${argv[0]}.${guess ? ` Did you mean --${guess}?` : ''} See phantom ${argv[0]} --help.`, 'unknown_flag');
|
|
116
118
|
}
|
|
117
119
|
// A person at a terminal reads each command's screen; a pipe (scripts, agents) or --json gets JSON.
|
package/dist/cli/screens.d.mts
CHANGED
|
@@ -92,11 +92,11 @@ export type LineupView = {
|
|
|
92
92
|
lineup: (Record<string, string | undefined> & {
|
|
93
93
|
fallbacks?: Record<string, string | undefined>;
|
|
94
94
|
}) | null;
|
|
95
|
-
tiers: Record<'
|
|
95
|
+
tiers: Record<'standard' | 'frontier', {
|
|
96
96
|
model: string;
|
|
97
97
|
name: string;
|
|
98
98
|
}>;
|
|
99
|
-
choices?: Record<'
|
|
99
|
+
choices?: Record<'standard' | 'frontier', Array<{
|
|
100
100
|
model: string;
|
|
101
101
|
name: string;
|
|
102
102
|
input_per_m: number | null;
|
|
@@ -107,7 +107,6 @@ export type LineupView = {
|
|
|
107
107
|
};
|
|
108
108
|
/** What each tier is for, in a few words. */
|
|
109
109
|
export declare const TIER_ABOUT: {
|
|
110
|
-
readonly economy: "phantom-1:free only; paid calls skip it";
|
|
111
110
|
readonly standard: "where every task starts";
|
|
112
111
|
readonly frontier: "hard steps: a failed try, an image";
|
|
113
112
|
};
|
package/dist/cli/screens.mjs
CHANGED
|
@@ -229,7 +229,6 @@ export function routeTestScreen(t, style = {}) {
|
|
|
229
229
|
}
|
|
230
230
|
/** What each tier is for, in a few words. */
|
|
231
231
|
export const TIER_ABOUT = {
|
|
232
|
-
economy: 'phantom-1:free only; paid calls skip it',
|
|
233
232
|
standard: 'where every task starts',
|
|
234
233
|
frontier: 'hard steps: a failed try, an image',
|
|
235
234
|
};
|
|
@@ -238,7 +237,7 @@ export function lineupScreen(l, style = {}) {
|
|
|
238
237
|
const p = paint(style.env ?? {}, Boolean(style.color));
|
|
239
238
|
const w = ruleWidth(style);
|
|
240
239
|
const lines = ['', ...caption(p, w, 'LINEUP', p.dim('the model phantom-1 runs in each tier'))];
|
|
241
|
-
for (const tier of ['
|
|
240
|
+
for (const tier of ['standard', 'frontier']) {
|
|
242
241
|
const mine = Boolean(l.lineup?.[tier]);
|
|
243
242
|
const fallback = l.lineup?.fallbacks?.[tier];
|
|
244
243
|
lines.push(` ${p.bold(tier.toUpperCase().padEnd(10))}${l.tiers[tier].model.padEnd(36)}${mine ? p.lime('your pick') : p.dim('default')}`);
|
package/dist/core/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** This release of phantom. `npm version` keeps it equal to the version in package.json. */
|
|
2
|
-
export declare const VERSION = "1.
|
|
2
|
+
export declare const VERSION = "1.5.1";
|
package/dist/core/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** This release of phantom. `npm version` keeps it equal to the version in package.json. */
|
|
2
|
-
export const VERSION = '1.
|
|
2
|
+
export const VERSION = '1.5.1';
|
package/dist/models/list.d.mts
CHANGED
|
@@ -6,7 +6,7 @@ export type Job = (typeof JOBS)[number][0];
|
|
|
6
6
|
export type ChatModel = {
|
|
7
7
|
/** Model id. */
|
|
8
8
|
id: string;
|
|
9
|
-
/**
|
|
9
|
+
/** standard, frontier or free (phantom-1:free's models). */
|
|
10
10
|
tier: string;
|
|
11
11
|
/** True when it costs $0. */
|
|
12
12
|
free: boolean;
|
package/dist/models/list.mjs
CHANGED
|
@@ -33,7 +33,7 @@ export async function getModels(baseUrl, apiKey = '') {
|
|
|
33
33
|
return Boolean(r.jobs.vision) || takesImages.has(r.id);
|
|
34
34
|
return Boolean(r.jobs[job]);
|
|
35
35
|
});
|
|
36
|
-
const chat = r.models.map((m) => ({ id: m.id, tier: m.tier, free: m.pricing.prompt === 0 && m.pricing.completion === 0 }));
|
|
36
|
+
const chat = r.models.map((m) => ({ id: m.id, tier: m.tier === 'economy' ? 'free' : m.tier, free: m.pricing.prompt === 0 && m.pricing.completion === 0 }));
|
|
37
37
|
return { id: r.id, name: r.name, description: r.description, chat, jobs: r.jobs, can };
|
|
38
38
|
});
|
|
39
39
|
}
|
package/dist/spend/command.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { flagNum, out, pickIo, showsScreen } from "../core/helpers.mjs";
|
|
|
5
5
|
import { colorOn, paint } from "../core/style.mjs";
|
|
6
6
|
import { choose } from "../core/pick.mjs";
|
|
7
7
|
import { hideHints, lineupScreen, priceHint, routeScreen, routeTestScreen, TIER_ABOUT } from "../cli/screens.mjs";
|
|
8
|
-
import { getLineup, putLineup, resetLineup, LINEUP_TIERS } from "./lineup.mjs";
|
|
8
|
+
import { currentTiersOnly, getLineup, putLineup, resetLineup, LINEUP_TIERS } from "./lineup.mjs";
|
|
9
9
|
import { getRoute, putRoute, patchRoute, clearRoute, testRoute, parseCondition, SORT_WORDS } from "./routing.mjs";
|
|
10
10
|
/** `phantom route`: the key's route policy, its rules, and a dry run. Run by `run()`. */
|
|
11
11
|
export async function routeCommand(input) {
|
|
@@ -124,9 +124,14 @@ function applyPick(into, tier, flag, value) {
|
|
|
124
124
|
else
|
|
125
125
|
into[tier] = value;
|
|
126
126
|
}
|
|
127
|
+
/** Flags from when phantom-1 had an Economy tier. They stop the command before it asks the server anything. */
|
|
128
|
+
const RETIRED_LINEUP_FLAGS = ['economy', 'economy-fallback'];
|
|
127
129
|
/** `phantom lineup`: the model phantom-1 runs in each tier, and a fallback for each. Run by `run()`. */
|
|
128
130
|
export async function lineupCommand(input) {
|
|
129
131
|
const { io, apiKey, subcommand, flags, baseUrl, env } = input;
|
|
132
|
+
const retired = RETIRED_LINEUP_FLAGS.find((name) => flags[name] !== undefined);
|
|
133
|
+
if (retired)
|
|
134
|
+
die(`phantom-1 has two tiers, Standard and Frontier. --${retired} is no longer an option.`, 'lineup_usage');
|
|
130
135
|
const table = showsScreen(input);
|
|
131
136
|
const style = { env, color: colorOn(env, io.stdoutIsTTY) };
|
|
132
137
|
const tableLineup = (d) => lineupScreen(d, style);
|
|
@@ -141,12 +146,11 @@ export async function lineupCommand(input) {
|
|
|
141
146
|
else if (subcommand === 'set') {
|
|
142
147
|
// PUT replaces the whole lineup, so start from what the key has now.
|
|
143
148
|
const read = await getLineup(apiKey, baseUrl);
|
|
144
|
-
const current = read.lineup
|
|
149
|
+
const current = currentTiersOnly(read.lineup);
|
|
145
150
|
const { fallbacks: currentFallbacks, ...picks } = current;
|
|
146
151
|
const fallbacks = { ...currentFallbacks };
|
|
147
|
-
const model = {
|
|
152
|
+
const model = { standard: flags['standard'], frontier: flags['frontier'] };
|
|
148
153
|
const fallback = {
|
|
149
|
-
economy: flags['economy-fallback'],
|
|
150
154
|
standard: flags['standard-fallback'],
|
|
151
155
|
frontier: flags['frontier-fallback'],
|
|
152
156
|
};
|
|
@@ -159,7 +163,7 @@ export async function lineupCommand(input) {
|
|
|
159
163
|
delete fallbacks[tier];
|
|
160
164
|
}
|
|
161
165
|
if (LINEUP_TIERS.every((tier) => model[tier] === undefined && fallback[tier] === undefined)) {
|
|
162
|
-
die('lineup set needs --
|
|
166
|
+
die('lineup set needs --standard or --frontier, or --standard-fallback or --frontier-fallback, each with a model id or "default"');
|
|
163
167
|
}
|
|
164
168
|
const next = Object.keys(fallbacks).length ? { ...picks, fallbacks } : picks;
|
|
165
169
|
out(await putLineup(apiKey, next, baseUrl), table, tableLineup, io.stdout);
|
|
@@ -173,7 +177,7 @@ export async function lineupCommand(input) {
|
|
|
173
177
|
return 0;
|
|
174
178
|
}
|
|
175
179
|
/** The flags `lineup set` reads; with none of them, at a terminal, it opens the picker instead. */
|
|
176
|
-
const LINEUP_FLAGS = ['
|
|
180
|
+
const LINEUP_FLAGS = ['standard', 'frontier', 'standard-fallback', 'frontier-fallback'];
|
|
177
181
|
/**
|
|
178
182
|
* `phantom lineup set` at a terminal: choose a tier, then a model for it from
|
|
179
183
|
* a list with prices (the default marked), and it saves at once. It loops
|
|
@@ -204,7 +208,7 @@ async function lineupPicker(input, pick, show) {
|
|
|
204
208
|
const model = await choose({ ...pick, esc: 'back' }, `Which model should ${tier} run?`, options.map((c) => ({ label: c.model, hint: priceHint(c), value: c.model })), Math.max(0, options.findIndex((c) => c.model === now)));
|
|
205
209
|
if (model === null)
|
|
206
210
|
continue;
|
|
207
|
-
const { fallbacks, ...picks } = read.lineup
|
|
211
|
+
const { fallbacks, ...picks } = currentTiersOnly(read.lineup);
|
|
208
212
|
const chosen = options.find((c) => c.model === model);
|
|
209
213
|
if (chosen?.default)
|
|
210
214
|
delete picks[tier];
|
package/dist/spend/lineup.d.mts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* (routers/phantom-1/runtime/src/lineup.ts in the Phantom repo), so the CLI
|
|
5
5
|
* passes model ids through.
|
|
6
6
|
*/
|
|
7
|
-
/** The
|
|
8
|
-
export declare const LINEUP_TIERS: readonly ["
|
|
7
|
+
/** The two tiers paid `phantom-1` picks between, cheapest first. */
|
|
8
|
+
export declare const LINEUP_TIERS: readonly ["standard", "frontier"];
|
|
9
9
|
/** One of {@link LINEUP_TIERS}. */
|
|
10
10
|
export type LineupTier = (typeof LINEUP_TIERS)[number];
|
|
11
11
|
/** A model id for each tier that has one. */
|
|
@@ -46,6 +46,12 @@ export type LineupResult = {
|
|
|
46
46
|
/** Each tier's choices, default first. Only GET sends them. */
|
|
47
47
|
choices?: Record<LineupTier, LineupChoice[]>;
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* A lineup with only the tiers phantom-1 has now. A server that is older than
|
|
51
|
+
* this CLI may still send an `economy` entry; the newer server answers 400 if
|
|
52
|
+
* a PUT carries one, so it is dropped before anything is sent back.
|
|
53
|
+
*/
|
|
54
|
+
export declare function currentTiersOnly(lineup: Lineup | null | undefined): Lineup;
|
|
49
55
|
/** The key's lineup, the model each tier runs, and each tier's choices (GET /key/lineup). */
|
|
50
56
|
export declare function getLineup(apiKey: string, baseUrl?: string): Promise<LineupResult>;
|
|
51
57
|
/** Replaces the key's whole lineup (PUT /key/lineup). The server checks it before saving. */
|
package/dist/spend/lineup.mjs
CHANGED
|
@@ -5,8 +5,25 @@ import { request } from "../core/request.mjs";
|
|
|
5
5
|
* (routers/phantom-1/runtime/src/lineup.ts in the Phantom repo), so the CLI
|
|
6
6
|
* passes model ids through.
|
|
7
7
|
*/
|
|
8
|
-
/** The
|
|
9
|
-
export const LINEUP_TIERS = ['
|
|
8
|
+
/** The two tiers paid `phantom-1` picks between, cheapest first. */
|
|
9
|
+
export const LINEUP_TIERS = ['standard', 'frontier'];
|
|
10
|
+
/**
|
|
11
|
+
* A lineup with only the tiers phantom-1 has now. A server that is older than
|
|
12
|
+
* this CLI may still send an `economy` entry; the newer server answers 400 if
|
|
13
|
+
* a PUT carries one, so it is dropped before anything is sent back.
|
|
14
|
+
*/
|
|
15
|
+
export function currentTiersOnly(lineup) {
|
|
16
|
+
const keep = (picks) => {
|
|
17
|
+
const kept = {};
|
|
18
|
+
for (const tier of LINEUP_TIERS)
|
|
19
|
+
if (picks?.[tier])
|
|
20
|
+
kept[tier] = picks[tier];
|
|
21
|
+
return kept;
|
|
22
|
+
};
|
|
23
|
+
const picks = keep(lineup ?? undefined);
|
|
24
|
+
const fallbacks = keep(lineup?.fallbacks);
|
|
25
|
+
return Object.keys(fallbacks).length ? { ...picks, fallbacks } : picks;
|
|
26
|
+
}
|
|
10
27
|
/** The key's lineup, the model each tier runs, and each tier's choices (GET /key/lineup). */
|
|
11
28
|
export function getLineup(apiKey, baseUrl) {
|
|
12
29
|
return request('GET', '/key/lineup', apiKey, undefined, baseUrl);
|
|
@@ -529,7 +529,10 @@ export async function forgetWorkspace(env, baseUrl) {
|
|
|
529
529
|
{
|
|
530
530
|
try {
|
|
531
531
|
const saved = JSON.parse(readSecret(env, file));
|
|
532
|
-
|
|
532
|
+
// `workspace import` saves the recovery file's own credential as the sign-in. Revoking that on the
|
|
533
|
+
// server would kill the recovery file, so a sign-in that is the recovery credential is only forgotten here.
|
|
534
|
+
const isRecoveryFile = saved?.recovery?.management_credential === saved?.management_credential;
|
|
535
|
+
if (saved?.workspace_id && saved?.management_credential && !isRecoveryFile) {
|
|
533
536
|
const url = httpsOnly(baseUrl || env.PHANTOM_BASE_URL || saved.base_url || DEFAULT_BASE_URL).replace(/\/$/, '');
|
|
534
537
|
await wire(url, 'POST', '/workspaces/' + encodeURIComponent(saved.workspace_id) + '/logout', {}, saved.management_credential).catch(() => { });
|
|
535
538
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phantomcodes/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Connects Claude Code, Codex, pi and other coding agents to Phantom AI, an OpenAI-compatible API, and manages your keys, credit and spending caps from the terminal.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"phantom",
|
|
@@ -98,11 +98,11 @@ phantom models use phantom-1:zdr
|
|
|
98
98
|
|
|
99
99
|
```bash
|
|
100
100
|
phantom lineup --table
|
|
101
|
-
phantom lineup set --frontier <model> --
|
|
101
|
+
phantom lineup set --frontier <model> --standard-fallback <model>
|
|
102
102
|
phantom lineup reset
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
Paid phantom-1 starts each task on
|
|
105
|
+
Paid phantom-1 has two tiers. It starts each task on standard and moves hard steps to frontier (a failed try, or an image). phantom-1:free runs its own free models and has no tier to pick. The lineup sets the model each tier runs, from the choices `phantom lineup` lists, and a fallback to try when that model fails. `default` in place of a model puts the tier back to its default. `lineup set` keeps the tiers you don't name.
|
|
106
106
|
|
|
107
107
|
## See what was spent
|
|
108
108
|
|