@tonyclaw/agent-inspector 3.1.32 → 4.0.2

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 (373) hide show
  1. package/.output/backend/nitro.json +1 -1
  2. package/.output/cli.js +241 -120
  3. package/.output/server/_ssr/index.mjs +1 -1
  4. package/.output/server/_ssr/{router-oXUk3MBR.mjs → router-BBY_zWRK.mjs} +91 -3
  5. package/.output/server/index.mjs +1 -1
  6. package/.output/ui/assets/{CompareDrawer-BtfPSpkV.js → CompareDrawer-rtNElN-B.js} +1 -1
  7. package/.output/ui/assets/{InspectorPet-D9DPPQ3n.js → InspectorPet-QaAiuF3d.js} +1 -1
  8. package/.output/ui/assets/{ProxyViewerContainer-Buu8vkCK.js → ProxyViewerContainer-6twNZHwl.js} +4 -4
  9. package/.output/ui/assets/{ReplayDialog-BER-QzpD.js → ReplayDialog-B7KlziO2.js} +1 -1
  10. package/.output/ui/assets/{RequestAnatomy-C8Zwxrr7.js → RequestAnatomy-2XVFBrW4.js} +1 -1
  11. package/.output/ui/assets/{ResponseView-DDpKdYk6.js → ResponseView-BULgzLVB.js} +1 -1
  12. package/.output/ui/assets/{StreamingChunkSequence-sMPGG7Sw.js → StreamingChunkSequence-DSkvkbns.js} +1 -1
  13. package/.output/ui/assets/{_sessionId-e4IheHnP.js → _sessionId-D2dmJi3G.js} +1 -1
  14. package/.output/ui/assets/{_sessionId-C5Uv72Fx.js → _sessionId-DcS0s1Mr.js} +1 -1
  15. package/.output/ui/assets/{index-B__qT0Yd.js → index-B0TN1KKO.js} +2 -2
  16. package/.output/ui/assets/{index-Be3bTCzi.js → index-Bva1zHEs.js} +1 -1
  17. package/.output/ui/assets/{index-C9q__p8J.js → index-BzBExOxu.js} +1 -1
  18. package/.output/ui/assets/{index-CtB0deSZ.js → index-k6sRQz55.js} +1 -1
  19. package/.output/ui/assets/{json-viewer-Db0AFp-7.js → json-viewer-CWM4tY-j.js} +1 -1
  20. package/.output/ui/assets/{jszip.min-DkY0Ym_q.js → jszip.min-BkWvRFlo.js} +1 -1
  21. package/.output/ui/index.html +1 -1
  22. package/package.json +8 -13
  23. package/src/assets/IDE/claudecode-color.svg +0 -1
  24. package/src/assets/IDE/codex-color.svg +0 -1
  25. package/src/assets/IDE/opencode.svg +0 -1
  26. package/src/assets/IDE/xiaomimimo.svg +0 -1
  27. package/src/assets/favicon.svg +0 -21
  28. package/src/assets/logos/alibaba.svg +0 -1
  29. package/src/assets/logos/anthropic.svg +0 -1
  30. package/src/assets/logos/claude-code.svg +0 -4
  31. package/src/assets/logos/deepseek.svg +0 -1
  32. package/src/assets/logos/minimax.jpeg +0 -0
  33. package/src/assets/logos/openai.svg +0 -1
  34. package/src/assets/logos/opencode.svg +0 -4
  35. package/src/assets/logos/qwen.webp +0 -0
  36. package/src/assets/logos/zhipuai.svg +0 -219
  37. package/src/backend/router.tsx +0 -36
  38. package/src/backend/routes/$.ts +0 -26
  39. package/src/backend/routes/__root.ts +0 -4
  40. package/src/backend/routes/api/-instances.ts +0 -7
  41. package/src/backend/routes/api/alerts.summary.ts +0 -28
  42. package/src/backend/routes/api/alerts.ts +0 -70
  43. package/src/backend/routes/api/config.paths.ts +0 -14
  44. package/src/backend/routes/api/config.ts +0 -73
  45. package/src/backend/routes/api/ecosystem.packages.$packageId.help.ts +0 -11
  46. package/src/backend/routes/api/ecosystem.packages.$packageId.install.ts +0 -11
  47. package/src/backend/routes/api/ecosystem.packages.$packageId.runner-presets.ts +0 -11
  48. package/src/backend/routes/api/ecosystem.packages.$packageId.upgrade.ts +0 -11
  49. package/src/backend/routes/api/ecosystem.packages.ts +0 -21
  50. package/src/backend/routes/api/ecosystem.recipes.$recipeId.run.ts +0 -11
  51. package/src/backend/routes/api/ecosystem.tasks.$taskId.ts +0 -16
  52. package/src/backend/routes/api/ecosystem.tasks.ts +0 -12
  53. package/src/backend/routes/api/groups.$groupId.evidence.ts +0 -55
  54. package/src/backend/routes/api/groups.$groupId.sessions.ts +0 -50
  55. package/src/backend/routes/api/groups.$groupId.ts +0 -93
  56. package/src/backend/routes/api/groups.ts +0 -79
  57. package/src/backend/routes/api/health.ts +0 -22
  58. package/src/backend/routes/api/instances.$name.connection.ts +0 -12
  59. package/src/backend/routes/api/instances.$name.restart.ts +0 -23
  60. package/src/backend/routes/api/instances.$name.start.ts +0 -18
  61. package/src/backend/routes/api/instances.$name.stop.ts +0 -23
  62. package/src/backend/routes/api/instances.$name.ts +0 -12
  63. package/src/backend/routes/api/instances.ts +0 -16
  64. package/src/backend/routes/api/knowledge.candidates.$candidateId.promote.ts +0 -32
  65. package/src/backend/routes/api/knowledge.candidates.$candidateId.ts +0 -50
  66. package/src/backend/routes/api/knowledge.candidates.ts +0 -10
  67. package/src/backend/routes/api/knowledge.project-context.ts +0 -29
  68. package/src/backend/routes/api/knowledge.search.ts +0 -62
  69. package/src/backend/routes/api/knowledge.sessions.$sessionId.candidates.ts +0 -26
  70. package/src/backend/routes/api/logs.$id.body.ts +0 -58
  71. package/src/backend/routes/api/logs.$id.chunks.ts +0 -37
  72. package/src/backend/routes/api/logs.$id.replay.ts +0 -297
  73. package/src/backend/routes/api/logs.$id.ts +0 -23
  74. package/src/backend/routes/api/logs.import.ts +0 -39
  75. package/src/backend/routes/api/logs.stream.ts +0 -174
  76. package/src/backend/routes/api/logs.ts +0 -214
  77. package/src/backend/routes/api/mcp.ts +0 -25
  78. package/src/backend/routes/api/models.ts +0 -10
  79. package/src/backend/routes/api/pi-agent.ts +0 -29
  80. package/src/backend/routes/api/providers.$providerId.model-metadata.ts +0 -173
  81. package/src/backend/routes/api/providers.$providerId.test.log.ts +0 -342
  82. package/src/backend/routes/api/providers.$providerId.ts +0 -111
  83. package/src/backend/routes/api/providers.export.ts +0 -44
  84. package/src/backend/routes/api/providers.import.ts +0 -81
  85. package/src/backend/routes/api/providers.scan.ts +0 -28
  86. package/src/backend/routes/api/providers.ts +0 -102
  87. package/src/backend/routes/api/runs.$runId.evidence.ts +0 -55
  88. package/src/backend/routes/api/runs.$runId.ts +0 -50
  89. package/src/backend/routes/api/runs.ts +0 -62
  90. package/src/backend/routes/api/runtime.ts +0 -46
  91. package/src/backend/routes/api/sessions.ts +0 -51
  92. package/src/backend/routes/api/storage.ts +0 -56
  93. package/src/backend/routes/livez.ts +0 -13
  94. package/src/backend/routes/metrics.ts +0 -14
  95. package/src/backend/routes/proxy/$.ts +0 -15
  96. package/src/backend/routes/readyz.ts +0 -18
  97. package/src/backend/start.ts +0 -10
  98. package/src/cli/alias.ts +0 -431
  99. package/src/cli/detect-tools.ts +0 -123
  100. package/src/cli/doctor.ts +0 -836
  101. package/src/cli/instance.ts +0 -1071
  102. package/src/cli/instanceApi.ts +0 -213
  103. package/src/cli/instanceArgs.ts +0 -301
  104. package/src/cli/instanceControl.ts +0 -191
  105. package/src/cli/instanceModel.ts +0 -276
  106. package/src/cli/instanceRegistry.ts +0 -731
  107. package/src/cli/networkHints.ts +0 -170
  108. package/src/cli/onboard.ts +0 -1668
  109. package/src/cli/onboardTarget.ts +0 -228
  110. package/src/cli/rustBackendPackage.ts +0 -458
  111. package/src/cli/startupOutput.ts +0 -16
  112. package/src/cli/templates/codex-skill-onboard.ts +0 -320
  113. package/src/cli/templates/command-onboard.ts +0 -25
  114. package/src/cli/templates/skill-onboard.ts +0 -625
  115. package/src/cli.ts +0 -1397
  116. package/src/components/OnboardingBanner.tsx +0 -115
  117. package/src/components/ProxyViewer.tsx +0 -2259
  118. package/src/components/ProxyViewerContainer.tsx +0 -1076
  119. package/src/components/alerts/AlertsDialog.tsx +0 -615
  120. package/src/components/clients/ClientLogo.tsx +0 -175
  121. package/src/components/ecosystem/AgentLabDialog.tsx +0 -947
  122. package/src/components/errors/SafeErrorBoundary.tsx +0 -201
  123. package/src/components/groups/GroupsDialog.tsx +0 -1304
  124. package/src/components/inspector-pet/InspectorPet.tsx +0 -398
  125. package/src/components/inspector-pet/InspectorPetCrab3D.tsx +0 -455
  126. package/src/components/inspector-pet/inspectorPetLogic.ts +0 -272
  127. package/src/components/pi-agent/PiAgentPanel.tsx +0 -446
  128. package/src/components/pi-agent/piAgentChatLogic.ts +0 -273
  129. package/src/components/providers/ImportWizardDialog.tsx +0 -281
  130. package/src/components/providers/ProviderCard.tsx +0 -347
  131. package/src/components/providers/ProviderForm.tsx +0 -1183
  132. package/src/components/providers/ProviderLogo.tsx +0 -122
  133. package/src/components/providers/ProviderTestResultsView.tsx +0 -734
  134. package/src/components/providers/ProvidersPanel.tsx +0 -714
  135. package/src/components/providers/SettingsDialog.tsx +0 -1042
  136. package/src/components/providers/providerFormCapabilities.ts +0 -36
  137. package/src/components/proxy-viewer/AgentTraceSummary.tsx +0 -902
  138. package/src/components/proxy-viewer/AnswerMarkdown.tsx +0 -51
  139. package/src/components/proxy-viewer/ApplicationBar.tsx +0 -123
  140. package/src/components/proxy-viewer/CompareDrawer.tsx +0 -984
  141. package/src/components/proxy-viewer/ConversationGroup.tsx +0 -208
  142. package/src/components/proxy-viewer/ConversationGroupList.tsx +0 -652
  143. package/src/components/proxy-viewer/ConversationHeader.tsx +0 -429
  144. package/src/components/proxy-viewer/LiveConnectionStatus.tsx +0 -186
  145. package/src/components/proxy-viewer/LogEntry.tsx +0 -1419
  146. package/src/components/proxy-viewer/LogEntryHeader.tsx +0 -596
  147. package/src/components/proxy-viewer/ProviderLogoStack.tsx +0 -57
  148. package/src/components/proxy-viewer/RawExportWarning.tsx +0 -77
  149. package/src/components/proxy-viewer/ReplayDialog.tsx +0 -636
  150. package/src/components/proxy-viewer/RequestToolsPanel.tsx +0 -299
  151. package/src/components/proxy-viewer/ResponseView.tsx +0 -202
  152. package/src/components/proxy-viewer/SessionLoadProgressBar.tsx +0 -61
  153. package/src/components/proxy-viewer/StreamingChunkSequence.tsx +0 -265
  154. package/src/components/proxy-viewer/ThreadConnector.tsx +0 -165
  155. package/src/components/proxy-viewer/ToolTraceEvents.tsx +0 -64
  156. package/src/components/proxy-viewer/TurnGroup.tsx +0 -383
  157. package/src/components/proxy-viewer/TurnGroupList.tsx +0 -156
  158. package/src/components/proxy-viewer/accessibility.ts +0 -8
  159. package/src/components/proxy-viewer/anatomy/RequestAnatomy.tsx +0 -887
  160. package/src/components/proxy-viewer/anatomy/SegmentBar.tsx +0 -222
  161. package/src/components/proxy-viewer/anatomy/contextIntelligence.ts +0 -737
  162. package/src/components/proxy-viewer/anatomy/sessionContextSummary.ts +0 -268
  163. package/src/components/proxy-viewer/anatomy/tokenEstimate.ts +0 -53
  164. package/src/components/proxy-viewer/anatomy/types.ts +0 -41
  165. package/src/components/proxy-viewer/anatomy/useAnatomyJump.ts +0 -114
  166. package/src/components/proxy-viewer/bodyHydration.ts +0 -123
  167. package/src/components/proxy-viewer/cacheTrend.ts +0 -50
  168. package/src/components/proxy-viewer/diff/DiffView.tsx +0 -321
  169. package/src/components/proxy-viewer/diff/computeDiff.ts +0 -178
  170. package/src/components/proxy-viewer/diff/index.ts +0 -3
  171. package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +0 -194
  172. package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +0 -81
  173. package/src/components/proxy-viewer/formats/anthropic/thinkingExtract.ts +0 -21
  174. package/src/components/proxy-viewer/formats/index.tsx +0 -47
  175. package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +0 -442
  176. package/src/components/proxy-viewer/index.ts +0 -9
  177. package/src/components/proxy-viewer/lazy.ts +0 -41
  178. package/src/components/proxy-viewer/liveConnectionState.ts +0 -158
  179. package/src/components/proxy-viewer/log-formats/anthropic.ts +0 -191
  180. package/src/components/proxy-viewer/log-formats/index.ts +0 -23
  181. package/src/components/proxy-viewer/log-formats/openai.ts +0 -256
  182. package/src/components/proxy-viewer/log-formats/types.ts +0 -40
  183. package/src/components/proxy-viewer/log-formats/unknown.ts +0 -18
  184. package/src/components/proxy-viewer/logEntryVisibility.ts +0 -73
  185. package/src/components/proxy-viewer/logFocus.ts +0 -54
  186. package/src/components/proxy-viewer/proxyViewerContainerLogic.ts +0 -124
  187. package/src/components/proxy-viewer/proxyViewerLogic.ts +0 -488
  188. package/src/components/proxy-viewer/replayComparison.ts +0 -131
  189. package/src/components/proxy-viewer/requestDiff.ts +0 -277
  190. package/src/components/proxy-viewer/requestTools.ts +0 -220
  191. package/src/components/proxy-viewer/useCopyFeedback.ts +0 -38
  192. package/src/components/proxy-viewer/useKeyboardNavigation.ts +0 -232
  193. package/src/components/proxy-viewer/viewerState.ts +0 -176
  194. package/src/components/ui/badge.tsx +0 -47
  195. package/src/components/ui/button.tsx +0 -47
  196. package/src/components/ui/collapsible.tsx +0 -21
  197. package/src/components/ui/confirm-dialog.tsx +0 -51
  198. package/src/components/ui/crab-logo.tsx +0 -45
  199. package/src/components/ui/crab-variants.tsx +0 -467
  200. package/src/components/ui/dialog.tsx +0 -130
  201. package/src/components/ui/icon-trigger.ts +0 -2
  202. package/src/components/ui/json-viewer-bulk.ts +0 -132
  203. package/src/components/ui/json-viewer.tsx +0 -508
  204. package/src/components/ui/scroll-area.tsx +0 -54
  205. package/src/components/ui/select.tsx +0 -178
  206. package/src/components/ui/separator.tsx +0 -28
  207. package/src/components/ui/tabs.tsx +0 -88
  208. package/src/components/ui/tooltip.tsx +0 -51
  209. package/src/components/ui/transient-toast.tsx +0 -105
  210. package/src/contracts/anthropic.ts +0 -230
  211. package/src/contracts/index.ts +0 -59
  212. package/src/contracts/json.ts +0 -37
  213. package/src/contracts/log.ts +0 -139
  214. package/src/contracts/openai.ts +0 -267
  215. package/src/index.css +0 -11
  216. package/src/knowledge/candidateStore.ts +0 -94
  217. package/src/knowledge/distiller.ts +0 -98
  218. package/src/knowledge/openclawClient.ts +0 -161
  219. package/src/knowledge/openclawGatewayClient.ts +0 -249
  220. package/src/knowledge/openclawMarkdown.ts +0 -146
  221. package/src/knowledge/redactor.ts +0 -80
  222. package/src/knowledge/types.ts +0 -83
  223. package/src/lib/alertContract.ts +0 -76
  224. package/src/lib/apiClient.ts +0 -166
  225. package/src/lib/apiFormat.ts +0 -29
  226. package/src/lib/backendImplementation.ts +0 -16
  227. package/src/lib/basePath.ts +0 -107
  228. package/src/lib/browserRuntimeContract.ts +0 -124
  229. package/src/lib/browserRuntimeResolver.ts +0 -333
  230. package/src/lib/chunkLoadRecovery.ts +0 -83
  231. package/src/lib/claudeCodeStrip.ts +0 -98
  232. package/src/lib/clipboard.ts +0 -67
  233. package/src/lib/codingAgentEndpoints.ts +0 -54
  234. package/src/lib/ecosystemContract.ts +0 -130
  235. package/src/lib/export-logs.ts +0 -287
  236. package/src/lib/groupContract.ts +0 -166
  237. package/src/lib/instanceContract.ts +0 -239
  238. package/src/lib/jsonFile.ts +0 -46
  239. package/src/lib/logImportContract.ts +0 -12
  240. package/src/lib/managedInstance.ts +0 -112
  241. package/src/lib/mask.ts +0 -4
  242. package/src/lib/objectUtils.ts +0 -22
  243. package/src/lib/piAgentContract.ts +0 -102
  244. package/src/lib/providerContract.ts +0 -125
  245. package/src/lib/providerImportContract.ts +0 -27
  246. package/src/lib/providerModelMetadata.ts +0 -458
  247. package/src/lib/providerTestContract.ts +0 -170
  248. package/src/lib/providerTestPrompt.ts +0 -100
  249. package/src/lib/publicBasePathContext.ts +0 -137
  250. package/src/lib/resourceLimits.ts +0 -345
  251. package/src/lib/runContract.ts +0 -164
  252. package/src/lib/runtimeConfig.ts +0 -43
  253. package/src/lib/safeDiagnostic.ts +0 -38
  254. package/src/lib/safeFetch.ts +0 -508
  255. package/src/lib/serverPort.ts +0 -47
  256. package/src/lib/sessionInfoContract.ts +0 -78
  257. package/src/lib/sessionUrl.ts +0 -46
  258. package/src/lib/ssrfGuard.ts +0 -133
  259. package/src/lib/stopReason.ts +0 -130
  260. package/src/lib/themeMode.ts +0 -41
  261. package/src/lib/timeDisplay.ts +0 -22
  262. package/src/lib/toolTrace.ts +0 -290
  263. package/src/lib/uiScale.ts +0 -117
  264. package/src/lib/unknown.ts +0 -27
  265. package/src/lib/upstreamUrl.ts +0 -150
  266. package/src/lib/useAlerts.ts +0 -82
  267. package/src/lib/useGroupEvidence.ts +0 -37
  268. package/src/lib/useGroups.ts +0 -32
  269. package/src/lib/useOnboarding.ts +0 -93
  270. package/src/lib/useProviders.ts +0 -30
  271. package/src/lib/useStripConfig.ts +0 -154
  272. package/src/lib/useThemeMode.ts +0 -40
  273. package/src/lib/useUiScale.ts +0 -52
  274. package/src/lib/utils.ts +0 -78
  275. package/src/mcp/currentContext.ts +0 -65
  276. package/src/mcp/instanceHandlers.ts +0 -151
  277. package/src/mcp/loopback.ts +0 -88
  278. package/src/mcp/mode.ts +0 -75
  279. package/src/mcp/previewExtractor.ts +0 -233
  280. package/src/mcp/server.ts +0 -2274
  281. package/src/mcp/toolHandlers.ts +0 -1533
  282. package/src/proxy/alerts.ts +0 -664
  283. package/src/proxy/chunkStorage.ts +0 -123
  284. package/src/proxy/config.ts +0 -218
  285. package/src/proxy/constants.ts +0 -66
  286. package/src/proxy/dataDir.ts +0 -147
  287. package/src/proxy/ecosystemExecutionConfirmation.ts +0 -114
  288. package/src/proxy/ecosystemExecutionRoute.ts +0 -116
  289. package/src/proxy/ecosystemRegistry.ts +0 -296
  290. package/src/proxy/ecosystemTasks.ts +0 -415
  291. package/src/proxy/evidenceAnalysis.ts +0 -526
  292. package/src/proxy/evidenceExporter.ts +0 -235
  293. package/src/proxy/formats/anthropic/anthropicProvider.ts +0 -75
  294. package/src/proxy/formats/anthropic/handler.ts +0 -75
  295. package/src/proxy/formats/anthropic/index.ts +0 -13
  296. package/src/proxy/formats/anthropic/register.ts +0 -4
  297. package/src/proxy/formats/anthropic/schemas.ts +0 -6
  298. package/src/proxy/formats/anthropic/stream.ts +0 -205
  299. package/src/proxy/formats/handler.ts +0 -46
  300. package/src/proxy/formats/index.ts +0 -13
  301. package/src/proxy/formats/jsonSchema.ts +0 -2
  302. package/src/proxy/formats/openai/alibabaProvider.ts +0 -34
  303. package/src/proxy/formats/openai/codexMetadata.ts +0 -61
  304. package/src/proxy/formats/openai/handler.ts +0 -133
  305. package/src/proxy/formats/openai/index.ts +0 -33
  306. package/src/proxy/formats/openai/provider.ts +0 -50
  307. package/src/proxy/formats/openai/register.ts +0 -4
  308. package/src/proxy/formats/openai/schemas.ts +0 -25
  309. package/src/proxy/formats/openai/stream.ts +0 -600
  310. package/src/proxy/formats/openai/zhipuProvider.ts +0 -31
  311. package/src/proxy/formats/providerAdapter.ts +0 -50
  312. package/src/proxy/formats/providerRegistry.ts +0 -51
  313. package/src/proxy/formats/providers/index.ts +0 -3
  314. package/src/proxy/formats/registry.ts +0 -65
  315. package/src/proxy/groupEvidenceExporter.ts +0 -371
  316. package/src/proxy/groupStore.ts +0 -336
  317. package/src/proxy/handler.ts +0 -729
  318. package/src/proxy/identityProxy.ts +0 -1842
  319. package/src/proxy/jsonlRecovery.ts +0 -554
  320. package/src/proxy/logBodyChunks.ts +0 -91
  321. package/src/proxy/logFinalizer.ts +0 -777
  322. package/src/proxy/logFinalizer.worker.ts +0 -24
  323. package/src/proxy/logImportUpload.ts +0 -128
  324. package/src/proxy/logImporter.ts +0 -813
  325. package/src/proxy/logIndex.ts +0 -663
  326. package/src/proxy/logSearch.ts +0 -122
  327. package/src/proxy/logger.ts +0 -537
  328. package/src/proxy/openaiOrphanToolStrip.ts +0 -142
  329. package/src/proxy/platformCommands.ts +0 -253
  330. package/src/proxy/privateDataPath.ts +0 -419
  331. package/src/proxy/providerImporters.ts +0 -578
  332. package/src/proxy/providerScanStore.ts +0 -87
  333. package/src/proxy/providerSecretStore.ts +0 -216
  334. package/src/proxy/providers.ts +0 -998
  335. package/src/proxy/rawStreamCapture.ts +0 -342
  336. package/src/proxy/runFailures.ts +0 -94
  337. package/src/proxy/runStore.ts +0 -214
  338. package/src/proxy/runtimeAdmission.ts +0 -55
  339. package/src/proxy/runtimeHealth.ts +0 -221
  340. package/src/proxy/runtimeMetrics.ts +0 -149
  341. package/src/proxy/runtimeShutdown.ts +0 -157
  342. package/src/proxy/schemas.ts +0 -112
  343. package/src/proxy/sessionArchive.ts +0 -479
  344. package/src/proxy/sessionInfo.ts +0 -266
  345. package/src/proxy/sessionProcess.ts +0 -194
  346. package/src/proxy/sessionRuntime.ts +0 -121
  347. package/src/proxy/sessionSupervisor.ts +0 -305
  348. package/src/proxy/sessionWorkerEntry.ts +0 -26
  349. package/src/proxy/shutdownCoordinator.ts +0 -90
  350. package/src/proxy/socketTracker.ts +0 -639
  351. package/src/proxy/sqliteLogIndex.ts +0 -733
  352. package/src/proxy/storageLifecycle.ts +0 -432
  353. package/src/proxy/store.ts +0 -1773
  354. package/src/proxy/streamTiming.ts +0 -31
  355. package/src/proxy/toolSchemaWarnings.ts +0 -529
  356. package/src/proxy/uiAssetServer.ts +0 -106
  357. package/src/proxy/upstream.ts +0 -127
  358. package/src/services/alerts.ts +0 -12
  359. package/src/services/groups.ts +0 -119
  360. package/src/services/piAgent.ts +0 -421
  361. package/src/services/piAgentRetrieval.ts +0 -1180
  362. package/src/services/result.ts +0 -17
  363. package/src/services/runs.ts +0 -76
  364. package/src/ui/bootstrap.ts +0 -167
  365. package/src/ui/index.html +0 -38
  366. package/src/ui/logsStreamClient.ts +0 -20
  367. package/src/ui/main.tsx +0 -13
  368. package/src/ui/public/runtime-config.js +0 -2
  369. package/src/ui/router.tsx +0 -13
  370. package/src/ui/routes/__root.tsx +0 -69
  371. package/src/ui/routes/index.tsx +0 -35
  372. package/src/ui/routes/session/$sessionId.tsx +0 -50
  373. package/src/ui/runtimeDiscovery.ts +0 -50
