@canonry/canonry 7.101.0 → 7.104.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.
Files changed (148) hide show
  1. package/assets/agent-workspace/skills/aero/references/ai-traffic-tracking.md +32 -4
  2. package/assets/agent-workspace/skills/canonry/references/ai-traffic-tracking.md +32 -4
  3. package/assets/agent-workspace/skills/canonry/references/canonry-cli.md +29 -2
  4. package/assets/agent-workspace/skills/canonry/references/server-side-traffic.md +51 -15
  5. package/assets/assets/{AccessControls-BMcboMU7.js → AccessControls-CBkDcxwx.js} +1 -1
  6. package/assets/assets/{AgentSetupPage-D8zYfyZC.js → AgentSetupPage-iGYETW-I.js} +4 -4
  7. package/assets/assets/AuditHistoryPanel-DiFMK7eE.js +1 -0
  8. package/assets/assets/{BacklinksPage-D8HxzRDh.js → BacklinksPage-Cg9LQLMo.js} +1 -1
  9. package/assets/assets/{ChartPrimitives-nJi3Kmez.js → ChartPrimitives-DYS88Zzt.js} +1 -1
  10. package/assets/assets/{HistoryPage-DZ9Cuei4.js → HistoryPage-CmI5CX94.js} +1 -1
  11. package/assets/assets/MeasurementPropertyPage-DshJzp9b.js +4 -0
  12. package/assets/assets/ProjectPage-DwVxUhxM.js +15 -0
  13. package/assets/assets/{RunsPage-Q_prFKG5.js → RunsPage-BqvrT8Xm.js} +1 -1
  14. package/assets/assets/{ServerTrafficSection-D03quNUe.js → ServerTrafficSection-CtFe7WDd.js} +2 -2
  15. package/assets/assets/{SettingsPage-BjNzAJC4.js → SettingsPage-snu8wJ8l.js} +1 -1
  16. package/assets/assets/ToneBadge-CkTo2T8d.js +60 -0
  17. package/assets/assets/{TrafficPage-B6W88b1f.js → TrafficPage-BxiiQjwl.js} +1 -1
  18. package/assets/assets/TrafficSourceDetailPage-8BKFz7py.js +1 -0
  19. package/assets/assets/{account-context-Do9YhtFR.js → account-context-BlfC71NP.js} +1 -1
  20. package/assets/assets/{agent-trust-copy-CYbhNL0S.js → agent-trust-copy-C_J3OmRg.js} +1 -1
  21. package/assets/assets/{card-FXvJKWST.js → card-CeXmlLH2.js} +1 -1
  22. package/assets/assets/index-BKbmkmyo.js +43 -0
  23. package/assets/assets/{index-C4GJ1tQ2.css → index-DPz1idfn.css} +1 -1
  24. package/assets/assets/{query-client-BhpTEFNb.js → query-client-DWYnC2Lg.js} +1 -1
  25. package/assets/assets/react-query-CQhkmL4O.js +1 -0
  26. package/assets/assets/{react-sigma_core.esm.min-DseCmd8v.js → react-sigma_core.esm.min-YHPB9pkU.js} +1 -1
  27. package/assets/assets/{server-traffic-1qKARWJy.js → server-traffic-ChxoKQ0y.js} +1 -1
  28. package/assets/assets/{service-CLPD132h.js → service-u1pn5oyA.js} +1 -1
  29. package/assets/index.html +9 -9
  30. package/dist/{ads-BCYHOU4L.js → ads-ARJJACSH.js} +3 -3
  31. package/dist/{agent-EX5MI762.js → agent-57EQMSOO.js} +7 -7
  32. package/dist/{agent-ask-BQPVESBJ.js → agent-ask-TF2WTRTO.js} +3 -3
  33. package/dist/{agent-conversations-A3JVDL3D.js → agent-conversations-5GXNREFK.js} +3 -3
  34. package/dist/{agent-journeys-3LQ7XWYH.js → agent-journeys-6CDPI4TE.js} +3 -3
  35. package/dist/{agent-memory-LPQQOZR7.js → agent-memory-X3FQ4YDE.js} +3 -3
  36. package/dist/{agent-providers-34EDHZQB.js → agent-providers-32Z3YXO4.js} +3 -3
  37. package/dist/{agent-transcript-LQUMSRRD.js → agent-transcript-2S64XPF2.js} +3 -3
  38. package/dist/{analytics-CVTVJUUE.js → analytics-WPCHRXQZ.js} +3 -3
  39. package/dist/{apply-6532DFBW.js → apply-3WHRQBQB.js} +3 -3
  40. package/dist/{backfill-TC57HUDP.js → backfill-KR2NSPSE.js} +10 -10
  41. package/dist/{backlinks-MZXW2DZL.js → backlinks-TRVNCPUB.js} +3 -3
  42. package/dist/{bing-VTXDVW6U.js → bing-F3B76XX5.js} +3 -3
  43. package/dist/{bootstrap-3IC5HUMH.js → bootstrap-QOAGLWNN.js} +10 -10
  44. package/dist/{cdp-CTL2TJE6.js → cdp-4I3DNMLG.js} +7 -7
  45. package/dist/{chunk-E2SYIZ55.js → chunk-2AECECUY.js} +1 -1
  46. package/dist/{chunk-WSAWPVPE.js → chunk-2QWG6HWM.js} +5 -5
  47. package/dist/{chunk-G7LYCMQJ.js → chunk-2VNQKUCW.js} +32 -2
  48. package/dist/{chunk-2FFTK4PG.js → chunk-3V5Y2XTA.js} +1 -1
  49. package/dist/{chunk-L7WSODHZ.js → chunk-52D6WBCZ.js} +1 -1
  50. package/dist/{chunk-WDGVJPWZ.js → chunk-5FMZGO6R.js} +4 -4
  51. package/dist/{chunk-F4FHK5IK.js → chunk-6AW6ONTF.js} +2 -2
  52. package/dist/{chunk-FGITR7KU.js → chunk-7UQZCDYK.js} +4 -1
  53. package/dist/{chunk-MUK7BYVL.js → chunk-7VKVGR6X.js} +3 -3
  54. package/dist/{chunk-OMGPF7QF.js → chunk-BYYP43Q3.js} +261 -1
  55. package/dist/{chunk-YMWX6QAX.js → chunk-C6RWAAF6.js} +4 -4
  56. package/dist/{chunk-S7UYYD2Y.js → chunk-CCHYRLX4.js} +2 -2
  57. package/dist/{chunk-UBOUJ6RS.js → chunk-CJ55MGWI.js} +1 -1
  58. package/dist/{chunk-AOIDPATQ.js → chunk-D76TB5JS.js} +1 -1
  59. package/dist/{chunk-JFTB74BQ.js → chunk-DLZCOJCY.js} +1 -1
  60. package/dist/{chunk-HN4EB3RS.js → chunk-FCUUJO3Z.js} +2 -2
  61. package/dist/{chunk-VAHTXCUU.js → chunk-FUERP5PU.js} +567 -185
  62. package/dist/{chunk-2T5HRNYT.js → chunk-HLM3GYK4.js} +1 -1
  63. package/dist/{chunk-7HQWMG3E.js → chunk-HPFT4IKN.js} +31 -1
  64. package/dist/{chunk-VLNJ2HEZ.js → chunk-HTGJSXCR.js} +5 -5
  65. package/dist/{chunk-5TSSSL2I.js → chunk-K32GU473.js} +632 -462
  66. package/dist/{chunk-BRNVPRLS.js → chunk-LCZZACLE.js} +3 -3
  67. package/dist/{chunk-5WZPTVEF.js → chunk-MDRAKMCV.js} +3 -3
  68. package/dist/{chunk-CT45LO6U.js → chunk-MT2LENZA.js} +6 -6
  69. package/dist/{chunk-2UF2K6MD.js → chunk-PL76V2DY.js} +3107 -1665
  70. package/dist/{chunk-3SJDTQMT.js → chunk-QRR5ZW22.js} +3 -3
  71. package/dist/{chunk-F73M7PKH.js → chunk-R4VAGCFW.js} +286 -28
  72. package/dist/{chunk-3ED3KWEP.js → chunk-RBAK7RQX.js} +409 -366
  73. package/dist/{chunk-XM6OZ2OK.js → chunk-SFLSZXLO.js} +4 -4
  74. package/dist/{chunk-3QA5NJR4.js → chunk-SZ64N26K.js} +1 -1
  75. package/dist/{chunk-YIJLFPSH.js → chunk-T3G44DHS.js} +46 -31
  76. package/dist/{chunk-XZE6RAHE.js → chunk-TCXITSDO.js} +1 -1
  77. package/dist/{chunk-UE27XRSS.js → chunk-TFP6UJXW.js} +3 -3
  78. package/dist/{chunk-PX7O4WH2.js → chunk-WQQ4TNIY.js} +2 -2
  79. package/dist/{chunk-6UB4Y6CB.js → chunk-WT22Z3I7.js} +361 -143
  80. package/dist/{chunk-CLYPPLCG.js → chunk-ZJFLVXDZ.js} +2 -2
  81. package/dist/{citations-QXQ5MUSF.js → citations-6CW3G5YP.js} +4 -4
  82. package/dist/{cli-catalog-B3TUL26L.js → cli-catalog-6B2O2JQE.js} +3 -3
  83. package/dist/{cli-commands-R3CN4VVC.js → cli-commands-RJX2UC5L.js} +7 -7
  84. package/dist/cli.js +13 -13
  85. package/dist/{competitor-25MZKLVJ.js → competitor-D4BVO2KQ.js} +3 -3
  86. package/dist/{content-4STS5IKM.js → content-H2PGFRWM.js} +3 -3
  87. package/dist/{dashboard-XBMH4MGN.js → dashboard-4GWISEMI.js} +6 -6
  88. package/dist/{demo-2S46SBJD.js → demo-63JTCWN5.js} +1 -1
  89. package/dist/{demo-server-JTRHOBVR.js → demo-server-QA5OSH45.js} +12 -12
  90. package/dist/{discover-W6BSJXYO.js → discover-K4GIXAN5.js} +4 -4
  91. package/dist/{discover-eval-VP3XYODD.js → discover-eval-L4IF5XFV.js} +3 -3
  92. package/dist/{doctor-M5CC6T2H.js → doctor-OVJTEQCK.js} +3 -3
  93. package/dist/{evidence-KA6S266J.js → evidence-MXQK4YYL.js} +3 -3
  94. package/dist/{export-cmd-IBWYGJ2S.js → export-cmd-Z3CWJALI.js} +3 -3
  95. package/dist/{ga-GR2QLPZI.js → ga-347UNNJP.js} +3 -3
  96. package/dist/{gbp-U7NRBE2Q.js → gbp-47MIYIQC.js} +3 -3
  97. package/dist/{google-IV62SWDP.js → google-7Q3FYNVP.js} +4 -4
  98. package/dist/{google-marketing-LBEJZ2NZ.js → google-marketing-TMKWY5AP.js} +1 -1
  99. package/dist/{health-cmd-Y57EUJCG.js → health-cmd-77TMLQ6T.js} +4 -4
  100. package/dist/{history-ZKZNZ24X.js → history-Q756HPJM.js} +3 -3
  101. package/dist/index.d.ts +867 -14
  102. package/dist/index.js +25 -25
  103. package/dist/{init-X6NNIX63.js → init-CLSFH5OL.js} +12 -12
  104. package/dist/{insights-3A2I5LQ5.js → insights-TPNHIVNH.js} +3 -3
  105. package/dist/intelligence-service-TTDFQ2TB.js +16 -0
  106. package/dist/{journeys-WHQ4XC4I.js → journeys-F6UAVPVI.js} +3 -3
  107. package/dist/{keys-6XIMEOV2.js → keys-Q6VMDIAH.js} +3 -3
  108. package/dist/{keyword-DGGFQNYE.js → keyword-7BH5P5P7.js} +3 -3
  109. package/dist/{logs-Z5ZV7ODN.js → logs-P2J6XFVJ.js} +3 -3
  110. package/dist/{mcp-U64GUOQN.js → mcp-RPXFNAKS.js} +4 -4
  111. package/dist/mcp.js +9 -9
  112. package/dist/{measurement-plan-J5ERRBIR.js → measurement-plan-KKUB6SLB.js} +5 -5
  113. package/dist/{notify-43M77D6T.js → notify-2IK6NR7Y.js} +3 -3
  114. package/dist/{organic-evidence-H2X6ILDC.js → organic-evidence-N4HIUIHJ.js} +3 -3
  115. package/dist/{overview-XT35O2XZ.js → overview-FSNB42W5.js} +5 -5
  116. package/dist/{project-F2EKXLWT.js → project-D5ODS46C.js} +3 -3
  117. package/dist/{project-setup-5GB65EUE.js → project-setup-X7NGKC4R.js} +3 -3
  118. package/dist/{query-MHSMDWMP.js → query-JGCEDLI2.js} +3 -3
  119. package/dist/{research-FH62JC57.js → research-3S5FLAFX.js} +3 -3
  120. package/dist/{results-export-D4VB2OBW.js → results-export-YMX4F2K6.js} +3 -3
  121. package/dist/{run-B4B3CG7J.js → run-MCJAGAHJ.js} +5 -5
  122. package/dist/{schedule-BUJX7ULT.js → schedule-CLWDPYZG.js} +3 -3
  123. package/dist/{search-6CXRPRG6.js → search-X7SXPESS.js} +3 -3
  124. package/dist/{serve-BAIQI6TL.js → serve-WDUJ36KJ.js} +26 -26
  125. package/dist/{session-AXSKOKCZ.js → session-M66S3VTK.js} +13 -13
  126. package/dist/{settings-TADPOGVE.js → settings-UZEODHZ3.js} +3 -3
  127. package/dist/{sitemaps-HHEQTH4E.js → sitemaps-SK2ZE5EJ.js} +3 -3
  128. package/dist/{skills-4L7SDS6D.js → skills-SI6C7MPT.js} +2 -2
  129. package/dist/{snapshot-6RWDOATX.js → snapshot-AOQUU5Q2.js} +3 -3
  130. package/dist/{src-XZVMW2PD.js → src-BXXLPHVZ.js} +10 -2
  131. package/dist/{status-4NRAVD3B.js → status-TMKQNQ74.js} +5 -5
  132. package/dist/{technical-aeo-DBWEDC3J.js → technical-aeo-WBLZMCUY.js} +3 -3
  133. package/dist/{telemetry-OEAHQV6Q.js → telemetry-DS22S3C3.js} +4 -4
  134. package/dist/{tools-64NJHOA5.js → tools-W63YOE6T.js} +11 -11
  135. package/dist/{traffic-M2TCCDCP.js → traffic-6AIRXYMI.js} +24 -7
  136. package/dist/{trends-XHOOQAGY.js → trends-LEAXHSM6.js} +3 -3
  137. package/dist/{users-VX5RRVBY.js → users-VCNIWES5.js} +54 -4
  138. package/dist/{visibility-stats-QGEQKBPJ.js → visibility-stats-4XA2YZET.js} +4 -4
  139. package/dist/{wordpress-HRTBWGT4.js → wordpress-YG3ECQXW.js} +3 -3
  140. package/package.json +1 -1
  141. package/assets/assets/AuditHistoryPanel-DWM5jJ3T.js +0 -1
  142. package/assets/assets/MeasurementPropertyPage-9-ItFHr-.js +0 -4
  143. package/assets/assets/ProjectPage-yQTM6p0E.js +0 -15
  144. package/assets/assets/ToneBadge-BZJuMrq1.js +0 -60
  145. package/assets/assets/TrafficSourceDetailPage-zSr5FqmD.js +0 -1
  146. package/assets/assets/index-BYLZIyID.js +0 -43
  147. package/assets/assets/react-query-Cja6j8Tp.js +0 -1
  148. package/dist/intelligence-service-5FILIP2J.js +0 -16
