@canonry/canonry 7.128.0 → 7.129.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/{AccessControls-QW1RtXqK.js → AccessControls-B1v2FZPP.js} +1 -1
- package/assets/assets/{AgentSetupPage-BFO6Jx36.js → AgentSetupPage-DAu_QuMy.js} +1 -1
- package/assets/assets/{AuditHistoryPanel-Cn9Tnnxo.js → AuditHistoryPanel-D_zRZDy7.js} +1 -1
- package/assets/assets/{BacklinksPage-Bv12EM38.js → BacklinksPage-DMZKWIfa.js} +1 -1
- package/assets/assets/{ChartPrimitives-DIAAi1Eq.js → ChartPrimitives-0854i4GX.js} +1 -1
- package/assets/assets/{HistoryPage-Bfn3nVjo.js → HistoryPage-Ci2llyKV.js} +1 -1
- package/assets/assets/{MeasurementPropertyPage-Cwyl4MS5.js → MeasurementPropertyPage-Bml0yUnY.js} +1 -1
- package/assets/assets/{ProjectPage-JCH068IS.js → ProjectPage-DQgRsgAv.js} +3 -3
- package/assets/assets/{RunsPage-B56n3Xwl.js → RunsPage-BihA-xXz.js} +1 -1
- package/assets/assets/{ServerTrafficSection-JZ7tID1A.js → ServerTrafficSection-B4FdP2Yn.js} +3 -3
- package/assets/assets/{SettingsPage-C1XRb6UB.js → SettingsPage-DuheQKDg.js} +1 -1
- package/assets/assets/{ToneBadge-DSr49xyr.js → ToneBadge-CvjNM6Ls.js} +1 -1
- package/assets/assets/{TrafficPage-BIbFPquR.js → TrafficPage-DiG_i3h4.js} +1 -1
- package/assets/assets/{TrafficSourceDetailPage-DpJyjmCY.js → TrafficSourceDetailPage-BRlxEdMd.js} +1 -1
- package/assets/assets/{account-context-CRwUczVQ.js → account-context-DBJg_gVV.js} +1 -1
- package/assets/assets/{agent-trust-copy-DduiTpc0.js → agent-trust-copy-DELKG03R.js} +1 -1
- package/assets/assets/{card-DtN_FyC4.js → card-WjxG7OUP.js} +1 -1
- package/assets/assets/{index-CmdxqiD3.js → index-DxQlUSXe.js} +3 -3
- package/assets/assets/{preload-helper-CqQPtzI4.js → preload-helper-CkO9IcjS.js} +1 -1
- package/assets/assets/query-client-BuEx84KK.js +1 -0
- package/assets/assets/{react-query-Bt-PaSFW.js → react-query-DF9z4xIx.js} +1 -1
- package/assets/assets/{react-sigma_core.esm.min-BTRnvmn2.js → react-sigma_core.esm.min-C1O8GFwj.js} +1 -1
- package/assets/assets/{server-traffic-D598cM_v.js → server-traffic-s9vqPEWz.js} +1 -1
- package/assets/assets/{service--wSlHsiA.js → service-ZGP6b4iE.js} +1 -1
- package/assets/index.html +9 -9
- package/dist/activity-JOXDL3UF.js +13 -0
- package/dist/{ads-PB3VFUPV.js → ads-XOHE65YV.js} +4 -4
- package/dist/{agent-VOL7SOEQ.js → agent-R2KM6VDZ.js} +8 -8
- package/dist/{agent-ask-F46ERE3W.js → agent-ask-LK6L5U2G.js} +4 -4
- package/dist/{agent-conversations-T5Q43627.js → agent-conversations-SPQZA674.js} +4 -4
- package/dist/{agent-journeys-GVEVJ5J2.js → agent-journeys-J4PRNH37.js} +4 -4
- package/dist/{agent-memory-XXN7QXNM.js → agent-memory-HXK5R5H2.js} +4 -4
- package/dist/{agent-providers-U6XIM5JI.js → agent-providers-YXCFLOAD.js} +4 -4
- package/dist/{agent-transcript-ONEA6JBO.js → agent-transcript-XLBIKNTI.js} +4 -4
- package/dist/{analytics-XWVTM57N.js → analytics-CT6X5AIK.js} +4 -4
- package/dist/{answerability-GNYSELX5.js → answerability-PRGBTPYO.js} +4 -4
- package/dist/{apply-WXW4KWUK.js → apply-6AQBJSLU.js} +4 -4
- package/dist/{backfill-SWDR5M4O.js → backfill-UMVXMH2Z.js} +11 -11
- package/dist/{backlinks-5LIBLUEG.js → backlinks-YAQL5BCW.js} +4 -4
- package/dist/{bing-4U4ODKGV.js → bing-A3BZHGVS.js} +4 -4
- package/dist/{bootstrap-FY72AHVW.js → bootstrap-3GXCVZR6.js} +11 -11
- package/dist/{cdp-H5WMBYIF.js → cdp-NTHQS2VZ.js} +8 -8
- package/dist/{chunk-3ZNDJ4OM.js → chunk-2DTDECRE.js} +5 -5
- package/dist/{chunk-X6DD3OIR.js → chunk-2QHWROIF.js} +23 -3
- package/dist/{chunk-DWFCDUE2.js → chunk-3HQ5GREG.js} +372 -372
- package/dist/{chunk-DY2Q3VIM.js → chunk-3HW7EDLQ.js} +2 -2
- package/dist/{chunk-HQEH4YRO.js → chunk-5QRZYOHL.js} +1 -1
- package/dist/{chunk-GCBFSIKI.js → chunk-66ESBZBC.js} +1 -1
- package/dist/{chunk-3GE4Z4J3.js → chunk-6HWV3PVJ.js} +5 -5
- package/dist/{chunk-ZKIEOEUZ.js → chunk-6S3Z37H7.js} +2 -2
- package/dist/{chunk-G2NIO2J3.js → chunk-6TEMKMWL.js} +2 -2
- package/dist/{chunk-QWD3ABAW.js → chunk-AFKCRFVL.js} +1 -1
- package/dist/{chunk-M4IAXLBT.js → chunk-APM25SLF.js} +3 -3
- package/dist/{chunk-A36PZKKS.js → chunk-BW3SUS45.js} +2 -2
- package/dist/{chunk-5WDU7ZML.js → chunk-CT6J54HN.js} +6 -6
- package/dist/{chunk-NEJEHRPT.js → chunk-EF6I66NL.js} +2 -2
- package/dist/{chunk-2PLJ4QG5.js → chunk-EGTMTGBD.js} +4 -4
- package/dist/{chunk-PWXLKW2F.js → chunk-GBYV3WM5.js} +3 -3
- package/dist/{chunk-RDCEFEXP.js → chunk-GUU3LZQ2.js} +3 -3
- package/dist/{chunk-XONND7NT.js → chunk-H7UFYW34.js} +3 -3
- package/dist/{chunk-GTX7C5Y5.js → chunk-HD73OWIQ.js} +53 -25
- package/dist/{chunk-GW4CL5ZO.js → chunk-HEWCB5LK.js} +315 -126
- package/dist/{chunk-HS2HYFPX.js → chunk-JJQ5USIP.js} +5 -5
- package/dist/{chunk-RMLGMB5B.js → chunk-JZDOF24J.js} +1 -1
- package/dist/{chunk-FIF4N7DP.js → chunk-KL6LUFZG.js} +1 -1
- package/dist/{chunk-K3YHPTKL.js → chunk-MWZQPB26.js} +2 -2
- package/dist/{chunk-GKQ4CYUM.js → chunk-MYDVOMA2.js} +62 -36
- package/dist/{chunk-2T4OGJWP.js → chunk-NJPBDYVK.js} +1 -1
- package/dist/{chunk-425BZPKK.js → chunk-OFW3JZLL.js} +9 -6
- package/dist/{chunk-OKIAF573.js → chunk-OWT4PYRT.js} +1 -1
- package/dist/{chunk-6TXHNNKW.js → chunk-PQL52QOQ.js} +4 -4
- package/dist/{chunk-LWRPSAVC.js → chunk-RHVX66CW.js} +1 -1
- package/dist/{chunk-IIL4NKRU.js → chunk-RXBK4GQX.js} +4 -4
- package/dist/{chunk-2VDYFOKB.js → chunk-SQ7ZF5MT.js} +8 -8
- package/dist/{chunk-GPPTW3HU.js → chunk-T5H4KNSZ.js} +4 -4
- package/dist/{chunk-FMS7CIEK.js → chunk-T7EDIDHA.js} +4 -4
- package/dist/{chunk-RPAWPX7B.js → chunk-V5B2CFBF.js} +1 -1
- package/dist/{chunk-QXRI6DRE.js → chunk-WPYUTGW5.js} +2331 -1983
- package/dist/{chunk-GRX2DION.js → chunk-YMWRR3HT.js} +4 -4
- package/dist/{chunk-BAO3PHQP.js → chunk-YYMXQVGL.js} +2 -2
- package/dist/{citations-622BWQTR.js → citations-GNB2QFVP.js} +5 -5
- package/dist/{cli-catalog-ACK3FVAX.js → cli-catalog-U6DBN4VK.js} +4 -4
- package/dist/cli-commands-LQS3WOKR.js +18 -0
- package/dist/cli.js +14 -14
- package/dist/{competitor-QYZIWXGC.js → competitor-I7Z6SSQP.js} +4 -4
- package/dist/{content-PJASAMIV.js → content-QIBZSUA6.js} +4 -4
- package/dist/{dashboard-FQOS3J4B.js → dashboard-7FYN233W.js} +7 -7
- package/dist/{demo-ZGGVSKN4.js → demo-P2V5SBGO.js} +3 -3
- package/dist/{demo-server-TLXLEPOI.js → demo-server-YYKW42LA.js} +13 -13
- package/dist/{discover-ZLDSXDRI.js → discover-RBTF62HF.js} +5 -5
- package/dist/{discover-eval-7F5Q3RXS.js → discover-eval-NMDHNYFT.js} +4 -4
- package/dist/{doctor-3KSQZDZ3.js → doctor-4CJAVMAD.js} +4 -4
- package/dist/{evidence-BJZIRJ4U.js → evidence-7Q4ET24V.js} +4 -4
- package/dist/{export-cmd-BYPGV4IU.js → export-cmd-CKK77OJI.js} +4 -4
- package/dist/{ga-A3BAZCYH.js → ga-EZOQAH3P.js} +4 -4
- package/dist/{gbp-U6VCRAFN.js → gbp-UL6TC2FY.js} +4 -4
- package/dist/{google-UNQZBUGS.js → google-7BM3AREH.js} +5 -5
- package/dist/{google-marketing-QSIRQAVH.js → google-marketing-DM6R3K7R.js} +2 -2
- package/dist/{health-cmd-Z5KTTJQU.js → health-cmd-TDD7FB7Z.js} +5 -5
- package/dist/{history-IIGUZMOM.js → history-V5CQNF4Z.js} +4 -4
- package/dist/index.d.ts +24 -24
- package/dist/index.js +26 -26
- package/dist/{init-GGKLWNRS.js → init-KLKQCQ54.js} +13 -13
- package/dist/{insights-UQ234W6T.js → insights-FRBCFTVP.js} +4 -4
- package/dist/intelligence-service-APERYL5N.js +15 -0
- package/dist/{journeys-2EZIRL7K.js → journeys-J76FXGLW.js} +4 -4
- package/dist/{keys-NIAANGXE.js → keys-LZVHDNZH.js} +4 -4
- package/dist/{keyword-LHHNG3GL.js → keyword-FMDPSY7C.js} +4 -4
- package/dist/{logs-UFOOIKTC.js → logs-LU33LBEQ.js} +4 -4
- package/dist/{mcp-AZYUFL5V.js → mcp-M63QTZK5.js} +5 -5
- package/dist/mcp.js +10 -10
- package/dist/{measurement-plan-H2HIHJ3D.js → measurement-plan-C6W7PUMR.js} +6 -6
- package/dist/{notify-TIE2ZJ26.js → notify-Q54WJSST.js} +4 -4
- package/dist/{organic-evidence-BX5MGZTK.js → organic-evidence-EGM6MHVP.js} +4 -4
- package/dist/{overview-MGQE43GU.js → overview-EWSJQE2E.js} +7 -7
- package/dist/{project-2JL4ZW52.js → project-K7U4L5TA.js} +4 -4
- package/dist/{project-setup-CXOVBRLZ.js → project-setup-H6JIED5C.js} +4 -4
- package/dist/{query-Q5BF63QF.js → query-NNFM2KSB.js} +4 -4
- package/dist/{research-RQBZ57W5.js → research-KHDVC2MP.js} +4 -4
- package/dist/{results-export-TVCBJNJN.js → results-export-2HTJWA2Y.js} +4 -4
- package/dist/{run-L6WG5WP2.js → run-VWAT66RX.js} +6 -6
- package/dist/{schedule-3HQMG3AM.js → schedule-6C26Y5DP.js} +4 -4
- package/dist/{search-ZLQE4J66.js → search-DY4JELQM.js} +4 -4
- package/dist/{serve-VV4SVEJW.js → serve-W6CTWEDL.js} +36 -27
- package/dist/{session-IJLUYO4T.js → session-IX6YUFT4.js} +14 -14
- package/dist/{settings-T3U7TQOF.js → settings-IPTMUYPV.js} +4 -4
- package/dist/{sitemaps-UZPLGN4W.js → sitemaps-JHAE7447.js} +4 -4
- package/dist/{skills-P4WSSFPF.js → skills-C5KQTJZX.js} +3 -3
- package/dist/{snapshot-ROJPISJE.js → snapshot-KZDIFYFO.js} +4 -4
- package/dist/{src-ZYWTGILQ.js → src-JWSI26BC.js} +2 -2
- package/dist/{status-43XNR3NS.js → status-7TFB73LG.js} +6 -6
- package/dist/{support-I7E4I3GG.js → support-ZZ2GJP4Z.js} +2 -2
- package/dist/{technical-aeo-D4F2R6M3.js → technical-aeo-R6GR6JJB.js} +4 -4
- package/dist/{telemetry-5DMVDDZI.js → telemetry-YTUYOO3M.js} +5 -5
- package/dist/{tools-M534GJMS.js → tools-6N3Q7TRE.js} +12 -12
- package/dist/{traffic-R2UA27AZ.js → traffic-5IN455SY.js} +6 -6
- package/dist/{trends-BXOZIWIE.js → trends-MULZJCGC.js} +4 -4
- package/dist/{users-X6WJV7VJ.js → users-4R5WLGZA.js} +4 -4
- package/dist/{visibility-stats-MCNUXUCL.js → visibility-stats-GFDD6IYA.js} +5 -5
- package/dist/{wordpress-AMGUJUZX.js → wordpress-S6NFAXJ6.js} +4 -4
- package/package.json +1 -1
- package/assets/assets/query-client-BcqjBQN8.js +0 -1
- package/dist/activity-2KFFWLYN.js +0 -13
- package/dist/cli-commands-IM2ISRXZ.js +0 -18
- package/dist/intelligence-service-S3GTOTGQ.js +0 -15
|
@@ -24,18 +24,18 @@ import {
|
|
|
24
24
|
resolveConfiguredAgentProvider,
|
|
25
25
|
resolveSessionProviderAndModel,
|
|
26
26
|
setAeroSystemPrompt
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-CT6J54HN.js";
|
|
28
28
|
import {
|
|
29
29
|
AeroToolProfiles,
|
|
30
30
|
AeroToolScopes,
|
|
31
31
|
buildAeroStateTools,
|
|
32
32
|
isAeroToolProfile,
|
|
33
33
|
truncateToolResult
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-2DTDECRE.js";
|
|
35
35
|
import {
|
|
36
36
|
answerServiceAdapters,
|
|
37
37
|
answerServiceDescriptors
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-AFKCRFVL.js";
|
|
39
39
|
import {
|
|
40
40
|
isManagedCanonryInstall
|
|
41
41
|
} from "./chunk-XAJS5FH3.js";
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
removeCloudflareTrafficConnection,
|
|
58
58
|
removeCloudflareTrafficConnectionBySourceId,
|
|
59
59
|
upsertCloudflareTrafficConnection
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-5QRZYOHL.js";
|
|
61
61
|
import {
|
|
62
62
|
claudeAdapter,
|
|
63
63
|
embedQueries,
|
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
openrouterAdapter,
|
|
70
70
|
perplexityAdapter,
|
|
71
71
|
startTrafficReclassification
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-HD73OWIQ.js";
|
|
73
73
|
import {
|
|
74
74
|
classifyUsageSurface,
|
|
75
75
|
createApiUsageTelemetry,
|
|
@@ -81,7 +81,7 @@ import {
|
|
|
81
81
|
startOutcomeTimer,
|
|
82
82
|
trackFeatureCompleted,
|
|
83
83
|
trackInstallState
|
|
84
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-T5H4KNSZ.js";
|
|
85
85
|
import {
|
|
86
86
|
isLoopbackBindHost
|
|
87
87
|
} from "./chunk-TSENU4GG.js";
|
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
isApiProviderRegistrable,
|
|
90
90
|
isCdpProviderRegistrable,
|
|
91
91
|
registeredProviderNames
|
|
92
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-66ESBZBC.js";
|
|
93
93
|
import {
|
|
94
94
|
checkLatestVersionForServer,
|
|
95
95
|
getOrCreateAnonymousId,
|
|
@@ -101,17 +101,17 @@ import {
|
|
|
101
101
|
recordDashboardEvent,
|
|
102
102
|
setTelemetryPreference,
|
|
103
103
|
trackEvent
|
|
104
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-3HW7EDLQ.js";
|
|
105
105
|
import {
|
|
106
106
|
createCanonryMcpServer
|
|
107
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-OFW3JZLL.js";
|
|
108
108
|
import {
|
|
109
109
|
CANONRY_MCP_TIERS,
|
|
110
110
|
CANONRY_MCP_TOOLKIT_NAMES
|
|
111
111
|
} from "./chunk-MG4COK23.js";
|
|
112
112
|
import {
|
|
113
113
|
ApiClient
|
|
114
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-H7UFYW34.js";
|
|
115
115
|
import {
|
|
116
116
|
AGENT_PROVIDERS,
|
|
117
117
|
PROVIDER_MODELS,
|
|
@@ -146,39 +146,39 @@ import {
|
|
|
146
146
|
saveConfigPatch,
|
|
147
147
|
sentimentInstallReadiness,
|
|
148
148
|
updateSharedProviderExecutionGate
|
|
149
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-T7EDIDHA.js";
|
|
150
150
|
import {
|
|
151
151
|
getBundledSkillSnapshots
|
|
152
|
-
} from "./chunk-
|
|
152
|
+
} from "./chunk-EF6I66NL.js";
|
|
153
153
|
import {
|
|
154
154
|
computeFactorAverages,
|
|
155
155
|
deleteSiteCrawlGraphLayout,
|
|
156
156
|
persistSiteCrawlGraphLayout,
|
|
157
157
|
prepareSiteCrawlGraphLayout,
|
|
158
158
|
recordedSharePct
|
|
159
|
-
} from "./chunk-
|
|
159
|
+
} from "./chunk-MWZQPB26.js";
|
|
160
160
|
import {
|
|
161
161
|
CanonryMcpToolNames,
|
|
162
162
|
canonryMcpTools
|
|
163
|
-
} from "./chunk-
|
|
163
|
+
} from "./chunk-JJQ5USIP.js";
|
|
164
164
|
import {
|
|
165
165
|
PACKAGE_VERSION
|
|
166
166
|
} from "./chunk-AOJU5LKX.js";
|
|
167
167
|
import {
|
|
168
168
|
CliError
|
|
169
|
-
} from "./chunk-
|
|
169
|
+
} from "./chunk-NJPBDYVK.js";
|
|
170
170
|
import {
|
|
171
171
|
IntelligenceService
|
|
172
|
-
} from "./chunk-
|
|
172
|
+
} from "./chunk-6HWV3PVJ.js";
|
|
173
173
|
import {
|
|
174
174
|
computeCitedCompetitorDomains,
|
|
175
175
|
determineCitationState
|
|
176
|
-
} from "./chunk-
|
|
176
|
+
} from "./chunk-V5B2CFBF.js";
|
|
177
177
|
import {
|
|
178
178
|
addLogListener,
|
|
179
179
|
createFastifyLogger,
|
|
180
180
|
createLogger
|
|
181
|
-
} from "./chunk-
|
|
181
|
+
} from "./chunk-6TEMKMWL.js";
|
|
182
182
|
import {
|
|
183
183
|
BING_THROTTLE_COOLDOWN_MS,
|
|
184
184
|
BingApiError,
|
|
@@ -194,6 +194,7 @@ import {
|
|
|
194
194
|
GbpApiError,
|
|
195
195
|
GoogleApiError,
|
|
196
196
|
GoogleAuthError,
|
|
197
|
+
LoginAttemptLimiter,
|
|
197
198
|
MCP_DELEGATED_KEY_MAX_AGE_MS,
|
|
198
199
|
PLUGIN_DIR,
|
|
199
200
|
SITE_REACHABILITY_CHECKS,
|
|
@@ -205,6 +206,7 @@ import {
|
|
|
205
206
|
anyUsersExist,
|
|
206
207
|
apiRoutes,
|
|
207
208
|
applyCompetitorAutoAliases,
|
|
209
|
+
assertCookieWriteOrigin,
|
|
208
210
|
assessConversionTrackingIntegrity,
|
|
209
211
|
auditFromRequest,
|
|
210
212
|
backfillProjectAnswerMentions,
|
|
@@ -310,7 +312,9 @@ import {
|
|
|
310
312
|
registerAgentConversationRoutes,
|
|
311
313
|
registerOAuthAdminRoutes,
|
|
312
314
|
registerOAuthRoutes,
|
|
315
|
+
registerResponseCompression,
|
|
313
316
|
requireInstanceAdministrator,
|
|
317
|
+
resolveCallerKey,
|
|
314
318
|
resolveCloudflareQueueSyncDeadlineMs,
|
|
315
319
|
resolveDestination,
|
|
316
320
|
resolveMeasurementSitemapTarget,
|
|
@@ -334,7 +338,7 @@ import {
|
|
|
334
338
|
webhookTargetRefusalReason,
|
|
335
339
|
webhookUserAgent,
|
|
336
340
|
writeAuditLog
|
|
337
|
-
} from "./chunk-
|
|
341
|
+
} from "./chunk-WPYUTGW5.js";
|
|
338
342
|
import {
|
|
339
343
|
OperationalLogStore,
|
|
340
344
|
SentimentIdempotencyConflict,
|
|
@@ -436,7 +440,7 @@ import {
|
|
|
436
440
|
unrecognizedAgentEventsHourly,
|
|
437
441
|
unrecognizedAgentNotifyState,
|
|
438
442
|
usageCounters
|
|
439
|
-
} from "./chunk-
|
|
443
|
+
} from "./chunk-2QHWROIF.js";
|
|
440
444
|
import {
|
|
441
445
|
AGENT_MEMORY_VALUE_MAX_BYTES,
|
|
442
446
|
AI_ENGINE_DOMAINS,
|
|
@@ -722,7 +726,7 @@ import {
|
|
|
722
726
|
winnabilityClassLabel,
|
|
723
727
|
withRetry,
|
|
724
728
|
withSkippedProviders
|
|
725
|
-
} from "./chunk-
|
|
729
|
+
} from "./chunk-MYDVOMA2.js";
|
|
726
730
|
|
|
727
731
|
// src/google-marketing-runtime.ts
|
|
728
732
|
import crypto2 from "crypto";
|
|
@@ -4824,6 +4828,12 @@ import os3 from "os";
|
|
|
4824
4828
|
import OpenAI from "openai";
|
|
4825
4829
|
|
|
4826
4830
|
// ../provider-local/src/utils.ts
|
|
4831
|
+
var MAX_RETRY_AFTER_WAIT_MS = 65e3;
|
|
4832
|
+
function isRetryableProviderError(err) {
|
|
4833
|
+
if (!isRetryableHttpError(err)) return false;
|
|
4834
|
+
const asked = retryAfterDelayMs(err);
|
|
4835
|
+
return asked === null || asked <= MAX_RETRY_AFTER_WAIT_MS;
|
|
4836
|
+
}
|
|
4827
4837
|
async function withRetry2(fn, options = {}) {
|
|
4828
4838
|
return withRetry(fn, {
|
|
4829
4839
|
maxRetries: options.maxRetries ?? 3,
|
|
@@ -4833,7 +4843,9 @@ async function withRetry2(fn, options = {}) {
|
|
|
4833
4843
|
// provider has shipped to date (1000, 2000, 4000ms). Enable per-caller
|
|
4834
4844
|
// if you need it.
|
|
4835
4845
|
jitter: false,
|
|
4836
|
-
isRetryable:
|
|
4846
|
+
isRetryable: isRetryableProviderError,
|
|
4847
|
+
computeDelayMs: (_attempt, err, defaultMs) => retryAfterDelayMs(err) ?? defaultMs,
|
|
4848
|
+
...options.sleep ? { sleep: options.sleep } : {},
|
|
4837
4849
|
onRetry: ({ attempt, err, delayMs }) => {
|
|
4838
4850
|
console.warn(
|
|
4839
4851
|
`[provider] Attempt ${attempt + 1} failed, retrying in ${delayMs}ms...`,
|
|
@@ -4845,6 +4857,14 @@ async function withRetry2(fn, options = {}) {
|
|
|
4845
4857
|
|
|
4846
4858
|
// ../provider-local/src/normalize.ts
|
|
4847
4859
|
var DEFAULT_MODEL = "llama3";
|
|
4860
|
+
function createClient(config) {
|
|
4861
|
+
return new OpenAI({
|
|
4862
|
+
baseURL: config.baseUrl,
|
|
4863
|
+
apiKey: config.apiKey || "not-needed",
|
|
4864
|
+
// Retries are canonry's (`withRetry`), not the SDK's.
|
|
4865
|
+
maxRetries: 0
|
|
4866
|
+
});
|
|
4867
|
+
}
|
|
4848
4868
|
function validateConfig(config) {
|
|
4849
4869
|
if (!config.baseUrl || config.baseUrl.length === 0) {
|
|
4850
4870
|
return { ok: false, provider: "local", message: "missing base URL" };
|
|
@@ -4860,10 +4880,7 @@ async function healthcheck(config, signal) {
|
|
|
4860
4880
|
const validation = validateConfig(config);
|
|
4861
4881
|
if (!validation.ok) return validation;
|
|
4862
4882
|
try {
|
|
4863
|
-
const client =
|
|
4864
|
-
baseURL: config.baseUrl,
|
|
4865
|
-
apiKey: config.apiKey || "not-needed"
|
|
4866
|
-
});
|
|
4883
|
+
const client = createClient(config);
|
|
4867
4884
|
const models = await withRetry2(async () => {
|
|
4868
4885
|
const list = await client.models.list({ signal });
|
|
4869
4886
|
const items = [];
|
|
@@ -4908,10 +4925,7 @@ function buildTrackedQueryRequest(input) {
|
|
|
4908
4925
|
async function executeTrackedQuery(input) {
|
|
4909
4926
|
const model = input.config.model ?? DEFAULT_MODEL;
|
|
4910
4927
|
const params = buildTrackedQueryRequest(input).body;
|
|
4911
|
-
const client =
|
|
4912
|
-
baseURL: input.config.baseUrl,
|
|
4913
|
-
apiKey: input.config.apiKey || "not-needed"
|
|
4914
|
-
});
|
|
4928
|
+
const client = createClient(input.config);
|
|
4915
4929
|
let response;
|
|
4916
4930
|
try {
|
|
4917
4931
|
response = await withRetry2(() => client.chat.completions.create(params));
|
|
@@ -4963,10 +4977,7 @@ function extractAnswerText(rawResponse) {
|
|
|
4963
4977
|
}
|
|
4964
4978
|
async function generateText(prompt, config) {
|
|
4965
4979
|
const model = config.model ?? DEFAULT_MODEL;
|
|
4966
|
-
const client =
|
|
4967
|
-
baseURL: config.baseUrl,
|
|
4968
|
-
apiKey: config.apiKey || "not-needed"
|
|
4969
|
-
});
|
|
4980
|
+
const client = createClient(config);
|
|
4970
4981
|
const response = await withRetry2(
|
|
4971
4982
|
() => client.chat.completions.create({
|
|
4972
4983
|
model,
|
|
@@ -5201,13 +5212,16 @@ var CDPConnectionManager = class {
|
|
|
5201
5212
|
}
|
|
5202
5213
|
this.tabs.delete(target.name);
|
|
5203
5214
|
}
|
|
5215
|
+
let createdTargetId = null;
|
|
5216
|
+
let client = null;
|
|
5204
5217
|
try {
|
|
5205
5218
|
const newTarget = await CDP.New({
|
|
5206
5219
|
host: this.host,
|
|
5207
5220
|
port: this.port,
|
|
5208
5221
|
url: target.baseUrl
|
|
5209
5222
|
});
|
|
5210
|
-
|
|
5223
|
+
createdTargetId = newTarget.id;
|
|
5224
|
+
client = await CDP({
|
|
5211
5225
|
host: this.host,
|
|
5212
5226
|
port: this.port,
|
|
5213
5227
|
target: newTarget
|
|
@@ -5229,6 +5243,18 @@ var CDPConnectionManager = class {
|
|
|
5229
5243
|
this.tabs.set(target.name, entry);
|
|
5230
5244
|
return client;
|
|
5231
5245
|
} catch (err) {
|
|
5246
|
+
if (client) {
|
|
5247
|
+
try {
|
|
5248
|
+
await client.close();
|
|
5249
|
+
} catch {
|
|
5250
|
+
}
|
|
5251
|
+
}
|
|
5252
|
+
if (createdTargetId) {
|
|
5253
|
+
try {
|
|
5254
|
+
await CDP.Close({ host: this.host, port: this.port, id: createdTargetId });
|
|
5255
|
+
} catch {
|
|
5256
|
+
}
|
|
5257
|
+
}
|
|
5232
5258
|
throw new CDPProviderError(
|
|
5233
5259
|
"CDP_CONNECTION_REFUSED",
|
|
5234
5260
|
`Failed to connect to Chrome at ${this.host}:${this.port}: ${describeError(err)}`
|
|
@@ -5240,17 +5266,31 @@ var CDPConnectionManager = class {
|
|
|
5240
5266
|
* new conversation URL. This gives a clean slate without losing
|
|
5241
5267
|
* the login session.
|
|
5242
5268
|
*/
|
|
5243
|
-
async prepareForQuery(target) {
|
|
5269
|
+
async prepareForQuery(target, navigationTimeoutMs = 3e4) {
|
|
5244
5270
|
const client = await this.ensureTab(target);
|
|
5271
|
+
let timer;
|
|
5245
5272
|
try {
|
|
5273
|
+
const loadFired = client.Page.loadEventFired();
|
|
5274
|
+
void loadFired.catch(() => {
|
|
5275
|
+
});
|
|
5246
5276
|
await client.Page.navigate({ url: target.newConversationUrl });
|
|
5247
|
-
await
|
|
5277
|
+
await Promise.race([
|
|
5278
|
+
loadFired,
|
|
5279
|
+
new Promise((_, reject) => {
|
|
5280
|
+
timer = setTimeout(
|
|
5281
|
+
() => reject(new Error(`Page load timed out after ${navigationTimeoutMs}ms`)),
|
|
5282
|
+
navigationTimeoutMs
|
|
5283
|
+
);
|
|
5284
|
+
})
|
|
5285
|
+
]);
|
|
5248
5286
|
await sleep(1500);
|
|
5249
5287
|
} catch (err) {
|
|
5250
5288
|
throw new CDPProviderError(
|
|
5251
5289
|
"CDP_TARGET_SELECTOR_FAILED",
|
|
5252
5290
|
`Failed to navigate to ${target.newConversationUrl}: ${describeError(err)}`
|
|
5253
5291
|
);
|
|
5292
|
+
} finally {
|
|
5293
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
5254
5294
|
}
|
|
5255
5295
|
const entry = this.tabs.get(target.name);
|
|
5256
5296
|
if (entry) entry.lastUsed = /* @__PURE__ */ new Date();
|
|
@@ -5609,6 +5649,11 @@ function getConnection(config) {
|
|
|
5609
5649
|
}
|
|
5610
5650
|
return conn;
|
|
5611
5651
|
}
|
|
5652
|
+
async function closeAllCdpConnections() {
|
|
5653
|
+
const managers = [...connectionPool.values()];
|
|
5654
|
+
connectionPool.clear();
|
|
5655
|
+
await Promise.allSettled(managers.map((mgr) => mgr.disconnect()));
|
|
5656
|
+
}
|
|
5612
5657
|
function getScreenshotDir() {
|
|
5613
5658
|
return path2.join(os.homedir(), ".canonry", "screenshots");
|
|
5614
5659
|
}
|
|
@@ -6474,7 +6519,7 @@ function nonBlank(value) {
|
|
|
6474
6519
|
return trimmed ? trimmed : void 0;
|
|
6475
6520
|
}
|
|
6476
6521
|
function resolveBuildCommit(env = process.env) {
|
|
6477
|
-
const embedded = true ? "
|
|
6522
|
+
const embedded = true ? "5d143178e9f0f49e74b4d0686f464e4c331d9bb2" : void 0;
|
|
6478
6523
|
return nonBlank(embedded) ?? nonBlank(env.CANONRY_COMMIT);
|
|
6479
6524
|
}
|
|
6480
6525
|
function resolveInstanceIdentity(env = process.env) {
|
|
@@ -9299,61 +9344,72 @@ async function executeGscSync(db, runId, projectId, opts) {
|
|
|
9299
9344
|
endDate
|
|
9300
9345
|
});
|
|
9301
9346
|
log4.info("fetch.complete", { runId, projectId, rowCount: rows.length });
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9320
|
-
|
|
9321
|
-
|
|
9322
|
-
|
|
9323
|
-
|
|
9324
|
-
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
|
|
9347
|
+
const insertNow = (/* @__PURE__ */ new Date()).toISOString();
|
|
9348
|
+
const batchSize = 400;
|
|
9349
|
+
db.transaction((tx) => {
|
|
9350
|
+
tx.delete(gscSearchData).where(
|
|
9351
|
+
and6(
|
|
9352
|
+
eq8(gscSearchData.projectId, projectId),
|
|
9353
|
+
sql3`${gscSearchData.date} >= ${startDate}`,
|
|
9354
|
+
sql3`${gscSearchData.date} <= ${endDate}`
|
|
9355
|
+
)
|
|
9356
|
+
).run();
|
|
9357
|
+
for (let i = 0; i < rows.length; i += batchSize) {
|
|
9358
|
+
const batch = rows.slice(i, i + batchSize).map((row) => {
|
|
9359
|
+
const [query, page, country, device, date] = row.keys;
|
|
9360
|
+
return {
|
|
9361
|
+
id: crypto10.randomUUID(),
|
|
9362
|
+
projectId,
|
|
9363
|
+
syncRunId: runId,
|
|
9364
|
+
date: date ?? "",
|
|
9365
|
+
query: query ?? "",
|
|
9366
|
+
page: page ?? "",
|
|
9367
|
+
country: country ?? null,
|
|
9368
|
+
device: device ?? null,
|
|
9369
|
+
clicks: row.clicks,
|
|
9370
|
+
impressions: row.impressions,
|
|
9371
|
+
ctr: String(row.ctr),
|
|
9372
|
+
position: String(row.position),
|
|
9373
|
+
createdAt: insertNow
|
|
9374
|
+
};
|
|
9375
|
+
});
|
|
9376
|
+
if (batch.length > 0) {
|
|
9377
|
+
tx.insert(gscSearchData).values(batch).run();
|
|
9378
|
+
}
|
|
9330
9379
|
}
|
|
9331
|
-
}
|
|
9380
|
+
});
|
|
9332
9381
|
const totalRows = await fetchSearchAnalytics(accessToken, propertyId, {
|
|
9333
9382
|
startDate,
|
|
9334
9383
|
endDate,
|
|
9335
9384
|
dimensions: ["date"]
|
|
9336
9385
|
});
|
|
9337
|
-
db.delete(gscDailyTotals).where(
|
|
9338
|
-
and6(
|
|
9339
|
-
eq8(gscDailyTotals.projectId, projectId),
|
|
9340
|
-
sql3`${gscDailyTotals.date} >= ${startDate}`,
|
|
9341
|
-
sql3`${gscDailyTotals.date} <= ${endDate}`
|
|
9342
|
-
)
|
|
9343
|
-
).run();
|
|
9344
9386
|
const dailyTotalsNow = (/* @__PURE__ */ new Date()).toISOString();
|
|
9345
|
-
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
|
|
9352
|
-
|
|
9353
|
-
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
|
|
9387
|
+
db.transaction((tx) => {
|
|
9388
|
+
tx.delete(gscDailyTotals).where(
|
|
9389
|
+
and6(
|
|
9390
|
+
eq8(gscDailyTotals.projectId, projectId),
|
|
9391
|
+
sql3`${gscDailyTotals.date} >= ${startDate}`,
|
|
9392
|
+
sql3`${gscDailyTotals.date} <= ${endDate}`
|
|
9393
|
+
)
|
|
9394
|
+
).run();
|
|
9395
|
+
for (let i = 0; i < totalRows.length; i += batchSize) {
|
|
9396
|
+
const batch = totalRows.slice(i, i + batchSize).map((row) => {
|
|
9397
|
+
const [date] = row.keys;
|
|
9398
|
+
return {
|
|
9399
|
+
id: crypto10.randomUUID(),
|
|
9400
|
+
projectId,
|
|
9401
|
+
date: date ?? "",
|
|
9402
|
+
clicks: row.clicks,
|
|
9403
|
+
impressions: row.impressions,
|
|
9404
|
+
position: String(row.position),
|
|
9405
|
+
createdAt: dailyTotalsNow
|
|
9406
|
+
};
|
|
9407
|
+
});
|
|
9408
|
+
if (batch.length > 0) {
|
|
9409
|
+
tx.insert(gscDailyTotals).values(batch).run();
|
|
9410
|
+
}
|
|
9411
|
+
}
|
|
9412
|
+
});
|
|
9357
9413
|
const observedThrough = totalRows.map((row) => row.keys[0] ?? "").filter((date) => date !== "").reduce((max2, date) => max2 === null || date > max2 ? date : max2, null);
|
|
9358
9414
|
let dataThroughDate = null;
|
|
9359
9415
|
if (observedThrough !== null || endDate) {
|
|
@@ -9384,20 +9440,11 @@ async function executeGscSync(db, runId, projectId, opts) {
|
|
|
9384
9440
|
endDate,
|
|
9385
9441
|
dimensions: ["date", "query"]
|
|
9386
9442
|
});
|
|
9387
|
-
db.delete(gscQueryDailyTotals).where(
|
|
9388
|
-
and6(
|
|
9389
|
-
eq8(gscQueryDailyTotals.projectId, projectId),
|
|
9390
|
-
sql3`${gscQueryDailyTotals.date} >= ${startDate}`,
|
|
9391
|
-
sql3`${gscQueryDailyTotals.date} <= ${endDate}`
|
|
9392
|
-
)
|
|
9393
|
-
).run();
|
|
9394
9443
|
const queryTotalsNow = (/* @__PURE__ */ new Date()).toISOString();
|
|
9395
|
-
|
|
9396
|
-
for (const row of queryTotalRows) {
|
|
9444
|
+
const validQueryTotals = queryTotalRows.map((row) => {
|
|
9397
9445
|
const [date, query] = row.keys;
|
|
9398
|
-
if (!date || !query)
|
|
9399
|
-
|
|
9400
|
-
db.insert(gscQueryDailyTotals).values({
|
|
9446
|
+
if (!date || !query) return null;
|
|
9447
|
+
return {
|
|
9401
9448
|
id: crypto10.randomUUID(),
|
|
9402
9449
|
projectId,
|
|
9403
9450
|
date,
|
|
@@ -9408,8 +9455,21 @@ async function executeGscSync(db, runId, projectId, opts) {
|
|
|
9408
9455
|
syncedAt: queryTotalsNow,
|
|
9409
9456
|
syncRunId: runId,
|
|
9410
9457
|
createdAt: queryTotalsNow
|
|
9411
|
-
}
|
|
9412
|
-
}
|
|
9458
|
+
};
|
|
9459
|
+
}).filter((row) => row !== null);
|
|
9460
|
+
const queryTotalsStored = validQueryTotals.length;
|
|
9461
|
+
db.transaction((tx) => {
|
|
9462
|
+
tx.delete(gscQueryDailyTotals).where(
|
|
9463
|
+
and6(
|
|
9464
|
+
eq8(gscQueryDailyTotals.projectId, projectId),
|
|
9465
|
+
sql3`${gscQueryDailyTotals.date} >= ${startDate}`,
|
|
9466
|
+
sql3`${gscQueryDailyTotals.date} <= ${endDate}`
|
|
9467
|
+
)
|
|
9468
|
+
).run();
|
|
9469
|
+
for (let i = 0; i < validQueryTotals.length; i += batchSize) {
|
|
9470
|
+
tx.insert(gscQueryDailyTotals).values(validQueryTotals.slice(i, i + batchSize)).run();
|
|
9471
|
+
}
|
|
9472
|
+
});
|
|
9413
9473
|
log4.info("query-totals.complete", { runId, projectId, rowCount: queryTotalRows.length });
|
|
9414
9474
|
let sitemapsStored = null;
|
|
9415
9475
|
try {
|
|
@@ -10922,13 +10982,19 @@ import crypto15 from "crypto";
|
|
|
10922
10982
|
import { eq as eq12 } from "drizzle-orm";
|
|
10923
10983
|
|
|
10924
10984
|
// src/sitemap-parser.ts
|
|
10985
|
+
import { promisify } from "util";
|
|
10986
|
+
import zlib from "zlib";
|
|
10925
10987
|
var log8 = createLogger("SitemapParser");
|
|
10988
|
+
var gunzipAsync = promisify(zlib.gunzip);
|
|
10989
|
+
var SITEMAP_FETCH_TIMEOUT_MS = 15e3;
|
|
10990
|
+
var MAX_SITEMAP_BYTES = 10 * 1024 * 1024;
|
|
10991
|
+
var MAX_SITEMAPS = 100;
|
|
10926
10992
|
var LOC_REGEX = /<loc>([^<]+)<\/loc>/gi;
|
|
10927
10993
|
var SITEMAP_TAG_REGEX = /<sitemap>[\s\S]*?<\/sitemap>/gi;
|
|
10928
10994
|
var sitemapFetch = createGuardedFetch({ allowLoopback: true });
|
|
10929
10995
|
async function fetchSitemap(url) {
|
|
10930
10996
|
try {
|
|
10931
|
-
return await sitemapFetch(url);
|
|
10997
|
+
return await sitemapFetch(url, { signal: AbortSignal.timeout(SITEMAP_FETCH_TIMEOUT_MS) });
|
|
10932
10998
|
} catch (err) {
|
|
10933
10999
|
if (err instanceof EgressRefusedError) {
|
|
10934
11000
|
throw withOutcomeReason(new Error(`Sitemap ${url} rejected: ${err.message}`), OutcomeReasonCodes.BLOCKED_UNSAFE_URL);
|
|
@@ -10939,15 +11005,50 @@ async function fetchSitemap(url) {
|
|
|
10939
11005
|
throw err;
|
|
10940
11006
|
}
|
|
10941
11007
|
}
|
|
11008
|
+
async function readResponseBytesWithLimit(res, maxBytes) {
|
|
11009
|
+
const contentLength = res.headers.get("content-length");
|
|
11010
|
+
if (contentLength !== null) {
|
|
11011
|
+
const declared = Number.parseInt(contentLength, 10);
|
|
11012
|
+
if (Number.isFinite(declared) && declared > maxBytes) {
|
|
11013
|
+
await res.body?.cancel();
|
|
11014
|
+
throw new Error(`Sitemap exceeds maximum size limit of ${maxBytes} bytes`);
|
|
11015
|
+
}
|
|
11016
|
+
}
|
|
11017
|
+
if (!res.body) {
|
|
11018
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
11019
|
+
if (buf.byteLength > maxBytes) {
|
|
11020
|
+
throw new Error(`Sitemap exceeds maximum size limit of ${maxBytes} bytes`);
|
|
11021
|
+
}
|
|
11022
|
+
return buf;
|
|
11023
|
+
}
|
|
11024
|
+
const reader = res.body.getReader();
|
|
11025
|
+
const chunks = [];
|
|
11026
|
+
let total = 0;
|
|
11027
|
+
try {
|
|
11028
|
+
while (true) {
|
|
11029
|
+
const { done, value } = await reader.read();
|
|
11030
|
+
if (done) break;
|
|
11031
|
+
if (!value) continue;
|
|
11032
|
+
total += value.byteLength;
|
|
11033
|
+
if (total > maxBytes) {
|
|
11034
|
+
await reader.cancel();
|
|
11035
|
+
throw new Error(`Sitemap exceeds maximum size limit of ${maxBytes} bytes`);
|
|
11036
|
+
}
|
|
11037
|
+
chunks.push(Buffer.from(value.buffer, value.byteOffset, value.byteLength));
|
|
11038
|
+
}
|
|
11039
|
+
} finally {
|
|
11040
|
+
reader.releaseLock();
|
|
11041
|
+
}
|
|
11042
|
+
return Buffer.concat(chunks, total);
|
|
11043
|
+
}
|
|
10942
11044
|
async function readSitemapBody(res) {
|
|
10943
|
-
const
|
|
10944
|
-
const bytes = new Uint8Array(buf);
|
|
11045
|
+
const bytes = await readResponseBytesWithLimit(res, MAX_SITEMAP_BYTES);
|
|
10945
11046
|
const isGzipped = bytes.length >= 2 && bytes[0] === 31 && bytes[1] === 139;
|
|
10946
11047
|
if (!isGzipped) {
|
|
10947
|
-
return
|
|
11048
|
+
return bytes.toString("utf8");
|
|
10948
11049
|
}
|
|
10949
|
-
const decompressed =
|
|
10950
|
-
return
|
|
11050
|
+
const decompressed = await gunzipAsync(bytes, { maxOutputLength: MAX_SITEMAP_BYTES });
|
|
11051
|
+
return decompressed.toString("utf8");
|
|
10951
11052
|
}
|
|
10952
11053
|
async function fetchAndParseSitemap(sitemapUrl) {
|
|
10953
11054
|
const urls = /* @__PURE__ */ new Set();
|
|
@@ -10965,6 +11066,7 @@ async function fetchAndParseSitemap(sitemapUrl) {
|
|
|
10965
11066
|
async function parseSitemapRecursive(url, urls, visited, depth, isChild) {
|
|
10966
11067
|
if (depth > 3) return;
|
|
10967
11068
|
if (visited.has(url)) return;
|
|
11069
|
+
if (visited.size >= MAX_SITEMAPS) return;
|
|
10968
11070
|
visited.add(url);
|
|
10969
11071
|
let res;
|
|
10970
11072
|
try {
|
|
@@ -12156,7 +12258,7 @@ import crypto19 from "crypto";
|
|
|
12156
12258
|
import path5 from "path";
|
|
12157
12259
|
import { and as and12, eq as eq17, sql as sql6 } from "drizzle-orm";
|
|
12158
12260
|
var log14 = createLogger("CommonCrawlSync");
|
|
12159
|
-
var INSERT_CHUNK_SIZE =
|
|
12261
|
+
var INSERT_CHUNK_SIZE = 500;
|
|
12160
12262
|
function defaultDeps2() {
|
|
12161
12263
|
return {
|
|
12162
12264
|
downloadFile,
|
|
@@ -12449,6 +12551,7 @@ async function executeBacklinkExtract(db, runId, projectId, opts = {}) {
|
|
|
12449
12551
|
)
|
|
12450
12552
|
).run();
|
|
12451
12553
|
if (rows.length > 0) {
|
|
12554
|
+
const INSERT_CHUNK_SIZE2 = 500;
|
|
12452
12555
|
const values = rows.map((r) => ({
|
|
12453
12556
|
id: crypto20.randomUUID(),
|
|
12454
12557
|
projectId,
|
|
@@ -12460,7 +12563,9 @@ async function executeBacklinkExtract(db, runId, projectId, opts = {}) {
|
|
|
12460
12563
|
numHosts: r.numHosts,
|
|
12461
12564
|
createdAt: queriedAt
|
|
12462
12565
|
}));
|
|
12463
|
-
|
|
12566
|
+
for (let i = 0; i < values.length; i += INSERT_CHUNK_SIZE2) {
|
|
12567
|
+
tx.insert(backlinkDomains).values(values.slice(i, i + INSERT_CHUNK_SIZE2)).run();
|
|
12568
|
+
}
|
|
12464
12569
|
}
|
|
12465
12570
|
const summary2 = computeSummary(rows);
|
|
12466
12571
|
tx.insert(backlinkSummaries).values({
|
|
@@ -12505,6 +12610,16 @@ async function executeBacklinkExtract(db, runId, projectId, opts = {}) {
|
|
|
12505
12610
|
throw err;
|
|
12506
12611
|
}
|
|
12507
12612
|
}
|
|
12613
|
+
function createBacklinkExtractQueue(runExtract) {
|
|
12614
|
+
let tail = Promise.resolve();
|
|
12615
|
+
return {
|
|
12616
|
+
enqueue(runId, projectId, release2) {
|
|
12617
|
+
const result = tail.then(() => runExtract(runId, projectId, release2));
|
|
12618
|
+
tail = result.then(() => void 0, () => void 0);
|
|
12619
|
+
return result;
|
|
12620
|
+
}
|
|
12621
|
+
};
|
|
12622
|
+
}
|
|
12508
12623
|
function computeSummary(rows) {
|
|
12509
12624
|
return computeBacklinkSummaryMetrics(rows);
|
|
12510
12625
|
}
|
|
@@ -13265,11 +13380,21 @@ function classifySiteCrawlTemplateLinks(db, scope, pagesFetched, placementRulese
|
|
|
13265
13380
|
}
|
|
13266
13381
|
}
|
|
13267
13382
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
13383
|
+
const CHUNKS_PER_TX = 10;
|
|
13384
|
+
const pendingUpdates = [];
|
|
13268
13385
|
for (const group of edgeKeysByValue.values()) {
|
|
13269
13386
|
for (const chunk of chunked(group.edgeKeys)) {
|
|
13270
|
-
|
|
13387
|
+
pendingUpdates.push({ isTemplate: group.isTemplate, templateRatio: group.templateRatio, edgeKeys: chunk });
|
|
13271
13388
|
}
|
|
13272
13389
|
}
|
|
13390
|
+
for (let i = 0; i < pendingUpdates.length; i += CHUNKS_PER_TX) {
|
|
13391
|
+
const slice = pendingUpdates.slice(i, i + CHUNKS_PER_TX);
|
|
13392
|
+
db.transaction((tx) => {
|
|
13393
|
+
for (const update of slice) {
|
|
13394
|
+
tx.update(siteCrawlEdges).set({ isTemplate: update.isTemplate, templateRatio: update.templateRatio, updatedAt: now }).where(and15(scopeFilter, inArray8(siteCrawlEdges.edgeKey, update.edgeKeys))).run();
|
|
13395
|
+
}
|
|
13396
|
+
});
|
|
13397
|
+
}
|
|
13273
13398
|
return {
|
|
13274
13399
|
detection: templateLinkDetection({ placementAvailable, ubiquityAvailable, tally }),
|
|
13275
13400
|
templateEdgeCount,
|
|
@@ -18665,7 +18790,7 @@ ${lines.join("\n")}
|
|
|
18665
18790
|
try {
|
|
18666
18791
|
let agent;
|
|
18667
18792
|
try {
|
|
18668
|
-
const scope =
|
|
18793
|
+
const scope = AeroToolScopes.readOnly;
|
|
18669
18794
|
const profile = this.profiles.get(projectName) ?? AeroToolProfiles.default;
|
|
18670
18795
|
agent = await this.acquireForTurn(projectName, { toolScope: scope, toolProfile: profile });
|
|
18671
18796
|
} catch (err) {
|
|
@@ -21632,15 +21757,23 @@ function runtimePathIdentity(runtimePath) {
|
|
|
21632
21757
|
var DASHBOARD_SCRYPT_KEYLEN = 64;
|
|
21633
21758
|
var DASHBOARD_SCRYPT_COST = 1 << 15;
|
|
21634
21759
|
var DASHBOARD_SCRYPT_MAXMEM = 64 * 1024 * 1024;
|
|
21635
|
-
function
|
|
21760
|
+
function scryptAsync(password, salt, keylen, options) {
|
|
21761
|
+
return new Promise((resolve, reject) => {
|
|
21762
|
+
crypto30.scrypt(password, salt, keylen, options, (err, derivedKey) => {
|
|
21763
|
+
if (err) reject(err);
|
|
21764
|
+
else resolve(derivedKey);
|
|
21765
|
+
});
|
|
21766
|
+
});
|
|
21767
|
+
}
|
|
21768
|
+
async function hashDashboardPassword(password) {
|
|
21636
21769
|
const salt = crypto30.randomBytes(16);
|
|
21637
|
-
const derived =
|
|
21770
|
+
const derived = await scryptAsync(password, salt, DASHBOARD_SCRYPT_KEYLEN, {
|
|
21638
21771
|
N: DASHBOARD_SCRYPT_COST,
|
|
21639
21772
|
maxmem: DASHBOARD_SCRYPT_MAXMEM
|
|
21640
21773
|
});
|
|
21641
21774
|
return `scrypt$1$${salt.toString("base64")}$${derived.toString("base64")}`;
|
|
21642
21775
|
}
|
|
21643
|
-
function verifyDashboardPassword(password, storedHash) {
|
|
21776
|
+
async function verifyDashboardPassword(password, storedHash) {
|
|
21644
21777
|
if (storedHash.startsWith("scrypt$1$")) {
|
|
21645
21778
|
const parts = storedHash.split("$");
|
|
21646
21779
|
if (parts.length !== 4) return { ok: false, needsRehash: false };
|
|
@@ -21655,7 +21788,7 @@ function verifyDashboardPassword(password, storedHash) {
|
|
|
21655
21788
|
} catch {
|
|
21656
21789
|
return { ok: false, needsRehash: false };
|
|
21657
21790
|
}
|
|
21658
|
-
const derived =
|
|
21791
|
+
const derived = await scryptAsync(password, salt, expected.length, {
|
|
21659
21792
|
N: DASHBOARD_SCRYPT_COST,
|
|
21660
21793
|
maxmem: DASHBOARD_SCRYPT_MAXMEM
|
|
21661
21794
|
});
|
|
@@ -21958,6 +22091,7 @@ async function createServer(opts) {
|
|
|
21958
22091
|
genReqId: () => crypto30.randomUUID(),
|
|
21959
22092
|
trustProxy
|
|
21960
22093
|
});
|
|
22094
|
+
registerResponseCompression(app);
|
|
21961
22095
|
if (!ownsDefaultConfig) {
|
|
21962
22096
|
const releaseAnonymousIdWrites = holdAnonymousIdWrites();
|
|
21963
22097
|
app.addHook("onClose", async () => {
|
|
@@ -22043,7 +22177,6 @@ async function createServer(opts) {
|
|
|
22043
22177
|
// the default config.yaml, so only the server running from it asks.
|
|
22044
22178
|
...ownsDefaultConfig ? { onFirstActivation: () => maybeShowActivationNotice() } : {}
|
|
22045
22179
|
});
|
|
22046
|
-
jobRunner.recoverStaleRuns();
|
|
22047
22180
|
const seoRuntime = new SeoRuntime(opts.db, () => loadConfig(runtimeConfigPath).seo, () => {
|
|
22048
22181
|
const stat = fs6.statSync(runtimeConfigPath, { bigint: true });
|
|
22049
22182
|
return `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
|
|
@@ -23029,7 +23162,11 @@ async function createServer(opts) {
|
|
|
23029
23162
|
const err = serverApiKeyMissing();
|
|
23030
23163
|
return reply.status(err.statusCode).send(err.toJSON());
|
|
23031
23164
|
}
|
|
23032
|
-
const passwordHash = hashDashboardPassword(password);
|
|
23165
|
+
const passwordHash = await hashDashboardPassword(password);
|
|
23166
|
+
if (opts.config.dashboardPasswordHash) {
|
|
23167
|
+
const err = validationError("Dashboard password is already configured");
|
|
23168
|
+
return reply.status(err.statusCode).send(err.toJSON());
|
|
23169
|
+
}
|
|
23033
23170
|
opts.config.dashboardPasswordHash = passwordHash;
|
|
23034
23171
|
let sessionId;
|
|
23035
23172
|
try {
|
|
@@ -23104,6 +23241,13 @@ async function createServer(opts) {
|
|
|
23104
23241
|
setSessionCookie(reply, sessionId);
|
|
23105
23242
|
return reply.send({ authenticated: true });
|
|
23106
23243
|
});
|
|
23244
|
+
const LEGACY_LOGIN_MAX_FAILURES = 10;
|
|
23245
|
+
const LEGACY_LOGIN_WINDOW_MS = 15 * 6e4;
|
|
23246
|
+
const LEGACY_LOGIN_MAX_GLOBAL_INFLIGHT = 8;
|
|
23247
|
+
const LEGACY_LOGIN_MAX_CALLER_INFLIGHT = 2;
|
|
23248
|
+
const legacyLoginLimiter = new LoginAttemptLimiter(LEGACY_LOGIN_MAX_FAILURES, LEGACY_LOGIN_WINDOW_MS);
|
|
23249
|
+
const legacyLoginInflightByCaller = /* @__PURE__ */ new Map();
|
|
23250
|
+
let legacyLoginGlobalInflight = 0;
|
|
23107
23251
|
app.post(apiPrefix + "/session", legacySessionRouteOptions, async (request, reply) => {
|
|
23108
23252
|
if (namedAccountsInUse()) {
|
|
23109
23253
|
const err2 = forbidden(NAMED_ACCOUNTS_MESSAGE);
|
|
@@ -23121,21 +23265,47 @@ async function createServer(opts) {
|
|
|
23121
23265
|
);
|
|
23122
23266
|
return reply.status(err2.statusCode).send(err2.toJSON());
|
|
23123
23267
|
}
|
|
23124
|
-
const
|
|
23125
|
-
|
|
23126
|
-
|
|
23127
|
-
|
|
23268
|
+
const callerKey = resolveCallerKey(request, trustProxy !== false) ?? "unidentified";
|
|
23269
|
+
const nowMs = Date.now();
|
|
23270
|
+
if (legacyLoginLimiter.isBlocked(callerKey, nowMs)) {
|
|
23271
|
+
return reply.status(429).send({
|
|
23272
|
+
error: { code: "RATE_LIMITED", message: "Too many failed sign-in attempts. Wait before trying again." }
|
|
23273
|
+
});
|
|
23274
|
+
}
|
|
23275
|
+
const callerInflight = legacyLoginInflightByCaller.get(callerKey) ?? 0;
|
|
23276
|
+
if (legacyLoginGlobalInflight >= LEGACY_LOGIN_MAX_GLOBAL_INFLIGHT || callerInflight >= LEGACY_LOGIN_MAX_CALLER_INFLIGHT) {
|
|
23277
|
+
return reply.status(429).send({
|
|
23278
|
+
error: { code: "RATE_LIMITED", message: "Too many concurrent sign-in requests. Try again shortly." }
|
|
23279
|
+
});
|
|
23280
|
+
}
|
|
23281
|
+
legacyLoginGlobalInflight += 1;
|
|
23282
|
+
legacyLoginInflightByCaller.set(callerKey, callerInflight + 1);
|
|
23283
|
+
const storedHash = opts.config.dashboardPasswordHash;
|
|
23284
|
+
let verification;
|
|
23285
|
+
try {
|
|
23286
|
+
verification = await verifyDashboardPassword(
|
|
23287
|
+
password,
|
|
23288
|
+
storedHash
|
|
23289
|
+
);
|
|
23290
|
+
} finally {
|
|
23291
|
+
legacyLoginGlobalInflight -= 1;
|
|
23292
|
+
const remaining = (legacyLoginInflightByCaller.get(callerKey) ?? 1) - 1;
|
|
23293
|
+
if (remaining <= 0) legacyLoginInflightByCaller.delete(callerKey);
|
|
23294
|
+
else legacyLoginInflightByCaller.set(callerKey, remaining);
|
|
23295
|
+
}
|
|
23128
23296
|
const onDisk = verification.ok && verification.needsRehash && persistedConfigPath !== void 0 ? loadConfigRaw(persistedConfigPath) : null;
|
|
23129
|
-
if (!verification.ok || onDisk && onDisk.dashboardPasswordHash !==
|
|
23297
|
+
if (!verification.ok || onDisk && onDisk.dashboardPasswordHash !== storedHash) {
|
|
23298
|
+
legacyLoginLimiter.recordFailure(callerKey, Date.now());
|
|
23130
23299
|
return reply.status(401).send({
|
|
23131
23300
|
error: { code: "AUTH_INVALID", message: "Incorrect password" }
|
|
23132
23301
|
});
|
|
23133
23302
|
}
|
|
23303
|
+
legacyLoginLimiter.clear(callerKey);
|
|
23134
23304
|
if (verification.needsRehash) {
|
|
23135
23305
|
if (persistedConfigPath !== void 0 && fs6.existsSync(persistedConfigPath) && (!onDisk || typeof onDisk !== "object" || Array.isArray(onDisk) || !onDisk.apiUrl || !onDisk.database || !onDisk.apiKey)) {
|
|
23136
23306
|
throw new Error("Cannot migrate dashboard password: config.yaml is unreadable or invalid");
|
|
23137
23307
|
}
|
|
23138
|
-
const migratedHash = hashDashboardPassword(password);
|
|
23308
|
+
const migratedHash = await hashDashboardPassword(password);
|
|
23139
23309
|
if (persistedConfigPath !== void 0) {
|
|
23140
23310
|
saveConfig({ ...onDisk ?? opts.config, dashboardPasswordHash: migratedHash }, persistedConfigPath);
|
|
23141
23311
|
}
|
|
@@ -23148,11 +23318,19 @@ async function createServer(opts) {
|
|
|
23148
23318
|
return reply.send({ authenticated: true });
|
|
23149
23319
|
}
|
|
23150
23320
|
if (apiKey) {
|
|
23321
|
+
const callerKey = resolveCallerKey(request, trustProxy !== false) ?? "unidentified";
|
|
23322
|
+
if (legacyLoginLimiter.isBlocked(callerKey, Date.now())) {
|
|
23323
|
+
return reply.status(429).send({
|
|
23324
|
+
error: { code: "RATE_LIMITED", message: "Too many failed sign-in attempts. Wait before trying again." }
|
|
23325
|
+
});
|
|
23326
|
+
}
|
|
23151
23327
|
const key = opts.db.select().from(apiKeys).where(eq40(apiKeys.keyHash, hashApiKey(apiKey))).get();
|
|
23152
23328
|
if (!key || key.revokedAt) {
|
|
23329
|
+
legacyLoginLimiter.recordFailure(callerKey, Date.now());
|
|
23153
23330
|
const err2 = authInvalid();
|
|
23154
23331
|
return reply.status(err2.statusCode).send(err2.toJSON());
|
|
23155
23332
|
}
|
|
23333
|
+
legacyLoginLimiter.clear(callerKey);
|
|
23156
23334
|
opts.db.update(apiKeys).set({ lastUsedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq40(apiKeys.id, key.id)).run();
|
|
23157
23335
|
setSessionCookie(reply, createSession(key));
|
|
23158
23336
|
return reply.send({ authenticated: true });
|
|
@@ -23161,6 +23339,14 @@ async function createServer(opts) {
|
|
|
23161
23339
|
return reply.status(err.statusCode).send(err.toJSON());
|
|
23162
23340
|
});
|
|
23163
23341
|
app.delete(apiPrefix + "/session", legacySessionRouteOptions, async (request, reply) => {
|
|
23342
|
+
try {
|
|
23343
|
+
assertCookieWriteOrigin(request);
|
|
23344
|
+
} catch (err) {
|
|
23345
|
+
if (err instanceof AppError) {
|
|
23346
|
+
return reply.status(err.statusCode).send(err.toJSON());
|
|
23347
|
+
}
|
|
23348
|
+
throw err;
|
|
23349
|
+
}
|
|
23164
23350
|
const sessionId = parseCookieHeader(request.headers.cookie)[SESSION_COOKIE_NAME];
|
|
23165
23351
|
clearSession(sessionId);
|
|
23166
23352
|
reply.header(
|
|
@@ -23408,6 +23594,9 @@ async function createServer(opts) {
|
|
|
23408
23594
|
},
|
|
23409
23595
|
connectionTests
|
|
23410
23596
|
});
|
|
23597
|
+
const backlinkExtractQueue = createBacklinkExtractQueue(
|
|
23598
|
+
(runId, projectId, release2) => executeBacklinkExtract(opts.db, runId, projectId, { release: release2 })
|
|
23599
|
+
);
|
|
23411
23600
|
await app.register(apiRoutes, {
|
|
23412
23601
|
// Outcome telemetry reported from route code (`app.emitOutcome`).
|
|
23413
23602
|
onOutcome: handleRouteOutcome,
|
|
@@ -23653,9 +23842,7 @@ async function createServer(opts) {
|
|
|
23653
23842
|
trigger: RunTriggers.scheduled,
|
|
23654
23843
|
createdAt: now
|
|
23655
23844
|
}).run();
|
|
23656
|
-
|
|
23657
|
-
release: r
|
|
23658
|
-
}).catch((err) => {
|
|
23845
|
+
backlinkExtractQueue.enqueue(runId, projectId, r).catch((err) => {
|
|
23659
23846
|
app.log.error(
|
|
23660
23847
|
{ runId, projectId, err },
|
|
23661
23848
|
"Auto backlink extract failed"
|
|
@@ -23668,7 +23855,7 @@ async function createServer(opts) {
|
|
|
23668
23855
|
});
|
|
23669
23856
|
},
|
|
23670
23857
|
onBacklinkExtractRequested: (runId, projectId, release2) => {
|
|
23671
|
-
|
|
23858
|
+
backlinkExtractQueue.enqueue(runId, projectId, release2).catch(
|
|
23672
23859
|
(err) => {
|
|
23673
23860
|
app.log.error({ runId, err }, "Backlink extract failed");
|
|
23674
23861
|
}
|
|
@@ -24248,6 +24435,7 @@ async function createServer(opts) {
|
|
|
24248
24435
|
app.addHook("onListen", () => {
|
|
24249
24436
|
if (runtimeStartupSettled) return;
|
|
24250
24437
|
try {
|
|
24438
|
+
jobRunner.recoverStaleRuns();
|
|
24251
24439
|
seoRuntime.start();
|
|
24252
24440
|
scheduler.start();
|
|
24253
24441
|
stopSiteLiveness = startSiteLivenessLoop({
|
|
@@ -24303,6 +24491,7 @@ async function createServer(opts) {
|
|
|
24303
24491
|
stopInstallState?.();
|
|
24304
24492
|
stopInstallState = null;
|
|
24305
24493
|
scheduler.stop();
|
|
24494
|
+
await closeAllCdpConnections();
|
|
24306
24495
|
});
|
|
24307
24496
|
return app;
|
|
24308
24497
|
}
|