@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,625 +0,0 @@
1
- /**
2
- * Renders `~/.claude/skills/agent-inspector-onboard/SKILL.md` for the
3
- * `agent-inspector onboard` subcommand. The body is a multi-phase teaching
4
- * workflow with `EXPLAIN / DO / PAUSE` markers — Claude reads it and walks
5
- * the user through real actions (start the proxy, hit /api/health, post a
6
- * test request, poll /api/logs) instead of just printing a static tutorial.
7
- *
8
- * The template embeds platform-aware shell snippets inline (bash + PowerShell
9
- * side-by-side). Skills are pure Markdown — they can't `require()` from the
10
- * package at runtime, so the duplication is the price of portability.
11
- *
12
- * All PowerShell snippets that use `$env:` variables are written so they
13
- * work when invoked via the Bash tool. The pattern is:
14
- * powershell -Command '<single-quoted block with $env:LITERAL>'
15
- * NOT
16
- * powershell -Command "<double-quoted block with escaped \$env:>"
17
- * The latter collapses `$env:` to a literal in bash before PowerShell sees
18
- * it, producing garbled paths. Single-quoted bash arguments pass through
19
- * to PowerShell unchanged.
20
- */
21
-
22
- export type SkillOnboardContext = {
23
- /** Package version (from `package.json`), stamped into the frontmatter. */
24
- readonly version: string;
25
- /** The default proxy port (mirrors `DEFAULT_PORT` in `src/cli.ts`). */
26
- readonly port: number;
27
- /** Public backend control/agent Base URL, including the configured Base Path. */
28
- readonly baseUrl: string;
29
- /** Optional composed or standalone UI URL. Undefined preserves the legacy composed default. */
30
- readonly uiUrl?: string | null;
31
- /** REST/SSE Base URL. Falls back to baseUrl for compatibility. */
32
- readonly controlBaseUrl?: string;
33
- /** Proxy/MCP Base URL. Falls back to baseUrl for compatibility. */
34
- readonly agentBaseUrl?: string;
35
- /** MCP config key selected by onboarding. */
36
- readonly mcpName?: string;
37
- /** Selected onboarding target type. */
38
- readonly targetKind?: "default" | "instance" | "base-url";
39
- /** Normalized registry name for a named target. */
40
- readonly instanceName?: string | null;
41
- /** CLI arguments that reproduce the selected target. */
42
- readonly onboardTargetArguments?: string;
43
- /**
44
- * One-line "detected tools" summary written into the Preflight phase so the
45
- * skill's instructions match the user's actual environment. Empty string
46
- * means "no known tool detected — fall through to the curl example".
47
- */
48
- readonly detectedSummary: string;
49
- };
50
-
51
- /** The 9 phase headings the spec requires. The validator checks for these. */
52
- export const REQUIRED_PHASE_HEADINGS = [
53
- "Phase 0: Idempotency check",
54
- "Preflight",
55
- "Phase 1: Welcome",
56
- "Phase 2: Provider setup",
57
- "Phase 3: Start proxy",
58
- "Phase 4: Wire tool",
59
- "Phase 4.5: Wire MCP server",
60
- "Phase 5: First capture",
61
- "Phase 6: Tour & wrap",
62
- ] as const;
63
-
64
- export function renderSkillOnboard(ctx: SkillOnboardContext): string {
65
- const { version, port, detectedSummary } = ctx;
66
- const controlBaseUrl = ctx.controlBaseUrl ?? ctx.baseUrl;
67
- const agentBaseUrl = ctx.agentBaseUrl ?? ctx.baseUrl;
68
- const uiUrl = ctx.uiUrl === undefined ? ctx.baseUrl : ctx.uiUrl;
69
- const mcpName = ctx.mcpName ?? "agent-inspector";
70
- const targetKind = ctx.targetKind ?? "default";
71
- const targetArguments = ctx.onboardTargetArguments ?? "";
72
- const instanceName = ctx.instanceName ?? null;
73
- const healthUrl = `${controlBaseUrl}/api/health`;
74
- const runtimeUrl = `${controlBaseUrl}/api/runtime`;
75
- const configUrl = `${controlBaseUrl}/api/config`;
76
- const anthropicProxyUrl = `${agentBaseUrl}/proxy`;
77
- const openAiProxyUrl = `${agentBaseUrl}/proxy/v1`;
78
- const mcpUrl = `${agentBaseUrl}/api/mcp`;
79
- const logsUrl = `${controlBaseUrl}/api/logs`;
80
- const providersUrl = `${controlBaseUrl}/api/providers`;
81
- const statusCommand = `agent-inspector onboard --status${targetArguments}`;
82
- const refreshCommand = `agent-inspector onboard --force${targetArguments}`;
83
- const startCommand =
84
- targetKind === "instance" && instanceName !== null
85
- ? `agent-inspector instance start ${instanceName}`
86
- : targetKind === "base-url"
87
- ? `# Explicit control target ${controlBaseUrl}: do not start a replacement local runtime.`
88
- : "agent-inspector --mode simple --background --no-open";
89
- const fullModeCommand =
90
- targetKind === "instance" && instanceName !== null
91
- ? `agent-inspector instance restart ${instanceName} --mode full`
92
- : targetKind === "base-url"
93
- ? "ask the target operator to enable Full capture mode"
94
- : "agent-inspector --mode full --force-restart";
95
- const bashStartSnippet =
96
- targetKind === "base-url" ? startCommand : `${startCommand} > /tmp/agent-inspector.log 2>&1`;
97
- const windowsStartArguments =
98
- targetKind === "instance" && instanceName !== null
99
- ? `instance start ${instanceName}`
100
- : "--mode simple --background --no-open";
101
- const powershellStartSnippet =
102
- targetKind === "base-url"
103
- ? startCommand
104
- : `$found = Get-Command agent-inspector -ErrorAction SilentlyContinue
105
- if (-not $found) { throw 'agent-inspector is not on PATH' }
106
- & $found.Source ${windowsStartArguments}`;
107
- const startExplanation =
108
- targetKind === "base-url"
109
- ? `The selected Inspector target uses control Base URL \`${controlBaseUrl}\` and agent Base URL \`${agentBaseUrl}\`. Do not launch a default local runtime as a substitute; verify the selected target and ask its operator for help if it is unavailable.`
110
- : `Start or reuse the selected Inspector backend. Its public control and agent endpoints preserve the selected Base Path; a Web UI may be composed at the same URL, hosted separately, or intentionally absent in backend-only mode. Use \`${fullModeCommand}\` only when the user needs raw headers, raw response, or SSE chunks.`;
111
- const stopSnippet =
112
- targetKind === "instance" && instanceName !== null
113
- ? `agent-inspector instance stop ${instanceName}`
114
- : targetKind === "base-url"
115
- ? `# Ask the operator of ${controlBaseUrl} to stop the selected runtime.`
116
- : `# Unix / macOS\n lsof -ti:${String(port)} | xargs -r kill -9\n\n # Windows PowerShell\n Get-NetTCPConnection -LocalPort ${String(port)} | ForEach-Object { Stop-Process -Id $_.OwningProcess -Force }`;
117
- const providerScopeGuidance =
118
- targetKind === "default"
119
- ? "The unmanaged default target owns the local Agent Inspector data directory used by the file checks below."
120
- : `The selected target is not the unmanaged default data directory. Do not inspect or edit local ~/.agent-inspector Provider files as a substitute. Query \`${providersUrl}\`, use the selected target's MCP Provider tools with explicit approval, or ask its operator to configure Providers. Skip local-file commands below.`;
121
- const selectedUi =
122
- uiUrl === null ? "not supplied (do not infer one from a backend URL)" : `\`${uiUrl}\``;
123
- const uiTour =
124
- uiUrl === null
125
- ? "not supplied; continue with MCP/REST, and ask the operator for a standalone UI URL only if the user needs one"
126
- : `\`${uiUrl}\` — use this explicit composed or standalone browser URL; do not replace it with the control or agent Base URL`;
127
- return `---
128
- name: agent-inspector-onboard
129
- description: Guided setup for Agent Inspector v${version}: start or select the backend, wire your AI coding tool, and capture your first request with or without a Web UI.
130
- metadata:
131
- author: agent-inspector
132
- version: ${version}
133
- ---
134
-
135
- # Agent Inspector onboard
136
-
137
- Guide the user from "I just installed Agent Inspector" to "my coding agent can use the proxy, REST API, and MCP surface". The backend works in composed and headless deployments; treat the Web UI as an optional presentation surface.
138
-
139
- Environment detected by the installer:
140
- ${detectedSummary || " (no known AI tool detected — the user can still use the generic curl example in Phase 4)"}
141
-
142
- Selected Inspector surfaces:
143
- - UI URL: ${selectedUi}
144
- - Control Base URL: \`${controlBaseUrl}\`
145
- - Agent Base URL: \`${agentBaseUrl}\`
146
- - MCP key: \`${mcpName}\`
147
-
148
- > **PAUSE protocol.** Every \`**PAUSE**\` marker in this skill is a real stop.
149
- > Use the \`AskUserQuestion\` tool to actually wait for the user before
150
- > continuing. Do not stream past a PAUSE based on context — the user has
151
- > not seen your output yet. Each PAUSE in the body below includes a sample
152
- > question you can adapt.
153
-
154
- ---
155
-
156
- ## Phase 0: Idempotency check
157
-
158
- **EXPLAIN:** "Before we do anything, let me see what's already set up. If some of the steps are already done, we can skip them."
159
-
160
- **DO:** First check whether the generated onboarding files match the installed npm package. If any
161
- entry is \`outdated\` or \`missing\`, tell the user to run \`${refreshCommand}\` before
162
- continuing so they are not guided by stale instructions.
163
-
164
- \`\`\`bash
165
- ${statusCommand}
166
- \`\`\`
167
-
168
- \`\`\`powershell
169
- ${statusCommand}
170
- \`\`\`
171
-
172
- **DO:** Then probe the three pieces of state this skill touches. Use targeted checks — do **not** read large JSON files into the conversation.
173
-
174
- **DO:** ${providerScopeGuidance}
175
-
176
- \`\`\`bash
177
- # 1. Is the backend already up?
178
- curl -fsS "${healthUrl}" 2>/dev/null && echo "BACKEND: up" || echo "BACKEND: down"
179
-
180
- # 2. Does the provider config have a real provider key?
181
- agent_inspector_data_dir() {
182
- base="\${HOME:-/tmp}"
183
- if [ -n "\${AGENT_INSPECTOR_DATA_DIR:-}" ]; then
184
- case "$AGENT_INSPECTOR_DATA_DIR" in /*) printf '%s\n' "$AGENT_INSPECTOR_DATA_DIR" ;; *) printf '%s\n' "$base/$AGENT_INSPECTOR_DATA_DIR" ;; esac
185
- elif [ -n "\${AGENT_INSPECTOR_CONFIG_DIR:-}" ]; then
186
- case "$AGENT_INSPECTOR_CONFIG_DIR" in /*) printf '%s\n' "$AGENT_INSPECTOR_CONFIG_DIR" ;; *) printf '%s\n' "$base/$AGENT_INSPECTOR_CONFIG_DIR" ;; esac
187
- else
188
- printf '%s\n' "$base/.agent-inspector"
189
- fi
190
- }
191
- DATA_DIR="$(agent_inspector_data_dir)"
192
- PROVIDERS="$DATA_DIR/providers.json"
193
- LEGACY_CONFIG="$DATA_DIR/config.json"
194
- if [ -f "$PROVIDERS" ] || [ -f "$LEGACY_CONFIG" ]; then
195
- if grep -qE '"apiKey"[[:space:]]*:[[:space:]]*"sk-[^"]+"' "$PROVIDERS" "$LEGACY_CONFIG" 2>/dev/null; then
196
- echo "CONFIG: has key (no REPLACE placeholder)"
197
- elif grep -qE '"apiKey"[[:space:]]*:[[:space:]]*"REPLACE' "$PROVIDERS" "$LEGACY_CONFIG" 2>/dev/null; then
198
- echo "CONFIG: missing or has placeholder key"
199
- else
200
- echo "CONFIG: missing or has placeholder key"
201
- fi
202
- else
203
- echo "CONFIG: file does not exist"
204
- fi
205
-
206
- # 3. Is the MCP server already wired? (project .mcp.json wins)
207
- PROJ_MCP=".mcp.json"
208
- HOME_MCP="$HOME/.claude.json"
209
- if [ -f "$PROJ_MCP" ] && grep -q '"${mcpName}"' "$PROJ_MCP"; then
210
- echo "MCP: wired in $PROJ_MCP"
211
- elif [ -f "$HOME_MCP" ] && grep -q '"${mcpName}"' "$HOME_MCP"; then
212
- echo "MCP: wired in $HOME_MCP"
213
- else
214
- echo "MCP: not wired"
215
- fi
216
- \`\`\`
217
-
218
- \`\`\`powershell
219
- # Windows PowerShell — single-quoted so $env: expands correctly
220
- $port = ${port}
221
- function Resolve-AgentInspectorDataDir {
222
- $base = $env:USERPROFILE
223
- if (-not $base) { $base = $env:APPDATA }
224
- if (-not $base) { $base = 'C:\\' }
225
- if ($env:AGENT_INSPECTOR_DATA_DIR) {
226
- if ([System.IO.Path]::IsPathRooted($env:AGENT_INSPECTOR_DATA_DIR)) { return $env:AGENT_INSPECTOR_DATA_DIR }
227
- return (Join-Path $base $env:AGENT_INSPECTOR_DATA_DIR)
228
- }
229
- if ($env:AGENT_INSPECTOR_CONFIG_DIR) {
230
- if ([System.IO.Path]::IsPathRooted($env:AGENT_INSPECTOR_CONFIG_DIR)) { return $env:AGENT_INSPECTOR_CONFIG_DIR }
231
- return (Join-Path $base $env:AGENT_INSPECTOR_CONFIG_DIR)
232
- }
233
- return (Join-Path $base '.agent-inspector')
234
- }
235
- $dataDir = Resolve-AgentInspectorDataDir
236
- $providers = Join-Path $dataDir 'providers.json'
237
- $legacyConfig = Join-Path $dataDir 'config.json'
238
-
239
- # 1. Is the backend already up?
240
- try {
241
- $null = Invoke-RestMethod -Uri "${healthUrl}" -TimeoutSec 2 -ErrorAction Stop
242
- Write-Host 'BACKEND: up'
243
- } catch {
244
- Write-Host 'BACKEND: down'
245
- }
246
-
247
- # 2. Does the config have a real provider key?
248
- if ((Test-Path $providers) -or (Test-Path $legacyConfig)) {
249
- $content = ''
250
- if (Test-Path $providers) { $content += Get-Content $providers -Raw }
251
- if (Test-Path $legacyConfig) { $content += Get-Content $legacyConfig -Raw }
252
- if ($content -match '"apiKey"[[:space:]]*:[[:space:]]*"(sk-[^"]+)"') {
253
- Write-Host 'CONFIG: has key'
254
- } elseif ($content -match 'REPLACE') {
255
- Write-Host 'CONFIG: has placeholder key'
256
- } else {
257
- Write-Host 'CONFIG: missing key'
258
- }
259
- } else {
260
- Write-Host 'CONFIG: file does not exist'
261
- }
262
-
263
- # 3. Is the MCP server already wired? (project .mcp.json wins)
264
- $projMcp = Join-Path (Get-Location) '.mcp.json'
265
- $homeMcp = Join-Path $env:USERPROFILE '.claude.json'
266
- if ((Test-Path $projMcp) -and (Select-String -Path $projMcp -SimpleMatch '${mcpName}' -Quiet)) {
267
- Write-Host "MCP: wired in $projMcp"
268
- } elseif ((Test-Path $homeMcp) -and (Select-String -Path $homeMcp -SimpleMatch '${mcpName}' -Quiet)) {
269
- Write-Host "MCP: wired in $homeMcp"
270
- } else {
271
- Write-Host 'MCP: not wired'
272
- }
273
- \`\`\`
274
-
275
- **DO:** Summarize the three checks in one line, then use \`AskUserQuestion\` to ask whether to skip the corresponding phases.
276
-
277
- > **PAUSE** — call \`AskUserQuestion\` with:
278
- > - header: \`Skip done\`
279
- > - question: \`Proxy/CONFIG/MCP state: <summary>. Skip the phases that are already done?\`
280
- > - options: \`["Yes, skip what's done", "No, walk me through everything again"]\`
281
- > Wait for the answer before moving to Preflight.
282
-
283
- ---
284
-
285
- ## Preflight
286
-
287
- **EXPLAIN:** "Quick env sanity check — make sure Node and Claude Code are present."
288
-
289
- **DO:** Run the platform-appropriate commands below.
290
-
291
- \`\`\`bash
292
- # Unix / macOS / WSL
293
- node --version # expect >= 18
294
- node -e "const fs=require('node:fs'),p=require('node:path');const names=process.platform==='win32'?['claude.cmd','claude.exe','claude']:['claude'];const found=(process.env.PATH||'').split(p.delimiter).some(d=>names.some(n=>fs.existsSync(p.join(d,n))));console.log(found?'claude-code: present':'claude-code: not detected')"
295
- \`\`\`
296
-
297
- \`\`\`powershell
298
- # Windows PowerShell — single-quoted so $env: expands correctly
299
- node --version # expect >= 18
300
- node -e "const fs=require('node:fs'),p=require('node:path');const names=process.platform==='win32'?['claude.cmd','claude.exe','claude']:['claude'];const found=(process.env.PATH||'').split(p.delimiter).some(d=>names.some(n=>fs.existsSync(p.join(d,n))));console.log(found?'claude-code: present':'claude-code: not detected')"
301
- \`\`\`
302
-
303
- > **PAUSE** — if Node is older than 18, ask the user to install a newer version (https://nodejs.org) before continuing. Use \`AskUserQuestion\` with header \`Node version\`.
304
-
305
- ---
306
-
307
- ## Phase 1: Welcome
308
-
309
- **EXPLAIN:**
310
-
311
- \`\`\`
312
- ## Welcome to Agent Inspector!
313
-
314
- Agent Inspector is an agent observability and knowledge-capture platform for AI coding tools. Its backend owns the transparent model proxy, REST/SSE APIs, capture storage, and MCP server. The default CLI composes a Web UI at the same public Base URL, while \`--backend-only\` keeps every Coding Agent surface available without serving UI files.
315
-
316
- Agent Inspector starts in **Simple mode** by default. Simple mode is the right habit for everyday use: it keeps requests, responses, tools, timing, and token usage while avoiding heavier raw headers, raw response, and detailed SSE chunk artifacts. Use **Full mode** only when the user is debugging provider headers, raw response payloads, or SSE stream details.
317
-
318
- **What we'll do in the next ~10 minutes:**
319
- 1. Add your first LLM provider (Anthropic or OpenAI key)
320
- 2. Start the proxy in Simple mode
321
- 3. Wire your AI tool to use it
322
- 4. Capture a first request end-to-end
323
- 5. Tour the key UI affordances
324
-
325
- Ready? Let's start with the provider.
326
- \`\`\`
327
-
328
- > **PAUSE** — use \`AskUserQuestion\` with header \`Ready?\` and options \`["Yes, let's go", "Wait, I have a question"]\`. Wait for the user before continuing.
329
-
330
- ---
331
-
332
- ## Phase 2: Provider setup
333
-
334
- **DO:** ${providerScopeGuidance}
335
-
336
- **EXPLAIN:** "A 'provider' is an upstream LLM endpoint — Anthropic, OpenAI, MiniMax, etc. agent-inspector routes each request to the right upstream based on the model name. You need at least one provider configured for the proxy to forward traffic."
337
-
338
- **DO:** First, re-check whether \`<dataDir>/providers.json\` already has a real key (Phase 0 may have raced with a manual edit). Use the same data-dir resolution and \`grep -qE '"apiKey":"sk-'\` (bash) or \`Select-String\` (PowerShell) check from Phase 0. If a real key is present, skip the rest of this phase.
339
-
340
- **DO:** If no real key, ask the user for the provider type and API key via \`AskUserQuestion\`. The question should be a free-form text field (no fixed options) — the API key is a secret, so don't echo it back in the question UI.
341
-
342
- \`\`\`bash
343
- # After collecting the key, write the config
344
- agent_inspector_data_dir() {
345
- base="\${HOME:-/tmp}"
346
- if [ -n "\${AGENT_INSPECTOR_DATA_DIR:-}" ]; then
347
- case "$AGENT_INSPECTOR_DATA_DIR" in /*) printf '%s\n' "$AGENT_INSPECTOR_DATA_DIR" ;; *) printf '%s\n' "$base/$AGENT_INSPECTOR_DATA_DIR" ;; esac
348
- elif [ -n "\${AGENT_INSPECTOR_CONFIG_DIR:-}" ]; then
349
- case "$AGENT_INSPECTOR_CONFIG_DIR" in /*) printf '%s\n' "$AGENT_INSPECTOR_CONFIG_DIR" ;; *) printf '%s\n' "$base/$AGENT_INSPECTOR_CONFIG_DIR" ;; esac
350
- else
351
- printf '%s\n' "$base/.agent-inspector"
352
- fi
353
- }
354
- DATA_DIR="$(agent_inspector_data_dir)"
355
- mkdir -p "$DATA_DIR"
356
- PROVIDERS="$DATA_DIR/providers.json"
357
- NOW="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
358
- cat > "$PROVIDERS" <<JSON
359
- {
360
- "providers": [
361
- {
362
- "id": "onboard-anthropic",
363
- "name": "Anthropic",
364
- "apiKey": "REPLACE_ME_BEFORE_WRITING",
365
- "models": ["claude-sonnet-4-5-20250929"],
366
- "format": "anthropic",
367
- "anthropicBaseUrl": "https://api.anthropic.com",
368
- "openaiBaseUrl": "",
369
- "authHeader": "bearer",
370
- "createdAt": "$NOW",
371
- "updatedAt": "$NOW"
372
- }
373
- ]
374
- }
375
- JSON
376
- # Then patch the apiKey with the user-provided value (use jq if available)
377
- \`\`\`
378
-
379
- \`\`\`powershell
380
- # Windows PowerShell — single-quoted so $env: expands correctly
381
- function Resolve-AgentInspectorDataDir {
382
- $base = $env:USERPROFILE
383
- if (-not $base) { $base = $env:APPDATA }
384
- if (-not $base) { $base = 'C:\\' }
385
- if ($env:AGENT_INSPECTOR_DATA_DIR) {
386
- if ([System.IO.Path]::IsPathRooted($env:AGENT_INSPECTOR_DATA_DIR)) { return $env:AGENT_INSPECTOR_DATA_DIR }
387
- return (Join-Path $base $env:AGENT_INSPECTOR_DATA_DIR)
388
- }
389
- if ($env:AGENT_INSPECTOR_CONFIG_DIR) {
390
- if ([System.IO.Path]::IsPathRooted($env:AGENT_INSPECTOR_CONFIG_DIR)) { return $env:AGENT_INSPECTOR_CONFIG_DIR }
391
- return (Join-Path $base $env:AGENT_INSPECTOR_CONFIG_DIR)
392
- }
393
- return (Join-Path $base '.agent-inspector')
394
- }
395
- $dir = Resolve-AgentInspectorDataDir
396
- $file = Join-Path $dir 'providers.json'
397
- New-Item -ItemType Directory -Force -Path $dir | Out-Null
398
- $now = (Get-Date).ToUniversalTime().ToString('o')
399
- $json = @{
400
- providers = @(
401
- @{
402
- id = 'onboard-anthropic'
403
- name = 'Anthropic'
404
- apiKey = 'REPLACE_ME_BEFORE_WRITING'
405
- models = @('claude-sonnet-4-5-20250929')
406
- format = 'anthropic'
407
- anthropicBaseUrl = 'https://api.anthropic.com'
408
- openaiBaseUrl = ''
409
- authHeader = 'bearer'
410
- createdAt = $now
411
- updatedAt = $now
412
- }
413
- )
414
- } | ConvertTo-Json -Depth 5
415
- $json | Set-Content -Path $file -Encoding UTF8
416
- # Then patch the apiKey with the user-provided value
417
- \`\`\`
418
-
419
- **DO:** Patch the placeholder with the actual key using \`jq\` (preferred) or a simple \`sed\`. Then read the file back to confirm the key is no longer \`REPLACE_ME_BEFORE_WRITING\`.
420
-
421
- **DO:** If the user declines to provide a key in the AskUserQuestion (selects "Skip for now"), do **not** write a placeholder config. Tell the user that Phase 5 (First capture) will be skipped, and that they can re-run the skill after adding a key.
422
-
423
- > **PAUSE** — use \`AskUserQuestion\` with header \`Provider key\` and options \`["Key is in, continue", "Skip for now, I'll add it later"]\`. Wait for the answer.
424
-
425
- ---
426
-
427
- ## Phase 3: Start proxy
428
-
429
- **EXPLAIN:** "${startExplanation}"
430
-
431
- **DO:** Skip this phase entirely if the Phase 0 health check already reported \`BACKEND: up\` and the user opted to skip done phases.
432
-
433
- **DO:** Otherwise, use the selected target command below. An explicit wrapper Base URL is connection-only and must not cause a replacement local runtime to start.
434
-
435
- \`\`\`bash
436
- ${bashStartSnippet}
437
- \`\`\`
438
-
439
- \`\`\`powershell
440
- # Windows PowerShell
441
- ${powershellStartSnippet}
442
- \`\`\`
443
-
444
- Then wait for the selected backend health URL to be ready:
445
-
446
- \`\`\`bash
447
- for i in $(seq 1 20); do
448
- curl -fsS "${healthUrl}" >/dev/null 2>&1 && echo "ready" && break
449
- sleep 0.5
450
- done
451
- \`\`\`
452
-
453
- **DO:** Hit the health endpoint to confirm the backend is alive:
454
-
455
- \`\`\`bash
456
- curl -sS "${healthUrl}"
457
- \`\`\`
458
-
459
- **DO:** Read the token-free runtime discovery document. Report \`deploymentMode\` and capabilities; do not treat \`backend-only\` as a failure or infer that a UI is present.
460
-
461
- \`\`\`bash
462
- curl -sS "${runtimeUrl}"
463
- \`\`\`
464
-
465
- **DO:** Read \`/api/config\` and tell the user which capture mode is active. If deeper capture is required, offer \`${fullModeCommand}\`.
466
-
467
- \`\`\`bash
468
- curl -sS "${configUrl}" | grep -o '"captureMode":"[^"]*"'
469
- \`\`\`
470
-
471
- > **PAUSE** — if the health check fails, show the user the log file (\`/tmp/agent-inspector.log\` or \`%TEMP%\\agent-inspector.log\`) and diagnose. Common issues: another process on the port, firewall, missing providers. Use \`AskUserQuestion\` with header \`Proxy up?\` and options \`["Yes, proxy is up", "No, I see an error in the log"]\`. Wait for the answer.
472
-
473
- ---
474
-
475
- ## Phase 4: Wire tool
476
-
477
- **EXPLAIN:** "Now we tell your AI tool to send traffic through the proxy instead of directly to the upstream API. The exact env var depends on which tool you have."
478
-
479
- **DO:** Based on the \`Environment detected\` block at the top of this skill, print the matching wiring command. Examples for each supported tool:
480
-
481
- \`\`\`bash
482
- # Claude Code
483
- export ANTHROPIC_BASE_URL=${anthropicProxyUrl}
484
- claude
485
-
486
- # OpenCode
487
- export LLM_BASE_URL=${openAiProxyUrl}
488
- opencode
489
-
490
- # MiMo Code
491
- export OPENAI_BASE_URL=${openAiProxyUrl}
492
- mimo
493
-
494
- # Cursor / Cody — set the OpenAI base URL in each tool's settings panel to ${openAiProxyUrl}
495
- \`\`\`
496
-
497
- **Container/network note:** If the AI tool runs in a different container, VM, WSL distro, or host
498
- than Agent Inspector, \`localhost\` points at the tool's own environment. Replace \`localhost\` with
499
- an Inspector address reachable from that environment, then verify the network/firewall path before
500
- debugging provider credentials.
501
-
502
- For a tool that wasn't auto-detected, fall through to the generic curl test in the next phase — the user can wire their tool later.
503
-
504
- > **PAUSE** — use \`AskUserQuestion\` with header \`Tool wired?\` and options \`["Yes, env var is set, claude is running", "No, I'm going to use the curl test instead"]\`. Wait for the answer.
505
-
506
- ---
507
-
508
- ## Phase 4.5: Wire MCP server
509
-
510
- **EXPLAIN:** "The proxy also exposes an MCP server at \`${mcpUrl}\`. Your AI agent can query logs, replay requests, and test providers through it — no need to leave the editor."
511
-
512
- **DO:** Skip this phase if Phase 0 reported \`MCP: wired in <path>\` and the user opted to skip done phases.
513
-
514
- **DO:** Otherwise, check the project-level \`.mcp.json\` first (preferred — modern Claude Code convention), then fall back to \`~/.claude.json\`. Use the \`Read\` tool to inspect; do **not** \`cat\` a 40 KB file into the conversation.
515
-
516
- If neither has a \`${mcpName}\` entry, add one. The simplest path is to write to project \`.mcp.json\` (create it if missing):
517
-
518
- \`\`\`json
519
- // .mcp.json (project root)
520
- {
521
- "mcpServers": {
522
- "${mcpName}": {
523
- "type": "http",
524
- "url": "${mcpUrl}"
525
- }
526
- }
527
- }
528
- \`\`\`
529
-
530
- If \`mcpServers\` already exists in \`.mcp.json\`, merge only the \`${mcpName}\` key into it via the \`Edit\` tool — do not overwrite other entries. If you can't create a project \`.mcp.json\` (no project root, permission, etc.), fall back to merging into \`~/.claude.json\` using the same \`Read\`/\`Edit\` pattern.
531
-
532
- **DO:** Verify the handshake. The MCP \`initialize\` request should return 200 with a \`serverInfo\` payload — that proves the server is mounted and reachable:
533
-
534
- \`\`\`bash
535
- curl -sS -X POST "${mcpUrl}" \\
536
- -H "Content-Type: application/json" \\
537
- -H "Accept: application/json, text/event-stream" \\
538
- -d '{
539
- "jsonrpc": "2.0",
540
- "id": 1,
541
- "method": "initialize",
542
- "params": {
543
- "protocolVersion": "2025-03-26",
544
- "capabilities": {},
545
- "clientInfo": { "name": "onboard-check", "version": "0" }
546
- }
547
- }' | grep -o '"name":"agent-inspector"' && echo "handshake OK"
548
- \`\`\`
549
-
550
- The \`grep -o '"name":"agent-inspector"'\` extracts only the serverInfo name — do not dump the full response. If the server returns session IDs, store the \`mcp-session-id\` header from the first response and use it for the follow-up \`tools/list\` call.
551
-
552
- > **PAUSE** — use \`AskUserQuestion\` with header \`MCP OK?\` and options \`["Yes, handshake returned 200", "No, the call failed"]\`. Wait for the answer.
553
-
554
- ---
555
-
556
- ## Phase 5: First capture
557
-
558
- **EXPLAIN:** "Let's prove the proxy works end-to-end. We'll send one real request through it and confirm the log shows up in the API."
559
-
560
- **DO:** First, re-check the config. If the \`apiKey\` is still a \`REPLACE_ME_BEFORE_WRITING\` placeholder (user opted out in Phase 2), **skip the capture test** and tell the user to fill in their key and re-run the skill. A 401 from the upstream is fine if they did provide a real key — the proxy will still log the request.
561
-
562
- Fire a minimal Anthropic-format request through the proxy:
563
-
564
- \`\`\`bash
565
- curl -sS -X POST "${anthropicProxyUrl}/v1/messages" \\
566
- -H "Content-Type: application/json" \\
567
- -H "anthropic-version: 2023-06-01" \\
568
- -H "x-api-key: \${AGENT_INSPECTOR_API_KEY:-sk-no-key-needed-for-routing}" \\
569
- -d '{"model":"claude-3-5-sonnet-20241022","max_tokens":1,"messages":[{"role":"user","content":"ping"}]}' \\
570
- -o /tmp/agent-inspector-capture.json -w 'STATUS:%{http_code}\\n'
571
- \`\`\`
572
-
573
- **DO:** Poll the logs API for up to 5 seconds. A 200 with at least one entry means the request reached the proxy:
574
-
575
- \`\`\`bash
576
- for i in $(seq 1 10); do
577
- resp=$(curl -sS "${logsUrl}?limit=1")
578
- count=$(echo "$resp" | grep -o '"total":[0-9]*' | head -1 | grep -o '[0-9]*$')
579
- if [ "\${count:-0}" -ge 1 ]; then
580
- echo "captured"
581
- echo "$resp" | head -c 400
582
- break
583
- fi
584
- sleep 0.5
585
- done
586
- \`\`\`
587
-
588
- **DO:** Diagnose the response based on the actual status and body. **Do not** default to "auth failure" for every 4xx.
589
-
590
- | Status | Body hint | Meaning |
591
- |--------|-----------|---------|
592
- | 200 | normal | Real success — the upstream returned data |
593
- | 401 | \`"unauthorized"\` or similar | Upstream rejected the key (expected with a test key) |
594
- | 403 | \`"Request not allowed"\` | **Proxy's allowlist** — not an auth failure, the proxy rejected the model/config. Show the user the proxy log. |
595
- | 403 | other text | Could be upstream ACL — different problem |
596
- | 5xx | anything | Upstream network error |
597
-
598
- > **PAUSE** — use \`AskUserQuestion\` with header \`Captured?\` and options matching the diagnosis above. Wait for the answer.
599
-
600
- ---
601
-
602
- ## Phase 6: Tour & wrap
603
-
604
- **EXPLAIN:** "Everything's working. Here's the cheat sheet for the backend surfaces and the optional Web UI:"
605
-
606
- - **Runtime discovery**: \`${runtimeUrl}\` — token-free deployment mode, UI Base Path, control/agent Base URLs, and capabilities.
607
- - **Web UI**: ${uiTour}.
608
- - **MCP server**: \`${mcpUrl}\` — connect from the coding agent to query logs, replay, and test providers; it does not require a Web UI process.
609
- - **REST API**: \`/api/logs\`, \`/api/sessions\`, \`/api/providers\` — for scripting and shell-based inspection.
610
- - **Stop the proxy**:
611
-
612
- \`\`\`bash
613
- ${stopSnippet}
614
- \`\`\`
615
-
616
- - **Re-run onboard**: \`${refreshCommand}\` refreshes this skill.
617
- - **Check onboard files**: \`${statusCommand}\` shows whether generated skills are
618
- current, outdated, missing, newer, or custom.
619
- - **Full docs**: see the project README; do not depend on a UI footer being available.
620
-
621
- > **PAUSE** — use \`AskUserQuestion\` with header \`All set?\` and options \`["All set, I'm done", "Wait, I want to revisit a phase"]\`. Wait for the answer.
622
-
623
- You're done. Happy inspecting.
624
- `;
625
- }