@ainyc/canonry 5.1.1 → 5.1.2

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.
Files changed (26) hide show
  1. package/assets/assets/{AuditHistoryPanel-9F_74jKS.js → AuditHistoryPanel-Dc_pymFg.js} +1 -1
  2. package/assets/assets/{BacklinksPage-DmF2rbwy.js → BacklinksPage-BkSo48YX.js} +1 -1
  3. package/assets/assets/{HistoryPage-DKopwAjo.js → HistoryPage-BbswsdU7.js} +1 -1
  4. package/assets/assets/{MeasurementPropertyPage-Dpd_DYQv.js → MeasurementPropertyPage-BbgtalkM.js} +1 -1
  5. package/assets/assets/{ProjectPage-b1-57SzP.js → ProjectPage-CAcRQp-T.js} +1 -1
  6. package/assets/assets/{RunRow-BjrSRp6X.js → RunRow-2cNW8FHz.js} +1 -1
  7. package/assets/assets/{RunsPage-BFrymZ7D.js → RunsPage-Cz3lJ6VJ.js} +1 -1
  8. package/assets/assets/{SettingsPage-DdVa6pLK.js → SettingsPage-BQwB0r9k.js} +1 -1
  9. package/assets/assets/{SiteHealthSection-CizmiBjA.js → SiteHealthSection-C0aJ_UhN.js} +3 -3
  10. package/assets/assets/{TrafficPage-N7sZgb9x.js → TrafficPage-DTic3zhO.js} +1 -1
  11. package/assets/assets/{TrafficSourceDetailPage-BNQmMJ5D.js → TrafficSourceDetailPage-BKfabnCw.js} +1 -1
  12. package/assets/assets/{extract-error-message-Bh9mRIz9.js → extract-error-message-BzB8j3fC.js} +1 -1
  13. package/assets/assets/{index-BnR1Tu9j.js → index-DQGEzxrN.js} +3 -3
  14. package/assets/assets/{react-sigma_core.esm.min-DGaYwjLZ.js → react-sigma_core.esm.min-rYv0aKKx.js} +1 -1
  15. package/assets/assets/{v2-overview-adapter-eqN-8OK5.js → v2-overview-adapter-CWWPfsm-.js} +1 -1
  16. package/assets/index.html +1 -1
  17. package/dist/{chunk-MEQGGODM.js → chunk-5K2NUQOV.js} +34 -5
  18. package/dist/{chunk-3DL3KV6C.js → chunk-5ZIUROAQ.js} +48 -0
  19. package/dist/{chunk-ZWVXUPLP.js → chunk-BS4ZC7FG.js} +141 -25
  20. package/dist/{chunk-66KGNC4U.js → chunk-NKEKDWGX.js} +2 -2
  21. package/dist/{chunk-LHHJVGH7.js → chunk-WSYJ4IT7.js} +43 -15
  22. package/dist/cli.js +17 -15
  23. package/dist/index.js +4 -4
  24. package/dist/{intelligence-service-7XX5ZRYE.js → intelligence-service-D2HY2S5F.js} +2 -2
  25. package/dist/mcp.js +5 -4
  26. package/package.json +11 -11
