@canonry/canonry 7.84.0 → 7.85.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/agent-workspace/skills/aero/references/ai-traffic-tracking.md +2 -1
- package/assets/agent-workspace/skills/canonry/references/ai-traffic-tracking.md +2 -1
- package/assets/agent-workspace/skills/canonry/references/server-side-traffic.md +31 -7
- package/assets/assets/{AgentSetupPage-B9NOQP8a.js → AgentSetupPage-NdqmQkYa.js} +1 -1
- package/assets/assets/{AuditHistoryPanel-Fvh4WFjq.js → AuditHistoryPanel-CuqdFCb9.js} +1 -1
- package/assets/assets/{BacklinksPage-D1UHFLoV.js → BacklinksPage-CVjZiG1i.js} +1 -1
- package/assets/assets/{HistoryPage-CBcacDgP.js → HistoryPage-DRvdgemW.js} +1 -1
- package/assets/assets/{MeasurementPropertyPage-ZuZpurwr.js → MeasurementPropertyPage-Bc5EpJFV.js} +1 -1
- package/assets/assets/{ProjectPage-BoqDyoGi.js → ProjectPage-CGGBSiK7.js} +1 -1
- package/assets/assets/{RunsPage-tlCk_gOw.js → RunsPage-B6_o81G3.js} +1 -1
- package/assets/assets/{SettingsPage-7mRTFLFQ.js → SettingsPage-DjmVapHO.js} +1 -1
- package/assets/assets/{SiteHealthSection-l_A_AmY_.js → SiteHealthSection-BPPB0D9D.js} +2 -2
- package/assets/assets/{ToneBadge-CXyUIWzB.js → ToneBadge-DwUBSAjL.js} +1 -1
- package/assets/assets/{TrafficPage-DQbBT3TP.js → TrafficPage-BvbjxOw3.js} +1 -1
- package/assets/assets/{TrafficSourceDetailPage-D3DwE6Qd.js → TrafficSourceDetailPage-BGJwxS_Q.js} +1 -1
- package/assets/assets/{account-context-Bhgg1lEH.js → account-context-D7M4W4wP.js} +1 -1
- package/assets/assets/agent-trust-copy-WXXeDvDs.js +1 -0
- package/assets/assets/{card-B16Dvxau.js → card-DULVRmzI.js} +1 -1
- package/assets/assets/{extract-error-message-B5_v_-U8.js → extract-error-message-B9-6WgLm.js} +1 -1
- package/assets/assets/{format-helpers-Bs9rrO74.js → format-helpers-Cgq0VzXz.js} +1 -1
- package/assets/assets/{index-3aBRkQpI.js → index-A-4JN4Pv.js} +4 -4
- package/assets/assets/{query-client-D-tt1sn3.js → query-client-1Q6EwPba.js} +1 -1
- package/assets/assets/{react-query-DQr9PoNm.js → react-query-D0OiMBt3.js} +1 -1
- package/assets/assets/{react-sigma_core.esm.min-BfZVKh7v.js → react-sigma_core.esm.min-CR09uPhZ.js} +1 -1
- package/assets/assets/{service-Cmt36bhL.js → service-Bu-7icpb.js} +1 -1
- package/assets/index.html +7 -7
- package/dist/{ads-KBXA3LV6.js → ads-ETZIGLL5.js} +3 -3
- package/dist/{agent-OMNIUTNZ.js → agent-WG2FUC7C.js} +7 -7
- package/dist/{agent-ask-3JQNG2PE.js → agent-ask-775XBFOH.js} +3 -3
- package/dist/{agent-conversations-KO5PDSM2.js → agent-conversations-AYZ3LQJQ.js} +3 -3
- package/dist/{agent-journeys-QL6NG3BE.js → agent-journeys-GWNZG73C.js} +3 -3
- package/dist/{agent-memory-2WZ6LVAN.js → agent-memory-E5MRRS5P.js} +3 -3
- package/dist/{agent-providers-TABMSD4J.js → agent-providers-DEQZWO2M.js} +3 -3
- package/dist/{agent-transcript-YNF63MPR.js → agent-transcript-4AKVVHQC.js} +3 -3
- package/dist/{analytics-5FGY3FHC.js → analytics-HSLTWKDA.js} +3 -3
- package/dist/{apply-2HX4KYT6.js → apply-4GD7VGG7.js} +3 -3
- package/dist/{backfill-ABSW6J3S.js → backfill-LNE2BW34.js} +10 -10
- package/dist/{backlinks-7CRPWNNN.js → backlinks-TGE3DWA2.js} +3 -3
- package/dist/{bing-IT46EUFH.js → bing-56GNRC55.js} +3 -3
- package/dist/{bootstrap-CHOXLC7Q.js → bootstrap-42XCWZTS.js} +10 -10
- package/dist/{cdp-HQWKZGVQ.js → cdp-UODIMKE3.js} +7 -7
- package/dist/{chunk-EMSZDVDP.js → chunk-2O5XBKEO.js} +5 -5
- package/dist/{chunk-O7TWL6ZH.js → chunk-2R6WI237.js} +333 -203
- package/dist/{chunk-B42R2SPU.js → chunk-2X6UAPAC.js} +191 -9
- package/dist/{chunk-VCUNNS4R.js → chunk-4KK3OTHE.js} +1 -1
- package/dist/{chunk-6TLHA6XA.js → chunk-5NEZO3SC.js} +3 -3
- package/dist/{chunk-WJITVHAU.js → chunk-6SGHSSWQ.js} +2 -2
- package/dist/{chunk-Q57GN464.js → chunk-AICFUZ6X.js} +1 -1
- package/dist/{chunk-2MROJL32.js → chunk-BQTXXXUG.js} +1 -1
- package/dist/{chunk-5PEVGTNX.js → chunk-C2H5TPKD.js} +338 -338
- package/dist/{chunk-LWYALZ6F.js → chunk-D45AMUYA.js} +4 -4
- package/dist/{chunk-WR4PA335.js → chunk-DWK6NIJF.js} +1 -1
- package/dist/{chunk-YPR2GVJC.js → chunk-GR7VVRNN.js} +1 -1
- package/dist/{chunk-3H6FSUKM.js → chunk-IOW23XNK.js} +3 -3
- package/dist/{chunk-6SVAUILQ.js → chunk-JVO5GQZH.js} +2912 -2560
- package/dist/{chunk-TZCUMC7U.js → chunk-KBLMQDUZ.js} +16 -8
- package/dist/{chunk-K3OY52MI.js → chunk-KNKOTLVW.js} +3 -1
- package/dist/{chunk-BIGIIVGV.js → chunk-L5R5S57T.js} +55 -1
- package/dist/{chunk-GJE3OG4Y.js → chunk-NY252PIY.js} +3 -3
- package/dist/{chunk-CEOIGQTS.js → chunk-OHDSI5XS.js} +1 -1
- package/dist/{chunk-I642VITF.js → chunk-OS5BVALI.js} +2 -2
- package/dist/{chunk-OMUINNSO.js → chunk-PQWZCAVS.js} +1 -1
- package/dist/{chunk-D37PJYLD.js → chunk-PX2KVGOJ.js} +1 -1
- package/dist/{chunk-ZRL5FO5G.js → chunk-Q7354YI3.js} +3 -3
- package/dist/{chunk-LYNYNNOD.js → chunk-QEATYB7C.js} +1 -1
- package/dist/{chunk-OBGP3DRQ.js → chunk-RCAB7M6A.js} +2 -2
- package/dist/{chunk-43CPBLRJ.js → chunk-SS33RWKG.js} +1 -1
- package/dist/{chunk-LHAD6EK3.js → chunk-TPUBPXBN.js} +2 -2
- package/dist/{chunk-MZDIWY3K.js → chunk-TVZMFCX2.js} +6 -6
- package/dist/{chunk-3EI4FHR5.js → chunk-UMEQ7EYN.js} +4 -4
- package/dist/{chunk-AAKRCOQV.js → chunk-UMV4HYHD.js} +2 -2
- package/dist/{chunk-6Y75QV2S.js → chunk-VFSHZHZS.js} +2 -2
- package/dist/{chunk-LE6ZODCY.js → chunk-X7XKMARG.js} +2 -2
- package/dist/{chunk-QLKG7G4Y.js → chunk-YDC2V5FQ.js} +21 -21
- package/dist/{chunk-HYEPL5UY.js → chunk-Z53CKLDS.js} +3 -3
- package/dist/{chunk-UYR5JI6R.js → chunk-ZXMDIWW6.js} +4 -4
- package/dist/{citations-YRBUXEWU.js → citations-RXBPR5MX.js} +3 -3
- package/dist/{cli-catalog-JTIC72BY.js → cli-catalog-QVCJWPCI.js} +3 -3
- package/dist/{cli-commands-LUGJZGJU.js → cli-commands-ZXR4Z2RW.js} +7 -7
- package/dist/cli.js +13 -13
- package/dist/{competitor-ZKNDADMJ.js → competitor-MDNNHRSD.js} +3 -3
- package/dist/{content-ANRSBG3Y.js → content-D3JZZQ64.js} +3 -3
- package/dist/{dashboard-HTJBWAPW.js → dashboard-5S2A46GM.js} +6 -6
- package/dist/{demo-V3ODU4JK.js → demo-DQHWRIKR.js} +1 -1
- package/dist/{demo-server-QYMT3KT7.js → demo-server-FY2XBSD2.js} +12 -12
- package/dist/{discover-DX7KIWHU.js → discover-NVNWHOTZ.js} +3 -3
- package/dist/{discover-eval-PXWJYPHE.js → discover-eval-CJB6GYUS.js} +3 -3
- package/dist/{doctor-W2MTLKX7.js → doctor-DLSKNC4W.js} +3 -3
- package/dist/{evidence-PKKLSVNG.js → evidence-QNJULIXM.js} +3 -3
- package/dist/{export-cmd-3PRWU7NH.js → export-cmd-Z2YG2WLK.js} +3 -3
- package/dist/{ga-QPH56JDO.js → ga-RSNHBP2B.js} +3 -3
- package/dist/{gbp-MJPIQZYZ.js → gbp-ZEV62LSZ.js} +3 -3
- package/dist/{google-2XZC7DNJ.js → google-RZHEIKW5.js} +4 -4
- package/dist/{google-marketing-EDXL7ODG.js → google-marketing-DYQXPTD3.js} +1 -1
- package/dist/{health-cmd-YR2MFYNK.js → health-cmd-6ATPYUYG.js} +3 -3
- package/dist/{history-OM4OXDOZ.js → history-KLX6XRY4.js} +3 -3
- package/dist/index.d.ts +301 -95
- package/dist/index.js +25 -25
- package/dist/{init-5FAQPNH4.js → init-5BALV6SU.js} +12 -12
- package/dist/{insights-YGMPBDVA.js → insights-ARCEFFK5.js} +3 -3
- package/dist/intelligence-service-YJFZ6IBI.js +16 -0
- package/dist/{journeys-ZPQCEHXY.js → journeys-WVRQRZQJ.js} +3 -3
- package/dist/{keys-YZBRRGYE.js → keys-5KAJFRZZ.js} +3 -3
- package/dist/{keyword-HSPNKAJQ.js → keyword-PTUH3TFD.js} +3 -3
- package/dist/{logs-NO2N7W34.js → logs-NM7ACXGQ.js} +3 -3
- package/dist/{mcp-EAGJ2Y2D.js → mcp-ALRQXYL3.js} +4 -4
- package/dist/mcp.js +9 -9
- package/dist/{measurement-plan-6VCBAM5B.js → measurement-plan-T52JHK2J.js} +5 -5
- package/dist/{notify-SS5H5GRB.js → notify-MJBMRDXD.js} +3 -3
- package/dist/{organic-evidence-XOZQXTHF.js → organic-evidence-ZUCQFWD5.js} +3 -3
- package/dist/{overview-3PLQYWDY.js → overview-74IHPU2A.js} +4 -4
- package/dist/{project-ARUHBFCG.js → project-DKQOPMH6.js} +3 -3
- package/dist/{query-4KCFDJ5V.js → query-YDJ5T46L.js} +3 -3
- package/dist/{research-3NTYXGWN.js → research-5DU6DFZW.js} +3 -3
- package/dist/{results-export-YOQQXBMP.js → results-export-EDVVXKVW.js} +3 -3
- package/dist/{run-64UJAPPG.js → run-HRHGSIYE.js} +4 -4
- package/dist/{schedule-JN5JE4EK.js → schedule-GZVKQGMP.js} +3 -3
- package/dist/{search-2QIHUMR7.js → search-M37GRKVC.js} +3 -3
- package/dist/{serve-V2NPNYMP.js → serve-DW6PPZPJ.js} +26 -26
- package/dist/{session-347VV5OG.js → session-H427H2SK.js} +13 -13
- package/dist/{settings-XM5NGHFW.js → settings-WGS7GP7C.js} +3 -3
- package/dist/{skills-4MWWCA36.js → skills-CDDUPMAU.js} +2 -2
- package/dist/{snapshot-RWHR3VJ4.js → snapshot-5MAK7PWE.js} +3 -3
- package/dist/{src-HUF2NBUG.js → src-FEV4KYXN.js} +6 -2
- package/dist/{status-3OI7PTQ5.js → status-EHFOYTXQ.js} +4 -4
- package/dist/{technical-aeo-RXHIFLHD.js → technical-aeo-KVY4RQWT.js} +3 -3
- package/dist/{telemetry-DZSITJKQ.js → telemetry-7XRRIHVC.js} +4 -4
- package/dist/{tools-ZUUOSB75.js → tools-EHONHGB6.js} +11 -11
- package/dist/{traffic-KIQBUHJW.js → traffic-TBR6GOWN.js} +5 -5
- package/dist/{users-ID4O7NXQ.js → users-YQS4X47Q.js} +3 -3
- package/dist/{visibility-stats-X5MTD47P.js → visibility-stats-JXIOSJXC.js} +3 -3
- package/dist/{wordpress-WU2HLWIW.js → wordpress-HVOLEPQY.js} +3 -3
- package/package.json +1 -1
- package/assets/assets/agent-trust-copy-CKZsKhc0.js +0 -1
- package/dist/intelligence-service-GCN4S6QT.js +0 -16
|
@@ -1,36 +1,47 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLogger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6SGHSSWQ.js";
|
|
4
4
|
import {
|
|
5
5
|
addLikelyFakeAgentHits,
|
|
6
|
+
correctBackgroundCallJourneys,
|
|
7
|
+
mergeSplitJourneyVisitors,
|
|
6
8
|
writeUnrecognizedAgentBuckets
|
|
7
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JVO5GQZH.js";
|
|
8
10
|
import {
|
|
11
|
+
AGENT_TRUST_RULES_VERSION,
|
|
9
12
|
BROWSER_SHAPED_AGENT_MARKERS,
|
|
10
13
|
DEFAULT_AI_CRAWLER_RULES,
|
|
11
14
|
GENERIC_HTTP_CLIENTS,
|
|
15
|
+
JOURNEY_RULES_VERSION,
|
|
16
|
+
SCANNER_BURST_WINDOW_MS,
|
|
12
17
|
SELF_TRAFFIC_USER_AGENT_PATTERNS,
|
|
13
18
|
UNLISTED_AGENT_SKIPPED_EXTENSIONS,
|
|
14
19
|
UNRECOGNIZED_AGENT_NAMING_VERSION,
|
|
15
20
|
classifyAiUserFetch,
|
|
16
21
|
classifyCrawler,
|
|
22
|
+
isScannerPath,
|
|
17
23
|
isSelfTraffic,
|
|
24
|
+
normalizeTrafficPathPattern,
|
|
18
25
|
unrecognizedAgentName
|
|
19
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-2R6WI237.js";
|
|
20
27
|
import {
|
|
21
28
|
RawEventSampleEventTypes,
|
|
29
|
+
agentJourneyCaptureDays,
|
|
30
|
+
agentJourneyEvents,
|
|
22
31
|
aiUserFetchEventsHourly,
|
|
32
|
+
aiUserFetchVerificationManifestsHourly,
|
|
23
33
|
crawlerEventsHourly,
|
|
24
34
|
migrationsTable,
|
|
25
35
|
parseJsonColumn,
|
|
26
36
|
rawEventSamples,
|
|
27
37
|
trafficReclassificationState,
|
|
28
38
|
unrecognizedAgentEventsHourly
|
|
29
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-L5R5S57T.js";
|
|
30
40
|
import {
|
|
31
41
|
AI_ENGINE_DOMAINS,
|
|
32
42
|
AI_ENGINE_SELF_DOMAINS,
|
|
33
43
|
AgentTrustLevels,
|
|
44
|
+
AgentTrustReasons,
|
|
34
45
|
AnchoredSpanSources,
|
|
35
46
|
OPENROUTER_MODEL_PATTERN,
|
|
36
47
|
OPENROUTER_ROUTE_FAMILY,
|
|
@@ -44,6 +55,7 @@ import {
|
|
|
44
55
|
TrafficSourceTypes,
|
|
45
56
|
UNRECORDED_TRAFFIC_PATH,
|
|
46
57
|
VERTEX_AI_SEARCH_PROXY_DOMAIN,
|
|
58
|
+
VerificationStatuses,
|
|
47
59
|
asRecord,
|
|
48
60
|
describeError,
|
|
49
61
|
hostMatchesAnyDomain,
|
|
@@ -57,7 +69,7 @@ import {
|
|
|
57
69
|
retryAfterDelayMs,
|
|
58
70
|
usageCount,
|
|
59
71
|
withRetry
|
|
60
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-KNKOTLVW.js";
|
|
61
73
|
|
|
62
74
|
// ../provider-openai/src/normalize.ts
|
|
63
75
|
import OpenAI from "openai";
|
|
@@ -2929,7 +2941,7 @@ function extractStoredAnswerAnchors(provider, rawResponse) {
|
|
|
2929
2941
|
// src/traffic-reclassify.ts
|
|
2930
2942
|
import { createHash } from "crypto";
|
|
2931
2943
|
import { setImmediate as yieldToEventLoop } from "timers/promises";
|
|
2932
|
-
import { and, eq, inArray, sql } from "drizzle-orm";
|
|
2944
|
+
import { and, eq, gte, inArray, lte, ne, sql } from "drizzle-orm";
|
|
2933
2945
|
var log = createLogger("TrafficReclassify");
|
|
2934
2946
|
var STATE_ID = "default";
|
|
2935
2947
|
var BATCH_SIZE = 200;
|
|
@@ -2947,6 +2959,8 @@ function trafficClassificationFingerprint() {
|
|
|
2947
2959
|
})),
|
|
2948
2960
|
self: SELF_TRAFFIC_USER_AGENT_PATTERNS.map(pattern),
|
|
2949
2961
|
naming: UNRECOGNIZED_AGENT_NAMING_VERSION,
|
|
2962
|
+
trust: AGENT_TRUST_RULES_VERSION,
|
|
2963
|
+
journeys: JOURNEY_RULES_VERSION,
|
|
2950
2964
|
genericClients: GENERIC_HTTP_CLIENTS,
|
|
2951
2965
|
browserMarkers: BROWSER_SHAPED_AGENT_MARKERS,
|
|
2952
2966
|
skippedExtensions: UNLISTED_AGENT_SKIPPED_EXTENSIONS
|
|
@@ -3178,6 +3192,163 @@ async function reclassifyUnknownSamples(db, opts) {
|
|
|
3178
3192
|
}
|
|
3179
3193
|
return result;
|
|
3180
3194
|
}
|
|
3195
|
+
function hourlyAgentRow(key) {
|
|
3196
|
+
const table = aiUserFetchEventsHourly;
|
|
3197
|
+
return and(
|
|
3198
|
+
eq(table.projectId, key.projectId),
|
|
3199
|
+
eq(table.sourceId, key.sourceId),
|
|
3200
|
+
eq(table.tsHour, key.tsHour),
|
|
3201
|
+
eq(table.botId, key.botId),
|
|
3202
|
+
eq(table.verificationStatus, key.verificationStatus),
|
|
3203
|
+
eq(table.pathNormalized, key.pathNormalized),
|
|
3204
|
+
eq(table.status, key.status)
|
|
3205
|
+
);
|
|
3206
|
+
}
|
|
3207
|
+
async function reassessAgentHits(db, opts) {
|
|
3208
|
+
const result = { examined: 0, moved: 0, movedHits: 0 };
|
|
3209
|
+
const table = aiUserFetchEventsHourly;
|
|
3210
|
+
const lastStartingRowid = Number(db.select({ max: sql`max(rowid)` }).from(table).get()?.max ?? 0);
|
|
3211
|
+
let lastRowid = 0;
|
|
3212
|
+
for (; ; ) {
|
|
3213
|
+
if (opts.shouldStop()) break;
|
|
3214
|
+
const rows = db.select({
|
|
3215
|
+
rowid: sql`rowid`,
|
|
3216
|
+
projectId: table.projectId,
|
|
3217
|
+
sourceId: table.sourceId,
|
|
3218
|
+
tsHour: table.tsHour,
|
|
3219
|
+
botId: table.botId,
|
|
3220
|
+
operator: table.operator,
|
|
3221
|
+
verificationStatus: table.verificationStatus,
|
|
3222
|
+
pathNormalized: table.pathNormalized,
|
|
3223
|
+
status: table.status
|
|
3224
|
+
}).from(table).where(and(
|
|
3225
|
+
sql`rowid > ${lastRowid}`,
|
|
3226
|
+
sql`rowid <= ${lastStartingRowid}`,
|
|
3227
|
+
ne(table.verificationStatus, VerificationStatuses.verified),
|
|
3228
|
+
opts.projectIds ? inArray(table.projectId, [...opts.projectIds]) : void 0
|
|
3229
|
+
)).orderBy(sql`rowid`).limit(BATCH_SIZE).all();
|
|
3230
|
+
if (rows.length === 0) break;
|
|
3231
|
+
lastRowid = rows[rows.length - 1].rowid;
|
|
3232
|
+
result.examined += rows.length;
|
|
3233
|
+
const probes = rows.filter((row) => isScannerPath(row.pathNormalized));
|
|
3234
|
+
if (probes.length > 0) {
|
|
3235
|
+
db.transaction((tx) => {
|
|
3236
|
+
for (const row of probes) {
|
|
3237
|
+
const current = tx.select({ hits: table.hits }).from(table).where(hourlyAgentRow(row)).get();
|
|
3238
|
+
if (!current) continue;
|
|
3239
|
+
result.moved++;
|
|
3240
|
+
result.movedHits += current.hits;
|
|
3241
|
+
if (opts.dryRun) continue;
|
|
3242
|
+
addLikelyFakeAgentHits(tx, {
|
|
3243
|
+
projectId: row.projectId,
|
|
3244
|
+
sourceId: row.sourceId,
|
|
3245
|
+
buckets: [{ tsHour: row.tsHour, botId: row.botId, operator: row.operator, reason: AgentTrustReasons["scanner-path"], hits: current.hits }],
|
|
3246
|
+
now: opts.now
|
|
3247
|
+
});
|
|
3248
|
+
tx.delete(table).where(hourlyAgentRow(row)).run();
|
|
3249
|
+
}
|
|
3250
|
+
}, { behavior: "immediate" });
|
|
3251
|
+
}
|
|
3252
|
+
await yieldToEventLoop();
|
|
3253
|
+
}
|
|
3254
|
+
return result;
|
|
3255
|
+
}
|
|
3256
|
+
function moveAgentHitToBurst(tx, row, now) {
|
|
3257
|
+
const key = {
|
|
3258
|
+
projectId: row.projectId,
|
|
3259
|
+
sourceId: row.sourceId,
|
|
3260
|
+
tsHour: hourOf(row.ts),
|
|
3261
|
+
botId: row.agentId,
|
|
3262
|
+
verificationStatus: row.verificationStatus,
|
|
3263
|
+
pathNormalized: normalizeTrafficPathPattern(row.path),
|
|
3264
|
+
status: row.status ?? 0
|
|
3265
|
+
};
|
|
3266
|
+
const table = aiUserFetchEventsHourly;
|
|
3267
|
+
const taken = tx.update(table).set({ hits: sql`${table.hits} - 1`, updatedAt: now }).where(and(hourlyAgentRow(key), sql`${table.hits} > 0`)).run();
|
|
3268
|
+
if (taken.changes === 0) return;
|
|
3269
|
+
const manifests = aiUserFetchVerificationManifestsHourly;
|
|
3270
|
+
if (row.verificationManifest) {
|
|
3271
|
+
const manifestRow = and(
|
|
3272
|
+
eq(manifests.projectId, key.projectId),
|
|
3273
|
+
eq(manifests.sourceId, key.sourceId),
|
|
3274
|
+
eq(manifests.tsHour, key.tsHour),
|
|
3275
|
+
eq(manifests.botId, key.botId),
|
|
3276
|
+
eq(manifests.verificationStatus, key.verificationStatus),
|
|
3277
|
+
eq(manifests.pathNormalized, key.pathNormalized),
|
|
3278
|
+
eq(manifests.status, key.status),
|
|
3279
|
+
eq(manifests.manifestId, row.verificationManifest.id)
|
|
3280
|
+
);
|
|
3281
|
+
tx.update(manifests).set({ hits: sql`${manifests.hits} - 1`, updatedAt: now }).where(and(manifestRow, sql`${manifests.hits} > 0`)).run();
|
|
3282
|
+
tx.delete(manifests).where(and(manifestRow, sql`${manifests.hits} <= 0`)).run();
|
|
3283
|
+
}
|
|
3284
|
+
tx.delete(table).where(and(hourlyAgentRow(key), sql`${table.hits} <= 0`)).run();
|
|
3285
|
+
addLikelyFakeAgentHits(tx, {
|
|
3286
|
+
projectId: row.projectId,
|
|
3287
|
+
sourceId: row.sourceId,
|
|
3288
|
+
buckets: [{ tsHour: key.tsHour, botId: row.agentId, operator: row.operator, reason: AgentTrustReasons["scanner-burst"], hits: 1 }],
|
|
3289
|
+
now
|
|
3290
|
+
});
|
|
3291
|
+
}
|
|
3292
|
+
async function reassessAgentRequests(db, opts) {
|
|
3293
|
+
const result = { examined: 0, probes: 0, removed: 0 };
|
|
3294
|
+
const table = agentJourneyEvents;
|
|
3295
|
+
const clients = /* @__PURE__ */ new Map();
|
|
3296
|
+
const lastStartingRowid = Number(db.select({ max: sql`max(rowid)` }).from(table).get()?.max ?? 0);
|
|
3297
|
+
let lastRowid = 0;
|
|
3298
|
+
for (; ; ) {
|
|
3299
|
+
if (opts.shouldStop()) return result;
|
|
3300
|
+
const rows = db.select({ rowid: sql`rowid`, projectId: table.projectId, sourceId: table.sourceId, correlationKey: table.correlationKey, ts: table.ts, path: table.path }).from(table).where(and(
|
|
3301
|
+
sql`rowid > ${lastRowid}`,
|
|
3302
|
+
sql`rowid <= ${lastStartingRowid}`,
|
|
3303
|
+
ne(table.trust, AgentTrustLevels.verified),
|
|
3304
|
+
opts.projectIds ? inArray(table.projectId, [...opts.projectIds]) : void 0
|
|
3305
|
+
)).orderBy(sql`rowid`).limit(BATCH_SIZE).all();
|
|
3306
|
+
if (rows.length === 0) break;
|
|
3307
|
+
lastRowid = rows[rows.length - 1].rowid;
|
|
3308
|
+
result.examined += rows.length;
|
|
3309
|
+
for (const row of rows) {
|
|
3310
|
+
if (!isScannerPath(row.path)) continue;
|
|
3311
|
+
result.probes++;
|
|
3312
|
+
const id = JSON.stringify([row.projectId, row.sourceId, row.correlationKey]);
|
|
3313
|
+
const client = clients.get(id) ?? { projectId: row.projectId, sourceId: row.sourceId, correlationKey: row.correlationKey, probes: [] };
|
|
3314
|
+
client.probes.push(Date.parse(row.ts));
|
|
3315
|
+
clients.set(id, client);
|
|
3316
|
+
}
|
|
3317
|
+
await yieldToEventLoop();
|
|
3318
|
+
}
|
|
3319
|
+
for (const client of clients.values()) {
|
|
3320
|
+
if (opts.shouldStop()) break;
|
|
3321
|
+
const probes = client.probes.sort((a, b) => a - b);
|
|
3322
|
+
const from = new Date(probes[0] - SCANNER_BURST_WINDOW_MS).toISOString();
|
|
3323
|
+
const to = new Date(probes.at(-1) + SCANNER_BURST_WINDOW_MS).toISOString();
|
|
3324
|
+
db.transaction((tx) => {
|
|
3325
|
+
const rows = tx.select().from(table).where(and(
|
|
3326
|
+
eq(table.projectId, client.projectId),
|
|
3327
|
+
eq(table.sourceId, client.sourceId),
|
|
3328
|
+
eq(table.correlationKey, client.correlationKey),
|
|
3329
|
+
gte(table.ts, from),
|
|
3330
|
+
lte(table.ts, to),
|
|
3331
|
+
ne(table.trust, AgentTrustLevels.verified)
|
|
3332
|
+
)).all();
|
|
3333
|
+
for (const row of rows) {
|
|
3334
|
+
const probe = isScannerPath(row.path);
|
|
3335
|
+
const at = Date.parse(row.ts);
|
|
3336
|
+
if (!probe && !probes.some((t) => Math.abs(at - t) <= SCANNER_BURST_WINDOW_MS)) continue;
|
|
3337
|
+
result.removed++;
|
|
3338
|
+
if (opts.dryRun) continue;
|
|
3339
|
+
tx.delete(table).where(eq(table.id, row.id)).run();
|
|
3340
|
+
tx.update(agentJourneyCaptureDays).set({ storedEvents: sql`max(${agentJourneyCaptureDays.storedEvents} - 1, 0)` }).where(and(
|
|
3341
|
+
eq(agentJourneyCaptureDays.projectId, row.projectId),
|
|
3342
|
+
eq(agentJourneyCaptureDays.sourceId, row.sourceId),
|
|
3343
|
+
eq(agentJourneyCaptureDays.day, row.ts.slice(0, 10))
|
|
3344
|
+
)).run();
|
|
3345
|
+
if (!probe) moveAgentHitToBurst(tx, row, opts.now);
|
|
3346
|
+
}
|
|
3347
|
+
}, { behavior: "immediate" });
|
|
3348
|
+
await yieldToEventLoop();
|
|
3349
|
+
}
|
|
3350
|
+
return result;
|
|
3351
|
+
}
|
|
3181
3352
|
async function reclassifyStoredTraffic(db, opts = {}) {
|
|
3182
3353
|
const shared = {
|
|
3183
3354
|
projectIds: opts.projectIds,
|
|
@@ -3187,7 +3358,11 @@ async function reclassifyStoredTraffic(db, opts = {}) {
|
|
|
3187
3358
|
};
|
|
3188
3359
|
const samples = await reclassifyUnknownSamples(db, shared);
|
|
3189
3360
|
const unrecognized = shared.shouldStop() ? { examined: 0, moved: 0, movedHits: 0, renamed: 0, removed: 0, byBot: {} } : await reclassifyUnrecognizedRows(db, shared);
|
|
3190
|
-
|
|
3361
|
+
const agentHits = shared.shouldStop() ? { examined: 0, moved: 0, movedHits: 0 } : await reassessAgentHits(db, shared);
|
|
3362
|
+
const agentRequests = shared.shouldStop() ? { examined: 0, probes: 0, removed: 0 } : await reassessAgentRequests(db, shared);
|
|
3363
|
+
const journeys = shared.shouldStop() ? { visitors: 0, visitorsRemoved: 0, visitsRemoved: 0, visitsRelanded: 0 } : correctBackgroundCallJourneys(db, shared);
|
|
3364
|
+
const journeyMerges = shared.shouldStop() ? { visitorsMerged: 0, visitsJoined: 0 } : mergeSplitJourneyVisitors(db, shared);
|
|
3365
|
+
return { dryRun: shared.dryRun, samples, unrecognized, agentHits, agentRequests, journeys, journeyMerges };
|
|
3191
3366
|
}
|
|
3192
3367
|
async function reclassifyStoredTrafficIfRulesChanged(db, opts = {}) {
|
|
3193
3368
|
const fingerprint = trafficClassificationFingerprint();
|
|
@@ -3209,7 +3384,7 @@ function startTrafficReclassification(opts) {
|
|
|
3209
3384
|
const timer = setTimeout(() => {
|
|
3210
3385
|
reclassifyStoredTrafficIfRulesChanged(opts.db, { shouldStop: () => stopped }).then((outcome) => {
|
|
3211
3386
|
if (!outcome.ran || !outcome.result) return;
|
|
3212
|
-
const { samples, unrecognized } = outcome.result;
|
|
3387
|
+
const { samples, unrecognized, agentHits, agentRequests, journeys, journeyMerges } = outcome.result;
|
|
3213
3388
|
log.info("traffic-reclassify.completed", {
|
|
3214
3389
|
samplesReclassified: samples.reclassified,
|
|
3215
3390
|
samplesCounted: samples.counted,
|
|
@@ -3217,7 +3392,14 @@ function startTrafficReclassification(opts) {
|
|
|
3217
3392
|
unrecognizedMoved: unrecognized.moved,
|
|
3218
3393
|
unrecognizedMovedHits: unrecognized.movedHits,
|
|
3219
3394
|
unrecognizedRenamed: unrecognized.renamed,
|
|
3220
|
-
unrecognizedRemoved: unrecognized.removed
|
|
3395
|
+
unrecognizedRemoved: unrecognized.removed,
|
|
3396
|
+
agentHitsMoved: agentHits.movedHits,
|
|
3397
|
+
agentRequestsRemoved: agentRequests.removed,
|
|
3398
|
+
journeyVisitorsRemoved: journeys.visitorsRemoved,
|
|
3399
|
+
journeyVisitsRemoved: journeys.visitsRemoved,
|
|
3400
|
+
journeyVisitsRelanded: journeys.visitsRelanded,
|
|
3401
|
+
journeyVisitorsMerged: journeyMerges.visitorsMerged,
|
|
3402
|
+
journeyVisitsJoined: journeyMerges.visitsJoined
|
|
3221
3403
|
});
|
|
3222
3404
|
}).catch((err) => {
|
|
3223
3405
|
if (!stopped) log.error("traffic-reclassify.failed", { error: describeError(err) });
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
resolveCliAccess,
|
|
4
4
|
resolveCliAccessForInvocation,
|
|
5
5
|
windowOptions
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4KK3OTHE.js";
|
|
7
7
|
import {
|
|
8
8
|
emitJsonl
|
|
9
9
|
} from "./chunk-Z7IUAJOF.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./chunk-HGMYEDAQ.js";
|
|
15
15
|
import {
|
|
16
16
|
OperationAccesses
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-KNKOTLVW.js";
|
|
18
18
|
|
|
19
19
|
// src/cli-catalog.ts
|
|
20
20
|
import { createRequire } from "module";
|
|
@@ -111,7 +111,7 @@ async function dispatchRegisteredCommand(args, fallbackFormat, specs) {
|
|
|
111
111
|
const accessValue = accessFilterFromArgs(argsWithoutHelp);
|
|
112
112
|
validateAccessFilter(accessValue);
|
|
113
113
|
if (fallbackFormat !== "text") {
|
|
114
|
-
const { printCliCatalog: printCliCatalog2 } = await import("./cli-catalog-
|
|
114
|
+
const { printCliCatalog: printCliCatalog2 } = await import("./cli-catalog-QVCJWPCI.js");
|
|
115
115
|
const group2 = argsWithoutHelp.find((arg) => !arg.startsWith("--"));
|
|
116
116
|
printCliCatalog2(specs, fallbackFormat, group2, accessValue);
|
|
117
117
|
return true;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getRequestContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PX2KVGOJ.js";
|
|
4
4
|
import {
|
|
5
5
|
diagnosticIdentity,
|
|
6
6
|
redactLogString,
|
|
7
7
|
redactLogValue
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KNKOTLVW.js";
|
|
9
9
|
|
|
10
10
|
// ../api-routes/src/runtime-logger.ts
|
|
11
11
|
import { format } from "util";
|