@phantomcodes/cli 1.6.3 → 1.7.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/LICENSE +1 -2
- package/README.md +139 -118
- package/bin/phantom.mjs +37 -2
- package/dist/agents/command.d.mts +8 -27
- package/dist/agents/command.mjs +323 -59
- package/dist/agents/login.d.mts +3 -0
- package/dist/agents/login.mjs +97 -0
- package/dist/agents/opencode-check.d.mts +15 -0
- package/dist/agents/opencode-check.mjs +193 -0
- package/dist/agents/phantom-key.d.mts +7 -0
- package/dist/agents/phantom-key.mjs +40 -0
- package/dist/agents/proxy.d.mts +26 -28
- package/dist/agents/proxy.mjs +225 -33
- package/dist/chatgpt/command.d.mts +2 -0
- package/dist/chatgpt/command.mjs +119 -0
- package/dist/chatgpt/session.d.mts +87 -0
- package/dist/chatgpt/session.mjs +253 -0
- package/dist/cli/accounts.d.mts +21 -0
- package/dist/cli/accounts.mjs +96 -0
- package/dist/cli/app.d.mts +4 -24
- package/dist/cli/app.mjs +224 -139
- package/dist/cli/commands.d.mts +1 -16
- package/dist/cli/commands.mjs +144 -239
- package/dist/cli/help.d.mts +0 -19
- package/dist/cli/help.mjs +30 -55
- package/dist/cli/run.mjs +35 -79
- package/dist/cli/start.d.mts +2 -31
- package/dist/cli/start.mjs +13 -116
- package/dist/core/brand.d.mts +0 -7
- package/dist/core/brand.mjs +0 -8
- package/dist/core/errors.d.mts +0 -16
- package/dist/core/errors.mjs +0 -16
- package/dist/core/helpers.d.mts +0 -46
- package/dist/core/helpers.mjs +1 -64
- package/dist/core/node-trust.d.mts +0 -5
- package/dist/core/node-trust.mjs +0 -6
- package/dist/core/pick.d.mts +7 -55
- package/dist/core/pick.mjs +49 -106
- package/dist/core/request.d.mts +0 -46
- package/dist/core/request.mjs +1 -60
- package/dist/core/secrets.d.mts +0 -4
- package/dist/core/secrets.mjs +0 -10
- package/dist/core/state.d.mts +3 -1
- package/dist/core/state.mjs +147 -4
- package/dist/core/style.d.mts +0 -27
- package/dist/core/style.mjs +0 -20
- package/dist/core/version.d.mts +1 -2
- package/dist/core/version.mjs +1 -2
- package/dist/local/accounts.d.mts +25 -0
- package/dist/local/accounts.mjs +40 -0
- package/dist/local/agent-headers.d.mts +7 -0
- package/dist/local/agent-headers.mjs +44 -0
- package/dist/local/chatgpt-plan.d.mts +147 -0
- package/dist/local/chatgpt-plan.mjs +384 -0
- package/dist/local/command.d.mts +24 -0
- package/dist/local/command.mjs +211 -0
- package/dist/local/config.d.mts +49 -0
- package/dist/local/config.mjs +168 -0
- package/dist/local/decide.d.mts +37 -0
- package/dist/local/decide.mjs +201 -0
- package/dist/local/failure-signs.d.mts +4 -0
- package/dist/local/failure-signs.mjs +99 -0
- package/dist/local/keys.d.mts +32 -0
- package/dist/local/keys.mjs +239 -0
- package/dist/local/models.d.mts +53 -0
- package/dist/local/models.mjs +117 -0
- package/dist/local/replay.d.mts +59 -0
- package/dist/local/replay.mjs +143 -0
- package/dist/local/report.d.mts +43 -0
- package/dist/local/report.mjs +153 -0
- package/dist/local/request-log.d.mts +53 -0
- package/dist/local/request-log.mjs +69 -0
- package/dist/local/retry-after.d.mts +3 -0
- package/dist/local/retry-after.mjs +28 -0
- package/dist/local/rust-router.d.mts +39 -0
- package/dist/local/rust-router.mjs +54 -0
- package/dist/local/server.d.mts +27 -0
- package/dist/local/server.mjs +449 -0
- package/dist/local/status-line.d.mts +17 -0
- package/dist/local/status-line.mjs +81 -0
- package/dist/local/tiers.d.mts +3 -0
- package/dist/local/tiers.mjs +137 -0
- package/dist/local/traces.d.mts +69 -0
- package/dist/local/traces.mjs +341 -0
- package/dist/phantom.d.mts +0 -37
- package/dist/phantom.mjs +0 -31
- package/package.json +15 -9
- package/skills/phantom-ai/SKILL.md +28 -97
- package/dist/cli/screens.d.mts +0 -177
- package/dist/cli/screens.mjs +0 -398
- package/dist/core/free.d.mts +0 -13
- package/dist/core/free.mjs +0 -14
- package/dist/core/motion.d.mts +0 -47
- package/dist/core/motion.mjs +0 -156
- package/dist/core/shapes.d.mts +0 -13
- package/dist/core/shapes.mjs +0 -1
- package/dist/keys/command.d.mts +0 -16
- package/dist/keys/command.mjs +0 -143
- package/dist/keys/saved.d.mts +0 -96
- package/dist/keys/saved.mjs +0 -169
- package/dist/models/choice.d.mts +0 -7
- package/dist/models/choice.mjs +0 -27
- package/dist/models/command.d.mts +0 -8
- package/dist/models/command.mjs +0 -66
- package/dist/models/list.d.mts +0 -39
- package/dist/models/list.mjs +0 -39
- package/dist/receipts/command.d.mts +0 -7
- package/dist/receipts/command.mjs +0 -41
- package/dist/receipts/receipts.d.mts +0 -76
- package/dist/receipts/receipts.mjs +0 -118
- package/dist/setup/agents.d.mts +0 -149
- package/dist/setup/agents.mjs +0 -886
- package/dist/setup/apply.d.mts +0 -85
- package/dist/setup/apply.mjs +0 -301
- package/dist/setup/command.d.mts +0 -12
- package/dist/setup/command.mjs +0 -307
- package/dist/setup/editors.d.mts +0 -108
- package/dist/setup/editors.mjs +0 -500
- package/dist/setup/legacy.d.mts +0 -13
- package/dist/setup/legacy.mjs +0 -36
- package/dist/setup/plan.d.mts +0 -104
- package/dist/setup/plan.mjs +0 -132
- package/dist/setup/screen.d.mts +0 -30
- package/dist/setup/screen.mjs +0 -260
- package/dist/setup/shared.d.mts +0 -141
- package/dist/setup/shared.mjs +0 -88
- package/dist/setup/was.d.mts +0 -42
- package/dist/setup/was.mjs +0 -91
- package/dist/spend/command.d.mts +0 -5
- package/dist/spend/command.mjs +0 -235
- package/dist/spend/lineup.d.mts +0 -61
- package/dist/spend/lineup.mjs +0 -39
- package/dist/spend/reason.d.mts +0 -5
- package/dist/spend/reason.mjs +0 -60
- package/dist/spend/report.d.mts +0 -105
- package/dist/spend/report.mjs +0 -68
- package/dist/spend/routing.d.mts +0 -74
- package/dist/spend/routing.mjs +0 -57
- package/dist/workspace/command.d.mts +0 -59
- package/dist/workspace/command.mjs +0 -871
package/dist/setup/was.d.mts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { type Env } from '../core/state.mts';
|
|
2
|
-
import { type JsonChange } from './editors.mts';
|
|
3
|
-
/**
|
|
4
|
-
* What `phantom setup` replaced in a JSON settings file, so `--provider off` can put it back.
|
|
5
|
-
*
|
|
6
|
-
* TOML and YAML files keep this in the file itself: the replaced line stays as a `# phantom setup was:`
|
|
7
|
-
* comment. JSON has no comments, and Claude Code and the other agents read these files strictly, so
|
|
8
|
-
* the record lives in `setup-json-was.json` in the state folder instead (mode 600, because a replaced
|
|
9
|
-
* value can be a key the user had in the file).
|
|
10
|
-
*/
|
|
11
|
-
/** One key setup wrote in a JSON file. */
|
|
12
|
-
export type JsonWasEntry = {
|
|
13
|
-
/** The keys from the top of the file down to the value, such as `['env', 'ANTHROPIC_MODEL']`. */
|
|
14
|
-
path: string[];
|
|
15
|
-
/** True when the key held a value before setup wrote it. */
|
|
16
|
-
had: boolean;
|
|
17
|
-
/** The value before setup wrote the key. Missing when `had` is false. */
|
|
18
|
-
was?: unknown;
|
|
19
|
-
/** What setup wrote. Off puts the old value back only while the key still holds this. */
|
|
20
|
-
wrote: unknown;
|
|
21
|
-
};
|
|
22
|
-
/** Every key setup wrote in one file. */
|
|
23
|
-
export type JsonWas = JsonWasEntry[];
|
|
24
|
-
/** What setup recorded for `file`, or an empty list. */
|
|
25
|
-
export declare function readJsonWas(env: Env, file: string): JsonWas;
|
|
26
|
-
/** Saves what setup recorded for `file`. null forgets it. */
|
|
27
|
-
export declare function writeJsonWas(env: Env, file: string, entries: JsonWas | null): void;
|
|
28
|
-
/**
|
|
29
|
-
* The record after setup writes `changes` to a file whose parsed content is `settings`. Each key remembers
|
|
30
|
-
* the value that was there. When setup runs again over its own value, the older record stays, so the
|
|
31
|
-
* user's first value survives any number of runs.
|
|
32
|
-
* @param previous What setup recorded for this file before.
|
|
33
|
-
* @param tracked The paths to record. Other changes are not remembered (a key setup adds to a list, say).
|
|
34
|
-
*/
|
|
35
|
-
export declare function trackJsonChanges(settings: Record<string, unknown>, previous: JsonWas, changes: JsonChange[], tracked: string[][]): JsonWas;
|
|
36
|
-
/**
|
|
37
|
-
* The changes for `--provider off`. `removals` are what an agent's own off step would do (it knows which
|
|
38
|
-
* values look like phantom's); this swaps in the record: a key still holding what setup wrote gets its old
|
|
39
|
-
* value back, or goes if setup added it, and a key the user changed since is left alone. A container
|
|
40
|
-
* that a removal of a key setup added leaves empty goes too, and so does each one in `tidy` that ends up empty.
|
|
41
|
-
*/
|
|
42
|
-
export declare function restoreJsonChanges(settings: Record<string, unknown>, record: JsonWas, removals: JsonChange[], tidy?: string[][]): JsonChange[];
|
package/dist/setup/was.mjs
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { isDeepStrictEqual } from 'node:util';
|
|
3
|
-
import { chmodSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { makePrivateFolder, stateDir } from "../core/state.mjs";
|
|
5
|
-
import { jsonGet, jsonSet } from "./editors.mjs";
|
|
6
|
-
const recordFile = (env) => path.join(stateDir(env), 'setup-json-was.json');
|
|
7
|
-
function readAll(env) {
|
|
8
|
-
try {
|
|
9
|
-
return JSON.parse(readFileSync(recordFile(env), 'utf-8'));
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
return {};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/** What setup recorded for `file`, or an empty list. */
|
|
16
|
-
export function readJsonWas(env, file) {
|
|
17
|
-
return readAll(env)[file] ?? [];
|
|
18
|
-
}
|
|
19
|
-
/** Saves what setup recorded for `file`. null forgets it. */
|
|
20
|
-
export function writeJsonWas(env, file, entries) {
|
|
21
|
-
const all = readAll(env);
|
|
22
|
-
if (entries === null || entries.length === 0)
|
|
23
|
-
delete all[file];
|
|
24
|
-
else
|
|
25
|
-
all[file] = entries;
|
|
26
|
-
makePrivateFolder(env, stateDir(env));
|
|
27
|
-
writeFileSync(recordFile(env), JSON.stringify(all, null, 2) + '\n', { mode: 0o600 });
|
|
28
|
-
chmodSync(recordFile(env), 0o600);
|
|
29
|
-
}
|
|
30
|
-
const same = (a, b) => a.length === b.length && a.every((k, i) => k === b[i]);
|
|
31
|
-
const startsWith = (path, prefix) => prefix.length <= path.length && prefix.every((k, i) => k === path[i]);
|
|
32
|
-
/**
|
|
33
|
-
* The record after setup writes `changes` to a file whose parsed content is `settings`. Each key remembers
|
|
34
|
-
* the value that was there. When setup runs again over its own value, the older record stays, so the
|
|
35
|
-
* user's first value survives any number of runs.
|
|
36
|
-
* @param previous What setup recorded for this file before.
|
|
37
|
-
* @param tracked The paths to record. Other changes are not remembered (a key setup adds to a list, say).
|
|
38
|
-
*/
|
|
39
|
-
export function trackJsonChanges(settings, previous, changes, tracked) {
|
|
40
|
-
const next = [...previous];
|
|
41
|
-
for (const [path, value] of changes) {
|
|
42
|
-
if (value === undefined || !tracked.some((t) => same(t, path)))
|
|
43
|
-
continue;
|
|
44
|
-
const current = jsonGet(settings, path);
|
|
45
|
-
const at = next.findIndex((e) => same(e.path, path));
|
|
46
|
-
// Setup's own value from an earlier run: the record of what came before it still holds.
|
|
47
|
-
if (at !== -1 && isDeepStrictEqual(current, next[at].wrote)) {
|
|
48
|
-
next[at] = { ...next[at], wrote: value };
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
const entry = { path, had: current !== undefined, ...(current !== undefined ? { was: current } : {}), wrote: value };
|
|
52
|
-
if (at === -1)
|
|
53
|
-
next.push(entry);
|
|
54
|
-
else
|
|
55
|
-
next[at] = entry;
|
|
56
|
-
}
|
|
57
|
-
return next;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* The changes for `--provider off`. `removals` are what an agent's own off step would do (it knows which
|
|
61
|
-
* values look like phantom's); this swaps in the record: a key still holding what setup wrote gets its old
|
|
62
|
-
* value back, or goes if setup added it, and a key the user changed since is left alone. A container
|
|
63
|
-
* that a removal of a key setup added leaves empty goes too, and so does each one in `tidy` that ends up empty.
|
|
64
|
-
*/
|
|
65
|
-
export function restoreJsonChanges(settings, record, removals, tidy = []) {
|
|
66
|
-
const restores = [];
|
|
67
|
-
for (const e of record) {
|
|
68
|
-
if (isDeepStrictEqual(jsonGet(settings, e.path), e.wrote))
|
|
69
|
-
restores.push([e.path, e.had ? e.was : undefined]);
|
|
70
|
-
}
|
|
71
|
-
// A removal at a tracked key, or above one, is the record's to decide.
|
|
72
|
-
const rest = removals.filter(([p]) => !record.some((e) => startsWith(e.path, p)));
|
|
73
|
-
const changes = [...restores, ...rest];
|
|
74
|
-
// Remove what setup created and left empty, starting from the nearest container.
|
|
75
|
-
const after = structuredClone(settings);
|
|
76
|
-
for (const [p, v] of changes)
|
|
77
|
-
jsonSet(after, p, v);
|
|
78
|
-
// The containers to check, nearest first: where a removed key lived, and each one asked for in `tidy`.
|
|
79
|
-
const containers = [...restores.filter(([, v]) => v === undefined).map(([p]) => p.slice(0, -1)), ...tidy].filter((c) => c.length > 0);
|
|
80
|
-
for (const container of containers) {
|
|
81
|
-
for (let depth = container.length; depth >= 1; depth--) {
|
|
82
|
-
const parent = container.slice(0, depth);
|
|
83
|
-
const node = jsonGet(after, parent);
|
|
84
|
-
if (!node || typeof node !== 'object' || Object.keys(node).length > 0)
|
|
85
|
-
break;
|
|
86
|
-
jsonSet(after, parent, undefined);
|
|
87
|
-
changes.push([parent, undefined]);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return changes;
|
|
91
|
-
}
|
package/dist/spend/command.d.mts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type CommandInput } from '../core/helpers.mts';
|
|
2
|
-
/** `phantom route`: the key's route policy, its rules, and a dry run. Run by `run()`. */
|
|
3
|
-
export declare function routeCommand(input: CommandInput): Promise<number>;
|
|
4
|
-
/** `phantom lineup`: the model phantom-1 runs in each tier, and a fallback for each. Run by `run()`. */
|
|
5
|
-
export declare function lineupCommand(input: CommandInput): Promise<number>;
|
package/dist/spend/command.mjs
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { unknownSub } from "../cli/start.mjs";
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
|
-
import { die } from "../core/errors.mjs";
|
|
4
|
-
import { flagNum, out, pickIo, showsScreen } from "../core/helpers.mjs";
|
|
5
|
-
import { colorOn, paint } from "../core/style.mjs";
|
|
6
|
-
import { choose } from "../core/pick.mjs";
|
|
7
|
-
import { hideHints, lineupScreen, priceHint, routeScreen, routeTestScreen, TIER_ABOUT } from "../cli/screens.mjs";
|
|
8
|
-
import { currentTiersOnly, getLineup, putLineup, resetLineup, LINEUP_TIERS } from "./lineup.mjs";
|
|
9
|
-
import { getRoute, putRoute, patchRoute, clearRoute, testRoute, parseCondition, SORT_WORDS } from "./routing.mjs";
|
|
10
|
-
/** `phantom route`: the key's route policy, its rules, and a dry run. Run by `run()`. */
|
|
11
|
-
export async function routeCommand(input) {
|
|
12
|
-
const { argv, io, apiKey, subcommand, flags, baseUrl, env } = input;
|
|
13
|
-
const table = showsScreen(input);
|
|
14
|
-
const style = { env, color: colorOn(env, io.stdoutIsTTY) };
|
|
15
|
-
const tableRoute = (d) => routeScreen(d, style);
|
|
16
|
-
const tableRouteTest = (d) => routeTestScreen(d, style);
|
|
17
|
-
if (!subcommand || subcommand === 'get') {
|
|
18
|
-
out(await getRoute(apiKey, baseUrl), table, tableRoute, io.stdout);
|
|
19
|
-
}
|
|
20
|
-
else if (subcommand === 'set') {
|
|
21
|
-
const file = flags['file'];
|
|
22
|
-
if (typeof file === 'string') {
|
|
23
|
-
let policy;
|
|
24
|
-
try {
|
|
25
|
-
policy = JSON.parse(readFileSync(file, 'utf-8'));
|
|
26
|
-
}
|
|
27
|
-
catch (e) {
|
|
28
|
-
die(`Could not read ${file} as JSON: ${e instanceof Error ? e.message : e}`);
|
|
29
|
-
}
|
|
30
|
-
out(await putRoute(apiKey, policy, baseUrl), table, tableRoute, io.stdout);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
const fields = {};
|
|
34
|
-
if (typeof flags['models'] === 'string')
|
|
35
|
-
fields.models = flags['models'].split(',').map((m) => m.trim()).filter(Boolean);
|
|
36
|
-
if (typeof flags['applies-to'] === 'string')
|
|
37
|
-
fields.applies_to = flags['applies-to'];
|
|
38
|
-
if (typeof flags['on-empty'] === 'string')
|
|
39
|
-
fields.on_empty = flags['on-empty'];
|
|
40
|
-
if (flags['fallback'] !== undefined)
|
|
41
|
-
fields.fallback_on_error = flags['fallback'] !== 'false';
|
|
42
|
-
const stick = flagNum(flags, 'stick-minutes');
|
|
43
|
-
if (stick !== undefined)
|
|
44
|
-
fields.stick_minutes = stick;
|
|
45
|
-
if (flags['stick-by-prompt'] !== undefined)
|
|
46
|
-
fields.stick_by_prompt = flags['stick-by-prompt'] !== 'false';
|
|
47
|
-
const sort = flags['sort'];
|
|
48
|
-
if (sort !== undefined && (typeof sort !== 'string' || !(sort in SORT_WORDS || sort === 'default'))) {
|
|
49
|
-
die('--sort takes fast (quickest to start answering), cheap (the default), throughput (most tokens a second) or default', 'route_usage');
|
|
50
|
-
}
|
|
51
|
-
if (typeof sort === 'string' && sort !== 'default')
|
|
52
|
-
fields.sort = SORT_WORDS[sort];
|
|
53
|
-
if (Object.keys(fields).length === 0 && sort !== 'default') {
|
|
54
|
-
die('route set needs --models a,b,c, --sort, --applies-to, --on-empty, --fallback, --stick-minutes, --stick-by-prompt, or --file policy.json');
|
|
55
|
-
}
|
|
56
|
-
const current = (await getRoute(apiKey, baseUrl)).route_policy;
|
|
57
|
-
let result;
|
|
58
|
-
if (sort === 'default') {
|
|
59
|
-
// Back to cheapest first: drop sort, and the whole policy when sort was all it held.
|
|
60
|
-
const { sort: _was, ...rest } = { ...(current ?? { models: [] }), ...fields };
|
|
61
|
-
void _was;
|
|
62
|
-
const empty = !rest.models.length && !rest.zdr && !rest.no_training && !(rest.rules ?? []).length;
|
|
63
|
-
result = !current ? { route_policy: null } : empty ? await clearRoute(apiKey, baseUrl) : await putRoute(apiKey, rest, baseUrl);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
// A key with no policy gets one of preferences only, which routes nothing, unless --models is given too.
|
|
67
|
-
result = current ? await patchRoute(apiKey, fields, baseUrl) : await putRoute(apiKey, { models: [], ...fields }, baseUrl);
|
|
68
|
-
}
|
|
69
|
-
out(result, table, tableRoute, io.stdout);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else if (subcommand === 'rule') {
|
|
73
|
-
const action = argv[2];
|
|
74
|
-
// The new rule is checked before the server is asked anything, so a typo in a condition costs no request.
|
|
75
|
-
let newRule = null;
|
|
76
|
-
if (action === 'add') {
|
|
77
|
-
const cond = flags['if'];
|
|
78
|
-
const use = flags['use'];
|
|
79
|
-
if (typeof cond !== 'string' || typeof use !== 'string')
|
|
80
|
-
die('route rule add requires --if name=value and --use <model|cheapest|first|next>');
|
|
81
|
-
newRule = { if: parseCondition(cond), use };
|
|
82
|
-
}
|
|
83
|
-
const current = (await getRoute(apiKey, baseUrl)).route_policy;
|
|
84
|
-
if (!current)
|
|
85
|
-
die('This key has no route policy. Start with: phantom route set --models a,b');
|
|
86
|
-
const rules = [...(current.rules ?? [])];
|
|
87
|
-
if (newRule) {
|
|
88
|
-
const rule = newRule;
|
|
89
|
-
const at = flagNum(flags, 'at');
|
|
90
|
-
if (at !== undefined)
|
|
91
|
-
rules.splice(Math.max(0, at - 1), 0, rule);
|
|
92
|
-
else
|
|
93
|
-
rules.push(rule);
|
|
94
|
-
}
|
|
95
|
-
else if (action === 'rm') {
|
|
96
|
-
const n = Number(argv[3]);
|
|
97
|
-
if (!Number.isInteger(n) || n < 1 || n > rules.length)
|
|
98
|
-
die(`route rule rm takes a rule number from 1 to ${rules.length}`);
|
|
99
|
-
rules.splice(n - 1, 1);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
die('Use: route rule add --if name=value --use <model> [--at n], or route rule rm <n>');
|
|
103
|
-
}
|
|
104
|
-
out(await patchRoute(apiKey, { rules }, baseUrl), table, tableRoute, io.stdout);
|
|
105
|
-
}
|
|
106
|
-
else if (subcommand === 'test') {
|
|
107
|
-
const model = typeof flags['model'] === 'string' ? flags['model'] : 'auto';
|
|
108
|
-
out(await testRoute(apiKey, { model }, baseUrl), table, tableRouteTest, io.stdout);
|
|
109
|
-
}
|
|
110
|
-
else if (subcommand === 'clear') {
|
|
111
|
-
out(await clearRoute(apiKey, baseUrl), table, tableRoute, io.stdout);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
die(unknownSub('route', String(subcommand), ['get', 'set', 'rule', 'test', 'clear']), 'route_usage');
|
|
115
|
-
}
|
|
116
|
-
return 0;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Changes one tier's entry in `into` from a flag value: a model id sets it,
|
|
120
|
-
* and `default` clears it so the tier runs its default again.
|
|
121
|
-
*/
|
|
122
|
-
function applyPick(into, tier, flag, value) {
|
|
123
|
-
if (value === undefined)
|
|
124
|
-
return;
|
|
125
|
-
if (value === true || !value)
|
|
126
|
-
die(`--${flag} needs a model id, or "default" to clear it`);
|
|
127
|
-
if (value === 'default')
|
|
128
|
-
delete into[tier];
|
|
129
|
-
else
|
|
130
|
-
into[tier] = value;
|
|
131
|
-
}
|
|
132
|
-
/** Flags from when phantom-1 had an Economy tier. They stop the command before it asks the server anything. */
|
|
133
|
-
const RETIRED_LINEUP_FLAGS = ['economy', 'economy-fallback'];
|
|
134
|
-
/** `phantom lineup`: the model phantom-1 runs in each tier, and a fallback for each. Run by `run()`. */
|
|
135
|
-
export async function lineupCommand(input) {
|
|
136
|
-
const { io, apiKey, subcommand, flags, baseUrl, env } = input;
|
|
137
|
-
const retired = RETIRED_LINEUP_FLAGS.find((name) => flags[name] !== undefined);
|
|
138
|
-
if (retired)
|
|
139
|
-
die(`phantom-1 has two tiers, Standard and Frontier. --${retired} is no longer an option.`, 'lineup_usage');
|
|
140
|
-
const table = showsScreen(input);
|
|
141
|
-
const style = { env, color: colorOn(env, io.stdoutIsTTY) };
|
|
142
|
-
const tableLineup = (d) => lineupScreen(d, style);
|
|
143
|
-
// lineup set with no flags, at a terminal: pick a tier, then its model, from lists with prices.
|
|
144
|
-
// lineup alone, or set with no flags, at a terminal: the table, then a picker to change it, instead of a command to type.
|
|
145
|
-
const pick = (!subcommand || subcommand === 'set') && !LINEUP_FLAGS.some((name) => flags[name] !== undefined) ? pickIo(input) : null;
|
|
146
|
-
if (pick)
|
|
147
|
-
return lineupPicker(input, pick, tableLineup);
|
|
148
|
-
if (!subcommand || subcommand === 'get') {
|
|
149
|
-
out(await getLineup(apiKey, baseUrl), table, tableLineup, io.stdout);
|
|
150
|
-
}
|
|
151
|
-
else if (subcommand === 'set') {
|
|
152
|
-
// PUT replaces the whole lineup, so start from what the key has now.
|
|
153
|
-
const read = await getLineup(apiKey, baseUrl);
|
|
154
|
-
const current = currentTiersOnly(read.lineup);
|
|
155
|
-
const { fallbacks: currentFallbacks, ...picks } = current;
|
|
156
|
-
const fallbacks = { ...currentFallbacks };
|
|
157
|
-
const model = { standard: flags['standard'], frontier: flags['frontier'] };
|
|
158
|
-
const fallback = {
|
|
159
|
-
standard: flags['standard-fallback'],
|
|
160
|
-
frontier: flags['frontier-fallback'],
|
|
161
|
-
};
|
|
162
|
-
for (const tier of LINEUP_TIERS) {
|
|
163
|
-
applyPick(picks, tier, tier, model[tier]);
|
|
164
|
-
applyPick(fallbacks, tier, `${tier}-fallback`, fallback[tier]);
|
|
165
|
-
// A fallback the key already had can't be its tier's own model, which the server refuses. Drop it when this change makes it so.
|
|
166
|
-
const runs = picks[tier] ?? read.choices?.[tier].find((c) => c.default)?.model;
|
|
167
|
-
if (fallback[tier] === undefined && fallbacks[tier] === runs)
|
|
168
|
-
delete fallbacks[tier];
|
|
169
|
-
}
|
|
170
|
-
if (LINEUP_TIERS.every((tier) => model[tier] === undefined && fallback[tier] === undefined)) {
|
|
171
|
-
die('lineup set needs --standard or --frontier, or --standard-fallback or --frontier-fallback, each with a model id or "default"');
|
|
172
|
-
}
|
|
173
|
-
const next = Object.keys(fallbacks).length ? { ...picks, fallbacks } : picks;
|
|
174
|
-
out(await putLineup(apiKey, next, baseUrl), table, tableLineup, io.stdout);
|
|
175
|
-
}
|
|
176
|
-
else if (subcommand === 'reset') {
|
|
177
|
-
out(await resetLineup(apiKey, baseUrl), table, tableLineup, io.stdout);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
die(unknownSub('lineup', String(subcommand), ['get', 'set', 'reset']), 'lineup_usage');
|
|
181
|
-
}
|
|
182
|
-
return 0;
|
|
183
|
-
}
|
|
184
|
-
/** The flags `lineup set` reads; with none of them, at a terminal, it opens the picker instead. */
|
|
185
|
-
const LINEUP_FLAGS = ['standard', 'frontier', 'standard-fallback', 'frontier-fallback'];
|
|
186
|
-
/**
|
|
187
|
-
* `phantom lineup set` at a terminal: choose a tier, then a model for it from
|
|
188
|
-
* a list with prices (the default marked), and it saves at once. It loops
|
|
189
|
-
* back to the tiers so you can change another; Esc there is done.
|
|
190
|
-
*/
|
|
191
|
-
async function lineupPicker(input, pick, show) {
|
|
192
|
-
const { io, apiKey, baseUrl } = input;
|
|
193
|
-
let read = await getLineup(apiKey, baseUrl);
|
|
194
|
-
// The table's "→ phantom lineup set" line would point at the picker that's already open.
|
|
195
|
-
const hintsWere = hideHints(true);
|
|
196
|
-
// The marker stays on the tier you last changed, so changing it again (or the next one) is one move.
|
|
197
|
-
let last = 0;
|
|
198
|
-
try {
|
|
199
|
-
for (;;) {
|
|
200
|
-
io.stdout(show(read) + '\n\n');
|
|
201
|
-
const tier = await choose({ ...pick, esc: 'back' }, 'Which tier do you want to change?', [
|
|
202
|
-
...LINEUP_TIERS.map((t) => ({ label: t[0].toUpperCase() + t.slice(1), hint: `${TIER_ABOUT[t]} · now ${read.tiers[t].model}`, value: t })),
|
|
203
|
-
{ label: 'Reset every tier', hint: 'back to its default', value: 'reset' },
|
|
204
|
-
], last);
|
|
205
|
-
if (tier === null)
|
|
206
|
-
return 0;
|
|
207
|
-
if (tier === 'reset') {
|
|
208
|
-
read = { ...(await resetLineup(apiKey, baseUrl)), choices: read.choices };
|
|
209
|
-
continue;
|
|
210
|
-
}
|
|
211
|
-
const options = read.choices?.[tier] ?? [];
|
|
212
|
-
const now = read.tiers[tier].model;
|
|
213
|
-
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)));
|
|
214
|
-
if (model === null)
|
|
215
|
-
continue;
|
|
216
|
-
const { fallbacks, ...picks } = currentTiersOnly(read.lineup);
|
|
217
|
-
const chosen = options.find((c) => c.model === model);
|
|
218
|
-
if (chosen?.default)
|
|
219
|
-
delete picks[tier];
|
|
220
|
-
else
|
|
221
|
-
picks[tier] = model;
|
|
222
|
-
// A fallback can't be the tier's own model, which the server refuses.
|
|
223
|
-
const keep = { ...fallbacks };
|
|
224
|
-
if (keep[tier] === model)
|
|
225
|
-
delete keep[tier];
|
|
226
|
-
read = { ...(await putLineup(apiKey, Object.keys(keep).length ? { ...picks, fallbacks: keep } : picks, baseUrl)), choices: read.choices };
|
|
227
|
-
last = LINEUP_TIERS.indexOf(tier);
|
|
228
|
-
// Said on its own line, so the change is plain before the table redraws.
|
|
229
|
-
io.stdout(`\n ${paint(input.env, colorOn(input.env, io.stdoutIsTTY)).lime('✓')} ${tier[0].toUpperCase() + tier.slice(1)} now runs ${model}.\n`);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
finally {
|
|
233
|
-
hideHints(hintsWere);
|
|
234
|
-
}
|
|
235
|
-
}
|
package/dist/spend/lineup.d.mts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A key's lineup decides which model `phantom-1` runs in each tier. The server
|
|
3
|
-
* checks every pick (routers/phantom-1/runtime/src/lineup.ts in the Phantom
|
|
4
|
-
* repo: any chat model that calls tools, reads images and holds 128,000
|
|
5
|
-
* tokens), so the CLI passes model ids through. The choices GET sends are
|
|
6
|
-
* only suggestions.
|
|
7
|
-
*/
|
|
8
|
-
/** The two tiers paid `phantom-1` picks between, cheapest first. */
|
|
9
|
-
export declare const LINEUP_TIERS: readonly ["standard", "frontier"];
|
|
10
|
-
/** One of {@link LINEUP_TIERS}. */
|
|
11
|
-
export type LineupTier = (typeof LINEUP_TIERS)[number];
|
|
12
|
-
/** A model id for each tier that has one. */
|
|
13
|
-
export type LineupPicks = Partial<Record<LineupTier, string>>;
|
|
14
|
-
/** A key's lineup as the server stores it. A tier left out runs its default. */
|
|
15
|
-
export type Lineup = LineupPicks & {
|
|
16
|
-
/** The model to try when the tier's model fails. A tier left out keeps the usual fallback. */
|
|
17
|
-
fallbacks?: LineupPicks;
|
|
18
|
-
};
|
|
19
|
-
/** One model a tier can run, with its price per million tokens. */
|
|
20
|
-
export type LineupChoice = {
|
|
21
|
-
/** Model id. */
|
|
22
|
-
model: string;
|
|
23
|
-
/** Display name. */
|
|
24
|
-
name: string;
|
|
25
|
-
/** USD per million input tokens. null when the catalog doesn't list the model right now. */
|
|
26
|
-
input_per_m: number | null;
|
|
27
|
-
/** USD per million output tokens. null when the catalog doesn't list the model right now. */
|
|
28
|
-
output_per_m: number | null;
|
|
29
|
-
/** Context window in tokens. */
|
|
30
|
-
context: number | null;
|
|
31
|
-
/** True for the tier's default. */
|
|
32
|
-
default: boolean;
|
|
33
|
-
};
|
|
34
|
-
/** The model a tier runs. */
|
|
35
|
-
export type LineupTierModel = {
|
|
36
|
-
/** Model id. */
|
|
37
|
-
model: string;
|
|
38
|
-
/** Display name. */
|
|
39
|
-
name: string;
|
|
40
|
-
};
|
|
41
|
-
/** The answer from the /key/lineup calls. */
|
|
42
|
-
export type LineupResult = {
|
|
43
|
-
/** What the key changed from the defaults. null means every tier runs its default. */
|
|
44
|
-
lineup: Lineup | null;
|
|
45
|
-
/** The model each tier runs now. */
|
|
46
|
-
tiers: Record<LineupTier, LineupTierModel>;
|
|
47
|
-
/** Each tier's choices, default first. Only GET sends them. */
|
|
48
|
-
choices?: Record<LineupTier, LineupChoice[]>;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* A lineup with only the tiers phantom-1 has now. A server that is older than
|
|
52
|
-
* this CLI may still send an `economy` entry; the newer server answers 400 if
|
|
53
|
-
* a PUT carries one, so it is dropped before anything is sent back.
|
|
54
|
-
*/
|
|
55
|
-
export declare function currentTiersOnly(lineup: Lineup | null | undefined): Lineup;
|
|
56
|
-
/** The key's lineup, the model each tier runs, and each tier's choices (GET /key/lineup). */
|
|
57
|
-
export declare function getLineup(apiKey: string, baseUrl?: string): Promise<LineupResult>;
|
|
58
|
-
/** Replaces the key's whole lineup (PUT /key/lineup). The server checks it before saving. */
|
|
59
|
-
export declare function putLineup(apiKey: string, lineup: Lineup, baseUrl?: string): Promise<LineupResult>;
|
|
60
|
-
/** Puts every tier back to its default (DELETE /key/lineup). */
|
|
61
|
-
export declare function resetLineup(apiKey: string, baseUrl?: string): Promise<LineupResult>;
|
package/dist/spend/lineup.mjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { request } from "../core/request.mjs";
|
|
2
|
-
/**
|
|
3
|
-
* A key's lineup decides which model `phantom-1` runs in each tier. The server
|
|
4
|
-
* checks every pick (routers/phantom-1/runtime/src/lineup.ts in the Phantom
|
|
5
|
-
* repo: any chat model that calls tools, reads images and holds 128,000
|
|
6
|
-
* tokens), so the CLI passes model ids through. The choices GET sends are
|
|
7
|
-
* only suggestions.
|
|
8
|
-
*/
|
|
9
|
-
/** The two tiers paid `phantom-1` picks between, cheapest first. */
|
|
10
|
-
export const LINEUP_TIERS = ['standard', 'frontier'];
|
|
11
|
-
/**
|
|
12
|
-
* A lineup with only the tiers phantom-1 has now. A server that is older than
|
|
13
|
-
* this CLI may still send an `economy` entry; the newer server answers 400 if
|
|
14
|
-
* a PUT carries one, so it is dropped before anything is sent back.
|
|
15
|
-
*/
|
|
16
|
-
export function currentTiersOnly(lineup) {
|
|
17
|
-
const keep = (picks) => {
|
|
18
|
-
const kept = {};
|
|
19
|
-
for (const tier of LINEUP_TIERS)
|
|
20
|
-
if (picks?.[tier])
|
|
21
|
-
kept[tier] = picks[tier];
|
|
22
|
-
return kept;
|
|
23
|
-
};
|
|
24
|
-
const picks = keep(lineup ?? undefined);
|
|
25
|
-
const fallbacks = keep(lineup?.fallbacks);
|
|
26
|
-
return Object.keys(fallbacks).length ? { ...picks, fallbacks } : picks;
|
|
27
|
-
}
|
|
28
|
-
/** The key's lineup, the model each tier runs, and each tier's choices (GET /key/lineup). */
|
|
29
|
-
export function getLineup(apiKey, baseUrl) {
|
|
30
|
-
return request('GET', '/key/lineup', apiKey, undefined, baseUrl);
|
|
31
|
-
}
|
|
32
|
-
/** Replaces the key's whole lineup (PUT /key/lineup). The server checks it before saving. */
|
|
33
|
-
export function putLineup(apiKey, lineup, baseUrl) {
|
|
34
|
-
return request('PUT', '/key/lineup', apiKey, lineup, baseUrl);
|
|
35
|
-
}
|
|
36
|
-
/** Puts every tier back to its default (DELETE /key/lineup). */
|
|
37
|
-
export function resetLineup(apiKey, baseUrl) {
|
|
38
|
-
return request('DELETE', '/key/lineup', apiKey, undefined, baseUrl);
|
|
39
|
-
}
|
package/dist/spend/reason.d.mts
DELETED
package/dist/spend/reason.mjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What each reason a route test gives means to a person, in the words the website uses for
|
|
3
|
-
* the same codes. This copies `reasonInWords` from `web/lib/route-reason.ts`, which the CLI
|
|
4
|
-
* can't import because that file only runs on the server. When the website's words change, change these.
|
|
5
|
-
*/
|
|
6
|
-
const PHANTOM_1_WORDS = {
|
|
7
|
-
session: 'continuing with the same model',
|
|
8
|
-
escalated: 'you asked for a stronger model',
|
|
9
|
-
'free-pool': 'free model',
|
|
10
|
-
'rules:only_option': 'the only model that fits',
|
|
11
|
-
'rules:contest_programming': 'contest programming problem',
|
|
12
|
-
'rules:contest_math': 'competition math problem',
|
|
13
|
-
'rules:concurrency_debugging': 'concurrency bug',
|
|
14
|
-
'rules:complex_reasoning': 'needs careful reasoning',
|
|
15
|
-
'rules:large_prompt': 'long prompt',
|
|
16
|
-
'rules:routine_formatting': 'routine text work',
|
|
17
|
-
'rules:default': 'typical coding step',
|
|
18
|
-
images: 'the request includes an image',
|
|
19
|
-
'too-large': 'the conversation is long, so moving up would cost a lot',
|
|
20
|
-
'said-failed': "you said the last try didn't work",
|
|
21
|
-
'agent-failed': "the agent said its last try didn't work",
|
|
22
|
-
helper: "a helper agent's side job",
|
|
23
|
-
'switchyard:fall_open': 'no sign it needs Frontier',
|
|
24
|
-
'switchyard:ambiguous': 'no clear sign it needs Frontier',
|
|
25
|
-
'switchyard:dimensions': 'based on the last few steps',
|
|
26
|
-
'switchyard:override': 'recovering from an error',
|
|
27
|
-
'switchyard:capable_hold': 'still recovering from an error',
|
|
28
|
-
'switchyard:efficient_hold': 'the work is going smoothly',
|
|
29
|
-
'switchyard:only-fit': 'the only model that fits',
|
|
30
|
-
'switchyard:unavailable': 'the strongest model, to be safe',
|
|
31
|
-
};
|
|
32
|
-
/** The reasons a key's own route policy gives, in words. */
|
|
33
|
-
const POLICY_WORDS = {
|
|
34
|
-
default: "the key's first model",
|
|
35
|
-
requested: 'you named this model',
|
|
36
|
-
cache: 'continuing the conversation on its model',
|
|
37
|
-
on_empty: 'the cap is used up, so the cheapest model',
|
|
38
|
-
budget_exceeded: 'the cap is used up',
|
|
39
|
-
};
|
|
40
|
-
/** A key's own rule as the server writes it: `has_tools:true`. */
|
|
41
|
-
const RULE_REASON = /^(pace|budget_left_pct_below|days_left_below|has_tools|input_tokens_over|reasoning_requested):(.*)$/;
|
|
42
|
-
/**
|
|
43
|
-
* Why a model ran, in plain words. A reason the CLI does not know reads "picked for the task",
|
|
44
|
-
* so a code never shows raw.
|
|
45
|
-
*/
|
|
46
|
-
export function reasonInWords(reason) {
|
|
47
|
-
const known = PHANTOM_1_WORDS[reason] ?? POLICY_WORDS[reason];
|
|
48
|
-
if (known)
|
|
49
|
-
return known;
|
|
50
|
-
const rule = RULE_REASON.exec(reason);
|
|
51
|
-
if (rule)
|
|
52
|
-
return `your rule ${rule[1]} = ${rule[2]}`;
|
|
53
|
-
if (reason.endsWith(':frontier'))
|
|
54
|
-
return 'hard task';
|
|
55
|
-
if (reason.endsWith(':free'))
|
|
56
|
-
return 'easy step';
|
|
57
|
-
if (reason.endsWith(':cheap') || reason.endsWith(':standard'))
|
|
58
|
-
return 'typical coding step';
|
|
59
|
-
return reason.startsWith('rules:') ? 'picked by phantom-1' : 'picked for the task';
|
|
60
|
-
}
|
package/dist/spend/report.d.mts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { type CommandInput } from '../core/helpers.mts';
|
|
2
|
-
/** One key or model's calls and cost. */
|
|
3
|
-
export type SpendLine = {
|
|
4
|
-
/** Calls, free ones included. */
|
|
5
|
-
calls: number;
|
|
6
|
-
/** What they cost, in US dollars. */
|
|
7
|
-
spent_usd: number;
|
|
8
|
-
};
|
|
9
|
-
/** Everything a spend report covers. */
|
|
10
|
-
export type SpendTotal = SpendLine & {
|
|
11
|
-
/** Prompt tokens, cached ones included. */
|
|
12
|
-
prompt_tokens: number;
|
|
13
|
-
/** Completion tokens. */
|
|
14
|
-
completion_tokens: number;
|
|
15
|
-
};
|
|
16
|
-
/** One model a key ran. */
|
|
17
|
-
export type SpendKeyModel = SpendLine & {
|
|
18
|
-
/** The model that ran. */
|
|
19
|
-
model: string;
|
|
20
|
-
};
|
|
21
|
-
/** One key's spend. */
|
|
22
|
-
export type SpendKey = SpendLine & {
|
|
23
|
-
/** The name the workspace gave the key, or `This key`. */
|
|
24
|
-
name: string;
|
|
25
|
-
/** The key's first characters, only in a workspace report; null otherwise. */
|
|
26
|
-
prefix: string | null;
|
|
27
|
-
/** False once the key was revoked or rotated away. */
|
|
28
|
-
active: boolean;
|
|
29
|
-
/** What phantom-1 saved on this key's calls, in US dollars; null when it can't be worked out. */
|
|
30
|
-
saved_usd: number | null;
|
|
31
|
-
/** The models the key ran, biggest spender first. */
|
|
32
|
-
models: SpendKeyModel[];
|
|
33
|
-
};
|
|
34
|
-
/** One model's spend across the keys in the report. */
|
|
35
|
-
export type SpendModel = SpendLine & {
|
|
36
|
-
/** The model that ran. */
|
|
37
|
-
model: string;
|
|
38
|
-
/** Prompt tokens. */
|
|
39
|
-
prompt_tokens: number;
|
|
40
|
-
/** Completion tokens. */
|
|
41
|
-
completion_tokens: number;
|
|
42
|
-
};
|
|
43
|
-
/** One UTC day's spend. */
|
|
44
|
-
export type SpendDay = SpendLine & {
|
|
45
|
-
/** The day, `YYYY-MM-DD`, UTC. */
|
|
46
|
-
date: string;
|
|
47
|
-
};
|
|
48
|
-
/** What phantom-1 routing saved: a figure, or the reason there is none. */
|
|
49
|
-
export type SpendRouting = {
|
|
50
|
-
/** True when the figures below are given. */
|
|
51
|
-
available: true;
|
|
52
|
-
/** Calls sent to a phantom-1 router. */
|
|
53
|
-
calls: number;
|
|
54
|
-
/** What those calls cost, in US dollars. */
|
|
55
|
-
spent_usd: number;
|
|
56
|
-
/** The model the same calls are priced on. */
|
|
57
|
-
baseline_model: string;
|
|
58
|
-
/** What the same calls would have cost on it, in US dollars. */
|
|
59
|
-
baseline_usd: number;
|
|
60
|
-
/** `baseline_usd` less `spent_usd`. */
|
|
61
|
-
saved_usd: number;
|
|
62
|
-
/** How `baseline_usd` is worked out, in words. */
|
|
63
|
-
basis: string;
|
|
64
|
-
} | {
|
|
65
|
-
/** False when the frontier model's price isn't listed. */
|
|
66
|
-
available: false;
|
|
67
|
-
/** Why there is no figure. */
|
|
68
|
-
reason: string;
|
|
69
|
-
};
|
|
70
|
-
/** The answer from `/key/spend` and `/workspaces/{id}/spend`. */
|
|
71
|
-
export type SpendResult = {
|
|
72
|
-
/** `key` for the calling key alone, `workspace` for every key in it. */
|
|
73
|
-
scope: 'key' | 'workspace';
|
|
74
|
-
/** First day, UTC, inclusive. */
|
|
75
|
-
from: string;
|
|
76
|
-
/** Last day, UTC, inclusive. */
|
|
77
|
-
to: string;
|
|
78
|
-
/** Everything in the range. */
|
|
79
|
-
total: SpendTotal;
|
|
80
|
-
/** Each key by name, biggest spender first. */
|
|
81
|
-
keys: SpendKey[];
|
|
82
|
-
/** Each model that ran, biggest spender first. */
|
|
83
|
-
models: SpendModel[];
|
|
84
|
-
/** Every day in the range, oldest first. */
|
|
85
|
-
days: SpendDay[];
|
|
86
|
-
/** What phantom-1 routing saved. */
|
|
87
|
-
routing: SpendRouting;
|
|
88
|
-
};
|
|
89
|
-
/** The `--from` and `--to` values, as parseFlags read them. */
|
|
90
|
-
export type SpendDates = {
|
|
91
|
-
/** The `--from` value. */
|
|
92
|
-
from?: string | true;
|
|
93
|
-
/** The `--to` value. */
|
|
94
|
-
to?: string | true;
|
|
95
|
-
};
|
|
96
|
-
/** What the key spent (GET /key/spend). */
|
|
97
|
-
export declare function getSpend(apiKey: string, dates?: SpendDates, baseUrl?: string): Promise<SpendResult>;
|
|
98
|
-
/** `--table` output for `spend`. */
|
|
99
|
-
export declare function tableSpend(d: unknown): string;
|
|
100
|
-
/**
|
|
101
|
-
* `phantom spend`: what the key spent, by model and day, and what phantom-1
|
|
102
|
-
* saved. `--workspace` shows every key in the workspace by name, with the
|
|
103
|
-
* workspace connection `phantom login` saved. Run by `run()`.
|
|
104
|
-
*/
|
|
105
|
-
export declare function spendCommand(input: CommandInput): Promise<number>;
|