@blindmarket/mcp-server 0.3.6 → 0.5.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 +65 -23
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/rent.d.ts.map +1 -1
- package/dist/rent.js +451 -95
- package/dist/rent.js.map +1 -1
- package/dist/settlement.d.ts +102 -13
- package/dist/settlement.d.ts.map +1 -1
- package/dist/settlement.js +168 -14
- package/dist/settlement.js.map +1 -1
- package/dist/state.d.ts +9 -4
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js.map +1 -1
- package/dist/tools.d.ts +11 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +63 -27
- package/dist/tools.js.map +1 -1
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +7 -5
- package/dist/wallet.js.map +1 -1
- package/package.json +3 -2
package/dist/settlement.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { JsonRpcProvider, getAddress } from 'ethers';
|
|
2
|
-
export
|
|
2
|
+
export function isErc20Settlement(s) {
|
|
3
|
+
return s.payment === 'relay-erc20' || s.payment === 'local-erc20';
|
|
4
|
+
}
|
|
5
|
+
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
6
|
+
export const OG_TOKEN = { kind: 'native', address: ZERO_ADDRESS, symbol: '0G', decimals: 18 };
|
|
7
|
+
export const OG_SETTLEMENT = { payment: 'local-native', mode: '0g', chain: '0g', token: OG_TOKEN, decimals: 18, symbol: '0G' };
|
|
8
|
+
const USDC_ON_BASE = { symbol: 'USDC', decimals: 6 };
|
|
3
9
|
// Mirrors frontend/src/config/constants.ts BASE_USDC_ADDRESS. Overridable via
|
|
4
10
|
// BLINDMARKET_USDC_ADDRESS for a chain not listed here.
|
|
5
11
|
export const BASE_USDC = {
|
|
@@ -10,6 +16,12 @@ export const BASE_RPC = {
|
|
|
10
16
|
8453: 'https://mainnet.base.org',
|
|
11
17
|
84532: 'https://sepolia.base.org',
|
|
12
18
|
};
|
|
19
|
+
/** Public RPCs for chains this process may sign on, by chain id. An env
|
|
20
|
+
* override (BLINDMARKET_<CHAIN>_RPC_URL) always wins. */
|
|
21
|
+
export const PUBLIC_RPC = {
|
|
22
|
+
...BASE_RPC,
|
|
23
|
+
5042002: 'https://rpc.testnet.arc.io',
|
|
24
|
+
};
|
|
13
25
|
/** How long a discovered mode is trusted before being re-asked. Short enough
|
|
14
26
|
* that a long-lived server notices a prod flip within minutes; long enough
|
|
15
27
|
* that a quote→confirm pair never straddles two lookups. */
|
|
@@ -32,14 +44,16 @@ function err(code, message) {
|
|
|
32
44
|
return e;
|
|
33
45
|
}
|
|
34
46
|
const isAddress = (a) => typeof a === 'string' && /^0x[0-9a-fA-F]{40}$/.test(a);
|
|
47
|
+
/** The shape of a backend chain key (backend a2a.ts registerSchema). */
|
|
48
|
+
const CHAIN_KEY = /^[a-z0-9][a-z0-9-]{0,31}$/;
|
|
35
49
|
// An escrow is never address(0); treating it as one would send value there.
|
|
36
50
|
const isEscrowAddress = (a) => isAddress(a) && !/^0x0{40}$/.test(a);
|
|
37
51
|
/** One discovery. Wrap with createSettlementResolver for the memoised form. */
|
|
38
52
|
export async function discoverSettlement(deps) {
|
|
39
53
|
const env = deps.env ?? process.env;
|
|
40
54
|
const forced = env.BLINDMARKET_SETTLEMENT;
|
|
41
|
-
if (forced && forced
|
|
42
|
-
throw err('BAD_SETTLEMENT', `BLINDMARKET_SETTLEMENT must be "0g" or "base", got "${forced}"`);
|
|
55
|
+
if (forced && !CHAIN_KEY.test(forced)) {
|
|
56
|
+
throw err('BAD_SETTLEMENT', `BLINDMARKET_SETTLEMENT must be a chain key such as "0g" or "base", got "${forced}"`);
|
|
43
57
|
}
|
|
44
58
|
if (forced === '0g')
|
|
45
59
|
return OG_SETTLEMENT;
|
|
@@ -60,6 +74,12 @@ export async function discoverSettlement(deps) {
|
|
|
60
74
|
'Refusing to guess the settlement chain. Set BLINDMARKET_SETTLEMENT=0g to force the legacy path.');
|
|
61
75
|
}
|
|
62
76
|
const data = json?.data ?? json;
|
|
77
|
+
if (data && typeof data === 'object' && 'postingChain' in data)
|
|
78
|
+
return settlementFromPostingChain(data, forced, env, deps);
|
|
79
|
+
// An older backend: only 0G and Base exist, and Base is read from `base`.
|
|
80
|
+
if (forced && forced !== 'base') {
|
|
81
|
+
throw err('BAD_SETTLEMENT', `BLINDMARKET_SETTLEMENT="${forced}", but this backend predates chain keys and settles only on "0g" or "base".`);
|
|
82
|
+
}
|
|
63
83
|
const bridge = data?.base ?? null;
|
|
64
84
|
if (!bridge?.configured) {
|
|
65
85
|
if (forced === 'base') {
|
|
@@ -91,10 +111,134 @@ export async function discoverSettlement(deps) {
|
|
|
91
111
|
}
|
|
92
112
|
return buildBaseSettlement(Number(bridge.chainId), bridge.escrowAddress, env, deps);
|
|
93
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* A backend that names its posting chain: POST /api/v1/tasks builds there, so
|
|
116
|
+
* that chain's `chains[]` entry decides the payment path. Its escrow, token and
|
|
117
|
+
* relay label come from the backend, not from tables here.
|
|
118
|
+
*/
|
|
119
|
+
async function settlementFromPostingChain(data, forced, env, deps) {
|
|
120
|
+
const posting = data.postingChain;
|
|
121
|
+
if (typeof posting !== 'string' || !CHAIN_KEY.test(posting)) {
|
|
122
|
+
throw err('SETTLEMENT_UNKNOWN', `${deps.apiBase}/health/bridge names no usable posting chain (${data.postingChainError ?? JSON.stringify(posting)}). ` +
|
|
123
|
+
'Refusing to guess where new tasks are escrowed. Set BLINDMARKET_SETTLEMENT=0g to force the legacy local-wallet path.');
|
|
124
|
+
}
|
|
125
|
+
const chains = Array.isArray(data.chains) ? data.chains : [];
|
|
126
|
+
const escrowChains = chains
|
|
127
|
+
.filter((c) => typeof c?.chain === 'string' && isEscrowAddress(c.escrowAddress))
|
|
128
|
+
.map((c) => c.chain);
|
|
129
|
+
const backendChains = { postingChain: posting, escrowChains };
|
|
130
|
+
// Forced to another chain the backend has an escrow on: tasks already there
|
|
131
|
+
// can still be delivered, cancelled and reclaimed; post_task and
|
|
132
|
+
// rent_service refuse (they fund on the posting chain only).
|
|
133
|
+
const target = forced ?? posting;
|
|
134
|
+
if (forced && !escrowChains.includes(forced)) {
|
|
135
|
+
throw err('BAD_SETTLEMENT', `BLINDMARKET_SETTLEMENT="${forced}" is not a chain this backend has an escrow on (${escrowChains.join(', ') || 'none'}).`);
|
|
136
|
+
}
|
|
137
|
+
const entry = chains.find((c) => c?.chain === target);
|
|
138
|
+
if (!entry) {
|
|
139
|
+
throw err('SETTLEMENT_UNKNOWN', `The backend posts on ${posting} but lists no such chain in chains[] on /health/bridge.`);
|
|
140
|
+
}
|
|
141
|
+
if (target === posting && (!entry.postable || !isEscrowAddress(entry.escrowAddress))) {
|
|
142
|
+
throw err('SETTLEMENT_NOT_POSTABLE', `The backend posts on ${posting} but has no escrow or settlement token configured there, so POST /api/v1/tasks refuses (CHAIN_NOT_CONFIGURED). Fix the backend's config for ${posting}.`);
|
|
143
|
+
}
|
|
144
|
+
const chainId = Number(entry.chainId);
|
|
145
|
+
if (!Number.isInteger(chainId) || chainId <= 0) {
|
|
146
|
+
throw err('SETTLEMENT_UNKNOWN', `The backend lists ${target} with no usable chain id (${JSON.stringify(entry.chainId)}).`);
|
|
147
|
+
}
|
|
148
|
+
// The backend serves addresses as configured, so a mixed-case one may carry
|
|
149
|
+
// a bad checksum; it compares them lowercased, and so does this.
|
|
150
|
+
const escrow = String(entry.escrowAddress).toLowerCase();
|
|
151
|
+
const token = entry.token;
|
|
152
|
+
if (token?.kind === 'native') {
|
|
153
|
+
// The local wallet signs over BLINDMARKET_RPC_URL, a 0G RPC, and native
|
|
154
|
+
// 0G is all it has ever paid. A native coin anywhere else is not a guess
|
|
155
|
+
// worth making with real value.
|
|
156
|
+
if (target !== '0g' || token.decimals !== 18) {
|
|
157
|
+
throw err('UNSUPPORTED_SETTLEMENT', `The backend settles ${target} in native ${token.symbol} (${token.decimals} decimals). This MCP pays native escrow only on 0G, from BLINDMARKET_PRIVATE_KEY.`);
|
|
158
|
+
}
|
|
159
|
+
return { ...OG_SETTLEMENT, ...backendChains, chainId, escrowAddress: getAddress(escrow) };
|
|
160
|
+
}
|
|
161
|
+
if (token?.kind === 'erc20') {
|
|
162
|
+
if (!isEscrowAddress(token.address) || !Number.isInteger(token.decimals) || token.decimals < 0 || token.decimals > 36 || typeof token.symbol !== 'string') {
|
|
163
|
+
throw err('SETTLEMENT_UNKNOWN', `The backend describes ${target}'s settlement token incompletely (${JSON.stringify(token)}).`);
|
|
164
|
+
}
|
|
165
|
+
if (typeof entry.relayChain !== 'string' || !entry.relayChain) {
|
|
166
|
+
// No relay on this chain (Arc): the local wallet signs, or nothing does.
|
|
167
|
+
if (!deps.localWallet) {
|
|
168
|
+
throw err('UNSUPPORTED_SETTLEMENT', `The backend settles ${target} in ${token.symbol} (ERC-20), and its relay does not serve ${target}, so this process has to sign there itself. ` +
|
|
169
|
+
`Set BLINDMARKET_PRIVATE_KEY to the key of the wallet that owns BLINDMARKET_API_KEY; it pays the escrow and ${target}'s gas (${entry.gasSymbol ?? 'the native coin'}).`);
|
|
170
|
+
}
|
|
171
|
+
const local = await buildLocalErc20Settlement({ chain: target, chainId, escrow, token: { kind: 'erc20', address: String(token.address).toLowerCase(), symbol: token.symbol, decimals: token.decimals } }, env, deps);
|
|
172
|
+
return { ...local, ...backendChains };
|
|
173
|
+
}
|
|
174
|
+
// The env override predates backends that name the token. Here it can
|
|
175
|
+
// only disagree with the one token POST /api/v1/tasks accepts.
|
|
176
|
+
const override = env.BLINDMARKET_USDC_ADDRESS;
|
|
177
|
+
if (isAddress(override) && override.toLowerCase() !== token.address.toLowerCase()) {
|
|
178
|
+
throw err('TOKEN_MISMATCH', `BLINDMARKET_USDC_ADDRESS=${override}, but the backend settles ${target} in ${token.symbol} at ${token.address}; POST /api/v1/tasks refuses any other token. Unset it.`);
|
|
179
|
+
}
|
|
180
|
+
const relay = await buildRelaySettlement({ chain: target, chainId, escrow, token: { kind: 'erc20', address: String(token.address).toLowerCase(), symbol: token.symbol, decimals: token.decimals }, relayChain: entry.relayChain }, env, deps);
|
|
181
|
+
return { ...relay, ...backendChains };
|
|
182
|
+
}
|
|
183
|
+
throw err('UNSUPPORTED_SETTLEMENT', `The backend settles ${target} in a token this MCP cannot pay (${JSON.stringify(token)}).`);
|
|
184
|
+
}
|
|
185
|
+
/** The env var that overrides a chain's RPC. */
|
|
186
|
+
export function rpcEnvName(chain) {
|
|
187
|
+
return chain === 'base' ? 'BLINDMARKET_BASE_RPC_URL' : `BLINDMARKET_${chain.toUpperCase().replace(/-/g, '_')}_RPC_URL`;
|
|
188
|
+
}
|
|
189
|
+
/** An RPC for a chain: its env override, else a public one this file knows. */
|
|
190
|
+
export function rpcFor(chain, chainId, env) {
|
|
191
|
+
return env[rpcEnvName(chain)] ?? PUBLIC_RPC[chainId] ?? null;
|
|
192
|
+
}
|
|
193
|
+
/** A local-signing settlement on an ERC-20 chain the relay does not serve.
|
|
194
|
+
* Checked before any spend can use it: the RPC must serve the chain the
|
|
195
|
+
* backend names (a wrong RPC would sign on another network), and the local
|
|
196
|
+
* wallet must be the API key's owner (the task is posted as that wallet). */
|
|
197
|
+
async function buildLocalErc20Settlement(p, env, deps) {
|
|
198
|
+
const { chain, chainId } = p;
|
|
199
|
+
const rpcUrl = rpcFor(chain, chainId, env);
|
|
200
|
+
if (!rpcUrl) {
|
|
201
|
+
throw err('RPC_UNKNOWN', `No RPC known for ${chain} (chainId ${chainId}) — set ${rpcEnvName(chain)}.`);
|
|
202
|
+
}
|
|
203
|
+
const provider = new JsonRpcProvider(rpcUrl, chainId, { staticNetwork: true });
|
|
204
|
+
let served;
|
|
205
|
+
try {
|
|
206
|
+
served = Number(BigInt(await provider.send('eth_chainId', [])));
|
|
207
|
+
}
|
|
208
|
+
catch (e) {
|
|
209
|
+
throw err('RPC_UNREACHABLE', `${rpcEnvName(chain)} (${rpcUrl}) did not answer eth_chainId: ${e.message}`);
|
|
210
|
+
}
|
|
211
|
+
if (served !== chainId) {
|
|
212
|
+
throw err('WRONG_RPC', `${rpcEnvName(chain)} serves chain ${served}, not ${chain} (${chainId}). Nothing is signed until it points at ${chain}.`);
|
|
213
|
+
}
|
|
214
|
+
const who = await deps.api('GET', '/api/v1/api-keys/whoami');
|
|
215
|
+
if (!isAddress(who?.address)) {
|
|
216
|
+
throw err('OWNER_UNKNOWN', `whoami returned "${who?.address}" — the API key must belong to a wallet (not the legacy AGENT_API_KEY principal) to post on ${chain}.`);
|
|
217
|
+
}
|
|
218
|
+
const local = getAddress(deps.localWallet);
|
|
219
|
+
if (who.address.toLowerCase() !== local.toLowerCase()) {
|
|
220
|
+
throw err('OWNER_MISMATCH', `BLINDMARKET_API_KEY belongs to ${who.address} but BLINDMARKET_PRIVATE_KEY is ${local}. On ${chain} the local wallet signs, and tasks are posted and delivered as the API key's wallet, ` +
|
|
221
|
+
'so an escrow funded from any other wallet is refused at listing (NOT_TASK_AGENT). Use that wallet\'s key, or mint an API key signed in as this one. Nothing was sent.');
|
|
222
|
+
}
|
|
223
|
+
const tokenAddress = getAddress(p.token.address);
|
|
224
|
+
return {
|
|
225
|
+
payment: 'local-erc20',
|
|
226
|
+
mode: chain,
|
|
227
|
+
chain,
|
|
228
|
+
chainId,
|
|
229
|
+
escrowAddress: getAddress(p.escrow),
|
|
230
|
+
token: { ...p.token, address: tokenAddress },
|
|
231
|
+
usdcAddress: tokenAddress,
|
|
232
|
+
decimals: p.token.decimals,
|
|
233
|
+
symbol: p.token.symbol,
|
|
234
|
+
rpcUrl,
|
|
235
|
+
provider,
|
|
236
|
+
payFrom: local,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
94
239
|
/** Assemble a Base settlement from a chain id and escrow address, whichever
|
|
95
|
-
* way
|
|
96
|
-
* USDC
|
|
97
|
-
* agree. */
|
|
240
|
+
* way an older backend let them be learned (health, or an explicit
|
|
241
|
+
* override). USDC and the relay label come from the tables here. */
|
|
98
242
|
async function buildBaseSettlement(chainId, escrow, env, deps) {
|
|
99
243
|
const relayChain = relayChainFor(chainId);
|
|
100
244
|
if (!relayChain) {
|
|
@@ -104,9 +248,15 @@ async function buildBaseSettlement(chainId, escrow, env, deps) {
|
|
|
104
248
|
if (!usdcAddress) {
|
|
105
249
|
throw err('USDC_UNKNOWN', `No USDC address known for chainId ${chainId} — set BLINDMARKET_USDC_ADDRESS.`);
|
|
106
250
|
}
|
|
107
|
-
|
|
251
|
+
return buildRelaySettlement({ chain: 'base', chainId, escrow, token: { kind: 'erc20', address: usdcAddress, ...USDC_ON_BASE }, relayChain }, env, deps);
|
|
252
|
+
}
|
|
253
|
+
/** A relay settlement from its chain facts, however they were learned. The
|
|
254
|
+
* RPC and the paying wallet are resolved here so every route agrees. */
|
|
255
|
+
async function buildRelaySettlement(p, env, deps) {
|
|
256
|
+
const { chain, chainId } = p;
|
|
257
|
+
const rpcUrl = rpcFor(chain, chainId, env);
|
|
108
258
|
if (!rpcUrl) {
|
|
109
|
-
throw err('RPC_UNKNOWN', `No RPC known for chainId ${chainId} — set
|
|
259
|
+
throw err('RPC_UNKNOWN', `No RPC known for ${chain} (chainId ${chainId}) — set ${rpcEnvName(chain)}.`);
|
|
110
260
|
}
|
|
111
261
|
// The relay refuses any wallet not linked to the caller — and the caller of
|
|
112
262
|
// an sk_ key IS its owner wallet, so that is the only address it can sign
|
|
@@ -115,14 +265,18 @@ async function buildBaseSettlement(chainId, escrow, env, deps) {
|
|
|
115
265
|
if (!isAddress(who?.address)) {
|
|
116
266
|
throw err('RELAY_WALLET_UNKNOWN', `whoami returned "${who?.address}" — the API key must belong to a wallet (not the legacy AGENT_API_KEY principal) for the relay to sign from it.`);
|
|
117
267
|
}
|
|
268
|
+
const tokenAddress = getAddress(p.token.address);
|
|
118
269
|
return {
|
|
119
|
-
|
|
270
|
+
payment: 'relay-erc20',
|
|
271
|
+
mode: chain,
|
|
272
|
+
chain,
|
|
120
273
|
chainId,
|
|
121
|
-
escrowAddress: getAddress(escrow),
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
274
|
+
escrowAddress: getAddress(p.escrow),
|
|
275
|
+
token: { ...p.token, address: tokenAddress },
|
|
276
|
+
usdcAddress: tokenAddress,
|
|
277
|
+
decimals: p.token.decimals,
|
|
278
|
+
symbol: p.token.symbol,
|
|
279
|
+
relayChain: p.relayChain,
|
|
126
280
|
rpcUrl,
|
|
127
281
|
provider: new JsonRpcProvider(rpcUrl, chainId),
|
|
128
282
|
payFrom: getAddress(who.address),
|
package/dist/settlement.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settlement.js","sourceRoot":"","sources":["../src/settlement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAyErD,MAAM,CAAC,MAAM,aAAa,GAAiB,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAEtF,8EAA8E;AAC9E,wDAAwD;AACxD,MAAM,CAAC,MAAM,SAAS,GAAqC;IACzD,IAAI,EAAE,4CAA4C;IAClD,KAAK,EAAE,4CAA4C;CACpD,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAqC;IACxD,IAAI,EAAE,0BAA0B;IAChC,KAAK,EAAE,0BAA0B;CAClC,CAAC;AAEF;;6DAE6D;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE9C,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,cAAc,CAAC;IAC5C,IAAI,OAAO,KAAK,KAAK;QAAE,OAAO,cAAc,CAAC;IAC7C,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,OAAe,EAAE,QAAiB;IACxD,IAAI,QAA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AAE,CAAC,CAAC,KAAK,CAAC,QAAQ;QAC1B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM;QACtB,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,MAAM;QACN,QAAQ,EAAE,IAAI,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC;QAC9C,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC;KACjC,CAAC;AACJ,CAAC;AASD;4DAC4D;AAC5D,MAAM,UAAU,wBAAwB,CAAC,IAAkB,EAAE,KAAK,GAAG,gBAAgB,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG;IACnG,IAAI,MAAM,GAA6C,IAAI,CAAC;IAC5D,MAAM,OAAO,GAAG,CAAC,KAAK,IAAI,EAAE;QAC1B,IAAI,MAAM,IAAI,GAAG,EAAE,GAAG,MAAM,CAAC,EAAE,GAAG,KAAK;YAAE,OAAO,MAAM,CAAC,KAAK,CAAC;QAC7D,MAAM,KAAK,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC,CAAuB,CAAC;IACzB,OAAO,CAAC,UAAU,GAAG,GAAG,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/state.d.ts
CHANGED
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
* nothing to index — the money moves back on the one transaction. */
|
|
15
15
|
export type SpendStage = 'created' | 'approved' | 'funded' | 'indexed' | 'sent' | 'confirmed';
|
|
16
16
|
/** Every kind moves money and so carries an idempotencyKey: rent/post pay it
|
|
17
|
-
* out of the wallet, cancel/timeout pull it back
|
|
18
|
-
|
|
17
|
+
* out of the wallet, cancel/timeout pull it back, deploy pays the agent
|
|
18
|
+
* deploy fee (created → sent once the fee transaction is broadcast →
|
|
19
|
+
* confirmed once the agent exists). */
|
|
20
|
+
export type SpendKind = 'rent' | 'post' | 'cancel' | 'timeout' | 'deploy';
|
|
19
21
|
export interface SpendRecord {
|
|
20
22
|
idempotencyKey: string;
|
|
21
23
|
kind: SpendKind;
|
|
@@ -25,8 +27,9 @@ export interface SpendRecord {
|
|
|
25
27
|
taskId?: number;
|
|
26
28
|
txHash?: string;
|
|
27
29
|
/** which chain this spend settles on — decides local-sign vs relay on resume */
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
/** the backend chain key the spend started on ('0g', 'base', …) */
|
|
31
|
+
settlement?: string;
|
|
32
|
+
/** escrow token: zero address for native 0G, the ERC-20 (USDC) address on a relay chain */
|
|
30
33
|
token?: string;
|
|
31
34
|
/** Base only: the USDC approve tx, persisted so a resume never re-approves */
|
|
32
35
|
approveTxHash?: string;
|
|
@@ -50,6 +53,8 @@ export interface SpendRecord {
|
|
|
50
53
|
requiredCapabilities?: string[];
|
|
51
54
|
amountWei?: string;
|
|
52
55
|
durationSecs?: number;
|
|
56
|
+
/** deploy only: the agent the fee paid for */
|
|
57
|
+
agentId?: string;
|
|
53
58
|
createdAt: string;
|
|
54
59
|
updatedAt: string;
|
|
55
60
|
}
|
package/dist/state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AAEH;;;;sEAIsE;AACtE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC;AAE9F;
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AAEH;;;;sEAIsE;AACtE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,G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AAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAsBD,wBAAgB,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAExE;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAIlD;AAED,wBAAgB,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAU5F;AAQD,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;CACnB;AAKD,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CASpF;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,IAAI,CAK3E"}
|
package/dist/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,MAAM,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,MAAM,MAAM,aAAa,CAAC;AAkEjC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB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I,CAAC,GAAG,EAAE;QAAE,OAAO,IAAI,CAAC;IAC/E,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa;IACrC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import type { BlindMarket } from '@blindmarket/sdk';
|
|
3
3
|
import type { WalletCtx } from './wallet.js';
|
|
4
|
-
|
|
4
|
+
import type { Settlement } from './settlement.js';
|
|
5
|
+
/**
|
|
6
|
+
* `settlement` is rent.ts's resolver. An executor registered from this process
|
|
7
|
+
* delivers through complete_task, which settles on that one chain (the
|
|
8
|
+
* backend's posting chain, or the one BLINDMARKET_SETTLEMENT names), so that
|
|
9
|
+
* is the only chain it declares. Declaring more would get it offered tasks it
|
|
10
|
+
* cannot deliver on a backend that filters by the list; declaring nothing is
|
|
11
|
+
* read as 0G+Base there and stored as ['0g'] by older backends — wrong either
|
|
12
|
+
* way for a one-chain process.
|
|
13
|
+
*/
|
|
14
|
+
export declare function registerMarketTools(server: McpServer, bb: BlindMarket, walletCtx?: WalletCtx | null, settlement?: () => Promise<Settlement>): void;
|
|
5
15
|
//# sourceMappingURL=tools.d.ts.map
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,EAAE,EAAE,WAAW,EACf,SAAS,GAAE,SAAS,GAAG,IAAW,EAClC,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,GACrC,IAAI,CAyZN"}
|
package/dist/tools.js
CHANGED
|
@@ -1,9 +1,36 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* `settlement` is rent.ts's resolver. An executor registered from this process
|
|
4
|
+
* delivers through complete_task, which settles on that one chain (the
|
|
5
|
+
* backend's posting chain, or the one BLINDMARKET_SETTLEMENT names), so that
|
|
6
|
+
* is the only chain it declares. Declaring more would get it offered tasks it
|
|
7
|
+
* cannot deliver on a backend that filters by the list; declaring nothing is
|
|
8
|
+
* read as 0G+Base there and stored as ['0g'] by older backends — wrong either
|
|
9
|
+
* way for a one-chain process.
|
|
10
|
+
*/
|
|
11
|
+
export function registerMarketTools(server, bb, walletCtx = null, settlement) {
|
|
12
|
+
async function declaredChains(tool) {
|
|
13
|
+
if (!settlement)
|
|
14
|
+
return { supportedChains: undefined };
|
|
15
|
+
try {
|
|
16
|
+
const s = await settlement();
|
|
17
|
+
return {
|
|
18
|
+
supportedChains: [s.mode],
|
|
19
|
+
...(s.payment === 'local-native' && !walletCtx
|
|
20
|
+
? { warning: `Declared ${s.mode}, but complete_task delivers on 0G from BLINDMARKET_PRIVATE_KEY, which is not set: tasks accepted there cannot be delivered from this process until it is.` }
|
|
21
|
+
: {}),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
const code = err.code ?? 'SETTLEMENT_UNKNOWN';
|
|
26
|
+
const message = `${tool} declares the chain this process can deliver on (the backend's posting chain, or the one BLINDMARKET_SETTLEMENT names), and could not learn it: ${err.message}`;
|
|
27
|
+
return { error: { isError: true, content: [{ type: 'text', text: JSON.stringify({ success: false, error: { code, message } }) }] } };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
3
30
|
// ── Health & Stats ────────────────────────────────────────────────────
|
|
4
31
|
server.registerTool('health', {
|
|
5
32
|
title: 'Health Check',
|
|
6
|
-
description: 'Check
|
|
33
|
+
description: 'Check that the BlindMarket backend this server talks to is up: returns its status and server time. It does not check settlement readiness (escrows, signers), so use it to tell an outage apart from a request that failed for its own reasons.',
|
|
7
34
|
inputSchema: {},
|
|
8
35
|
}, async () => {
|
|
9
36
|
const result = await bb.health();
|
|
@@ -11,7 +38,7 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
11
38
|
});
|
|
12
39
|
server.registerTool('stats', {
|
|
13
40
|
title: 'Platform Stats',
|
|
14
|
-
description: 'Get live
|
|
41
|
+
description: 'Get live platform totals: open tasks in the legacy 0G TaskRegistry, active and deployed agents, registered users, completed tasks, and the volume processed through escrow in the pricing unit (USDC). Public and read-only; for work you can take, use browse_a2a_tasks.',
|
|
15
42
|
inputSchema: {},
|
|
16
43
|
}, async () => {
|
|
17
44
|
const result = await bb.stats();
|
|
@@ -20,9 +47,9 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
20
47
|
// ── Tasks ─────────────────────────────────────────────────────────────
|
|
21
48
|
server.registerTool('list_open_tasks', {
|
|
22
49
|
title: 'List Open Tasks',
|
|
23
|
-
description: 'List open tasks
|
|
50
|
+
description: 'List open tasks from the legacy 0G TaskRegistry (numeric ids on the 0G escrow), up to limit (max 50), each flagged a2aIndexed when agents can reach it. Tasks escrowed on Base or Arc are not in this list: use browse_a2a_tasks to find work you can take.',
|
|
24
51
|
inputSchema: {
|
|
25
|
-
limit: z.number().optional().describe('Maximum number of tasks to return (default 20)'),
|
|
52
|
+
limit: z.number().optional().describe('Maximum number of tasks to return (default 20, max 50)'),
|
|
26
53
|
},
|
|
27
54
|
}, async ({ limit }) => {
|
|
28
55
|
const tasks = await bb.listTasks(limit ?? 20);
|
|
@@ -30,9 +57,9 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
30
57
|
});
|
|
31
58
|
server.registerTool('get_task', {
|
|
32
59
|
title: 'Get Task Details',
|
|
33
|
-
description:
|
|
60
|
+
description: "Get one task: its on-chain escrow record (status 0 Funded, 1 Assigned, 2 Submitted, 3 failed verification, 4 Completed, 5 Cancelled, 6 Disputed; reward, deadline, poster and worker), the reward's unit, and its marketplace state. Prefer the 0x task hash, which resolves to whichever chain holds the task; a numeric id is read on the chain new tasks are posted on, and ids repeat across chains. The deliverable (resultData) is included only for the task's poster or worker, or when the task is public.",
|
|
34
61
|
inputSchema: {
|
|
35
|
-
taskId: z.string().describe('Task
|
|
62
|
+
taskId: z.string().describe('Task hash (0x-prefixed bytes32, preferred) or numeric escrow id'),
|
|
36
63
|
},
|
|
37
64
|
}, async ({ taskId }) => {
|
|
38
65
|
const task = await bb.getTask(taskId);
|
|
@@ -40,10 +67,10 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
40
67
|
});
|
|
41
68
|
server.registerTool('browse_a2a_tasks', {
|
|
42
69
|
title: 'Browse A2A Tasks',
|
|
43
|
-
description:
|
|
70
|
+
description: "List open agent-to-agent tasks you could execute, with public metadata only (such as the task's chain, deadline, required capabilities and verification mode, plus the brief itself for a public task), never an encrypted brief or anyone's wrapped key; tasks past their deadline are left out. With capabilities, a task is kept only if every capability it requires is in your list (tasks requiring none are always kept). Results are not filtered by chain, so check each task's chain against the one this process delivers on (wallet_status) before accept_task.",
|
|
44
71
|
inputSchema: {
|
|
45
72
|
capabilities: z.string().optional().describe('Comma-separated capability filter (e.g. "data_processing,web_research")'),
|
|
46
|
-
minReputation: z.number().optional().describe('
|
|
73
|
+
minReputation: z.number().optional().describe('Accepted for compatibility; ignored by the backend'),
|
|
47
74
|
},
|
|
48
75
|
}, async ({ capabilities, minReputation }) => {
|
|
49
76
|
const result = await bb.browseA2ATasks({
|
|
@@ -55,7 +82,7 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
55
82
|
// ── Agents ────────────────────────────────────────────────────────────
|
|
56
83
|
server.registerTool('create_agent', {
|
|
57
84
|
title: 'Create Agent',
|
|
58
|
-
description: "Register as an A2A executor using the local wallet (BLINDMARKET_PRIVATE_KEY): derives its uncompressed public key and registers it. The executor is
|
|
85
|
+
description: "Register as an A2A executor using the local wallet (BLINDMARKET_PRIVATE_KEY): derives its uncompressed public key and registers it. The executor is always the wallet that owns BLINDMARKET_API_KEY, so on 0G the two must be the same wallet (checked — a mismatch is refused). No wallet is generated and no key is returned. On Base with a Privy owner wallet, use register_as_executor with wallet_status's executorPublicKey instead.",
|
|
59
86
|
inputSchema: {
|
|
60
87
|
displayName: z.string().describe('Display name for the agent'),
|
|
61
88
|
capabilities: z.string().describe('Comma-separated capabilities (e.g. "data_processing,web_research")'),
|
|
@@ -73,7 +100,11 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
73
100
|
if (typeof bb.deliverResult !== 'function') {
|
|
74
101
|
return { isError: true, content: [{ type: 'text', text: JSON.stringify({ success: false, error: { code: 'SDK_TOO_OLD', message: 'The installed @blindmarket/sdk ignores the wallet key passed to createAgent. Upgrade @blindmarket/sdk, or use register_as_executor with wallet_status\'s executorPublicKey.' } }) }] };
|
|
75
102
|
}
|
|
103
|
+
const chains = await declaredChains('create_agent');
|
|
104
|
+
if ('error' in chains)
|
|
105
|
+
return chains.error;
|
|
76
106
|
const { executor, wallet } = await bb.createAgent({
|
|
107
|
+
supportedChains: chains.supportedChains,
|
|
77
108
|
privateKey: walletCtx.wallet.privateKey,
|
|
78
109
|
displayName,
|
|
79
110
|
capabilities: capabilities.split(',').map(s => s.trim()),
|
|
@@ -83,12 +114,12 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
83
114
|
: undefined,
|
|
84
115
|
});
|
|
85
116
|
// Never echo the private key into the model's context.
|
|
86
|
-
const result = { executor, wallet: { address: wallet.address, publicKey: wallet.publicKey } };
|
|
117
|
+
const result = { executor, wallet: { address: wallet.address, publicKey: wallet.publicKey }, ...(chains.warning ? { warning: chains.warning } : {}) };
|
|
87
118
|
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
88
119
|
});
|
|
89
120
|
server.registerTool('register_as_executor', {
|
|
90
121
|
title: 'Register as Executor',
|
|
91
|
-
description: "Register as an A2A executor. The executor address is
|
|
122
|
+
description: "Register as an A2A executor. The executor address is always the wallet that owns BLINDMARKET_API_KEY; publicKey is the key briefs get wrapped to (wallet_status reports the local one as executorPublicKey). Declares the one chain this process delivers on (the chain the backend posts new tasks on, or BLINDMARKET_SETTLEMENT's — wallet_status shows it); a backend that filters by it then offers only tasks it can complete.",
|
|
92
123
|
inputSchema: {
|
|
93
124
|
address: z.string().optional().describe("Ignored by the backend — the executor is the API key's owner wallet"),
|
|
94
125
|
displayName: z.string().describe('Display name'),
|
|
@@ -97,17 +128,22 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
97
128
|
minReward: z.string().optional().describe("Minimum reward, as an integer in the payment token's smallest unit (USDC: 6 decimals)"),
|
|
98
129
|
},
|
|
99
130
|
}, async ({ displayName, capabilities, publicKey, minReward }) => {
|
|
131
|
+
const chains = await declaredChains('register_as_executor');
|
|
132
|
+
if ('error' in chains)
|
|
133
|
+
return chains.error;
|
|
100
134
|
const result = await bb.registerExecutor({
|
|
135
|
+
supportedChains: chains.supportedChains,
|
|
101
136
|
displayName,
|
|
102
137
|
capabilities: capabilities.split(',').map(s => s.trim()),
|
|
103
138
|
publicKey,
|
|
104
139
|
minReward: minReward ?? undefined,
|
|
105
140
|
});
|
|
106
|
-
|
|
141
|
+
const body = chains.warning ? { ...result, warning: chains.warning } : result;
|
|
142
|
+
return { content: [{ type: 'text', text: JSON.stringify(body, null, 2) }] };
|
|
107
143
|
});
|
|
108
144
|
server.registerTool('list_agents', {
|
|
109
145
|
title: 'List Agents',
|
|
110
|
-
description:
|
|
146
|
+
description: "List agents hosted on BlindMarket with their public profile (name, provider and model, status, capabilities); keys and secrets are never included. Returns the first 20; pass ownerAddress to see one owner's agents. Agents that take tasks from elsewhere (SDK, MCP) are not hosted here, so use search_agents to find agents to hire.",
|
|
111
147
|
inputSchema: {
|
|
112
148
|
ownerAddress: z.string().optional().describe('Filter by owner wallet address'),
|
|
113
149
|
},
|
|
@@ -117,7 +153,7 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
117
153
|
});
|
|
118
154
|
server.registerTool('get_agent', {
|
|
119
155
|
title: 'Get Agent Details',
|
|
120
|
-
description:
|
|
156
|
+
description: "Get one hosted agent's public profile by its agent id (from list_agents): status, provider and model, capabilities, wallet address and on-chain identity. Keys and secrets are never included.",
|
|
121
157
|
inputSchema: {
|
|
122
158
|
agentId: z.string().describe('Agent ID'),
|
|
123
159
|
},
|
|
@@ -128,7 +164,7 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
128
164
|
// ── A2A Actions ───────────────────────────────────────────────────────
|
|
129
165
|
server.registerTool('bid_on_task', {
|
|
130
166
|
title: 'Bid on Task',
|
|
131
|
-
description:
|
|
167
|
+
description: "Register interest in an open A2A task whose brief key has not been wrapped to you, so the poster can wrap it to your public key; accept_task then succeeds. Use it when accept_task answers NEEDS_WRAP. Idempotent. Refused for your own task, before you have registered as an executor with a public key, or when your registration does not include the task's chain (CHAIN_UNSUPPORTED).",
|
|
132
168
|
inputSchema: {
|
|
133
169
|
taskId: z.string().describe('Task ID'),
|
|
134
170
|
},
|
|
@@ -153,7 +189,7 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
153
189
|
// finalize, with /rebroadcast healing for a stranded 'submitted' task.
|
|
154
190
|
server.registerTool('verify_task', {
|
|
155
191
|
title: 'Verify Task',
|
|
156
|
-
description: '
|
|
192
|
+
description: "Ask the platform's AI verifier (0G Compute, in a TEE) for a verdict on a submitted result: returns passed, confidence, reasoning, the model used and whether the run was TEE-attested. It does not settle the escrow or change the task; settlement follows the task's verification mode. Only the task's poster, designated verifier or assigned executor may call it, only the poster or verifier may add taskRequirements, and calls are rate-limited because each one runs a paid inference.",
|
|
157
193
|
inputSchema: {
|
|
158
194
|
// taskHash, not a numeric id: ids collide across 0G and Base, so the
|
|
159
195
|
// backend keys verification on the hash like every other A2A surface.
|
|
@@ -176,7 +212,7 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
176
212
|
// ── Reputation ────────────────────────────────────────────────────────
|
|
177
213
|
server.registerTool('get_reputation', {
|
|
178
214
|
title: 'Get Reputation',
|
|
179
|
-
description: "Get an address's on-chain
|
|
215
|
+
description: "Get an address's reputation: its on-chain BlindReputation record and the platform's decayed score, which halves for every 7 days since the address's last task. Use it to vet an agent before relying on its work.",
|
|
180
216
|
inputSchema: {
|
|
181
217
|
address: z.string().describe('Wallet address (0x...)'),
|
|
182
218
|
},
|
|
@@ -186,7 +222,7 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
186
222
|
});
|
|
187
223
|
server.registerTool('get_leaderboard', {
|
|
188
224
|
title: 'Get Leaderboard',
|
|
189
|
-
description: 'Get top workers ranked by reputation score',
|
|
225
|
+
description: 'Get the top workers ranked by reputation score, up to limit (default 50). For agents with a particular capability, use search_agents.',
|
|
190
226
|
inputSchema: {
|
|
191
227
|
limit: z.number().optional().describe('Number of top workers to return (default 50)'),
|
|
192
228
|
},
|
|
@@ -197,10 +233,10 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
197
233
|
// ── Marketplace ───────────────────────────────────────────────────────
|
|
198
234
|
server.registerTool('search_agents', {
|
|
199
235
|
title: 'Search Agents',
|
|
200
|
-
description:
|
|
236
|
+
description: "Search agents registered to take marketplace tasks, by capability tag and optionally a minimum average review rating. Returns the 20 most recently registered matches, each with its address, name, capabilities, reputation, average rating, earned badges and lowest service price; use it to find an agent to hire or delegate to.",
|
|
201
237
|
inputSchema: {
|
|
202
238
|
capability: z.string().optional().describe('Capability filter'),
|
|
203
|
-
minRating: z.number().optional().describe(
|
|
239
|
+
minRating: z.number().optional().describe("Minimum average review rating from posters' reviews (1-5)"),
|
|
204
240
|
},
|
|
205
241
|
}, async ({ capability, minRating }) => {
|
|
206
242
|
const agents = await bb.searchAgents({
|
|
@@ -212,7 +248,7 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
212
248
|
// ── Messages ─────────────────────────────────────────────────────────
|
|
213
249
|
server.registerTool('send_message', {
|
|
214
250
|
title: 'Send Message',
|
|
215
|
-
description: 'Send a message
|
|
251
|
+
description: 'Send a message on a task to another participant. to is a wallet address, or the shortcut "poster" (the task\'s poster) or "agent" (its assigned executor), which need taskId. The recipient reads it in their BlindMarket inbox; replies arrive in get_inbox.',
|
|
216
252
|
inputSchema: {
|
|
217
253
|
taskId: z.string().describe('Task ID'),
|
|
218
254
|
to: z.string().describe('Recipient address or "poster"/"agent" shortcut'),
|
|
@@ -224,7 +260,7 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
224
260
|
});
|
|
225
261
|
server.registerTool('get_inbox', {
|
|
226
262
|
title: 'Get Inbox',
|
|
227
|
-
description:
|
|
263
|
+
description: "Read the messages sent to the wallet behind your API key, across all tasks, with each message's sender and task. Check it after send_message to read replies.",
|
|
228
264
|
inputSchema: {},
|
|
229
265
|
}, async () => {
|
|
230
266
|
const result = await bb.getInbox();
|
|
@@ -233,7 +269,7 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
233
269
|
// ── Agent Management (write) ──────────────────────────────────────────
|
|
234
270
|
server.registerTool('start_agent', {
|
|
235
271
|
title: 'Start Agent',
|
|
236
|
-
description: 'Start
|
|
272
|
+
description: 'Start one of your hosted agents (owner only). On start it re-registers as an executor, resumes any task still assigned to it, and begins taking tasks, paying gas from its own wallet, so fund that wallet on the settlement chain first. Returns the agent\'s updated record.',
|
|
237
273
|
inputSchema: {
|
|
238
274
|
agentId: z.string().describe('Agent ID'),
|
|
239
275
|
},
|
|
@@ -243,7 +279,7 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
243
279
|
});
|
|
244
280
|
server.registerTool('stop_agent', {
|
|
245
281
|
title: 'Stop Agent',
|
|
246
|
-
description: 'Stop
|
|
282
|
+
description: 'Stop one of your hosted agents (owner only): its process ends and it takes no new tasks until started again, when it resumes any task still assigned to it. Returns the agent\'s updated record.',
|
|
247
283
|
inputSchema: {
|
|
248
284
|
agentId: z.string().describe('Agent ID'),
|
|
249
285
|
},
|
|
@@ -253,7 +289,7 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
253
289
|
});
|
|
254
290
|
server.registerTool('pause_agent', {
|
|
255
291
|
title: 'Pause Agent',
|
|
256
|
-
description: '
|
|
292
|
+
description: 'Freeze one of your hosted agents in place (owner only). Unlike stop_agent it keeps the process and any task it holds, doing nothing until brought back; restart_agent brings it back as a fresh process. Fails if the agent is not running.',
|
|
257
293
|
inputSchema: {
|
|
258
294
|
agentId: z.string().describe('Agent ID'),
|
|
259
295
|
},
|
|
@@ -263,7 +299,7 @@ export function registerMarketTools(server, bb, walletCtx = null) {
|
|
|
263
299
|
});
|
|
264
300
|
server.registerTool('restart_agent', {
|
|
265
301
|
title: 'Restart Agent',
|
|
266
|
-
description: '
|
|
302
|
+
description: 'Stop and start one of your hosted agents (owner only), for example to pick up a changed configuration. Returns the agent\'s updated record.',
|
|
267
303
|
inputSchema: {
|
|
268
304
|
agentId: z.string().describe('Agent ID'),
|
|
269
305
|
},
|