@@ -1,333 +0,0 @@
1
- import { getConfiguredBasePath } from "./basePath";
2
- import {
3
- BROWSER_RUNTIME_SCHEMA_VERSION,
4
- BrowserRuntimeDeploymentSchema,
5
- normalizeBrowserRuntimeBasePath,
6
- normalizeBrowserRuntimeBaseUrl,
7
- type BrowserRuntimeDeployment,
8
- } from "./browserRuntimeContract";
9
-
10
- export const AGENT_INSPECTOR_INJECTED_RUNTIME_GLOBAL = "__AGENT_INSPECTOR_RUNTIME__";
11
- export const AGENT_INSPECTOR_OPERATOR_RUNTIME_GLOBAL = "__AGENT_INSPECTOR_RUNTIME_CONFIG__";
12
- export const AGENT_INSPECTOR_RUNTIME_DISCOVERED_EVENT = "agent-inspector:runtime-discovered";
13
-
14
- export type BrowserRuntimeSource = "injected" | "operator" | "discovered" | "composed-fallback";
15
-
16
- export type BrowserRuntimeComposedFallback = {
17
- origin: string;
18
- uiBasePath: string;
19
- };
20
-
21
- export type BrowserRuntimeSources = {
22
- injected?: unknown;
23
- operator?: unknown;
24
- composedFallback?: BrowserRuntimeComposedFallback;
25
- };
26
-
27
- export type BrowserRuntimeResolution =
28
- | {
29
- ok: true;
30
- source: BrowserRuntimeSource;
31
- runtime: BrowserRuntimeDeployment;
32
- }
33
- | {
34
- ok: false;
35
- source: BrowserRuntimeSource | "none";
36
- code: "invalid" | "missing";
37
- issues: readonly string[];
38
- };
39
-
40
- let discoveredRuntimeForDocument: BrowserRuntimeDeployment | null = null;
41
-
42
- export function resetBrowserRuntimeDiscoveryForTests(): void {
43
- discoveredRuntimeForDocument = null;
44
- }
45
-
46
- function readGlobalValue(name: string): unknown {
47
- const descriptor = Object.getOwnPropertyDescriptor(globalThis, name);
48
- const value: unknown = descriptor?.value;
49
- if (
50
- typeof value === "object" &&
51
- value !== null &&
52
- !Array.isArray(value) &&
53
- Object.keys(value).length === 0
54
- ) {
55
- return undefined;
56
- }
57
- return value;
58
- }
59
-
60
- export function readBrowserRuntimeSources(): Pick<BrowserRuntimeSources, "injected" | "operator"> {
61
- return {
62
- injected: readGlobalValue(AGENT_INSPECTOR_INJECTED_RUNTIME_GLOBAL),
63
- operator: readGlobalValue(AGENT_INSPECTOR_OPERATOR_RUNTIME_GLOBAL),
64
- };
65
- }
66
-
67
- function formatIssues(error: {
68
- issues: readonly { path: PropertyKey[]; message: string }[];
69
- }): string[] {
70
- return error.issues.map((issue) => {
71
- const path = issue.path.map(String).join(".");
72
- return path.length === 0 ? issue.message : `${path}: ${issue.message}`;
73
- });
74
- }
75
-
76
- function validateRuntime(source: BrowserRuntimeSource, value: unknown): BrowserRuntimeResolution {
77
- const parsed = BrowserRuntimeDeploymentSchema.safeParse(value);
78
- if (parsed.success) {
79
- return { ok: true, source, runtime: parsed.data };
80
- }
81
- return {
82
- ok: false,
83
- source,
84
- code: "invalid",
85
- issues: formatIssues(parsed.error),
86
- };
87
- }
88
-
89
- function parseRuntimeBaseUrl(value: string): URL | null {
90
- try {
91
- return new URL(value);
92
- } catch {
93
- return null;
94
- }
95
- }
96
-
97
- function isLoopbackHostname(hostname: string): boolean {
98
- const normalized = hostname.toLowerCase();
99
- return (
100
- normalized === "localhost" ||
101
- normalized === "127.0.0.1" ||
102
- normalized === "::1" ||
103
- normalized === "[::1]"
104
- );
105
- }
106
-
107
- function sameLoopbackEndpoint(left: URL, right: URL): boolean {
108
- return (
109
- left.protocol === right.protocol &&
110
- left.port === right.port &&
111
- isLoopbackHostname(left.hostname) &&
112
- isLoopbackHostname(right.hostname)
113
- );
114
- }
115
-
116
- function runtimeBasePathFromUrl(url: URL): string | null {
117
- return normalizeBrowserRuntimeBasePath(url.pathname);
118
- }
119
-
120
- function rewriteLoopbackBaseUrlToDocumentOrigin(baseUrl: string, uiBasePath: string): string {
121
- if (typeof globalThis.location === "undefined") return baseUrl;
122
- const documentOrigin = normalizeBrowserRuntimeBaseUrl(globalThis.location.origin);
123
- if (documentOrigin === null) return baseUrl;
124
-
125
- const parsedBase = parseRuntimeBaseUrl(baseUrl);
126
- const parsedDocument = parseRuntimeBaseUrl(documentOrigin);
127
- if (parsedBase === null || parsedDocument === null) return baseUrl;
128
- if (!sameLoopbackEndpoint(parsedBase, parsedDocument)) return baseUrl;
129
-
130
- const normalizedUiBasePath = normalizeBrowserRuntimeBasePath(uiBasePath);
131
- const normalizedRuntimeBasePath = runtimeBasePathFromUrl(parsedBase);
132
- if (
133
- normalizedUiBasePath === null ||
134
- normalizedRuntimeBasePath === null ||
135
- normalizedUiBasePath !== normalizedRuntimeBasePath
136
- ) {
137
- return baseUrl;
138
- }
139
-
140
- return normalizedUiBasePath === "/"
141
- ? parsedDocument.origin
142
- : `${parsedDocument.origin}${normalizedUiBasePath}`;
143
- }
144
-
145
- function preferDocumentLoopbackRuntime(
146
- runtime: BrowserRuntimeDeployment,
147
- ): BrowserRuntimeDeployment {
148
- return {
149
- ...runtime,
150
- control: {
151
- baseUrl: rewriteLoopbackBaseUrlToDocumentOrigin(runtime.control.baseUrl, runtime.ui.basePath),
152
- },
153
- agent: {
154
- baseUrl: rewriteLoopbackBaseUrlToDocumentOrigin(runtime.agent.baseUrl, runtime.ui.basePath),
155
- },
156
- };
157
- }
158
-
159
- function fallbackRuntime(fallback: BrowserRuntimeComposedFallback): unknown {
160
- const normalizedOrigin = normalizeBrowserRuntimeBaseUrl(fallback.origin);
161
- const normalizedBasePath = normalizeBrowserRuntimeBasePath(
162
- fallback.uiBasePath.length === 0 ? "/" : fallback.uiBasePath,
163
- );
164
- if (
165
- normalizedOrigin === null ||
166
- normalizedBasePath === null ||
167
- normalizedOrigin !== new URL(normalizedOrigin).origin
168
- ) {
169
- return null;
170
- }
171
-
172
- const baseUrl =
173
- normalizedBasePath === "/" ? normalizedOrigin : `${normalizedOrigin}${normalizedBasePath}`;
174
- return {
175
- schemaVersion: BROWSER_RUNTIME_SCHEMA_VERSION,
176
- deploymentMode: "composed",
177
- ui: { basePath: normalizedBasePath },
178
- control: { baseUrl },
179
- agent: { baseUrl },
180
- capabilities: {
181
- rest: true,
182
- sse: true,
183
- proxy: true,
184
- mcp: true,
185
- },
186
- };
187
- }
188
-
189
- export function resolveBrowserRuntime(sources: BrowserRuntimeSources): BrowserRuntimeResolution {
190
- if (sources.injected !== undefined) {
191
- return validateRuntime("injected", sources.injected);
192
- }
193
- if (sources.operator !== undefined) {
194
- return validateRuntime("operator", sources.operator);
195
- }
196
- if (sources.composedFallback !== undefined) {
197
- return validateRuntime("composed-fallback", fallbackRuntime(sources.composedFallback));
198
- }
199
- return {
200
- ok: false,
201
- source: "none",
202
- code: "missing",
203
- issues: ["No injected, operator, or explicit composed runtime configuration is available."],
204
- };
205
- }
206
-
207
- function configuredBrowserRuntimeForDocument(): BrowserRuntimeResolution | null {
208
- const sources = readBrowserRuntimeSources();
209
- if (sources.injected !== undefined || sources.operator !== undefined) {
210
- return resolveBrowserRuntime(sources);
211
- }
212
- return null;
213
- }
214
-
215
- export function acceptBrowserRuntimeDiscovery(
216
- expectedFallback: BrowserRuntimeDeployment,
217
- value: unknown,
218
- ): BrowserRuntimeResolution {
219
- const discovered = validateRuntime("discovered", value);
220
- if (!discovered.ok) return discovered;
221
- const normalizedRuntime = preferDocumentLoopbackRuntime(discovered.runtime);
222
- if (
223
- normalizedRuntime.control.baseUrl !== expectedFallback.control.baseUrl ||
224
- normalizedRuntime.ui.basePath !== expectedFallback.ui.basePath
225
- ) {
226
- return {
227
- ok: false,
228
- source: "discovered",
229
- code: "invalid",
230
- issues: ["Backend discovery does not match the same-origin fallback control surface."],
231
- };
232
- }
233
- discoveredRuntimeForDocument = normalizedRuntime;
234
- if (typeof globalThis.dispatchEvent === "function" && typeof globalThis.Event === "function") {
235
- globalThis.dispatchEvent(new Event(AGENT_INSPECTOR_RUNTIME_DISCOVERED_EVENT));
236
- }
237
- return { ok: true, source: "discovered", runtime: normalizedRuntime };
238
- }
239
-
240
- export function resolveVerifiedBrowserRuntimeForDocument(): BrowserRuntimeResolution {
241
- const configured = configuredBrowserRuntimeForDocument();
242
- if (configured !== null) {
243
- return configured.ok
244
- ? { ...configured, runtime: preferDocumentLoopbackRuntime(configured.runtime) }
245
- : configured;
246
- }
247
- if (discoveredRuntimeForDocument !== null) {
248
- const discovered = validateRuntime("discovered", discoveredRuntimeForDocument);
249
- return discovered.ok
250
- ? { ...discovered, runtime: preferDocumentLoopbackRuntime(discovered.runtime) }
251
- : discovered;
252
- }
253
- return {
254
- ok: false,
255
- source: "none",
256
- code: "missing",
257
- issues: ["The same-origin backend discovery response has not been validated."],
258
- };
259
- }
260
-
261
- export function resolveBrowserRuntimeForDocument(): BrowserRuntimeResolution {
262
- const configured = configuredBrowserRuntimeForDocument();
263
- if (configured !== null) {
264
- return configured.ok
265
- ? { ...configured, runtime: preferDocumentLoopbackRuntime(configured.runtime) }
266
- : configured;
267
- }
268
- if (discoveredRuntimeForDocument !== null) {
269
- const discovered = validateRuntime("discovered", discoveredRuntimeForDocument);
270
- return discovered.ok
271
- ? { ...discovered, runtime: preferDocumentLoopbackRuntime(discovered.runtime) }
272
- : discovered;
273
- }
274
- if (typeof globalThis.location === "undefined") return resolveBrowserRuntime({});
275
- return resolveBrowserRuntime({
276
- composedFallback: {
277
- origin: globalThis.location.origin,
278
- uiBasePath: getConfiguredBasePath(),
279
- },
280
- });
281
- }
282
-
283
- function hasControlCharacter(value: string): boolean {
284
- return [...value].some((character) => {
285
- const code = character.charCodeAt(0);
286
- return code < 32 || code === 127;
287
- });
288
- }
289
-
290
- function normalizeLogicalRuntimePath(value: string): string | null {
291
- if (
292
- value.trim() !== value ||
293
- !value.startsWith("/") ||
294
- value.startsWith("//") ||
295
- value.includes("#") ||
296
- value.includes("\\") ||
297
- hasControlCharacter(value)
298
- ) {
299
- return null;
300
- }
301
-
302
- const queryIndex = value.indexOf("?");
303
- const pathname = queryIndex < 0 ? value : value.slice(0, queryIndex);
304
- const segments = pathname.split("/");
305
- if (
306
- segments.some(
307
- (segment) => segment === "." || segment === ".." || /%(?:2e|2f|5c)/iu.test(segment),
308
- )
309
- ) {
310
- return null;
311
- }
312
- return value === "/" ? "" : value;
313
- }
314
-
315
- function buildRuntimeUrl(baseUrl: string, logicalPath: string): string | null {
316
- const path = normalizeLogicalRuntimePath(logicalPath);
317
- if (path === null) return null;
318
- return `${baseUrl}${path}`;
319
- }
320
-
321
- export function buildControlRuntimeUrl(
322
- runtime: BrowserRuntimeDeployment,
323
- logicalPath: string,
324
- ): string | null {
325
- return buildRuntimeUrl(runtime.control.baseUrl, logicalPath);
326
- }
327
-
328
- export function buildAgentRuntimeUrl(
329
- runtime: BrowserRuntimeDeployment,
330
- logicalPath: string,
331
- ): string | null {
332
- return buildRuntimeUrl(runtime.agent.baseUrl, logicalPath);
333
- }
@@ -1,83 +0,0 @@
1
- const CHUNK_LOAD_RELOAD_AT_KEY = "agent-inspector.chunkLoadReloadAt";
2
- const CHUNK_LOAD_RELOAD_WINDOW_MS = 15_000;
3
-
4
- const CHUNK_LOAD_FAILURE_PATTERNS = [
5
- "failed to fetch dynamically imported module",
6
- "failed to load module script",
7
- "importing a module script failed",
8
- "error loading dynamically imported module",
9
- "loading chunk",
10
- "unable to preload css",
11
- ];
12
-
13
- function messageFromReason(reason: unknown): string {
14
- if (reason instanceof Error) {
15
- return reason.message;
16
- }
17
-
18
- if (typeof reason === "string") {
19
- return reason;
20
- }
21
-
22
- return "";
23
- }
24
-
25
- function isChunkLoadFailureMessage(message: string): boolean {
26
- const normalizedMessage = message.toLowerCase();
27
- return CHUNK_LOAD_FAILURE_PATTERNS.some((pattern) => normalizedMessage.includes(pattern));
28
- }
29
-
30
- function readLastReloadAt(): number {
31
- const storedValue = window.sessionStorage.getItem(CHUNK_LOAD_RELOAD_AT_KEY);
32
- if (storedValue === null) {
33
- return 0;
34
- }
35
-
36
- const parsedValue = Number(storedValue);
37
- return Number.isFinite(parsedValue) ? parsedValue : 0;
38
- }
39
-
40
- function reloadOnceForChunkFailure(): void {
41
- const now = Date.now();
42
- const lastReloadAt = readLastReloadAt();
43
- if (now - lastReloadAt < CHUNK_LOAD_RELOAD_WINDOW_MS) {
44
- return;
45
- }
46
-
47
- window.sessionStorage.setItem(CHUNK_LOAD_RELOAD_AT_KEY, String(now));
48
- window.location.reload();
49
- }
50
-
51
- export function installChunkLoadRecovery(): () => void {
52
- if (typeof window === "undefined") {
53
- return () => {};
54
- }
55
-
56
- const handleUnhandledRejection = (event: PromiseRejectionEvent): void => {
57
- const message = messageFromReason(event.reason);
58
- if (!isChunkLoadFailureMessage(message)) {
59
- return;
60
- }
61
-
62
- event.preventDefault();
63
- reloadOnceForChunkFailure();
64
- };
65
-
66
- const handleError = (event: ErrorEvent): void => {
67
- const message = event.message !== "" ? event.message : messageFromReason(event.error);
68
- if (!isChunkLoadFailureMessage(message)) {
69
- return;
70
- }
71
-
72
- event.preventDefault();
73
- reloadOnceForChunkFailure();
74
- };
75
-
76
- window.addEventListener("unhandledrejection", handleUnhandledRejection);
77
- window.addEventListener("error", handleError);
78
-
79
- return () => {
80
- window.removeEventListener("unhandledrejection", handleUnhandledRejection);
81
- window.removeEventListener("error", handleError);
82
- };
83
- }
@@ -1,98 +0,0 @@
1
- import { isPlainRecord, safeGetOwnProperty } from "./objectUtils";
2
-
3
- /**
4
- * Claude Code (and similar Anthropic SDK-based clients) prepend a synthetic
5
- * text block to the `system` array that looks like an HTTP header:
6
- *
7
- * x-anthropic-billing-header: cc_version=2.1.92.61c; cc_entrypoint=cli; cch=00000;
8
- *
9
- * The `cch` field is a per-request cache-hint value. When this block is
10
- * forwarded verbatim to a third-party model, the system prompt prefix
11
- * changes on every request, which kills prefix-cache hit rates and wastes
12
- * input tokens.
13
- *
14
- * This browser-safe module contains only the pure request transformation so
15
- * the proxy and UI preview can share it without coupling the UI to the proxy.
16
- */
17
-
18
- const BILLING_HEADER_PREFIX = "x-anthropic-billing-header:";
19
-
20
- type StripResult = {
21
- /** The new request body. Equal to input when no change was made. */
22
- body: string;
23
- /** Number of billing-header text blocks removed. */
24
- removed: number;
25
- };
26
-
27
- /**
28
- * Returns true if the given text looks like the synthetic billing-header
29
- * block that Claude Code injects. Whitespace at the start is tolerated and
30
- * the match is case-insensitive on the header name.
31
- */
32
- export function isClaudeCodeBillingHeaderBlock(text: string): boolean {
33
- const trimmed = text.trimStart();
34
- return trimmed.toLowerCase().startsWith(BILLING_HEADER_PREFIX);
35
- }
36
-
37
- function isObjectWithSystem(value: unknown): value is { system?: unknown[] } {
38
- if (!isPlainRecord(value)) return false;
39
- return Object.prototype.hasOwnProperty.call(value, "system");
40
- }
41
-
42
- function isBillingHeaderTextBlock(block: unknown): boolean {
43
- if (!isPlainRecord(block)) return false;
44
- const typeVal = safeGetOwnProperty(block, "type");
45
- const textVal = safeGetOwnProperty(block, "text");
46
- if (typeof typeVal !== "string" || typeVal !== "text") return false;
47
- if (typeof textVal !== "string") return false;
48
- return isClaudeCodeBillingHeaderBlock(textVal);
49
- }
50
-
51
- /**
52
- * Inspects the request body and, if it is an Anthropic-format request whose
53
- * `system` array contains one or more Claude Code billing-header text blocks,
54
- * returns a new body with those blocks removed. The original string is
55
- * returned unchanged when no edit is needed so callers can avoid
56
- * re-serializing.
57
- */
58
- export function stripClaudeCodeBillingHeader(rawBody: string): StripResult {
59
- let parsed: unknown;
60
- try {
61
- parsed = JSON.parse(rawBody);
62
- } catch {
63
- return { body: rawBody, removed: 0 };
64
- }
65
-
66
- if (!isObjectWithSystem(parsed)) {
67
- return { body: rawBody, removed: 0 };
68
- }
69
-
70
- const system = parsed.system;
71
-
72
- if (!Array.isArray(system) || system.length === 0) {
73
- return { body: rawBody, removed: 0 };
74
- }
75
-
76
- const kept: unknown[] = [];
77
- let removed = 0;
78
-
79
- for (const block of system) {
80
- if (isBillingHeaderTextBlock(block)) {
81
- removed += 1;
82
- continue;
83
- }
84
- kept.push(block);
85
- }
86
-
87
- if (removed === 0) {
88
- return { body: rawBody, removed: 0 };
89
- }
90
-
91
- if (kept.length === 0) {
92
- delete parsed.system;
93
- } else {
94
- parsed.system = kept;
95
- }
96
-
97
- return { body: JSON.stringify(parsed), removed };
98
- }
@@ -1,67 +0,0 @@
1
- function restoreSelection(selection: Selection | null, ranges: readonly Range[]): void {
2
- if (selection === null) return;
3
- selection.removeAllRanges();
4
- for (const range of ranges) {
5
- selection.addRange(range);
6
- }
7
- }
8
-
9
- function readSelectionRanges(selection: Selection | null): Range[] {
10
- if (selection === null) return [];
11
- const ranges: Range[] = [];
12
- for (let index = 0; index < selection.rangeCount; index++) {
13
- ranges.push(selection.getRangeAt(index));
14
- }
15
- return ranges;
16
- }
17
-
18
- function copyWithTextareaFallback(text: string): boolean {
19
- if (typeof document === "undefined") return false;
20
-
21
- const activeElement = document.activeElement;
22
- const selection = document.getSelection();
23
- const ranges = readSelectionRanges(selection);
24
- const textarea = document.createElement("textarea");
25
-
26
- textarea.value = text;
27
- textarea.setAttribute("readonly", "");
28
- textarea.style.position = "fixed";
29
- textarea.style.top = "0";
30
- textarea.style.left = "-9999px";
31
- textarea.style.opacity = "0";
32
-
33
- document.body.appendChild(textarea);
34
- textarea.focus();
35
- textarea.select();
36
- textarea.setSelectionRange(0, text.length);
37
-
38
- let copied = false;
39
- try {
40
- copied = document.execCommand("copy");
41
- } catch {
42
- // Keep the false default.
43
- } finally {
44
- document.body.removeChild(textarea);
45
- restoreSelection(selection, ranges);
46
- if (typeof HTMLElement !== "undefined" && activeElement instanceof HTMLElement) {
47
- activeElement.focus({ preventScroll: true });
48
- }
49
- }
50
-
51
- return copied;
52
- }
53
-
54
- export async function copyTextToClipboard(text: string): Promise<boolean> {
55
- const clipboard = globalThis.navigator?.clipboard;
56
- if (clipboard !== undefined) {
57
- try {
58
- await clipboard.writeText(text);
59
- return true;
60
- } catch {
61
- // Fall back below. Some embedded browsers expose Clipboard API but reject
62
- // writes outside a secure context or without an explicit permission grant.
63
- }
64
- }
65
-
66
- return copyWithTextareaFallback(text);
67
- }
@@ -1,54 +0,0 @@
1
- import { appendBasePathToOrigin } from "./basePath";
2
- import type { BrowserRuntimeDeployment } from "./browserRuntimeContract";
3
- import {
4
- AGENT_INSPECTOR_RUNTIME_DISCOVERED_EVENT,
5
- buildAgentRuntimeUrl,
6
- resolveVerifiedBrowserRuntimeForDocument,
7
- } from "./browserRuntimeResolver";
8
-
9
- export type CodingAgentEndpoints = {
10
- proxy: string;
11
- openAiV1: string;
12
- mcp: string;
13
- };
14
-
15
- /** Derive the public protocol endpoints shown to coding agents from one Inspector origin. */
16
- export function deriveCodingAgentEndpoints(origin: string, basePath: string): CodingAgentEndpoints {
17
- return {
18
- proxy: appendBasePathToOrigin(origin, "/proxy", basePath),
19
- openAiV1: appendBasePathToOrigin(origin, "/proxy/v1", basePath),
20
- mcp: appendBasePathToOrigin(origin, "/api/mcp", basePath),
21
- };
22
- }
23
-
24
- /** Derive copyable Coding Agent endpoints exclusively from the agent-facing runtime surface. */
25
- export function deriveCodingAgentEndpointsFromRuntime(
26
- runtime: BrowserRuntimeDeployment,
27
- ): CodingAgentEndpoints | null {
28
- const proxy = buildAgentRuntimeUrl(runtime, "/proxy");
29
- const openAiV1 = buildAgentRuntimeUrl(runtime, "/proxy/v1");
30
- const mcp = buildAgentRuntimeUrl(runtime, "/api/mcp");
31
- if (proxy === null || openAiV1 === null || mcp === null) return null;
32
- return { proxy, openAiV1, mcp };
33
- }
34
-
35
- export function resolveCodingAgentEndpointsForDocument(): CodingAgentEndpoints | null {
36
- const runtime = resolveVerifiedBrowserRuntimeForDocument();
37
- if (!runtime.ok) return null;
38
- return deriveCodingAgentEndpointsFromRuntime(runtime.runtime);
39
- }
40
-
41
- export function subscribeCodingAgentEndpoints(
42
- listener: (endpoints: CodingAgentEndpoints | null) => void,
43
- ): () => void {
44
- const update = (): void => listener(resolveCodingAgentEndpointsForDocument());
45
- update();
46
- if (
47
- typeof globalThis.addEventListener !== "function" ||
48
- typeof globalThis.removeEventListener !== "function"
49
- ) {
50
- return () => undefined;
51
- }
52
- globalThis.addEventListener(AGENT_INSPECTOR_RUNTIME_DISCOVERED_EVENT, update);
53
- return () => globalThis.removeEventListener(AGENT_INSPECTOR_RUNTIME_DISCOVERED_EVENT, update);
54
- }