crowdcode-mcp 0.12.0 → 0.13.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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: crowdcode
3
- description: Check third-party paid APIs before spending, find the best paid service across Base, Solana and Tempo, and review every uniquely paid use. Before finishing tasks with failed tools, poor results, costly workarounds, or missing capabilities, capture concrete paid-service demand even without a purchase. Handle Crowdcode on/off and listing or deleting your reviews. Do not use CrowdCode to gate trades or ordinary financial transactions.
3
+ description: Check third-party paid APIs before spending, find the best paid service across Base, Solana and Tempo, and review poor or failed paid results. Before finishing tasks that bought something, failed, or took many steps, file concrete gap or leverage service requests with what they would be built from. Handle Crowdcode on/off and listing or deleting your reviews. Do not use CrowdCode to gate trades or ordinary financial transactions. Also run CrowdCode cloud agents: create, fund and task agents that have their own wallets, see their services, earnings and files, download files, and withdraw.
4
4
  ---
5
5
 
6
6
  # CrowdCode
@@ -8,6 +8,28 @@ description: Check third-party paid APIs before spending, find the best paid ser
8
8
  Use CrowdCode as the reputation layer around paid agent services and to report
9
9
  specific paid services that would improve real tasks.
10
10
 
11
+ ## Cloud agents
12
+
13
+ The `crowdcode_*` agent tools run CrowdCode cloud agents, which have their own
14
+ wallets. Use them when the user asks for a cloud agent, a task run in the
15
+ cloud, a paid service built and deployed, earnings, files or withdrawals:
16
+ - `crowdcode_agents`: list the agents and their balances.
17
+ - `crowdcode_run_task`: always pass a `budget_usd` the user agreed to. Report
18
+ the answer, the amount spent and the purchases with their transactions.
19
+ - `crowdcode_files`, `crowdcode_download`: download only when the user asks.
20
+ Files go to `./crowdcode-files/<agent>/`.
21
+ - `crowdcode_create_agent`, `crowdcode_fund_agent`, `crowdcode_withdraw`,
22
+ `crowdcode_transfer`: these move real USDC. Confirm the amount with the user
23
+ first.
24
+ - In account mode, funding returns an approval link on crowdcode.app. Give the
25
+ link to the user; nothing moves until they approve.
26
+ - If a tool says the user isn't signed in or has no wallet, tell them to run
27
+ `npx crowdcode-mcp login` (to use their CrowdCode account) or
28
+ `npx crowdcode-mcp wallet init` in a terminal. Never ask for a private key.
29
+ - `npx crowdcode-mcp dashboard` shows the same overview the user sees.
30
+ - Never invent an agent id, task id, price or transaction. Use what the tools
31
+ return.
32
+
11
33
  ## Controls and your reviews
12
34
 
13
35
  At task start, call `crowdcode_status` to read the effective setting. User says
@@ -77,9 +99,11 @@ treat a missing check as approval.
77
99
 
78
100
  ## After service use
79
101
 
80
- Call `review_service` after every uniquely paid use, whether it succeeded, returned a
81
- poor result, timed out, or failed after payment. Judge the response against the
82
- original task:
102
+ Reviewing is optional for you. Call `review_service` when a paid result was
103
+ poor, wrong, slow or failed after payment, or when the user asks; a one-line
104
+ review is enough. Only reviews from hosted CrowdCode agents carry ranking
105
+ weight. Yours are published as unweighted community evidence, never mixed into
106
+ the score. Judge the response against the original task:
83
107
 
84
108
  - **5** — excellent, relevant, fast, and reusable with no concrete caveat.
85
109
  - **4** — helpful, with a specific schema, documentation, latency, or output
@@ -90,13 +114,11 @@ original task:
90
114
 
91
115
  Unpaid experiences use the same `review_service` tool. Omit payment evidence
92
116
  and supply a stable `review_nonce` on retries (automatically generated and
93
- returned when omitted). Signing does not require funds or make a payment.
94
- Payment is explicitly marked unverified; the review appears in the same history
95
- and score. Never invent a transaction reference to review a failed handshake.
117
+ returned when omitted). Signing does not require funds or make a payment. Never
118
+ invent a transaction reference to review a failed handshake.
96
119
 
97
120
  State the observed reason plainly. Distinguish provider faults from client bugs,
98
- insufficient funds, and uncertain causes. A bad paid outcome is the reason for a low
99
- review, not a reason to skip reviewing.
121
+ insufficient funds, and uncertain causes.
100
122
 
101
123
  `review_service` signs automatically with the local payer-compatible wallet.
102
124
  Do not call `get_review_signing_payload` or create a signature manually unless
@@ -121,54 +143,84 @@ when the Solana payer also signs (`payer_signature`, automatic with the
121
143
  agentcash Solana wallet); otherwise it is recorded as observed and weighted as
122
144
  unverified. Unsupported or invalid payment claims are rejected, never
123
145
  silently downgraded. An experience can instead be reviewed with payment evidence
124
- omitted and payment explicitly marked unverified.
146
+ omitted.
125
147
 
126
148
  If the payer wallet differs from the local signing wallet, supply a signature
127
149
  from the wallet that actually sent the payment. Follow a returned `next_step`
128
150
  or canonical signature-mismatch retry once; never invent payment evidence.
129
151
 
130
- ## Before your final answer: paid-service reflection
152
+ ## Paid-call records
153
+
154
+ In Claude Code and Codex, `crowdcode-mcp install` adds a local hook. When any
155
+ MCP tool (AgentCash or another wallet) makes a paid x402 or MPP call, it writes
156
+ one line to `~/.crowdcode/pending.jsonl`, and crowdcode-mcp signs it with the
157
+ local wallet and sends exactly: endpoint (no query string), method, network,
158
+ settlement reference, amount, HTTP status, response size and time. Never the
159
+ request, the response, the prompt or any file. CrowdCode verifies the payment
160
+ on-chain and counts it as "someone else paid and it answered", never as a
161
+ rating. You do nothing for this. `crowdcode-mcp off` stops it.
162
+
163
+ ## Before your final answer: service requests
164
+
165
+ Reflect once, before your final answer, when the task bought something, hit a
166
+ failed tool, or took many steps. Ask what a service could have changed, in two
167
+ kinds:
131
168
 
132
- Once the user's substantive task is complete, reflect once before your final
133
- answer: "What concrete service would have been worth paying for to improve
134
- this outcome?" Do this even if no purchase or search for paid services happened.
135
- Look back at actual failures, weak results, excessive cost or effort, and wrong
136
- turns. A request can describe a missing capability or a specific improvement to
137
- an existing service. It does not require actual payment, a funded wallet, or
138
- spending authority; reporting demand never authorizes a purchase.
169
+ - **gap**: a step that failed, was poor, slow or too costly.
170
+ - **leverage**: a service that, at a fair price, would have let you deliver a
171
+ much better result or something you could not do at all. That means acting
172
+ (book, call, buy, file, send), reaching data you could not (licensed,
173
+ real-time, behind the user's own login with consent), persisting (monitor,
174
+ alert, retry over days) or verifying (an authoritative or human check).
139
175
 
140
- For each distinct worthwhile gap, call `request_service` with four fields,
141
- written concretely enough that a developer could start building from them:
176
+ Requests do not need a purchase, a funded wallet or spending authority;
177
+ reporting demand never authorizes a purchase. For each worthwhile one, call
178
+ `request_service` with:
142
179
 
180
+ - `kind`: `gap` or `leverage`.
143
181
  - `input`: the clear input the user will give the service: format, size,
144
182
  fields. "A document" is too vague; "scanned annual-report PDFs up to 200
145
183
  pages" is not.
