@adport/mcp 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/bin.js +1 -1
- package/dist/{chunk-YCSBIOYH.js → chunk-WN2KEUAP.js} +72 -12
- package/dist/chunk-WN2KEUAP.js.map +1 -0
- package/dist/index.js +1 -1
- package/package.json +28 -13
- package/dist/chunk-YCSBIOYH.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @adport/mcp
|
|
2
|
+
|
|
3
|
+
adport MCP server: the open control plane for paid media.
|
|
4
|
+
|
|
5
|
+
This package is part of [Adport](https://github.com/ynnickw/adport), an open-source control plane for paid media. Most users should install the [`adport` CLI](https://www.npmjs.com/package/adport), which assembles the provider modules and shared policy engine.
|
|
6
|
+
|
|
7
|
+
Requires Node.js 22.13 or newer. Advertising mutations must use the shared preview/apply policy gate. Provider credentials and approvals are configured separately; package installation does not grant platform access.
|
|
8
|
+
|
|
9
|
+
[Documentation](https://github.com/ynnickw/adport/blob/main/docs/README.md) · [Contributing](https://github.com/ynnickw/adport/blob/main/CONTRIBUTING.md) · [Security](https://github.com/ynnickw/adport/blob/main/SECURITY.md)
|
|
10
|
+
|
|
11
|
+
Licensed under Apache-2.0.
|
package/dist/bin.js
CHANGED
|
@@ -19,7 +19,7 @@ import { createXModule } from "@adport/provider-x";
|
|
|
19
19
|
// package.json
|
|
20
20
|
var package_default = {
|
|
21
21
|
name: "@adport/mcp",
|
|
22
|
-
version: "0.
|
|
22
|
+
version: "0.7.0",
|
|
23
23
|
description: "adport MCP server \u2014 the open control plane for paid media",
|
|
24
24
|
license: "Apache-2.0",
|
|
25
25
|
type: "module",
|
|
@@ -34,7 +34,9 @@ var package_default = {
|
|
|
34
34
|
bin: {
|
|
35
35
|
"adport-mcp": "./dist/bin.js"
|
|
36
36
|
},
|
|
37
|
-
files: [
|
|
37
|
+
files: [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
38
40
|
scripts: {
|
|
39
41
|
build: "tsup src/index.ts src/bin.ts --format esm --dts --sourcemap --clean",
|
|
40
42
|
"render:submission-previews": "node scripts/render-submission-previews.mjs",
|
|
@@ -64,6 +66,21 @@ var package_default = {
|
|
|
64
66
|
tsup: "^8.3.0",
|
|
65
67
|
typescript: "^5.8.0",
|
|
66
68
|
vitest: "^4.1.10"
|
|
69
|
+
},
|
|
70
|
+
repository: {
|
|
71
|
+
type: "git",
|
|
72
|
+
url: "git+https://github.com/ynnickw/adport.git",
|
|
73
|
+
directory: "packages/mcp"
|
|
74
|
+
},
|
|
75
|
+
homepage: "https://github.com/ynnickw/adport#readme",
|
|
76
|
+
bugs: {
|
|
77
|
+
url: "https://github.com/ynnickw/adport/issues"
|
|
78
|
+
},
|
|
79
|
+
engines: {
|
|
80
|
+
node: ">=22.13"
|
|
81
|
+
},
|
|
82
|
+
publishConfig: {
|
|
83
|
+
access: "public"
|
|
67
84
|
}
|
|
68
85
|
};
|
|
69
86
|
|
|
@@ -153,7 +170,7 @@ var ADPORT_UI_HTML = String.raw`<!doctype html>
|
|
|
153
170
|
.shell { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 10px 32px rgba(20,20,20,.07) }
|
|
154
171
|
.top { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:14px 16px 10px }
|
|
155
172
|
.brand { display:flex; align-items:center; gap:9px; min-width:0 }
|
|
156
|
-
.dot {
|
|
173
|
+
.wordmark-dot { color:#ff6b00; font-size:1.3em; line-height:0 }
|
|
157
174
|
.brand b { font-size:12px; letter-spacing:-.02em }
|
|
158
175
|
.context { color:var(--muted); font-size:11px; text-align:right }
|
|
159
176
|
.content { padding:4px 16px 16px }
|
|
@@ -204,6 +221,11 @@ var ADPORT_UI_HTML = String.raw`<!doctype html>
|
|
|
204
221
|
.approval { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin:12px 0 }
|
|
205
222
|
.approve { cursor:pointer; padding:9px 16px; border:0; border-radius:99px; background:var(--ink); color:var(--paper); font-size:12px; font-weight:700 }
|
|
206
223
|
.approve:disabled { cursor:default; opacity:.55 }
|
|
224
|
+
.approve { position:relative; overflow:hidden; touch-action:none; user-select:none }
|
|
225
|
+
.approve::before { content:''; position:absolute; inset:0; background:#ff650055; transform:scaleX(0); transform-origin:left }
|
|
226
|
+
.approve.holding::before { transform:scaleX(1); transition:transform .9s linear }
|
|
227
|
+
.approve:focus-visible { outline:2px solid var(--orange); outline-offset:3px }
|
|
228
|
+
@media (prefers-reduced-motion:reduce) { .approve.holding::before { transition:none } }
|
|
207
229
|
details { border-top:1px solid var(--line); padding-top:10px; color:var(--muted); font-size:11px; line-height:1.5 }
|
|
208
230
|
summary { cursor:pointer; width:fit-content; padding:3px 0 }
|
|
209
231
|
summary:focus-visible { outline:2px solid var(--orange); outline-offset:3px }
|
|
@@ -218,7 +240,7 @@ var ADPORT_UI_HTML = String.raw`<!doctype html>
|
|
|
218
240
|
</head>
|
|
219
241
|
<body>
|
|
220
242
|
<main id="app" class="shell" aria-live="polite">
|
|
221
|
-
<header class="top"><div class="brand"><span class="dot"></
|
|
243
|
+
<header class="top"><div class="brand"><b>adport<span class="wordmark-dot" aria-hidden="true">.</span></b></div></header>
|
|
222
244
|
<section class="content"><div class="empty">Loading…</div></section>
|
|
223
245
|
</main>
|
|
224
246
|
<script>
|
|
@@ -259,7 +281,7 @@ var ADPORT_UI_HTML = String.raw`<!doctype html>
|
|
|
259
281
|
};
|
|
260
282
|
const logo = (id) => '<span class="logo '+esc(id)+'" aria-hidden="true">'+(providerSvg[id] || esc(initials(id)))+'</span>';
|
|
261
283
|
let syntheticResult = false;
|
|
262
|
-
const chrome = (body, context) => '<header class="top"><div class="brand"><span class="dot"></
|
|
284
|
+
const chrome = (body, context) => '<header class="top"><div class="brand"><b>adport<span class="wordmark-dot" aria-hidden="true">.</span></b></div><span class="context">'+(syntheticResult?'Synthetic demo · ':'')+esc(context || '')+'</span></header><section class="content">'+body+'</section>';
|
|
263
285
|
function renderAccounts(data, meta) {
|
|
264
286
|
const accounts = arr(data.accounts), errors = arr(data.errors), names = meta.providerNames || {};
|
|
265
287
|
const body = notices(data)+(accounts.length ? '<div class="list">'+accounts.map(a => { const status=statusOf(a.status); return '<div class="row"><div class="identity">'+logo(a.provider)+'<div class="identity-copy"><b>'+esc(a.name || 'Ad account')+'</b><span>'+esc(providerName(a.provider,names))+' · '+esc(a.id)+(a.currency ? ' · '+esc(a.currency) : '')+'</span></div></div><span class="pill '+status.tone+'">'+esc(status.label)+'</span></div>'; }).join('')+'</div>' : '<div class="empty">'+(errors.length ? 'Account inventory could not be fully loaded.' : 'No accessible ad accounts were returned.')+'</div>');
|
|
@@ -326,14 +348,37 @@ var ADPORT_UI_HTML = String.raw`<!doctype html>
|
|
|
326
348
|
const table=comparisons.length?'<table class="comparison" aria-label="Before and after"><thead><tr><th scope="col">Change</th><th scope="col">Before</th><th scope="col">After</th></tr></thead><tbody>'+comparisons.map(v=>'<tr><td>'+esc(v.label)+'</td><td>'+esc(v.before)+'</td><td class="'+(v.before!==v.after?'changed':'')+'">'+esc(v.after)+'</td></tr>').join('')+'</tbody></table>':'<p class="notice">No change details were returned. Review the tool response before applying.</p>';
|
|
327
349
|
const approval=meta.approval;
|
|
328
350
|
const canApprove=typeof pending==='string' && pending.length>0 && typeof preview.summary==='string' && preview.summary.trim() && approval?.arguments && typeof approval.arguments==='object' && !Array.isArray(approval.arguments) && typeof meta.tool==='string';
|
|
329
|
-
const action=canApprove?'<div class="approval"><button class="approve" data-approve="true" '+(state.approving?'disabled':'')+'>'+(state.approving?'Applying…':'
|
|
351
|
+
const action=canApprove?'<div class="approval"><button class="approve" data-approve="true" aria-label="Hold to approve and apply" '+(state.approving || state.approvalError?'disabled':'')+'>'+(state.approving?'Applying…':state.approvalError?'Check result in chat':'Hold to apply')+'</button><span class="context">Hold for 0.9s · release to cancel. Expires '+esc(data.expires_at || 'soon')+'</span></div>':'';
|
|
330
352
|
const body=(title?'<p class="operation-name">'+esc(title)+'</p>':'')+table+(changes.length>12?'<p class="notice">Showing 12 of '+changes.length+' changes. All changes are in Details.</p>':'')+coercions.map(v=>'<p class="adjustment">'+esc(v)+'</p>').join('')+(state.approvalError?'<p class="notice" role="alert">'+esc(state.approvalError)+'</p>':'')+action+(applied?'<p class="notice">Applied. '+esc(preview.summary || 'The change was submitted.')+'</p>':'')+'<details><summary>Details</summary><p>'+esc(validation)+'</p><p>'+esc(preview.summary || 'No change details returned.')+'</p>'+changes.map(v=>'<p>'+esc(v)+'</p>').join('')+(pending?'<p>Nothing has been changed. Apply requires the matching pending operation token before it expires.</p>':'')+'<p>'+esc(meta.tool || '')+'</p></details>';
|
|
331
353
|
app.innerHTML = chrome(body, applied?'Applied':pending?'Preview · Not applied':'Result');
|
|
332
|
-
if (canApprove) app.querySelectorAll('[data-approve]').forEach(button=>button
|
|
354
|
+
if (canApprove) app.querySelectorAll('[data-approve]').forEach(button=>bindHold(button,()=>approve(meta.tool,approval.arguments,pending)));
|
|
355
|
+
}
|
|
356
|
+
function bindHold(button,complete) {
|
|
357
|
+
let timer=null, interacted=false;
|
|
358
|
+
const cancel=()=>{clearTimeout(timer);timer=null;button.classList.remove('holding');};
|
|
359
|
+
const begin=event=>{
|
|
360
|
+
if (button.disabled || timer!==null) return;
|
|
361
|
+
if (event.type==='keydown') {
|
|
362
|
+
if (![' ','Enter'].includes(event.key) || event.repeat) return;
|
|
363
|
+
event.preventDefault();
|
|
364
|
+
} else {
|
|
365
|
+
if (event.button!==0) return;
|
|
366
|
+
button.setPointerCapture?.(event.pointerId);
|
|
367
|
+
}
|
|
368
|
+
interacted=true;button.classList.add('holding');
|
|
369
|
+
timer=setTimeout(()=>{cancel();complete();},900);
|
|
370
|
+
};
|
|
371
|
+
button.addEventListener('pointerdown',begin);
|
|
372
|
+
button.addEventListener('keydown',begin);
|
|
373
|
+
['pointerup','pointerleave','pointercancel','lostpointercapture','blur'].forEach(name=>button.addEventListener(name,cancel));
|
|
374
|
+
button.addEventListener('keyup',event=>{if ([' ','Enter','Escape'].includes(event.key)) cancel();});
|
|
375
|
+
button.addEventListener('contextmenu',event=>event.preventDefault());
|
|
376
|
+
// Screen-reader activation has no pointer/key sequence. Retain an accessible activation path.
|
|
377
|
+
button.addEventListener('click',event=>{if (event.detail===0 && !interacted && !button.disabled) complete();});
|
|
333
378
|
}
|
|
334
379
|
const pendingRequests=new Map();
|
|
335
380
|
async function approve(tool,args,pending) {
|
|
336
|
-
if (state.approving || !state.result) return;
|
|
381
|
+
if (state.approving || state.approvalError || !state.result) return;
|
|
337
382
|
state.approving=true;state.approvalError='';render(state.result);
|
|
338
383
|
const requestId=id++;
|
|
339
384
|
const response=new Promise((resolve,reject)=>{
|
|
@@ -343,14 +388,27 @@ var ADPORT_UI_HTML = String.raw`<!doctype html>
|
|
|
343
388
|
},30000);
|
|
344
389
|
pendingRequests.set(requestId,{resolve,reject,timer});
|
|
345
390
|
});
|
|
346
|
-
|
|
391
|
+
const parameters={...args,pending_operation_id:pending};
|
|
392
|
+
// Use the native ChatGPT bridge when supplied; never dispatch a second write as fallback.
|
|
393
|
+
if (typeof window.openai?.callTool==='function') {
|
|
394
|
+
Promise.resolve().then(()=>window.openai.callTool(tool,parameters)).then(result=>{
|
|
395
|
+
const request=pendingRequests.get(requestId);
|
|
396
|
+
if (request) {clearTimeout(request.timer);pendingRequests.delete(requestId);request.resolve(result);}
|
|
397
|
+
},error=>{
|
|
398
|
+
const request=pendingRequests.get(requestId);
|
|
399
|
+
if (request) {clearTimeout(request.timer);pendingRequests.delete(requestId);request.reject(error);}
|
|
400
|
+
});
|
|
401
|
+
} else send({jsonrpc:'2.0',id:requestId,method:'tools/call',params:{name:tool,arguments:parameters}});
|
|
347
402
|
try {
|
|
348
403
|
const result=await response;
|
|
349
404
|
if (!result || result.isError) throw new Error('Adport could not confirm the change. Check its status before retrying.');
|
|
350
|
-
|
|
405
|
+
let value=result.structuredContent || result;
|
|
406
|
+
if (!result.structuredContent && Array.isArray(result.content)) {
|
|
407
|
+
for (const item of result.content) {if (item.type==='text') {try {value=JSON.parse(item.text);break;} catch {}}}
|
|
408
|
+
}
|
|
351
409
|
const outcome=tool==='recommendation_apply'?value.result:value;
|
|
352
410
|
if (outcome?.applied!==true || outcome?.status!=='applied') throw new Error('The change was not confirmed as applied. Check its status before retrying.');
|
|
353
|
-
state.approving=false;state.approvalError='';acceptResult(result);
|
|
411
|
+
state.approving=false;state.approvalError='';acceptResult({structuredContent:{...value,_adport:{...(state.result.structuredContent?._adport || {}),...value._adport,approval:undefined}}});
|
|
354
412
|
} catch (error) {
|
|
355
413
|
state.approving=false;state.approvalError=error?.message || 'The change could not be confirmed. Check its status before retrying.';
|
|
356
414
|
render(state.result);
|
|
@@ -504,6 +562,7 @@ function createMcpServer({ runtime, name = "adport", version = package_default.v
|
|
|
504
562
|
})
|
|
505
563
|
);
|
|
506
564
|
for (const tool of runtime.registry.list()) {
|
|
565
|
+
if (productionOnly && (tool.name === "recommendation_apply" || /_api_(read|create|update|delete|remove)$/.test(tool.name))) continue;
|
|
507
566
|
const requiredScope = tool.annotations.readOnly ? "tools:read" : "tools:write";
|
|
508
567
|
const scopeDenial = scopes && !scopes.includes(requiredScope) ? scopeDenials?.[requiredScope] : void 0;
|
|
509
568
|
if (scopes && !scopes.includes(requiredScope) && !scopeDenial) continue;
|
|
@@ -522,6 +581,7 @@ Unavailable on the current plan: ${scopeDenial.message}` : tool.description,
|
|
|
522
581
|
...runtime.dataSource === "synthetic" ? { data_source: z.literal("synthetic") } : {}
|
|
523
582
|
}) } : {},
|
|
524
583
|
annotations: {
|
|
584
|
+
title: toolTitle(tool.name),
|
|
525
585
|
readOnlyHint: tool.annotations.readOnly ?? false,
|
|
526
586
|
destructiveHint: tool.annotations.destructive ?? false,
|
|
527
587
|
openWorldHint: tool.annotations.openWorld ?? false
|
|
@@ -605,4 +665,4 @@ export {
|
|
|
605
665
|
createMcpServer,
|
|
606
666
|
runStdioServer
|
|
607
667
|
};
|
|
608
|
-
//# sourceMappingURL=chunk-
|
|
668
|
+
//# sourceMappingURL=chunk-WN2KEUAP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../package.json","../src/ui.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { z } from 'zod';\nimport { registerAppResource, registerAppTool, RESOURCE_MIME_TYPE } from '@modelcontextprotocol/ext-apps/server';\nimport { AdportError, CredentialStore, createContext, type AdportRuntime, type ProviderModule } from '@adport/core';\nimport { createGoogleModule } from '@adport/provider-google';\nimport { createMetaModule } from '@adport/provider-meta';\nimport { createTikTokModule } from '@adport/provider-tiktok';\nimport { createAppleModule } from '@adport/provider-apple';\nimport { createMicrosoftModule } from '@adport/provider-microsoft';\nimport { createRedditModule } from '@adport/provider-reddit';\nimport { createSnapchatModule } from '@adport/provider-snapchat';\nimport { createSpotifyModule } from '@adport/provider-spotify';\nimport { createPinterestModule } from '@adport/provider-pinterest';\nimport { createLinkedInModule } from '@adport/provider-linkedin';\nimport { createXModule } from '@adport/provider-x';\nimport packageJson from '../package.json';\nimport {\n ADPORT_UI_HTML,\n ADPORT_UI_DOMAIN,\n ADPORT_UI_URI,\n structuredResult,\n toolInvocationLabels,\n toolTitle,\n viewForTool,\n} from './ui.js';\n\nexport const PROVIDER_IDS = ['google', 'meta', 'tiktok', 'apple', 'microsoft', 'reddit', 'snapchat', 'spotify', 'pinterest', 'linkedin', 'x'] as const;\n\nconst DEFAULT_MCP_ICONS = [{\n src: 'https://app.adport.dev/icon.svg?brand=orange-dot-v2',\n mimeType: 'image/svg+xml',\n sizes: ['any'],\n}];\n\n/**\n * Standard runtime assembly: real providers whose credentials exist. Mock data\n * is opt-in so a live runtime never silently substitutes synthetic accounts.\n */\nexport interface AssembleRuntimeOptions {\n includeMock?: boolean;\n}\n\nexport async function assembleRuntime(options: AssembleRuntimeOptions = {}): Promise<AdportRuntime> {\n const store = new CredentialStore();\n const modules: ProviderModule[] = [];\n const includeMock = options.includeMock ?? process.env.ADPORT_DEMO === 'true';\n if (!includeMock) {\n for (const factory of [createGoogleModule, createMetaModule, createTikTokModule, createAppleModule, createMicrosoftModule, createRedditModule, createSnapchatModule, createSpotifyModule, createPinterestModule, createLinkedInModule, createXModule]) {\n const module = await factory(store);\n if (module) modules.push(module);\n }\n }\n return createContext({ providerModules: modules, includeMock });\n}\n\nexport interface CreateServerOptions {\n runtime: AdportRuntime;\n name?: string;\n version?: string;\n /** Brand icons advertised to MCP clients during initialization. */\n icons?: Array<{ src: string; mimeType?: string; sizes?: string[] }>;\n /** When set by a remote transport, only register tools authorized by this key. */\n scopes?: readonly string[];\n /**\n * Register tools blocked by a dynamic entitlement and return this structured\n * error when called. Missing credential scopes without a denial stay hidden.\n */\n scopeDenials?: Readonly<Record<string, ToolScopeDenial | undefined>>;\n /** Hosted transports can replace local CLI setup guidance, without changing the error code. */\n notConnectedMessage?: string;\n /** Hosted production must never serve synthetic results or demo tool definitions. */\n productionOnly?: boolean;\n /** Host-specific MCP Apps sandbox domain; OpenAI's widget domain stays independent. */\n uiDomain?: string;\n}\n\nexport interface ToolScopeDenial {\n code: string;\n message: string;\n data?: Record<string, unknown>;\n}\n\n/**\n * Thin adapter: every tool in the shared registry becomes an MCP tool.\n * No tool logic lives here — see the \"one tool-definition layer\" principle.\n */\nexport function createMcpServer({ runtime, name = 'adport', version = packageJson.version, icons = DEFAULT_MCP_ICONS, scopes, scopeDenials, notConnectedMessage, productionOnly = false, uiDomain = ADPORT_UI_DOMAIN }: CreateServerOptions): McpServer {\n if (productionOnly && (runtime.dataSource === 'synthetic'\n || runtime.ctx.providers.list().some(provider => !PROVIDER_IDS.includes(provider.id as typeof PROVIDER_IDS[number]))\n || runtime.registry.list().some(tool => /^(demo|mock|synthetic)(_|$)/.test(tool.name) || /^(demo|mock|synthetic)$/.test(tool.namespace)))) {\n throw new AdportError('POLICY_VIOLATION', 'Demo tools and synthetic runtimes are not available on the production connector.');\n }\n const provenance = (value: unknown): unknown => runtime.dataSource === 'synthetic'\n ? { ...(value && typeof value === 'object' && !Array.isArray(value) ? value : { value }), data_source: 'synthetic' }\n : value;\n const server = new McpServer({ name, version, ...(icons ? { icons } : {}) });\n registerAppResource(\n server,\n 'Adport insight card',\n ADPORT_UI_URI,\n {\n description: 'Responsive Adport accounts, performance, recommendations, and guarded-change view.',\n _meta: {\n ui: { domain: uiDomain, prefersBorder: false, csp: { connectDomains: [], resourceDomains: [] } },\n 'openai/widgetDomain': ADPORT_UI_DOMAIN,\n },\n },\n async () => ({\n contents: [{\n uri: ADPORT_UI_URI,\n mimeType: RESOURCE_MIME_TYPE,\n text: ADPORT_UI_HTML,\n _meta: {\n ui: { domain: uiDomain, prefersBorder: false, csp: { connectDomains: [], resourceDomains: [] } },\n 'openai/widgetDomain': ADPORT_UI_DOMAIN,\n },\n }],\n }),\n );\n for (const tool of runtime.registry.list()) {\n // Hosted directory tools must expose each operation explicitly. Keep generic\n // dispatchers in the local CLI/stdio registry, never as a hosted escape hatch.\n if (productionOnly && (tool.name === 'recommendation_apply' || /_api_(read|create|update|delete|remove)$/.test(tool.name))) continue;\n const requiredScope = tool.annotations.readOnly ? 'tools:read' : 'tools:write';\n const scopeDenial = scopes && !scopes.includes(requiredScope) ? scopeDenials?.[requiredScope] : undefined;\n if (scopes && !scopes.includes(requiredScope) && !scopeDenial) continue;\n const view = viewForTool(tool.name, tool.annotations.readOnly ?? false);\n const labels = view ? toolInvocationLabels(view) : undefined;\n // MCP structuredContent must be an object. Preserve legacy raw arrays in\n // text/CLI results, exposing their declared schema under a value envelope.\n const wrapOutput = !!tool.output && !(tool.output instanceof z.ZodObject);\n const objectOutput = tool.output\n ? tool.output instanceof z.ZodObject ? tool.output : z.object({ value: tool.output })\n : undefined;\n const config = {\n title: toolTitle(tool.name),\n description: scopeDenial\n ? `${tool.description}\\n\\nUnavailable on the current plan: ${scopeDenial.message}`\n : tool.description,\n inputSchema: tool.input.shape,\n ...(objectOutput ? { outputSchema: objectOutput.extend({\n ...(view ? { _adport: z.object({ tool: z.literal(tool.name), view: z.literal(view), providerNames: z.record(z.string(), z.string()), approval: z.object({ arguments: z.record(z.string(), z.unknown()) }).optional() }) } : {}),\n ...(runtime.dataSource === 'synthetic' ? { data_source: z.literal('synthetic') } : {}),\n }) } : {}),\n annotations: {\n title: toolTitle(tool.name),\n readOnlyHint: tool.annotations.readOnly ?? false,\n destructiveHint: tool.annotations.destructive ?? false,\n openWorldHint: tool.annotations.openWorld ?? false,\n },\n };\n const callback = async (args: Record<string, unknown>) => {\n if (scopeDenial) {\n const payload = provenance({\n error: scopeDenial.code,\n code: scopeDenial.code,\n message: scopeDenial.message,\n ...scopeDenial.data,\n });\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify(payload, null, 2),\n }],\n // SDK clients validate structuredContent even on isError responses.\n // Errors use JSON text (also consumed by the widget), never a fake\n // success object to satisfy the advertised output schema.\n isError: true,\n };\n }\n try {\n const rawResult = await runtime.registry.call(tool.name, args, runtime.ctx);\n const result = provenance(rawResult);\n const structured = provenance(wrapOutput ? { value: rawResult } : rawResult);\n const rawObject = rawResult && typeof rawResult === 'object' && !Array.isArray(rawResult)\n ? rawResult as Record<string, unknown> : {};\n const nestedResult = rawObject.result && typeof rawObject.result === 'object' && !Array.isArray(rawObject.result)\n ? rawObject.result as Record<string, unknown> : {};\n const pending = rawObject.pending_operation_id ?? nestedResult.pending_operation_id;\n const approval = view === 'operation' && typeof pending === 'string' && !args.pending_operation_id\n ? { arguments: { ...args } }\n : undefined;\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }],\n ...(view ? { structuredContent: structuredResult(tool.name, view, structured, approval) }\n : tool.output ? { structuredContent: structured as Record<string, unknown> } : {}),\n };\n } catch (err) {\n const payload = provenance(\n err instanceof AdportError\n ? { ...err.toJSON(), ...(err.code === 'NOT_CONNECTED' && notConnectedMessage ? { message: notConnectedMessage } : {}) }\n : {\n error: 'INTERNAL',\n // Unexpected exceptions can contain credentials or private paths.\n // Do not imply that a failed response means a write was not applied.\n message: 'Adport could not complete this request. If this was a write, check its status before retrying. Contact support if the problem persists.',\n });\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(payload, null, 2) }],\n isError: true,\n };\n }\n };\n if (view) {\n registerAppTool(server, tool.name, {\n ...config,\n _meta: {\n ui: { resourceUri: ADPORT_UI_URI, visibility: ['model', 'app'] },\n 'openai/widgetAccessible': true,\n 'openai/outputTemplate': ADPORT_UI_URI,\n 'openai/toolInvocation/invoking': labels!.invoking,\n 'openai/toolInvocation/invoked': labels!.invoked,\n },\n }, callback);\n } else {\n server.registerTool(tool.name, config, callback);\n }\n }\n return server;\n}\n\nexport async function runStdioServer(runtime: AdportRuntime, version?: string): Promise<void> {\n const server = createMcpServer({ runtime, version });\n await server.connect(new StdioServerTransport());\n // stdout is the protocol channel; stderr is for humans.\n console.error(`adport MCP server on stdio (${runtime.registry.list().length} tools, policy: ${runtime.policySource})`);\n if (runtime.ctx.providers.list().length === 0) {\n console.error('No ad providers connected. Run `adport connect <provider>` or restart with `--demo` for synthetic mock data.');\n }\n}\n","{\n \"name\": \"@adport/mcp\",\n \"version\": \"0.7.0\",\n \"description\": \"adport MCP server — the open control plane for paid media\",\n \"license\": \"Apache-2.0\",\n \"type\": \"module\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n }\n },\n \"bin\": {\n \"adport-mcp\": \"./dist/bin.js\"\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/index.ts src/bin.ts --format esm --dts --sourcemap --clean\",\n \"render:submission-previews\": \"node scripts/render-submission-previews.mjs\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\",\n \"clean\": \"rm -rf dist\"\n },\n \"dependencies\": {\n \"@adport/core\": \"workspace:*\",\n \"@adport/provider-apple\": \"workspace:*\",\n \"@adport/provider-google\": \"workspace:*\",\n \"@adport/provider-meta\": \"workspace:*\",\n \"@adport/provider-microsoft\": \"workspace:*\",\n \"@adport/provider-reddit\": \"workspace:*\",\n \"@adport/provider-snapchat\": \"workspace:*\",\n \"@adport/provider-spotify\": \"workspace:*\",\n \"@adport/provider-pinterest\": \"workspace:*\",\n \"@adport/provider-linkedin\": \"workspace:*\",\n \"@adport/provider-x\": \"workspace:*\",\n \"@adport/provider-tiktok\": \"workspace:*\",\n \"@modelcontextprotocol/ext-apps\": \"^1.7.5\",\n \"@modelcontextprotocol/sdk\": \"^1.30.0\",\n \"zod\": \"^4.4.3\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^26.1.2\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.8.0\",\n \"vitest\": \"^4.1.10\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/ynnickw/adport.git\",\n \"directory\": \"packages/mcp\"\n },\n \"homepage\": \"https://github.com/ynnickw/adport#readme\",\n \"bugs\": {\n \"url\": \"https://github.com/ynnickw/adport/issues\"\n },\n \"engines\": {\n \"node\": \">=22.13\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","export const ADPORT_UI_URI = 'ui://adport/insight-card-v2.html';\nexport const ADPORT_UI_DOMAIN = 'https://app.adport.dev';\n\nexport type AdportView = 'accounts' | 'report' | 'operation' | 'insights';\n\nconst providerNames: Record<string, string> = {\n google: 'Google Ads',\n meta: 'Meta Ads',\n tiktok: 'TikTok Ads',\n apple: 'Apple Ads',\n microsoft: 'Microsoft Advertising',\n reddit: 'Reddit Ads',\n snapchat: 'Snapchat Ads',\n spotify: 'Spotify Ads',\n pinterest: 'Pinterest Ads',\n linkedin: 'LinkedIn Ads',\n x: 'X Ads',\n mock: 'Demo',\n demo: 'Synthetic demo',\n};\n\nexport function viewForTool(name: string, readOnly: boolean): AdportView | undefined {\n if (name === 'accounts_list') return 'accounts';\n if (name === 'report') return 'report';\n if (name === 'audit_run' || name === 'recommendation_dismiss') return 'insights';\n if (!readOnly) return 'operation';\n if (name.startsWith('recommendation') || name.startsWith('audit_')) return 'insights';\n return undefined;\n}\n\nexport function toolTitle(name: string): string {\n if (name === 'accounts_list') return 'Show connected ad accounts';\n if (name === 'report') return 'Show advertising performance';\n return name\n .split('_')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(' ');\n}\n\nexport function toolInvocationLabels(view: AdportView): { invoking: string; invoked: string } {\n switch (view) {\n case 'accounts': return { invoking: 'Loading ad accounts…', invoked: 'Ad accounts ready' };\n case 'report': return { invoking: 'Analyzing performance…', invoked: 'Performance ready' };\n // Descriptor labels cover both preview and apply; the card shows the actual result.\n case 'operation': return { invoking: 'Processing change…', invoked: 'Change result ready' };\n case 'insights': return { invoking: 'Reviewing opportunities…', invoked: 'Opportunities ready' };\n }\n}\n\nexport function structuredResult(tool: string, view: AdportView, result: unknown, approval?: { arguments: Record<string, unknown> }): Record<string, unknown> {\n const payload = result && typeof result === 'object' && !Array.isArray(result)\n ? result as Record<string, unknown>\n : { value: result };\n return {\n ...payload,\n _adport: {\n tool,\n view,\n providerNames,\n ...(approval ? { approval } : {}),\n },\n };\n}\n\n/**\n * Self-contained MCP App. It uses the open MCP Apps postMessage protocol and\n * has no network dependencies, which keeps its review CSP intentionally empty.\n */\nexport const ADPORT_UI_HTML = String.raw`<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" />\n <meta name=\"color-scheme\" content=\"light dark\" />\n <title>Adport insight</title>\n <style>\n :root {\n --ink: var(--color-text-primary, #171717);\n --muted: var(--color-text-secondary, #6f6f73);\n --faint: var(--color-text-tertiary, #949499);\n --paper: var(--color-background-primary, #ffffff);\n --soft: var(--color-background-secondary, #f6f6f4);\n --line: var(--color-border-secondary, rgba(23,23,23,.11));\n --orange: #ff5a1f;\n --green: #16845b;\n --red: #c8392f;\n --amber: #a86500;\n --radius: var(--border-radius-lg, 18px);\n --sans: var(--font-sans, ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif);\n --mono: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);\n }\n * { box-sizing: border-box }\n html, body { margin: 0; min-width: 0; background: transparent; color: var(--ink); font-family: var(--sans) }\n body { padding: 2px; }\n button { font: inherit }\n .shell { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 10px 32px rgba(20,20,20,.07) }\n .top { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:14px 16px 10px }\n .brand { display:flex; align-items:center; gap:9px; min-width:0 }\n .wordmark-dot { color:#ff6b00; font-size:1.3em; line-height:0 }\n .brand b { font-size:12px; letter-spacing:-.02em }\n .context { color:var(--muted); font-size:11px; text-align:right }\n .content { padding:4px 16px 16px }\n .kpis { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; margin-bottom:15px }\n .kpi { min-width:0; padding:12px; border-radius:13px; background:var(--soft); border:1px solid color-mix(in srgb,var(--line) 70%,transparent) }\n button.kpi { cursor:pointer; color:var(--ink); text-align:left }\n button.kpi[aria-pressed=\"true\"] { border-color:color-mix(in srgb,var(--orange) 65%,var(--line)) }\n .kpi small { display:block; color:var(--faint); font:600 9px/1.2 var(--mono); letter-spacing:.11em; text-transform:uppercase }\n .kpi strong { display:block; overflow:hidden; margin-top:8px; font-size:clamp(17px,3vw,24px); line-height:1; letter-spacing:-.04em; text-overflow:ellipsis }\n .panel { min-width:0; padding:13px; border:1px solid var(--line); border-radius:14px }\n .panel-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px }\n .panel-head b { font-size:12px }\n .panel-head span { color:var(--faint); font:500 9px/1 var(--mono); text-transform:uppercase; letter-spacing:.1em }\n .bars { display:grid; gap:9px }\n .bar-row { display:grid; grid-template-columns:minmax(100px,1fr) minmax(60px,2fr) auto; align-items:center; gap:9px; font-size:11px }\n .bar-name { display:flex; align-items:center; gap:7px; min-width:0 }\n .bar-name > span:last-child { overflow:hidden; white-space:nowrap; text-overflow:ellipsis }\n .bar-name .logo { width:22px; height:22px; padding:4px; border-radius:6px }\n .track { height:7px; overflow:hidden; border-radius:99px; background:var(--soft) }\n .fill { height:100%; border-radius:99px; background:linear-gradient(90deg,var(--orange),#ff985e) }\n .tabs { display:flex; gap:6px; overflow:auto; padding-bottom:12px }\n .tabs button { flex:0 0 auto; cursor:pointer; padding:8px 12px; border:1px solid var(--line); border-radius:99px; background:var(--paper); color:var(--muted); font-size:12px }\n .tabs button[aria-pressed=\"true\"] { color:var(--ink); border-color:var(--orange); background:color-mix(in srgb,var(--orange) 8%,var(--paper)) }\n button:focus-visible { outline:2px solid var(--orange); outline-offset:2px }\n .notice { padding:10px 12px; margin:0 0 12px; border-radius:10px; background:var(--soft); color:var(--muted); font-size:12px; line-height:1.45 }\n .bar-value { color:var(--muted); font:600 10px/1 var(--mono); white-space:nowrap }\n .list { display:grid; gap:7px }\n .row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 11px; border:1px solid var(--line); border-radius:12px }\n .identity { display:flex; align-items:center; gap:10px; min-width:0 }\n .logo { display:grid; place-items:center; flex:0 0 auto; width:29px; height:29px; padding:6px; border:1px solid var(--line); border-radius:9px; color:var(--ink); background:var(--paper); font-weight:800; font-size:10px }\n .logo svg { display:block; width:100%; height:100% }\n .logo.reddit { background:#ff4500 }.logo.linkedin { background:#0a66c2 }.logo.spotify { background:#1db954 }.logo.pinterest { background:#e60023 }.logo.x { background:#111 }.logo.snapchat { background:#fffc00;color:#111 }\n .identity-copy { min-width:0 }\n .identity-copy b, .identity-copy span { display:block; overflow:hidden; white-space:nowrap; text-overflow:ellipsis }\n .identity-copy b { font-size:12px }.identity-copy span { margin-top:3px; color:var(--muted); font-size:10px }\n .pill { flex:0 0 auto; padding:5px 8px; border-radius:99px; color:var(--green); background:color-mix(in srgb,var(--green) 10%,transparent); font:700 9px/1 var(--mono); letter-spacing:.08em; text-transform:uppercase }\n .pill.warn { color:var(--amber); background:color-mix(in srgb,var(--amber) 11%,transparent) }\n .pill.danger { color:var(--red); background:color-mix(in srgb,var(--red) 10%,transparent) }\n .pill.neutral { color:var(--muted); background:var(--soft) }\n .operation-name { margin:2px 0 16px; font-size:14px; line-height:1.4; font-weight:600; overflow-wrap:anywhere }\n .comparison { width:100%; border-collapse:collapse; table-layout:fixed; margin-bottom:12px }\n .comparison th { padding:0 8px 8px; color:var(--muted); font-size:10px; font-weight:500; text-align:left }\n .comparison td { border-top:1px solid var(--line); padding:12px 8px; font-size:14px; overflow-wrap:anywhere }\n .comparison td:first-child { color:var(--muted); font-size:11px }\n .comparison td:last-child { font-weight:600 }\n .comparison .changed { color:var(--orange) }\n .adjustment { margin:8px 0; color:var(--amber); font-size:11px; line-height:1.4 }\n .approval { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin:12px 0 }\n .approve { cursor:pointer; padding:9px 16px; border:0; border-radius:99px; background:var(--ink); color:var(--paper); font-size:12px; font-weight:700 }\n .approve:disabled { cursor:default; opacity:.55 }\n .approve { position:relative; overflow:hidden; touch-action:none; user-select:none }\n .approve::before { content:''; position:absolute; inset:0; background:#ff650055; transform:scaleX(0); transform-origin:left }\n .approve.holding::before { transform:scaleX(1); transition:transform .9s linear }\n .approve:focus-visible { outline:2px solid var(--orange); outline-offset:3px }\n @media (prefers-reduced-motion:reduce) { .approve.holding::before { transition:none } }\n details { border-top:1px solid var(--line); padding-top:10px; color:var(--muted); font-size:11px; line-height:1.5 }\n summary { cursor:pointer; width:fit-content; padding:3px 0 }\n summary:focus-visible { outline:2px solid var(--orange); outline-offset:3px }\n details p { margin:8px 0; overflow-wrap:anywhere }\n .empty { padding:26px 12px; text-align:center; color:var(--muted); font-size:12px }\n @media (max-width:620px) { .kpis { grid-template-columns:repeat(2,minmax(0,1fr)) }.top,.content { padding-left:12px; padding-right:12px } }\n @media (max-width:420px) { .bar-row { grid-template-columns:minmax(0,1fr) auto; gap:5px }.bar-name { grid-column:1/-1 }.bar-name > span:last-child { white-space:normal }.bars { gap:12px } }\n @media (prefers-reduced-motion:reduce) { * { animation:none!important; transition:none!important } }\n :root[data-theme=\"dark\"] { --ink:#f5f5f3;--muted:#aaa9ad;--faint:#a09fa5;--paper:#171717;--soft:#222220;--line:rgba(255,255,255,.11) }\n @media (prefers-color-scheme:dark) { :root:not([data-theme=\"light\"]) { --ink:#f5f5f3;--muted:#aaa9ad;--faint:#a09fa5;--paper:#171717;--soft:#222220;--line:rgba(255,255,255,.11) } }\n </style>\n</head>\n<body>\n <main id=\"app\" class=\"shell\" aria-live=\"polite\">\n <header class=\"top\"><div class=\"brand\"><b>adport<span class=\"wordmark-dot\" aria-hidden=\"true\">.</span></b></div></header>\n <section class=\"content\"><div class=\"empty\">Loading…</div></section>\n </main>\n <script>\n (() => {\n const app = document.getElementById('app');\n const state = { host: {}, result: null, reportGroup: null, reportMetric: 'spend', approving: false, approvalError: '' };\n const esc = (value) => String(value ?? '').replace(/[&<>\"']/g, (c) => ({'&':'&','<':'<','>':'>','\"':'"',\"'\":'''}[c]));\n const arr = (value) => Array.isArray(value) ? value : [];\n const num = (value) => Number.isFinite(Number(value)) ? Number(value) : 0;\n const money = (value, currency, maximumFractionDigits=2) => currency\n ? new Intl.NumberFormat(state.host.locale || 'en', { style:'currency', currency, maximumFractionDigits }).format(num(value))\n : new Intl.NumberFormat(state.host.locale || 'en', { maximumFractionDigits }).format(num(value));\n const compact = (value) => new Intl.NumberFormat(state.host.locale || 'en', { notation:'compact', maximumFractionDigits:1 }).format(num(value));\n const available = (value) => typeof value === 'number' && Number.isFinite(value);\n const total = (rows, key) => rows.length && rows.every(r => available(r.metrics?.[key])) ? rows.reduce((sum,r) => sum+r.metrics[key],0) : null;\n const rowReturn = (row) => {\n const m=row.metrics || {};\n if (available(m.conversion_value)) return m.conversion_value;\n // A report can request ROAS without conversion_value. Weight reported\n // ratios by spend; never average campaign ratios or infer missing revenue.\n const value=available(m.spend) && m.spend>0 && available(m.roas) ? m.spend*m.roas : null;\n return available(value) ? value : null;\n };\n const currencyOf = (row) => typeof row.currency === 'string' && /^[A-Z]{3}$/.test(row.currency) ? row.currency : null;\n const statusOf = (status) => !status || /unknown|unspecified/i.test(status) ? {label:'Status unavailable',tone:'neutral'} : /disabled|removed|inactive|closed|suspended/i.test(status) ? {label:status,tone:'danger'} : /paused|disable$/i.test(status) ? {label:status,tone:'warn'} : /^(enabled|active|approved)$/i.test(status) ? {label:status,tone:''} : {label:status,tone:'neutral'};\n const notices = (data) => [...arr(data.errors).map(e => (e.provider || 'Provider')+': '+(e.message || 'Read failed')), ...arr(data.warnings).map(e => e.message || 'Some metadata is unavailable'), ...(data.truncated ? ['Partial result: row limit reached. Totals and charts cover returned rows only.'] : [])].map(text => '<p class=\"notice\">'+esc(text)+'</p>').join('');\n const providerName = (id, names) => names?.[id] || String(id || 'Provider');\n const initials = (id) => ({snapchat:'S',spotify:'S',pinterest:'P',linkedin:'in',x:'X'}[id] || String(id || '?').slice(0,2).toUpperCase());\n const providerSvg = {\n // Unmodified official Ghost paths, matching cloud/components/snapchat-logo.tsx.\n snapchat:\"<svg viewBox=\\\"0 0 1024 1024\\\" aria-hidden=\\\"true\\\"> <path fill=\\\"#fff\\\" d=\\\"M992.5,756.3c-4.2-13.9-24.3-23.7-24.3-23.7l0,0c-1.9-1-3.6-1.9-5-2.6c-33.5-16.2-63.2-35.7-88.2-57.8 c-20.1-17.8-37.3-37.4-51.1-58.2c-16.9-25.4-24.8-46.6-28.2-58.1c-1.9-7.5-1.6-10.5,0-14.4c1.3-3.3,5.2-6.4,7-7.9 c11.3-8,29.5-19.8,40.7-27c9.7-6.3,18-11.7,22.9-15.1c15.7-11,26.5-22.2,32.8-34.3c8.2-15.6,9.2-32.8,2.8-49.7 c-8.6-22.8-29.9-36.4-57-36.4c-6,0-12.2,0.7-18.4,2c-15.5,3.4-30.2,8.9-42.5,13.7c-0.9,0.4-1.9-0.3-1.8-1.3 c1.3-30.5,2.8-71.5-0.6-110.4c-3-35.2-10.3-64.9-22.1-90.8c-11.9-26-27.4-45.2-39.5-59.1C708.5,112,688.2,92.5,657.6,75 C614.6,50.4,565.6,37.9,512,37.9c-53.5,0-102.4,12.5-145.5,37.1c-32.4,18.5-53.1,39.4-62.5,50.2c-12.1,13.9-27.6,33.1-39.5,59.1 c-11.9,25.9-19.1,55.5-22.1,90.8c-3.4,39.1-2,76.8-0.6,110.4c0,1-0.9,1.7-1.9,1.3c-12.3-4.8-27-10.3-42.5-13.7 c-6.1-1.3-12.3-2-18.4-2c-27,0-48.3,13.6-57,36.4c-6.4,16.9-5.4,34.1,2.8,49.7c6.4,12.1,17.1,23.3,32.8,34.3 c4.8,3.4,13.2,8.8,22.9,15.1c10.9,7.1,28.6,18.6,40,26.5c1.4,1,6.2,4.6,7.7,8.4c1.6,4,1.9,7-0.2,15c-3.5,11.6-11.4,32.6-28,57.5 c-13.8,20.9-31,40.4-51.1,58.2c-25,22.1-54.7,41.6-88.2,57.8c-1.6,0.8-3.5,1.7-5.5,2.9l0,0c0,0-20,10.2-23.8,23.4 c-5.6,19.5,9.3,37.8,24.4,47.6c24.8,16,55,24.6,72.5,29.3c4.9,1.3,9.3,2.5,13.3,3.7c2.5,0.8,8.8,3.2,11.5,6.7 c3.4,4.4,3.8,9.8,5,15.9v0c1.9,10.3,6.2,23,18.9,31.8c14,9.6,31.7,10.3,54.2,11.2c23.5,0.9,52.7,2,86.2,13.1 c15.5,5.1,29.6,13.8,45.8,23.8c34,20.9,76.3,46.9,148.5,46.9c72.3,0,114.9-26.1,149.1-47.1c16.2-9.9,30.1-18.5,45.3-23.5 c33.5-11.1,62.7-12.2,86.2-13.1c22.5-0.9,40.2-1.5,54.2-11.2c13.6-9.4,17.5-23.4,19.3-33.9c1-5.2,1.6-9.9,4.6-13.7 c2.6-3.3,8.4-5.6,11.1-6.5c4.1-1.3,8.7-2.5,13.8-3.9c17.5-4.7,39.5-10.2,66.2-25.3C993.7,789.8,995.9,767.4,992.5,756.3z\\\" /> <path fill=\\\"#000\\\" d=\\\"M1020.3,745.5c-7.1-19.4-20.7-29.7-36.1-38.3c-2.9-1.7-5.6-3.1-7.8-4.1c-4.6-2.4-9.3-4.7-14-7.1 c-48.1-25.5-85.7-57.7-111.7-95.8c-8.8-12.9-14.9-24.5-19.2-34c-2.2-6.4-2.1-10-0.5-13.3c1.2-2.5,4.4-5.1,6.2-6.4 c8.3-5.5,16.8-11,22.6-14.7c10.3-6.7,18.5-12,23.7-15.6c19.8-13.8,33.6-28.5,42.2-44.9c12.2-23.1,13.7-49.5,4.3-74.3 c-13-34.4-45.6-55.8-85-55.8c-8.2,0-16.5,0.9-24.7,2.7c-2.2,0.5-4.3,1-6.4,1.5c0.4-23.4-0.2-48.4-2.3-72.8 c-7.4-86-37.5-131.1-68.9-167c-13.1-15-35.9-36.9-70.1-56.5C624.9,21.7,570.9,7.9,512,7.9c-58.7,0-112.7,13.8-160.4,41.1 c-34.4,19.6-57.2,41.6-70.2,56.5c-31.4,35.9-61.5,81-68.9,167c-2.1,24.4-2.6,49.4-2.3,72.8c-2.1-0.5-4.3-1-6.4-1.5 c-8.2-1.8-16.6-2.7-24.7-2.7c-39.4,0-72,21.4-85,55.8c-9.4,24.8-7.9,51.2,4.3,74.3c8.6,16.4,22.5,31.1,42.2,44.9 c5.3,3.7,13.4,9,23.7,15.6c5.6,3.6,13.7,8.9,21.7,14.2c1.2,0.8,5.5,4,7,7c1.7,3.4,1.7,7.1-0.8,13.9c-4.2,9.3-10.3,20.7-18.9,33.3 c-25.5,37.3-62,68.9-108.5,94.1c-24.7,13.1-50.3,21.8-61.1,51.2c-8.2,22.2-2.8,47.5,17.9,68.8l0,0c6.8,7.3,15.4,13.8,26.2,19.8 c25.4,14,47,20.9,64,25.6c3,0.9,9.9,3.1,12.9,5.8c7.6,6.6,6.5,16.6,16.6,31.2c6.1,9.1,13.1,15.3,18.9,19.3 c21.1,14.6,44.9,15.5,70.1,16.5c22.7,0.9,48.5,1.9,77.9,11.6c12.2,4,24.9,11.8,39.5,20.8c35.2,21.7,83.5,51.3,164.2,51.3 c80.8,0,129.3-29.8,164.8-51.5c14.6-8.9,27.2-16.7,39-20.6c29.4-9.7,55.2-10.7,77.9-11.6c25.2-1,48.9-1.9,70.1-16.5 c6.6-4.6,15-12.1,21.6-23.5c7.2-12.3,7.1-21,13.9-26.9c2.8-2.4,8.9-4.5,12.2-5.5c17.1-4.7,39-11.6,64.9-25.9 c11.5-6.3,20.4-13.2,27.5-21.1c0.1-0.1,0.2-0.2,0.3-0.3C1023.4,791.7,1028.3,767.2,1020.3,745.5z M948.6,784 c-43.8,24.2-72.9,21.6-95.5,36.1c-19.2,12.4-7.9,39.1-21.8,48.7c-17.2,11.9-67.9-0.8-133.4,20.8c-54,17.9-88.5,69.2-185.8,69.2 c-97.5,0-131-51.1-185.8-69.2c-65.5-21.6-116.3-8.9-133.4-20.8c-13.9-9.6-2.6-36.3-21.8-48.7c-22.6-14.6-51.7-12-95.5-36.1 c-27.9-15.4-12.1-24.9-2.8-29.4c158.6-76.7,183.8-195.3,185-204.2c1.4-10.6,2.9-19-8.8-29.9c-11.3-10.5-61.6-41.6-75.5-51.3 c-23.1-16.1-33.2-32.2-25.7-52c5.2-13.7,18-18.8,31.5-18.8c4.2,0,8.5,0.5,12.6,1.4c25.3,5.5,49.9,18.2,64.1,21.6 c2,0.5,3.7,0.7,5.2,0.7c7.6,0,10.2-3.8,9.7-12.5c-1.6-27.7-5.6-81.7-1.2-132.2c6-69.4,28.4-103.8,55-134.3 c12.8-14.6,72.8-78,187.5-78c115,0,174.7,63.4,187.5,78c26.6,30.4,49,64.8,55,134.3c4.4,50.5,0.6,104.5-1.2,132.2 c-0.6,9.1,2.2,12.5,9.7,12.5c1.5,0,3.3-0.2,5.2-0.7c14.2-3.4,38.8-16.1,64.1-21.6c4.1-0.9,8.4-1.4,12.6-1.4 c13.5,0,26.3,5.2,31.5,18.8c7.5,19.8-2.7,35.9-25.7,52c-13.9,9.7-64.2,40.8-75.5,51.3c-11.7,10.8-10.2,19.2-8.8,29.9 c1.1,8.9,26.4,127.5,185,204.2C960.6,759.1,976.5,768.6,948.6,784z\\\" /> </svg>\",\n google:'<svg viewBox=\"0 0 24 24\"><path fill=\"#34a853\" d=\"M4 22.93a4 4 0 1 1 0-8 4 4 0 0 1 0 8Z\"/><path fill=\"#4285f4\" d=\"M23.464 16.929 15.463 3.072A4 4 0 0 0 8.534 7.072l8.001 13.857a4 4 0 0 0 6.929-4Z\"/><path fill=\"#fbbc04\" d=\"M7.514 4.844 1.565 15.148A4.5 4.5 0 0 1 4 14.43a4.5 4.5 0 0 1 4.494 4.715l3.217-5.573-3.61-6.25a4 4 0 0 1-.587-2.478Z\"/></svg>',\n meta:'<svg viewBox=\"0 0 24 24\"><path fill=\"#0866ff\" d=\"M6.915 4.03C2.484 4.03 0 9.95 0 14.449c0 3.37 1.276 5.521 4.439 5.521 2.93 0 4.146-2.574 6.628-6.764l.942-1.664 2.335 3.895c1.883 3.15 3.38 4.533 5.53 4.533 2.788 0 4.126-1.93 4.126-5.56 0-5.53-2.73-10.38-6.8-10.38-2.04 0-3.835 1.53-5.173 3.348C10.16 5.01 8.593 4.03 6.915 4.03Zm-.04 2.606c1.55 0 2.445 1.193 3.908 3.025l-1.02 1.566c-2.22 3.41-3.576 6.155-5.323 6.155-1.23 0-2.154-1.075-2.154-2.9 0-3.755 2.088-7.846 4.588-7.846Zm10.2-.553c2.488 0 4.639 4.054 4.639 8.4 0 1.547-.368 2.899-1.839 2.899-1.193 0-2.027-1.42-4.496-5.362l-1.872-3.008c1.12-1.814 2.248-2.929 3.559-2.929Z\"/></svg>',\n tiktok:'<svg viewBox=\"0 0 58 58\"><path fill=\"#2dccd3\" d=\"M25.98 0v37.68c0 4.94-3.55 8.11-7.88 8.11-1.43 0-2.79-.33-3.97-.95 1.5 1.91 3.87 3.01 6.47 3.01 4.32 0 7.87-3.17 7.87-8.11V2.06h6.85A20.3 20.3 0 0 1 34.87 0h-8.89Z\"/><path fill=\"#f1204a\" d=\"M41.73 11.11a17.48 17.48 0 0 1-4.37-9.05h-2.04c1.16 4.23 3.56 7.18 6.41 9.05Zm7.63 11.37a19.31 19.31 0 0 1-11-2.97c3.84 3.84 8.5 5.03 13.5 5.03v-8.82a17.4 17.4 0 0 1-2.5-.37v7.13Z\"/><path fill=\"currentColor\" d=\"M35.32 2.06h-6.85v37.68c0 4.94-3.55 8.11-7.87 8.11-2.6 0-4.97-1.1-6.47-3.01-2.48-1.29-4.19-3.82-4.19-7.16 0-5.71 4.47-8.71 10.42-8.09v-7.68C10.63 21.93 2.49 29.73 2.49 39.4c0 5.16 2.04 9.71 5.32 12.96 2.89 1.97 6.39 3.11 10.15 3.11 8.69 0 17.91-6.38 17.91-18.41V17.45c.8.8 1.63 1.48 2.49 2.06a19.31 19.31 0 0 0 11 2.97v-7.13a16.14 16.14 0 0 1-7.63-4.24c-2.85-1.87-5.25-4.82-6.41-9.05Z\"/></svg>',\n apple:'<svg viewBox=\"0 0 24 24\"><path fill=\"currentColor\" d=\"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09Zm3.377-3.065C16.372 2.819 16.929 1.403 16.774 0c-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.56-1.701Z\"/></svg>',\n microsoft:'<svg viewBox=\"0 0 24 24\"><path fill=\"#f25022\" d=\"M0 0h11.4v11.4H0Z\"/><path fill=\"#7fba00\" d=\"M12.6 0H24v11.4H12.6Z\"/><path fill=\"#00a4ef\" d=\"M0 12.6h11.4V24H0Z\"/><path fill=\"#ffb900\" d=\"M12.6 12.6H24V24H12.6Z\"/></svg>',\n reddit:'<svg viewBox=\"0 0 24 24\"><path fill=\"#ff4500\" d=\"M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0Zm5.01 4.744c.688 0 1.25.561 1.25 1.249a1.25 1.25 0 0 1-2.498.056l-2.597-.547-.8 3.747c1.824.07 3.48.632 4.674 1.488.308-.309.73-.491 1.207-.491.968 0 1.754.786 1.754 1.754 0 .716-.435 1.333-1.01 1.614.028.169.042.342.042.52 0 2.694-3.13 4.87-7.004 4.87-3.874 0-7.004-2.176-7.004-4.87 0-.183.015-.366.043-.534A1.748 1.748 0 0 1 4.028 12c0-.968.786-1.754 1.754-1.754.463 0 .898.196 1.207.49 1.207-.883 2.878-1.43 4.744-1.487l.885-4.182a.342.342 0 0 1 .378-.239l2.906.617a1.214 1.214 0 0 1 1.108-.701Z\"/></svg>'\n };\n const logo = (id) => '<span class=\"logo '+esc(id)+'\" aria-hidden=\"true\">'+(providerSvg[id] || esc(initials(id)))+'</span>';\n let syntheticResult = false;\n const chrome = (body, context) => '<header class=\"top\"><div class=\"brand\"><b>adport<span class=\"wordmark-dot\" aria-hidden=\"true\">.</span></b></div><span class=\"context\">'+(syntheticResult?'Synthetic demo · ':'')+esc(context || '')+'</span></header><section class=\"content\">'+body+'</section>';\n function renderAccounts(data, meta) {\n const accounts = arr(data.accounts), errors = arr(data.errors), names = meta.providerNames || {};\n const body = notices(data)+(accounts.length ? '<div class=\"list\">'+accounts.map(a => { const status=statusOf(a.status); return '<div class=\"row\"><div class=\"identity\">'+logo(a.provider)+'<div class=\"identity-copy\"><b>'+esc(a.name || 'Ad account')+'</b><span>'+esc(providerName(a.provider,names))+' · '+esc(a.id)+(a.currency ? ' · '+esc(a.currency) : '')+'</span></div></div><span class=\"pill '+status.tone+'\">'+esc(status.label)+'</span></div>'; }).join('')+'</div>' : '<div class=\"empty\">'+(errors.length ? 'Account inventory could not be fully loaded.' : 'No accessible ad accounts were returned.')+'</div>');\n app.innerHTML = chrome(body, accounts.length+' account'+(accounts.length===1?'':'s'));\n }\n function renderReport(data) {\n const groups = new Map();\n for (const row of arr(data.rows)) {\n const currency=currencyOf(row), key=currency || JSON.stringify([row.provider,row.accountId]);\n if (!groups.has(key)) groups.set(key,{key,currency,label:currency || (row.provider+' · '+row.accountId),rows:[]});\n groups.get(key).rows.push(row);\n }\n const choices=[...groups.values()];\n const selected=groups.get(state.reportGroup) || choices[0];\n const rows=selected?.rows || [], currency=selected?.currency;\n state.reportGroup=selected?.key;\n const tabs=choices.length>1 ? '<div class=\"tabs\" role=\"group\" aria-label=\"Report currency or account\">'+choices.map((g,i)=>'<button data-group=\"'+i+'\" aria-pressed=\"'+(g===selected)+'\">'+esc(g.label)+'</button>').join('')+'</div>' : '';\n const summary=arr(data.summary?.groups).find(group=>group.key===selected?.key)?.metrics;\n const aggregate=key=>summary ? (available(summary[key])?summary[key]:null) : total(rows,key);\n const spend=aggregate('spend'), returns=rows.map(rowReturn);\n const value=returns.length && returns.every(available) ? returns.reduce((sum,value)=>sum+value,0) : null;\n const ratio=summary ? summary.roas : spend>0 && value!==null ? value/spend : null;\n const roas=available(ratio) ? ratio.toFixed(2)+'×' : '—';\n const metric=state.reportMetric, labels={spend:'Spend',clicks:'Clicks',conversions:'Conversions',roas:'ROAS'};\n const metricValue=r=>metric==='roas' ? (available(r.metrics?.conversion_value) && r.metrics?.spend>0 ? r.metrics.conversion_value/r.metrics.spend : r.metrics?.roas) : r.metrics?.[metric];\n const format=value=>metric==='spend'?money(value,currency):metric==='roas'?value.toFixed(2)+'×':compact(value);\n const ranked=[...rows].filter(r=>available(metricValue(r))).sort((a,b)=>metricValue(b)-metricValue(a)).slice(0,6), max=Math.max(1,...ranked.map(metricValue));\n const bars=ranked.length ? ranked.map(r=>'<div class=\"bar-row\"><span class=\"bar-name\" title=\"'+esc(r.entity?.name || r.entity?.id)+'\">'+logo(r.provider)+'<span>'+esc(r.entity?.name || r.entity?.id || 'Entity')+'</span></span><span class=\"track\" aria-hidden=\"true\"><span class=\"fill\" style=\"display:block;width:'+Math.max(0,metricValue(r)/max*100).toFixed(1)+'%\"></span></span><span class=\"bar-value\">'+esc(format(metricValue(r)))+'</span></div>').join('') : '<div class=\"empty\">No '+esc(labels[metric])+' values were returned.</div>';\n const kpi=(key,label,value)=>'<button class=\"kpi\" data-metric=\"'+key+'\" aria-pressed=\"'+(metric===key)+'\" aria-label=\"Chart '+esc(label)+'\"><small>'+esc(label)+'</small><strong>'+esc(value)+'</strong></button>';\n const period=typeof data.date_range==='string' ? data.date_range.replaceAll('_',' ') : data.date_range ? data.date_range.start+' – '+data.date_range.end : 'Selected period';\n const body=notices(data)+tabs+(rows.length ? (!currency?'<p class=\"notice\">Currency unavailable. These values belong to this account only; no cross-account money total is calculated.</p>':'')+'<div class=\"kpis\" role=\"group\" aria-label=\"Chart metric\">'+kpi('spend','Spend',spend===null?'—':money(spend,currency))+kpi('clicks','Clicks',total(rows,'clicks')===null?'—':compact(total(rows,'clicks')))+kpi('conversions','Conversions',total(rows,'conversions')===null?'—':compact(total(rows,'conversions')))+kpi('roas','ROAS',roas)+'</div><div class=\"panel\"><div class=\"panel-head\"><b>'+esc(labels[metric])+'</b><span>Top '+ranked.length+' of '+rows.length+' rows</span></div><div class=\"bars\">'+bars+'</div></div>' : '<div class=\"empty\">'+(arr(data.errors).length?'Report unavailable for the requested providers.':'No rows returned for this period.')+'</div>');\n app.innerHTML=chrome(body,period+(currency?' · '+currency:''));\n app.querySelectorAll('[data-group]').forEach(button=>button.addEventListener('click',()=>{state.reportGroup=choices[Number(button.dataset.group)].key;renderReport(data);}));\n app.querySelectorAll('[data-metric]').forEach(button=>button.addEventListener('click',()=>{state.reportMetric=button.dataset.metric;renderReport(data);}));\n }\n function renderOperation(data, meta) {\n if (meta.tool === 'recommendation_apply' && data.result) data = data.result;\n const preview = data.preview || {}, pending = data.pending_operation_id, applied = data.status === 'applied' || data.applied === true;\n const changes = arr(preview.changes), coercions = arr(preview.coercions), deltas = arr(preview.budgetDeltas);\n // Review amounts must preserve micros; rounded report totals are not suitable for consent.\n const comparisons=deltas.map(v=>{const currency=currencyOf(v);return {label:(v.target || 'Budget')+(currency?' · '+currency:' (account units)'),before:available(v.fromMicros)?money(v.fromMicros/1e6,currency,6):'—',after:available(v.toMicros)?money(v.toMicros/1e6,currency,6):'—'};});\n // Split only explicit field/value arrows. Freeform JSON updates still\n // show the proposed payload, but never claim a previous value.\n for (const change of changes) {\n const match=String(change).match(/^~\\s+(?:.+?\\s+)?(status|configured_status|bidding_strategy|delivery|bid|dailyBudget\\.value|DailyBudget|value)\\s*:?\\s*(.*?)\\s*→\\s*(.+)$/i);\n if (match) { const label=match[1].replaceAll('_',' ').replace(/([a-z])([A-Z])/g,'$1 $2');comparisons.push({label:label[0].toUpperCase()+label.slice(1),before:match[2].trim() || '—',after:match[3].trim()}); }\n }\n // Other provider plans still have a concrete change list. Show the\n // proposed effect without pretending we fetched the previous object.\n for (const change of changes.slice(0,12)) {\n const value=String(change).trim();\n if (/^~\\s+(?:.+?\\s+)?(status|configured_status|bidding_strategy|delivery|bid|dailyBudget\\.value|DailyBudget|value)\\s*:?\\s*.*?\\s*→\\s*.+$/i.test(value)) continue;\n if (deltas.length && /\\b(budget|amount_micros)\\b/i.test(value) && /\\s*→\\s*/.test(value)) continue;\n const kind=value[0];\n comparisons.push({\n label:kind==='+'?'Create':kind==='-'?'Remove':kind==='~'?'Update':'Change',\n before:kind==='+'?'Not present':kind==='-'?value.slice(1).trim():'Not provided',\n after:kind==='-'?'Removed':/^[+~!]\\s*/.test(value)?value.replace(/^[+~!]\\s*/,''):value,\n });\n }\n if (!comparisons.length && preview.summary) comparisons.push({label:'Proposed change',before:'Not provided',after:String(preview.summary)});\n const title=String(preview.summary || '').match(/\"([^\"]+)\"/)?.[1] || (comparisons.length ? '' : preview.summary);\n const validation=preview.serverValidated===true?'server validated':preview.serverValidated===false?'local preview · not server validated':'validation not reported';\n const table=comparisons.length?'<table class=\"comparison\" aria-label=\"Before and after\"><thead><tr><th scope=\"col\">Change</th><th scope=\"col\">Before</th><th scope=\"col\">After</th></tr></thead><tbody>'+comparisons.map(v=>'<tr><td>'+esc(v.label)+'</td><td>'+esc(v.before)+'</td><td class=\"'+(v.before!==v.after?'changed':'')+'\">'+esc(v.after)+'</td></tr>').join('')+'</tbody></table>':'<p class=\"notice\">No change details were returned. Review the tool response before applying.</p>';\n const approval=meta.approval;\n const canApprove=typeof pending==='string' && pending.length>0 && typeof preview.summary==='string' && preview.summary.trim() && approval?.arguments && typeof approval.arguments==='object' && !Array.isArray(approval.arguments) && typeof meta.tool==='string';\n const action=canApprove?'<div class=\"approval\"><button class=\"approve\" data-approve=\"true\" aria-label=\"Hold to approve and apply\" '+(state.approving || state.approvalError?'disabled':'')+'>'+(state.approving?'Applying…':state.approvalError?'Check result in chat':'Hold to apply')+'</button><span class=\"context\">Hold for 0.9s · release to cancel. Expires '+esc(data.expires_at || 'soon')+'</span></div>':'';\n const body=(title?'<p class=\"operation-name\">'+esc(title)+'</p>':'')+table+(changes.length>12?'<p class=\"notice\">Showing 12 of '+changes.length+' changes. All changes are in Details.</p>':'')+coercions.map(v=>'<p class=\"adjustment\">'+esc(v)+'</p>').join('')+(state.approvalError?'<p class=\"notice\" role=\"alert\">'+esc(state.approvalError)+'</p>':'')+action+(applied?'<p class=\"notice\">Applied. '+esc(preview.summary || 'The change was submitted.')+'</p>':'')+'<details><summary>Details</summary><p>'+esc(validation)+'</p><p>'+esc(preview.summary || 'No change details returned.')+'</p>'+changes.map(v=>'<p>'+esc(v)+'</p>').join('')+(pending?'<p>Nothing has been changed. Apply requires the matching pending operation token before it expires.</p>':'')+'<p>'+esc(meta.tool || '')+'</p></details>';\n app.innerHTML = chrome(body, applied?'Applied':pending?'Preview · Not applied':'Result');\n if (canApprove) app.querySelectorAll('[data-approve]').forEach(button=>bindHold(button,()=>approve(meta.tool,approval.arguments,pending)));\n }\n function bindHold(button,complete) {\n let timer=null, interacted=false;\n const cancel=()=>{clearTimeout(timer);timer=null;button.classList.remove('holding');};\n const begin=event=>{\n if (button.disabled || timer!==null) return;\n if (event.type==='keydown') {\n if (![' ','Enter'].includes(event.key) || event.repeat) return;\n event.preventDefault();\n } else {\n if (event.button!==0) return;\n button.setPointerCapture?.(event.pointerId);\n }\n interacted=true;button.classList.add('holding');\n timer=setTimeout(()=>{cancel();complete();},900);\n };\n button.addEventListener('pointerdown',begin);\n button.addEventListener('keydown',begin);\n ['pointerup','pointerleave','pointercancel','lostpointercapture','blur'].forEach(name=>button.addEventListener(name,cancel));\n button.addEventListener('keyup',event=>{if ([' ','Enter','Escape'].includes(event.key)) cancel();});\n button.addEventListener('contextmenu',event=>event.preventDefault());\n // Screen-reader activation has no pointer/key sequence. Retain an accessible activation path.\n button.addEventListener('click',event=>{if (event.detail===0 && !interacted && !button.disabled) complete();});\n }\n const pendingRequests=new Map();\n async function approve(tool,args,pending) {\n if (state.approving || state.approvalError || !state.result) return;\n state.approving=true;state.approvalError='';render(state.result);\n const requestId=id++;\n const response=new Promise((resolve,reject)=>{\n const timer=setTimeout(()=>{\n pendingRequests.delete(requestId);\n reject(new Error('No confirmation arrived. The write may have succeeded; check its status before retrying.'));\n },30000);\n pendingRequests.set(requestId,{resolve,reject,timer});\n });\n const parameters={...args,pending_operation_id:pending};\n // Use the native ChatGPT bridge when supplied; never dispatch a second write as fallback.\n if (typeof window.openai?.callTool==='function') {\n Promise.resolve().then(()=>window.openai.callTool(tool,parameters)).then(result=>{\n const request=pendingRequests.get(requestId);\n if (request) {clearTimeout(request.timer);pendingRequests.delete(requestId);request.resolve(result);}\n },error=>{\n const request=pendingRequests.get(requestId);\n if (request) {clearTimeout(request.timer);pendingRequests.delete(requestId);request.reject(error);}\n });\n } else send({jsonrpc:'2.0',id:requestId,method:'tools/call',params:{name:tool,arguments:parameters}});\n try {\n const result=await response;\n if (!result || result.isError) throw new Error('Adport could not confirm the change. Check its status before retrying.');\n let value=result.structuredContent || result;\n if (!result.structuredContent && Array.isArray(result.content)) {\n for (const item of result.content) {if (item.type==='text') {try {value=JSON.parse(item.text);break;} catch {}}}\n }\n const outcome=tool==='recommendation_apply'?value.result:value;\n if (outcome?.applied!==true || outcome?.status!=='applied') throw new Error('The change was not confirmed as applied. Check its status before retrying.');\n state.approving=false;state.approvalError='';acceptResult({structuredContent:{...value,_adport:{...(state.result.structuredContent?._adport || {}),...value._adport,approval:undefined}}});\n } catch (error) {\n state.approving=false;state.approvalError=error?.message || 'The change could not be confirmed. Check its status before retrying.';\n render(state.result);\n }\n }\n function renderInsights(data) {\n const items = data.finding ? [data.finding] : arr(data.findings || data.recommendations || data.results || data.entries);\n const body = items.length ? '<div class=\"list\">'+items.slice(0,8).map((item,i)=>'<div class=\"row\"><div class=\"identity\"><span class=\"logo\" style=\"background:var(--orange)\">'+(i+1)+'</span><div class=\"identity-copy\"><b>'+esc(item.title || item.summary || item.rule || 'Opportunity')+'</b><span>'+esc(item.description || item.status || item.severity || 'Review recommended')+'</span></div></div><span class=\"pill '+(/high|critical/i.test(item.severity || '')?'danger':'')+'\">'+esc(item.severity || item.status || 'open')+'</span></div>').join('')+'</div>' : '<div class=\"empty\">No active recommendations were returned.</div>';\n app.innerHTML = chrome(body, items.length+' recommendation'+(items.length===1?'':'s'));\n }\n function render(result) {\n let data = result?.structuredContent || result || {};\n if (!result?.structuredContent && Array.isArray(result?.content)) {\n for (const item of result.content) {\n if (item.type !== 'text') continue;\n try { const parsed = JSON.parse(item.text); if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) { data = parsed; break; } } catch {}\n }\n }\n const meta = data._adport || {};\n syntheticResult = data.data_source === 'synthetic';\n if (data.cancelled) {\n app.innerHTML=chrome('<p class=\"notice\">'+esc(data.message || 'The host interrupted this request. Check the tool response before retrying.')+'</p>','Request interrupted');\n return;\n }\n if (result?.isError || data.error) {\n app.innerHTML=chrome('<p class=\"notice\">'+esc(data.message || 'The request could not complete. See the tool response for details.')+'</p>','Request failed');\n return;\n }\n if (meta.view === 'accounts') return renderAccounts(data,meta);\n if (meta.view === 'report') return renderReport(data,meta);\n if (meta.view === 'operation') return renderOperation(data,meta);\n return renderInsights(data,meta);\n }\n function acceptResult(result) {\n if (!result || typeof result !== 'object') return;\n clearTimeout(resultWait);\n // ChatGPT can deliver the same result through both supported bridges.\n // Do not reset an open disclosure when the second copy arrives.\n if (state.result && JSON.stringify(state.result) === JSON.stringify(result)) return;\n state.result = result;\n render(result);\n }\n function receiveGlobals(globals) {\n if (!globals) return;\n const metadata = globals.toolResponseMetadata;\n const envelope = metadata?.mcp_tool_result || metadata?.call_tool_result;\n if (envelope && typeof envelope === 'object') return acceptResult(envelope);\n if (globals.toolOutput && typeof globals.toolOutput === 'object') acceptResult({structuredContent:globals.toolOutput});\n }\n // Some hosts mount an error result's resource but never relay its payload.\n // This is a delivery fallback, not a claim about tool execution or success.\n const resultWait = setTimeout(() => {\n if (!state.result) app.innerHTML=chrome('<p class=\"notice\">The host has not provided a result to this view. Check the tool response in the conversation. This card will update if a result arrives.</p>','Result not received');\n }, 15000);\n const send = (message) => window.parent.postMessage(message,'*');\n const resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => {\n send({jsonrpc:'2.0',method:'ui/notifications/size-changed',params:{height:Math.ceil(document.body.getBoundingClientRect().height)}});\n });\n let id = 1;\n window.addEventListener('message', (event) => {\n if (event.source !== window.parent) return;\n const message = event.data;\n if (!message || message.jsonrpc !== '2.0') return;\n if (message.id !== undefined && pendingRequests.has(message.id)) {\n const request=pendingRequests.get(message.id);\n pendingRequests.delete(message.id);\n clearTimeout(request.timer);\n if (message.error) request.reject(message.error);\n else request.resolve(message.result);\n return;\n }\n if (message.id === 1 && message.result) {\n state.host = message.result.hostContext || {};\n document.documentElement.dataset.theme = state.host.theme || '';\n send({jsonrpc:'2.0',method:'ui/notifications/initialized'});\n resize?.observe(document.body);\n if (state.result) render(state.result);\n }\n if (message.method === 'ui/notifications/tool-result') acceptResult(message.params);\n if (message.method === 'ui/notifications/tool-cancelled') acceptResult({structuredContent:{cancelled:true,message:message.params?.reason}});\n if (message.method === 'ui/notifications/host-context-changed') {\n const previousLocale = state.host.locale;\n state.host = {...state.host,...message.params};\n document.documentElement.dataset.theme = state.host.theme || '';\n // Size/theme updates must not rebuild the DOM: opening Details changes\n // the iframe height, which some hosts echo back as a context update.\n if (state.result && previousLocale !== state.host.locale) {\n const expanded = app.querySelector('details')?.open || false;\n render(state.result);\n const details = app.querySelector('details');\n if (details) details.open = expanded;\n }\n }\n });\n // The compatibility bridge can hydrate after the iframe has mounted,\n // including full error envelopes in toolResponseMetadata.\n window.addEventListener('openai:set_globals', event => receiveGlobals(event.detail?.globals));\n send({jsonrpc:'2.0',id:id++,method:'ui/initialize',params:{appInfo:{name:'Adport Insight',version:'1.0.0'},appCapabilities:{},protocolVersion:'2026-01-26'}});\n receiveGlobals(window.openai);\n })();\n </script>\n</body>\n</html>`;\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,SAAS;AAClB,SAAS,qBAAqB,iBAAiB,0BAA0B;AACzE,SAAS,aAAa,iBAAiB,qBAA8D;AACrG,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAClC,SAAS,6BAA6B;AACtC,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;;;ACf9B;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,MAAQ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AAA,EACF;AACA,SAAO;AACT;AAEA,eAAsB,eAAe,SAAwB,SAAiC;AAC5F,QAAM,SAAS,gBAAgB,EAAE,SAAS,QAAQ,CAAC;AACnD,QAAM,OAAO,QAAQ,IAAI,qBAAqB,CAAC;AAE/C,UAAQ,MAAM,+BAA+B,QAAQ,SAAS,KAAK,EAAE,MAAM,mBAAmB,QAAQ,YAAY,GAAG;AACrH,MAAI,QAAQ,IAAI,UAAU,KAAK,EAAE,WAAW,GAAG;AAC7C,YAAQ,MAAM,8GAA8G;AAAA,EAC9H;AACF;","names":[]}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adport/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "adport MCP server — the open control plane for paid media",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
"@modelcontextprotocol/ext-apps": "^1.7.5",
|
|
23
23
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
24
24
|
"zod": "^4.4.3",
|
|
25
|
-
"@adport/core": "0.
|
|
26
|
-
"@adport/provider-apple": "0.
|
|
27
|
-
"@adport/provider-google": "0.
|
|
28
|
-
"@adport/provider-meta": "0.
|
|
29
|
-
"@adport/provider-microsoft": "0.
|
|
30
|
-
"@adport/provider-reddit": "0.
|
|
31
|
-
"@adport/provider-snapchat": "0.
|
|
32
|
-
"@adport/provider-
|
|
33
|
-
"@adport/provider-
|
|
34
|
-
"@adport/provider-
|
|
35
|
-
"@adport/provider-
|
|
36
|
-
"@adport/provider-
|
|
25
|
+
"@adport/core": "0.7.0",
|
|
26
|
+
"@adport/provider-apple": "0.7.0",
|
|
27
|
+
"@adport/provider-google": "0.7.0",
|
|
28
|
+
"@adport/provider-meta": "0.7.0",
|
|
29
|
+
"@adport/provider-microsoft": "0.7.0",
|
|
30
|
+
"@adport/provider-reddit": "0.7.0",
|
|
31
|
+
"@adport/provider-snapchat": "0.7.0",
|
|
32
|
+
"@adport/provider-spotify": "0.7.0",
|
|
33
|
+
"@adport/provider-x": "0.7.0",
|
|
34
|
+
"@adport/provider-tiktok": "0.7.0",
|
|
35
|
+
"@adport/provider-pinterest": "0.7.0",
|
|
36
|
+
"@adport/provider-linkedin": "0.7.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^26.1.2",
|
|
@@ -41,6 +41,21 @@
|
|
|
41
41
|
"typescript": "^5.8.0",
|
|
42
42
|
"vitest": "^4.1.10"
|
|
43
43
|
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/ynnickw/adport.git",
|
|
47
|
+
"directory": "packages/mcp"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/ynnickw/adport#readme",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/ynnickw/adport/issues"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=22.13"
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
44
59
|
"scripts": {
|
|
45
60
|
"build": "tsup src/index.ts src/bin.ts --format esm --dts --sourcemap --clean",
|
|
46
61
|
"render:submission-previews": "node scripts/render-submission-previews.mjs",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../package.json","../src/ui.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { z } from 'zod';\nimport { registerAppResource, registerAppTool, RESOURCE_MIME_TYPE } from '@modelcontextprotocol/ext-apps/server';\nimport { AdportError, CredentialStore, createContext, type AdportRuntime, type ProviderModule } from '@adport/core';\nimport { createGoogleModule } from '@adport/provider-google';\nimport { createMetaModule } from '@adport/provider-meta';\nimport { createTikTokModule } from '@adport/provider-tiktok';\nimport { createAppleModule } from '@adport/provider-apple';\nimport { createMicrosoftModule } from '@adport/provider-microsoft';\nimport { createRedditModule } from '@adport/provider-reddit';\nimport { createSnapchatModule } from '@adport/provider-snapchat';\nimport { createSpotifyModule } from '@adport/provider-spotify';\nimport { createPinterestModule } from '@adport/provider-pinterest';\nimport { createLinkedInModule } from '@adport/provider-linkedin';\nimport { createXModule } from '@adport/provider-x';\nimport packageJson from '../package.json';\nimport {\n ADPORT_UI_HTML,\n ADPORT_UI_DOMAIN,\n ADPORT_UI_URI,\n structuredResult,\n toolInvocationLabels,\n toolTitle,\n viewForTool,\n} from './ui.js';\n\nexport const PROVIDER_IDS = ['google', 'meta', 'tiktok', 'apple', 'microsoft', 'reddit', 'snapchat', 'spotify', 'pinterest', 'linkedin', 'x'] as const;\n\nconst DEFAULT_MCP_ICONS = [{\n src: 'https://app.adport.dev/icon.svg?brand=orange-dot-v2',\n mimeType: 'image/svg+xml',\n sizes: ['any'],\n}];\n\n/**\n * Standard runtime assembly: real providers whose credentials exist. Mock data\n * is opt-in so a live runtime never silently substitutes synthetic accounts.\n */\nexport interface AssembleRuntimeOptions {\n includeMock?: boolean;\n}\n\nexport async function assembleRuntime(options: AssembleRuntimeOptions = {}): Promise<AdportRuntime> {\n const store = new CredentialStore();\n const modules: ProviderModule[] = [];\n const includeMock = options.includeMock ?? process.env.ADPORT_DEMO === 'true';\n if (!includeMock) {\n for (const factory of [createGoogleModule, createMetaModule, createTikTokModule, createAppleModule, createMicrosoftModule, createRedditModule, createSnapchatModule, createSpotifyModule, createPinterestModule, createLinkedInModule, createXModule]) {\n const module = await factory(store);\n if (module) modules.push(module);\n }\n }\n return createContext({ providerModules: modules, includeMock });\n}\n\nexport interface CreateServerOptions {\n runtime: AdportRuntime;\n name?: string;\n version?: string;\n /** Brand icons advertised to MCP clients during initialization. */\n icons?: Array<{ src: string; mimeType?: string; sizes?: string[] }>;\n /** When set by a remote transport, only register tools authorized by this key. */\n scopes?: readonly string[];\n /**\n * Register tools blocked by a dynamic entitlement and return this structured\n * error when called. Missing credential scopes without a denial stay hidden.\n */\n scopeDenials?: Readonly<Record<string, ToolScopeDenial | undefined>>;\n /** Hosted transports can replace local CLI setup guidance, without changing the error code. */\n notConnectedMessage?: string;\n /** Hosted production must never serve synthetic results or demo tool definitions. */\n productionOnly?: boolean;\n /** Host-specific MCP Apps sandbox domain; OpenAI's widget domain stays independent. */\n uiDomain?: string;\n}\n\nexport interface ToolScopeDenial {\n code: string;\n message: string;\n data?: Record<string, unknown>;\n}\n\n/**\n * Thin adapter: every tool in the shared registry becomes an MCP tool.\n * No tool logic lives here — see the \"one tool-definition layer\" principle.\n */\nexport function createMcpServer({ runtime, name = 'adport', version = packageJson.version, icons = DEFAULT_MCP_ICONS, scopes, scopeDenials, notConnectedMessage, productionOnly = false, uiDomain = ADPORT_UI_DOMAIN }: CreateServerOptions): McpServer {\n if (productionOnly && (runtime.dataSource === 'synthetic'\n || runtime.ctx.providers.list().some(provider => !PROVIDER_IDS.includes(provider.id as typeof PROVIDER_IDS[number]))\n || runtime.registry.list().some(tool => /^(demo|mock|synthetic)(_|$)/.test(tool.name) || /^(demo|mock|synthetic)$/.test(tool.namespace)))) {\n throw new AdportError('POLICY_VIOLATION', 'Demo tools and synthetic runtimes are not available on the production connector.');\n }\n const provenance = (value: unknown): unknown => runtime.dataSource === 'synthetic'\n ? { ...(value && typeof value === 'object' && !Array.isArray(value) ? value : { value }), data_source: 'synthetic' }\n : value;\n const server = new McpServer({ name, version, ...(icons ? { icons } : {}) });\n registerAppResource(\n server,\n 'Adport insight card',\n ADPORT_UI_URI,\n {\n description: 'Responsive Adport accounts, performance, recommendations, and guarded-change view.',\n _meta: {\n ui: { domain: uiDomain, prefersBorder: false, csp: { connectDomains: [], resourceDomains: [] } },\n 'openai/widgetDomain': ADPORT_UI_DOMAIN,\n },\n },\n async () => ({\n contents: [{\n uri: ADPORT_UI_URI,\n mimeType: RESOURCE_MIME_TYPE,\n text: ADPORT_UI_HTML,\n _meta: {\n ui: { domain: uiDomain, prefersBorder: false, csp: { connectDomains: [], resourceDomains: [] } },\n 'openai/widgetDomain': ADPORT_UI_DOMAIN,\n },\n }],\n }),\n );\n for (const tool of runtime.registry.list()) {\n const requiredScope = tool.annotations.readOnly ? 'tools:read' : 'tools:write';\n const scopeDenial = scopes && !scopes.includes(requiredScope) ? scopeDenials?.[requiredScope] : undefined;\n if (scopes && !scopes.includes(requiredScope) && !scopeDenial) continue;\n const view = viewForTool(tool.name, tool.annotations.readOnly ?? false);\n const labels = view ? toolInvocationLabels(view) : undefined;\n // MCP structuredContent must be an object. Preserve legacy raw arrays in\n // text/CLI results, exposing their declared schema under a value envelope.\n const wrapOutput = !!tool.output && !(tool.output instanceof z.ZodObject);\n const objectOutput = tool.output\n ? tool.output instanceof z.ZodObject ? tool.output : z.object({ value: tool.output })\n : undefined;\n const config = {\n title: toolTitle(tool.name),\n description: scopeDenial\n ? `${tool.description}\\n\\nUnavailable on the current plan: ${scopeDenial.message}`\n : tool.description,\n inputSchema: tool.input.shape,\n ...(objectOutput ? { outputSchema: objectOutput.extend({\n ...(view ? { _adport: z.object({ tool: z.literal(tool.name), view: z.literal(view), providerNames: z.record(z.string(), z.string()), approval: z.object({ arguments: z.record(z.string(), z.unknown()) }).optional() }) } : {}),\n ...(runtime.dataSource === 'synthetic' ? { data_source: z.literal('synthetic') } : {}),\n }) } : {}),\n annotations: {\n readOnlyHint: tool.annotations.readOnly ?? false,\n destructiveHint: tool.annotations.destructive ?? false,\n openWorldHint: tool.annotations.openWorld ?? false,\n },\n };\n const callback = async (args: Record<string, unknown>) => {\n if (scopeDenial) {\n const payload = provenance({\n error: scopeDenial.code,\n code: scopeDenial.code,\n message: scopeDenial.message,\n ...scopeDenial.data,\n });\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify(payload, null, 2),\n }],\n // SDK clients validate structuredContent even on isError responses.\n // Errors use JSON text (also consumed by the widget), never a fake\n // success object to satisfy the advertised output schema.\n isError: true,\n };\n }\n try {\n const rawResult = await runtime.registry.call(tool.name, args, runtime.ctx);\n const result = provenance(rawResult);\n const structured = provenance(wrapOutput ? { value: rawResult } : rawResult);\n const rawObject = rawResult && typeof rawResult === 'object' && !Array.isArray(rawResult)\n ? rawResult as Record<string, unknown> : {};\n const nestedResult = rawObject.result && typeof rawObject.result === 'object' && !Array.isArray(rawObject.result)\n ? rawObject.result as Record<string, unknown> : {};\n const pending = rawObject.pending_operation_id ?? nestedResult.pending_operation_id;\n const approval = view === 'operation' && typeof pending === 'string' && !args.pending_operation_id\n ? { arguments: { ...args } }\n : undefined;\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }],\n ...(view ? { structuredContent: structuredResult(tool.name, view, structured, approval) }\n : tool.output ? { structuredContent: structured as Record<string, unknown> } : {}),\n };\n } catch (err) {\n const payload = provenance(\n err instanceof AdportError\n ? { ...err.toJSON(), ...(err.code === 'NOT_CONNECTED' && notConnectedMessage ? { message: notConnectedMessage } : {}) }\n : {\n error: 'INTERNAL',\n // Unexpected exceptions can contain credentials or private paths.\n // Do not imply that a failed response means a write was not applied.\n message: 'Adport could not complete this request. If this was a write, check its status before retrying. Contact support if the problem persists.',\n });\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(payload, null, 2) }],\n isError: true,\n };\n }\n };\n if (view) {\n registerAppTool(server, tool.name, {\n ...config,\n _meta: {\n ui: { resourceUri: ADPORT_UI_URI, visibility: ['model', 'app'] },\n 'openai/widgetAccessible': true,\n 'openai/outputTemplate': ADPORT_UI_URI,\n 'openai/toolInvocation/invoking': labels!.invoking,\n 'openai/toolInvocation/invoked': labels!.invoked,\n },\n }, callback);\n } else {\n server.registerTool(tool.name, config, callback);\n }\n }\n return server;\n}\n\nexport async function runStdioServer(runtime: AdportRuntime, version?: string): Promise<void> {\n const server = createMcpServer({ runtime, version });\n await server.connect(new StdioServerTransport());\n // stdout is the protocol channel; stderr is for humans.\n console.error(`adport MCP server on stdio (${runtime.registry.list().length} tools, policy: ${runtime.policySource})`);\n if (runtime.ctx.providers.list().length === 0) {\n console.error('No ad providers connected. Run `adport connect <provider>` or restart with `--demo` for synthetic mock data.');\n }\n}\n","{\n \"name\": \"@adport/mcp\",\n \"version\": \"0.6.1\",\n \"description\": \"adport MCP server — the open control plane for paid media\",\n \"license\": \"Apache-2.0\",\n \"type\": \"module\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n }\n },\n \"bin\": {\n \"adport-mcp\": \"./dist/bin.js\"\n },\n \"files\": [\"dist\"],\n \"scripts\": {\n \"build\": \"tsup src/index.ts src/bin.ts --format esm --dts --sourcemap --clean\",\n \"render:submission-previews\": \"node scripts/render-submission-previews.mjs\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\",\n \"clean\": \"rm -rf dist\"\n },\n \"dependencies\": {\n \"@adport/core\": \"workspace:*\",\n \"@adport/provider-apple\": \"workspace:*\",\n \"@adport/provider-google\": \"workspace:*\",\n \"@adport/provider-meta\": \"workspace:*\",\n \"@adport/provider-microsoft\": \"workspace:*\",\n \"@adport/provider-reddit\": \"workspace:*\",\n \"@adport/provider-snapchat\": \"workspace:*\",\n \"@adport/provider-spotify\": \"workspace:*\",\n \"@adport/provider-pinterest\": \"workspace:*\",\n \"@adport/provider-linkedin\": \"workspace:*\",\n \"@adport/provider-x\": \"workspace:*\",\n \"@adport/provider-tiktok\": \"workspace:*\",\n \"@modelcontextprotocol/ext-apps\": \"^1.7.5\",\n \"@modelcontextprotocol/sdk\": \"^1.30.0\",\n \"zod\": \"^4.4.3\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^26.1.2\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.8.0\",\n \"vitest\": \"^4.1.10\"\n }\n}\n","export const ADPORT_UI_URI = 'ui://adport/insight-card-v2.html';\nexport const ADPORT_UI_DOMAIN = 'https://app.adport.dev';\n\nexport type AdportView = 'accounts' | 'report' | 'operation' | 'insights';\n\nconst providerNames: Record<string, string> = {\n google: 'Google Ads',\n meta: 'Meta Ads',\n tiktok: 'TikTok Ads',\n apple: 'Apple Ads',\n microsoft: 'Microsoft Advertising',\n reddit: 'Reddit Ads',\n snapchat: 'Snapchat Ads',\n spotify: 'Spotify Ads',\n pinterest: 'Pinterest Ads',\n linkedin: 'LinkedIn Ads',\n x: 'X Ads',\n mock: 'Demo',\n demo: 'Synthetic demo',\n};\n\nexport function viewForTool(name: string, readOnly: boolean): AdportView | undefined {\n if (name === 'accounts_list') return 'accounts';\n if (name === 'report') return 'report';\n if (name === 'audit_run' || name === 'recommendation_dismiss') return 'insights';\n if (!readOnly) return 'operation';\n if (name.startsWith('recommendation') || name.startsWith('audit_')) return 'insights';\n return undefined;\n}\n\nexport function toolTitle(name: string): string {\n if (name === 'accounts_list') return 'Show connected ad accounts';\n if (name === 'report') return 'Show advertising performance';\n return name\n .split('_')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(' ');\n}\n\nexport function toolInvocationLabels(view: AdportView): { invoking: string; invoked: string } {\n switch (view) {\n case 'accounts': return { invoking: 'Loading ad accounts…', invoked: 'Ad accounts ready' };\n case 'report': return { invoking: 'Analyzing performance…', invoked: 'Performance ready' };\n // Descriptor labels cover both preview and apply; the card shows the actual result.\n case 'operation': return { invoking: 'Processing change…', invoked: 'Change result ready' };\n case 'insights': return { invoking: 'Reviewing opportunities…', invoked: 'Opportunities ready' };\n }\n}\n\nexport function structuredResult(tool: string, view: AdportView, result: unknown, approval?: { arguments: Record<string, unknown> }): Record<string, unknown> {\n const payload = result && typeof result === 'object' && !Array.isArray(result)\n ? result as Record<string, unknown>\n : { value: result };\n return {\n ...payload,\n _adport: {\n tool,\n view,\n providerNames,\n ...(approval ? { approval } : {}),\n },\n };\n}\n\n/**\n * Self-contained MCP App. It uses the open MCP Apps postMessage protocol and\n * has no network dependencies, which keeps its review CSP intentionally empty.\n */\nexport const ADPORT_UI_HTML = String.raw`<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" />\n <meta name=\"color-scheme\" content=\"light dark\" />\n <title>Adport insight</title>\n <style>\n :root {\n --ink: var(--color-text-primary, #171717);\n --muted: var(--color-text-secondary, #6f6f73);\n --faint: var(--color-text-tertiary, #949499);\n --paper: var(--color-background-primary, #ffffff);\n --soft: var(--color-background-secondary, #f6f6f4);\n --line: var(--color-border-secondary, rgba(23,23,23,.11));\n --orange: #ff5a1f;\n --green: #16845b;\n --red: #c8392f;\n --amber: #a86500;\n --radius: var(--border-radius-lg, 18px);\n --sans: var(--font-sans, ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif);\n --mono: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);\n }\n * { box-sizing: border-box }\n html, body { margin: 0; min-width: 0; background: transparent; color: var(--ink); font-family: var(--sans) }\n body { padding: 2px; }\n button { font: inherit }\n .shell { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 10px 32px rgba(20,20,20,.07) }\n .top { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:14px 16px 10px }\n .brand { display:flex; align-items:center; gap:9px; min-width:0 }\n .dot { width:10px; height:10px; border-radius:99px; background:var(--orange); box-shadow:0 0 0 5px color-mix(in srgb,var(--orange) 12%,transparent) }\n .brand b { font-size:12px; letter-spacing:-.02em }\n .context { color:var(--muted); font-size:11px; text-align:right }\n .content { padding:4px 16px 16px }\n .kpis { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; margin-bottom:15px }\n .kpi { min-width:0; padding:12px; border-radius:13px; background:var(--soft); border:1px solid color-mix(in srgb,var(--line) 70%,transparent) }\n button.kpi { cursor:pointer; color:var(--ink); text-align:left }\n button.kpi[aria-pressed=\"true\"] { border-color:color-mix(in srgb,var(--orange) 65%,var(--line)) }\n .kpi small { display:block; color:var(--faint); font:600 9px/1.2 var(--mono); letter-spacing:.11em; text-transform:uppercase }\n .kpi strong { display:block; overflow:hidden; margin-top:8px; font-size:clamp(17px,3vw,24px); line-height:1; letter-spacing:-.04em; text-overflow:ellipsis }\n .panel { min-width:0; padding:13px; border:1px solid var(--line); border-radius:14px }\n .panel-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px }\n .panel-head b { font-size:12px }\n .panel-head span { color:var(--faint); font:500 9px/1 var(--mono); text-transform:uppercase; letter-spacing:.1em }\n .bars { display:grid; gap:9px }\n .bar-row { display:grid; grid-template-columns:minmax(100px,1fr) minmax(60px,2fr) auto; align-items:center; gap:9px; font-size:11px }\n .bar-name { display:flex; align-items:center; gap:7px; min-width:0 }\n .bar-name > span:last-child { overflow:hidden; white-space:nowrap; text-overflow:ellipsis }\n .bar-name .logo { width:22px; height:22px; padding:4px; border-radius:6px }\n .track { height:7px; overflow:hidden; border-radius:99px; background:var(--soft) }\n .fill { height:100%; border-radius:99px; background:linear-gradient(90deg,var(--orange),#ff985e) }\n .tabs { display:flex; gap:6px; overflow:auto; padding-bottom:12px }\n .tabs button { flex:0 0 auto; cursor:pointer; padding:8px 12px; border:1px solid var(--line); border-radius:99px; background:var(--paper); color:var(--muted); font-size:12px }\n .tabs button[aria-pressed=\"true\"] { color:var(--ink); border-color:var(--orange); background:color-mix(in srgb,var(--orange) 8%,var(--paper)) }\n button:focus-visible { outline:2px solid var(--orange); outline-offset:2px }\n .notice { padding:10px 12px; margin:0 0 12px; border-radius:10px; background:var(--soft); color:var(--muted); font-size:12px; line-height:1.45 }\n .bar-value { color:var(--muted); font:600 10px/1 var(--mono); white-space:nowrap }\n .list { display:grid; gap:7px }\n .row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 11px; border:1px solid var(--line); border-radius:12px }\n .identity { display:flex; align-items:center; gap:10px; min-width:0 }\n .logo { display:grid; place-items:center; flex:0 0 auto; width:29px; height:29px; padding:6px; border:1px solid var(--line); border-radius:9px; color:var(--ink); background:var(--paper); font-weight:800; font-size:10px }\n .logo svg { display:block; width:100%; height:100% }\n .logo.reddit { background:#ff4500 }.logo.linkedin { background:#0a66c2 }.logo.spotify { background:#1db954 }.logo.pinterest { background:#e60023 }.logo.x { background:#111 }.logo.snapchat { background:#fffc00;color:#111 }\n .identity-copy { min-width:0 }\n .identity-copy b, .identity-copy span { display:block; overflow:hidden; white-space:nowrap; text-overflow:ellipsis }\n .identity-copy b { font-size:12px }.identity-copy span { margin-top:3px; color:var(--muted); font-size:10px }\n .pill { flex:0 0 auto; padding:5px 8px; border-radius:99px; color:var(--green); background:color-mix(in srgb,var(--green) 10%,transparent); font:700 9px/1 var(--mono); letter-spacing:.08em; text-transform:uppercase }\n .pill.warn { color:var(--amber); background:color-mix(in srgb,var(--amber) 11%,transparent) }\n .pill.danger { color:var(--red); background:color-mix(in srgb,var(--red) 10%,transparent) }\n .pill.neutral { color:var(--muted); background:var(--soft) }\n .operation-name { margin:2px 0 16px; font-size:14px; line-height:1.4; font-weight:600; overflow-wrap:anywhere }\n .comparison { width:100%; border-collapse:collapse; table-layout:fixed; margin-bottom:12px }\n .comparison th { padding:0 8px 8px; color:var(--muted); font-size:10px; font-weight:500; text-align:left }\n .comparison td { border-top:1px solid var(--line); padding:12px 8px; font-size:14px; overflow-wrap:anywhere }\n .comparison td:first-child { color:var(--muted); font-size:11px }\n .comparison td:last-child { font-weight:600 }\n .comparison .changed { color:var(--orange) }\n .adjustment { margin:8px 0; color:var(--amber); font-size:11px; line-height:1.4 }\n .approval { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin:12px 0 }\n .approve { cursor:pointer; padding:9px 16px; border:0; border-radius:99px; background:var(--ink); color:var(--paper); font-size:12px; font-weight:700 }\n .approve:disabled { cursor:default; opacity:.55 }\n details { border-top:1px solid var(--line); padding-top:10px; color:var(--muted); font-size:11px; line-height:1.5 }\n summary { cursor:pointer; width:fit-content; padding:3px 0 }\n summary:focus-visible { outline:2px solid var(--orange); outline-offset:3px }\n details p { margin:8px 0; overflow-wrap:anywhere }\n .empty { padding:26px 12px; text-align:center; color:var(--muted); font-size:12px }\n @media (max-width:620px) { .kpis { grid-template-columns:repeat(2,minmax(0,1fr)) }.top,.content { padding-left:12px; padding-right:12px } }\n @media (max-width:420px) { .bar-row { grid-template-columns:minmax(0,1fr) auto; gap:5px }.bar-name { grid-column:1/-1 }.bar-name > span:last-child { white-space:normal }.bars { gap:12px } }\n @media (prefers-reduced-motion:reduce) { * { animation:none!important; transition:none!important } }\n :root[data-theme=\"dark\"] { --ink:#f5f5f3;--muted:#aaa9ad;--faint:#a09fa5;--paper:#171717;--soft:#222220;--line:rgba(255,255,255,.11) }\n @media (prefers-color-scheme:dark) { :root:not([data-theme=\"light\"]) { --ink:#f5f5f3;--muted:#aaa9ad;--faint:#a09fa5;--paper:#171717;--soft:#222220;--line:rgba(255,255,255,.11) } }\n </style>\n</head>\n<body>\n <main id=\"app\" class=\"shell\" aria-live=\"polite\">\n <header class=\"top\"><div class=\"brand\"><span class=\"dot\"></span><b>adport.dev</b></div></header>\n <section class=\"content\"><div class=\"empty\">Loading…</div></section>\n </main>\n <script>\n (() => {\n const app = document.getElementById('app');\n const state = { host: {}, result: null, reportGroup: null, reportMetric: 'spend', approving: false, approvalError: '' };\n const esc = (value) => String(value ?? '').replace(/[&<>\"']/g, (c) => ({'&':'&','<':'<','>':'>','\"':'"',\"'\":'''}[c]));\n const arr = (value) => Array.isArray(value) ? value : [];\n const num = (value) => Number.isFinite(Number(value)) ? Number(value) : 0;\n const money = (value, currency, maximumFractionDigits=2) => currency\n ? new Intl.NumberFormat(state.host.locale || 'en', { style:'currency', currency, maximumFractionDigits }).format(num(value))\n : new Intl.NumberFormat(state.host.locale || 'en', { maximumFractionDigits }).format(num(value));\n const compact = (value) => new Intl.NumberFormat(state.host.locale || 'en', { notation:'compact', maximumFractionDigits:1 }).format(num(value));\n const available = (value) => typeof value === 'number' && Number.isFinite(value);\n const total = (rows, key) => rows.length && rows.every(r => available(r.metrics?.[key])) ? rows.reduce((sum,r) => sum+r.metrics[key],0) : null;\n const rowReturn = (row) => {\n const m=row.metrics || {};\n if (available(m.conversion_value)) return m.conversion_value;\n // A report can request ROAS without conversion_value. Weight reported\n // ratios by spend; never average campaign ratios or infer missing revenue.\n const value=available(m.spend) && m.spend>0 && available(m.roas) ? m.spend*m.roas : null;\n return available(value) ? value : null;\n };\n const currencyOf = (row) => typeof row.currency === 'string' && /^[A-Z]{3}$/.test(row.currency) ? row.currency : null;\n const statusOf = (status) => !status || /unknown|unspecified/i.test(status) ? {label:'Status unavailable',tone:'neutral'} : /disabled|removed|inactive|closed|suspended/i.test(status) ? {label:status,tone:'danger'} : /paused|disable$/i.test(status) ? {label:status,tone:'warn'} : /^(enabled|active|approved)$/i.test(status) ? {label:status,tone:''} : {label:status,tone:'neutral'};\n const notices = (data) => [...arr(data.errors).map(e => (e.provider || 'Provider')+': '+(e.message || 'Read failed')), ...arr(data.warnings).map(e => e.message || 'Some metadata is unavailable'), ...(data.truncated ? ['Partial result: row limit reached. Totals and charts cover returned rows only.'] : [])].map(text => '<p class=\"notice\">'+esc(text)+'</p>').join('');\n const providerName = (id, names) => names?.[id] || String(id || 'Provider');\n const initials = (id) => ({snapchat:'S',spotify:'S',pinterest:'P',linkedin:'in',x:'X'}[id] || String(id || '?').slice(0,2).toUpperCase());\n const providerSvg = {\n // Unmodified official Ghost paths, matching cloud/components/snapchat-logo.tsx.\n snapchat:\"<svg viewBox=\\\"0 0 1024 1024\\\" aria-hidden=\\\"true\\\"> <path fill=\\\"#fff\\\" d=\\\"M992.5,756.3c-4.2-13.9-24.3-23.7-24.3-23.7l0,0c-1.9-1-3.6-1.9-5-2.6c-33.5-16.2-63.2-35.7-88.2-57.8 c-20.1-17.8-37.3-37.4-51.1-58.2c-16.9-25.4-24.8-46.6-28.2-58.1c-1.9-7.5-1.6-10.5,0-14.4c1.3-3.3,5.2-6.4,7-7.9 c11.3-8,29.5-19.8,40.7-27c9.7-6.3,18-11.7,22.9-15.1c15.7-11,26.5-22.2,32.8-34.3c8.2-15.6,9.2-32.8,2.8-49.7 c-8.6-22.8-29.9-36.4-57-36.4c-6,0-12.2,0.7-18.4,2c-15.5,3.4-30.2,8.9-42.5,13.7c-0.9,0.4-1.9-0.3-1.8-1.3 c1.3-30.5,2.8-71.5-0.6-110.4c-3-35.2-10.3-64.9-22.1-90.8c-11.9-26-27.4-45.2-39.5-59.1C708.5,112,688.2,92.5,657.6,75 C614.6,50.4,565.6,37.9,512,37.9c-53.5,0-102.4,12.5-145.5,37.1c-32.4,18.5-53.1,39.4-62.5,50.2c-12.1,13.9-27.6,33.1-39.5,59.1 c-11.9,25.9-19.1,55.5-22.1,90.8c-3.4,39.1-2,76.8-0.6,110.4c0,1-0.9,1.7-1.9,1.3c-12.3-4.8-27-10.3-42.5-13.7 c-6.1-1.3-12.3-2-18.4-2c-27,0-48.3,13.6-57,36.4c-6.4,16.9-5.4,34.1,2.8,49.7c6.4,12.1,17.1,23.3,32.8,34.3 c4.8,3.4,13.2,8.8,22.9,15.1c10.9,7.1,28.6,18.6,40,26.5c1.4,1,6.2,4.6,7.7,8.4c1.6,4,1.9,7-0.2,15c-3.5,11.6-11.4,32.6-28,57.5 c-13.8,20.9-31,40.4-51.1,58.2c-25,22.1-54.7,41.6-88.2,57.8c-1.6,0.8-3.5,1.7-5.5,2.9l0,0c0,0-20,10.2-23.8,23.4 c-5.6,19.5,9.3,37.8,24.4,47.6c24.8,16,55,24.6,72.5,29.3c4.9,1.3,9.3,2.5,13.3,3.7c2.5,0.8,8.8,3.2,11.5,6.7 c3.4,4.4,3.8,9.8,5,15.9v0c1.9,10.3,6.2,23,18.9,31.8c14,9.6,31.7,10.3,54.2,11.2c23.5,0.9,52.7,2,86.2,13.1 c15.5,5.1,29.6,13.8,45.8,23.8c34,20.9,76.3,46.9,148.5,46.9c72.3,0,114.9-26.1,149.1-47.1c16.2-9.9,30.1-18.5,45.3-23.5 c33.5-11.1,62.7-12.2,86.2-13.1c22.5-0.9,40.2-1.5,54.2-11.2c13.6-9.4,17.5-23.4,19.3-33.9c1-5.2,1.6-9.9,4.6-13.7 c2.6-3.3,8.4-5.6,11.1-6.5c4.1-1.3,8.7-2.5,13.8-3.9c17.5-4.7,39.5-10.2,66.2-25.3C993.7,789.8,995.9,767.4,992.5,756.3z\\\" /> <path fill=\\\"#000\\\" d=\\\"M1020.3,745.5c-7.1-19.4-20.7-29.7-36.1-38.3c-2.9-1.7-5.6-3.1-7.8-4.1c-4.6-2.4-9.3-4.7-14-7.1 c-48.1-25.5-85.7-57.7-111.7-95.8c-8.8-12.9-14.9-24.5-19.2-34c-2.2-6.4-2.1-10-0.5-13.3c1.2-2.5,4.4-5.1,6.2-6.4 c8.3-5.5,16.8-11,22.6-14.7c10.3-6.7,18.5-12,23.7-15.6c19.8-13.8,33.6-28.5,42.2-44.9c12.2-23.1,13.7-49.5,4.3-74.3 c-13-34.4-45.6-55.8-85-55.8c-8.2,0-16.5,0.9-24.7,2.7c-2.2,0.5-4.3,1-6.4,1.5c0.4-23.4-0.2-48.4-2.3-72.8 c-7.4-86-37.5-131.1-68.9-167c-13.1-15-35.9-36.9-70.1-56.5C624.9,21.7,570.9,7.9,512,7.9c-58.7,0-112.7,13.8-160.4,41.1 c-34.4,19.6-57.2,41.6-70.2,56.5c-31.4,35.9-61.5,81-68.9,167c-2.1,24.4-2.6,49.4-2.3,72.8c-2.1-0.5-4.3-1-6.4-1.5 c-8.2-1.8-16.6-2.7-24.7-2.7c-39.4,0-72,21.4-85,55.8c-9.4,24.8-7.9,51.2,4.3,74.3c8.6,16.4,22.5,31.1,42.2,44.9 c5.3,3.7,13.4,9,23.7,15.6c5.6,3.6,13.7,8.9,21.7,14.2c1.2,0.8,5.5,4,7,7c1.7,3.4,1.7,7.1-0.8,13.9c-4.2,9.3-10.3,20.7-18.9,33.3 c-25.5,37.3-62,68.9-108.5,94.1c-24.7,13.1-50.3,21.8-61.1,51.2c-8.2,22.2-2.8,47.5,17.9,68.8l0,0c6.8,7.3,15.4,13.8,26.2,19.8 c25.4,14,47,20.9,64,25.6c3,0.9,9.9,3.1,12.9,5.8c7.6,6.6,6.5,16.6,16.6,31.2c6.1,9.1,13.1,15.3,18.9,19.3 c21.1,14.6,44.9,15.5,70.1,16.5c22.7,0.9,48.5,1.9,77.9,11.6c12.2,4,24.9,11.8,39.5,20.8c35.2,21.7,83.5,51.3,164.2,51.3 c80.8,0,129.3-29.8,164.8-51.5c14.6-8.9,27.2-16.7,39-20.6c29.4-9.7,55.2-10.7,77.9-11.6c25.2-1,48.9-1.9,70.1-16.5 c6.6-4.6,15-12.1,21.6-23.5c7.2-12.3,7.1-21,13.9-26.9c2.8-2.4,8.9-4.5,12.2-5.5c17.1-4.7,39-11.6,64.9-25.9 c11.5-6.3,20.4-13.2,27.5-21.1c0.1-0.1,0.2-0.2,0.3-0.3C1023.4,791.7,1028.3,767.2,1020.3,745.5z M948.6,784 c-43.8,24.2-72.9,21.6-95.5,36.1c-19.2,12.4-7.9,39.1-21.8,48.7c-17.2,11.9-67.9-0.8-133.4,20.8c-54,17.9-88.5,69.2-185.8,69.2 c-97.5,0-131-51.1-185.8-69.2c-65.5-21.6-116.3-8.9-133.4-20.8c-13.9-9.6-2.6-36.3-21.8-48.7c-22.6-14.6-51.7-12-95.5-36.1 c-27.9-15.4-12.1-24.9-2.8-29.4c158.6-76.7,183.8-195.3,185-204.2c1.4-10.6,2.9-19-8.8-29.9c-11.3-10.5-61.6-41.6-75.5-51.3 c-23.1-16.1-33.2-32.2-25.7-52c5.2-13.7,18-18.8,31.5-18.8c4.2,0,8.5,0.5,12.6,1.4c25.3,5.5,49.9,18.2,64.1,21.6 c2,0.5,3.7,0.7,5.2,0.7c7.6,0,10.2-3.8,9.7-12.5c-1.6-27.7-5.6-81.7-1.2-132.2c6-69.4,28.4-103.8,55-134.3 c12.8-14.6,72.8-78,187.5-78c115,0,174.7,63.4,187.5,78c26.6,30.4,49,64.8,55,134.3c4.4,50.5,0.6,104.5-1.2,132.2 c-0.6,9.1,2.2,12.5,9.7,12.5c1.5,0,3.3-0.2,5.2-0.7c14.2-3.4,38.8-16.1,64.1-21.6c4.1-0.9,8.4-1.4,12.6-1.4 c13.5,0,26.3,5.2,31.5,18.8c7.5,19.8-2.7,35.9-25.7,52c-13.9,9.7-64.2,40.8-75.5,51.3c-11.7,10.8-10.2,19.2-8.8,29.9 c1.1,8.9,26.4,127.5,185,204.2C960.6,759.1,976.5,768.6,948.6,784z\\\" /> </svg>\",\n google:'<svg viewBox=\"0 0 24 24\"><path fill=\"#34a853\" d=\"M4 22.93a4 4 0 1 1 0-8 4 4 0 0 1 0 8Z\"/><path fill=\"#4285f4\" d=\"M23.464 16.929 15.463 3.072A4 4 0 0 0 8.534 7.072l8.001 13.857a4 4 0 0 0 6.929-4Z\"/><path fill=\"#fbbc04\" d=\"M7.514 4.844 1.565 15.148A4.5 4.5 0 0 1 4 14.43a4.5 4.5 0 0 1 4.494 4.715l3.217-5.573-3.61-6.25a4 4 0 0 1-.587-2.478Z\"/></svg>',\n meta:'<svg viewBox=\"0 0 24 24\"><path fill=\"#0866ff\" d=\"M6.915 4.03C2.484 4.03 0 9.95 0 14.449c0 3.37 1.276 5.521 4.439 5.521 2.93 0 4.146-2.574 6.628-6.764l.942-1.664 2.335 3.895c1.883 3.15 3.38 4.533 5.53 4.533 2.788 0 4.126-1.93 4.126-5.56 0-5.53-2.73-10.38-6.8-10.38-2.04 0-3.835 1.53-5.173 3.348C10.16 5.01 8.593 4.03 6.915 4.03Zm-.04 2.606c1.55 0 2.445 1.193 3.908 3.025l-1.02 1.566c-2.22 3.41-3.576 6.155-5.323 6.155-1.23 0-2.154-1.075-2.154-2.9 0-3.755 2.088-7.846 4.588-7.846Zm10.2-.553c2.488 0 4.639 4.054 4.639 8.4 0 1.547-.368 2.899-1.839 2.899-1.193 0-2.027-1.42-4.496-5.362l-1.872-3.008c1.12-1.814 2.248-2.929 3.559-2.929Z\"/></svg>',\n tiktok:'<svg viewBox=\"0 0 58 58\"><path fill=\"#2dccd3\" d=\"M25.98 0v37.68c0 4.94-3.55 8.11-7.88 8.11-1.43 0-2.79-.33-3.97-.95 1.5 1.91 3.87 3.01 6.47 3.01 4.32 0 7.87-3.17 7.87-8.11V2.06h6.85A20.3 20.3 0 0 1 34.87 0h-8.89Z\"/><path fill=\"#f1204a\" d=\"M41.73 11.11a17.48 17.48 0 0 1-4.37-9.05h-2.04c1.16 4.23 3.56 7.18 6.41 9.05Zm7.63 11.37a19.31 19.31 0 0 1-11-2.97c3.84 3.84 8.5 5.03 13.5 5.03v-8.82a17.4 17.4 0 0 1-2.5-.37v7.13Z\"/><path fill=\"currentColor\" d=\"M35.32 2.06h-6.85v37.68c0 4.94-3.55 8.11-7.87 8.11-2.6 0-4.97-1.1-6.47-3.01-2.48-1.29-4.19-3.82-4.19-7.16 0-5.71 4.47-8.71 10.42-8.09v-7.68C10.63 21.93 2.49 29.73 2.49 39.4c0 5.16 2.04 9.71 5.32 12.96 2.89 1.97 6.39 3.11 10.15 3.11 8.69 0 17.91-6.38 17.91-18.41V17.45c.8.8 1.63 1.48 2.49 2.06a19.31 19.31 0 0 0 11 2.97v-7.13a16.14 16.14 0 0 1-7.63-4.24c-2.85-1.87-5.25-4.82-6.41-9.05Z\"/></svg>',\n apple:'<svg viewBox=\"0 0 24 24\"><path fill=\"currentColor\" d=\"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09Zm3.377-3.065C16.372 2.819 16.929 1.403 16.774 0c-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.56-1.701Z\"/></svg>',\n microsoft:'<svg viewBox=\"0 0 24 24\"><path fill=\"#f25022\" d=\"M0 0h11.4v11.4H0Z\"/><path fill=\"#7fba00\" d=\"M12.6 0H24v11.4H12.6Z\"/><path fill=\"#00a4ef\" d=\"M0 12.6h11.4V24H0Z\"/><path fill=\"#ffb900\" d=\"M12.6 12.6H24V24H12.6Z\"/></svg>',\n reddit:'<svg viewBox=\"0 0 24 24\"><path fill=\"#ff4500\" d=\"M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0Zm5.01 4.744c.688 0 1.25.561 1.25 1.249a1.25 1.25 0 0 1-2.498.056l-2.597-.547-.8 3.747c1.824.07 3.48.632 4.674 1.488.308-.309.73-.491 1.207-.491.968 0 1.754.786 1.754 1.754 0 .716-.435 1.333-1.01 1.614.028.169.042.342.042.52 0 2.694-3.13 4.87-7.004 4.87-3.874 0-7.004-2.176-7.004-4.87 0-.183.015-.366.043-.534A1.748 1.748 0 0 1 4.028 12c0-.968.786-1.754 1.754-1.754.463 0 .898.196 1.207.49 1.207-.883 2.878-1.43 4.744-1.487l.885-4.182a.342.342 0 0 1 .378-.239l2.906.617a1.214 1.214 0 0 1 1.108-.701Z\"/></svg>'\n };\n const logo = (id) => '<span class=\"logo '+esc(id)+'\" aria-hidden=\"true\">'+(providerSvg[id] || esc(initials(id)))+'</span>';\n let syntheticResult = false;\n const chrome = (body, context) => '<header class=\"top\"><div class=\"brand\"><span class=\"dot\"></span><b>adport.dev</b></div><span class=\"context\">'+(syntheticResult?'Synthetic demo · ':'')+esc(context || '')+'</span></header><section class=\"content\">'+body+'</section>';\n function renderAccounts(data, meta) {\n const accounts = arr(data.accounts), errors = arr(data.errors), names = meta.providerNames || {};\n const body = notices(data)+(accounts.length ? '<div class=\"list\">'+accounts.map(a => { const status=statusOf(a.status); return '<div class=\"row\"><div class=\"identity\">'+logo(a.provider)+'<div class=\"identity-copy\"><b>'+esc(a.name || 'Ad account')+'</b><span>'+esc(providerName(a.provider,names))+' · '+esc(a.id)+(a.currency ? ' · '+esc(a.currency) : '')+'</span></div></div><span class=\"pill '+status.tone+'\">'+esc(status.label)+'</span></div>'; }).join('')+'</div>' : '<div class=\"empty\">'+(errors.length ? 'Account inventory could not be fully loaded.' : 'No accessible ad accounts were returned.')+'</div>');\n app.innerHTML = chrome(body, accounts.length+' account'+(accounts.length===1?'':'s'));\n }\n function renderReport(data) {\n const groups = new Map();\n for (const row of arr(data.rows)) {\n const currency=currencyOf(row), key=currency || JSON.stringify([row.provider,row.accountId]);\n if (!groups.has(key)) groups.set(key,{key,currency,label:currency || (row.provider+' · '+row.accountId),rows:[]});\n groups.get(key).rows.push(row);\n }\n const choices=[...groups.values()];\n const selected=groups.get(state.reportGroup) || choices[0];\n const rows=selected?.rows || [], currency=selected?.currency;\n state.reportGroup=selected?.key;\n const tabs=choices.length>1 ? '<div class=\"tabs\" role=\"group\" aria-label=\"Report currency or account\">'+choices.map((g,i)=>'<button data-group=\"'+i+'\" aria-pressed=\"'+(g===selected)+'\">'+esc(g.label)+'</button>').join('')+'</div>' : '';\n const summary=arr(data.summary?.groups).find(group=>group.key===selected?.key)?.metrics;\n const aggregate=key=>summary ? (available(summary[key])?summary[key]:null) : total(rows,key);\n const spend=aggregate('spend'), returns=rows.map(rowReturn);\n const value=returns.length && returns.every(available) ? returns.reduce((sum,value)=>sum+value,0) : null;\n const ratio=summary ? summary.roas : spend>0 && value!==null ? value/spend : null;\n const roas=available(ratio) ? ratio.toFixed(2)+'×' : '—';\n const metric=state.reportMetric, labels={spend:'Spend',clicks:'Clicks',conversions:'Conversions',roas:'ROAS'};\n const metricValue=r=>metric==='roas' ? (available(r.metrics?.conversion_value) && r.metrics?.spend>0 ? r.metrics.conversion_value/r.metrics.spend : r.metrics?.roas) : r.metrics?.[metric];\n const format=value=>metric==='spend'?money(value,currency):metric==='roas'?value.toFixed(2)+'×':compact(value);\n const ranked=[...rows].filter(r=>available(metricValue(r))).sort((a,b)=>metricValue(b)-metricValue(a)).slice(0,6), max=Math.max(1,...ranked.map(metricValue));\n const bars=ranked.length ? ranked.map(r=>'<div class=\"bar-row\"><span class=\"bar-name\" title=\"'+esc(r.entity?.name || r.entity?.id)+'\">'+logo(r.provider)+'<span>'+esc(r.entity?.name || r.entity?.id || 'Entity')+'</span></span><span class=\"track\" aria-hidden=\"true\"><span class=\"fill\" style=\"display:block;width:'+Math.max(0,metricValue(r)/max*100).toFixed(1)+'%\"></span></span><span class=\"bar-value\">'+esc(format(metricValue(r)))+'</span></div>').join('') : '<div class=\"empty\">No '+esc(labels[metric])+' values were returned.</div>';\n const kpi=(key,label,value)=>'<button class=\"kpi\" data-metric=\"'+key+'\" aria-pressed=\"'+(metric===key)+'\" aria-label=\"Chart '+esc(label)+'\"><small>'+esc(label)+'</small><strong>'+esc(value)+'</strong></button>';\n const period=typeof data.date_range==='string' ? data.date_range.replaceAll('_',' ') : data.date_range ? data.date_range.start+' – '+data.date_range.end : 'Selected period';\n const body=notices(data)+tabs+(rows.length ? (!currency?'<p class=\"notice\">Currency unavailable. These values belong to this account only; no cross-account money total is calculated.</p>':'')+'<div class=\"kpis\" role=\"group\" aria-label=\"Chart metric\">'+kpi('spend','Spend',spend===null?'—':money(spend,currency))+kpi('clicks','Clicks',total(rows,'clicks')===null?'—':compact(total(rows,'clicks')))+kpi('conversions','Conversions',total(rows,'conversions')===null?'—':compact(total(rows,'conversions')))+kpi('roas','ROAS',roas)+'</div><div class=\"panel\"><div class=\"panel-head\"><b>'+esc(labels[metric])+'</b><span>Top '+ranked.length+' of '+rows.length+' rows</span></div><div class=\"bars\">'+bars+'</div></div>' : '<div class=\"empty\">'+(arr(data.errors).length?'Report unavailable for the requested providers.':'No rows returned for this period.')+'</div>');\n app.innerHTML=chrome(body,period+(currency?' · '+currency:''));\n app.querySelectorAll('[data-group]').forEach(button=>button.addEventListener('click',()=>{state.reportGroup=choices[Number(button.dataset.group)].key;renderReport(data);}));\n app.querySelectorAll('[data-metric]').forEach(button=>button.addEventListener('click',()=>{state.reportMetric=button.dataset.metric;renderReport(data);}));\n }\n function renderOperation(data, meta) {\n if (meta.tool === 'recommendation_apply' && data.result) data = data.result;\n const preview = data.preview || {}, pending = data.pending_operation_id, applied = data.status === 'applied' || data.applied === true;\n const changes = arr(preview.changes), coercions = arr(preview.coercions), deltas = arr(preview.budgetDeltas);\n // Review amounts must preserve micros; rounded report totals are not suitable for consent.\n const comparisons=deltas.map(v=>{const currency=currencyOf(v);return {label:(v.target || 'Budget')+(currency?' · '+currency:' (account units)'),before:available(v.fromMicros)?money(v.fromMicros/1e6,currency,6):'—',after:available(v.toMicros)?money(v.toMicros/1e6,currency,6):'—'};});\n // Split only explicit field/value arrows. Freeform JSON updates still\n // show the proposed payload, but never claim a previous value.\n for (const change of changes) {\n const match=String(change).match(/^~\\s+(?:.+?\\s+)?(status|configured_status|bidding_strategy|delivery|bid|dailyBudget\\.value|DailyBudget|value)\\s*:?\\s*(.*?)\\s*→\\s*(.+)$/i);\n if (match) { const label=match[1].replaceAll('_',' ').replace(/([a-z])([A-Z])/g,'$1 $2');comparisons.push({label:label[0].toUpperCase()+label.slice(1),before:match[2].trim() || '—',after:match[3].trim()}); }\n }\n // Other provider plans still have a concrete change list. Show the\n // proposed effect without pretending we fetched the previous object.\n for (const change of changes.slice(0,12)) {\n const value=String(change).trim();\n if (/^~\\s+(?:.+?\\s+)?(status|configured_status|bidding_strategy|delivery|bid|dailyBudget\\.value|DailyBudget|value)\\s*:?\\s*.*?\\s*→\\s*.+$/i.test(value)) continue;\n if (deltas.length && /\\b(budget|amount_micros)\\b/i.test(value) && /\\s*→\\s*/.test(value)) continue;\n const kind=value[0];\n comparisons.push({\n label:kind==='+'?'Create':kind==='-'?'Remove':kind==='~'?'Update':'Change',\n before:kind==='+'?'Not present':kind==='-'?value.slice(1).trim():'Not provided',\n after:kind==='-'?'Removed':/^[+~!]\\s*/.test(value)?value.replace(/^[+~!]\\s*/,''):value,\n });\n }\n if (!comparisons.length && preview.summary) comparisons.push({label:'Proposed change',before:'Not provided',after:String(preview.summary)});\n const title=String(preview.summary || '').match(/\"([^\"]+)\"/)?.[1] || (comparisons.length ? '' : preview.summary);\n const validation=preview.serverValidated===true?'server validated':preview.serverValidated===false?'local preview · not server validated':'validation not reported';\n const table=comparisons.length?'<table class=\"comparison\" aria-label=\"Before and after\"><thead><tr><th scope=\"col\">Change</th><th scope=\"col\">Before</th><th scope=\"col\">After</th></tr></thead><tbody>'+comparisons.map(v=>'<tr><td>'+esc(v.label)+'</td><td>'+esc(v.before)+'</td><td class=\"'+(v.before!==v.after?'changed':'')+'\">'+esc(v.after)+'</td></tr>').join('')+'</tbody></table>':'<p class=\"notice\">No change details were returned. Review the tool response before applying.</p>';\n const approval=meta.approval;\n const canApprove=typeof pending==='string' && pending.length>0 && typeof preview.summary==='string' && preview.summary.trim() && approval?.arguments && typeof approval.arguments==='object' && !Array.isArray(approval.arguments) && typeof meta.tool==='string';\n const action=canApprove?'<div class=\"approval\"><button class=\"approve\" data-approve=\"true\" '+(state.approving?'disabled':'')+'>'+(state.approving?'Applying…':'Approve and apply')+'</button><span class=\"context\">Expires '+esc(data.expires_at || 'soon')+'</span></div>':'';\n const body=(title?'<p class=\"operation-name\">'+esc(title)+'</p>':'')+table+(changes.length>12?'<p class=\"notice\">Showing 12 of '+changes.length+' changes. All changes are in Details.</p>':'')+coercions.map(v=>'<p class=\"adjustment\">'+esc(v)+'</p>').join('')+(state.approvalError?'<p class=\"notice\" role=\"alert\">'+esc(state.approvalError)+'</p>':'')+action+(applied?'<p class=\"notice\">Applied. '+esc(preview.summary || 'The change was submitted.')+'</p>':'')+'<details><summary>Details</summary><p>'+esc(validation)+'</p><p>'+esc(preview.summary || 'No change details returned.')+'</p>'+changes.map(v=>'<p>'+esc(v)+'</p>').join('')+(pending?'<p>Nothing has been changed. Apply requires the matching pending operation token before it expires.</p>':'')+'<p>'+esc(meta.tool || '')+'</p></details>';\n app.innerHTML = chrome(body, applied?'Applied':pending?'Preview · Not applied':'Result');\n if (canApprove) app.querySelectorAll('[data-approve]').forEach(button=>button.addEventListener('click',()=>approve(meta.tool,approval.arguments,pending)));\n }\n const pendingRequests=new Map();\n async function approve(tool,args,pending) {\n if (state.approving || !state.result) return;\n state.approving=true;state.approvalError='';render(state.result);\n const requestId=id++;\n const response=new Promise((resolve,reject)=>{\n const timer=setTimeout(()=>{\n pendingRequests.delete(requestId);\n reject(new Error('No confirmation arrived. The write may have succeeded; check its status before retrying.'));\n },30000);\n pendingRequests.set(requestId,{resolve,reject,timer});\n });\n send({jsonrpc:'2.0',id:requestId,method:'tools/call',params:{name:tool,arguments:{...args,pending_operation_id:pending}}});\n try {\n const result=await response;\n if (!result || result.isError) throw new Error('Adport could not confirm the change. Check its status before retrying.');\n const value=result.structuredContent || result;\n const outcome=tool==='recommendation_apply'?value.result:value;\n if (outcome?.applied!==true || outcome?.status!=='applied') throw new Error('The change was not confirmed as applied. Check its status before retrying.');\n state.approving=false;state.approvalError='';acceptResult(result);\n } catch (error) {\n state.approving=false;state.approvalError=error?.message || 'The change could not be confirmed. Check its status before retrying.';\n render(state.result);\n }\n }\n function renderInsights(data) {\n const items = data.finding ? [data.finding] : arr(data.findings || data.recommendations || data.results || data.entries);\n const body = items.length ? '<div class=\"list\">'+items.slice(0,8).map((item,i)=>'<div class=\"row\"><div class=\"identity\"><span class=\"logo\" style=\"background:var(--orange)\">'+(i+1)+'</span><div class=\"identity-copy\"><b>'+esc(item.title || item.summary || item.rule || 'Opportunity')+'</b><span>'+esc(item.description || item.status || item.severity || 'Review recommended')+'</span></div></div><span class=\"pill '+(/high|critical/i.test(item.severity || '')?'danger':'')+'\">'+esc(item.severity || item.status || 'open')+'</span></div>').join('')+'</div>' : '<div class=\"empty\">No active recommendations were returned.</div>';\n app.innerHTML = chrome(body, items.length+' recommendation'+(items.length===1?'':'s'));\n }\n function render(result) {\n let data = result?.structuredContent || result || {};\n if (!result?.structuredContent && Array.isArray(result?.content)) {\n for (const item of result.content) {\n if (item.type !== 'text') continue;\n try { const parsed = JSON.parse(item.text); if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) { data = parsed; break; } } catch {}\n }\n }\n const meta = data._adport || {};\n syntheticResult = data.data_source === 'synthetic';\n if (data.cancelled) {\n app.innerHTML=chrome('<p class=\"notice\">'+esc(data.message || 'The host interrupted this request. Check the tool response before retrying.')+'</p>','Request interrupted');\n return;\n }\n if (result?.isError || data.error) {\n app.innerHTML=chrome('<p class=\"notice\">'+esc(data.message || 'The request could not complete. See the tool response for details.')+'</p>','Request failed');\n return;\n }\n if (meta.view === 'accounts') return renderAccounts(data,meta);\n if (meta.view === 'report') return renderReport(data,meta);\n if (meta.view === 'operation') return renderOperation(data,meta);\n return renderInsights(data,meta);\n }\n function acceptResult(result) {\n if (!result || typeof result !== 'object') return;\n clearTimeout(resultWait);\n // ChatGPT can deliver the same result through both supported bridges.\n // Do not reset an open disclosure when the second copy arrives.\n if (state.result && JSON.stringify(state.result) === JSON.stringify(result)) return;\n state.result = result;\n render(result);\n }\n function receiveGlobals(globals) {\n if (!globals) return;\n const metadata = globals.toolResponseMetadata;\n const envelope = metadata?.mcp_tool_result || metadata?.call_tool_result;\n if (envelope && typeof envelope === 'object') return acceptResult(envelope);\n if (globals.toolOutput && typeof globals.toolOutput === 'object') acceptResult({structuredContent:globals.toolOutput});\n }\n // Some hosts mount an error result's resource but never relay its payload.\n // This is a delivery fallback, not a claim about tool execution or success.\n const resultWait = setTimeout(() => {\n if (!state.result) app.innerHTML=chrome('<p class=\"notice\">The host has not provided a result to this view. Check the tool response in the conversation. This card will update if a result arrives.</p>','Result not received');\n }, 15000);\n const send = (message) => window.parent.postMessage(message,'*');\n const resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => {\n send({jsonrpc:'2.0',method:'ui/notifications/size-changed',params:{height:Math.ceil(document.body.getBoundingClientRect().height)}});\n });\n let id = 1;\n window.addEventListener('message', (event) => {\n if (event.source !== window.parent) return;\n const message = event.data;\n if (!message || message.jsonrpc !== '2.0') return;\n if (message.id !== undefined && pendingRequests.has(message.id)) {\n const request=pendingRequests.get(message.id);\n pendingRequests.delete(message.id);\n clearTimeout(request.timer);\n if (message.error) request.reject(message.error);\n else request.resolve(message.result);\n return;\n }\n if (message.id === 1 && message.result) {\n state.host = message.result.hostContext || {};\n document.documentElement.dataset.theme = state.host.theme || '';\n send({jsonrpc:'2.0',method:'ui/notifications/initialized'});\n resize?.observe(document.body);\n if (state.result) render(state.result);\n }\n if (message.method === 'ui/notifications/tool-result') acceptResult(message.params);\n if (message.method === 'ui/notifications/tool-cancelled') acceptResult({structuredContent:{cancelled:true,message:message.params?.reason}});\n if (message.method === 'ui/notifications/host-context-changed') {\n const previousLocale = state.host.locale;\n state.host = {...state.host,...message.params};\n document.documentElement.dataset.theme = state.host.theme || '';\n // Size/theme updates must not rebuild the DOM: opening Details changes\n // the iframe height, which some hosts echo back as a context update.\n if (state.result && previousLocale !== state.host.locale) {\n const expanded = app.querySelector('details')?.open || false;\n render(state.result);\n const details = app.querySelector('details');\n if (details) details.open = expanded;\n }\n }\n });\n // The compatibility bridge can hydrate after the iframe has mounted,\n // including full error envelopes in toolResponseMetadata.\n window.addEventListener('openai:set_globals', event => receiveGlobals(event.detail?.globals));\n send({jsonrpc:'2.0',id:id++,method:'ui/initialize',params:{appInfo:{name:'Adport Insight',version:'1.0.0'},appCapabilities:{},protocolVersion:'2026-01-26'}});\n receiveGlobals(window.openai);\n })();\n </script>\n</body>\n</html>`;\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,SAAS;AAClB,SAAS,qBAAqB,iBAAiB,0BAA0B;AACzE,SAAS,aAAa,iBAAiB,qBAA8D;AACrG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