@phantomcodes/cli 1.4.1 → 1.4.3

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.
Files changed (69) hide show
  1. package/README.md +99 -133
  2. package/dist/agents/command.d.mts +36 -0
  3. package/dist/agents/command.mjs +22 -10
  4. package/dist/agents/proxy.d.mts +44 -0
  5. package/dist/agents/proxy.mjs +4 -2
  6. package/dist/cli/app.d.mts +25 -0
  7. package/dist/cli/app.mjs +2 -2
  8. package/dist/cli/commands.d.mts +23 -0
  9. package/dist/cli/commands.mjs +106 -54
  10. package/dist/cli/help.d.mts +26 -0
  11. package/dist/cli/help.mjs +10 -6
  12. package/dist/cli/run.d.mts +2 -0
  13. package/dist/cli/screens.d.mts +171 -0
  14. package/dist/cli/screens.mjs +3 -3
  15. package/dist/cli/start.d.mts +34 -0
  16. package/dist/core/brand.d.mts +12 -0
  17. package/dist/core/errors.d.mts +27 -0
  18. package/dist/core/free.d.mts +13 -0
  19. package/dist/core/helpers.d.mts +75 -0
  20. package/dist/core/helpers.mjs +27 -2
  21. package/dist/core/motion.d.mts +47 -0
  22. package/dist/core/node-trust.d.mts +12 -0
  23. package/dist/core/pick.d.mts +86 -0
  24. package/dist/core/request.d.mts +64 -0
  25. package/dist/core/request.mjs +78 -29
  26. package/dist/core/secrets.d.mts +33 -0
  27. package/dist/core/shapes.d.mts +13 -0
  28. package/dist/core/state.d.mts +3 -0
  29. package/dist/core/style.d.mts +49 -0
  30. package/dist/core/version.d.mts +2 -0
  31. package/dist/core/version.mjs +1 -1
  32. package/dist/keys/command.d.mts +16 -0
  33. package/dist/keys/saved.d.mts +90 -0
  34. package/dist/keys/saved.mjs +6 -2
  35. package/dist/models/choice.d.mts +7 -0
  36. package/dist/models/choice.mjs +1 -1
  37. package/dist/models/command.d.mts +8 -0
  38. package/dist/models/list.d.mts +39 -0
  39. package/dist/phantom.d.mts +45 -0
  40. package/dist/receipts/command.d.mts +7 -0
  41. package/dist/receipts/receipts.d.mts +67 -0
  42. package/dist/receipts/receipts.mjs +15 -11
  43. package/dist/setup/agents.d.mts +149 -0
  44. package/dist/setup/agents.mjs +50 -37
  45. package/dist/setup/apply.d.mts +71 -0
  46. package/dist/setup/apply.mjs +7 -2
  47. package/dist/setup/command.d.mts +12 -0
  48. package/dist/setup/command.mjs +32 -5
  49. package/dist/setup/editors.d.mts +101 -0
  50. package/dist/setup/editors.mjs +6 -4
  51. package/dist/setup/legacy.d.mts +13 -0
  52. package/dist/setup/plan.d.mts +104 -0
  53. package/dist/setup/plan.mjs +5 -3
  54. package/dist/setup/screen.d.mts +30 -0
  55. package/dist/setup/screen.mjs +2 -2
  56. package/dist/setup/shared.d.mts +141 -0
  57. package/dist/setup/shared.mjs +8 -2
  58. package/dist/setup/was.d.mts +42 -0
  59. package/dist/setup/was.mjs +91 -0
  60. package/dist/spend/command.d.mts +5 -0
  61. package/dist/spend/lineup.d.mts +54 -0
  62. package/dist/spend/lineup.mjs +3 -2
  63. package/dist/spend/report.d.mts +105 -0
  64. package/dist/spend/report.mjs +2 -2
  65. package/dist/spend/routing.d.mts +72 -0
  66. package/dist/workspace/command.d.mts +59 -0
  67. package/dist/workspace/command.mjs +106 -52
  68. package/package.json +7 -7
  69. package/skills/phantom-ai/SKILL.md +40 -66
