@phantomcodes/cli 1.3.1 → 1.3.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.
@@ -50,7 +50,7 @@ export const COMMANDS = [
50
50
  {
51
51
  name: 'fund', handler: fundDispatch, keyless: true,
52
52
  group: 'Money', summary: 'add credit by card or crypto',
53
- help: ` fund --amount <USD> [--card | --coin usdc|usdt|sol] [--no-browser]
53
+ help: ` fund --amount <USD> [--card | --coin usdc|usdt|sol|usdc-base] [--no-browser]
54
54
  fund your workspace balance with card (plus Stripe's fee) or crypto`,
55
55
  },
56
56
  {
@@ -43,7 +43,14 @@ export function bar(p, share, width, fill) {
43
43
  /** A date as `Nov 1, 2026`, read as UTC, or the text as given when it isn't one. */
44
44
  function day(iso) {
45
45
  const d = new Date(iso.length === 10 ? `${iso}T00:00:00Z` : iso);
46
- return Number.isNaN(d.getTime()) ? iso : d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' });
46
+ return Number.isNaN(d.getTime())
47
+ ? iso
48
+ : d.toLocaleDateString('en-US', {
49
+ month: 'short',
50
+ day: 'numeric',
51
+ year: 'numeric',
52
+ timeZone: 'UTC',
53
+ });
47
54
  }
48
55
  /** `phantom balance`: the credit in bold, then what it spent and when the key stops working. */
49
56
  export function balanceScreen(b, style = {}) {
@@ -163,12 +170,7 @@ export function signedInScreen(saved, style = {}) {
163
170
  /** `phantom login` when this computer already has a key: say so, then how to switch or add one. */
164
171
  export function alreadySignedInScreen(keyIdShown, style = {}) {
165
172
  const p = paint(style.env ?? {}, Boolean(style.color));
166
- return [
167
- '',
168
- ` ${p.lime('✓')} ${p.bold('You are already signed in on this computer.')}${keyIdShown ? ` ${p.dim(`key ${keyIdShown}`)}` : ''}`,
169
- ...next(p, 'Use another workspace: run phantom logout, then', 'phantom login'),
170
- ...next(p, 'Add a second key here:', 'phantom login --save <name>'),
171
- ].join('\n');
173
+ return ['', ` ${p.lime('✓')} ${p.bold('You are already signed in on this computer.')}${keyIdShown ? ` ${p.dim(`key ${keyIdShown}`)}` : ''}`, ...next(p, 'Use another workspace: run phantom logout, then', 'phantom login'), ...next(p, 'Add a second key here:', 'phantom login --save <name>')].join('\n');
172
174
  }
173
175
  /** A ✓ line with an optional dim detail, for a change that worked. */
174
176
  function done(p, words, detail = '') {
@@ -182,7 +184,11 @@ export function routeScreen(r, style = {}) {
182
184
  const policy = r.route_policy;
183
185
  const row = (label, value) => ` ${p.dim(label.padEnd(14))}${value}`;
184
186
  // Which providers serve first holds for every request, routed or not.
185
- const sortWords = { cost: 'cheapest first', ttft: 'fastest to start answering first', tps: 'most tokens a second first' };
187
+ const sortWords = {
188
+ cost: 'cheapest first',
189
+ ttft: 'fastest to start answering first',
190
+ tps: 'most tokens a second first',
191
+ };
186
192
  const providers = row('providers', `${sortWords[policy?.sort ?? 'cost']}${policy?.sort ? '' : p.dim(' (the default)')}${policy?.zdr ? ', zero data retention only' : ''}${policy?.no_training ? ', no training on prompts' : ''}`);
187
193
  if (!policy || !policy.models.length) {
188
194
  lines.push(' No route policy, so model "auto" runs phantom-1, which picks a model for each request.', '', providers);
@@ -202,7 +208,9 @@ export function routeScreen(r, style = {}) {
202
208
  if (!rules.length)
203
209
  lines.push(` ${p.dim('None: "auto" runs the first model.')}`);
204
210
  rules.forEach((rule, k) => {
205
- const when = Object.entries(rule.if).map(([name, value]) => `${name} = ${value}`).join(' and ');
211
+ const when = Object.entries(rule.if)
212
+ .map(([name, value]) => `${name} = ${value}`)
213
+ .join(' and ');
206
214
  lines.push(` ${p.dim(`${k + 1}.`)} if ${when}, use ${p.bold(rule.use)}`);
207
215
  });
208
216
  lines.push(...next(p, 'See what a request would get now:', 'phantom route test'));
@@ -222,7 +230,11 @@ export function routeTestScreen(t, style = {}) {
222
230
  return lines.join('\n');
223
231
  }
224
232
  /** What each tier is for, in a few words. */
225
- export const TIER_ABOUT = { economy: 'short, easy requests', standard: 'everyday coding', frontier: 'the hardest work' };
233
+ export const TIER_ABOUT = {
234
+ economy: 'short, easy requests',
235
+ standard: 'everyday coding',
236
+ frontier: 'the hardest work',
237
+ };
226
238
  /** `phantom lineup`: the model phantom-1 runs in each tier, whether it's the default or your pick, and its fallback. */
227
239
  export function lineupScreen(l, style = {}) {
228
240
  const p = paint(style.env ?? {}, Boolean(style.color));
@@ -286,11 +298,7 @@ export function fundScreen(f, style = {}) {
286
298
  }
287
299
  const p = paint(style.env ?? {}, Boolean(style.color));
288
300
  const w = ruleWidth(style);
289
- return [
290
- linkScreen(`Pay ${f.amount ?? ''} ${(f.coin ?? '').toUpperCase()} from your wallet`.replace(/\s+/g, ' '), f.solana_pay_url ?? '', null, style),
291
- ` ${p.dim('payment')} ${f.payment_id ?? ''}${f.expires_at ? p.dim(` · good until ${day(f.expires_at)}`) : ''}`,
292
- ...next(p, 'Check it landed:', `phantom workspace payment --id ${f.payment_id ?? '<id>'}`),
293
- ].join('\n');
301
+ return [linkScreen(`Pay ${f.amount ?? ''} ${(f.coin ?? '').toUpperCase()} from your wallet`.replace(/\s+/g, ' '), f.payment_url ?? f.solana_pay_url ?? '', null, style), ` ${p.dim('payment')} ${f.payment_id ?? ''}${f.expires_at ? p.dim(` · good until ${day(f.expires_at)}`) : ''}`, ...next(p, 'Check it landed:', `phantom workspace payment --id ${f.payment_id ?? '<id>'}`)].join('\n');
294
302
  }
295
303
  /** `phantom workspace payment`: whether a payment has come in. */
296
304
  export function paymentScreen(pay, style = {}) {
@@ -1,2 +1,2 @@
1
1
  /** This release of phantom. `npm version` keeps it equal to the version in package.json. */
2
- export const VERSION = '1.3.1';
2
+ export const VERSION = '1.3.3';
@@ -151,22 +151,3 @@ export function forgetKeyAs(env, target) {
151
151
  else
152
152
  removeNamedKey(env, target);
153
153
  }
154
- /**
155
- * True when PHANTOM_API_KEY holds the same key as the login. `phantom setup`'s
156
- * shell block sets it that way, so a rotate or burn must update the login too.
157
- */
158
- export function envIsLogin(env) {
159
- return Boolean(env.PHANTOM_API_KEY) && existsSync(keyPath(env)) && readSecret(env, keyPath(env)).trim() === env.PHANTOM_API_KEY?.trim();
160
- }
161
- /** After a rotate, put the new key where the old one was saved. */
162
- export function replaceSavedKey(env, src, key) {
163
- if (src.from === 'named') {
164
- saveNamedKey(env, src.name, key, { replace: true });
165
- return src.name;
166
- }
167
- if (src.from === 'login' || (src.from === 'env' && envIsLogin(env))) {
168
- writeKeyFile(env, keyPath(env), key);
169
- return 'login';
170
- }
171
- return null;
172
- }
@@ -71,7 +71,7 @@ export function claudePlan(env, opts) {
71
71
  const changes = [];
72
72
  if (ours) {
73
73
  changes.push([['apiKeyHelper'], undefined]);
74
- const mine = ['ANTHROPIC_BASE_URL', 'ENABLE_TOOL_SEARCH', 'ANTHROPIC_MODEL', 'CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY', ...(vars.ANTHROPIC_API_KEY === '' ? ['ANTHROPIC_API_KEY'] : [])];
74
+ const mine = ['ANTHROPIC_BASE_URL', 'ENABLE_TOOL_SEARCH', 'ANTHROPIC_MODEL', 'ANTHROPIC_DEFAULT_HAIKU_MODEL', 'CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY', ...(vars.ANTHROPIC_API_KEY === '' ? ['ANTHROPIC_API_KEY'] : [])];
75
75
  if (Object.keys(vars).every((k) => mine.includes(k)))
76
76
  changes.push([['env'], undefined]);
77
77
  else
@@ -97,6 +97,9 @@ export function claudePlan(env, opts) {
97
97
  CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY: '1',
98
98
  // phantom-1 unless a model is named, as Codex gets: it runs free until there is credit.
99
99
  ANTHROPIC_MODEL: opts.model ?? 'claude-code/phantom-1',
100
+ // Claude Code's background calls (titles, summaries) and its Explore agent use the
101
+ // haiku model. Through phantom-1 they run on Standard instead of Claude Haiku.
102
+ ANTHROPIC_DEFAULT_HAIKU_MODEL: 'claude-code/phantom-1',
100
103
  };
101
104
  const changes = [[['apiKeyHelper'], `${phantomCommand(opts.onPath ?? onPath)} key show`], ...Object.entries(set).map(([k, v]) => [['env', k], v])];
102
105
  // A token outranks apiKeyHelper, and would send a non-Phantom key.
@@ -17,7 +17,15 @@ import { keyId, keyPath, listNamedKeys, namedKeyPath, readNamedKey, resolveApiKe
17
17
  const credentialPath = (env) => path.join(stateDir(env), 'workspace');
18
18
  const base = (input) => httpsOnly(input.baseUrl || input.env.PHANTOM_BASE_URL || DEFAULT_BASE_URL).replace(/\/$/, '');
19
19
  async function wire(url, method, endpoint, body, token) {
20
- const response = await fetch(url + endpoint, { method, redirect: 'error', headers: { ...(token ? { Authorization: `Bearer ${token}` } : {}), ...(body === undefined ? {} : { 'Content-Type': 'application/json' }) }, body: body === undefined ? undefined : JSON.stringify(body) });
20
+ const response = await fetch(url + endpoint, {
21
+ method,
22
+ redirect: 'error',
23
+ headers: {
24
+ ...(token ? { Authorization: `Bearer ${token}` } : {}),
25
+ ...(body === undefined ? {} : { 'Content-Type': 'application/json' }),
26
+ },
27
+ body: body === undefined ? undefined : JSON.stringify(body),
28
+ });
21
29
  const data = await response.json();
22
30
  if (!response.ok)
23
31
  throw apiError(response.status, data);
@@ -63,9 +71,21 @@ export async function workspaceLogin(input, opts = {}) {
63
71
  let noBrowser = Boolean(flags['no-browser']);
64
72
  if (pick) {
65
73
  const how = await choose(pick, 'How do you want to sign in?', [
66
- { label: 'Open the browser', hint: 'approve there, and phantom saves your key', value: 'browser' },
67
- { label: 'Just show the link', hint: 'to open it yourself, or on another device', value: 'link' },
68
- { label: 'Paste a key I already have', hint: 'starts with sk-phantom-', value: 'paste' },
74
+ {
75
+ label: 'Open the browser',
76
+ hint: 'approve there, and phantom saves your key',
77
+ value: 'browser',
78
+ },
79
+ {
80
+ label: 'Just show the link',
81
+ hint: 'to open it yourself, or on another device',
82
+ value: 'link',
83
+ },
84
+ {
85
+ label: 'Paste a key I already have',
86
+ hint: 'starts with sk-phantom-',
87
+ value: 'paste',
88
+ },
69
89
  ]);
70
90
  // Esc: back to the menu when it started this, otherwise stop without saving anything.
71
91
  if (how === null && input.io.fromMenu)
@@ -75,7 +95,12 @@ export async function workspaceLogin(input, opts = {}) {
75
95
  return 0;
76
96
  }
77
97
  if (how === 'paste') {
78
- await loginCommand({ ...input, subcommand: undefined, flags: {}, io: opts.inSetup ? { ...input.io, stdout: input.io.stderr } : input.io });
98
+ await loginCommand({
99
+ ...input,
100
+ subcommand: undefined,
101
+ flags: {},
102
+ io: opts.inSetup ? { ...input.io, stdout: input.io.stderr } : input.io,
103
+ });
79
104
  return 0;
80
105
  }
81
106
  noBrowser = how === 'link';
@@ -98,7 +123,13 @@ export async function workspaceLogin(input, opts = {}) {
98
123
  // At a terminal, Esc or Ctrl+C stops the wait, as they do everywhere else.
99
124
  const cancel = pick ? cancelKeys((pick.keys ?? keyboard)()) : null;
100
125
  try {
101
- return await pollForApproval(input, opts, { url, start, name, spinner, cancel: cancel?.pressed ?? null });
126
+ return await pollForApproval(input, opts, {
127
+ url,
128
+ start,
129
+ name,
130
+ spinner,
131
+ cancel: cancel?.pressed ?? null,
132
+ });
102
133
  }
103
134
  finally {
104
135
  spinner?.stop();
@@ -109,9 +140,16 @@ export async function workspaceLogin(input, opts = {}) {
109
140
  function alreadySignedIn(input) {
110
141
  const { env, io } = input;
111
142
  const key = resolveApiKey(env);
112
- const result = { signed_in: true, already: true, key_id: key ? keyId(key) : null };
143
+ const result = {
144
+ signed_in: true,
145
+ already: true,
146
+ key_id: key ? keyId(key) : null,
147
+ };
113
148
  if (showsScreen(input))
114
- io.stdout(alreadySignedInScreen(result.key_id, { env, color: colorOn(env, io.stdoutIsTTY) }) + '\n');
149
+ io.stdout(alreadySignedInScreen(result.key_id, {
150
+ env,
151
+ color: colorOn(env, io.stdoutIsTTY),
152
+ }) + '\n');
115
153
  else
116
154
  io.stdout(JSON.stringify(result) + '\n');
117
155
  return 0;
@@ -133,7 +171,10 @@ function waiting(write, p, words = 'Waiting for you to approve...', doneWords =
133
171
  clearInterval(timer);
134
172
  write(`\r\x1b[2K${line}`);
135
173
  };
136
- return { stop: () => stop(), done: () => stop(` ${p.lime('✓')} ${doneWords}\n`) };
174
+ return {
175
+ stop: () => stop(),
176
+ done: () => stop(` ${p.lime('✓')} ${doneWords}\n`),
177
+ };
137
178
  }
138
179
  /** Asks the server for the approved key until it comes, the code expires, or it fails. */
139
180
  async function pollForApproval(input, opts, ctx) {
@@ -155,7 +196,9 @@ async function pollForApproval(input, opts, ctx) {
155
196
  }
156
197
  let token;
157
198
  try {
158
- token = await wire(url, 'POST', '/auth/device/token', { device_code: start.device_code });
199
+ token = await wire(url, 'POST', '/auth/device/token', {
200
+ device_code: start.device_code,
201
+ });
159
202
  }
160
203
  catch (error) {
161
204
  const code = error.code;
@@ -168,7 +211,13 @@ async function pollForApproval(input, opts, ctx) {
168
211
  throw error;
169
212
  }
170
213
  spinner?.done();
171
- const saved = { version: 1, workspace_id: token.workspace_id, management_credential: token.management_token, base_url: url, recovery: token.recovery };
214
+ const saved = {
215
+ version: 1,
216
+ workspace_id: token.workspace_id,
217
+ management_credential: token.management_token,
218
+ base_url: url,
219
+ recovery: token.recovery,
220
+ };
172
221
  try {
173
222
  writeSecret(env, credentialPath(env), JSON.stringify(saved));
174
223
  if (name === 'default')
@@ -184,7 +233,12 @@ async function pollForApproval(input, opts, ctx) {
184
233
  io.stderr(` ${p.lime('✓')} Signed in. Setting up your agents next.\n\n`);
185
234
  return 0;
186
235
  }
187
- const result = { saved_as: name, key_name: token.key_name, workspace_id: token.workspace_id, storage: keychainOn(env) ? 'macOS Keychain' : 'private files' };
236
+ const result = {
237
+ saved_as: name,
238
+ key_name: token.key_name,
239
+ workspace_id: token.workspace_id,
240
+ storage: keychainOn(env) ? 'macOS Keychain' : 'private files',
241
+ };
188
242
  if (showsScreen(input)) {
189
243
  io.stdout(signedInScreen(result, { env, color: colorOn(env, io.stdoutIsTTY) }) + '\n');
190
244
  return 0;
@@ -201,7 +255,14 @@ export async function workspaceCommand(input) {
201
255
  if (argv[0] === 'keys') {
202
256
  if (subcommand === 'saved' || subcommand === 'save' || subcommand === 'show' || subcommand === 'rm') {
203
257
  // Only the flags the key command reads pass through; --copy must, or `keys show --copy` would print the key.
204
- return keyCommand({ ...input, flags: { ...(flags.balance ? { balance: flags.balance } : {}), ...(flags.copy ? { copy: flags.copy } : {}) }, subcommand: subcommand === 'saved' ? 'list' : subcommand });
258
+ return keyCommand({
259
+ ...input,
260
+ flags: {
261
+ ...(flags.balance ? { balance: flags.balance } : {}),
262
+ ...(flags.copy ? { copy: flags.copy } : {}),
263
+ },
264
+ subcommand: subcommand === 'saved' ? 'list' : subcommand,
265
+ });
205
266
  }
206
267
  const remoteCommands = new Set(['list', 'create', 'rotate', 'revoke', 'set', undefined]);
207
268
  if (!remoteCommands.has(subcommand)) {
@@ -227,7 +288,10 @@ export async function workspaceCommand(input) {
227
288
  die('This is an account workspace. Sign in to recover it on another computer.');
228
289
  if (typeof flags.file !== 'string')
229
290
  die('Use phantom workspace export --file <path>.');
230
- writeFileSync(flags.file, JSON.stringify(saved.recovery, null, 2), { mode: 0o600, flag: 'wx' });
291
+ writeFileSync(flags.file, JSON.stringify(saved.recovery, null, 2), {
292
+ mode: 0o600,
293
+ flag: 'wx',
294
+ });
231
295
  io.stdout(showsScreen(input) ? `\n ${paint(env, colorOn(env, io.stdoutIsTTY)).lime('✓')} Recovery saved to ${flags.file}. Keep that file private: it can manage this workspace.\n` : 'Recovery exported. Keep that file private; it grants workspace management.\n');
232
296
  return 0;
233
297
  }
@@ -257,7 +321,14 @@ export async function workspaceCommand(input) {
257
321
  saveApiKey(env, result.api_key);
258
322
  else
259
323
  saveNamedKey(env, name, result.api_key, { replace: replacing });
260
- io.stdout(showsScreen(input) ? keyChangeScreen(command === 'create' ? 'created' : 'rotated', name, { env, color: colorOn(env, io.stdoutIsTTY), storage: keychainOn(env) ? 'macOS Keychain' : 'private files', limit }) + '\n' : JSON.stringify({ saved_as: name }) + '\n');
324
+ io.stdout(showsScreen(input)
325
+ ? keyChangeScreen(command === 'create' ? 'created' : 'rotated', name, {
326
+ env,
327
+ color: colorOn(env, io.stdoutIsTTY),
328
+ storage: keychainOn(env) ? 'macOS Keychain' : 'private files',
329
+ limit,
330
+ }) + '\n'
331
+ : JSON.stringify({ saved_as: name }) + '\n');
261
332
  return 0;
262
333
  }
263
334
  if (command === 'revoke') {
@@ -268,7 +339,11 @@ export async function workspaceCommand(input) {
268
339
  const pick = flags['yes'] ? null : pickIo(input);
269
340
  if (pick) {
270
341
  const go = await choose({ ...pick, esc: 'back' }, `Revoke ${which.name}?`, [
271
- { label: `Revoke ${which.name}`, hint: 'anything using it stops working at once; its credit stays', value: true },
342
+ {
343
+ label: `Revoke ${which.name}`,
344
+ hint: 'anything using it stops working at once; its credit stays',
345
+ value: true,
346
+ },
272
347
  { label: 'Cancel', hint: 'keep it', value: false },
273
348
  ], 1);
274
349
  if (!go) {
@@ -277,7 +352,12 @@ export async function workspaceCommand(input) {
277
352
  }
278
353
  }
279
354
  await wire(saved.base_url, 'DELETE', endpoint + '/keys/' + which.id, undefined, saved.management_credential);
280
- io.stdout(showsScreen(input) ? keyChangeScreen('revoked', null, { env, color: colorOn(env, io.stdoutIsTTY) }) + '\n' : 'Key revoked.\n');
355
+ io.stdout(showsScreen(input)
356
+ ? keyChangeScreen('revoked', null, {
357
+ env,
358
+ color: colorOn(env, io.stdoutIsTTY),
359
+ }) + '\n'
360
+ : 'Key revoked.\n');
281
361
  return 0;
282
362
  }
283
363
  if (command === 'set') {
@@ -295,7 +375,12 @@ export async function workspaceCommand(input) {
295
375
  flags.limit = limit === null ? 'none' : String(limit);
296
376
  }
297
377
  const body = {};
298
- const controls = { limit_usd: flags.limit, budget_usd: flags.budget, period_days: flags.period, rate_usd_per_min: flags.rate };
378
+ const controls = {
379
+ limit_usd: flags.limit,
380
+ budget_usd: flags.budget,
381
+ period_days: flags.period,
382
+ rate_usd_per_min: flags.rate,
383
+ };
299
384
  for (const [field, value] of Object.entries(controls))
300
385
  if (value !== undefined)
301
386
  body[field] = value === 'none' ? null : Number(value);
@@ -306,7 +391,12 @@ export async function workspaceCommand(input) {
306
391
  if (flags['clear-policy'])
307
392
  body.route_policy = null;
308
393
  const result = await wire(saved.base_url, 'PATCH', endpoint + '/keys/' + id, body, saved.management_credential);
309
- io.stdout(showsScreen(input) ? keyChangeScreen('updated', null, { env, color: colorOn(env, io.stdoutIsTTY) }) + '\n' : JSON.stringify(result) + '\n');
394
+ io.stdout(showsScreen(input)
395
+ ? keyChangeScreen('updated', null, {
396
+ env,
397
+ color: colorOn(env, io.stdoutIsTTY),
398
+ }) + '\n'
399
+ : JSON.stringify(result) + '\n');
310
400
  return 0;
311
401
  }
312
402
  if (command === 'revoke-access') {
@@ -327,30 +417,46 @@ export async function workspaceCommand(input) {
327
417
  if (flags.pay)
328
418
  die('--pay has been removed. Use --card or --coin.');
329
419
  if (flags.coin === true)
330
- die(`--coin needs usdc, usdt or sol. ${FUND_EXAMPLE}`);
420
+ die(`--coin needs usdc, usdt, sol or usdc-base. ${FUND_EXAMPLE}`);
331
421
  let amount = dollarsFlag(flags);
332
422
  let method = flags.card ? 'card' : flags.coin;
333
423
  // At a terminal, whatever is missing is asked for: first how much, then how to pay.
334
424
  const pick = amount === undefined || !method ? pickIo(input) : null;
335
425
  if (pick && amount === undefined) {
336
- amount = (await choose(pick, 'How much credit do you want to add?', [5, 10, 25, 50, 100].map((n) => ({ label: `$${n}`, value: n })), 1)) ?? undefined;
426
+ amount =
427
+ (await choose(pick, 'How much credit do you want to add?', [5, 10, 25, 50, 100].map((n) => ({ label: `$${n}`, value: n })), 1)) ?? undefined;
337
428
  if (amount === undefined)
338
429
  return leaveFund(input);
339
430
  }
340
431
  if (pick && !method) {
341
- method = (await choose({ ...pick, esc: 'back' }, 'How do you want to pay?', [
342
- { label: 'Card', hint: "on Stripe's page, plus Stripe's card fee", value: 'card' },
343
- { label: 'USDC', hint: 'from a Solana wallet', value: 'usdc' },
344
- { label: 'USDT', hint: 'from a Solana wallet', value: 'usdt' },
345
- { label: 'SOL', hint: 'from a Solana wallet', value: 'sol' },
346
- ])) ?? undefined;
432
+ method =
433
+ (await choose({ ...pick, esc: 'back' }, 'How do you want to pay?', [
434
+ {
435
+ label: 'Card',
436
+ hint: "on Stripe's page, plus Stripe's card fee",
437
+ value: 'card',
438
+ },
439
+ { label: 'USDC', hint: 'from a Solana wallet', value: 'usdc' },
440
+ { label: 'USDT', hint: 'from a Solana wallet', value: 'usdt' },
441
+ { label: 'SOL', hint: 'from a Solana wallet', value: 'sol' },
442
+ ])) ?? undefined;
347
443
  if (!method)
348
444
  return leaveFund(input);
349
445
  }
350
446
  if (amount === undefined || !method)
351
447
  die(`fund needs how much and how to pay. ${FUND_EXAMPLE}`, 'fund_usage');
352
- const result = await wire(saved.base_url, 'POST', endpoint + '/fund', { method: method === 'card' ? 'card' : 'crypto', amount_usd: amount, coin: method === 'card' ? 'usdc' : method }, saved.management_credential);
353
- io.stdout((showsScreen(input) ? fundScreen(result, { env, color: colorOn(env, io.stdoutIsTTY), opened: Boolean(result.checkout_url) && !flags['no-browser'] }) : JSON.stringify(result)) + '\n');
448
+ const result = await wire(saved.base_url, 'POST', endpoint + '/fund', {
449
+ method: method === 'card' ? 'card' : 'crypto',
450
+ amount_usd: amount,
451
+ coin: method === 'card' ? 'usdc' : method,
452
+ }, saved.management_credential);
453
+ io.stdout((showsScreen(input)
454
+ ? fundScreen(result, {
455
+ env,
456
+ color: colorOn(env, io.stdoutIsTTY),
457
+ opened: Boolean(result.checkout_url) && !flags['no-browser'],
458
+ })
459
+ : JSON.stringify(result)) + '\n');
354
460
  if (result.checkout_url && !flags['no-browser'])
355
461
  openUrl(result.checkout_url);
356
462
  // At a terminal, wait for the payment to land, so nobody wonders whether it worked.
@@ -389,7 +495,7 @@ export async function forgetWorkspace(env, baseUrl) {
389
495
  return true;
390
496
  }
391
497
  /** The working fund command every fund error shows, so one try is enough. */
392
- const FUND_EXAMPLE = 'For example: phantom fund --amount 10 --card (or --coin usdc).';
498
+ const FUND_EXAMPLE = 'For example: phantom fund --amount 10 --card (or --coin usdc-base).';
393
499
  /**
394
500
  * `--amount` as dollars: `10`, `10.50` or `$10`. A bare `--amount` is
395
501
  * usually `--amount $5` after the shell has replaced `$5` with nothing, so
@@ -422,13 +528,20 @@ function leaveFund(input) {
422
528
  async function whichKey(input, saved, endpoint, verb) {
423
529
  const { flags } = input;
424
530
  const view = await wire(saved.base_url, 'GET', endpoint, undefined, saved.management_credential);
425
- const named = (id) => ({ id, name: view.keys.find((k) => k.id === id)?.name ?? 'Key' });
531
+ const named = (id) => ({
532
+ id,
533
+ name: view.keys.find((k) => k.id === id)?.name ?? 'Key',
534
+ });
426
535
  if (typeof flags.id === 'string')
427
536
  return named(findKey(view.keys, flags.id));
428
537
  const pick = pickIo(input);
429
538
  if (!pick)
430
539
  die(`Say which key with --id: its id, name or start. For example: phantom keys ${verb === 'change' ? 'set' : verb} --id CI${verb === 'change' ? ' --limit 5' : ''}`, 'key_usage');
431
- const chosen = await choose(pick, `Which key do you want to ${verb}?`, view.keys.map((k) => ({ label: k.name ?? 'Key', hint: `${k.prefix ?? ''} · id ${k.id.slice(0, 8)} · spent $${(k.spent_usd ?? 0).toFixed(2)}`, value: k.id })));
540
+ const chosen = await choose(pick, `Which key do you want to ${verb}?`, view.keys.map((k) => ({
541
+ label: k.name ?? 'Key',
542
+ hint: `${k.prefix ?? ''} · id ${k.id.slice(0, 8)} · spent $${(k.spent_usd ?? 0).toFixed(2)}`,
543
+ value: k.id,
544
+ })));
432
545
  if (chosen === null && input.io.fromMenu)
433
546
  throw new BackToMenu();
434
547
  if (chosen === null)
@@ -466,8 +579,16 @@ function savedNameFor(env, id) {
466
579
  /** A limit picker: no limit, or a few round amounts. undefined means Esc. */
467
580
  async function chooseLimit(pick) {
468
581
  const limit = await choose({ ...pick, esc: 'back' }, 'Spending limit for this key?', [
469
- { label: 'No limit', hint: 'it can spend the whole workspace balance', value: 'none' },
470
- ...[5, 10, 25, 50, 100].map((n) => ({ label: `$${n}`, hint: 'then it stops working until you raise it', value: n })),
582
+ {
583
+ label: 'No limit',
584
+ hint: 'it can spend the whole workspace balance',
585
+ value: 'none',
586
+ },
587
+ ...[5, 10, 25, 50, 100].map((n) => ({
588
+ label: `$${n}`,
589
+ hint: 'then it stops working until you raise it',
590
+ value: n,
591
+ })),
471
592
  ]);
472
593
  return limit === null ? undefined : limit === 'none' ? null : limit;
473
594
  }
@@ -489,11 +610,20 @@ async function newKeyForm(input, pick, saved, endpoint) {
489
610
  return leaveKeys(input);
490
611
  const result = await wire(saved.base_url, 'POST', endpoint + '/keys', { name, limit_usd: limit }, saved.management_credential);
491
612
  saveNamedKey(env, name, result.api_key);
492
- const style = { env, color: colorOn(env, io.stdoutIsTTY), storage: keychainOn(env) ? 'macOS Keychain' : 'private files', limit };
613
+ const style = {
614
+ env,
615
+ color: colorOn(env, io.stdoutIsTTY),
616
+ storage: keychainOn(env) ? 'macOS Keychain' : 'private files',
617
+ limit,
618
+ };
493
619
  io.stdout(keyChangeScreen('created', name, style) + '\n');
494
620
  if (process.platform === 'darwin' && onPath('pbcopy')) {
495
621
  const copy = await choose({ ...pick, esc: 'back' }, 'Hand it to someone?', [
496
- { label: 'Copy the key to the clipboard', hint: 'then paste it to your teammate; it is not shown here', value: true },
622
+ {
623
+ label: 'Copy the key to the clipboard',
624
+ hint: 'then paste it to your teammate; it is not shown here',
625
+ value: true,
626
+ },
497
627
  { label: 'No, keep it saved here only', value: false },
498
628
  ]);
499
629
  if (copy) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phantomcodes/cli",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "AI inference for your coding agents. Route models, control spending, and fund your workspace.",
5
5
  "keywords": [
6
6
  "phantom",
@@ -43,8 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "jsonc-parser": "^3.3.1",
46
- "smol-toml": "^1.9.0",
47
- "zod": "^4.5.4"
46
+ "smol-toml": "^1.9.0"
48
47
  },
49
48
  "scripts": {
50
49
  "build": "tsc -p .",