@@ -7,12 +7,12 @@ import {
7
7
  import {
8
8
  createApiClient,
9
9
  runWithUsageTags
10
- } from "./chunk-G7LYCMQJ.js";
10
+ } from "./chunk-2VNQKUCW.js";
11
11
  import {
12
12
  canonryMcpTools,
13
13
  mcpOutputSchema,
14
14
  toolOperationAccess
15
- } from "./chunk-VLNJ2HEZ.js";
15
+ } from "./chunk-HTGJSXCR.js";
16
16
  import {
17
17
  PACKAGE_VERSION
18
18
  } from "./chunk-AOJU5LKX.js";
@@ -25,7 +25,7 @@ import {
25
25
  isReadOnlyKey,
26
26
  restrictedWriteScopes,
27
27
  upgradeCaveatFor
28
- } from "./chunk-6UB4Y6CB.js";
28
+ } from "./chunk-WT22Z3I7.js";
29
29
 
30
30
  // src/mcp/server.ts
31
31
  import { randomUUID } from "crypto";
@@ -23,18 +23,18 @@ import {
23
23
  resolveConfiguredAgentProvider,
24
24
  resolveSessionProviderAndModel,
25
25
  setAeroSystemPrompt
26
- } from "./chunk-CT45LO6U.js";
26
+ } from "./chunk-MT2LENZA.js";
27
27
  import {
28
28
  answerServiceAdapters,
29
29
  answerServiceDescriptors
30
- } from "./chunk-L7WSODHZ.js";
30
+ } from "./chunk-52D6WBCZ.js";
31
31
  import {
32
32
  AeroToolProfiles,
33
33
  AeroToolScopes,
34
34
  buildAeroStateTools,
35
35
  isAeroToolProfile,
36
36
  truncateToolResult
37
- } from "./chunk-XM6OZ2OK.js";
37
+ } from "./chunk-SFLSZXLO.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-2FFTK4PG.js";
56
+ } from "./chunk-3V5Y2XTA.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-VAHTXCUU.js";
68
+ } from "./chunk-FUERP5PU.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-WDGVJPWZ.js";
80
+ } from "./chunk-5FMZGO6R.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-3QA5NJR4.js";
88
+ } from "./chunk-SZ64N26K.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-CLYPPLCG.js";
100
+ } from "./chunk-ZJFLVXDZ.js";
101
101
  import {
102
102
  createCanonryMcpServer
103
- } from "./chunk-3SJDTQMT.js";
103
+ } from "./chunk-QRR5ZW22.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-G7LYCMQJ.js";
110
+ } from "./chunk-2VNQKUCW.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-7HQWMG3E.js";
145
+ } from "./chunk-HPFT4IKN.js";
144
146
  import {
145
147
  getBundledSkillSnapshots
146
- } from "./chunk-2T5HRNYT.js";
148
+ } from "./chunk-HLM3GYK4.js";
147
149
  import {
148
150
  computeFactorAverages,
149
151
  deleteSiteCrawlGraphLayout,
150
152
  persistSiteCrawlGraphLayout,
151
153
  prepareSiteCrawlGraphLayout,
152
154
  recordedSharePct
153
- } from "./chunk-F4FHK5IK.js";
155
+ } from "./chunk-6AW6ONTF.js";
154
156
  import {
155
157
  CanonryMcpToolNames,
156
158
  canonryMcpTools
157
- } from "./chunk-VLNJ2HEZ.js";
159
+ } from "./chunk-HTGJSXCR.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-WSAWPVPE.js";
168
+ } from "./chunk-2QWG6HWM.js";
167
169
  import {
168
170
  computeCitedCompetitorDomains,
169
171
  determineCitationState
170
- } from "./chunk-UBOUJ6RS.js";
172
+ } from "./chunk-CJ55MGWI.js";
171
173
  import {
172
174
  addLogListener,
173
175
  createFastifyLogger,
174
176
  createLogger
175
- } from "./chunk-PX7O4WH2.js";
177
+ } from "./chunk-WQQ4TNIY.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-2UF2K6MD.js";
325
+ } from "./chunk-PL76V2DY.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-OMGPF7QF.js";
424
+ } from "./chunk-BYYP43Q3.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,
@@ -690,7 +699,7 @@ import {
690
699
  winnabilityClassLabel,
691
700
  withRetry,
692
701
  withSkippedProviders
693
- } from "./chunk-6UB4Y6CB.js";
702
+ } from "./chunk-WT22Z3I7.js";
694
703
 