@@ -0,0 +1,90 @@
1
+ import { type Env } from '../core/state.mts';
2
+ export declare function keyPath(env: Env): string;
3
+ export declare function namedKeyPath(env: Env, name: string): string;
4
+ /** A key's whole SHA-256 hash: the id the workspace routes name a key by (`hashKey` in web/lib/crypto.ts). */
5
+ export declare function keyHash(key: string): string;
6
+ /** A key's id: the start of its SHA-256 hash, safe to print. */
7
+ export declare function keyId(key: string): string;
8
+ /** Where the key a command runs as comes from. */
9
+ export type KeySource = {
10
+ /** PHANTOM_API_KEY. */
11
+ from: 'env';
12
+ } | {
13
+ /** A key saved by name, chosen with PHANTOM_KEY_NAME. */
14
+ from: 'named';
15
+ /** The saved key's name. */
16
+ name: string;
17
+ } | {
18
+ /** The default key, saved by `phantom keys create` or `phantom keys save default`. */
19
+ from: 'login';
20
+ } | {
21
+ /** No key at all. */
22
+ from: 'none';
23
+ };
24
+ /**
25
+ * Which key a command runs as: the saved key named by PHANTOM_KEY_NAME, then
26
+ * PHANTOM_API_KEY, then the default key. It only looks; {@link resolveApiKey}
27
+ * reads the key.
28
+ */
29
+ export declare function keySource(env: Env): KeySource;
30
+ /** The key a command runs as, chosen by {@link keySource}. An empty string when there is none. */
31
+ export declare function resolveApiKey(env: Env): string;
32
+ /**
33
+ * A key saved by name.
34
+ * @throws {@link CliError} when no key has that name, or the name is not valid.
35
+ */
36
+ export declare function readNamedKey(env: Env, name: string): string;
37
+ /**
38
+ * Saves a key by name, in the Keychain or a mode 600 file (see {@link keychain}).
39
+ * Refuses a name already in use unless `replace` is set, and anything that
40
+ * doesn't start with `sk-phantom-`.
41
+ * @returns The name, and the key's {@link keyId}.
42
+ */
43
+ export declare function saveNamedKey(env: Env, name: string, key: string, opts?: {
44
+ replace?: boolean;
45
+ }): {
46
+ /** The name the key was saved under. */
47
+ name: string;
48
+ /** The key's id, as {@link keyId} computes it. */
49
+ id: string;
50
+ };
51
+ /** Forgets a saved key. The key itself keeps working. */
52
+ export declare function removeNamedKey(env: Env, name: string): {
53
+ /** The name asked for. */
54
+ name: string;
55
+ /** False when no key was saved under that name. */
56
+ removed: boolean;
57
+ };
58
+ /** Every key saved by name, sorted, with its id. Never returns the keys. */
59
+ export declare function listNamedKeys(env: Env): {
60
+ /** One entry per saved key. */
61
+ keys: Array<{
62
+ /** The saved name. */
63
+ name: string;
64
+ /** The key's id, as {@link keyId} computes it. */
65
+ id: string;
66
+ }>;
67
+ };
68
+ /** The default key, the one `phantom keys create` saves when no name is given, or null when none is saved. */
69
+ export declare function defaultKey(env: Env): string | null;
70
+ /** Saves the default key, the one used when neither PHANTOM_KEY_NAME nor PHANTOM_API_KEY is set. */
71
+ export declare function saveApiKey(env: Env, key: string): {
72
+ /** The path of the file that holds the key or its Keychain pointer. */
73
+ saved: string;
74
+ };
75
+ /** Forgets the default key. */
76
+ export declare function removeApiKey(env: Env): {
77
+ /** False when no default key was saved. */
78
+ removed: boolean;
79
+ };
80
+ /**
81
+ * Where a new key will be saved: the name in `save` (`--save`), or `default`.
82
+ * Run it before anything is asked for: it refuses a name already in use and,
83
+ * with no name, a default key that is saved already.
84
+ * @throws {@link CliError} `key_exists`, or `cli_error` for `--save` with no name.
85
+ */
86
+ export declare function saveTarget(env: Env, save: string | true | undefined): string;
87
+ /** Saves a key under a {@link saveTarget}: `default`, or a name. */
88
+ export declare function saveKeyAs(env: Env, target: string, key: string): void;
89
+ /** Forgets a key saved under a {@link saveTarget}. */
90
+ export declare function forgetKeyAs(env: Env, target: string): void;
@@ -25,9 +25,13 @@ export function namedKeyPath(env, name) {
25
25
  die(`Key names use letters, numbers, - and _ (up to 32): ${name}`);
26
26
  return path.join(stateDir(env), 'keys', name);
27
27
  }
