@tempoxyz/mercator 0.0.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.
- package/README.md +208 -0
- package/THIRD_PARTY_NOTICES.md +11 -0
- package/dist/agents.d.ts +26 -0
- package/dist/agents.js +152 -0
- package/dist/agents.js.map +1 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +4 -0
- package/dist/bin.js.map +1 -0
- package/dist/client-selection.d.ts +13 -0
- package/dist/client-selection.js +97 -0
- package/dist/client-selection.js.map +1 -0
- package/dist/clients.d.ts +70 -0
- package/dist/clients.js +282 -0
- package/dist/clients.js.map +1 -0
- package/dist/codex-plugin.d.ts +52 -0
- package/dist/codex-plugin.js +417 -0
- package/dist/codex-plugin.js.map +1 -0
- package/dist/command.d.ts +17 -0
- package/dist/command.js +59 -0
- package/dist/command.js.map +1 -0
- package/dist/doctor.d.ts +10 -0
- package/dist/doctor.js +105 -0
- package/dist/doctor.js.map +1 -0
- package/dist/globe-frames.d.ts +6 -0
- package/dist/globe-frames.js +208 -0
- package/dist/globe-frames.js.map +1 -0
- package/dist/globe.d.ts +12 -0
- package/dist/globe.js +73 -0
- package/dist/globe.js.map +1 -0
- package/dist/index.d.ts +118 -0
- package/dist/index.js +568 -0
- package/dist/index.js.map +1 -0
- package/dist/native-payments.d.ts +34 -0
- package/dist/native-payments.js +191 -0
- package/dist/native-payments.js.map +1 -0
- package/dist/plugin-bundle/.codex-plugin/plugin.json +35 -0
- package/dist/plugin-bundle/.mcp.json +9 -0
- package/dist/plugin-bundle/README.md +26 -0
- package/dist/plugin-bundle/assets/favicon.svg +7 -0
- package/dist/plugin-bundle/assets/mercator-overview.png +0 -0
- package/dist/plugin-bundle/assets/service-network.png +0 -0
- package/dist/plugin-bundle/assets/workflow-composition.png +0 -0
- package/dist/setup-progress.d.ts +13 -0
- package/dist/setup-progress.js +22 -0
- package/dist/setup-progress.js.map +1 -0
- package/dist/submit.d.ts +15 -0
- package/dist/submit.js +127 -0
- package/dist/submit.js.map +1 -0
- package/dist/wallet.d.ts +77 -0
- package/dist/wallet.js +319 -0
- package/dist/wallet.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { Client } from './clients.js';
|
|
5
|
+
import { commandAvailable, runCapturedCommand, runInteractiveCommand, } from './command.js';
|
|
6
|
+
/** Native payment integrations managed by their agent runtime. */
|
|
7
|
+
const NativePayment = {
|
|
8
|
+
HermesMpp: 'hermes-mpp',
|
|
9
|
+
OpenClawMpp: 'openclaw-mpp',
|
|
10
|
+
};
|
|
11
|
+
const defaultDependencies = () => ({
|
|
12
|
+
commandAvailable,
|
|
13
|
+
env: process.env,
|
|
14
|
+
home: homedir(),
|
|
15
|
+
interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY),
|
|
16
|
+
readTextFile: (path) => readFile(path, 'utf8'),
|
|
17
|
+
runCaptured: (command, args) => runCapturedCommand(command, args, {
|
|
18
|
+
includeStderr: false,
|
|
19
|
+
maxOutputBytes: 128 * 1024,
|
|
20
|
+
timeoutMs: 10_000,
|
|
21
|
+
}),
|
|
22
|
+
runInteractive: runInteractiveCommand,
|
|
23
|
+
});
|
|
24
|
+
/** Configures runtime-native payment integrations for selected clients. */
|
|
25
|
+
export async function setupNativePayments(clients, options, overrides = {}) {
|
|
26
|
+
const dependencies = { ...defaultDependencies(), ...overrides };
|
|
27
|
+
const origin = new URL(options.endpoint).origin;
|
|
28
|
+
const reports = [];
|
|
29
|
+
if (clients.includes(Client.OpenClaw)) {
|
|
30
|
+
reports.push(await setupOpenClaw(options, dependencies));
|
|
31
|
+
}
|
|
32
|
+
if (clients.includes(Client.Hermes)) {
|
|
33
|
+
reports.push(await setupHermes(origin, options, dependencies));
|
|
34
|
+
}
|
|
35
|
+
return reports;
|
|
36
|
+
}
|
|
37
|
+
/** Reads only the Hermes MPP origin allowlist, never other environment values. */
|
|
38
|
+
export function parseAllowedOrigins(content) {
|
|
39
|
+
const line = content
|
|
40
|
+
.split(/\r?\n/)
|
|
41
|
+
.find((candidate) => candidate.trimStart().startsWith('MPP_ALLOWED_ORIGINS='));
|
|
42
|
+
if (line === undefined)
|
|
43
|
+
return undefined;
|
|
44
|
+
const value = line
|
|
45
|
+
.slice(line.indexOf('=') + 1)
|
|
46
|
+
.trim()
|
|
47
|
+
.replace(/^(['"])(.*)\1$/, '$2');
|
|
48
|
+
return value
|
|
49
|
+
.split(',')
|
|
50
|
+
.map((origin) => origin.trim())
|
|
51
|
+
.filter(Boolean);
|
|
52
|
+
}
|
|
53
|
+
/** Adds one exact origin without removing or duplicating existing entries. */
|
|
54
|
+
export function mergeAllowedOrigins(existing, origin) {
|
|
55
|
+
return [...new Set([...existing, origin])];
|
|
56
|
+
}
|
|
57
|
+
async function setupOpenClaw(options, dependencies) {
|
|
58
|
+
const base = {
|
|
59
|
+
client: Client.OpenClaw,
|
|
60
|
+
integration: NativePayment.OpenClawMpp,
|
|
61
|
+
};
|
|
62
|
+
const available = await dependencies.commandAvailable('openclaw');
|
|
63
|
+
const commands = [
|
|
64
|
+
'openclaw plugins install clawhub:openclaw-mpp',
|
|
65
|
+
'openclaw mpp setup',
|
|
66
|
+
'openclaw gateway restart',
|
|
67
|
+
];
|
|
68
|
+
if (!available) {
|
|
69
|
+
return {
|
|
70
|
+
...base,
|
|
71
|
+
guidance: commands,
|
|
72
|
+
status: options.dryRun ? 'planned' : 'action_required',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const [plugin, wallet] = await Promise.all([
|
|
76
|
+
dependencies.runCaptured('openclaw', [
|
|
77
|
+
'plugins',
|
|
78
|
+
'inspect',
|
|
79
|
+
'mpp',
|
|
80
|
+
'--runtime',
|
|
81
|
+
'--json',
|
|
82
|
+
]),
|
|
83
|
+
dependencies.runCaptured('openclaw', ['mpp', 'status']),
|
|
84
|
+
]);
|
|
85
|
+
if (plugin.code === 0 && wallet.code === 0) {
|
|
86
|
+
return {
|
|
87
|
+
...base,
|
|
88
|
+
guidance: ['Use mpp_fetch to POST paid jobs to the Mercator REST endpoint.'],
|
|
89
|
+
status: 'ready',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
if (options.dryRun)
|
|
93
|
+
return { ...base, guidance: commands, status: 'planned' };
|
|
94
|
+
if (!dependencies.interactive) {
|
|
95
|
+
return { ...base, guidance: commands, status: 'action_required' };
|
|
96
|
+
}
|
|
97
|
+
if (plugin.code !== 0) {
|
|
98
|
+
await dependencies.runInteractive('openclaw', [
|
|
99
|
+
'plugins',
|
|
100
|
+
'install',
|
|
101
|
+
'clawhub:openclaw-mpp',
|
|
102
|
+
]);
|
|
103
|
+
}
|
|
104
|
+
if (wallet.code !== 0)
|
|
105
|
+
await dependencies.runInteractive('openclaw', ['mpp', 'setup']);
|
|
106
|
+
await dependencies.runInteractive('openclaw', ['gateway', 'restart']);
|
|
107
|
+
const [verifiedPlugin, verifiedWallet] = await Promise.all([
|
|
108
|
+
dependencies.runCaptured('openclaw', [
|
|
109
|
+
'plugins',
|
|
110
|
+
'inspect',
|
|
111
|
+
'mpp',
|
|
112
|
+
'--runtime',
|
|
113
|
+
'--json',
|
|
114
|
+
]),
|
|
115
|
+
dependencies.runCaptured('openclaw', ['mpp', 'status']),
|
|
116
|
+
]);
|
|
117
|
+
const ready = verifiedPlugin.code === 0 && verifiedWallet.code === 0;
|
|
118
|
+
return {
|
|
119
|
+
...base,
|
|
120
|
+
guidance: ready
|
|
121
|
+
? ['Use mpp_fetch to POST paid jobs to the Mercator REST endpoint.']
|
|
122
|
+
: commands,
|
|
123
|
+
status: ready ? 'ready' : 'action_required',
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
async function setupHermes(origin, options, dependencies) {
|
|
127
|
+
const base = {
|
|
128
|
+
client: Client.Hermes,
|
|
129
|
+
integration: NativePayment.HermesMpp,
|
|
130
|
+
};
|
|
131
|
+
const plugin = await dependencies.runCaptured('hermes', ['plugins', 'list']);
|
|
132
|
+
const installed = plugin.code === 0 && /\bmpp\b.*\benabled\b/im.test(plugin.output);
|
|
133
|
+
const envFile = join(dependencies.env.HERMES_HOME ?? join(dependencies.home, '.hermes'), '.env');
|
|
134
|
+
const configuredOrigins = await readAllowedOrigins(envFile, dependencies.readTextFile);
|
|
135
|
+
const unrestricted = installed && configuredOrigins === undefined;
|
|
136
|
+
const origins = mergeAllowedOrigins(configuredOrigins ?? [], origin);
|
|
137
|
+
if (installed && (unrestricted || origins.length === configuredOrigins?.length)) {
|
|
138
|
+
return {
|
|
139
|
+
...base,
|
|
140
|
+
guidance: [
|
|
141
|
+
unrestricted
|
|
142
|
+
? 'hermes-mpp is enabled without an origin allowlist.'
|
|
143
|
+
: 'Use mpp_fetch to POST paid jobs to the Mercator REST endpoint.',
|
|
144
|
+
],
|
|
145
|
+
status: 'ready',
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const args = [
|
|
149
|
+
'hermes-mpp',
|
|
150
|
+
'install',
|
|
151
|
+
...origins.flatMap((allowedOrigin) => ['--allowed-origin', allowedOrigin]),
|
|
152
|
+
];
|
|
153
|
+
const command = `uvx ${args.map(shellQuote).join(' ')}`;
|
|
154
|
+
if (options.dryRun)
|
|
155
|
+
return { ...base, guidance: [command], status: 'planned' };
|
|
156
|
+
const uvxAvailable = await dependencies.commandAvailable('uvx');
|
|
157
|
+
if (!uvxAvailable || !dependencies.interactive) {
|
|
158
|
+
return { ...base, guidance: [command], status: 'action_required' };
|
|
159
|
+
}
|
|
160
|
+
await dependencies.runInteractive('uvx', args);
|
|
161
|
+
const verified = await dependencies.runCaptured('hermes', ['plugins', 'list']);
|
|
162
|
+
return {
|
|
163
|
+
...base,
|
|
164
|
+
guidance: verified.code === 0 && /\bmpp\b.*\benabled\b/im.test(verified.output)
|
|
165
|
+
? ['Use mpp_fetch to POST paid jobs to the Mercator REST endpoint.']
|
|
166
|
+
: [command],
|
|
167
|
+
status: verified.code === 0 && /\bmpp\b.*\benabled\b/im.test(verified.output)
|
|
168
|
+
? 'ready'
|
|
169
|
+
: 'action_required',
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function shellQuote(value) {
|
|
173
|
+
return /^[A-Za-z0-9_./:@-]+$/.test(value)
|
|
174
|
+
? value
|
|
175
|
+
: `'${value.replaceAll("'", `'\\''`)}'`;
|
|
176
|
+
}
|
|
177
|
+
async function readAllowedOrigins(path, readTextFile) {
|
|
178
|
+
try {
|
|
179
|
+
return parseAllowedOrigins(await readTextFile(path));
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (typeof error === 'object' &&
|
|
183
|
+
error !== null &&
|
|
184
|
+
'code' in error &&
|
|
185
|
+
error.code === 'ENOENT') {
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=native-payments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-payments.js","sourceRoot":"","sources":["../src/native-payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,MAAM,EAAiB,MAAM,cAAc,CAAA;AACpD,OAAO,EAEN,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,GACrB,MAAM,cAAc,CAAA;AAErB,kEAAkE;AAClE,MAAM,aAAa,GAAG;IACrB,SAAS,EAAE,YAAY;IACvB,WAAW,EAAE,cAAc;CAClB,CAAA;AAyBV,MAAM,mBAAmB,GAAG,GAA8B,EAAE,CAAC,CAAC;IAC7D,gBAAgB;IAChB,GAAG,EAAE,OAAO,CAAC,GAAG;IAChB,IAAI,EA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IAAI,KAAK,CAAC,IAAI,wBAAwB,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YACpE,CAAC,CAAC,CAAC,gEAAgE,CAAC;YACpE,CAAC,CAAC,CAAC,OAAO,CAAC;QACb,MAAM,EACL,QAAQ,CAAC,IAAI,KAAK,CAAC,IAAI,wBAAwB,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YACpE,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,iBAAiB;KACrB,CAAA;AACF,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAChC,OAAO,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC;QACxC,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAA;AACzC,CAAC;AAED,KAAK,UAAU,kBAAkB,CAChC,IAAY,EACZ,YAAuD;IAEvD,IAAI,CAAC;QACJ,OAAO,mBAAmB,CAAC,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;IACrD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IACC,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,KAAK,IAAI;YACd,MAAM,IAAI,KAAK;YACf,KAAK,CAAC,IAAI,KAAK,QAAQ,EACtB,CAAC;YACF,OAAO,SAAS,CAAA;QACjB,CAAC;QACD,MAAM,KAAK,CAAA;IACZ,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mercator",
|
|
3
|
+
"version": "0.1.0+codex.20260826165140",
|
|
4
|
+
"description": "Discover, live-price, and run current-data and API workflows through Mercator. Powered by MPP.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Tempo",
|
|
7
|
+
"url": "https://tempo.xyz/"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://mercator.tempoxyz.dev/",
|
|
10
|
+
"repository": "https://github.com/tempoxyz/mercator",
|
|
11
|
+
"keywords": ["api", "current data", "mercator", "mcp", "paid services", "tempo"],
|
|
12
|
+
"mcpServers": "./.mcp.json",
|
|
13
|
+
"interface": {
|
|
14
|
+
"displayName": "Mercator",
|
|
15
|
+
"shortDescription": "Discover and run paid API workflows, powered by MPP",
|
|
16
|
+
"longDescription": "Find current-data and API services, get live quotes, and execute durable paid workflows through one MCP gateway. Powered by MPP.",
|
|
17
|
+
"developerName": "Tempo",
|
|
18
|
+
"category": "Productivity",
|
|
19
|
+
"capabilities": ["Interactive", "Read", "Write"],
|
|
20
|
+
"websiteURL": "https://mercator.tempoxyz.dev/",
|
|
21
|
+
"defaultPrompt": [
|
|
22
|
+
"Rescue my canceled Boston-to-London flight under $1,200; add a hotel and transfer if needed, then email the itinerary.",
|
|
23
|
+
"Find 15 overlooked Boston HVAC businesses, verify owner emails, flag outdated sites, and map a route from Back Bay.",
|
|
24
|
+
"Investigate unusual AAVE activity across smart-money flows, holders, price, news, and regulation; return a sourced chart."
|
|
25
|
+
],
|
|
26
|
+
"brandColor": "#1D4FFF",
|
|
27
|
+
"composerIcon": "./assets/favicon.svg",
|
|
28
|
+
"logo": "./assets/favicon.svg",
|
|
29
|
+
"screenshots": [
|
|
30
|
+
"./assets/mercator-overview.png",
|
|
31
|
+
"./assets/workflow-composition.png",
|
|
32
|
+
"./assets/service-network.png"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Mercator plugin
|
|
2
|
+
|
|
3
|
+
Use Mercator from Codex or ChatGPT without configuring an agent CLI MCP client. The plugin connects
|
|
4
|
+
to the production Streamable HTTP server at `https://mercator.tempoxyz.dev/mcp`.
|
|
5
|
+
|
|
6
|
+
## Test from this repository
|
|
7
|
+
|
|
8
|
+
From the repository root:
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
codex plugin marketplace add "$PWD"
|
|
12
|
+
codex plugin add mercator@personal
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Refresh Codex or ChatGPT, enable Mercator in the Plugins directory, and start a new task. Local
|
|
16
|
+
marketplace installation is for development; desktop-only distribution requires publishing this
|
|
17
|
+
bundle to the universal plugin directory.
|
|
18
|
+
|
|
19
|
+
## Package contents
|
|
20
|
+
|
|
21
|
+
- `.codex-plugin/plugin.json`: plugin metadata and capability declaration.
|
|
22
|
+
- `.mcp.json`: production Mercator remote MCP connection.
|
|
23
|
+
- `assets/favicon.svg`: the exact Mercator globe used by the site favicon.
|
|
24
|
+
|
|
25
|
+
The remote server provides activation and workflow instructions during MCP initialization, so this
|
|
26
|
+
bundle intentionally does not duplicate the maintained server contract in a local skill.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg width="32" height="32" viewBox="0 0 782 782" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<title>Mercator</title>
|
|
3
|
+
<circle cx="391" cy="391" r="386" stroke="#0B0B0B" stroke-width="10" />
|
|
4
|
+
<ellipse cx="391" cy="391" rx="262" ry="386" stroke="#0B0B0B" stroke-width="10" />
|
|
5
|
+
<ellipse cx="391" cy="391" rx="101" ry="386" stroke="#0B0B0B" stroke-width="10" />
|
|
6
|
+
<ellipse cx="391" cy="391" rx="386" ry="101" stroke="#0B0B0B" stroke-width="10" />
|
|
7
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type GlobeAnimation } from './globe.js';
|
|
2
|
+
/** Terminal progress renderer shared by the complete setup lifecycle. */
|
|
3
|
+
export type SetupProgress = {
|
|
4
|
+
readonly globe: GlobeAnimation;
|
|
5
|
+
readonly report: (message: string) => void;
|
|
6
|
+
readonly stop: () => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
/** Starts one globe and writes setup progress beneath it without disrupting redraws. */
|
|
9
|
+
export declare function startSetupProgress(output: NodeJS.WritableStream, options: {
|
|
10
|
+
readonly animate: boolean;
|
|
11
|
+
}): SetupProgress;
|
|
12
|
+
/** Starts animated setup progress when stdout is an interactive terminal. */
|
|
13
|
+
export declare function startTerminalSetupProgress(): SetupProgress | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { startMercatorGlobe } from './globe.js';
|
|
2
|
+
/** Starts one globe and writes setup progress beneath it without disrupting redraws. */
|
|
3
|
+
export function startSetupProgress(output, options) {
|
|
4
|
+
const globe = startMercatorGlobe(output, options);
|
|
5
|
+
return {
|
|
6
|
+
globe,
|
|
7
|
+
report: (message) => {
|
|
8
|
+
output.write(` ${message}\n`);
|
|
9
|
+
globe.addLinesBelow(1);
|
|
10
|
+
},
|
|
11
|
+
stop: globe.stop,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** Starts animated setup progress when stdout is an interactive terminal. */
|
|
15
|
+
export function startTerminalSetupProgress() {
|
|
16
|
+
if (!process.stdout.isTTY)
|
|
17
|
+
return undefined;
|
|
18
|
+
return startSetupProgress(process.stdout, {
|
|
19
|
+
animate: process.env.CI === undefined && process.env.TERM !== 'dumb',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=setup-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-progress.js","sourceRoot":"","sources":["../src/setup-progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,kBAAkB,EAAE,MAAM,YAAY,CAAA;AASpE,wFAAwF;AACxF,MAAM,UAAU,kBAAkB,CACjC,MAA6B,EAC7B,OAAsC;IAEtC,MAAM,KAAK,GAAG,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjD,OAAO;QACN,KAAK;QACL,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;YACnB,MAAM,CAAC,KAAK,CAAC,KAAK,OAAO,IAAI,CAAC,CAAA;YAC9B,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAA;QACvB,CAAC;QACD,IAAI,EAAE,KAAK,CAAC,IAAI;KAChB,CAAA;AACF,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,0BAA0B;IACzC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;QAAE,OAAO,SAAS,CAAA;IAC3C,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;KACpE,CAAC,CAAA;AACH,CAAC"}
|
package/dist/submit.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createPaymentProvider } from './wallet.js';
|
|
2
|
+
/** Inputs carried by the bounded paid-job handoff. */
|
|
3
|
+
export type SubmitOptions = {
|
|
4
|
+
body: string;
|
|
5
|
+
maxSpend: string;
|
|
6
|
+
url: string;
|
|
7
|
+
};
|
|
8
|
+
type SubmitDependencies = {
|
|
9
|
+
createPaymentProvider: typeof createPaymentProvider;
|
|
10
|
+
fetch: typeof globalThis.fetch;
|
|
11
|
+
timeoutMs: number;
|
|
12
|
+
};
|
|
13
|
+
/** Executes the bounded direct-charge REST handoff returned by Mercator MCP. */
|
|
14
|
+
export declare function submitPaidJob(options: SubmitOptions, overrides?: Partial<SubmitDependencies>): Promise<unknown>;
|
|
15
|
+
export {};
|
package/dist/submit.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Challenge } from 'mppx';
|
|
2
|
+
import { parseUnits } from 'viem';
|
|
3
|
+
import { createPaymentProvider } from './wallet.js';
|
|
4
|
+
/** Mercator's mainnet billing token (USDC.e). */
|
|
5
|
+
const BILLING_CURRENCY = '0x20c000000000000000000000b9537d11c60e8b50';
|
|
6
|
+
/** Tempo mainnet, the only chain accepted by the handoff. */
|
|
7
|
+
const CHAIN_ID = 4217;
|
|
8
|
+
/** Maximum wait for either Mercator jobs request. */
|
|
9
|
+
const SUBMIT_TIMEOUT_MS = 30_000;
|
|
10
|
+
/** Process-backed submission dependencies used outside tests. */
|
|
11
|
+
const defaultDependencies = {
|
|
12
|
+
createPaymentProvider,
|
|
13
|
+
fetch: globalThis.fetch,
|
|
14
|
+
timeoutMs: SUBMIT_TIMEOUT_MS,
|
|
15
|
+
};
|
|
16
|
+
/** Executes the bounded direct-charge REST handoff returned by Mercator MCP. */
|
|
17
|
+
export async function submitPaidJob(options, overrides = {}) {
|
|
18
|
+
const dependencies = { ...defaultDependencies, ...overrides };
|
|
19
|
+
const body = parseBody(options.body);
|
|
20
|
+
assertJobBody(body);
|
|
21
|
+
const challenge = await fetchJob(dependencies.fetch, options.url, options.body, dependencies.timeoutMs);
|
|
22
|
+
if (challenge.status !== 402)
|
|
23
|
+
return responseBody(challenge);
|
|
24
|
+
assertChallengeSpend(challenge, options.maxSpend);
|
|
25
|
+
const wallet = await dependencies.createPaymentProvider(replayChallenge(dependencies.fetch, options.url, challenge));
|
|
26
|
+
const response = await fetchJob(wallet.fetch, options.url, options.body, dependencies.timeoutMs);
|
|
27
|
+
return responseBody(response);
|
|
28
|
+
}
|
|
29
|
+
async function fetchJob(fetch, url, body, timeoutMs) {
|
|
30
|
+
const signal = AbortSignal.timeout(timeoutMs);
|
|
31
|
+
try {
|
|
32
|
+
return await fetch(url, {
|
|
33
|
+
body,
|
|
34
|
+
headers: {
|
|
35
|
+
Accept: 'application/json',
|
|
36
|
+
'Accept-Payment': 'tempo/charge',
|
|
37
|
+
'Content-Type': 'application/json',
|
|
38
|
+
},
|
|
39
|
+
method: 'POST',
|
|
40
|
+
signal,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (signal.aborted) {
|
|
45
|
+
throw new Error('Mercator submission timed out. Retry with the same idempotency key.');
|
|
46
|
+
}
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function replayChallenge(fetch, url, challenge) {
|
|
51
|
+
let pending = true;
|
|
52
|
+
return async (input, init) => {
|
|
53
|
+
const request = new Request(input, init);
|
|
54
|
+
if (pending && request.method === 'POST' && request.url === url) {
|
|
55
|
+
pending = false;
|
|
56
|
+
return challenge.clone();
|
|
57
|
+
}
|
|
58
|
+
return fetch(input, init);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function parseBody(json) {
|
|
62
|
+
try {
|
|
63
|
+
const body = JSON.parse(json);
|
|
64
|
+
if (body && typeof body === 'object' && !Array.isArray(body)) {
|
|
65
|
+
return body;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch { }
|
|
69
|
+
throw new Error('--body must contain a JSON object.');
|
|
70
|
+
}
|
|
71
|
+
function assertJobBody(body) {
|
|
72
|
+
const plan = body.plan;
|
|
73
|
+
if (!plan || typeof plan !== 'object' || Array.isArray(plan)) {
|
|
74
|
+
throw new Error('The handoff JSON is missing its plan.');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function assertChallengeSpend(response, maxSpend) {
|
|
78
|
+
let request;
|
|
79
|
+
try {
|
|
80
|
+
request = Challenge.fromResponseList(response).find((challenge) => challenge.method === 'tempo' && challenge.intent === 'charge')?.request;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
throw new Error('Mercator returned an invalid direct-charge challenge.');
|
|
84
|
+
}
|
|
85
|
+
if (!request)
|
|
86
|
+
throw new Error('Mercator did not offer the required direct charge.');
|
|
87
|
+
if (!request || typeof request !== 'object' || Array.isArray(request)) {
|
|
88
|
+
throw new Error('Mercator returned an invalid direct-charge challenge.');
|
|
89
|
+
}
|
|
90
|
+
const payment = request;
|
|
91
|
+
const details = payment.methodDetails;
|
|
92
|
+
if (typeof payment.amount !== 'string' ||
|
|
93
|
+
!/^\d+$/.test(payment.amount) ||
|
|
94
|
+
typeof payment.currency !== 'string' ||
|
|
95
|
+
payment.currency.toLowerCase() !== BILLING_CURRENCY ||
|
|
96
|
+
!details ||
|
|
97
|
+
typeof details !== 'object' ||
|
|
98
|
+
Array.isArray(details) ||
|
|
99
|
+
details.chainId !== CHAIN_ID) {
|
|
100
|
+
throw new Error('Mercator returned an unexpected direct-charge challenge.');
|
|
101
|
+
}
|
|
102
|
+
if (BigInt(payment.amount) > units(maxSpend)) {
|
|
103
|
+
throw new Error('Mercator direct charge exceeds --max-spend.');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function units(amount) {
|
|
107
|
+
try {
|
|
108
|
+
if (!/^\d+(?:\.\d{1,6})?$/.test(amount))
|
|
109
|
+
throw new Error('invalid amount');
|
|
110
|
+
return parseUnits(amount, 6);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
throw new Error('Expected a non-negative decimal --max-spend with at most 6 decimals.');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function responseBody(response) {
|
|
117
|
+
if (!response.ok)
|
|
118
|
+
throw new Error(`Mercator submission failed (${response.status}).`);
|
|
119
|
+
const text = await response.text();
|
|
120
|
+
try {
|
|
121
|
+
return JSON.parse(text);
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return text;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=submit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submit.js","sourceRoot":"","sources":["../src/submit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEnD,iDAAiD;AACjD,MAAM,gBAAgB,GAAG,4CAA4C,CAAA;AACrE,6DAA6D;AAC7D,MAAM,QAAQ,GAAG,IAAI,CAAA;AACrB,qDAAqD;AACrD,MAAM,iBAAiB,GAAG,MAAM,CAAA;AAehC,iEAAiE;AACjE,MAAM,mBAAmB,GAAuB;IAC/C,qBAAqB;IACrB,KAAK,EAAE,UAAU,CA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,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAA;IAC5E,CAAC;IACD,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;IAC/D,CAAC;AACF,CAAC;AAED,SAAS,KAAK,CAAC,MAAc;IAC5B,IAAI,CAAC;QACJ,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;QAC1E,OAAO,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAC7B,CAAC;IAAC,MAAM,CAAC;QACR,MAAM,IAAI,KAAK,CACd,sEAAsE,CACtE,CAAA;IACF,CAAC;AACF,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,QAAkB;IAC7C,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAA;IACrF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAClC,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACxB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAA;IACZ,CAAC;AACF,CAAC"}
|
package/dist/wallet.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Provider } from 'accounts';
|
|
2
|
+
import { type Address } from 'viem';
|
|
3
|
+
/** Mercator-owned wallet implementations. */
|
|
4
|
+
export declare const WalletProvider: {
|
|
5
|
+
readonly Local: "local";
|
|
6
|
+
readonly Tempo: "tempo";
|
|
7
|
+
};
|
|
8
|
+
/** Wallet implementation selected for Mercator payments. */
|
|
9
|
+
export type WalletProvider = (typeof WalletProvider)[keyof typeof WalletProvider];
|
|
10
|
+
/** Stable wallet readiness states exposed by setup and doctor. */
|
|
11
|
+
type WalletStatus = 'needs_account' | 'needs_funding' | 'needs_login' | 'ready';
|
|
12
|
+
/** Ordered payment-token balances shown only by explicit wallet commands. */
|
|
13
|
+
type WalletBalances = {
|
|
14
|
+
machineUSD: string;
|
|
15
|
+
pathUSD: string;
|
|
16
|
+
'USDC.e': string;
|
|
17
|
+
};
|
|
18
|
+
/** Local wallet readiness report, including balances when an account is available. */
|
|
19
|
+
export type WalletReport = {
|
|
20
|
+
address?: Address;
|
|
21
|
+
balances?: WalletBalances;
|
|
22
|
+
guidance: string[];
|
|
23
|
+
provider?: WalletProvider;
|
|
24
|
+
sessionClient: 'ready' | 'unavailable';
|
|
25
|
+
status: WalletStatus;
|
|
26
|
+
};
|
|
27
|
+
/** Signals that payment requires explicit wallet setup before retrying. */
|
|
28
|
+
export declare class WalletRequiredError extends Error {
|
|
29
|
+
readonly code = "WALLET_REQUIRED";
|
|
30
|
+
constructor(message?: string);
|
|
31
|
+
}
|
|
32
|
+
type AccountState = {
|
|
33
|
+
address?: Address;
|
|
34
|
+
balances?: WalletBalances;
|
|
35
|
+
funded: boolean;
|
|
36
|
+
usable: boolean;
|
|
37
|
+
};
|
|
38
|
+
type PaymentAuthorizationProvider = {
|
|
39
|
+
getAccessKeyStatus: Provider.Provider['getAccessKeyStatus'];
|
|
40
|
+
store: unknown;
|
|
41
|
+
};
|
|
42
|
+
type WalletDependencies = {
|
|
43
|
+
activeProvider: () => Promise<WalletProvider | undefined>;
|
|
44
|
+
chooseProvider: () => Promise<WalletProvider>;
|
|
45
|
+
connectTempo: () => Promise<AccountState>;
|
|
46
|
+
createLocal: () => Promise<AccountState>;
|
|
47
|
+
inspect: (provider: WalletProvider) => Promise<AccountState>;
|
|
48
|
+
interactive: boolean;
|
|
49
|
+
openUrl: (url: string) => Promise<void>;
|
|
50
|
+
setActiveProvider: (provider: WalletProvider) => Promise<void>;
|
|
51
|
+
};
|
|
52
|
+
type WalletSetupOptions = {
|
|
53
|
+
action?: 'connect' | 'create';
|
|
54
|
+
dryRun?: boolean;
|
|
55
|
+
};
|
|
56
|
+
type FundingPageDependencies = Pick<WalletDependencies, 'openUrl'>;
|
|
57
|
+
/** Result of attempting to open the Mercator funding page. */
|
|
58
|
+
export type FundingPageResult = {
|
|
59
|
+
opened: boolean;
|
|
60
|
+
url: string;
|
|
61
|
+
};
|
|
62
|
+
/** Inspects Mercator wallet state without creating or reconnecting an account. */
|
|
63
|
+
export declare function inspectWallet(overrides?: Partial<WalletDependencies>): Promise<WalletReport>;
|
|
64
|
+
/** Creates a local disk wallet or connects Tempo Wallet through the Accounts SDK. */
|
|
65
|
+
export declare function setupWallet(options?: WalletSetupOptions, overrides?: Partial<WalletDependencies>): Promise<WalletReport>;
|
|
66
|
+
/** Creates an Accounts provider for the active Mercator payment wallet. */
|
|
67
|
+
export declare function createPaymentProvider(baseFetch?: typeof globalThis.fetch): Promise<{
|
|
68
|
+
address: Address;
|
|
69
|
+
fetch: typeof globalThis.fetch;
|
|
70
|
+
provider: PaymentAuthorizationProvider;
|
|
71
|
+
}>;
|
|
72
|
+
/** Returns the Mercator funding page for a wallet address. */
|
|
73
|
+
export declare function fundingUrl(address: Address, origin?: string): string;
|
|
74
|
+
/** Checks whether a stored Tempo key can spend a supported Mercator payment token. */
|
|
75
|
+
export declare function hasPaymentAuthorization(provider: PaymentAuthorizationProvider, address: Address): Promise<boolean>;
|
|
76
|
+
export declare function openFundingPage(address: Address, overrides?: Partial<FundingPageDependencies>): Promise<FundingPageResult>;
|
|
77
|
+
export {};
|