@phantomcodes/cli 1.6.2 → 1.7.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.
Files changed (139) hide show
  1. package/README.md +138 -117
  2. package/bin/phantom.mjs +37 -2
  3. package/dist/agents/command.d.mts +8 -27
  4. package/dist/agents/command.mjs +323 -59
  5. package/dist/agents/login.d.mts +3 -0
  6. package/dist/agents/login.mjs +97 -0
  7. package/dist/agents/opencode-check.d.mts +15 -0
  8. package/dist/agents/opencode-check.mjs +193 -0
  9. package/dist/agents/phantom-key.d.mts +7 -0
  10. package/dist/agents/phantom-key.mjs +40 -0
  11. package/dist/agents/proxy.d.mts +26 -28
  12. package/dist/agents/proxy.mjs +225 -33
  13. package/dist/chatgpt/command.d.mts +2 -0
  14. package/dist/chatgpt/command.mjs +119 -0
  15. package/dist/chatgpt/session.d.mts +87 -0
  16. package/dist/chatgpt/session.mjs +253 -0
  17. package/dist/cli/accounts.d.mts +21 -0
  18. package/dist/cli/accounts.mjs +96 -0
  19. package/dist/cli/app.d.mts +4 -24
  20. package/dist/cli/app.mjs +224 -139
  21. package/dist/cli/commands.d.mts +1 -16
  22. package/dist/cli/commands.mjs +144 -239
  23. package/dist/cli/help.d.mts +0 -19
  24. package/dist/cli/help.mjs +30 -55
  25. package/dist/cli/run.mjs +35 -79
  26. package/dist/cli/start.d.mts +2 -31
  27. package/dist/cli/start.mjs +13 -116
  28. package/dist/core/brand.d.mts +0 -7
  29. package/dist/core/brand.mjs +0 -8
  30. package/dist/core/errors.d.mts +0 -16
  31. package/dist/core/errors.mjs +0 -16
  32. package/dist/core/helpers.d.mts +0 -46
  33. package/dist/core/helpers.mjs +1 -64
  34. package/dist/core/node-trust.d.mts +0 -5
  35. package/dist/core/node-trust.mjs +0 -6
  36. package/dist/core/pick.d.mts +7 -55
  37. package/dist/core/pick.mjs +49 -106
  38. package/dist/core/request.d.mts +0 -46
  39. package/dist/core/request.mjs +1 -60
  40. package/dist/core/secrets.d.mts +0 -4
  41. package/dist/core/secrets.mjs +0 -10
  42. package/dist/core/state.d.mts +3 -1
  43. package/dist/core/state.mjs +147 -4
  44. package/dist/core/style.d.mts +0 -27
  45. package/dist/core/style.mjs +0 -20
  46. package/dist/core/version.d.mts +1 -2
  47. package/dist/core/version.mjs +1 -2
  48. package/dist/local/accounts.d.mts +25 -0
  49. package/dist/local/accounts.mjs +40 -0
  50. package/dist/local/agent-headers.d.mts +7 -0
  51. package/dist/local/agent-headers.mjs +44 -0
  52. package/dist/local/chatgpt-plan.d.mts +147 -0
  53. package/dist/local/chatgpt-plan.mjs +384 -0
  54. package/dist/local/command.d.mts +24 -0
  55. package/dist/local/command.mjs +211 -0
  56. package/dist/local/config.d.mts +49 -0
  57. package/dist/local/config.mjs +168 -0
  58. package/dist/local/decide.d.mts +37 -0
  59. package/dist/local/decide.mjs +201 -0
  60. package/dist/local/failure-signs.d.mts +4 -0
  61. package/dist/local/failure-signs.mjs +99 -0
  62. package/dist/local/keys.d.mts +32 -0
  63. package/dist/local/keys.mjs +239 -0
  64. package/dist/local/models.d.mts +53 -0
  65. package/dist/local/models.mjs +117 -0
  66. package/dist/local/replay.d.mts +59 -0
  67. package/dist/local/replay.mjs +143 -0
  68. package/dist/local/report.d.mts +43 -0
  69. package/dist/local/report.mjs +153 -0
  70. package/dist/local/request-log.d.mts +53 -0
  71. package/dist/local/request-log.mjs +69 -0
  72. package/dist/local/retry-after.d.mts +3 -0
  73. package/dist/local/retry-after.mjs +28 -0
  74. package/dist/local/rust-router.d.mts +39 -0
  75. package/dist/local/rust-router.mjs +54 -0
  76. package/dist/local/server.d.mts +27 -0
  77. package/dist/local/server.mjs +449 -0
  78. package/dist/local/status-line.d.mts +17 -0
  79. package/dist/local/status-line.mjs +81 -0
  80. package/dist/local/tiers.d.mts +3 -0
  81. package/dist/local/tiers.mjs +137 -0
  82. package/dist/local/traces.d.mts +69 -0
  83. package/dist/local/traces.mjs +341 -0
  84. package/dist/phantom.d.mts +0 -37
  85. package/dist/phantom.mjs +0 -31
  86. package/package.json +15 -9
  87. package/skills/phantom-ai/SKILL.md +28 -97
  88. package/dist/cli/screens.d.mts +0 -177
  89. package/dist/cli/screens.mjs +0 -398
  90. package/dist/core/free.d.mts +0 -13
  91. package/dist/core/free.mjs +0 -14
  92. package/dist/core/motion.d.mts +0 -47
  93. package/dist/core/motion.mjs +0 -156
  94. package/dist/core/shapes.d.mts +0 -13
  95. package/dist/core/shapes.mjs +0 -1
  96. package/dist/keys/command.d.mts +0 -16
  97. package/dist/keys/command.mjs +0 -143
  98. package/dist/keys/saved.d.mts +0 -96
  99. package/dist/keys/saved.mjs +0 -169
  100. package/dist/models/choice.d.mts +0 -7
  101. package/dist/models/choice.mjs +0 -27
  102. package/dist/models/command.d.mts +0 -8
  103. package/dist/models/command.mjs +0 -66
  104. package/dist/models/list.d.mts +0 -39
  105. package/dist/models/list.mjs +0 -39
  106. package/dist/receipts/command.d.mts +0 -7
  107. package/dist/receipts/command.mjs +0 -41
  108. package/dist/receipts/receipts.d.mts +0 -76
  109. package/dist/receipts/receipts.mjs +0 -114
  110. package/dist/setup/agents.d.mts +0 -149
  111. package/dist/setup/agents.mjs +0 -886
  112. package/dist/setup/apply.d.mts +0 -85
  113. package/dist/setup/apply.mjs +0 -301
  114. package/dist/setup/command.d.mts +0 -12
  115. package/dist/setup/command.mjs +0 -307
  116. package/dist/setup/editors.d.mts +0 -108
  117. package/dist/setup/editors.mjs +0 -500
  118. package/dist/setup/legacy.d.mts +0 -13
  119. package/dist/setup/legacy.mjs +0 -36
  120. package/dist/setup/plan.d.mts +0 -104
  121. package/dist/setup/plan.mjs +0 -132
  122. package/dist/setup/screen.d.mts +0 -30
  123. package/dist/setup/screen.mjs +0 -260
  124. package/dist/setup/shared.d.mts +0 -141
  125. package/dist/setup/shared.mjs +0 -88
  126. package/dist/setup/was.d.mts +0 -42
  127. package/dist/setup/was.mjs +0 -91
  128. package/dist/spend/command.d.mts +0 -5
  129. package/dist/spend/command.mjs +0 -235
  130. package/dist/spend/lineup.d.mts +0 -61
  131. package/dist/spend/lineup.mjs +0 -39
  132. package/dist/spend/reason.d.mts +0 -5
  133. package/dist/spend/reason.mjs +0 -60
  134. package/dist/spend/report.d.mts +0 -105
  135. package/dist/spend/report.mjs +0 -68
  136. package/dist/spend/routing.d.mts +0 -74
  137. package/dist/spend/routing.mjs +0 -57
  138. package/dist/workspace/command.d.mts +0 -59
  139. package/dist/workspace/command.mjs +0 -871
