@adport/mcp 0.12.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  assembleRuntime,
4
4
  runStdioServer
5
- } from "./chunk-RE4ZCAVJ.js";
5
+ } from "./chunk-TNQOM6VM.js";
6
6
 
7
7
  // src/bin.ts
8
8
  var includeRawTools = process.argv.includes("--raw-api-tools");
@@ -22,7 +22,7 @@ import { createOpenAIModule } from "@adport/provider-openai";
22
22
  // package.json
23
23
  var package_default = {
24
24
  name: "@adport/mcp",
25
- version: "0.12.1",
25
+ version: "0.13.0",
26
26
  description: "adport MCP server \u2014 the open control plane for paid media",
27
27
  license: "Apache-2.0",
28
28
  type: "module",
@@ -438,8 +438,192 @@ var TREND_UI_SCRIPT = String.raw`
438
438
  }
439
439
  `;
440
440
 
441
+ // src/record-collection-ui.ts
442
+ var RECORD_COLLECTION_STYLES = String.raw`
443
+ .collection-heading { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:.65rem 1rem; margin:.35rem 0 .85rem }
444
+ .collection-heading .operation-heading { margin:0 }
445
+ .collection-filter { min-width:0; width:12rem; max-width:100%; padding:.45rem .65rem; border:1px solid var(--line); border-radius:.5rem; background:var(--soft); color:var(--ink); font:inherit; font-size:.8rem }
446
+ .collection-filter::placeholder { color:var(--muted) }
447
+ .collection-filter:focus-visible,.collection-scroll:focus-visible { outline:2px solid var(--orange); outline-offset:2px }
448
+ .collection-scroll { overflow:auto; max-height:24rem; scrollbar-width:thin; border:1px solid var(--line); border-radius:.65rem }
449
+ .collection-scroll .workflow-table { font-size:.8125rem; line-height:1.4; font-variant-numeric:tabular-nums }
450
+ .collection-scroll .workflow-table :is(td,th) { padding:.48rem .7rem }
451
+ .collection-scroll .workflow-table thead th { background:var(--soft); font-size:.75rem; font-weight:600 }
452
+ .collection-scroll .workflow-table tbody th { font-weight:600 }
453
+ .collection-scroll .workflow-table tbody tr:last-child > * { border-bottom:0 }
454
+ .collection-scroll .workflow-table tr[hidden] { display:none }
455
+ @media (pointer:coarse) { .collection-filter { min-height:44px; font-size:1rem } }
456
+ @media (max-width:480px) {
457
+ .collection-filter { flex:1 1 9rem }
458
+ .collection-scroll .workflow-table:not(.workflow-stack) :is(td,th) { padding:.45rem .5rem }
459
+ .collection-scroll .workflow-stack tbody :is(td,th) { padding:.2rem .65rem }
460
+ .collection-scroll .workflow-stack tbody th { display:block }
461
+ .collection-scroll .workflow-stack tbody th .workflow-cell-label { display:none }
462
+ }
463
+ `;
464
+ var RECORD_COLLECTION_UI = String.raw`
465
+ function recordLabel(path) {
466
+ const words = human(path.replace(/([A-Z]+)([A-Z][a-z])/g,'$1 $2')).toLowerCase();
467
+ return human(words).replace(/\b(?:id|url|sku|iso)\b/gi, word => word.toUpperCase());
468
+ }
469
+
470
+ function recordLeaf(path) { return recordLabel(path.split('.').at(-1)).toLowerCase(); }
471
+
472
+ function recordVisibleFields(row) {
473
+ return dataFields(row).filter(({label}) =>
474
+ !/(?:hash|token|secret|password|authorization|credential|pending operation|snapshot|resource receipt|preview url|preview cover url|logo url|pixel code)/i.test(label) &&
475
+ !/^(?:notes?|actions)$/i.test(label));
476
+ }
477
+
478
+ const recordRank = {name:0, qualifiedName:1, value:2, code:3, other:4, id:5, resource:6};
479
+ function recordFieldPriority(path) {
480
+ const leaf = recordLeaf(path);
481
+ if (/^(?:name|display name|descriptive name|title|label|search term|keyword(?: text)?)$/.test(leaf) ||
482
+ (leaf === 'text' && /keyword/i.test(path))) return recordRank.name;
483
+ if (leaf === 'resource name') return recordRank.resource;
484
+ if (/ name$/.test(leaf)) return recordRank.qualifiedName;
485
+ if (leaf === 'value') return recordRank.value;
486
+ if (/(?:^| )code$/.test(leaf)) return recordRank.code;
487
+ if (/(?:^| )id$/.test(leaf)) return recordRank.id;
488
+ return recordRank.other;
489
+ }
490
+
491
+ // Use the shortest unambiguous suffix, e.g. "Name" or "Campaign name" and "Ad group name".
492
+ function recordColumnLabels(paths) {
493
+ const parts = paths.map(path => path.split('.'));
494
+ return new Map(paths.map((path, i) => {
495
+ let depth = 1;
496
+ const label = () => recordLabel(parts[i].slice(-depth).join(' '));
497
+ while (depth < parts[i].length && parts.some((other, j) =>
498
+ i !== j && recordLabel(other.slice(-depth).join(' ')) === label())) depth++;
499
+ return [path, label()];
500
+ }));
501
+ }
502
+
503
+ function recordCollection(rows, meta, total) {
504
+ // A provider cursor may return a different projection on the next page.
505
+ // Its incremental cards keep their identity, focus and scroll position.
506
+ if (!rows.length || (rows.length === 1 && meta.tool !== 'google_gaql') || meta.pagination) return null;
507
+ const columns = new Map(), values = [];
508
+ for (const row of rows) {
509
+ if (!object(row) || (row.provider && row.provider !== meta.provider) || (providerSvg[row.platform] && row.platform !== meta.provider)) return null;
510
+ const fields = recordVisibleFields(row);
511
+ if (!fields.length || fields.some(field => Array.isArray(field.after))) return null;
512
+ const cells = new Map();
513
+ for (const {path, after} of fields) {
514
+ if (path === 'provider' && after === meta.provider) continue;
515
+ cells.set(path, after);
516
+ columns.set(path, (columns.get(path) || 0) + 1);
517
+ }
518
+ if (columns.size > 12) return null;
519
+ values.push(cells);
520
+ }
521
+ let paths = [...columns.keys()];
522
+ const shared = paths.filter(path => columns.get(path) === rows.length);
523
+ if (!shared.length || (shared.length * 2 < paths.length && !shared.some(path => recordFieldPriority(path) <= recordRank.value))) return null;
524
+ const root = paths[0].split('.')[0];
525
+ const oneResource = paths.every(path => path.startsWith(root + '.'));
526
+ const geo = oneResource && recordLabel(root) === 'Geo target constant';
527
+ const language = oneResource && recordLabel(root) === 'Language constant';
528
+ const types = paths.filter(path => /^(?:target type|type)$/.test(recordLeaf(path)));
529
+ const type = types.length === 1 ? types[0] : null;
530
+ const kind = type && values[0].get(type);
531
+ const sameType = typeof kind === 'string' && kind.trim() && rows.length === total && values.every(row => row.get(type) === kind);
532
+ const countries = geo && sameType && type.split('.').length === 2 && recordLeaf(type) === 'target type' && kind.toLowerCase() === 'country';
533
+ const summarizeType = sameType && paths.length > 1 && (countries || rows.length > 1);
534
+ // Google also returns a resource name for some queries. Omit it only when
535
+ // it is the same prefix plus the exact ID that is already visible.
536
+ paths = paths.filter(path => {
537
+ if (summarizeType && path === type) return false;
538
+ if (recordLeaf(path) !== 'resource name') return true;
539
+ const id = paths.find(other => other.split('.').slice(0,-1).join('.') === path.split('.').slice(0,-1).join('.') && recordLeaf(other) === 'id');
540
+ if (!id) return true;
541
+ const first = String(values[0].get(path) ?? ''), prefix = first.slice(0, first.lastIndexOf('/') + 1);
542
+ return !prefix || !values.every(row => row.get(id) != null && row.get(path) === prefix + row.get(id));
543
+ });
544
+ if (!paths.length) return null;
545
+ paths.sort((a,b) => recordFieldPriority(a) - recordFieldPriority(b));
546
+ const distinct = new Map(paths.map(path => [path, new Set(values.map(row => row.get(path)).filter(value => value != null && value !== '')).size]));
547
+ const names = paths.filter(path => recordFieldPriority(path) <= recordRank.value);
548
+ const identifiers = paths.filter(path => recordFieldPriority(path) !== recordRank.other && recordLeaf(path) !== 'currency code');
549
+ // Display a distinguishing name first. A repeated name can still sit beside its unique ID.
550
+ const primary = names.find(path => distinct.get(path) === rows.length) ||
551
+ names.find(path => distinct.get(path) > 1 && values.every(row => row.get(path) != null && row.get(path) !== '')) ||
552
+ identifiers.find(path => distinct.get(path) === rows.length) ||
553
+ identifiers.find(path => distinct.get(path) > 1) || names.find(path => distinct.get(path)) || paths[0];
554
+ paths = [primary, ...paths.filter(path => path !== primary)];
555
+ const labels = recordColumnLabels(paths);
556
+ let title;
557
+ if (geo || language) {
558
+ title = countries ? 'Countries' : geo ? 'Target locations' : 'Languages';
559
+ for (const path of paths) {
560
+ if (path.split('.').length !== 2) continue;
561
+ const leaf = recordLeaf(path);
562
+ if (leaf === 'name') labels.set(path, countries ? 'Country' : geo ? 'Location' : 'Language');
563
+ if (geo && leaf === 'id') labels.set(path,'Target ID');
564
+ if (geo && leaf === 'target type') labels.set(path,'Type');
565
+ }
566
+ } else if (oneResource && meta.tool === 'google_gaql') {
567
+ title = recordLabel(root).replace(/ (?:constant|view)$/i,'') + ' results';
568
+ }
569
+ const subject = summarizeType && !countries ? 'Type · ' + kind : '';
570
+ return {paths, labels, values, title, subject};
571
+ }
572
+
573
+ function recordCollectionTable(collection, meta, title) {
574
+ const {paths, labels, values} = collection;
575
+ const scales = paths.map(recordAmountScale);
576
+ const headers = paths.map((path,i) => scales[i] ? labels.get(path).replace(/ (?:micros|cents)$/i,'') : labels.get(path));
577
+ const currencyPaths = paths.filter(recordCurrencyField);
578
+ const rows = values.map(cells => {
579
+ const currency = recordCurrency(currencyPaths.map(path => cells.get(path)),meta);
580
+ return '<tr role="row">' + paths.map((path,i) => {
581
+ const value = cells.get(path);
582
+ return workflowCell(headers[i], value == null || value === '' ? '—' : recordValue(value,path,currency,scales[i]), i === 0);
583
+ }).join('') + '</tr>';
584
+ });
585
+ return '<div class="collection-scroll" role="region" aria-label="Returned records" tabindex="0"><table class="workflow-table' +
586
+ (paths.length > 3 ? ' workflow-stack' : '') + '" role="table" aria-label="' + esc(title) + '">' + workflowHeader(headers) +
587
+ '<tbody id="record-collection-rows" role="rowgroup">' + rows.join('') + '</tbody></table></div>';
588
+ }
589
+
590
+ function renderRecordCollection(data, meta, collection, title, scope, clean, total) {
591
+ const shown = collection.values.length;
592
+ const count = total + (total === 1 ? ' result' : ' results');
593
+ const search = shown >= 15 ? '<input class="collection-filter" type="search" aria-label="Filter shown results" aria-controls="record-collection-rows" placeholder="Filter results" autocomplete="off">' : '';
594
+ const heading = collection.title || title;
595
+ const subject = [scope,collection.subject].filter(Boolean).join(' · ');
596
+ app.innerHTML = chrome('<div class="collection-heading">' + operationHeader(heading,subject,meta.provider) + search + '</div>' +
597
+ notices(data) + recordCollectionTable(collection,meta,heading) + '<p class="operation-note" data-collection-empty hidden>No matching results.</p>' +
598
+ (shown < total ? workflowNote('Showing ' + shown.toLocaleString() + ' of ' + total.toLocaleString() + ' results. The full response is in Details.') : '') +
599
+ '<details><summary>Details</summary><pre>' + esc(JSON.stringify(clean,null,2)) + '</pre></details>',count);
600
+ if (!search) return;
601
+ const input = app.querySelector('.collection-filter'), context = app.querySelector('.context'), empty = app.querySelector('[data-collection-empty]');
602
+ const original = context.textContent;
603
+ const entries = [...app.querySelectorAll('#record-collection-rows tr')].map(node => ({
604
+ node, text: [...node.cells].map(cell => cell.textContent).join(' ').toLowerCase()
605
+ }));
606
+ context.setAttribute('role','status');
607
+ function filter() {
608
+ const query = input.value.trim().toLowerCase();
609
+ let matched = 0;
610
+ for (const {node,text} of entries) {
611
+ node.hidden = !text.includes(query);
612
+ if (!node.hidden) matched++;
613
+ }
614
+ empty.hidden = matched !== 0;
615
+ context.textContent = query ? (syntheticResult ? 'Synthetic demo · ' : '') + matched + ' of ' + shown + ' shown' : original;
616
+ }
617
+ input.addEventListener('input',filter);
618
+ input.addEventListener('keydown',event => {
619
+ if (event.key === 'Escape' && input.value) { event.preventDefault(); input.value = ''; filter(); }
620
+ });
621
+ }
622
+ `;
623
+
441
624
  // src/record-ui.ts
442
625
  var RECORD_UI_STYLES = String.raw`
626
+ ${RECORD_COLLECTION_STYLES}
443
627
  .record-list { display:grid; max-height:400px; overflow:auto; scrollbar-width:thin }
444
628
  .record-row { min-width:0; padding:10px 0; border-bottom:1px solid var(--line) }
445
629
  .record-heading { display:flex; align-items:baseline; justify-content:space-between; gap:10px; min-width:0 }
@@ -470,6 +654,7 @@ var RECORD_UI_STYLES = String.raw`
470
654
  }
