@ainyc/canonry 4.8.0 → 4.11.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.
@@ -2042,6 +2042,73 @@ function reportConfidenceLabel(confidence) {
2042
2042
  }
2043
2043
  }
2044
2044
 
2045
+ // ../contracts/src/report-dedup.ts
2046
+ var REPORT_INTENT_STOPWORDS = /* @__PURE__ */ new Set([
2047
+ "a",
2048
+ "an",
2049
+ "and",
2050
+ "for",
2051
+ "from",
2052
+ "in",
2053
+ "near",
2054
+ "of",
2055
+ "on",
2056
+ "or",
2057
+ "the",
2058
+ "to"
2059
+ ]);
2060
+ function tokenizeReportIntent(value) {
2061
+ return value.toLowerCase().match(/[a-z0-9]+/g) ?? [];
2062
+ }
2063
+ function normalizeReportIntentToken(token) {
2064
+ if (token.length > 4 && token.endsWith("ies")) return `${token.slice(0, -3)}y`;
2065
+ if (token.length > 4 && token.endsWith("s") && !token.endsWith("ss")) return token.slice(0, -1);
2066
+ return token;
2067
+ }
2068
+ function reportIntentModifiers(report) {
2069
+ const location = report.meta.location;
2070
+ if (!location) return /* @__PURE__ */ new Set();
2071
+ return new Set(
2072
+ [location.label, location.city, location.region, location.country].flatMap(tokenizeReportIntent).map(normalizeReportIntentToken).filter(Boolean)
2073
+ );
2074
+ }
2075
+ function reportIntentKey(value, modifiers) {
2076
+ const tokens = tokenizeReportIntent(value).map(normalizeReportIntentToken).filter(Boolean).filter((token) => !REPORT_INTENT_STOPWORDS.has(token)).filter((token) => !modifiers.has(token));
2077
+ return [...new Set(tokens)].sort().join(" ");
2078
+ }
2079
+ function extractActionQuery(action) {
2080
+ return action.title.match(/"([^"]+)"/)?.[1] ?? action.successMetric.match(/"([^"]+)"/)?.[1] ?? action.title;
2081
+ }
2082
+ function dedupeReportActions(report, actions) {
2083
+ const modifiers = reportIntentModifiers(report);
2084
+ if (actions.length <= 1 || modifiers.size === 0) return [...actions];
2085
+ const seen = /* @__PURE__ */ new Set();
2086
+ const result = [];
2087
+ for (const action of actions) {
2088
+ if (action.category !== "content") {
2089
+ result.push(action);
2090
+ continue;
2091
+ }
2092
+ const key = reportIntentKey(extractActionQuery(action), modifiers);
2093
+ if (!key || seen.has(key)) continue;
2094
+ seen.add(key);
2095
+ result.push(action);
2096
+ }
2097
+ return result;
2098
+ }
2099
+ function dedupeReportOpportunities(report) {
2100
+ const modifiers = reportIntentModifiers(report);
2101
+ const opportunities = report.contentOpportunities;
2102
+ if (opportunities.length <= 1 || modifiers.size === 0) return opportunities;
2103
+ const seen = /* @__PURE__ */ new Set();
2104
+ return opportunities.filter((opportunity) => {
2105
+ const key = reportIntentKey(opportunity.query, modifiers);
2106
+ if (!key || seen.has(key)) return false;
2107
+ seen.add(key);
2108
+ return true;
2109
+ });
2110
+ }
2111
+
2045
2112
  // ../contracts/src/skills.ts
2046
2113
  import { z as z19 } from "zod";
2047
2114
  var codingAgentSchema = z19.enum(["claude", "codex"]);
@@ -2049,6 +2116,64 @@ var CodingAgents = codingAgentSchema.enum;
2049
2116
  var skillsClientSchema = z19.enum(["claude", "codex", "all"]);
2050
2117
  var SkillsClients = skillsClientSchema.enum;
2051
2118
 