28
+ /** A key's whole SHA-256 hash: the id the workspace routes name a key by (`hashKey` in web/lib/crypto.ts). */
29
+ export function keyHash(key) {
30
+ return createHash('sha256').update(key.trim()).digest('hex');
31
+ }
28
32
  /** A key's id: the start of its SHA-256 hash, safe to print. */
29
33
  export function keyId(key) {
30
- return createHash('sha256').update(key.trim()).digest('hex').slice(0, 12);
34
+ return keyHash(key).slice(0, 12);
31
35
  }
32
36
  /**
33
37
  * Which key a command runs as: the saved key named by PHANTOM_KEY_NAME, then
@@ -68,7 +72,7 @@ function writeKeyFile(env, file, key) {
68
72
  export function readNamedKey(env, name) {
69
73
  const file = namedKeyPath(env, name);
70
74
  if (!existsSync(file))
71
- die(`No saved key named ${name}. See: phantom key list`);
75
+ die(`No saved key named ${name}. See the saved keys with phantom keys saved.`);
72
76
  return readSecret(env, file).trim();
73
77
  }
74
78
  /**
@@ -0,0 +1,7 @@
1
+ import { type Env } from '../core/state.mts';
2
+ /** The model you picked with `phantom models`, or undefined when you never picked one. */
3
+ export declare function savedModel(env: Env): string | undefined;
4
+ /** Saves the model your agents start on. */
5
+ export declare function saveModel(env: Env, id: string): void;
6
+ /** The model agents start on: the one you picked, or phantom-1. */
7
+ export declare function startModel(env: Env): string;
@@ -18,7 +18,7 @@ export function savedModel(env) {
18
18
  }
19
19
  /** Saves the model your agents start on. */
20
20
  export function saveModel(env, id) {
21
- mkdirSync(stateDir(env), { recursive: true });
21
+ mkdirSync(stateDir(env), { recursive: true, mode: 0o700 });
22
22
  writeFileSync(choiceFile(env), `${id}\n`);
23
23
  }
24
24
  /** The model agents start on: the one you picked, or phantom-1. */
