crowdcode-mcp 0.3.1 → 0.3.2
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/dist/cli.js
CHANGED
|
@@ -110,6 +110,9 @@ var MIRRORED_REMOTE_TOOLS = [
|
|
|
110
110
|
function orNull(value) {
|
|
111
111
|
return typeof value === "string" && value !== "" ? value : null;
|
|
112
112
|
}
|
|
113
|
+
function isRecord(value) {
|
|
114
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
115
|
+
}
|
|
113
116
|
async function getReviewSigningPayload(deps, args) {
|
|
114
117
|
let identity;
|
|
115
118
|
try {
|
|
@@ -136,13 +139,15 @@ async function getReviewSigningPayload(deps, args) {
|
|
|
136
139
|
let effective = identity;
|
|
137
140
|
if (score.found === true) {
|
|
138
141
|
try {
|
|
142
|
+
const hasResolvedIdentity = isRecord(score.resolved_identity);
|
|
143
|
+
const resolved = hasResolvedIdentity ? score.resolved_identity : score;
|
|
139
144
|
effective = buildIdentity({
|
|
140
|
-
service_id: orNull(
|
|
145
|
+
service_id: orNull(resolved.service_id),
|
|
141
146
|
service_name: orNull(score.service_name),
|
|
142
|
-
api_endpoint:
|
|
143
|
-
payment_provider:
|
|
144
|
-
payment_target_ref:
|
|
145
|
-
directory_slug:
|
|
147
|
+
api_endpoint: hasResolvedIdentity ? orNull(resolved.api_endpoint) : orNull(score.canonical_endpoint),
|
|
148
|
+
payment_provider: orNull(resolved.payment_provider),
|
|
149
|
+
payment_target_ref: orNull(resolved.payment_target_ref),
|
|
150
|
+
directory_slug: orNull(resolved.directory_slug)
|
|
146
151
|
});
|
|
147
152
|
} catch (err) {
|
|
148
153
|
return { ok: false, reason: err.message };
|
|
@@ -238,17 +243,21 @@ async function prepareSignedReview(deps, args, wallet) {
|
|
|
238
243
|
const signature = await loaded.account.signMessage({
|
|
239
244
|
message: payload.message
|
|
240
245
|
});
|
|
241
|
-
const identity =
|
|
246
|
+
const identity = buildIdentity(
|
|
247
|
+
payload.identity
|
|
248
|
+
);
|
|
249
|
+
const signedReason = String(payload.reason);
|
|
242
250
|
return {
|
|
243
251
|
args: {
|
|
244
252
|
...args,
|
|
245
253
|
// Pass the resolved identity verbatim so the backend rebuilds the exact
|
|
246
254
|
// payload that was just signed.
|
|
247
|
-
service_id: identity.service_id
|
|
248
|
-
api_endpoint: identity.api_endpoint
|
|
249
|
-
payment_provider: identity.payment_provider
|
|
250
|
-
payment_target_ref: identity.payment_target_ref
|
|
251
|
-
directory_slug: identity.directory_slug
|
|
255
|
+
service_id: identity.service_id,
|
|
256
|
+
api_endpoint: identity.api_endpoint,
|
|
257
|
+
payment_provider: identity.payment_provider,
|
|
258
|
+
payment_target_ref: identity.payment_target_ref,
|
|
259
|
+
directory_slug: identity.directory_slug,
|
|
260
|
+
reason: signedReason,
|
|
252
261
|
reviewer_wallet: loaded.address,
|
|
253
262
|
review_signature: signature,
|
|
254
263
|
signature_scheme: "eip191"
|
|
@@ -256,24 +265,70 @@ async function prepareSignedReview(deps, args, wallet) {
|
|
|
256
265
|
signed: true,
|
|
257
266
|
wallet_source: loaded.source,
|
|
258
267
|
wallet_created: loaded.created,
|
|
259
|
-
wallet: loaded
|
|
268
|
+
wallet: loaded,
|
|
269
|
+
signed_payload: {
|
|
270
|
+
identity,
|
|
271
|
+
rating: args.rating,
|
|
272
|
+
reason: signedReason,
|
|
273
|
+
payment_reference: String(args.payment_reference ?? "")
|
|
274
|
+
}
|
|
260
275
|
};
|
|
261
276
|
}
|
|
277
|
+
var SIGNED_IDENTITY_FIELDS = [
|
|
278
|
+
"service_id",
|
|
279
|
+
"api_endpoint",
|
|
280
|
+
"payment_provider",
|
|
281
|
+
"payment_target_ref",
|
|
282
|
+
"directory_slug"
|
|
283
|
+
];
|
|
284
|
+
function resolvedIdentity(value) {
|
|
285
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
const record = value;
|
|
289
|
+
for (const field of SIGNED_IDENTITY_FIELDS) {
|
|
290
|
+
if (!(field in record)) return null;
|
|
291
|
+
if (record[field] !== null && typeof record[field] !== "string") return null;
|
|
292
|
+
}
|
|
293
|
+
try {
|
|
294
|
+
return buildIdentity(record);
|
|
295
|
+
} catch {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function preservesSignedIdentity(signed, resolved) {
|
|
300
|
+
return SIGNED_IDENTITY_FIELDS.every(
|
|
301
|
+
(field) => signed[field] === null || signed[field] === resolved[field]
|
|
302
|
+
);
|
|
303
|
+
}
|
|
262
304
|
async function resignFromMismatch(prepared, response) {
|
|
263
305
|
if (!prepared.signed || !prepared.wallet?.account) return null;
|
|
306
|
+
if (!prepared.signed_payload) return null;
|
|
264
307
|
if (response.accepted !== false) return null;
|
|
265
308
|
if (typeof response.expected_message !== "string") return null;
|
|
266
|
-
const identity = response.resolved_identity
|
|
309
|
+
const identity = resolvedIdentity(response.resolved_identity);
|
|
310
|
+
if (identity === null) return null;
|
|
311
|
+
if (!preservesSignedIdentity(prepared.signed_payload.identity, identity)) {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
const message = canonicalReviewPayload({
|
|
315
|
+
identity,
|
|
316
|
+
rating: prepared.signed_payload.rating,
|
|
317
|
+
reason: prepared.signed_payload.reason,
|
|
318
|
+
paymentReference: prepared.signed_payload.payment_reference
|
|
319
|
+
});
|
|
320
|
+
if (message !== response.expected_message) return null;
|
|
267
321
|
const signature = await prepared.wallet.account.signMessage({
|
|
268
|
-
message
|
|
322
|
+
message
|
|
269
323
|
});
|
|
270
324
|
return {
|
|
271
325
|
...prepared.args,
|
|
272
|
-
service_id: identity.service_id
|
|
273
|
-
api_endpoint: identity.api_endpoint
|
|
274
|
-
payment_provider: identity.payment_provider
|
|
275
|
-
payment_target_ref: identity.payment_target_ref
|
|
276
|
-
directory_slug: identity.directory_slug
|
|
326
|
+
service_id: identity.service_id,
|
|
327
|
+
api_endpoint: identity.api_endpoint,
|
|
328
|
+
payment_provider: identity.payment_provider,
|
|
329
|
+
payment_target_ref: identity.payment_target_ref,
|
|
330
|
+
directory_slug: identity.directory_slug,
|
|
331
|
+
reason: prepared.signed_payload.reason,
|
|
277
332
|
review_signature: signature
|
|
278
333
|
};
|
|
279
334
|
}
|
|
@@ -329,13 +384,13 @@ var UpstreamClient = class {
|
|
|
329
384
|
);
|
|
330
385
|
}
|
|
331
386
|
const structured = result.structuredContent;
|
|
332
|
-
if (structured !== void 0 &&
|
|
387
|
+
if (structured !== void 0 && isRecord2(structured)) {
|
|
333
388
|
return structured;
|
|
334
389
|
}
|
|
335
390
|
const text = firstText(result.content);
|
|
336
391
|
try {
|
|
337
392
|
const parsed = JSON.parse(text);
|
|
338
|
-
if (
|
|
393
|
+
if (isRecord2(parsed)) return parsed;
|
|
339
394
|
} catch {
|
|
340
395
|
}
|
|
341
396
|
throw new UpstreamError(
|
|
@@ -348,13 +403,13 @@ var UpstreamClient = class {
|
|
|
348
403
|
return tools.map((tool) => tool.name);
|
|
349
404
|
}
|
|
350
405
|
};
|
|
351
|
-
function
|
|
406
|
+
function isRecord2(value) {
|
|
352
407
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
353
408
|
}
|
|
354
409
|
function firstText(content) {
|
|
355
410
|
if (Array.isArray(content)) {
|
|
356
411
|
for (const item of content) {
|
|
357
|
-
if (
|
|
412
|
+
if (isRecord2(item) && item.type === "text" && typeof item.text === "string") {
|
|
358
413
|
return item.text;
|
|
359
414
|
}
|
|
360
415
|
}
|
|
@@ -638,4 +693,4 @@ export {
|
|
|
638
693
|
createToolHandlers,
|
|
639
694
|
startServer
|
|
640
695
|
};
|
|
641
|
-
//# sourceMappingURL=server-
|
|
696
|
+
//# sourceMappingURL=server-R5RIEZZ7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server.ts","../src/attestation.ts","../src/redaction/policy.ts","../src/schemas.ts","../src/tools/signing-payload.ts","../src/tools/sign-review.ts","../src/upstream.ts"],"sourcesContent":["/**\n * The stdio MCP server. Advertises the same tools as the CrowdCode backend;\n * free-text arguments are redacted locally (Rampart + secret recognizers)\n * before forwarding over streamable-HTTP, and get_review_signing_payload is\n * served entirely locally so raw review text never leaves this machine at\n * signing time.\n */\n\nimport { RedactionEngine } from \"@crowdcode/redaction\";\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { toToolResult, withRedactionAttestation } from \"./attestation.js\";\nimport { getConfig } from \"./config.js\";\nimport { redactArgs } from \"./redaction/policy.js\";\nimport {\n MIRRORED_REMOTE_TOOLS,\n getServiceScoreShape,\n requestServiceShape,\n reviewServiceShape,\n signingPayloadShape,\n} from \"./schemas.js\";\nimport {\n prepareSignedReview,\n resignFromMismatch,\n installWalletNextStep,\n type PreparedReview,\n type WalletOptions,\n} from \"./tools/sign-review.js\";\nimport {\n getReviewSigningPayload,\n type SigningPayloadArgs,\n} from \"./tools/signing-payload.js\";\nimport { UpstreamClient, UpstreamError, type Upstream } from \"./upstream.js\";\nimport { loadWallet } from \"./wallet.js\";\n\nexport interface ServerDeps {\n engine: RedactionEngine;\n upstream: Upstream;\n /** Wallet loading knobs; defaults come from getConfig(). Injectable in tests. */\n wallet?: Partial<WalletOptions>;\n}\n\ntype ToolResult = ReturnType<typeof toToolResult>;\n\nfunction errorPayload(\n tool: string,\n err: unknown,\n): Record<string, unknown> {\n const message =\n err instanceof UpstreamError\n ? err.message\n : `could not reach the CrowdCode backend: ${(err as Error).message}`;\n const next_step = {\n action: \"retry_backend\",\n summary:\n \"The CrowdCode backend may be cold-starting (free-tier hosting); retry \" +\n \"the same call in ~30 seconds.\",\n command: null,\n link: null,\n retry: { tool, after_seconds: 30, with: {} },\n };\n if (tool === \"get_service_score\") {\n return {\n found: false,\n score: null,\n n_eff: 0,\n unproven: true,\n avg_rating: null,\n num_reviews: 0,\n summary: null,\n recent_reviews: [],\n reason: message,\n next_step,\n };\n }\n return { accepted: false, reason: message, next_step };\n}\n\nfunction withWalletInfo(\n payload: Record<string, unknown>,\n prepared: PreparedReview,\n): Record<string, unknown> {\n const out = { ...payload };\n if (prepared.wallet_source !== undefined) {\n out.wallet_source = prepared.wallet_source;\n }\n if (prepared.wallet_created) out.wallet_created = true;\n if (prepared.wallet_error) out.wallet_error = prepared.wallet_error;\n if (out.next_step === undefined && prepared.next_step) {\n out.next_step = prepared.next_step;\n }\n return out;\n}\n\nexport function createToolHandlers(deps: ServerDeps) {\n const { engine, upstream } = deps;\n const config = getConfig();\n const walletOptions: WalletOptions = {\n walletDir: deps.wallet?.walletDir ?? config.walletDir,\n autoCreate: deps.wallet?.autoCreate ?? config.walletAutoCreate,\n env: deps.wallet?.env,\n };\n const signingDeps = { redact: (text: string) => engine.redact(text), upstream };\n // Show the install-wallet onboarding CTA at most once per process so score\n // lookups don't nag (agentcash pattern: CTA on success, never stacked).\n let onboardingCtaShown = false;\n\n async function forwardPayload(\n tool: string,\n args: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n const redacted = await redactArgs(engine, tool, args);\n try {\n const result = await upstream.call(tool, redacted.args);\n return withRedactionAttestation(result, {\n entitiesRemoved: redacted.entitiesRemoved,\n modelActive: redacted.modelActive,\n });\n } catch (err) {\n return errorPayload(tool, err);\n }\n }\n\n return {\n request_service: async (\n args: Record<string, unknown>,\n ): Promise<ToolResult> => {\n let outgoing = args;\n if (!outgoing.requester_wallet) {\n // Read-only probe: requests never mint a wallet; the review flow does.\n const wallet = await loadWallet({\n walletDir: walletOptions.walletDir,\n env: walletOptions.env,\n autoCreate: false,\n });\n if (wallet.address) {\n outgoing = { ...outgoing, requester_wallet: wallet.address };\n }\n }\n return toToolResult(await forwardPayload(\"request_service\", outgoing));\n },\n\n get_service_score: async (\n args: Record<string, unknown>,\n ): Promise<ToolResult> => {\n let payload: Record<string, unknown>;\n try {\n payload = await upstream.call(\"get_service_score\", args);\n } catch (err) {\n return toToolResult(errorPayload(\"get_service_score\", err));\n }\n const provider = payload.payment_provider;\n if (\n !onboardingCtaShown &&\n payload.found === true &&\n (provider === \"mppx\" || provider === \"x402\")\n ) {\n const wallet = await loadWallet({\n walletDir: walletOptions.walletDir,\n env: walletOptions.env,\n autoCreate: false,\n });\n if (wallet.source === \"none\") {\n onboardingCtaShown = true;\n payload = {\n ...payload,\n onboarding_cta: {\n message:\n \"This is a paid x402/mppx service and you have no local \" +\n \"signing wallet yet. Install agentcash (or set \" +\n \"X402_PRIVATE_KEY) so your post-purchase review can be \" +\n \"signed and counted.\",\n command: installWalletNextStep(\"review_service\").command,\n },\n };\n }\n }\n return toToolResult(payload);\n },\n\n get_review_signing_payload: async (\n args: SigningPayloadArgs & { auto_sign?: boolean | null },\n ): Promise<ToolResult> => {\n const payload = await getReviewSigningPayload(signingDeps, args);\n if (args.auto_sign !== true || payload.ok !== true) {\n return toToolResult(payload);\n }\n const wallet = await loadWallet(walletOptions);\n if (wallet.source === \"none\" || wallet.account === null) {\n return toToolResult({\n ...payload,\n wallet_source: \"none\",\n wallet_error: wallet.error,\n next_step: installWalletNextStep(\"review_service\"),\n });\n }\n const signature = await wallet.account.signMessage({\n message: payload.message as string,\n });\n return toToolResult({\n ...payload,\n review_signature: signature,\n reviewer_wallet: wallet.address,\n wallet_source: wallet.source,\n ...(wallet.created ? { wallet_created: true } : {}),\n });\n },\n\n review_service: async (\n args: Record<string, unknown>,\n ): Promise<ToolResult> => {\n const prepared = await prepareSignedReview(signingDeps, args, walletOptions);\n let payload = await forwardPayload(\"review_service\", prepared.args);\n // Signature-mismatch recovery (identity resolution race): re-sign the\n // backend's expected_message once with the same wallet and retry. A\n // second mismatch is surfaced to the caller.\n const retryArgs = await resignFromMismatch(prepared, payload);\n if (retryArgs !== null) {\n payload = await forwardPayload(\"review_service\", retryArgs);\n }\n return toToolResult(withWalletInfo(payload, prepared));\n },\n };\n}\n\nconst SERVER_INSTRUCTIONS = [\n \"CrowdCode is a shared reputation layer for paid agent services. Use it\",\n \"whenever a task involves paying for, provisioning, or calling a paid\",\n \"service — especially x402 or mppx/MPP services.\",\n \"\",\n \"Before spending: call get_service_score on each candidate (prefer\",\n \"api_endpoint + payment_provider + payment_target_ref, or service_id /\",\n \"directory_slug). Prefer higher `score` (the canonical trust-weighted\",\n \"rating), using `n_eff` as evidence context; `unproven: true` means not\",\n \"enough trusted reviews yet — treat it as insufficient evidence, not a bad\",\n \"score, and fall back to price and the spend policy. When present,\",\n \"`summary` digests what reviewers reported (strengths / failure modes /\",\n \"caveats).\",\n \"\",\n \"After ANY paid use — success, slow response, or failure: submit a review.\",\n \"A slow or broken paid call is not a reason to skip the review; it IS the\",\n \"review (slowness or breakage goes in the rating and reason). Rate against\",\n \"the ORIGINAL task you were solving: was the response relevant and did it\",\n \"actually help answer that question? Fixed scale: 5 = excellent (clear\",\n \"schema, relevant output that answered the original question, fast, clean\",\n \"receipt — would reuse confidently); 4 = helped but a real\",\n \"schema/docs/latency/output caveat; 3 = paid but response thin, confusing,\",\n \"needed guesswork, or not actually relevant/helpful for the task (a\",\n \"technically valid answer that did not help is a 3 at best); 2 = paid but\",\n \"poor (client error, unclear failure, hard to use); 1 = paid and broken\",\n \"(server error, unusable output, misleading challenge, timeout/severe\",\n \"reliability). A service that simply worked well AND helped is a 5 — do\",\n \"not hedge to 4 without a concrete caveat.\",\n \"\",\n \"Signing is AUTOMATIC: review_service signs with your local wallet\",\n \"(X402_PRIVATE_KEY, or the agentcash wallet at ~/.agentcash/wallet.json,\",\n \"auto-created if missing) — you do not need get_review_signing_payload or\",\n \"an external signer. Responses include wallet_source (env | agentcash |\",\n \"none). For x402/mppx, take identity and proofs from the ACTUAL payment,\",\n \"not a directory listing: payment_reference = the settlement tx hash (x402)\",\n \"or Payment-Receipt reference (mppx); payment_proof = the base64 response\",\n \"header string (payment-response for x402, Payment-Receipt for mppx), not\",\n \"the tx hash or decoded JSON. payment_proof is OPTIONAL: verified-purchase\",\n \"status (double scoring weight) comes from CrowdCode verifying the ERC-20\",\n \"transfer on-chain, which works from the settlement tx hash in\",\n \"payment_reference alone — so clients that only have a tx hash (e.g.\",\n \"agentcash) get the same verified status as clients that pass the proof\",\n \"header. payment_verification_level in the response is the source of\",\n \"truth. On-chain verification covers x402 on Base and mppx on Tempo;\",\n \"payments settled elsewhere (e.g. Solana) are accepted but stay\",\n \"signature_only. payment_target_ref = the real on-chain payee (the 402\",\n \"challenge recipient / Transfer `to`), not a directory payTo.\",\n \"\",\n \"Workflow: 1) get_service_score on each candidate; 2) pay and use the\",\n \"service; 3) review_service with the settlement tx hash as\",\n \"payment_reference (plus the payment_proof header if you have it). Reviews\",\n \"are limited to 1 per service per wallet per 24h; failed calls return a\",\n \"next_step object with the exact command or retry that fixes them —\",\n \"follow it.\",\n \"\",\n \"When you were actively trying to BUY a capability and no fitting paid\",\n \"service exists, call request_service once (requires a wallet identity,\",\n \"attached automatically; limited to 5 requests per wallet per 24h). The\",\n \"gate is willingness to pay: you had the task, a wallet, and spend\",\n \"authority, and would have paid concrete money for this right then if it\",\n \"existed. 'A provider could charge for this' is not enough — a free tool\",\n \"that would merely have been convenient is not a service request. Describe\",\n \"the paid API call you wanted to make: the input you would have sent, the\",\n \"output or state change you were paying for, and roughly what a call was\",\n \"worth to the task. Never free-tool wishes, runtime or agent-harness\",\n \"wishes (context management, local compute), or one-off task help. Never\",\n \"send secrets or private data — free-text fields are redacted locally\",\n \"before anything is sent.\",\n].join(\"\\n\");\n\nexport function buildServer(deps: ServerDeps): McpServer {\n const server = new McpServer(\n { name: \"crowdcode\", version: \"0.3.0\" },\n { instructions: SERVER_INSTRUCTIONS },\n );\n const handlers = createToolHandlers(deps);\n\n server.registerTool(\n \"request_service\",\n {\n description:\n \"Record unmet paid-service demand for future directory coverage. \" +\n \"Call this only when you were actively trying to BUY a capability — \" +\n \"you had the task, a wallet, and spend authority, and would have \" +\n \"paid concrete money right then if the service existed — and no \" +\n \"fitting paid service (x402/mppx/Stripe) could be found. 'A provider \" +\n \"could charge for this' is not enough; if you would only use it for \" +\n \"free, do not request it. Describe the paid API call you wanted to \" +\n \"make: the input you would have sent, the output or state change you \" +\n \"were paying for, and roughly what a call was worth to the task, \" +\n \"phrased generally enough to serve multiple users. Good: 'resolve a \" +\n \"citation like Smith et al. 2019 to the actual paper, or report \" +\n \"that it does not exist — worth ~$0.10 per lookup'; 'semantic \" +\n \"search over paywalled full-text academic PDFs returning page-level \" +\n \"citations — worth ~$0.25 per query'. Bad: free tools that would \" +\n \"merely have been convenient, wishes about your own runtime or \" +\n \"harness ('cleaner context', 'more memory', local compute/IDE \" +\n \"features), and one-off task help ('fix my CI'). Requires a wallet \" +\n \"identity (attached automatically from your \" +\n \"local agentcash/X402_PRIVATE_KEY wallet); limited to 5 requests per \" +\n \"wallet per 24h. Free-text fields are redacted locally (PII and \" +\n \"secrets become [PLACEHOLDER]s) before anything is sent to the shared \" +\n \"CrowdCode backend.\",\n inputSchema: requestServiceShape,\n },\n (args) => handlers.request_service(args),\n );\n\n server.registerTool(\n \"get_service_score\",\n {\n description:\n \"Return the canonical trust-weighted score (`score`, with `n_eff` \" +\n \"evidence and an `unproven` flag), an AI review summary when \" +\n \"available, plus raw rating stats and recent reviews for a service, \" +\n \"identified by service_id, api_endpoint, payment target, or \" +\n \"directory_slug. Check this before paying for, provisioning, or calling \" +\n \"any paid agent service — especially x402 and mppx/MPP services.\",\n inputSchema: getServiceScoreShape,\n },\n (args) => handlers.get_service_score(args),\n );\n\n server.registerTool(\n \"get_review_signing_payload\",\n {\n description:\n \"Build the exact EIP-191 message for an mppx/x402 review — usually \" +\n \"UNNECESSARY: review_service signs automatically with your local \" +\n \"wallet. Use this only for transparency/debugging or when signing \" +\n \"with an external wallet. Runs entirely locally: the review reason is \" +\n \"redacted on this machine and only its hash enters the payload. Pass \" +\n \"auto_sign=true to also sign with the local wallet and get \" +\n \"review_signature + reviewer_wallet back. If signing externally, sign \" +\n \"`message` VERBATIM (byte-for-byte) with the payer wallet, then call \" +\n \"review_service with the returned `reason` and `identity` fields \" +\n \"verbatim, in this same session.\",\n inputSchema: signingPayloadShape,\n },\n (args) => handlers.get_review_signing_payload(args as SigningPayloadArgs),\n );\n\n server.registerTool(\n \"review_service\",\n {\n description:\n \"Submit a review after paying for a service — call this after EVERY \" +\n \"paid x402/mppx use, including slow responses and failures. A bad \" +\n \"outcome is not a reason to skip the review; it IS the review: rate \" +\n \"1-2 with the failure in the reason. Rate against the ORIGINAL task \" +\n \"you were solving: was the response relevant and did it actually \" +\n \"help answer that question? Rating scale: 5 = excellent (clear \" +\n \"schema, relevant output that answered the original question, fast, \" +\n \"clean receipt — would reuse confidently); 4 = helped but a real \" +\n \"schema/docs/latency/output caveat; 3 = paid but \" +\n \"thin/confusing/needed guesswork or not actually relevant/helpful \" +\n \"for the task (a technically valid answer that did not help is a 3 \" +\n \"at best); 2 = paid but poor (client error, unclear failure, hard \" +\n \"to use); 1 = paid and broken (server error, unusable output, \" +\n \"misleading challenge, timeout). A service that simply worked well \" +\n \"AND helped is a 5 — do not hedge to 4 without a concrete caveat. \" +\n \"SIGNING IS AUTOMATIC: this tool signs with your local \" +\n \"agentcash/X402_PRIVATE_KEY wallet (auto-created if missing) — do not \" +\n \"call get_review_signing_payload or sign externally. Get identity and \" +\n \"proofs from the ACTUAL payment, not a directory listing: \" +\n \"payment_reference = the settlement tx hash (x402) or Payment-Receipt \" +\n \"`reference` (mppx); \" +\n \"payment_proof = the base64 response header STRING — `payment-response` \" +\n \"for x402, `Payment-Receipt` for mppx — NOT the tx hash and NOT decoded \" +\n \"JSON. payment_proof is OPTIONAL: verified-purchase status (double \" +\n \"scoring weight) comes from on-chain transfer verification, which works \" +\n \"from the settlement tx hash in payment_reference alone — pass the \" +\n \"proof header too when you have it. payment_verification_level in the \" +\n \"response is the source of truth; \" +\n \"payment_target_ref = the real payee (the 402 challenge recipient / \" +\n \"on-chain Transfer `to`), not a bazaar/directory payTo. If you paid \" +\n \"from a different wallet than the local one, pass reviewer_wallet and \" +\n \"review_signature yourself (the wallet that SENT the payment — the \" +\n \"ERC-20 Transfer `from`, not the gasless facilitator). Limited to 1 \" +\n \"review per service per wallet per 24h. Free-text is redacted locally.\",\n inputSchema: reviewServiceShape,\n },\n (args) => handlers.review_service(args),\n );\n\n return server;\n}\n\nasync function warnOnToolDrift(upstream: Upstream): Promise<void> {\n try {\n const remote = new Set(await upstream.listToolNames());\n const missing = MIRRORED_REMOTE_TOOLS.filter((name) => !remote.has(name));\n if (missing.length > 0) {\n process.stderr.write(\n `crowdcode-mcp: backend no longer advertises: ${missing.join(\", \")} — ` +\n \"update the crowdcode-mcp package.\\n\",\n );\n }\n } catch {\n // Backend unreachable at startup (cold start); tool calls will retry.\n }\n}\n\nexport async function startServer(): Promise<void> {\n const config = getConfig();\n const engine = await RedactionEngine.create({\n cacheDir: config.cacheDir,\n enableModel: !config.disableModel,\n });\n const upstream = new UpstreamClient(config.backendUrl, config.upstreamTimeoutMs);\n const server = buildServer({ engine, upstream });\n await server.connect(new StdioServerTransport());\n void warnOnToolDrift(upstream);\n}\n","export interface RedactionInfo {\n entitiesRemoved: number;\n modelActive: boolean;\n}\n\n/** Attach the local-redaction attestation so agents (and users reading\n * transcripts) can see that redaction ran and at what coverage level. */\nexport function withRedactionAttestation(\n payload: Record<string, unknown>,\n info: RedactionInfo,\n): Record<string, unknown> {\n return {\n ...payload,\n _redaction: {\n entities_removed: info.entitiesRemoved,\n model_active: info.modelActive,\n },\n };\n}\n\nexport function toToolResult(payload: Record<string, unknown>): {\n content: Array<{ type: \"text\"; text: string }>;\n} {\n return { content: [{ type: \"text\", text: JSON.stringify(payload) }] };\n}\n","/**\n * Which tool arguments get redacted before leaving the machine.\n *\n * Only free-text fields are listed. Identity fields (api_endpoint,\n * payment_target_ref, directory_slug, service_id, service_name) and payment\n * material (payment_reference, payment_proof, reviewer_wallet,\n * review_signature) pass through untouched — redacting them would break\n * service resolution and payment verification, and they are minimized\n * server-side instead.\n */\n\nimport type { RedactionEngine } from \"@crowdcode/redaction\";\n\nexport const REDACTION_POLICY: Record<string, readonly string[]> = {\n request_service: [\"service_description\", \"task_context\"],\n review_service: [\"reason\", \"task_context\"],\n};\n\nexport interface RedactedArgs {\n args: Record<string, unknown>;\n entitiesRemoved: number;\n modelActive: boolean;\n}\n\nexport async function redactArgs(\n engine: RedactionEngine,\n tool: string,\n args: Record<string, unknown>,\n): Promise<RedactedArgs> {\n const fields = REDACTION_POLICY[tool] ?? [];\n const out = { ...args };\n let entitiesRemoved = 0;\n let modelActive = engine.modelActive;\n for (const field of fields) {\n const value = out[field];\n if (typeof value !== \"string\" || value === \"\") continue;\n const result = await engine.redact(value);\n out[field] = result.text;\n entitiesRemoved += result.entitiesRemoved;\n modelActive = result.modelActive;\n }\n return { args: out, entitiesRemoved, modelActive };\n}\n","/**\n * Static mirror of the backend tool signatures (src/crowdcode/server.py).\n * A static mirror — not dynamic passthrough — because get_review_signing_payload\n * is overridden locally and the redaction policy is keyed to known parameter\n * names; upstream drift should fail loudly, not silently forward unredacted\n * fields. Names/optionality must match the Python signatures exactly.\n */\n\nimport { z } from \"zod\";\n\nexport const identityShape = {\n service_id: z.string().nullish().describe(\"Canonical service id (svc_...)\"),\n api_endpoint: z.string().nullish().describe(\"Service API endpoint URL\"),\n payment_provider: z\n .string()\n .nullish()\n .describe(\"One of: stripe, stripe_payment_link, mppx, x402, manual\"),\n payment_target_ref: z\n .string()\n .nullish()\n .describe(\"Payment recipient reference (wallet address, account id, ...)\"),\n directory_slug: z.string().nullish().describe(\"Directory slug if known\"),\n};\n\nconst RATING_DESCRIPTION =\n \"Rating 1-5. Judge the output against the ORIGINAL task you were solving \" +\n \"(the task_context): was the response relevant and did it actually help \" +\n \"answer that question? 5 = excellent: clear schema, relevant output that \" +\n \"answered the original question, fast, clean receipt/proof — you would \" +\n \"reuse it confidently. 4 = works and helped with the task, but with a real \" +\n \"schema/docs/latency/output caveat (name it in the reason). 3 = mixed: \" +\n \"paid successfully but the response was thin, confusing, needed guesswork, \" +\n \"or was not actually relevant or helpful for the task — a technically \" +\n \"valid answer that did not help is a 3 at best. 2 = paid but poor: client \" +\n \"error, unclear failure, or hard to use. 1 = paid and broken: server \" +\n \"error, unusable output, misleading challenge, or severe reliability \" +\n \"problem (e.g. timeout). A service that simply worked well AND helped is \" +\n \"a 5 — do not hedge to 4 without a concrete caveat.\";\n\nexport const requestServiceShape = {\n service_description: z\n .string()\n .describe(\n \"The paid API call you wanted to make but could not find a provider \" +\n \"for: the input you would have sent, the output or state change you \" +\n \"were paying for, and roughly what a call was worth to the task \" +\n \"(e.g. 'would have paid ~$0.10 per lookup'). Must be something you \" +\n \"would have spent concrete money on right then — not a free tool \" +\n \"that would merely have been convenient. Keep it reusable across \" +\n \"users. Do NOT request local runtime/agent-harness wishes (context \" +\n \"management, local compute, IDE features) or one-off task help. Do \" +\n \"not include secrets, credentials, or private user data — free text \" +\n \"is additionally redacted locally before it leaves this machine.\",\n ),\n task_context: z\n .string()\n .nullish()\n .describe(\n \"Optional: what you were trying to accomplish when you hit the gap, \" +\n \"and the spend intent — that you searched for a paid service, found \" +\n \"none, and what you were prepared to pay.\",\n ),\n requester_wallet: z\n .string()\n .nullish()\n .describe(\n \"EVM 0x address identifying who is asking (rate-limit key). \" +\n \"Auto-filled from your local agentcash/X402_PRIVATE_KEY wallet — \" +\n \"only pass it to override.\",\n ),\n};\n\nexport const getServiceScoreShape = { ...identityShape };\n\nexport const signingPayloadShape = {\n rating: z.number().int().describe(RATING_DESCRIPTION),\n reason: z.string().describe(\"Review text (redacted locally before hashing)\"),\n payment_reference: z.string().describe(\"Payment reference for this review\"),\n ...identityShape,\n auto_sign: z\n .boolean()\n .nullish()\n .describe(\n \"When true, also sign the message with the local wallet and return \" +\n \"review_signature + reviewer_wallet. Usually unnecessary: \" +\n \"review_service signs automatically.\",\n ),\n};\n\nexport const reviewServiceShape = {\n rating: z.number().int().describe(RATING_DESCRIPTION),\n reason: z.string().describe(\"Review text (redacted locally before sending)\"),\n payment_reference: z.string().describe(\"Unique payment reference\"),\n service_id: identityShape.service_id,\n task_context: z.string().nullish(),\n service_name: z.string().nullish(),\n api_endpoint: identityShape.api_endpoint,\n payment_provider: identityShape.payment_provider,\n payment_target_ref: identityShape.payment_target_ref,\n directory_slug: identityShape.directory_slug,\n payment_proof: z\n .string()\n .nullish()\n .describe(\n \"Optional: the base64 payment-response (x402) or Payment-Receipt \" +\n \"(mppx) header string. Verified-purchase status comes from on-chain \" +\n \"transfer verification, which also works from a settlement tx hash \" +\n \"in payment_reference alone — without either, the review is stored \" +\n \"as UNVERIFIED and carries half weight in scoring.\",\n ),\n payment_challenge: z.string().nullish(),\n reviewer_wallet: z\n .string()\n .nullish()\n .describe(\"Optional; auto-filled from your local wallet when signing locally\"),\n review_signature: z\n .string()\n .nullish()\n .describe(\n \"Optional; crowdcode-mcp signs automatically with your local \" +\n \"agentcash/X402_PRIVATE_KEY wallet. A supplied signature always wins.\",\n ),\n signature_scheme: z.string().default(\"eip191\"),\n};\n\nexport const MIRRORED_REMOTE_TOOLS = [\n \"request_service\",\n \"get_service_score\",\n \"review_service\",\n] as const;\n","/**\n * Local implementation of get_review_signing_payload.\n *\n * This replaces the remote tool so raw review text is never sent at signing\n * time: the reason is redacted locally, hashed locally, and the canonical\n * EIP-191 message is constructed locally (spec/CANONICAL_PAYLOAD.md).\n *\n * The identity-merge logic mirrors the backend exactly\n * (src/crowdcode/server.py review_service effective_identity): the server\n * verifies signatures by REBUILDING the payload from its own resolved\n * identity, so the message signed here must match that reconstruction\n * byte-for-byte. Canonical identity comes from get_service_score when the\n * service exists; otherwise the caller-provided identity is used verbatim,\n * exactly like the old remote signing tool.\n */\n\nimport type { RedactionResult } from \"@crowdcode/redaction\";\nimport { buildIdentity, type ServiceIdentity } from \"../canonical/identity.js\";\nimport { canonicalReviewPayload } from \"../canonical/payload.js\";\nimport type { Upstream } from \"../upstream.js\";\n\nexport interface SigningPayloadArgs {\n rating: number;\n reason: string;\n payment_reference: string;\n service_id?: string | null;\n api_endpoint?: string | null;\n payment_provider?: string | null;\n payment_target_ref?: string | null;\n directory_slug?: string | null;\n}\n\nexport interface SigningDeps {\n redact(text: string): Promise<RedactionResult>;\n upstream: Pick<Upstream, \"call\">;\n}\n\nfunction orNull(value: unknown): string | null {\n return typeof value === \"string\" && value !== \"\" ? value : null;\n}\n\nexport async function getReviewSigningPayload(\n deps: SigningDeps,\n args: SigningPayloadArgs,\n): Promise<Record<string, unknown>> {\n let identity: ServiceIdentity;\n try {\n identity = buildIdentity(args);\n } catch (err) {\n return { ok: false, reason: (err as Error).message };\n }\n\n const redacted = await deps.redact(args.reason);\n\n let score: Record<string, unknown>;\n try {\n score = await deps.upstream.call(\"get_service_score\", {\n service_id: identity.service_id,\n api_endpoint: identity.api_endpoint,\n payment_provider: identity.payment_provider,\n payment_target_ref: identity.payment_target_ref,\n directory_slug: identity.directory_slug,\n });\n } catch (err) {\n return {\n ok: false,\n reason: `could not reach the CrowdCode backend to resolve the service: ${\n (err as Error).message\n }`,\n };\n }\n\n let effective = identity;\n if (score.found === true) {\n try {\n // Same merge as the backend: caller-normalized fields win, canonical\n // values fill the gaps, and the result is re-normalized.\n effective = buildIdentity({\n service_id: orNull(score.service_id),\n service_name: orNull(score.service_name),\n api_endpoint: identity.api_endpoint ?? orNull(score.canonical_endpoint),\n payment_provider:\n identity.payment_provider ?? orNull(score.payment_provider),\n payment_target_ref:\n identity.payment_target_ref ?? orNull(score.payment_target_ref),\n directory_slug: identity.directory_slug ?? orNull(score.directory_slug),\n });\n } catch (err) {\n return { ok: false, reason: (err as Error).message };\n }\n } else if (\n typeof score.reason === \"string\" &&\n score.reason !== \"service not found\"\n ) {\n // e.g. \"service identity conflict\" — same failure the remote tool returned.\n return { ok: false, reason: score.reason };\n }\n\n const message = canonicalReviewPayload({\n identity: effective,\n rating: args.rating,\n reason: redacted.text,\n paymentReference: args.payment_reference,\n });\n\n return {\n ok: true,\n signature_scheme: \"eip191\",\n message,\n reason: redacted.text,\n identity: {\n service_id: effective.service_id,\n api_endpoint: effective.api_endpoint,\n payment_provider: effective.payment_provider,\n payment_target_ref: effective.payment_target_ref,\n directory_slug: effective.directory_slug,\n },\n instructions:\n \"Sign `message` with the reviewer wallet (EIP-191 personal_sign). Then \" +\n \"call review_service in this same session, passing this exact `reason` \" +\n \"string and every field of `identity` verbatim, plus the same rating \" +\n \"and payment_reference.\",\n _redaction: {\n entities_removed: redacted.entitiesRemoved,\n model_active: redacted.modelActive,\n },\n };\n}\n","/**\n * Transparent in-process signing for review_service.\n *\n * For mppx/x402 reviews where the caller did not supply review_signature,\n * this builds the canonical message (identity-merge + local redaction via\n * getReviewSigningPayload), signs it with the local agentcash wallet (or\n * X402_PRIVATE_KEY), and augments the outgoing arguments — so an agent can\n * call review_service end-to-end with no external signing step. A\n * caller-supplied signature always wins.\n *\n * The signature covers the REDACTED reason; the redaction engine memoizes,\n * so the later per-forward redaction pass produces the byte-identical string\n * the backend hashes when rebuilding the payload.\n */\n\nimport { normalizePaymentProvider } from \"../canonical/identity.js\";\nimport {\n loadWallet,\n type LoadedWallet,\n type WalletSource,\n} from \"../wallet.js\";\nimport { getReviewSigningPayload, type SigningDeps } from \"./signing-payload.js\";\n\nexport const AGENTCASH_INSTALL_COMMAND =\n \"claude mcp add --scope user agentcash -- npx -y agentcash@latest\";\n\nexport interface NextStep {\n action: string;\n summary: string;\n command: string | null;\n link: string | null;\n retry: { tool: string; after_seconds: number | null; with: Record<string, unknown> } | null;\n}\n\nexport function installWalletNextStep(retryTool: string): NextStep {\n return {\n action: \"install_wallet\",\n summary:\n \"No local signing wallet found. Install agentcash (or set \" +\n \"X402_PRIVATE_KEY) so crowdcode-mcp can sign automatically, then retry \" +\n retryTool +\n \".\",\n command: AGENTCASH_INSTALL_COMMAND,\n link: null,\n retry: { tool: retryTool, after_seconds: null, with: {} },\n };\n}\n\nexport interface WalletOptions {\n walletDir?: string;\n autoCreate: boolean;\n env?: NodeJS.ProcessEnv;\n}\n\nexport interface PreparedReview {\n args: Record<string, unknown>;\n /** Set when local signing was attempted (mppx/x402, no caller signature). */\n wallet_source?: WalletSource;\n wallet_created?: boolean;\n wallet_error?: string;\n next_step?: NextStep;\n /** Wallet used for signing — kept so a signature-mismatch retry can re-sign. */\n wallet?: LoadedWallet;\n signed: boolean;\n}\n\nfunction isMachineProvider(value: unknown): boolean {\n if (typeof value !== \"string\") return false;\n try {\n const provider = normalizePaymentProvider(value);\n return provider === \"mppx\" || provider === \"x402\";\n } catch {\n // Unknown provider: forward as-is and let the backend produce its error.\n return false;\n }\n}\n\nexport async function prepareSignedReview(\n deps: SigningDeps,\n args: Record<string, unknown>,\n wallet: WalletOptions,\n): Promise<PreparedReview> {\n if (!isMachineProvider(args.payment_provider) || args.review_signature) {\n return { args, signed: false };\n }\n\n const loaded = await loadWallet({\n walletDir: wallet.walletDir,\n autoCreate: wallet.autoCreate,\n env: wallet.env,\n });\n if (loaded.source === \"none\" || loaded.account === null) {\n return {\n args,\n signed: false,\n wallet_source: \"none\",\n wallet_error: loaded.error,\n next_step: installWalletNextStep(\"review_service\"),\n };\n }\n\n const payload = await getReviewSigningPayload(deps, {\n rating: args.rating as number,\n reason: String(args.reason ?? \"\"),\n payment_reference: String(args.payment_reference ?? \"\"),\n service_id: args.service_id as string | null | undefined,\n api_endpoint: args.api_endpoint as string | null | undefined,\n payment_provider: args.payment_provider as string | null | undefined,\n payment_target_ref: args.payment_target_ref as string | null | undefined,\n directory_slug: args.directory_slug as string | null | undefined,\n });\n if (payload.ok !== true || typeof payload.message !== \"string\") {\n // Forward unsigned; the backend rejection (plus its next_step) is more\n // actionable than failing locally with a half-built payload.\n return {\n args,\n signed: false,\n wallet_source: loaded.source,\n wallet_created: loaded.created,\n wallet_error: `could not build the signing payload locally: ${String(\n payload.reason ?? \"unknown error\",\n )}`,\n };\n }\n\n const signature = await loaded.account.signMessage({\n message: payload.message,\n });\n const identity = payload.identity as Record<string, unknown>;\n return {\n args: {\n ...args,\n // Pass the resolved identity verbatim so the backend rebuilds the exact\n // payload that was just signed.\n service_id: identity.service_id ?? args.service_id,\n api_endpoint: identity.api_endpoint ?? args.api_endpoint,\n payment_provider: identity.payment_provider ?? args.payment_provider,\n payment_target_ref: identity.payment_target_ref ?? args.payment_target_ref,\n directory_slug: identity.directory_slug ?? args.directory_slug,\n reviewer_wallet: loaded.address,\n review_signature: signature,\n signature_scheme: \"eip191\",\n },\n signed: true,\n wallet_source: loaded.source,\n wallet_created: loaded.created,\n wallet: loaded,\n };\n}\n\n/**\n * Handle the backend's signature-mismatch recovery contract: re-sign the\n * returned expected_message with the same wallet and rebuild the args using\n * resolved_identity. Returns null when the response is not a recoverable\n * mismatch (or we did not sign locally in the first place).\n */\nexport async function resignFromMismatch(\n prepared: PreparedReview,\n response: Record<string, unknown>,\n): Promise<Record<string, unknown> | null> {\n if (!prepared.signed || !prepared.wallet?.account) return null;\n if (response.accepted !== false) return null;\n if (typeof response.expected_message !== \"string\") return null;\n\n const identity = (response.resolved_identity ?? {}) as Record<string, unknown>;\n const signature = await prepared.wallet.account.signMessage({\n message: response.expected_message,\n });\n return {\n ...prepared.args,\n service_id: identity.service_id ?? prepared.args.service_id,\n api_endpoint: identity.api_endpoint ?? prepared.args.api_endpoint,\n payment_provider: identity.payment_provider ?? prepared.args.payment_provider,\n payment_target_ref:\n identity.payment_target_ref ?? prepared.args.payment_target_ref,\n directory_slug: identity.directory_slug ?? prepared.args.directory_slug,\n review_signature: signature,\n };\n}\n","import { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\n\n/** A tool-level failure reported by the backend (not a transport problem). */\nexport class UpstreamError extends Error {}\n\nexport interface Upstream {\n call(\n name: string,\n args: Record<string, unknown>,\n ): Promise<Record<string, unknown>>;\n listToolNames(): Promise<string[]>;\n}\n\nexport class UpstreamClient implements Upstream {\n private client: Client | null = null;\n\n constructor(\n private readonly baseUrl: string,\n private readonly timeoutMs: number,\n ) {}\n\n private async connect(): Promise<Client> {\n if (this.client !== null) return this.client;\n const client = new Client({ name: \"crowdcode-mcp-local\", version: \"0.1.0\" });\n const transport = new StreamableHTTPClientTransport(new URL(this.baseUrl));\n await client.connect(transport);\n this.client = client;\n return client;\n }\n\n private async reset(): Promise<void> {\n const client = this.client;\n this.client = null;\n if (client !== null) {\n try {\n await client.close();\n } catch {\n // already broken\n }\n }\n }\n\n async call(\n name: string,\n args: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n try {\n return await this.callOnce(name, args);\n } catch (err) {\n if (err instanceof UpstreamError) throw err;\n // Transport-level failure: reconnect once (absorbs dropped sessions and\n // Render cold starts).\n await this.reset();\n return this.callOnce(name, args);\n }\n }\n\n private async callOnce(\n name: string,\n args: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n const client = await this.connect();\n const result = await client.callTool({ name, arguments: args }, undefined, {\n timeout: this.timeoutMs,\n });\n\n if (result.isError) {\n throw new UpstreamError(\n `backend tool ${name} failed: ${firstText(result.content)}`,\n );\n }\n const structured = result.structuredContent;\n if (structured !== undefined && isRecord(structured)) {\n return structured;\n }\n const text = firstText(result.content);\n try {\n const parsed: unknown = JSON.parse(text);\n if (isRecord(parsed)) return parsed;\n } catch {\n // fall through\n }\n throw new UpstreamError(\n `backend tool ${name} returned an unparseable result: ${text.slice(0, 200)}`,\n );\n }\n\n async listToolNames(): Promise<string[]> {\n const client = await this.connect();\n const { tools } = await client.listTools();\n return tools.map((tool) => tool.name);\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction firstText(content: unknown): string {\n if (Array.isArray(content)) {\n for (const item of content) {\n if (\n isRecord(item) &&\n item.type === \"text\" &&\n typeof item.text === \"string\"\n ) {\n return item.text;\n }\n }\n }\n return \"\";\n}\n"],"mappings":";;;;;;;;;;;AAQA,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,4BA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3C;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,aACE;AAAA,MAUF,aAAa;AAAA,IACf;AAAA,IACA,CAAC,SAAS,SAAS,2BAA2B,IAA0B;AAAA,EAC1E;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,aACE;AAAA,MAkCF,aAAa;AAAA,IACf;AAAA,IACA,CAAC,SAAS,SAAS,eAAe,IAAI;AAAA,EACxC;AAEA,SAAO;AACT;AAEA,eAAe,gBAAgB,UAAmC;AAChE,MAAI;AACF,UAAM,SAAS,IAAI,IAAI,MAAM,SAAS,cAAc,CAAC;AACrD,UAAM,UAAU,sBAAsB,OAAO,CAAC,SAAS,CAAC,OAAO,IAAI,IAAI,CAAC;AACxE,QAAI,QAAQ,SAAS,GAAG;AACtB,cAAQ,OAAO;AAAA,QACb,gDAAgD,QAAQ,KAAK,IAAI,CAAC;AAAA;AAAA,MAEpE;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AACF;AAEA,eAAsB,cAA6B;AACjD,QAAM,SAAS,UAAU;AACzB,QAAM,SAAS,MAAM,gBAAgB,OAAO;AAAA,IAC1C,UAAU,OAAO;AAAA,IACjB,aAAa,CAAC,OAAO;AAAA,EACvB,CAAC;AACD,QAAM,WAAW,IAAI,eAAe,OAAO,YAAY,OAAO,iBAAiB;AAC/E,QAAM,SAAS,YAAY,EAAE,QAAQ,SAAS,CAAC;AAC/C,QAAM,OAAO,QAAQ,IAAI,qBAAqB,CAAC;AAC/C,OAAK,gBAAgB,QAAQ;AAC/B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/server.ts","../src/attestation.ts","../src/redaction/policy.ts","../src/schemas.ts","../src/tools/signing-payload.ts","../src/tools/sign-review.ts","../src/upstream.ts"],"sourcesContent":["/**\n * The stdio MCP server. Advertises the same tools as the CrowdCode backend;\n * free-text arguments are redacted locally (Rampart + secret recognizers)\n * before forwarding over streamable-HTTP, and get_review_signing_payload is\n * served entirely locally so raw review text never leaves this machine at\n * signing time.\n */\n\nimport { RedactionEngine } from \"@crowdcode/redaction\";\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { toToolResult, withRedactionAttestation } from \"./attestation.js\";\nimport { getConfig } from \"./config.js\";\nimport { redactArgs } from \"./redaction/policy.js\";\nimport {\n MIRRORED_REMOTE_TOOLS,\n getServiceScoreShape,\n requestServiceShape,\n reviewServiceShape,\n signingPayloadShape,\n} from \"./schemas.js\";\nimport {\n prepareSignedReview,\n resignFromMismatch,\n installWalletNextStep,\n type PreparedReview,\n type WalletOptions,\n} from \"./tools/sign-review.js\";\nimport {\n getReviewSigningPayload,\n type SigningPayloadArgs,\n} from \"./tools/signing-payload.js\";\nimport { UpstreamClient, UpstreamError, type Upstream } from \"./upstream.js\";\nimport { loadWallet } from \"./wallet.js\";\n\nexport interface ServerDeps {\n engine: RedactionEngine;\n upstream: Upstream;\n /** Wallet loading knobs; defaults come from getConfig(). Injectable in tests. */\n wallet?: Partial<WalletOptions>;\n}\n\ntype ToolResult = ReturnType<typeof toToolResult>;\n\nfunction errorPayload(\n tool: string,\n err: unknown,\n): Record<string, unknown> {\n const message =\n err instanceof UpstreamError\n ? err.message\n : `could not reach the CrowdCode backend: ${(err as Error).message}`;\n const next_step = {\n action: \"retry_backend\",\n summary:\n \"The CrowdCode backend may be cold-starting (free-tier hosting); retry \" +\n \"the same call in ~30 seconds.\",\n command: null,\n link: null,\n retry: { tool, after_seconds: 30, with: {} },\n };\n if (tool === \"get_service_score\") {\n return {\n found: false,\n score: null,\n n_eff: 0,\n unproven: true,\n avg_rating: null,\n num_reviews: 0,\n summary: null,\n recent_reviews: [],\n reason: message,\n next_step,\n };\n }\n return { accepted: false, reason: message, next_step };\n}\n\nfunction withWalletInfo(\n payload: Record<string, unknown>,\n prepared: PreparedReview,\n): Record<string, unknown> {\n const out = { ...payload };\n if (prepared.wallet_source !== undefined) {\n out.wallet_source = prepared.wallet_source;\n }\n if (prepared.wallet_created) out.wallet_created = true;\n if (prepared.wallet_error) out.wallet_error = prepared.wallet_error;\n if (out.next_step === undefined && prepared.next_step) {\n out.next_step = prepared.next_step;\n }\n return out;\n}\n\nexport function createToolHandlers(deps: ServerDeps) {\n const { engine, upstream } = deps;\n const config = getConfig();\n const walletOptions: WalletOptions = {\n walletDir: deps.wallet?.walletDir ?? config.walletDir,\n autoCreate: deps.wallet?.autoCreate ?? config.walletAutoCreate,\n env: deps.wallet?.env,\n };\n const signingDeps = { redact: (text: string) => engine.redact(text), upstream };\n // Show the install-wallet onboarding CTA at most once per process so score\n // lookups don't nag (agentcash pattern: CTA on success, never stacked).\n let onboardingCtaShown = false;\n\n async function forwardPayload(\n tool: string,\n args: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n const redacted = await redactArgs(engine, tool, args);\n try {\n const result = await upstream.call(tool, redacted.args);\n return withRedactionAttestation(result, {\n entitiesRemoved: redacted.entitiesRemoved,\n modelActive: redacted.modelActive,\n });\n } catch (err) {\n return errorPayload(tool, err);\n }\n }\n\n return {\n request_service: async (\n args: Record<string, unknown>,\n ): Promise<ToolResult> => {\n let outgoing = args;\n if (!outgoing.requester_wallet) {\n // Read-only probe: requests never mint a wallet; the review flow does.\n const wallet = await loadWallet({\n walletDir: walletOptions.walletDir,\n env: walletOptions.env,\n autoCreate: false,\n });\n if (wallet.address) {\n outgoing = { ...outgoing, requester_wallet: wallet.address };\n }\n }\n return toToolResult(await forwardPayload(\"request_service\", outgoing));\n },\n\n get_service_score: async (\n args: Record<string, unknown>,\n ): Promise<ToolResult> => {\n let payload: Record<string, unknown>;\n try {\n payload = await upstream.call(\"get_service_score\", args);\n } catch (err) {\n return toToolResult(errorPayload(\"get_service_score\", err));\n }\n const provider = payload.payment_provider;\n if (\n !onboardingCtaShown &&\n payload.found === true &&\n (provider === \"mppx\" || provider === \"x402\")\n ) {\n const wallet = await loadWallet({\n walletDir: walletOptions.walletDir,\n env: walletOptions.env,\n autoCreate: false,\n });\n if (wallet.source === \"none\") {\n onboardingCtaShown = true;\n payload = {\n ...payload,\n onboarding_cta: {\n message:\n \"This is a paid x402/mppx service and you have no local \" +\n \"signing wallet yet. Install agentcash (or set \" +\n \"X402_PRIVATE_KEY) so your post-purchase review can be \" +\n \"signed and counted.\",\n command: installWalletNextStep(\"review_service\").command,\n },\n };\n }\n }\n return toToolResult(payload);\n },\n\n get_review_signing_payload: async (\n args: SigningPayloadArgs & { auto_sign?: boolean | null },\n ): Promise<ToolResult> => {\n const payload = await getReviewSigningPayload(signingDeps, args);\n if (args.auto_sign !== true || payload.ok !== true) {\n return toToolResult(payload);\n }\n const wallet = await loadWallet(walletOptions);\n if (wallet.source === \"none\" || wallet.account === null) {\n return toToolResult({\n ...payload,\n wallet_source: \"none\",\n wallet_error: wallet.error,\n next_step: installWalletNextStep(\"review_service\"),\n });\n }\n const signature = await wallet.account.signMessage({\n message: payload.message as string,\n });\n return toToolResult({\n ...payload,\n review_signature: signature,\n reviewer_wallet: wallet.address,\n wallet_source: wallet.source,\n ...(wallet.created ? { wallet_created: true } : {}),\n });\n },\n\n review_service: async (\n args: Record<string, unknown>,\n ): Promise<ToolResult> => {\n const prepared = await prepareSignedReview(signingDeps, args, walletOptions);\n let payload = await forwardPayload(\"review_service\", prepared.args);\n // Signature-mismatch recovery (identity resolution race): re-sign the\n // backend's expected_message once with the same wallet and retry. A\n // second mismatch is surfaced to the caller.\n const retryArgs = await resignFromMismatch(prepared, payload);\n if (retryArgs !== null) {\n payload = await forwardPayload(\"review_service\", retryArgs);\n }\n return toToolResult(withWalletInfo(payload, prepared));\n },\n };\n}\n\nconst SERVER_INSTRUCTIONS = [\n \"CrowdCode is a shared reputation layer for paid agent services. Use it\",\n \"whenever a task involves paying for, provisioning, or calling a paid\",\n \"service — especially x402 or mppx/MPP services.\",\n \"\",\n \"Before spending: call get_service_score on each candidate (prefer\",\n \"api_endpoint + payment_provider + payment_target_ref, or service_id /\",\n \"directory_slug). Prefer higher `score` (the canonical trust-weighted\",\n \"rating), using `n_eff` as evidence context; `unproven: true` means not\",\n \"enough trusted reviews yet — treat it as insufficient evidence, not a bad\",\n \"score, and fall back to price and the spend policy. When present,\",\n \"`summary` digests what reviewers reported (strengths / failure modes /\",\n \"caveats).\",\n \"\",\n \"After ANY paid use — success, slow response, or failure: submit a review.\",\n \"A slow or broken paid call is not a reason to skip the review; it IS the\",\n \"review (slowness or breakage goes in the rating and reason). Rate against\",\n \"the ORIGINAL task you were solving: was the response relevant and did it\",\n \"actually help answer that question? Fixed scale: 5 = excellent (clear\",\n \"schema, relevant output that answered the original question, fast, clean\",\n \"receipt — would reuse confidently); 4 = helped but a real\",\n \"schema/docs/latency/output caveat; 3 = paid but response thin, confusing,\",\n \"needed guesswork, or not actually relevant/helpful for the task (a\",\n \"technically valid answer that did not help is a 3 at best); 2 = paid but\",\n \"poor (client error, unclear failure, hard to use); 1 = paid and broken\",\n \"(server error, unusable output, misleading challenge, timeout/severe\",\n \"reliability). A service that simply worked well AND helped is a 5 — do\",\n \"not hedge to 4 without a concrete caveat.\",\n \"\",\n \"Signing is AUTOMATIC: review_service signs with your local wallet\",\n \"(X402_PRIVATE_KEY, or the agentcash wallet at ~/.agentcash/wallet.json,\",\n \"auto-created if missing) — you do not need get_review_signing_payload or\",\n \"an external signer. Responses include wallet_source (env | agentcash |\",\n \"none). For x402/mppx, take identity and proofs from the ACTUAL payment,\",\n \"not a directory listing: payment_reference = the settlement tx hash (x402)\",\n \"or Payment-Receipt reference (mppx); payment_proof = the base64 response\",\n \"header string (payment-response for x402, Payment-Receipt for mppx), not\",\n \"the tx hash or decoded JSON. payment_proof is OPTIONAL: verified-purchase\",\n \"status (double scoring weight) comes from CrowdCode verifying the ERC-20\",\n \"transfer on-chain, which works from the settlement tx hash in\",\n \"payment_reference alone — so clients that only have a tx hash (e.g.\",\n \"agentcash) get the same verified status as clients that pass the proof\",\n \"header. payment_verification_level in the response is the source of\",\n \"truth. On-chain verification covers x402 on Base and mppx on Tempo;\",\n \"payments settled elsewhere (e.g. Solana) are accepted but stay\",\n \"signature_only. payment_target_ref = the real on-chain payee (the 402\",\n \"challenge recipient / Transfer `to`), not a directory payTo.\",\n \"\",\n \"Workflow: 1) get_service_score on each candidate; 2) pay and use the\",\n \"service; 3) review_service with the settlement tx hash as\",\n \"payment_reference (plus the payment_proof header if you have it). Reviews\",\n \"are limited to 1 per service per wallet per 24h; failed calls return a\",\n \"next_step object with the exact command or retry that fixes them —\",\n \"follow it.\",\n \"\",\n \"When you were actively trying to BUY a capability and no fitting paid\",\n \"service exists, call request_service once (requires a wallet identity,\",\n \"attached automatically; limited to 5 requests per wallet per 24h). The\",\n \"gate is willingness to pay: you had the task, a wallet, and spend\",\n \"authority, and would have paid concrete money for this right then if it\",\n \"existed. 'A provider could charge for this' is not enough — a free tool\",\n \"that would merely have been convenient is not a service request. Describe\",\n \"the paid API call you wanted to make: the input you would have sent, the\",\n \"output or state change you were paying for, and roughly what a call was\",\n \"worth to the task. Never free-tool wishes, runtime or agent-harness\",\n \"wishes (context management, local compute), or one-off task help. Never\",\n \"send secrets or private data — free-text fields are redacted locally\",\n \"before anything is sent.\",\n].join(\"\\n\");\n\nexport function buildServer(deps: ServerDeps): McpServer {\n const server = new McpServer(\n { name: \"crowdcode\", version: \"0.3.0\" },\n { instructions: SERVER_INSTRUCTIONS },\n );\n const handlers = createToolHandlers(deps);\n\n server.registerTool(\n \"request_service\",\n {\n description:\n \"Record unmet paid-service demand for future directory coverage. \" +\n \"Call this only when you were actively trying to BUY a capability — \" +\n \"you had the task, a wallet, and spend authority, and would have \" +\n \"paid concrete money right then if the service existed — and no \" +\n \"fitting paid service (x402/mppx/Stripe) could be found. 'A provider \" +\n \"could charge for this' is not enough; if you would only use it for \" +\n \"free, do not request it. Describe the paid API call you wanted to \" +\n \"make: the input you would have sent, the output or state change you \" +\n \"were paying for, and roughly what a call was worth to the task, \" +\n \"phrased generally enough to serve multiple users. Good: 'resolve a \" +\n \"citation like Smith et al. 2019 to the actual paper, or report \" +\n \"that it does not exist — worth ~$0.10 per lookup'; 'semantic \" +\n \"search over paywalled full-text academic PDFs returning page-level \" +\n \"citations — worth ~$0.25 per query'. Bad: free tools that would \" +\n \"merely have been convenient, wishes about your own runtime or \" +\n \"harness ('cleaner context', 'more memory', local compute/IDE \" +\n \"features), and one-off task help ('fix my CI'). Requires a wallet \" +\n \"identity (attached automatically from your \" +\n \"local agentcash/X402_PRIVATE_KEY wallet); limited to 5 requests per \" +\n \"wallet per 24h. Free-text fields are redacted locally (PII and \" +\n \"secrets become [PLACEHOLDER]s) before anything is sent to the shared \" +\n \"CrowdCode backend.\",\n inputSchema: requestServiceShape,\n },\n (args) => handlers.request_service(args),\n );\n\n server.registerTool(\n \"get_service_score\",\n {\n description:\n \"Return the canonical trust-weighted score (`score`, with `n_eff` \" +\n \"evidence and an `unproven` flag), an AI review summary when \" +\n \"available, plus raw rating stats and recent reviews for a service, \" +\n \"identified by service_id, api_endpoint, payment target, or \" +\n \"directory_slug. Check this before paying for, provisioning, or calling \" +\n \"any paid agent service — especially x402 and mppx/MPP services.\",\n inputSchema: getServiceScoreShape,\n },\n (args) => handlers.get_service_score(args),\n );\n\n server.registerTool(\n \"get_review_signing_payload\",\n {\n description:\n \"Build the exact EIP-191 message for an mppx/x402 review — usually \" +\n \"UNNECESSARY: review_service signs automatically with your local \" +\n \"wallet. Use this only for transparency/debugging or when signing \" +\n \"with an external wallet. Runs entirely locally: the review reason is \" +\n \"redacted on this machine and only its hash enters the payload. Pass \" +\n \"auto_sign=true to also sign with the local wallet and get \" +\n \"review_signature + reviewer_wallet back. If signing externally, sign \" +\n \"`message` VERBATIM (byte-for-byte) with the payer wallet, then call \" +\n \"review_service with the returned `reason` and `identity` fields \" +\n \"verbatim, in this same session.\",\n inputSchema: signingPayloadShape,\n },\n (args) => handlers.get_review_signing_payload(args as SigningPayloadArgs),\n );\n\n server.registerTool(\n \"review_service\",\n {\n description:\n \"Submit a review after paying for a service — call this after EVERY \" +\n \"paid x402/mppx use, including slow responses and failures. A bad \" +\n \"outcome is not a reason to skip the review; it IS the review: rate \" +\n \"1-2 with the failure in the reason. Rate against the ORIGINAL task \" +\n \"you were solving: was the response relevant and did it actually \" +\n \"help answer that question? Rating scale: 5 = excellent (clear \" +\n \"schema, relevant output that answered the original question, fast, \" +\n \"clean receipt — would reuse confidently); 4 = helped but a real \" +\n \"schema/docs/latency/output caveat; 3 = paid but \" +\n \"thin/confusing/needed guesswork or not actually relevant/helpful \" +\n \"for the task (a technically valid answer that did not help is a 3 \" +\n \"at best); 2 = paid but poor (client error, unclear failure, hard \" +\n \"to use); 1 = paid and broken (server error, unusable output, \" +\n \"misleading challenge, timeout). A service that simply worked well \" +\n \"AND helped is a 5 — do not hedge to 4 without a concrete caveat. \" +\n \"SIGNING IS AUTOMATIC: this tool signs with your local \" +\n \"agentcash/X402_PRIVATE_KEY wallet (auto-created if missing) — do not \" +\n \"call get_review_signing_payload or sign externally. Get identity and \" +\n \"proofs from the ACTUAL payment, not a directory listing: \" +\n \"payment_reference = the settlement tx hash (x402) or Payment-Receipt \" +\n \"`reference` (mppx); \" +\n \"payment_proof = the base64 response header STRING — `payment-response` \" +\n \"for x402, `Payment-Receipt` for mppx — NOT the tx hash and NOT decoded \" +\n \"JSON. payment_proof is OPTIONAL: verified-purchase status (double \" +\n \"scoring weight) comes from on-chain transfer verification, which works \" +\n \"from the settlement tx hash in payment_reference alone — pass the \" +\n \"proof header too when you have it. payment_verification_level in the \" +\n \"response is the source of truth; \" +\n \"payment_target_ref = the real payee (the 402 challenge recipient / \" +\n \"on-chain Transfer `to`), not a bazaar/directory payTo. If you paid \" +\n \"from a different wallet than the local one, pass reviewer_wallet and \" +\n \"review_signature yourself (the wallet that SENT the payment — the \" +\n \"ERC-20 Transfer `from`, not the gasless facilitator). Limited to 1 \" +\n \"review per service per wallet per 24h. Free-text is redacted locally.\",\n inputSchema: reviewServiceShape,\n },\n (args) => handlers.review_service(args),\n );\n\n return server;\n}\n\nasync function warnOnToolDrift(upstream: Upstream): Promise<void> {\n try {\n const remote = new Set(await upstream.listToolNames());\n const missing = MIRRORED_REMOTE_TOOLS.filter((name) => !remote.has(name));\n if (missing.length > 0) {\n process.stderr.write(\n `crowdcode-mcp: backend no longer advertises: ${missing.join(\", \")} — ` +\n \"update the crowdcode-mcp package.\\n\",\n );\n }\n } catch {\n // Backend unreachable at startup (cold start); tool calls will retry.\n }\n}\n\nexport async function startServer(): Promise<void> {\n const config = getConfig();\n const engine = await RedactionEngine.create({\n cacheDir: config.cacheDir,\n enableModel: !config.disableModel,\n });\n const upstream = new UpstreamClient(config.backendUrl, config.upstreamTimeoutMs);\n const server = buildServer({ engine, upstream });\n await server.connect(new StdioServerTransport());\n void warnOnToolDrift(upstream);\n}\n","export interface RedactionInfo {\n entitiesRemoved: number;\n modelActive: boolean;\n}\n\n/** Attach the local-redaction attestation so agents (and users reading\n * transcripts) can see that redaction ran and at what coverage level. */\nexport function withRedactionAttestation(\n payload: Record<string, unknown>,\n info: RedactionInfo,\n): Record<string, unknown> {\n return {\n ...payload,\n _redaction: {\n entities_removed: info.entitiesRemoved,\n model_active: info.modelActive,\n },\n };\n}\n\nexport function toToolResult(payload: Record<string, unknown>): {\n content: Array<{ type: \"text\"; text: string }>;\n} {\n return { content: [{ type: \"text\", text: JSON.stringify(payload) }] };\n}\n","/**\n * Which tool arguments get redacted before leaving the machine.\n *\n * Only free-text fields are listed. Identity fields (api_endpoint,\n * payment_target_ref, directory_slug, service_id, service_name) and payment\n * material (payment_reference, payment_proof, reviewer_wallet,\n * review_signature) pass through untouched — redacting them would break\n * service resolution and payment verification, and they are minimized\n * server-side instead.\n */\n\nimport type { RedactionEngine } from \"@crowdcode/redaction\";\n\nexport const REDACTION_POLICY: Record<string, readonly string[]> = {\n request_service: [\"service_description\", \"task_context\"],\n review_service: [\"reason\", \"task_context\"],\n};\n\nexport interface RedactedArgs {\n args: Record<string, unknown>;\n entitiesRemoved: number;\n modelActive: boolean;\n}\n\nexport async function redactArgs(\n engine: RedactionEngine,\n tool: string,\n args: Record<string, unknown>,\n): Promise<RedactedArgs> {\n const fields = REDACTION_POLICY[tool] ?? [];\n const out = { ...args };\n let entitiesRemoved = 0;\n let modelActive = engine.modelActive;\n for (const field of fields) {\n const value = out[field];\n if (typeof value !== \"string\" || value === \"\") continue;\n const result = await engine.redact(value);\n out[field] = result.text;\n entitiesRemoved += result.entitiesRemoved;\n modelActive = result.modelActive;\n }\n return { args: out, entitiesRemoved, modelActive };\n}\n","/**\n * Static mirror of the backend tool signatures (src/crowdcode/server.py).\n * A static mirror — not dynamic passthrough — because get_review_signing_payload\n * is overridden locally and the redaction policy is keyed to known parameter\n * names; upstream drift should fail loudly, not silently forward unredacted\n * fields. Names/optionality must match the Python signatures exactly.\n */\n\nimport { z } from \"zod\";\n\nexport const identityShape = {\n service_id: z.string().nullish().describe(\"Canonical service id (svc_...)\"),\n api_endpoint: z.string().nullish().describe(\"Service API endpoint URL\"),\n payment_provider: z\n .string()\n .nullish()\n .describe(\"One of: stripe, stripe_payment_link, mppx, x402, manual\"),\n payment_target_ref: z\n .string()\n .nullish()\n .describe(\"Payment recipient reference (wallet address, account id, ...)\"),\n directory_slug: z.string().nullish().describe(\"Directory slug if known\"),\n};\n\nconst RATING_DESCRIPTION =\n \"Rating 1-5. Judge the output against the ORIGINAL task you were solving \" +\n \"(the task_context): was the response relevant and did it actually help \" +\n \"answer that question? 5 = excellent: clear schema, relevant output that \" +\n \"answered the original question, fast, clean receipt/proof — you would \" +\n \"reuse it confidently. 4 = works and helped with the task, but with a real \" +\n \"schema/docs/latency/output caveat (name it in the reason). 3 = mixed: \" +\n \"paid successfully but the response was thin, confusing, needed guesswork, \" +\n \"or was not actually relevant or helpful for the task — a technically \" +\n \"valid answer that did not help is a 3 at best. 2 = paid but poor: client \" +\n \"error, unclear failure, or hard to use. 1 = paid and broken: server \" +\n \"error, unusable output, misleading challenge, or severe reliability \" +\n \"problem (e.g. timeout). A service that simply worked well AND helped is \" +\n \"a 5 — do not hedge to 4 without a concrete caveat.\";\n\nexport const requestServiceShape = {\n service_description: z\n .string()\n .describe(\n \"The paid API call you wanted to make but could not find a provider \" +\n \"for: the input you would have sent, the output or state change you \" +\n \"were paying for, and roughly what a call was worth to the task \" +\n \"(e.g. 'would have paid ~$0.10 per lookup'). Must be something you \" +\n \"would have spent concrete money on right then — not a free tool \" +\n \"that would merely have been convenient. Keep it reusable across \" +\n \"users. Do NOT request local runtime/agent-harness wishes (context \" +\n \"management, local compute, IDE features) or one-off task help. Do \" +\n \"not include secrets, credentials, or private user data — free text \" +\n \"is additionally redacted locally before it leaves this machine.\",\n ),\n task_context: z\n .string()\n .nullish()\n .describe(\n \"Optional: what you were trying to accomplish when you hit the gap, \" +\n \"and the spend intent — that you searched for a paid service, found \" +\n \"none, and what you were prepared to pay.\",\n ),\n requester_wallet: z\n .string()\n .nullish()\n .describe(\n \"EVM 0x address identifying who is asking (rate-limit key). \" +\n \"Auto-filled from your local agentcash/X402_PRIVATE_KEY wallet — \" +\n \"only pass it to override.\",\n ),\n};\n\nexport const getServiceScoreShape = { ...identityShape };\n\nexport const signingPayloadShape = {\n rating: z.number().int().describe(RATING_DESCRIPTION),\n reason: z.string().describe(\"Review text (redacted locally before hashing)\"),\n payment_reference: z.string().describe(\"Payment reference for this review\"),\n ...identityShape,\n auto_sign: z\n .boolean()\n .nullish()\n .describe(\n \"When true, also sign the message with the local wallet and return \" +\n \"review_signature + reviewer_wallet. Usually unnecessary: \" +\n \"review_service signs automatically.\",\n ),\n};\n\nexport const reviewServiceShape = {\n rating: z.number().int().describe(RATING_DESCRIPTION),\n reason: z.string().describe(\"Review text (redacted locally before sending)\"),\n payment_reference: z.string().describe(\"Unique payment reference\"),\n service_id: identityShape.service_id,\n task_context: z.string().nullish(),\n service_name: z.string().nullish(),\n api_endpoint: identityShape.api_endpoint,\n payment_provider: identityShape.payment_provider,\n payment_target_ref: identityShape.payment_target_ref,\n directory_slug: identityShape.directory_slug,\n payment_proof: z\n .string()\n .nullish()\n .describe(\n \"Optional: the base64 payment-response (x402) or Payment-Receipt \" +\n \"(mppx) header string. Verified-purchase status comes from on-chain \" +\n \"transfer verification, which also works from a settlement tx hash \" +\n \"in payment_reference alone — without either, the review is stored \" +\n \"as UNVERIFIED and carries half weight in scoring.\",\n ),\n payment_challenge: z.string().nullish(),\n reviewer_wallet: z\n .string()\n .nullish()\n .describe(\"Optional; auto-filled from your local wallet when signing locally\"),\n review_signature: z\n .string()\n .nullish()\n .describe(\n \"Optional; crowdcode-mcp signs automatically with your local \" +\n \"agentcash/X402_PRIVATE_KEY wallet. A supplied signature always wins.\",\n ),\n signature_scheme: z.string().default(\"eip191\"),\n};\n\nexport const MIRRORED_REMOTE_TOOLS = [\n \"request_service\",\n \"get_service_score\",\n \"review_service\",\n] as const;\n","/**\n * Local implementation of get_review_signing_payload.\n *\n * This replaces the remote tool so raw review text is never sent at signing\n * time: the reason is redacted locally, hashed locally, and the canonical\n * EIP-191 message is constructed locally (spec/CANONICAL_PAYLOAD.md).\n *\n * The backend verifies signatures by rebuilding the payload from its\n * database-authorized identity. Existing services therefore use the\n * resolved_identity returned by get_service_score (including registered\n * aliases); caller fields never override stored payment identity. New,\n * unresolved services continue to use the caller-provided strong identity.\n */\n\nimport type { RedactionResult } from \"@crowdcode/redaction\";\nimport { buildIdentity, type ServiceIdentity } from \"../canonical/identity.js\";\nimport { canonicalReviewPayload } from \"../canonical/payload.js\";\nimport type { Upstream } from \"../upstream.js\";\n\nexport interface SigningPayloadArgs {\n rating: number;\n reason: string;\n payment_reference: string;\n service_id?: string | null;\n api_endpoint?: string | null;\n payment_provider?: string | null;\n payment_target_ref?: string | null;\n directory_slug?: string | null;\n}\n\nexport interface SigningDeps {\n redact(text: string): Promise<RedactionResult>;\n upstream: Pick<Upstream, \"call\">;\n}\n\nfunction orNull(value: unknown): string | null {\n return typeof value === \"string\" && value !== \"\" ? value : null;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport async function getReviewSigningPayload(\n deps: SigningDeps,\n args: SigningPayloadArgs,\n): Promise<Record<string, unknown>> {\n let identity: ServiceIdentity;\n try {\n identity = buildIdentity(args);\n } catch (err) {\n return { ok: false, reason: (err as Error).message };\n }\n\n const redacted = await deps.redact(args.reason);\n\n let score: Record<string, unknown>;\n try {\n score = await deps.upstream.call(\"get_service_score\", {\n service_id: identity.service_id,\n api_endpoint: identity.api_endpoint,\n payment_provider: identity.payment_provider,\n payment_target_ref: identity.payment_target_ref,\n directory_slug: identity.directory_slug,\n });\n } catch (err) {\n return {\n ok: false,\n reason: `could not reach the CrowdCode backend to resolve the service: ${\n (err as Error).message\n }`,\n };\n }\n\n let effective = identity;\n if (score.found === true) {\n try {\n const hasResolvedIdentity = isRecord(score.resolved_identity);\n const resolved: Record<string, unknown> = hasResolvedIdentity\n ? (score.resolved_identity as Record<string, unknown>)\n : score;\n effective = buildIdentity({\n service_id: orNull(resolved.service_id),\n service_name: orNull(score.service_name),\n api_endpoint: hasResolvedIdentity\n ? orNull(resolved.api_endpoint)\n : orNull(score.canonical_endpoint),\n payment_provider: orNull(resolved.payment_provider),\n payment_target_ref: orNull(resolved.payment_target_ref),\n directory_slug: orNull(resolved.directory_slug),\n });\n } catch (err) {\n return { ok: false, reason: (err as Error).message };\n }\n } else if (\n typeof score.reason === \"string\" &&\n score.reason !== \"service not found\"\n ) {\n // e.g. \"service identity conflict\" — same failure the remote tool returned.\n return { ok: false, reason: score.reason };\n }\n\n const message = canonicalReviewPayload({\n identity: effective,\n rating: args.rating,\n reason: redacted.text,\n paymentReference: args.payment_reference,\n });\n\n return {\n ok: true,\n signature_scheme: \"eip191\",\n message,\n reason: redacted.text,\n identity: {\n service_id: effective.service_id,\n api_endpoint: effective.api_endpoint,\n payment_provider: effective.payment_provider,\n payment_target_ref: effective.payment_target_ref,\n directory_slug: effective.directory_slug,\n },\n instructions:\n \"Sign `message` with the reviewer wallet (EIP-191 personal_sign). Then \" +\n \"call review_service in this same session, passing this exact `reason` \" +\n \"string and every field of `identity` verbatim, plus the same rating \" +\n \"and payment_reference.\",\n _redaction: {\n entities_removed: redacted.entitiesRemoved,\n model_active: redacted.modelActive,\n },\n };\n}\n","/**\n * Transparent in-process signing for review_service.\n *\n * For mppx/x402 reviews where the caller did not supply review_signature,\n * this builds the canonical message (identity-merge + local redaction via\n * getReviewSigningPayload), signs it with the local agentcash wallet (or\n * X402_PRIVATE_KEY), and augments the outgoing arguments — so an agent can\n * call review_service end-to-end with no external signing step. A\n * caller-supplied signature always wins.\n *\n * The signature covers the REDACTED reason; the redaction engine memoizes,\n * so the later per-forward redaction pass produces the byte-identical string\n * the backend hashes when rebuilding the payload.\n */\n\nimport {\n buildIdentity,\n normalizePaymentProvider,\n type ServiceIdentity,\n} from \"../canonical/identity.js\";\nimport { canonicalReviewPayload } from \"../canonical/payload.js\";\nimport {\n loadWallet,\n type LoadedWallet,\n type WalletSource,\n} from \"../wallet.js\";\nimport { getReviewSigningPayload, type SigningDeps } from \"./signing-payload.js\";\n\nexport const AGENTCASH_INSTALL_COMMAND =\n \"claude mcp add --scope user agentcash -- npx -y agentcash@latest\";\n\nexport interface NextStep {\n action: string;\n summary: string;\n command: string | null;\n link: string | null;\n retry: { tool: string; after_seconds: number | null; with: Record<string, unknown> } | null;\n}\n\nexport function installWalletNextStep(retryTool: string): NextStep {\n return {\n action: \"install_wallet\",\n summary:\n \"No local signing wallet found. Install agentcash (or set \" +\n \"X402_PRIVATE_KEY) so crowdcode-mcp can sign automatically, then retry \" +\n retryTool +\n \".\",\n command: AGENTCASH_INSTALL_COMMAND,\n link: null,\n retry: { tool: retryTool, after_seconds: null, with: {} },\n };\n}\n\nexport interface WalletOptions {\n walletDir?: string;\n autoCreate: boolean;\n env?: NodeJS.ProcessEnv;\n}\n\nexport interface PreparedReview {\n args: Record<string, unknown>;\n /** Set when local signing was attempted (mppx/x402, no caller signature). */\n wallet_source?: WalletSource;\n wallet_created?: boolean;\n wallet_error?: string;\n next_step?: NextStep;\n /** Wallet used for signing — kept so a signature-mismatch retry can re-sign. */\n wallet?: LoadedWallet;\n /** Locally constrained review fields used to validate any retry message. */\n signed_payload?: {\n identity: ServiceIdentity;\n rating: number;\n reason: string;\n payment_reference: string;\n };\n signed: boolean;\n}\n\nfunction isMachineProvider(value: unknown): boolean {\n if (typeof value !== \"string\") return false;\n try {\n const provider = normalizePaymentProvider(value);\n return provider === \"mppx\" || provider === \"x402\";\n } catch {\n // Unknown provider: forward as-is and let the backend produce its error.\n return false;\n }\n}\n\nexport async function prepareSignedReview(\n deps: SigningDeps,\n args: Record<string, unknown>,\n wallet: WalletOptions,\n): Promise<PreparedReview> {\n if (!isMachineProvider(args.payment_provider) || args.review_signature) {\n return { args, signed: false };\n }\n\n const loaded = await loadWallet({\n walletDir: wallet.walletDir,\n autoCreate: wallet.autoCreate,\n env: wallet.env,\n });\n if (loaded.source === \"none\" || loaded.account === null) {\n return {\n args,\n signed: false,\n wallet_source: \"none\",\n wallet_error: loaded.error,\n next_step: installWalletNextStep(\"review_service\"),\n };\n }\n\n const payload = await getReviewSigningPayload(deps, {\n rating: args.rating as number,\n reason: String(args.reason ?? \"\"),\n payment_reference: String(args.payment_reference ?? \"\"),\n service_id: args.service_id as string | null | undefined,\n api_endpoint: args.api_endpoint as string | null | undefined,\n payment_provider: args.payment_provider as string | null | undefined,\n payment_target_ref: args.payment_target_ref as string | null | undefined,\n directory_slug: args.directory_slug as string | null | undefined,\n });\n if (payload.ok !== true || typeof payload.message !== \"string\") {\n // Forward unsigned; the backend rejection (plus its next_step) is more\n // actionable than failing locally with a half-built payload.\n return {\n args,\n signed: false,\n wallet_source: loaded.source,\n wallet_created: loaded.created,\n wallet_error: `could not build the signing payload locally: ${String(\n payload.reason ?? \"unknown error\",\n )}`,\n };\n }\n\n const signature = await loaded.account.signMessage({\n message: payload.message,\n });\n const identity = buildIdentity(\n payload.identity as Parameters<typeof buildIdentity>[0],\n );\n const signedReason = String(payload.reason);\n return {\n args: {\n ...args,\n // Pass the resolved identity verbatim so the backend rebuilds the exact\n // payload that was just signed.\n service_id: identity.service_id,\n api_endpoint: identity.api_endpoint,\n payment_provider: identity.payment_provider,\n payment_target_ref: identity.payment_target_ref,\n directory_slug: identity.directory_slug,\n reason: signedReason,\n reviewer_wallet: loaded.address,\n review_signature: signature,\n signature_scheme: \"eip191\",\n },\n signed: true,\n wallet_source: loaded.source,\n wallet_created: loaded.created,\n wallet: loaded,\n signed_payload: {\n identity,\n rating: args.rating as number,\n reason: signedReason,\n payment_reference: String(args.payment_reference ?? \"\"),\n },\n };\n}\n\nconst SIGNED_IDENTITY_FIELDS = [\n \"service_id\",\n \"api_endpoint\",\n \"payment_provider\",\n \"payment_target_ref\",\n \"directory_slug\",\n] as const;\n\nfunction resolvedIdentity(value: unknown): ServiceIdentity | null {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return null;\n }\n const record = value as Record<string, unknown>;\n for (const field of SIGNED_IDENTITY_FIELDS) {\n if (!(field in record)) return null;\n if (record[field] !== null && typeof record[field] !== \"string\") return null;\n }\n try {\n return buildIdentity(record as Parameters<typeof buildIdentity>[0]);\n } catch {\n return null;\n }\n}\n\nfunction preservesSignedIdentity(\n signed: ServiceIdentity,\n resolved: ServiceIdentity,\n): boolean {\n return SIGNED_IDENTITY_FIELDS.every(\n (field) => signed[field] === null || signed[field] === resolved[field],\n );\n}\n\n/**\n * Handle the backend's signature-mismatch recovery contract: re-sign the\n * returned message only after reconstructing the constrained CrowdCode review\n * payload locally. Arbitrary server-provided text is never signed.\n */\nexport async function resignFromMismatch(\n prepared: PreparedReview,\n response: Record<string, unknown>,\n): Promise<Record<string, unknown> | null> {\n if (!prepared.signed || !prepared.wallet?.account) return null;\n if (!prepared.signed_payload) return null;\n if (response.accepted !== false) return null;\n if (typeof response.expected_message !== \"string\") return null;\n\n const identity = resolvedIdentity(response.resolved_identity);\n if (identity === null) return null;\n if (!preservesSignedIdentity(prepared.signed_payload.identity, identity)) {\n return null;\n }\n const message = canonicalReviewPayload({\n identity,\n rating: prepared.signed_payload.rating,\n reason: prepared.signed_payload.reason,\n paymentReference: prepared.signed_payload.payment_reference,\n });\n if (message !== response.expected_message) return null;\n\n const signature = await prepared.wallet.account.signMessage({\n message,\n });\n return {\n ...prepared.args,\n service_id: identity.service_id,\n api_endpoint: identity.api_endpoint,\n payment_provider: identity.payment_provider,\n payment_target_ref: identity.payment_target_ref,\n directory_slug: identity.directory_slug,\n reason: prepared.signed_payload.reason,\n review_signature: signature,\n };\n}\n","import { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\n\n/** A tool-level failure reported by the backend (not a transport problem). */\nexport class UpstreamError extends Error {}\n\nexport interface Upstream {\n call(\n name: string,\n args: Record<string, unknown>,\n ): Promise<Record<string, unknown>>;\n listToolNames(): Promise<string[]>;\n}\n\nexport class UpstreamClient implements Upstream {\n private client: Client | null = null;\n\n constructor(\n private readonly baseUrl: string,\n private readonly timeoutMs: number,\n ) {}\n\n private async connect(): Promise<Client> {\n if (this.client !== null) return this.client;\n const client = new Client({ name: \"crowdcode-mcp-local\", version: \"0.1.0\" });\n const transport = new StreamableHTTPClientTransport(new URL(this.baseUrl));\n await client.connect(transport);\n this.client = client;\n return client;\n }\n\n private async reset(): Promise<void> {\n const client = this.client;\n this.client = null;\n if (client !== null) {\n try {\n await client.close();\n } catch {\n // already broken\n }\n }\n }\n\n async call(\n name: string,\n args: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n try {\n return await this.callOnce(name, args);\n } catch (err) {\n if (err instanceof UpstreamError) throw err;\n // Transport-level failure: reconnect once (absorbs dropped sessions and\n // Render cold starts).\n await this.reset();\n return this.callOnce(name, args);\n }\n }\n\n private async callOnce(\n name: string,\n args: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n const client = await this.connect();\n const result = await client.callTool({ name, arguments: args }, undefined, {\n timeout: this.timeoutMs,\n });\n\n if (result.isError) {\n throw new UpstreamError(\n `backend tool ${name} failed: ${firstText(result.content)}`,\n );\n }\n const structured = result.structuredContent;\n if (structured !== undefined && isRecord(structured)) {\n return structured;\n }\n const text = firstText(result.content);\n try {\n const parsed: unknown = JSON.parse(text);\n if (isRecord(parsed)) return parsed;\n } catch {\n // fall through\n }\n throw new UpstreamError(\n `backend tool ${name} returned an unparseable result: ${text.slice(0, 200)}`,\n );\n }\n\n async listToolNames(): Promise<string[]> {\n const client = await this.connect();\n const { tools } = await client.listTools();\n return tools.map((tool) => tool.name);\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction firstText(content: unknown): string {\n if (Array.isArray(content)) {\n for (const item of content) {\n if (\n isRecord(item) &&\n item.type === \"text\" &&\n typeof item.text === \"string\"\n ) {\n return item.text;\n }\n }\n }\n return \"\";\n}\n"],"mappings":";;;;;;;;;;;AAQA,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;;;ACH9B,SAAS,yBACd,SACA,MACyB;AACzB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,YAAY;AAAA,MACV,kBAAkB,KAAK;AAAA,MACvB,cAAc,KAAK;AAAA,IACrB;AAAA,EACF;AACF;AAEO,SAAS,aAAa,SAE3B;AACA,SAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,OAAO,EAAE,CAAC,EAAE;AACtE;;;ACXO,IAAM,mBAAsD;AAAA,EACjE,iBAAiB,CAAC,uBAAuB,cAAc;AAAA,EACvD,gBAAgB,CAAC,UAAU,cAAc;AAC3C;AAQA,eAAsB,WACpB,QACA,MACA,MACuB;AACvB,QAAM,SAAS,iBAAiB,IAAI,KAAK,CAAC;AAC1C,QAAM,MAAM,EAAE,GAAG,KAAK;AACtB,MAAI,kBAAkB;AACtB,M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F;AAEA,eAAsB,cAA6B;AACjD,QAAM,SAAS,UAAU;AACzB,QAAM,SAAS,MAAM,gBAAgB,OAAO;AAAA,IAC1C,UAAU,OAAO;AAAA,IACjB,aAAa,CAAC,OAAO;AAAA,EACvB,CAAC;AACD,QAAM,WAAW,IAAI,eAAe,OAAO,YAAY,OAAO,iBAAiB;AAC/E,QAAM,SAAS,YAAY,EAAE,QAAQ,SAAS,CAAC;AAC/C,QAAM,OAAO,QAAQ,IAAI,qBAAqB,CAAC;AAC/C,OAAK,gBAAgB,QAAQ;AAC/B;","names":["isRecord"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crowdcode-mcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "CrowdCode MCP client with local-first PII redaction. Free-text tool inputs are redacted on your machine before anything is sent to the CrowdCode backend.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|