2119
+ // ../contracts/src/traffic.ts
2120
+ import { z as z20 } from "zod";
2121
+ var trafficSourceTypeSchema = z20.enum([
2122
+ "cloud-run",
2123
+ "wordpress",
2124
+ "cloudflare",
2125
+ "vercel",
2126
+ "generic-log"
2127
+ ]);
2128
+ var TrafficSourceTypes = trafficSourceTypeSchema.enum;
2129
+ var trafficAdapterCapabilitySchema = z20.enum([
2130
+ "raw-request-events",
2131
+ "aggregate-request-metrics",
2132
+ "request-url",
2133
+ "status-code",
2134
+ "user-agent",
2135
+ "remote-ip",
2136
+ "referer",
2137
+ "cursor-pull"
2138
+ ]);
2139
+ var TrafficAdapterCapabilities = trafficAdapterCapabilitySchema.enum;
2140
+ var trafficEvidenceKindSchema = z20.enum(["raw-request", "aggregate-bucket"]);
2141
+ var TrafficEvidenceKinds = trafficEvidenceKindSchema.enum;
2142
+ var trafficEventConfidenceSchema = z20.enum(["observed", "provider-aggregated", "inferred"]);
2143
+ var TrafficEventConfidences = trafficEventConfidenceSchema.enum;
2144
+ var trafficProviderResourceSchema = z20.object({
2145
+ type: z20.string().nullable(),
2146
+ labels: z20.record(z20.string(), z20.string())
2147
+ });
2148
+ var normalizedTrafficRequestSchema = z20.object({
2149
+ sourceType: trafficSourceTypeSchema,
2150
+ evidenceKind: z20.literal(TrafficEvidenceKinds["raw-request"]),
2151
+ confidence: z20.literal(TrafficEventConfidences.observed),
2152
+ eventId: z20.string().min(1),
2153
+ observedAt: z20.string().min(1),
2154
+ method: z20.string().nullable(),
2155
+ requestUrl: z20.string().nullable(),
2156
+ host: z20.string().nullable(),
2157
+ path: z20.string().min(1),
2158
+ queryString: z20.string().nullable(),
2159
+ status: z20.number().int().nullable(),
2160
+ userAgent: z20.string().nullable(),
2161
+ remoteIp: z20.string().nullable(),
2162
+ referer: z20.string().nullable(),
2163
+ latencyMs: z20.number().nullable(),
2164
+ requestSizeBytes: z20.number().int().nullable(),
2165
+ responseSizeBytes: z20.number().int().nullable(),
2166
+ providerResource: trafficProviderResourceSchema,
2167
+ providerLabels: z20.record(z20.string(), z20.string())
2168
+ });
2169
+ var normalizedTrafficPullPageSchema = z20.object({
2170
+ events: z20.array(normalizedTrafficRequestSchema),
2171
+ rawEntryCount: z20.number().int().nonnegative(),
2172
+ skippedEntryCount: z20.number().int().nonnegative(),
2173
+ nextPageToken: z20.string().optional(),
2174
+ filter: z20.string()
2175
+ });
2176
+
2052
2177
  export {
2053
2178
  __export,
2054
2179
  providerQuotaPolicySchema,
@@ -2134,6 +2259,8 @@ export {
2134
2259
  reportHorizonLabel,
2135
2260
  reportActionCategoryLabel,
2136
2261
  reportConfidenceLabel,
2262
+ dedupeReportActions,
2263
+ dedupeReportOpportunities,
2137
2264
  CodingAgents,
2138
2265
  skillsClientSchema,
2139
2266
  SkillsClients
@@ -12,7 +12,7 @@ import {
12
12
  queryGenerateRequestSchema,
13
13
  runTriggerRequestSchema,
14
14
  scheduleUpsertRequestSchema
15
- } from "./chunk-IJEP6LB4.js";
15
+ } from "./chunk-WWU65YPN.js";
16
16
 
17
17
  // src/config.ts
18
18
  import fs from "fs";
package/dist/cli.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  setGoogleAuthConfig,
19
19
  showFirstRunNotice,
20
20
  trackEvent
21
- } from "./chunk-O4VXWABZ.js";
21
+ } from "./chunk-NG2PJHVL.js";
22
22
  import {
23
23
  CliError,
24
24
  EXIT_SYSTEM_ERROR,
@@ -33,7 +33,7 @@ import {
33
33
  saveConfig,
34
34
  saveConfigPatch,
35
35
  usageError
36
- } from "./chunk-5KIFQH52.js";
36
+ } from "./chunk-ZR4AVT4T.js";
37
37
  import {
38
38
  apiKeys,
39
39
  competitors,
@@ -45,7 +45,7 @@ import {
45
45
  projects,
46
46
  querySnapshots,
47
47
  runs
48
- } from "./chunk-QEPFB7UW.js";
48
+ } from "./chunk-5G6WYP2S.js";
49
49
  import {
50
50
  CcReleaseSyncStatuses,
51
51
  CheckScopes,
@@ -64,7 +64,7 @@ import {
64
64
  providerQuotaPolicySchema,
65
65
  resolveProviderInput,
66
66
  skillsClientSchema
67
- } from "./chunk-IJEP6LB4.js";
67
+ } from "./chunk-WWU65YPN.js";
68
68
 