@@ -0,0 +1,8 @@
1
+ import { type CommandInput } from '../core/helpers.mts';
2
+ /**
3
+ * `phantom models`: phantom-1, phantom-1:free and phantom-1:zdr side by side,
4
+ * with the jobs each can do and the model behind each job. At a terminal you
5
+ * pick one, and your agents start on it (`./choice.mts`).
6
+ * `phantom models use <id>` picks without the menu.
7
+ */
8
+ export declare function modelsCommand(input: CommandInput): Promise<number>;
@@ -0,0 +1,39 @@
1
+ /** Each job a model can do, with its name on screen, in the order the table lists them. */
2
+ export declare const JOBS: readonly [readonly ["chat", "Chat"], readonly ["vision", "Images in"], readonly ["embedding", "Embeddings"], readonly ["rerank", "Rerank"], readonly ["image", "Make images"], readonly ["video", "Make video"], readonly ["speech", "Text to speech"], readonly ["transcription", "Speech to text"]];
3
+ /** One of {@link JOBS}. */
4
+ export type Job = (typeof JOBS)[number][0];
5
+ /** One chat model a Phantom model picks between. */
6
+ export type ChatModel = {
7
+ /** Model id. */
8
+ id: string;
9
+ /** economy, standard or frontier. */
10
+ tier: string;
11
+ /** True when it costs $0. */
12
+ free: boolean;
13
+ };
14
+ /** One of Phantom's own models, as `phantom models` shows it. */
15
+ export type PhantomModel = {
16
+ /** The name an agent sends, such as phantom-1:zdr. */
17
+ id: string;
18
+ /** Display name. */
19
+ name: string;
20
+ /** What it does, from the server. */
21
+ description: string;
22
+ /** The chat models it picks between, in order. */
23
+ chat: ChatModel[];
24
+ /** The model that runs each job other than chat. Images in can run on the chat models, so it may be missing here and still be in `can`. */
25
+ jobs: Partial<Record<Job, string>>;
26
+ /** Every job it can do. */
27
+ can: Job[];
28
+ };
29
+ /** What `phantom models` prints: every model, and the one your agents start on. */
30
+ export type ModelsView = {
31
+ models: PhantomModel[];
32
+ using: string;
33
+ };
34
+ /**
35
+ * Phantom's own models from the server. /v1/routers names each one's chat
36
+ * models and the model behind every other job; /v1/models says whether it
37
+ * takes images. Neither needs a key.
38
+ */
39
+ export declare function getModels(baseUrl?: string, apiKey?: string): Promise<PhantomModel[]>;
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * phantom: points your coding agents at Phantom AI.
4
+ *
5
+ * Keys, money and setup for any AI agent: a Phantom AI key, model routing,
6
+ * and receipts that show which model answered. It runs as a CLI and through
7
+ * the phantom-ai skill, so pi, Claude Code, Codex and Cursor can all drive it
8
+ * by prompt.
9
+ *
10
+ * This file is the entry point. The code lives in one folder per feature
11
+ * beside it, and this file exports the public API from them. From a
12
+ * checkout: `node src/phantom.mts`.
13
+ */
14
+ export { DEFAULT_BASE_URL, REQUEST_TIMEOUT_MS, request, httpsOnly, getBalance } from './core/request.mts';
15
+ export { VERSION } from './core/version.mts';
16
+ export { PhantomApiError, CliError, die } from './core/errors.mts';
17
+ export type { BalanceResult } from './core/shapes.mts';
18
+ export { getLineup, putLineup, resetLineup, LINEUP_TIERS } from './spend/lineup.mts';
19
+ export type { Lineup, LineupPicks, LineupTier, LineupChoice, LineupTierModel, LineupResult } from './spend/lineup.mts';
20
+ export { getRoute, putRoute, patchRoute, clearRoute, testRoute, parseCondition } from './spend/routing.mts';
21
+ export type { RouteRule, RoutePolicy, RouteResult, RouteTestResult } from './spend/routing.mts';
22
+ export { getSpend, tableSpend } from './spend/report.mts';
23
+ export type { SpendResult, SpendLine, SpendTotal, SpendKey, SpendKeyModel, SpendModel, SpendDay, SpendRouting, SpendDates } from './spend/report.mts';
24
+ export { checkReceipt, modelsMatch, verifyModel } from './receipts/receipts.mts';
25
+ export type { Receipt, ReceiptCheck, VerifyModelResult } from './receipts/receipts.mts';
26
+ export type { Env } from './core/state.mts';
27
+ export { keychain } from './core/secrets.mts';
28
+ export { keyId, keySource, resolveApiKey, readNamedKey, saveNamedKey, removeNamedKey, listNamedKeys, saveApiKey, removeApiKey } from './keys/saved.mts';
29
+ export type { KeySource } from './keys/saved.mts';
30
+ export { SETUP_MODEL, agentBaseUrl } from './setup/shared.mts';
31
+ export type { SetupAgent, AgentPath, ProviderResult } from './setup/shared.mts';
32
+ export { planSetup } from './setup/plan.mts';
33
+ export type { SetupFile, SetupPlan, SetupResult, SetupOptions } from './setup/plan.mts';
34
+ export { applySetup, previewSetup, setupAgents, restoreSetup } from './setup/apply.mts';
35
+ export type { RestoreResult } from './setup/apply.mts';
36
+ export type { SetupContext, SetupEdit, ProviderPlan, SetupAgentSpec } from './setup/shared.mts';
37
+ export { jsonEdit, tomlSet, tomlRemoveOurs, yamlSetTop, yamlAddModel, yamlRemoveOurs, shellRcFile, shellBlock } from './setup/editors.mts';
38
+ export type { JsonChange, ShellBlockState } from './setup/editors.mts';
39
+ export { SETUP_AGENTS } from './setup/agents.mts';
40
+ export { claudeProvider } from './setup/apply.mts';
41
+ export { ENV_VARS, HELP } from './cli/help.mts';
42
+ export type { EnvVar } from './cli/help.mts';
43
+ export { run } from './cli/run.mts';
44
+ /** The installed entry point: {@link run} with the process's arguments, then `process.exit` with its code when it is not 0. */
45
+ export declare function main(): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import { type CommandInput } from '../core/helpers.mts';
2
+ /** `--table` output for `verify --model`. */
3
+ export declare function tableVerifyModel(d: unknown): string;
4
+ /** `--table` output for `verify --receipt`. */
5
+ export declare function tableReceiptCheck(d: unknown): string;
6
+ /** `phantom verify`: checks a receipt, or makes one small call and checks its receipt. Run by `run()`. */
7
+ export declare function verifyCommand({ io, apiKey, flags, table, baseUrl }: CommandInput): Promise<number>;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * The signed content of a receipt. phantom reads the fields listed here; the
3
+ * server signs more (such as hashes of the request and response), and they
4
+ * pass through untouched.
5
+ */
6
+ export type Receipt = {
7
+ /** The receipt format version. {@link checkReceipt} accepts only version 1. */
8
+ v: number;
9
+ /** Phantom AI's id for the call. */
10
+ request_id: string;
11
+ /** When the receipt was signed, as an ISO 8601 time. */
12
+ ts: string;
13
+ /** The model id the call asked for. */
14
+ model_requested: string;
15
+ /** The model id the upstream's own response named. */
16
+ model_served: string;
17
+ /** Tokens in the prompt. */
18
+ prompt_tokens: number;
19
+ /** Tokens in the answer. */
20
+ completion_tokens: number;
21
+ /** Reasoning tokens in the answer. 0 when there were none. */
22
+ reasoning_tokens: number;
23
+ /** What the call cost, in millionths of a US dollar. */
24
+ cost_micro_usd: number;
25
+ /** Other signed fields. */
26
+ [field: string]: unknown;
27
+ };
28
+ /** The result of checking a receipt with {@link checkReceipt}. */
29
+ export type ReceiptCheck = {
30
+ /** True when the signature matches Phantom AI's published key. */
31
+ valid: boolean;
32
+ /** The decoded receipt, or null when it could not be read. */
33
+ receipt: Receipt | null;
34
+ /** Why the check failed. Absent when it passed. */
35
+ reason?: string;
36
+ };
37
+ /** The result of {@link verifyModel}. */
38
+ export type VerifyModelResult = {
39
+ /** The model id phantom asked for. */
40
+ model_requested: string;
41
+ /** The model the receipt says answered. null when there was no readable receipt. */
42
+ model_served: string | null;
43
+ /** True when the signature is valid and the served model matches the one asked for ({@link modelsMatch}). */
44
+ match: boolean;
45
+ /** True when the receipt's signature matches Phantom AI's published key. */
46
+ signature_valid: boolean;
47
+ /** What the call cost, in USD. null without a receipt. */
48
+ cost_usd: number | null;
49
+ /** Phantom AI's id for the call. null without a receipt. */
50
+ request_id: string | null;
51
+ /** The compact receipt from the x-phantom-receipt header. null when the answer had none. */
52
+ receipt: string | null;
53
+ /** Why it did not match or could not be checked. Absent when all is well. */
54
+ reason?: string;
55
+ };
56
+ /**
57
+ * Checks a compact receipt (`payload.signature`, both base64url) against the
58
+ * public key from GET /receipts/key. Needs no API key.
59
+ * @param timeoutMs How long to wait for the key. Defaults to {@link REQUEST_TIMEOUT_MS}.
60
+ * @throws {@link PhantomApiError} when the public key cannot be fetched.
61
+ * @throws {@link CliError} `request_timeout` when the server does not answer in time, `bad_answer` when it sends a web page.
62
+ */
63
+ export declare function checkReceipt(compact: string, baseUrl?: string, timeoutMs?: number): Promise<ReceiptCheck>;
64
+ /** The served id can drop the provider prefix, so a bare name counts as a match. */
65
+ export declare function modelsMatch(requested: string, served: string): boolean;
66
+ /** One small priced call to `model`, then a check of the receipt it returns. */
67
+ export declare function verifyModel(apiKey: string, model: string, baseUrl?: string, timeoutMs?: number): Promise<VerifyModelResult>;
@@ -1,5 +1,6 @@
1
1
  import { createPublicKey, verify as cryptoVerify } from 'node:crypto';