471
655
  `;
472
656
  var RECORD_UI_SCRIPT = String.raw`
657
+ ${RECORD_COLLECTION_UI}
473
658
  let recordPages=null;
474
659
  function recordPagesIgnoreEcho(data) {
475
660
  return !!recordPages?.busy && data?._adport?.view===recordPages.meta.view && galleryMatches(data._adport,recordPages.meta) && galleryScope(data._adport)===recordPages.scope;
@@ -495,6 +680,7 @@ var RECORD_UI_SCRIPT = String.raw`
495
680
  }
496
681
  function recordPayload(data) {
497
682
  if(object(data)&&Array.isArray(data.records))return {records:data.records};
683
+ if(data._adport?.tool==='google_custom_conversion_goals' && Array.isArray(data.goals))return {records:data.goals};
498
684
  const value=data.value ?? data.data ?? data.result ?? data;
499
685
  if(!object(value))return value;
500
686
  for(const key of ['keyword','audience','pixel','capi_integration','mobile_app','dataset','board','campaign','ad_group','ad','asset','customer_list'])if(object(value[key]))return value[key];
@@ -505,27 +691,49 @@ var RECORD_UI_SCRIPT = String.raw`
505
691
  if(!object(payload))return null;
506
692
  if(['name','value','title','id','saved_audience_name','saved_audience_id','pixel_name','pixel_id','capi_connection_id'].some(key=>Object.hasOwn(payload,key)&&!object(payload[key])&&!Array.isArray(payload[key])))return null;
507
693
  const ignored=/^(_adport|notes|warnings|errors|actions|creatives|fields|media|resourceIds|resource_ids)$/;
508
- const keys=['items','results','records','campaigns','ad_groups','ad_sets','ads','keywords','audiences','accounts','projects','assets','data'];
694
+ const keys=['items','results','records','rows','campaigns','ad_groups','ad_sets','ads','keywords','audiences','accounts','projects','assets','data'];
509
695
  const key=keys.find(key=>Array.isArray(payload[key])) ?? Object.keys(payload).find(key=>!ignored.test(key)&&Array.isArray(payload[key]));
510
696
  return key?payload[key]:null;
511
697
  }