695
704
  // src/google-marketing-runtime.ts
696
705
  import crypto2 from "crypto";
@@ -6444,7 +6453,7 @@ function nonBlank(value) {
6444
6453
  return trimmed ? trimmed : void 0;
6445
6454
  }
6446
6455
  function resolveBuildCommit(env = process.env) {
6447
- const embedded = true ? "cb93b5f4f45392cf52101cc8855330254445b90b" : void 0;
6456
+ const embedded = true ? "bae4b8576b5f9846afcc71da4ea2b4756855b14e" : void 0;
6448
6457
  return nonBlank(embedded) ?? nonBlank(env.CANONRY_COMMIT);
6449
6458
  }
6450
6459
  function resolveInstanceIdentity(env = process.env) {
@@ -18216,6 +18225,139 @@ ${lines.join("\n")}
18216
18225
  // src/agent/viewer-sessions.ts
18217
18226
  import crypto28 from "crypto";
18218
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
18219
18361
  var AERO_VIEWER_EXCLUDED_MCP_TOOLS = /* @__PURE__ */ new Set([
18220
18362
  CanonryMcpToolNames.canonry_ads_account,
18221
18363
  CanonryMcpToolNames.canonry_ads_geo_search,
@@ -18247,6 +18389,7 @@ var OPERATOR_ONLY_TOOL_NAMES = new Set(
18247
18389
  );
18248
18390
  var VIEWER_AERO_MAX_PROMPT_CHARS = 4e3;
18249
18391
  var VIEWER_AERO_DAILY_TURN_LIMIT = 50;
18392
+ var VIEWER_AERO_PLAN_DAILY_TURN_LIMIT = 200;
18250
18393
  function viewerAeroDailyLimitExceeded(limit) {
18251
18394
  return new AppError(
18252
18395
  "QUOTA_EXCEEDED",
@@ -18255,6 +18398,20 @@ function viewerAeroDailyLimitExceeded(limit) {
18255
18398
  { metric: "aero.viewer.turns", limit }
18256
18399
  );
18257
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
+ }
18258
18415
  var VIEWER_AERO_KEY_PREFIX = "aero-viewer:";
18259
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.";
18260
18417
  var MAX_VIEWER_MESSAGES = 40;
@@ -18326,16 +18483,22 @@ var ViewerAeroSessions = class {
18326
18483
  this.evictIdle();
18327
18484
  const key = this.key(project.name, userId);
18328
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);
18329
18489
  const today = new Date(this.now()).toISOString().slice(0, 10);
18330
18490
  const used = this.turnsToday.get(key);
18331
18491
  const count6 = used?.date === today ? used.count : 0;
18332
- if (count6 >= VIEWER_AERO_DAILY_TURN_LIMIT) throw viewerAeroDailyLimitExceeded(VIEWER_AERO_DAILY_TURN_LIMIT);
18492
+ const limit = funding.kind === "plan" ? VIEWER_AERO_PLAN_DAILY_TURN_LIMIT : VIEWER_AERO_DAILY_TURN_LIMIT;
18493
+ if (count6 >= limit) throw viewerAeroDailyLimitExceeded(limit);
18333
18494
  const minted = mintViewerAeroKey(this.opts.db, userId, new Date(this.now()));
18334
18495
  this.acquisitions.add(key);
18335
18496
  let handedOff = false;
18336
18497
  try {
18337
18498
  const client = new ApiClient(this.opts.selfApiUrl, minted.raw, { skipProbe: true, surface: "aero" });
18338
- const agent = this.sessions.get(key)?.agent ?? await this.createAgent(project, client, preferences.signal);
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);
18339
18502
  agent.state.messages = trimViewerTranscript(agent.state.messages.filter((message) => message.role !== "system"));
18340
18503
  const view = { client, projectName: project.name, basePath: this.opts.config.basePath, context: preferences.context };
18341
18504
  const evidence = preferences.context ? await readAeroViewEvidenceForTurn(view, preferences.signal) : void 0;
@@ -18343,7 +18506,10 @@ var ViewerAeroSessions = class {
18343
18506
  const shape = aeroProjectShape(this.opts.db, project.id);
18344
18507
  setAeroSystemPrompt(agent, loadAeroSystemPrompt(void 0, { extras: false }) + VIEWER_AERO_PROMPT + shape.prompt + aeroViewPrompt(preferences.context));
18345
18508
  configureAeroRuntime(agent, [...buildViewerAeroTools(client, project.name, this.opts.managedSweeps), buildAeroViewTool(view, evidence)], void 0, true, shape.pinned);
18346
- this.sessions.set(key, { agent, lastUsedAt: this.now(), updatedAt: this.sessions.get(key)?.updatedAt ?? null });
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) });
18347
18513
  this.turnsToday.set(key, { date: today, count: count6 + 1 });
18348
18514
  handedOff = true;
18349
18515
  let released = false;
@@ -18369,7 +18535,23 @@ var ViewerAeroSessions = class {
18369
18535
  }
18370
18536
  }
18371
18537
  }
