m2m-market 2.4.1 → 2.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 CHANGED
@@ -161,6 +161,48 @@ becomes `reconciled_released`. If the payment did settle, the status becomes
161
161
  `reconciled_settled` and the charge stands. The same applies to
162
162
  `seller_error_refund_pending_review`.
163
163
 
164
+ ## Describe what you need
165
+ `buyExternal` does the search, the listing choice and the request building for
166
+ you. Give a short `need` and the data to send. M2M finds a listing, matches your
167
+ data to its input schema by exact field name, and buys it. Nothing is invented:
168
+ a field you do not supply is never filled in.
169
+ ```js
170
+ const result = await client.buyExternal(
171
+ "weather forecast",
172
+ { city: "Paris", units: "metric" }, // values by schema field name
173
+ { maxPriceUsdc: "0.01" }, // optional, can only lower the ceiling
174
+ );
175
+ console.log(result.status, result.purchase);
176
+ ```
177
+ Check first with `{ dryRun: true }`. It charges, journals and signs nothing and
178
+ resolves with `status: "planned"` and the method, URL, listing price and body.
179
+ `maxPriceUsdc` is optional. Your Agent token policy and the account limits
180
+ always apply, whether or not you set it.
181
+
182
+ | `status` | Meaning |
183
+ |---|---|
184
+ | a purchase status (`completed`, `pending`, `paid_request_rejected`, ...) | A listing was bought. The result has `purchase`, `candidate_id`, `idempotency_key` and `attempts`. |
185
+ | `planned` | `dryRun` only. Nothing was charged. |
186
+ | `needs_input` | No listing could be built from your data. `candidates` (up to 3) each list `input_schema`, `missing` (such as `body.city`) and `invalid`. Nothing was charged. Add the fields and call again. |
187
+ | `no_match` | Nothing matched `need`. |
188
+ | `over_price_cap` | Every match costs more than `maxPriceUsdc`. |
189
+
190
+ Use `inputs.body` or `inputs.query` to give a whole request body or query as is,
191
+ for listings with no schema. Search now returns each listing's `body_schema` and
192
+ `query_schema` in `listing.input` (left out with `schema_truncated: true` above
193
+ 16 KB).
194
+
195
+ Another listing is tried only after a refusal that happened before any charge,
196
+ at most 3 in all. After a charge, a `pending` result or `paid_request_rejected`,
197
+ the call stops and returns that result. A different seller is never tried. Each
198
+ attempt uses its own key derived from your `idempotencyKey` and the listing, so
199
+ repeating a call never pays twice. If the status is `pending`, collect it with
200
+ `await client.purchaseExternal(result.resume.candidateId, result.resume.options)`.
201
+
202
+ As a model tool, use `buyExternalToolDefinition()` and
203
+ `createBuyExternalToolHandler(client)` from `m2m-market/adapters`; the tool is
204
+ named `buy_external_service`.
205
+
164
206
  ## OpenAI-compatible tool
165
207
 
