@phantomcodes/cli 1.2.8 → 1.3.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 +20 -0
- package/dist/agents/command.mjs +9 -10
- package/dist/cli/app.mjs +2 -0
- package/dist/cli/commands.mjs +8 -0
- package/dist/cli/screens.mjs +47 -0
- package/dist/core/free.mjs +2 -0
- package/dist/core/version.mjs +1 -1
- package/dist/models/choice.mjs +27 -0
- package/dist/models/command.mjs +66 -0
- package/dist/models/list.mjs +39 -0
- package/dist/setup/command.mjs +3 -1
- package/package.json +1 -1
- package/skills/phantom-ai/SKILL.md +12 -0
package/README.md
CHANGED
|
@@ -137,6 +137,25 @@ PHANTOM_KEY_NAME=coding phantom route test --table
|
|
|
137
137
|
Prefer a specific model? Select it in your agent. Policies that apply only to
|
|
138
138
|
`auto` leave explicit model choices alone.
|
|
139
139
|
|
|
140
|
+
Phantom has three models of its own. `phantom models` shows what each can do
|
|
141
|
+
(chat, images in, embeddings, rerank, images, video, speech, transcription) and
|
|
142
|
+
the model behind each job:
|
|
143
|
+
|
|
144
|
+
- `phantom-1` does every job, and picks economy, standard or frontier for each chat request.
|
|
145
|
+
- `phantom-1:free` is chat on free models at $0, with no card.
|
|
146
|
+
- `phantom-1:zdr` is chat (with images) on providers that keep none of your data.
|
|
147
|
+
|
|
148
|
+
At a terminal, `phantom models` asks which one your agents should use. To pick
|
|
149
|
+
without the menu:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
phantom models use phantom-1:zdr
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
`phantom claude`, `phantom codex` and `phantom pi` start on the model you pick,
|
|
156
|
+
and so does the next `phantom setup`. Agents set up before you picked keep their
|
|
157
|
+
model until you run `phantom setup` again.
|
|
158
|
+
|
|
140
159
|
`phantom-1` picks a tier for each request: economy, standard or frontier. Your key's
|
|
141
160
|
lineup picks the model in each tier, and a fallback model to try when it fails:
|
|
142
161
|
|
|
@@ -188,6 +207,7 @@ it cancels. A named model, not `phantom-1`, still spends credit.
|
|
|
188
207
|
| Manage workspace keys | `phantom keys create`, `phantom keys set`, `phantom keys rotate`, `phantom keys revoke` |
|
|
189
208
|
| Manage local copies | `phantom keys saved`, `phantom keys save`, `phantom keys rm` |
|
|
190
209
|
| Route models | `phantom route` |
|
|
210
|
+
| See phantom-1, phantom-1:free and phantom-1:zdr, and pick one | `phantom models`, `phantom models use <id>` |
|
|
191
211
|
| Pick phantom-1's models | `phantom lineup`, `phantom lineup set`, `phantom lineup reset` |
|
|
192
212
|
|
|
193
213
|
Put phantom flags before agent arguments; use `--` to separate them:
|
package/dist/agents/command.mjs
CHANGED
|
@@ -6,10 +6,9 @@ import { die, NO_KEY } from "../core/errors.mjs";
|
|
|
6
6
|
import { DEFAULT_BASE_URL, httpsOnly, request } from "../core/request.mjs";
|
|
7
7
|
import { keyId, readNamedKey, resolveApiKey } from "../keys/saved.mjs";
|
|
8
8
|
import { workspaceLogin } from "../workspace/command.mjs";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const CLAUDE_DEFAULT_MODEL = `claude-code/${DEFAULT_MODEL}`;
|
|
9
|
+
import { startModel } from "../models/choice.mjs";
|
|
10
|
+
/** The model as Claude Code names it: its picker keeps only ids that say "claude", so Phantom lists them as `claude-code/<id>`. */
|
|
11
|
+
const claudeName = (model) => `claude-code/${model}`;
|
|
13
12
|
/** The key's spend and balance, or null when the answer has no numbers, such as a sign-in page that came back with status 200. */
|
|
14
13
|
async function keyStatus(apiKey, baseUrl) {
|
|
15
14
|
const s = await request('GET', '/key/balance', apiKey, undefined, baseUrl);
|
|
@@ -28,9 +27,9 @@ export const AGENTS = {
|
|
|
28
27
|
// reads the token from the environment, so it stays off the command line.
|
|
29
28
|
// It runs with this phantom's own Node: the curl installer puts none on PATH.
|
|
30
29
|
const helper = `${JSON.stringify(process.execPath)} -p "process.env.PHANTOM_AGENT_TOKEN || ''"`;
|
|
31
|
-
// phantom-1 unless the user
|
|
32
|
-
// Claude Code ranks below --model and below a model in its settings file.
|
|
33
|
-
const model = hasModel(args) || env.ANTHROPIC_MODEL ? {} : { ANTHROPIC_MODEL:
|
|
30
|
+
// The model picked with `phantom models` (phantom-1 until then), unless the user names one. It goes in the
|
|
31
|
+
// environment, which Claude Code ranks below --model and below a model in its settings file.
|
|
32
|
+
const model = hasModel(args) || env.ANTHROPIC_MODEL ? {} : { ANTHROPIC_MODEL: claudeName(startModel(env)) };
|
|
34
33
|
const vars = { ANTHROPIC_BASE_URL: proxy, CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY: '1', ENABLE_TOOL_SEARCH: 'true' };
|
|
35
34
|
const { ANTHROPIC_AUTH_TOKEN: _auth, ...rest } = env;
|
|
36
35
|
return {
|
|
@@ -57,7 +56,7 @@ export const AGENTS = {
|
|
|
57
56
|
'model_provider="phantom_run"',
|
|
58
57
|
...provider.map(([k, v]) => `model_providers.phantom_run.${k}=${JSON.stringify(v)}`),
|
|
59
58
|
'features.api_key_model_discovery=true',
|
|
60
|
-
...(hasModel(args) ? [] : [`model=${JSON.stringify(
|
|
59
|
+
...(hasModel(args) ? [] : [`model=${JSON.stringify(startModel(env))}`]),
|
|
61
60
|
];
|
|
62
61
|
return { args: [...config.flatMap((c) => ['-c', c]), ...args], env: { ...env, OPENAI_BASE_URL: base, PHANTOM_AGENT_TOKEN: token } };
|
|
63
62
|
},
|
|
@@ -70,9 +69,9 @@ export const AGENTS = {
|
|
|
70
69
|
// for this run leaves the user's own files alone. Its key is read from
|
|
71
70
|
// PHANTOM_AGENT_TOKEN when pi calls, so the file holds no secret.
|
|
72
71
|
const file = path.join(tmp, 'phantom-provider.ts');
|
|
73
|
-
const model = { id:
|
|
72
|
+
const model = { id: startModel(env), name: 'Phantom AI router (phantom)', reasoning: true, input: ['text', 'image'], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, contextWindow: 1_000_000, maxTokens: 64_000 };
|
|
74
73
|
writeFileSync(file, `export default function (pi) {\n pi.registerProvider('phantom', ${JSON.stringify({ baseUrl: `${proxy}/v1`, api: 'openai-completions', apiKey: '$PHANTOM_AGENT_TOKEN', models: [model] })});\n}\n`, { mode: 0o600 });
|
|
75
|
-
return { args: ['-e', file, ...(hasModel(args) ? [] : ['--provider', 'phantom', '--model',
|
|
74
|
+
return { args: ['-e', file, ...(hasModel(args) ? [] : ['--provider', 'phantom', '--model', startModel(env)]), ...args], env: { ...env, PHANTOM_AGENT_TOKEN: token } };
|
|
76
75
|
},
|
|
77
76
|
},
|
|
78
77
|
};
|
package/dist/cli/app.mjs
CHANGED
|
@@ -32,6 +32,7 @@ export function mainMenu(s) {
|
|
|
32
32
|
{ label: 'Balance', hint: 'what this key can spend', value: { run: ['balance'] } },
|
|
33
33
|
{ label: 'Spend', hint: 'what you spent, and what phantom-1 saved', value: { run: ['spend'] } },
|
|
34
34
|
{ label: 'Add credit', hint: 'by card or crypto', value: { run: ['fund'] } },
|
|
35
|
+
{ label: 'Models', hint: 'phantom-1, free or zdr: what each can do, and pick one', value: { run: ['models'] } },
|
|
35
36
|
{ label: 'Choose models', hint: 'the model phantom-1 runs in each tier', value: { run: ['lineup', 'set'] } },
|
|
36
37
|
{ label: 'Keys', hint: 'list, new, limits, revoke', value: { open: 'keys' } },
|
|
37
38
|
{ label: 'Plan', hint: 'Pro or Max, instead of credit', value: { run: ['plan'] } },
|
|
@@ -78,6 +79,7 @@ export function nextSteps(ran) {
|
|
|
78
79
|
workspace: [['See my keys', ['keys']], ['Spend by key', ['spend', '--workspace']]],
|
|
79
80
|
keys: [['New key', ['keys', 'create']], ['Set a spending limit', ['keys', 'set']], ['Revoke a key', ['keys', 'revoke']]],
|
|
80
81
|
plan: [['Start Pro', ['plan', 'pro']], ['Start Max', ['plan', 'max']], ['Manage billing', ['plan', 'manage']]],
|
|
82
|
+
models: [['Put it in my agents', ['setup']], ['Choose the model in each tier', ['lineup', 'set']]],
|
|
81
83
|
route: [['See what a request would get', ['route', 'test']], ['Choose models', ['lineup', 'set']]],
|
|
82
84
|
'setup --restore': [['Sign out, and forget saved keys', ['logout', '--all']]],
|
|
83
85
|
login: [['Set up my agents', ['setup']]],
|
package/dist/cli/commands.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { planCommand } from "../plan/command.mjs";
|
|
|
7
7
|
import { verifyCommand } from "../receipts/command.mjs";
|
|
8
8
|
import { setupCommand } from "../setup/command.mjs";
|
|
9
9
|
import { SETUP_MODEL } from "../setup/shared.mjs";
|
|
10
|
+
import { modelsCommand } from "../models/command.mjs";
|
|
10
11
|
import { SETUP_NAMES, orList } from "../setup/agents.mjs";
|
|
11
12
|
/** The short `--help`'s headings, in the order they print. */
|
|
12
13
|
export const HELP_GROUPS = ['Start', 'Run', 'Money', 'Keys', 'Routing', 'More'];
|
|
@@ -145,6 +146,13 @@ export const COMMANDS = [
|
|
|
145
146
|
[--frontier-fallback <model>]
|
|
146
147
|
the model to try when a tier's model fails
|
|
147
148
|
lineup reset every tier back to its default`,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'models', handler: modelsCommand, keyless: true,
|
|
152
|
+
group: 'Routing', summary: 'phantom-1, free or zdr: what each can do, and which your agents use',
|
|
153
|
+
help: ` models what phantom-1, phantom-1:free and phantom-1:zdr can do,
|
|
154
|
+
and the model behind each job; at a terminal, pick one
|
|
155
|
+
models use <id> start your agents on it, without the menu`,
|
|
148
156
|
},
|
|
149
157
|
{
|
|
150
158
|
name: 'logout', handler: logoutDispatch, keyless: true,
|
package/dist/cli/screens.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { paint } from "../core/style.mjs";
|
|
2
|
+
import { JOBS } from "../models/list.mjs";
|
|
3
|
+
import { FREE_AGENT_REQUESTS_A_DAY, FREE_REQUESTS_A_DAY } from "../core/free.mjs";
|
|
2
4
|
/** The window's width: given, or the terminal's, or 100 for a pipe. */
|
|
3
5
|
const widthOf = (style) => style.columns ?? process.stdout.columns ?? 100;
|
|
4
6
|
/** How long a caption's rule is: 66, or less in a narrow window. */
|
|
@@ -351,3 +353,48 @@ export function keySavedScreen(name, style = {}) {
|
|
|
351
353
|
const w = ruleWidth(style);
|
|
352
354
|
return ['', done(p, `Key "${name}" saved on this computer.`), ...next(p, 'Run an agent on it:', `phantom codex --key ${name}`)].join('\n');
|
|
353
355
|
}
|
|
356
|
+
/** What each of Phantom's own models is for, in a few words. */
|
|
357
|
+
const MODEL_ABOUT = {
|
|
358
|
+
'phantom-1': 'every job; chat picks economy, standard or frontier for each request',
|
|
359
|
+
'phantom-1:free': `chat on free models at $0, no card; ${FREE_REQUESTS_A_DAY} requests a day, ${FREE_AGENT_REQUESTS_A_DAY} from an agent`,
|
|
360
|
+
'phantom-1:zdr': 'chat on providers that keep none of your data, at their prices',
|
|
361
|
+
};
|
|
362
|
+
/** A model's few words: {@link MODEL_ABOUT}, or the first sentence the server gives for a model this CLI doesn't know yet. */
|
|
363
|
+
const modelAbout = (m) => MODEL_ABOUT[m.id] ?? m.description.split('. ')[0];
|
|
364
|
+
/**
|
|
365
|
+
* `phantom models`: a table of what each of Phantom's own models can do, a
|
|
366
|
+
* column per model, a ✓ per job. Under it, the model behind each job, so you
|
|
367
|
+
* can see what runs before you pick.
|
|
368
|
+
*/
|
|
369
|
+
export function modelsScreen(v, style = {}) {
|
|
370
|
+
const p = paint(style.env ?? {}, Boolean(style.color));
|
|
371
|
+
const LABEL = 18;
|
|
372
|
+
const COLUMN = 17;
|
|
373
|
+
// Padding goes outside the color, so the row's trailing spaces can be trimmed.
|
|
374
|
+
const cell = (text, color) => color(text) + ' '.repeat(Math.max(0, COLUMN - text.length));
|
|
375
|
+
const row = (label, cells) => ` ${label.padEnd(LABEL)}${cells.join('')}`.trimEnd();
|
|
376
|
+
const lines = ['', ...caption(p, ruleWidth(style), 'MODELS', p.dim('one name each; your agents send it'))];
|
|
377
|
+
lines.push(row('', v.models.map((m) => cell(m.id, p.bold))));
|
|
378
|
+
lines.push(row('', v.models.map((m) => cell(m.id === v.using ? 'in use' : '', p.lime))));
|
|
379
|
+
for (const [job, label] of JOBS) {
|
|
380
|
+
lines.push(row(label, v.models.map((m) => (m.can.includes(job) ? cell('✓', p.lime) : cell('·', p.dim)))));
|
|
381
|
+
}
|
|
382
|
+
for (const m of v.models) {
|
|
383
|
+
lines.push('', ` ${p.bold(m.id)}${m.id === v.using ? ` ${p.lime('in use')}` : ''}`, ` ${p.dim(modelAbout(m))}`);
|
|
384
|
+
// Chat models in different tiers are named by tier; models in one tier are tried in order.
|
|
385
|
+
const oneTier = new Set(m.chat.map((c) => c.tier)).size === 1;
|
|
386
|
+
const idWidth = Math.max(0, ...m.chat.map((c) => c.id.length));
|
|
387
|
+
m.chat.forEach((c, i) => {
|
|
388
|
+
const label = oneTier ? (i === 0 ? 'chat' : 'then') : c.tier;
|
|
389
|
+
lines.push(` ${p.dim(label.padEnd(16))}${c.free ? `${c.id.padEnd(idWidth)} ${p.dim('$0')}` : c.id}`);
|
|
390
|
+
});
|
|
391
|
+
for (const [job, label] of JOBS) {
|
|
392
|
+
if (job === 'chat' || !m.can.includes(job))
|
|
393
|
+
continue;
|
|
394
|
+
lines.push(` ${p.dim(label.toLowerCase().padEnd(16))}${m.jobs[job] ?? p.dim('on the chat models above')}`);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
const other = v.models.find((m) => m.id !== v.using)?.id ?? v.using;
|
|
398
|
+
lines.push(...next(p, 'Pick the one your agents use:', `phantom models use ${other}`));
|
|
399
|
+
return lines.join('\n');
|
|
400
|
+
}
|
package/dist/core/free.mjs
CHANGED
|
@@ -5,5 +5,7 @@
|
|
|
5
5
|
* repo's `lib/config.ts`; change both together.
|
|
6
6
|
*/
|
|
7
7
|
export const FREE_REQUESTS_A_DAY = 50;
|
|
8
|
+
/** The same, for requests a coding agent sends (`FREE_ROUTER_CAPS.perDayAgent` in the Phantom repo). */
|
|
9
|
+
export const FREE_AGENT_REQUESTS_A_DAY = 200;
|
|
8
10
|
/** The free offer in one line short enough for an 80-column terminal. */
|
|
9
11
|
export const FREE_LINE = `phantom-1 runs free models, ${FREE_REQUESTS_A_DAY} requests a day, with no card`;
|
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.3.0';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { stateDir } from "../core/state.mjs";
|
|
4
|
+
import { SETUP_MODEL } from "../setup/shared.mjs";
|
|
5
|
+
// The model you picked with `phantom models`. Setup writes it into each
|
|
6
|
+
// agent's settings, and `phantom claude`, `phantom codex` and `phantom pi`
|
|
7
|
+
// start on it. It lives in one plain file, `model`, in the state folder.
|
|
8
|
+
/** The file that holds the model you picked. */
|
|
9
|
+
const choiceFile = (env) => path.join(stateDir(env), 'model');
|
|
10
|
+
/** The model you picked with `phantom models`, or undefined when you never picked one. */
|
|
11
|
+
export function savedModel(env) {
|
|
12
|
+
try {
|
|
13
|
+
return readFileSync(choiceFile(env), 'utf-8').trim() || undefined;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Saves the model your agents start on. */
|
|
20
|
+
export function saveModel(env, id) {
|
|
21
|
+
mkdirSync(stateDir(env), { recursive: true });
|
|
22
|
+
writeFileSync(choiceFile(env), `${id}\n`);
|
|
23
|
+
}
|
|
24
|
+
/** The model agents start on: the one you picked, or phantom-1. */
|
|
25
|
+
export function startModel(env) {
|
|
26
|
+
return savedModel(env) ?? SETUP_MODEL;
|
|
27
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { die } from "../core/errors.mjs";
|
|
2
|
+
import { out, pickIo, showsScreen } from "../core/helpers.mjs";
|
|
3
|
+
import { choose } from "../core/pick.mjs";
|
|
4
|
+
import { colorOn, paint } from "../core/style.mjs";
|
|
5
|
+
import { hideHints, modelsScreen } from "../cli/screens.mjs";
|
|
6
|
+
import { unknownSub } from "../cli/start.mjs";
|
|
7
|
+
import { isSetUp } from "../setup/apply.mjs";
|
|
8
|
+
import { saveModel, startModel } from "./choice.mjs";
|
|
9
|
+
import { getModels } from "./list.mjs";
|
|
10
|
+
/**
|
|
11
|
+
* `phantom models`: phantom-1, phantom-1:free and phantom-1:zdr side by side,
|
|
12
|
+
* with the jobs each can do and the model behind each job. At a terminal you
|
|
13
|
+
* pick one, and your agents start on it (`./choice.mts`).
|
|
14
|
+
* `phantom models use <id>` picks without the menu.
|
|
15
|
+
*/
|
|
16
|
+
export async function modelsCommand(input) {
|
|
17
|
+
const { io, env, subcommand, argv, baseUrl, apiKey } = input;
|
|
18
|
+
const table = showsScreen(input);
|
|
19
|
+
const style = { env, color: colorOn(env, io.stdoutIsTTY), columns: io.columns };
|
|
20
|
+
const models = await getModels(baseUrl, apiKey);
|
|
21
|
+
const ids = models.map((m) => m.id);
|
|
22
|
+
if (subcommand === 'use') {
|
|
23
|
+
const id = argv[2] && !argv[2].startsWith('--') ? argv[2] : undefined;
|
|
24
|
+
if (!id || !ids.includes(id))
|
|
25
|
+
die(`models use needs one of: ${ids.join(', ')}`, 'models_usage');
|
|
26
|
+
saveModel(env, id);
|
|
27
|
+
out({ using: id }, table, () => picked(input, id), io.stdout);
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
if (subcommand)
|
|
31
|
+
die(unknownSub('models', subcommand, ['use']), 'models_usage');
|
|
32
|
+
const view = { models, using: startModel(env) };
|
|
33
|
+
const pick = pickIo(input);
|
|
34
|
+
if (!pick) {
|
|
35
|
+
out(view, table, (d) => modelsScreen(d, style), io.stdout);
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
// At a terminal: the table, then a picker, instead of a command to type.
|
|
39
|
+
const hintsWere = hideHints(true);
|
|
40
|
+
let id;
|
|
41
|
+
try {
|
|
42
|
+
io.stdout(modelsScreen(view, style) + '\n\n');
|
|
43
|
+
const choices = models.map((m) => ({ label: m.id, hint: m.id === view.using ? 'what they use now' : m.name, value: m.id }));
|
|
44
|
+
id = await choose({ ...pick, esc: 'back' }, 'Which one should your agents use?', choices, Math.max(0, ids.indexOf(view.using)));
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
hideHints(hintsWere);
|
|
48
|
+
}
|
|
49
|
+
if (id === null)
|
|
50
|
+
return 0;
|
|
51
|
+
if (id === view.using) {
|
|
52
|
+
io.stdout(`\n Your agents already use ${id}.\n`);
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
saveModel(env, id);
|
|
56
|
+
io.stdout(`\n${picked(input, id)}\n`);
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
/** The lines after a pick: what changed, and how to put it in agents set up already. */
|
|
60
|
+
function picked(input, id) {
|
|
61
|
+
const p = paint(input.env, colorOn(input.env, input.io.stdoutIsTTY));
|
|
62
|
+
const lines = [` ${p.lime('✓')} Your agents start on ${id} from now on.`];
|
|
63
|
+
if (isSetUp(input.env))
|
|
64
|
+
lines.push(` ${p.dim('Agents set up already keep their model until you run')} ${p.cyan('phantom setup')}${p.dim('.')}`);
|
|
65
|
+
return lines.join('\n');
|
|
66
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { request } from "../core/request.mjs";
|
|
2
|
+
// Phantom's own models (phantom-1, phantom-1:free, phantom-1:zdr) and what
|
|
3
|
+
// each can do, read from the server, so a model Phantom adds or changes shows
|
|
4
|
+
// up with no new CLI release. `phantom models` shows them.
|
|
5
|
+
/** Each job a model can do, with its name on screen, in the order the table lists them. */
|
|
6
|
+
export const JOBS = [
|
|
7
|
+
['chat', 'Chat'],
|
|
8
|
+
['vision', 'Images in'],
|
|
9
|
+
['embedding', 'Embeddings'],
|
|
10
|
+
['rerank', 'Rerank'],
|
|
11
|
+
['image', 'Make images'],
|
|
12
|
+
['video', 'Make video'],
|
|
13
|
+
['speech', 'Text to speech'],
|
|
14
|
+
['transcription', 'Speech to text'],
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Phantom's own models from the server. /v1/routers names each one's chat
|
|
18
|
+
* models and the model behind every other job; /v1/models says whether it
|
|
19
|
+
* takes images. Neither needs a key.
|
|
20
|
+
*/
|
|
21
|
+
export async function getModels(baseUrl, apiKey = '') {
|
|
22
|
+
const [routers, list] = await Promise.all([
|
|
23
|
+
request('GET', '/routers', apiKey, undefined, baseUrl),
|
|
24
|
+
request('GET', '/models', apiKey, undefined, baseUrl),
|
|
25
|
+
]);
|
|
26
|
+
const takesImages = new Set(list.data.filter((m) => m.modalities?.input?.includes('image')).map((m) => m.id));
|
|
27
|
+
return routers.data.map((r) => {
|
|
28
|
+
const can = JOBS.map(([job]) => job).filter((job) => {
|
|
29
|
+
if (job === 'chat')
|
|
30
|
+
return r.models.length > 0;
|
|
31
|
+
// phantom-1 names a model for images; phantom-1:zdr sends them to its chat models.
|
|
32
|
+
if (job === 'vision')
|
|
33
|
+
return Boolean(r.jobs.vision) || takesImages.has(r.id);
|
|
34
|
+
return Boolean(r.jobs[job]);
|
|
35
|
+
});
|
|
36
|
+
const chat = r.models.map((m) => ({ id: m.id, tier: m.tier, free: m.pricing.prompt === 0 && m.pricing.completion === 0 }));
|
|
37
|
+
return { id: r.id, name: r.name, description: r.description, chat, jobs: r.jobs, can };
|
|
38
|
+
});
|
|
39
|
+
}
|
package/dist/setup/command.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { setupScreen } from "./screen.mjs";
|
|
|
14
14
|
import { colorOn, paint, unstyled } from "../core/style.mjs";
|
|
15
15
|
import { inApp } from "../cli/screens.mjs";
|
|
16
16
|
import { brandIntro, motionOn, play, reveal } from "../core/motion.mjs";
|
|
17
|
+
import { savedModel } from "../models/choice.mjs";
|
|
17
18
|
/** `--table` output for `setup`, and what a terminal shows: see {@link setupScreen}. */
|
|
18
19
|
export function tableSetup(d, opts = {}) {
|
|
19
20
|
return setupScreen(d, opts);
|
|
@@ -120,7 +121,8 @@ export async function setupCommand(input) {
|
|
|
120
121
|
const options = {
|
|
121
122
|
agent,
|
|
122
123
|
provider: guided || provider === true ? true : provider === 'off' ? 'off' : false,
|
|
123
|
-
model:
|
|
124
|
+
// No --model: the one picked with `phantom models`, or phantom-1.
|
|
125
|
+
model: typeof model === 'string' ? model : savedModel(env),
|
|
124
126
|
guided,
|
|
125
127
|
shell: !flags['no-shell'],
|
|
126
128
|
};
|
package/package.json
CHANGED
|
@@ -102,6 +102,18 @@ phantom route test --table
|
|
|
102
102
|
Routing affects `auto` requests. Use `PHANTOM_KEY_NAME=coding` to manage the same
|
|
103
103
|
key used by an agent with `--key coding`. Route tests are free.
|
|
104
104
|
|
|
105
|
+
## Pick phantom-1, phantom-1:free or phantom-1:zdr
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
phantom models
|
|
109
|
+
phantom models use phantom-1:zdr
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`phantom models` lists Phantom's three models with the jobs each can do and the
|
|
113
|
+
model behind each job. `phantom-1` does every job; `phantom-1:free` is chat at $0;
|
|
114
|
+
`phantom-1:zdr` is chat on providers that keep no data. `models use` sets the model
|
|
115
|
+
`phantom claude`, `phantom codex`, `phantom pi` and the next `phantom setup` start on.
|
|
116
|
+
|
|
105
117
|
## Pick phantom-1's models
|
|
106
118
|
|
|
107
119
|
```bash
|