18372
- 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
+ }
18373
18555
  const { provider, modelId } = resolveSessionProviderAndModel(this.opts.config);
18374
18556
  await refreshAgentModels(provider, signal);
18375
18557
  return createAeroSession({
@@ -18385,6 +18567,27 @@ var ViewerAeroSessions = class {
18385
18567
  projectId: project.id
18386
18568
  });
18387
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
+ }
18388
18591
  /**
18389
18592
  * Delete the turn's key rather than revoke it: the key list shows revoked
18390
18593
  * keys too, and one per turn would bury the operator's own. Revoke only if
@@ -18845,6 +19048,42 @@ function registerMcpHttpRoutes(scope, opts) {
18845
19048
  }
18846
19049
  }
18847
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
+
18848
19087
  // src/agent/agent-routes.ts
18849
19088
  import { eq as eq35 } from "drizzle-orm";
18850
19089
  function viewerAeroCaller(request, opts) {
@@ -18858,9 +19097,12 @@ function viewerRedact(_key, value) {
18858
19097
  if (!value || typeof value !== "object" || value.role !== "assistant") return value;
18859
19098
  const copy = { ...value };
18860
19099
  for (const key of VIEWER_HIDDEN_ASSISTANT_KEYS) delete copy[key];
18861
- if (typeof copy.errorMessage === "string" && copy.errorMessage) copy.errorMessage = VIEWER_ERROR_MESSAGE;
19100
+ if (typeof copy.errorMessage === "string" && copy.errorMessage) copy.errorMessage = viewerErrorText(copy.errorMessage);
18862
19101
  return copy;
18863
19102
  }
19103
+ function viewerErrorText(message) {
19104
+ return isChatGptAeroError(message) ? message : VIEWER_ERROR_MESSAGE;
19105
+ }
18864
19106
  function redactForViewer(value) {
18865
19107
  return JSON.parse(JSON.stringify(value, viewerRedact));
18866
19108
  }
@@ -18908,7 +19150,7 @@ async function streamAgentTurn(reply, agent, turn) {
18908
19150
  const write = (payload) => {
18909
19151
  if (reply.raw.writableEnded) return;
18910
19152
  try {
18911
- const frame = turn.viewer && payload.type === "error" ? { type: "error", message: VIEWER_ERROR_MESSAGE } : payload;
19153
+ const frame = turn.viewer && payload.type === "error" ? { type: "error", message: viewerErrorText(payload.message) } : payload;
18912
19154
  reply.raw.write(`data: ${JSON.stringify(frame, turn.viewer ? viewerRedact : void 0)}
18913
19155
 
18914
19156
  `);
@@ -21129,12 +21371,22 @@ async function createServer(opts) {
21129
21371
  proactive: agentProactive,
21130
21372
  managedSweeps: dashboardManagedRunKinds.includes(SchedulableRunKinds["answer-visibility"])
21131
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
+ }
21132
21383
  const agentAllowViewers = agentEnabled && resolveAgentAllowViewers(process.env, opts.config);
21133
21384
  const viewerAeroSessions = agentAllowViewers ? new ViewerAeroSessions({
21134
21385
  db: opts.db,
21135
21386
  config: opts.config,
21136
21387
  selfApiUrl: opts.config.apiUrl,
21137
- managedSweeps: dashboardManagedRunKinds.includes(SchedulableRunKinds["answer-visibility"])
21388
+ managedSweeps: dashboardManagedRunKinds.includes(SchedulableRunKinds["answer-visibility"]),
21389
+ chatgpt: chatgptAccounts
21138
21390
  }) : void 0;
21139
21391
  const runCoordinator = new RunCoordinator(
21140
21392
  opts.db,
@@ -22441,6 +22693,9 @@ async function createServer(opts) {
22441
22693
  path: sessionCookiePath,
22442
22694
  ...sessionCookieSecure ? { secure: true } : {}
22443
22695
  },
22696
+ chatgptAccounts,
22697
+ chatgptPreferredModel: () => preferredChatGptModel(opts.config),
22698
+ dashboardPath: basePath ?? "/",
22444
22699
  // Whether an operator has declared which hops to believe. The per-caller
22445
22700
  // sign-in budget depends on this being the truth rather than something
22446
22701
  // inferred from a header the caller controls.
@@ -23194,6 +23449,9 @@ async function createServer(opts) {
23194
23449
  return resolved ? { id: resolved.user.id, name: resolved.user.name } : null;
23195
23450
  },
23196
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,
23197
23455
  startSession: (userId) => {
23198
23456
  const token = createUserSession(opts.db, userId);
23199
23457
  return serializeUserSessionCookie({