crowdcode-mcp 0.1.3 → 0.3.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 +0,0 @@
1
- {"version":3,"sources":["../src/server.ts","../src/attestation.ts","../src/redaction/policy.ts","../src/schemas.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 { 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 getReviewSigningPayload,\n type SigningPayloadArgs,\n} from \"./tools/signing-payload.js\";\nimport { UpstreamClient, UpstreamError, type Upstream } from \"./upstream.js\";\n\nexport interface ServerDeps {\n engine: RedactionEngine;\n upstream: Upstream;\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 if (tool === \"get_service_score\") {\n return {\n found: false,\n avg_rating: null,\n num_reviews: 0,\n recent_reviews: [],\n reason: message,\n };\n }\n return { accepted: false, reason: message };\n}\n\nexport function createToolHandlers(deps: ServerDeps) {\n const { engine, upstream } = deps;\n\n async function forwardWithRedaction(\n tool: string,\n args: Record<string, unknown>,\n ): Promise<ToolResult> {\n const redacted = await redactArgs(engine, tool, args);\n try {\n const result = await upstream.call(tool, redacted.args);\n return toToolResult(\n withRedactionAttestation(result, {\n entitiesRemoved: redacted.entitiesRemoved,\n modelActive: redacted.modelActive,\n }),\n );\n } catch (err) {\n return toToolResult(errorPayload(tool, err));\n }\n }\n\n return {\n request_service: (args: Record<string, unknown>) =>\n forwardWithRedaction(\"request_service\", args),\n\n get_service_score: async (\n args: Record<string, unknown>,\n ): Promise<ToolResult> => {\n try {\n return toToolResult(await upstream.call(\"get_service_score\", args));\n } catch (err) {\n return toToolResult(errorPayload(\"get_service_score\", err));\n }\n },\n\n get_review_signing_payload: async (\n args: SigningPayloadArgs,\n ): Promise<ToolResult> =>\n toToolResult(\n await getReviewSigningPayload(\n { redact: (text) => engine.redact(text), upstream },\n args,\n ),\n ),\n\n review_service: (args: Record<string, unknown>) =>\n forwardWithRedaction(\"review_service\", args),\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 avg_rating, using num_reviews as sample-size\",\n \"context; with few or no reviews, fall back to price and the spend policy.\",\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 on a\",\n \"fixed scale: 5 = excellent (clear schema, useful output, fast, clean\",\n \"receipt — would reuse confidently); 4 = works but a real\",\n \"schema/docs/latency/output caveat; 3 = paid but response thin, confusing,\",\n \"or needed guesswork; 2 = paid but poor (client error, unclear failure,\",\n \"hard to use); 1 = paid and broken (server error, unusable output,\",\n \"misleading challenge, timeout/severe reliability). A service that simply\",\n \"worked well is a 5 — do not hedge to 4 without a concrete caveat.\",\n \"\",\n \"For x402/mppx, take the\",\n \"identity and proofs from the ACTUAL payment, not a directory listing:\",\n \"payment_reference = the settlement tx hash (x402) or Payment-Receipt\",\n \"reference (mppx); payment_proof = the base64 response header string\",\n \"(payment-response for x402, Payment-Receipt for mppx), not the tx hash or\",\n \"decoded JSON; payment_target_ref = the real on-chain payee (the 402\",\n \"challenge recipient / Transfer `to`), not a directory payTo; reviewer_wallet\",\n \"= the wallet that SENT the payment (the Transfer `from`, not the gasless\",\n \"facilitator), which must be a self-custody wallet you can EIP-191 sign with.\",\n \"Call get_review_signing_payload, sign the returned message verbatim, then\",\n \"call review_service in the same session.\",\n \"\",\n \"When no fitting paid service exists, call request_service once with a\",\n \"specific, reusable capability description. Only request things a provider\",\n \"could sell as a remote paid API — the test is: could you pay for it with\",\n \"an x402/mpp request to someone else's endpoint? Never runtime or\",\n \"agent-harness wishes (context management, local compute). Never send\",\n \"secrets or private data — free-text fields are redacted locally before\",\n \"anything is sent.\",\n].join(\"\\n\");\n\nexport function buildServer(deps: ServerDeps): McpServer {\n const server = new McpServer(\n { name: \"crowdcode\", version: \"0.1.3\" },\n { instructions: SERVER_INSTRUCTIONS },\n );\n const handlers = createToolHandlers(deps);\n\n server.registerTool(\n \"request_service\",\n {\n description:\n \"Capture an unmet, reusable service request for future directory \" +\n \"coverage. Use only when no fitting paid or external service exists. \" +\n \"Only request capabilities a provider could sell as a remote paid API \" +\n \"(x402/mppx/Stripe) — the test: could you pay for it with an x402/mpp \" +\n \"request to someone else's endpoint? Describe a specific capability \" +\n \"with clear inputs and outputs, general enough to apply to multiple \" +\n \"users. Good: 'resolve a citation like Smith et al. 2019 to the \" +\n \"actual paper, or report that it does not exist'; 'semantic search \" +\n \"over paywalled full-text academic PDFs returning page-level \" +\n \"citations'; 'live versioned registry of current API schemas'. Bad: \" +\n \"wishes about your own runtime or harness ('cleaner context', 'more \" +\n \"memory', local compute/IDE features) and one-off task help ('fix my \" +\n \"CI'). Free-text fields are redacted locally (PII and secrets become \" +\n \"[PLACEHOLDER]s) before anything is sent to the shared CrowdCode \" +\n \"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 average rating, review count, and recent reviews for a \" +\n \"service, 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 to sign before submitting an mppx or \" +\n \"x402 review. Runs entirely locally: the review reason is redacted on \" +\n \"this machine and only its hash enters the payload. Sign the returned \" +\n \"`message` VERBATIM (byte-for-byte) with the payer wallet — the same \" +\n \"self-custody wallet that sent the payment, whose key you hold \" +\n \"(custodial or login-only wallets cannot sign an arbitrary message). \" +\n \"Then call review_service with the returned `reason` and `identity` \" +\n \"fields passed through 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. Rating scale: 5 = excellent \" +\n \"(clear schema, useful output, fast, clean receipt — would reuse \" +\n \"confidently); 4 = works but a real schema/docs/latency/output \" +\n \"caveat; 3 = paid but thin/confusing/needed guesswork; 2 = paid but \" +\n \"poor (client error, unclear failure, hard to use); 1 = paid and \" +\n \"broken (server error, unusable output, misleading challenge, \" +\n \"timeout). A service that simply worked well is a 5 — do not hedge \" +\n \"to 4 without a concrete caveat. \" +\n \"Requires the payment reference; mppx/x402 reviews also \" +\n \"require payment_proof, reviewer_wallet, and review_signature over the \" +\n \"message from get_review_signing_payload. Get these from the ACTUAL \" +\n \"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; \" +\n \"payment_target_ref = the real payee (the 402 challenge recipient / \" +\n \"on-chain Transfer `to`), not a bazaar/directory payTo; \" +\n \"reviewer_wallet = the wallet that SENT the payment (the ERC-20 \" +\n \"Transfer `from`) — for gasless x402/mppx the tx sender is a \" +\n \"facilitator, not the payer. Free-text is redacted locally; pass the \" +\n \"exact `reason` returned by get_review_signing_payload.\",\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. 5 = excellent: clear schema, useful output, fast, clean \" +\n \"receipt/proof — you would reuse it confidently. 4 = works and is useful, \" +\n \"but with a real schema/docs/latency/output caveat (name it in the reason). \" +\n \"3 = mixed: paid successfully but the response was thin, confusing, or \" +\n \"needed guesswork. 2 = paid but poor: client error, unclear failure, or \" +\n \"hard to use. 1 = paid and broken: server error, unusable output, \" +\n \"misleading challenge, or severe reliability problem (e.g. timeout). A \" +\n \"service that simply worked well is a 5 — do not hedge to 4 without a \" +\n \"concrete caveat.\";\n\nexport const requestServiceShape = {\n service_description: z\n .string()\n .describe(\n \"Specific, reusable capability that a provider could sell as a remote \" +\n \"paid API (x402/mppx/Stripe) — something you could pay for with an \" +\n \"HTTP request to someone else's endpoint. Include clear inputs and \" +\n \"outputs. 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(\"Optional context about the task that needed this service\"),\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};\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.string().nullish(),\n payment_challenge: z.string().nullish(),\n reviewer_wallet: z.string().nullish(),\n review_signature: z.string().nullish(),\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","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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