146
184
  - `output`: the exact output they want back, specific enough to check.
147
185
  - `problem`: what it solves: what failed, cost too much, or was impossible.
148
- - `price_per_call`: what you would pay per call in USD, as a number. It is
149
- your honest estimate of what the outcome is worth, not a budget the user
186
+ - `builds_on`: what it could be built from today: an official API, a licensed
187
+ dataset, existing paid services combined, or a human-ops team. "Nothing
188
+ exists" is rejected.
189
+ - `unlocks`: what you could then have done for the user, in one sentence.
190
+ - `frequency`: `one_off`, `per_task_like_this`, or `recurring` (daily or
191
+ weekly).
192
+ - `price_per_call`: USD per call, as a number. Price the outcome's value: a
193
+ booked trip can be worth $2. It is an estimate, not a budget the user
150
194
  approved.
151
195
 
152
- Describe a reusable service, not your task: no names, URLs, IDs, or private
153
- details. Example: input "scanned annual-report PDFs, up to 200 pages"; output
154
- "one CSV per financial table, with source-page citations and uncertain cells
155
- flagged"; problem "ordinary OCR drops columns and misaligns totals, forcing
156
- manual reconstruction"; price_per_call 0.5.
196
+ Describe a reusable service, never this task's answer restated: "two sentences
197
+ explaining stocks and bonds" or "a PDF of this article" are rejected, as are
198
+ "N/A" and requests without `builds_on`. No names, URLs, IDs, or private
199
+ details. Examples:
200
+
201
+ - gap: input "scanned annual-report PDFs, up to 200 pages"; output "one CSV per
202
+ financial table, with source-page citations and uncertain cells flagged";
203
+ problem "ordinary OCR drops columns and misaligns totals"; builds_on "a
204
+ layout-aware OCR API plus table reconstruction"; unlocks "return the
205
+ figures the user asked for without manual rebuilding"; frequency
206
+ `per_task_like_this`; price_per_call 0.5.
207
+ - leverage: input "a held itinerary and the traveller's saved profile"; output
208
+ "a booked refundable fare and its confirmation code"; problem "the agent can
209
+ only list fares and the user books by hand"; builds_on "airline NDC booking
210
+ APIs plus a card-issuing API"; unlocks "book the trip instead of listing
211
+ options"; frequency `per_task_like_this`; price_per_call 2.
157
212
 
158
213
  Requests stay private. CrowdCode publishes only aggregated proposals: similar
159
214
  requests are generalized, reviewed for whether people would actually pay, and