@@ -1,4 +1,4 @@
1
- import{g as Bt,t as S,r as C}from"./vendor-tanstack-ZXXkndVj.js";import{e as Ht,G as Wt}from"./SiteHealthSection-CizmiBjA.js";import"./index-BnR1Tu9j.js";import"./vendor-radix-twS1M3FF.js";import"./vendor-recharts-D-cUuLZo.js";import"./vendor-lucide-CW2qe0uH.js";import"./vendor-markdown-B-Oq2NYq.js";import"./vendor-yaml-GWJz5H2G.js";import"./ChartPrimitives-Bxa_vFmq.js";function Vt(r,n){if(typeof r!="object"||!r)return r;var i=r[Symbol.toPrimitive];if(i!==void 0){var e=i.call(r,n);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function ae(r){var n=Vt(r,"string");return typeof n=="symbol"?n:n+""}function A(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function He(r,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,ae(e.key),e)}}function L(r,n,i){return n&&He(r.prototype,n),i&&He(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r}function Q(r){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Q(r)}function yt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(yt=function(){return!!r})()}function jt(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Zt(r,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jt(r)}function I(r,n,i){return n=Q(n),Zt(r,yt()?Reflect.construct(n,i||[],Q(r).constructor):n.apply(r,i))}function xe(r,n){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,e){return i.__proto__=e,i},xe(r,n)}function G(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&xe(r,n)}function qt(r){if(Array.isArray(r))return r}function Yt(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var e,t,a,o,s=[],l=!0,h=!1;try{if(a=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(e=a.call(i)).done)&&(s.push(e.value),s.length!==n);l=!0);}catch(u){h=!0,t=u}finally{try{if(!l&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(h)throw t}}return s}}function Se(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,e=Array(n);i<n;i++)e[i]=r[i];return e}function Tt(r,n){if(r){if(typeof r=="string")return Se(r,n);var i={}.toString.call(r).slice(8,-1);return i==="Object"&&r.constructor&&(i=r.constructor.name),i==="Map"||i==="Set"?Array.from(r):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Se(r,n):void 0}}function Xt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{g as Bt,t as S,r as C}from"./vendor-tanstack-ZXXkndVj.js";import{e as Ht,G as Wt}from"./SiteHealthSection-C0aJ_UhN.js";import"./index-DQGEzxrN.js";import"./vendor-radix-twS1M3FF.js";import"./vendor-recharts-D-cUuLZo.js";import"./vendor-lucide-CW2qe0uH.js";import"./vendor-markdown-B-Oq2NYq.js";import"./vendor-yaml-GWJz5H2G.js";import"./ChartPrimitives-Bxa_vFmq.js";function Vt(r,n){if(typeof r!="object"||!r)return r;var i=r[Symbol.toPrimitive];if(i!==void 0){var e=i.call(r,n);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function ae(r){var n=Vt(r,"string");return typeof n=="symbol"?n:n+""}function A(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function He(r,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,ae(e.key),e)}}function L(r,n,i){return n&&He(r.prototype,n),i&&He(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r}function Q(r){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Q(r)}function yt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(yt=function(){return!!r})()}function jt(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Zt(r,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jt(r)}function I(r,n,i){return n=Q(n),Zt(r,yt()?Reflect.construct(n,i||[],Q(r).constructor):n.apply(r,i))}function xe(r,n){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,e){return i.__proto__=e,i},xe(r,n)}function G(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&xe(r,n)}function qt(r){if(Array.isArray(r))return r}function Yt(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var e,t,a,o,s=[],l=!0,h=!1;try{if(a=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(e=a.call(i)).done)&&(s.push(e.value),s.length!==n);l=!0);}catch(u){h=!0,t=u}finally{try{if(!l&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(h)throw t}}return s}}function Se(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,e=Array(n);i<n;i++)e[i]=r[i];return e}function Tt(r,n){if(r){if(typeof r=="string")return Se(r,n);var i={}.toString.call(r).slice(8,-1);return i==="Object"&&r.constructor&&(i=r.constructor.name),i==="Map"||i==="Set"?Array.from(r):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Se(r,n):void 0}}function Xt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ee(r,n){return qt(r)||Yt(r,n)||Tt(r,n)||Xt()}var pe={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},Ct=new Int8Array(4),be=new Int32Array(Ct.buffer,0,1),$t=new Float32Array(Ct.buffer,0,1),Kt=/^\s*rgba?\s*\(/,Jt=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Qt(r){var n=0,i=0,e=0,t=1;if(r[0]==="#")r.length===4?(n=parseInt(r.charAt(1)+r.charAt(1),16),i=parseInt(r.charAt(2)+r.charAt(2),16),e=parseInt(r.charAt(3)+r.charAt(3),16)):(n=parseInt(r.charAt(1)+r.charAt(2),16),i=parseInt(r.charAt(3)+r.charAt(4),16),e=parseInt(r.charAt(5)+r.charAt(6),16)),r.length===9&&(t=parseInt(r.charAt(7)+r.charAt(8),16)/255);else if(Kt.test(r)){var a=r.match(Jt);a&&(n=+a[1],i=+a[2],e=+a[3],a[4]&&(t=+a[4]))}return{r:n,g:i,b:e,a:t}}var J={};for(var le in pe)J[le]=oe(pe[le]),J[pe[le]]=J[le];function Rt(r,n,i,e,t){return be[0]=e<<24|i<<16|n<<8|r,be[0]=be[0]&4278190079,$t[0]}function oe(r){if(r=r.toLowerCase(),typeof J[r]<"u")return J[r];var n=Qt(r),i=n.r,e=n.g,t=n.b,a=n.a;a=a*255|0;var o=Rt(i,e,t,a);return J[r]=o,o}var Ee={};function _t(r){if(typeof Ee[r]<"u")return Ee[r];var n=(r&16711680)>>>16,i=(r&65280)>>>8,e=r&255,t=255,a=Rt(n,i,e,t);return Ee[r]=a,a}function We(r,n,i,e){return i+(n<<8)+(r<<16)}function Ve(r,n,i,e,t,a){var o=Math.floor(i/a*t),s=Math.floor(r.drawingBufferHeight/a-e/a*t),l=new Uint8Array(4);r.bindFramebuffer(r.FRAMEBUFFER,n),r.readPixels(o,s,1,1,r.RGBA,r.UNSIGNED_BYTE,l);var h=ee(l,4),u=h[0],d=h[1],f=h[2],g=h[3];return[u,d,f,g]}function c(r,n,i){return(n=ae(n))in r?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,r}function je(r,n){var i=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);n&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),i.push.apply(i,e)}return i}function b(r){for(var n=1;n<arguments.length;n++){var i=arguments[n]!=null?arguments[n]:{};n%2?je(Object(i),!0).forEach(function(e){c(r,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):je(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function ei(r,n){for(;!{}.hasOwnProperty.call(r,n)&&(r=Q(r))!==null;);return r}function Ae(){return Ae=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(r,n,i){var e=ei(r,n);if(e){var t=Object.getOwnPropertyDescriptor(e,n);return t.get?t.get.call(arguments.length<3?r:i):t.value}},Ae.apply(null,arguments)}function wt(r,n,i,e){var t=Ae(Q(r.prototype),n,i);return typeof t=="function"?function(a){return t.apply(i,a)}:t}function ti(r){return r.normalized?1:r.size}function ye(r){var n=0;return r.forEach(function(i){return n+=ti(i)}),n}function xt(r,n,i){var e=r==="VERTEX"?n.VERTEX_SHADER:n.FRAGMENT_SHADER,t=n.createShader(e);if(t===null)throw new Error("loadShader: error while creating the shader");n.shaderSource(t,i),n.compileShader(t);var a=n.getShaderParameter(t,n.COMPILE_STATUS);if(!a){var o=n.getShaderInfoLog(t);throw n.deleteShader(t),new Error(`loadShader: error while compiling the shader:
3
3
  `.concat(o,`
4
4
  `).concat(i))}return t}function ii(r,n){return xt("VERTEX",r,n)}function ri(r,n){return xt("FRAGMENT",r,n)}function ni(r,n){var i=r.createProgram();if(i===null)throw new Error("loadProgram: error while creating the program.");var e,t;for(e=0,t=n.length;e<t;e++)r.attachShader(i,n[e]);r.linkProgram(i);var a=r.getProgramParameter(i,r.LINK_STATUS);if(!a){var o=r.getProgramInfoLog(i);throw r.deleteProgram(i),new Error("loadProgram: error while linking the program: ".concat(o))}return i}function Ze(r){var n=r.gl,i=r.buffer,e=r.program,t=r.vertexShader,a=r.fragmentShader;n.deleteShader(t),n.deleteShader(a),n.deleteProgram(e),n.deleteBuffer(i)}var qe=`#define PICKING_MODE
@@ -1 +1 @@
1
- import{j as o,r as C}from"./vendor-tanstack-ZXXkndVj.js";import{y as M,B as A}from"./index-BnR1Tu9j.js";import{M as $}from"./vendor-markdown-B-Oq2NYq.js";const H="Sources",y={copy:"Copy answer",copying:"Copying…",copied:"Copied",failed:"Could not copy. Select and copy the answer above."};function N({headingLevel:e}){return n=>{const r=[],s=i=>{i.type==="heading"&&i.depth&&r.push(i),i.children?.forEach(s)};s(n);const l=r.reduce((i,u)=>Math.min(i,u.depth),6);for(const i of r){const u=i.depth-l;i.depth=Math.min(6,e+u),i.data={...i.data,hProperties:{...i.data?.hProperties,"data-answer-heading-level":u+1}}}}}function R({answer:e}){const[n,r]=C.useState("idle"),s=C.useRef(!1),l=async()=>{if(!s.current){s.current=!0,r("copying");try{await navigator.clipboard.writeText(e),r("copied")}catch{r("failed")}finally{s.current=!1}}};return o.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3",children:[o.jsx(A,{type:"button",variant:"ghost",className:"min-h-11 px-2","aria-disabled":n==="copying","aria-busy":n==="copying",onClick:()=>{l()},children:n==="copying"?y.copying:y.copy}),o.jsx("span",{role:"status",className:"text-sm text-secondary",children:n==="copied"?y.copied:n==="failed"?y.failed:""})]})}function L({children:e,headingLevel:n=4,copyable:r=!1}){return o.jsxs("div",{className:"answer-markdown",children:[o.jsx($,{remarkPlugins:[[N,{headingLevel:n}]],components:{p:({children:s})=>o.jsx("p",{className:"mb-3 whitespace-pre-wrap last:mb-0",children:s}),ul:({children:s})=>o.jsx("ul",{className:"mb-3 ml-5 list-disc space-y-1",children:s}),ol:({children:s,start:l})=>o.jsx("ol",{start:l,className:"mb-3 ml-5 list-decimal space-y-1",children:s}),pre:({children:s})=>o.jsx("pre",{className:"mb-3 overflow-x-auto whitespace-pre-wrap",children:s}),a:({children:s,href:l})=>{const i=M(l);return i?o.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-link underline",children:s}):o.jsx("span",{children:s})},img:({alt:s})=>o.jsx("span",{children:s})},children:e}),r&&e.trim()?o.jsx(R,{answer:e},e):null]})}function F(e){const n=e[0];return n?e.every(r=>r.mode===n.mode&&r.scope.kind===n.scope.kind&&r.scope.key===n.scope.key&&r.queryClass===n.queryClass&&r.measurement.displayedRunId===n.measurement.displayedRunId):!0}function p(e){return e.state==="unavailable"?{numerator:null,denominator:null,reason:e.reason}:e.numerator===void 0||e.denominator===void 0||e.denominator<=0?{numerator:null,denominator:null,reason:"not_applicable"}:{numerator:e.numerator,denominator:e.denominator}}function I(e){return e.kind==="exact"?e.url:e.kind==="prefix"?`https://${e.host}${e.pathPrefix}/*`:`https://${e.host}/*`}function T(e){return e==="assigned"?"this-property":e==="sibling"?"another-property":e==="ownedUnmapped"?"owned-unassigned":e==="external"?"external":e==="ambiguous"?"multiple-properties":"invalid-url"}function _(e){return e==="assigned"?"positive":e==="external"?"neutral":e==="invalid"?"negative":"caution"}function k(e){return`target:${e.targetKey}:${e.queryId}:${e.executionNodeKey}`}function j(e,n,r){const s=new Map;if(!n)return s;const l=new Map(e.usageEdges.map(a=>[k(a),a.targetKey])),i=new Map(e.assignments.map(a=>[`${a.targetKey}:${a.queryId}`,a.queryClass])),u=new Map(e.usageEdges.map(a=>[k(a),i.get(`${a.targetKey}:${a.queryId}`)]));for(const a of n.evidence){if(r&&u.get(a.usageEdgeId)!==r)continue;const c=l.get(a.usageEdgeId);if(!c)continue;const m=s.get(c)??[];m.push({id:`${a.observationId}:${a.expectedSlotId}:${a.usageEdgeId}:${a.sourceUrl}`,kind:T(a.classification),query:a.queryText,provider:a.provider,location:a.location,url:a.sourceUrl,tone:_(a.classification),historical:a.historical||a.bridged}),s.set(c,m)}return s}function B(e){if(e.flags>0)return{label:"Review",tone:"caution"};const n=[e.mentionCoverage,e.citationCoverage].filter(r=>r.state==="unavailable").map(r=>r.reason);return n.includes("no_completed_run")?{label:"Not measured",tone:"neutral"}:n.includes("plan_v1")?{label:"Update setup",tone:"caution"}:n.includes("evidence_incomplete")?{label:"Evidence incomplete",tone:"caution"}:n.includes("no_population")?{label:"No queries",tone:"neutral"}:n.includes("not_applicable")?{label:"Not applicable",tone:"neutral"}:{label:"Complete",tone:"positive"}}function O(e){return e==="complete"?{label:"Complete",tone:"positive"}:e==="partial"?{label:"Partial",tone:"caution"}:e==="queued"?{label:"Queued",tone:"neutral"}:e==="running"?{label:"Running",tone:"neutral"}:e==="failed"?{label:"Failed",tone:"negative"}:{label:"Not measured",tone:"neutral"}}function U(e){if(!e)return"";const n=new Date(e);return Number.isFinite(n.getTime())?n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"}):""}function q(e){const n=e.nextAction.count??e.flags.total;if(e.nextAction.kind==="review_flags")return`${n} flagged ${n===1?"result needs":"results need"} review.`;if(e.nextAction.kind==="complete_setup")return"Finish setup.";if(e.nextAction.kind==="republish_setup")return"Setup update required.";if(e.nextAction.kind==="run_measurement")return"Ready to measure."}function W({overview:e,activePlan:n,report:r,reportState:s=r?"ready":"loading",sort:l}){if(n.plan.schemaVersion!==2||e.mode!=="active-v2")throw new Error("The current overview requires an active version-two setup.");if(e.scope.kind!=="all"&&e.scope.kind!=="group")throw new Error("The current overview requires an All Properties or group scope.");const i=n.plan,u=new Map(i.targets.map(t=>[t.stableKey,t])),a=new Map(i.querySnapshots.map(t=>[t.queryId,t.queryText])),c=new Map;for(const t of i.assignments){if(e.queryClass!=="all"&&t.queryClass!==e.queryClass)continue;const d=a.get(t.queryId);if(!d)continue;const g=c.get(t.targetKey)??new Set;g.add(d),c.set(t.targetKey,g)}const m=r?.revision===n.revision&&r.run?.id===e.measurement.displayedRunId?r:null,K=e.measurement.displayedRunId===void 0||m?"ready":s==="error"||r!=null?"error":"loading",S=j(i,m,e.queryClass==="all"?void 0:e.queryClass),h=new Map;for(const t of i.groups)for(const d of t.targetKeys)h.has(d)||h.set(d,t.label);const x=e.properties.items.map(t=>{const d=u.get(t.targetKey),g=S.get(t.targetKey)??[];return{id:t.targetKey,name:t.label,mentionCoverage:p(t.mentionCoverage),citationCoverage:p(t.citationCoverage),status:B(t),providers:t.providers?.map(f=>({provider:f.provider,mentionCoverage:p(f.mentionCoverage),citationCoverage:p(f.citationCoverage)})),market:h.get(t.targetKey),assignedQueries:[...c.get(t.targetKey)??[]],urls:d?.urlMatchers.map(I)??[],evidence:g,evidenceState:K,historical:g.some(f=>f.historical)}}),b=e.namedShareOfVoice?.entries.map(t=>({name:t.label,coverage:{numerator:t.credits,denominator:e.namedShareOfVoice.denominator}})),E=e.properties.items.flatMap(t=>t.flags>0?[{id:`property:${t.targetKey}`,property:t.label,summary:`${t.flags} ${t.flags===1?"result needs":"results need"} review.`,tone:"caution",count:t.flags}]:[]);return{classReporting:"available",latestMeasurement:{status:O(e.measurement.state),completedSlots:e.measurement.completed,totalSlots:e.measurement.expected,date:U(e.measurement.completedAt),includesBridgedHistory:e.measurement.includesHistoricalData===!0},currentView:{scope:e.scope.kind==="group"?{kind:"group",...e.scope.key?{key:e.scope.key}:{}}:{kind:"all"},queryClass:e.queryClass,aggregate:{metrics:{propertiesMentioned:p(e.metrics.propertiesMentioned),mentionCoverage:p(e.metrics.mentionCoverage),citationCoverage:p(e.metrics.citationCoverage)},properties:x,...b?{shareOfVoice:b}:{}},propertyTotal:e.properties.totalEstimate??x.length,outcomes:e.outcomes,nextCursor:e.properties.nextCursor,...l?{sort:l}:{}},availableGroups:i.groups.map(t=>({id:t.stableKey,label:t.label})),...q(e)?{nextActionText:q(e)}:{},flaggedResultsTotal:e.flags.total,flaggedResults:E}}export{L as A,H as a,F as b,W as c,I as m};
1
+ import{j as o,r as C}from"./vendor-tanstack-ZXXkndVj.js";import{y as M,B as A}from"./index-DQGEzxrN.js";import{M as $}from"./vendor-markdown-B-Oq2NYq.js";const H="Sources",y={copy:"Copy answer",copying:"Copying…",copied:"Copied",failed:"Could not copy. Select and copy the answer above."};function N({headingLevel:e}){return n=>{const r=[],s=i=>{i.type==="heading"&&i.depth&&r.push(i),i.children?.forEach(s)};s(n);const l=r.reduce((i,u)=>Math.min(i,u.depth),6);for(const i of r){const u=i.depth-l;i.depth=Math.min(6,e+u),i.data={...i.data,hProperties:{...i.data?.hProperties,"data-answer-heading-level":u+1}}}}}function R({answer:e}){const[n,r]=C.useState("idle"),s=C.useRef(!1),l=async()=>{if(!s.current){s.current=!0,r("copying");try{await navigator.clipboard.writeText(e),r("copied")}catch{r("failed")}finally{s.current=!1}}};return o.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3",children:[o.jsx(A,{type:"button",variant:"ghost",className:"min-h-11 px-2","aria-disabled":n==="copying","aria-busy":n==="copying",onClick:()=>{l()},children:n==="copying"?y.copying:y.copy}),o.jsx("span",{role:"status",className:"text-sm text-secondary",children:n==="copied"?y.copied:n==="failed"?y.failed:""})]})}function L({children:e,headingLevel:n=4,copyable:r=!1}){return o.jsxs("div",{className:"answer-markdown",children:[o.jsx($,{remarkPlugins:[[N,{headingLevel:n}]],components:{p:({children:s})=>o.jsx("p",{className:"mb-3 whitespace-pre-wrap last:mb-0",children:s}),ul:({children:s})=>o.jsx("ul",{className:"mb-3 ml-5 list-disc space-y-1",children:s}),ol:({children:s,start:l})=>o.jsx("ol",{start:l,className:"mb-3 ml-5 list-decimal space-y-1",children:s}),pre:({children:s})=>o.jsx("pre",{className:"mb-3 overflow-x-auto whitespace-pre-wrap",children:s}),a:({children:s,href:l})=>{const i=M(l);return i?o.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-link underline",children:s}):o.jsx("span",{children:s})},img:({alt:s})=>o.jsx("span",{children:s})},children:e}),r&&e.trim()?o.jsx(R,{answer:e},e):null]})}function F(e){const n=e[0];return n?e.every(r=>r.mode===n.mode&&r.scope.kind===n.scope.kind&&r.scope.key===n.scope.key&&r.queryClass===n.queryClass&&r.measurement.displayedRunId===n.measurement.displayedRunId):!0}function p(e){return e.state==="unavailable"?{numerator:null,denominator:null,reason:e.reason}:e.numerator===void 0||e.denominator===void 0||e.denominator<=0?{numerator:null,denominator:null,reason:"not_applicable"}:{numerator:e.numerator,denominator:e.denominator}}function I(e){return e.kind==="exact"?e.url:e.kind==="prefix"?`https://${e.host}${e.pathPrefix}/*`:`https://${e.host}/*`}function T(e){return e==="assigned"?"this-property":e==="sibling"?"another-property":e==="ownedUnmapped"?"owned-unassigned":e==="external"?"external":e==="ambiguous"?"multiple-properties":"invalid-url"}function _(e){return e==="assigned"?"positive":e==="external"?"neutral":e==="invalid"?"negative":"caution"}function k(e){return`target:${e.targetKey}:${e.queryId}:${e.executionNodeKey}`}function j(e,n,r){const s=new Map;if(!n)return s;const l=new Map(e.usageEdges.map(a=>[k(a),a.targetKey])),i=new Map(e.assignments.map(a=>[`${a.targetKey}:${a.queryId}`,a.queryClass])),u=new Map(e.usageEdges.map(a=>[k(a),i.get(`${a.targetKey}:${a.queryId}`)]));for(const a of n.evidence){if(r&&u.get(a.usageEdgeId)!==r)continue;const c=l.get(a.usageEdgeId);if(!c)continue;const m=s.get(c)??[];m.push({id:`${a.observationId}:${a.expectedSlotId}:${a.usageEdgeId}:${a.sourceUrl}`,kind:T(a.classification),query:a.queryText,provider:a.provider,location:a.location,url:a.sourceUrl,tone:_(a.classification),historical:a.historical||a.bridged}),s.set(c,m)}return s}function B(e){if(e.flags>0)return{label:"Review",tone:"caution"};const n=[e.mentionCoverage,e.citationCoverage].filter(r=>r.state==="unavailable").map(r=>r.reason);return n.includes("no_completed_run")?{label:"Not measured",tone:"neutral"}:n.includes("plan_v1")?{label:"Update setup",tone:"caution"}:n.includes("evidence_incomplete")?{label:"Evidence incomplete",tone:"caution"}:n.includes("no_population")?{label:"No queries",tone:"neutral"}:n.includes("not_applicable")?{label:"Not applicable",tone:"neutral"}:{label:"Complete",tone:"positive"}}function O(e){return e==="complete"?{label:"Complete",tone:"positive"}:e==="partial"?{label:"Partial",tone:"caution"}:e==="queued"?{label:"Queued",tone:"neutral"}:e==="running"?{label:"Running",tone:"neutral"}:e==="failed"?{label:"Failed",tone:"negative"}:{label:"Not measured",tone:"neutral"}}function U(e){if(!e)return"";const n=new Date(e);return Number.isFinite(n.getTime())?n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"}):""}function q(e){const n=e.nextAction.count??e.flags.total;if(e.nextAction.kind==="review_flags")return`${n} flagged ${n===1?"result needs":"results need"} review.`;if(e.nextAction.kind==="complete_setup")return"Finish setup.";if(e.nextAction.kind==="republish_setup")return"Setup update required.";if(e.nextAction.kind==="run_measurement")return"Ready to measure."}function W({overview:e,activePlan:n,report:r,reportState:s=r?"ready":"loading",sort:l}){if(n.plan.schemaVersion!==2||e.mode!=="active-v2")throw new Error("The current overview requires an active version-two setup.");if(e.scope.kind!=="all"&&e.scope.kind!=="group")throw new Error("The current overview requires an All Properties or group scope.");const i=n.plan,u=new Map(i.targets.map(t=>[t.stableKey,t])),a=new Map(i.querySnapshots.map(t=>[t.queryId,t.queryText])),c=new Map;for(const t of i.assignments){if(e.queryClass!=="all"&&t.queryClass!==e.queryClass)continue;const d=a.get(t.queryId);if(!d)continue;const g=c.get(t.targetKey)??new Set;g.add(d),c.set(t.targetKey,g)}const m=r?.revision===n.revision&&r.run?.id===e.measurement.displayedRunId?r:null,K=e.measurement.displayedRunId===void 0||m?"ready":s==="error"||r!=null?"error":"loading",S=j(i,m,e.queryClass==="all"?void 0:e.queryClass),h=new Map;for(const t of i.groups)for(const d of t.targetKeys)h.has(d)||h.set(d,t.label);const x=e.properties.items.map(t=>{const d=u.get(t.targetKey),g=S.get(t.targetKey)??[];return{id:t.targetKey,name:t.label,mentionCoverage:p(t.mentionCoverage),citationCoverage:p(t.citationCoverage),status:B(t),providers:t.providers?.map(f=>({provider:f.provider,mentionCoverage:p(f.mentionCoverage),citationCoverage:p(f.citationCoverage)})),market:h.get(t.targetKey),assignedQueries:[...c.get(t.targetKey)??[]],urls:d?.urlMatchers.map(I)??[],evidence:g,evidenceState:K,historical:g.some(f=>f.historical)}}),b=e.namedShareOfVoice?.entries.map(t=>({name:t.label,coverage:{numerator:t.credits,denominator:e.namedShareOfVoice.denominator}})),E=e.properties.items.flatMap(t=>t.flags>0?[{id:`property:${t.targetKey}`,property:t.label,summary:`${t.flags} ${t.flags===1?"result needs":"results need"} review.`,tone:"caution",count:t.flags}]:[]);return{classReporting:"available",latestMeasurement:{status:O(e.measurement.state),completedSlots:e.measurement.completed,totalSlots:e.measurement.expected,date:U(e.measurement.completedAt),includesBridgedHistory:e.measurement.includesHistoricalData===!0},currentView:{scope:e.scope.kind==="group"?{kind:"group",...e.scope.key?{key:e.scope.key}:{}}:{kind:"all"},queryClass:e.queryClass,aggregate:{metrics:{propertiesMentioned:p(e.metrics.propertiesMentioned),mentionCoverage:p(e.metrics.mentionCoverage),citationCoverage:p(e.metrics.citationCoverage)},properties:x,...b?{shareOfVoice:b}:{}},propertyTotal:e.properties.totalEstimate??x.length,outcomes:e.outcomes,nextCursor:e.properties.nextCursor,...l?{sort:l}:{}},availableGroups:i.groups.map(t=>({id:t.stableKey,label:t.label})),...q(e)?{nextActionText:q(e)}:{},flaggedResultsTotal:e.flags.total,flaggedResults:E}}export{L as A,H as a,F as b,W as c,I as m};
package/assets/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <link rel="icon" type="image/png" sizes="32x32" href="./favicon-32.png" />
13
13
  <link rel="apple-touch-icon" href="./apple-touch-icon.png" />
14
14
  <title>Canonry</title>
15
- <script type="module" crossorigin src="./assets/index-BnR1Tu9j.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-DQGEzxrN.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="./assets/vendor-tanstack-ZXXkndVj.js">
17
17
  <link rel="modulepreload" crossorigin href="./assets/vendor-radix-twS1M3FF.js">
18
18
  <link rel="modulepreload" crossorigin href="./assets/vendor-recharts-D-cUuLZo.js">
@@ -9,6 +9,7 @@ import {
9
9
  RESEARCH_RUN_SCOPE,
10
10
  SKILL_MANIFEST_FILENAME,
11
11
  SkillsClients,
12
+ USAGE_TELEMETRY_HEADERS,
12
13
  adsActivateTreeRequestSchema,
13
14
  adsAdCreateRequestSchema,
14
15
  adsAdGroupCreateRequestSchema,
@@ -30,6 +31,7 @@ import {
30
31
  competitorBatchRequestSchema,
31
32
  competitorLandscapeQuerySchema,
32
33
  describeError,
34
+ detectAgentRuntime,
33
35
  discoveryBucketSchema,
34
36
  discoveryCompetitorTypeSchema,
35
37
  discoveryPromoteRequestSchema,
@@ -82,6 +84,7 @@ import {
82
84
  measurementQueryTemplateApplyRequestSchema,
83
85
  measurementQueryTemplateUpsertRequestSchema,
84
86
  measurementQuestionResultQuerySchema,
87
+ normalizeAgentSlug,
85
88
  normalizeTelemetryStatus,
86
89
  notificationCreateRequestSchema,
87
90
  notificationEventSchema,
@@ -115,7 +118,7 @@ import {
115
118
  trafficEventKindSchema,
116
119
  trafficSeriesGranularitySchema,
117
120
  visibilityReportRequestSchema
118
- } from "./chunk-3DL3KV6C.js";
121
+ } from "./chunk-5ZIUROAQ.js";
119
122
 
120
123
  // src/cli-error.ts
121
124
  function isMachineFormat(format) {
@@ -609,6 +612,9 @@ function configExists() {
609
612
  return fs.existsSync(getConfigPath());
610
613
  }
611
614
 
615
+ // src/client.ts
616
+ import { AsyncLocalStorage } from "async_hooks";
617
+
612
618
  // src/client-reliability.ts
613
619
  function parseRetryAfterMs(header, now = Date.now()) {
614
620
  if (!header) return void 0;
@@ -6021,6 +6027,11 @@ function createClient2(opts) {
6021
6027
  }
6022
6028
 
6023
6029
  // src/client.ts
6030
+ var usageTagStore = new AsyncLocalStorage();
6031
+ function runWithUsageTags(client2, tags, fn) {
6032
+ if (!(client2 instanceof ApiClient)) return fn();
6033
+ return usageTagStore.run(tags, fn);
6034
+ }
6024
6035
  var SAFE_CLIENT_NAME = /^\w[\w./-]{0,127}$/;
6025
6036
  var SAFE_ACTOR_SESSION = /^\w[\w.:-]{0,127}$/;
6026
6037
  function safeClientName(value) {
@@ -6049,12 +6060,24 @@ var ApiClient = class {
6049
6060
  this.probeSkipped = opts?.skipProbe ?? false;
6050
6061
  this.heyClientBaseUrl = this.originUrl;
6051
6062
  const actorSession = safeActorSession(opts?.actorSession);
6063
+ const surface = opts?.surface ?? "cli";
6064
+ const serverHosted = surface === "mcp-http" || surface === "aero";
6052
6065
  this.requestHeaders = {
6053
6066
  authorization: `Bearer ${this.apiKey}`,
6054
6067
  "user-agent": safeClientName(opts?.clientName),
6055
- ...actorSession ? { "x-canonry-actor-session": actorSession } : {}
6068
+ ...actorSession ? { "x-canonry-actor-session": actorSession } : {},
6069
+ [USAGE_TELEMETRY_HEADERS.surface]: surface,
6070
+ ...serverHosted ? {} : { [USAGE_TELEMETRY_HEADERS.agent]: detectAgentRuntime(process.env) }
6056
6071
  };
6057
6072
  this.heyClient = createClient2({ baseUrl: this.originUrl, apiKey: this.apiKey, headers: this.requestHeaders });
6073
+ this.heyClient.interceptors.request.use((request) => {
6074
+ const tags = usageTagStore.getStore();
6075
+ if (tags?.mcpTool) request.headers.set(USAGE_TELEMETRY_HEADERS.mcpTool, tags.mcpTool);
6076
+ if (tags?.mcpCall) request.headers.set(USAGE_TELEMETRY_HEADERS.mcpCall, tags.mcpCall);
6077
+ const mcpClient = normalizeAgentSlug(tags?.mcpClient);
6078
+ if (mcpClient) request.headers.set(USAGE_TELEMETRY_HEADERS.mcpClient, mcpClient);
6079
+ return request;
6080
+ });
6058
6081
  }
6059
6082
  /**
6060
6083
  * On first API call, probe /health to auto-discover basePath when the user
@@ -6330,7 +6353,7 @@ var ApiClient = class {
6330
6353
  let res;
6331
6354
  try {
6332
6355
  res = await fetch(url, {
6333
- headers: { Authorization: `Bearer ${this.apiKey}` }
6356
+ headers: { ...this.requestHeaders }
6334
6357
  });
6335
6358
  } catch (err) {
6336
6359
  const message = describeError(err);
@@ -8939,6 +8962,7 @@ var ApiClient = class {
8939
8962
  };
8940
8963
 
8941
8964
  // src/mcp/server.ts
8965
+ import { randomUUID } from "crypto";
8942
8966
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
8943
8967
  import { z as z5 } from "zod";
8944
8968
 
@@ -13116,7 +13140,7 @@ function createCanonryMcpServer(options = {}) {
13116
13140
  }
13117
13141
  var SERVER_INSTRUCTIONS = OPERATIONS_GUIDE.initialize;
13118
13142
  function createCanonryMcpServerWithCatalog(options = {}) {
13119
- const clientFactory = options.clientFactory ?? (() => createApiClient({ clientName: "canonry-mcp" }));
13143
+ const clientFactory = options.clientFactory ?? (() => createApiClient({ clientName: "canonry-mcp", surface: "mcp-stdio", actorSession: randomUUID() }));
13120
13144
  const client2 = clientFactory();
13121
13145
  const scope = options.scope ?? "all";
13122
13146
  const server = new McpServer({
@@ -13141,7 +13165,11 @@ function createCanonryMcpServerWithCatalog(options = {}) {
13141
13165
  },
13142
13166
  async (input) => withToolErrors(async () => {
13143
13167
  const parsed = tool.inputSchema.parse(input ?? {});
13144
- return handler(client2, parsed);
13168
+ return runWithUsageTags(client2, {
13169
+ mcpTool: tool.name,
13170
+ mcpCall: randomUUID(),
13171
+ mcpClient: server.server.getClientVersion()?.name
13172
+ }, () => handler(client2, parsed));
13145
13173
  })
13146
13174
  );
13147
13175
  entries.push({ tool, registered });
@@ -13618,6 +13646,7 @@ export {
13618
13646
  emitInstallSummary,
13619
13647
  getMissingUserSkillsNudge,
13620
13648
  parseSkillsClient,
13649
+ runWithUsageTags,
13621
13650
  createApiClient,
13622
13651
  ApiClient,
13623
13652
  measurementDraftOperationSchema,
@@ -17782,6 +17782,49 @@ function isGhostTelemetryEvent(eventName, properties) {
17782
17782
  const location = typeof properties.location === "string" ? properties.location.trim().toLowerCase() : "";
17783
17783
  return GHOST_TELEMETRY_TEST_LOCATIONS.has(location);
17784
17784
  }
17785
+ var usageSurfaceSchema = z60.enum(["cli", "mcp-stdio", "mcp-http", "aero", "api", "dashboard"]);
17786
+ var USAGE_TELEMETRY_HEADERS = {
17787
+ surface: "x-canonry-surface",
17788
+ agent: "x-canonry-agent",
17789
+ mcpClient: "x-canonry-mcp-client",
17790
+ mcpTool: "x-canonry-mcp-tool",
17791
+ mcpCall: "x-canonry-mcp-call"
17792
+ };
17793
+ var AGENT_NONE = "none";
17794
+ var AGENT_SLUG_PATTERN = /^[a-z0-9][a-z0-9._-]{0,39}$/;
17795
+ function normalizeAgentSlug(value) {
17796
+ if (!value) return null;
17797
+ const slug = value.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").slice(0, 40).replace(/^[-._]+|[-._]+$/g, "");
17798
+ return AGENT_SLUG_PATTERN.test(slug) ? slug : null;
17799
+ }
17800
+ var AI_AGENT_ALIASES = {
17801
+ "claude-code": "claude",
17802
+ "github-copilot-cli": "github-copilot"
17803
+ };
17804
+ function agentFromAiAgentVariable(value) {
17805
+ const name = value.trim().toLowerCase().replace(/_agent$/, "").replace(/_\d[\d._-]*$/, "");
17806
+ const slug = normalizeAgentSlug(name);
17807
+ return slug ? AI_AGENT_ALIASES[slug] ?? slug : null;
17808
+ }
17809
+ function detectAgentRuntime(env) {
17810
+ const explicit = normalizeAgentSlug(env.CANONRY_AGENT);
17811
+ if (explicit) return explicit;
17812
+ if (env.AI_AGENT?.trim()) {
17813
+ const named = agentFromAiAgentVariable(env.AI_AGENT);
17814
+ if (named) return named;
17815
+ }
17816
+ if (env.CURSOR_TRACE_ID) return "cursor";
17817
+ if (env.CURSOR_AGENT || env.CURSOR_EXTENSION_HOST_ROLE === "agent-exec") return "cursor-cli";
17818
+ if (env.GEMINI_CLI) return "gemini";
17819
+ if (env.CODEX_SANDBOX || env.CODEX_CI || env.CODEX_THREAD_ID) return "codex";
17820
+ if (env.ANTIGRAVITY_AGENT) return "antigravity";
17821
+ if (env.AUGMENT_AGENT) return "augment-cli";
17822
+ if (env.OPENCODE_CLIENT) return "opencode";
17823
+ if (env.CLAUDECODE || env.CLAUDE_CODE) return env.CLAUDE_CODE_IS_COWORK ? "cowork" : "claude";
17824
+ if (env.REPL_ID) return "replit";
17825
+ if (env.COPILOT_MODEL || env.COPILOT_ALLOW_ALL || env.COPILOT_GITHUB_TOKEN) return "github-copilot";
17826
+ return AGENT_NONE;
17827
+ }
17785
17828
 
17786
17829
  // ../contracts/src/trend-stability.ts
17787
17830
  var MIN_TREND_POINTS = 4;
@@ -18793,6 +18836,11 @@ export {
18793
18836
  normalizeOnboardingEventForCollection,
18794
18837
  telemetryEventAcceptedDtoSchema,
18795
18838
  isGhostTelemetryEvent,
18839
+ usageSurfaceSchema,
18840
+ USAGE_TELEMETRY_HEADERS,
18841
+ AGENT_NONE,
18842
+ normalizeAgentSlug,
18843
+ detectAgentRuntime,
18796
18844
  MIN_TREND_POINTS,
18797
18845
  isTrendBaseline,
18798
18846
  operationalLogEntryDtoSchema,
@@ -15,8 +15,9 @@ import {
15
15
  loadConfig,
16
16
  loadConfigRaw,
17
17
  resolveOperatorApiKeyIds,
18
+ runWithUsageTags,
18
19
  saveConfigPatch
19
- } from "./chunk-MEQGGODM.js";
20
+ } from "./chunk-5K2NUQOV.js";
20
21
  import {
21
22
  CC_CACHE_DIR,
22
23
  DUCKDB_SPEC,
@@ -167,9 +168,10 @@ import {
167
168
  siteCrawlSnapshots,
168
169
  toAlertView,
169
170
  usageCounters
170
- } from "./chunk-LHHJVGH7.js";
171
+ } from "./chunk-WSYJ4IT7.js";
171
172
  import {
172
173
  AGENT_MEMORY_VALUE_MAX_BYTES,
174
+ AGENT_NONE,
173
175
  AGENT_PROVIDER_IDS,
174
176
  AI_ENGINE_DOMAINS,
175
177
  AI_ENGINE_SELF_DOMAINS,
@@ -247,6 +249,7 @@ import {
247
249
  deriveIndexCoverage,
248
250
  deriveSiteHealthState,
249
251
  describeError,
252
+ detectAgentRuntime,
250
253
  determineAnswerMentioned,
251
254
  dollarsToMicros,
252
255
  effectiveBrandNames,
@@ -283,6 +286,7 @@ import {
283
286
  mapWithConcurrency,
284
287
  maskTelemetryAnonymousId,
285
288
  nextScheduleUpdatedAt,
289
+ normalizeAgentSlug,
286
290
  normalizeIdTokens,
287
291
  normalizeMeasurementExecutionQueryText,
288
292
  normalizeServedModel,
@@ -309,10 +313,19 @@ import {
309
313
  templateLinkUbiquityAvailable,
310
314
  textContainsBrandAlias,
311
315
  textContainsDomain,
316
+ usageSurfaceSchema,
312
317
  validationError,
313
318
  winnabilityClassLabel,
314
319
  withRetry
315
- } from "./chunk-3DL3KV6C.js";
320
+ } from "./chunk-5ZIUROAQ.js";
321
+
322
+ // src/runtime-context.ts
323
+ function cliRuntimeContext(env = process.env, stdio = process) {
324
+ return {
325
+ agent: detectAgentRuntime(env),
326
+ interactive: Boolean(stdio.stdin.isTTY && stdio.stdout.isTTY)
327
+ };
328
+ }
316
329
 
317
330
  // src/telemetry.ts
318
331
  import crypto from "crypto";
@@ -343,7 +356,8 @@ function trackCliCommandFinished(input) {
343
356
  command: input.command,
344
357
  success: input.success,
345
358
  duration_bucket: bucketCliCommandDuration(input.durationMs),
346
- ...input.setupState ? { setup_state: input.setupState } : {}
359
+ ...input.setupState ? { setup_state: input.setupState } : {},
360
+ ...cliRuntimeContext()
347
361
  },
348
362
  input.errorCode ? { errorCode: input.errorCode } : void 0
349
363
  );
@@ -418,7 +432,8 @@ function getOrCreateAnonymousId() {
418
432
  try {
419
433
  const config = loadConfig();
420
434
  if (config.anonymousId) return config.anonymousId;
421
- const id = crypto.randomUUID();
435
+ const carried = preConfigAnonymousId?.configPath === getConfigPath() ? preConfigAnonymousId.id : void 0;
436
+ const id = carried ?? crypto.randomUUID();
422
437
  config.anonymousId = id;
423
438
  try {
424
439
  saveConfigPatch(config);
@@ -430,8 +445,11 @@ function getOrCreateAnonymousId() {
430
445
  return getDeterministicAnonymousId();
431
446
  }
432
447
  }
433
- return getDeterministicAnonymousId();
448
+ const fallback = getDeterministicAnonymousId();
449
+ if (fallback) preConfigAnonymousId = { configPath: getConfigPath(), id: fallback };
450
+ return fallback;
434
451
  }
452
+ var preConfigAnonymousId;
435
453
  function readEnvAnonymousId() {
436
454
  const raw = process.env[ANON_ID_ENV_VAR]?.trim();
437
455
  if (!raw) return void 0;
@@ -506,10 +524,19 @@ function detectAndTrackUpgrade() {
506
524
  trackEvent("cli.upgraded", { fromVersion: lastSeen, toVersion: VERSION });
507
525
  }
508
526
  function trackEvent(event, properties, options) {
509
- if (!isTelemetryEnabled()) return;
510
- if (shouldDropTelemetryEvent(event, properties)) return;
527
+ void deliverEvent(event, properties, options);
528
+ }
529
+ function setTelemetryPreference(enabled, method) {
530
+ loadConfig();
531
+ const announce = !enabled && isTelemetryEnabled();
532
+ saveConfigPatch({ telemetry: enabled });
533
+ return announce ? deliverEvent("telemetry.disabled", { method }, void 0, { preferenceChecked: true }) : Promise.resolve();
534
+ }
535
+ function deliverEvent(event, properties, options, delivery = {}) {
536
+ if (!delivery.preferenceChecked && !isTelemetryEnabled()) return Promise.resolve();
537
+ if (shouldDropTelemetryEvent(event, properties)) return Promise.resolve();
511
538
  const anonymousId = getOrCreateAnonymousId();
512
- if (!anonymousId) return;
539
+ if (!anonymousId) return Promise.resolve();
513
540
  const payload = {
514
541
  eventId: options?.eventId ?? crypto.randomUUID(),
515
542
  anonymousId,
@@ -529,15 +556,15 @@ function trackEvent(event, properties, options) {
529
556
  const timeout = setTimeout(() => controller.abort(), TIMEOUT_MS);
530
557
  timeout.unref();
531
558
  try {
532
- void fetch(TELEMETRY_ENDPOINT, {
559
+ return fetch(TELEMETRY_ENDPOINT, {
533
560
  method: "POST",
534
561
  headers: { "Content-Type": "application/json" },
535
562
  body: JSON.stringify(payload),
536
563
  signal: controller.signal
537
- }).catch(() => {
538
- }).finally(() => clearTimeout(timeout));
564
+ }).then(() => void 0, () => void 0).finally(() => clearTimeout(timeout));
539
565
  } catch {
540
566
  clearTimeout(timeout);
567
+ return Promise.resolve();
541
568
  }
542
569
  }
543
570
 
@@ -6280,13 +6307,93 @@ function removeWordpressConnection(config, projectName) {
6280
6307
  return true;
6281
6308
  }
6282
6309
 
6310
+ // src/usage-telemetry.ts
6311
+ var API_REQUEST_BUCKET_CAPACITY = 20;
6312
+ var API_REQUEST_REFILL_PER_MS = 1 / 1e4;
6313
+ var MAX_TRACKED_MCP_SESSIONS = 2e3;
6314
+ var MAX_ROUTE_LENGTH = 200;
6315
+ var SKIPPED_ROUTE_PATTERN = /(?:^|\/)(?:health|openapi\.json|telemetry)(?:\/|$)/;
6316
+ var MCP_CALL_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
6317
+ var MCP_TOOL_PATTERN = /^[a-z][a-z0-9_]{0,79}$/;
6318
+ function classifyUsageSurface(info) {
6319
+ const labelled = usageSurfaceSchema.safeParse(info.usageLabels.surface);
6320
+ if (labelled.success) return labelled.data;
6321
+ const ua = info.userAgent ?? "";
6322
+ if (ua.startsWith("canonry-cli")) return "cli";
6323
+ if (ua.startsWith("canonry-mcp/")) return "mcp-http";
6324
+ if (ua === "canonry-mcp") return "mcp-stdio";
6325
+ if (ua.startsWith("Mozilla/")) return "dashboard";
6326
+ return "api";
6327
+ }
6328
+ function statusClass(statusCode) {
6329
+ if (statusCode >= 500) return "5xx";
6330
+ if (statusCode >= 400) return "4xx";
6331
+ if (statusCode >= 300) return "3xx";
6332
+ return "2xx";
6333
+ }
6334
+ function createApiUsageTelemetry(options = {}) {
6335
+ const emit = options.emit ?? trackEvent;
6336
+ const now = options.now ?? Date.now;
6337
+ let tokens = API_REQUEST_BUCKET_CAPACITY;
6338
+ let refilledAt = now();
6339
+ let droppedBefore = 0;
6340
+ const seenSessions = /* @__PURE__ */ new Set();
6341
+ const takeToken = () => {
6342
+ const at = now();
6343
+ tokens = Math.min(API_REQUEST_BUCKET_CAPACITY, tokens + (at - refilledAt) * API_REQUEST_REFILL_PER_MS);
6344
+ refilledAt = at;
6345
+ if (tokens < 1) return false;
6346
+ tokens -= 1;
6347
+ return true;
6348
+ };
6349
+ return (info) => {
6350
+ if (info.method === "OPTIONS" || info.method === "HEAD") return;
6351
+ if (SKIPPED_ROUTE_PATTERN.test(info.route)) return;
6352
+ const surface = classifyUsageSurface(info);
6353
+ if (surface === "cli" || surface === "dashboard") return;
6354
+ const labels = info.usageLabels;
6355
+ const mcpClient = normalizeAgentSlug(labels.mcpClient);
6356
+ const detected = normalizeAgentSlug(labels.agent);
6357
+ const agent = detected && detected !== AGENT_NONE ? detected : mcpClient ?? detected ?? AGENT_NONE;
6358
+ const mcpTool = labels.mcpTool && MCP_TOOL_PATTERN.test(labels.mcpTool) ? labels.mcpTool : void 0;
6359
+ const mcpCallId = labels.mcpCall && MCP_CALL_ID_PATTERN.test(labels.mcpCall) ? labels.mcpCall.toLowerCase() : void 0;
6360
+ const isMcp = surface === "mcp-stdio" || surface === "mcp-http";
6361
+ if (isMcp && mcpTool && info.actorSession && !seenSessions.has(info.actorSession)) {
6362
+ if (seenSessions.size >= MAX_TRACKED_MCP_SESSIONS) {
6363
+ const oldest = seenSessions.values().next().value;
6364
+ if (oldest !== void 0) seenSessions.delete(oldest);
6365
+ }
6366
+ seenSessions.add(info.actorSession);
6367
+ emit("mcp.session.started", { surface, agent, ...mcpClient ? { mcpClient } : {} }, { source: "cli-server" });
6368
+ }
6369
+ if (!takeToken()) {
6370
+ droppedBefore += 1;
6371
+ return;
6372
+ }
6373
+ const properties = {
6374
+ surface,
6375
+ agent,
6376
+ method: info.method,
6377
+ route: info.route.slice(0, MAX_ROUTE_LENGTH),
6378
+ statusClass: statusClass(info.statusCode),
6379
+ durationBucket: bucketCliCommandDuration(info.durationMs),
6380
+ ...mcpClient ? { mcpClient } : {},
6381
+ ...mcpTool ? { mcpTool } : {},
6382
+ ...mcpCallId ? { mcpCallId } : {},
6383
+ ...droppedBefore > 0 ? { droppedBefore } : {}
6384
+ };
6385
+ droppedBefore = 0;
6386
+ emit("api.request", properties, { source: "cli-server" });
6387
+ };
6388
+ }
6389
+
6283
6390
  // src/instance-identity.ts
6284
6391
  function nonBlank(value) {
6285
6392
  const trimmed = value?.trim();
6286
6393
  return trimmed ? trimmed : void 0;
6287
6394
  }
6288
6395
  function resolveBuildCommit(env = process.env) {
6289
- const embedded = true ? "2c66fea459e20ff285096090dbc6a6ee788c4c00" : void 0;
6396
+ const embedded = true ? "267b6410fa27a2bf032d4957047859e1f9eee6d1" : void 0;
6290
6397
  return nonBlank(embedded) ?? nonBlank(env.CANONRY_COMMIT);
6291
6398
  }
6292
6399
  function resolveInstanceIdentity(env = process.env) {
@@ -12212,7 +12319,7 @@ function readStoredGroundingSources(rawResponse) {
12212
12319
  return result;
12213
12320
  }
12214
12321
  async function backfillInsightsCommand(project, opts) {
12215
- const { IntelligenceService: IntelligenceService2 } = await import("./intelligence-service-7XX5ZRYE.js");
12322
+ const { IntelligenceService: IntelligenceService2 } = await import("./intelligence-service-D2HY2S5F.js");
12216
12323
  const config = loadConfig();
12217
12324
  const db = createClient(config.database);
12218
12325
  migrate(db);
@@ -14306,6 +14413,7 @@ import { Type as Type3 } from "@sinclair/typebox";
14306
14413
 
14307
14414
  // src/agent/mcp-to-agent-tool.ts
14308
14415
  import { Type as Type2 } from "@sinclair/typebox";
14416
+ import { randomUUID } from "crypto";
14309
14417
  var MAX_TOOL_RESULT_CHARS = 2e4;
14310
14418
  var TRUNCATION_NOTE = "... (truncated \u2014 result too large)";
14311
14419
  function serializeResult(value) {
@@ -14455,7 +14563,7 @@ function mcpToAgentTool(tool, ctx) {
14455
14563
  const parameters = Type2.Unsafe(visibleSchema);
14456
14564
  const execute = async (_toolCallId, params) => {
14457
14565
  const handlerInput = hadProject ? { ...params, project: ctx.projectName } : params;
14458
- const result = await tool.handler(ctx.client, handlerInput);
14566
+ const result = await runWithUsageTags(ctx.client, { mcpTool: tool.name, mcpCall: randomUUID() }, () => tool.handler(ctx.client, handlerInput));
14459
14567
  return textResult2(result);
14460
14568
  };
14461
14569
  return {
@@ -15969,6 +16077,7 @@ function registerMcpHttpRoutes(scope, opts) {
15969
16077
  const client = new ApiClient(opts.selfApiUrl, sessionKey?.raw ?? bearer, {
15970
16078
  skipProbe: true,
15971
16079
  clientName: `canonry-mcp/${PACKAGE_VERSION}`,
16080
+ surface: "mcp-http",
15972
16081
  // Correlation only: this is never accepted as caller identity or authority.
15973
16082
  actorSession: crypto26.randomUUID()
15974
16083
  });
@@ -17723,7 +17832,7 @@ function cloneGtmConfig(config) {
17723
17832
  function createGoogleMarketingConfigCredentialStore(input) {
17724
17833
  const persistConfigPatch = input.saveConfigPatch ?? saveConfigPatch;
17725
17834
  const env = input.env ?? process.env;
17726
- const randomUUID = input.randomUUID ?? crypto27.randomUUID;
17835
+ const randomUUID2 = input.randomUUID ?? crypto27.randomUUID;
17727
17836
  const snapshot = () => ({
17728
17837
  googleAds: cloneGoogleAdsConfig(input.config.googleAds),
17729
17838
  gtm: cloneGtmConfig(input.config.gtm)
@@ -17771,7 +17880,7 @@ function createGoogleMarketingConfigCredentialStore(input) {
17771
17880
  upsertGoogleAdsConnection(input.config, {
17772
17881
  projectId: project.id,
17773
17882
  projectName: project.name,
17774
- credentialGeneration: randomUUID(),
17883
+ credentialGeneration: randomUUID2(),
17775
17884
  ...credential.accessToken ? { accessToken: credential.accessToken } : {},
17776
17885
  refreshToken: credential.refreshToken ?? null,
17777
17886
  tokenExpiresAt: credential.expiresAt ?? null,
@@ -17783,7 +17892,7 @@ function createGoogleMarketingConfigCredentialStore(input) {
17783
17892
  upsertGtmConnection(input.config, {
17784
17893
  projectId: project.id,
17785
17894
  projectName: project.name,
17786
- credentialGeneration: randomUUID(),
17895
+ credentialGeneration: randomUUID2(),
17787
17896
  ...credential.accessToken ? { accessToken: credential.accessToken } : {},
17788
17897
  refreshToken: credential.refreshToken ?? null,
17789
17898
  tokenExpiresAt: credential.expiresAt ?? null,
@@ -17896,6 +18005,10 @@ async function createServer(opts) {
17896
18005
  const notifier = new Notifier(opts.db, serverUrl);
17897
18006
  const intelligenceService = new IntelligenceService(opts.db);
17898
18007
  const aeroClient = new ApiClient(opts.config.apiUrl, opts.config.apiKey, {
18008
+ skipProbe: true,
18009
+ surface: "aero"
18010
+ });
18011
+ const schedulerClient = new ApiClient(opts.config.apiUrl, opts.config.apiKey, {
17899
18012
  skipProbe: true
17900
18013
  });
17901
18014
  const agentEnabled = resolveAgentEnabled(process.env, opts.config);
@@ -18336,7 +18449,7 @@ async function createServer(opts) {
18336
18449
  getRunnableProviderNames: () => registry.getAll().map((provider) => provider.adapter.name),
18337
18450
  getEffectiveProviderModels: () => effectiveProviderModels(registry),
18338
18451
  onTrafficSyncRequested: (projectName, sourceId) => {
18339
- aeroClient.trafficSync(projectName, sourceId).catch((err) => {
18452
+ schedulerClient.trafficSync(projectName, sourceId).catch((err) => {
18340
18453
  app.log.error(
18341
18454
  {
18342
18455
  projectName,
@@ -18356,7 +18469,7 @@ async function createServer(opts) {
18356
18469
  onDoctorRequested: (projectName) => {
18357
18470
  void (async () => {
18358
18471
  try {
18359
- const report = await aeroClient.runDoctor({ project: projectName });
18472
+ const report = await schedulerClient.runDoctor({ project: projectName });
18360
18473
  const project = opts.db.select().from(projects).where(eq26(projects.name, projectName)).get();
18361
18474
  if (!project) {
18362
18475
  app.log.warn({ projectName }, "doctor schedule fired for an unknown project");
@@ -18372,7 +18485,7 @@ async function createServer(opts) {
18372
18485
  })();
18373
18486
  },
18374
18487
  onDataRefreshRequested: (projectName) => {
18375
- void refreshAllIntegrations(aeroClient, projectName);
18488
+ void refreshAllIntegrations(schedulerClient, projectName);
18376
18489
  },
18377
18490
  onBacklinksSyncRequested: (projectName) => {
18378
18491
  void (async () => {
@@ -18397,7 +18510,7 @@ async function createServer(opts) {
18397
18510
  );
18398
18511
  return;
18399
18512
  }
18400
- aeroClient.backlinksTriggerSync(probed.release).catch((err) => {
18513
+ schedulerClient.backlinksTriggerSync(probed.release).catch((err) => {
18401
18514
  app.log.error(
18402
18515
  {
18403
18516
  projectName,
@@ -18898,6 +19011,9 @@ async function createServer(opts) {
18898
19011
  await app.register(apiRoutes, {
18899
19012
  db: opts.db,
18900
19013
  routePrefix: apiPrefix,
19014
+ // Agent-surface usage (MCP, Aero, raw API). CLI and dashboard requests are
19015
+ // measured elsewhere and skipped inside.
19016
+ onRequestCompleted: createApiUsageTelemetry(),
18901
19017
  skipAuth: false,
18902
19018
  sessionCookieName: SESSION_COOKIE_NAME,
18903
19019
  resolveSessionApiKeyId,
@@ -19428,9 +19544,7 @@ async function createServer(opts) {
19428
19544
  listOperationalLogs: (query) => operationalLogs.list(query),
19429
19545
  getTelemetryStatus,
19430
19546
  setTelemetryEnabled: (enabled) => {
19431
- const config = loadConfig();
19432
- config.telemetry = enabled;
19433
- saveConfigPatch(config);
19547
+ void setTelemetryPreference(enabled, "api");
19434
19548
  opts.config.telemetry = enabled;
19435
19549
  },
19436
19550
  recordOnboardingEvent: (event) => {
@@ -19762,6 +19876,7 @@ function parseQueryResponse(raw, count2) {
19762
19876
  }
19763
19877
 
19764
19878
  export {
19879
+ cliRuntimeContext,
19765
19880
  trackCliCommandFinished,
19766
19881
  setTelemetrySource,
19767
19882
  getTelemetryStatus,
@@ -19771,6 +19886,7 @@ export {
19771
19886
  showFirstRunNotice,
19772
19887
  detectAndTrackUpgrade,
19773
19888
  trackEvent,
19889
+ setTelemetryPreference,
19774
19890
  backfillAnswerVisibilityCommand,
19775
19891
  backfillNormalizedPaths,
19776
19892
  backfillNormalizedPathsCommand,
@@ -5,11 +5,11 @@ import {
5
5
  installSkills,
6
6
  loadConfigRaw,
7
7
  saveConfigPatch
8
- } from "./chunk-MEQGGODM.js";
8
+ } from "./chunk-5K2NUQOV.js";
9
9
  import {
10
10
  SKILL_MANIFEST_FILENAME,
11
11
  SkillsClients
12
- } from "./chunk-3DL3KV6C.js";
12
+ } from "./chunk-5ZIUROAQ.js";
13
13
 
14
14
  // src/skills-autosync.ts
15
15
  import fs from "fs";