166
208
  ```bash
package/adapters.d.ts CHANGED
@@ -35,3 +35,22 @@ export function createOpenAIToolHandler(
35
35
  definition: JsonObject;
36
36
  handle: (toolCall: { function: { arguments: string } }) => Promise<string>;
37
37
  };
38
+
39
+ export const M2M_BUY_EXTERNAL_TOOL_NAME: "buy_external_service";
40
+ export const M2M_BUY_EXTERNAL_TOOL_DESCRIPTION: string;
41
+ export interface BuyExternalToolArguments {
42
+ need: string;
43
+ inputs?: JsonObject;
44
+ max_price_usdc?: string;
45
+ dry_run?: boolean;
46
+ }
47
+ export function buyExternalToolDefinition(): JsonObject;
48
+ export class M2MExternalToolAdapter {
49
+ constructor(client: M2MConnectionClient);
50
+ invoke(argumentsValue: BuyExternalToolArguments): Promise<JsonObject>;
51
+ invokeJson(argumentsValue: string | BuyExternalToolArguments): Promise<string>;
52
+ }
53
+ export function createBuyExternalToolHandler(client: M2MConnectionClient): {
54
+ definition: JsonObject;
55
+ handle: (toolCall: { function: { arguments: string } }) => Promise<string>;
56
+ };
package/adapters.js CHANGED
@@ -154,3 +154,58 @@ export function createOpenAIToolHandler(client, options = {}) {
154
154
  handle: (toolCall) => adapter.invokeJson(toolCall.function.arguments),
155
155
  };
156
156
  }
157
+
158
+ export const M2M_BUY_EXTERNAL_TOOL_NAME = "buy_external_service";
159
+ export const M2M_BUY_EXTERNAL_TOOL_DESCRIPTION =
160
+ "Describe what you need and give the data to send. M2M finds a matching paid x402 service, checks your data against its input schema and buys it. If the data does not fit any service the result is needs_input with the fields to add; nothing is charged. Use dry_run to check first.";
161
+
162
+ export function buyExternalToolDefinition() {
163
+ return {
164
+ type: "function",
165
+ function: {
166
+ name: M2M_BUY_EXTERNAL_TOOL_NAME,
167
+ description: M2M_BUY_EXTERNAL_TOOL_DESCRIPTION,
168
+ parameters: {
169
+ type: "object",
170
+ properties: {
171
+ need: { type: "string", description: "What you need, in a few plain words, such as 'token price on Base'." },
172
+ inputs: {
173
+ type: "object",
174
+ description: "Values to send, by field name, such as {\"city\": \"Paris\"}. Use 'body' or 'query' for a whole request body or query as is.",
175
+ additionalProperties: true,
176
+ },
177
+ max_price_usdc: { type: "string", description: "Optional price ceiling in USDC, such as '0.01'. Account limits always apply." },
178
+ dry_run: { type: "boolean", description: "Check what would be bought without charging." },
179
+ },
180
+ required: ["need"],
181
+ additionalProperties: false,
182
+ },
183
+ },
184
+ };
185
+ }
186
+
187
+ export class M2MExternalToolAdapter {
188
+ constructor(client) {
189
+ if (!(client instanceof M2MConnectionClient)) {
190
+ throw new TypeError("M2MExternalToolAdapter requires an M2MConnectionClient");
191
+ }
192
+ this.client = client;
193
+ }
194
+
195
+ invoke({ need, inputs, max_price_usdc, dry_run = false }) {
196
+ return this.client.buyExternal(need, inputs, { maxPriceUsdc: max_price_usdc, dryRun: dry_run === true });
197
+ }
198
+
199
+ async invokeJson(argumentsValue) {
200
+ const parsed = typeof argumentsValue === "string" ? JSON.parse(argumentsValue) : argumentsValue;
201
+ return JSON.stringify(await this.invoke(parsed));
202
+ }
203
+ }
204
+
205
+ export function createBuyExternalToolHandler(client) {
206
+ const adapter = new M2MExternalToolAdapter(client);
207
+ return {
208
+ definition: buyExternalToolDefinition(),
209
+ handle: (toolCall) => adapter.invokeJson(toolCall.function.arguments),
210
+ };
211
+ }
package/index.d.ts CHANGED
@@ -48,7 +48,40 @@ export interface ExecuteTaskOptions extends Omit<SubmitOptions, "attemptNumber"
48
48
 
49
49
  export type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
50
50
 
51
+ export interface BuyExternalOptions {
52
+ /** Optional price cap in USDC, for example "0.01". It can only lower the ceiling; Agent token policy and account limits always apply. */
53
+ maxPriceUsdc?: string | number;
54
+ /** Return the validated plan without charging. */
55
+ dryRun?: boolean;
56
+ /** Key for the whole call. Each listing attempt uses a key derived from it, so a repeat never pays twice. */
57
+ idempotencyKey?: string;
58
+ /** Search result limit, 1 to 25. */
59
+ limit?: number;
60
+ }
61
+ export interface BuyExternalCandidate {
62
+ candidate_id: string;
63
+ name: string;
64
+ price_usdc_base_units: string;
65
+ method: string;
66
+ input_schema: JsonObject;
67
+ /** Required fields not supplied, such as "body.city" or "query.q". */
68
+ missing: string[];
69
+ /** Validation errors from the server, as { path, code }. */
70
+ invalid: JsonObject[];
71
+ }
72
+ export interface BuyExternalResult extends JsonObject {
73
+ /** A purchase status, or planned, needs_input, no_match, over_price_cap. */
74
+ status: string;
75
+ candidate_id?: string;
76
+ idempotency_key?: string;
77
+ attempts?: Array<{ candidate_id: string; outcome: string }>;
78
+ candidates?: BuyExternalCandidate[];
79
+ /** Present when status is pending: purchaseExternal(resume.candidateId, resume.options) collects it. */
80
+ resume?: { candidateId: string; options: PurchaseExternalOptions };
81
+ }
51
82
  export interface PurchaseExternalOptions {
83
+ /** Return the plan without charging, journaling or signing. purchase.status is "planned". */
84
+ dryRun?: boolean;
52
85
  /** Reuse the same key to fetch a pending result. A key reused with a different request is refused (409). */
53
86
  idempotencyKey?: string;
54
87
  /** Must match the listing's method (`consumption.method`). Optional. */
@@ -87,6 +120,8 @@ export class M2MConnectionClient {
87
120
  /** Find x402 Bazaar resources M2M can buy for this Agent (read-only). */
88
121
  searchExternal(intent: string, options?: { limit?: number; cursor?: string }): Promise<JsonObject>;
89
122
  purchaseExternal(candidateId: string, options?: PurchaseExternalOptions): Promise<JsonObject>;
123
+ /** Describe what you need and give your data. M2M finds and buys a matching x402 service. */
124
+ buyExternal(need: string, inputs?: JsonObject | null, options?: BuyExternalOptions): Promise<BuyExternalResult>;
90
125
  /** Evidence only; does not change settlement, reputation or ranking. */
91
126
  submitAcceptance(queryId: string, options: { acceptanceId: string; accepted: boolean }): Promise<JsonObject>;
92
127
  getQueryStatus(queryId: string): Promise<JsonObject>;
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import { randomUUID } from 'node:crypto';
1
+ import { createHash, randomUUID } from 'node:crypto';
2
+ import { matchInputs, usdcToBaseUnits } from './matching.js';
2
3
 
3
4
  export const DEFAULT_API_BASE_URL = "https://api.m2mmarket.ai";
4
5
 
@@ -18,6 +19,13 @@ export class M2MNoMatchingServiceError extends M2MConnectionError {
18
19
  }
19
20
  }
20
21
 
22
+ // Refusals raised before anything is charged. Only these allow trying the next listing.
23
+ const PRE_CHARGE_REFUSALS = new Set([
24
+ "input_required", "input_invalid", "candidate_not_consumable", "method_unknown", "method_unsupported",
25
+ "method_mismatch", "body_not_accepted", "body_type_unsupported", "query_conflict", "input_too_large",
26
+ ]);
27
+ const PRE_CHARGE_ATTEMPTS = 3;
28
+
21
29
  export class M2MConnectionClient {
22
30
  constructor({
23
31
  connectionToken,
@@ -189,8 +197,9 @@ export class M2MConnectionClient {
189
197
  * Optional request fields, sent only when supplied (a call without them sends the same JSON as before):
190
198
  * method (must match the listing), body (any JSON value, undefined means no body) and query (object).
191
199
  * Put sensitive values in the body, not the query. The server validates all of them before anything is paid.
200
+ * dryRun: true charges, journals and signs nothing; purchase.status is "planned" with the request the purchase would use.
192
201
  */
193
- async purchaseExternal(candidateId, { idempotencyKey, method, body, query } = {}) {
202
+ async purchaseExternal(candidateId, { idempotencyKey, method, body, query, dryRun = false } = {}) {
194
203
  const key = String(idempotencyKey || randomUUID());
195
204
  if (key.length < 8 || key.length > 128) throw new Error("idempotencyKey must be 8-128 characters");
196
205
  if (!String(candidateId || "").trim()) throw new Error("candidateId is required");
@@ -207,10 +216,114 @@ export class M2MConnectionClient {
207
216
  if (method !== undefined && method !== null) payload.method = method.trim().toUpperCase();
208
217
  if (body !== undefined) payload.body = body;
209
218
  if (query !== undefined && query !== null) payload.query = query;
219
+ if (dryRun) payload.dry_run = true;
210
220
  const result = await this.request("POST", "/connect/x402/purchase", payload);
211
221
  return { idempotency_key: key, ...result };
212
222
  }
213
223
 
224
+ /**
225
+ * Describe what you need and give your data. M2M finds and buys a matching x402 service.
226
+ *
227
+ * Searches the x402 Bazaar for `need`, keeps listings M2M can buy (and, with maxPriceUsdc, priced at or
228
+ * below it), maps `inputs` to each listing's schema by exact field name, and buys the best listing the
229
+ * inputs satisfy. maxPriceUsdc is optional and can only lower the ceiling: the Agent token policy and the
230
+ * account limits always apply. Use inputs.body or inputs.query to give a whole body or query as is.
231
+ *
232
+ * Resolves with `status`: the purchase status (completed, pending, paid_request_rejected, ...) plus
233
+ * purchase, candidate_id, idempotency_key, attempts and, for pending, `resume`; or planned (dryRun),
234
+ * needs_input (up to 3 candidates with input_schema, missing, invalid), no_match, over_price_cap.
235
+ *
236
+ * Another listing is tried only after a refusal that happened before any charge, at most 3 in all.
237
+ * After a charge, a pending result or a rejected paid request it stops; a different seller is never tried.
238
+ * Each attempt uses its own key derived from idempotencyKey and the listing. To collect a pending result:
239
+ * client.purchaseExternal(r.resume.candidateId, r.resume.options).
240
+ */
241
+ async buyExternal(need, inputs, { maxPriceUsdc, dryRun = false, idempotencyKey, limit = 25 } = {}) {
242
+ const text = String(need || "").trim();
243
+ if (!text) throw new Error("need is required");
244
+ if (inputs !== undefined && inputs !== null && (typeof inputs !== "object" || Array.isArray(inputs))) {
245
+ throw new TypeError("inputs must be an object");
246
+ }
247
+ const cap = maxPriceUsdc === undefined || maxPriceUsdc === null ? null : usdcToBaseUnits(maxPriceUsdc);
248
+ const callKey = String(idempotencyKey || randomUUID());
249
+ if (callKey.length < 8 || callKey.length > 128) throw new Error("idempotencyKey must be 8-128 characters");
250
+
251
+ const found = await this.searchExternal(text, { limit });
252
+ const listings = (Array.isArray(found.listings) ? found.listings : []).filter((item) => item && typeof item === "object");
253
+ const priced = [];
254
+ listings.forEach((listing, position) => {
255
+ let price;
256
+ try { price = BigInt(String(listing.price_usdc_base_units)); } catch { return; }
257
+ if (listing.candidate_id) priced.push({ position, price, listing });
258
+ });
259
+ if (priced.length === 0) return { status: "no_match", searched: listings.length };
260
+ const affordable = priced.filter((entry) => cap === null || entry.price <= cap);
261
+ if (affordable.length === 0) {
262
+ return { status: "over_price_cap", searched: listings.length, max_price_usdc_base_units: String(cap) };
263
+ }
264
+
265
+ const ranked = affordable.map((entry) => ({ ...entry, built: matchInputs(entry.listing, inputs) }));
266
+ ranked.sort((a, b) => {
267
+ if (a.built.satisfied !== b.built.satisfied) return a.built.satisfied ? -1 : 1;
268
+ if (a.price !== b.price) return a.price < b.price ? -1 : 1;
269
+ return a.position - b.position;
270
+ });
271
+ const usable = ranked.filter((entry) => entry.built.satisfied).slice(0, PRE_CHARGE_ATTEMPTS);
272
+
273
+ const describe = ({ listing, built }, invalid = []) => {
274
+ const declared = listing.input && typeof listing.input === "object" ? listing.input : {};
275
+ const schema = {};
276
+ for (const key of ["body_required", "body_schema", "query_schema", "schema_truncated"]) {
277
+ if (key in declared) schema[key] = declared[key];
278
+ }
279
+ return {
280
+ candidate_id: listing.candidate_id,
281
+ name: listing.name,
282
+ price_usdc_base_units: listing.price_usdc_base_units,
283
+ method: listing.method,
284
+ input_schema: schema,
285
+ missing: [...built.missing],
286
+ invalid: [...invalid],
287
+ };
288
+ };
289
+
290
+ const attempts = [];
291
+ const refused = [];
292
+ for (const entry of usable) {
293
+ const { listing, built } = entry;
294
+ const candidateId = String(listing.candidate_id);
295
+ const key = createHash("sha256").update(`${callKey}:${candidateId}`).digest("hex");
296
+ const options = { idempotencyKey: key, dryRun };
297
+ if (listing.method) options.method = String(listing.method);
298
+ if (built.has_body) options.body = built.body;
299
+ if (built.has_query) options.query = built.query;
300
+ let result;
301
+ try {
302
+ result = await this.purchaseExternal(candidateId, options);
303
+ } catch (error) {
304
+ const code = error instanceof M2MConnectionError ? String((error.payload || {}).code || "") : "";
305
+ if (!PRE_CHARGE_REFUSALS.has(code)) {
306
+ if (error && typeof error === "object") error.attempts = [...attempts, { candidate_id: candidateId, outcome: code || "error" }];
307
+ throw error;
308
+ }
309
+ attempts.push({ candidate_id: candidateId, outcome: code });
310
+ refused.push(describe(entry, (error.payload || {}).fields || []));
311
+ continue;
312
+ }
313
+ const purchase = result.purchase && typeof result.purchase === "object" ? result.purchase : {};
314
+ const status = String(purchase.status || result.status || "");
315
+ attempts.push({ candidate_id: candidateId, outcome: status });
316
+ const out = { ...result, status, candidate_id: candidateId, attempts };
317
+ if (status === "pending") {
318
+ const { dryRun: _unused, ...resumeOptions } = options;
319
+ out.resume = { candidateId, options: resumeOptions };
320
+ }
321
+ return out;
322
+ }
323
+ const candidates = refused.length > 0 ? refused : ranked.slice(0, 3).map((entry) => describe(entry));
324
+ return { status: "needs_input", candidates, attempts };
325
+ }
326
+
214
327
  /** Evidence only: does not change settlement, reputation or ranking. */
215
328
  submitAcceptance(queryId, { acceptanceId, accepted } = {}) {
216
329
  if (typeof accepted !== "boolean") throw new TypeError("accepted must be a boolean");
package/matching.js ADDED
@@ -0,0 +1,106 @@
1
+ // Map an Agent's inputs to the request one x402 Bazaar listing expects.
2
+ //
3
+ // Pure and deterministic: no network, no model. Values are matched to schema
4
+ // properties by exact name and copied unchanged. Nothing is invented. The server
5
+ // validates the final request again before anything is signed or charged, so a
6
+ // local mismatch can only cause a refusal before payment, never a wrong purchase.
7
+
8
+ const USDC_DECIMALS = 6;
9
+
10
+ /** Convert a USDC amount such as "0.01" to base units (6 decimals) as a BigInt, rounding down. */
11
+ export function usdcToBaseUnits(value) {
12
+ const text = String(value ?? "").trim();
13
+ const found = /^(\d+)(?:\.(\d+))?$/.exec(text);
14
+ if (!found) throw new RangeError("maxPriceUsdc must be a decimal number such as '0.01'");
15
+ const fraction = (found[2] || "").slice(0, USDC_DECIMALS).padEnd(USDC_DECIMALS, "0");
16
+ const units = BigInt(found[1]) * 10n ** BigInt(USDC_DECIMALS) + BigInt(fraction || "0");
17
+ if (units <= 0n) throw new RangeError("maxPriceUsdc must be greater than zero");
18
+ return units;
19
+ }
20
+
21
+ const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
22
+
23
+ function properties(schema) {
24
+ if (!isObject(schema)) return null;
25
+ const known = schema.properties;
26
+ const type = schema.type;
27
+ return (type === undefined || type === null || type === "object") && isObject(known) ? known : null;
28
+ }
29
+
30
+ function required(schema) {
31
+ return isObject(schema) && Array.isArray(schema.required)
32
+ ? schema.required.filter((name) => typeof name === "string")
33
+ : [];
34
+ }
35
+
36
+ const has = (object, name) => Object.prototype.hasOwnProperty.call(object, name);
37
+
38
+ /**
39
+ * Build the body and query for `listing` from `inputs`.
40
+ * `inputs` may carry values by field name, or an explicit `body` and/or `query` used as given.
41
+ * Returns { satisfied, has_body, body, has_query, query, missing }.
42
+ */
43
+ export function matchInputs(listing, inputs) {
44
+ const values = isObject(inputs) ? inputs : {};
45
+ const declared = isObject(listing?.input) ? listing.input : {};
46
+ const method = String(listing?.method || "").toUpperCase();
47
+ const missing = [];
48
+ let body = null;
49
+ let hasBody = false;
50
+ const bodyNames = new Set();
51
+
52
+ if (method !== "GET") {
53
+ const bodySchema = declared.body_schema;
54
+ const props = properties(bodySchema);
55
+ const bodyRequired = declared.body_required === true;
56
+ if (has(values, "body")) {
57
+ body = values.body;
58
+ hasBody = true;
59
+ if (props && isObject(body)) {
60
+ for (const name of required(bodySchema)) if (!has(body, name)) missing.push(`body.${name}`);
61
+ }
62
+ } else if (props) {
63
+ body = {};
64
+ for (const name of Object.keys(props)) {
65
+ if (has(values, name)) {
66
+ body[name] = values[name];
67
+ bodyNames.add(name);
68
+ }
69
+ }
70
+ hasBody = bodyRequired || bodyNames.size > 0;
71
+ for (const name of required(bodySchema)) if (!has(body, name)) missing.push(`body.${name}`);
72
+ if (!hasBody) body = null;
73
+ } else if (bodyRequired) {
74
+ missing.push("body");
75
+ }
76
+ }
77
+
78
+ let query = null;
79
+ let hasQuery = false;
80
+ const querySchema = declared.query_schema;
81
+ const queryProps = properties(querySchema);
82
+ if (isObject(values.query)) {
83
+ query = values.query;
84
+ hasQuery = true;
85
+ if (queryProps) {
86
+ for (const name of required(querySchema)) if (!has(query, name)) missing.push(`query.${name}`);
87
+ }
88
+ } else if (queryProps) {
89
+ query = {};
90
+ for (const name of Object.keys(queryProps)) {
91
+ if (has(values, name) && !bodyNames.has(name)) query[name] = values[name];
92
+ }
93
+ hasQuery = Object.keys(query).length > 0;
94
+ for (const name of required(querySchema)) if (!has(query, name)) missing.push(`query.${name}`);
95
+ if (!hasQuery) query = null;
96
+ }
97
+
98
+ return {
99
+ satisfied: missing.length === 0,
100
+ has_body: hasBody,
101
+ body: hasBody ? body : null,
102
+ has_query: hasQuery,
103
+ query: hasQuery ? query : null,
104
+ missing,
105
+ };
106
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "m2m-market",
3
- "version": "2.4.1",
3
+ "version": "2.5.0",
4
4
  "description": "Customer SDK for connecting AI Agents to M2M Market",
5
5
  "author": "M2M Market, Inc.",
6
6
  "type": "module",
@@ -20,7 +20,7 @@
20
20
  "./outcomes": {"types": "./outcomes.d.ts", "import": "./outcomes.js"},
21
21
  "./reputation": {"types": "./reputation.d.ts", "import": "./reputation.js"}
22
22
  },
23
- "files": ["index.js", "index.d.ts", "adapters.js", "adapters.d.ts", "README.md", "procurement.js", "procurement.d.ts", "protocols.js", "protocols.d.ts", "procurement-adapters.js", "procurement-adapters.d.ts", "payments.js", "payments.d.ts", "commercial.js", "commercial.d.ts", "x402.js", "x402.d.ts", "mpp.js", "mpp.d.ts", "ap2.js", "ap2.d.ts", "outcomes.js", "outcomes.d.ts", "reputation.js", "reputation.d.ts"],
23
+ "files": ["index.js", "index.d.ts", "matching.js", "adapters.js", "adapters.d.ts", "README.md", "procurement.js", "procurement.d.ts", "protocols.js", "protocols.d.ts", "procurement-adapters.js", "procurement-adapters.d.ts", "payments.js", "payments.d.ts", "commercial.js", "commercial.d.ts", "x402.js", "x402.d.ts", "mpp.js", "mpp.d.ts", "ap2.js", "ap2.d.ts", "outcomes.js", "outcomes.d.ts", "reputation.js", "reputation.d.ts"],
24
24
  "engines": {"node": ">=18"},
25
25
  "scripts": {
26
26
  "test": "node --test",
package/protocols.js CHANGED
@@ -32,7 +32,7 @@ export async function connectMcp({ accessToken, timeoutMs = 30000, fetchImpl = g
32
32
  const transport = new sdk.StreamableHTTPClientTransport(new URL(MCP_RESOURCE), {
33
33
  fetch: guardedFetch, reconnectionOptions: { maxRetries: 0, initialReconnectionDelay: 1000, maxReconnectionDelay: 1000, reconnectionDelayGrowFactor: 1 }
34
34
  });
35
- const client = new sdk.Client({ name: 'm2m-market', version: '2.4.1' });
35
+ const client = new sdk.Client({ name: 'm2m-market', version: '2.5.0' });
36
36
  try { await client.connect(transport); }
37
37
  catch { await client.close().catch(() => {}); throw new M2MAPIError('mcp_connection_failed'); }
38
38
  return client; // caller closes it in finally; no automatic paid call or replay