512
- function recordValue(value,key,currency) {
513
- if(typeof value==='number'&&Number.isFinite(value)&&/micros$|cents$/i.test(key))return esc(money(value/(/cents$/i.test(key)?100:1e6),currency,6));
698
+ function recordAmountScale(path) {
699
+ const leaf=recordLeaf(path), label=/^(micros|cents)$/.test(leaf)?recordLabel(path).toLowerCase():leaf;
700
+ if(!/\b(?:budget|amount|price|cost|bid|spend|revenue|fee)\b/.test(label))return 0;
701
+ return /\bmicros$/.test(leaf)?6:/\bcents$/.test(leaf)?2:0;
702
+ }
703
+ function recordCurrencyField(path) { return /^(?:currency|currency code)$/.test(recordLeaf(path)); }
704
+ function recordCurrency(values,meta) {
705
+ const codes=new Set(values.filter(value=>typeof value==='string'&&/^[A-Z]{3}$/.test(value)));
706
+ if(!codes.size)return currencyOf(meta);
707
+ return codes.size===1?[...codes][0]:null;
708
+ }
709
+ function recordValue(value,key,currency,scale=recordAmountScale(key)) {
710
+ if(scale) {
711
+ const amount=nativeReportDecimal(value,scale);
712
+ if(amount!==null)return esc(currency?new Intl.NumberFormat(state.host.locale||'en',{style:'currency',currency,maximumFractionDigits:6}).format(amount):amount+' account units');
713
+ }
514
714
  return valueHTML(value,true);
515
715
  }
516
716
  function recordRow(value,index,meta) {
517
717
  if(!object(value))return '<article class="record-row">'+valueHTML(value,true)+'</article>';
518
- const fields=dataFields(value).filter(field=>!/(?:hash|token|secret|password|authorization|pending operation|snapshot)/i.test(field.label));
519
- const name=fields.find(field=>/^(name|display name|title|value|keyword|keyword text|campaign name|ad group name|ad name|creative name|account name|audience name|saved audience name|pixel name)$/i.test(field.label));
520
- const id=fields.find(field=>/^(id|resource name|saved audience id|pixel id|capi connection id)$/i.test(field.label));
521
- const status=fields.find(field=>/^(status|state|delivery status|archived)$/i.test(field.label));
522
- const currency=currencyOf(value)||(/^[A-Z]{3}$/.test(value.currency_code||'')?value.currency_code:currencyOf(meta));
523
- const chosen=fields.filter(field=>!/^note$|^notes$|^actions$|preview url|preview cover url|logo url/i.test(field.label)&&field!==name&&field!==status&&!/^(id|saved audience id|pixel id|pixel code|capi connection id|account id|provider|resource name|currency|currency code)$/i.test(field.label));
718
+ const fields=recordVisibleFields(value);
719
+ const identities=fields.filter(field=>(typeof field.after==='string'&&field.after.trim())||typeof field.after==='number')
720
+ .sort((a,b)=>recordFieldPriority(a.path)-recordFieldPriority(b.path));
721
+ const name=identities.find(field=>recordFieldPriority(field.path)<=recordRank.code && recordLeaf(field.path)!=='currency code');
722
+ const id=identities.find(field=>recordFieldPriority(field.path)>=recordRank.id);
723
+ const status=fields.find(field=>/^(status|state|delivery status|archived)$/.test(recordLeaf(field.path)));
724
+ const currency=recordCurrency(fields.filter(field=>recordCurrencyField(field.path)).map(field=>field.after),meta);
725
+ const chosen=fields.filter(field=>field!==(name||id)&&field!==status&&!/^(id|saved audience id|pixel id|capi connection id|account id|provider|resource name|currency|currency code)$/.test(recordLeaf(field.path)));
524
726
  chosen.sort((a,b)=>{const priority=field=>/match type|scope|budget|bid|size|type|rule|frequency/i.test(field.label)?0:1;return priority(a)-priority(b);});
525
- const label=name?.after ?? id?.after ?? 'Record '+(index+1);
727
+ const displayed=chosen.slice(0,4), labels=recordColumnLabels(displayed.map(field=>field.path));
728
+ const label=name?.after ?? id?.after ?? (displayed.length?null:'Record '+(index+1));
526
729
  const nativeProvider=typeof value.provider==='string'?value.provider:typeof value.platform==='string'&&providerSvg[value.platform]?value.platform:undefined;
527
730
  const provider=nativeProvider!==meta.provider?nativeProvider:undefined;
528
- return '<article class="record-row"><div class="record-heading"><div class="record-name">'+(provider?'<span role="img" aria-label="'+esc(providerName(provider,meta.providerNames||{}))+'">'+logo(provider)+'</span>':'')+'<strong>'+esc(label)+'</strong></div>'+(status?'<span>'+esc(status.label==='Archived'&&typeof status.after==='boolean'?(status.after?'Archived':'Unarchived'):status.after)+'</span>':'')+'</div>'+(chosen.length?'<dl class="record-fields">'+chosen.slice(0,4).map(field=>/^(providers|platforms)$/i.test(field.label)&&Array.isArray(field.after)?'<div><dd>'+providerMarks(field.after,meta)+'</dd></div>':'<div><dt>'+esc(/micros$|cents$/i.test(field.label)?field.label.replace(/ (?:micros|cents)$/i,'')+' · '+(currency||'account units'):field.label)+'</dt><dd>'+recordValue(field.after,field.label.replaceAll(' ','_'),currency)+'</dd></div>').join('')+'</dl>':'')+'</article>';
731
+ const heading=label!=null||provider||status?'<div class="record-heading"><div class="record-name">'+(provider?'<span role="img" aria-label="'+esc(providerName(provider,meta.providerNames||{}))+'">'+logo(provider)+'</span>':'')+(label!=null?'<strong>'+esc(label)+'</strong>':'')+'</div>'+(status?'<span>'+esc(recordLeaf(status.path)==='archived'&&typeof status.after==='boolean'?(status.after?'Archived':'Unarchived'):status.after)+'</span>':'')+'</div>':'';
732
+ return '<article class="record-row">'+heading+(displayed.length?'<dl class="record-fields">'+displayed.map(field=>{
733
+ if(/^(providers|platforms)$/i.test(field.label)&&Array.isArray(field.after))return '<div><dd>'+providerMarks(field.after,meta)+'</dd></div>';
734
+ const label=labels.get(field.path);
735
+ return '<div><dt>'+esc(recordAmountScale(field.path)?label.replace(/ (?:micros|cents)$/i,''):label)+'</dt><dd>'+recordValue(field.after,field.path,currency)+'</dd></div>';
736
+ }).join('')+'</dl>':'')+'</article>';
529
737
  }
530
738
  function entityRecordTable(tool) {
531
739
  return /^(?:google|meta|apple|microsoft|tiktok|linkedin|pinterest|reddit|snapchat|spotify|openai|x)_(?:list_)?(?:campaigns|campaign_groups|adgroups|ad_groups|ad_sets|adsets|line_items|adsquads)$/.test(tool||'');
@@ -560,6 +768,13 @@ var RECORD_UI_SCRIPT = String.raw`
560
768
  workflowCell(entityHeaders[i],esc(workflowText(value)||(i===0?'Record '+(index+1):'—')),i===0)).join('')+'</tr>';
561
769
  }
562
770
 
771
+ function campaignGoalSettings(data) {
772
+ if(data._adport?.tool!=='google_custom_conversion_goals'||!Array.isArray(data.campaigns)||!data.campaigns.length)return '';
773
+ const rows=data.campaigns.map(campaign=>'<article class="record-row"><div class="record-heading"><strong>'+
774
+ esc(campaign.name||campaign.campaign_id)+'</strong></div><p class="operation-note">'+esc(campaign.summary)+'</p></article>').join('');
775
+ return '<section aria-label="Campaign goal settings" data-campaign-goals><h3>Campaign goal settings</h3>'+rows+'</section>';
776
+ }
777
+
563
778
  function renderRecordPages(message='') {
564
779
  const pages=recordPages,area=app.querySelector('[data-record-pages]');if(!pages||!area)return;
565
780
  const next=pages.rows.length<1000 && galleryNext(pages.meta);
@@ -591,6 +806,7 @@ var RECORD_UI_SCRIPT = String.raw`
591
806
  pages.seen.add(key);pages.meta={...meta,...(!added||pages.rows.length>=1000?{next:undefined}:{})};pages.data=value;
592
807
  state.hasLocalResult=true;state.result={structuredContent:{...value,records:pages.rows.slice(),_adport:pages.meta}};
593
808
  const notes=app.querySelector('.record-notes');if(notes)notes.innerHTML=notices(value);
809
+ const settings=app.querySelector('[data-campaign-goals]');if(settings)settings.outerHTML=campaignGoalSettings(value);
594
810
  const details=app.querySelector('[data-record-details]');if(details){details.querySelector('summary').textContent='Details · '+pages.rows.length+' loaded';details.querySelector('pre').textContent=JSON.stringify({loaded_records:pages.rows,latest_page:Object.fromEntries(Object.entries(value).filter(([field])=>field!=='_adport'))},null,2);}
595
811
  pages.busy=false;renderRecordPages(pages.rows.length>=1000?'Showing 1,000 records. Ask your assistant if you need more results.':!added&&rows.length?'No new records were returned. Ask your assistant for a fresh view.':'');
596
812
  }catch(error){if(recordPages===pages){pages.busy=false;renderRecordPages(error?.message||'Could not load more records.');}}
@@ -600,17 +816,20 @@ var RECORD_UI_SCRIPT = String.raw`
600
816
  if(meta.tool==='apple_report')return renderAppleReport(data,meta);
601
817
  if(nativeReportTools.has(meta.tool)&&(meta.tool!=='google_gaql'||arr(recordPayload(data)?.rows).some(row=>object(row?.metrics)&&Object.keys(row.metrics).length)))return renderNativeReport(data,meta);
602
818
  const payload=recordPayload(data),entries=recordEntries(payload),rows=entries ?? [payload];
603
- const title=human(String(meta.tool||'Results').replace(/^(?:google|meta|tiktok|apple|microsoft|reddit|snapchat|spotify|pinterest|linkedin|x)_/,'').replace(/^(?:list|get)_/,'').replace(/_(?:list|get)$/,'').replaceAll('_',' '));
819
+ const title=meta.tool==='google_gaql'?'Google Ads query results':human(String(meta.tool||'Results').replace(/^(?:google|meta|tiktok|apple|microsoft|reddit|snapchat|spotify|pinterest|linkedin|openai|x)_/,'').replace(/^(?:list|get)_/,'').replace(/_(?:list|get)$/,'').replaceAll('_',' '));
604
820
  const parent=object(data.parent)?Object.entries(data.parent).filter(([key])=>/_id$/.test(key)).map(([key,value])=>human(key.replace(/_id$/,''))+' '+value).join(' · '):'';
605
821
  const scope=[parent,typeof data.parent_id==='string'&&!parent?data.parent_id:'',meta.accountId].filter(Boolean).join(' · ');
606
822
  const clean=object(data)?Object.fromEntries(Object.entries(data).filter(([key])=>key!=='_adport'&&!(key==='creatives'&&meta.view==='records'))):data;
607
823
  const table=Array.isArray(entries)&&entityRecordTable(meta.tool)&&rows.every(object);
608
824
  const displayMeta=currencyOf(data)?{...meta,currency:currencyOf(data)}:meta;
609
- const markup=rows.slice(0,1000).map((row,index)=>recordEntryMarkup(row,index,displayMeta,table)).join('');
825
+ const shown=rows.slice(0,1000);
826
+ const collection=entries&&!table&&recordCollection(shown,meta,rows.length);
827
+ if(collection)return renderRecordCollection(data,displayMeta,collection,title,scope,clean,rows.length);
828
+ const markup=shown.map((row,index)=>recordEntryMarkup(row,index,displayMeta,table)).join('');
610
829
  const content=rows.length?table?'<div class="workflow-scroll" role="region" aria-label="Returned records" tabindex="0"><table class="workflow-table workflow-stack" role="table">'+workflowHeader(entityHeaders)+
611
830
  '<tbody data-record-list role="rowgroup">'+markup+'</tbody></table></div>':
612
- '<div class="record-list" data-record-list role="region" aria-label="Returned records" tabindex="0">'+markup+'</div>':'<p class="operation-note">No results returned.</p>';
613
- app.innerHTML=chrome(operationHeader(title,scope,meta.provider)+'<div class="record-notes">'+notices(data)+'</div>'+content+(rows.length>1000?'<p class="operation-note">Showing 1,000 of '+rows.length+' records. The full response is in Details.</p>':'')+'<div data-record-pages></div><details data-record-details><summary>Details'+(entries?' · '+entries.length+' results':'')+'</summary><pre>'+esc(JSON.stringify(clean,null,2))+'</pre></details>','');
831
+ '<div class="record-list" data-record-list role="region" aria-label="Returned records" tabindex="0">'+markup+'</div>':'<p class="operation-note">'+(meta.tool==='google_custom_conversion_goals'?'No custom conversion goals returned.':'No results returned.')+'</p>';
832
+ app.innerHTML=chrome(operationHeader(title,scope,meta.provider)+'<div class="record-notes">'+notices(data)+'</div>'+content+(rows.length>1000?'<p class="operation-note">Showing 1,000 of '+rows.length+' records. The full response is in Details.</p>':'')+'<div data-record-pages></div>'+campaignGoalSettings(data)+'<details data-record-details><summary>Details'+(entries?' · '+entries.length+' results':'')+'</summary><pre>'+esc(JSON.stringify(clean,null,2))+'</pre></details>','');
614
833
  if(Array.isArray(entries)&&rows.length&&galleryNext(meta)){
615
834
  recordPages={scope:galleryScope(meta),meta,data,table,rows:rows.slice(0,1000),items:new Map(),seen:new Set([galleryStable(meta.refresh.arguments)]),busy:false};
616
835
  const nodes=app.querySelectorAll('[data-record-list]>*');recordPages.rows.forEach((row,index)=>{const identity=object(row)&&(typeof row.id==='string'&&row.id||typeof row.id==='number'&&Number.isSafeInteger(row.id))?'id:'+String(row.id):galleryStable(meta.refresh.arguments)+':'+index;recordPages.items.set(identity,{row,index,node:nodes[index]});});
@@ -1016,6 +1235,10 @@ var OPERATION_RECONCILIATION_UI = String.raw`
1016
1235
 
1017
1236
  // src/operation-ui.ts
1018
1237
  var OPERATION_UI_SCRIPT = String.raw`
1238
+ const bulkNegativeKeywordTools = new Set(['google_create_negative_keyword_list','google_update_negative_keyword_list','google_link_negative_keyword_list','google_add_campaign_negative_keywords']);
1239
+ function callOperationTool(tool,args) {
1240
+ return callTool(tool,args,bulkNegativeKeywordTools.has(tool) ? 180000 : undefined);
1241
+ }
1019
1242
  const attempts = new Map(), pendingRequests = new Map();
1020
1243
  let cancelHold = () => {}, expiryTimer;
1021
1244
  const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
@@ -1096,7 +1319,7 @@ var OPERATION_UI_SCRIPT = String.raw`
1096
1319
  const previewArgs={...args};delete previewArgs.pending_operation_id;
1097
1320
  attempt.refreshing=true;render(state.result);
1098
1321
  try {
1099
- const result=await callTool(tool,previewArgs),value=resultData(result),meta=value._adport;
1322
+ const result=await callOperationTool(tool,previewArgs),value=resultData(result),meta=value._adport;
1100
1323
  if(result?.isError || value.error) throw new Error(value.message || 'The connection is not ready. Finish account selection before refreshing again.');
1101
1324
  if(value.applied!==false || value.status!=='pending_validation' || typeof value.pending_operation_id!=='string'
1102
1325
  || value.pending_operation_id===pending || meta?.tool!==tool || meta.context?.project_id!==attempt.recovery.project_id
@@ -1172,7 +1395,7 @@ var OPERATION_UI_SCRIPT = String.raw`
1172
1395
  return 'unconfirmed';
1173
1396
  }
1174
1397
  function callHostTool(tool,args) {
1175
- return callTool(tool,args).catch(error=>{throw new Error((error?.message || 'No confirmation arrived.')+' The write may have succeeded; check its status before retrying.');});
1398
+ return callOperationTool(tool,args).catch(error=>{throw new Error((error?.message || 'No confirmation arrived.')+' The write may have succeeded; check its status before retrying.');});
1176
1399
  }
1177
1400
  async function approve(tool,args,pending,expires) {
1178
1401
  if(attempts.has(pending) || pendingOf(state.result)!==pending) return;
@@ -1570,8 +1793,8 @@ var WORKFLOW_UI_STYLES = String.raw`
1570
1793
  .workflow-stack thead { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%) }
1571
1794
  .workflow-stack tbody tr { border-bottom:1px solid var(--line); padding:7px 0 }
1572
1795
  .workflow-stack tbody :is(td,th) { display:grid; grid-template-columns:minmax(88px,2fr) minmax(0,3fr); gap:8px; padding:4px 0; border:0 }
1573
- .workflow-cell-label { display:block; color:var(--muted); font-weight:400 }
1574
- .workflow-cell-label::before { content:attr(data-label) }
1796
+ .workflow-stack .workflow-cell-label { display:block; color:var(--muted); font-weight:400 }
1797
+ .workflow-stack .workflow-cell-label::before { content:attr(data-label) }
1575
1798
  }
1576
1799
  `;
1577
1800
  var WORKFLOW_UI = String.raw`
@@ -2155,8 +2378,8 @@ var REPORT_CHART_SCRIPT = String.raw`
2155
2378
  `;
2156
2379
 
2157
2380
  // src/ui.ts
2158
- var ADPORT_UI_URI = "ui://adport/insight-card-v33.html";
2159
- var ADPORT_SUMMARY_UI_URI = "ui://adport/summary-card-v33.html";
2381
+ var ADPORT_UI_URI = "ui://adport/insight-card-v36.html";
2382
+ var ADPORT_SUMMARY_UI_URI = "ui://adport/summary-card-v36.html";
2160
2383
  var ADPORT_UI_DOMAIN = "https://app.adport.dev";
2161
2384
  var ADPORT_UI_RESOURCE_DOMAINS = [
2162
2385
  ADPORT_UI_DOMAIN,
@@ -2209,6 +2432,7 @@ function viewForTool(name, readOnly) {
2209
2432
  function toolTitle(name) {
2210
2433
  if (name === "accounts_list") return "Show connected ad accounts";
2211
2434
  if (name === "report") return "Show advertising performance";
2435
+ if (name === "google_gaql") return "Query Google Ads";
2212
2436
  return name.split("_").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
2213
2437
  }
2214
2438
  function toolInvocationLabels(view) {
@@ -2634,7 +2858,7 @@ ${PLANNING_UI}
2634
2858
 
2635
2859
  // src/index.ts
2636
2860
  var PROVIDER_IDS = ["ga4", "gsc", "gtm", "google", "meta", "tiktok", "apple", "microsoft", "reddit", "snapchat", "spotify", "pinterest", "linkedin", "x", "openai"];
2637
- var ADPORT_UI_RESOURCE_URIS = [ADPORT_UI_URI, "ui://adport/insight-card-v32.html", "ui://adport/insight-card-v31.html", "ui://adport/insight-card-v30.html", "ui://adport/insight-card-v29.html", "ui://adport/insight-card-v28.html", "ui://adport/insight-card-v27.html", "ui://adport/insight-card-v26.html", "ui://adport/insight-card-v25.html", "ui://adport/insight-card-v24.html", "ui://adport/insight-card-v23.html", "ui://adport/insight-card-v22.html", "ui://adport/insight-card-v21.html", "ui://adport/insight-card-v20.html", "ui://adport/insight-card-v19.html", "ui://adport/insight-card-v18.html", "ui://adport/insight-card-v17.html", "ui://adport/insight-card-v16.html", "ui://adport/insight-card-v15.html", "ui://adport/insight-card-v14.html", "ui://adport/insight-card-v13.html", "ui://adport/insight-card-v12.html", "ui://adport/insight-card-v11.html", "ui://adport/insight-card-v10.html", "ui://adport/insight-card-v9.html", "ui://adport/insight-card-v8.html", "ui://adport/insight-card-v7.html", "ui://adport/insight-card-v6.html", "ui://adport/insight-card-v5.html", "ui://adport/insight-card-v4.html", "ui://adport/insight-card-v3.html", "ui://adport/insight-card-v2.html", ADPORT_SUMMARY_UI_URI, "ui://adport/summary-card-v32.html", "ui://adport/summary-card-v30.html"];
2861
+ var ADPORT_UI_RESOURCE_URIS = [ADPORT_UI_URI, "ui://adport/insight-card-v35.html", "ui://adport/insight-card-v34.html", "ui://adport/insight-card-v33.html", "ui://adport/insight-card-v32.html", "ui://adport/insight-card-v31.html", "ui://adport/insight-card-v30.html", "ui://adport/insight-card-v29.html", "ui://adport/insight-card-v28.html", "ui://adport/insight-card-v27.html", "ui://adport/insight-card-v26.html", "ui://adport/insight-card-v25.html", "ui://adport/insight-card-v24.html", "ui://adport/insight-card-v23.html", "ui://adport/insight-card-v22.html", "ui://adport/insight-card-v21.html", "ui://adport/insight-card-v20.html", "ui://adport/insight-card-v19.html", "ui://adport/insight-card-v18.html", "ui://adport/insight-card-v17.html", "ui://adport/insight-card-v16.html", "ui://adport/insight-card-v15.html", "ui://adport/insight-card-v14.html", "ui://adport/insight-card-v13.html", "ui://adport/insight-card-v12.html", "ui://adport/insight-card-v11.html", "ui://adport/insight-card-v10.html", "ui://adport/insight-card-v9.html", "ui://adport/insight-card-v8.html", "ui://adport/insight-card-v7.html", "ui://adport/insight-card-v6.html", "ui://adport/insight-card-v5.html", "ui://adport/insight-card-v4.html", "ui://adport/insight-card-v3.html", "ui://adport/insight-card-v2.html", ADPORT_SUMMARY_UI_URI, "ui://adport/summary-card-v35.html", "ui://adport/summary-card-v34.html", "ui://adport/summary-card-v33.html", "ui://adport/summary-card-v32.html", "ui://adport/summary-card-v30.html"];
2638
2862
  var DEFAULT_MCP_ICONS = [{
2639
2863
  src: "https://app.adport.dev/icon.svg?brand=orange-dot-v2",
2640
2864
  mimeType: "image/svg+xml",
@@ -2853,4 +3077,4 @@ export {
2853
3077
  createMcpServer,
2854
3078
  runStdioServer
2855
3079
  };
2856
- //# sourceMappingURL=chunk-RE4ZCAVJ.js.map
3080
+ //# sourceMappingURL=chunk-TNQOM6VM.js.map