2
- import { apiBase, apiError } from "../core/request.mjs";
2
+ import { die } from "../core/errors.mjs";
3
+ import { REQUEST_TIMEOUT_MS, answerError, apiBase, fetchAnswer } from "../core/request.mjs";
3
4
  /**
4
5
  * Every priced call returns a receipt signed with Phantom AI's Ed25519 key. The
5
6
  * check runs here, against the public key from /receipts/key, so the answer
@@ -10,13 +11,17 @@ const RECEIPT_VERSION = 1;
10
11
  /**
11
12
  * Checks a compact receipt (`payload.signature`, both base64url) against the
12
13
  * public key from GET /receipts/key. Needs no API key.
14
+ * @param timeoutMs How long to wait for the key. Defaults to {@link REQUEST_TIMEOUT_MS}.
13
15
  * @throws {@link PhantomApiError} when the public key cannot be fetched.
16
+ * @throws {@link CliError} `request_timeout` when the server does not answer in time, `bad_answer` when it sends a web page.
14
17
  */
15
- export async function checkReceipt(compact, baseUrl) {
16
- const res = await fetch(`${apiBase(baseUrl)}/receipts/key`);
17
- const json = (await res.json().catch(() => ({})));
18
+ export async function checkReceipt(compact, baseUrl, timeoutMs = REQUEST_TIMEOUT_MS) {
19
+ const { res, answer } = await fetchAnswer(`${apiBase(baseUrl)}/receipts/key`, {}, 'GET /receipts/key', timeoutMs);
18
20
  if (!res.ok)
19
- throw apiError(res.status, json);
21
+ throw answerError(res.status, answer);
22
+ if (answer.kind === 'text')
23
+ die('Phantom AI sent a web page instead of its receipt key. Check PHANTOM_BASE_URL, and try again in a minute.', 'bad_answer');
24
+ const json = answer.json;
20
25
  if (!json.signs || !json.public_key_jwk) {
21
26
  return { valid: false, receipt: null, reason: 'This deployment signs no receipts' };
22
27
  }
@@ -45,15 +50,14 @@ export function modelsMatch(requested, served) {
45
50
  return requested.toLowerCase() === served.toLowerCase() || bare(requested) === bare(served);
46
51
  }
47
52
  /** One small priced call to `model`, then a check of the receipt it returns. */
48
- export async function verifyModel(apiKey, model, baseUrl) {
49
- const res = await fetch(`${apiBase(baseUrl)}/chat/completions`, {
53
+ export async function verifyModel(apiKey, model, baseUrl, timeoutMs = REQUEST_TIMEOUT_MS) {
54
+ const { res, answer } = await fetchAnswer(`${apiBase(baseUrl)}/chat/completions`, {
50
55
  method: 'POST',
51
56
  headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
52
57
  body: JSON.stringify({ model, max_tokens: 16, messages: [{ role: 'user', content: 'Reply with ok.' }] }),
53
- });
54
- const json = await res.json().catch(() => ({}));
58
+ }, 'POST /chat/completions', timeoutMs);
55
59
  if (!res.ok)
56
- throw apiError(res.status, json);
60
+ throw answerError(res.status, answer);
57
61
  const compact = res.headers.get('x-phantom-receipt');
58
62
  if (!compact) {
59
63
  return {
@@ -67,7 +71,7 @@ export async function verifyModel(apiKey, model, baseUrl) {
67
71
  reason: 'The response carried no receipt',
68
72
  };
69
73
  }
70
- const check = await checkReceipt(compact, baseUrl);
74
+ const check = await checkReceipt(compact, baseUrl, timeoutMs);
71
75
  const r = check.receipt;
72
76
  return {
73
77
  model_requested: model,
@@ -0,0 +1,149 @@
1
+ import type { Env } from '../core/state.mts';
2
+ import { type SetupAgent, type SetupAgentSpec, type SetupContext, type ProviderPlan } from './shared.mts';
3
+ /** An agent whose model settings live on its own settings screen: setup prints the steps. */
4
+ export declare function manualProvider(where: string, steps: (ctx: SetupContext) => string[], note?: string): NonNullable<SetupAgentSpec['provider']>;
5
+ /** Codex's folder: `$CODEX_HOME`, else `~/.codex`. */
6
+ export declare function codexDir(env: Env, home: string): string;
7
+ /**
8
+ * Codex: `config.toml` in Codex's folder gets a `phantom` model provider at
9
+ * `/codex/v1` that reads the key from PHANTOM_API_KEY (as Vercel's writes a
10
+ * `vercel` provider with `env_key`). phantom also writes the model, and Phantom
11
+ * AI's model list at `/codex/v1/models`, which Codex 0.156 reads only with
12
+ * `[features] api_key_model_discovery`.
13
+ */
14
+ export declare function codexProvider(ctx: SetupContext, off: boolean): ProviderPlan;
15
+ /** Claude Code's folder: `$CLAUDE_CONFIG_DIR`, else `~/.claude`. */
16
+ export declare function claudeDir(env: Env, home: string): string;
17
+ /** The plan behind {@link claudeProvider}. */
18
+ export declare function claudePlan(env: Env, opts: {
19
+ off?: boolean;
20
+ model?: string;
21
+ onPath?: (bin: string) => boolean;
22
+ }): ProviderPlan;
23
+ /** GitHub Copilot CLI's folder: `$COPILOT_HOME`, else `~/.copilot`. */
24
+ export declare function copilotDir(env: Env, home: string): string;
25
+ /** GitHub Copilot CLI: set up by the shell block alone, as Vercel's setup does. Its variables are in {@link SetupAgentSpec.shellEnv}. */
26
+ export declare function copilotProvider(ctx: SetupContext, off: boolean): ProviderPlan;
27
+ /** opencode's config file: `opencode.json` (or `.jsonc`) in `$XDG_CONFIG_HOME/opencode`, else `~/.config/opencode`. */
28
+ export declare function opencodeFile(env: Env, home: string): string;
29
+ /**
30
+ * opencode: a `phantom` provider at `/coding-agent/v1` whose key is
31
+ * `{env:PHANTOM_API_KEY}`. Like Vercel's setup, it pins no model unless
32
+ * `--model` asks; pick `phantom/<model>` in opencode.
33
+ */
34
+ export declare function opencodeProvider(ctx: SetupContext, off: boolean): ProviderPlan;
35
+ /**
36
+ * Continue: `~/.continue/config.yaml` gets a model at `/coding-agent/v1`,
37
+ * first in `models:` so the `cn` CLI starts with it, with the key from
38
+ * `${{ secrets.PHANTOM_API_KEY }}`. Like Vercel's setup it also writes
39
+ * `.onboarding_complete` beside it, so `cn`'s first-run questions don't
40
+ * replace the list.
41
+ */
42
+ export declare function continueProvider(ctx: SetupContext, off: boolean): ProviderPlan;
43
+ /**
44
+ * Goose, as Vercel's setup does it: a custom provider file,
45
+ * `custom_providers/custom_phantom.json` in Goose's folder, at
46
+ * `/coding-agent/v1/chat/completions` with the key from PHANTOM_API_KEY, and
47
+ * GOOSE_PROVIDER and GOOSE_MODEL in Goose's `config.yaml`, which the desktop
48
+ * app reads too.
49
+ */
50
+ export declare function gooseProvider(ctx: SetupContext, off: boolean): ProviderPlan;
51
+ /**
52
+ * Aider, as Vercel's setup does it: `~/.aider.conf.yml` gets
53
+ * `openai-api-base` at `/coding-agent/v1` and the model as `openai/<model>`,
54
+ * `~/.aider.model.metadata.json` and `~/.aider.model.settings.yml` tell Aider
55
+ * the model's context window and edit format, and the key comes from
56
+ * AIDER_OPENAI_API_KEY in the shell block.
57
+ */
58
+ export declare function aiderProvider(ctx: SetupContext, off: boolean): ProviderPlan;
59
+ /**
60
+ * Cline, as Vercel's setup does it: `~/.cline/data/settings/providers.json`
61
+ * (mode 600), which Cline's CLI and editor extension share, gets an OpenAI
62
+ * Compatible provider at `/coding-agent/v1` and is made the one Cline uses.
63
+ * Cline reads its key only from this file, with no variable or command to
64
+ * point it at, so this is the one config phantom writes the key into. After
65
+ * `phantom keys rotate`, run setup again to update it.
66
+ */
67
+ export declare function clineProvider(ctx: SetupContext, off: boolean): ProviderPlan;
68
+ /** Gemini CLI's folder: `.gemini` in `$GEMINI_CLI_HOME`, else in the home folder. */
69
+ export declare function geminiDir(env: Env, home: string): string;
70
+ /**
71
+ * Gemini CLI speaks Google's API, which Phantom AI serves at `/gemini-cli`.
72
+ * The shell block sets GOOGLE_GEMINI_BASE_URL to it and GEMINI_API_KEY to
73
+ * the Phantom key; `settings.json` in Gemini CLI's folder picks API key
74
+ * sign-in (`security.auth.selectedType`) and the model (`model.name`).
75
+ * `--provider off` takes out a phantom model; the sign-in choice stays, and
76
+ * `phantom setup --restore` puts the file back as it was.
77
+ */
78
+ export declare function geminiProvider(ctx: SetupContext, off: boolean): ProviderPlan;
79
+ /** Crush's config folder: `$CRUSH_GLOBAL_CONFIG`, else `crush` in the config folder. */
80
+ export declare function crushDir(env: Env, home: string): string;
81
+ /**
82
+ * Crush: `crush.json` in Crush's config folder gets a `phantom` provider at
83
+ * `/coding-agent/v1` whose key is `$PHANTOM_API_KEY`, which Crush expands
84
+ * when it loads, and phantom-1 as both its large and small model. Crush 0.99
85
+ * reads this file beside a `crushrc`.
86
+ */
87
+ export declare function crushProvider(ctx: SetupContext, off: boolean): ProviderPlan;
88
+ /** Qwen Code's folder: `$QWEN_HOME`, else `~/.qwen`. */
89
+ export declare function qwenDir(env: Env, home: string): string;
90
+ /**
91
+ * Qwen Code: `settings.json` in its folder gets a model under
92
+ * `modelProviders.openai` at `/coding-agent/v1` that reads its key from
93
+ * PHANTOM_API_KEY (`envKey`), is picked as the model (`model.name`), and the
94
+ * OpenAI-compatible sign-in (`security.auth.selectedType`), so Qwen Code
95
+ * starts without asking. Its other models stay.
96
+ */
97
+ export declare function qwenProvider(ctx: SetupContext, off: boolean): ProviderPlan;
98
+ /** Kilo Code's config file: `kilo.jsonc` (or `kilo.json`) in `$XDG_CONFIG_HOME/kilo`, else `~/.config/kilo`. */
99
+ export declare function kiloFile(env: Env, home: string): string;
100
+ /**
101
+ * Kilo Code's CLI, a fork of opencode: its global config gets the same
102
+ * `phantom` provider opencode does, with the key as `{env:PHANTOM_API_KEY}`,
103
+ * and `phantom/<model>` as the model. Kilo resolves `{env:...}` only in the
104
+ * global file, which is the one written here.
105
+ */
106
+ export declare function kiloProvider(ctx: SetupContext, off: boolean): ProviderPlan;
107
+ /** Kimi Code's folder: `$KIMI_CODE_HOME`, else `~/.kimi-code`. */
108
+ export declare function kimiDir(env: Env, home: string): string;
109
+ /**
110
+ * Kimi Code CLI: `config.toml` in its folder gets a `phantom` provider at
111
+ * `/coding-agent/v1` that reads its key from PHANTOM_API_KEY
112
+ * (`api_key_env`), a `phantom/<model>` model, and that model as
113
+ * `default_model`. Each run starts from the file without phantom's lines, so
114
+ * a new `--model` replaces the old one.
115
+ */
116
+ export declare function kimiProvider(ctx: SetupContext, off: boolean): ProviderPlan;
117
+ /**
118
+ * Factory's Droid: `~/.factory/settings.json` gets a custom model at
119
+ * `/coding-agent/v1` (chat completions) with the key as `${PHANTOM_API_KEY}`,
120
+ * which Droid expands, and that model as `model`. Droid names a custom
121
+ * model by its place in `customModels`, so phantom's goes last, or stays
122
+ * where it was, and the user's own keep their names.
123
+ */
124
+ export declare function droidProvider(ctx: SetupContext, off: boolean): ProviderPlan;
125
+ /**
126
+ * Mistral Vibe: `~/.vibe/config.toml` gets a `phantom` provider at
127
+ * `/coding-agent/v1` that reads its key from PHANTOM_API_KEY
128
+ * (`api_key_env_var`), a model on it, and that model as `active_model`.
129
+ * Providers and models are lists of tables (`[[providers]]`), so phantom's
130
+ * go at the end as marked lines, which `--provider off` takes out again.
131
+ */
132
+ export declare function vibeProvider(ctx: SetupContext, off: boolean): ProviderPlan;
133
+ /**
134
+ * Zed's agent panel: `settings.json` in Zed's config folder gets an OpenAI
135
+ * compatible provider named `phantom` at `/coding-agent/v1`, and its model
136
+ * as the agent's default. Zed reads the key for a provider named `phantom`
137
+ * from PHANTOM_API_KEY by itself, so no key goes in the file.
138
+ */
139
+ export declare function zedProvider(ctx: SetupContext, off: boolean): ProviderPlan;
140
+ /**
141
+ * The agents `phantom setup` knows, in the order setup runs them. Adding an agent
142
+ * is one entry here and its name in {@link SetupAgent}: help, errors and
143
+ * `--agent` read their names from this list.
144
+ * @deprecated Compatibility export. Use {@link planSetup}, {@link applySetup}, and {@link restoreSetup} for agent setup.
145
+ */
146
+ export declare const SETUP_AGENTS: Record<SetupAgent, SetupAgentSpec>;
147
+ export declare const SETUP_NAMES: SetupAgent[];
148
+ /** `a, b or c`. */
149
+ export declare function orList(items: string[]): string;