69
69
  // src/cli.ts
70
70
  import { pathToFileURL } from "url";
@@ -580,7 +580,7 @@ function readStoredGroundingSources(rawResponse) {
580
580
  return result;
581
581
  }
582
582
  async function backfillInsightsCommand(project, opts) {
583
- const { IntelligenceService } = await import("./intelligence-service-X7CBN7S4.js");
583
+ const { IntelligenceService } = await import("./intelligence-service-ZFIYBHLQ.js");
584
584
  const config = loadConfig();
585
585
  const db = createClient(config.database);
586
586
  migrate(db);
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  createServer
3
- } from "./chunk-O4VXWABZ.js";
3
+ } from "./chunk-NG2PJHVL.js";
4
4
  import {
5
5
  loadConfig
6
- } from "./chunk-5KIFQH52.js";
7
- import "./chunk-QEPFB7UW.js";
8
- import "./chunk-IJEP6LB4.js";
6
+ } from "./chunk-ZR4AVT4T.js";
7
+ import "./chunk-5G6WYP2S.js";
8
+ import "./chunk-WWU65YPN.js";
9
9
  export {
10
10
  createServer,
11
11
  loadConfig
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  IntelligenceService
3
- } from "./chunk-QEPFB7UW.js";
4
- import "./chunk-IJEP6LB4.js";
3
+ } from "./chunk-5G6WYP2S.js";
4
+ import "./chunk-WWU65YPN.js";
5
5
  export {
6
6
  IntelligenceService
7
7
  };
package/dist/mcp.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  CliError,
3
3
  canonryMcpTools,
4
4
  createApiClient
5
- } from "./chunk-5KIFQH52.js";
6
- import "./chunk-IJEP6LB4.js";
5
+ } from "./chunk-ZR4AVT4T.js";
6
+ import "./chunk-WWU65YPN.js";
7
7
 
8
8
  // src/mcp/cli.ts
9
9
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ainyc/canonry",
3
- "version": "4.8.0",
3
+ "version": "4.11.0",
4
4
  "type": "module",
5
5
  "description": "Agent-first open-source AEO operating platform - track how answer engines cite your domain",
6
6
  "license": "FSL-1.1-ALv2",
@@ -59,21 +59,21 @@
59
59
  "@types/node-cron": "^3.0.11",
60
60
  "tsup": "^8.5.1",
61
61
  "tsx": "^4.19.0",
62
- "@ainyc/canonry-api-routes": "0.0.0",
63
62
  "@ainyc/canonry-config": "0.0.0",
63
+ "@ainyc/canonry-api-routes": "0.0.0",
64
+ "@ainyc/canonry-db": "0.0.0",
64
65
  "@ainyc/canonry-contracts": "0.0.0",
65
66
  "@ainyc/canonry-intelligence": "0.0.0",
66
- "@ainyc/canonry-db": "0.0.0",
67
67
  "@ainyc/canonry-integration-bing": "0.0.0",
68
- "@ainyc/canonry-integration-google": "0.0.0",
69
68
  "@ainyc/canonry-integration-commoncrawl": "0.0.0",
69
+ "@ainyc/canonry-integration-google": "0.0.0",
70
+ "@ainyc/canonry-integration-wordpress": "0.0.0",
70
71
  "@ainyc/canonry-provider-cdp": "0.0.0",
71
72
  "@ainyc/canonry-provider-claude": "0.0.0",
72
- "@ainyc/canonry-integration-wordpress": "0.0.0",
73
+ "@ainyc/canonry-provider-openai": "0.0.0",
73
74
  "@ainyc/canonry-provider-gemini": "0.0.0",
74
- "@ainyc/canonry-provider-local": "0.0.0",
75
75
  "@ainyc/canonry-provider-perplexity": "0.0.0",
76
- "@ainyc/canonry-provider-openai": "0.0.0"
76
+ "@ainyc/canonry-provider-local": "0.0.0"
77
77
  },
78
78
  "scripts": {
79
79
  "build": "tsx scripts/copy-agent-assets.ts && tsup && tsx build-web.ts",