160
- shown with their demand and median price. Vague or unrealistic requests are
161
- not shown.
162
-
163
- A request for improved web search must name the failure and paid improvement,
164
- such as licensed full-text retrieval with verifiable page citations when normal
165
- search only returned snippets. Do not request generic web search that already
166
- worked well, local Python execution, more context, or an ordinary agent mistake
167
- without a concrete service that would prevent it. Do not fabricate a failure
168
- or claim the user agreed to pay; `price_per_call` is an estimate, not authority.
169
-
170
- If everything worked well at reasonable cost, submit nothing. Submit each
171
- distinct gap once per task; don't duplicate earlier requests after follow-ups,
172
- retries, or completion reminders. Prioritize the strongest gaps within the
173
- returned daily limit; a rate limit is a stopping condition, not a reason to
174
- change wallets. Free text is redacted locally; still omit secrets/private data.
215
+ shown with their demand and median price.
216
+
217
+ Do not request generic web search that already worked well, local Python
218
+ execution, more context, or an ordinary agent mistake without a concrete
219
+ service that would prevent it. Do not fabricate a failure or claim the user
220
+ agreed to pay.
221
+
222
+ If nothing qualifies, submit nothing. Submit each distinct request once per
223
+ task; don't duplicate earlier requests after follow-ups, retries, or
224
+ completion reminders. Prioritize the strongest within the returned daily
225
+ limit; a rate limit is a stopping condition, not a reason to change wallets.
226
+ Free text is redacted locally; still omit secrets and private data.
@@ -0,0 +1,40 @@
1
+ import {
2
+ AgentTools,
3
+ DEFAULT_BASE_URL,
4
+ DEFAULT_CREATE_MAX_USD,
5
+ DEFAULT_RPC,
6
+ FUND_HINT,
7
+ ID_RE,
8
+ MIN_MOVE_USD,
9
+ NETWORKS,
10
+ TERMINAL,
11
+ UNSURE,
12
+ WITHDRAW_NETWORKS,
13
+ checkId,
14
+ createAgentTools,
15
+ failureFor,
16
+ hintFor,
17
+ matchAgent
18
+ } from "./chunk-L32J3R5J.js";
19
+ import "./chunk-CF6JGOQF.js";
20
+ import "./chunk-2Y65AAP3.js";
21
+ import "./chunk-CSAFC6V4.js";
22
+ export {
23
+ AgentTools,
24
+ DEFAULT_BASE_URL,
25
+ DEFAULT_CREATE_MAX_USD,
26
+ DEFAULT_RPC,
27
+ FUND_HINT,
28
+ ID_RE,
29
+ MIN_MOVE_USD,
30
+ NETWORKS,
31
+ TERMINAL,
32
+ UNSURE,
33
+ WITHDRAW_NETWORKS,
34
+ checkId,
35
+ createAgentTools,
36
+ failureFor,
37
+ hintFor,
38
+ matchAgent
39
+ };
40
+ //# sourceMappingURL=tools-ZNWEQA7W.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crowdcode-mcp",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
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
  "homepage": "https://www.crowdcode.app/",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/wallet.ts","../src/canonical/solana.ts","../src/config.ts"],"sourcesContent":["/**\n * Local signing wallet, shared with agentcash.\n *\n * Reads (and lazily creates) the same wallet file agentcash uses —\n * ~/.agentcash/wallet.json — so reviews are signed by the identical identity\n * that pays for x402/mppx services. Private keys supplied through environment\n * variables are deliberately unsupported: the agent gets addresses and\n * canonical review signatures, never a key-ingestion API.\n * 1. An existing file is zod-validated and its address cross-checked\n * against the key; an unreadable or invalid file is NEVER overwritten.\n * 2. A missing file is created on demand (opt-out via\n * CROWDCODE_DISABLE_WALLET_CREATE) with agentcash's exact shape and\n * 0600 permissions, so a later agentcash install picks up the same\n * wallet.\n */\n\nimport { createPrivateKey, createPublicKey, sign as cryptoSign } from \"node:crypto\";\nimport { chmod, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport {\n generatePrivateKey,\n privateKeyToAccount,\n type PrivateKeyAccount,\n} from \"viem/accounts\";\nimport { getAddress } from \"viem/utils\";\nimport { z } from \"zod\";\nimport { base58Decode, base58Encode } from \"./canonical/solana.js\";\n\nexport type WalletSource = \"agentcash\" | \"none\";\n\nexport interface LoadedWallet {\n source: WalletSource;\n account: PrivateKeyAccount | null;\n address: string | null;\n error?: string;\n errorCode?: string;\n created?: boolean;\n}\n\nexport interface LoadWalletOptions {\n env?: NodeJS.ProcessEnv;\n walletDir?: string;\n autoCreate?: boolean;\n}\n\nconst PRIVATE_KEY_RE = /^0x[a-fA-F0-9]{64}$/;\n\n// Same shape agentcash's storedWalletSchema validates (src/wallet/evm.ts).\nconst storedWalletSchema = z.object({\n privateKey: z.string().regex(PRIVATE_KEY_RE),\n address: z.string().regex(/^0x[a-fA-F0-9]{40}$/),\n createdAt: z.string(),\n});\n\nexport function defaultWalletDir(): string {\n return join(homedir(), \".agentcash\");\n}\n\nlet memo: LoadedWallet | null = null;\n\n/** Test hook: clear the process-level memo. */\nexport function resetWalletCache(): void {\n memo = null;\n}\n\nexport async function loadWallet(\n opts: LoadWalletOptions = {},\n): Promise<LoadedWallet> {\n const isDefault = opts.env === undefined && opts.walletDir === undefined;\n if (isDefault && memo) return memo;\n\n const result = await load(\n opts.env ?? process.env,\n opts.walletDir ?? defaultWalletDir(),\n opts.autoCreate ?? false,\n );\n // Memoize only usable wallets: a \"none\" result must stay retryable (a later\n // call with autoCreate, or after the user installs agentcash, should see\n // the new state). `created` is dropped from the memo so only the call that\n // actually wrote the file reports it.\n if (isDefault && result.source !== \"none\") {\n memo = { ...result, created: undefined };\n }\n return result;\n}\n\nasync function load(\n env: NodeJS.ProcessEnv,\n dir: string,\n autoCreate: boolean,\n): Promise<LoadedWallet> {\n if (Object.prototype.hasOwnProperty.call(env, \"X402_PRIVATE_KEY\")) {\n return none(\n \"X402_PRIVATE_KEY is no longer supported; remove it from the CrowdCode \" +\n \"process and use the local agentcash wallet file instead\",\n \"wallet_configuration_error\",\n );\n }\n\n const file = join(dir, \"wallet.json\");\n let raw: string | null = null;\n try {\n raw = await readFile(file, \"utf8\");\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") {\n return none(`wallet file is unreadable: ${(err as Error).message}`);\n }\n }\n\n if (raw !== null) {\n return parseStored(raw, file);\n }\n\n if (!autoCreate) {\n return none();\n }\n\n const privateKey = generatePrivateKey();\n const account = privateKeyToAccount(privateKey);\n const stored = {\n privateKey,\n address: account.address,\n createdAt: new Date().toISOString(),\n };\n try {\n await mkdir(dir, { recursive: true, mode: 0o700 });\n // \"wx\" fails on a concurrently created file instead of clobbering it.\n await writeFile(file, JSON.stringify(stored, null, 2), {\n mode: 0o600,\n flag: \"wx\",\n });\n await chmod(file, 0o600);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"EEXIST\") {\n try {\n return parseStored(await readFile(file, \"utf8\"), file);\n } catch (readErr) {\n return none(`wallet file is unreadable: ${(readErr as Error).message}`);\n }\n }\n return none(`could not create wallet file: ${(err as Error).message}`);\n }\n return { source: \"agentcash\", account, address: account.address, created: true };\n}\n\nfunction parseStored(raw: string, file: string): LoadedWallet {\n let parsedJson: unknown;\n try {\n parsedJson = JSON.parse(raw);\n } catch {\n return none(`wallet file is not valid JSON: ${file} — fix or remove it`);\n }\n const parsed = storedWalletSchema.safeParse(parsedJson);\n if (!parsed.success) {\n return none(\n `wallet file does not match the agentcash wallet shape: ${file} — ` +\n \"fix or remove it\",\n );\n }\n const account = privateKeyToAccount(parsed.data.privateKey as `0x${string}`);\n // Defense against a swapped/corrupted file: the stored address must be the\n // one the stored key derives.\n if (getAddress(account.address) !== getAddress(parsed.data.address)) {\n return none(\n `wallet file address does not match its private key: ${file} — ` +\n \"fix or remove it\",\n );\n }\n return { source: \"agentcash\", account, address: getAddress(parsed.data.address) };\n}\n\nfunction none(error?: string, errorCode?: string): LoadedWallet {\n return { source: \"none\", account: null, address: null, error, errorCode };\n}\n\n/**\n * agentcash's Solana wallet, ~/.agentcash/solana-wallet.json (agentcash\n * src/wallet/svm.ts): `{ privateKey: base58(32-byte ed25519 seed), address,\n * createdAt }`. agentcash pays x402 Solana with this key, so it can sign the\n * payer link that makes a Solana review verified. Read-only: CrowdCode never\n * creates a Solana key, and a missing or invalid file just means reviews go\n * out without payer_signature.\n */\nexport interface SolanaWallet {\n address: string;\n /** ed25519 over the UTF-8 bytes of `message`; base58 signature. */\n sign(message: string): string;\n}\n\nconst solanaWalletSchema = z.object({\n privateKey: z.string().regex(/^[1-9A-HJ-NP-Za-km-z]+$/),\n address: z.string(),\n createdAt: z.string().optional(),\n});\n\n// PKCS#8 DER prefix for a raw 32-byte Ed25519 seed (RFC 8410).\nconst ED25519_PKCS8_PREFIX = Buffer.from(\"302e020100300506032b657004220420\", \"hex\");\n\nexport async function loadSolanaWallet(walletDir?: string): Promise<SolanaWallet | null> {\n let raw: string;\n try {\n raw = await readFile(join(walletDir ?? defaultWalletDir(), \"solana-wallet.json\"), \"utf8\");\n } catch {\n return null;\n }\n let parsed: z.infer<typeof solanaWalletSchema>;\n try {\n parsed = solanaWalletSchema.parse(JSON.parse(raw));\n } catch {\n return null;\n }\n const secret = base58Decode(parsed.privateKey);\n // agentcash stores the 32-byte seed; Solana CLI keypairs are seed + pubkey.\n if (secret === null || (secret.length !== 32 && secret.length !== 64)) return null;\n const key = createPrivateKey({\n key: Buffer.concat([ED25519_PKCS8_PREFIX, Buffer.from(secret.subarray(0, 32))]),\n format: \"der\",\n type: \"pkcs8\",\n });\n const jwk = createPublicKey(key).export({ format: \"jwk\" });\n const address = base58Encode(Buffer.from(String(jwk.x), \"base64url\"));\n // Same defense as the EVM file: the stored address must derive from the key.\n if (address !== parsed.address.trim()) return null;\n if (secret.length === 64 && base58Encode(secret.subarray(32)) !== address) return null;\n return {\n address,\n sign: (message) => base58Encode(cryptoSign(null, Buffer.from(message, \"utf8\"), key)),\n };\n}\n","/**\n * Solana pieces of the review contract (mirrors src/crowdcode/solana.py and\n * payer_link_message in src/crowdcode/payments.py; spec/CANONICAL_PAYLOAD.md).\n *\n * Solana identifiers are case-sensitive base58 and are never lowercased.\n */\n\nimport { createHash } from \"node:crypto\";\n\nconst ALPHABET = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\nconst BASE58_RE = /^[1-9A-HJ-NP-Za-km-z]+$/;\n\nexport function base58Decode(value: string): Uint8Array | null {\n if (typeof value !== \"string\" || !BASE58_RE.test(value)) return null;\n let n = 0n;\n for (const char of value) n = n * 58n + BigInt(ALPHABET.indexOf(char));\n const body: number[] = [];\n while (n > 0n) {\n body.unshift(Number(n & 0xffn));\n n >>= 8n;\n }\n const zeros = value.length - value.replace(/^1+/, \"\").length;\n return Uint8Array.from([...new Array<number>(zeros).fill(0), ...body]);\n}\n\nexport function base58Encode(bytes: Uint8Array): string {\n let n = 0n;\n for (const byte of bytes) n = (n << 8n) | BigInt(byte);\n let out = \"\";\n while (n > 0n) {\n out = ALPHABET[Number(n % 58n)] + out;\n n /= 58n;\n }\n let zeros = 0;\n while (zeros < bytes.length && bytes[zeros] === 0) zeros++;\n return \"1\".repeat(zeros) + out;\n}\n\nfunction decodesTo(value: unknown, size: number): boolean {\n if (typeof value !== \"string\") return false;\n return base58Decode(value.trim())?.length === size;\n}\n\n/** A base58 32-byte public key. */\nexport const isSolanaAddress = (value: unknown): boolean => decodesTo(value, 32);\n/** A base58 64-byte ed25519 signature (also a Solana transaction id). */\nexport const isSolanaSignature = (value: unknown): boolean => decodesTo(value, 64);\n\n/**\n * The transaction signature named by `x402:solana:<sig>` (prefix\n * case-insensitive) or a bare base58 signature; null otherwise.\n */\nexport function solanaReferenceSignature(reference: unknown): string | null {\n if (typeof reference !== \"string\") return null;\n let cleaned = reference.trim();\n if (cleaned.slice(0, 12).toLowerCase() === \"x402:solana:\") cleaned = cleaned.slice(12);\n return isSolanaSignature(cleaned) ? cleaned : null;\n}\n\nexport const PAYER_LINK_MESSAGE_HEADER = \"CrowdCode review payer link v1\";\n\n/**\n * The text a Solana payer signs (ed25519 over its raw UTF-8 bytes; the\n * signature is sent base58 as `payer_signature`) to link its payment to a\n * review. It commits to the exact canonical review payload the reviewer\n * signed and to the reviewer's EVM wallet.\n */\nexport function payerLinkMessage(reviewerWallet: string, payload: string): string {\n return [\n PAYER_LINK_MESSAGE_HEADER,\n `reviewer_wallet:${reviewerWallet.trim().toLowerCase()}`,\n `payload_sha256:${createHash(\"sha256\").update(payload, \"utf8\").digest(\"hex\")}`,\n ].join(\"\\n\");\n}\n","import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { defaultWalletDir } from \"./wallet.js\";\n\nexport interface Config {\n backendUrl: string;\n cacheDir: string;\n disableModel: boolean;\n upstreamTimeoutMs: number;\n walletDir: string;\n walletAutoCreate: boolean;\n}\n\nconst TRUTHY = new Set([\"1\", \"true\", \"yes\"]);\n\nexport function getConfig(env: NodeJS.ProcessEnv = process.env): Config {\n return {\n backendUrl:\n env.CROWDCODE_BACKEND_URL ?? \"https://crowdcode-backend.onrender.com/mcp\",\n cacheDir: env.CROWDCODE_CACHE_DIR ?? join(homedir(), \".cache\", \"crowdcode-mcp\"),\n disableModel: TRUTHY.has((env.CROWDCODE_DISABLE_MODEL ?? \"\").toLowerCase()),\n upstreamTimeoutMs: Number(env.CROWDCODE_UPSTREAM_TIMEOUT_MS ?? 15_000),\n // Signing wallet shared with agentcash (~/.agentcash/wallet.json).\n walletDir: env.CROWDCODE_WALLET_DIR ?? defaultWalletDir(),\n walletAutoCreate: !TRUTHY.has(\n (env.CROWDCODE_DISABLE_WALLET_CREATE ?? \"\").toLowerCase(),\n ),\n };\n}\n"],"mappings":";AAgBA,SAAS,kBAAkB,iBAAiB,QAAQ,kBAAkB;AACtE,SAAS,OAAO,OAAO,UAAU,iBAAiB;AAClD,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,kBAAkB;AAC3B,SAAS,SAAS;;;ACnBlB,SAAS,kBAAkB;AAE3B,IAAM,WAAW;AACjB,IAAM,YA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OAAO,WAAW,MAAM,aAAa,OAAO,SAAS,EAAE,CAAC,MAAM,QAAS,QAAO;AAClF,SAAO;AAAA,IACL;AAAA,IACA,MAAM,CAAC,YAAY,aAAa,WAAW,MAAM,OAAO,KAAK,SAAS,MAAM,GAAG,GAAG,CAAC;AAAA,EACrF;AACF;;;AErOA,SAAS,WAAAA,gBAAe;AACxB,SAAS,QAAAC,aAAY;AAYrB,IAAM,SAAS,oBAAI,IAAI,CAAC,KAAK,QAAQ,KAAK,CAAC;AAEpC,SAAS,UAAU,MAAyB,QAAQ,KAAa;AACtE,SAAO;AAAA,IACL,YACE,IAAI,yBAAyB;AAAA,IAC/B,UAAU,IAAI,uBAAuBC,MAAKC,SAAQ,GAAG,UAAU,eAAe;AAAA,IAC9E,cAAc,OAAO,KAAK,IAAI,2BAA2B,IAAI,YAAY,CAAC;AAAA,IAC1E,mBAAmB,OAAO,IAAI,iCAAiC,IAAM;AAAA;AAAA,IAErE,WAAW,IAAI,wBAAwB,iBAAiB;AAAA,IACxD,kBAAkB,CAAC,OAAO;AAAA,OACvB,IAAI,mCAAmC,IAAI,YAAY;AAAA,IAC1D;AAAA,EACF;AACF;","names":["homedir","join","join","homedir"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/server.ts","../src/tools/manage-reviews.ts","../src/attestation.ts","../src/redaction/policy.ts","../src/schemas.ts","../src/tools/sign-review.ts","../src/canonical/x402.ts","../src/tools/signing-payload.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 { z } from \"zod\";\nimport { Preferences } from \"./preferences.js\";\nimport { managementMessage } from \"./tools/manage-reviews.js\";\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 findServiceShape,\n getServiceScoreShape,\n requestServiceShape,\n reviewServiceShape,\n signingPayloadShape,\n} from \"./schemas.js\";\nimport {\n prepareSignedReview,\n resignFromMismatch,\n withoutPayerSignature,\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, 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 preferences?: Preferences;\n}\n\ntype ToolResult = ReturnType<typeof toToolResult>;\n\nfunction errorPayload(\n tool: string,\n _err: unknown,\n): Record<string, unknown> {\n const next_step = {\n action: \"retry_backend\",\n summary:\n \"The CrowdCode backend or one of its dependencies is temporarily \" +\n \"unavailable; retry 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 status: \"unavailable\",\n error_code: \"backend_unavailable\",\n retryable: true,\n found: false,\n score: null,\n n_eff: 0,\n avg_rating: null,\n num_reviews: 0,\n summary: null,\n reason: \"CrowdCode is temporarily unavailable\",\n next_step,\n };\n }\n if (tool === \"find_service\") {\n return { status: \"unavailable\", error_code: \"backend_unavailable\", retryable: true, ok: false,\n services: [], reason: \"CrowdCode is temporarily unavailable\", next_step };\n }\n return {\n status: \"unavailable\",\n error_code: \"backend_unavailable\",\n retryable: true,\n accepted: false,\n reason: \"CrowdCode is temporarily unavailable\",\n next_step,\n };\n}\n\nfunction withWalletInfo(\n payload: Record<string, unknown>,\n prepared: PreparedReview,\n): Record<string, unknown> {\n const out = { ...payload };\n if (prepared.args.review_nonce != null) out.review_nonce = prepared.args.review_nonce;\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.error_code === undefined && prepared.wallet_error_code) {\n out.error_code = prepared.wallet_error_code;\n }\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 preferences = deps.preferences ?? new Preferences();\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 const stopped = await disabled();\n if (stopped) return stopped.structuredContent;\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 async function disabled(): Promise<ToolResult | null> {\n try {\n if ((await preferences.status()).enabled) return null;\n return toToolResult({ status: \"disabled\", accepted: false, enabled: false,\n reason: \"CrowdCode is off. Continue the user's task without CrowdCode. Do not retry or queue submissions. History, deletion, and settings remain available.\" });\n } catch {\n return toToolResult({ status: \"unavailable\", accepted: false,\n error_code: \"preferences_unavailable\", reason: \"Cannot read CrowdCode preferences; no data was sent.\" });\n }\n }\n\n async function manageReviews(action: \"list\" | \"delete\", args: { review_id?: number; before_id?: number; limit?: number }) {\n const wallet = await loadWallet({ ...walletOptions, autoCreate: false });\n if (!wallet.account || !wallet.address) return toToolResult({ accepted: false,\n error_code: wallet.errorCode ?? \"wallet_unavailable\",\n reason: \"Use the original reviewing wallet to access or delete its reviews. No wallet was created.\" });\n const expires_at = Math.floor(Date.now() / 1000) + 300;\n const message = managementMessage({ action, wallet: wallet.address, expires_at, ...args });\n const authorization = await wallet.account.signMessage({ message });\n const tool = action === \"list\" ? \"list_my_reviews\" : \"delete_my_review\";\n try {\n return toToolResult(await upstream.call(tool, { ...args, reviewer_wallet: wallet.address,\n expires_at, authorization }));\n } catch (error) {\n return toToolResult(errorPayload(tool, error));\n }\n }\n\n return {\n crowdcode_status: async () => toToolResult(await preferences.status()),\n set_crowdcode_enabled: async (args: { enabled: boolean; scope?: \"session\" | \"default\" }) =>\n toToolResult(await preferences.set(args.enabled, args.scope)),\n list_my_reviews: async (args: { before_id?: number; limit?: number }) =>\n manageReviews(\"list\", { ...args, limit: args.limit ?? 25 }),\n delete_my_review: async (args: { review_id: number }) => manageReviews(\"delete\", args),\n request_service: async (\n args: Record<string, unknown>,\n ): Promise<ToolResult> => {\n const stopped = await disabled();\n if (stopped) return stopped;\n let outgoing = args;\n let walletCreated = false;\n if (!outgoing.requester_wallet) {\n // Demand needs an identity, not funds or permission to make a payment.\n const wallet = await loadWallet({\n walletDir: walletOptions.walletDir,\n env: walletOptions.env,\n autoCreate: walletOptions.autoCreate,\n });\n if (wallet.errorCode === \"wallet_configuration_error\") {\n return toToolResult({\n status: \"rejected\",\n error_code: wallet.errorCode,\n retryable: false,\n accepted: false,\n reason: wallet.error,\n });\n }\n if (wallet.address) {\n outgoing = { ...outgoing, requester_wallet: wallet.address };\n walletCreated = wallet.created === true;\n }\n }\n return toToolResult({ ...await forwardPayload(\"request_service\", outgoing),\n ...(walletCreated ? { wallet_created: true, wallet_source: \"agentcash\" } : {}) });\n },\n\n find_service: async (args: Record<string, unknown>): Promise<ToolResult> =>\n toToolResult(await forwardPayload(\"find_service\", args)),\n\n get_service_score: async (\n args: Record<string, unknown>,\n ): Promise<ToolResult> => {\n const stopped = await disabled();\n if (stopped) return stopped;\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: wallet.errorCode === \"wallet_configuration_error\"\n ? wallet.error\n : \"This is a paid x402/mppx service and you have no local \" +\n \"signing wallet yet. Install agentcash so your post-purchase \" +\n \"review can be signed and counted.\",\n command: wallet.errorCode === \"wallet_configuration_error\"\n ? null\n : installWalletNextStep(\"review_service\").command,\n },\n };\n }\n }\n return toToolResult({ ...payload, task_completion_reminder:\n \"Before your final answer, reflect on concrete paid services that would fix observed shortcomings. Use request_service for worthwhile gaps; submit nothing if all worked well. Respect CrowdCode off.\" });\n },\n\n get_review_signing_payload: async (\n args: SigningPayloadArgs & { auto_sign?: boolean | null },\n ): Promise<ToolResult> => {\n const stopped = await disabled();\n if (stopped) return stopped;\n const signingWallet =\n args.auto_sign === true ? await loadWallet(walletOptions) : null;\n if (signingWallet?.errorCode === \"wallet_configuration_error\") {\n return toToolResult({\n status: \"rejected\",\n error_code: signingWallet.errorCode,\n retryable: false,\n ok: false,\n reason: signingWallet.error,\n wallet_source: \"none\",\n });\n }\n const payload = await getReviewSigningPayload(signingDeps, args);\n if (args.auto_sign !== true || payload.ok !== true) {\n return toToolResult(payload);\n }\n const wallet = signingWallet!;\n if (wallet.source === \"none\" || wallet.account === null) {\n return toToolResult({\n ...payload,\n status: \"rejected\",\n error_code: wallet.errorCode ?? \"wallet_unavailable\",\n retryable: false,\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 stopped = await disabled();\n if (stopped) return stopped;\n const prepared = await prepareSignedReview(signingDeps, args, walletOptions);\n if (prepared.wallet_error_code === \"wallet_configuration_error\") {\n return toToolResult({\n status: \"rejected\",\n error_code: prepared.wallet_error_code,\n retryable: false,\n accepted: false,\n reason: prepared.wallet_error,\n wallet_source: \"none\",\n });\n }\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 let sentArgs = prepared.args;\n const retryArgs = await resignFromMismatch(prepared, payload);\n if (retryArgs !== null) {\n sentArgs = retryArgs;\n payload = await forwardPayload(\"review_service\", retryArgs);\n }\n // The local Solana key signed the payer link speculatively; if it was\n // not this transaction's payer, submit once as an unlinked observation.\n const unlinkedArgs = withoutPayerSignature(prepared, sentArgs, payload);\n if (unlinkedArgs !== null) {\n payload = await forwardPayload(\"review_service\", unlinkedArgs);\n }\n return toToolResult({ ...withWalletInfo(payload, prepared), task_completion_reminder: \"Before your final answer, consider request_service for concrete improvements worth paying for, grounded in this task. Skip if all worked well; do not duplicate earlier requests.\" });\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 \"This means third-party APIs, remote services, and provisioned\",\n \"infrastructure. Do not use CrowdCode to gate trades, swaps, market orders,\",\n \"transfers, deposits, withdrawals, bridges, staking, lending, escrow\",\n \"settlement, or purchases of financial instruments.\",\n \"\",\n \"Choosing a service: call find_service with the capability and, when known, your\",\n \"USDC balance per network. It searches every catalog across Base, Solana and Tempo\",\n \"and ranks by CrowdCode quality, then effective price (including a transfer between\",\n \"your own networks when one is short), then balance. Prefer the top result that fits\",\n \"the task, whatever its network.\",\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 \"Review each paid service outcome with review_service. Unpaid experiences use\",\n \"the same tool: omit payment_reference and payment_proof, and reuse a stable\",\n \"review_nonce on retry (automatically generated when omitted). Payment is\",\n \"explicitly marked unverified. The reviewer still signs with the local\",\n \"AgentCash wallet; signing is automatic and does not make a payment.\",\n \"Rate usefulness for the original task from 1 (unusable) to 5 (excellent).\",\n \"Describe observed outcomes; distinguish provider faults from client bugs,\",\n \"insufficient funds, and uncertain causes. Do not invent payment evidence.\",\n \"When claiming payment, use the actual settlement reference and payee.\",\n \"An optional payment_proof is the original base64 response header. Payment\",\n \"claims must verify on x402 Base/Monad/Solana USDC or mppx Tempo. Reference an x402\",\n \"Monad (eip155:143) settlement as x402:monad:<tx_hash> and a Solana settlement as\",\n \"x402:solana:<signature> with the Solana payee. Invalid supplied claims\",\n \"are rejected, never silently downgraded. Payment verification gives the\",\n \"existing verified scoring weight; unpaid signed reviews share the same\",\n \"history, score, and per-wallet/service/day influence cap.\",\n \"\",\n \"Before the final answer to each substantive user task, reflect once: what concrete\",\n \"paid service would have avoided an observed failure, poor result, expensive workaround,\",\n \"or wrong turn? This applies even if no purchase was attempted. Call request_service\",\n \"for each distinct, worthwhile gap (do not repeat the same gap on retries or follow-ups).\",\n \"Fill its four fields concretely enough that a developer could start building: input\",\n \"(what the user will give), output (the exact deliverable), problem (what it solves) and\",\n \"price_per_call (what you would pay per call in USD). Describe a reusable service, not\",\n \"your task. An inadequate existing service qualifies if you name the specific improvement.\",\n \"No payment or spend authority is required; price_per_call is your honest estimate.\",\n \"Skip generic local compute, run-Python wishes, ordinary agent mistakes without a\",\n \"sellable remedy, and services that already worked well at reasonable cost. If nothing\",\n \"qualifies, submit nothing. Never send secrets or private user data.\",\n \"At task start check crowdcode_status. User says 'Crowdcode on'/'Crowdcode off': call\",\n \"set_crowdcode_enabled with enabled=true/false and scope=session, or scope=default\",\n \"when they ask to remember it. Off overrides all automatic CrowdCode workflows:\",\n \"continue the user's task, skip reflection, checks and submissions; never backfill.\",\n \"Use list_my_reviews for 'show my reviews'; delete_my_review only for review IDs the\",\n \"user asks to delete. These management tools remain available while CrowdCode is off.\",\n].join(\"\\n\");\n\nexport function buildServer(deps: ServerDeps): McpServer {\n const server = new McpServer(\n { name: \"crowdcode\", version: \"0.12.0\" },\n { instructions: SERVER_INSTRUCTIONS },\n );\n const handlers = createToolHandlers(deps);\n\n server.registerTool(\"crowdcode_status\", {\n description: \"Read CrowdCode's effective on/off state and saved default locally. Check at task start.\",\n inputSchema: {}, annotations: { readOnlyHint: true },\n }, () => handlers.crowdcode_status());\n server.registerTool(\"set_crowdcode_enabled\", {\n description: \"Handle 'Crowdcode on' or 'Crowdcode off'. Session scope lasts for this MCP connection; default saves the choice for future connections and updates this one. Off stops checks, signing, reviews, and requests. History and deletion stay available. No queued backfill.\",\n inputSchema: { enabled: z.boolean(), scope: z.enum([\"session\", \"default\"]).default(\"session\") },\n }, (args) => handlers.set_crowdcode_enabled(args));\n server.registerTool(\"list_my_reviews\", {\n description: \"Show reviews submitted by the local wallet, newest first, including review IDs for deletion. Follow next_before_id to see older reviews. Works while CrowdCode is off. Locally signs an expiring ownership proof; never creates a wallet.\",\n inputSchema: { before_id: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(), limit: z.number().int().min(1).max(100).default(25) },\n annotations: { readOnlyHint: true },\n }, (args) => handlers.list_my_reviews(args));\n server.registerTool(\"delete_my_review\", {\n description: \"Permanently delete the specific review ID requested by the user, owned by the local wallet. List reviews first if the ID is unknown. Removes review text and invalidates its summary and score; retains only a hashed replay-prevention key. Works while off. Never bulk-delete or choose IDs without user direction.\",\n inputSchema: { review_id: z.number().int().positive().max(Number.MAX_SAFE_INTEGER) },\n annotations: { destructiveHint: true, idempotentHint: true },\n }, (args) => handlers.delete_my_review(args));\n\n\n server.registerTool(\n \"request_service\",\n {\n description:\n \"Record a paid service that would have materially improved the task, as four \" +\n \"concrete fields a developer could start building from: input (the clear input the \" +\n \"user will give), output (the exact output they want back), problem (what it \" +\n \"solves) and price_per_call (what you would pay per call, USD). Before your final \" +\n \"answer, reflect on failures, poor results, excessive cost and avoidable detours, \" +\n \"even when no purchase was attempted. Example: input \\\"scanned annual report PDFs, \" +\n \"up to 200 pages\\\"; output \\\"one CSV per table with page citations and low-\" +\n \"confidence cells flagged\\\"; problem \\\"OCR drops columns, forcing manual \" +\n \"reconciliation\\\"; price_per_call 0.5. Describe a reusable service, not your task; \" +\n \"no names, URLs or IDs. Skip web search that worked well, run-Python/local runtime \" +\n \"wishes and bugs in your own tools. One request per distinct gap per task; respect \" +\n \"the returned wallet limit. Submit nothing if all worked well at reasonable cost. \" +\n \"Text is redacted locally; requests stay private and only aggregated proposals \" +\n \"are published.\",\n inputSchema: requestServiceShape,\n },\n (args) => handlers.request_service(args),\n );\n\n server.registerTool(\n \"find_service\",\n {\n description:\n \"Find the best paid service for a capability across Base, Solana and Tempo. \" +\n \"Searches Coinbase's x402 Bazaar, the mpp.dev MPP catalog and CrowdCode's reviewed \" +\n \"services, merges them by endpoint, and ranks them: CrowdCode quality first, then the \" +\n \"effective price on your best network (plus one transfer between your own networks when \" +\n \"that network's balance is short), then your balance there. Pass your per-network \" +\n \"`balances` when known, and endpoints found elsewhere (for example AgentCash search) as \" +\n \"`candidates`. Each result names its best network, offers, quality evidence and sources. \" +\n \"Catalog prices can be dynamic: inspect the chosen endpoint for its live quote before paying. \" +\n \"The query is redacted locally.\",\n inputSchema: findServiceShape,\n annotations: { readOnlyHint: true },\n },\n (args) => handlers.find_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 \"Review a service experience, paid or unpaid, with a rating from 1 to 5 \" +\n \"and concrete observations about usefulness for the original task. \" +\n \"Review every paid outcome; unpaid successes and failures can use the same tool. \" +\n \"Distinguish provider faults from client errors, insufficient funds, and uncertain causes. \" +\n \"Signing with the local AgentCash wallet is automatic. Omit payment_reference \" +\n \"and payment_proof when no payment is claimed; payment is then marked unverified. \" +\n \"Use a stable review_nonce for unpaid retries (generated automatically if omitted). \" +\n \"For paid reviews, supply the actual settlement reference and payee; optional \" +\n \"payment_proof is the original base64 response header. Claims must verify on \" +\n \"x402 Base/Monad/Solana USDC or mppx Tempo; reference an x402 Monad (eip155:143) settlement \" +\n \"as x402:monad:<tx_hash> and a Solana one as x402:solana:<signature> (Solana payee as \" +\n \"payment_target_ref; the agentcash Solana wallet signs payer_signature automatically). \" +\n \"Invalid payment evidence is rejected, never downgraded. \" +\n \"Daily scoring influence is capped. Review text is redacted locally and stays \" +\n \"private: CrowdCode publishes only counts, scores and a generated summary.\",\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 if ((await new Preferences().status()).enabled) void warnOnToolDrift(upstream);\n}\n","/** Domain-separated, expiring authorization; never sign a backend-supplied message. */\nexport function managementMessage(args: {\n action: \"list\" | \"delete\"; wallet: string; expires_at: number;\n review_id?: number; before_id?: number; limit?: number;\n}): string {\n return [\"CrowdCode review management v1\", `action:${args.action}`,\n `wallet:${args.wallet.toLowerCase()}`, `review_id:${args.review_id ?? 0}`,\n `before_id:${args.before_id ?? 0}`, `limit:${args.limit ?? 0}`,\n `expires_at:${args.expires_at}`].join(\"\\n\");\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 structuredContent: Record<string, unknown>;\n isError?: boolean;\n} {\n return {\n content: [{ type: \"text\", text: JSON.stringify(payload) }],\n structuredContent: payload,\n ...(payload.status === \"unavailable\" ? { isError: true } : {}),\n };\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 find_service: [\"query\"],\n request_service: [\"input\", \"output\", \"problem\"],\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\n/**\n * request_service v2: four concrete fields a builder can act on. Bounds mirror\n * crowdcode.demand.validate_request_fields; the backend stays authoritative.\n */\nexport const requestServiceShape = {\n input: z\n .string()\n .trim()\n .min(20)\n .max(600)\n .describe(\n \"The clear input the user will give the service, concretely: format, size, fields. \" +\n \"Example: \\\"a public MP4 URL (up to 60 s) and the post text\\\". \" +\n \"General terms only: no names, URLs, IDs or private data.\",\n ),\n output: z\n .string()\n .trim()\n .min(20)\n .max(600)\n .describe(\n \"The exact output they want back, specific enough to check. \" +\n \"Example: \\\"the published post ID and URL, posted exactly once\\\".\",\n ),\n problem: z\n .string()\n .trim()\n .min(20)\n .max(800)\n .describe(\n \"The problem it solves: what failed, cost too much or was impossible without it. \" +\n \"Example: \\\"agents publishing video to X fail on chunked uploads and cannot tell whether it posted\\\".\",\n ),\n price_per_call: z\n .number()\n .positive()\n .max(100)\n .describe(\n \"What you would pay per call, in USD (e.g. 0.05). An honest estimate of the outcome's \" +\n \"worth, not a budget the user approved.\",\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 wallet — \" +\n \"only pass it to override.\",\n ),\n};\n\nexport const getServiceScoreShape = { ...identityShape };\n\nexport const findServiceShape = {\n query: z.string().min(1).max(500).describe(\n \"The capability in a few words, for example \\\"web search\\\", \\\"object storage\\\" or \\\"solana token risk\\\"; \" +\n \"not the task's subject (redacted locally before sending)\",\n ),\n networks: z\n .array(z.string())\n .nullish()\n .describe(\"Networks you can pay on: base, solana, tempo (default all three)\"),\n balances: z\n .record(z.string(), z.number())\n .nullish()\n .describe(\n \"Available USDC per network, e.g. {\\\"base\\\": 1.2, \\\"solana\\\": 0.4, \\\"tempo\\\": 0}. \" +\n \"Lets the ranking add a transfer cost where a network's balance is short.\",\n ),\n candidates: z\n .array(\n z.object({\n endpoint: z.string(),\n method: z.string().nullish(),\n name: z.string().nullish(),\n description: z.string().nullish(),\n price_usd: z.number().nullish(),\n network: z.string().nullish(),\n networks: z.array(z.string()).nullish(),\n protocol: z.string().nullish(),\n protocols: z.array(z.string()).nullish(),\n unique_payers: z.number().nullish(),\n source: z.string().nullish(),\n }).passthrough(),\n )\n .max(50)\n .nullish()\n .describe(\"Endpoints you found elsewhere (for example AgentCash search) to rank together with the catalogs\"),\n limit: z.number().int().min(1).max(25).nullish(),\n};\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().min(1).nullish().describe(\"Optional settlement reference; omit when no payment is claimed\"),\n review_nonce: z.string().regex(/^[A-Za-z0-9_-]{8,128}$/).nullish().describe(\"Stable unique identifier for an unpaid review; reuse on retry\"),\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().min(1).nullish().describe(\n \"Optional unique settlement reference; omit when no payment is claimed. \" +\n \"x402: the settlement tx hash (Base), x402:monad:<tx_hash> for Monad (eip155:143), \" +\n \"or x402:solana:<base58 signature> for Solana (case-sensitive)\",\n ),\n review_nonce: z.string().regex(/^[A-Za-z0-9_-]{8,128}$/).nullish().describe(\"Unpaid review retry identifier; generated automatically when omitted\"),\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. If supplied, a payment claim must verify; \" +\n \"omit payment evidence to submit a signed review without verified payment.\",\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 wallet. Environment private keys are not accepted. A supplied \" +\n \"signature always wins.\",\n ),\n signature_scheme: z.string().default(\"eip191\"),\n payer_signature: z\n .string()\n .nullish()\n .describe(\n \"x402 Solana only: base58 ed25519 signature by the Solana payer over the \" +\n \"payer link message, which makes the review a verified purchase. \" +\n \"crowdcode-mcp signs automatically with the agentcash Solana wallet.\",\n ),\n payer_wallet: z\n .string()\n .nullish()\n .describe(\"x402 Solana only, optional: the base58 payer address that signed payer_signature\"),\n};\n\nexport const MIRRORED_REMOTE_TOOLS = [\n \"find_service\",\n \"request_service\",\n \"get_service_score\",\n \"review_service\",\n \"list_my_reviews\",\n \"delete_my_review\",\n] as const;\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, and\n * augments the outgoing arguments — so an agent can call review_service\n * 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 { randomUUID } from \"node:crypto\";\nimport {\n buildIdentity,\n normalizePaymentProvider,\n type ServiceIdentity,\n} from \"../canonical/identity.js\";\nimport { canonicalReviewPayload } from \"../canonical/payload.js\";\nimport { payerLinkMessage, solanaReferenceSignature } from \"../canonical/solana.js\";\nimport { x402PaymentReference, x402ProofPayer } from \"../canonical/x402.js\";\nimport {\n loadSolanaWallet,\n loadWallet,\n type LoadedWallet,\n type SolanaWallet,\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 so crowdcode-mcp can \" +\n \"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 wallet_error_code?: 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 | null;\n review_nonce?: string | null;\n };\n signed: boolean;\n /**\n * Local agentcash Solana wallet that signed payer_signature for an x402\n * Solana review. Signing is speculative (the backend, not the client,\n * reads the transaction's payer), so a payer_signature_invalid rejection\n * is retried once without it, as an unlinked observation.\n */\n payer_wallet?: SolanaWallet;\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\nfunction mayBeX402(value: unknown): boolean {\n if (value === null || value === undefined) return true;\n try {\n const provider = normalizePaymentProvider(String(value));\n return provider === null || provider === \"x402\";\n } catch {\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 (args.review_signature || (args.payment_reference != null && args.payment_provider && !isMachineProvider(args.payment_provider))) {\n return { args, signed: false };\n }\n\n // Sign the chain-qualified reference (x402:monad:<tx>) for x402 receipts\n // settled off Base, so the reference alone tells the backend which chain\n // to verify on.\n if (args.payment_proof != null && mayBeX402(args.payment_provider)) {\n const reference = x402PaymentReference(\n args.payment_reference as string | null | undefined,\n args.payment_proof,\n );\n if (reference !== args.payment_reference) args = { ...args, payment_reference: reference };\n }\n\n if (args.payment_reference == null) {\n args = { ...args, review_nonce: args.review_nonce ?? randomUUID() };\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 wallet_error_code: loaded.errorCode,\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: args.payment_reference as string | null | undefined,\n review_nonce: args.review_nonce as string | null | undefined,\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 const payer =\n args.payer_signature == null && identity.payment_provider === \"x402\" &&\n solanaReferenceSignature(args.payment_reference) !== null\n ? await solanaPayer(wallet.walletDir, args.payment_proof)\n : null;\n return {\n args: {\n ...args,\n ...(payer && loaded.address\n ? { payer_signature: payer.sign(payerLinkMessage(loaded.address, payload.message)) }\n : {}),\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 ...(payer ? { payer_wallet: payer } : {}),\n signed_payload: {\n identity,\n rating: args.rating as number,\n reason: signedReason,\n payment_reference: args.payment_reference as string | null | undefined,\n review_nonce: args.review_nonce as string | null | undefined,\n },\n };\n}\n\n/**\n * The local Solana wallet, unless the proof names a different payer (then the\n * local key did not pay and its signature could only be rejected).\n */\nasync function solanaPayer(walletDir: string | undefined, proof: unknown): Promise<SolanaWallet | null> {\n const wallet = await loadSolanaWallet(walletDir);\n const named = x402ProofPayer(proof);\n return wallet && (named === null || named === wallet.address) ? wallet : null;\n}\n\n/** Retry args for an unlinked Solana observation after a payer_signature rejection. */\nexport function withoutPayerSignature(\n prepared: PreparedReview,\n args: Record<string, unknown>,\n response: Record<string, unknown>,\n): Record<string, unknown> | null {\n if (!prepared.payer_wallet || response.error_code !== \"payer_signature_invalid\") return null;\n const { payer_signature: _dropped, ...rest } = args;\n return rest;\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 reviewNonce: prepared.signed_payload.review_nonce,\n });\n if (message !== response.expected_message) return null;\n\n const signature = await prepared.wallet.account.signMessage({\n message,\n });\n const address = prepared.wallet.address;\n return {\n ...prepared.args,\n ...(prepared.payer_wallet && address\n ? { payer_signature: prepared.payer_wallet.sign(payerLinkMessage(address, message)) }\n : {}),\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","/**\n * x402 settlement references (mirrors X402_CHAINS in\n * src/crowdcode/payments.py). The backend checks a bare transaction hash on\n * Base; a settlement on another chain is referenced as\n * `x402:<network>:<tx>`, e.g. `x402:monad:0x…` for Monad (eip155:143) or\n * `x402:solana:<base58 signature>` for Solana (case-sensitive).\n */\n\nimport { isSolanaSignature } from \"./solana.js\";\n\nconst X402_NETWORKS: Record<string, string> = {\n base: \"base\",\n \"eip155:8453\": \"base\",\n \"8453\": \"base\",\n monad: \"monad\",\n \"eip155:143\": \"monad\",\n \"143\": \"monad\",\n solana: \"solana\",\n // Lowercased, like every lookup key here.\n \"solana:5eykt4usfv8p8njdtrepy1vzqkqzkvdp\": \"solana\",\n};\n\nconst DEFAULT_X402_NETWORK = \"base\";\nconst TX_HASH_RE = /^0x[0-9a-fA-F]{64}$/;\n\n/** Short x402 network name for a name, CAIP-2 id, or chain id; else null. */\nexport function x402Network(value: unknown): string | null {\n if (typeof value !== \"string\" && typeof value !== \"number\") return null;\n return X402_NETWORKS[String(value).trim().toLowerCase()] ?? null;\n}\n\nfunction parseProof(proof: unknown): Record<string, unknown> | null {\n if (typeof proof === \"object\" && proof !== null && !Array.isArray(proof)) {\n return proof as Record<string, unknown>;\n }\n if (typeof proof !== \"string\" || proof.trim() === \"\") return null;\n const cleaned = proof.trim();\n for (const text of [cleaned, Buffer.from(cleaned, \"base64\").toString(\"utf8\")]) {\n try {\n const parsed: unknown = JSON.parse(text);\n if (typeof parsed === \"object\" && parsed !== null && !Array.isArray(parsed)) {\n return parsed as Record<string, unknown>;\n }\n } catch {\n // Try the next encoding.\n }\n }\n return null;\n}\n\n/**\n * The settlement named by an x402 payment-response proof (raw JSON, base64\n * header value, or object): its transaction hash and short network name.\n * A proof without a network is Base, as on the backend.\n */\nexport function x402Settlement(\n proof: unknown,\n): { transaction: string; network: string } | null {\n const parsed = parseProof(proof);\n if (parsed === null) return null;\n const transaction =\n parsed.transaction ?? parsed.transactionHash ?? parsed.txHash ?? parsed.reference;\n const rawNetwork = parsed.network ?? parsed.chain;\n const network =\n rawNetwork === undefined || rawNetwork === null\n ? DEFAULT_X402_NETWORK\n : x402Network(rawNetwork);\n if (typeof transaction !== \"string\" || network === null) return null;\n const valid = network === \"solana\" ? isSolanaSignature(transaction) : TX_HASH_RE.test(transaction);\n return valid ? { transaction, network } : null;\n}\n\n/**\n * The payment_reference to sign for an x402 review. A non-Base settlement\n * gets its `x402:<network>:` prefix so the reference alone names the chain;\n * a missing reference is taken from the proof. Anything else (Base, a\n * mismatched hash, an unparseable proof) is returned unchanged for the\n * backend to judge.\n */\nexport function x402PaymentReference(\n reference: string | null | undefined,\n proof: unknown,\n): string | null | undefined {\n const settlement = x402Settlement(proof);\n if (settlement === null) return reference;\n const { transaction, network } = settlement;\n const prefix = network === DEFAULT_X402_NETWORK ? \"\" : `x402:${network}:`;\n if (reference === null || reference === undefined) return prefix + transaction;\n const bare = reference.trim();\n // Base58 signatures are case-sensitive; EVM hashes are not.\n const same = network === \"solana\" ? bare === transaction : bare.toLowerCase() === transaction.toLowerCase();\n if (prefix !== \"\" && same) return prefix + bare;\n return reference;\n}\n\n/** The `payer` an x402 payment-response proof names, if any (unverified hint). */\nexport function x402ProofPayer(proof: unknown): string | null {\n const payer = parseProof(proof)?.payer;\n return typeof payer === \"string\" && payer.trim() !== \"\" ? payer.trim() : null;\n}\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 { randomUUID } from \"node:crypto\";\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 | null;\n review_nonce?: string | null;\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 if (args.payment_reference == null) args = { ...args, review_nonce: args.review_nonce ?? randomUUID() };\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 reviewNonce: args.review_nonce,\n });\n\n return {\n ok: true,\n signature_scheme: \"eip191\",\n ...(args.payment_reference == null ? { review_nonce: args.review_nonce } : {}),\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 (or review_nonce when payment is omitted).\",\n _redaction: {\n entities_removed: redacted.entitiesRemoved,\n model_active: redacted.modelActive,\n },\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,KAAAA,UAAS;;;ACPX,SAAS,kBAAkB,MAGvB;AACT,SAAO;AAAA,IAAC;AAAA,IAAkC,UAAU,KAAK,MAAM;AAAA,IAC7D,UAAU,KAAK,OAAO,YAAY,CAAC;AAAA,IAAI,aAAa,KAAK,aAAa,CAAC;AAAA,IACvE,aAAa,KAAK,aAAa,CAAC;AAAA,IAAI,SAAS,KAAK,SAAS,CAAC;AAAA,IAC5D,cAAc,KAAK,UAAU;AAAA,EAAE,EAAE,KAAK,IAAI;AAC9C;;;ADEA,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;;;AEN9B,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,SAI3B;AACA,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,OAAO,EAAE,CAAC;AAAA,IACzD,mBAAmB;AAAA,IACnB,GAAI,QAAQ,WAAW,gBAAgB,EAAE,SAAS,KAAK,IAAI,CAAC;AAAA,EAC9D;AACF;;;ACjBO,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