@tempoxyz/mercator 0.0.322 → 0.0.329
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 +8 -4
- package/dist/binary.js +7 -0
- package/dist/binary.js.map +1 -1
- package/dist/clients.d.ts +5 -1
- package/dist/clients.js +62 -5
- package/dist/clients.js.map +1 -1
- package/dist/codex-marketplace.js +1 -1
- package/dist/codex-marketplace.js.map +1 -1
- package/dist/doctor.d.ts +1 -0
- package/dist/doctor.js +28 -2
- package/dist/doctor.js.map +1 -1
- package/dist/globe.d.ts +1 -0
- package/dist/globe.js +9 -6
- package/dist/globe.js.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +141 -55
- package/dist/index.js.map +1 -1
- package/dist/mcp-authorization.d.ts +18 -0
- package/dist/mcp-authorization.js +184 -0
- package/dist/mcp-authorization.js.map +1 -0
- package/dist/plugin-bundle/.claude-plugin/plugin.json +2 -2
- package/dist/plugin-bundle/.codex-plugin/plugin.json +6 -6
- package/dist/plugin-bundle/.cursor-plugin/plugin.json +16 -0
- package/dist/plugin-bundle/.mcp.json +2 -2
- package/dist/plugin-bundle/README.md +12 -2
- package/dist/plugin-bundle/assets/favicon.svg +6 -5
- package/dist/plugin-bundle/mcp.json +1 -1
- package/dist/plugin-bundle/plugin.json +3 -3
- package/dist/plugin-bundle/skills/mercator/SKILL.md +19 -27
- package/dist/plugin-bundle/skills/mercator/references/examples.md +2 -1
- package/dist/setup-confirmation.d.ts +1 -0
- package/dist/setup-confirmation.js +6 -3
- package/dist/setup-confirmation.js.map +1 -1
- package/dist/setup-progress.d.ts +6 -1
- package/dist/setup-progress.js +22 -4
- package/dist/setup-progress.js.map +1 -1
- package/dist/terminal-style.d.ts +17 -0
- package/dist/terminal-style.js +24 -0
- package/dist/terminal-style.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
2
|
+
import { createServer } from 'node:http';
|
|
3
|
+
import { openBrowserUrl } from './wallet.js';
|
|
4
|
+
/** OAuth client name shown by Tempo Wallet during installer-assisted Grok authorization. */
|
|
5
|
+
export const GROK_OAUTH_CLIENT_NAME = 'Grok';
|
|
6
|
+
const defaultDependencies = {
|
|
7
|
+
fetcher: fetch,
|
|
8
|
+
openUrl: openBrowserUrl,
|
|
9
|
+
random: randomBytes,
|
|
10
|
+
showUrl: (url) => console.error(`Open Tempo Wallet authorization:\n${url}`),
|
|
11
|
+
timeoutMs: 10 * 60 * 1_000,
|
|
12
|
+
};
|
|
13
|
+
/** Completes authorization-code PKCE and returns a bearer without exposing wallet keys. */
|
|
14
|
+
export async function authorizeMcpClient(endpoint, overrides = {}) {
|
|
15
|
+
const dependencies = { ...defaultDependencies, ...overrides };
|
|
16
|
+
const resource = new URL(endpoint);
|
|
17
|
+
if (resource.protocol !== 'https:' && resource.hostname !== '127.0.0.1') {
|
|
18
|
+
throw new Error('MCP authorization requires HTTPS');
|
|
19
|
+
}
|
|
20
|
+
const origin = resource.origin;
|
|
21
|
+
const state = base64Url(dependencies.random(32));
|
|
22
|
+
const verifier = base64Url(dependencies.random(32));
|
|
23
|
+
const challenge = base64Url(createHash('sha256').update(verifier).digest());
|
|
24
|
+
const callback = await listenForCallback(state, dependencies.timeoutMs);
|
|
25
|
+
try {
|
|
26
|
+
const client = await postJson(`${origin}/oauth/register`, {
|
|
27
|
+
client_name: GROK_OAUTH_CLIENT_NAME,
|
|
28
|
+
grant_types: ['authorization_code'],
|
|
29
|
+
redirect_uris: [callback.redirectUri],
|
|
30
|
+
response_types: ['code'],
|
|
31
|
+
token_endpoint_auth_method: 'none',
|
|
32
|
+
}, dependencies.fetcher);
|
|
33
|
+
const clientId = requiredString(client, 'client_id', 'OAuth registration');
|
|
34
|
+
const authorizationUrl = new URL('/authorize', origin);
|
|
35
|
+
authorizationUrl.search = new URLSearchParams({
|
|
36
|
+
client_id: clientId,
|
|
37
|
+
code_challenge: challenge,
|
|
38
|
+
code_challenge_method: 'S256',
|
|
39
|
+
redirect_uri: callback.redirectUri,
|
|
40
|
+
resource: resource.href,
|
|
41
|
+
response_type: 'code',
|
|
42
|
+
scope: 'mercator:tools',
|
|
43
|
+
state,
|
|
44
|
+
}).toString();
|
|
45
|
+
try {
|
|
46
|
+
await dependencies.openUrl(authorizationUrl.href);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
dependencies.showUrl(authorizationUrl.href);
|
|
50
|
+
}
|
|
51
|
+
const code = await callback.result;
|
|
52
|
+
const response = await dependencies.fetcher(`${origin}/oauth/token`, {
|
|
53
|
+
body: new URLSearchParams({
|
|
54
|
+
client_id: clientId,
|
|
55
|
+
code,
|
|
56
|
+
code_verifier: verifier,
|
|
57
|
+
grant_type: 'authorization_code',
|
|
58
|
+
redirect_uri: callback.redirectUri,
|
|
59
|
+
resource: resource.href,
|
|
60
|
+
}),
|
|
61
|
+
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
62
|
+
method: 'POST',
|
|
63
|
+
signal: AbortSignal.timeout(15_000),
|
|
64
|
+
});
|
|
65
|
+
const token = await readJson(response, 'OAuth token exchange');
|
|
66
|
+
if (!response.ok)
|
|
67
|
+
throw new Error(oauthError(token, 'OAuth token exchange failed'));
|
|
68
|
+
const accessToken = requiredString(token, 'access_token', 'OAuth token exchange');
|
|
69
|
+
const tokenType = requiredString(token, 'token_type', 'OAuth token exchange');
|
|
70
|
+
const expiresIn = token.expires_in;
|
|
71
|
+
if (tokenType.toLowerCase() !== 'bearer') {
|
|
72
|
+
throw new Error('OAuth token exchange returned an unsupported token type');
|
|
73
|
+
}
|
|
74
|
+
if (typeof expiresIn !== 'number' ||
|
|
75
|
+
!Number.isSafeInteger(expiresIn) ||
|
|
76
|
+
expiresIn <= 0) {
|
|
77
|
+
throw new Error('OAuth token exchange returned an invalid expiry');
|
|
78
|
+
}
|
|
79
|
+
return { authorization: `Bearer ${accessToken}`, expiresIn };
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
await callback.close();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function postJson(url, body, fetcher) {
|
|
86
|
+
const response = await fetcher(url, {
|
|
87
|
+
body: JSON.stringify(body),
|
|
88
|
+
headers: { 'content-type': 'application/json' },
|
|
89
|
+
method: 'POST',
|
|
90
|
+
signal: AbortSignal.timeout(15_000),
|
|
91
|
+
});
|
|
92
|
+
const result = await readJson(response, 'OAuth registration');
|
|
93
|
+
if (!response.ok)
|
|
94
|
+
throw new Error(oauthError(result, 'OAuth registration failed'));
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
async function readJson(response, operation) {
|
|
98
|
+
const value = (await response.json().catch(() => null));
|
|
99
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
100
|
+
throw new Error(`${operation} returned an invalid response`);
|
|
101
|
+
}
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
function requiredString(value, key, operation) {
|
|
105
|
+
const result = value[key];
|
|
106
|
+
if (typeof result !== 'string' || result.length === 0) {
|
|
107
|
+
throw new Error(`${operation} omitted ${key}`);
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
function oauthError(value, fallback) {
|
|
112
|
+
return typeof value.error_description === 'string'
|
|
113
|
+
? value.error_description
|
|
114
|
+
: typeof value.error === 'string'
|
|
115
|
+
? value.error
|
|
116
|
+
: fallback;
|
|
117
|
+
}
|
|
118
|
+
function base64Url(value) {
|
|
119
|
+
return value.toString('base64url');
|
|
120
|
+
}
|
|
121
|
+
async function listenForCallback(expectedState, timeoutMs) {
|
|
122
|
+
let resolveResult = () => undefined;
|
|
123
|
+
let rejectResult = () => undefined;
|
|
124
|
+
const result = new Promise((resolve, reject) => {
|
|
125
|
+
resolveResult = resolve;
|
|
126
|
+
rejectResult = reject;
|
|
127
|
+
});
|
|
128
|
+
// The browser can reject before the caller finishes awaiting the launcher.
|
|
129
|
+
void result.catch(() => undefined);
|
|
130
|
+
const server = createServer((request, response) => {
|
|
131
|
+
const url = new URL(request.url ?? '/', 'http://127.0.0.1');
|
|
132
|
+
if (request.method !== 'GET' || url.pathname !== '/callback') {
|
|
133
|
+
response.writeHead(404).end('Not found');
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const error = url.searchParams.get('error');
|
|
137
|
+
const state = url.searchParams.get('state');
|
|
138
|
+
const code = url.searchParams.get('code');
|
|
139
|
+
if (state !== expectedState || error || !code) {
|
|
140
|
+
response.writeHead(400, { 'content-type': 'text/plain; charset=utf-8' });
|
|
141
|
+
response.end('Mercator authorization failed. Return to the installer.');
|
|
142
|
+
rejectResult(new Error(error ?? 'OAuth callback validation failed'));
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
response.writeHead(200, { 'content-type': 'text/plain; charset=utf-8' });
|
|
146
|
+
response.end('Mercator connected. You can close this tab.');
|
|
147
|
+
resolveResult(code);
|
|
148
|
+
});
|
|
149
|
+
await listen(server);
|
|
150
|
+
const address = server.address();
|
|
151
|
+
if (!address || typeof address === 'string') {
|
|
152
|
+
await closeServer(server);
|
|
153
|
+
throw new Error('Could not start the OAuth callback listener');
|
|
154
|
+
}
|
|
155
|
+
const timer = setTimeout(() => rejectResult(new Error('Tempo Wallet authorization timed out')), timeoutMs);
|
|
156
|
+
timer.unref();
|
|
157
|
+
return {
|
|
158
|
+
close: async () => {
|
|
159
|
+
clearTimeout(timer);
|
|
160
|
+
await closeServer(server);
|
|
161
|
+
},
|
|
162
|
+
redirectUri: `http://127.0.0.1:${address.port}/callback`,
|
|
163
|
+
result,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function listen(server) {
|
|
167
|
+
return new Promise((resolve, reject) => {
|
|
168
|
+
server.once('error', reject);
|
|
169
|
+
server.listen(0, '127.0.0.1', () => {
|
|
170
|
+
server.off('error', reject);
|
|
171
|
+
resolve();
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function closeServer(server) {
|
|
176
|
+
return new Promise((resolve, reject) => {
|
|
177
|
+
if (!server.listening) {
|
|
178
|
+
resolve();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
server.close((error) => (error ? reject(error) : resolve()));
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=mcp-authorization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-authorization.js","sourceRoot":"","sources":["../src/mcp-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAA;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,4FAA4F;AAC5F,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAA;AAgB5C,MAAM,mBAAmB,GAA8B;IACtD,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,qCAAqC,GAAG,EAAE,CAAC;IAC3E,SAAS,EAAE,EAAE,GAAG,EAAE,GAAG,KAAK;CAC1B,CAAA;AAED,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,QAAgB,EAChB,YAAgD,EAAE;IAElD,MAAM,YAAY,GAAG,EAAE,GAAG,mBAAmB,EAAE,GAAG,SAAS,EAAE,CAAA;IAC7D,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAA;IAClC,IAAI,QAAQ,CAAC,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;IACpD,CAAC;IACD,MAAM,MAAM,GA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": "mercator",
|
|
4
4
|
"displayName": "Mercator",
|
|
5
|
-
"version": "0.
|
|
6
|
-
"description": "Discover,
|
|
5
|
+
"version": "0.3.0",
|
|
6
|
+
"description": "Discover, quote, and run paid API workflows through one secure MCP connection. Connect a Tempo Wallet once; no local CLI or wallet setup.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Tempo"
|
|
9
9
|
},
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mercator",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Discover,
|
|
3
|
+
"version": "0.3.0+codex.20260901193640",
|
|
4
|
+
"description": "Discover, quote, and run paid API workflows through one secure MCP connection. Connect a Tempo Wallet once; no local CLI or wallet setup.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Tempo",
|
|
7
7
|
"url": "https://tempo.xyz/"
|
|
8
8
|
},
|
|
9
|
-
"homepage": "https://mercator.
|
|
9
|
+
"homepage": "https://mercator.tempo.xyz/",
|
|
10
10
|
"repository": "https://github.com/tempoxyz/mercator",
|
|
11
11
|
"keywords": ["api", "current data", "mercator", "mcp", "paid services", "tempo"],
|
|
12
12
|
"mcpServers": "./.mcp.json",
|
|
13
13
|
"skills": "./skills/",
|
|
14
14
|
"interface": {
|
|
15
15
|
"displayName": "Mercator",
|
|
16
|
-
"shortDescription": "Discover and run paid API workflows
|
|
17
|
-
"longDescription": "
|
|
16
|
+
"shortDescription": "Discover, quote, and run paid API workflows",
|
|
17
|
+
"longDescription": "Connect agents to current data and paid APIs through one remote MCP server. Authorize a limited Tempo Wallet key once; no CLI or wallet key is installed in the agent VM.",
|
|
18
18
|
"developerName": "Tempo",
|
|
19
19
|
"category": "Productivity",
|
|
20
20
|
"capabilities": ["Interactive", "Read", "Write"],
|
|
21
|
-
"websiteURL": "https://mercator.
|
|
21
|
+
"websiteURL": "https://mercator.tempo.xyz/",
|
|
22
22
|
"defaultPrompt": [
|
|
23
23
|
"Rescue my canceled Boston-to-London flight under $1,200; add a hotel and transfer if needed, then email the itinerary.",
|
|
24
24
|
"Find 15 overlooked Boston HVAC businesses, verify owner emails, flag outdated sites, and map a route from Back Bay.",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mercator",
|
|
3
|
+
"displayName": "Mercator",
|
|
4
|
+
"version": "0.3.0",
|
|
5
|
+
"description": "Discover, quote, and run paid API workflows through one secure MCP connection. Connect a Tempo Wallet once; no local CLI or wallet setup.",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Tempo"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://mercator.tempo.xyz/",
|
|
10
|
+
"repository": "https://github.com/tempoxyz/mercator",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"logo": "./assets/favicon.svg",
|
|
13
|
+
"keywords": ["api", "current-data", "mercator", "mcp", "payments", "tempo"],
|
|
14
|
+
"mcpServers": "./.mcp.json",
|
|
15
|
+
"skills": "./skills/"
|
|
16
|
+
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"mcpServers": {
|
|
3
3
|
"mercator": {
|
|
4
4
|
"type": "http",
|
|
5
|
-
"url": "https://mercator.tempo.xyz/mcp",
|
|
6
|
-
"note": "Mercator service discovery, live quotes,
|
|
5
|
+
"url": "https://mercator.tempo.xyz/mcp/auth",
|
|
6
|
+
"note": "Mercator remote MCP for service discovery, live quotes, secure Tempo payments, and durable paid jobs."
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# Mercator plugin
|
|
2
2
|
|
|
3
3
|
Use Mercator from Agent Plugins-compatible clients without configuring the MCP server manually. The
|
|
4
|
-
bundle connects to the
|
|
4
|
+
bundle connects to the OAuth Streamable HTTP server at
|
|
5
|
+
`https://mercator.tempo.xyz/mcp/auth`. The existing public `/mcp` endpoint remains available.
|
|
5
6
|
|
|
6
7
|
## Compatible clients
|
|
7
8
|
|
|
@@ -21,7 +22,12 @@ grok plugin install mercator@tempo
|
|
|
21
22
|
```
|
|
22
23
|
|
|
23
24
|
The public docs repository supplies the native marketplace manifests. After installation, start a
|
|
24
|
-
new conversation so the host loads both the Mercator MCP server and skill.
|
|
25
|
+
new conversation so the host loads both the Mercator MCP server and skill. OAuth-capable hosts show
|
|
26
|
+
a native **Authorize** action that opens Mercator's Account page; the user chooses USDC.e and MACH
|
|
27
|
+
limits for a 30-day access key retained in Mercator's encrypted OAuth grant, while the bot receives
|
|
28
|
+
only its OAuth bearer token. Grok CLI does not expose that authorization handoff itself; after
|
|
29
|
+
installing the plugin, run `mercator setup --client grok`. The installer opens the same Account flow
|
|
30
|
+
and writes the bearer to Grok's user MCP configuration without printing it.
|
|
25
31
|
|
|
26
32
|
### Grok Bot development
|
|
27
33
|
|
|
@@ -30,6 +36,9 @@ marketplace. Import this repository from **Dashboard → Plugins → Add Marketp
|
|
|
30
36
|
Repo**, then add `mercator` with **Default On** (or **Required** for a clean-room test group). The
|
|
31
37
|
repository-level `.cursor-plugin/marketplace.json` points at this portable Agent Plugin. Start a
|
|
32
38
|
fresh Bot after the marketplace refresh so the Mercator MCP tools are registered in the chat.
|
|
39
|
+
Click **Authorize** once on the Mercator MCP connection and complete Tempo Wallet in the opened web
|
|
40
|
+
page. The callback returns directly to Grok Bot; there is no terminal command to keep alive and no
|
|
41
|
+
"approved" chat message to send.
|
|
33
42
|
|
|
34
43
|
For a local Cursor development session, copy or symlink this directory to
|
|
35
44
|
`~/.cursor/plugins/local/mercator` and reload the window. That local path is not a substitute for a
|
|
@@ -78,6 +87,7 @@ Example requests:
|
|
|
78
87
|
|
|
79
88
|
- `plugin.json`: portable Agent Plugins metadata.
|
|
80
89
|
- `mcp.json`: portable Streamable HTTP MCP connection.
|
|
90
|
+
- `.cursor-plugin/plugin.json`: Grok Bot and Cursor display metadata, logo, MCP, and skills.
|
|
81
91
|
- `.codex-plugin/plugin.json`: Codex interface metadata and backwards-compatible manifest.
|
|
82
92
|
- `.claude-plugin/plugin.json`: Grok and Claude-compatible plugin metadata.
|
|
83
93
|
- repository `.cursor-plugin/marketplace.json`: Grok Bot/Cursor team-marketplace entry.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
<svg width="
|
|
1
|
+
<svg width="96" height="96" viewBox="0 0 96 96" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
2
|
<title>Mercator</title>
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
<ellipse cx="
|
|
6
|
-
<ellipse cx="
|
|
3
|
+
<rect width="96" height="96" fill="#0B0B0B" />
|
|
4
|
+
<circle cx="48" cy="48" r="30" stroke="#F2F1EC" stroke-width="1.5" />
|
|
5
|
+
<ellipse cx="48" cy="48" rx="20" ry="30" stroke="#F2F1EC" stroke-width="1.5" />
|
|
6
|
+
<ellipse cx="48" cy="48" rx="8" ry="30" stroke="#F2F1EC" stroke-width="1.5" />
|
|
7
|
+
<ellipse cx="48" cy="48" rx="30" ry="8" stroke="#F2F1EC" stroke-width="1.5" />
|
|
7
8
|
</svg>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "mercator",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "Discover,
|
|
4
|
+
"version": "0.3.0",
|
|
5
|
+
"description": "Discover, quote, and run paid API workflows through one secure MCP connection. Connect a Tempo Wallet once; no local CLI or wallet setup.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Tempo",
|
|
8
8
|
"url": "https://tempo.xyz/"
|
|
9
9
|
},
|
|
10
|
-
"homepage": "https://mercator.
|
|
10
|
+
"homepage": "https://mercator.tempo.xyz/",
|
|
11
11
|
"repository": "https://github.com/tempoxyz/mercator",
|
|
12
12
|
"keywords": ["api", "current data", "mercator", "mcp", "paid services", "tempo"]
|
|
13
13
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mercator
|
|
3
|
-
description: Use Mercator to discover, quote, and run fresh external research or API actions. Covers
|
|
3
|
+
description: Use Mercator to discover, quote, and run fresh external research or API actions across extraction, enrichment, social, maps, travel, communications, media, financial, and on-chain data. Covers REST job submission, durable status tracking, and recovery; not for local files, repository work, supplied-content reasoning, or requests that forbid external or paid services.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Mercator
|
|
@@ -10,17 +10,6 @@ outcome needs external capabilities, especially when it spans providers or domai
|
|
|
10
10
|
direct tool clearly covers the complete outcome with less overhead, use it. Otherwise, carry the
|
|
11
11
|
request through Mercator to a result instead of merely recommending a provider or API.
|
|
12
12
|
|
|
13
|
-
## Keep command families separate
|
|
14
|
-
|
|
15
|
-
Mercator MCP and the Mercator CLI are not the legacy Tempo Wallet CLI.
|
|
16
|
-
|
|
17
|
-
- Execute an MCP handoff by invoking `handoff.client.executable` with its `arguments` array exactly.
|
|
18
|
-
Do not rewrite, translate, or approximate it as a `tempo wallet ...` command.
|
|
19
|
-
- Mercator payment setup and recovery commands begin with `mercator wallet ...`. Tempo Wallet is one
|
|
20
|
-
provider behind `mercator wallet connect`; it is not the command namespace for Mercator jobs.
|
|
21
|
-
- If the `mercator` executable is unavailable, install Mercator with the exact setup command returned
|
|
22
|
-
by the MCP server. Do not substitute an older wallet or MPP CLI.
|
|
23
|
-
|
|
24
13
|
## Decide quickly
|
|
25
14
|
|
|
26
15
|
Use Mercator when all are true:
|
|
@@ -38,8 +27,8 @@ fastest way to determine whether Mercator can complete the request.
|
|
|
38
27
|
|
|
39
28
|
## Default workflow
|
|
40
29
|
|
|
41
|
-
`search_services` -> optional `describe_service` -> `quote_plan` -> approval ->
|
|
42
|
-
|
|
30
|
+
`search_services` -> optional `describe_service` -> `quote_plan` -> approval -> `create_job` ->
|
|
31
|
+
`get_job`
|
|
43
32
|
|
|
44
33
|
1. **Search for the outcome.** Give `search_services` the user's complete intended outcome,
|
|
45
34
|
constraints, and deliverable. Use static resolution unless current provider availability matters.
|
|
@@ -51,21 +40,24 @@ REST status listener
|
|
|
51
40
|
4. **Confirm scope and cost.** Before submitting the job, briefly state what will run and show
|
|
52
41
|
`totalAmount`. Proceed only when the requested actions are authorized and either the user accepts
|
|
53
42
|
the quote or a previously supplied budget covers it. A budget authorizes cost, not extra actions.
|
|
54
|
-
5. **Submit
|
|
55
|
-
quoted plan
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
returns
|
|
59
|
-
|
|
60
|
-
|
|
43
|
+
5. **Submit once.** Generate one stable 8-200 character idempotency key and call `create_job` with
|
|
44
|
+
the unchanged quoted plan and the accepted `totalAmount` as `approved_total`. If the refreshed
|
|
45
|
+
quote differs, no charge is made: quote again and ask the user to accept the new total. In an
|
|
46
|
+
OAuth-connected host, Mercator charges the browser-authorized, policy-bounded wallet capability
|
|
47
|
+
and returns the job directly. Continue immediately; do not wait
|
|
48
|
+
for the user to send a second "approved" message. The agent host receives no wallet private key.
|
|
49
|
+
A legacy client without hosted wallet authorization instead receives a structured handoff. Send
|
|
50
|
+
its exact `handoff.rest.method`, `url`, and `body`, bounded by `handoff.maxSpend`. The returned
|
|
51
|
+
`mercator` command is a ready-to-run client for this same REST request. Do not edit the body,
|
|
52
|
+
construct payment credentials, or call `create_job` again.
|
|
61
53
|
Treat `handoff.requestIdentity` as the stable review key only after verifying it from the
|
|
62
54
|
structured method, URL, body, and maximum spend. Invoke `handoff.client.executable` with its
|
|
63
55
|
argument array exactly. On hosts that accept only a command string, apply mechanically lossless
|
|
64
56
|
shell quoting to each argument so the child process receives the same argument array. Do not edit,
|
|
65
57
|
omit, reorder, or reinterpret arguments, and do not move the request body through a temporary file.
|
|
66
|
-
In Grok Bot, keep the same task alive while that argument array completes.
|
|
67
|
-
resumes the waiting command automatically; never ask the user to
|
|
68
|
-
|
|
58
|
+
In a legacy Grok Bot handoff, keep the same task alive while that argument array completes.
|
|
59
|
+
Browser approval resumes the waiting command automatically; never ask the user to send an
|
|
60
|
+
"approved" chat message. If authorization reports a timeout, inspect
|
|
69
61
|
`mercator wallet status` before opening a second authorization request. Continue immediately when
|
|
70
62
|
it reports ready; otherwise retry authorization once.
|
|
71
63
|
6. **Listen for completion.** Persist the returned `jobId` immediately; it is the only status and
|
|
@@ -77,9 +69,9 @@ REST status listener
|
|
|
77
69
|
equivalent when REST GET is unavailable.
|
|
78
70
|
|
|
79
71
|
For a warm Grok Bot installation, target less than two minutes from the user's request to a terminal
|
|
80
|
-
result, excluding the user's time reviewing the quoted charge.
|
|
81
|
-
|
|
82
|
-
approval or pending status transition.
|
|
72
|
+
result, excluding the user's time reviewing the quoted charge. OAuth authorization is a one-time
|
|
73
|
+
plugin connection, not a per-job wallet setup. Run discovery and description only as needed, and
|
|
74
|
+
continue automatically after every completed approval or pending status transition.
|
|
83
75
|
|
|
84
76
|
## Hard boundaries
|
|
85
77
|
|
|
@@ -84,7 +84,8 @@ Ask for that address; do not invent it or quietly remove the email step.
|
|
|
84
84
|
|
|
85
85
|
After approval, submit the unchanged quoted plan to `POST https://mercator.tempo.xyz/v1/jobs` with a
|
|
86
86
|
stable idempotency key and a payment spend limit equal to the approved quote. When using MCP, call
|
|
87
|
-
`create_job` once
|
|
87
|
+
`create_job` once with the accepted `totalAmount` as `approved_total`. If it returns a handoff, use
|
|
88
|
+
its exact REST request:
|
|
88
89
|
|
|
89
90
|
```text
|
|
90
91
|
handoff.rest: { method: POST, url: https://mercator.tempo.xyz/v1/jobs, body: {...} }
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline/promises';
|
|
2
2
|
import { openPromptInput } from './prompt-input.js';
|
|
3
|
+
import { styleText, supportsColor } from './terminal-style.js';
|
|
3
4
|
/** Resolves process-backed confirmation streams for the current invocation. */
|
|
4
5
|
const defaultStreams = () => ({
|
|
5
6
|
input: process.stdin,
|
|
@@ -18,9 +19,11 @@ export async function confirmSetup(actions, overrides = {}) {
|
|
|
18
19
|
streams.output.write(value);
|
|
19
20
|
streams.globe?.addLinesBelow(value.match(/\n/g)?.length ?? 0);
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const color = supportsColor(streams.output, streams.color);
|
|
23
|
+
write(`\n${styleText('Mercator will:', 'bold', color)}\n\n`);
|
|
24
|
+
for (const action of actions) {
|
|
25
|
+
write(` ${styleText('✓', 'green', color)} ${action}\n`);
|
|
26
|
+
}
|
|
24
27
|
write('\nContinue? [Y/n]: ');
|
|
25
28
|
const readline = createInterface({
|
|
26
29
|
input: promptInput.input,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-confirmation.js","sourceRoot":"","sources":["../src/setup-confirmation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAGxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"setup-confirmation.js","sourceRoot":"","sources":["../src/setup-confirmation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAGxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAU9D,+EAA+E;AAC/E,MAAM,cAAc,GAAG,GAA6B,EAAE,CAAC,CAAC;IACvD,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IACjE,MAAM,EAAE,OAAO,CAAC,MAAM;CACtB,CAAC,CAAA;AAEF,oEAAoE;AACpE,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC,OAA0B,EAC1B,YAA+C,EAAE;IAEjD,MAAM,OAAO,GAAG,EAAE,GAAG,cAAc,EAAE,EAAE,GAAG,SAAS,EAAE,CAAA;IACrD,IAAI,CAAC,OAAO,C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K,EAAE,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,KAAK;gBAAE,OAAO,IAAI,CAAA;YACpE,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,IAAI;gBAAE,OAAO,KAAK,CAAA;YACnD,KAAK,CAAC,wDAAwD,CAAC,CAAA;QAChE,CAAC;QACD,OAAO,KAAK,CAAA;IACb,CAAC;YAAS,CAAC;QACV,QAAQ,CAAC,KAAK,EAAE,CAAA;QAChB,WAAW,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;AACF,CAAC"}
|
package/dist/setup-progress.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type GlobeAnimation } from './globe.js';
|
|
2
2
|
/** Terminal progress renderer shared by the complete setup lifecycle. */
|
|
3
3
|
export type SetupProgress = {
|
|
4
|
+
readonly color?: boolean;
|
|
4
5
|
readonly globe: GlobeAnimation;
|
|
5
6
|
readonly report: (message: string) => void;
|
|
6
7
|
readonly stop: () => Promise<void>;
|
|
@@ -8,6 +9,10 @@ export type SetupProgress = {
|
|
|
8
9
|
/** Starts one globe and writes setup progress beneath it without disrupting redraws. */
|
|
9
10
|
export declare function startSetupProgress(output: NodeJS.WritableStream, options: {
|
|
10
11
|
readonly animate: boolean;
|
|
12
|
+
readonly color?: boolean;
|
|
13
|
+
readonly transient?: boolean;
|
|
11
14
|
}): SetupProgress;
|
|
12
15
|
/** Starts animated setup progress when stdout is an interactive terminal. */
|
|
13
|
-
export declare function startTerminalSetupProgress(
|
|
16
|
+
export declare function startTerminalSetupProgress(options?: {
|
|
17
|
+
readonly color?: boolean;
|
|
18
|
+
}): SetupProgress | undefined;
|
package/dist/setup-progress.js
CHANGED
|
@@ -1,22 +1,40 @@
|
|
|
1
1
|
import { startMercatorGlobe } from './globe.js';
|
|
2
|
+
import { styleText, supportsColor } from './terminal-style.js';
|
|
2
3
|
/** Starts one globe and writes setup progress beneath it without disrupting redraws. */
|
|
3
4
|
export function startSetupProgress(output, options) {
|
|
4
|
-
const
|
|
5
|
+
const color = options.color ?? false;
|
|
6
|
+
const globe = startMercatorGlobe(output, { animate: options.animate, color });
|
|
7
|
+
let hasProgressLine = false;
|
|
5
8
|
return {
|
|
9
|
+
color,
|
|
6
10
|
globe,
|
|
7
11
|
report: (message) => {
|
|
8
|
-
|
|
12
|
+
if (options.transient) {
|
|
13
|
+
if (!hasProgressLine)
|
|
14
|
+
globe.addLinesBelow(1);
|
|
15
|
+
output.write(`${hasProgressLine ? '\r\u001B[2K' : ''}${styleText('→', 'cyan', color)} ${styleText(message, 'dim', color)}`);
|
|
16
|
+
hasProgressLine = true;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
output.write(`${styleText('→', 'cyan', color)} ${message}\n`);
|
|
9
20
|
globe.addLinesBelow(1);
|
|
10
21
|
},
|
|
11
|
-
stop:
|
|
22
|
+
stop: async () => {
|
|
23
|
+
await globe.stop();
|
|
24
|
+
if (options.transient && hasProgressLine)
|
|
25
|
+
output.write('\r\u001B[2K');
|
|
26
|
+
},
|
|
12
27
|
};
|
|
13
28
|
}
|
|
14
29
|
/** Starts animated setup progress when stdout is an interactive terminal. */
|
|
15
|
-
export function startTerminalSetupProgress() {
|
|
30
|
+
export function startTerminalSetupProgress(options = {}) {
|
|
16
31
|
if (!process.stdout.isTTY)
|
|
17
32
|
return undefined;
|
|
33
|
+
const color = supportsColor(process.stdout, options.color);
|
|
18
34
|
return startSetupProgress(process.stdout, {
|
|
19
35
|
animate: process.env.CI === undefined && process.env.TERM !== 'dumb',
|
|
36
|
+
color,
|
|
37
|
+
transient: true,
|
|
20
38
|
});
|
|
21
39
|
}
|
|
22
40
|
//# sourceMappingURL=setup-progress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-progress.js","sourceRoot":"","sources":["../src/setup-progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,kBAAkB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3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C,KAAK,CAAC,aAAa,CAAC,CAAA;QACtE,CAAC;KACD,CAAA;AACF,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,0BAA0B,CACzC,UAAwC,EAAE;IAE1C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;QAAE,OAAO,SAAS,CAAA;IAC3C,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IAC1D,OAAO,kBAAkB,CAAC,OAAO,CAAC,MAAM,EAAE;QACzC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM;QACpE,KAAK;QACL,SAAS,EAAE,IAAI;KACf,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Terminal colors used by Mercator's human-readable output. */
|
|
2
|
+
declare const ANSI: {
|
|
3
|
+
readonly bold: "\u001B[1m";
|
|
4
|
+
readonly cyan: "\u001B[36m";
|
|
5
|
+
readonly dim: "\u001B[2m";
|
|
6
|
+
readonly green: "\u001B[32m";
|
|
7
|
+
readonly purple: "\u001B[35m";
|
|
8
|
+
readonly red: "\u001B[31m";
|
|
9
|
+
readonly yellow: "\u001B[33m";
|
|
10
|
+
};
|
|
11
|
+
/** Supported semantic styles for terminal output. */
|
|
12
|
+
export type TerminalStyle = keyof typeof ANSI;
|
|
13
|
+
/** Returns whether a stream should receive ANSI color. */
|
|
14
|
+
export declare function supportsColor(output: NodeJS.WritableStream, requested?: boolean): boolean;
|
|
15
|
+
/** Applies one semantic color without leaking formatting into following text. */
|
|
16
|
+
export declare function styleText(value: string, style: TerminalStyle, enabled: boolean): string;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** ANSI reset sequence used after styled terminal text. */
|
|
2
|
+
const RESET = '\u001B[0m';
|
|
3
|
+
/** Terminal colors used by Mercator's human-readable output. */
|
|
4
|
+
const ANSI = {
|
|
5
|
+
bold: '\u001B[1m',
|
|
6
|
+
cyan: '\u001B[36m',
|
|
7
|
+
dim: '\u001B[2m',
|
|
8
|
+
green: '\u001B[32m',
|
|
9
|
+
purple: '\u001B[35m',
|
|
10
|
+
red: '\u001B[31m',
|
|
11
|
+
yellow: '\u001B[33m',
|
|
12
|
+
};
|
|
13
|
+
/** Returns whether a stream should receive ANSI color. */
|
|
14
|
+
export function supportsColor(output, requested = true) {
|
|
15
|
+
return (requested &&
|
|
16
|
+
process.env.NO_COLOR === undefined &&
|
|
17
|
+
process.env.TERM !== 'dumb' &&
|
|
18
|
+
Boolean(output.isTTY));
|
|
19
|
+
}
|
|
20
|
+
/** Applies one semantic color without leaking formatting into following text. */
|
|
21
|
+
export function styleText(value, style, enabled) {
|
|
22
|
+
return enabled ? `${ANSI[style]}${value}${RESET}` : value;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=terminal-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-style.js","sourceRoot":"","sources":["../src/terminal-style.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,MAAM,KAAK,GAAG,WAAW,CAAA;AAEzB,gEAAgE;AAChE,MAAM,IAAI,GAAG;IACZ,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,WAAW;IAChB,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,YAAY;IACpB,GAAG,EAAE,YAAY;IACjB,MAAM,EAAE,YAAY;CACX,CAAA;AAKV,0DAA0D;AAC1D,MAAM,UAAU,aAAa,CAC5B,MAA6B,EAC7B,YAAqB,IAAI;IAEzB,OAAO,CACN,SAAS;QACT,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS;QAClC,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM;QAC3B,OAAO,CAAE,MAA6B,CAAC,KAAK,CAAC,CAC7C,CAAA;AACF,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,KAAoB,EAAE,OAAgB;IAC9E,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;AAC1D,CAAC"}
|