@@ -1,41 +0,0 @@
1
- import { die } from "../core/errors.mjs";
2
- import { out } from "../core/helpers.mjs";
3
- import { checkReceipt, verifyModel } from "./receipts.mjs";
4
- /** `--table` output for `verify --model`. */
5
- export function tableVerifyModel(d) {
6
- const v = d;
7
- return [
8
- `requested ${v.model_requested}`,
9
- `served ${v.model_served ?? '-'}`,
10
- `match ${v.match}`,
11
- `signature ${v.signature_valid ? 'valid' : 'invalid'}`,
12
- `cost ${v.cost_usd === null ? '-' : `$${v.cost_usd.toFixed(6)}`}`,
13
- ...(v.reason ? [`reason ${v.reason}`] : []),
14
- ].join('\n');
15
- }
16
- /** `--table` output for `verify --receipt`. */
17
- export function tableReceiptCheck(d) {
18
- const c = d;
19
- return [
20
- `signature ${c.valid ? 'valid' : 'invalid'}`,
21
- `requested ${c.receipt?.model_requested ?? '-'}`,
22
- `served ${c.receipt?.model_served ?? '-'}`,
23
- `signed_at ${c.receipt?.ts ?? '-'}`,
24
- ...(c.reason ? [`reason ${c.reason}`] : []),
25
- ].join('\n');
26
- }
27
- /** `phantom verify`: checks a receipt, or makes one small call and checks its receipt. Run by `run()`. */
28
- export async function verifyCommand({ io, apiKey, flags, table, baseUrl }) {
29
- const model = flags['model'];
30
- const receipt = flags['receipt'];
31
- if (typeof receipt === 'string') {
32
- const result = await checkReceipt(receipt, baseUrl);
33
- out(result, table, tableReceiptCheck, io.stdout);
34
- return result.valid ? 0 : 1;
35
- }
36
- if (typeof model !== 'string')
37
- die('verify requires --model <id> or --receipt <receipt>');
38
- const result = await verifyModel(apiKey, model, baseUrl);
39
- out(result, table, tableVerifyModel, io.stdout);
40
- return result.match ? 0 : 1;
41
- }
@@ -1,76 +0,0 @@
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
- /**
44
- * True when the signature is valid and the model matches the one asked for.
45
- * For an ordinary model id, `model_served` is compared ({@link modelsMatch}).
46
- * For a Phantom router id, the receipt's requested model is compared, because
47
- * the served model is whatever the router picked.
48
- */
49
- match: boolean;
50
- /** Which receipt field `match` compared with `model_requested`. */
51
- compared_with: 'model_served' | 'model_requested';
52
- /** True when the receipt's signature matches Phantom AI's published key. */
53
- signature_valid: boolean;
54
- /** What the call cost, in USD. null without a receipt. */
55
- cost_usd: number | null;
56
- /** Phantom AI's id for the call. null without a receipt. */
57
- request_id: string | null;
58
- /** The compact receipt from the x-phantom-receipt header. null when the answer had none. */
59
- receipt: string | null;
60
- /** Why it did not match or could not be checked. Absent when all is well. */
61
- reason?: string;
62
- };
63
- /**
64
- * Checks a compact receipt (`payload.signature`, both base64url) against the
65
- * public key from GET /receipts/key. Needs no API key.
66
- * @param timeoutMs How long to wait for the key. Defaults to {@link REQUEST_TIMEOUT_MS}.
67
- * @throws {@link PhantomApiError} when the public key cannot be fetched.
68
- * @throws {@link CliError} `request_timeout` when the server does not answer in time, `bad_answer` when it sends a web page.
69
- */
70
- export declare function checkReceipt(compact: string, baseUrl?: string, timeoutMs?: number): Promise<ReceiptCheck>;
71
- /** The served id can drop the provider prefix, so a bare name counts as a match. */
72
- export declare function modelsMatch(requested: string, served: string): boolean;
73
- /** One small priced call to `model`, then a check of the receipt it returns. */
74
- export declare function verifyModel(apiKey: string, model: string, baseUrl?: string, timeoutMs?: number): Promise<VerifyModelResult>;
75
- /** True when `model` is one of Phantom's routers (`phantom-1`, `phantom-1:free`, `phantom-1:zdr`, `auto`), in any case. */
76
- export declare function isPhantomRouter(model: string): boolean;
@@ -1,114 +0,0 @@
1
- import { createPublicKey, verify as cryptoVerify } from 'node:crypto';
2
- import { die } from "../core/errors.mjs";
3
- import { REQUEST_TIMEOUT_MS, answerError, apiBase, fetchAnswer } from "../core/request.mjs";
4
- /**
5
- * Every priced call returns a receipt signed with Phantom AI's Ed25519 key. The
6
- * check runs here, against the public key from /receipts/key, so the answer
7
- * never comes from Phantom AI saying it was honest.
8
- */
9
- /** Matches RECEIPT_VERSION in lib/receipts.ts. */
10
- const RECEIPT_VERSION = 1;
11
- /**
12
- * Checks a compact receipt (`payload.signature`, both base64url) against the
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}.
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.
17
- */
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);
20
- if (!res.ok)
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;
25
- if (!json.signs || !json.public_key_jwk) {
26
- return { valid: false, receipt: null, reason: 'This deployment signs no receipts' };
27
- }
28
- const parts = compact.trim().split('.');
29
- if (parts.length !== 2)
30
- return { valid: false, receipt: null, reason: 'Not a receipt: expected payload.signature' };
31
- const payload = Buffer.from(parts[0], 'base64url');
32
- let receipt;
33
- try {
34
- receipt = JSON.parse(payload.toString('utf-8'));
35
- }
36
- catch {
37
- return { valid: false, receipt: null, reason: 'Receipt payload is not JSON' };
38
- }
39
- if (!receipt || typeof receipt !== 'object')
40
- return { valid: false, receipt: null, reason: 'Receipt payload is not an object' };
41
- if (receipt.v !== RECEIPT_VERSION)
42
- return { valid: false, receipt, reason: `Unknown receipt version ${receipt.v}` };
43
- const key = createPublicKey({ key: json.public_key_jwk, format: 'jwk' });
44
- const valid = cryptoVerify(null, payload, key, Buffer.from(parts[1], 'base64url'));
45
- return valid ? { valid, receipt } : { valid, receipt, reason: 'Signature does not match the published key' };
46
- }
47
- /** The served id can drop the provider prefix, so a bare name counts as a match. */
48
- export function modelsMatch(requested, served) {
49
- const bare = (id) => id.toLowerCase().split('/').pop();
50
- return requested.toLowerCase() === served.toLowerCase() || bare(requested) === bare(served);
51
- }
52
- /** One small priced call to `model`, then a check of the receipt it returns. */
53
- export async function verifyModel(apiKey, model, baseUrl, timeoutMs = REQUEST_TIMEOUT_MS) {
54
- const { res, answer } = await fetchAnswer(`${apiBase(baseUrl)}/chat/completions`, {
55
- method: 'POST',
56
- headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
57
- body: JSON.stringify({ model, max_tokens: 16, messages: [{ role: 'user', content: 'Reply with ok.' }] }),
58
- }, 'POST /chat/completions', timeoutMs);
59
- if (!res.ok)
60
- throw answerError(res.status, answer);
61
- const compact = res.headers.get('x-phantom-receipt');
62
- if (!compact) {
63
- return {
64
- model_requested: model,
65
- model_served: null,
66
- match: false,
67
- compared_with: isPhantomRouter(model) ? 'model_requested' : 'model_served',
68
- signature_valid: false,
69
- cost_usd: null,
70
- request_id: null,
71
- receipt: null,
72
- reason: 'The response carried no receipt',
73
- };
74
- }
75
- const check = await checkReceipt(compact, baseUrl, timeoutMs);
76
- const r = check.receipt;
77
- const routerCheck = isPhantomRouter(model) ? checkRouterRequest(model, r?.model_requested) : null;
78
- return {
79
- model_requested: model,
80
- model_served: r?.model_served ?? null,
81
- match: check.valid && r !== null && (routerCheck ? routerCheck.match : modelsMatch(model, r.model_served)),
82
- compared_with: routerCheck?.compared_with ?? 'model_served',
83
- signature_valid: check.valid,
84
- cost_usd: r ? r.cost_micro_usd / 1_000_000 : null,
85
- request_id: r?.request_id ?? null,
86
- receipt: compact,
87
- // A failed signature is the first thing to fix, so its reason comes before a router note.
88
- ...(check.reason ? { reason: check.reason } : routerCheck?.reason ? { reason: routerCheck.reason } : {}),
89
- };
90
- }
91
- /** The ids of Phantom's routers: names that pick a model for each request, so no upstream model ever has them as its own id. */
92
- const PHANTOM_ROUTERS = ['phantom-1', 'phantom-1:free', 'phantom-1:zdr', 'auto'];
93
- /** True when `model` is one of Phantom's routers (`phantom-1`, `phantom-1:free`, `phantom-1:zdr`, `auto`), in any case. */
94
- export function isPhantomRouter(model) {
95
- return PHANTOM_ROUTERS.includes(model.toLowerCase());
96
- }
97
- /**
98
- * Checks a router id against what the receipt says was requested. `model_served`
99
- * is the model the upstream ran, such as `anthropic/claude-sonnet-5.5`, and
100
- * never a router id, so it can't be the comparison here. A receipt with no
101
- * requested model leaves nothing to compare, and says so.
102
- */
103
- function checkRouterRequest(router, receiptRequested) {
104
- if (typeof receiptRequested !== 'string' || !receiptRequested) {
105
- return {
106
- match: false,
107
- compared_with: 'model_served',
108
- reason: `${router} is a router, so it can't be checked against model_served, which is the model the upstream ran. This receipt names no requested model.`,
109
- };
110
- }
111
- if (receiptRequested.toLowerCase() === router.toLowerCase())
112
- return { match: true, compared_with: 'model_requested' };
113
- return { match: false, compared_with: 'model_requested', reason: `The receipt says the request was for '${receiptRequested}', not '${router}'.` };
114
- }
@@ -1,149 +0,0 @@
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;