@canonry/canonry 7.52.0 → 7.53.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/canonry/references/canonry-cli.md +11 -1
- package/assets/assets/{AccessControls-CteIuEGI.js → AccessControls-B-5YUuLE.js} +1 -1
- package/assets/assets/{AuditHistoryPanel-DqJGiLsf.js → AuditHistoryPanel-BkCUPvPv.js} +1 -1
- package/assets/assets/{BacklinksPage-DotWEPQt.js → BacklinksPage-BMgHZKuw.js} +1 -1
- package/assets/assets/{HistoryPage-aOd198dT.js → HistoryPage-D2DOk7ms.js} +1 -1
- package/assets/assets/MeasurementPropertyPage-Bwv8nKS7.js +4 -0
- package/assets/assets/ProjectPage-CsJfGPx3.js +7 -0
- package/assets/assets/RunsPage-DSHDuj9b.js +1 -0
- package/assets/assets/SettingsPage-BDRdWk5X.js +1 -0
- package/assets/assets/SiteHealthSection-DV06NTxC.js +2 -0
- package/assets/assets/TrafficPage-CBMMwRfw.js +40 -0
- package/assets/assets/{TrafficSourceDetailPage-BPtjnF9s.js → TrafficSourceDetailPage-Czpt0S7j.js} +1 -1
- package/assets/assets/card-CVejjbhs.js +60 -0
- package/assets/assets/{extract-error-message-DKQJJlZ-.js → extract-error-message-Co6zPipR.js} +1 -1
- package/assets/assets/{format-helpers-BWnMmkiO.js → format-helpers-B_2jkVGI.js} +1 -1
- package/assets/assets/index-BnS2Vuv0.js +40 -0
- package/assets/assets/index-DgS5TTSb.css +1 -0
- package/assets/assets/{query-client-vB35tVTz.js → query-client-BKJLgjJd.js} +1 -1
- package/assets/assets/react-query-ltP1RErY.js +1 -0
- package/assets/assets/{react-sigma_core.esm.min-hGyOC4V_.js → react-sigma_core.esm.min-Bjux3j_1.js} +1 -1
- package/assets/assets/service-CDsqgNrS.js +1 -0
- package/assets/index.html +8 -7
- package/dist/{ads-MREK2AGL.js → ads-S4S74OXM.js} +3 -3
- package/dist/{agent-4RUZ3MC4.js → agent-JZWKCI5V.js} +7 -7
- package/dist/{agent-ask-YLTYBEYH.js → agent-ask-N2DG5ZLZ.js} +3 -3
- package/dist/{agent-conversations-QA6IKDGR.js → agent-conversations-7UDNE7YI.js} +3 -3
- package/dist/{agent-memory-MEQAJOB3.js → agent-memory-I74OWTU7.js} +3 -3
- package/dist/{agent-providers-AXYPDJHL.js → agent-providers-MEMCZPGE.js} +3 -3
- package/dist/{agent-transcript-SMNQNYCD.js → agent-transcript-Z7VTL7PY.js} +3 -3
- package/dist/{analytics-4OR64IGV.js → analytics-4NUSNTKT.js} +3 -3
- package/dist/{apply-CQXCFXAH.js → apply-OZKQK3YF.js} +3 -3
- package/dist/{backfill-TMXCNVOB.js → backfill-PLY2NOOY.js} +9 -9
- package/dist/{backlinks-6KFAQGYV.js → backlinks-2CMRJFWO.js} +3 -3
- package/dist/{bing-HFCACTAC.js → bing-RD3DDESD.js} +3 -3
- package/dist/{bootstrap-SQVQXOJC.js → bootstrap-JOYV4SWM.js} +9 -9
- package/dist/{cdp-IACL7EXU.js → cdp-LUGL3CT6.js} +7 -7
- package/dist/{chunk-EGIZNSDA.js → chunk-23UZNTF4.js} +1 -1
- package/dist/{chunk-BYOK6Z4F.js → chunk-2EYBZYDG.js} +2 -2
- package/dist/{chunk-O4RMPA6H.js → chunk-2GAXZAQJ.js} +107 -11
- package/dist/{chunk-BU3VAG5J.js → chunk-2HWY4NRQ.js} +3 -3
- package/dist/{chunk-RVUCY4ZV.js → chunk-2XDGFHPM.js} +6 -4
- package/dist/{chunk-GNKOBKPW.js → chunk-3DO3CS7Y.js} +4 -4
- package/dist/{chunk-SNFBJKAW.js → chunk-6VSKBVB3.js} +3 -3
- package/dist/{chunk-7244X3K6.js → chunk-6ZCZRZ66.js} +2 -2
- package/dist/{chunk-FC4XND45.js → chunk-BGZL5RCP.js} +1 -1
- package/dist/{chunk-MKAC7HKH.js → chunk-BH274VEO.js} +3 -3
- package/dist/{chunk-LK2BG6EX.js → chunk-BQT7VLGM.js} +11 -1
- package/dist/{chunk-6BPZHNDC.js → chunk-C5GCRQ66.js} +2 -2
- package/dist/{chunk-QLPLENDT.js → chunk-DFQHGWPB.js} +1 -1
- package/dist/{chunk-IIOEAJTV.js → chunk-F55ER5RQ.js} +3 -3
- package/dist/{chunk-DSNSD5J3.js → chunk-IWQGZQHE.js} +19 -9
- package/dist/{chunk-YSEC6TIB.js → chunk-JZARXJV6.js} +821 -227
- package/dist/{chunk-MJNUSPO4.js → chunk-LGU3O5YP.js} +2 -2
- package/dist/{chunk-BBOHY2DQ.js → chunk-LYCYSM6O.js} +1 -1
- package/dist/chunk-N3WQHLDI.js +1199 -0
- package/dist/{chunk-AWCWIQAU.js → chunk-N6MS4VG2.js} +226 -5
- package/dist/{chunk-TALC5DX5.js → chunk-NKSASP4U.js} +1 -1
- package/dist/{chunk-V5D4XNWV.js → chunk-O3OTW7F4.js} +39 -2
- package/dist/{chunk-K5I45PZI.js → chunk-P4SXRRB4.js} +307 -194
- package/dist/{chunk-ILDT4LPB.js → chunk-QARV5HVI.js} +26 -240
- package/dist/{chunk-O77IBNVO.js → chunk-QNU7IIO7.js} +326 -324
- package/dist/{chunk-I6KNMZ77.js → chunk-QXJ356KK.js} +4 -4
- package/dist/{chunk-JY3RLZGB.js → chunk-RVBGFWJ3.js} +1 -1
- package/dist/{chunk-7XE2IRBG.js → chunk-SZG7S7TE.js} +1 -1
- package/dist/{chunk-KXAOMTXN.js → chunk-U7JJKXLA.js} +5 -5
- package/dist/{chunk-Y4GK7GCV.js → chunk-VEH4YLWR.js} +1 -1
- package/dist/{chunk-R2J4SNKF.js → chunk-WNXKW3NS.js} +1 -1
- package/dist/{chunk-HEGXGCGL.js → chunk-XTIP5WSA.js} +3 -3
- package/dist/{chunk-5N6245R7.js → chunk-ZXH5IFIA.js} +4 -4
- package/dist/{citations-NSBBWRZ4.js → citations-GMLBTNLW.js} +3 -3
- package/dist/{cli-catalog-OFWJMNMD.js → cli-catalog-WKUCQEWA.js} +3 -3
- package/dist/{cli-commands-WVBL337U.js → cli-commands-YCHQWUNK.js} +7 -7
- package/dist/cli.js +13 -13
- package/dist/{competitor-V4OHORBC.js → competitor-QNPVJFEI.js} +3 -3
- package/dist/{content-RUXRI5IC.js → content-NFTC74HD.js} +3 -3
- package/dist/{dashboard-JXB2YAQJ.js → dashboard-TMUQT5H5.js} +6 -6
- package/dist/{demo-55ZNUOXU.js → demo-O5SPVLZZ.js} +1 -1
- package/dist/{demo-server-XO7PHM4I.js → demo-server-WKZ53RGK.js} +11 -11
- package/dist/{discover-JJQ564HS.js → discover-LTTO7KHN.js} +3 -3
- package/dist/{discover-eval-KLEKZ6U4.js → discover-eval-QRDNMDUE.js} +3 -3
- package/dist/{doctor-JAMQZCMZ.js → doctor-SFL5FOW4.js} +3 -3
- package/dist/{evidence-YRSB7GFE.js → evidence-J6WZ767P.js} +3 -3
- package/dist/{export-cmd-MHML4OYU.js → export-cmd-D3JDTBDV.js} +3 -3
- package/dist/{ga-LSXPE2MN.js → ga-N56LXQUN.js} +3 -3
- package/dist/{gbp-RMKMLOC7.js → gbp-7WVJYWDR.js} +3 -3
- package/dist/{google-JQ4T6JTQ.js → google-YLRVXYVJ.js} +4 -4
- package/dist/{google-marketing-J6SEODYC.js → google-marketing-4DGX3RBB.js} +1 -1
- package/dist/{health-cmd-MV2JM2C3.js → health-cmd-PK3BASF6.js} +3 -3
- package/dist/{history-SRRH7A2E.js → history-UWTEZ626.js} +3 -3
- package/dist/index.d.ts +40 -7
- package/dist/index.js +23 -23
- package/dist/{init-ZJZFUERV.js → init-RBI2IOBY.js} +11 -11
- package/dist/{insights-PMMGNWZH.js → insights-ZUC5XHFD.js} +3 -3
- package/dist/intelligence-service-JXXB43RB.js +15 -0
- package/dist/{keys-TS7NZANS.js → keys-NOG3M76V.js} +3 -3
- package/dist/{keyword-VNCKDUGC.js → keyword-HD57L76I.js} +3 -3
- package/dist/{logs-VH3WOTZJ.js → logs-VAB7ITBS.js} +3 -3
- package/dist/{mcp-DG2RROB3.js → mcp-HYHIL5FB.js} +2 -2
- package/dist/mcp.js +9 -9
- package/dist/{measurement-plan-4T35TUGG.js → measurement-plan-GEHOHCH3.js} +5 -5
- package/dist/{notify-BWHUSKL7.js → notify-VQ2ZDGN4.js} +3 -3
- package/dist/{organic-evidence-QX4SXXJP.js → organic-evidence-6TX627YW.js} +3 -3
- package/dist/{overview-7IHUTKUV.js → overview-XBO7WYAV.js} +4 -4
- package/dist/{project-JXLSWDE2.js → project-DR6744WZ.js} +3 -3
- package/dist/{query-S75EL25H.js → query-OGVTCPG5.js} +3 -3
- package/dist/{research-KFTV3IP4.js → research-B2TGKSMC.js} +3 -3
- package/dist/{results-export-GTKVBU34.js → results-export-K7PAYPWQ.js} +3 -3
- package/dist/{run-26HDIRHF.js → run-Y6LUMCVL.js} +4 -4
- package/dist/{schedule-N6G4SVHQ.js → schedule-PNAUJ5FX.js} +3 -3
- package/dist/{search-MI32EPYM.js → search-PMVOGL4U.js} +3 -3
- package/dist/{serve-XLGE42AG.js → serve-PQHXSS5T.js} +24 -24
- package/dist/{session-W5DXWIYM.js → session-S5NDMMKF.js} +16 -15
- package/dist/{settings-T7WI2UVE.js → settings-AL7E7QUK.js} +3 -3
- package/dist/{skills-F3WPKPTK.js → skills-GQOOTDR7.js} +2 -2
- package/dist/{snapshot-PD3EAVEX.js → snapshot-W3FXRTZM.js} +3 -3
- package/dist/{src-XDUXMJC3.js → src-WZLTQFCH.js} +2 -2
- package/dist/{status-PUH7JFZ4.js → status-MBJVN4W5.js} +4 -4
- package/dist/{technical-aeo-AUFWWJIP.js → technical-aeo-Y4RFST72.js} +3 -3
- package/dist/{telemetry-XBYT7G2K.js → telemetry-VK6F5QSZ.js} +4 -4
- package/dist/{tools-GVHIRWSN.js → tools-W3AQY5TY.js} +11 -11
- package/dist/{traffic-B3HW2ZWG.js → traffic-ER4I6V3B.js} +5 -5
- package/dist/{users-M5HNQZYI.js → users-KZK2OF4L.js} +3 -3
- package/dist/{visibility-stats-Y7GJKMHN.js → visibility-stats-CR7BUG5G.js} +3 -3
- package/dist/{wordpress-GCIURYPN.js → wordpress-DG5JUCAC.js} +3 -3
- package/package.json +2 -1
- package/assets/assets/MeasurementPropertyPage-CuaKVK8x.js +0 -4
- package/assets/assets/ProjectPage-O9oufMgi.js +0 -8
- package/assets/assets/RunsPage-DIXMrc-N.js +0 -1
- package/assets/assets/SettingsPage-BuGb6AGa.js +0 -1
- package/assets/assets/SiteHealthSection-CweaKjCo.js +0 -2
- package/assets/assets/TrafficPage-B7MaQalp.js +0 -40
- package/assets/assets/card-DoV-8Txo.js +0 -60
- package/assets/assets/index-CsPsaUr7.css +0 -1
- package/assets/assets/index-Z63c4PeO.js +0 -39
- package/assets/assets/react-query-BI0567qs.js +0 -1
- package/assets/assets/service-c4YvpVKX.js +0 -1
- package/dist/chunk-OFL4PTYU.js +0 -644
- package/dist/intelligence-service-KCSU6ZUJ.js +0 -15
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AGENT_PROVIDERS,
|
|
3
2
|
AeroLlmUsageFeatures,
|
|
4
3
|
aeroTurnStatus,
|
|
5
4
|
aeroTurnUsage,
|
|
6
5
|
aeroViewPrompt,
|
|
7
|
-
agentProviderApiKeyEnvVar,
|
|
8
|
-
agentProvidersByPriority,
|
|
9
6
|
buildAeroViewTool,
|
|
10
|
-
buildAgentProvidersResponse,
|
|
11
7
|
buildApiKeyResolver,
|
|
12
8
|
buildSkillDocTools,
|
|
13
|
-
coerceAgentProvider,
|
|
14
|
-
completeOnce,
|
|
15
9
|
configureAeroRuntime,
|
|
16
10
|
createAeroSession,
|
|
17
11
|
describeAgentPin,
|
|
18
12
|
detectAgentProvider,
|
|
19
|
-
getAgentProvider,
|
|
20
|
-
isAgentModelAvailable,
|
|
21
13
|
isRunFailureMessage,
|
|
22
14
|
isSystemMessage,
|
|
23
15
|
loadAeroSystemPrompt,
|
|
@@ -28,19 +20,17 @@ import {
|
|
|
28
20
|
resolveAgentEnabled,
|
|
29
21
|
resolveAgentProactiveEnabled,
|
|
30
22
|
resolveAgentReasoning,
|
|
31
|
-
resolveApiKeyFor,
|
|
32
23
|
resolveConfiguredAgentProvider,
|
|
33
|
-
resolveModelForCapability,
|
|
34
24
|
resolveSessionProviderAndModel,
|
|
35
25
|
setAeroSystemPrompt
|
|
36
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-QARV5HVI.js";
|
|
37
27
|
import {
|
|
38
28
|
AeroToolProfiles,
|
|
39
29
|
AeroToolScopes,
|
|
40
30
|
buildAeroStateTools,
|
|
41
31
|
isAeroToolProfile,
|
|
42
32
|
truncateToolResult
|
|
43
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-ZXH5IFIA.js";
|
|
44
34
|
import {
|
|
45
35
|
getGoogleAuthConfig,
|
|
46
36
|
getGoogleConnection,
|
|
@@ -59,7 +49,7 @@ import {
|
|
|
59
49
|
removeCloudflareTrafficConnection,
|
|
60
50
|
removeCloudflareTrafficConnectionBySourceId,
|
|
61
51
|
upsertCloudflareTrafficConnection
|
|
62
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-WNXKW3NS.js";
|
|
63
53
|
import {
|
|
64
54
|
claudeAdapter,
|
|
65
55
|
embedQueries,
|
|
@@ -68,8 +58,9 @@ import {
|
|
|
68
58
|
geminiAdapter,
|
|
69
59
|
museAdapter,
|
|
70
60
|
openaiAdapter,
|
|
61
|
+
openrouterAdapter,
|
|
71
62
|
perplexityAdapter
|
|
72
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-N6MS4VG2.js";
|
|
73
64
|
import {
|
|
74
65
|
classifyUsageSurface,
|
|
75
66
|
createApiUsageTelemetry,
|
|
@@ -81,7 +72,7 @@ import {
|
|
|
81
72
|
startOutcomeTimer,
|
|
82
73
|
trackFeatureCompleted,
|
|
83
74
|
trackInstallState
|
|
84
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-QXJ356KK.js";
|
|
85
76
|
import {
|
|
86
77
|
isLoopbackBindHost
|
|
87
78
|
} from "./chunk-TSENU4GG.js";
|
|
@@ -89,7 +80,7 @@ import {
|
|
|
89
80
|
isApiProviderRegistrable,
|
|
90
81
|
isCdpProviderRegistrable,
|
|
91
82
|
registeredProviderNames
|
|
92
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-RVBGFWJ3.js";
|
|
93
84
|
import {
|
|
94
85
|
checkLatestVersionForServer,
|
|
95
86
|
getOrCreateAnonymousId,
|
|
@@ -100,46 +91,62 @@ import {
|
|
|
100
91
|
recordDashboardEvent,
|
|
101
92
|
setTelemetryPreference,
|
|
102
93
|
trackEvent
|
|
103
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-6ZCZRZ66.js";
|
|
104
95
|
import {
|
|
105
96
|
createCanonryMcpServer
|
|
106
|
-
} from "./chunk-
|
|
97
|
+
} from "./chunk-6VSKBVB3.js";
|
|
107
98
|
import {
|
|
108
99
|
CANONRY_MCP_TIERS,
|
|
109
100
|
CANONRY_MCP_TOOLKIT_NAMES
|
|
110
101
|
} from "./chunk-4MJYGB56.js";
|
|
111
102
|
import {
|
|
112
103
|
ApiClient
|
|
113
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-O3OTW7F4.js";
|
|
114
105
|
import {
|
|
106
|
+
AGENT_PROVIDERS,
|
|
115
107
|
adapterSupportsBatch,
|
|
108
|
+
aeroModels,
|
|
109
|
+
agentProviderApiKeyEnvVar,
|
|
110
|
+
agentProvidersByPriority,
|
|
116
111
|
batchEligibleProviderNames,
|
|
112
|
+
buildAgentProvidersResponse,
|
|
113
|
+
coerceAgentProvider,
|
|
114
|
+
completeOnce,
|
|
117
115
|
dashboardManagedRunKindsSchema,
|
|
116
|
+
getAgentProvider,
|
|
118
117
|
getConfigPath,
|
|
118
|
+
getSharedProviderExecutionGate,
|
|
119
|
+
isAgentModelAvailable,
|
|
120
|
+
isAgentModelUnchecked,
|
|
119
121
|
loadConfig,
|
|
120
122
|
loadConfigRaw,
|
|
123
|
+
openRouterModels,
|
|
121
124
|
providerConfigFromEntry,
|
|
122
125
|
providersWithUnsupportedBatch,
|
|
126
|
+
refreshAgentModels,
|
|
127
|
+
resolveApiKeyFor,
|
|
128
|
+
resolveModelForCapability,
|
|
123
129
|
resolveOperatorApiKeyIds,
|
|
124
130
|
resolveSentimentInstallConfig,
|
|
125
131
|
saveConfig,
|
|
126
132
|
saveConfigPatch,
|
|
127
|
-
sentimentInstallReadiness
|
|
128
|
-
|
|
133
|
+
sentimentInstallReadiness,
|
|
134
|
+
updateSharedProviderExecutionGate
|
|
135
|
+
} from "./chunk-N3WQHLDI.js";
|
|
129
136
|
import {
|
|
130
137
|
getBundledSkillSnapshots
|
|
131
|
-
} from "./chunk-
|
|
138
|
+
} from "./chunk-NKSASP4U.js";
|
|
132
139
|
import {
|
|
133
140
|
computeFactorAverages,
|
|
134
141
|
deleteSiteCrawlGraphLayout,
|
|
135
142
|
persistSiteCrawlGraphLayout,
|
|
136
143
|
prepareSiteCrawlGraphLayout,
|
|
137
144
|
recordedSharePct
|
|
138
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-2EYBZYDG.js";
|
|
139
146
|
import {
|
|
140
147
|
CanonryMcpToolNames,
|
|
141
148
|
canonryMcpTools
|
|
142
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-2XDGFHPM.js";
|
|
143
150
|
import {
|
|
144
151
|
PACKAGE_VERSION
|
|
145
152
|
} from "./chunk-AOJU5LKX.js";
|
|
@@ -151,11 +158,11 @@ import {
|
|
|
151
158
|
addLogListener,
|
|
152
159
|
createFastifyLogger,
|
|
153
160
|
createLogger
|
|
154
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-U7JJKXLA.js";
|
|
155
162
|
import {
|
|
156
163
|
computeCitedCompetitorDomains,
|
|
157
164
|
determineCitationState
|
|
158
|
-
} from "./chunk-
|
|
165
|
+
} from "./chunk-BGZL5RCP.js";
|
|
159
166
|
import {
|
|
160
167
|
BingApiError,
|
|
161
168
|
CC_CACHE_DIR,
|
|
@@ -271,7 +278,7 @@ import {
|
|
|
271
278
|
webhookResponseReason,
|
|
272
279
|
webhookTargetRefusalReason,
|
|
273
280
|
writeAuditLog
|
|
274
|
-
} from "./chunk-
|
|
281
|
+
} from "./chunk-JZARXJV6.js";
|
|
275
282
|
import {
|
|
276
283
|
OperationalLogStore,
|
|
277
284
|
SentimentIdempotencyConflict,
|
|
@@ -353,7 +360,7 @@ import {
|
|
|
353
360
|
siteLivenessState,
|
|
354
361
|
trafficSources,
|
|
355
362
|
usageCounters
|
|
356
|
-
} from "./chunk-
|
|
363
|
+
} from "./chunk-BH274VEO.js";
|
|
357
364
|
import {
|
|
358
365
|
AGENT_MEMORY_VALUE_MAX_BYTES,
|
|
359
366
|
AI_ENGINE_DOMAINS,
|
|
@@ -385,6 +392,7 @@ import {
|
|
|
385
392
|
GtmSnapshotKinds,
|
|
386
393
|
INTEGRATION_NAMES,
|
|
387
394
|
IntegrationNames,
|
|
395
|
+
LlmCapabilities,
|
|
388
396
|
MEASUREMENT_CHANGES_NOISE_ANSWERS,
|
|
389
397
|
MEASUREMENT_PLAN_V2_SCHEMA_VERSION,
|
|
390
398
|
MemorySources,
|
|
@@ -411,6 +419,9 @@ import {
|
|
|
411
419
|
RunKinds,
|
|
412
420
|
RunStatuses,
|
|
413
421
|
RunTriggers,
|
|
422
|
+
SENTIMENT_MODEL,
|
|
423
|
+
SENTIMENT_OPENROUTER_MODEL,
|
|
424
|
+
SENTIMENT_OPENROUTER_SERVED_MODEL,
|
|
414
425
|
SITE_AUDIT_DEFAULT_PAGE_LIMIT,
|
|
415
426
|
SITE_AUDIT_MAX_EDGE_LIMIT,
|
|
416
427
|
SITE_AUDIT_MAX_PAGE_LIMIT,
|
|
@@ -506,10 +517,12 @@ import {
|
|
|
506
517
|
inclusiveDayCount,
|
|
507
518
|
isBrowserProvider,
|
|
508
519
|
isNegativeReviewRating,
|
|
520
|
+
isOpenRouterRoute,
|
|
509
521
|
isReadOnlyKey,
|
|
510
522
|
isRetryableHttpError,
|
|
511
523
|
isSearchLocationIgnored,
|
|
512
524
|
isSelfLink,
|
|
525
|
+
isSweepProvider,
|
|
513
526
|
isVertexGroundingRedirect,
|
|
514
527
|
mapWithConcurrency,
|
|
515
528
|
matcherMatchesText,
|
|
@@ -528,11 +541,13 @@ import {
|
|
|
528
541
|
notificationEventSchema,
|
|
529
542
|
observeTemplateLinkDetection,
|
|
530
543
|
observeTemplateLinkEdges,
|
|
544
|
+
openRouterRouteModel,
|
|
531
545
|
operationInProgress,
|
|
532
546
|
parseMeasurementRunManifestV1,
|
|
533
547
|
parseOriginList,
|
|
534
548
|
parseRunError,
|
|
535
549
|
percentOf,
|
|
550
|
+
providerConnectionName,
|
|
536
551
|
providerError,
|
|
537
552
|
providerSupportsLocationContext,
|
|
538
553
|
quotaExceeded,
|
|
@@ -545,6 +560,7 @@ import {
|
|
|
545
560
|
retryAfterDelayMs,
|
|
546
561
|
sentimentClassifierInputSchema,
|
|
547
562
|
sentimentClassifierOutputSchema,
|
|
563
|
+
sentimentEvaluatorProvider,
|
|
548
564
|
sentimentSelectionSchema,
|
|
549
565
|
serializeForInlineScript,
|
|
550
566
|
serializeRunError,
|
|
@@ -566,7 +582,7 @@ import {
|
|
|
566
582
|
winnabilityClassLabel,
|
|
567
583
|
withRetry,
|
|
568
584
|
withSkippedProviders
|
|
569
|
-
} from "./chunk-
|
|
585
|
+
} from "./chunk-2GAXZAQJ.js";
|
|
570
586
|
|
|
571
587
|
// src/google-marketing-runtime.ts
|
|
572
588
|
import crypto2 from "crypto";
|
|
@@ -958,10 +974,10 @@ function findRequestId(value, depth = 0) {
|
|
|
958
974
|
}
|
|
959
975
|
return void 0;
|
|
960
976
|
}
|
|
961
|
-
const
|
|
962
|
-
const direct = safeRequestId(
|
|
977
|
+
const record = value;
|
|
978
|
+
const direct = safeRequestId(record.requestId) ?? safeRequestId(record.request_id);
|
|
963
979
|
if (direct) return direct;
|
|
964
|
-
for (const nested of Object.values(
|
|
980
|
+
for (const nested of Object.values(record)) {
|
|
965
981
|
const found = findRequestId(nested, depth + 1);
|
|
966
982
|
if (found) return found;
|
|
967
983
|
}
|
|
@@ -3263,11 +3279,9 @@ import { createHash } from "crypto";
|
|
|
3263
3279
|
|
|
3264
3280
|
// ../integration-typesafe/src/client.ts
|
|
3265
3281
|
var TYPESAFE_URL = "https://api.typesafe.ai/v1/systemone";
|
|
3266
|
-
|
|
3267
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
3268
|
-
}
|
|
3282
|
+
var JEV_MODEL = SENTIMENT_MODEL;
|
|
3269
3283
|
function usageFrom(value) {
|
|
3270
|
-
const usage =
|
|
3284
|
+
const usage = asRecord(asRecord(value)?.usage);
|
|
3271
3285
|
const input = usage?.input_tokens;
|
|
3272
3286
|
const output = usage?.output_tokens;
|
|
3273
3287
|
if (typeof input === "number" && Number.isSafeInteger(input) && input >= 0 && typeof output === "number" && Number.isSafeInteger(output) && output >= 0) {
|
|
@@ -3280,6 +3294,7 @@ function failure(code, message, retryable = false, retryAfterMs = null, usage =
|
|
|
3280
3294
|
}
|
|
3281
3295
|
async function fetchOnce2(request, options) {
|
|
3282
3296
|
if (options.signal?.aborted) return failure("canceled", "Classification was canceled before dispatch.");
|
|
3297
|
+
if (request.model !== JEV_MODEL) return failure("model-mismatch", "The direct TypeSafe evaluator requires its pinned model.");
|
|
3283
3298
|
if (!options.apiKey.trim()) return failure("credential-missing", "TypeSafe credentials are unavailable.");
|
|
3284
3299
|
const timeoutMs = options.timeoutMs ?? 3e4;
|
|
3285
3300
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0 || timeoutMs > 12e4) {
|
|
@@ -3315,12 +3330,12 @@ async function fetchOnce2(request, options) {
|
|
|
3315
3330
|
const code = response.status === 401 || response.status === 403 ? "provider-authorization" : response.status === 413 ? "provider-context-limit" : response.status === 429 ? "provider-rate-limit" : retryable ? "provider-unavailable" : "provider-rejected";
|
|
3316
3331
|
return failure(code, `TypeSafe returned HTTP ${response.status}.`, retryable, retryAfterDelayMs(statusError), usage);
|
|
3317
3332
|
}
|
|
3318
|
-
const parsed =
|
|
3333
|
+
const parsed = asRecord(body);
|
|
3319
3334
|
const model = typeof parsed?.model === "string" ? parsed.model : null;
|
|
3320
3335
|
if (model !== null && model !== request.model) {
|
|
3321
3336
|
return failure("model-mismatch", "TypeSafe returned a different evaluator model.", false, null, usage, model);
|
|
3322
3337
|
}
|
|
3323
|
-
const answers =
|
|
3338
|
+
const answers = asRecord(parsed?.answers);
|
|
3324
3339
|
if (!model || !answers || usage.kind !== "reported") {
|
|
3325
3340
|
return failure("response-contract", "TypeSafe returned an incomplete evaluation response.", false, null, usage, model);
|
|
3326
3341
|
}
|
|
@@ -3415,8 +3430,8 @@ function buildJevSentimentRequest(input) {
|
|
|
3415
3430
|
return { ok: true, request, estimate };
|
|
3416
3431
|
}
|
|
3417
3432
|
function parseChoice(value, question) {
|
|
3418
|
-
const answer =
|
|
3419
|
-
const probabilities =
|
|
3433
|
+
const answer = asRecord(value);
|
|
3434
|
+
const probabilities = asRecord(answer?.probabilities);
|
|
3420
3435
|
if (answer?.type !== "choice" || typeof answer.choice !== "string" || !Object.hasOwn(question.criteria, answer.choice) || !probabilities) return null;
|
|
3421
3436
|
const expected = Object.keys(question.criteria);
|
|
3422
3437
|
if (Object.keys(probabilities).length !== expected.length || expected.some((key) => typeof probabilities[key] !== "number" || !Number.isFinite(probabilities[key]) || probabilities[key] < 0 || probabilities[key] > 1)) return null;
|
|
@@ -3426,13 +3441,16 @@ function parseChoice(value, question) {
|
|
|
3426
3441
|
return { choice: answer.choice, confidence: typeof answer.confidence === "number" ? answer.confidence : null };
|
|
3427
3442
|
}
|
|
3428
3443
|
function createTypeSafeClassifier(options) {
|
|
3444
|
+
return createJevSentimentClassifier((request, signal) => requestJev(request, { ...options, signal }));
|
|
3445
|
+
}
|
|
3446
|
+
function createJevSentimentClassifier(dispatch) {
|
|
3429
3447
|
return { async classify(rawInput, callOptions) {
|
|
3430
3448
|
const valid = sentimentClassifierInputSchema.safeParse(rawInput);
|
|
3431
3449
|
if (!valid.success) return { kind: "failed", outcome: SentimentOutcomes.failed, returnedModel: null, usage: UNKNOWN_USAGE, error: { code: "input-contract", message: "The classifier input does not match its frozen contract.", retryable: false, retryAfterMs: null } };
|
|
3432
3450
|
const input = valid.data;
|
|
3433
3451
|
const built = buildJevSentimentRequest(input);
|
|
3434
3452
|
if (!built.ok) return { kind: "abstained", outcome: built.outcome, reason: built.reason, returnedModel: null, usage: UNKNOWN_USAGE };
|
|
3435
|
-
const response = await
|
|
3453
|
+
const response = await dispatch(built.request, callOptions?.signal);
|
|
3436
3454
|
if (!response.ok) return { kind: "failed", outcome: SentimentOutcomes.failed, returnedModel: response.returnedModel, usage: response.usage, error: response.error };
|
|
3437
3455
|
const parsed = Object.fromEntries(Object.entries(built.request.questions).map(([id, question]) => [id, parseChoice(response.answers[id], question)]));
|
|
3438
3456
|
const spans = new Map(input.sentences.map((span) => [span.id, span]));
|
|
@@ -3443,7 +3461,7 @@ function createTypeSafeClassifier(options) {
|
|
|
3443
3461
|
return span ? [{ ...span }] : null;
|
|
3444
3462
|
};
|
|
3445
3463
|
const abstain = (outcome, reason) => ({ kind: "abstained", outcome, reason, returnedModel: response.returnedModel, usage: response.usage });
|
|
3446
|
-
if (!parsed.identity || !parsed.judgment || !parsed.stance) return { kind: "failed", outcome: SentimentOutcomes.failed, returnedModel: response.returnedModel, usage: response.usage, error: { code: "response-contract", message: "
|
|
3464
|
+
if (!parsed.identity || !parsed.judgment || !parsed.stance) return { kind: "failed", outcome: SentimentOutcomes.failed, returnedModel: response.returnedModel, usage: response.usage, error: { code: "response-contract", message: "Jev returned a malformed headline decision.", retryable: false, retryAfterMs: null } };
|
|
3447
3465
|
if (parsed.identity.choice === "absent") return abstain(SentimentOutcomes["subject-not-mentioned"], "The known intended subject is not discussed in the answer.");
|
|
3448
3466
|
if (parsed.identity.choice === "wrong") return abstain(SentimentOutcomes["wrong-subject"], "The answer refers to another subject.");
|
|
3449
3467
|
if (parsed.identity.choice !== "correct") return abstain(SentimentOutcomes["ambiguous-subject"], "The intended subject cannot be resolved unambiguously.");
|
|
@@ -3466,6 +3484,70 @@ var SENTIMENT_CHALLENGE_GATES = {
|
|
|
3466
3484
|
"caveated-favorable": { outcome: SentimentOutcomes.favorable, target: 0.9 }
|
|
3467
3485
|
};
|
|
3468
3486
|
|
|
3487
|
+
// src/sentiment-openrouter.ts
|
|
3488
|
+
var OPENROUTER_SYSTEM_ONE_URL = "https://openrouter.ai/api/v1/systemone";
|
|
3489
|
+
var UNKNOWN_USAGE2 = { kind: "unknown", inputTokens: null, outputTokens: null };
|
|
3490
|
+
function createConfiguredSentimentClassifier(configuration, registry, reload) {
|
|
3491
|
+
if (configuration.provider !== "openrouter") return createTypeSafeClassifier({ apiKey: configuration.apiKey });
|
|
3492
|
+
return createJevSentimentClassifier(async (request, signal) => {
|
|
3493
|
+
const failure2 = (code, retryable = false, usage = UNKNOWN_USAGE2, returnedModel = null, retryAfterMs = null) => ({
|
|
3494
|
+
ok: false,
|
|
3495
|
+
returnedModel,
|
|
3496
|
+
usage,
|
|
3497
|
+
error: { code, message: "The OpenRouter sentiment evaluator did not return a usable pinned result.", retryable, retryAfterMs }
|
|
3498
|
+
});
|
|
3499
|
+
if (request.model !== SENTIMENT_OPENROUTER_MODEL) return failure2("model-mismatch");
|
|
3500
|
+
const model = aeroModels.getModelOfType("classifier", "openrouter", SENTIMENT_OPENROUTER_MODEL);
|
|
3501
|
+
if (!model) return failure2("unsupported-model");
|
|
3502
|
+
const quota = registry?.get("openrouter")?.config.quotaPolicy;
|
|
3503
|
+
const gate = getSharedProviderExecutionGate("openrouter", quota?.maxConcurrency ?? configuration.maxConcurrency, quota?.maxRequestsPerMinute ?? configuration.maxRequestsPerMinute);
|
|
3504
|
+
return gate.run(async () => {
|
|
3505
|
+
const active = reload?.() ?? configuration;
|
|
3506
|
+
const readiness = sentimentInstallReadiness(active);
|
|
3507
|
+
if (!readiness.ready) return failure2(readiness.reason ?? "invalid-config", true);
|
|
3508
|
+
if (active.provider !== configuration.provider || active.model !== request.model) return failure2("evaluator-route-changed", true);
|
|
3509
|
+
const observed = { body: null };
|
|
3510
|
+
const observedFetch = async (url, init) => {
|
|
3511
|
+
const endpoint = typeof url === "string" ? url : url instanceof URL ? url.href : url.url;
|
|
3512
|
+
if (endpoint !== OPENROUTER_SYSTEM_ONE_URL) throw new Error("Unsupported sentiment transport endpoint.");
|
|
3513
|
+
const response = await fetch(OPENROUTER_SYSTEM_ONE_URL, { ...init, redirect: "error" });
|
|
3514
|
+
observed.status = response.status;
|
|
3515
|
+
observed.retryAfter = response.headers.get("retry-after") ?? void 0;
|
|
3516
|
+
try {
|
|
3517
|
+
observed.body = asRecord(await response.clone().json());
|
|
3518
|
+
} catch {
|
|
3519
|
+
observed.body = null;
|
|
3520
|
+
}
|
|
3521
|
+
return response;
|
|
3522
|
+
};
|
|
3523
|
+
const result = await aeroModels.classify(model, { state: request.state, questions: request.questions }, {
|
|
3524
|
+
apiKey: active.apiKey,
|
|
3525
|
+
signal,
|
|
3526
|
+
maxRetries: 0,
|
|
3527
|
+
timeoutMs: 3e4,
|
|
3528
|
+
headers: { "User-Agent": "canonry" },
|
|
3529
|
+
fetch: observedFetch
|
|
3530
|
+
});
|
|
3531
|
+
const responseBody = observed.body;
|
|
3532
|
+
const returnedModel = typeof responseBody?.model === "string" ? responseBody.model : null;
|
|
3533
|
+
const counts = asRecord(responseBody?.usage);
|
|
3534
|
+
const input = counts?.input_tokens;
|
|
3535
|
+
const output = counts?.output_tokens;
|
|
3536
|
+
const usage = typeof input === "number" && Number.isSafeInteger(input) && input >= 0 && typeof output === "number" && Number.isSafeInteger(output) && output >= 0 ? { kind: "reported", inputTokens: input, outputTokens: output } : UNKNOWN_USAGE2;
|
|
3537
|
+
if (result.stopReason !== "stop") {
|
|
3538
|
+
if (signal?.aborted) return failure2("canceled", false, usage, returnedModel);
|
|
3539
|
+
const { status, retryAfter } = observed;
|
|
3540
|
+
const httpError = { status, retryAfter };
|
|
3541
|
+
const code = status === 401 || status === 403 ? "provider-authorization" : status === 413 ? "provider-context-limit" : status === 429 ? "provider-rate-limit" : status && status >= 400 ? isRetryableHttpError(httpError) ? "provider-unavailable" : "provider-rejected" : status ? "response-contract" : "provider-network";
|
|
3542
|
+
return failure2(code, isRetryableHttpError(httpError), usage, returnedModel, retryAfterDelayMs(httpError));
|
|
3543
|
+
}
|
|
3544
|
+
if (returnedModel !== SENTIMENT_OPENROUTER_SERVED_MODEL) return failure2("model-mismatch", false, usage, returnedModel);
|
|
3545
|
+
if (usage.kind !== "reported") return failure2("response-contract", false, usage, returnedModel);
|
|
3546
|
+
return { ok: true, returnedModel, usage, answers: result.answers };
|
|
3547
|
+
}, signal).catch(() => signal?.aborted ? failure2(signal.reason instanceof DOMException && signal.reason.name === "TimeoutError" ? "provider-timeout" : "canceled", signal.reason instanceof DOMException && signal.reason.name === "TimeoutError") : failure2("provider-network", true));
|
|
3548
|
+
});
|
|
3549
|
+
}
|
|
3550
|
+
|
|
3469
3551
|
// src/sentiment-worker.ts
|
|
3470
3552
|
import { createHash as createHash3, randomUUID } from "crypto";
|
|
3471
3553
|
import { and, asc, eq, gt } from "drizzle-orm";
|
|
@@ -3523,7 +3605,7 @@ var SentimentWorker = class {
|
|
|
3523
3605
|
service() {
|
|
3524
3606
|
return new SentimentService(this.db, { install: () => {
|
|
3525
3607
|
const config = this.options.configuration();
|
|
3526
|
-
return { ...sentimentInstallReadiness(config), model: config.model };
|
|
3608
|
+
return { ...sentimentInstallReadiness(config), model: config.model, provider: config.provider };
|
|
3527
3609
|
}, previewSecret: this.owner, now: this.options.now });
|
|
3528
3610
|
}
|
|
3529
3611
|
/** The completion callback is merely a wakeup; receipts make a missed callback recoverable. */
|
|
@@ -3538,7 +3620,7 @@ var SentimentWorker = class {
|
|
|
3538
3620
|
const receipts = this.db.select().from(sentimentCompletionReceipts).where(and(eq(sentimentCompletionReceipts.projectId, settings.projectId), gt(sentimentCompletionReceipts.sequence, start))).orderBy(asc(sentimentCompletionReceipts.sequence)).all();
|
|
3539
3621
|
if (!receipts.length) continue;
|
|
3540
3622
|
const definition = service.definition(settings.evaluationDefinitionId);
|
|
3541
|
-
if (!hasCurrentSentimentTemplate(definition)) continue;
|
|
3623
|
+
if (!hasCurrentSentimentTemplate(definition) || sentimentEvaluatorProvider(definition) !== configuration.provider || definition.requestedModel !== configuration.model) continue;
|
|
3542
3624
|
let reconciled = start;
|
|
3543
3625
|
try {
|
|
3544
3626
|
for (const receipt of receipts) {
|
|
@@ -3640,6 +3722,11 @@ var SentimentWorker = class {
|
|
|
3640
3722
|
report({ status: OutcomeStatuses.skipped, reasonCode: OutcomeReasonCodes.NOT_CONNECTED });
|
|
3641
3723
|
return;
|
|
3642
3724
|
}
|
|
3725
|
+
if (sentimentEvaluatorProvider(input.definition) !== config.provider || input.definition.requestedModel !== config.model) {
|
|
3726
|
+
this.repository.failWork({ workItemId: work.id, owner, now: this.now(), errorCode: "EVALUATOR_ROUTE_CHANGED", retryAt: new Date(Date.parse(this.now()) + 6e4).toISOString() });
|
|
3727
|
+
report({ status: OutcomeStatuses.skipped, reasonCode: OutcomeReasonCodes.NOT_CONNECTED });
|
|
3728
|
+
return;
|
|
3729
|
+
}
|
|
3643
3730
|
const settings = this.repository.getSettings(work.projectId);
|
|
3644
3731
|
if (!settings?.enabled || settings.enablementEpoch !== work.enablementEpoch) {
|
|
3645
3732
|
this.repository.cancelProject(work.projectId, this.now());
|
|
@@ -3677,8 +3764,9 @@ var SentimentWorker = class {
|
|
|
3677
3764
|
result = { kind: "failed", outcome: "failed", returnedModel: null, usage: { kind: "unknown", inputTokens: null, outputTokens: null }, error: { code: "CLASSIFIER_TRANSPORT_ERROR", message: "The classifier attempt did not return a usable response.", retryable: true, retryAfterMs: null } };
|
|
3678
3765
|
}
|
|
3679
3766
|
const now = this.now();
|
|
3680
|
-
const
|
|
3681
|
-
|
|
3767
|
+
const evaluatorProvider = sentimentEvaluatorProvider(input.definition);
|
|
3768
|
+
const usage = result.usage.inputTokens !== null && result.usage.outputTokens !== null ? { inputTokens: result.usage.inputTokens, outputTokens: result.usage.outputTokens, ...evaluatorProvider === "typesafe" ? { costMillicents: Math.round(result.usage.inputTokens * 42e-4) } : {} } : void 0;
|
|
3769
|
+
this.repository.finishAttempt({ attemptId: attempt.id, now, provider: evaluatorProvider, returnedModel: result.returnedModel, usageStatus: result.usage.kind, usage, safeFailure: result.kind === "failed" ? result.error.code : null });
|
|
3682
3770
|
const counts = { attempts: attempt.attemptNumber, ...usage ? { inputTokens: usage.inputTokens, outputTokens: usage.outputTokens } : {} };
|
|
3683
3771
|
if (result.kind === "failed") {
|
|
3684
3772
|
const failure2 = transportError ? outcomeFailure(transportError.error) : { reasonCode: CLASSIFIER_FAILURE_REASONS[result.error.code] ?? OutcomeReasonCodes.UNKNOWN };
|
|
@@ -3745,7 +3833,9 @@ function loadSentimentInstallConfig() {
|
|
|
3745
3833
|
const document = parse(fs.readFileSync(getConfigPath(), "utf8"));
|
|
3746
3834
|
const sentiment = isRecord(document) ? document.sentiment : void 0;
|
|
3747
3835
|
if (!isRecord(document) || sentiment != null && !isRecord(sentiment)) return invalidSentimentInstallConfig();
|
|
3748
|
-
|
|
3836
|
+
const providers = isRecord(document.providers) ? document.providers : void 0;
|
|
3837
|
+
const openrouter = providers && isRecord(providers.openrouter) ? providers.openrouter.apiKey : void 0;
|
|
3838
|
+
return resolveSentimentInstallConfig(process.env, sentiment ?? void 0, { openrouter: typeof openrouter === "string" ? openrouter : void 0 });
|
|
3749
3839
|
} catch {
|
|
3750
3840
|
return invalidSentimentInstallConfig();
|
|
3751
3841
|
}
|
|
@@ -4963,7 +5053,7 @@ var UI_EVENT_HOUR_CAPACITY = 600;
|
|
|
4963
5053
|
function createUiTelemetryGate(options = {}) {
|
|
4964
5054
|
const now = options.now ?? Date.now;
|
|
4965
5055
|
const enabled = options.enabled ?? isTelemetryEnabled;
|
|
4966
|
-
const
|
|
5056
|
+
const record = options.record ?? recordDashboardEvent;
|
|
4967
5057
|
const buckets = [
|
|
4968
5058
|
{ capacity: UI_EVENT_MINUTE_CAPACITY, perMs: UI_EVENT_MINUTE_CAPACITY / 6e4, tokens: UI_EVENT_MINUTE_CAPACITY },
|
|
4969
5059
|
{ capacity: UI_EVENT_HOUR_CAPACITY, perMs: UI_EVENT_HOUR_CAPACITY / 36e5, tokens: UI_EVENT_HOUR_CAPACITY }
|
|
@@ -4977,7 +5067,7 @@ function createUiTelemetryGate(options = {}) {
|
|
|
4977
5067
|
for (const bucket of buckets) bucket.tokens = Math.min(bucket.capacity, bucket.tokens + elapsed * bucket.perMs);
|
|
4978
5068
|
if (buckets.some((bucket) => bucket.tokens < 1)) return false;
|
|
4979
5069
|
for (const bucket of buckets) bucket.tokens -= 1;
|
|
4980
|
-
|
|
5070
|
+
record(event);
|
|
4981
5071
|
return true;
|
|
4982
5072
|
};
|
|
4983
5073
|
}
|
|
@@ -4988,7 +5078,7 @@ function nonBlank(value) {
|
|
|
4988
5078
|
return trimmed ? trimmed : void 0;
|
|
4989
5079
|
}
|
|
4990
5080
|
function resolveBuildCommit(env = process.env) {
|
|
4991
|
-
const embedded = true ? "
|
|
5081
|
+
const embedded = true ? "e27d5bf88109fe71ea2bfa3a1456e269ca3370d8" : void 0;
|
|
4992
5082
|
return nonBlank(embedded) ?? nonBlank(env.CANONRY_COMMIT);
|
|
4993
5083
|
}
|
|
4994
5084
|
function resolveInstanceIdentity(env = process.env) {
|
|
@@ -5035,7 +5125,7 @@ function buildRunCompletedProps(input) {
|
|
|
5035
5125
|
const props = {
|
|
5036
5126
|
status: input.status,
|
|
5037
5127
|
providerCount: input.providerCount,
|
|
5038
|
-
providers: [...input.providers],
|
|
5128
|
+
providers: [...new Set(input.providers.map(providerConnectionName))],
|
|
5039
5129
|
queryCount: input.queryCount,
|
|
5040
5130
|
durationMs: totalMs
|
|
5041
5131
|
};
|
|
@@ -5048,7 +5138,7 @@ function buildRunCompletedProps(input) {
|
|
|
5048
5138
|
return props;
|
|
5049
5139
|
}
|
|
5050
5140
|
function runUsageProps(answers) {
|
|
5051
|
-
const counted = answers.filter((answer) => KNOWN_PROVIDERS.has(answer.provider));
|
|
5141
|
+
const counted = answers.map((answer) => ({ ...answer, provider: providerConnectionName(answer.provider) })).filter((answer) => KNOWN_PROVIDERS.has(answer.provider));
|
|
5052
5142
|
if (counted.length === 0) return {};
|
|
5053
5143
|
const providerCalls = {};
|
|
5054
5144
|
for (const answer of [...counted].sort((left, right) => compareText(left.provider, right.provider))) {
|
|
@@ -5068,9 +5158,17 @@ function runUsageProps(answers) {
|
|
|
5068
5158
|
return { providerCalls, usage };
|
|
5069
5159
|
}
|
|
5070
5160
|
function providerLatencyProps(latencies) {
|
|
5161
|
+
const byConnection = /* @__PURE__ */ new Map();
|
|
5162
|
+
for (const [provider, values] of latencies ?? []) {
|
|
5163
|
+
const connection = providerConnectionName(provider);
|
|
5164
|
+
if (!KNOWN_PROVIDERS.has(connection)) continue;
|
|
5165
|
+
const samples = byConnection.get(connection) ?? [];
|
|
5166
|
+
samples.push(...values);
|
|
5167
|
+
byConnection.set(connection, samples);
|
|
5168
|
+
}
|
|
5071
5169
|
const providerLatencyMs = {};
|
|
5072
|
-
for (const [provider, values] of [...
|
|
5073
|
-
const middle =
|
|
5170
|
+
for (const [provider, values] of [...byConnection].sort(([left], [right]) => compareText(left, right))) {
|
|
5171
|
+
const middle = median(values);
|
|
5074
5172
|
if (middle !== null) providerLatencyMs[provider] = Math.max(0, Math.round(middle));
|
|
5075
5173
|
}
|
|
5076
5174
|
return Object.keys(providerLatencyMs).length > 0 ? { providerLatencyMs } : {};
|
|
@@ -5103,32 +5201,42 @@ var MAX_NESTED_KEYS = 12;
|
|
|
5103
5201
|
function buildProviderOutcomeProps(providers, providerErrors, skippedProviders = []) {
|
|
5104
5202
|
if (providerErrors.size === 0 && skippedProviders.length === 0) return {};
|
|
5105
5203
|
const skipped = new Set(skippedProviders);
|
|
5106
|
-
const
|
|
5204
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
5205
|
+
for (const provider of /* @__PURE__ */ new Set([...providers, ...providerErrors.keys(), ...skipped])) {
|
|
5206
|
+
const name = providerConnectionName(provider);
|
|
5207
|
+
grouped.set(name, [...grouped.get(name) ?? [], provider]);
|
|
5208
|
+
}
|
|
5107
5209
|
const providerOutcomes = {};
|
|
5108
5210
|
const providerHttpStatus = {};
|
|
5109
|
-
for (const name of
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
}
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
providerOutcomes[name] = "ok";
|
|
5211
|
+
for (const [name, routes] of [...grouped].slice(0, MAX_NESTED_KEYS)) {
|
|
5212
|
+
const failures = routes.flatMap((route) => {
|
|
5213
|
+
const message2 = providerErrors.get(route);
|
|
5214
|
+
return !skipped.has(route) && message2 !== void 0 ? [{ message: message2, code: classifyProviderErrorMessage(message2) }] : [];
|
|
5215
|
+
});
|
|
5216
|
+
if (failures.length === 0) {
|
|
5217
|
+
providerOutcomes[name] = routes.every((route) => skipped.has(route)) ? "skipped" : "ok";
|
|
5117
5218
|
continue;
|
|
5118
5219
|
}
|
|
5119
|
-
|
|
5220
|
+
const code = mostActionableProviderErrorCode(failures.map((failure2) => failure2.code));
|
|
5221
|
+
const message = failures.find((failure2) => failure2.code === code).message;
|
|
5222
|
+
providerOutcomes[name] = code;
|
|
5120
5223
|
const status = extractProviderHttpStatus(message);
|
|
5121
5224
|
if (status !== void 0) providerHttpStatus[name] = status;
|
|
5122
5225
|
}
|
|
5123
5226
|
return Object.keys(providerHttpStatus).length > 0 ? { providerOutcomes, providerHttpStatus } : { providerOutcomes };
|
|
5124
5227
|
}
|
|
5125
5228
|
function buildRunRefusedProps(input) {
|
|
5126
|
-
const outcomes =
|
|
5229
|
+
const outcomes = /* @__PURE__ */ new Map();
|
|
5230
|
+
for (const [provider, code] of Object.entries(input.providers)) {
|
|
5231
|
+
const name = providerConnectionName(provider);
|
|
5232
|
+
const previous = outcomes.get(name);
|
|
5233
|
+
outcomes.set(name, previous === void 0 ? code : mostActionableProviderErrorCode([previous, code]));
|
|
5234
|
+
}
|
|
5127
5235
|
const props = {
|
|
5128
5236
|
reason: "providers_failing",
|
|
5129
5237
|
providerCount: Object.keys(input.providers).length,
|
|
5130
|
-
providers:
|
|
5131
|
-
providerOutcomes: Object.fromEntries(outcomes),
|
|
5238
|
+
providers: [...outcomes.keys()],
|
|
5239
|
+
providerOutcomes: Object.fromEntries([...outcomes].slice(0, MAX_NESTED_KEYS)),
|
|
5132
5240
|
trigger: input.trigger
|
|
5133
5241
|
};
|
|
5134
5242
|
const domainHash = hashDomain(input.canonicalDomain ?? null);
|
|
@@ -5164,83 +5272,6 @@ function failureStreakSampling(status, priorStreak, runId) {
|
|
|
5164
5272
|
};
|
|
5165
5273
|
}
|
|
5166
5274
|
|
|
5167
|
-
// src/provider-execution-gate.ts
|
|
5168
|
-
var ProviderExecutionGate = class {
|
|
5169
|
-
constructor(maxConcurrency, maxPerMinute) {
|
|
5170
|
-
this.maxConcurrency = maxConcurrency;
|
|
5171
|
-
this.maxPerMinute = maxPerMinute;
|
|
5172
|
-
}
|
|
5173
|
-
maxConcurrency;
|
|
5174
|
-
maxPerMinute;
|
|
5175
|
-
window = [];
|
|
5176
|
-
waiters = [];
|
|
5177
|
-
rateTimer;
|
|
5178
|
-
dispatching = false;
|
|
5179
|
-
inFlight = 0;
|
|
5180
|
-
updatePolicy(maxConcurrency, maxPerMinute) {
|
|
5181
|
-
this.maxConcurrency = maxConcurrency;
|
|
5182
|
-
this.maxPerMinute = maxPerMinute;
|
|
5183
|
-
this.dispatchQueued();
|
|
5184
|
-
}
|
|
5185
|
-
async run(task) {
|
|
5186
|
-
return new Promise((resolve, reject) => {
|
|
5187
|
-
this.waiters.push(() => {
|
|
5188
|
-
void this.execute(task, resolve, reject);
|
|
5189
|
-
});
|
|
5190
|
-
this.dispatchQueued();
|
|
5191
|
-
});
|
|
5192
|
-
}
|
|
5193
|
-
async execute(task, resolve, reject) {
|
|
5194
|
-
try {
|
|
5195
|
-
resolve(await task());
|
|
5196
|
-
} catch (error) {
|
|
5197
|
-
reject(error);
|
|
5198
|
-
} finally {
|
|
5199
|
-
this.inFlight--;
|
|
5200
|
-
this.dispatchQueued();
|
|
5201
|
-
}
|
|
5202
|
-
}
|
|
5203
|
-
dispatchQueued() {
|
|
5204
|
-
if (this.dispatching) return;
|
|
5205
|
-
if (this.rateTimer !== void 0) {
|
|
5206
|
-
clearTimeout(this.rateTimer);
|
|
5207
|
-
this.rateTimer = void 0;
|
|
5208
|
-
}
|
|
5209
|
-
this.dispatching = true;
|
|
5210
|
-
try {
|
|
5211
|
-
while (this.waiters.length > 0 && this.inFlight < Math.max(1, this.maxConcurrency)) {
|
|
5212
|
-
const now = Date.now();
|
|
5213
|
-
const windowStart = now - 6e4;
|
|
5214
|
-
while (this.window.length > 0 && this.window[0] < windowStart) this.window.shift();
|
|
5215
|
-
if (this.window.length >= this.maxPerMinute) break;
|
|
5216
|
-
this.window.push(now);
|
|
5217
|
-
this.inFlight++;
|
|
5218
|
-
this.waiters.shift()();
|
|
5219
|
-
}
|
|
5220
|
-
} finally {
|
|
5221
|
-
this.dispatching = false;
|
|
5222
|
-
}
|
|
5223
|
-
if (this.waiters.length > 0 && this.inFlight < Math.max(1, this.maxConcurrency)) {
|
|
5224
|
-
this.rateTimer = setTimeout(() => {
|
|
5225
|
-
this.rateTimer = void 0;
|
|
5226
|
-
this.dispatchQueued();
|
|
5227
|
-
}, this.window[0] + 6e4 - Date.now() + 50);
|
|
5228
|
-
}
|
|
5229
|
-
}
|
|
5230
|
-
};
|
|
5231
|
-
var sharedGates = /* @__PURE__ */ new Map();
|
|
5232
|
-
function getSharedProviderExecutionGate(providerName, maxConcurrency, maxPerMinute) {
|
|
5233
|
-
const key = providerName.trim().toLocaleLowerCase("en");
|
|
5234
|
-
const existing = sharedGates.get(key);
|
|
5235
|
-
if (existing) return existing;
|
|
5236
|
-
const gate = new ProviderExecutionGate(maxConcurrency, maxPerMinute);
|
|
5237
|
-
sharedGates.set(key, gate);
|
|
5238
|
-
return gate;
|
|
5239
|
-
}
|
|
5240
|
-
function updateSharedProviderExecutionGate(providerName, maxConcurrency, maxPerMinute) {
|
|
5241
|
-
getSharedProviderExecutionGate(providerName, maxConcurrency, maxPerMinute).updatePolicy(maxConcurrency, maxPerMinute);
|
|
5242
|
-
}
|
|
5243
|
-
|
|
5244
5275
|
// src/usage-quota.ts
|
|
5245
5276
|
import crypto5 from "crypto";
|
|
5246
5277
|
import { and as and2, eq as eq2, lte, sql } from "drizzle-orm";
|
|
@@ -5283,7 +5314,7 @@ var RESOLUTION_TIMEOUT_MS = 5e3;
|
|
|
5283
5314
|
var MAX_VERTEX_PROXY_HOPS = 3;
|
|
5284
5315
|
var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
5285
5316
|
function isRouteCapableProvider(provider) {
|
|
5286
|
-
return ROUTE_CAPABLE_CITED_URL_PROVIDERS.includes(provider);
|
|
5317
|
+
return isOpenRouterRoute(provider) || ROUTE_CAPABLE_CITED_URL_PROVIDERS.includes(provider);
|
|
5287
5318
|
}
|
|
5288
5319
|
function parseHttpUrl(value, base) {
|
|
5289
5320
|
try {
|
|
@@ -5511,8 +5542,7 @@ function resolvePlanExecution(run, projectQueries) {
|
|
|
5511
5542
|
return {
|
|
5512
5543
|
manifest,
|
|
5513
5544
|
unitsByProvider,
|
|
5514
|
-
nodeCount: nodes.size
|
|
5515
|
-
maxUnitsPerProvider: Math.max(0, ...[...unitsByProvider.values()].map((units) => units.length))
|
|
5545
|
+
nodeCount: nodes.size
|
|
5516
5546
|
};
|
|
5517
5547
|
}
|
|
5518
5548
|
function resolveProviderFanout() {
|
|
@@ -5799,10 +5829,10 @@ var JobRunner = class {
|
|
|
5799
5829
|
...runTrigger ? { trigger: runTrigger } : {},
|
|
5800
5830
|
...canonicalDomain ? { canonicalDomain } : {}
|
|
5801
5831
|
};
|
|
5802
|
-
const queriesPerProvider = planExecution?.maxUnitsPerProvider ?? projectQueries.length;
|
|
5803
5832
|
const todayPeriod = getCurrentUsageDay();
|
|
5804
5833
|
for (const p of calledProviders) {
|
|
5805
|
-
const
|
|
5834
|
+
const queriesPerProvider = planExecution ? planExecution.unitsByProvider.get(p.adapter.name)?.length ?? 0 : projectQueries.length;
|
|
5835
|
+
const providerScope = `${projectId}:${providerConnectionName(p.adapter.name)}`;
|
|
5806
5836
|
const limit = p.config.quotaPolicy.maxRequestsPerDay;
|
|
5807
5837
|
const quota = reserveDailyQueryQuota(this.db, { scope: providerScope, period: todayPeriod, count: queriesPerProvider, limit });
|
|
5808
5838
|
if (!quota.reserved) {
|
|
@@ -5903,7 +5933,7 @@ var JobRunner = class {
|
|
|
5903
5933
|
allBrandNames,
|
|
5904
5934
|
competitorAliases
|
|
5905
5935
|
);
|
|
5906
|
-
const answerLocation = runLocation && isSearchLocationIgnored(providerName, normalized.retrievalStatus) ? { location: null, requestedContext: runLocation, supportedContext: { status: "ignored" } } : { location: runLocation?.label ?? null };
|
|
5936
|
+
const answerLocation = runLocation && (isOpenRouterRoute(providerName) || isSearchLocationIgnored(providerName, normalized.retrievalStatus)) ? { location: null, requestedContext: runLocation, supportedContext: { status: "ignored" } } : { location: runLocation?.label ?? null };
|
|
5907
5937
|
let screenshotRelPath = null;
|
|
5908
5938
|
if (raw.screenshotPath && fs3.existsSync(raw.screenshotPath)) {
|
|
5909
5939
|
const snapshotId = crypto6.randomUUID();
|
|
@@ -6176,7 +6206,7 @@ var JobRunner = class {
|
|
|
6176
6206
|
trackEvent("run.aborted", {
|
|
6177
6207
|
reason: abortReason2,
|
|
6178
6208
|
providerCount: executionContext.providerCount,
|
|
6179
|
-
providers: executionContext.providers,
|
|
6209
|
+
providers: [...new Set(executionContext.providers.map(providerConnectionName))],
|
|
6180
6210
|
queryCount: executionContext.queryCount,
|
|
6181
6211
|
durationMs: Date.now() - startTime,
|
|
6182
6212
|
...executionContext.trigger ? { trigger: executionContext.trigger } : {},
|
|
@@ -7006,7 +7036,7 @@ var JobRunner = class {
|
|
|
7006
7036
|
for (const registered of activeProviders) {
|
|
7007
7037
|
const name = registered.adapter.name;
|
|
7008
7038
|
const count4 = unitsByProvider.get(name)?.length ?? 0;
|
|
7009
|
-
const scope = `${projectId}:${name}`;
|
|
7039
|
+
const scope = `${projectId}:${providerConnectionName(name)}`;
|
|
7010
7040
|
const limit = registered.config.quotaPolicy.maxRequestsPerDay;
|
|
7011
7041
|
const quota = reserveDailyQueryQuota(this.db, { scope, period: todayPeriod, count: count4, limit });
|
|
7012
7042
|
if (!quota.reserved) {
|
|
@@ -7214,7 +7244,7 @@ var JobRunner = class {
|
|
|
7214
7244
|
const providerName = adapter.name;
|
|
7215
7245
|
const { domains: competitorDomains, aliases: competitorAliases } = ctx.competitorsFor(unit.executionId);
|
|
7216
7246
|
const requestedContext = unit.context;
|
|
7217
|
-
const supportedContext = requestedContext && providerSupportsLocationContext(adapter) ? { status: "applied", resolved: requestedContext } : null;
|
|
7247
|
+
const supportedContext = requestedContext && providerSupportsLocationContext(adapter) ? { status: "applied", resolved: requestedContext } : requestedContext && isOpenRouterRoute(providerName) ? { status: "ignored" } : null;
|
|
7218
7248
|
this.throwIfRunCancelled(ctx.runId);
|
|
7219
7249
|
const providerResult = adapter.normalizeResult(raw);
|
|
7220
7250
|
const rawGroundingSources = providerResult.groundingSources;
|
|
@@ -10427,8 +10457,10 @@ async function executeDiscoveryRun(opts) {
|
|
|
10427
10457
|
canonicalDomains,
|
|
10428
10458
|
competitorDomains: projectCompetitors
|
|
10429
10459
|
};
|
|
10460
|
+
const classifierConfig = opts.getClassifierConfig?.() ?? opts.classifierConfig;
|
|
10461
|
+
await refreshAgentModels(classifierConfig?.classification?.provider);
|
|
10430
10462
|
notConfigured = true;
|
|
10431
|
-
const deps = buildDefaultDeps(opts.registry);
|
|
10463
|
+
const deps = buildDefaultDeps(opts.registry, classifierConfig);
|
|
10432
10464
|
notConfigured = false;
|
|
10433
10465
|
const result = await executeDiscovery({
|
|
10434
10466
|
db: opts.db,
|
|
@@ -10484,7 +10516,7 @@ async function executeDiscoveryRun(opts) {
|
|
|
10484
10516
|
});
|
|
10485
10517
|
}
|
|
10486
10518
|
}
|
|
10487
|
-
function buildDefaultDeps(registry) {
|
|
10519
|
+
function buildDefaultDeps(registry, classifierConfig) {
|
|
10488
10520
|
const gemini = registry.get("gemini");
|
|
10489
10521
|
if (!gemini) {
|
|
10490
10522
|
throw new Error("Gemini provider is not configured. Add a Gemini API key (or Vertex project) before running discovery.");
|
|
@@ -10494,6 +10526,9 @@ function buildDefaultDeps(registry) {
|
|
|
10494
10526
|
throw new Error("Gemini provider is missing both apiKey and vertexProject \u2014 cannot run discovery.");
|
|
10495
10527
|
}
|
|
10496
10528
|
const adapter = gemini.adapter;
|
|
10529
|
+
const classifierProvider = classifierConfig?.classification?.provider ?? AgentProviderIds.gemini;
|
|
10530
|
+
const classifierModel = classifierConfig?.classification ? resolveModelForCapability(classifierProvider, LlmCapabilities.classify, classifierConfig.classification.model) : void 0;
|
|
10531
|
+
const classifierKey = resolveApiKeyFor(classifierProvider, classifierConfig ?? { providers: { gemini: { apiKey: cfg.apiKey } } });
|
|
10497
10532
|
function seedProviderFor(name) {
|
|
10498
10533
|
if (name === "gemini") return { adapter, config: cfg };
|
|
10499
10534
|
const entry = registry.get(name);
|
|
@@ -10574,8 +10609,19 @@ function buildDefaultDeps(registry) {
|
|
|
10574
10609
|
},
|
|
10575
10610
|
async classifyDomains(input) {
|
|
10576
10611
|
const prompt = buildClassificationPrompt(input);
|
|
10577
|
-
|
|
10578
|
-
|
|
10612
|
+
if (!classifierModel) {
|
|
10613
|
+
const text2 = await adapter.generateText(prompt, cfg);
|
|
10614
|
+
return { classifications: parseClassificationResponse(text2, input.domains), evaluator: { provider: "gemini", requestedModel: cfg.model ?? adapter.modelRegistry.defaultModel, servedModel: null, promptVersion: "domain-category-v1" } };
|
|
10615
|
+
}
|
|
10616
|
+
if (!classifierKey) throw new Error("The configured domain classifier has no API key.");
|
|
10617
|
+
const quota = registry.get(classifierProvider)?.config.quotaPolicy ?? cfg.quotaPolicy;
|
|
10618
|
+
const generate = () => completeOnce(classifierModel, {
|
|
10619
|
+
messages: [{ role: "user", content: prompt, timestamp: Date.now() }]
|
|
10620
|
+
}, { apiKey: classifierKey });
|
|
10621
|
+
const response = classifierProvider === AgentProviderIds.openrouter ? await generate() : await getSharedProviderExecutionGate(classifierProvider, quota.maxConcurrency, quota.maxRequestsPerMinute).run(generate);
|
|
10622
|
+
if (response.stopReason === "error" || response.stopReason === "aborted") throw new Error("The domain classifier did not complete.");
|
|
10623
|
+
const text = response.content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
|
|
10624
|
+
return { classifications: parseClassificationResponse(text, input.domains), evaluator: { provider: classifierProvider, requestedModel: classifierModel.id, servedModel: response.responseModel ?? null, promptVersion: "domain-category-v1" } };
|
|
10579
10625
|
}
|
|
10580
10626
|
};
|
|
10581
10627
|
}
|
|
@@ -11902,22 +11948,37 @@ var ProviderRegistry = class {
|
|
|
11902
11948
|
}
|
|
11903
11949
|
}
|
|
11904
11950
|
get(name) {
|
|
11905
|
-
|
|
11951
|
+
const registered = this.providers.get(name);
|
|
11952
|
+
if (registered) return registered;
|
|
11953
|
+
const model = openRouterRouteModel(name);
|
|
11954
|
+
const connection = model ? this.providers.get(providerConnectionName(name)) : void 0;
|
|
11955
|
+
if (!connection || !model) return void 0;
|
|
11956
|
+
const config = { ...connection.config, provider: name, model };
|
|
11957
|
+
return {
|
|
11958
|
+
config,
|
|
11959
|
+
adapter: {
|
|
11960
|
+
...connection.adapter,
|
|
11961
|
+
name,
|
|
11962
|
+
displayName: `${model} \xB7 OpenRouter`,
|
|
11963
|
+
modelRegistry: { ...connection.adapter.modelRegistry, defaultModel: model },
|
|
11964
|
+
parseTrackedQueryResponse: connection.adapter.parseTrackedQueryResponse ? (body, requestedModel) => ({ ...connection.adapter.parseTrackedQueryResponse(body, requestedModel), provider: name }) : void 0
|
|
11965
|
+
}
|
|
11966
|
+
};
|
|
11906
11967
|
}
|
|
11907
11968
|
getAll() {
|
|
11908
11969
|
return [...this.providers.values()];
|
|
11909
11970
|
}
|
|
11910
11971
|
getForProject(projectProviders) {
|
|
11911
11972
|
if (projectProviders.length === 0) {
|
|
11912
|
-
return this.getAll();
|
|
11973
|
+
return this.getAll().filter((provider) => isSweepProvider(provider.adapter.name));
|
|
11913
11974
|
}
|
|
11914
11975
|
const result = [];
|
|
11915
11976
|
const seen = /* @__PURE__ */ new Set();
|
|
11916
11977
|
for (const name of projectProviders) {
|
|
11917
11978
|
if (seen.has(name)) continue;
|
|
11918
11979
|
seen.add(name);
|
|
11919
|
-
const provider = this.
|
|
11920
|
-
if (provider) {
|
|
11980
|
+
const provider = this.get(name);
|
|
11981
|
+
if (provider && isSweepProvider(provider.adapter.name)) {
|
|
11921
11982
|
result.push(provider);
|
|
11922
11983
|
}
|
|
11923
11984
|
}
|
|
@@ -11929,7 +11990,7 @@ var ProviderRegistry = class {
|
|
|
11929
11990
|
}
|
|
11930
11991
|
/** Get only API-based providers */
|
|
11931
11992
|
getApiProviders() {
|
|
11932
|
-
return this.getAll().filter((p) => !isBrowserProvider(p.adapter.name));
|
|
11993
|
+
return this.getAll().filter((p) => !isBrowserProvider(p.adapter.name) && isSweepProvider(p.adapter.name));
|
|
11933
11994
|
}
|
|
11934
11995
|
get size() {
|
|
11935
11996
|
return this.providers.size;
|
|
@@ -12015,8 +12076,10 @@ function buildInstallState(sources, now, startedAt) {
|
|
|
12015
12076
|
if (isCdpProviderRegistrable(config.cdp)) connected.add(IntegrationNames.cdp);
|
|
12016
12077
|
const providerCalls = /* @__PURE__ */ new Map();
|
|
12017
12078
|
const addCalls = (provider, calls) => {
|
|
12018
|
-
if (!provider ||
|
|
12019
|
-
|
|
12079
|
+
if (!provider || calls <= 0) return;
|
|
12080
|
+
const connection = providerConnectionName(provider);
|
|
12081
|
+
if (!KNOWN_PROVIDERS2.has(connection)) return;
|
|
12082
|
+
providerCalls.set(connection, (providerCalls.get(connection) ?? 0) + calls);
|
|
12020
12083
|
};
|
|
12021
12084
|
const usagePath = (field) => sql7`json_extract(${querySnapshots.usage}, ${`$.${field}`})`;
|
|
12022
12085
|
const answers = db.select({
|
|
@@ -12240,8 +12303,8 @@ var RETRY_MS = 60 * 1e3;
|
|
|
12240
12303
|
var TIMEOUT_MS2 = 3e3;
|
|
12241
12304
|
function createProviderModelCatalog(registry) {
|
|
12242
12305
|
const cache = /* @__PURE__ */ new Map();
|
|
12243
|
-
const read = async (name) => {
|
|
12244
|
-
const provider = registry.get(name);
|
|
12306
|
+
const read = async (name, unregistered) => {
|
|
12307
|
+
const provider = registry.get(name) ?? unregistered?.();
|
|
12245
12308
|
if (!provider) {
|
|
12246
12309
|
cache.delete(name);
|
|
12247
12310
|
return [];
|
|
@@ -12283,14 +12346,21 @@ function createProviderModelCatalog(registry) {
|
|
|
12283
12346
|
});
|
|
12284
12347
|
return current.pending;
|
|
12285
12348
|
};
|
|
12286
|
-
const cached = (name) => {
|
|
12287
|
-
const provider = registry.get(name);
|
|
12349
|
+
const cached = (name, unregistered) => {
|
|
12350
|
+
const provider = registry.get(name) ?? unregistered?.();
|
|
12288
12351
|
if (!provider) return [];
|
|
12289
12352
|
const entry = cache.get(name);
|
|
12290
12353
|
const identity = createHash5("sha256").update(JSON.stringify(provider.config)).digest("hex");
|
|
12291
12354
|
return (entry?.identity === identity ? entry.models : void 0) ?? provider.adapter.modelRegistry.knownModels;
|
|
12292
12355
|
};
|
|
12293
|
-
return Object.assign(read, {
|
|
12356
|
+
return Object.assign((name) => read(name), {
|
|
12357
|
+
cached: (name) => cached(name),
|
|
12358
|
+
/** The same reads, falling back to `unregistered` when the registry has no connection under the name. */
|
|
12359
|
+
orUnregistered: (unregistered) => ({
|
|
12360
|
+
read: (name) => read(name, unregistered),
|
|
12361
|
+
cached: (name) => cached(name, unregistered)
|
|
12362
|
+
})
|
|
12363
|
+
});
|
|
12294
12364
|
}
|
|
12295
12365
|
|
|
12296
12366
|
// src/scheduler.ts
|
|
@@ -13115,9 +13185,9 @@ function gaRefreshDays(now = /* @__PURE__ */ new Date()) {
|
|
|
13115
13185
|
return Math.max(30, reach);
|
|
13116
13186
|
}
|
|
13117
13187
|
function queuedRun(result) {
|
|
13118
|
-
const
|
|
13119
|
-
const runId =
|
|
13120
|
-
const runStatus =
|
|
13188
|
+
const record = asRecord(result);
|
|
13189
|
+
const runId = record?.runId ?? record?.id;
|
|
13190
|
+
const runStatus = record?.status;
|
|
13121
13191
|
return {
|
|
13122
13192
|
runId: typeof runId === "string" ? runId : null,
|
|
13123
13193
|
runStatus: typeof runStatus === "string" ? runStatus : null
|
|
@@ -15090,6 +15160,8 @@ ${lines.join("\n")}
|
|
|
15090
15160
|
* that names no provider returns to it.
|
|
15091
15161
|
*/
|
|
15092
15162
|
async acquireForTurn(projectName, preferences) {
|
|
15163
|
+
preferences?.signal?.throwIfAborted();
|
|
15164
|
+
await refreshAgentModels(this.turnProvider(projectName, preferences), preferences?.signal);
|
|
15093
15165
|
preferences?.signal?.throwIfAborted();
|
|
15094
15166
|
if (this.acquisitions.has(projectName)) throw agentBusy(projectName);
|
|
15095
15167
|
const agent = this.getOrCreate(projectName, preferences);
|
|
@@ -15226,11 +15298,31 @@ ${lines.join("\n")}
|
|
|
15226
15298
|
const stored = coerceAgentProvider(current.provider ?? void 0);
|
|
15227
15299
|
const provider = preferences?.provider ?? pinned ?? stored ?? detectAgentProvider(this.opts.config);
|
|
15228
15300
|
if (!provider) throw new Error(missingProviderMessage());
|
|
15229
|
-
const carried = !preferences?.provider && !pinned && provider === current.provider && current.modelId && isAgentModelAvailable(provider, current.modelId) ? current.modelId : void 0;
|
|
15301
|
+
const carried = !preferences?.provider && !pinned && provider === current.provider && current.modelId && (isAgentModelAvailable(provider, current.modelId) || isAgentModelUnchecked(provider, current.modelId) && !!resolveApiKeyFor(provider, this.opts.config)) ? current.modelId : void 0;
|
|
15230
15302
|
const pinnedModelId = provider === pinned ? this.opts.config.agent?.model ?? void 0 : void 0;
|
|
15231
15303
|
const modelId = preferences?.modelId ?? pinnedModelId ?? carried ?? getAgentProvider(provider).defaultModel;
|
|
15232
15304
|
return { provider, modelId };
|
|
15233
15305
|
}
|
|
15306
|
+
/** The provider the next turn would run on; undefined when none can (the turn then fails as before). */
|
|
15307
|
+
turnProvider(projectName, preferences) {
|
|
15308
|
+
return this.nextTurnModel(projectName, preferences)?.provider;
|
|
15309
|
+
}
|
|
15310
|
+
/**
|
|
15311
|
+
* The provider and model the next turn would run on, resolved exactly as the
|
|
15312
|
+
* turn resolves them: a request's choice, then the `agent.provider` pin, then
|
|
15313
|
+
* the conversation's stored model, then the provider default. With no
|
|
15314
|
+
* preferences this is what the dashboard shows when the operator has picked
|
|
15315
|
+
* nothing. Null when no provider can run.
|
|
15316
|
+
*/
|
|
15317
|
+
nextTurnModel(projectName, preferences) {
|
|
15318
|
+
const projectId = this.tryResolveProjectId(projectName);
|
|
15319
|
+
const row = projectId ? this.loadRow(projectId) : null;
|
|
15320
|
+
try {
|
|
15321
|
+
return this.resolveTurnModel(preferences, { provider: row?.modelProvider, modelId: row?.modelId });
|
|
15322
|
+
} catch {
|
|
15323
|
+
return null;
|
|
15324
|
+
}
|
|
15325
|
+
}
|
|
15234
15326
|
alignModel(projectName, agent, preferences) {
|
|
15235
15327
|
const projectId = this.tryResolveProjectId(projectName);
|
|
15236
15328
|
if (!projectId) return;
|
|
@@ -15241,7 +15333,7 @@ ${lines.join("\n")}
|
|
|
15241
15333
|
const { provider: nextProvider, modelId: nextModelId } = this.resolveTurnModel(preferences, { provider: row.modelProvider, modelId: row.modelId });
|
|
15242
15334
|
if (nextProvider === currentProvider && nextModelId === currentModelId) return;
|
|
15243
15335
|
agent.state.model = resolveAeroModel(nextProvider, nextModelId);
|
|
15244
|
-
agent.state.thinkingLevel = resolveAgentReasoning(process.env, this.opts.config, nextProvider);
|
|
15336
|
+
agent.state.thinkingLevel = resolveAgentReasoning(process.env, this.opts.config, nextProvider, agent.state.model.id);
|
|
15245
15337
|
this.opts.db.update(agentSessions).set({
|
|
15246
15338
|
modelProvider: nextProvider,
|
|
15247
15339
|
modelId: nextModelId,
|
|
@@ -15436,12 +15528,13 @@ ${lines.join("\n")}
|
|
|
15436
15528
|
}
|
|
15437
15529
|
insertRow(params) {
|
|
15438
15530
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
15531
|
+
const modelProvider = params.provider ?? params.modelProvider ?? AgentProviderIds.claude;
|
|
15439
15532
|
this.opts.db.insert(agentSessions).values({
|
|
15440
15533
|
id: params.id ?? crypto23.randomUUID(),
|
|
15441
15534
|
projectId: params.projectId,
|
|
15442
15535
|
systemPrompt: params.systemPrompt,
|
|
15443
|
-
modelProvider
|
|
15444
|
-
modelId: params.modelId ??
|
|
15536
|
+
modelProvider,
|
|
15537
|
+
modelId: params.modelId ?? getAgentProvider(coerceAgentProvider(modelProvider) ?? AgentProviderIds.claude).defaultModel,
|
|
15445
15538
|
messages: JSON.stringify(withoutPersistedToolDetails(params.messages)),
|
|
15446
15539
|
followUpQueue: JSON.stringify(params.followUpQueue),
|
|
15447
15540
|
createdAt: now,
|
|
@@ -15585,7 +15678,7 @@ var ViewerAeroSessions = class {
|
|
|
15585
15678
|
let handedOff = false;
|
|
15586
15679
|
try {
|
|
15587
15680
|
const client = new ApiClient(this.opts.selfApiUrl, minted.raw, { skipProbe: true, surface: "aero" });
|
|
15588
|
-
const agent = this.sessions.get(key)?.agent ?? this.createAgent(project, client);
|
|
15681
|
+
const agent = this.sessions.get(key)?.agent ?? await this.createAgent(project, client, preferences.signal);
|
|
15589
15682
|
agent.state.messages = trimViewerTranscript(agent.state.messages.filter((message) => message.role !== "system"));
|
|
15590
15683
|
const view = { client, projectName: project.name, basePath: this.opts.config.basePath, context: preferences.context };
|
|
15591
15684
|
const evidence = preferences.context ? await readAeroViewEvidence(view) : void 0;
|
|
@@ -15619,8 +15712,9 @@ var ViewerAeroSessions = class {
|
|
|
15619
15712
|
}
|
|
15620
15713
|
}
|
|
15621
15714
|
}
|
|
15622
|
-
createAgent(project, client) {
|
|
15715
|
+
async createAgent(project, client, signal) {
|
|
15623
15716
|
const { provider, modelId } = resolveSessionProviderAndModel(this.opts.config);
|
|
15717
|
+
await refreshAgentModels(provider, signal);
|
|
15624
15718
|
return createAeroSession({
|
|
15625
15719
|
projectName: project.name,
|
|
15626
15720
|
client,
|
|
@@ -16042,8 +16136,9 @@ function registerAgentRoutes(app, opts) {
|
|
|
16042
16136
|
requireInstanceAdministrator(request);
|
|
16043
16137
|
const project = resolveProject(opts.db, request.params.name);
|
|
16044
16138
|
const row = opts.db.select().from(agentSessions).where(eq28(agentSessions.projectId, project.id)).get();
|
|
16139
|
+
const nextTurn = opts.sessionRegistry.nextTurnModel(project.name);
|
|
16045
16140
|
if (!row) {
|
|
16046
|
-
return { conversationId: null, messages: [], modelProvider: null, modelId: null, updatedAt: null };
|
|
16141
|
+
return { conversationId: null, messages: [], modelProvider: null, modelId: null, nextTurn, updatedAt: null };
|
|
16047
16142
|
}
|
|
16048
16143
|
const messages = parseJsonColumn(row.messages, []);
|
|
16049
16144
|
return {
|
|
@@ -16052,6 +16147,7 @@ function registerAgentRoutes(app, opts) {
|
|
|
16052
16147
|
isStreaming: opts.sessionRegistry.isBusy(project.name),
|
|
16053
16148
|
modelProvider: row.modelProvider,
|
|
16054
16149
|
modelId: row.modelId,
|
|
16150
|
+
nextTurn,
|
|
16055
16151
|
updatedAt: row.updatedAt
|
|
16056
16152
|
};
|
|
16057
16153
|
}
|
|
@@ -16061,7 +16157,7 @@ function registerAgentRoutes(app, opts) {
|
|
|
16061
16157
|
async (request) => {
|
|
16062
16158
|
requireInstanceAdministrator(request);
|
|
16063
16159
|
resolveProject(opts.db, request.params.name);
|
|
16064
|
-
return buildAgentProvidersResponse(opts.sessionRegistry.getConfig());
|
|
16160
|
+
return buildAgentProvidersResponse(opts.sessionRegistry.getConfig(), { models: true });
|
|
16065
16161
|
}
|
|
16066
16162
|
);
|
|
16067
16163
|
app.delete(
|
|
@@ -16292,6 +16388,7 @@ function pickExplainProvider(config, providerOverride) {
|
|
|
16292
16388
|
function createRecommendationExplainer(opts) {
|
|
16293
16389
|
return async (input) => {
|
|
16294
16390
|
const provider = pickExplainProvider(opts.config, input.providerOverride);
|
|
16391
|
+
await refreshAgentModels(provider);
|
|
16295
16392
|
const model = resolveModelForCapability(provider, "analyze", input.modelOverride);
|
|
16296
16393
|
const prompt = buildRecommendationPrompt({
|
|
16297
16394
|
projectName: input.projectName,
|
|
@@ -16370,6 +16467,7 @@ function parseBrief(text, recommendation) {
|
|
|
16370
16467
|
function createRecommendationBriefSynthesizer(opts) {
|
|
16371
16468
|
return async (input) => {
|
|
16372
16469
|
const provider = pickExplainProvider(opts.config, input.providerOverride);
|
|
16470
|
+
await refreshAgentModels(provider);
|
|
16373
16471
|
const model = resolveModelForCapability(provider, "analyze", input.modelOverride);
|
|
16374
16472
|
const apiKey = resolveApiKeyFor(provider, opts.config);
|
|
16375
16473
|
const prompt = buildBriefPrompt({
|
|
@@ -16529,9 +16627,10 @@ var SnapshotService = class {
|
|
|
16529
16627
|
const manualCompetitors = normalizeStringList(input.competitors ?? []);
|
|
16530
16628
|
const requestedNames = input.providers === void 0 ? void 0 : [...new Set(input.providers)];
|
|
16531
16629
|
const mode = input.providerMode ?? SnapshotProviderModes.all;
|
|
16532
|
-
const providers = requestedNames === void 0 ? this.registry.getAll().filter((provider) => mode === SnapshotProviderModes.all || provider.adapter.mode === mode) : requestedNames.map((name) => {
|
|
16630
|
+
const providers = requestedNames === void 0 ? this.registry.getAll().filter((provider) => isSweepProvider(provider.adapter.name) && (mode === SnapshotProviderModes.all || provider.adapter.mode === mode)) : requestedNames.map((name) => {
|
|
16533
16631
|
const provider = this.registry.get(name);
|
|
16534
16632
|
if (!provider) throw validationError(`Snapshot provider "${name}" is not configured`);
|
|
16633
|
+
if (!isSweepProvider(name)) throw validationError("Select a concrete OpenRouter model for the snapshot");
|
|
16535
16634
|
if (mode !== SnapshotProviderModes.all && provider.adapter.mode !== mode) {
|
|
16536
16635
|
throw validationError(`Snapshot provider "${name}" does not match providerMode "${mode}"`);
|
|
16537
16636
|
}
|
|
@@ -17068,7 +17167,7 @@ async function executeResearchRun(db, registry, runId, projectId, options = {})
|
|
|
17068
17167
|
throw new Error("Configured API provider is unavailable.");
|
|
17069
17168
|
}
|
|
17070
17169
|
const period = getCurrentUsageDay();
|
|
17071
|
-
const scope = `${projectId}:${run.provider}`;
|
|
17170
|
+
const scope = `${projectId}:${providerConnectionName(run.provider)}`;
|
|
17072
17171
|
const quota = reserveDailyQueryQuota(db, {
|
|
17073
17172
|
scope,
|
|
17074
17173
|
period,
|
|
@@ -17145,13 +17244,14 @@ async function executeResearchRun(db, registry, runId, projectId, options = {})
|
|
|
17145
17244
|
if (reservation && reserved > dispatched) {
|
|
17146
17245
|
releaseDailyQueryQuota(db, { ...reservation, count: reserved - dispatched });
|
|
17147
17246
|
}
|
|
17247
|
+
const telemetryProvider = providerConnectionName(run.provider);
|
|
17148
17248
|
trackFeatureCompleted({
|
|
17149
17249
|
feature: "research",
|
|
17150
17250
|
operation: "run",
|
|
17151
17251
|
status: researchOutcomeStatus(final.status),
|
|
17152
17252
|
// Batches re-dispatched at boot are the server's own; any other batch reports who asked.
|
|
17153
17253
|
...options.trigger ? { trigger: options.trigger, ...options.trigger === OutcomeTriggers.startup ? { surface: OutcomeSurfaces.system } : {} } : requested ?? { trigger: OutcomeTriggers.manual },
|
|
17154
|
-
...PROVIDER_NAMES.includes(
|
|
17254
|
+
...PROVIDER_NAMES.includes(telemetryProvider) ? { provider: telemetryProvider } : {},
|
|
17155
17255
|
...final.status === ResearchRunStatuses.completed ? {} : fatalReason ?? classifyProviderOutcomeError(queryFailure),
|
|
17156
17256
|
durationBucket: elapsed(),
|
|
17157
17257
|
counts: { queries: final.total, snapshots: final.completed, failures: final.failed }
|
|
@@ -17578,7 +17678,8 @@ var API_ADAPTERS = [
|
|
|
17578
17678
|
claudeAdapter,
|
|
17579
17679
|
localAdapter,
|
|
17580
17680
|
perplexityAdapter,
|
|
17581
|
-
museAdapter
|
|
17681
|
+
museAdapter,
|
|
17682
|
+
openrouterAdapter
|
|
17582
17683
|
];
|
|
17583
17684
|
var BROWSER_ADAPTERS = [cdpChatgptAdapter];
|
|
17584
17685
|
var adapterMap = Object.fromEntries(
|
|
@@ -18630,8 +18731,8 @@ async function createServer(opts) {
|
|
|
18630
18731
|
getConnection: (projectName) => {
|
|
18631
18732
|
return getCloudRunConnection(opts.config, projectName);
|
|
18632
18733
|
},
|
|
18633
|
-
upsertConnection: (
|
|
18634
|
-
const updated = upsertCloudRunConnection(opts.config,
|
|
18734
|
+
upsertConnection: (record) => {
|
|
18735
|
+
const updated = upsertCloudRunConnection(opts.config, record);
|
|
18635
18736
|
saveConfigPatch(opts.config);
|
|
18636
18737
|
return updated;
|
|
18637
18738
|
},
|
|
@@ -18645,8 +18746,8 @@ async function createServer(opts) {
|
|
|
18645
18746
|
getConnection: (projectName) => {
|
|
18646
18747
|
return getWordpressTrafficConnection(opts.config, projectName);
|
|
18647
18748
|
},
|
|
18648
|
-
upsertConnection: (
|
|
18649
|
-
const updated = upsertWordpressTrafficConnection(opts.config,
|
|
18749
|
+
upsertConnection: (record) => {
|
|
18750
|
+
const updated = upsertWordpressTrafficConnection(opts.config, record);
|
|
18650
18751
|
saveConfigPatch(opts.config);
|
|
18651
18752
|
return updated;
|
|
18652
18753
|
},
|
|
@@ -18663,8 +18764,8 @@ async function createServer(opts) {
|
|
|
18663
18764
|
getConnection: (projectName) => {
|
|
18664
18765
|
return getVercelTrafficConnection(opts.config, projectName);
|
|
18665
18766
|
},
|
|
18666
|
-
upsertConnection: (
|
|
18667
|
-
const updated = upsertVercelTrafficConnection(opts.config,
|
|
18767
|
+
upsertConnection: (record) => {
|
|
18768
|
+
const updated = upsertVercelTrafficConnection(opts.config, record);
|
|
18668
18769
|
saveConfigPatch(opts.config);
|
|
18669
18770
|
return updated;
|
|
18670
18771
|
},
|
|
@@ -18681,8 +18782,8 @@ async function createServer(opts) {
|
|
|
18681
18782
|
getConnectionBySourceId: (sourceId) => {
|
|
18682
18783
|
return getCloudflareTrafficConnectionBySourceId(opts.config, sourceId);
|
|
18683
18784
|
},
|
|
18684
|
-
upsertConnection: (
|
|
18685
|
-
const updated = upsertCloudflareTrafficConnection(opts.config,
|
|
18785
|
+
upsertConnection: (record) => {
|
|
18786
|
+
const updated = upsertCloudflareTrafficConnection(opts.config, record);
|
|
18686
18787
|
saveConfigPatch(opts.config);
|
|
18687
18788
|
return updated;
|
|
18688
18789
|
},
|
|
@@ -19086,7 +19187,7 @@ async function createServer(opts) {
|
|
|
19086
19187
|
};
|
|
19087
19188
|
const sentimentWorker = new SentimentWorker(opts.db, {
|
|
19088
19189
|
configuration: loadSentimentInstallConfig,
|
|
19089
|
-
classifier: (configuration) =>
|
|
19190
|
+
classifier: (configuration) => createConfiguredSentimentClassifier(configuration, registry, loadSentimentInstallConfig),
|
|
19090
19191
|
prepare: (input) => {
|
|
19091
19192
|
const built = buildJevSentimentRequest(input);
|
|
19092
19193
|
return built.ok ? { ok: true, estimatedInputTokens: built.estimate.inputTokens } : built;
|
|
@@ -19218,6 +19319,17 @@ async function createServer(opts) {
|
|
|
19218
19319
|
await sentimentPoller.settled();
|
|
19219
19320
|
});
|
|
19220
19321
|
const providerModelCatalog = createProviderModelCatalog(registry);
|
|
19322
|
+
const aeroOpenRouterCatalog = providerModelCatalog.orUnregistered(() => {
|
|
19323
|
+
const apiKey = resolveApiKeyFor(ProviderNames.openrouter, opts.config);
|
|
19324
|
+
return apiKey ? { adapter: openrouterAdapter, config: { provider: ProviderNames.openrouter, apiKey, quotaPolicy: DEFAULT_PROVIDER_QUOTA } } : void 0;
|
|
19325
|
+
});
|
|
19326
|
+
const disconnectOpenRouterModels = openRouterModels.connect({
|
|
19327
|
+
read: () => aeroOpenRouterCatalog.read(ProviderNames.openrouter),
|
|
19328
|
+
cached: () => aeroOpenRouterCatalog.cached(ProviderNames.openrouter)
|
|
19329
|
+
});
|
|
19330
|
+
app.addHook("onClose", async () => {
|
|
19331
|
+
disconnectOpenRouterModels();
|
|
19332
|
+
});
|
|
19221
19333
|
const recordProviderChange = (name, before, after, auditContext) => {
|
|
19222
19334
|
const beforeConfig = summarizeProviderConfig(before);
|
|
19223
19335
|
const afterConfig = summarizeProviderConfig(after);
|
|
@@ -19254,7 +19366,7 @@ async function createServer(opts) {
|
|
|
19254
19366
|
sentiment: {
|
|
19255
19367
|
install: () => {
|
|
19256
19368
|
const configuration = loadSentimentInstallConfig();
|
|
19257
|
-
return { ...sentimentInstallReadiness(configuration), model: configuration.model };
|
|
19369
|
+
return { ...sentimentInstallReadiness(configuration), model: configuration.model, provider: configuration.provider };
|
|
19258
19370
|
},
|
|
19259
19371
|
previewSecret: opts.config.apiKey,
|
|
19260
19372
|
estimate: (input) => {
|
|
@@ -19511,6 +19623,7 @@ async function createServer(opts) {
|
|
|
19511
19623
|
executeDiscoveryRun({
|
|
19512
19624
|
db: opts.db,
|
|
19513
19625
|
registry,
|
|
19626
|
+
getClassifierConfig: () => loadConfig(runtimeConfigPath),
|
|
19514
19627
|
runId: input.runId,
|
|
19515
19628
|
sessionId: input.sessionId,
|
|
19516
19629
|
projectId: input.projectId,
|