@tempoxyz/mercator 0.0.343 → 0.0.346
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -27
- package/dist/claim.js +5 -5
- package/dist/claim.js.map +1 -1
- package/dist/fund.js +3 -3
- package/dist/fund.js.map +1 -1
- package/dist/index.d.ts +39 -67
- package/dist/index.js +133 -230
- package/dist/index.js.map +1 -1
- package/dist/submit.js +1 -1
- package/dist/submit.js.map +1 -1
- package/dist/wallet-selection.js +2 -2
- package/dist/wallet-selection.js.map +1 -1
- package/dist/wallet.d.ts +3 -1
- package/dist/wallet.js +15 -10
- package/dist/wallet.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TimeoutError as DeviceCodeTimeoutError } from 'accounts/deviceCode';
|
|
2
1
|
import { Cli, z } from 'incur';
|
|
3
2
|
import packageMetadata from '../package.json' with { type: 'json' };
|
|
4
3
|
import { installCodexAgents, removeCodexAgents } from './agents.js';
|
|
@@ -17,8 +16,26 @@ import { startTerminalSetupProgress } from './setup-progress.js';
|
|
|
17
16
|
import { SubmitError, submitPaidJob } from './submit.js';
|
|
18
17
|
import { styleText, supportsColor } from './terminal-style.js';
|
|
19
18
|
import { standaloneUpdate } from './update.js';
|
|
20
|
-
import { inspectWallet,
|
|
19
|
+
import { inspectWallet, inspectWalletProvider, openBrowserUrl, openFundingPage, setupWallet, useWallet, WalletProvider, WalletRequiredError, } from './wallet.js';
|
|
21
20
|
const DEFAULT_ENDPOINT = 'https://mercator.tempo.xyz/mcp/auth';
|
|
21
|
+
/** Tempo-authenticated management page for remote MCP grants and spending limits. */
|
|
22
|
+
const ACCOUNT_URL = 'https://mercator.tempo.xyz/account?login=1';
|
|
23
|
+
/** Concise human help for the remote-first installer and recovery surface. */
|
|
24
|
+
const ROOT_HELP = `mercator@${packageMetadata.version} — Connect your agent to Mercator
|
|
25
|
+
|
|
26
|
+
Usage: mercator <command>
|
|
27
|
+
|
|
28
|
+
Commands:
|
|
29
|
+
setup Connect Mercator to installed agent clients
|
|
30
|
+
status Show configured clients and connection state
|
|
31
|
+
doctor Diagnose remote MCP connectivity
|
|
32
|
+
account Manage wallet access, spending limits, and MACH claims
|
|
33
|
+
uninstall Remove Mercator integrations
|
|
34
|
+
|
|
35
|
+
Advanced:
|
|
36
|
+
local Local-wallet REST recovery when remote MCP is unavailable
|
|
37
|
+
|
|
38
|
+
Run \`mercator <command> --help\` for command options.`;
|
|
22
39
|
const defaultDependencies = {
|
|
23
40
|
claimMach,
|
|
24
41
|
confirmSetup,
|
|
@@ -33,13 +50,14 @@ const defaultDependencies = {
|
|
|
33
50
|
installGrokMarketplacePlugin,
|
|
34
51
|
authorizeMcpClient,
|
|
35
52
|
inspectWallet,
|
|
36
|
-
|
|
53
|
+
inspectWalletProvider,
|
|
37
54
|
installedClients,
|
|
38
55
|
mergeConfigFile,
|
|
39
56
|
removeCodexAgents,
|
|
40
57
|
removeCodexMarketplacePlugin,
|
|
41
58
|
removeCodexPlugin,
|
|
42
59
|
removeConfigFile,
|
|
60
|
+
openBrowserUrl,
|
|
43
61
|
openFundingPage,
|
|
44
62
|
protectGrokConfig,
|
|
45
63
|
runCommand: runInteractiveCommand,
|
|
@@ -93,6 +111,9 @@ const jobGetArgs = z.object({
|
|
|
93
111
|
const jobGetOptions = z.object({
|
|
94
112
|
wait: z.boolean().default(false).describe('Poll until the job is terminal'),
|
|
95
113
|
});
|
|
114
|
+
const endpointOptions = z.object({
|
|
115
|
+
url: z.url().default(DEFAULT_ENDPOINT).describe('Mercator MCP endpoint'),
|
|
116
|
+
});
|
|
96
117
|
/** Creates the Mercator CLI router with injectable side-effect dependencies. */
|
|
97
118
|
export function createMercatorCli(overrides = {}) {
|
|
98
119
|
const dependencies = { ...defaultDependencies, ...overrides };
|
|
@@ -111,21 +132,8 @@ export function createMercatorCli(overrides = {}) {
|
|
|
111
132
|
? result
|
|
112
133
|
: formatSetupResult(result, supportsColor(process.stdout, options.color));
|
|
113
134
|
};
|
|
114
|
-
const runWalletSetup = async (context
|
|
115
|
-
|
|
116
|
-
try {
|
|
117
|
-
report = await dependencies.setupWallet(action ? { action } : {});
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
if (error instanceof DeviceCodeTimeoutError) {
|
|
121
|
-
return context.error({
|
|
122
|
-
code: 'WALLET_CONNECT_TIMEOUT',
|
|
123
|
-
exitCode: 1,
|
|
124
|
-
message: 'Tempo Wallet authorization timed out. Run `mercator wallet connect` to start a fresh request.',
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
throw error;
|
|
128
|
-
}
|
|
135
|
+
const runWalletSetup = async (context) => {
|
|
136
|
+
const report = await dependencies.setupWallet({ action: 'create' });
|
|
129
137
|
if (report.sessionClient !== 'ready') {
|
|
130
138
|
return context.error({
|
|
131
139
|
code: 'WALLET_REQUIRED',
|
|
@@ -135,6 +143,7 @@ export function createMercatorCli(overrides = {}) {
|
|
|
135
143
|
}
|
|
136
144
|
return { ready: true, report };
|
|
137
145
|
};
|
|
146
|
+
const inspectFallbackWallet = async () => dependencies.inspectWalletProvider(WalletProvider.Local);
|
|
138
147
|
const runWalletClaim = async (context, provider) => {
|
|
139
148
|
const report = await dependencies.inspectWallet();
|
|
140
149
|
if (!report.address || !report.provider || report.sessionClient !== 'ready') {
|
|
@@ -142,12 +151,11 @@ export function createMercatorCli(overrides = {}) {
|
|
|
142
151
|
code: 'WALLET_REQUIRED',
|
|
143
152
|
exitCode: 1,
|
|
144
153
|
message: [
|
|
145
|
-
'Set up a
|
|
146
|
-
' mercator wallet create',
|
|
147
|
-
' mercator wallet connect',
|
|
154
|
+
'Set up a local claim wallet first:',
|
|
155
|
+
' mercator local wallet create',
|
|
148
156
|
'',
|
|
149
157
|
'Then run:',
|
|
150
|
-
` mercator
|
|
158
|
+
` mercator account claim ${provider}`,
|
|
151
159
|
].join('\n'),
|
|
152
160
|
});
|
|
153
161
|
}
|
|
@@ -170,7 +178,7 @@ export function createMercatorCli(overrides = {}) {
|
|
|
170
178
|
return context.error({
|
|
171
179
|
code: 'INVALID_ARGUMENT',
|
|
172
180
|
exitCode: 1,
|
|
173
|
-
message: `Run without additional arguments:\n mercator
|
|
181
|
+
message: `Run without additional arguments:\n mercator account claim ${provider}`,
|
|
174
182
|
});
|
|
175
183
|
}
|
|
176
184
|
return runWalletClaim(context, provider);
|
|
@@ -179,11 +187,11 @@ export function createMercatorCli(overrides = {}) {
|
|
|
179
187
|
additionalArguments: z.array(z.string()).default([]).describe('Must be omitted'),
|
|
180
188
|
});
|
|
181
189
|
const claimCommand = Cli.create('claim', {
|
|
182
|
-
description: 'Claim the one-time MACH grant
|
|
190
|
+
description: 'Claim the one-time MACH grant to a stored wallet',
|
|
183
191
|
run: async (context) => context.error({
|
|
184
192
|
code: 'CLAIM_PROVIDER_REQUIRED',
|
|
185
193
|
exitCode: 1,
|
|
186
|
-
message: 'Choose a claim provider:\n mercator
|
|
194
|
+
message: 'Choose a claim provider:\n mercator account claim github\n mercator account claim x',
|
|
187
195
|
}),
|
|
188
196
|
})
|
|
189
197
|
.command('github', {
|
|
@@ -198,55 +206,28 @@ export function createMercatorCli(overrides = {}) {
|
|
|
198
206
|
run: async (context) => runExactWalletClaim(context, ClaimProvider.X),
|
|
199
207
|
usage: [{}],
|
|
200
208
|
});
|
|
201
|
-
const
|
|
202
|
-
description: '
|
|
203
|
-
run: async (
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
209
|
+
const accountCommand = Cli.create('account', {
|
|
210
|
+
description: 'Manage wallet access, spending limits, and MACH claims',
|
|
211
|
+
run: async () => {
|
|
212
|
+
await dependencies.openBrowserUrl(ACCOUNT_URL);
|
|
213
|
+
return { opened: true, url: ACCOUNT_URL };
|
|
214
|
+
},
|
|
215
|
+
}).command(claimCommand);
|
|
216
|
+
const localWalletCommand = Cli.create('wallet', {
|
|
217
|
+
description: 'Manage the local wallet used only for REST fallback',
|
|
208
218
|
})
|
|
209
219
|
.command('create', {
|
|
210
|
-
description: 'Create or activate the local
|
|
211
|
-
run: async (context) => runWalletSetup(context
|
|
212
|
-
})
|
|
213
|
-
.command('list', {
|
|
214
|
-
description: 'List stored wallets; the active wallet pays for jobs',
|
|
215
|
-
run: async () => dependencies.listWallets(),
|
|
216
|
-
})
|
|
217
|
-
.command('use', {
|
|
218
|
-
aliases: ['switch'],
|
|
219
|
-
args: z.object({
|
|
220
|
-
provider: z
|
|
221
|
-
.enum([WalletProvider.Tempo, WalletProvider.Local])
|
|
222
|
-
.describe('Stored wallet provider to activate'),
|
|
223
|
-
}),
|
|
224
|
-
description: 'Use a stored wallet without browser authorization',
|
|
225
|
-
run: async (context) => {
|
|
226
|
-
try {
|
|
227
|
-
const report = await dependencies.useWallet(context.args.provider);
|
|
228
|
-
return { active: context.args.provider, report };
|
|
229
|
-
}
|
|
230
|
-
catch (error) {
|
|
231
|
-
if (error instanceof WalletRequiredError) {
|
|
232
|
-
return context.error({
|
|
233
|
-
code: error.code,
|
|
234
|
-
exitCode: 1,
|
|
235
|
-
message: error.message,
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
throw error;
|
|
239
|
-
}
|
|
240
|
-
},
|
|
220
|
+
description: 'Create or activate the local REST fallback wallet',
|
|
221
|
+
run: async (context) => runWalletSetup(context),
|
|
241
222
|
})
|
|
242
223
|
.command('status', {
|
|
243
|
-
description: 'Show
|
|
244
|
-
run: async () =>
|
|
224
|
+
description: 'Show local REST fallback wallet readiness',
|
|
225
|
+
run: async () => inspectFallbackWallet(),
|
|
245
226
|
})
|
|
246
227
|
.command('balance', {
|
|
247
|
-
description: 'Show the
|
|
228
|
+
description: 'Show the local REST fallback wallet balance',
|
|
248
229
|
run: async (context) => {
|
|
249
|
-
const report = await
|
|
230
|
+
const report = await inspectFallbackWallet();
|
|
250
231
|
if (!report.address ||
|
|
251
232
|
!report.provider ||
|
|
252
233
|
report.sessionClient !== 'ready' ||
|
|
@@ -266,9 +247,9 @@ export function createMercatorCli(overrides = {}) {
|
|
|
266
247
|
})
|
|
267
248
|
.command('fund', {
|
|
268
249
|
args: fundArgs,
|
|
269
|
-
description: 'Buy MACH for the
|
|
250
|
+
description: 'Buy MACH for the local REST fallback wallet',
|
|
270
251
|
run: async (context) => {
|
|
271
|
-
const report = await
|
|
252
|
+
const report = await inspectFallbackWallet();
|
|
272
253
|
if (!report.address || !report.provider || report.sessionClient !== 'ready') {
|
|
273
254
|
return context.error({
|
|
274
255
|
code: 'WALLET_REQUIRED',
|
|
@@ -306,14 +287,13 @@ export function createMercatorCli(overrides = {}) {
|
|
|
306
287
|
url: result.url,
|
|
307
288
|
};
|
|
308
289
|
},
|
|
309
|
-
})
|
|
310
|
-
.command(claimCommand);
|
|
290
|
+
});
|
|
311
291
|
const jobCommand = Cli.create('job', {
|
|
312
|
-
description: 'Inspect
|
|
292
|
+
description: 'Inspect jobs submitted through REST fallback',
|
|
313
293
|
run: async (context) => context.error({
|
|
314
294
|
code: 'JOB_ACTION_REQUIRED',
|
|
315
295
|
exitCode: 1,
|
|
316
|
-
message: 'Choose a job action:\n mercator job get <id>',
|
|
296
|
+
message: 'Choose a job action:\n mercator local job get <id>',
|
|
317
297
|
}),
|
|
318
298
|
}).command('get', {
|
|
319
299
|
args: jobGetArgs,
|
|
@@ -321,21 +301,47 @@ export function createMercatorCli(overrides = {}) {
|
|
|
321
301
|
options: jobGetOptions,
|
|
322
302
|
run: async (context) => dependencies.getJob({ ...context.args, ...context.options }),
|
|
323
303
|
});
|
|
304
|
+
const localCommand = Cli.create('local', {
|
|
305
|
+
description: 'Use a local wallet only when remote MCP submission is unavailable',
|
|
306
|
+
})
|
|
307
|
+
.command(localWalletCommand)
|
|
308
|
+
.command(jobCommand)
|
|
309
|
+
.command('submit', {
|
|
310
|
+
description: 'Submit a bounded REST fallback with an existing local wallet',
|
|
311
|
+
options: submitOptions,
|
|
312
|
+
run: async (context) => {
|
|
313
|
+
try {
|
|
314
|
+
await dependencies.useWallet(WalletProvider.Local);
|
|
315
|
+
return await dependencies.submitPaidJob(context.options);
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
if (error instanceof WalletRequiredError || error instanceof SubmitError) {
|
|
319
|
+
return context.error({
|
|
320
|
+
code: error.code,
|
|
321
|
+
exitCode: 1,
|
|
322
|
+
message: error.message,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
throw error;
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
});
|
|
324
329
|
return Cli.create('mercator', {
|
|
325
|
-
description: '
|
|
326
|
-
examples: [
|
|
327
|
-
{ description: 'Set up Mercator for Codex', options: { client: [Client.Codex] } },
|
|
328
|
-
],
|
|
329
|
-
options: setupOptions,
|
|
330
|
+
description: 'Connect your agent to the Mercator remote MCP server',
|
|
330
331
|
update: standaloneUpdate(),
|
|
331
332
|
version: packageMetadata.version,
|
|
332
|
-
run: async (context) => runSetup(context, context.options),
|
|
333
333
|
})
|
|
334
334
|
.command('setup', {
|
|
335
|
-
description: '
|
|
335
|
+
description: 'Connect Mercator to installed agent clients',
|
|
336
336
|
options: setupOptions,
|
|
337
337
|
run: async (context) => runSetup(context, context.options),
|
|
338
338
|
})
|
|
339
|
+
.command('status', {
|
|
340
|
+
description: 'Show installed clients and their Mercator connection state',
|
|
341
|
+
options: endpointOptions,
|
|
342
|
+
run: async (context) => clientStatus(context.options.url, dependencies),
|
|
343
|
+
})
|
|
344
|
+
.command(accountCommand)
|
|
339
345
|
.command('uninstall', {
|
|
340
346
|
description: 'Remove Mercator MCP registrations, plugin, and managed guidance',
|
|
341
347
|
destructive: true,
|
|
@@ -350,32 +356,10 @@ export function createMercatorCli(overrides = {}) {
|
|
|
350
356
|
return uninstall(context.options, dependencies);
|
|
351
357
|
},
|
|
352
358
|
})
|
|
353
|
-
.command(
|
|
354
|
-
.command(jobCommand)
|
|
355
|
-
.command('submit', {
|
|
356
|
-
description: 'Submit a bounded REST fallback with an existing Mercator wallet',
|
|
357
|
-
options: submitOptions,
|
|
358
|
-
run: async (context) => {
|
|
359
|
-
try {
|
|
360
|
-
return await dependencies.submitPaidJob(context.options);
|
|
361
|
-
}
|
|
362
|
-
catch (error) {
|
|
363
|
-
if (error instanceof WalletRequiredError || error instanceof SubmitError) {
|
|
364
|
-
return context.error({
|
|
365
|
-
code: error.code,
|
|
366
|
-
exitCode: 1,
|
|
367
|
-
message: error.message,
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
throw error;
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
})
|
|
359
|
+
.command(localCommand)
|
|
374
360
|
.command('doctor', {
|
|
375
|
-
description: '
|
|
376
|
-
options:
|
|
377
|
-
url: z.url().default(DEFAULT_ENDPOINT).describe('Mercator MCP endpoint'),
|
|
378
|
-
}),
|
|
361
|
+
description: 'Diagnose remote MCP transport, discovery, and local integration',
|
|
362
|
+
options: endpointOptions,
|
|
379
363
|
run: async (context) => {
|
|
380
364
|
const progress = context.agent ? undefined : dependencies.startSetupProgress();
|
|
381
365
|
let result;
|
|
@@ -394,52 +378,18 @@ export function createMercatorCli(overrides = {}) {
|
|
|
394
378
|
}
|
|
395
379
|
return result;
|
|
396
380
|
},
|
|
397
|
-
})
|
|
398
|
-
.command('clients', {
|
|
399
|
-
description: 'List supported agent clients',
|
|
400
|
-
run: () => ({ clients: CLIENT_IDS }),
|
|
401
381
|
});
|
|
402
382
|
}
|
|
403
383
|
/** Runs the CLI and returns its exit code without terminating the current process. */
|
|
404
384
|
export async function run(argv, overrides = {}) {
|
|
385
|
+
if (argv.length === 0 ||
|
|
386
|
+
(argv.length === 1 && ['--help', '-h'].includes(argv[0] ?? ''))) {
|
|
387
|
+
console.log(ROOT_HELP);
|
|
388
|
+
return 0;
|
|
389
|
+
}
|
|
405
390
|
let exitCode = 0;
|
|
406
391
|
let frameworkOutput = '';
|
|
407
|
-
const commands = new Set([
|
|
408
|
-
'clients',
|
|
409
|
-
'doctor',
|
|
410
|
-
'job',
|
|
411
|
-
'setup',
|
|
412
|
-
'submit',
|
|
413
|
-
'uninstall',
|
|
414
|
-
'wallet',
|
|
415
|
-
]);
|
|
416
|
-
const walletCommands = new Set([
|
|
417
|
-
'balance',
|
|
418
|
-
'claim',
|
|
419
|
-
'connect',
|
|
420
|
-
'create',
|
|
421
|
-
'fund',
|
|
422
|
-
'list',
|
|
423
|
-
'switch',
|
|
424
|
-
'status',
|
|
425
|
-
'use',
|
|
426
|
-
]);
|
|
427
|
-
const setupFlags = new Set([
|
|
428
|
-
'--agents',
|
|
429
|
-
'--client',
|
|
430
|
-
'--color',
|
|
431
|
-
'--dry-run',
|
|
432
|
-
'--force',
|
|
433
|
-
'--no-agents',
|
|
434
|
-
'--no-color',
|
|
435
|
-
'--no-plugin',
|
|
436
|
-
'--no-skill',
|
|
437
|
-
'--plugin',
|
|
438
|
-
'--remove-agents',
|
|
439
|
-
'--skill',
|
|
440
|
-
'--url',
|
|
441
|
-
'--yes',
|
|
442
|
-
]);
|
|
392
|
+
const commands = new Set(['account', 'doctor', 'local', 'setup', 'status', 'uninstall']);
|
|
443
393
|
const requestedCommand = argv[0];
|
|
444
394
|
if (requestedCommand !== undefined &&
|
|
445
395
|
!requestedCommand.startsWith('-') &&
|
|
@@ -447,15 +397,7 @@ export async function run(argv, overrides = {}) {
|
|
|
447
397
|
console.error(`Unknown command: ${requestedCommand}\nRun \`mercator --help\` for usage.`);
|
|
448
398
|
return 1;
|
|
449
399
|
}
|
|
450
|
-
|
|
451
|
-
if (requestedWalletCommand !== undefined &&
|
|
452
|
-
!requestedWalletCommand.startsWith('-') &&
|
|
453
|
-
!walletCommands.has(requestedWalletCommand)) {
|
|
454
|
-
console.error(`Unknown command: ${requestedWalletCommand}\nRun \`mercator wallet --help\` for usage.`);
|
|
455
|
-
return 1;
|
|
456
|
-
}
|
|
457
|
-
const normalizedArgv = argv[0] && setupFlags.has(argv[0]) ? ['setup', ...argv] : argv;
|
|
458
|
-
await createMercatorCli(overrides).serve(normalizedArgv, {
|
|
400
|
+
await createMercatorCli(overrides).serve(argv, {
|
|
459
401
|
exit: (code) => {
|
|
460
402
|
exitCode = code;
|
|
461
403
|
},
|
|
@@ -698,38 +640,17 @@ async function setup(options, dependencies, progress) {
|
|
|
698
640
|
warnings.push(`Codex guidance skipped: ${errorMessage(error)}. MCP access is unaffected; rerun mercator setup --agents to retry.`);
|
|
699
641
|
}
|
|
700
642
|
}
|
|
701
|
-
progress?.report('Checking native payment integrations...');
|
|
702
643
|
let nativePayments = [];
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
dryRun: options.dryRun || options.force,
|
|
706
|
-
endpoint: options.url,
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
catch (error) {
|
|
710
|
-
warnings.push(`Native payment setup skipped: ${errorMessage(error)}. Free operations remain available; rerun mercator setup to retry.`);
|
|
711
|
-
}
|
|
712
|
-
const hasGenericClient = !isProtectedMcpEndpoint(options.url) &&
|
|
713
|
-
(plugin !== undefined ||
|
|
714
|
-
clients.some((client) => client !== Client.OpenClaw && client !== Client.Hermes));
|
|
715
|
-
let walletReport;
|
|
716
|
-
if (hasGenericClient) {
|
|
644
|
+
if (clients.some((client) => client === Client.OpenClaw || client === Client.Hermes)) {
|
|
645
|
+
progress?.report('Checking client-managed MCP payments...');
|
|
717
646
|
try {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
722
|
-
else {
|
|
723
|
-
progress?.report('Preparing payment wallet...');
|
|
724
|
-
walletReport = await dependencies.setupWallet({
|
|
725
|
-
allowSkip: true,
|
|
726
|
-
dryRun: options.dryRun,
|
|
727
|
-
...(progress ? { globe: progress.globe } : {}),
|
|
728
|
-
});
|
|
729
|
-
}
|
|
647
|
+
nativePayments = await dependencies.setupNativePayments(clients, {
|
|
648
|
+
dryRun: options.dryRun || options.force,
|
|
649
|
+
endpoint: options.url,
|
|
650
|
+
});
|
|
730
651
|
}
|
|
731
652
|
catch (error) {
|
|
732
|
-
warnings.push(`
|
|
653
|
+
warnings.push(`Client-managed payment setup skipped: ${errorMessage(error)}. Retry with mercator setup.`);
|
|
733
654
|
}
|
|
734
655
|
}
|
|
735
656
|
if (options.dryRun) {
|
|
@@ -742,7 +663,6 @@ async function setup(options, dependencies, progress) {
|
|
|
742
663
|
...(marketplacePlugins.length > 0 ? { marketplacePlugins } : {}),
|
|
743
664
|
ready: true,
|
|
744
665
|
warnings,
|
|
745
|
-
...(walletReport ? { wallet: withoutBalances(walletReport) } : {}),
|
|
746
666
|
};
|
|
747
667
|
}
|
|
748
668
|
progress?.report('Running Mercator readiness checks...');
|
|
@@ -786,7 +706,6 @@ async function setup(options, dependencies, progress) {
|
|
|
786
706
|
(integrationReady ||
|
|
787
707
|
marketplacePlugins.some(({ status }) => status === 'configured')),
|
|
788
708
|
warnings,
|
|
789
|
-
...(walletReport ? { wallet: withoutBalances(walletReport) } : {}),
|
|
790
709
|
};
|
|
791
710
|
}
|
|
792
711
|
function unavailableClientGuidance(client) {
|
|
@@ -828,7 +747,9 @@ function setupConfirmationActions(clients, options) {
|
|
|
828
747
|
if (options.agents && (options.plugin || clients.includes(Client.Codex))) {
|
|
829
748
|
actions.push('Install Mercator guidance');
|
|
830
749
|
}
|
|
831
|
-
|
|
750
|
+
if (clients.some((client) => client === Client.OpenClaw || client === Client.Hermes)) {
|
|
751
|
+
actions.push('Configure client-managed MCP payments');
|
|
752
|
+
}
|
|
832
753
|
return actions;
|
|
833
754
|
}
|
|
834
755
|
async function removeClientConfiguration(client, dependencies) {
|
|
@@ -946,16 +867,6 @@ function formatSetupResult(result, color = false) {
|
|
|
946
867
|
}
|
|
947
868
|
}
|
|
948
869
|
}
|
|
949
|
-
if ('wallet' in result && result.wallet) {
|
|
950
|
-
const walletLabel = result.wallet.provider
|
|
951
|
-
? `${result.wallet.provider === 'tempo' ? 'Tempo' : 'Local'} wallet`
|
|
952
|
-
: 'Payment wallet';
|
|
953
|
-
const glyph = result.wallet.status === 'ready' ? '✓' : '!';
|
|
954
|
-
readiness.push(formatSetupRow(glyph, walletLabel, humanizeStatus(result.wallet.status), color));
|
|
955
|
-
if (result.wallet.status !== 'ready') {
|
|
956
|
-
readiness.push(...result.wallet.guidance.map((guidance) => ` ${guidance}`));
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
870
|
if ('diagnosis' in result) {
|
|
960
871
|
readiness.push(formatSetupRow(result.diagnosis.transport === 'ready' ? '✓' : '✗', 'MCP transport', humanizeStatus(result.diagnosis.transport), color), formatSetupRow(result.diagnosis.discovery === 'ready'
|
|
961
872
|
? '✓'
|
|
@@ -983,10 +894,8 @@ function formatSetupResult(result, color = false) {
|
|
|
983
894
|
lines.push('', 'Your completed setup was preserved.', '', 'Retry readiness checks:', ' mercator doctor');
|
|
984
895
|
return lines.join('\n');
|
|
985
896
|
}
|
|
986
|
-
const wallet = 'wallet' in result ? result.wallet : undefined;
|
|
987
897
|
const nativePaymentsReady = 'nativePayments' in result &&
|
|
988
898
|
result.nativePayments.every((payment) => payment.status === 'ready');
|
|
989
|
-
const paymentsReady = nativePaymentsReady && (wallet === undefined || wallet.status === 'ready');
|
|
990
899
|
const pluginReload = 'plugin' in result && result.plugin ? result.plugin.reloadRequired : false;
|
|
991
900
|
const agentsReload = 'agents' in result && result.agents && 'reloadRequired' in result.agents
|
|
992
901
|
? result.agents.reloadRequired
|
|
@@ -1003,21 +912,10 @@ function formatSetupResult(result, color = false) {
|
|
|
1003
912
|
lines.push('Restart Codex to load the updated guidance.');
|
|
1004
913
|
}
|
|
1005
914
|
}
|
|
1006
|
-
if (!paymentsReady) {
|
|
1007
|
-
lines.push('', 'Free operations are ready.');
|
|
1008
|
-
if (wallet?.status === 'needs_funding') {
|
|
1009
|
-
lines.push('', 'Enable paid jobs:', ' mercator wallet claim github', ' mercator wallet claim x', ' mercator wallet fund');
|
|
1010
|
-
}
|
|
1011
|
-
else {
|
|
1012
|
-
const walletCommand = walletAction(wallet);
|
|
1013
|
-
if (walletCommand)
|
|
1014
|
-
lines.push('', 'Enable paid jobs:', ` ${walletCommand}`);
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
915
|
const everythingCurrent = result.clients.every((client) => client.status === 'already_configured') &&
|
|
1018
916
|
(!('plugin' in result) || result.plugin?.status === 'already_configured') &&
|
|
1019
917
|
(!('agents' in result) || result.agents?.state === 'current') &&
|
|
1020
|
-
|
|
918
|
+
nativePaymentsReady &&
|
|
1021
919
|
!pluginReload &&
|
|
1022
920
|
!agentsReload;
|
|
1023
921
|
if (everythingCurrent) {
|
|
@@ -1039,17 +937,6 @@ function formatSetupRow(glyph, label, status, color) {
|
|
|
1039
937
|
const detail = status ? ` — ${styleText(status, style, color)}` : '';
|
|
1040
938
|
return ` ${styleText(glyph, style, color)} ${label}${detail}`;
|
|
1041
939
|
}
|
|
1042
|
-
function walletAction(wallet) {
|
|
1043
|
-
if (!wallet || wallet.status === 'ready')
|
|
1044
|
-
return undefined;
|
|
1045
|
-
if (wallet.status === 'needs_funding')
|
|
1046
|
-
return 'mercator wallet fund';
|
|
1047
|
-
if (wallet.provider === 'tempo')
|
|
1048
|
-
return 'mercator wallet connect';
|
|
1049
|
-
if (wallet.provider === 'local')
|
|
1050
|
-
return 'mercator wallet create';
|
|
1051
|
-
return 'mercator wallet';
|
|
1052
|
-
}
|
|
1053
940
|
function humanizeStatus(status) {
|
|
1054
941
|
return status.replaceAll('_', ' ');
|
|
1055
942
|
}
|
|
@@ -1102,23 +989,39 @@ async function uninstall(options, dependencies) {
|
|
|
1102
989
|
preserved: ['wallets', 'keys', 'balances', 'payment_sessions', 'mpp_plugins'],
|
|
1103
990
|
};
|
|
1104
991
|
}
|
|
992
|
+
async function clientStatus(endpoint, dependencies) {
|
|
993
|
+
const installed = await dependencies.installedClients();
|
|
994
|
+
const clients = await Promise.all(installed.map(async (client) => {
|
|
995
|
+
const clientUrl = clientEndpoint(client, endpoint);
|
|
996
|
+
try {
|
|
997
|
+
return {
|
|
998
|
+
client,
|
|
999
|
+
endpoint: clientUrl,
|
|
1000
|
+
state: await dependencies.configurationState(setupPlan(client, clientUrl)),
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
catch (error) {
|
|
1004
|
+
return {
|
|
1005
|
+
client,
|
|
1006
|
+
endpoint: clientUrl,
|
|
1007
|
+
error: errorMessage(error),
|
|
1008
|
+
state: 'unknown',
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
}));
|
|
1012
|
+
return { clients, endpoint };
|
|
1013
|
+
}
|
|
1105
1014
|
async function doctor(options, dependencies, progress) {
|
|
1106
|
-
const [report,
|
|
1015
|
+
const [report, plugin] = await Promise.all([
|
|
1107
1016
|
dependencies.diagnose(options.url, undefined, progress?.report),
|
|
1108
|
-
dependencies.inspectWallet(),
|
|
1109
1017
|
dependencies.inspectCodexPlugin({ packageVersion: packageMetadata.version }),
|
|
1110
1018
|
]);
|
|
1111
|
-
const combined = { ...report, plugin
|
|
1019
|
+
const combined = { ...report, plugin };
|
|
1112
1020
|
return {
|
|
1113
|
-
ready: report.transport === 'ready' &&
|
|
1114
|
-
report.discovery === 'ready' &&
|
|
1115
|
-
walletReport.status === 'ready',
|
|
1021
|
+
ready: report.transport === 'ready' && report.discovery === 'ready',
|
|
1116
1022
|
report: combined,
|
|
1117
1023
|
};
|
|
1118
1024
|
}
|
|
1119
|
-
function withoutBalances({ balances: _, ...report }) {
|
|
1120
|
-
return report;
|
|
1121
|
-
}
|
|
1122
1025
|
async function diagnoseWithoutWallet(endpoint, dependencies, progress, authorization) {
|
|
1123
1026
|
const authenticatedFetch = authorization
|
|
1124
1027
|
? (input, init) => {
|
|
@@ -1133,5 +1036,5 @@ async function diagnoseWithoutWallet(endpoint, dependencies, progress, authoriza
|
|
|
1133
1036
|
report,
|
|
1134
1037
|
};
|
|
1135
1038
|
}
|
|
1136
|
-
export { diagnose, inspectCodexPlugin, inspectWallet, installClaudeMarketplacePlugin, installCodexMarketplacePlugin, installCodexPlugin, installGrokMarketplacePlugin,
|
|
1039
|
+
export { diagnose, inspectCodexPlugin, inspectWallet, inspectWalletProvider, installClaudeMarketplacePlugin, installCodexMarketplacePlugin, installCodexPlugin, installGrokMarketplacePlugin, openFundingPage, removeCodexMarketplacePlugin, removeCodexPlugin, setupPlan, setupWallet, useWallet, };
|
|
1137
1040
|
//# sourceMappingURL=index.js.map
|