@canonry/canonry 7.100.0 → 7.102.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/agent-workspace/skills/aero/references/site-health.md +11 -1
- package/assets/agent-workspace/skills/canonry/references/canonry-cli.md +18 -5
- package/assets/assets/{AccessControls-DzO5Y8v9.js → AccessControls-CpSlWN3W.js} +1 -1
- package/assets/assets/{AgentSetupPage-DWWovaCw.js → AgentSetupPage-0le_Bx7d.js} +4 -4
- package/assets/assets/AuditHistoryPanel-BQH1dQ4V.js +1 -0
- package/assets/assets/{BacklinksPage-D6wdOMXt.js → BacklinksPage-_ffwmtrl.js} +1 -1
- package/assets/assets/{ChartPrimitives-CtKdkn64.js → ChartPrimitives-6Yq_3ION.js} +1 -1
- package/assets/assets/{HistoryPage-B_ReWHbL.js → HistoryPage-DUR17GrK.js} +1 -1
- package/assets/assets/MeasurementPropertyPage-dutXSW7s.js +4 -0
- package/assets/assets/ProjectPage-DA-07-jJ.js +15 -0
- package/assets/assets/{RunsPage-DxN0xXQh.js → RunsPage-Bs4f0-sW.js} +1 -1
- package/assets/assets/{ServerTrafficSection-CvISj5pf.js → ServerTrafficSection-qMBbUI-0.js} +5 -5
- package/assets/assets/{SettingsPage-CpRpBlMV.js → SettingsPage-Bccypqbr.js} +1 -1
- package/assets/assets/ToneBadge-DvK4cIwq.js +60 -0
- package/assets/assets/{TrafficPage-zk6zMZyz.js → TrafficPage-BPojOqd_.js} +1 -1
- package/assets/assets/{TrafficSourceDetailPage-DJtsI06Z.js → TrafficSourceDetailPage-DSoQk94d.js} +1 -1
- package/assets/assets/{account-context-CoJVqEXZ.js → account-context-evpXzY8L.js} +1 -1
- package/assets/assets/{agent-trust-copy-BIXDMtBm.js → agent-trust-copy-CkaSg2FT.js} +1 -1
- package/assets/assets/{card-Dwmc7Srx.js → card-01OafAPU.js} +1 -1
- package/assets/assets/{index-fh1T5JQY.css → index-DPz1idfn.css} +1 -1
- package/assets/assets/index-StZErOkd.js +43 -0
- package/assets/assets/{query-client-Tg1fZu4i.js → query-client-D6xwAuZW.js} +1 -1
- package/assets/assets/react-query-CdE7FNH6.js +1 -0
- package/assets/assets/{react-sigma_core.esm.min-D1q0DR_j.js → react-sigma_core.esm.min-DlfcmDYc.js} +1 -1
- package/assets/assets/{server-traffic-Djnh_9f0.js → server-traffic-yEflW4RI.js} +1 -1
- package/assets/assets/{service-BQjBdN4O.js → service-DfuRVpyN.js} +1 -1
- package/assets/index.html +9 -9
- package/dist/{ads-FVPZ6R6Z.js → ads-UDJVYKHF.js} +3 -3
- package/dist/{agent-2LPU2E5I.js → agent-EOB54XNS.js} +7 -7
- package/dist/{agent-ask-5ODREK6D.js → agent-ask-5V4LX4VW.js} +3 -3
- package/dist/{agent-conversations-SNLOOJEM.js → agent-conversations-OAF6RCFP.js} +3 -3
- package/dist/{agent-journeys-XDXVL6PK.js → agent-journeys-GETB4UGM.js} +3 -3
- package/dist/{agent-memory-NKAI2S3U.js → agent-memory-JXHPH6H5.js} +3 -3
- package/dist/{agent-providers-R5L7A72X.js → agent-providers-AAUCUOKY.js} +3 -3
- package/dist/{agent-transcript-C5WAGYVC.js → agent-transcript-WT4QH3ZY.js} +3 -3
- package/dist/{analytics-EJVOLIQL.js → analytics-JEZWLRTZ.js} +3 -3
- package/dist/{apply-I6JOM247.js → apply-LDIMMO4N.js} +3 -3
- package/dist/{backfill-UVUR36IB.js → backfill-JOJHBVGV.js} +10 -10
- package/dist/{backlinks-3VMVACWN.js → backlinks-D2O3UM6F.js} +3 -3
- package/dist/{bing-R5RL3PW2.js → bing-BG7KZZPK.js} +3 -3
- package/dist/{bootstrap-GMMSDTNO.js → bootstrap-IXVATZLB.js} +10 -10
- package/dist/{cdp-FJKUXHEY.js → cdp-3AJG7OLP.js} +7 -7
- package/dist/{chunk-COHSL6KW.js → chunk-2YLTELT2.js} +1 -1
- package/dist/{chunk-7SNMIXEQ.js → chunk-3TPHFDZN.js} +2 -2
- package/dist/{chunk-EE3QTCLS.js → chunk-4CF5536B.js} +31 -1
- package/dist/{chunk-O6APBEJE.js → chunk-66EXWVMN.js} +2 -2
- package/dist/{chunk-2DV7F6XA.js → chunk-7I2NJ4BH.js} +168 -1
- package/dist/{chunk-T7UDY7W3.js → chunk-7JJCFGL2.js} +3 -3
- package/dist/{chunk-QS5DWJDI.js → chunk-AENOUFTF.js} +2 -2
- package/dist/{chunk-F46TBLXK.js → chunk-AG6BTE7R.js} +23 -14
- package/dist/{chunk-YU2WX7RD.js → chunk-BDLHLE2F.js} +3 -3
- package/dist/{chunk-O5UFAXUI.js → chunk-BG6TVNA6.js} +445 -388
- package/dist/{chunk-J6536OL6.js → chunk-C2YVADFC.js} +1 -1
- package/dist/{chunk-LNVFERI4.js → chunk-CZOGOHIN.js} +1 -1
- package/dist/{chunk-SWZXHHAG.js → chunk-DP3FE2OW.js} +5 -5
- package/dist/{chunk-KVRX7YIH.js → chunk-DRNBMKR5.js} +6 -6
- package/dist/{chunk-LJO2BKWU.js → chunk-EXPBZFN4.js} +1 -1
- package/dist/{chunk-G6QN4VFS.js → chunk-FHK6M4RK.js} +3 -3
- package/dist/{chunk-7BH53MOB.js → chunk-G4ODBZO7.js} +4 -1
- package/dist/{chunk-DGDLLRS4.js → chunk-GLKR6C2L.js} +1 -1
- package/dist/{chunk-AMGM55CP.js → chunk-IBRABPHA.js} +2 -2
- package/dist/{chunk-DHIB7EIA.js → chunk-LGTSVS6Q.js} +4 -4
- package/dist/{chunk-HL2LGRTI.js → chunk-M25KDHD4.js} +1 -1
- package/dist/{chunk-RBG2QXQM.js → chunk-N4VEG6GB.js} +4 -4
- package/dist/{chunk-VHULVUDL.js → chunk-N7773GJW.js} +1 -1
- package/dist/{chunk-AYKTVQF7.js → chunk-NAJ3ZYZ2.js} +3 -3
- package/dist/{chunk-O7S7OHLE.js → chunk-NHBXQWE3.js} +452 -149
- package/dist/{chunk-NQYJHKML.js → chunk-NJZVDUKD.js} +3 -3
- package/dist/{chunk-HBHLYWKE.js → chunk-O5AIKUW3.js} +1 -1
- package/dist/{chunk-BKDRT4VS.js → chunk-ONHBQYSA.js} +7 -7
- package/dist/{chunk-FZ3MUTU3.js → chunk-QK4IICRM.js} +2 -2
- package/dist/{chunk-FBO25TA3.js → chunk-RXWD25P7.js} +1 -1
- package/dist/{chunk-UGO2FO6V.js → chunk-S7ZOYNW3.js} +38 -6
- package/dist/{chunk-YIIRS7V7.js → chunk-UX6XWC4F.js} +5 -5
- package/dist/{chunk-YGAQQSCL.js → chunk-VH424YVI.js} +2669 -1207
- package/dist/{chunk-7BEGCVVB.js → chunk-WNR3YQAD.js} +1 -1
- package/dist/{chunk-56VVRWJM.js → chunk-YTR2S4MU.js} +4 -4
- package/dist/{chunk-7J2RIIYU.js → chunk-ZIKPEZ3K.js} +370 -32
- package/dist/{citations-LOEQRDUB.js → citations-GM42U2ZH.js} +4 -4
- package/dist/{cli-catalog-5RXNUFBS.js → cli-catalog-EMZPMAJP.js} +3 -3
- package/dist/{cli-commands-HE2BQY3Y.js → cli-commands-VDMZAETM.js} +7 -7
- package/dist/cli.js +13 -13
- package/dist/{competitor-PIX2BHJW.js → competitor-4ZLKGNQW.js} +3 -3
- package/dist/{content-PJGW4WZF.js → content-YJRMT4JW.js} +3 -3
- package/dist/{dashboard-7OKBD4MG.js → dashboard-L4EE3C5T.js} +6 -6
- package/dist/{demo-SCOFAWFM.js → demo-3XDVCUT5.js} +1 -1
- package/dist/{demo-server-SJPI6RSL.js → demo-server-7ZJWSGE2.js} +12 -12
- package/dist/{discover-I3WL2QUN.js → discover-SQGUDXSU.js} +4 -4
- package/dist/{discover-eval-YRECOIP5.js → discover-eval-BUNKP6EW.js} +3 -3
- package/dist/{doctor-F4J6LILX.js → doctor-HPIGLMRX.js} +3 -3
- package/dist/{evidence-MYQTCY4V.js → evidence-JKEM5BYW.js} +3 -3
- package/dist/{export-cmd-3SUFOJM6.js → export-cmd-KTQM455W.js} +3 -3
- package/dist/{ga-VA6FYK4L.js → ga-D7ZLTSSA.js} +3 -3
- package/dist/{gbp-DI6ZVFHL.js → gbp-OWBX2BFK.js} +3 -3
- package/dist/{google-UVKWJCD2.js → google-UNAGUCXQ.js} +4 -4
- package/dist/{google-marketing-S63HN733.js → google-marketing-AZC7WHZR.js} +1 -1
- package/dist/{health-cmd-DOZXGI46.js → health-cmd-XHEDL6CF.js} +4 -4
- package/dist/{history-UTJTUDYK.js → history-MKQDN6LY.js} +3 -3
- package/dist/index.d.ts +920 -8
- package/dist/index.js +25 -25
- package/dist/{init-IVJSS33J.js → init-W4LWSMCC.js} +12 -12
- package/dist/{insights-UHCVCZ76.js → insights-HNJR7UEC.js} +3 -3
- package/dist/intelligence-service-SWQABQ3X.js +16 -0
- package/dist/{journeys-XIT7WDM2.js → journeys-RQBYPWHU.js} +3 -3
- package/dist/{keys-MQKW4JUI.js → keys-KNZAMXJU.js} +3 -3
- package/dist/{keyword-EASMKYZ3.js → keyword-7SUZG7RB.js} +3 -3
- package/dist/{logs-ZHZ6XM55.js → logs-RTQFOKLJ.js} +3 -3
- package/dist/{mcp-ECVT2YGU.js → mcp-JWBPAYR4.js} +4 -4
- package/dist/mcp.js +9 -9
- package/dist/{measurement-plan-7FQKUOMR.js → measurement-plan-AETWMIGC.js} +5 -5
- package/dist/{notify-TC7ARC6W.js → notify-DGFNKFVG.js} +3 -3
- package/dist/{organic-evidence-M34MWJXE.js → organic-evidence-VA47O6HU.js} +3 -3
- package/dist/{overview-P6BRMXJN.js → overview-SMXNZLPG.js} +5 -5
- package/dist/{project-WZ2YXFPJ.js → project-WXEDQJLS.js} +28 -5
- package/dist/{project-setup-WV6SPGIV.js → project-setup-VFBTUA5W.js} +3 -3
- package/dist/{query-WAFJKDHG.js → query-C2VIB2XW.js} +3 -3
- package/dist/{research-B5ZPQX7R.js → research-76TYES7M.js} +3 -3
- package/dist/{results-export-NIZV6R3K.js → results-export-F4FKVOQN.js} +3 -3
- package/dist/{run-ICLPZ7QT.js → run-H6GGXFKQ.js} +5 -5
- package/dist/{schedule-4C44LQ7R.js → schedule-KTQNJGMO.js} +3 -3
- package/dist/{search-UJM7KII3.js → search-YRFUC7SW.js} +3 -3
- package/dist/{serve-A6UIO6WP.js → serve-PWIVPUX7.js} +26 -26
- package/dist/{session-RTE22GQT.js → session-LRR2N6IP.js} +13 -13
- package/dist/{settings-BOF5Z7ML.js → settings-TLDN77K4.js} +3 -3
- package/dist/{sitemaps-BM7S76H2.js → sitemaps-BQ6JI4EW.js} +3 -3
- package/dist/{skills-X5SR4HRO.js → skills-SQBKFXAN.js} +2 -2
- package/dist/{snapshot-KLKE37VY.js → snapshot-ICGETMOY.js} +3 -3
- package/dist/{src-EKLG5A6O.js → src-XW5T4IQS.js} +10 -2
- package/dist/{status-OYG57DWU.js → status-VN65JTUD.js} +5 -5
- package/dist/{technical-aeo-KWVWOOTI.js → technical-aeo-OBCWTN3M.js} +27 -8
- package/dist/{telemetry-KGE6FF3Y.js → telemetry-ZU6REKKU.js} +4 -4
- package/dist/{tools-4R33AZQ3.js → tools-RQDMCSZB.js} +11 -11
- package/dist/{traffic-SVMOKCSS.js → traffic-YLZSRX5P.js} +5 -5
- package/dist/{trends-RGAKGX3L.js → trends-OWWELIE2.js} +3 -3
- package/dist/{users-47WKA2TO.js → users-2ICURHTW.js} +54 -4
- package/dist/{visibility-stats-DTGQJPNV.js → visibility-stats-FJK3MDYE.js} +4 -4
- package/dist/{wordpress-2CNUX4UE.js → wordpress-UQFA5TFU.js} +3 -3
- package/package.json +2 -2
- package/assets/assets/AuditHistoryPanel-BG-n1i8c.js +0 -1
- package/assets/assets/MeasurementPropertyPage-zdyLL-kl.js +0 -4
- package/assets/assets/ProjectPage-KZNKXR4w.js +0 -15
- package/assets/assets/ToneBadge-DcwPruHr.js +0 -60
- package/assets/assets/index-mqc2mWUR.js +0 -42
- package/assets/assets/react-query-BqcEEfEO.js +0 -1
- package/dist/intelligence-service-3EENJ5DS.js +0 -16
|
@@ -23,18 +23,18 @@ import {
|
|
|
23
23
|
resolveConfiguredAgentProvider,
|
|
24
24
|
resolveSessionProviderAndModel,
|
|
25
25
|
setAeroSystemPrompt
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-DRNBMKR5.js";
|
|
27
27
|
import {
|
|
28
28
|
answerServiceAdapters,
|
|
29
29
|
answerServiceDescriptors
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-M25KDHD4.js";
|
|
31
31
|
import {
|
|
32
32
|
AeroToolProfiles,
|
|
33
33
|
AeroToolScopes,
|
|
34
34
|
buildAeroStateTools,
|
|
35
35
|
isAeroToolProfile,
|
|
36
36
|
truncateToolResult
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-YTR2S4MU.js";
|
|
38
38
|
import {
|
|
39
39
|
getGoogleAuthConfig,
|
|
40
40
|
getGoogleConnection,
|
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
removeCloudflareTrafficConnection,
|
|
54
54
|
removeCloudflareTrafficConnectionBySourceId,
|
|
55
55
|
upsertCloudflareTrafficConnection
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-N7773GJW.js";
|
|
57
57
|
import {
|
|
58
58
|
claudeAdapter,
|
|
59
59
|
embedQueries,
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
openrouterAdapter,
|
|
66
66
|
perplexityAdapter,
|
|
67
67
|
startTrafficReclassification
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-UX6XWC4F.js";
|
|
69
69
|
import {
|
|
70
70
|
classifyUsageSurface,
|
|
71
71
|
createApiUsageTelemetry,
|
|
@@ -77,7 +77,7 @@ import {
|
|
|
77
77
|
startOutcomeTimer,
|
|
78
78
|
trackFeatureCompleted,
|
|
79
79
|
trackInstallState
|
|
80
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-LGTSVS6Q.js";
|
|
81
81
|
import {
|
|
82
82
|
isLoopbackBindHost
|
|
83
83
|
} from "./chunk-TSENU4GG.js";
|
|
@@ -85,7 +85,7 @@ import {
|
|
|
85
85
|
isApiProviderRegistrable,
|
|
86
86
|
isCdpProviderRegistrable,
|
|
87
87
|
registeredProviderNames
|
|
88
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-2YLTELT2.js";
|
|
89
89
|
import {
|
|
90
90
|
checkLatestVersionForServer,
|
|
91
91
|
getOrCreateAnonymousId,
|
|
@@ -97,21 +97,23 @@ import {
|
|
|
97
97
|
recordDashboardEvent,
|
|
98
98
|
setTelemetryPreference,
|
|
99
99
|
trackEvent
|
|
100
|
-
} from "./chunk-
|
|
100
|
+
} from "./chunk-IBRABPHA.js";
|
|
101
101
|
import {
|
|
102
102
|
createCanonryMcpServer
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-FHK6M4RK.js";
|
|
104
104
|
import {
|
|
105
105
|
CANONRY_MCP_TIERS,
|
|
106
106
|
CANONRY_MCP_TOOLKIT_NAMES
|
|
107
107
|
} from "./chunk-2FWYWGIR.js";
|
|
108
108
|
import {
|
|
109
109
|
ApiClient
|
|
110
|
-
} from "./chunk-
|
|
110
|
+
} from "./chunk-S7ZOYNW3.js";
|
|
111
111
|
import {
|
|
112
112
|
AGENT_PROVIDERS,
|
|
113
|
+
PROVIDER_MODELS,
|
|
113
114
|
adapterSupportsBatch,
|
|
114
115
|
aeroModels,
|
|
116
|
+
aeroStreamFn,
|
|
115
117
|
agentProviderApiKeyEnvVar,
|
|
116
118
|
agentProvidersByPriority,
|
|
117
119
|
batchEligibleProviderNames,
|
|
@@ -140,21 +142,21 @@ import {
|
|
|
140
142
|
saveConfigPatch,
|
|
141
143
|
sentimentInstallReadiness,
|
|
142
144
|
updateSharedProviderExecutionGate
|
|
143
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-4CF5536B.js";
|
|
144
146
|
import {
|
|
145
147
|
getBundledSkillSnapshots
|
|
146
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-RXWD25P7.js";
|
|
147
149
|
import {
|
|
148
150
|
computeFactorAverages,
|
|
149
151
|
deleteSiteCrawlGraphLayout,
|
|
150
152
|
persistSiteCrawlGraphLayout,
|
|
151
153
|
prepareSiteCrawlGraphLayout,
|
|
152
154
|
recordedSharePct
|
|
153
|
-
} from "./chunk-
|
|
155
|
+
} from "./chunk-QK4IICRM.js";
|
|
154
156
|
import {
|
|
155
157
|
CanonryMcpToolNames,
|
|
156
158
|
canonryMcpTools
|
|
157
|
-
} from "./chunk-
|
|
159
|
+
} from "./chunk-AG6BTE7R.js";
|
|
158
160
|
import {
|
|
159
161
|
PACKAGE_VERSION
|
|
160
162
|
} from "./chunk-AOJU5LKX.js";
|
|
@@ -163,19 +165,21 @@ import {
|
|
|
163
165
|
} from "./chunk-HGMYEDAQ.js";
|
|
164
166
|
import {
|
|
165
167
|
IntelligenceService
|
|
166
|
-
} from "./chunk-
|
|
168
|
+
} from "./chunk-DP3FE2OW.js";
|
|
167
169
|
import {
|
|
168
170
|
computeCitedCompetitorDomains,
|
|
169
171
|
determineCitationState
|
|
170
|
-
} from "./chunk-
|
|
172
|
+
} from "./chunk-O5AIKUW3.js";
|
|
171
173
|
import {
|
|
172
174
|
addLogListener,
|
|
173
175
|
createFastifyLogger,
|
|
174
176
|
createLogger
|
|
175
|
-
} from "./chunk-
|
|
177
|
+
} from "./chunk-3TPHFDZN.js";
|
|
176
178
|
import {
|
|
177
179
|
BingApiError,
|
|
178
180
|
CC_CACHE_DIR,
|
|
181
|
+
ChatGptAccounts,
|
|
182
|
+
ChatGptPlanError,
|
|
179
183
|
DUCKDB_SPEC,
|
|
180
184
|
EgressFailedError,
|
|
181
185
|
EgressRefusedError,
|
|
@@ -280,6 +284,7 @@ import {
|
|
|
280
284
|
nextRunFromSchedule,
|
|
281
285
|
notProbeRun,
|
|
282
286
|
parseBingDate,
|
|
287
|
+
parseChatGptTokenKey,
|
|
283
288
|
parseCookieHeader,
|
|
284
289
|
previewCompetitorAutoAliases,
|
|
285
290
|
probeLatestRelease,
|
|
@@ -317,7 +322,7 @@ import {
|
|
|
317
322
|
webhookResponseReason,
|
|
318
323
|
webhookTargetRefusalReason,
|
|
319
324
|
writeAuditLog
|
|
320
|
-
} from "./chunk-
|
|
325
|
+
} from "./chunk-VH424YVI.js";
|
|
321
326
|
import {
|
|
322
327
|
OperationalLogStore,
|
|
323
328
|
SentimentIdempotencyConflict,
|
|
@@ -416,7 +421,7 @@ import {
|
|
|
416
421
|
unrecognizedAgentEventsHourly,
|
|
417
422
|
unrecognizedAgentNotifyState,
|
|
418
423
|
usageCounters
|
|
419
|
-
} from "./chunk-
|
|
424
|
+
} from "./chunk-7I2NJ4BH.js";
|
|
420
425
|
import {
|
|
421
426
|
AGENT_MEMORY_VALUE_MAX_BYTES,
|
|
422
427
|
AI_ENGINE_DOMAINS,
|
|
@@ -427,9 +432,12 @@ import {
|
|
|
427
432
|
AppError,
|
|
428
433
|
BacklinkSources,
|
|
429
434
|
BingSiteSnapshotKinds,
|
|
435
|
+
CHATGPT_AERO_ERRORS,
|
|
436
|
+
CHATGPT_RESOURCE,
|
|
430
437
|
CHECK_RUNTIME_ERROR_SUFFIX,
|
|
431
438
|
CITED_URL_CAPTURE_VERSION,
|
|
432
439
|
CcReleaseSyncStatuses,
|
|
440
|
+
ChatGptPlanStatuses,
|
|
433
441
|
CheckNotificationPolicies,
|
|
434
442
|
CheckStatuses,
|
|
435
443
|
CitationStates,
|
|
@@ -602,6 +610,7 @@ import {
|
|
|
602
610
|
hostOf,
|
|
603
611
|
inclusiveDayCount,
|
|
604
612
|
isBrowserProvider,
|
|
613
|
+
isChatGptAeroError,
|
|
605
614
|
isCitationMeasurable,
|
|
606
615
|
isCitationStateMeasured,
|
|
607
616
|
isEligibleFor,
|
|
@@ -655,6 +664,7 @@ import {
|
|
|
655
664
|
resolveNegativeReviewMaxStars,
|
|
656
665
|
resolveProviderModel,
|
|
657
666
|
resolveProviderRoute,
|
|
667
|
+
resolveSiteAuditDomains,
|
|
658
668
|
resolveSnapshotRequestQueries,
|
|
659
669
|
retryAfterDelayMs,
|
|
660
670
|
routeFamiliesOf,
|
|
@@ -689,7 +699,7 @@ import {
|
|
|
689
699
|
winnabilityClassLabel,
|
|
690
700
|
withRetry,
|
|
691
701
|
withSkippedProviders
|
|
692
|
-
} from "./chunk-
|
|
702
|
+
} from "./chunk-NHBXQWE3.js";
|
|
693
703
|
|
|
694
704
|
// src/google-marketing-runtime.ts
|
|
695
705
|
import crypto2 from "crypto";
|
|
@@ -6443,7 +6453,7 @@ function nonBlank(value) {
|
|
|
6443
6453
|
return trimmed ? trimmed : void 0;
|
|
6444
6454
|
}
|
|
6445
6455
|
function resolveBuildCommit(env = process.env) {
|
|
6446
|
-
const embedded = true ? "
|
|
6456
|
+
const embedded = true ? "b3e583c0cefcae761dd3c2cb452f72599528b8ab" : void 0;
|
|
6447
6457
|
return nonBlank(embedded) ?? nonBlank(env.CANONRY_COMMIT);
|
|
6448
6458
|
}
|
|
6449
6459
|
function resolveInstanceIdentity(env = process.env) {
|
|
@@ -13183,6 +13193,51 @@ function isCancelled(error, signal) {
|
|
|
13183
13193
|
function isLegacyScorecardPage(page) {
|
|
13184
13194
|
return isScoredPage(page) || page.state === "fetch-error";
|
|
13185
13195
|
}
|
|
13196
|
+
function pageSite(page, mainHost) {
|
|
13197
|
+
const host = hostOf(page.requestedUrl);
|
|
13198
|
+
return host === null || host === mainHost ? null : host;
|
|
13199
|
+
}
|
|
13200
|
+
function siteRollups(input) {
|
|
13201
|
+
const rollups = /* @__PURE__ */ new Map();
|
|
13202
|
+
const rollupOf = (site) => {
|
|
13203
|
+
const existing = rollups.get(site);
|
|
13204
|
+
if (existing) return existing;
|
|
13205
|
+
const created = { pages: 0, pagesEligible: 0, scored: [] };
|
|
13206
|
+
rollups.set(site, created);
|
|
13207
|
+
return created;
|
|
13208
|
+
};
|
|
13209
|
+
for (const page of input.pages) {
|
|
13210
|
+
if (isNonPageMedia(page)) continue;
|
|
13211
|
+
const rollup = rollupOf(pageSite(page, input.mainHost));
|
|
13212
|
+
rollup.pages += 1;
|
|
13213
|
+
if (isInventoryEligible(page)) rollup.pagesEligible += 1;
|
|
13214
|
+
if (isScoredPage(page)) rollup.scored.push(page.audit.overallScore);
|
|
13215
|
+
}
|
|
13216
|
+
const describe = (site, host, rootUrl, error) => {
|
|
13217
|
+
const rollup = rollups.get(site);
|
|
13218
|
+
const scored = rollup?.scored ?? [];
|
|
13219
|
+
return {
|
|
13220
|
+
host,
|
|
13221
|
+
main: site === null,
|
|
13222
|
+
rootUrl,
|
|
13223
|
+
pages: rollup?.pages ?? 0,
|
|
13224
|
+
pagesEligible: rollup?.pagesEligible ?? 0,
|
|
13225
|
+
pagesAudited: scored.length,
|
|
13226
|
+
aggregateScore: scored.length > 0 ? Math.round(scored.reduce((total, score) => total + score, 0) / scored.length) : null,
|
|
13227
|
+
error
|
|
13228
|
+
};
|
|
13229
|
+
};
|
|
13230
|
+
const sites = [describe(null, input.mainHost, input.mainRootUrl, null)];
|
|
13231
|
+
const listed = /* @__PURE__ */ new Set();
|
|
13232
|
+
for (const extra of input.extraSites) {
|
|
13233
|
+
listed.add(extra.host);
|
|
13234
|
+
sites.push(describe(extra.host, extra.host, extra.rootUrl, extra.error));
|
|
13235
|
+
}
|
|
13236
|
+
for (const site of [...rollups.keys()].filter((key) => key !== null && !listed.has(key)).sort()) {
|
|
13237
|
+
sites.push(describe(site, site, null, null));
|
|
13238
|
+
}
|
|
13239
|
+
return sites;
|
|
13240
|
+
}
|
|
13186
13241
|
function emptyCompleteCrawlError(rootUrl, finalRootUrl, pagesObserved) {
|
|
13187
13242
|
if (!finalRootUrl) return new Error(`Agent Readiness audit scan could not successfully audit any of ${pagesObserved} observed page(s).`);
|
|
13188
13243
|
try {
|
|
@@ -13274,6 +13329,7 @@ async function executeSiteAudit(db, runId, projectId, opts = {}) {
|
|
|
13274
13329
|
}).run();
|
|
13275
13330
|
const observedPages = /* @__PURE__ */ new Map();
|
|
13276
13331
|
const observedEdges = /* @__PURE__ */ new Map();
|
|
13332
|
+
let mainHost = null;
|
|
13277
13333
|
const nodeKeyByUrl = /* @__PURE__ */ new Map();
|
|
13278
13334
|
const nodePriorityByUrl = /* @__PURE__ */ new Map();
|
|
13279
13335
|
const registerNode = (url, nodeKey, priority, changedUrls) => {
|
|
@@ -13346,6 +13402,7 @@ async function executeSiteAudit(db, runId, projectId, opts = {}) {
|
|
|
13346
13402
|
attemptId,
|
|
13347
13403
|
nodeKey: page.key,
|
|
13348
13404
|
url: page.requestedUrl,
|
|
13405
|
+
site: pageSite(page, mainHost),
|
|
13349
13406
|
path: pagePath(page),
|
|
13350
13407
|
parentPath: parentPath(page),
|
|
13351
13408
|
discoverySource: pageDiscoverySource(page),
|
|
@@ -13385,6 +13442,7 @@ async function executeSiteAudit(db, runId, projectId, opts = {}) {
|
|
|
13385
13442
|
target: [siteCrawlPages.projectId, siteCrawlPages.runId, siteCrawlPages.attemptId, siteCrawlPages.nodeKey],
|
|
13386
13443
|
set: {
|
|
13387
13444
|
url: page.requestedUrl,
|
|
13445
|
+
site: pageSite(page, mainHost),
|
|
13388
13446
|
path: pagePath(page),
|
|
13389
13447
|
parentPath: parentPath(page),
|
|
13390
13448
|
discoverySource: pageDiscoverySource(page),
|
|
@@ -13553,7 +13611,24 @@ async function executeSiteAudit(db, runId, projectId, opts = {}) {
|
|
|
13553
13611
|
signal: opts.signal
|
|
13554
13612
|
});
|
|
13555
13613
|
const crawlRootUrl = resolvedRoot.effectiveUrl;
|
|
13614
|
+
mainHost = hostOf(crawlRootUrl);
|
|
13556
13615
|
if (opts.sitemapUrl) await assertSiteAuditUrlAllowed(opts.sitemapUrl, "sitemapUrl");
|
|
13616
|
+
const extraSites = await Promise.all(
|
|
13617
|
+
[...new Set(opts.sites ?? [])].filter((host) => host !== mainHost).map(async (host) => {
|
|
13618
|
+
try {
|
|
13619
|
+
const resolved = await resolveSiteAuditRootUrl(toHomepageUrl(host), {
|
|
13620
|
+
resolveTarget: resolveMeasurementSitemapTarget,
|
|
13621
|
+
signal: opts.signal
|
|
13622
|
+
});
|
|
13623
|
+
return { host, rootUrl: resolved.effectiveUrl, error: null };
|
|
13624
|
+
} catch (error) {
|
|
13625
|
+
if (isCancelled(error, opts.signal)) throw error;
|
|
13626
|
+
log15.warn("extra-site.unreachable", { runId, projectId, host, error: describeError(error) });
|
|
13627
|
+
return { host, rootUrl: null, error: describeError(error) };
|
|
13628
|
+
}
|
|
13629
|
+
})
|
|
13630
|
+
);
|
|
13631
|
+
const additionalRoots = extraSites.flatMap((site) => site.rootUrl ? [site.rootUrl] : []);
|
|
13557
13632
|
let entities = null;
|
|
13558
13633
|
try {
|
|
13559
13634
|
entities = activePlanEntityRegistry(db, projectId);
|
|
@@ -13569,7 +13644,8 @@ async function executeSiteAudit(db, runId, projectId, opts = {}) {
|
|
|
13569
13644
|
maxPages,
|
|
13570
13645
|
maxEdges,
|
|
13571
13646
|
maxDepth: opts.maxDepth ?? null,
|
|
13572
|
-
entityPlanRevision: entities?.planRevision ?? null
|
|
13647
|
+
entityPlanRevision: entities?.planRevision ?? null,
|
|
13648
|
+
extraSites: extraSites.map((site) => site.host)
|
|
13573
13649
|
});
|
|
13574
13650
|
const report = await runSiteCrawl(crawlRootUrl, {
|
|
13575
13651
|
mode: "summary",
|
|
@@ -13581,6 +13657,7 @@ async function executeSiteAudit(db, runId, projectId, opts = {}) {
|
|
|
13581
13657
|
includeGeo: opts.includeGeo ?? false,
|
|
13582
13658
|
includeAgentSkills: opts.includeAgentSkills ?? true,
|
|
13583
13659
|
skipUrlVersionsAfter: SITE_AUDIT_SKIP_URL_VERSIONS_AFTER,
|
|
13660
|
+
...additionalRoots.length > 0 ? { additionalRoots } : {},
|
|
13584
13661
|
...entities ? { entityRegistry: entities.registry } : {},
|
|
13585
13662
|
signal: opts.signal,
|
|
13586
13663
|
onEvent: persistEvent
|
|
@@ -13625,6 +13702,13 @@ async function executeSiteAudit(db, runId, projectId, opts = {}) {
|
|
|
13625
13702
|
const deadLinksUnverified = new Set(unverifiedLinks.map((finding) => finding.to)).size;
|
|
13626
13703
|
const legacyIssues = factors.map((factor) => toLegacyIssue(factor, pagesAudited)).filter((issue) => issue !== null);
|
|
13627
13704
|
const issueEvidence = buildSiteCrawlIssueEvidence(crawlSummary.siteIssues, pageObservations);
|
|
13705
|
+
const finalRootUrl = crawlSummary.finalRootUrl ?? crawlSummary.rootUrl;
|
|
13706
|
+
const sites = siteRollups({
|
|
13707
|
+
mainHost: mainHost ?? hostOf(finalRootUrl) ?? new URL(finalRootUrl).hostname,
|
|
13708
|
+
mainRootUrl: finalRootUrl,
|
|
13709
|
+
extraSites,
|
|
13710
|
+
pages: observedPages.values()
|
|
13711
|
+
});
|
|
13628
13712
|
try {
|
|
13629
13713
|
persistSiteCrawlGraphLayout(db, { projectId, runId, attemptId }, graphLayout, finishedAt);
|
|
13630
13714
|
} catch (error) {
|
|
@@ -13712,7 +13796,9 @@ async function executeSiteAudit(db, runId, projectId, opts = {}) {
|
|
|
13712
13796
|
includeGeo: opts.includeGeo ?? false,
|
|
13713
13797
|
includeAgentSkills: opts.includeAgentSkills ?? true,
|
|
13714
13798
|
// The plan revision whose Properties pages were checked against; null when none were.
|
|
13715
|
-
entityPlanRevision: entities?.planRevision ?? null
|
|
13799
|
+
entityPlanRevision: entities?.planRevision ?? null,
|
|
13800
|
+
// Owned domains asked for besides the main domain, as bare hosts.
|
|
13801
|
+
sites: extraSites.map((site) => site.host)
|
|
13716
13802
|
},
|
|
13717
13803
|
pageBudget: maxPages,
|
|
13718
13804
|
edgeBudget: maxEdges ?? null,
|
|
@@ -13734,6 +13820,7 @@ async function executeSiteAudit(db, runId, projectId, opts = {}) {
|
|
|
13734
13820
|
deadLinksUnverified,
|
|
13735
13821
|
templateDetection: templateLinks.detection,
|
|
13736
13822
|
linkPlacementRulesetVersion: placementRulesetVersion,
|
|
13823
|
+
sites,
|
|
13737
13824
|
createdAt: finishedAt,
|
|
13738
13825
|
updatedAt: finishedAt
|
|
13739
13826
|
}).run();
|
|
@@ -14723,7 +14810,8 @@ var Scheduler = class {
|
|
|
14723
14810
|
}
|
|
14724
14811
|
const runId2 = crypto23.randomUUID();
|
|
14725
14812
|
const checks = siteAuditScheduleChecks(currentSchedule.siteAuditChecks);
|
|
14726
|
-
const
|
|
14813
|
+
const savedSites = resolveSiteAuditDomains(project, project.siteAuditDomains).domains;
|
|
14814
|
+
const effectiveRequest = normalizeSiteAuditRunRequest(checks, project.siteAuditMaxPages, savedSites);
|
|
14727
14815
|
this.db.transaction((tx) => {
|
|
14728
14816
|
tx.insert(runs).values({
|
|
14729
14817
|
id: runId2,
|
|
@@ -14750,7 +14838,8 @@ var Scheduler = class {
|
|
|
14750
14838
|
maxPages: effectiveRequest.maxPages,
|
|
14751
14839
|
checkDeadLinks: effectiveRequest.checkDeadLinks,
|
|
14752
14840
|
includeGeo: effectiveRequest.includeGeo,
|
|
14753
|
-
includeAgentSkills: effectiveRequest.includeAgentSkills
|
|
14841
|
+
includeAgentSkills: effectiveRequest.includeAgentSkills,
|
|
14842
|
+
sites: effectiveRequest.sites
|
|
14754
14843
|
});
|
|
14755
14844
|
return SLOT_FIRED;
|
|
14756
14845
|
}
|
|
@@ -18136,6 +18225,139 @@ ${lines.join("\n")}
|
|
|
18136
18225
|
// src/agent/viewer-sessions.ts
|
|
18137
18226
|
import crypto28 from "crypto";
|
|
18138
18227
|
import { and as and27, eq as eq33, isNotNull as isNotNull4, like as like2 } from "drizzle-orm";
|
|
18228
|
+
|
|
18229
|
+
// src/agent/chatgpt-plan.ts
|
|
18230
|
+
import { createAssistantMessageEventStream } from "@earendil-works/pi-ai";
|
|
18231
|
+
var CHATGPT_TOOL_NAMESPACE = "canonry";
|
|
18232
|
+
var ZERO_COST = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
18233
|
+
function chatGptPlanModel(modelId) {
|
|
18234
|
+
const known = aeroModels.getModel("openai", modelId);
|
|
18235
|
+
const base = known ?? {
|
|
18236
|
+
id: modelId,
|
|
18237
|
+
name: modelId,
|
|
18238
|
+
api: "openai-responses",
|
|
18239
|
+
provider: "openai",
|
|
18240
|
+
baseUrl: CHATGPT_RESOURCE,
|
|
18241
|
+
reasoning: false,
|
|
18242
|
+
input: ["text"],
|
|
18243
|
+
contextWindow: 128e3,
|
|
18244
|
+
maxTokens: 32e3,
|
|
18245
|
+
cost: ZERO_COST
|
|
18246
|
+
};
|
|
18247
|
+
return { ...base, api: "openai-responses", provider: "openai", baseUrl: CHATGPT_RESOURCE, cost: ZERO_COST };
|
|
18248
|
+
}
|
|
18249
|
+
function asRecord2(value) {
|
|
18250
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
18251
|
+
}
|
|
18252
|
+
function namespaceChatGptPayload(payload) {
|
|
18253
|
+
const params = asRecord2(payload);
|
|
18254
|
+
if (!params) return void 0;
|
|
18255
|
+
const input = Array.isArray(params.input) ? params.input.map((item) => {
|
|
18256
|
+
const record = asRecord2(item);
|
|
18257
|
+
if (!record) return item;
|
|
18258
|
+
if (record.role === "system") return { ...record, role: "developer" };
|
|
18259
|
+
if ((record.type === "function_call" || record.type === "custom_tool_call") && record.namespace === void 0) {
|
|
18260
|
+
return { ...record, namespace: CHATGPT_TOOL_NAMESPACE };
|
|
18261
|
+
}
|
|
18262
|
+
return item;
|
|
18263
|
+
}) : params.input;
|
|
18264
|
+
const tools = Array.isArray(params.tools) ? params.tools : [];
|
|
18265
|
+
return {
|
|
18266
|
+
...params,
|
|
18267
|
+
input,
|
|
18268
|
+
...tools.length > 0 ? { tools: [{ type: "namespace", name: CHATGPT_TOOL_NAMESPACE, description: "Canonry tools Aero may use for this answer.", tools }] } : {}
|
|
18269
|
+
};
|
|
18270
|
+
}
|
|
18271
|
+
function chatGptPlanFailure(status, detail) {
|
|
18272
|
+
const text = detail ?? "";
|
|
18273
|
+
if (status === 401 || text.includes("subscription_sharing_invalid_user")) return CHATGPT_AERO_ERRORS.reconnect;
|
|
18274
|
+
if (text.includes("subscription_sharing_usage_limit_exceeded") || status === 429) return CHATGPT_AERO_ERRORS.usageLimit;
|
|
18275
|
+
if (text.includes("subscription_sharing_user_not_eligible")) return CHATGPT_AERO_ERRORS.notEligible;
|
|
18276
|
+
if (text.includes("chatpass_v2_scope_not_authorized") || text.includes("chatpass_v2_invalid_authorization_context")) return CHATGPT_AERO_ERRORS.reconnect;
|
|
18277
|
+
if (status === 403) return CHATGPT_AERO_ERRORS.notEligible;
|
|
18278
|
+
if (status === 503 || text.includes("subscription_sharing_usage_unavailable") || text.includes("subscription_sharing_user_unavailable")) {
|
|
18279
|
+
return CHATGPT_AERO_ERRORS.unavailable;
|
|
18280
|
+
}
|
|
18281
|
+
return CHATGPT_AERO_ERRORS.failed;
|
|
18282
|
+
}
|
|
18283
|
+
function chatGptPlanStreamFn(onReconnect) {
|
|
18284
|
+
return (model, context, options) => {
|
|
18285
|
+
let status;
|
|
18286
|
+
const output = createAssistantMessageEventStream();
|
|
18287
|
+
const rewrite = (message) => {
|
|
18288
|
+
const failure2 = chatGptPlanFailure(status, message.errorMessage);
|
|
18289
|
+
if (failure2 === CHATGPT_AERO_ERRORS.reconnect) onReconnect();
|
|
18290
|
+
message.errorMessage = failure2;
|
|
18291
|
+
message.content = [];
|
|
18292
|
+
};
|
|
18293
|
+
void (async () => {
|
|
18294
|
+
try {
|
|
18295
|
+
const source = await aeroStreamFn(model, context, {
|
|
18296
|
+
...options,
|
|
18297
|
+
// Observe every HTTP response, failures included: pi-ai calls
|
|
18298
|
+
// onResponse only for a successful one, and its error text is not a
|
|
18299
|
+
// contract to parse a status out of.
|
|
18300
|
+
fetch: async (input, init) => {
|
|
18301
|
+
const response = await (options?.fetch ?? globalThis.fetch)(input, init);
|
|
18302
|
+
status = response.status;
|
|
18303
|
+
return response;
|
|
18304
|
+
}
|
|
18305
|
+
});
|
|
18306
|
+
for await (const event of source) {
|
|
18307
|
+
if (event.type === "error") rewrite(event.error);
|
|
18308
|
+
output.push(event);
|
|
18309
|
+
}
|
|
18310
|
+
const result = await source.result();
|
|
18311
|
+
if (result.stopReason === "error" && !Object.values(CHATGPT_AERO_ERRORS).includes(result.errorMessage)) {
|
|
18312
|
+
rewrite(result);
|
|
18313
|
+
}
|
|
18314
|
+
output.end(result);
|
|
18315
|
+
} catch (error) {
|
|
18316
|
+
const message = error instanceof ChatGptPlanError ? error.message : CHATGPT_AERO_ERRORS.failed;
|
|
18317
|
+
output.push({
|
|
18318
|
+
type: "error",
|
|
18319
|
+
reason: "error",
|
|
18320
|
+
error: {
|
|
18321
|
+
role: "assistant",
|
|
18322
|
+
content: [],
|
|
18323
|
+
api: model.api,
|
|
18324
|
+
provider: model.provider,
|
|
18325
|
+
model: model.id,
|
|
18326
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { ...ZERO_COST, total: 0 } },
|
|
18327
|
+
stopReason: "error",
|
|
18328
|
+
errorMessage: message,
|
|
18329
|
+
timestamp: Date.now()
|
|
18330
|
+
}
|
|
18331
|
+
});
|
|
18332
|
+
output.end();
|
|
18333
|
+
}
|
|
18334
|
+
})();
|
|
18335
|
+
return output;
|
|
18336
|
+
};
|
|
18337
|
+
}
|
|
18338
|
+
function preferredChatGptModel(config) {
|
|
18339
|
+
try {
|
|
18340
|
+
const { provider, modelId } = resolveSessionProviderAndModel(config);
|
|
18341
|
+
if (provider === AgentProviderIds.openai) return modelId;
|
|
18342
|
+
} catch {
|
|
18343
|
+
}
|
|
18344
|
+
return PROVIDER_MODELS[AgentProviderIds.openai].agent;
|
|
18345
|
+
}
|
|
18346
|
+
function fundingKey(funding) {
|
|
18347
|
+
return funding.kind === "install" ? "install" : `plan:${funding.connectionId}`;
|
|
18348
|
+
}
|
|
18349
|
+
function applyChatGptPlanTurn(agent, input) {
|
|
18350
|
+
agent.state.model = chatGptPlanModel(input.modelId);
|
|
18351
|
+
agent.state.thinkingLevel = resolveAgentReasoning(process.env, input.config, AgentProviderIds.openai, input.modelId);
|
|
18352
|
+
agent.getApiKey = async (provider) => {
|
|
18353
|
+
if (provider !== "openai") return void 0;
|
|
18354
|
+
const access = await input.accounts.planAccess(input.userId);
|
|
18355
|
+
return access.accessToken;
|
|
18356
|
+
};
|
|
18357
|
+
agent.onPayload = (payload) => namespaceChatGptPayload(payload);
|
|
18358
|
+
}
|
|
18359
|
+
|
|
18360
|
+
// src/agent/viewer-sessions.ts
|
|
18139
18361
|
var AERO_VIEWER_EXCLUDED_MCP_TOOLS = /* @__PURE__ */ new Set([
|
|
18140
18362
|
CanonryMcpToolNames.canonry_ads_account,
|
|
18141
18363
|
CanonryMcpToolNames.canonry_ads_geo_search,
|
|
@@ -18167,6 +18389,7 @@ var OPERATOR_ONLY_TOOL_NAMES = new Set(
|
|
|
18167
18389
|
);
|
|
18168
18390
|
var VIEWER_AERO_MAX_PROMPT_CHARS = 4e3;
|
|
18169
18391
|
var VIEWER_AERO_DAILY_TURN_LIMIT = 50;
|
|
18392
|
+
var VIEWER_AERO_PLAN_DAILY_TURN_LIMIT = 200;
|
|
18170
18393
|
function viewerAeroDailyLimitExceeded(limit) {
|
|
18171
18394
|
return new AppError(
|
|
18172
18395
|
"QUOTA_EXCEEDED",
|
|
@@ -18175,6 +18398,20 @@ function viewerAeroDailyLimitExceeded(limit) {
|
|
|
18175
18398
|
{ metric: "aero.viewer.turns", limit }
|
|
18176
18399
|
);
|
|
18177
18400
|
}
|
|
18401
|
+
function chatGptPlanAppError(error) {
|
|
18402
|
+
switch (error.kind) {
|
|
18403
|
+
case "usage-limit":
|
|
18404
|
+
return new AppError("QUOTA_EXCEEDED", error.message, 429, { reason: "chatgpt-usage-limit" });
|
|
18405
|
+
case "not-eligible":
|
|
18406
|
+
return new AppError("FORBIDDEN", error.message, 403, { reason: "chatgpt-not-eligible" });
|
|
18407
|
+
case "unavailable":
|
|
18408
|
+
return new AppError("PROVIDER_ERROR", error.message, 503, { reason: "chatgpt-unavailable" });
|
|
18409
|
+
case "not-connected":
|
|
18410
|
+
return new AppError("VALIDATION_ERROR", error.message, 409, { reason: "chatgpt-connect-required" });
|
|
18411
|
+
default:
|
|
18412
|
+
return new AppError("VALIDATION_ERROR", error.message, 409, { reason: "chatgpt-reconnect" });
|
|
18413
|
+
}
|
|
18414
|
+
}
|
|
18178
18415
|
var VIEWER_AERO_KEY_PREFIX = "aero-viewer:";
|
|
18179
18416
|
var VIEWER_AERO_PROMPT = "\n\nThis conversation is with a view-only account. You can read this project's data but cannot change anything, start or schedule sweeps, or spend on live provider reads. If asked to, say an administrator has to do it. You cannot see the operator's own Aero conversations or notes.";
|
|
18180
18417
|
var MAX_VIEWER_MESSAGES = 40;
|
|
@@ -18246,16 +18483,22 @@ var ViewerAeroSessions = class {
|
|
|
18246
18483
|
this.evictIdle();
|
|
18247
18484
|
const key = this.key(project.name, userId);
|
|
18248
18485
|
if (this.isBusy(project.name, userId)) throw agentBusy(project.name);
|
|
18486
|
+
const funding = await this.resolveFunding(userId);
|
|
18487
|
+
preferences.signal?.throwIfAborted();
|
|
18488
|
+
if (this.isBusy(project.name, userId)) throw agentBusy(project.name);
|
|
18249
18489
|
const today = new Date(this.now()).toISOString().slice(0, 10);
|
|
18250
18490
|
const used = this.turnsToday.get(key);
|
|
18251
18491
|
const count6 = used?.date === today ? used.count : 0;
|
|
18252
|
-
|
|
18492
|
+
const limit = funding.kind === "plan" ? VIEWER_AERO_PLAN_DAILY_TURN_LIMIT : VIEWER_AERO_DAILY_TURN_LIMIT;
|
|
18493
|
+
if (count6 >= limit) throw viewerAeroDailyLimitExceeded(limit);
|
|
18253
18494
|
const minted = mintViewerAeroKey(this.opts.db, userId, new Date(this.now()));
|
|
18254
18495
|
this.acquisitions.add(key);
|
|
18255
18496
|
let handedOff = false;
|
|
18256
18497
|
try {
|
|
18257
18498
|
const client = new ApiClient(this.opts.selfApiUrl, minted.raw, { skipProbe: true, surface: "aero" });
|
|
18258
|
-
const
|
|
18499
|
+
const existing = this.sessions.get(key);
|
|
18500
|
+
const reusable = existing && existing.funding === fundingKey(funding) ? existing.agent : void 0;
|
|
18501
|
+
const agent = reusable ?? await this.createAgent(project, client, preferences.signal, funding, userId);
|
|
18259
18502
|
agent.state.messages = trimViewerTranscript(agent.state.messages.filter((message) => message.role !== "system"));
|
|
18260
18503
|
const view = { client, projectName: project.name, basePath: this.opts.config.basePath, context: preferences.context };
|
|
18261
18504
|
const evidence = preferences.context ? await readAeroViewEvidenceForTurn(view, preferences.signal) : void 0;
|
|
@@ -18263,7 +18506,10 @@ var ViewerAeroSessions = class {
|
|
|
18263
18506
|
const shape = aeroProjectShape(this.opts.db, project.id);
|
|
18264
18507
|
setAeroSystemPrompt(agent, loadAeroSystemPrompt(void 0, { extras: false }) + VIEWER_AERO_PROMPT + shape.prompt + aeroViewPrompt(preferences.context));
|
|
18265
18508
|
configureAeroRuntime(agent, [...buildViewerAeroTools(client, project.name, this.opts.managedSweeps), buildAeroViewTool(view, evidence)], void 0, true, shape.pinned);
|
|
18266
|
-
|
|
18509
|
+
if (funding.kind === "plan") {
|
|
18510
|
+
applyChatGptPlanTurn(agent, { accounts: this.opts.chatgpt, userId, modelId: funding.modelId, config: this.opts.config });
|
|
18511
|
+
}
|
|
18512
|
+
this.sessions.set(key, { agent, lastUsedAt: this.now(), updatedAt: existing?.updatedAt ?? null, funding: fundingKey(funding) });
|
|
18267
18513
|
this.turnsToday.set(key, { date: today, count: count6 + 1 });
|
|
18268
18514
|
handedOff = true;
|
|
18269
18515
|
let released = false;
|
|
@@ -18289,7 +18535,23 @@ var ViewerAeroSessions = class {
|
|
|
18289
18535
|
}
|
|
18290
18536
|
}
|
|
18291
18537
|
}
|
|
18292
|
-
async createAgent(project, client, signal) {
|
|
18538
|
+
async createAgent(project, client, signal, funding, userId) {
|
|
18539
|
+
if (funding.kind === "plan") {
|
|
18540
|
+
const accounts = this.opts.chatgpt;
|
|
18541
|
+
return createAeroSession({
|
|
18542
|
+
projectName: project.name,
|
|
18543
|
+
client,
|
|
18544
|
+
config: this.opts.config,
|
|
18545
|
+
provider: AgentProviderIds.openai,
|
|
18546
|
+
modelId: PROVIDER_MODELS[AgentProviderIds.openai].agent,
|
|
18547
|
+
systemPromptOverride: loadAeroSystemPrompt(void 0, { extras: false }) + VIEWER_AERO_PROMPT,
|
|
18548
|
+
toolScope: AeroToolScopes.readOnly,
|
|
18549
|
+
managedSweeps: this.opts.managedSweeps,
|
|
18550
|
+
db: this.opts.db,
|
|
18551
|
+
projectId: project.id,
|
|
18552
|
+
streamFn: chatGptPlanStreamFn(() => accounts.markReconnectRequired(userId, funding.connectionId))
|
|
18553
|
+
});
|
|
18554
|
+
}
|
|
18293
18555
|
const { provider, modelId } = resolveSessionProviderAndModel(this.opts.config);
|
|
18294
18556
|
await refreshAgentModels(provider, signal);
|
|
18295
18557
|
return createAeroSession({
|
|
@@ -18305,6 +18567,27 @@ var ViewerAeroSessions = class {
|
|
|
18305
18567
|
projectId: project.id
|
|
18306
18568
|
});
|
|
18307
18569
|
}
|
|
18570
|
+
/**
|
|
18571
|
+
* What this viewer's next turn runs on. A connected ChatGPT plan wins; a plan
|
|
18572
|
+
* that needs connecting again is refused rather than quietly charged to the
|
|
18573
|
+
* install; no plan means the install's Aero, as before.
|
|
18574
|
+
*/
|
|
18575
|
+
async resolveFunding(userId) {
|
|
18576
|
+
const accounts = this.opts.chatgpt;
|
|
18577
|
+
if (!accounts?.planUsageEnabled()) return { kind: "install" };
|
|
18578
|
+
const plan = accounts.status(userId).account?.plan;
|
|
18579
|
+
if (!plan || plan.status === ChatGptPlanStatuses.notConnected) {
|
|
18580
|
+
if (accounts.planRequired()) throw chatGptPlanAppError(new ChatGptPlanError("not-connected", CHATGPT_AERO_ERRORS.connectRequired));
|
|
18581
|
+
return { kind: "install" };
|
|
18582
|
+
}
|
|
18583
|
+
try {
|
|
18584
|
+
const { access, modelId } = await accounts.resolveModel(userId, preferredChatGptModel(this.opts.config));
|
|
18585
|
+
return { kind: "plan", connectionId: access.connectionId, modelId };
|
|
18586
|
+
} catch (error) {
|
|
18587
|
+
if (error instanceof ChatGptPlanError) throw chatGptPlanAppError(error);
|
|
18588
|
+
throw error;
|
|
18589
|
+
}
|
|
18590
|
+
}
|
|
18308
18591
|
/**
|
|
18309
18592
|
* Delete the turn's key rather than revoke it: the key list shows revoked
|
|
18310
18593
|
* keys too, and one per turn would bury the operator's own. Revoke only if
|
|
@@ -18765,6 +19048,42 @@ function registerMcpHttpRoutes(scope, opts) {
|
|
|
18765
19048
|
}
|
|
18766
19049
|
}
|
|
18767
19050
|
|
|
19051
|
+
// src/chatgpt-config.ts
|
|
19052
|
+
var CALLBACK_SUFFIX = "/api/v1/auth/chatgpt/callback";
|
|
19053
|
+
function isLoopbackHost(hostname) {
|
|
19054
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]" || hostname.endsWith(".localhost");
|
|
19055
|
+
}
|
|
19056
|
+
function chatGptRedirectUri(publicUrl) {
|
|
19057
|
+
const configured = publicUrl?.trim();
|
|
19058
|
+
if (!configured) return null;
|
|
19059
|
+
let url;
|
|
19060
|
+
try {
|
|
19061
|
+
url = new URL(configured);
|
|
19062
|
+
} catch {
|
|
19063
|
+
return null;
|
|
19064
|
+
}
|
|
19065
|
+
if (url.username || url.password || url.search || url.hash) return null;
|
|
19066
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLoopbackHost(url.hostname))) return null;
|
|
19067
|
+
return `${url.origin}${url.pathname.replace(/\/$/, "")}${CALLBACK_SUFFIX}`;
|
|
19068
|
+
}
|
|
19069
|
+
function resolveChatGptSettings(config, env = process.env) {
|
|
19070
|
+
const entry = config.chatgpt;
|
|
19071
|
+
const clientId = entry?.clientId?.trim();
|
|
19072
|
+
if (!entry || !clientId || entry.signIn !== true && entry.planUsage !== true) return null;
|
|
19073
|
+
const redirectUri = chatGptRedirectUri(config.publicUrl);
|
|
19074
|
+
if (!redirectUri) return null;
|
|
19075
|
+
const clientSecret = entry.clientSecret?.trim();
|
|
19076
|
+
return {
|
|
19077
|
+
clientId,
|
|
19078
|
+
...clientSecret ? { clientSecret } : {},
|
|
19079
|
+
signIn: entry.signIn === true,
|
|
19080
|
+
planUsage: entry.planUsage === true,
|
|
19081
|
+
requirePlan: entry.requirePlan === true,
|
|
19082
|
+
tokenKey: parseChatGptTokenKey(env.CANONRY_CHATGPT_TOKEN_KEY ?? entry.tokenKey),
|
|
19083
|
+
redirectUri
|
|
19084
|
+
};
|
|
19085
|
+
}
|
|
19086
|
+
|
|
18768
19087
|
// src/agent/agent-routes.ts
|
|
18769
19088
|
import { eq as eq35 } from "drizzle-orm";
|
|
18770
19089
|
function viewerAeroCaller(request, opts) {
|
|
@@ -18778,9 +19097,12 @@ function viewerRedact(_key, value) {
|
|
|
18778
19097
|
if (!value || typeof value !== "object" || value.role !== "assistant") return value;
|
|
18779
19098
|
const copy = { ...value };
|
|
18780
19099
|
for (const key of VIEWER_HIDDEN_ASSISTANT_KEYS) delete copy[key];
|
|
18781
|
-
if (typeof copy.errorMessage === "string" && copy.errorMessage) copy.errorMessage =
|
|
19100
|
+
if (typeof copy.errorMessage === "string" && copy.errorMessage) copy.errorMessage = viewerErrorText(copy.errorMessage);
|
|
18782
19101
|
return copy;
|
|
18783
19102
|
}
|
|
19103
|
+
function viewerErrorText(message) {
|
|
19104
|
+
return isChatGptAeroError(message) ? message : VIEWER_ERROR_MESSAGE;
|
|
19105
|
+
}
|
|
18784
19106
|
function redactForViewer(value) {
|
|
18785
19107
|
return JSON.parse(JSON.stringify(value, viewerRedact));
|
|
18786
19108
|
}
|
|
@@ -18828,7 +19150,7 @@ async function streamAgentTurn(reply, agent, turn) {
|
|
|
18828
19150
|
const write = (payload) => {
|
|
18829
19151
|
if (reply.raw.writableEnded) return;
|
|
18830
19152
|
try {
|
|
18831
|
-
const frame = turn.viewer && payload.type === "error" ? { type: "error", message:
|
|
19153
|
+
const frame = turn.viewer && payload.type === "error" ? { type: "error", message: viewerErrorText(payload.message) } : payload;
|
|
18832
19154
|
reply.raw.write(`data: ${JSON.stringify(frame, turn.viewer ? viewerRedact : void 0)}
|
|
18833
19155
|
|
|
18834
19156
|
`);
|
|
@@ -21049,12 +21371,22 @@ async function createServer(opts) {
|
|
|
21049
21371
|
proactive: agentProactive,
|
|
21050
21372
|
managedSweeps: dashboardManagedRunKinds.includes(SchedulableRunKinds["answer-visibility"])
|
|
21051
21373
|
}) : void 0;
|
|
21374
|
+
const chatgptAccounts = new ChatGptAccounts({
|
|
21375
|
+
db: opts.db,
|
|
21376
|
+
settings: () => resolveChatGptSettings(opts.config)
|
|
21377
|
+
});
|
|
21378
|
+
if (opts.config.chatgpt && (opts.config.chatgpt.signIn || opts.config.chatgpt.planUsage) && !resolveChatGptSettings(opts.config)) {
|
|
21379
|
+
log29.warn("chatgpt.disabled", {
|
|
21380
|
+
reason: "Sign in with ChatGPT needs chatgpt.clientId and an HTTPS publicUrl; it stays off until both are set."
|
|
21381
|
+
});
|
|
21382
|
+
}
|
|
21052
21383
|
const agentAllowViewers = agentEnabled && resolveAgentAllowViewers(process.env, opts.config);
|
|
21053
21384
|
const viewerAeroSessions = agentAllowViewers ? new ViewerAeroSessions({
|
|
21054
21385
|
db: opts.db,
|
|
21055
21386
|
config: opts.config,
|
|
21056
21387
|
selfApiUrl: opts.config.apiUrl,
|
|
21057
|
-
managedSweeps: dashboardManagedRunKinds.includes(SchedulableRunKinds["answer-visibility"])
|
|
21388
|
+
managedSweeps: dashboardManagedRunKinds.includes(SchedulableRunKinds["answer-visibility"]),
|
|
21389
|
+
chatgpt: chatgptAccounts
|
|
21058
21390
|
}) : void 0;
|
|
21059
21391
|
const runCoordinator = new RunCoordinator(
|
|
21060
21392
|
opts.db,
|
|
@@ -22361,6 +22693,9 @@ async function createServer(opts) {
|
|
|
22361
22693
|
path: sessionCookiePath,
|
|
22362
22694
|
...sessionCookieSecure ? { secure: true } : {}
|
|
22363
22695
|
},
|
|
22696
|
+
chatgptAccounts,
|
|
22697
|
+
chatgptPreferredModel: () => preferredChatGptModel(opts.config),
|
|
22698
|
+
dashboardPath: basePath ?? "/",
|
|
22364
22699
|
// Whether an operator has declared which hops to believe. The per-caller
|
|
22365
22700
|
// sign-in budget depends on this being the truth rather than something
|
|
22366
22701
|
// inferred from a header the caller controls.
|
|
@@ -23114,6 +23449,9 @@ async function createServer(opts) {
|
|
|
23114
23449
|
return resolved ? { id: resolved.user.id, name: resolved.user.name } : null;
|
|
23115
23450
|
},
|
|
23116
23451
|
credentials: credentialChecker,
|
|
23452
|
+
// A person whose account signs in only with ChatGPT approves MCP
|
|
23453
|
+
// clients too: the consent page offers it and comes back to itself.
|
|
23454
|
+
chatgptSignInUrl: (returnTo) => chatgptAccounts.signInEnabled() ? `${apiPrefix}/auth/chatgpt/start?${new URLSearchParams({ intent: "login", returnTo }).toString()}` : null,
|
|
23117
23455
|
startSession: (userId) => {
|
|
23118
23456
|
const token = createUserSession(opts.db, userId);
|
|
23119
23457
|
return serializeUserSessionCookie({
|