@cookiemunch/mcp 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/bin.ts","../src/index.ts","../src/tools.ts","../src/tools-config.ts","../src/tools-platform.ts","../src/tools-integrations.ts","../src/tools-rights-page.ts","../src/design-warnings.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * stdio entry point for the Cookie Munch MCP server. Reads COOKIEMUNCH_API_KEY\n * (required) and COOKIEMUNCH_BASE_URL (optional) from the environment, builds the\n * server, and serves it over stdio — the transport Claude Desktop / Claude Code use\n * to spawn local MCP servers.\n */\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { createCookieMunchMcp } from './index.js';\n\nasync function main(): Promise<void> {\n const apiKey = process.env.COOKIEMUNCH_API_KEY;\n if (!apiKey) {\n console.error('COOKIEMUNCH_API_KEY is required.');\n process.exit(1);\n }\n const baseUrl = process.env.COOKIEMUNCH_BASE_URL ?? 'https://api.cookiemunch.net';\n const server = createCookieMunchMcp({ apiKey, baseUrl });\n const transport = new StdioServerTransport();\n await server.connect(transport);\n // The process now stays alive serving MCP requests over stdio.\n}\n\nmain().catch((err) => {\n console.error('cookiemunch-mcp failed to start:', err);\n process.exit(1);\n});\n","/**\n * @cookiemunch/mcp — a Model Context Protocol server exposing the Cookie Munch\n * Developer API as MCP tools, built on @cookiemunch/sdk. The library entry exports\n * the tool registration (registerTools) and a server factory (createCookieMunchMcp);\n * the stdio bootstrap lives in bin.ts.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { createCookieMunch, type CookieMunchClient } from '@cookiemunch/sdk';\nimport { registerTools, type ToolServer } from './tools.js';\n\nexport { registerTools, type ToolServer, type ToolResult } from './tools.js';\n\nexport interface CookieMunchMcpOptions {\n apiKey: string;\n baseUrl: string;\n /** Inject a pre-built SDK client (e.g. for tests); otherwise one is created from apiKey/baseUrl. */\n client?: CookieMunchClient;\n}\n\n/** Build an McpServer with all Cookie Munch tools registered. Connect a transport to run it. */\nexport function createCookieMunchMcp(opts: CookieMunchMcpOptions): McpServer {\n const client = opts.client ?? createCookieMunch({ apiKey: opts.apiKey, baseUrl: opts.baseUrl });\n const server = new McpServer({ name: 'cookiemunch', version: '1.0.0' });\n // McpServer structurally satisfies ToolServer; the cast bridges the SDK's broader\n // generic registerTool signature to our minimal, testable surface.\n registerTools(server as unknown as ToolServer, client);\n return server;\n}\n","/**\n * Tool registration for the Cookie Munch MCP server. registerTools wires the\n * @cookiemunch/sdk client onto an MCP server's registerTool API. It depends only\n * on a minimal ToolServer shape (structurally satisfied by McpServer), so the\n * registration logic is unit-testable against a fake server + mocked SDK client\n * without standing up a stdio transport.\n */\n\nimport { z, type ZodRawShape } from 'zod';\nimport type { CookieMunchClient } from '@cookiemunch/sdk';\nimport { registerConfigTools } from './tools-config.js';\nimport { registerPlatformTools } from './tools-platform.js';\nimport { registerIntegrationTools } from './tools-integrations.js';\nimport { registerRightsPageTools, registerRightsTools } from './tools-rights-page.js';\nimport { withDesignWarnings } from './design-warnings.js';\n// No @cookiemunch/core dependency: the v2 flow engine runs server-side behind the\n// /v1/sites/:cbid/flow endpoints, which the SDK client surfaces as getFlow/editFlow/\n// setFlow. The MCP server therefore bundles only the SDK.\n\nexport interface ToolResult {\n content: Array<{ type: 'text'; text: string }>;\n isError?: boolean;\n /** MCP's CallToolResult carries an open index signature; included for structural compatibility. */\n [key: string]: unknown;\n}\n\n/**\n * The `tool` registrar shape: registers one tool whose handler wraps SDK errors\n * into an isError result. Passed to sibling modules (e.g. tools-config.ts) so they\n * register into the same set while preserving order.\n */\nexport type ToolRegistrar = (\n name: string,\n description: string,\n inputSchema: ZodRawShape,\n run: (args: Record<string, unknown>) => Promise<unknown>,\n) => void;\n\n/** The slice of McpServer.registerTool we depend on (structurally compatible). */\nexport interface ToolServer {\n registerTool(\n name: string,\n config: { title?: string; description: string; inputSchema?: ZodRawShape },\n handler: (args: Record<string, unknown>) => Promise<ToolResult>,\n ): unknown;\n}\n\nfunction text(value: unknown, tool = ''): ToolResult {\n const body = typeof value === 'string' ? value : JSON.stringify(value, null, 2);\n // A config/design result whose Accept is pushed harder than its Reject says so FIRST, and\n // says truthfully whether anything was saved.\n return { content: [{ type: 'text', text: withDesignWarnings(value, body, tool) }] };\n}\n\nfunction fail(err: unknown): ToolResult {\n const message = err instanceof Error ? err.message : String(err);\n return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };\n}\n\nexport function registerTools(server: ToolServer, client: CookieMunchClient): void {\n /** Register a tool whose handler wraps SDK errors into an isError result. */\n const tool: ToolRegistrar = (name, description, inputSchema, run) => {\n server.registerTool(name, { description, inputSchema }, async (args) => {\n try {\n return text(await run(args), name);\n } catch (err) {\n return fail(err);\n }\n });\n };\n\n const cbid = { cbid: z.string().describe('Site identifier (cbid). Must belong to your org.') };\n const range = {\n from: z.number().optional().describe('Epoch-ms lower bound.'),\n to: z.number().optional().describe('Epoch-ms upper bound.'),\n };\n\n tool(\n 'whoami',\n 'Return the identity tied to the API key: orgId and name, the effective plan with planSource (org = its own subscription, account = covered by a higher plan another org on the same account pays for) and the features it unlocks, and the key\\u2019s scopes.',\n {},\n () => client.me(),\n );\n tool(\n 'list_account_orgs',\n 'The organisations on this key\\u2019s account, each with its effective plan and planSource, plus the per-account org cap (max/used) and the upgrade URL. Read-only; needs an unscoped key.',\n {},\n () => client.orgs.list(),\n );\n\n tool('list_sites', 'List all sites (cbids) in your organization.', {}, () => client.sites.list());\n tool('get_site', 'One site: its domain, cbid and verification status. Read-only.', { cbid: z.string() }, (a) =>\n client.sites.get(a.cbid as string),\n );\n tool(\n 'get_site_banner',\n 'Which banner design a site uses, or bannerId null when none is assigned. Read-only.',\n { cbid: z.string() },\n (a) => client.sites.banner(a.cbid as string),\n );\n\n tool(\n 'get_privacy_policy',\n \"Generate the site's privacy and cookie policy as Markdown, naming the org's data controller. Needs a contact email: the one given, else the org controller's, else the owner's. Read-only — nothing is published.\",\n { cbid: z.string(), contactEmail: z.string().optional(), effectiveDate: z.string().optional().describe('YYYY-MM-DD; defaults to today.'), jurisdictions: z.array(z.string()).optional() },\n (a) =>\n client.sites.policy(a.cbid as string, {\n ...(a.contactEmail ? { contactEmail: a.contactEmail as string } : {}),\n ...(a.effectiveDate ? { effectiveDate: a.effectiveDate as string } : {}),\n ...(a.jurisdictions ? { jurisdictions: a.jurisdictions as string[] } : {}),\n }),\n );\n\n tool(\n 'set_ad_personalization',\n \"Add or remove the separate 'personalised ads' choice on the site's live banner. With it on, accepting marketing no longer implies personalised ads unless `default` is true.\",\n { cbid: z.string(), enabled: z.boolean(), default: z.boolean().optional(), label: z.string().optional() },\n (a) =>\n client.sites.setAdPersonalization(a.cbid as string, {\n enabled: a.enabled as boolean,\n ...(a.default !== undefined ? { default: a.default as boolean } : {}),\n ...(a.label ? { label: a.label as string } : {}),\n }),\n );\n\n tool(\n 'analyze_session',\n 'Analyse a captured browsing session against the consent it ran under: which trackers fired after the visitor opted out, and what personal data left the page. Read-only.',\n {\n cbid: z.string(),\n har: z.unknown().optional().describe('A HAR export of the session.'),\n requests: z.array(z.unknown()).optional().describe('Or the requests directly.'),\n consent: z.record(z.string(), z.boolean()).optional(),\n gpc: z.boolean().optional(),\n },\n (a) =>\n client.sites.analyzeSession(a.cbid as string, {\n ...(a.har !== undefined ? { har: a.har } : {}),\n ...(a.requests ? { requests: a.requests as unknown[] } : {}),\n ...(a.consent ? { consent: a.consent as Record<string, boolean> } : {}),\n ...(a.gpc !== undefined ? { gpc: a.gpc as boolean } : {}),\n }),\n );\n\n tool(\n 'create_site',\n 'Create a new site. The cbid is auto-generated if you omit it.',\n { domain: z.string().describe('The site domain, e.g. example.com.'), cbid: z.string().optional().describe('Optional explicit cbid.') },\n (a) => client.sites.create({ domain: a.domain as string, ...(typeof a.cbid === 'string' ? { cbid: a.cbid } : {}) }),\n );\n\n tool(\n 'create_sites_bulk',\n 'Create up to 100 sites in one call. Partial success: each item reports ok or its own error, and a bad or duplicate item fails only itself.',\n {\n sites: z\n .array(z.object({ domain: z.string(), cbid: z.string().optional(), platform: z.string().optional() }))\n .min(1)\n .max(100),\n },\n (a) => client.sites.createBulk(a.sites as Array<{ domain: string; cbid?: string; platform?: string }>),\n );\n\n tool('get_site_config', 'Get the banner/consent configuration for a site.', { ...cbid }, (a) => client.sites.getConfig(a.cbid as string));\n\n tool(\n 'update_site_config',\n 'Replace (overwrite) the banner/consent configuration for a site via PUT. This is destructive, not a merge: any top-level SiteConfig field you omit from `config` reverts to its default rather than keeping its current value — unless keepUnspecified is true, in which case omitted top-level fields keep their stored value and only the fields you send are replaced (each whole). A top-level field sent as null reverts to its default. To change one setting, use patch_site_config instead — it merges server-side. Prefer the narrower set_* tools (set_blocking, set_banner_basics, etc.) when they cover your change.',\n {\n ...cbid,\n config: z.record(z.unknown()).describe('The full SiteConfig to write, not a patch. Without keepUnspecified, omitted top-level fields are NOT preserved from the current config.'),\n keepUnspecified: z.boolean().optional().describe('PUT ?keep=unspecified: keep the stored value of every top-level field `config` omits, instead of reverting it to its default.'),\n },\n (a) =>\n a.keepUnspecified === true\n ? client.sites.putConfig(a.cbid as string, a.config as Record<string, unknown>, { keep: 'unspecified' })\n : client.sites.putConfig(a.cbid as string, a.config as Record<string, unknown>),\n );\n\n tool(\n 'patch_site_config',\n 'Change part of a site\\'s banner/consent configuration. The patch is a JSON Merge Patch (RFC 7386) over the stored config server-side: any field you omit keeps its current value, and a field set to null is REMOVED (it falls back to its default) — e.g. { \"banner\": { \"i18n\": { \"es\": null } } } drops the Spanish override. This is the safe way to flip one setting, and it needs no read-modify-write. Use update_site_config only when you genuinely mean to replace the whole document.',\n { ...cbid, config: z.record(z.unknown()).describe('The subset of SiteConfig to change, e.g. { \"banner\": { \"showRightsLink\": true } }. Everything else is preserved; null removes a field.') },\n (a) => client.sites.patchConfig(a.cbid as string, a.config as Record<string, unknown>),\n );\n\n tool(\n 'preview_site_config',\n 'Preview a config change WITHOUT saving it: returns the config as it would be saved, a diff of every field that would change, and any warnings (plan-gated or unrecognised fields). mode \"patch\" (default) previews patch_site_config; mode \"put\" previews update_site_config, and its diff lists everything a replace would revert to its default (unless keepUnspecified is true). Use it before any write you are not sure of.',\n {\n ...cbid,\n config: z.record(z.unknown()).describe('The patch (or, with mode \"put\", the full config) to preview.'),\n mode: z.enum(['patch', 'put']).optional().describe('patch (default) merges; put replaces.'),\n keepUnspecified: z.boolean().optional().describe('With mode \"put\": preview update_site_config with keepUnspecified (omitted top-level fields keep their stored value).'),\n },\n (a) =>\n client.sites.dryRunConfig(a.cbid as string, a.config as Record<string, unknown>, {\n mode: (a.mode as 'patch' | 'put' | undefined) ?? 'patch',\n ...(a.keepUnspecified === true ? { keep: 'unspecified' as const } : {}),\n }),\n );\n\n tool(\n 'lint_banner_config',\n 'Check a banner config for consent-button parity WITHOUT saving it: is \"Accept all\" more prominent than \"Reject all\" anywhere — a brighter or more saturated colour, a bigger or bolder button, Reject styled as a link, hidden, below the fold, set apart, missing from the first layer, or worded to guilt-trip? Regulators (EDPB, CNIL) treat that as a dark pattern. Returns findings, a 0–100 score and the reject style that would match Accept. It checks exactly what the write would store: merged over the stored config as patch_site_config would, or with replace: true replaced as update_site_config would. Run it before writing any banner design.',\n {\n ...cbid,\n config: z.record(z.unknown()).describe('The proposed SiteConfig (or a partial one, or a v2 flow design).'),\n replace: z.boolean().optional().describe('Check what update_site_config (a full replace) would store, instead of what patch_site_config (a merge) would.'),\n },\n async (a) => {\n const r = await client.sites.lintConfig(a.cbid as string, a.config as Record<string, unknown>, a.replace === true ? { replace: true } : {});\n // A clean bill is said in words too, so an agent does not have to infer it from an empty array.\n return r.designWarnings.length === 0\n ? `No design warnings: Accept all and Reject all have equal weight on every surface checked (score ${r.score}). Nothing was saved.\\n\\n${JSON.stringify(r, null, 2)}`\n : r;\n },\n );\n\n tool(\n 'verify_consent_log',\n \"Verify a site's consent log has not been tampered with. Each record carries the hash of the one before it, so an edited, reordered or deleted record breaks the chain and this returns valid: false. This is the evidence behind a consent log — what you check when someone asks whether the record can be trusted, not just what it says.\",\n { ...cbid },\n (a) => client.consent.verify(a.cbid as string),\n );\n\n tool(\n 'get_consent_stats',\n 'Get aggregated per-day consent statistics for a site.',\n { ...cbid, ...range },\n (a) => client.consent.stats(a.cbid as string, { from: a.from as number | undefined, to: a.to as number | undefined }),\n );\n\n tool(\n 'get_consent_log',\n 'Get recent anonymised consent records for a site.',\n { ...cbid, ...range, limit: z.number().optional().describe('Max records to return (default 200).') },\n (a) =>\n client.consent.log(a.cbid as string, {\n from: a.from as number | undefined,\n to: a.to as number | undefined,\n limit: a.limit as number | undefined,\n }),\n );\n\n tool(\n 'get_subject_consent',\n \"One person's consent records across every site in the org — web, mobile and desktop — by the subjectId your apps attach. Consent data: needs the consent:read scope. Read-only.\",\n { subjectId: z.string() },\n (a) => client.subjects.consent(a.subjectId as string),\n );\n\n tool('list_dsar', 'List all Data Subject Access Requests for your organization.', {}, () => client.dsar.list());\n tool(\n 'update_dsar_executor',\n 'Change a connected system in place — its profile, address, credential or auto flag. Only what you pass changes; the stored credential is kept unless you give a new one. With dryRun, answers the connection as it would be and a diff, and changes nothing.',\n {\n id: z.string(),\n patch: z.record(z.unknown()),\n dryRun: z.boolean().optional().describe('Validate and diff without saving.'),\n },\n (a) =>\n a.dryRun === true\n ? client.fulfillment.dryRunUpdateExecutor(a.id as string, a.patch as Record<string, unknown>)\n : client.fulfillment.updateExecutor(a.id as string, a.patch as Record<string, unknown>),\n );\n tool(\n 'get_dsar',\n 'One rights request by id, including its status and the deadline it must be answered by.',\n { id: z.string() },\n (a) => client.dsar.get(a.id as string),\n );\n tool(\n 'erase_dsar_subject',\n 'For a deletion request that is past identity verification: erase the person’s consent records on one site, identified by their consent stamp. Irreversible. The erasure is noted on the request. If the response carries a warning, nothing was cryptographically erased — tell the user.',\n { id: z.string(), cbid: z.string(), stamp: z.string() },\n (a) => client.dsar.erase(a.id as string, a.cbid as string, a.stamp as string),\n );\n tool(\n 'export_dsar_subject',\n 'For an access or portability request that is past identity verification: the person’s consent records on one site, identified by their consent stamp. The export is noted on the request.',\n { id: z.string(), cbid: z.string(), stamp: z.string() },\n (a) => client.dsar.export(a.id as string, a.cbid as string, a.stamp as string),\n );\n tool(\n 'get_dsar_response_notice',\n 'The subject-facing response notice for a request, as plain text — what to send the person. Read-only; nothing is sent.',\n { id: z.string() },\n (a) => client.dsar.response(a.id as string),\n );\n\n tool(\n 'create_dsar',\n 'Open a new Data Subject Access Request.',\n {\n type: z.enum(['access', 'deletion', 'rectification', 'portability', 'opt-out']).describe('DSAR right being exercised.'),\n subjectEmail: z.string().describe('The data subject’s email.'),\n regulation: z.enum(['gdpr', 'ccpa']).describe('Governing regulation.'),\n note: z.string().optional().describe('Optional INTERNAL note; never shown to the data subject.'),\n messageToSubject: z.string().max(2000).optional().describe('The line the data subject reads in the response notice. Never an API key.'),\n test: z\n .boolean()\n .optional()\n .describe('Mark it as a test request: kept off the SLA board and deletable afterwards with delete_test_dsar.'),\n },\n (a) =>\n client.dsar.create({\n type: a.type as never,\n subjectEmail: a.subjectEmail as string,\n regulation: a.regulation as never,\n ...(typeof a.note === 'string' ? { note: a.note } : {}),\n ...(typeof a.messageToSubject === 'string' ? { messageToSubject: a.messageToSubject } : {}),\n ...(a.test === true ? { test: true } : {}),\n }),\n );\n\n tool(\n 'create_rights_link',\n 'Mint a signed, single-use link to a site’s hosted rights page for a person you know is signed in to that site. On the page their email is filled in and locked and the email-code step is skipped; the filed request is recorded as verified by their account. Give the link only to that person. Expires in 15 minutes by default (max 1 hour). Needs dsar:write.',\n {\n cbid: z.string().describe('Site identifier (cbid). Must belong to your org.'),\n email: z.string().describe('The signed-in person’s verified email address.'),\n userId: z.string().optional().describe('Your own account id for them; recorded on the request.'),\n rights: z\n .array(z.enum(['access', 'erasure', 'rectification', 'portability', 'restriction', 'objection', 'opt_out_sale', 'opt_out_targeted', 'limit_sensitive']))\n .min(1)\n .optional()\n .describe('Limit the link to these rights. Default: every right the page offers.'),\n ttlSeconds: z.number().int().min(60).max(3600).optional().describe('How long the link works, in seconds (default 900).'),\n },\n (a) =>\n client.rightsLinks.create(a.cbid as string, {\n subject: { email: a.email as string, ...(typeof a.userId === 'string' ? { userId: a.userId } : {}) },\n ...(Array.isArray(a.rights) ? { rights: a.rights as never } : {}),\n ...(typeof a.ttlSeconds === 'number' ? { ttlSeconds: a.ttlSeconds } : {}),\n }),\n );\n\n tool(\n 'delete_test_dsar',\n 'Delete a TEST rights request (one created with test: true), with its tasks and their upstream log. Real requests cannot be deleted and are refused. The deletion is recorded in the audit log.',\n { id: z.string().describe('The test request id.') },\n async (a) => {\n await client.dsar.delete(a.id as string);\n return { deleted: a.id };\n },\n );\n\n tool(\n 'mark_dsar_test',\n 'Mark a CLOSED rights request (completed or rejected) as a test request, after the fact — for trial requests filed before test: true existed. An open request is refused (request_not_closed), so a live obligation can never be relabelled. Recorded in the audit log; afterwards delete_test_dsar can remove it. Returns { request, changed }.',\n { id: z.string().describe('The closed request id.') },\n (a) => client.dsar.markTest(a.id as string),\n );\n\n tool(\n 'advance_dsar',\n 'Advance a DSAR to a new status (received → verifying → in_progress → completed, or rejected).',\n {\n id: z.string().describe('The DSAR id.'),\n toStatus: z.enum(['received', 'verifying', 'in_progress', 'completed', 'rejected']).describe('Target status.'),\n messageToSubject: z.string().max(2000).optional().describe('Replaces the line the data subject reads in the notice — for a rejection, why.'),\n },\n (a) =>\n typeof a.messageToSubject === 'string'\n ? client.dsar.advance(a.id as string, a.toStatus as never, { messageToSubject: a.messageToSubject })\n : client.dsar.advance(a.id as string, a.toStatus as never),\n );\n\n tool(\n 'export_consent',\n 'Export a site’s consent log as raw CSV text.',\n { ...cbid, ...range },\n (a) => client.consent.export(a.cbid as string, { from: a.from as number | undefined, to: a.to as number | undefined }),\n );\n\n tool(\n 'get_receipt',\n 'Fetch the signed consent receipt for a single consent record (by stamp).',\n { ...cbid, stamp: z.string().describe('The consent record stamp/id.') },\n (a) => client.consent.receipt(a.cbid as string, a.stamp as string),\n );\n\n tool('delete_site', 'Delete a site (cbid) and its configuration from your org.', { ...cbid }, async (a) => {\n await client.sites.delete(a.cbid as string);\n return { ok: true };\n });\n\n tool('list_vendors', 'List vendors (processors) with their computed risk scores.', {}, () => client.vendors.list());\n\n tool(\n 'create_vendor',\n 'Register a vendor (processor) and compute its risk score.',\n {\n name: z.string().describe('Vendor name.'),\n category: z.string().describe('Vendor category, e.g. analytics.'),\n dataShared: z.array(z.string()).describe('Categories of data shared with the vendor.'),\n dpaSigned: z.boolean().describe('Whether a Data Processing Agreement is signed.'),\n subprocessors: z.number().describe('Number of subprocessors.'),\n certifications: z.array(z.string()).describe('Compliance certifications, e.g. ISO27001.'),\n region: z.string().describe('Primary processing region, e.g. EU.'),\n },\n (a) =>\n client.vendors.create({\n name: a.name as string,\n category: a.category as string,\n dataShared: a.dataShared as string[],\n dpaSigned: a.dpaSigned as boolean,\n subprocessors: a.subprocessors as number,\n certifications: a.certifications as string[],\n region: a.region as string,\n }),\n );\n\n tool('list_ropa', 'List Records of Processing Activities (RoPA) for your organization.', {}, () => client.ropa.list());\n tool('export_ropa_csv', 'The org’s RoPA (GDPR Art. 30) as CSV. Read-only.', {}, () => client.ropa.exportCsv());\n\n tool(\n 'create_ropa',\n 'Create a Record of Processing Activity (RoPA) entry.',\n {\n name: z.string().describe('Activity name.'),\n purpose: z.string().describe('Purpose of processing.'),\n legalBasis: z\n .enum(['consent', 'contract', 'legal-obligation', 'vital-interests', 'public-task', 'legitimate-interests'])\n .describe('GDPR legal basis.'),\n dataCategories: z.array(z.string()).describe('Categories of personal data.'),\n recipients: z.array(z.string()).describe('Recipients of the data.'),\n retentionDays: z.number().describe('Retention period in days.'),\n crossBorderTransfer: z.boolean().describe('Whether data is transferred across borders.'),\n },\n (a) =>\n client.ropa.create({\n name: a.name as string,\n purpose: a.purpose as string,\n legalBasis: a.legalBasis as never,\n dataCategories: a.dataCategories as string[],\n recipients: a.recipients as string[],\n retentionDays: a.retentionDays as number,\n crossBorderTransfer: a.crossBorderTransfer as boolean,\n }),\n );\n\n tool('get_site_cookies', 'List the cookies discovered on a site, with their consent categories.', { ...cbid }, (a) =>\n client.sites.cookies(a.cbid as string),\n );\n\n tool(\n 'scan_site',\n 'Trigger a cookie crawl of a site (at most 90 s). Returns its scanId and state (queued). With wait: true, returns once it is done or failed — state, cookieCount, pagesVisited, durationMs, error. The stored list keeps cookies earlier crawls and real visits found; retire one the site no longer sets.',\n { ...cbid, wait: z.boolean().optional().describe('Wait for the scan to finish (up to 100 s) and return its outcome.') },\n async (a) => {\n let started: unknown;\n try {\n started = await client.sites.scan(a.cbid as string);\n } catch (err) {\n // Already running: with wait, wait for that one rather than fail.\n if (!a.wait || (err as { status?: number }).status !== 409) throw err;\n }\n return a.wait ? client.sites.waitForScan(a.cbid as string, { timeoutMs: 100_000 }) : started;\n },\n );\n\n tool(\n 'get_scan_status',\n 'Get a site’s last cookie scan: state (queued, scanning, done, failed), scanId, durationMs, cookieCount, pagesVisited and error when it failed.',\n { ...cbid, wait: z.number().min(0).max(60).optional().describe('Seconds (≤60) to wait for a running scan to settle before answering.') },\n (a) => (a.wait !== undefined ? client.sites.scanStatus(a.cbid as string, { wait: a.wait as number }) : client.sites.scanStatus(a.cbid as string)),\n );\n\n tool('get_ab_results', 'Get A/B banner experiment results (per variant) for a site.', { ...cbid }, (a) =>\n client.sites.ab(a.cbid as string),\n );\n\n tool('list_brand_kits', 'List reusable brand kits (colors/logo/typography) for your org.', {}, () => client.brandKits.list());\n\n tool('list_preferences', 'List configurable consent preferences/purposes for your org.', {}, () => client.preferences.list());\n\n tool('list_members', 'List the members of your organization.', {}, () => client.members.list());\n\n tool('list_api_keys', 'List the API keys for your organization (secrets are not returned), with each key\\u2019s scopes, expiry and when it was last used.', {}, () => client.keys.list());\n\n tool(\n 'api_key_report',\n 'Key hygiene: keys not used for a while, keys with broad (full or wide write) access, and keys expiring soon, each with the reason. Read-only.',\n {\n unusedDays: z.number().int().min(1).max(3650).optional().describe('Unused for at least this many days (default 90).'),\n expiringDays: z.number().int().min(1).max(3650).optional().describe('Expiring within this many days (default 14).'),\n },\n (a) => client.keys.report({ ...(a.unusedDays !== undefined ? { unusedDays: a.unusedDays as number } : {}), ...(a.expiringDays !== undefined ? { expiringDays: a.expiringDays as number } : {}) }),\n );\n\n tool('get_usage', 'Get the current usage/quota summary for your organization.', {}, () => client.usage());\n\n tool('list_webhooks', 'List webhook subscriptions for your organization.', {}, () => client.webhooks.list());\n\n tool(\n 'create_webhook',\n 'Create a webhook subscription. The response includes the signing secret (shown once).',\n {\n url: z.string().describe('HTTPS endpoint to deliver events to.'),\n events: z.array(z.string()).describe('Event names to subscribe to, e.g. consent.created.'),\n cbid: z.string().optional().describe('Optional site cbid to scope the subscription to.'),\n },\n (a) =>\n client.webhooks.create({\n url: a.url as string,\n events: a.events as string[],\n ...(typeof a.cbid === 'string' ? { cbid: a.cbid } : {}),\n }),\n );\n\n tool(\n 'roll_webhook_secret',\n 'Rotate a webhook subscription’s signing secret. The new secret is returned once; the receiving endpoint must be updated to verify with it.',\n { id: z.string() },\n (a) => client.webhooks.rollSecret(a.id as string),\n );\n\n tool(\n 'test_webhook',\n 'Send a signed test event to a webhook subscription now, and report what the endpoint answered.',\n { id: z.string() },\n (a) => client.webhooks.test(a.id as string),\n );\n\n tool(\n 'list_webhook_dead_letters',\n 'Webhook deliveries that failed every retry, newest first, with the last status or error. Read-only.',\n {},\n () => client.webhooks.deadLetters(),\n );\n\n tool(\n 'replay_webhook_dead_letter',\n 'Deliver a dead-lettered webhook event again, to the subscription as it is now.',\n { id: z.string() },\n (a) => client.webhooks.replayDeadLetter(a.id as string),\n );\n\n tool(\n 'update_webhook',\n 'Change a webhook subscription, or pause it with active:false (delivery stops; the subscription is kept). Only the fields given change. cbid: null widens it to every property in the org.',\n {\n id: z.string(),\n url: z.string().optional(),\n events: z.array(z.string()).optional(),\n cbid: z.string().nullable().optional(),\n active: z.boolean().optional(),\n },\n (a) =>\n client.webhooks.update(a.id as string, {\n ...(a.url !== undefined ? { url: a.url as string } : {}),\n ...(a.events !== undefined ? { events: a.events as string[] } : {}),\n ...(a.cbid !== undefined ? { cbid: a.cbid as string | null } : {}),\n ...(a.active !== undefined ? { active: a.active as boolean } : {}),\n }),\n );\n\n tool('delete_webhook', 'Delete a webhook subscription by id.', { id: z.string().describe('The webhook subscription id.') }, async (a) => {\n await client.webhooks.delete(a.id as string);\n return { ok: true };\n });\n\n tool(\n 'verify_site',\n 'Verify that your organization controls a domain by one of three challenge methods (dns / meta / file). Required to unlock consent export and signed receipts.',\n { ...cbid, method: z.enum(['dns', 'meta', 'file']).describe('Challenge method: dns (TXT record), meta (HTML tag), or file (/.well-known/cookiemunch-verify.txt).') },\n (a) => client.sites.verify(a.cbid as string, a.method as 'dns' | 'meta' | 'file'),\n );\n\n tool(\n 'get_verification_challenge',\n 'Exactly what to publish to prove control of a site’s domain: the DNS TXT record, the meta tag, the file, or installing the embed. Read-only — publish one, then call verify_site.',\n { cbid: z.string() },\n (a) => client.sites.verifyChallenge(a.cbid as string),\n );\n\n tool(\n 'match_site_brand',\n 'Extract theme colors and typography from a site\\'s homepage to suggest a matching brand theme for the consent banner.',\n { ...cbid },\n (a) => client.sites.brand(a.cbid as string),\n );\n\n // ---------------------------------------------------------------------------\n // V2 flow-editing tools\n // ---------------------------------------------------------------------------\n\n tool(\n 'get_flow',\n 'Get the v2 banner flow config for a site, including current views, categories, and any lint issues.',\n { cbid: z.string().describe('Site identifier (cbid).') },\n (a) => client.sites.getFlow(a.cbid as string),\n );\n\n tool(\n 'edit_flow',\n 'Apply a batch of structured edit operations to a site\\'s v2 banner flow. All ops are validated server-side and the final config must be lint-clean before it is saved.',\n {\n cbid: z.string().describe('Site identifier (cbid).'),\n operations: z\n .array(z.record(z.unknown()))\n .describe(\n 'Ordered list of ops. Each must have an \"op\" field: addView | removeView | addElement | setButtonTransition | addCustomCategory.',\n ),\n },\n (a) => client.sites.editFlow(a.cbid as string, a.operations as { op: string }[]),\n );\n\n tool(\n 'set_flow',\n 'Wholesale replace a site\\'s v2 banner flow with a complete config (e.g. from a template). Validated server-side before it is saved.',\n {\n cbid: z.string().describe('Site identifier (cbid).'),\n config: z.record(z.unknown()).describe('A full v2 FlowConfig object ({ v:2, flow, categories, ... }).'),\n },\n (a) => client.sites.setFlow(a.cbid as string, a.config as Record<string, unknown>),\n );\n\n // ---------------------------------------------------------------------------\n // Task 3: Structured, validated config tools for non-flow config domains, plus\n // the install-snippet tool. Extracted to tools-config.ts; registered here (in\n // order) via the shared `tool` registrar.\n // ---------------------------------------------------------------------------\n\n registerConfigTools(tool, client);\n\n registerPlatformTools(tool, client);\n registerIntegrationTools(tool, client);\n registerRightsTools(tool, client);\n registerRightsPageTools(tool, client);\n\n // ---------------------------------------------------------------------------\n // Task 4: org/member/brand-kit/preference writes + issue_api_key\n //\n // SECURITY: all operations are scoped to the key's org (the SDK and dev-api\n // derive the org from the API key — callers never pass an orgId). The org OWNER\n // is protected from role-change/removal by the dev-api. Roles are runtime-\n // validated on the server to {admin, member, viewer}.\n // ---------------------------------------------------------------------------\n\n tool(\n 'invite_member',\n 'Invite a person to your organization by email. role must be admin, member, or viewer. The org is derived from the API key — you cannot invite into a different org.',\n {\n email: z.string().describe('Email address of the person to invite.'),\n role: z.enum(['admin', 'member', 'viewer']).describe('Role to assign: admin, member, or viewer. owner is not assignable via API key.'),\n },\n (a) => client.members.invite(a.email as string, a.role as string),\n );\n\n tool(\n 'set_member_role',\n 'Change the role of a member in your organization. The org owner\\'s role cannot be changed.',\n {\n userId: z.string().describe('The userId of the member whose role to change.'),\n role: z.enum(['admin', 'member', 'viewer']).describe('New role: admin, member, or viewer.'),\n },\n (a) => client.members.setRole(a.userId as string, a.role as string),\n );\n\n tool(\n 'remove_member',\n 'Remove a member from your organization. The org owner cannot be removed.',\n {\n userId: z.string().describe('The userId of the member to remove.'),\n },\n async (a) => {\n await client.members.remove(a.userId as string);\n return { ok: true };\n },\n );\n\n tool(\n 'create_brand_kit',\n 'Create a reusable brand kit (colors, logo, typography) for your organization\\'s consent banners.',\n {\n name: z.string().describe('Display name for the brand kit.'),\n theme: z.record(z.unknown()).describe('Theme tokens (colors, fonts, etc.) as a JSON object.'),\n content: z.record(z.unknown()).optional().describe('Optional banner copy overrides.'),\n logoUrl: z.string().optional().describe('Optional URL for your org logo.'),\n customCss: z.string().optional().describe('Optional custom CSS string to inject into the banner.'),\n },\n (a) =>\n client.brandKits.create({\n name: a.name as string,\n theme: a.theme as Record<string, unknown>,\n ...(a.content !== undefined ? { content: a.content as Record<string, unknown> } : {}),\n ...(typeof a.logoUrl === 'string' ? { logoUrl: a.logoUrl } : {}),\n ...(typeof a.customCss === 'string' ? { customCss: a.customCss } : {}),\n }),\n );\n\n tool(\n 'delete_brand_kit',\n 'Delete a brand kit by id. The kit must belong to your organization (cross-org deletes are rejected).',\n {\n id: z.string().describe('The brand kit id to delete.'),\n },\n async (a) => {\n await client.brandKits.delete(a.id as string);\n return { ok: true };\n },\n );\n\n tool(\n 'save_preference',\n 'Save or update the consent preferences for an end-user (by subjectId) within your organization. purposes is a map of purpose-name → boolean.',\n {\n subjectId: z.string().describe('The end-user identifier (e.g. email or internal user id).'),\n purposes: z.record(z.boolean()).describe('Map of purpose names to consent values, e.g. { \"newsletter\": true, \"analytics\": false }.'),\n },\n (a) => client.preferences.save(a.subjectId as string, a.purposes as Record<string, boolean>),\n );\n\n tool(\n 'get_preference',\n 'One end-user’s saved preferences, by subjectId. Read-only.',\n { subjectId: z.string() },\n (a) => client.preferences.get(a.subjectId as string),\n );\n\n tool(\n 'issue_api_key',\n 'Issue a new API key. The secret is returned once and never again. Prefer the least privilege the job needs: `scopes` limits what it can do, `cbids` locks it to specific sites (it then cannot reach anything org-wide), `expiresInDays` retires it. Omitting all three mints a full-access, org-wide, non-expiring key.',\n {\n name: z.string().optional(),\n scopes: z.array(z.string()).optional(),\n cbids: z.array(z.string()).min(1).optional(),\n expiresInDays: z.number().int().min(1).max(3650).optional(),\n expiresAt: z.string().optional().describe('Or the exact expiry, an ISO date-time (not with expiresInDays).'),\n },\n (a) =>\n client.keys.issue({\n ...(a.expiresAt ? { expiresAt: a.expiresAt as string } : {}),\n ...(a.name ? { name: a.name as string } : {}),\n ...(a.scopes ? { scopes: a.scopes as string[] } : {}),\n ...(a.cbids ? { cbids: a.cbids as string[] } : {}),\n ...(a.expiresInDays !== undefined ? { expiresInDays: a.expiresInDays as number } : {}),\n }),\n );\n\n tool('revoke_api_key', 'Revoke an API key by its prefix. Takes effect immediately; anything using that key stops working.', { prefix: z.string() }, async (a) => {\n await client.keys.revoke(a.prefix as string);\n return { revoked: a.prefix };\n });\n\n tool(\n 'import_cookie_declaration',\n 'Read a cookie declaration exported from another CMP (OneTrust, Cookiebot, CookieYes, or any CSV/JSON with the same columns) and translate its categories into ours. Nothing is applied — it comes back for review, with the rows whose category could not be placed listed separately.',\n { cbid: z.string(), data: z.string().describe('The exported file, as text (CSV or JSON).') },\n (a) => client.sites.importDeclaration(a.cbid as string, a.data as string),\n );\n\n tool(\n 'apply_cookie_import',\n 'Import a cookie declaration exported from another CMP AND declare it: every row whose category mapped to ours and that has a purpose becomes a site declaration; the rest come back in `skipped` with the reason. Cookies the site already declared are kept unless overwrite is true. Prefer import_cookie_declaration first to review.',\n { cbid: z.string(), data: z.string().describe('The exported file, as text (CSV or JSON).'), overwrite: z.boolean().optional() },\n (a) => client.sites.applyImport(a.cbid as string, a.data as string, a.overwrite ? { overwrite: true } : undefined),\n );\n\n const declarationShape = {\n category: z.string().describe('necessary, preferences, statistics, marketing, or one of the site’s categories.custom ids.'),\n purpose: z.string().describe('What the cookie does, as visitors will read it — and the fallback for any language purposes lacks.'),\n purposes: z\n .record(z.string(), z.string().max(1000))\n .nullable()\n .optional()\n .describe('The purpose in other languages, keyed by BCP-47 tag: {\"es\": \"…\", \"pt-BR\": \"…\"}. The banner, data-cc=\"declaration\" and cookie-declaration.js draw the visitor’s language. null clears.'),\n provider: z.string().optional(),\n expiry: z.string().optional().describe('e.g. \"Session\", \"30 days\", \"1 year\" (the banner localises these forms).'),\n domain: z.string().optional(),\n pattern: z.boolean().optional().describe('Treat the name as a prefix wildcard (a trailing * does the same).'),\n };\n\n const dryRunArg = z\n .boolean()\n .optional()\n .describe('Store nothing: answer with the would-be declarations and a diff (added / removed / changed) to check first.');\n\n tool(\n 'declare_cookie',\n 'Declare what one of the site’s cookies is. Overrides the scanner, observed visits and the cookie database everywhere the declaration is shown (API, preference modal, data-cc=\"declaration\"). Use for the site’s own cookies the database cannot know. A name ending in * covers every cookie with that prefix.',\n { cbid: z.string(), name: z.string(), ...declarationShape, dryRun: dryRunArg },\n (a) => {\n const { cbid, name, dryRun, ...rest } = a as { cbid: string; name: string; dryRun?: boolean } & Record<string, unknown>;\n return client.sites.declareCookie(cbid, name, rest as never, dryRun ? { dryRun: true } : undefined);\n },\n );\n\n tool(\n 'declare_cookies',\n 'Declare many cookies at once. All-or-nothing: one invalid item refuses the whole request and nothing is saved. replace: true also removes every declaration the list does not name.',\n { cbid: z.string(), cookies: z.array(z.object({ name: z.string(), ...declarationShape })).max(500), replace: z.boolean().optional(), dryRun: dryRunArg },\n (a) => {\n const o = { ...(a.replace ? { replace: true } : {}), ...(a.dryRun ? { dryRun: true } : {}) };\n return client.sites.declareCookies(a.cbid as string, a.cookies as never, Object.keys(o).length ? o : undefined);\n },\n );\n\n tool(\n 'undeclare_cookie',\n 'Remove a cookie declaration; the scanned/observed classification applies again.',\n { cbid: z.string(), name: z.string(), dryRun: dryRunArg },\n async (a) => {\n if (a.dryRun) return client.sites.undeclareCookie(a.cbid as string, a.name as string, { dryRun: true });\n await client.sites.undeclareCookie(a.cbid as string, a.name as string);\n return { undeclared: a.name };\n },\n );\n\n tool(\n 'retire_cookie',\n 'Retire a cookie the site renamed or stopped setting: it leaves the banner’s cookie list, data-cc=\"declaration\" and the public feed, and stays listed for the owner with retired. A name ending in * retires every cookie with that prefix; the name must match a scanned, observed or declared cookie. If a crawl or a real visit sees it again afterwards, it is listed again with review: retired_but_seen.',\n {\n cbid: z.string(),\n name: z.string(),\n renamedTo: z.string().max(256).optional().describe('The cookie’s new name, if it was renamed.'),\n note: z.string().max(1000).optional(),\n dryRun: z.boolean().optional().describe('Store nothing: answer with the would-be retirement and list to check first.'),\n },\n (a) => {\n const input = { ...(a.renamedTo ? { renamedTo: a.renamedTo as string } : {}), ...(a.note ? { note: a.note as string } : {}) };\n return client.sites.retireCookie(a.cbid as string, a.name as string, input, a.dryRun ? { dryRun: true } : undefined);\n },\n );\n\n tool(\n 'unretire_cookie',\n 'Un-retire a cookie: it is listed again everywhere.',\n { cbid: z.string(), name: z.string(), dryRun: z.boolean().optional().describe('Store nothing: answer with what the list would be.') },\n async (a) => {\n if (a.dryRun) return client.sites.unretireCookie(a.cbid as string, a.name as string, { dryRun: true });\n await client.sites.unretireCookie(a.cbid as string, a.name as string);\n return { unretired: a.name };\n },\n );\n\n tool(\n 'list_cookie_presets',\n 'Declaration presets for the platforms a site is built on (atlas, forumulate, chatly, cookiemunch): each one’s parameters, what it has declared on this site, and whether the vendor’s live manifest can be imported yet. Read-only.',\n { cbid: z.string() },\n (a) => client.sites.cookiePresets(a.cbid as string),\n );\n\n tool(\n 'apply_cookie_preset',\n 'Apply (or re-sync) a vendor preset: declares exactly what that platform writes — cookies and browser storage, with domain and lifetime — marked as declared by that vendor. Re-applying removes keys the vendor no longer writes. Names the owner declared are kept (skipped). Atlas needs frontendApiHost (and crossSubdomainCookies, default true); Chatly needs publicId.',\n {\n cbid: z.string(),\n vendor: z.enum(['atlas', 'forumulate', 'chatly', 'cookiemunch']),\n frontendApiHost: z.string().optional().describe('Atlas: your frontend API host, e.g. auth.example.com.'),\n crossSubdomainCookies: z.boolean().optional().describe('Atlas: default true — the cookies live on the parent domain.'),\n publicId: z.string().optional().describe('Chatly: the channel public id (ch_web_…).'),\n dragging: z.boolean().optional().describe('Chatly: the launcher can be dragged (adds the drag-position key).'),\n category: z.string().optional().describe('Chatly: the category for its keys. Default necessary.'),\n dryRun: dryRunArg,\n },\n (a) => {\n const params: Record<string, unknown> = {};\n for (const k of ['frontendApiHost', 'crossSubdomainCookies', 'publicId', 'dragging', 'category'] as const) if (a[k] !== undefined) params[k] = a[k];\n return client.sites.applyCookiePreset(a.cbid as string, a.vendor as 'atlas', params, a.dryRun ? { dryRun: true } : undefined);\n },\n );\n\n tool(\n 'remove_cookie_preset',\n 'Remove every declaration a vendor preset made on this site.',\n { cbid: z.string(), vendor: z.enum(['atlas', 'forumulate', 'chatly', 'cookiemunch']), dryRun: dryRunArg },\n (a) => client.sites.removeCookiePreset(a.cbid as string, a.vendor as 'atlas', a.dryRun ? { dryRun: true } : undefined),\n );\n\n tool(\n 'delete_observed_cookie',\n 'Remove every stored row of this name that crawls or real visits put in the site’s cookie list (e.g. a name someone reported that the site never sets). A declaration of it stays. If real visits keep reporting it, it comes back quarantined.',\n { cbid: z.string(), name: z.string(), dryRun: dryRunArg },\n async (a) => {\n if (a.dryRun) return client.sites.deleteObservedCookie(a.cbid as string, a.name as string, { dryRun: true });\n await client.sites.deleteObservedCookie(a.cbid as string, a.name as string);\n return { deleted: a.name };\n },\n );\n\n tool(\n 'purge_observed_cookies',\n 'Purge observed since T: remove every row a real visit first reported at or after `since` (and before `until`). Crawled rows and declarations stay. Rows from before provenance was recorded use their last-seen time, so run with dryRun first.',\n {\n cbid: z.string(),\n since: z.union([z.string(), z.number()]).describe('ISO-8601 time or epoch milliseconds.'),\n until: z.union([z.string(), z.number()]).optional().describe('Optional end of the window (exclusive).'),\n dryRun: dryRunArg,\n },\n (a) => client.sites.purgeObservedCookies(\n a.cbid as string,\n { since: a.since as string | number, ...(a.until !== undefined ? { until: a.until as string | number } : {}) },\n a.dryRun ? { dryRun: true } : undefined,\n ),\n );\n\n tool(\n 'get_blocked_pages',\n 'Pages where the embed could not load its banner renderer — the page’s Content Security Policy or Trusted Types policy refused it, so nobody there can be asked for consent. An empty list is healthy. Read-only.',\n { cbid: z.string() },\n (a) => client.sites.blocked(a.cbid as string),\n );\n\n tool(\n 'roll_api_key',\n 'Rotate an API key: returns a new secret once, with the same name, scopes, property lock and expiry. The old secret stops working immediately — if it is the key this server runs with, this server stops working too until it is reconfigured.',\n { prefix: z.string() },\n (a) => client.keys.roll(a.prefix as string),\n );\n\n tool(\n 'update_api_key',\n 'Rename an API key, replace its scopes or the properties it is locked to, or set or remove its expiry. Only the fields given change; the secret does not.',\n {\n prefix: z.string(),\n name: z.string().optional(),\n scopes: z.array(z.string()).optional(),\n cbids: z.array(z.string()).min(1).optional(),\n expiresAt: z.string().nullable().optional().describe('A new expiry (ISO date-time), or null to remove it.'),\n },\n (a) =>\n client.keys.update(a.prefix as string, {\n ...(a.expiresAt !== undefined ? { expiresAt: a.expiresAt as string | null } : {}),\n ...(a.name !== undefined ? { name: a.name as string } : {}),\n ...(a.scopes ? { scopes: a.scopes as string[] } : {}),\n ...(a.cbids ? { cbids: a.cbids as string[] } : {}),\n }),\n );\n\n // ---- organisation ----\n tool('get_org', 'Your organisation: id, name, plan and logo URL. Read-only.', {}, () => client.org.get());\n\n tool(\n 'update_org',\n 'Rename your organisation or set its logo. logoUrl: null removes the logo; upload an image with upload_asset to get a URL. Deleting the organisation is not possible here.',\n { name: z.string().min(1).optional(), logoUrl: z.string().nullable().optional() },\n (a) =>\n client.org.update({\n ...(a.name !== undefined ? { name: a.name as string } : {}),\n ...(a.logoUrl !== undefined ? { logoUrl: a.logoUrl as string | null } : {}),\n }),\n );\n\n // ---- the organisation's own mail provider for rights-request mail (BYOK) ----\n tool(\n 'get_mail_provider',\n 'Your own mail provider for rights-request mail (verification codes and other privacy-request mail), if any. Never returns the credential, only its last four characters. `sender` says whether verification codes are mailed through it now (own) or not at all (none) — there is no shared sender. Read-only.',\n {},\n () => client.org.mailProvider.get(),\n );\n\n tool(\n 'set_mail_provider',\n 'Connect your own mail provider for rights-request mail — recommended, so codes come from your own domain. Replaces the stored one. It carries mail only after test_mail_provider succeeds; every save clears that. Omit secret to keep the stored one (same provider only).',\n {\n provider: z.enum(['brevo', 'sendgrid', 'postmark', 'resend', 'ses', 'smtp']),\n fromEmail: z.string().describe('An address on a domain your provider has verified.'),\n fromName: z.string().max(100).nullable().optional(),\n replyTo: z.string().nullable().optional(),\n secret: z.string().optional().describe('API key (Brevo, SendGrid, Resend), server token (Postmark), secret access key (SES) or SMTP password. Write-only.'),\n ses: z.object({ region: z.string(), accessKeyId: z.string() }).optional().describe('Required for ses.'),\n smtp: z\n .object({ host: z.string(), port: z.union([z.literal(25), z.literal(465), z.literal(587), z.literal(2525)]), security: z.enum(['tls', 'starttls']), username: z.string() })\n .optional()\n .describe('Required for smtp. TLS is always required.'),\n },\n (a) => client.org.mailProvider.set(a as never),\n );\n\n tool(\n 'test_mail_provider',\n 'Send a test message through your own mail provider (never Cookie Munch’s) and report what it answered. Success marks the configuration verified, after which it carries all rights mail.',\n { to: z.string().optional().describe('Recipient. Default: the reply-to, else the from address.') },\n (a) => client.org.mailProvider.test(a.to as string | undefined),\n );\n\n tool(\n 'remove_mail_provider',\n 'Remove your own mail provider. Rights mail goes back to Cookie Munch’s shared sender, labelled as sending on your site’s behalf.',\n {},\n async () => {\n await client.org.mailProvider.remove();\n return { removed: true };\n },\n );\n\n // ---- the rights page's captcha: the customer's own keys, or off (Cookie Munch's own is never used there) ----\n const CAPTCHA_OFF = 'Off removes spam protection beyond the hidden spam-trap field, the rate limits and the email code: expect more spam requests. Own keys are recommended.';\n const captchaInput = {\n mode: z.enum(['own', 'off']).describe(`own: your own captcha provider keys (recommended). off: no captcha. ${CAPTCHA_OFF}`),\n provider: z.enum(['turnstile', 'hcaptcha', 'recaptcha_v2', 'recaptcha_v3']).optional().describe('Required for own.'),\n siteKey: z.string().optional().describe('Required for own: the public site key. List your rights-page hostnames on it at the provider.'),\n secret: z.string().optional().describe('The provider secret key. Write-only; never returned. Omit to keep the stored one (same provider).'),\n minScore: z.number().min(0.1).max(0.9).optional().describe('reCAPTCHA v3 only. Default 0.5.'),\n };\n const captchaBody = (a: Record<string, unknown>) => ({\n mode: a.mode as 'own' | 'off',\n ...(a.provider !== undefined ? { provider: a.provider as never } : {}),\n ...(a.siteKey !== undefined ? { siteKey: a.siteKey as string } : {}),\n ...(a.secret !== undefined ? { secret: a.secret as string } : {}),\n ...(a.minScore !== undefined ? { minScore: a.minScore as number } : {}),\n });\n\n tool(\n 'get_rights_captcha',\n 'The captcha on a site’s hosted rights page: its own setting, else the organisation default, else off (`source` says which). Never returns the secret. Read-only.',\n { cbid: z.string() },\n (a) => client.rightsCaptcha.get(a.cbid as string),\n );\n\n tool(\n 'set_rights_captcha',\n `Set a site’s rights-page captcha: your own Turnstile, hCaptcha or reCAPTCHA keys (recommended; the provider must accept the secret before it is saved), or off. ${CAPTCHA_OFF} Audited with the old and new mode.`,\n { cbid: z.string(), ...captchaInput },\n (a) => client.rightsCaptcha.set(a.cbid as string, captchaBody(a)),\n );\n\n tool(\n 'remove_rights_captcha',\n 'Remove a site’s own captcha setting: it inherits the organisation default again (or off). Returns the setting now in force.',\n { cbid: z.string() },\n (a) => client.rightsCaptcha.remove(a.cbid as string),\n );\n\n tool(\n 'get_rights_captcha_default',\n 'The organisation default captcha for its rights pages, used by every site without its own setting. Never returns the secret. Read-only.',\n {},\n () => client.org.rightsCaptcha.get(),\n );\n\n tool(\n 'set_rights_captcha_default',\n `Set the organisation default captcha for its rights pages: your own keys (recommended) or off. ${CAPTCHA_OFF}`,\n captchaInput,\n (a) => client.org.rightsCaptcha.set(captchaBody(a)),\n );\n\n tool(\n 'remove_rights_captcha_default',\n 'Remove the organisation default: sites without their own setting then have no captcha. Returns the setting now in force.',\n {},\n () => client.org.rightsCaptcha.remove(),\n );\n\n // ---- the sign-in provider rights requests are verified with (Clerk, Atlas, any JWKS issuer) ----\n const IDENTITY_NOTE = 'The JWKS is fetched and checked before anything is saved. The session token must carry the email and a verified-email claim (default email_verified) set to true (Clerk: add email: {{user.primary_email_address}} to the session token; Clerk documents no claim for whether that address is verified, so either add your own or set trustEmailClaim). oidc_jwt needs an audience or authorizedParties.';\n const identityInput = {\n type: z.enum(['clerk', 'atlas', 'oidc_jwt']).describe('clerk, atlas (Clerk-shaped), or oidc_jwt (any issuer that signs session JWTs with a published JWKS).'),\n issuer: z.string().describe('https URL exactly as in the token’s iss (Clerk: your Frontend API URL).'),\n jwksUrl: z.string().optional().describe('Required for oidc_jwt; clerk/atlas default to <issuer>/.well-known/jwks.json.'),\n audience: z.string().optional().describe('Expected aud. For oidc_jwt an audience or authorizedParties is required (a shared issuer mints tokens for every app).'),\n authorizedParties: z.array(z.string()).optional().describe('Your own origins (https://www.example.com) the token’s azp must be one of. Required for clerk and atlas; for oidc_jwt when there is no audience.'),\n emailClaim: z.string().optional().describe('Default email.'),\n emailVerifiedClaim: z.string().optional().describe('Default email_verified; must be exactly true.'),\n sessionCookieName: z.string().optional().describe('Default __session: the cookie the hosted page on your custom domain reads.'),\n trustEmailClaim: z.boolean().optional().describe('clerk/atlas only, default false. True: a token without the verified claim is accepted, its email claim taken as verified. Set only if every address your provider puts in that claim is verified.'),\n };\n const identityBody = (a: Record<string, unknown>) => {\n const out: Record<string, unknown> = { type: a.type, issuer: a.issuer };\n for (const k of ['jwksUrl', 'audience', 'authorizedParties', 'emailClaim', 'emailVerifiedClaim', 'sessionCookieName', 'trustEmailClaim']) if (a[k] !== undefined) out[k] = a[k];\n return out as never;\n };\n\n tool(\n 'get_rights_identity',\n 'The sign-in provider a site’s rights requests are verified with: its own setting, else the organisation default, else none (`source` says which). Read-only.',\n { cbid: z.string() },\n (a) => client.rightsIdentity.get(a.cbid as string),\n );\n\n tool(\n 'set_rights_identity',\n `Connect a site’s sign-in provider so a visitor signed in to the site is verified by their session, with no code mail. ${IDENTITY_NOTE} Audited.`,\n { cbid: z.string(), ...identityInput },\n (a) => client.rightsIdentity.set(a.cbid as string, identityBody(a)),\n );\n\n tool(\n 'remove_rights_identity',\n 'Remove a site’s own sign-in provider: it inherits the organisation default again (or none). Returns the setting now in force.',\n { cbid: z.string() },\n (a) => client.rightsIdentity.remove(a.cbid as string),\n );\n\n tool(\n 'get_rights_identity_default',\n 'The organisation default sign-in provider for its rights requests, used by every site without its own. Read-only.',\n {},\n () => client.org.rightsIdentity.get(),\n );\n\n tool(\n 'set_rights_identity_default',\n `Set the organisation default sign-in provider for its rights requests. ${IDENTITY_NOTE}`,\n identityInput,\n (a) => client.org.rightsIdentity.set(identityBody(a)),\n );\n\n tool(\n 'remove_rights_identity_default',\n 'Remove the organisation default sign-in provider. Returns the setting now in force.',\n {},\n () => client.org.rightsIdentity.remove(),\n );\n\n tool(\n 'get_audit_log',\n 'The organisation’s audit log, newest first: administrative changes made in the dashboard or through the API, and who made them. Read-only.',\n { limit: z.number().int().min(1).max(500).optional() },\n (a) => client.audit(a.limit as number | undefined),\n );\n\n tool(\n 'upload_asset',\n 'Upload an image — a banner logo — and get its public URL. data is base64 (a data: URL also works); PNG, JPEG, WebP, GIF or SVG, up to 1,000,000 bytes.',\n {\n data: z.string(),\n contentType: z.enum(['image/png', 'image/jpeg', 'image/webp', 'image/gif', 'image/svg+xml']),\n },\n (a) => client.assets.upload({ data: a.data as string, contentType: a.contentType as 'image/png' }),\n );\n\n tool(\n 'delete_asset',\n 'Delete a stored image by its URL (or file name). Only your own organisation’s images can be named.',\n { url: z.string().describe('The URL upload_asset returned, or just its file name.') },\n async (a) => {\n await client.assets.delete(a.url as string);\n return { deleted: a.url };\n },\n );\n\n // ---- reseller ----\n tool(\n 'list_customers',\n 'The child orgs this reseller has provisioned, with pooled usage against the reseller plan’s cap. Read-only.',\n {},\n () => client.reseller.list(),\n );\n\n tool('get_customer', 'One child org: its controller details and usage. Read-only.', { id: z.string() }, (a) =>\n client.reseller.get(a.id as string),\n );\n\n tool(\n 'provision_customer',\n 'Create a new child org under this reseller. With `mintKey`, its first API key is returned once. Counts toward the reseller plan’s pooled limits.',\n {\n name: z.string(),\n ownerEmail: z.string().optional(),\n delegatedAccess: z.boolean().optional().describe('Whether this reseller may act inside the child.'),\n mintKey: z.boolean().optional(),\n keyScopes: z.array(z.string()).optional(),\n },\n (a) =>\n client.reseller.create({\n name: a.name as string,\n ...(a.ownerEmail ? { ownerEmail: a.ownerEmail as string } : {}),\n ...(a.delegatedAccess !== undefined ? { delegatedAccess: a.delegatedAccess as boolean } : {}),\n ...(a.mintKey !== undefined ? { mintKey: a.mintKey as boolean } : {}),\n ...(a.keyScopes ? { keyScopes: a.keyScopes as string[] } : {}),\n }),\n );\n\n tool(\n 'update_customer',\n 'Change a child org’s status, delegated access or DSAR routing. `dsarRouting: null` clears the override.',\n {\n id: z.string(),\n status: z.enum(['active', 'suspended']).optional(),\n delegatedAccess: z.boolean().optional(),\n dsarRouting: z.enum(['reseller', 'child']).nullable().optional(),\n },\n (a) =>\n client.reseller.update(a.id as string, {\n ...(a.status ? { status: a.status as 'active' | 'suspended' } : {}),\n ...(a.delegatedAccess !== undefined ? { delegatedAccess: a.delegatedAccess as boolean } : {}),\n ...(a.dsarRouting !== undefined ? { dsarRouting: a.dsarRouting as 'reseller' | 'child' | null } : {}),\n }),\n );\n\n // Suspend only. The API's purge option hard-deletes a customer org and all of its data;\n // that is not something to leave one agent call away, so this tool cannot pass it.\n tool(\n 'suspend_customer',\n 'Suspend a child org: it stops ingesting consent and its keys stop working, and it can be reactivated with update_customer. Its data is kept. (Permanent deletion is deliberately not available here.)',\n { id: z.string() },\n async (a) => {\n await client.reseller.deprovision(a.id as string);\n return { suspended: a.id };\n },\n );\n\n tool('list_customer_keys', \"A child org's API key prefixes. Never the secrets. Read-only.\", { id: z.string() }, (a) =>\n client.reseller.listKeys(a.id as string),\n );\n\n tool(\n 'issue_customer_key',\n \"Mint an API key for a child org. The secret is returned once. Prefer scopes and a property lock over a full-access key.\",\n { id: z.string(), name: z.string().optional(), scopes: z.array(z.string()).optional(), cbids: z.array(z.string()).min(1).optional() },\n (a) =>\n client.reseller.mintKey(a.id as string, {\n ...(a.name ? { name: a.name as string } : {}),\n ...(a.scopes ? { scopes: a.scopes as string[] } : {}),\n ...(a.cbids ? { cbids: a.cbids as string[] } : {}),\n }),\n );\n\n tool('revoke_customer_key', \"Revoke a child org's API key by prefix. Takes effect immediately.\", { id: z.string(), prefix: z.string() }, async (a) => {\n await client.reseller.revokeKey(a.id as string, a.prefix as string);\n return { revoked: a.prefix };\n });\n\n tool(\n 'erase_subject_data',\n 'IRREVERSIBLY crypto-erase a data subject\\'s consent records by their consent-receipt stamp (GDPR/CCPA deletion). Destroys the encryption key; the tamper-evident chain stays intact.',\n { cbid: z.string(), stamp: z.string() },\n (a) => client.consent.eraseSubject(a.cbid as string, a.stamp as string),\n );\n\n tool(\n 'export_subject_data',\n 'Export a data subject\\'s consent records (GDPR access/portability).',\n { cbid: z.string(), stamp: z.string() },\n (a) => client.consent.exportSubject(a.cbid as string, a.stamp as string),\n );\n\n // ---------------------------------------------------------------------------\n // Task 7: account-level banner library — reusable banner designs assignable\n // to many sites, decoupled from any single site's config.\n // ---------------------------------------------------------------------------\n\n tool('list_banners', 'List reusable banner designs in your org.', {}, () => client.banners.list());\n\n tool(\n 'create_banner',\n 'Create a reusable banner design.',\n { name: z.string(), json: z.record(z.unknown()).describe('A v2 BannerConfig.') },\n (a) => client.banners.create({ name: a.name as string, json: a.json as never }),\n );\n\n tool('get_banner', 'Get a banner design by id.', { id: z.string() }, (a) => client.banners.get(a.id as string));\n\n tool(\n 'update_banner',\n 'Update a banner design (name and/or config).',\n { id: z.string(), name: z.string().optional(), json: z.record(z.unknown()).optional() },\n (a) =>\n client.banners.update(a.id as string, {\n ...(a.name !== undefined ? { name: a.name as string } : {}),\n ...(a.json !== undefined ? { json: a.json as never } : {}),\n }),\n );\n\n tool('delete_banner', 'Delete a banner design (fails if assigned to sites).', { id: z.string() }, async (a) => {\n await client.banners.delete(a.id as string);\n return { ok: true };\n });\n\n tool(\n 'get_banner_assignments',\n 'The sites (cbids) a banner design is currently assigned to. Read-only.',\n { id: z.string() },\n (a) => client.banners.assignments(a.id as string),\n );\n\n tool(\n 'assign_banner',\n 'Set which sites (cbids) use a banner design.',\n { id: z.string(), cbids: z.array(z.string()) },\n (a) => client.banners.setAssignments(a.id as string, a.cbids as string[]),\n );\n\n tool('publish_banner', 'Publish a design live to all its assigned sites.', { id: z.string() }, (a) =>\n client.banners.publish(a.id as string),\n );\n}\n","/**\n * Structured, validated config tools for non-flow config domains (Task 3), plus\n * the install-snippet tool. Extracted from tools.ts as a cohesive group. Each tool\n * fetches the current SiteConfig, patches only its own domain, and PUTs it back.\n *\n * registerConfigTools is handed the same `tool` registrar that registerTools uses,\n * so registration order is preserved when it is called at the right point in the\n * sequence.\n */\n\nimport { z } from 'zod';\nimport type { CookieMunchClient } from '@cookiemunch/sdk';\nimport type { ToolRegistrar } from './tools.js';\n\nexport function registerConfigTools(tool: ToolRegistrar, client: CookieMunchClient): void {\n // Reusable zod schemas mirroring config.ts enums exactly\n const blockingModeEnum = z.enum(['auto', 'manual'] as const);\n const bannerModeEnum = z.enum(['opt-in', 'opt-out', 'off'] as const);\n const bannerTypeEnum = z.enum(['multilevel', 'inline', 'accept-decline', 'accept-only', 'do-not-sell'] as const);\n const bannerLayoutEnum = z.enum(['top', 'bottom', 'push-down', 'popup', 'overlay'] as const);\n const consentModeModeEnum = z.enum(['basic', 'advanced'] as const);\n\n const geoRuleSchema = z.object({\n match: z.object({\n countries: z.array(z.string()).optional(),\n regions: z.array(z.string()).optional(),\n }),\n mode: bannerModeEnum,\n });\n\n const setBlockingSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n mode: blockingModeEnum.describe('Blocking mode. auto = block non-consented scripts; manual = never block.'),\n ignoreSelectors: z.array(z.string()).optional().describe('CSS selectors for elements that should never be blocked.'),\n });\n\n tool(\n 'set_blocking',\n 'Configure the script-blocking mode for a site. Fetches the current config, patches only the blocking domain, and PUTs.',\n setBlockingSchema.shape,\n async (a) => {\n const { cbid: siteId, mode, ignoreSelectors } = setBlockingSchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n const existingBlocking = (cfg['blocking'] ?? {}) as Record<string, unknown>;\n const blocking: Record<string, unknown> = {\n ...existingBlocking,\n mode,\n ...(ignoreSelectors !== undefined ? { ignoreSelectors } : {}),\n };\n return client.sites.putConfig(siteId, { ...cfg, blocking });\n },\n );\n\n const setGeoRulesSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n geoRules: z.array(geoRuleSchema).describe('Ordered list of geo rules. First match wins.'),\n defaultMode: bannerModeEnum.optional().describe('Banner mode when no geo rule matches. Default: opt-in.'),\n });\n\n tool(\n 'set_geo_rules',\n 'Set geo-targeting rules for a site (which banner mode to show per country/region). Fetches the current config, patches only geoRules + defaultMode, and PUTs.',\n setGeoRulesSchema.shape,\n async (a) => {\n const { cbid: siteId, geoRules, defaultMode } = setGeoRulesSchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n return client.sites.putConfig(siteId, {\n ...cfg,\n geoRules,\n ...(defaultMode !== undefined ? { defaultMode } : {}),\n });\n },\n );\n\n tool(\n 'list_supported_languages',\n 'The languages the banner already has copy for, with their English name, their name in themselves, whether they read right to left, and whether they ship in the base embed or in the renderer. Check this before writing translations with set_languages — the ones listed here need none. Read-only.',\n {},\n () => client.languages(),\n );\n\n const identitySourceSchema = z.object({\n name: z.string().describe('What you call the identifier, e.g. \"customerId\" or \"email\".'),\n from: z.enum(['dataLayer', 'window', 'cookie', 'localStorage', 'query', 'meta']).describe('Where the page keeps it.'),\n key: z.string().describe('Dotted path for dataLayer/window; cookie, storage key, query parameter or meta name otherwise.'),\n hash: z.boolean().optional().describe('Default true: SHA-256 the trimmed, lowercased value in the browser. false for an opaque id.'),\n });\n const setIdentitySourcesSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n sources: z.array(identitySourceSchema).describe('In priority order; the first with a value becomes the consent record\\'s subjectId. Empty array removes them.'),\n });\n\n tool(\n 'set_identity_sources',\n 'Tell the web embed where a site keeps its signed-in customer (data layer, window object, cookie, local storage, query parameter or meta tag), so consent records carry that customer\\'s subjectId and can be read with GET /v1/subjects/:id/consent. Values are hashed in the browser unless a source sets hash:false. Fetches the current config, patches only identity, and PUTs.',\n setIdentitySourcesSchema.shape,\n async (a) => {\n const { cbid: siteId, sources } = setIdentitySourcesSchema.parse(a);\n const cfg = (await client.sites.getConfig(siteId)) as Record<string, unknown>;\n const { identity: _old, ...rest } = cfg;\n return client.sites.putConfig(siteId, sources.length > 0 ? { ...rest, identity: { sources } } : rest);\n },\n );\n\n const setLanguagesSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n defaultCulture: z.string().optional().describe('Default locale/culture code, e.g. \"en\", \"fr\". Stored in i18n.defaultCulture.'),\n autoDetect: z.union([z.boolean(), z.literal('page')]).optional().describe('true: follow the visitor\\'s browser language; false: defaultCulture for everyone; \"page\": follow the page\\'s <html lang>, then the browser. Stored in i18n.autoDetect.'),\n translations: z.record(z.record(z.unknown())).optional().describe('Per-locale banner copy overrides. Merged onto banner.i18n (locale keys preserved).'),\n overrides: z\n .record(z.object({ banner: z.record(z.string()).optional(), categories: z.record(z.object({ label: z.string().optional(), description: z.string().optional() })).optional() }))\n .optional()\n .describe('The site\\'s own copy per language, keyed by tag (de, pt-BR): { banner: { title, body, … }, categories: { <id>: { label, description } } }. Each language given replaces its entry in i18n.overrides; other languages are kept. Strings the site wrote are shown as written in any language without an override — stock translations never replace them.'),\n });\n\n tool(\n 'set_languages',\n 'Configure language/i18n settings for a site: default culture, auto-detect, and the site\\'s own copy per language (overrides). Fetches the current config, patches only i18n + banner.i18n, and PUTs.',\n setLanguagesSchema.shape,\n async (a) => {\n const { cbid: siteId, defaultCulture, autoDetect, translations, overrides } = setLanguagesSchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n const existingI18n = (cfg['i18n'] ?? {}) as Record<string, unknown>;\n const existingBanner = (cfg['banner'] ?? {}) as Record<string, unknown>;\n const existingBannerI18n = (existingBanner['i18n'] ?? {}) as Record<string, unknown>;\n const i18n: Record<string, unknown> = {\n ...existingI18n,\n ...(defaultCulture !== undefined ? { defaultCulture } : {}),\n ...(autoDetect !== undefined ? { autoDetect } : {}),\n ...(overrides !== undefined\n ? { overrides: { ...((existingI18n['overrides'] ?? {}) as Record<string, unknown>), ...overrides } }\n : {}),\n };\n const banner: Record<string, unknown> = {\n ...existingBanner,\n ...(translations !== undefined ? { i18n: { ...existingBannerI18n, ...translations } } : {}),\n };\n return client.sites.putConfig(siteId, { ...cfg, i18n, banner });\n },\n );\n\n const setConsentModeSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n enabled: z.boolean().describe('Whether Google Consent Mode signals are emitted.'),\n mode: consentModeModeEnum.describe('basic = gtag consent commands only; advanced = also passes redacted pings before consent.'),\n waitForUpdate: z.number().optional().describe('Milliseconds to wait for consent before gtag proceeds. Default 500.'),\n });\n\n tool(\n 'set_consent_mode',\n 'Configure Google Consent Mode for a site (enabled, basic/advanced, waitForUpdate). Fetches the current config, patches only consentMode, and PUTs.',\n setConsentModeSchema.shape,\n async (a) => {\n const { cbid: siteId, enabled, mode, waitForUpdate } = setConsentModeSchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n const existingCm = (cfg['consentMode'] ?? {}) as Record<string, unknown>;\n const consentMode: Record<string, unknown> = {\n ...existingCm,\n enabled,\n mode,\n ...(waitForUpdate !== undefined ? { waitForUpdate } : {}),\n };\n return client.sites.putConfig(siteId, { ...cfg, consentMode });\n },\n );\n\n const setAbExperimentSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n enabled: z.boolean().describe('Whether the A/B experiment is active.'),\n splitB: z.number().min(0).max(100).describe('Percentage of visitors (0–100) who see variant B.'),\n variantB: z.record(z.unknown()).optional().describe('Partial BannerConfig override for variant B visitors. Deep-merged over the base banner.'),\n });\n\n tool(\n 'set_ab_experiment',\n 'Configure the A/B banner experiment for a site (enabled, split percentage, variant B overrides). Fetches the current config, patches only experiment, and PUTs.',\n setAbExperimentSchema.shape,\n async (a) => {\n const { cbid: siteId, enabled, splitB, variantB } = setAbExperimentSchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n const existingExperiment = (cfg['experiment'] ?? {}) as Record<string, unknown>;\n const experiment: Record<string, unknown> = {\n ...existingExperiment,\n enabled,\n splitB,\n ...(variantB !== undefined ? { variantB } : {}),\n };\n return client.sites.putConfig(siteId, { ...cfg, experiment });\n },\n );\n\n const setConsentPolicySchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n expiryDays: z.number().optional().describe('Re-prompt visitors after this many days. Omit to disable time-based expiry.'),\n version: z.number().optional().describe('Bump this integer to force a re-prompt (e.g. when your cookie usage changes).'),\n });\n\n tool(\n 'set_consent_policy',\n 'Configure consent persistence policy for a site (expiry days, version bump). Fetches the current config, patches only consent, and PUTs.',\n setConsentPolicySchema.shape,\n async (a) => {\n const { cbid: siteId, expiryDays, version } = setConsentPolicySchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n const existingConsent = (cfg['consent'] ?? {}) as Record<string, unknown>;\n const consent: Record<string, unknown> = {\n ...existingConsent,\n ...(expiryDays !== undefined ? { expiryDays } : {}),\n ...(version !== undefined ? { version } : {}),\n };\n return client.sites.putConfig(siteId, { ...cfg, consent });\n },\n );\n\n const setBannerBasicsSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n type: bannerTypeEnum.optional().describe('Banner type. multilevel | inline | accept-decline | accept-only | do-not-sell.'),\n layout: bannerLayoutEnum.optional().describe('Banner layout. top | bottom | push-down | popup | overlay.'),\n preset: z\n .enum(['bar', 'box', 'full'] as const)\n .optional()\n .describe('Named shape that sets type/secondLayer (and layout for box): bar = slim one-row bar + categories in a modal; box = centred card + modal; full = every category in the first layer.'),\n secondLayer: z.enum(['expand', 'popup', 'modal'] as const).optional().describe('Where the categories open from an inline banner.'),\n density: z.enum(['comfortable', 'compact'] as const).optional().describe('compact = one-row bar from 760px wide.'),\n theme: z.record(z.unknown()).optional().describe('Partial ThemeTokens — deep-merged onto the existing banner theme. Includes `scrollbar`: { style: themed|thin|native|hidden, thumb?, thumbHover?, track?, width? 4–16, radius? 0–999 }.'),\n content: z.record(z.unknown()).optional().describe('Partial BannerContent — banner copy overrides (title, body, button labels, policyUrl, etc.).'),\n });\n\n tool(\n 'set_banner_basics',\n 'Configure v1 banner appearance for a site: preset, type, layout, second layer, density, theme tokens, and copy (content.preferencesTitle titles the preferences dialog). Fetches the current config, patches only those banner fields, and PUTs. Setting type or secondLayer (or layout under the box preset) without a preset removes the stored preset, which would otherwise re-derive them.',\n setBannerBasicsSchema.shape,\n async (a) => {\n const { cbid: siteId, type, layout, preset, secondLayer, density, theme, content } = setBannerBasicsSchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n const existingBanner = (cfg['banner'] ?? {}) as Record<string, unknown>;\n const existingTheme = (existingBanner['theme'] ?? {}) as Record<string, unknown>;\n const existingContent = (existingBanner['content'] ?? {}) as Record<string, unknown>;\n const banner: Record<string, unknown> = {\n ...existingBanner,\n ...(type !== undefined ? { type } : {}),\n ...(layout !== undefined ? { layout } : {}),\n ...(secondLayer !== undefined ? { secondLayer } : {}),\n ...(density !== undefined ? { density } : {}),\n ...(preset !== undefined ? { preset } : {}),\n ...(theme !== undefined ? { theme: { ...existingTheme, ...theme } } : {}),\n ...(content !== undefined ? { content: { ...existingContent, ...content } } : {}),\n };\n // The preset owns type/secondLayer; a hand-set shape without a preset replaces it.\n const owned = type !== undefined || secondLayer !== undefined || (layout !== undefined && banner['preset'] === 'box');\n if (preset === undefined && owned) delete banner['preset'];\n return client.sites.putConfig(siteId, { ...cfg, banner });\n },\n );\n\n const getInstallSnippetSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid). Must belong to your org.'),\n blockingMode: z\n .enum(['auto', 'manual'])\n .optional()\n .describe(\n '\"auto\" (default) blocks third-party scripts until consent is given; \"manual\" never blocks. These are the only two modes the runtime embed honors — any other value is rejected rather than silently downgraded.',\n ),\n culture: z.string().optional().describe('Language culture override, e.g. \"en\", \"fr\", \"de\".'),\n });\n\n tool(\n 'get_install_snippet',\n 'Get the exact <script> tag to install Cookie Munch on a site. Copy and paste this into the <head> of every page on the site.',\n getInstallSnippetSchema.shape,\n (a) => {\n const { cbid: siteId, blockingMode, culture } = getInstallSnippetSchema.parse(a);\n return client.sites.snippet(siteId, { blockingMode, culture });\n },\n );\n\n const previewBannerSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid). Must belong to your org.'),\n region: z.string().optional().describe('Region to show the banner for: a country or subdivision code (\"de\", \"us-ca\") or \"eu\".'),\n lang: z.string().optional().describe('Language to show it in, e.g. \"de\", \"pt-BR\".'),\n url: z.string().optional().describe(\"The page to open. Default: the site's registered domain.\"),\n ttlSeconds: z.number().int().min(1).max(3600).optional().describe('How long the link works, in seconds (default 900, max 3600).'),\n });\n\n tool(\n 'preview_banner',\n 'Get a short-lived link that shows the site’s banner exactly as a visitor in a given region and language sees it — it works from a headless browser too (bot suppression is bypassed), and nothing done on it is recorded as consent or counted in statistics.',\n previewBannerSchema.shape,\n (a) => {\n const { cbid: siteId, ...opts } = previewBannerSchema.parse(a);\n return client.sites.previewToken(siteId, opts);\n },\n );\n}\n","/**\n * MCP tools for the platform surfaces beyond the CMP: identity resolution, the Permission\n * Vault, profiles, subscriptions, assessments, data discovery, DSR fulfillment and AI\n * governance.\n *\n * Registered through the same ToolRegistrar as the core tools, so error wrapping and ordering\n * stay consistent. Descriptions spell out the CONSEQUENCE of each call (what it mutates, what\n * it gates) — an agent picking a tool from a one-line summary needs to know that `link` merges\n * two people permanently and that `activate` is consent-gated.\n */\n\nimport { z } from 'zod';\nimport type { CookieMunchClient, FulfillmentOp, Identifier } from '@cookiemunch/sdk';\nimport type { ToolRegistrar } from './tools.js';\n\nconst identifierSchema = z\n .array(z.object({ space: z.string(), value: z.string() }))\n .describe(\"A person's identifiers, e.g. [{space:'email_sha256', value:'<sha256 of the lowercased email>'}].\");\n\nconst ids = (a: Record<string, unknown>): Identifier[] => a.identifiers as Identifier[];\n\nexport function registerPlatformTools(tool: ToolRegistrar, client: CookieMunchClient): void {\n // ---- identity ----\n tool(\n 'resolve_identity',\n 'Resolve identifiers to the canonical subject id for one person, or null if unknown. Read-only.',\n { identifiers: identifierSchema },\n (a) => client.identity.resolve(ids(a)),\n );\n\n tool(\n 'get_identity_cluster',\n 'Every identifier currently stitched to one subject — what resolve_identity and link_identity have merged. Read-only.',\n { subjectId: z.string() },\n (a) => client.identity.cluster(a.subjectId as string),\n );\n\n tool(\n 'link_identity',\n 'Stitch identifiers together as ONE person and return the canonical subject id. This is a durable merge: if the identifiers already belong to different subjects, those subjects are combined and their consent and profile data are carried onto the survivor. Use resolve_identity if you only need to look someone up.',\n { identifiers: identifierSchema },\n (a) => client.identity.link(ids(a)),\n );\n\n // ---- permission vault ----\n tool(\n 'record_consent_decision',\n 'Record consent decisions against the resolved person in the Permission Vault. The latest decision per purpose wins, so this is how a withdrawal is registered too (allowed:false).',\n {\n identifiers: identifierSchema,\n decisions: z\n .array(z.object({\n purpose: z.string(),\n allowed: z.boolean(),\n legalBasis: z.string().optional(),\n jurisdiction: z.string().optional(),\n provenance: z.string().optional().describe('Where the decision came from, e.g. banner_accept_all, gpc, preference_center.'),\n collectedAt: z.number().optional().describe('Unix ms; latest per purpose wins.'),\n }))\n .describe('One entry per purpose.'),\n },\n (a) => client.vault.record(ids(a), a.decisions as never),\n );\n\n tool(\n 'get_consent_state',\n \"A person's current allow/deny per purpose, resolved across ALL their identifiers. Read-only.\",\n { identifiers: identifierSchema },\n (a) => client.vault.current(ids(a)),\n );\n\n tool(\n 'list_permits',\n \"A person's consent decisions in full: per purpose, allowed or not, with the legal basis, jurisdiction, where it was collected and when. The audit-grade view behind get_consent_state. Read-only.\",\n { identifiers: identifierSchema },\n (a) => client.vault.permits(ids(a)),\n );\n\n // ---- profile ----\n tool(\n 'get_profile',\n 'The unified profile for a person: their identifiers, current permits and first-party attributes. Read-only.',\n { identifiers: identifierSchema },\n (a) => client.profile.get(ids(a)),\n );\n\n tool(\n 'set_profile_attributes',\n 'Set first-party profile attributes for a person. A newer collectedAt wins over an older value.',\n {\n identifiers: identifierSchema,\n attributes: z\n .record(z.object({ value: z.string(), purpose: z.string().optional(), collectedAt: z.number().optional() }))\n .describe('Attribute name to value, e.g. { plan: { value: \"pro\" } }.'),\n },\n (a) => client.profile.setAttributes(ids(a), a.attributes as never),\n );\n\n tool(\n 'activate_profile',\n 'Get the attribute values usable for a purpose. CONSENT-GATED: returns {} when the person has not consented to that purpose, so it is safe to call before sending data to a marketing or AI destination.',\n { identifiers: identifierSchema, purpose: z.string().describe('The activation purpose, e.g. marketing.') },\n (a) => client.profile.activate(ids(a), a.purpose as string),\n );\n\n // ---- subscriptions ----\n tool(\n 'get_subscriptions',\n \"A subject's marketing subscription state (topics x channels). Read-only.\",\n { subjectId: z.string() },\n (a) => client.subscriptions.get(a.subjectId as string),\n );\n\n tool(\n 'set_subscription',\n 'Opt a subject in or out of one topic on one channel.',\n {\n subjectId: z.string(),\n topic: z.string(),\n channel: z.string().describe('email | sms | push | mail | phone, or a custom channel.'),\n optedIn: z.boolean(),\n },\n (a) => client.subscriptions.set(a.subjectId as string, a.topic as string, a.channel as string, a.optedIn as boolean),\n );\n\n tool(\n 'global_unsubscribe',\n 'Suppress every topic and channel for a subject WITHOUT erasing their per-topic choices, so a later resubscribe restores them.',\n { subjectId: z.string() },\n (a) => client.subscriptions.unsubscribeAll(a.subjectId as string),\n );\n\n tool(\n 'resubscribe',\n 'Lift a global unsubscribe. Restores the per-topic choices the subject had before it — it does not opt them in to anything they had not chosen.',\n { subjectId: z.string() },\n (a) => client.subscriptions.resubscribe(a.subjectId as string),\n );\n\n tool(\n 'get_subscription_activation',\n \"What to send downstream for a subject: per topic and channel, whether they are subscribed and which mapped downstream group (e.g. an ESP list id) that is. Honours a global unsubscribe. Read-only.\",\n {\n subjectId: z.string(),\n topics: z\n .array(\n z.object({\n code: z.string(),\n name: z.string().optional(),\n channels: z.array(z.string()),\n downstream: z.record(z.string(), z.string()).optional(),\n }),\n )\n .describe('The topics to resolve, usually the catalog from get_subscription_topics.'),\n },\n (a) => client.subscriptions.activation(a.subjectId as string, a.topics as never),\n );\n\n // ---- assessments ----\n tool(\n 'list_assessment_templates',\n 'The assessment templates available (DPIA, PIA, LIA, TIA, AI impact, vendor) and the questions each asks.',\n {},\n () => client.assessments.templates(),\n );\n\n tool(\n 'list_assessments',\n 'Every assessment in the org with its status: draft, in_review, approved or rejected. Read-only.',\n {},\n () => client.assessments.list(),\n );\n\n tool(\n 'autopopulate_assessment',\n 'Prefill an assessment from evidence you supply. Never overwrites a human answer, and stamps every filled answer with `source` so a reviewer can see where it came from. The assessment still needs a human to submit and approve it.',\n { id: z.string(), evidence: z.record(z.string(), z.unknown()).describe('questionId → answer.'), source: z.string().optional() },\n (a) => client.assessments.autoPopulate(a.id as string, a.evidence as Record<string, unknown>, a.source as string | undefined),\n );\n\n tool(\n 'start_assessment',\n 'Start an assessment from a template against a subject (a processing activity, system or vendor).',\n {\n template: z.string().describe('dpia | pia | lia | tia | ai_impact | vendor'),\n subject: z.string().describe('What is being assessed.'),\n },\n (a) => client.assessments.start(a.template as string, a.subject as string),\n );\n\n tool(\n 'get_assessment',\n 'An assessment with its derived risk score, completeness (what is still missing) and which SME owns each outstanding question.',\n { id: z.string() },\n (a) => client.assessments.get(a.id as string),\n );\n\n tool(\n 'answer_assessment_question',\n 'Record one answer on an assessment. Note: answering an APPROVED assessment reopens it to draft, because changing the facts invalidates the sign-off.',\n { id: z.string(), questionId: z.string(), value: z.union([z.string(), z.number(), z.boolean()]) },\n (a) => client.assessments.answer(a.id as string, a.questionId as string, a.value as string | number | boolean),\n );\n\n tool(\n 'autopopulate_assessment_from_data_map',\n 'Fill an assessment from the organisation’s latest data-map scan. Only facts the scan can establish are applied, a human’s existing answer is never overwritten, and machine answers are stamped with provenance so a reviewer can tell them apart.',\n { id: z.string() },\n (a) => client.assessments.autoPopulateFromMap(a.id as string),\n );\n\n tool(\n 'submit_assessment',\n 'Submit an assessment for review. Refused while any required question is unanswered.',\n { id: z.string() },\n (a) => client.assessments.submit(a.id as string),\n );\n\n // ---- discovery ----\n tool(\n 'get_data_map',\n 'The latest data map: which systems hold personal data, and which categories. Read-only.',\n {},\n () => client.discovery.getMap(),\n );\n\n tool(\n 'get_data_drift',\n 'What changed in the estate since the previous scan, and where the documented RoPA disagrees with what is actually there (undocumented systems, undeclared data categories, stale records).',\n {},\n () => client.discovery.drift(),\n );\n\n tool(\n 'get_ropa_drafts',\n 'Draft processing-activity records generated from the latest data map. These are DRAFTS: the factual fields come from the scan, the legal ones still need a human.',\n {},\n () => client.discovery.ropaDrafts(),\n );\n\n tool(\n 'get_discovery_evidence',\n 'The assessment answers the latest data map can actually support — only questions a scan can genuinely answer, never guesses. What autopopulate_assessment_from_data_map would apply. Read-only.',\n {},\n () => client.discovery.evidence(),\n );\n\n tool(\n 'plan_warehouse_enforcement',\n 'Plan warehouse-native policy (Snowflake masking / row access, Postgres RLS) from the latest data map. ' +\n 'Returns a PLAN and its revert — nothing is applied to the warehouse by calling this. Also reports what ' +\n 'it declined to do and why, so gaps are visible rather than silently missing.',\n {\n dialect: z.enum(['postgres', 'mysql', 'snowflake']),\n rules: z\n .array(\n z.object({\n id: z.string(),\n action: z.enum(['mask', 'restrict']),\n minSensitivity: z.enum(['personal', 'sensitive']).optional(),\n categories: z.array(z.string()).optional(),\n allowRoles: z.array(z.string()).optional(),\n purpose: z.string().optional(),\n subjectColumn: z.string().optional(),\n }),\n )\n .describe('A rule with neither minSensitivity nor categories matches nothing, by design.'),\n permitsTable: z.string().optional(),\n policyPrefix: z.string().optional(),\n },\n (a) =>\n client.discovery.planEnforcement(\n a.dialect as 'postgres' | 'mysql' | 'snowflake',\n a.rules as Parameters<typeof client.discovery.planEnforcement>[1],\n {\n ...(typeof a.permitsTable === 'string' ? { permitsTable: a.permitsTable } : {}),\n ...(typeof a.policyPrefix === 'string' ? { policyPrefix: a.policyPrefix } : {}),\n },\n ),\n );\n\n // ---- subscription topic catalog ----\n tool(\n 'get_subscription_topics',\n \"The org's marketing topic catalog — what a subject can subscribe to, and on which channels. Read-only.\",\n {},\n () => client.subscriptions.topics(),\n );\n\n tool(\n 'set_subscription_topics',\n 'Replace the subscription topic catalog. The list is authored whole, so anything omitted is removed.',\n {\n topics: z.array(\n z.object({\n code: z.string(),\n name: z.string().optional(),\n channels: z.array(z.string()),\n downstream: z.record(z.string()).optional(),\n }),\n ),\n },\n (a) => client.subscriptions.setTopics(a.topics as Parameters<typeof client.subscriptions.setTopics>[0]),\n );\n\n // ---- regulatory intelligence ----\n tool(\n 'get_regulatory_feed',\n 'The curated privacy-law dataset, optionally narrowed to the jurisdictions you operate in. ' +\n 'Carries reviewedAt: this ships with the product and is only as current as its last review. Not legal advice.',\n {\n jurisdictions: z\n .array(z.string())\n .optional()\n .describe(\"ISO codes, e.g. ['US-CA','BR']. A subdivision also matches its country; an EEA country matches the EU-wide regulations.\"),\n },\n (a) => client.regulatory.feed(a.jurisdictions as string[] | undefined),\n );\n\n tool(\n 'get_upcoming_regulations',\n 'Privacy laws taking effect within a horizon (default 180 days), soonest first. Same caveat as the feed: ' +\n 'a shipped dataset with a review date, not live legal research.',\n { days: z.number().int().positive().optional() },\n (a) => client.regulatory.upcoming(a.days as number | undefined),\n );\n\n // ---- DSR fulfillment ----\n tool(\n 'get_dsr_sla',\n 'The rights queue at a glance: how many requests are overdue, due today, due soon or on track, plus the overdue ids.',\n {},\n () => client.fulfillment.sla(),\n );\n\n tool(\n 'plan_dsr_fulfillment',\n 'Break a data-subject request into one fulfillment task per system. The tasks are then executed by the in-VPC agent inside the customer network — this call only queues the work.',\n {\n requestId: z.string(),\n systems: z\n .array(z.object({ system: z.string(), operation: z.enum(['locate', 'export', 'erase', 'optOut']) }))\n .describe('One entry per system to act on.'),\n includeHistorical: z.boolean().optional().describe('Also reprocess already-collected records, not just future ones.'),\n },\n (a) => client.fulfillment.plan(\n a.requestId as string,\n a.systems as Array<{ system: string; operation: FulfillmentOp }>,\n a.includeHistorical as boolean | undefined,\n ),\n );\n\n tool(\n 'list_dsar_executors',\n 'Systems connected to run part of a rights request themselves — an identity platform, a CRM, anything with a rights API. The in-VPC agent covers systems we cannot reach; these are the ones we can. Each carries the profile that describes its API. Never returns credentials. Read-only.',\n {},\n () => client.fulfillment.executors(),\n );\n\n tool(\n 'connect_dsar_executor',\n 'Connect a system that runs part of a rights request — an identity platform, a CRM, anything with a rights API. Cookie Munch is not specific to any platform: the `profile` describes that system\\'s API (paths, the words it uses for export/erase, its status vocabulary, how it signs webhooks), so connecting a new one needs no code. The secret key is stored encrypted and never returned; the response carries the webhook URL to configure in that system. Sub-tasks open automatically once a request reaches fulfilment (after identity verification), and completions are picked up by webhook or by polling.',\n {\n preset: z\n .string()\n .optional()\n .describe('Build profile (and, unless the preset takes baseUrl as a param, baseUrl) from a versioned preset instead of sending profile. list_dsar_executor_presets names them, what each needs, and which wait on another platform.'),\n presetVersion: z.number().int().optional().describe('With preset: the version to build. Default the latest.'),\n orgId: z.string().optional().describe(\"A preset param, when the preset's params list it.\"),\n atlasIdAppId: z.string().optional().describe(\"A preset param, when the preset's params list it: the identity platform's app id, so an erasure also revokes the app's grant.\"),\n system: z.string().optional().describe('The name this connection answers to in a plan, e.g. identity or crm. Required unless the preset has a default.'),\n baseUrl: z.string().optional().describe(\"The system's public https origin. Required unless the preset sets it.\"),\n secretKey: z.string().describe('Its API key, with whatever scope that system needs to export and erase a user.'),\n webhookSecret: z.string().optional().describe('Signing secret of its webhook endpoint. Optional: polling closes tasks without it.'),\n auto: z.boolean().optional().describe('Open a sub-task automatically when a request reaches fulfilment. Default true.'),\n profile: z\n .record(z.unknown())\n .optional()\n .describe('How to drive that system: { open, poll, statuses } required, plus optional subjectLookup, auth, idempotencyHeader, grantRevoke and webhook. Omit it when using preset.'),\n dryRun: z.boolean().optional().describe('Validate everything and answer the connection that would be created, storing nothing.'),\n },\n (a) => {\n const { dryRun, ...input } = a as Record<string, unknown>;\n return dryRun === true ? client.fulfillment.dryRunConnectExecutor(input as never) : client.fulfillment.connectExecutor(input as never);\n },\n );\n\n tool(\n 'list_dsar_executor_presets',\n \"The versioned executor presets: each one's name, params, latest version, and whether it is usable now or waits on another platform's API (waitingOn names the platform and its spec items). Also this org's canary address for connection tests. Read-only.\",\n {},\n () => client.fulfillment.executorPresets(),\n );\n\n tool(\n 'upgrade_dsar_executor_preset',\n \"Rebuild a connection's profile and address from its preset's latest version (or presetVersion), keeping its id, credentials, system and scope — or adopt a preset on a hand-written connection by naming it. Answers with a diff. Use dryRun first: the answer shows exactly what would change and nothing is stored.\",\n {\n id: z.string().describe('The connection id.'),\n preset: z.string().optional().describe('Only to adopt a preset on a connection that has none.'),\n presetVersion: z.number().int().optional(),\n orgId: z.string().optional(),\n atlasIdAppId: z.string().optional(),\n dryRun: z.boolean().optional().describe('Answer the diff and change nothing.'),\n },\n (a) => {\n const { id, dryRun, ...input } = a as Record<string, unknown>;\n return dryRun === true\n ? client.fulfillment.dryRunUpgradeExecutorPreset(id as string, input as never)\n : client.fulfillment.upgradeExecutorPreset(id as string, input as never);\n },\n );\n\n tool(\n 'test_dsar_executor_webhook',\n \"Would this webhook delivery from a connected system verify? Runs the receiver's exact check (headers, timestamp tolerance, prefix, HMAC) on headers and a raw body you supply, acts on nothing, and returns { verified, stage, reason } naming the stage that failed. `body` must be the raw request body string, byte for byte. Read-only.\",\n {\n id: z.string().describe('The connection id.'),\n headers: z.record(z.string()).describe('The delivery headers, e.g. its id, timestamp and signature headers.'),\n body: z.string().describe('The raw body exactly as it was signed.'),\n },\n (a) => client.fulfillment.testExecutorWebhook(a.id as string, { headers: a.headers as Record<string, string>, body: a.body as string }),\n );\n\n tool(\n 'list_dsar_executor_webhook_deliveries',\n \"The last 50 deliveries to a connected system's webhook, newest first, each with whether it verified and, if not, the stage and reason. Never includes the secret, the signature or the body (only a short hash and size). Read-only.\",\n { id: z.string().describe('The connection id.') },\n (a) => client.fulfillment.executorWebhookDeliveries(a.id as string),\n );\n\n tool(\n 'disconnect_dsar_executor',\n 'Disconnect a system. Its open sub-tasks stop being driven, and the stored credentials are deleted.',\n { id: z.string() },\n async (a) => {\n await client.fulfillment.disconnectExecutor(a.id as string);\n return { disconnected: a.id };\n },\n );\n\n tool(\n 'get_dsar_task',\n 'One fulfilment task in detail: its status history, what it means for the person (exported, no record, done without an export…), every request Cookie Munch made to the connected system on its behalf with the answer it got (credentials removed, kept 30 days), and whether that system was redeployed mid-request. Read-only. Use it to explain why a system answered the way it did.',\n { requestId: z.string(), taskId: z.string() },\n (a) => client.fulfillment.task(a.requestId as string, a.taskId as string),\n );\n\n tool(\n 'test_dsar_executor',\n 'Try a connected system against one email (or the org canary, canary: true) WITHOUT filing a rights request. Runs its subject lookup and returns the raw upstream answers (credentials removed) and a one-line verdict; code base_url_redirects means its baseUrl redirects and the verdict names where. The open step is rendered but not sent, unless open is true on an export, which opens and polls a real export once. An erasure is never sent by a test.',\n {\n id: z.string().describe('The connection id.'),\n email: z.string().optional().describe('The address to look up. Omit it with canary.'),\n canary: z.boolean().optional().describe(\"Use this org's canary address — no real person involved. A canary locate also updates the connection's health.\"),\n operation: z.enum(['locate', 'export', 'erase']).optional().describe('Default locate.'),\n open: z.boolean().optional().describe('For export only: open a real export and poll it once.'),\n },\n (a) =>\n client.fulfillment.testExecutor(a.id as string, {\n ...(typeof a.email === 'string' ? { email: a.email } : {}),\n ...(a.canary === true ? { canary: true } : {}),\n ...(a.operation ? { operation: a.operation as 'locate' | 'export' | 'erase' } : {}),\n ...(typeof a.open === 'boolean' ? { open: a.open } : {}),\n }),\n );\n\n tool(\n 'get_dsar_task_export',\n 'The export bundle a connected system produced for one sub-task, fetched from that system on demand. The platform keeps no copy.',\n { requestId: z.string(), taskId: z.string() },\n (a) => client.fulfillment.taskExport(a.requestId as string, a.taskId as string),\n );\n\n tool(\n 'get_dsr_fulfillment_status',\n 'Per-system fulfillment status for one request (\"n of m systems done\"), including which systems failed and why.',\n { requestId: z.string() },\n (a) => client.fulfillment.status(a.requestId as string),\n );\n\n // ---- AI governance ----\n tool(\n 'inspect_ai_prompt',\n 'Run a prompt or model response through the AI governance gateway BEFORE it reaches the model or the user. Returns action allow | redact | block plus the text to actually forward (redacted, or empty when blocked). Pass `consent` when the call concerns an identified person: data for a purpose they have not consented to is blocked outright.',\n {\n prompt: z.string(),\n purpose: z.string().describe('What the AI call is for, e.g. support or marketing.'),\n model: z.string().optional(),\n actor: z.string().optional(),\n direction: z.enum(['prompt', 'response']).optional(),\n consent: z.record(z.boolean()).optional().describe(\"The person's current permits, e.g. { marketing: false }.\"),\n },\n (a) => client.ai.inspect(a as never),\n );\n\n tool(\n 'get_ai_policy',\n 'The AI gateway policy: its rules, and what happens when no rule matches. `configured` is false while the built-in default applies. Read-only.',\n {},\n () => client.ai.getPolicy(),\n );\n\n tool(\n 'set_ai_policy',\n 'REPLACE the AI gateway policy. Takes effect on the next inspected prompt: a rule with action `block` stops matching calls, `redact` strips the matched data. `default` decides every call no rule matches — `block` fails closed.',\n {\n rules: z\n .array(\n z.object({\n id: z.string(),\n purposes: z.array(z.string()).optional(),\n categories: z.array(z.string()).optional(),\n minSensitivity: z.string().optional(),\n action: z.enum(['allow', 'redact', 'block']),\n reason: z.string().describe('Recorded on every audit entry this rule decides.'),\n }),\n )\n .describe('Evaluated in order; the first match decides.'),\n default: z.enum(['allow', 'redact', 'block']),\n },\n (a) => client.ai.setPolicy({ rules: a.rules, default: a.default }),\n );\n\n tool(\n 'register_ai_system',\n 'Declare an AI system so it appears in the inventory as registered rather than shadow. Idempotent on `id`.',\n { id: z.string(), name: z.string(), provider: z.string().optional(), purpose: z.string().optional() },\n (a) =>\n client.ai.registerSystem({\n id: a.id as string,\n name: a.name as string,\n ...(a.provider ? { provider: a.provider as string } : {}),\n ...(a.purpose ? { purpose: a.purpose as string } : {}),\n }),\n );\n\n tool('list_ai_systems', 'The AI systems declared with register_ai_system. Read-only.', {}, () => client.ai.systems());\n\n tool(\n 'get_ai_audit_log',\n 'Recent AI gateway decisions — what was allowed, redacted or blocked, and which rule decided. Read-only.',\n { limit: z.number().int().positive().max(500).optional() },\n (a) => client.ai.audit(a.limit as number | undefined),\n );\n\n tool(\n 'get_ai_inventory',\n 'Every AI system seen or declared, highest risk first, plus the SHADOW subset — models observed handling data that were never registered.',\n {},\n () => client.ai.inventory(),\n );\n\n tool(\n 'get_ai_lineage',\n 'Which data categories reach which model. Answers \"does anything send SSNs to a vendor model?\".',\n {},\n () => client.ai.lineage(),\n );\n}\n","/**\n * MCP tools for a site's identity and its integrations as a whole: rename/move a site, the\n * integration-health report, one-call provisioning, and partner trust links.\n */\n\nimport { z } from 'zod';\nimport type { CookieMunchClient } from '@cookiemunch/sdk';\nimport type { ToolRegistrar } from './tools.js';\n\nexport function registerIntegrationTools(tool: ToolRegistrar, client: CookieMunchClient): void {\n const updateSiteSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n domain: z.string().optional().describe('New domain, a bare hostname. A move clears verification: verify the new domain afterwards.'),\n name: z.string().nullable().optional().describe('Display name data subjects see on the rights page and in notices; null clears it.'),\n aliases: z.array(z.string()).optional().describe('Other hosts serving the site (replaces the list; [] clears it). Accepted consent origins, never verified claims.'),\n dryRun: z.boolean().optional().describe('Answer with the diff and its effects, storing nothing.'),\n });\n tool(\n 'update_site',\n 'Rename or move a site: its domain, display name and aliases. The cbid and the consent ledger stay. Moving the domain clears verification; the scanner and preview links follow the new domain. Use dryRun first to see the diff and every effect.',\n updateSiteSchema.shape,\n (a) => {\n const { cbid, dryRun, ...patch } = updateSiteSchema.parse(a);\n return client.sites.update(cbid, patch, { dryRun });\n },\n );\n\n tool(\n 'integration_health',\n 'Check every link a site’s privacy wiring depends on: the domain, the snippet and CSP on the live page, connected systems (base URL redirects, a test lookup), webhooks, partner links, Atlas cookie_consent, cookies needing review, the rights page, the mail provider and the request SLA. Each row has ok (null = could not check) and a fix hint. Read-only.',\n { cbid: z.string().optional().describe('Site identifier; optional when the org has one site.') },\n (a) => client.integrationHealth(a.cbid as string | undefined),\n );\n\n const provisionSchema = z.object({\n product: z.string().describe('A slug naming the product.'),\n domain: z.string().describe('The product’s domain (bare hostname).'),\n name: z.string().optional(),\n aliases: z.array(z.string()).optional(),\n cbid: z.string().optional().describe('Update this site instead of matching by domain.'),\n atlas: z.object({ secretKey: z.string(), cookieConsent: z.boolean().optional(), dsrWebhook: z.boolean().optional(), frontendApiHost: z.string().optional().describe('Your Atlas frontend API host (auth.example.com): declares the Atlas sign-in cookies on the site.') }).optional()\n .describe('Atlas secret key (sk_…) — used for this call only, never stored or returned.'),\n forumulate: z.object({ token: z.string(), orgId: z.string(), consent: z.boolean().optional(), executorKey: z.boolean().optional(), label: z.string().optional() }).optional()\n .describe('Forumulate org token — used for this call only, never stored or returned.'),\n rightsApi: z.object({ baseUrl: z.string(), secretKey: z.string(), profilePreset: z.string().optional() }).optional(),\n dryRun: z.boolean().optional().describe('Report what each step would do; write nothing on any platform. Run this first.'),\n });\n tool(\n 'provision_product',\n 'Wire a product’s privacy in one call: create or update the site, connected systems, the Atlas request-completion webhook and hosted-page consent banner, and Forumulate consent and executor key. Writes across three platforms; run with dryRun first. Idempotent: a re-run answers every step unchanged. No secret appears in the result.',\n provisionSchema.shape,\n (a) => {\n const { dryRun, ...input } = provisionSchema.parse(a);\n return client.provision(input, { dryRun });\n },\n );\n\n tool(\n 'list_site_partners',\n 'Which partner platforms (Forumulate, Atlas) receive this site’s consent events, each with its status, and which partners are on offer. Read-only.',\n { cbid: z.string() },\n (a) => client.sites.listPartners(a.cbid as string),\n );\n\n const linkSchema = z.object({\n cbid: z.string(),\n partner: z.enum(['forumulate', 'atlas']),\n externalId: z.string().describe('The partner’s id for the receiving account, e.g. a Forumulate organisation id.'),\n label: z.string().optional().describe('Shown with the partner name, e.g. \"docs\".'),\n events: z.array(z.enum(['consent.recorded', 'consent.withdrawn'])).optional(),\n dryRun: z.boolean().optional(),\n });\n tool(\n 'link_site_partner',\n 'Grant a partner platform this site’s consent events (they start flowing out to it). No secret is created: deliveries are signed with Cookie Munch’s own key. Idempotent.',\n linkSchema.shape,\n (a) => {\n const { cbid, dryRun, ...input } = linkSchema.parse(a);\n return client.sites.linkPartner(cbid, input, { dryRun });\n },\n );\n\n tool(\n 'unlink_site_partner',\n 'Revoke a partner link: no further consent events go to that partner.',\n { cbid: z.string(), linkId: z.string() },\n (a) => client.sites.unlinkPartner(a.cbid as string, a.linkId as string),\n );\n}\n","/**\n * MCP tools for the hosted rights page: read and write the draft, preview a write, publish,\n * list versions and roll back. Registered through the shared ToolRegistrar.\n *\n * Also the custom-hostname tools: every call is scoped to the key's org by the API; a hostname\n * is only ever routed after its owner proves it in DNS, so adding one cannot take over traffic.\n */\nimport { z } from 'zod';\nimport type { CookieMunchClient, RightsPageDocument } from '@cookiemunch/sdk';\nimport type { ToolRegistrar } from './tools.js';\n\n/** The hosted rights page as a document. */\nexport function registerRightsTools(tool: ToolRegistrar, client: CookieMunchClient): void {\n const cbid = { cbid: z.string().describe('Site identifier (cbid). Must belong to your org.') };\n const base = {\n baseUpdatedAt: z.union([z.number().int(), z.string(), z.null()]).optional()\n .describe('The draft’s updatedAt from your last read (null if it had none). If someone saved since, the write is refused with 409 draft_conflict and the current draft; omit to overwrite regardless.'),\n };\n const baseOpt = (a: Record<string, unknown>) => (a.baseUpdatedAt !== undefined ? { baseUpdatedAt: a.baseUpdatedAt as number | string | null } : {});\n tool('get_rights_page', 'Read the site’s rights page DRAFT (the default page until first saved), with warnings that would block publishing.', cbid, (a) => client.rightsPage.get(a.cbid as string));\n tool(\n 'update_rights_page',\n 'Replace the rights page draft with a full document (theme, sections, form, i18n, seo, customCss). Nothing goes live until publish_rights_page. Prefer patch_rights_page for small changes and preview_rights_page when unsure. Pass baseUpdatedAt (from get_rights_page) to avoid overwriting someone else’s save: a mismatch is 409 draft_conflict with the current draft.',\n { ...cbid, page: z.record(z.unknown()).describe('The whole RightsPage document (v: 1).'), ...base },\n (a) => client.rightsPage.put(a.cbid as string, a.page as unknown as RightsPageDocument, baseOpt(a)),\n );\n tool(\n 'patch_rights_page',\n 'Change part of the rights page draft: objects merge, arrays (sections, request types, fields) replace whole, null removes a field. baseUpdatedAt works as on update_rights_page (409 draft_conflict).',\n { ...cbid, patch: z.record(z.unknown()), ...base },\n (a) => client.rightsPage.patch(a.cbid as string, a.patch as Record<string, unknown>, baseOpt(a)),\n );\n tool(\n 'preview_rights_page',\n 'Validate a rights-page write WITHOUT saving: returns the document as it would be stored and any publish warnings. mode \"patch\" (default) or \"put\".',\n { ...cbid, page: z.record(z.unknown()), mode: z.enum(['patch', 'put']).optional() },\n (a) => client.rightsPage.dryRun(a.cbid as string, a.page as Record<string, unknown>, { mode: (a.mode as 'patch' | 'put' | undefined) ?? 'patch' }),\n );\n tool('get_published_rights_page', 'Read the LIVE rights page document (404 not_published while the site shows the default page).', cbid, (a) => client.rightsPage.getPublished(a.cbid as string));\n tool(\n 'publish_rights_page',\n 'Publish the draft as the next version: it goes live at once, to every visitor. Refused unless the page has exactly one form section and an enabled request type. Pass baseUpdatedAt (from get_rights_page) so only the draft you read goes live; without it, whatever the draft holds now is published, including someone else’s later edits. A mismatch is 409 draft_conflict with the current draft.',\n { ...cbid, ...base },\n (a) => client.rightsPage.publish(a.cbid as string, baseOpt(a)),\n );\n tool('list_rights_page_versions', 'Published versions of the rights page, newest first, each with publishedBy, publishedByEmail (null for an API key) and publishedVia.', cbid, (a) => client.rightsPage.versions(a.cbid as string));\n tool(\n 'rollback_rights_page',\n 'Publish an earlier version of the rights page again (as a new version): it goes live at once and REPLACES the current draft, so unpublished edits are lost and cannot be recovered (versions hold only published documents). Pass baseUpdatedAt (from get_rights_page) to refuse with 409 draft_conflict if anyone saved the draft since you read it.',\n { ...cbid, version: z.number().int().min(1), ...base },\n (a) => client.rightsPage.rollback(a.cbid as string, a.version as number, baseOpt(a)),\n );\n}\n\n/** Custom hostnames for a site's hosted rights page. */\nexport function registerRightsPageTools(tool: ToolRegistrar, client: CookieMunchClient): void {\n const site = z.object({ cbid: z.string().describe('Site identifier (cbid). Must belong to your org.') });\n const host = site.extend({\n hostname: z.string().describe('The custom hostname, e.g. privacy.example.com (unicode or punycode).'),\n });\n\n tool(\n 'list_rights_page_domains',\n \"List the custom hostnames serving a site's rights page, each with its status (pending_dns, verifying, issuing, active, error), the exact DNS records to create, and the plan's allowance.\",\n site.shape,\n (a) => client.rightsPage.listDomains(site.parse(a).cbid),\n );\n\n tool(\n 'add_rights_page_domain',\n \"Add a custom hostname for a site's rights page (e.g. privacy.example.com). Returns the DNS records the owner must create: a CNAME to this domain's own <token>.cname.cookiemunch.net (a CNAME to anything else never verifies it), or for an apex / flattened / proxied record the _cookiemunch TXT. Then call verify_rights_page_domain. Plans include Free 0, Starter 1, Pro 5, Scale unlimited.\",\n host.shape,\n (a) => {\n const { cbid, hostname } = host.parse(a);\n return client.rightsPage.addDomain(cbid, hostname);\n },\n );\n\n tool(\n 'verify_rights_page_domain',\n 'Check a custom hostname now: DNS while it is pending or in error, the HTTPS answer once it is routed. Returns the domain as it now stands; lastError and dnsSeen say what is missing.',\n host.shape,\n (a) => {\n const { cbid, hostname } = host.parse(a);\n return client.rightsPage.verifyDomain(cbid, hostname);\n },\n );\n\n tool(\n 'remove_rights_page_domain',\n 'Remove a custom hostname from a site\\'s rights page. It stops being served at once and its certificate is no longer renewed.',\n host.shape,\n async (a) => {\n const { cbid, hostname } = host.parse(a);\n await client.rightsPage.removeDomain(cbid, hostname);\n return { removed: hostname };\n },\n );\n}\n","/**\n * Consent-button parity findings, worded for an AI agent. A tool result that carries\n * `designWarnings` opens with them, before any JSON, because an agent acts on what it reads\n * first: it should come away knowing the Accept button is pushed harder than Reject, that\n * regulators call that a dark pattern, and exactly which reject style values fix it.\n */\n\nimport type { ButtonParityFinding, SuggestedRejectStyle } from '@cookiemunch/sdk';\n\nfunction whereText(f: ButtonParityFinding): string {\n const w = f.where ?? {};\n const bits = [\n f.layer === 'banner' ? 'first layer' : `${f.layer} layer`,\n w.view ? `view \"${w.view}\"` : '',\n w.variant && w.variant !== 'base' ? `variant ${w.variant}` : '',\n w.theme === 'dark' ? 'dark theme' : '',\n w.breakpoint === 'mobile' ? 'mobile' : '',\n w.language ? `language ${w.language}` : '',\n w.url ? w.url : '',\n ].filter(Boolean);\n return bits.join(', ');\n}\n\nfunction styleText(s: Partial<SuggestedRejectStyle>): string {\n const parts = [\n s.background ? `background ${s.background}` : '',\n s.color ? `text ${s.color}` : '',\n s.borderColor ? `border ${s.borderWidth ?? 1}px ${s.borderColor}` : '',\n s.fontSize ? `font ${s.fontSize}px` : '',\n s.fontWeight ? `weight ${s.fontWeight}` : '',\n s.width && s.height ? `${Math.round(s.width)}×${Math.round(s.height)}px` : '',\n ].filter(Boolean);\n return parts.join(', ');\n}\n\n/**\n * What the tool did, so the header can say it truthfully: an agent that reads \"saved\" after\n * a lint may skip the real write, or tell the user a change is live.\n */\nexport type DesignContext = 'saved' | 'preview' | 'lint' | 'read' | 'scan';\n\nconst CONTEXT_TEXT: Record<DesignContext, string> = {\n saved: 'The config was saved as sent; this is a warning, not an error.',\n preview: 'Nothing was saved: this is a preview of the write.',\n lint: 'Nothing was saved: this is a lint of a proposed config.',\n read: 'This describes the config as it is stored now; nothing was changed.',\n scan: 'This was measured on the live site by the last cookie scan; fix the banner, then scan again.',\n};\n\n/** The context of a tool's result: from the result itself where it says, else from the tool's name. */\nexport function designContext(tool: string, value: unknown): DesignContext {\n const v = (value && typeof value === 'object' ? value : {}) as { dryRun?: unknown; buttonParity?: unknown };\n if (tool === 'lint_banner_config') return 'lint';\n if (v.dryRun === true || tool.startsWith('preview_')) return 'preview';\n if (v.buttonParity && typeof v.buttonParity === 'object') return 'scan';\n if (/^(update|patch|set|edit|create|assign|apply)_/.test(tool)) return 'saved';\n return 'read';\n}\n\n/** The plain-words block that goes on top of a tool result. Empty string when there is nothing to say. */\nexport function designWarningText(findings: ButtonParityFinding[], suggested?: SuggestedRejectStyle[], context: DesignContext = 'read'): string {\n if (!Array.isArray(findings) || findings.length === 0) return '';\n const warnings = findings.filter((f) => f.severity === 'warning');\n const notices = findings.filter((f) => f.severity !== 'warning');\n const lines: string[] = [];\n if (warnings.length) {\n lines.push(\n `Design warning: the Accept button is more prominent than Reject (${warnings.length} issue${warnings.length === 1 ? '' : 's'}). ` +\n 'Regulators treat this as a dark pattern (EDPB Guidelines 03/2022, the EDPB cookie banner taskforce, CNIL). ' +\n `Make both buttons the same style. ${CONTEXT_TEXT[context]}`,\n );\n for (const f of warnings) lines.push(`- [${f.code}] (${whereText(f)}) ${f.detail} Fix: ${f.fix}`);\n }\n if (notices.length) {\n lines.push(\n `Design notice: ${notices.length} thing${notices.length === 1 ? '' : 's'} to check about how Reject compares with Accept.` +\n (warnings.length ? '' : ` ${CONTEXT_TEXT[context]}`),\n );\n for (const f of notices) lines.push(`- [${f.code}] (${whereText(f)}) ${f.detail} Fix: ${f.fix}`);\n }\n const fixes: Array<Partial<SuggestedRejectStyle>> =\n suggested && suggested.length\n ? suggested\n : findings.filter((f) => f.accept && f.reject).slice(0, 1).map((f) => ({ ...f.accept!, layer: f.layer, view: f.where?.view }));\n for (const s of fixes) {\n const style = styleText(s);\n if (style) {\n lines.push(\n `Suggested fix: style Reject all${s.view ? ` in view \"${s.view}\"` : ''} with ${style} — the same as Accept all. ` +\n 'In a flow design, give the Reject button the same `variant` and size as the Accept button.',\n );\n }\n }\n return lines.join('\\n');\n}\n\n/** Lead a tool result's text with its design warnings, when it has any. `tool` names what ran. */\nexport function withDesignWarnings(value: unknown, body: string, tool = ''): string {\n if (!value || typeof value !== 'object') return body;\n // A scan status carries them one level down, on what it measured of the live banner.\n const nested = (value as { buttonParity?: unknown }).buttonParity;\n const v = (nested && typeof nested === 'object' ? nested : value) as { designWarnings?: unknown; suggestedReject?: unknown };\n if (!Array.isArray(v.designWarnings) || v.designWarnings.length === 0) return body;\n const head = designWarningText(\n v.designWarnings as ButtonParityFinding[],\n Array.isArray(v.suggestedReject) ? (v.suggestedReject as SuggestedRejectStyle[]) : undefined,\n designContext(tool, value),\n );\n return head ? `${head}\\n\\n${body}` : body;\n}\n"],"mappings":";;;;AAQA,mBAAqC;;;ACDrC,iBAA0B;AAC1B,iBAA0D;;;ACA1D,IAAAA,cAAoC;;;ACEpC,iBAAkB;AAIX,SAAS,oBAAoB,MAAqB,QAAiC;AAExF,QAAM,mBAAmB,aAAE,KAAK,CAAC,QAAQ,QAAQ,CAAU;AAC3D,QAAM,iBAAiB,aAAE,KAAK,CAAC,UAAU,WAAW,KAAK,CAAU;AACnE,QAAM,iBAAiB,aAAE,KAAK,CAAC,cAAc,UAAU,kBAAkB,eAAe,aAAa,CAAU;AAC/G,QAAM,mBAAmB,aAAE,KAAK,CAAC,OAAO,UAAU,aAAa,SAAS,SAAS,CAAU;AAC3F,QAAM,sBAAsB,aAAE,KAAK,CAAC,SAAS,UAAU,CAAU;AAEjE,QAAM,gBAAgB,aAAE,OAAO;AAAA,IAC7B,OAAO,aAAE,OAAO;AAAA,MACd,WAAW,aAAE,MAAM,aAAE,OAAO,CAAC,EAAE,SAAS;AAAA,MACxC,SAAS,aAAE,MAAM,aAAE,OAAO,CAAC,EAAE,SAAS;AAAA,IACxC,CAAC;AAAA,IACD,MAAM;AAAA,EACR,CAAC;AAED,QAAM,oBAAoB,aAAE,OAAO;AAAA,IACjC,MAAM,aAAE,OAAO,EAAE,SAAS,yBAAyB;AAAA,IACnD,MAAM,iBAAiB,SAAS,0EAA0E;AAAA,IAC1G,iBAAiB,aAAE,MAAM,aAAE,OAAO,CAAC,EAAE,SAAS,EAAE,SAAS,0DAA0D;AAAA,EACrH,CAAC;AAED;AAAA,IACE;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB,OAAO,MAAM;AACX,YAAM,EAAE,MAAM,QAAQ,MA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kCAAkC;AAChD,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,QAAM,UAAU,QAAQ,IAAI,wBAAwB;AACpD,QAAM,SAAS,qBAAqB,EAAE,QAAQ,QAAQ,CAAC;AACvD,QAAM,YAAY,IAAI,kCAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAEhC;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,oCAAoC,GAAG;AACrD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["import_zod","import_zod","import_zod","import_zod","cbid"]}
1
+ {"version":3,"sources":["../src/bin.ts","../src/index.ts","../src/tools.ts","../src/tools-config.ts","../src/tools-platform.ts","../src/tools-integrations.ts","../src/tools-rights-page.ts","../src/design-warnings.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * stdio entry point for the Cookie Munch MCP server. Reads COOKIEMUNCH_API_KEY\n * (required) and COOKIEMUNCH_BASE_URL (optional) from the environment, builds the\n * server, and serves it over stdio — the transport Claude Desktop / Claude Code use\n * to spawn local MCP servers.\n */\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { createCookieMunchMcp } from './index.js';\n\nasync function main(): Promise<void> {\n const apiKey = process.env.COOKIEMUNCH_API_KEY;\n if (!apiKey) {\n console.error('COOKIEMUNCH_API_KEY is required.');\n process.exit(1);\n }\n const baseUrl = process.env.COOKIEMUNCH_BASE_URL ?? 'https://api.cookiemunch.net';\n const server = createCookieMunchMcp({ apiKey, baseUrl, ...(process.env.COOKIEMUNCH_USER_AGENT ? { userAgent: process.env.COOKIEMUNCH_USER_AGENT } : {}) });\n const transport = new StdioServerTransport();\n await server.connect(transport);\n // The process now stays alive serving MCP requests over stdio.\n}\n\nmain().catch((err) => {\n console.error('cookiemunch-mcp failed to start:', err);\n process.exit(1);\n});\n","/**\n * @cookiemunch/mcp — a Model Context Protocol server exposing the Cookie Munch\n * Developer API as MCP tools, built on @cookiemunch/sdk. The library entry exports\n * the tool registration (registerTools) and a server factory (createCookieMunchMcp);\n * the stdio bootstrap lives in bin.ts.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { createCookieMunch, type CookieMunchClient } from '@cookiemunch/sdk';\nimport { registerTools, type ToolServer } from './tools.js';\n\nexport { registerTools, type ToolServer, type ToolResult } from './tools.js';\n\n/** This package's version, sent in the default User-Agent (a test pins it to package.json). */\nexport const MCP_VERSION = '0.4.1';\n\nexport interface CookieMunchMcpOptions {\n apiKey: string;\n baseUrl: string;\n /** The `User-Agent` sent to the API. Default `cookiemunch-mcp/<version>`. */\n userAgent?: string;\n /** Inject a pre-built SDK client (e.g. for tests); otherwise one is created from apiKey/baseUrl. */\n client?: CookieMunchClient;\n}\n\n/** Build an McpServer with all Cookie Munch tools registered. Connect a transport to run it. */\nexport function createCookieMunchMcp(opts: CookieMunchMcpOptions): McpServer {\n const client = opts.client ?? createCookieMunch({ apiKey: opts.apiKey, baseUrl: opts.baseUrl, userAgent: opts.userAgent ?? `cookiemunch-mcp/${MCP_VERSION}` });\n const server = new McpServer({ name: 'cookiemunch', version: '1.0.0' });\n // McpServer structurally satisfies ToolServer; the cast bridges the SDK's broader\n // generic registerTool signature to our minimal, testable surface.\n registerTools(server as unknown as ToolServer, client);\n return server;\n}\n","/**\n * Tool registration for the Cookie Munch MCP server. registerTools wires the\n * @cookiemunch/sdk client onto an MCP server's registerTool API. It depends only\n * on a minimal ToolServer shape (structurally satisfied by McpServer), so the\n * registration logic is unit-testable against a fake server + mocked SDK client\n * without standing up a stdio transport.\n */\n\nimport { z, type ZodRawShape } from 'zod';\nimport type { CookieMunchClient } from '@cookiemunch/sdk';\nimport { registerConfigTools } from './tools-config.js';\nimport { registerPlatformTools } from './tools-platform.js';\nimport { registerIntegrationTools } from './tools-integrations.js';\nimport { registerRightsPageTools, registerRightsTools } from './tools-rights-page.js';\nimport { withDesignWarnings } from './design-warnings.js';\n// No @cookiemunch/core dependency: the v2 flow engine runs server-side behind the\n// /v1/sites/:cbid/flow endpoints, which the SDK client surfaces as getFlow/editFlow/\n// setFlow. The MCP server therefore bundles only the SDK.\n\nexport interface ToolResult {\n content: Array<{ type: 'text'; text: string }>;\n isError?: boolean;\n /** MCP's CallToolResult carries an open index signature; included for structural compatibility. */\n [key: string]: unknown;\n}\n\n/**\n * The `tool` registrar shape: registers one tool whose handler wraps SDK errors\n * into an isError result. Passed to sibling modules (e.g. tools-config.ts) so they\n * register into the same set while preserving order.\n */\nexport type ToolRegistrar = (\n name: string,\n description: string,\n inputSchema: ZodRawShape,\n run: (args: Record<string, unknown>) => Promise<unknown>,\n) => void;\n\n/** The slice of McpServer.registerTool we depend on (structurally compatible). */\nexport interface ToolServer {\n registerTool(\n name: string,\n config: { title?: string; description: string; inputSchema?: ZodRawShape },\n handler: (args: Record<string, unknown>) => Promise<ToolResult>,\n ): unknown;\n}\n\nfunction text(value: unknown, tool = ''): ToolResult {\n const body = typeof value === 'string' ? value : JSON.stringify(value, null, 2);\n // A config/design result whose Accept is pushed harder than its Reject says so FIRST, and\n // says truthfully whether anything was saved.\n return { content: [{ type: 'text', text: withDesignWarnings(value, body, tool) }] };\n}\n\nfunction fail(err: unknown): ToolResult {\n const message = err instanceof Error ? err.message : String(err);\n return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };\n}\n\nexport function registerTools(server: ToolServer, client: CookieMunchClient): void {\n /** Register a tool whose handler wraps SDK errors into an isError result. */\n const tool: ToolRegistrar = (name, description, inputSchema, run) => {\n server.registerTool(name, { description, inputSchema }, async (args) => {\n try {\n return text(await run(args), name);\n } catch (err) {\n return fail(err);\n }\n });\n };\n\n const cbid = { cbid: z.string().describe('Site identifier (cbid). Must belong to your org.') };\n const range = {\n from: z.number().optional().describe('Epoch-ms lower bound.'),\n to: z.number().optional().describe('Epoch-ms upper bound.'),\n };\n\n tool(\n 'whoami',\n 'Return the identity tied to the API key: orgId and name, the effective plan with planSource (org = its own subscription, account = covered by a higher plan another org on the same account pays for) and the features it unlocks, and the key\\u2019s scopes.',\n {},\n () => client.me(),\n );\n tool(\n 'list_account_orgs',\n 'The organisations on this key\\u2019s account, each with its effective plan and planSource, plus the per-account org cap (max/used) and the upgrade URL. Read-only; needs an unscoped key.',\n {},\n () => client.orgs.list(),\n );\n\n tool('list_sites', 'List all sites (cbids) in your organization.', {}, () => client.sites.list());\n tool('get_site', 'One site: its domain, cbid and verification status. Read-only.', { cbid: z.string() }, (a) =>\n client.sites.get(a.cbid as string),\n );\n tool(\n 'get_site_banner',\n 'Which banner design a site uses, or bannerId null when none is assigned. Read-only.',\n { cbid: z.string() },\n (a) => client.sites.banner(a.cbid as string),\n );\n\n tool(\n 'get_privacy_policy',\n \"Generate the site's privacy and cookie policy as Markdown, naming the org's data controller. Needs a contact email: the one given, else the org controller's, else the owner's. Read-only — nothing is published.\",\n { cbid: z.string(), contactEmail: z.string().optional(), effectiveDate: z.string().optional().describe('YYYY-MM-DD; defaults to today.'), jurisdictions: z.array(z.string()).optional() },\n (a) =>\n client.sites.policy(a.cbid as string, {\n ...(a.contactEmail ? { contactEmail: a.contactEmail as string } : {}),\n ...(a.effectiveDate ? { effectiveDate: a.effectiveDate as string } : {}),\n ...(a.jurisdictions ? { jurisdictions: a.jurisdictions as string[] } : {}),\n }),\n );\n\n tool(\n 'set_ad_personalization',\n \"Add or remove the separate 'personalised ads' choice on the site's live banner. With it on, accepting marketing no longer implies personalised ads unless `default` is true.\",\n { cbid: z.string(), enabled: z.boolean(), default: z.boolean().optional(), label: z.string().optional() },\n (a) =>\n client.sites.setAdPersonalization(a.cbid as string, {\n enabled: a.enabled as boolean,\n ...(a.default !== undefined ? { default: a.default as boolean } : {}),\n ...(a.label ? { label: a.label as string } : {}),\n }),\n );\n\n tool(\n 'analyze_session',\n 'Analyse a captured browsing session against the consent it ran under: which trackers fired after the visitor opted out, and what personal data left the page. Read-only.',\n {\n cbid: z.string(),\n har: z.unknown().optional().describe('A HAR export of the session.'),\n requests: z.array(z.unknown()).optional().describe('Or the requests directly.'),\n consent: z.record(z.string(), z.boolean()).optional(),\n gpc: z.boolean().optional(),\n },\n (a) =>\n client.sites.analyzeSession(a.cbid as string, {\n ...(a.har !== undefined ? { har: a.har } : {}),\n ...(a.requests ? { requests: a.requests as unknown[] } : {}),\n ...(a.consent ? { consent: a.consent as Record<string, boolean> } : {}),\n ...(a.gpc !== undefined ? { gpc: a.gpc as boolean } : {}),\n }),\n );\n\n tool(\n 'create_site',\n 'Create a new site. The cbid is auto-generated if you omit it.',\n { domain: z.string().describe('The site domain, e.g. example.com.'), cbid: z.string().optional().describe('Optional explicit cbid.') },\n (a) => client.sites.create({ domain: a.domain as string, ...(typeof a.cbid === 'string' ? { cbid: a.cbid } : {}) }),\n );\n\n tool(\n 'create_sites_bulk',\n 'Create up to 100 sites in one call. Partial success: each item reports ok or its own error, and a bad or duplicate item fails only itself.',\n {\n sites: z\n .array(z.object({ domain: z.string(), cbid: z.string().optional(), platform: z.string().optional() }))\n .min(1)\n .max(100),\n },\n (a) => client.sites.createBulk(a.sites as Array<{ domain: string; cbid?: string; platform?: string }>),\n );\n\n tool('get_site_config', 'Get the banner/consent configuration for a site.', { ...cbid }, (a) => client.sites.getConfig(a.cbid as string));\n\n tool(\n 'update_site_config',\n 'Replace (overwrite) the banner/consent configuration for a site via PUT. This is destructive, not a merge: any top-level SiteConfig field you omit from `config` reverts to its default rather than keeping its current value — unless keepUnspecified is true, in which case omitted top-level fields keep their stored value and only the fields you send are replaced (each whole). A top-level field sent as null reverts to its default. To change one setting, use patch_site_config instead — it merges server-side. Prefer the narrower set_* tools (set_blocking, set_banner_basics, etc.) when they cover your change.',\n {\n ...cbid,\n config: z.record(z.unknown()).describe('The full SiteConfig to write, not a patch. Without keepUnspecified, omitted top-level fields are NOT preserved from the current config.'),\n keepUnspecified: z.boolean().optional().describe('PUT ?keep=unspecified: keep the stored value of every top-level field `config` omits, instead of reverting it to its default.'),\n },\n (a) =>\n a.keepUnspecified === true\n ? client.sites.putConfig(a.cbid as string, a.config as Record<string, unknown>, { keep: 'unspecified' })\n : client.sites.putConfig(a.cbid as string, a.config as Record<string, unknown>),\n );\n\n tool(\n 'patch_site_config',\n 'Change part of a site\\'s banner/consent configuration. The patch is a JSON Merge Patch (RFC 7386) over the stored config server-side: any field you omit keeps its current value, and a field set to null is REMOVED (it falls back to its default) — e.g. { \"banner\": { \"i18n\": { \"es\": null } } } drops the Spanish override. This is the safe way to flip one setting, and it needs no read-modify-write. Use update_site_config only when you genuinely mean to replace the whole document.',\n { ...cbid, config: z.record(z.unknown()).describe('The subset of SiteConfig to change, e.g. { \"banner\": { \"showRightsLink\": true } }. Everything else is preserved; null removes a field.') },\n (a) => client.sites.patchConfig(a.cbid as string, a.config as Record<string, unknown>),\n );\n\n tool(\n 'preview_site_config',\n 'Preview a config change WITHOUT saving it: returns the config as it would be saved, a diff of every field that would change, and any warnings (plan-gated or unrecognised fields). mode \"patch\" (default) previews patch_site_config; mode \"put\" previews update_site_config, and its diff lists everything a replace would revert to its default (unless keepUnspecified is true). Use it before any write you are not sure of.',\n {\n ...cbid,\n config: z.record(z.unknown()).describe('The patch (or, with mode \"put\", the full config) to preview.'),\n mode: z.enum(['patch', 'put']).optional().describe('patch (default) merges; put replaces.'),\n keepUnspecified: z.boolean().optional().describe('With mode \"put\": preview update_site_config with keepUnspecified (omitted top-level fields keep their stored value).'),\n },\n (a) =>\n client.sites.dryRunConfig(a.cbid as string, a.config as Record<string, unknown>, {\n mode: (a.mode as 'patch' | 'put' | undefined) ?? 'patch',\n ...(a.keepUnspecified === true ? { keep: 'unspecified' as const } : {}),\n }),\n );\n\n tool(\n 'lint_banner_config',\n 'Check a banner config for consent-button parity WITHOUT saving it: is \"Accept all\" more prominent than \"Reject all\" anywhere — a brighter or more saturated colour, a bigger or bolder button, Reject styled as a link, hidden, below the fold, set apart, missing from the first layer, or worded to guilt-trip? Regulators (EDPB, CNIL) treat that as a dark pattern. Returns findings, a 0–100 score and the reject style that would match Accept. It checks exactly what the write would store: merged over the stored config as patch_site_config would, or with replace: true replaced as update_site_config would. Run it before writing any banner design.',\n {\n ...cbid,\n config: z.record(z.unknown()).describe('The proposed SiteConfig (or a partial one, or a v2 flow design).'),\n replace: z.boolean().optional().describe('Check what update_site_config (a full replace) would store, instead of what patch_site_config (a merge) would.'),\n },\n async (a) => {\n const r = await client.sites.lintConfig(a.cbid as string, a.config as Record<string, unknown>, a.replace === true ? { replace: true } : {});\n // A clean bill is said in words too, so an agent does not have to infer it from an empty array.\n return r.designWarnings.length === 0\n ? `No design warnings: Accept all and Reject all have equal weight on every surface checked (score ${r.score}). Nothing was saved.\\n\\n${JSON.stringify(r, null, 2)}`\n : r;\n },\n );\n\n tool(\n 'verify_consent_log',\n \"Verify a site's consent log has not been tampered with. Each record carries the hash of the one before it, so an edited, reordered or deleted record breaks the chain and this returns valid: false. This is the evidence behind a consent log — what you check when someone asks whether the record can be trusted, not just what it says.\",\n { ...cbid },\n (a) => client.consent.verify(a.cbid as string),\n );\n\n tool(\n 'get_consent_stats',\n 'Get aggregated per-day consent statistics for a site.',\n { ...cbid, ...range },\n (a) => client.consent.stats(a.cbid as string, { from: a.from as number | undefined, to: a.to as number | undefined }),\n );\n\n tool(\n 'get_consent_log',\n 'Get recent anonymised consent records for a site.',\n { ...cbid, ...range, limit: z.number().optional().describe('Max records to return (default 200).') },\n (a) =>\n client.consent.log(a.cbid as string, {\n from: a.from as number | undefined,\n to: a.to as number | undefined,\n limit: a.limit as number | undefined,\n }),\n );\n\n tool(\n 'get_subject_consent',\n \"One person's consent records across every site in the org — web, mobile and desktop — by the subjectId your apps attach. Consent data: needs the consent:read scope. Read-only.\",\n { subjectId: z.string() },\n (a) => client.subjects.consent(a.subjectId as string),\n );\n\n tool('list_dsar', 'List all Data Subject Access Requests for your organization.', {}, () => client.dsar.list());\n tool(\n 'update_dsar_executor',\n 'Change a connected system in place — its profile, address, credential or auto flag. Only what you pass changes; the stored credential is kept unless you give a new one. With dryRun, answers the connection as it would be and a diff, and changes nothing.',\n {\n id: z.string(),\n patch: z.record(z.unknown()),\n dryRun: z.boolean().optional().describe('Validate and diff without saving.'),\n },\n (a) =>\n a.dryRun === true\n ? client.fulfillment.dryRunUpdateExecutor(a.id as string, a.patch as Record<string, unknown>)\n : client.fulfillment.updateExecutor(a.id as string, a.patch as Record<string, unknown>),\n );\n tool(\n 'get_dsar',\n 'One rights request by id, including its status and the deadline it must be answered by.',\n { id: z.string() },\n (a) => client.dsar.get(a.id as string),\n );\n tool(\n 'erase_dsar_subject',\n 'For a deletion request that is past identity verification: erase the person’s consent records on one site, identified by their consent stamp. Irreversible. The erasure is noted on the request. If the response carries a warning, nothing was cryptographically erased — tell the user.',\n { id: z.string(), cbid: z.string(), stamp: z.string() },\n (a) => client.dsar.erase(a.id as string, a.cbid as string, a.stamp as string),\n );\n tool(\n 'export_dsar_subject',\n 'For an access or portability request that is past identity verification: the person’s consent records on one site, identified by their consent stamp. The export is noted on the request.',\n { id: z.string(), cbid: z.string(), stamp: z.string() },\n (a) => client.dsar.export(a.id as string, a.cbid as string, a.stamp as string),\n );\n tool(\n 'get_dsar_response_notice',\n 'The subject-facing response notice for a request, as plain text — what to send the person. Read-only; nothing is sent.',\n { id: z.string() },\n (a) => client.dsar.response(a.id as string),\n );\n\n tool(\n 'create_dsar',\n 'Open a new Data Subject Access Request.',\n {\n type: z.enum(['access', 'deletion', 'rectification', 'portability', 'opt-out']).describe('DSAR right being exercised.'),\n subjectEmail: z.string().describe('The data subject’s email.'),\n regulation: z.enum(['gdpr', 'ccpa']).describe('Governing regulation.'),\n note: z.string().optional().describe('Optional INTERNAL note; never shown to the data subject.'),\n messageToSubject: z.string().max(2000).optional().describe('The line the data subject reads in the response notice. Never an API key.'),\n test: z\n .boolean()\n .optional()\n .describe('Mark it as a test request: kept off the SLA board and deletable afterwards with delete_test_dsar.'),\n },\n (a) =>\n client.dsar.create({\n type: a.type as never,\n subjectEmail: a.subjectEmail as string,\n regulation: a.regulation as never,\n ...(typeof a.note === 'string' ? { note: a.note } : {}),\n ...(typeof a.messageToSubject === 'string' ? { messageToSubject: a.messageToSubject } : {}),\n ...(a.test === true ? { test: true } : {}),\n }),\n );\n\n tool(\n 'create_rights_link',\n 'Mint a signed, single-use link to a site’s hosted rights page for a person you know is signed in to that site. On the page their email is filled in and locked and the email-code step is skipped; the filed request is recorded as verified by their account. Give the link only to that person. Expires in 15 minutes by default (max 1 hour). Needs dsar:write.',\n {\n cbid: z.string().describe('Site identifier (cbid). Must belong to your org.'),\n email: z.string().describe('The signed-in person’s verified email address.'),\n userId: z.string().optional().describe('Your own account id for them; recorded on the request.'),\n rights: z\n .array(z.enum(['access', 'erasure', 'rectification', 'portability', 'restriction', 'objection', 'opt_out_sale', 'opt_out_targeted', 'limit_sensitive']))\n .min(1)\n .optional()\n .describe('Limit the link to these rights. Default: every right the page offers.'),\n ttlSeconds: z.number().int().min(60).max(3600).optional().describe('How long the link works, in seconds (default 900).'),\n },\n (a) =>\n client.rightsLinks.create(a.cbid as string, {\n subject: { email: a.email as string, ...(typeof a.userId === 'string' ? { userId: a.userId } : {}) },\n ...(Array.isArray(a.rights) ? { rights: a.rights as never } : {}),\n ...(typeof a.ttlSeconds === 'number' ? { ttlSeconds: a.ttlSeconds } : {}),\n }),\n );\n\n tool(\n 'delete_test_dsar',\n 'Delete a TEST rights request (one created with test: true), with its tasks and their upstream log. Real requests cannot be deleted and are refused. The deletion is recorded in the audit log.',\n { id: z.string().describe('The test request id.') },\n async (a) => {\n await client.dsar.delete(a.id as string);\n return { deleted: a.id };\n },\n );\n\n tool(\n 'mark_dsar_test',\n 'Mark a CLOSED rights request (completed or rejected) as a test request, after the fact — for trial requests filed before test: true existed. An open request is refused (request_not_closed), so a live obligation can never be relabelled. Recorded in the audit log; afterwards delete_test_dsar can remove it. Returns { request, changed }.',\n { id: z.string().describe('The closed request id.') },\n (a) => client.dsar.markTest(a.id as string),\n );\n\n tool(\n 'advance_dsar',\n 'Advance a DSAR to a new status (received → verifying → in_progress → completed, or rejected).',\n {\n id: z.string().describe('The DSAR id.'),\n toStatus: z.enum(['received', 'verifying', 'in_progress', 'completed', 'rejected']).describe('Target status.'),\n messageToSubject: z.string().max(2000).optional().describe('Replaces the line the data subject reads in the notice — for a rejection, why.'),\n },\n (a) =>\n typeof a.messageToSubject === 'string'\n ? client.dsar.advance(a.id as string, a.toStatus as never, { messageToSubject: a.messageToSubject })\n : client.dsar.advance(a.id as string, a.toStatus as never),\n );\n\n tool(\n 'export_consent',\n 'Export a site’s consent log as raw CSV text.',\n { ...cbid, ...range },\n (a) => client.consent.export(a.cbid as string, { from: a.from as number | undefined, to: a.to as number | undefined }),\n );\n\n tool(\n 'get_receipt',\n 'Fetch the signed consent receipt for a single consent record (by stamp).',\n { ...cbid, stamp: z.string().describe('The consent record stamp/id.') },\n (a) => client.consent.receipt(a.cbid as string, a.stamp as string),\n );\n\n tool('delete_site', 'Delete a site (cbid) and its configuration from your org.', { ...cbid }, async (a) => {\n await client.sites.delete(a.cbid as string);\n return { ok: true };\n });\n\n tool('list_vendors', 'List vendors (processors) with their computed risk scores.', {}, () => client.vendors.list());\n\n tool(\n 'create_vendor',\n 'Register a vendor (processor) and compute its risk score.',\n {\n name: z.string().describe('Vendor name.'),\n category: z.string().describe('Vendor category, e.g. analytics.'),\n dataShared: z.array(z.string()).describe('Categories of data shared with the vendor.'),\n dpaSigned: z.boolean().describe('Whether a Data Processing Agreement is signed.'),\n subprocessors: z.number().describe('Number of subprocessors.'),\n certifications: z.array(z.string()).describe('Compliance certifications, e.g. ISO27001.'),\n region: z.string().describe('Primary processing region, e.g. EU.'),\n },\n (a) =>\n client.vendors.create({\n name: a.name as string,\n category: a.category as string,\n dataShared: a.dataShared as string[],\n dpaSigned: a.dpaSigned as boolean,\n subprocessors: a.subprocessors as number,\n certifications: a.certifications as string[],\n region: a.region as string,\n }),\n );\n\n tool('list_ropa', 'List Records of Processing Activities (RoPA) for your organization.', {}, () => client.ropa.list());\n tool('export_ropa_csv', 'The org’s RoPA (GDPR Art. 30) as CSV. Read-only.', {}, () => client.ropa.exportCsv());\n\n tool(\n 'create_ropa',\n 'Create a Record of Processing Activity (RoPA) entry.',\n {\n name: z.string().describe('Activity name.'),\n purpose: z.string().describe('Purpose of processing.'),\n legalBasis: z\n .enum(['consent', 'contract', 'legal-obligation', 'vital-interests', 'public-task', 'legitimate-interests'])\n .describe('GDPR legal basis.'),\n dataCategories: z.array(z.string()).describe('Categories of personal data.'),\n recipients: z.array(z.string()).describe('Recipients of the data.'),\n retentionDays: z.number().describe('Retention period in days.'),\n crossBorderTransfer: z.boolean().describe('Whether data is transferred across borders.'),\n },\n (a) =>\n client.ropa.create({\n name: a.name as string,\n purpose: a.purpose as string,\n legalBasis: a.legalBasis as never,\n dataCategories: a.dataCategories as string[],\n recipients: a.recipients as string[],\n retentionDays: a.retentionDays as number,\n crossBorderTransfer: a.crossBorderTransfer as boolean,\n }),\n );\n\n tool('get_site_cookies', 'List the cookies discovered on a site, with their consent categories.', { ...cbid }, (a) =>\n client.sites.cookies(a.cbid as string),\n );\n\n tool(\n 'scan_site',\n 'Trigger a cookie crawl of a site (at most 90 s). Returns its scanId and state (queued). With wait: true, returns once it is done or failed — state, cookieCount, pagesVisited, durationMs, error. The stored list keeps cookies earlier crawls and real visits found; retire one the site no longer sets.',\n { ...cbid, wait: z.boolean().optional().describe('Wait for the scan to finish (up to 100 s) and return its outcome.') },\n async (a) => {\n let started: unknown;\n try {\n started = await client.sites.scan(a.cbid as string);\n } catch (err) {\n // Already running: with wait, wait for that one rather than fail.\n if (!a.wait || (err as { status?: number }).status !== 409) throw err;\n }\n return a.wait ? client.sites.waitForScan(a.cbid as string, { timeoutMs: 100_000 }) : started;\n },\n );\n\n tool(\n 'get_scan_status',\n 'Get a site’s last cookie scan: state (queued, scanning, done, failed), scanId, durationMs, cookieCount, pagesVisited and error when it failed.',\n { ...cbid, wait: z.number().min(0).max(60).optional().describe('Seconds (≤60) to wait for a running scan to settle before answering.') },\n (a) => (a.wait !== undefined ? client.sites.scanStatus(a.cbid as string, { wait: a.wait as number }) : client.sites.scanStatus(a.cbid as string)),\n );\n\n tool('get_ab_results', 'Get A/B banner experiment results (per variant) for a site.', { ...cbid }, (a) =>\n client.sites.ab(a.cbid as string),\n );\n\n tool('list_brand_kits', 'List reusable brand kits (colors/logo/typography) for your org.', {}, () => client.brandKits.list());\n\n tool('list_preferences', 'List configurable consent preferences/purposes for your org.', {}, () => client.preferences.list());\n\n tool('list_members', 'List the members of your organization.', {}, () => client.members.list());\n\n tool('list_api_keys', 'List the API keys for your organization (secrets are not returned), with each key\\u2019s scopes, expiry and when it was last used.', {}, () => client.keys.list());\n\n tool(\n 'api_key_report',\n 'Key hygiene: keys not used for a while, keys with broad (full or wide write) access, and keys expiring soon, each with the reason. Read-only.',\n {\n unusedDays: z.number().int().min(1).max(3650).optional().describe('Unused for at least this many days (default 90).'),\n expiringDays: z.number().int().min(1).max(3650).optional().describe('Expiring within this many days (default 14).'),\n },\n (a) => client.keys.report({ ...(a.unusedDays !== undefined ? { unusedDays: a.unusedDays as number } : {}), ...(a.expiringDays !== undefined ? { expiringDays: a.expiringDays as number } : {}) }),\n );\n\n tool('get_usage', 'Get the current usage/quota summary for your organization.', {}, () => client.usage());\n\n tool('list_webhooks', 'List webhook subscriptions for your organization.', {}, () => client.webhooks.list());\n\n tool(\n 'create_webhook',\n 'Create a webhook subscription. The response includes the signing secret (shown once).',\n {\n url: z.string().describe('HTTPS endpoint to deliver events to.'),\n events: z.array(z.string()).describe('Event names to subscribe to, e.g. consent.created.'),\n cbid: z.string().optional().describe('Optional site cbid to scope the subscription to.'),\n },\n (a) =>\n client.webhooks.create({\n url: a.url as string,\n events: a.events as string[],\n ...(typeof a.cbid === 'string' ? { cbid: a.cbid } : {}),\n }),\n );\n\n tool(\n 'roll_webhook_secret',\n 'Rotate a webhook subscription’s signing secret. The new secret is returned once; the receiving endpoint must be updated to verify with it.',\n { id: z.string() },\n (a) => client.webhooks.rollSecret(a.id as string),\n );\n\n tool(\n 'test_webhook',\n 'Send a signed test event to a webhook subscription now, and report what the endpoint answered.',\n { id: z.string() },\n (a) => client.webhooks.test(a.id as string),\n );\n\n tool(\n 'list_webhook_dead_letters',\n 'Webhook deliveries that failed every retry, newest first, with the last status or error. Read-only.',\n {},\n () => client.webhooks.deadLetters(),\n );\n\n tool(\n 'replay_webhook_dead_letter',\n 'Deliver a dead-lettered webhook event again, to the subscription as it is now.',\n { id: z.string() },\n (a) => client.webhooks.replayDeadLetter(a.id as string),\n );\n\n tool(\n 'update_webhook',\n 'Change a webhook subscription, or pause it with active:false (delivery stops; the subscription is kept). Only the fields given change. cbid: null widens it to every property in the org.',\n {\n id: z.string(),\n url: z.string().optional(),\n events: z.array(z.string()).optional(),\n cbid: z.string().nullable().optional(),\n active: z.boolean().optional(),\n },\n (a) =>\n client.webhooks.update(a.id as string, {\n ...(a.url !== undefined ? { url: a.url as string } : {}),\n ...(a.events !== undefined ? { events: a.events as string[] } : {}),\n ...(a.cbid !== undefined ? { cbid: a.cbid as string | null } : {}),\n ...(a.active !== undefined ? { active: a.active as boolean } : {}),\n }),\n );\n\n tool('delete_webhook', 'Delete a webhook subscription by id.', { id: z.string().describe('The webhook subscription id.') }, async (a) => {\n await client.webhooks.delete(a.id as string);\n return { ok: true };\n });\n\n tool(\n 'verify_site',\n 'Verify that your organization controls a domain by one of three challenge methods (dns / meta / file). Required to unlock consent export and signed receipts.',\n { ...cbid, method: z.enum(['dns', 'meta', 'file']).describe('Challenge method: dns (TXT record), meta (HTML tag), or file (/.well-known/cookiemunch-verify.txt).') },\n (a) => client.sites.verify(a.cbid as string, a.method as 'dns' | 'meta' | 'file'),\n );\n\n tool(\n 'get_verification_challenge',\n 'Exactly what to publish to prove control of a site’s domain: the DNS TXT record, the meta tag, the file, or installing the embed. Read-only — publish one, then call verify_site.',\n { cbid: z.string() },\n (a) => client.sites.verifyChallenge(a.cbid as string),\n );\n\n tool(\n 'match_site_brand',\n 'Extract theme colors and typography from a site\\'s homepage to suggest a matching brand theme for the consent banner.',\n { ...cbid },\n (a) => client.sites.brand(a.cbid as string),\n );\n\n // ---------------------------------------------------------------------------\n // V2 flow-editing tools\n // ---------------------------------------------------------------------------\n\n tool(\n 'get_flow',\n 'Get the v2 banner flow config for a site, including current views, categories, and any lint issues.',\n { cbid: z.string().describe('Site identifier (cbid).') },\n (a) => client.sites.getFlow(a.cbid as string),\n );\n\n tool(\n 'edit_flow',\n 'Apply a batch of structured edit operations to a site\\'s v2 banner flow. All ops are validated server-side and the final config must be lint-clean before it is saved.',\n {\n cbid: z.string().describe('Site identifier (cbid).'),\n operations: z\n .array(z.record(z.unknown()))\n .describe(\n 'Ordered list of ops. Each must have an \"op\" field: addView | removeView | addElement | setButtonTransition | addCustomCategory.',\n ),\n },\n (a) => client.sites.editFlow(a.cbid as string, a.operations as { op: string }[]),\n );\n\n tool(\n 'set_flow',\n 'Wholesale replace a site\\'s v2 banner flow with a complete config (e.g. from a template). Validated server-side before it is saved.',\n {\n cbid: z.string().describe('Site identifier (cbid).'),\n config: z.record(z.unknown()).describe('A full v2 FlowConfig object ({ v:2, flow, categories, ... }).'),\n },\n (a) => client.sites.setFlow(a.cbid as string, a.config as Record<string, unknown>),\n );\n\n // ---------------------------------------------------------------------------\n // Task 3: Structured, validated config tools for non-flow config domains, plus\n // the install-snippet tool. Extracted to tools-config.ts; registered here (in\n // order) via the shared `tool` registrar.\n // ---------------------------------------------------------------------------\n\n registerConfigTools(tool, client);\n\n registerPlatformTools(tool, client);\n registerIntegrationTools(tool, client);\n registerRightsTools(tool, client);\n registerRightsPageTools(tool, client);\n\n // ---------------------------------------------------------------------------\n // Task 4: org/member/brand-kit/preference writes + issue_api_key\n //\n // SECURITY: all operations are scoped to the key's org (the SDK and dev-api\n // derive the org from the API key — callers never pass an orgId). The org OWNER\n // is protected from role-change/removal by the dev-api. Roles are runtime-\n // validated on the server to {admin, member, viewer}.\n // ---------------------------------------------------------------------------\n\n tool(\n 'invite_member',\n 'Invite a person to your organization by email. role must be admin, member, or viewer. The org is derived from the API key — you cannot invite into a different org.',\n {\n email: z.string().describe('Email address of the person to invite.'),\n role: z.enum(['admin', 'member', 'viewer']).describe('Role to assign: admin, member, or viewer. owner is not assignable via API key.'),\n },\n (a) => client.members.invite(a.email as string, a.role as string),\n );\n\n tool(\n 'set_member_role',\n 'Change the role of a member in your organization. The org owner\\'s role cannot be changed.',\n {\n userId: z.string().describe('The userId of the member whose role to change.'),\n role: z.enum(['admin', 'member', 'viewer']).describe('New role: admin, member, or viewer.'),\n },\n (a) => client.members.setRole(a.userId as string, a.role as string),\n );\n\n tool(\n 'remove_member',\n 'Remove a member from your organization. The org owner cannot be removed.',\n {\n userId: z.string().describe('The userId of the member to remove.'),\n },\n async (a) => {\n await client.members.remove(a.userId as string);\n return { ok: true };\n },\n );\n\n tool(\n 'create_brand_kit',\n 'Create a reusable brand kit (colors, logo, typography) for your organization\\'s consent banners.',\n {\n name: z.string().describe('Display name for the brand kit.'),\n theme: z.record(z.unknown()).describe('Theme tokens (colors, fonts, etc.) as a JSON object.'),\n content: z.record(z.unknown()).optional().describe('Optional banner copy overrides.'),\n logoUrl: z.string().optional().describe('Optional URL for your org logo.'),\n customCss: z.string().optional().describe('Optional custom CSS string to inject into the banner.'),\n },\n (a) =>\n client.brandKits.create({\n name: a.name as string,\n theme: a.theme as Record<string, unknown>,\n ...(a.content !== undefined ? { content: a.content as Record<string, unknown> } : {}),\n ...(typeof a.logoUrl === 'string' ? { logoUrl: a.logoUrl } : {}),\n ...(typeof a.customCss === 'string' ? { customCss: a.customCss } : {}),\n }),\n );\n\n tool(\n 'delete_brand_kit',\n 'Delete a brand kit by id. The kit must belong to your organization (cross-org deletes are rejected).',\n {\n id: z.string().describe('The brand kit id to delete.'),\n },\n async (a) => {\n await client.brandKits.delete(a.id as string);\n return { ok: true };\n },\n );\n\n tool(\n 'save_preference',\n 'Save or update the consent preferences for an end-user (by subjectId) within your organization. purposes is a map of purpose-name → boolean.',\n {\n subjectId: z.string().describe('The end-user identifier (e.g. email or internal user id).'),\n purposes: z.record(z.boolean()).describe('Map of purpose names to consent values, e.g. { \"newsletter\": true, \"analytics\": false }.'),\n },\n (a) => client.preferences.save(a.subjectId as string, a.purposes as Record<string, boolean>),\n );\n\n tool(\n 'get_preference',\n 'One end-user’s saved preferences, by subjectId. Read-only.',\n { subjectId: z.string() },\n (a) => client.preferences.get(a.subjectId as string),\n );\n\n tool(\n 'issue_api_key',\n 'Issue a new API key. The secret is returned once and never again. Prefer the least privilege the job needs: `scopes` limits what it can do, `cbids` locks it to specific sites (it then cannot reach anything org-wide), `expiresInDays` retires it. Omitting all three mints a full-access, org-wide, non-expiring key.',\n {\n name: z.string().optional(),\n scopes: z.array(z.string()).optional(),\n cbids: z.array(z.string()).min(1).optional(),\n expiresInDays: z.number().int().min(1).max(3650).optional(),\n expiresAt: z.string().optional().describe('Or the exact expiry, an ISO date-time (not with expiresInDays).'),\n },\n (a) =>\n client.keys.issue({\n ...(a.expiresAt ? { expiresAt: a.expiresAt as string } : {}),\n ...(a.name ? { name: a.name as string } : {}),\n ...(a.scopes ? { scopes: a.scopes as string[] } : {}),\n ...(a.cbids ? { cbids: a.cbids as string[] } : {}),\n ...(a.expiresInDays !== undefined ? { expiresInDays: a.expiresInDays as number } : {}),\n }),\n );\n\n tool('revoke_api_key', 'Revoke an API key by its prefix. Takes effect immediately; anything using that key stops working.', { prefix: z.string() }, async (a) => {\n await client.keys.revoke(a.prefix as string);\n return { revoked: a.prefix };\n });\n\n tool(\n 'import_cookie_declaration',\n 'Read a cookie declaration exported from another CMP (OneTrust, Cookiebot, CookieYes, or any CSV/JSON with the same columns) and translate its categories into ours. Nothing is applied — it comes back for review, with the rows whose category could not be placed listed separately.',\n { cbid: z.string(), data: z.string().describe('The exported file, as text (CSV or JSON).') },\n (a) => client.sites.importDeclaration(a.cbid as string, a.data as string),\n );\n\n tool(\n 'apply_cookie_import',\n 'Import a cookie declaration exported from another CMP AND declare it: every row whose category mapped to ours and that has a purpose becomes a site declaration; the rest come back in `skipped` with the reason. Cookies the site already declared are kept unless overwrite is true. Prefer import_cookie_declaration first to review.',\n { cbid: z.string(), data: z.string().describe('The exported file, as text (CSV or JSON).'), overwrite: z.boolean().optional() },\n (a) => client.sites.applyImport(a.cbid as string, a.data as string, a.overwrite ? { overwrite: true } : undefined),\n );\n\n const declarationShape = {\n category: z.string().describe('necessary, preferences, statistics, marketing, or one of the site’s categories.custom ids.'),\n purpose: z.string().describe('What the cookie does, as visitors will read it — and the fallback for any language purposes lacks.'),\n purposes: z\n .record(z.string(), z.string().max(1000))\n .nullable()\n .optional()\n .describe('The purpose in other languages, keyed by BCP-47 tag: {\"es\": \"…\", \"pt-BR\": \"…\"}. The banner, data-cc=\"declaration\" and cookie-declaration.js draw the visitor’s language. null clears.'),\n provider: z.string().optional(),\n expiry: z.string().optional().describe('e.g. \"Session\", \"30 days\", \"1 year\" (the banner localises these forms).'),\n domain: z.string().optional(),\n pattern: z.boolean().optional().describe('Treat the name as a prefix wildcard (a trailing * does the same).'),\n };\n\n const dryRunArg = z\n .boolean()\n .optional()\n .describe('Store nothing: answer with the would-be declarations and a diff (added / removed / changed) to check first.');\n\n tool(\n 'declare_cookie',\n 'Declare what one of the site’s cookies is. Overrides the scanner, observed visits and the cookie database everywhere the declaration is shown (API, preference modal, data-cc=\"declaration\"). Use for the site’s own cookies the database cannot know. A name ending in * covers every cookie with that prefix.',\n { cbid: z.string(), name: z.string(), ...declarationShape, dryRun: dryRunArg },\n (a) => {\n const { cbid, name, dryRun, ...rest } = a as { cbid: string; name: string; dryRun?: boolean } & Record<string, unknown>;\n return client.sites.declareCookie(cbid, name, rest as never, dryRun ? { dryRun: true } : undefined);\n },\n );\n\n tool(\n 'declare_cookies',\n 'Declare many cookies at once. All-or-nothing: one invalid item refuses the whole request and nothing is saved. replace: true also removes every declaration the list does not name.',\n { cbid: z.string(), cookies: z.array(z.object({ name: z.string(), ...declarationShape })).max(500), replace: z.boolean().optional(), dryRun: dryRunArg },\n (a) => {\n const o = { ...(a.replace ? { replace: true } : {}), ...(a.dryRun ? { dryRun: true } : {}) };\n return client.sites.declareCookies(a.cbid as string, a.cookies as never, Object.keys(o).length ? o : undefined);\n },\n );\n\n tool(\n 'undeclare_cookie',\n 'Remove a cookie declaration; the scanned/observed classification applies again.',\n { cbid: z.string(), name: z.string(), dryRun: dryRunArg },\n async (a) => {\n if (a.dryRun) return client.sites.undeclareCookie(a.cbid as string, a.name as string, { dryRun: true });\n await client.sites.undeclareCookie(a.cbid as string, a.name as string);\n return { undeclared: a.name };\n },\n );\n\n tool(\n 'retire_cookie',\n 'Retire a cookie the site renamed or stopped setting: it leaves the banner’s cookie list, data-cc=\"declaration\" and the public feed, and stays listed for the owner with retired. A name ending in * retires every cookie with that prefix; the name must match a scanned, observed or declared cookie. If a crawl or a real visit sees it again afterwards, it is listed again with review: retired_but_seen.',\n {\n cbid: z.string(),\n name: z.string(),\n renamedTo: z.string().max(256).optional().describe('The cookie’s new name, if it was renamed.'),\n note: z.string().max(1000).optional(),\n dryRun: z.boolean().optional().describe('Store nothing: answer with the would-be retirement and list to check first.'),\n },\n (a) => {\n const input = { ...(a.renamedTo ? { renamedTo: a.renamedTo as string } : {}), ...(a.note ? { note: a.note as string } : {}) };\n return client.sites.retireCookie(a.cbid as string, a.name as string, input, a.dryRun ? { dryRun: true } : undefined);\n },\n );\n\n tool(\n 'unretire_cookie',\n 'Un-retire a cookie: it is listed again everywhere.',\n { cbid: z.string(), name: z.string(), dryRun: z.boolean().optional().describe('Store nothing: answer with what the list would be.') },\n async (a) => {\n if (a.dryRun) return client.sites.unretireCookie(a.cbid as string, a.name as string, { dryRun: true });\n await client.sites.unretireCookie(a.cbid as string, a.name as string);\n return { unretired: a.name };\n },\n );\n\n tool(\n 'list_cookie_presets',\n 'Declaration presets for the platforms a site is built on (atlas, forumulate, chatly, cookiemunch, referally): each one’s parameters, what it has declared on this site, and whether the vendor’s live manifest can be imported yet. Read-only.',\n { cbid: z.string() },\n (a) => client.sites.cookiePresets(a.cbid as string),\n );\n\n tool(\n 'apply_cookie_preset',\n 'Apply (or re-sync) a vendor preset: declares exactly what that platform writes — cookies and browser storage, with domain and lifetime — marked as declared by that vendor. Re-applying removes keys the vendor no longer writes. Names the owner declared are kept (skipped). Atlas needs frontendApiHost (and crossSubdomainCookies, default true); Chatly needs publicId.',\n {\n cbid: z.string(),\n vendor: z.enum(['atlas', 'forumulate', 'chatly', 'cookiemunch', 'referally']),\n frontendApiHost: z.string().optional().describe('Atlas: your frontend API host, e.g. auth.example.com.'),\n crossSubdomainCookies: z.boolean().optional().describe('Atlas: default true — the cookies live on the parent domain.'),\n publicId: z.string().optional().describe('Chatly: the channel public id (ch_web_…).'),\n dragging: z.boolean().optional().describe('Chatly: the launcher can be dragged (adds the drag-position key).'),\n category: z.string().optional().describe('Chatly: the category for its keys (default necessary). Referally: default the site\\'s referrals category, else marketing.'),\n cookieDomain: z.string().optional().describe('Referally: the domain aff.js sets referally_ctx on, e.g. .example.com. Default the site domain.'),\n cookieDays: z.number().int().min(1).max(400).optional().describe('Referally: how long the cookie lives, 1 to 400 days. Default 60.'),\n dryRun: dryRunArg,\n },\n (a) => {\n const params: Record<string, unknown> = {};\n for (const k of ['frontendApiHost', 'crossSubdomainCookies', 'publicId', 'dragging', 'category', 'cookieDomain', 'cookieDays'] as const) if (a[k] !== undefined) params[k] = a[k];\n return client.sites.applyCookiePreset(a.cbid as string, a.vendor as 'atlas', params, a.dryRun ? { dryRun: true } : undefined);\n },\n );\n\n tool(\n 'remove_cookie_preset',\n 'Remove every declaration a vendor preset made on this site.',\n { cbid: z.string(), vendor: z.enum(['atlas', 'forumulate', 'chatly', 'cookiemunch', 'referally']), dryRun: dryRunArg },\n (a) => client.sites.removeCookiePreset(a.cbid as string, a.vendor as 'atlas', a.dryRun ? { dryRun: true } : undefined),\n );\n\n tool(\n 'delete_observed_cookie',\n 'Remove every stored row of this name that crawls or real visits put in the site’s cookie list (e.g. a name someone reported that the site never sets). A declaration of it stays. If real visits keep reporting it, it comes back quarantined.',\n { cbid: z.string(), name: z.string(), dryRun: dryRunArg },\n async (a) => {\n if (a.dryRun) return client.sites.deleteObservedCookie(a.cbid as string, a.name as string, { dryRun: true });\n await client.sites.deleteObservedCookie(a.cbid as string, a.name as string);\n return { deleted: a.name };\n },\n );\n\n tool(\n 'purge_observed_cookies',\n 'Purge observed since T: remove every row a real visit first reported at or after `since` (and before `until`). Crawled rows and declarations stay. Rows from before provenance was recorded use their last-seen time, so run with dryRun first.',\n {\n cbid: z.string(),\n since: z.union([z.string(), z.number()]).describe('ISO-8601 time or epoch milliseconds.'),\n until: z.union([z.string(), z.number()]).optional().describe('Optional end of the window (exclusive).'),\n dryRun: dryRunArg,\n },\n (a) => client.sites.purgeObservedCookies(\n a.cbid as string,\n { since: a.since as string | number, ...(a.until !== undefined ? { until: a.until as string | number } : {}) },\n a.dryRun ? { dryRun: true } : undefined,\n ),\n );\n\n tool(\n 'get_blocked_pages',\n 'Pages where the embed could not load its banner renderer — the page’s Content Security Policy or Trusted Types policy refused it, so nobody there can be asked for consent. An empty list is healthy. Read-only.',\n { cbid: z.string() },\n (a) => client.sites.blocked(a.cbid as string),\n );\n\n tool(\n 'roll_api_key',\n 'Rotate an API key: returns a new secret once, with the same name, scopes, property lock and expiry. The old secret stops working immediately — if it is the key this server runs with, this server stops working too until it is reconfigured.',\n { prefix: z.string() },\n (a) => client.keys.roll(a.prefix as string),\n );\n\n tool(\n 'update_api_key',\n 'Rename an API key, replace its scopes or the properties it is locked to, or set or remove its expiry. Only the fields given change; the secret does not.',\n {\n prefix: z.string(),\n name: z.string().optional(),\n scopes: z.array(z.string()).optional(),\n cbids: z.array(z.string()).min(1).optional(),\n expiresAt: z.string().nullable().optional().describe('A new expiry (ISO date-time), or null to remove it.'),\n },\n (a) =>\n client.keys.update(a.prefix as string, {\n ...(a.expiresAt !== undefined ? { expiresAt: a.expiresAt as string | null } : {}),\n ...(a.name !== undefined ? { name: a.name as string } : {}),\n ...(a.scopes ? { scopes: a.scopes as string[] } : {}),\n ...(a.cbids ? { cbids: a.cbids as string[] } : {}),\n }),\n );\n\n // ---- organisation ----\n tool('get_org', 'Your organisation: id, name, plan and logo URL. Read-only.', {}, () => client.org.get());\n\n tool(\n 'update_org',\n 'Rename your organisation or set its logo. logoUrl: null removes the logo; upload an image with upload_asset to get a URL. Deleting the organisation is not possible here.',\n { name: z.string().min(1).optional(), logoUrl: z.string().nullable().optional() },\n (a) =>\n client.org.update({\n ...(a.name !== undefined ? { name: a.name as string } : {}),\n ...(a.logoUrl !== undefined ? { logoUrl: a.logoUrl as string | null } : {}),\n }),\n );\n\n // ---- the organisation's own mail provider for rights-request mail (BYOK) ----\n tool(\n 'get_mail_provider',\n 'Your own mail provider for rights-request mail (verification codes and other privacy-request mail), if any. Never returns the credential, only its last four characters. `sender` says whether verification codes are mailed through it now (own) or not at all (none) — there is no shared sender. Read-only.',\n {},\n () => client.org.mailProvider.get(),\n );\n\n tool(\n 'set_mail_provider',\n 'Connect your own mail provider for rights-request mail — recommended, so codes come from your own domain. Replaces the stored one. It carries mail only after test_mail_provider succeeds; every save clears that. Omit secret to keep the stored one (same provider only).',\n {\n provider: z.enum(['brevo', 'sendgrid', 'postmark', 'resend', 'ses', 'smtp']),\n fromEmail: z.string().describe('An address on a domain your provider has verified.'),\n fromName: z.string().max(100).nullable().optional(),\n replyTo: z.string().nullable().optional(),\n secret: z.string().optional().describe('API key (Brevo, SendGrid, Resend), server token (Postmark), secret access key (SES) or SMTP password. Write-only.'),\n ses: z.object({ region: z.string(), accessKeyId: z.string() }).optional().describe('Required for ses.'),\n smtp: z\n .object({ host: z.string(), port: z.union([z.literal(25), z.literal(465), z.literal(587), z.literal(2525)]), security: z.enum(['tls', 'starttls']), username: z.string() })\n .optional()\n .describe('Required for smtp. TLS is always required.'),\n },\n (a) => client.org.mailProvider.set(a as never),\n );\n\n tool(\n 'test_mail_provider',\n 'Send a test message through your own mail provider (never Cookie Munch’s) and report what it answered. Success marks the configuration verified, after which it carries all rights mail.',\n { to: z.string().optional().describe('Recipient. Default: the reply-to, else the from address.') },\n (a) => client.org.mailProvider.test(a.to as string | undefined),\n );\n\n tool(\n 'remove_mail_provider',\n 'Remove your own mail provider. Rights mail goes back to Cookie Munch’s shared sender, labelled as sending on your site’s behalf.',\n {},\n async () => {\n await client.org.mailProvider.remove();\n return { removed: true };\n },\n );\n\n // ---- the rights page's captcha: the customer's own keys, or off (Cookie Munch's own is never used there) ----\n const CAPTCHA_OFF = 'Off removes spam protection beyond the hidden spam-trap field, the rate limits and the email code: expect more spam requests. Own keys are recommended.';\n const captchaInput = {\n mode: z.enum(['own', 'off']).describe(`own: your own captcha provider keys (recommended). off: no captcha. ${CAPTCHA_OFF}`),\n provider: z.enum(['turnstile', 'hcaptcha', 'recaptcha_v2', 'recaptcha_v3']).optional().describe('Required for own.'),\n siteKey: z.string().optional().describe('Required for own: the public site key. List your rights-page hostnames on it at the provider.'),\n secret: z.string().optional().describe('The provider secret key. Write-only; never returned. Omit to keep the stored one (same provider).'),\n minScore: z.number().min(0.1).max(0.9).optional().describe('reCAPTCHA v3 only. Default 0.5.'),\n };\n const captchaBody = (a: Record<string, unknown>) => ({\n mode: a.mode as 'own' | 'off',\n ...(a.provider !== undefined ? { provider: a.provider as never } : {}),\n ...(a.siteKey !== undefined ? { siteKey: a.siteKey as string } : {}),\n ...(a.secret !== undefined ? { secret: a.secret as string } : {}),\n ...(a.minScore !== undefined ? { minScore: a.minScore as number } : {}),\n });\n\n tool(\n 'get_rights_captcha',\n 'The captcha on a site’s hosted rights page: its own setting, else the organisation default, else off (`source` says which). Never returns the secret. Read-only.',\n { cbid: z.string() },\n (a) => client.rightsCaptcha.get(a.cbid as string),\n );\n\n tool(\n 'set_rights_captcha',\n `Set a site’s rights-page captcha: your own Turnstile, hCaptcha or reCAPTCHA keys (recommended; the provider must accept the secret before it is saved), or off. ${CAPTCHA_OFF} Audited with the old and new mode.`,\n { cbid: z.string(), ...captchaInput },\n (a) => client.rightsCaptcha.set(a.cbid as string, captchaBody(a)),\n );\n\n tool(\n 'remove_rights_captcha',\n 'Remove a site’s own captcha setting: it inherits the organisation default again (or off). Returns the setting now in force.',\n { cbid: z.string() },\n (a) => client.rightsCaptcha.remove(a.cbid as string),\n );\n\n tool(\n 'get_rights_captcha_default',\n 'The organisation default captcha for its rights pages, used by every site without its own setting. Never returns the secret. Read-only.',\n {},\n () => client.org.rightsCaptcha.get(),\n );\n\n tool(\n 'set_rights_captcha_default',\n `Set the organisation default captcha for its rights pages: your own keys (recommended) or off. ${CAPTCHA_OFF}`,\n captchaInput,\n (a) => client.org.rightsCaptcha.set(captchaBody(a)),\n );\n\n tool(\n 'remove_rights_captcha_default',\n 'Remove the organisation default: sites without their own setting then have no captcha. Returns the setting now in force.',\n {},\n () => client.org.rightsCaptcha.remove(),\n );\n\n // ---- the sign-in provider rights requests are verified with (Clerk, Atlas, any JWKS issuer) ----\n const IDENTITY_NOTE = 'The JWKS is fetched and checked before anything is saved. The session token must carry the email and a verified-email claim (default email_verified) set to true (Clerk: add email: {{user.primary_email_address}} to the session token; Clerk documents no claim for whether that address is verified, so either add your own or set trustEmailClaim). oidc_jwt needs an audience or authorizedParties.';\n const identityInput = {\n type: z.enum(['clerk', 'atlas', 'oidc_jwt']).describe('clerk, atlas (Clerk-shaped), or oidc_jwt (any issuer that signs session JWTs with a published JWKS).'),\n issuer: z.string().describe('https URL exactly as in the token’s iss (Clerk: your Frontend API URL).'),\n jwksUrl: z.string().optional().describe('Required for oidc_jwt; clerk/atlas default to <issuer>/.well-known/jwks.json.'),\n audience: z.string().optional().describe('Expected aud. For oidc_jwt an audience or authorizedParties is required (a shared issuer mints tokens for every app).'),\n authorizedParties: z.array(z.string()).optional().describe('Your own origins (https://www.example.com) the token’s azp must be one of. Required for clerk and atlas; for oidc_jwt when there is no audience.'),\n emailClaim: z.string().optional().describe('Default email.'),\n emailVerifiedClaim: z.string().optional().describe('Default email_verified; must be exactly true.'),\n sessionCookieName: z.string().optional().describe('Default __session: the cookie the hosted page on your custom domain reads.'),\n trustEmailClaim: z.boolean().optional().describe('clerk/atlas only, default false. True: a token without the verified claim is accepted, its email claim taken as verified. Set only if every address your provider puts in that claim is verified.'),\n };\n const identityBody = (a: Record<string, unknown>) => {\n const out: Record<string, unknown> = { type: a.type, issuer: a.issuer };\n for (const k of ['jwksUrl', 'audience', 'authorizedParties', 'emailClaim', 'emailVerifiedClaim', 'sessionCookieName', 'trustEmailClaim']) if (a[k] !== undefined) out[k] = a[k];\n return out as never;\n };\n\n tool(\n 'get_rights_identity',\n 'The sign-in provider a site’s rights requests are verified with: its own setting, else the organisation default, else none (`source` says which). Read-only.',\n { cbid: z.string() },\n (a) => client.rightsIdentity.get(a.cbid as string),\n );\n\n tool(\n 'set_rights_identity',\n `Connect a site’s sign-in provider so a visitor signed in to the site is verified by their session, with no code mail. ${IDENTITY_NOTE} Audited.`,\n { cbid: z.string(), ...identityInput },\n (a) => client.rightsIdentity.set(a.cbid as string, identityBody(a)),\n );\n\n tool(\n 'remove_rights_identity',\n 'Remove a site’s own sign-in provider: it inherits the organisation default again (or none). Returns the setting now in force.',\n { cbid: z.string() },\n (a) => client.rightsIdentity.remove(a.cbid as string),\n );\n\n tool(\n 'get_rights_identity_default',\n 'The organisation default sign-in provider for its rights requests, used by every site without its own. Read-only.',\n {},\n () => client.org.rightsIdentity.get(),\n );\n\n tool(\n 'set_rights_identity_default',\n `Set the organisation default sign-in provider for its rights requests. ${IDENTITY_NOTE}`,\n identityInput,\n (a) => client.org.rightsIdentity.set(identityBody(a)),\n );\n\n tool(\n 'remove_rights_identity_default',\n 'Remove the organisation default sign-in provider. Returns the setting now in force.',\n {},\n () => client.org.rightsIdentity.remove(),\n );\n\n tool(\n 'get_audit_log',\n 'The organisation’s audit log, newest first: administrative changes made in the dashboard or through the API, and who made them. Read-only.',\n { limit: z.number().int().min(1).max(500).optional() },\n (a) => client.audit(a.limit as number | undefined),\n );\n\n tool(\n 'upload_asset',\n 'Upload an image — a banner logo — and get its public URL. data is base64 (a data: URL also works); PNG, JPEG, WebP, GIF or SVG, up to 1,000,000 bytes.',\n {\n data: z.string(),\n contentType: z.enum(['image/png', 'image/jpeg', 'image/webp', 'image/gif', 'image/svg+xml']),\n },\n (a) => client.assets.upload({ data: a.data as string, contentType: a.contentType as 'image/png' }),\n );\n\n tool(\n 'delete_asset',\n 'Delete a stored image by its URL (or file name). Only your own organisation’s images can be named.',\n { url: z.string().describe('The URL upload_asset returned, or just its file name.') },\n async (a) => {\n await client.assets.delete(a.url as string);\n return { deleted: a.url };\n },\n );\n\n // ---- reseller ----\n tool(\n 'list_customers',\n 'The child orgs this reseller has provisioned, with pooled usage against the reseller plan’s cap. Read-only.',\n {},\n () => client.reseller.list(),\n );\n\n tool('get_customer', 'One child org: its controller details and usage. Read-only.', { id: z.string() }, (a) =>\n client.reseller.get(a.id as string),\n );\n\n tool(\n 'provision_customer',\n 'Create a new child org under this reseller. With `mintKey`, its first API key is returned once. Counts toward the reseller plan’s pooled limits.',\n {\n name: z.string(),\n ownerEmail: z.string().optional(),\n delegatedAccess: z.boolean().optional().describe('Whether this reseller may act inside the child.'),\n mintKey: z.boolean().optional(),\n keyScopes: z.array(z.string()).optional(),\n },\n (a) =>\n client.reseller.create({\n name: a.name as string,\n ...(a.ownerEmail ? { ownerEmail: a.ownerEmail as string } : {}),\n ...(a.delegatedAccess !== undefined ? { delegatedAccess: a.delegatedAccess as boolean } : {}),\n ...(a.mintKey !== undefined ? { mintKey: a.mintKey as boolean } : {}),\n ...(a.keyScopes ? { keyScopes: a.keyScopes as string[] } : {}),\n }),\n );\n\n tool(\n 'update_customer',\n 'Change a child org’s status, delegated access or DSAR routing. `dsarRouting: null` clears the override.',\n {\n id: z.string(),\n status: z.enum(['active', 'suspended']).optional(),\n delegatedAccess: z.boolean().optional(),\n dsarRouting: z.enum(['reseller', 'child']).nullable().optional(),\n },\n (a) =>\n client.reseller.update(a.id as string, {\n ...(a.status ? { status: a.status as 'active' | 'suspended' } : {}),\n ...(a.delegatedAccess !== undefined ? { delegatedAccess: a.delegatedAccess as boolean } : {}),\n ...(a.dsarRouting !== undefined ? { dsarRouting: a.dsarRouting as 'reseller' | 'child' | null } : {}),\n }),\n );\n\n // Suspend only. The API's purge option hard-deletes a customer org and all of its data;\n // that is not something to leave one agent call away, so this tool cannot pass it.\n tool(\n 'suspend_customer',\n 'Suspend a child org: it stops ingesting consent and its keys stop working, and it can be reactivated with update_customer. Its data is kept. (Permanent deletion is deliberately not available here.)',\n { id: z.string() },\n async (a) => {\n await client.reseller.deprovision(a.id as string);\n return { suspended: a.id };\n },\n );\n\n tool('list_customer_keys', \"A child org's API key prefixes. Never the secrets. Read-only.\", { id: z.string() }, (a) =>\n client.reseller.listKeys(a.id as string),\n );\n\n tool(\n 'issue_customer_key',\n \"Mint an API key for a child org. The secret is returned once. Prefer scopes and a property lock over a full-access key.\",\n { id: z.string(), name: z.string().optional(), scopes: z.array(z.string()).optional(), cbids: z.array(z.string()).min(1).optional() },\n (a) =>\n client.reseller.mintKey(a.id as string, {\n ...(a.name ? { name: a.name as string } : {}),\n ...(a.scopes ? { scopes: a.scopes as string[] } : {}),\n ...(a.cbids ? { cbids: a.cbids as string[] } : {}),\n }),\n );\n\n tool('revoke_customer_key', \"Revoke a child org's API key by prefix. Takes effect immediately.\", { id: z.string(), prefix: z.string() }, async (a) => {\n await client.reseller.revokeKey(a.id as string, a.prefix as string);\n return { revoked: a.prefix };\n });\n\n tool(\n 'erase_subject_data',\n 'IRREVERSIBLY crypto-erase a data subject\\'s consent records by their consent-receipt stamp (GDPR/CCPA deletion). Destroys the encryption key; the tamper-evident chain stays intact.',\n { cbid: z.string(), stamp: z.string() },\n (a) => client.consent.eraseSubject(a.cbid as string, a.stamp as string),\n );\n\n tool(\n 'export_subject_data',\n 'Export a data subject\\'s consent records (GDPR access/portability).',\n { cbid: z.string(), stamp: z.string() },\n (a) => client.consent.exportSubject(a.cbid as string, a.stamp as string),\n );\n\n // ---------------------------------------------------------------------------\n // Task 7: account-level banner library — reusable banner designs assignable\n // to many sites, decoupled from any single site's config.\n // ---------------------------------------------------------------------------\n\n tool('list_banners', 'List reusable banner designs in your org.', {}, () => client.banners.list());\n\n tool(\n 'create_banner',\n 'Create a reusable banner design.',\n { name: z.string(), json: z.record(z.unknown()).describe('A v2 BannerConfig.') },\n (a) => client.banners.create({ name: a.name as string, json: a.json as never }),\n );\n\n tool('get_banner', 'Get a banner design by id.', { id: z.string() }, (a) => client.banners.get(a.id as string));\n\n tool(\n 'update_banner',\n 'Update a banner design (name and/or config).',\n { id: z.string(), name: z.string().optional(), json: z.record(z.unknown()).optional() },\n (a) =>\n client.banners.update(a.id as string, {\n ...(a.name !== undefined ? { name: a.name as string } : {}),\n ...(a.json !== undefined ? { json: a.json as never } : {}),\n }),\n );\n\n tool('delete_banner', 'Delete a banner design (fails if assigned to sites).', { id: z.string() }, async (a) => {\n await client.banners.delete(a.id as string);\n return { ok: true };\n });\n\n tool(\n 'get_banner_assignments',\n 'The sites (cbids) a banner design is currently assigned to. Read-only.',\n { id: z.string() },\n (a) => client.banners.assignments(a.id as string),\n );\n\n tool(\n 'assign_banner',\n 'Set which sites (cbids) use a banner design.',\n { id: z.string(), cbids: z.array(z.string()) },\n (a) => client.banners.setAssignments(a.id as string, a.cbids as string[]),\n );\n\n tool('publish_banner', 'Publish a design live to all its assigned sites.', { id: z.string() }, (a) =>\n client.banners.publish(a.id as string),\n );\n}\n","/**\n * Structured, validated config tools for non-flow config domains (Task 3), plus\n * the install-snippet tool. Extracted from tools.ts as a cohesive group. Each tool\n * fetches the current SiteConfig, patches only its own domain, and PUTs it back.\n *\n * registerConfigTools is handed the same `tool` registrar that registerTools uses,\n * so registration order is preserved when it is called at the right point in the\n * sequence.\n */\n\nimport { z } from 'zod';\nimport type { CookieMunchClient } from '@cookiemunch/sdk';\nimport type { ToolRegistrar } from './tools.js';\n\nexport function registerConfigTools(tool: ToolRegistrar, client: CookieMunchClient): void {\n // Reusable zod schemas mirroring config.ts enums exactly\n const blockingModeEnum = z.enum(['auto', 'manual'] as const);\n const bannerModeEnum = z.enum(['opt-in', 'opt-out', 'off'] as const);\n const bannerTypeEnum = z.enum(['multilevel', 'inline', 'accept-decline', 'accept-only', 'do-not-sell'] as const);\n const bannerLayoutEnum = z.enum(['top', 'bottom', 'push-down', 'popup', 'overlay'] as const);\n const consentModeModeEnum = z.enum(['basic', 'advanced'] as const);\n\n const geoRuleSchema = z.object({\n match: z.object({\n countries: z.array(z.string()).optional(),\n regions: z.array(z.string()).optional(),\n }),\n mode: bannerModeEnum,\n });\n\n const setBlockingSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n mode: blockingModeEnum.describe('Blocking mode. auto = block non-consented scripts; manual = never block.'),\n ignoreSelectors: z.array(z.string()).optional().describe('CSS selectors for elements that should never be blocked.'),\n });\n\n tool(\n 'set_blocking',\n 'Configure the script-blocking mode for a site. Fetches the current config, patches only the blocking domain, and PUTs.',\n setBlockingSchema.shape,\n async (a) => {\n const { cbid: siteId, mode, ignoreSelectors } = setBlockingSchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n const existingBlocking = (cfg['blocking'] ?? {}) as Record<string, unknown>;\n const blocking: Record<string, unknown> = {\n ...existingBlocking,\n mode,\n ...(ignoreSelectors !== undefined ? { ignoreSelectors } : {}),\n };\n return client.sites.putConfig(siteId, { ...cfg, blocking });\n },\n );\n\n const setGeoRulesSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n geoRules: z.array(geoRuleSchema).describe('Ordered list of geo rules. First match wins.'),\n defaultMode: bannerModeEnum.optional().describe('Banner mode when no geo rule matches. Default: opt-in.'),\n });\n\n tool(\n 'set_geo_rules',\n 'Set geo-targeting rules for a site (which banner mode to show per country/region). Fetches the current config, patches only geoRules + defaultMode, and PUTs.',\n setGeoRulesSchema.shape,\n async (a) => {\n const { cbid: siteId, geoRules, defaultMode } = setGeoRulesSchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n return client.sites.putConfig(siteId, {\n ...cfg,\n geoRules,\n ...(defaultMode !== undefined ? { defaultMode } : {}),\n });\n },\n );\n\n tool(\n 'list_supported_languages',\n 'The languages the banner already has copy for, with their English name, their name in themselves, whether they read right to left, and whether they ship in the base embed or in the renderer. Check this before writing translations with set_languages — the ones listed here need none. Read-only.',\n {},\n () => client.languages(),\n );\n\n const identitySourceSchema = z.object({\n name: z.string().describe('What you call the identifier, e.g. \"customerId\" or \"email\".'),\n from: z.enum(['dataLayer', 'window', 'cookie', 'localStorage', 'query', 'meta']).describe('Where the page keeps it.'),\n key: z.string().describe('Dotted path for dataLayer/window; cookie, storage key, query parameter or meta name otherwise.'),\n hash: z.boolean().optional().describe('Default true: SHA-256 the trimmed, lowercased value in the browser. false for an opaque id.'),\n });\n const setIdentitySourcesSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n sources: z.array(identitySourceSchema).describe('In priority order; the first with a value becomes the consent record\\'s subjectId. Empty array removes them.'),\n });\n\n tool(\n 'set_identity_sources',\n 'Tell the web embed where a site keeps its signed-in customer (data layer, window object, cookie, local storage, query parameter or meta tag), so consent records carry that customer\\'s subjectId and can be read with GET /v1/subjects/:id/consent. Values are hashed in the browser unless a source sets hash:false. Fetches the current config, patches only identity, and PUTs.',\n setIdentitySourcesSchema.shape,\n async (a) => {\n const { cbid: siteId, sources } = setIdentitySourcesSchema.parse(a);\n const cfg = (await client.sites.getConfig(siteId)) as Record<string, unknown>;\n const { identity: _old, ...rest } = cfg;\n return client.sites.putConfig(siteId, sources.length > 0 ? { ...rest, identity: { sources } } : rest);\n },\n );\n\n const setLanguagesSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n defaultCulture: z.string().optional().describe('Default locale/culture code, e.g. \"en\", \"fr\". Stored in i18n.defaultCulture.'),\n autoDetect: z.union([z.boolean(), z.literal('page')]).optional().describe('true: follow the visitor\\'s browser language; false: defaultCulture for everyone; \"page\": follow the page\\'s <html lang>, then the browser. Stored in i18n.autoDetect.'),\n translations: z.record(z.record(z.unknown())).optional().describe('Per-locale banner copy overrides. Merged onto banner.i18n (locale keys preserved).'),\n overrides: z\n .record(z.object({ banner: z.record(z.string()).optional(), categories: z.record(z.object({ label: z.string().optional(), description: z.string().optional() })).optional() }))\n .optional()\n .describe('The site\\'s own copy per language, keyed by tag (de, pt-BR): { banner: { title, body, … }, categories: { <id>: { label, description } } }. Each language given replaces its entry in i18n.overrides; other languages are kept. Strings the site wrote are shown as written in any language without an override — stock translations never replace them.'),\n });\n\n tool(\n 'set_languages',\n 'Configure language/i18n settings for a site: default culture, auto-detect, and the site\\'s own copy per language (overrides). Fetches the current config, patches only i18n + banner.i18n, and PUTs.',\n setLanguagesSchema.shape,\n async (a) => {\n const { cbid: siteId, defaultCulture, autoDetect, translations, overrides } = setLanguagesSchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n const existingI18n = (cfg['i18n'] ?? {}) as Record<string, unknown>;\n const existingBanner = (cfg['banner'] ?? {}) as Record<string, unknown>;\n const existingBannerI18n = (existingBanner['i18n'] ?? {}) as Record<string, unknown>;\n const i18n: Record<string, unknown> = {\n ...existingI18n,\n ...(defaultCulture !== undefined ? { defaultCulture } : {}),\n ...(autoDetect !== undefined ? { autoDetect } : {}),\n ...(overrides !== undefined\n ? { overrides: { ...((existingI18n['overrides'] ?? {}) as Record<string, unknown>), ...overrides } }\n : {}),\n };\n const banner: Record<string, unknown> = {\n ...existingBanner,\n ...(translations !== undefined ? { i18n: { ...existingBannerI18n, ...translations } } : {}),\n };\n return client.sites.putConfig(siteId, { ...cfg, i18n, banner });\n },\n );\n\n const setConsentModeSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n enabled: z.boolean().describe('Whether Google Consent Mode signals are emitted.'),\n mode: consentModeModeEnum.describe('basic = gtag consent commands only; advanced = also passes redacted pings before consent.'),\n waitForUpdate: z.number().optional().describe('Milliseconds to wait for consent before gtag proceeds. Default 500.'),\n });\n\n tool(\n 'set_consent_mode',\n 'Configure Google Consent Mode for a site (enabled, basic/advanced, waitForUpdate). Fetches the current config, patches only consentMode, and PUTs.',\n setConsentModeSchema.shape,\n async (a) => {\n const { cbid: siteId, enabled, mode, waitForUpdate } = setConsentModeSchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n const existingCm = (cfg['consentMode'] ?? {}) as Record<string, unknown>;\n const consentMode: Record<string, unknown> = {\n ...existingCm,\n enabled,\n mode,\n ...(waitForUpdate !== undefined ? { waitForUpdate } : {}),\n };\n return client.sites.putConfig(siteId, { ...cfg, consentMode });\n },\n );\n\n const setAbExperimentSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n enabled: z.boolean().describe('Whether the A/B experiment is active.'),\n splitB: z.number().min(0).max(100).describe('Percentage of visitors (0–100) who see variant B.'),\n variantB: z.record(z.unknown()).optional().describe('Partial BannerConfig override for variant B visitors. Deep-merged over the base banner.'),\n });\n\n tool(\n 'set_ab_experiment',\n 'Configure the A/B banner experiment for a site (enabled, split percentage, variant B overrides). Fetches the current config, patches only experiment, and PUTs.',\n setAbExperimentSchema.shape,\n async (a) => {\n const { cbid: siteId, enabled, splitB, variantB } = setAbExperimentSchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n const existingExperiment = (cfg['experiment'] ?? {}) as Record<string, unknown>;\n const experiment: Record<string, unknown> = {\n ...existingExperiment,\n enabled,\n splitB,\n ...(variantB !== undefined ? { variantB } : {}),\n };\n return client.sites.putConfig(siteId, { ...cfg, experiment });\n },\n );\n\n const setConsentPolicySchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n expiryDays: z.number().optional().describe('Re-prompt visitors after this many days. Omit to disable time-based expiry.'),\n version: z.number().optional().describe('Bump this integer to force a re-prompt (e.g. when your cookie usage changes).'),\n });\n\n tool(\n 'set_consent_policy',\n 'Configure consent persistence policy for a site (expiry days, version bump). Fetches the current config, patches only consent, and PUTs.',\n setConsentPolicySchema.shape,\n async (a) => {\n const { cbid: siteId, expiryDays, version } = setConsentPolicySchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n const existingConsent = (cfg['consent'] ?? {}) as Record<string, unknown>;\n const consent: Record<string, unknown> = {\n ...existingConsent,\n ...(expiryDays !== undefined ? { expiryDays } : {}),\n ...(version !== undefined ? { version } : {}),\n };\n return client.sites.putConfig(siteId, { ...cfg, consent });\n },\n );\n\n const setBannerBasicsSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n type: bannerTypeEnum.optional().describe('Banner type. multilevel | inline | accept-decline | accept-only | do-not-sell.'),\n layout: bannerLayoutEnum.optional().describe('Banner layout. top | bottom | push-down | popup | overlay.'),\n preset: z\n .enum(['bar', 'box', 'full'] as const)\n .optional()\n .describe('Named shape that sets type/secondLayer (and layout for box): bar = slim one-row bar + categories in a modal; box = centred card + modal; full = every category in the first layer.'),\n secondLayer: z.enum(['expand', 'popup', 'modal'] as const).optional().describe('Where the categories open from an inline banner.'),\n density: z.enum(['comfortable', 'compact'] as const).optional().describe('compact = one-row bar from 760px wide.'),\n theme: z.record(z.unknown()).optional().describe('Partial ThemeTokens — deep-merged onto the existing banner theme. Includes `scrollbar`: { style: themed|thin|native|hidden, thumb?, thumbHover?, track?, width? 4–16, radius? 0–999 }.'),\n content: z.record(z.unknown()).optional().describe('Partial BannerContent — banner copy overrides (title, body, button labels, policyUrl, etc.).'),\n });\n\n tool(\n 'set_banner_basics',\n 'Configure v1 banner appearance for a site: preset, type, layout, second layer, density, theme tokens, and copy (content.preferencesTitle titles the preferences dialog). Fetches the current config, patches only those banner fields, and PUTs. Setting type or secondLayer (or layout under the box preset) without a preset removes the stored preset, which would otherwise re-derive them.',\n setBannerBasicsSchema.shape,\n async (a) => {\n const { cbid: siteId, type, layout, preset, secondLayer, density, theme, content } = setBannerBasicsSchema.parse(a);\n const cfg = await client.sites.getConfig(siteId) as Record<string, unknown>;\n const existingBanner = (cfg['banner'] ?? {}) as Record<string, unknown>;\n const existingTheme = (existingBanner['theme'] ?? {}) as Record<string, unknown>;\n const existingContent = (existingBanner['content'] ?? {}) as Record<string, unknown>;\n const banner: Record<string, unknown> = {\n ...existingBanner,\n ...(type !== undefined ? { type } : {}),\n ...(layout !== undefined ? { layout } : {}),\n ...(secondLayer !== undefined ? { secondLayer } : {}),\n ...(density !== undefined ? { density } : {}),\n ...(preset !== undefined ? { preset } : {}),\n ...(theme !== undefined ? { theme: { ...existingTheme, ...theme } } : {}),\n ...(content !== undefined ? { content: { ...existingContent, ...content } } : {}),\n };\n // The preset owns type/secondLayer; a hand-set shape without a preset replaces it.\n const owned = type !== undefined || secondLayer !== undefined || (layout !== undefined && banner['preset'] === 'box');\n if (preset === undefined && owned) delete banner['preset'];\n return client.sites.putConfig(siteId, { ...cfg, banner });\n },\n );\n\n const getInstallSnippetSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid). Must belong to your org.'),\n blockingMode: z\n .enum(['auto', 'manual'])\n .optional()\n .describe(\n '\"auto\" (default) blocks third-party scripts until consent is given; \"manual\" never blocks. These are the only two modes the runtime embed honors — any other value is rejected rather than silently downgraded.',\n ),\n culture: z.string().optional().describe('Language culture override, e.g. \"en\", \"fr\", \"de\".'),\n });\n\n tool(\n 'get_install_snippet',\n 'Get the exact <script> tag to install Cookie Munch on a site. Copy and paste this into the <head> of every page on the site.',\n getInstallSnippetSchema.shape,\n (a) => {\n const { cbid: siteId, blockingMode, culture } = getInstallSnippetSchema.parse(a);\n return client.sites.snippet(siteId, { blockingMode, culture });\n },\n );\n\n const previewBannerSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid). Must belong to your org.'),\n region: z.string().optional().describe('Region to show the banner for: a country or subdivision code (\"de\", \"us-ca\") or \"eu\".'),\n lang: z.string().optional().describe('Language to show it in, e.g. \"de\", \"pt-BR\".'),\n url: z.string().optional().describe(\"The page to open. Default: the site's registered domain.\"),\n ttlSeconds: z.number().int().min(1).max(3600).optional().describe('How long the link works, in seconds (default 900, max 3600).'),\n });\n\n tool(\n 'preview_banner',\n 'Get a short-lived link that shows the site’s banner exactly as a visitor in a given region and language sees it — it works from a headless browser too (bot suppression is bypassed), and nothing done on it is recorded as consent or counted in statistics.',\n previewBannerSchema.shape,\n (a) => {\n const { cbid: siteId, ...opts } = previewBannerSchema.parse(a);\n return client.sites.previewToken(siteId, opts);\n },\n );\n}\n","/**\n * MCP tools for the platform surfaces beyond the CMP: identity resolution, the Permission\n * Vault, profiles, subscriptions, assessments, data discovery, DSR fulfillment and AI\n * governance.\n *\n * Registered through the same ToolRegistrar as the core tools, so error wrapping and ordering\n * stay consistent. Descriptions spell out the CONSEQUENCE of each call (what it mutates, what\n * it gates) — an agent picking a tool from a one-line summary needs to know that `link` merges\n * two people permanently and that `activate` is consent-gated.\n */\n\nimport { z } from 'zod';\nimport type { CookieMunchClient, FulfillmentOp, Identifier } from '@cookiemunch/sdk';\nimport type { ToolRegistrar } from './tools.js';\n\nconst identifierSchema = z\n .array(z.object({ space: z.string(), value: z.string() }))\n .describe(\"A person's identifiers, e.g. [{space:'email_sha256', value:'<sha256 of the lowercased email>'}].\");\n\nconst ids = (a: Record<string, unknown>): Identifier[] => a.identifiers as Identifier[];\n\nexport function registerPlatformTools(tool: ToolRegistrar, client: CookieMunchClient): void {\n // ---- identity ----\n tool(\n 'resolve_identity',\n 'Resolve identifiers to the canonical subject id for one person, or null if unknown. Read-only.',\n { identifiers: identifierSchema },\n (a) => client.identity.resolve(ids(a)),\n );\n\n tool(\n 'get_identity_cluster',\n 'Every identifier currently stitched to one subject — what resolve_identity and link_identity have merged. Read-only.',\n { subjectId: z.string() },\n (a) => client.identity.cluster(a.subjectId as string),\n );\n\n tool(\n 'link_identity',\n 'Stitch identifiers together as ONE person and return the canonical subject id. This is a durable merge: if the identifiers already belong to different subjects, those subjects are combined and their consent and profile data are carried onto the survivor. Use resolve_identity if you only need to look someone up.',\n { identifiers: identifierSchema },\n (a) => client.identity.link(ids(a)),\n );\n\n // ---- permission vault ----\n tool(\n 'record_consent_decision',\n 'Record consent decisions against the resolved person in the Permission Vault. The latest decision per purpose wins, so this is how a withdrawal is registered too (allowed:false).',\n {\n identifiers: identifierSchema,\n decisions: z\n .array(z.object({\n purpose: z.string(),\n allowed: z.boolean(),\n legalBasis: z.string().optional(),\n jurisdiction: z.string().optional(),\n provenance: z.string().optional().describe('Where the decision came from, e.g. banner_accept_all, gpc, preference_center.'),\n collectedAt: z.number().optional().describe('Unix ms; latest per purpose wins.'),\n }))\n .describe('One entry per purpose.'),\n },\n (a) => client.vault.record(ids(a), a.decisions as never),\n );\n\n tool(\n 'get_consent_state',\n \"A person's current allow/deny per purpose, resolved across ALL their identifiers. Read-only.\",\n { identifiers: identifierSchema },\n (a) => client.vault.current(ids(a)),\n );\n\n tool(\n 'list_permits',\n \"A person's consent decisions in full: per purpose, allowed or not, with the legal basis, jurisdiction, where it was collected and when. The audit-grade view behind get_consent_state. Read-only.\",\n { identifiers: identifierSchema },\n (a) => client.vault.permits(ids(a)),\n );\n\n // ---- profile ----\n tool(\n 'get_profile',\n 'The unified profile for a person: their identifiers, current permits and first-party attributes. Read-only.',\n { identifiers: identifierSchema },\n (a) => client.profile.get(ids(a)),\n );\n\n tool(\n 'set_profile_attributes',\n 'Set first-party profile attributes for a person. A newer collectedAt wins over an older value.',\n {\n identifiers: identifierSchema,\n attributes: z\n .record(z.object({ value: z.string(), purpose: z.string().optional(), collectedAt: z.number().optional() }))\n .describe('Attribute name to value, e.g. { plan: { value: \"pro\" } }.'),\n },\n (a) => client.profile.setAttributes(ids(a), a.attributes as never),\n );\n\n tool(\n 'activate_profile',\n 'Get the attribute values usable for a purpose. CONSENT-GATED: returns {} when the person has not consented to that purpose, so it is safe to call before sending data to a marketing or AI destination.',\n { identifiers: identifierSchema, purpose: z.string().describe('The activation purpose, e.g. marketing.') },\n (a) => client.profile.activate(ids(a), a.purpose as string),\n );\n\n // ---- subscriptions ----\n tool(\n 'get_subscriptions',\n \"A subject's marketing subscription state (topics x channels). Read-only.\",\n { subjectId: z.string() },\n (a) => client.subscriptions.get(a.subjectId as string),\n );\n\n tool(\n 'set_subscription',\n 'Opt a subject in or out of one topic on one channel.',\n {\n subjectId: z.string(),\n topic: z.string(),\n channel: z.string().describe('email | sms | push | mail | phone, or a custom channel.'),\n optedIn: z.boolean(),\n },\n (a) => client.subscriptions.set(a.subjectId as string, a.topic as string, a.channel as string, a.optedIn as boolean),\n );\n\n tool(\n 'global_unsubscribe',\n 'Suppress every topic and channel for a subject WITHOUT erasing their per-topic choices, so a later resubscribe restores them.',\n { subjectId: z.string() },\n (a) => client.subscriptions.unsubscribeAll(a.subjectId as string),\n );\n\n tool(\n 'resubscribe',\n 'Lift a global unsubscribe. Restores the per-topic choices the subject had before it — it does not opt them in to anything they had not chosen.',\n { subjectId: z.string() },\n (a) => client.subscriptions.resubscribe(a.subjectId as string),\n );\n\n tool(\n 'get_subscription_activation',\n \"What to send downstream for a subject: per topic and channel, whether they are subscribed and which mapped downstream group (e.g. an ESP list id) that is. Honours a global unsubscribe. Read-only.\",\n {\n subjectId: z.string(),\n topics: z\n .array(\n z.object({\n code: z.string(),\n name: z.string().optional(),\n channels: z.array(z.string()),\n downstream: z.record(z.string(), z.string()).optional(),\n }),\n )\n .describe('The topics to resolve, usually the catalog from get_subscription_topics.'),\n },\n (a) => client.subscriptions.activation(a.subjectId as string, a.topics as never),\n );\n\n // ---- assessments ----\n tool(\n 'list_assessment_templates',\n 'The assessment templates available (DPIA, PIA, LIA, TIA, AI impact, vendor) and the questions each asks.',\n {},\n () => client.assessments.templates(),\n );\n\n tool(\n 'list_assessments',\n 'Every assessment in the org with its status: draft, in_review, approved or rejected. Read-only.',\n {},\n () => client.assessments.list(),\n );\n\n tool(\n 'autopopulate_assessment',\n 'Prefill an assessment from evidence you supply. Never overwrites a human answer, and stamps every filled answer with `source` so a reviewer can see where it came from. The assessment still needs a human to submit and approve it.',\n { id: z.string(), evidence: z.record(z.string(), z.unknown()).describe('questionId → answer.'), source: z.string().optional() },\n (a) => client.assessments.autoPopulate(a.id as string, a.evidence as Record<string, unknown>, a.source as string | undefined),\n );\n\n tool(\n 'start_assessment',\n 'Start an assessment from a template against a subject (a processing activity, system or vendor).',\n {\n template: z.string().describe('dpia | pia | lia | tia | ai_impact | vendor'),\n subject: z.string().describe('What is being assessed.'),\n },\n (a) => client.assessments.start(a.template as string, a.subject as string),\n );\n\n tool(\n 'get_assessment',\n 'An assessment with its derived risk score, completeness (what is still missing) and which SME owns each outstanding question.',\n { id: z.string() },\n (a) => client.assessments.get(a.id as string),\n );\n\n tool(\n 'answer_assessment_question',\n 'Record one answer on an assessment. Note: answering an APPROVED assessment reopens it to draft, because changing the facts invalidates the sign-off.',\n { id: z.string(), questionId: z.string(), value: z.union([z.string(), z.number(), z.boolean()]) },\n (a) => client.assessments.answer(a.id as string, a.questionId as string, a.value as string | number | boolean),\n );\n\n tool(\n 'autopopulate_assessment_from_data_map',\n 'Fill an assessment from the organisation’s latest data-map scan. Only facts the scan can establish are applied, a human’s existing answer is never overwritten, and machine answers are stamped with provenance so a reviewer can tell them apart.',\n { id: z.string() },\n (a) => client.assessments.autoPopulateFromMap(a.id as string),\n );\n\n tool(\n 'submit_assessment',\n 'Submit an assessment for review. Refused while any required question is unanswered.',\n { id: z.string() },\n (a) => client.assessments.submit(a.id as string),\n );\n\n // ---- discovery ----\n tool(\n 'get_data_map',\n 'The latest data map: which systems hold personal data, and which categories. Read-only.',\n {},\n () => client.discovery.getMap(),\n );\n\n tool(\n 'get_data_drift',\n 'What changed in the estate since the previous scan, and where the documented RoPA disagrees with what is actually there (undocumented systems, undeclared data categories, stale records).',\n {},\n () => client.discovery.drift(),\n );\n\n tool(\n 'get_ropa_drafts',\n 'Draft processing-activity records generated from the latest data map. These are DRAFTS: the factual fields come from the scan, the legal ones still need a human.',\n {},\n () => client.discovery.ropaDrafts(),\n );\n\n tool(\n 'get_discovery_evidence',\n 'The assessment answers the latest data map can actually support — only questions a scan can genuinely answer, never guesses. What autopopulate_assessment_from_data_map would apply. Read-only.',\n {},\n () => client.discovery.evidence(),\n );\n\n tool(\n 'plan_warehouse_enforcement',\n 'Plan warehouse-native policy (Snowflake masking / row access, Postgres RLS) from the latest data map. ' +\n 'Returns a PLAN and its revert — nothing is applied to the warehouse by calling this. Also reports what ' +\n 'it declined to do and why, so gaps are visible rather than silently missing.',\n {\n dialect: z.enum(['postgres', 'mysql', 'snowflake']),\n rules: z\n .array(\n z.object({\n id: z.string(),\n action: z.enum(['mask', 'restrict']),\n minSensitivity: z.enum(['personal', 'sensitive']).optional(),\n categories: z.array(z.string()).optional(),\n allowRoles: z.array(z.string()).optional(),\n purpose: z.string().optional(),\n subjectColumn: z.string().optional(),\n }),\n )\n .describe('A rule with neither minSensitivity nor categories matches nothing, by design.'),\n permitsTable: z.string().optional(),\n policyPrefix: z.string().optional(),\n },\n (a) =>\n client.discovery.planEnforcement(\n a.dialect as 'postgres' | 'mysql' | 'snowflake',\n a.rules as Parameters<typeof client.discovery.planEnforcement>[1],\n {\n ...(typeof a.permitsTable === 'string' ? { permitsTable: a.permitsTable } : {}),\n ...(typeof a.policyPrefix === 'string' ? { policyPrefix: a.policyPrefix } : {}),\n },\n ),\n );\n\n // ---- subscription topic catalog ----\n tool(\n 'get_subscription_topics',\n \"The org's marketing topic catalog — what a subject can subscribe to, and on which channels. Read-only.\",\n {},\n () => client.subscriptions.topics(),\n );\n\n tool(\n 'set_subscription_topics',\n 'Replace the subscription topic catalog. The list is authored whole, so anything omitted is removed.',\n {\n topics: z.array(\n z.object({\n code: z.string(),\n name: z.string().optional(),\n channels: z.array(z.string()),\n downstream: z.record(z.string()).optional(),\n }),\n ),\n },\n (a) => client.subscriptions.setTopics(a.topics as Parameters<typeof client.subscriptions.setTopics>[0]),\n );\n\n // ---- regulatory intelligence ----\n tool(\n 'get_regulatory_feed',\n 'The curated privacy-law dataset, optionally narrowed to the jurisdictions you operate in. ' +\n 'Carries reviewedAt: this ships with the product and is only as current as its last review. Not legal advice.',\n {\n jurisdictions: z\n .array(z.string())\n .optional()\n .describe(\"ISO codes, e.g. ['US-CA','BR']. A subdivision also matches its country; an EEA country matches the EU-wide regulations.\"),\n },\n (a) => client.regulatory.feed(a.jurisdictions as string[] | undefined),\n );\n\n tool(\n 'get_upcoming_regulations',\n 'Privacy laws taking effect within a horizon (default 180 days), soonest first. Same caveat as the feed: ' +\n 'a shipped dataset with a review date, not live legal research.',\n { days: z.number().int().positive().optional() },\n (a) => client.regulatory.upcoming(a.days as number | undefined),\n );\n\n // ---- DSR fulfillment ----\n tool(\n 'get_dsr_sla',\n 'The rights queue at a glance: how many requests are overdue, due today, due soon or on track, plus the overdue ids.',\n {},\n () => client.fulfillment.sla(),\n );\n\n tool(\n 'plan_dsr_fulfillment',\n 'Break a data-subject request into one fulfillment task per system. The tasks are then executed by the in-VPC agent inside the customer network — this call only queues the work.',\n {\n requestId: z.string(),\n systems: z\n .array(z.object({ system: z.string(), operation: z.enum(['locate', 'export', 'erase', 'optOut']) }))\n .describe('One entry per system to act on.'),\n includeHistorical: z.boolean().optional().describe('Also reprocess already-collected records, not just future ones.'),\n },\n (a) => client.fulfillment.plan(\n a.requestId as string,\n a.systems as Array<{ system: string; operation: FulfillmentOp }>,\n a.includeHistorical as boolean | undefined,\n ),\n );\n\n tool(\n 'list_dsar_executors',\n 'Systems connected to run part of a rights request themselves — an identity platform, a CRM, anything with a rights API. The in-VPC agent covers systems we cannot reach; these are the ones we can. Each carries the profile that describes its API. Never returns credentials. Read-only.',\n {},\n () => client.fulfillment.executors(),\n );\n\n tool(\n 'connect_dsar_executor',\n 'Connect a system that runs part of a rights request — an identity platform, a CRM, anything with a rights API. Cookie Munch is not specific to any platform: the `profile` describes that system\\'s API (paths, the words it uses for export/erase, its status vocabulary, how it signs webhooks), so connecting a new one needs no code. The secret key is stored encrypted and never returned; the response carries the webhook URL to configure in that system. Sub-tasks open automatically once a request reaches fulfilment (after identity verification), and completions are picked up by webhook or by polling.',\n {\n preset: z\n .string()\n .optional()\n .describe('Build profile (and, unless the preset takes baseUrl as a param, baseUrl) from a versioned preset instead of sending profile. list_dsar_executor_presets names them, what each needs, and which wait on another platform.'),\n presetVersion: z.number().int().optional().describe('With preset: the version to build. Default the latest.'),\n orgId: z.string().optional().describe(\"A preset param, when the preset's params list it.\"),\n atlasIdAppId: z.string().optional().describe(\"A preset param, when the preset's params list it: the identity platform's app id, so an erasure also revokes the app's grant.\"),\n system: z.string().optional().describe('The name this connection answers to in a plan, e.g. identity or crm. Required unless the preset has a default.'),\n baseUrl: z.string().optional().describe(\"The system's public https origin. Required unless the preset sets it.\"),\n secretKey: z.string().describe('Its API key, with whatever scope that system needs to export and erase a user.'),\n webhookSecret: z.string().optional().describe('Signing secret of its webhook endpoint. Optional: polling closes tasks without it.'),\n auto: z.boolean().optional().describe('Open a sub-task automatically when a request reaches fulfilment. Default true.'),\n profile: z\n .record(z.unknown())\n .optional()\n .describe('How to drive that system: { open, poll, statuses } required, plus optional subjectLookup, auth, idempotencyHeader, grantRevoke and webhook. Omit it when using preset.'),\n dryRun: z.boolean().optional().describe('Validate everything and answer the connection that would be created, storing nothing.'),\n },\n (a) => {\n const { dryRun, ...input } = a as Record<string, unknown>;\n return dryRun === true ? client.fulfillment.dryRunConnectExecutor(input as never) : client.fulfillment.connectExecutor(input as never);\n },\n );\n\n tool(\n 'list_dsar_executor_presets',\n \"The versioned executor presets: each one's name, params, latest version, and whether it is usable now or waits on another platform's API (waitingOn names the platform and its spec items). Also this org's canary address for connection tests. Read-only.\",\n {},\n () => client.fulfillment.executorPresets(),\n );\n\n tool(\n 'upgrade_dsar_executor_preset',\n \"Rebuild a connection's profile and address from its preset's latest version (or presetVersion), keeping its id, credentials, system and scope — or adopt a preset on a hand-written connection by naming it. Answers with a diff. Use dryRun first: the answer shows exactly what would change and nothing is stored.\",\n {\n id: z.string().describe('The connection id.'),\n preset: z.string().optional().describe('Only to adopt a preset on a connection that has none.'),\n presetVersion: z.number().int().optional(),\n orgId: z.string().optional(),\n atlasIdAppId: z.string().optional(),\n dryRun: z.boolean().optional().describe('Answer the diff and change nothing.'),\n },\n (a) => {\n const { id, dryRun, ...input } = a as Record<string, unknown>;\n return dryRun === true\n ? client.fulfillment.dryRunUpgradeExecutorPreset(id as string, input as never)\n : client.fulfillment.upgradeExecutorPreset(id as string, input as never);\n },\n );\n\n tool(\n 'test_dsar_executor_webhook',\n \"Would this webhook delivery from a connected system verify? Runs the receiver's exact check (headers, timestamp tolerance, prefix, HMAC) on headers and a raw body you supply, acts on nothing, and returns { verified, stage, reason } naming the stage that failed. `body` must be the raw request body string, byte for byte. Read-only.\",\n {\n id: z.string().describe('The connection id.'),\n headers: z.record(z.string()).describe('The delivery headers, e.g. its id, timestamp and signature headers.'),\n body: z.string().describe('The raw body exactly as it was signed.'),\n },\n (a) => client.fulfillment.testExecutorWebhook(a.id as string, { headers: a.headers as Record<string, string>, body: a.body as string }),\n );\n\n tool(\n 'list_dsar_executor_webhook_deliveries',\n \"The last 50 deliveries to a connected system's webhook, newest first, each with whether it verified and, if not, the stage and reason. Never includes the secret, the signature or the body (only a short hash and size). Read-only.\",\n { id: z.string().describe('The connection id.') },\n (a) => client.fulfillment.executorWebhookDeliveries(a.id as string),\n );\n\n tool(\n 'disconnect_dsar_executor',\n 'Disconnect a system. Its open sub-tasks stop being driven, and the stored credentials are deleted.',\n { id: z.string() },\n async (a) => {\n await client.fulfillment.disconnectExecutor(a.id as string);\n return { disconnected: a.id };\n },\n );\n\n tool(\n 'get_dsar_task',\n 'One fulfilment task in detail: its status history, what it means for the person (exported, no record, done without an export…), every request Cookie Munch made to the connected system on its behalf with the answer it got (credentials removed, kept 30 days), and whether that system was redeployed mid-request. Read-only. Use it to explain why a system answered the way it did.',\n { requestId: z.string(), taskId: z.string() },\n (a) => client.fulfillment.task(a.requestId as string, a.taskId as string),\n );\n\n tool(\n 'test_dsar_executor',\n 'Try a connected system against one email (or the org canary, canary: true) WITHOUT filing a rights request. Runs its subject lookup and returns the raw upstream answers (credentials removed) and a one-line verdict; code base_url_redirects means its baseUrl redirects and the verdict names where. The open step is rendered but not sent, unless open is true on an export, which opens and polls a real export once. An erasure is never sent by a test.',\n {\n id: z.string().describe('The connection id.'),\n email: z.string().optional().describe('The address to look up. Omit it with canary.'),\n canary: z.boolean().optional().describe(\"Use this org's canary address — no real person involved. A canary locate also updates the connection's health.\"),\n operation: z.enum(['locate', 'export', 'erase']).optional().describe('Default locate.'),\n open: z.boolean().optional().describe('For export only: open a real export and poll it once.'),\n },\n (a) =>\n client.fulfillment.testExecutor(a.id as string, {\n ...(typeof a.email === 'string' ? { email: a.email } : {}),\n ...(a.canary === true ? { canary: true } : {}),\n ...(a.operation ? { operation: a.operation as 'locate' | 'export' | 'erase' } : {}),\n ...(typeof a.open === 'boolean' ? { open: a.open } : {}),\n }),\n );\n\n tool(\n 'get_dsar_task_export',\n 'The export bundle a connected system produced for one sub-task, fetched from that system on demand. The platform keeps no copy.',\n { requestId: z.string(), taskId: z.string() },\n (a) => client.fulfillment.taskExport(a.requestId as string, a.taskId as string),\n );\n\n tool(\n 'get_dsr_fulfillment_status',\n 'Per-system fulfillment status for one request (\"n of m systems done\"), including which systems failed and why.',\n { requestId: z.string() },\n (a) => client.fulfillment.status(a.requestId as string),\n );\n\n // ---- AI governance ----\n tool(\n 'inspect_ai_prompt',\n 'Run a prompt or model response through the AI governance gateway BEFORE it reaches the model or the user. Returns action allow | redact | block plus the text to actually forward (redacted, or empty when blocked). Pass `consent` when the call concerns an identified person: data for a purpose they have not consented to is blocked outright.',\n {\n prompt: z.string(),\n purpose: z.string().describe('What the AI call is for, e.g. support or marketing.'),\n model: z.string().optional(),\n actor: z.string().optional(),\n direction: z.enum(['prompt', 'response']).optional(),\n consent: z.record(z.boolean()).optional().describe(\"The person's current permits, e.g. { marketing: false }.\"),\n },\n (a) => client.ai.inspect(a as never),\n );\n\n tool(\n 'get_ai_policy',\n 'The AI gateway policy: its rules, and what happens when no rule matches. `configured` is false while the built-in default applies. Read-only.',\n {},\n () => client.ai.getPolicy(),\n );\n\n tool(\n 'set_ai_policy',\n 'REPLACE the AI gateway policy. Takes effect on the next inspected prompt: a rule with action `block` stops matching calls, `redact` strips the matched data. `default` decides every call no rule matches — `block` fails closed.',\n {\n rules: z\n .array(\n z.object({\n id: z.string(),\n purposes: z.array(z.string()).optional(),\n categories: z.array(z.string()).optional(),\n minSensitivity: z.string().optional(),\n action: z.enum(['allow', 'redact', 'block']),\n reason: z.string().describe('Recorded on every audit entry this rule decides.'),\n }),\n )\n .describe('Evaluated in order; the first match decides.'),\n default: z.enum(['allow', 'redact', 'block']),\n },\n (a) => client.ai.setPolicy({ rules: a.rules, default: a.default }),\n );\n\n tool(\n 'register_ai_system',\n 'Declare an AI system so it appears in the inventory as registered rather than shadow. Idempotent on `id`.',\n { id: z.string(), name: z.string(), provider: z.string().optional(), purpose: z.string().optional() },\n (a) =>\n client.ai.registerSystem({\n id: a.id as string,\n name: a.name as string,\n ...(a.provider ? { provider: a.provider as string } : {}),\n ...(a.purpose ? { purpose: a.purpose as string } : {}),\n }),\n );\n\n tool('list_ai_systems', 'The AI systems declared with register_ai_system. Read-only.', {}, () => client.ai.systems());\n\n tool(\n 'get_ai_audit_log',\n 'Recent AI gateway decisions — what was allowed, redacted or blocked, and which rule decided. Read-only.',\n { limit: z.number().int().positive().max(500).optional() },\n (a) => client.ai.audit(a.limit as number | undefined),\n );\n\n tool(\n 'get_ai_inventory',\n 'Every AI system seen or declared, highest risk first, plus the SHADOW subset — models observed handling data that were never registered.',\n {},\n () => client.ai.inventory(),\n );\n\n tool(\n 'get_ai_lineage',\n 'Which data categories reach which model. Answers \"does anything send SSNs to a vendor model?\".',\n {},\n () => client.ai.lineage(),\n );\n}\n","/**\n * MCP tools for a site's identity and its integrations as a whole: rename/move a site, the\n * integration-health report, one-call provisioning, and partner trust links.\n */\n\nimport { z } from 'zod';\nimport type { CookieMunchClient } from '@cookiemunch/sdk';\nimport type { ToolRegistrar } from './tools.js';\n\nexport function registerIntegrationTools(tool: ToolRegistrar, client: CookieMunchClient): void {\n const updateSiteSchema = z.object({\n cbid: z.string().describe('Site identifier (cbid).'),\n domain: z.string().optional().describe('New domain, a bare hostname. A move clears verification: verify the new domain afterwards.'),\n name: z.string().nullable().optional().describe('Display name data subjects see on the rights page and in notices; null clears it.'),\n aliases: z.array(z.string()).optional().describe('Other hosts serving the site (replaces the list; [] clears it). Accepted consent origins, never verified claims.'),\n dryRun: z.boolean().optional().describe('Answer with the diff and its effects, storing nothing.'),\n });\n tool(\n 'update_site',\n 'Rename or move a site: its domain, display name and aliases. The cbid and the consent ledger stay. Moving the domain clears verification; the scanner and preview links follow the new domain. Use dryRun first to see the diff and every effect.',\n updateSiteSchema.shape,\n (a) => {\n const { cbid, dryRun, ...patch } = updateSiteSchema.parse(a);\n return client.sites.update(cbid, patch, { dryRun });\n },\n );\n\n tool(\n 'integration_health',\n 'Check every link a site’s privacy wiring depends on: the domain, the snippet and CSP on the live page, connected systems (base URL redirects, a test lookup), webhooks, partner links, Atlas cookie_consent, cookies needing review, the rights page, the mail provider and the request SLA. Each row has ok (null = could not check) and a fix hint. Read-only.',\n { cbid: z.string().optional().describe('Site identifier; optional when the org has one site.') },\n (a) => client.integrationHealth(a.cbid as string | undefined),\n );\n\n const provisionSchema = z.object({\n product: z.string().describe('A slug naming the product.'),\n domain: z.string().describe('The product’s domain (bare hostname).'),\n name: z.string().optional(),\n aliases: z.array(z.string()).optional(),\n cbid: z.string().optional().describe('Update this site instead of matching by domain.'),\n atlas: z.object({ secretKey: z.string(), cookieConsent: z.boolean().optional(), dsrWebhook: z.boolean().optional(), frontendApiHost: z.string().optional().describe('Your Atlas frontend API host (auth.example.com): declares the Atlas sign-in cookies on the site.') }).optional()\n .describe('Atlas secret key (sk_…) — used for this call only, never stored or returned.'),\n forumulate: z.object({ token: z.string(), orgId: z.string(), consent: z.boolean().optional(), executorKey: z.boolean().optional(), label: z.string().optional() }).optional()\n .describe('Forumulate org token — used for this call only, never stored or returned.'),\n rightsApi: z.object({ baseUrl: z.string(), secretKey: z.string(), profilePreset: z.string().optional() }).optional(),\n dryRun: z.boolean().optional().describe('Report what each step would do; write nothing on any platform. Run this first.'),\n });\n tool(\n 'provision_product',\n 'Wire a product’s privacy in one call: create or update the site, connected systems, the Atlas request-completion webhook and hosted-page consent banner, and Forumulate consent and executor key. Writes across three platforms; run with dryRun first. Idempotent: a re-run answers every step unchanged. No secret appears in the result.',\n provisionSchema.shape,\n (a) => {\n const { dryRun, ...input } = provisionSchema.parse(a);\n return client.provision(input, { dryRun });\n },\n );\n\n tool(\n 'list_site_partners',\n 'Which partner platforms (Forumulate, Atlas) receive this site’s consent events, each with its status, and which partners are on offer. Read-only.',\n { cbid: z.string() },\n (a) => client.sites.listPartners(a.cbid as string),\n );\n\n const linkSchema = z.object({\n cbid: z.string(),\n partner: z.enum(['forumulate', 'atlas']),\n externalId: z.string().describe('The partner’s id for the receiving account, e.g. a Forumulate organisation id.'),\n label: z.string().optional().describe('Shown with the partner name, e.g. \"docs\".'),\n events: z.array(z.enum(['consent.recorded', 'consent.withdrawn'])).optional(),\n dryRun: z.boolean().optional(),\n });\n tool(\n 'link_site_partner',\n 'Grant a partner platform this site’s consent events (they start flowing out to it). No secret is created: deliveries are signed with Cookie Munch’s own key. Idempotent.',\n linkSchema.shape,\n (a) => {\n const { cbid, dryRun, ...input } = linkSchema.parse(a);\n return client.sites.linkPartner(cbid, input, { dryRun });\n },\n );\n\n tool(\n 'unlink_site_partner',\n 'Revoke a partner link: no further consent events go to that partner.',\n { cbid: z.string(), linkId: z.string() },\n (a) => client.sites.unlinkPartner(a.cbid as string, a.linkId as string),\n );\n}\n","/**\n * MCP tools for the hosted rights page: read and write the draft, preview a write, publish,\n * list versions and roll back. Registered through the shared ToolRegistrar.\n *\n * Also the custom-hostname tools: every call is scoped to the key's org by the API; a hostname\n * is only ever routed after its owner proves it in DNS, so adding one cannot take over traffic.\n */\nimport { z } from 'zod';\nimport type { CookieMunchClient, RightsPageDocument } from '@cookiemunch/sdk';\nimport type { ToolRegistrar } from './tools.js';\n\n/** The hosted rights page as a document. */\nexport function registerRightsTools(tool: ToolRegistrar, client: CookieMunchClient): void {\n const cbid = { cbid: z.string().describe('Site identifier (cbid). Must belong to your org.') };\n const base = {\n baseUpdatedAt: z.union([z.number().int(), z.string(), z.null()]).optional()\n .describe('The draft’s updatedAt from your last read (null if it had none). If someone saved since, the write is refused with 409 draft_conflict and the current draft; omit to overwrite regardless.'),\n };\n const baseOpt = (a: Record<string, unknown>) => (a.baseUpdatedAt !== undefined ? { baseUpdatedAt: a.baseUpdatedAt as number | string | null } : {});\n tool('get_rights_page', 'Read the site’s rights page DRAFT (the default page until first saved), with warnings that would block publishing.', cbid, (a) => client.rightsPage.get(a.cbid as string));\n tool(\n 'update_rights_page',\n 'Replace the rights page draft with a full document (theme, sections, form, i18n, seo, customCss). Nothing goes live until publish_rights_page. Prefer patch_rights_page for small changes and preview_rights_page when unsure. Pass baseUpdatedAt (from get_rights_page) to avoid overwriting someone else’s save: a mismatch is 409 draft_conflict with the current draft.',\n { ...cbid, page: z.record(z.unknown()).describe('The whole RightsPage document (v: 1).'), ...base },\n (a) => client.rightsPage.put(a.cbid as string, a.page as unknown as RightsPageDocument, baseOpt(a)),\n );\n tool(\n 'patch_rights_page',\n 'Change part of the rights page draft: objects merge, arrays (sections, request types, fields) replace whole, null removes a field. baseUpdatedAt works as on update_rights_page (409 draft_conflict).',\n { ...cbid, patch: z.record(z.unknown()), ...base },\n (a) => client.rightsPage.patch(a.cbid as string, a.patch as Record<string, unknown>, baseOpt(a)),\n );\n tool(\n 'preview_rights_page',\n 'Validate a rights-page write WITHOUT saving: returns the document as it would be stored and any publish warnings. mode \"patch\" (default) or \"put\".',\n { ...cbid, page: z.record(z.unknown()), mode: z.enum(['patch', 'put']).optional() },\n (a) => client.rightsPage.dryRun(a.cbid as string, a.page as Record<string, unknown>, { mode: (a.mode as 'patch' | 'put' | undefined) ?? 'patch' }),\n );\n tool('get_published_rights_page', 'Read the LIVE rights page document (404 not_published while the site shows the default page).', cbid, (a) => client.rightsPage.getPublished(a.cbid as string));\n tool(\n 'publish_rights_page',\n 'Publish the draft as the next version: it goes live at once, to every visitor. Refused unless the page has exactly one form section and an enabled request type. Pass baseUpdatedAt (from get_rights_page) so only the draft you read goes live; without it, whatever the draft holds now is published, including someone else’s later edits. A mismatch is 409 draft_conflict with the current draft.',\n { ...cbid, ...base },\n (a) => client.rightsPage.publish(a.cbid as string, baseOpt(a)),\n );\n tool('list_rights_page_versions', 'Published versions of the rights page, newest first, each with publishedBy, publishedByEmail (null for an API key) and publishedVia.', cbid, (a) => client.rightsPage.versions(a.cbid as string));\n tool(\n 'rollback_rights_page',\n 'Publish an earlier version of the rights page again (as a new version): it goes live at once and REPLACES the current draft, so unpublished edits are lost and cannot be recovered (versions hold only published documents). Pass baseUpdatedAt (from get_rights_page) to refuse with 409 draft_conflict if anyone saved the draft since you read it.',\n { ...cbid, version: z.number().int().min(1), ...base },\n (a) => client.rightsPage.rollback(a.cbid as string, a.version as number, baseOpt(a)),\n );\n}\n\n/** Custom hostnames for a site's hosted rights page. */\nexport function registerRightsPageTools(tool: ToolRegistrar, client: CookieMunchClient): void {\n const site = z.object({ cbid: z.string().describe('Site identifier (cbid). Must belong to your org.') });\n const host = site.extend({\n hostname: z.string().describe('The custom hostname, e.g. privacy.example.com (unicode or punycode).'),\n });\n\n tool(\n 'list_rights_page_domains',\n \"List the custom hostnames serving a site's rights page, each with its status (pending_dns, verifying, issuing, active, error), the exact DNS records to create, and the plan's allowance.\",\n site.shape,\n (a) => client.rightsPage.listDomains(site.parse(a).cbid),\n );\n\n tool(\n 'add_rights_page_domain',\n \"Add a custom hostname for a site's rights page (e.g. privacy.example.com). Returns the DNS records the owner must create: a CNAME to this domain's own <token>.cname.cookiemunch.net (a CNAME to anything else never verifies it), or for an apex / flattened / proxied record the _cookiemunch TXT. Then call verify_rights_page_domain. Plans include Free 0, Starter 1, Pro 5, Scale unlimited.\",\n host.shape,\n (a) => {\n const { cbid, hostname } = host.parse(a);\n return client.rightsPage.addDomain(cbid, hostname);\n },\n );\n\n tool(\n 'verify_rights_page_domain',\n 'Check a custom hostname now: DNS while it is pending or in error, the HTTPS answer once it is routed. Returns the domain as it now stands; lastError and dnsSeen say what is missing.',\n host.shape,\n (a) => {\n const { cbid, hostname } = host.parse(a);\n return client.rightsPage.verifyDomain(cbid, hostname);\n },\n );\n\n tool(\n 'remove_rights_page_domain',\n 'Remove a custom hostname from a site\\'s rights page. It stops being served at once and its certificate is no longer renewed.',\n host.shape,\n async (a) => {\n const { cbid, hostname } = host.parse(a);\n await client.rightsPage.removeDomain(cbid, hostname);\n return { removed: hostname };\n },\n );\n}\n","/**\n * Consent-button parity findings, worded for an AI agent. A tool result that carries\n * `designWarnings` opens with them, before any JSON, because an agent acts on what it reads\n * first: it should come away knowing the Accept button is pushed harder than Reject, that\n * regulators call that a dark pattern, and exactly which reject style values fix it.\n */\n\nimport type { ButtonParityFinding, SuggestedRejectStyle } from '@cookiemunch/sdk';\n\nfunction whereText(f: ButtonParityFinding): string {\n const w = f.where ?? {};\n const bits = [\n f.layer === 'banner' ? 'first layer' : `${f.layer} layer`,\n w.view ? `view \"${w.view}\"` : '',\n w.variant && w.variant !== 'base' ? `variant ${w.variant}` : '',\n w.theme === 'dark' ? 'dark theme' : '',\n w.breakpoint === 'mobile' ? 'mobile' : '',\n w.language ? `language ${w.language}` : '',\n w.url ? w.url : '',\n ].filter(Boolean);\n return bits.join(', ');\n}\n\nfunction styleText(s: Partial<SuggestedRejectStyle>): string {\n const parts = [\n s.background ? `background ${s.background}` : '',\n s.color ? `text ${s.color}` : '',\n s.borderColor ? `border ${s.borderWidth ?? 1}px ${s.borderColor}` : '',\n s.fontSize ? `font ${s.fontSize}px` : '',\n s.fontWeight ? `weight ${s.fontWeight}` : '',\n s.width && s.height ? `${Math.round(s.width)}×${Math.round(s.height)}px` : '',\n ].filter(Boolean);\n return parts.join(', ');\n}\n\n/**\n * What the tool did, so the header can say it truthfully: an agent that reads \"saved\" after\n * a lint may skip the real write, or tell the user a change is live.\n */\nexport type DesignContext = 'saved' | 'preview' | 'lint' | 'read' | 'scan';\n\nconst CONTEXT_TEXT: Record<DesignContext, string> = {\n saved: 'The config was saved as sent; this is a warning, not an error.',\n preview: 'Nothing was saved: this is a preview of the write.',\n lint: 'Nothing was saved: this is a lint of a proposed config.',\n read: 'This describes the config as it is stored now; nothing was changed.',\n scan: 'This was measured on the live site by the last cookie scan; fix the banner, then scan again.',\n};\n\n/** The context of a tool's result: from the result itself where it says, else from the tool's name. */\nexport function designContext(tool: string, value: unknown): DesignContext {\n const v = (value && typeof value === 'object' ? value : {}) as { dryRun?: unknown; buttonParity?: unknown };\n if (tool === 'lint_banner_config') return 'lint';\n if (v.dryRun === true || tool.startsWith('preview_')) return 'preview';\n if (v.buttonParity && typeof v.buttonParity === 'object') return 'scan';\n if (/^(update|patch|set|edit|create|assign|apply)_/.test(tool)) return 'saved';\n return 'read';\n}\n\n/** The plain-words block that goes on top of a tool result. Empty string when there is nothing to say. */\nexport function designWarningText(findings: ButtonParityFinding[], suggested?: SuggestedRejectStyle[], context: DesignContext = 'read'): string {\n if (!Array.isArray(findings) || findings.length === 0) return '';\n const warnings = findings.filter((f) => f.severity === 'warning');\n const notices = findings.filter((f) => f.severity !== 'warning');\n const lines: string[] = [];\n if (warnings.length) {\n lines.push(\n `Design warning: the Accept button is more prominent than Reject (${warnings.length} issue${warnings.length === 1 ? '' : 's'}). ` +\n 'Regulators treat this as a dark pattern (EDPB Guidelines 03/2022, the EDPB cookie banner taskforce, CNIL). ' +\n `Make both buttons the same style. ${CONTEXT_TEXT[context]}`,\n );\n for (const f of warnings) lines.push(`- [${f.code}] (${whereText(f)}) ${f.detail} Fix: ${f.fix}`);\n }\n if (notices.length) {\n lines.push(\n `Design notice: ${notices.length} thing${notices.length === 1 ? '' : 's'} to check about how Reject compares with Accept.` +\n (warnings.length ? '' : ` ${CONTEXT_TEXT[context]}`),\n );\n for (const f of notices) lines.push(`- [${f.code}] (${whereText(f)}) ${f.detail} Fix: ${f.fix}`);\n }\n const fixes: Array<Partial<SuggestedRejectStyle>> =\n suggested && suggested.length\n ? suggested\n : findings.filter((f) => f.accept && f.reject).slice(0, 1).map((f) => ({ ...f.accept!, layer: f.layer, view: f.where?.view }));\n for (const s of fixes) {\n const style = styleText(s);\n if (style) {\n lines.push(\n `Suggested fix: style Reject all${s.view ? ` in view \"${s.view}\"` : ''} with ${style} — the same as Accept all. ` +\n 'In a flow design, give the Reject button the same `variant` and size as the Accept button.',\n );\n }\n }\n return lines.join('\\n');\n}\n\n/** Lead a tool result's text with its design warnings, when it has any. `tool` names what ran. */\nexport function withDesignWarnings(value: unknown, body: string, tool = ''): string {\n if (!value || typeof value !== 'object') return body;\n // A scan status carries them one level down, on what it measured of the live banner.\n const nested = (value as { buttonParity?: unknown }).buttonParity;\n const v = (nested && typeof nested === 'object' ? nested : value) as { designWarnings?: unknown; suggestedReject?: unknown };\n if (!Array.isArray(v.designWarnings) || v.designWarnings.length === 0) return body;\n const head = designWarningText(\n v.designWarnings as ButtonParityFinding[],\n Array.isArray(v.suggestedReject) ? (v.suggestedReject as SuggestedRejectStyle[]) : undefined,\n designContext(tool, value),\n );\n return head ? `${head}\\n\\n${body}` : body;\n}\n"],"mappings":";;;;AAQA,mBAAqC;;;ACDrC,iBAA0B;AAC1B,iBAA0D;;;ACA1D,IAAAA,cAAoC;;;ACEpC,iBAAkB;AAIX,SAAS,oBAAoB,MAAqB,QAAiC;AAExF,QAAM,mBAAmB,aAAE,KAAK,CAAC,QAAQ,QAAQ,CAAU;AAC3D,QAAM,iBAAiB,aAAE,KAAK,CAAC,UAAU,WAAW,KAAK,CAAU;AACnE,QAAM,iBAAiB,aAAE,KAAK,CAAC,cAAc,UAAU,kBAAkB,eAAe,aAAa,CAAU;AAC/G,QAAM,mBAAmB,aAAE,KAAK,CAAC,OAAO,UAAU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