@ainyc/canonry 4.44.0 → 4.45.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/assets/assets/{index-kRilKhIW.js → index-ObgzOp7B.js} +24 -24
- package/assets/assets/{index-jvmhx0du.css → index-PWkDKYPZ.css} +1 -1
- package/assets/index.html +2 -2
- package/dist/{chunk-U73SXACQ.js → chunk-G2HQOLPK.js} +30 -25
- package/dist/{chunk-JZ2VJW4U.js → chunk-GRFMZ7PD.js} +12 -0
- package/dist/{chunk-MITJYCHG.js → chunk-TBADB57G.js} +22 -0
- package/dist/cli.js +275 -21
- package/dist/index.js +3 -3
- package/dist/{intelligence-service-HWWNLBZM.js → intelligence-service-YFBVWCK2.js} +1 -1
- package/dist/mcp.js +1 -1
- package/package.json +8 -8
package/assets/index.html
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
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-
|
|
16
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
15
|
+
<script type="module" crossorigin src="./assets/index-ObgzOp7B.js"></script>
|
|
16
|
+
<link rel="stylesheet" crossorigin href="./assets/index-PWkDKYPZ.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
|
19
19
|
<div id="root"></div>
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
loadConfig,
|
|
6
6
|
loadConfigRaw,
|
|
7
7
|
saveConfigPatch
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GRFMZ7PD.js";
|
|
9
9
|
import {
|
|
10
10
|
DEFAULT_RUN_HISTORY_LIMIT,
|
|
11
11
|
IntelligenceService,
|
|
@@ -77,9 +77,10 @@ import {
|
|
|
77
77
|
rawEventSamples,
|
|
78
78
|
runs,
|
|
79
79
|
schedules,
|
|
80
|
+
smoothedRunDelta,
|
|
80
81
|
trafficSources,
|
|
81
82
|
usageCounters
|
|
82
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-TBADB57G.js";
|
|
83
84
|
import {
|
|
84
85
|
AGENT_MEMORY_VALUE_MAX_BYTES,
|
|
85
86
|
AGENT_PROVIDER_IDS,
|
|
@@ -3150,12 +3151,16 @@ function clientConfidenceLabel(confidence) {
|
|
|
3150
3151
|
function clientTrendCopy(delta) {
|
|
3151
3152
|
if (!delta) return null;
|
|
3152
3153
|
if (delta.direction === "up") {
|
|
3153
|
-
return { text: `Up ${delta.deltaAbs.toFixed(1)} points
|
|
3154
|
+
return { text: `Up ${delta.deltaAbs.toFixed(1)} points ${compareCopy(delta)}`, tone: "positive", arrow: "\u2191" };
|
|
3154
3155
|
}
|
|
3155
3156
|
if (delta.direction === "down") {
|
|
3156
|
-
return { text: `Down ${Math.abs(delta.deltaAbs).toFixed(1)} points
|
|
3157
|
+
return { text: `Down ${Math.abs(delta.deltaAbs).toFixed(1)} points ${compareCopy(delta)}`, tone: "negative", arrow: "\u2193" };
|
|
3157
3158
|
}
|
|
3158
|
-
return { text: `Holding steady
|
|
3159
|
+
return { text: `Holding steady ${compareCopy(delta)}`, tone: "neutral", arrow: "\u2192" };
|
|
3160
|
+
}
|
|
3161
|
+
function compareCopy(delta) {
|
|
3162
|
+
const window = delta.window ?? 1;
|
|
3163
|
+
return window >= 2 ? `vs prior ${window} checks (avg ${delta.prior}%)` : `since last check (was ${delta.prior}%)`;
|
|
3159
3164
|
}
|
|
3160
3165
|
function compactInlineList(items, limit = 3) {
|
|
3161
3166
|
const visible = items.slice(0, limit);
|
|
@@ -6688,6 +6693,8 @@ function buildAgencyDiagnostics(input) {
|
|
|
6688
6693
|
}
|
|
6689
6694
|
var WHATS_CHANGED_PERIOD_DAYS2 = 14;
|
|
6690
6695
|
var WHATS_CHANGED_MIN_TREND_POINTS = WHATS_CHANGED_PERIOD_DAYS2 * 2;
|
|
6696
|
+
var RATE_REAL_MOVEMENT_THRESHOLD_PP = 3;
|
|
6697
|
+
var COUNT_REAL_MOVEMENT_THRESHOLD = 0.5;
|
|
6691
6698
|
var WIN_REGRESSION_LIMIT = 5;
|
|
6692
6699
|
function rateDirection(delta, threshold = 0.5) {
|
|
6693
6700
|
if (delta > threshold) return "up";
|
|
@@ -6716,7 +6723,8 @@ function buildWhatsChangedHeadline(citation, gscClicks, aiReferrals, enoughHisto
|
|
|
6716
6723
|
if (citation) {
|
|
6717
6724
|
const arrow = citation.direction === "up" ? "\u2191" : citation.direction === "down" ? "\u2193" : "\u2192";
|
|
6718
6725
|
const verb = citation.direction === "up" ? "rose" : citation.direction === "down" ? "fell" : "held";
|
|
6719
|
-
|
|
6726
|
+
const smoothingHint = citation.window && citation.window >= 2 ? ` (avg of last ${citation.window} checks)` : "";
|
|
6727
|
+
parts.push(`Citation rate ${verb} ${citation.prior}% ${arrow} ${citation.current}%${smoothingHint}`);
|
|
6720
6728
|
}
|
|
6721
6729
|
if (aiReferrals && aiReferrals.direction !== "flat") {
|
|
6722
6730
|
const arrow = aiReferrals.direction === "up" ? "\u2191" : "\u2193";
|
|
@@ -6733,23 +6741,20 @@ function buildWhatsChanged(input) {
|
|
|
6733
6741
|
const latest = citationsTrend.at(-1);
|
|
6734
6742
|
const prior = citationsTrend.length >= 2 ? citationsTrend.at(-2) : null;
|
|
6735
6743
|
const enoughHistory = !baseline && latest !== void 0 && prior !== void 0;
|
|
6736
|
-
const
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
direction: rateDirection(latest.citationRate - prior.citationRate)
|
|
6744
|
+
const citationRateSmoothed = smoothedRunDelta(citationsTrend, (p) => p.citationRate);
|
|
6745
|
+
const citationRate = enoughHistory && citationRateSmoothed ? {
|
|
6746
|
+
...citationRateSmoothed,
|
|
6747
|
+
direction: rateDirection(citationRateSmoothed.deltaAbs, RATE_REAL_MOVEMENT_THRESHOLD_PP)
|
|
6741
6748
|
} : null;
|
|
6742
|
-
const
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
direction: rateDirection(latest.mentionRate - prior.mentionRate)
|
|
6749
|
+
const mentionRateSmoothed = smoothedRunDelta(citationsTrend, (p) => p.mentionRate);
|
|
6750
|
+
const mentionRate = enoughHistory && mentionRateSmoothed ? {
|
|
6751
|
+
...mentionRateSmoothed,
|
|
6752
|
+
direction: rateDirection(mentionRateSmoothed.deltaAbs, RATE_REAL_MOVEMENT_THRESHOLD_PP)
|
|
6747
6753
|
} : null;
|
|
6748
|
-
const
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
direction: rateDirection(latest.citedQueryCount - prior.citedQueryCount, 0)
|
|
6754
|
+
const citedQueryCountSmoothed = smoothedRunDelta(citationsTrend, (p) => p.citedQueryCount);
|
|
6755
|
+
const citedQueryCount = enoughHistory && citedQueryCountSmoothed ? {
|
|
6756
|
+
...citedQueryCountSmoothed,
|
|
6757
|
+
direction: rateDirection(citedQueryCountSmoothed.deltaAbs, COUNT_REAL_MOVEMENT_THRESHOLD)
|
|
6753
6758
|
} : null;
|
|
6754
6759
|
const providerMovements = [];
|
|
6755
6760
|
if (enoughHistory) {
|
|
@@ -13499,7 +13504,7 @@ async function bingRoutes(app, opts) {
|
|
|
13499
13504
|
connected: true,
|
|
13500
13505
|
domain: project.canonicalDomain,
|
|
13501
13506
|
siteUrl: existing?.siteUrl ?? null,
|
|
13502
|
-
availableSites: sites.map((s) => ({ url: s.Url, verified: s.
|
|
13507
|
+
availableSites: sites.map((s) => ({ url: s.Url, verified: s.IsVerified ?? false }))
|
|
13503
13508
|
};
|
|
13504
13509
|
});
|
|
13505
13510
|
app.delete("/projects/:name/bing/disconnect", async (request, reply) => {
|
|
@@ -13535,7 +13540,7 @@ async function bingRoutes(app, opts) {
|
|
|
13535
13540
|
const project = resolveProject(app.db, request.params.name);
|
|
13536
13541
|
const conn = requireConnection(store, project.canonicalDomain);
|
|
13537
13542
|
const sites = await getSites(conn.apiKey);
|
|
13538
|
-
return { sites: sites.map((s) => ({ url: s.Url, verified: s.
|
|
13543
|
+
return { sites: sites.map((s) => ({ url: s.Url, verified: s.IsVerified ?? false })) };
|
|
13539
13544
|
});
|
|
13540
13545
|
app.post("/projects/:name/bing/set-site", async (request) => {
|
|
13541
13546
|
const store = requireConnectionStore();
|
|
@@ -19607,7 +19612,7 @@ var BING_AUTH_CHECKS = [
|
|
|
19607
19612
|
}
|
|
19608
19613
|
};
|
|
19609
19614
|
}
|
|
19610
|
-
if (!match.
|
|
19615
|
+
if (!match.IsVerified) {
|
|
19611
19616
|
return {
|
|
19612
19617
|
status: CheckStatuses.fail,
|
|
19613
19618
|
code: "bing.auth.site-not-verified",
|
|
@@ -26309,7 +26314,7 @@ function readStoredGroundingSources(rawResponse) {
|
|
|
26309
26314
|
return result;
|
|
26310
26315
|
}
|
|
26311
26316
|
async function backfillInsightsCommand(project, opts) {
|
|
26312
|
-
const { IntelligenceService: IntelligenceService2 } = await import("./intelligence-service-
|
|
26317
|
+
const { IntelligenceService: IntelligenceService2 } = await import("./intelligence-service-YFBVWCK2.js");
|
|
26313
26318
|
const config = loadConfig();
|
|
26314
26319
|
const db = createClient(config.database);
|
|
26315
26320
|
migrate(db);
|
|
@@ -322,6 +322,8 @@ var ApiClient = class {
|
|
|
322
322
|
"Accept": "application/json",
|
|
323
323
|
...serializedBody != null ? { "Content-Type": "application/json" } : {}
|
|
324
324
|
};
|
|
325
|
+
const traceEnabled = process.env.CANONRY_TRACE === "1";
|
|
326
|
+
const traceStart = traceEnabled ? Date.now() : 0;
|
|
325
327
|
let res;
|
|
326
328
|
try {
|
|
327
329
|
res = await fetch(url, {
|
|
@@ -330,6 +332,11 @@ var ApiClient = class {
|
|
|
330
332
|
body: serializedBody
|
|
331
333
|
});
|
|
332
334
|
} catch (err) {
|
|
335
|
+
if (traceEnabled) {
|
|
336
|
+
const durMs = Date.now() - traceStart;
|
|
337
|
+
process.stderr.write(`[trace] ${method} ${url} \u2192 ERROR (${durMs}ms)
|
|
338
|
+
`);
|
|
339
|
+
}
|
|
333
340
|
if (err instanceof CliError) throw err;
|
|
334
341
|
const msg = err instanceof Error ? err.message : String(err);
|
|
335
342
|
if (msg.includes("fetch failed") || msg.includes("ECONNREFUSED") || msg.includes("connect ECONNREFUSED")) {
|
|
@@ -362,6 +369,11 @@ var ApiClient = class {
|
|
|
362
369
|
}
|
|
363
370
|
});
|
|
364
371
|
}
|
|
372
|
+
if (traceEnabled) {
|
|
373
|
+
const durMs = Date.now() - traceStart;
|
|
374
|
+
process.stderr.write(`[trace] ${method} ${url} \u2192 ${res.status} (${durMs}ms)
|
|
375
|
+
`);
|
|
376
|
+
}
|
|
365
377
|
if (res.status === 204) {
|
|
366
378
|
return void 0;
|
|
367
379
|
}
|
|
@@ -3793,6 +3793,27 @@ function formatImpressions2(value) {
|
|
|
3793
3793
|
return value.toString();
|
|
3794
3794
|
}
|
|
3795
3795
|
|
|
3796
|
+
// ../intelligence/src/smoothed-delta.ts
|
|
3797
|
+
var SMOOTHED_RUN_DELTA_MAX_WINDOW = 3;
|
|
3798
|
+
function smoothedRunDelta(points, valueFn, maxWindow = SMOOTHED_RUN_DELTA_MAX_WINDOW) {
|
|
3799
|
+
if (points.length < 2) return null;
|
|
3800
|
+
const window = Math.min(maxWindow, Math.floor(points.length / 2));
|
|
3801
|
+
const tail = points.slice(-window);
|
|
3802
|
+
const prior = points.slice(-window * 2, -window);
|
|
3803
|
+
const sum = (arr) => arr.reduce((s, p) => s + valueFn(p), 0);
|
|
3804
|
+
const currentAvg = sum(tail) / tail.length;
|
|
3805
|
+
const priorAvg = sum(prior) / prior.length;
|
|
3806
|
+
return {
|
|
3807
|
+
current: roundTo1Decimal(currentAvg),
|
|
3808
|
+
prior: roundTo1Decimal(priorAvg),
|
|
3809
|
+
deltaAbs: currentAvg - priorAvg,
|
|
3810
|
+
window
|
|
3811
|
+
};
|
|
3812
|
+
}
|
|
3813
|
+
function roundTo1Decimal(value) {
|
|
3814
|
+
return Math.round(value * 10) / 10;
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3796
3817
|
// src/intelligence-service.ts
|
|
3797
3818
|
import crypto from "crypto";
|
|
3798
3819
|
|
|
@@ -4323,6 +4344,7 @@ export {
|
|
|
4323
4344
|
providerKey,
|
|
4324
4345
|
buildMentionShare,
|
|
4325
4346
|
buildSuggestedQueries,
|
|
4347
|
+
smoothedRunDelta,
|
|
4326
4348
|
createLogger,
|
|
4327
4349
|
IntelligenceService
|
|
4328
4350
|
};
|