@tonyclaw/agent-inspector 3.0.44 → 3.0.46

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 (347) hide show
  1. package/.output/{nitro.json → backend/nitro.json} +3 -3
  2. package/.output/backend-public/assets/index-D4LX-sw-.js +11 -0
  3. package/.output/cli.js +22707 -17099
  4. package/.output/server/_libs/extend.mjs +4 -8
  5. package/.output/server/_libs/jszip.mjs +9 -35
  6. package/.output/server/_libs/modelcontextprotocol__core.mjs +25 -25
  7. package/.output/server/_libs/modelcontextprotocol__server.mjs +2 -2
  8. package/.output/server/_libs/react-dom.mjs +2 -3
  9. package/.output/server/_libs/react.mjs +1 -27
  10. package/.output/server/_libs/tanstack__react-router.mjs +1 -329
  11. package/.output/server/_libs/tanstack__router-core.mjs +42 -100
  12. package/.output/server/_libs/use-sync-external-store.mjs +1 -64
  13. package/.output/server/_libs/ws.mjs +1 -1
  14. package/.output/server/_libs/zod.mjs +6 -6
  15. package/.output/server/_ssr/index.mjs +5 -4
  16. package/.output/server/_ssr/publicBasePathContext-IH2ilOfu.mjs +176 -0
  17. package/.output/server/_ssr/{router-DWcUFPR3.mjs → router-D18yUq36.mjs} +7877 -5597
  18. package/.output/server/_ssr/start-COQu_AgD.mjs +57 -0
  19. package/.output/server/_tanstack-start-manifest_v-DnbdNeun.mjs +4 -0
  20. package/.output/server/index.mjs +5 -145
  21. package/.output/{public/assets/CompareDrawer-DQHjxFO6.js → ui/assets/CompareDrawer-DAUuIJ6G.js} +1 -1
  22. package/.output/{public/assets/InspectorPet-D1A4505B.js → ui/assets/InspectorPet-BRBVjOWI.js} +1 -1
  23. package/.output/ui/assets/ProxyViewerContainer-D7Sq0ctc.js +59 -0
  24. package/.output/{public/assets/ReplayDialog-C5vmbecv.js → ui/assets/ReplayDialog-nDLsjOhs.js} +1 -1
  25. package/.output/{public/assets/RequestAnatomy-CPGNB8lk.js → ui/assets/RequestAnatomy-zd4BDgL0.js} +1 -1
  26. package/.output/ui/assets/ResponseView-AdIXGcSn.js +2 -0
  27. package/.output/ui/assets/StreamingChunkSequence-CesTz8He.js +1 -0
  28. package/.output/{public/assets/_sessionId-CDhRgzf6.js → ui/assets/_sessionId-BAfzrhSU.js} +1 -1
  29. package/.output/{public/assets/_sessionId-mw3aA8Bp.js → ui/assets/_sessionId-QnBomgPD.js} +1 -1
  30. package/.output/ui/assets/favicon-DYEkHSNl.svg +21 -0
  31. package/.output/{public/assets/index-B2eoeT-Z.js → ui/assets/index-BcsdxBAd.js} +1 -1
  32. package/.output/ui/assets/index-BvXp42al.css +1 -0
  33. package/.output/{public/assets/index-CX7_rf7o.js → ui/assets/index-D0rtCN9V.js} +1 -1
  34. package/.output/ui/assets/index-DHpwr08Z.js +73 -0
  35. package/.output/{public/assets/index-BfRhTvOd.js → ui/assets/index-dNuk2dsU.js} +1 -1
  36. package/.output/ui/assets/json-viewer-BvFHglMb.js +1 -0
  37. package/.output/{public/assets/jszip.min-C9rCFoU3.js → ui/assets/jszip.min-B5Z7gNZB.js} +1 -1
  38. package/.output/ui/index.html +229 -0
  39. package/.output/ui/runtime-config.js +2 -0
  40. package/.output/workers/logFinalizer.worker.js +983 -414
  41. package/.output/workers/sessionWorkerEntry.js +983 -414
  42. package/README.md +363 -35
  43. package/docs/instance-control.openapi.yaml +361 -0
  44. package/package.json +28 -5
  45. package/scripts/generate-theme-scales.mjs +3 -3
  46. package/src/{router.tsx → backend/router.tsx} +3 -15
  47. package/src/backend/routes/$.ts +26 -0
  48. package/src/backend/routes/__root.ts +4 -0
  49. package/src/backend/routes/api/-instances.ts +109 -0
  50. package/src/{routes → backend/routes}/api/alerts.summary.ts +3 -3
  51. package/src/{routes → backend/routes}/api/alerts.ts +4 -4
  52. package/src/{routes → backend/routes}/api/config.paths.ts +1 -1
  53. package/src/{routes → backend/routes}/api/config.ts +11 -2
  54. package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.help.ts +1 -1
  55. package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.install.ts +1 -1
  56. package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.runner-presets.ts +1 -1
  57. package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.upgrade.ts +1 -1
  58. package/src/{routes → backend/routes}/api/ecosystem.packages.ts +5 -1
  59. package/src/{routes → backend/routes}/api/ecosystem.recipes.$recipeId.run.ts +1 -1
  60. package/src/{routes → backend/routes}/api/ecosystem.tasks.$taskId.ts +1 -1
  61. package/src/{routes → backend/routes}/api/ecosystem.tasks.ts +1 -1
  62. package/src/{routes → backend/routes}/api/groups.$groupId.evidence.ts +2 -2
  63. package/src/{routes → backend/routes}/api/groups.$groupId.sessions.ts +2 -2
  64. package/src/{routes → backend/routes}/api/groups.$groupId.ts +2 -2
  65. package/src/{routes → backend/routes}/api/groups.ts +2 -2
  66. package/src/{routes → backend/routes}/api/health.ts +3 -3
  67. package/src/backend/routes/api/instances.$name.connection.ts +12 -0
  68. package/src/backend/routes/api/instances.$name.restart.ts +23 -0
  69. package/src/backend/routes/api/instances.$name.start.ts +18 -0
  70. package/src/backend/routes/api/instances.$name.stop.ts +23 -0
  71. package/src/backend/routes/api/instances.$name.ts +12 -0
  72. package/src/backend/routes/api/instances.ts +16 -0
  73. package/src/{routes → backend/routes}/api/knowledge.candidates.$candidateId.promote.ts +2 -2
  74. package/src/{routes → backend/routes}/api/knowledge.candidates.$candidateId.ts +2 -2
  75. package/src/{routes → backend/routes}/api/knowledge.candidates.ts +1 -1
  76. package/src/{routes → backend/routes}/api/knowledge.project-context.ts +2 -2
  77. package/src/{routes → backend/routes}/api/knowledge.search.ts +2 -2
  78. package/src/{routes → backend/routes}/api/knowledge.sessions.$sessionId.candidates.ts +3 -3
  79. package/src/{routes → backend/routes}/api/logs.$id.body.ts +6 -6
  80. package/src/{routes → backend/routes}/api/logs.$id.chunks.ts +5 -4
  81. package/src/{routes → backend/routes}/api/logs.$id.replay.ts +12 -11
  82. package/src/{routes → backend/routes}/api/logs.$id.ts +4 -3
  83. package/src/{routes → backend/routes}/api/logs.import.ts +3 -3
  84. package/src/{routes → backend/routes}/api/logs.stream.ts +11 -7
  85. package/src/{routes → backend/routes}/api/logs.ts +17 -9
  86. package/src/{routes → backend/routes}/api/mcp.ts +1 -1
  87. package/src/{routes → backend/routes}/api/models.ts +1 -1
  88. package/src/{routes → backend/routes}/api/pi-agent.ts +2 -2
  89. package/src/{routes → backend/routes}/api/providers.$providerId.model-metadata.ts +5 -5
  90. package/src/{routes → backend/routes}/api/providers.$providerId.test.log.ts +7 -7
  91. package/src/{routes → backend/routes}/api/providers.$providerId.ts +4 -4
  92. package/src/{routes → backend/routes}/api/providers.export.ts +1 -1
  93. package/src/{routes → backend/routes}/api/providers.import.ts +3 -3
  94. package/src/{routes → backend/routes}/api/providers.scan.ts +2 -2
  95. package/src/{routes → backend/routes}/api/providers.ts +9 -4
  96. package/src/{routes → backend/routes}/api/runs.$runId.evidence.ts +2 -2
  97. package/src/{routes → backend/routes}/api/runs.$runId.ts +2 -2
  98. package/src/{routes → backend/routes}/api/runs.ts +4 -4
  99. package/src/backend/routes/api/runtime.ts +46 -0
  100. package/src/{routes → backend/routes}/api/sessions.ts +3 -3
  101. package/src/{routes → backend/routes}/proxy/$.ts +1 -1
  102. package/src/{routes → backend/routes}/readyz.ts +1 -1
  103. package/src/backend/start.ts +10 -0
  104. package/src/cli/alias.ts +431 -0
  105. package/src/cli/doctor.ts +32 -9
  106. package/src/cli/instance.ts +1050 -0
  107. package/src/cli/instanceArgs.ts +285 -0
  108. package/src/cli/instanceControl.ts +181 -0
  109. package/src/cli/instanceModel.ts +267 -0
  110. package/src/cli/instanceRegistry.ts +731 -0
  111. package/src/cli/networkHints.ts +27 -14
  112. package/src/cli/onboard.ts +190 -35
  113. package/src/cli/onboardTarget.ts +228 -0
  114. package/src/cli/templates/codex-skill-onboard.ts +109 -31
  115. package/src/cli/templates/skill-onboard.ts +140 -70
  116. package/src/cli.ts +338 -77
  117. package/src/components/ProxyViewer.tsx +20 -10
  118. package/src/components/ProxyViewerContainer.tsx +12 -11
  119. package/src/components/pi-agent/PiAgentPanel.tsx +2 -2
  120. package/src/components/providers/ProviderCard.tsx +1 -1
  121. package/src/components/providers/ProviderTestResultsView.tsx +1 -1
  122. package/src/components/providers/SettingsDialog.tsx +160 -140
  123. package/src/components/proxy-viewer/ApplicationBar.tsx +2 -1
  124. package/src/components/proxy-viewer/LogEntry.tsx +1 -1
  125. package/src/components/proxy-viewer/log-formats/index.ts +1 -1
  126. package/src/contracts/index.ts +5 -0
  127. package/src/contracts/log.ts +33 -3
  128. package/src/knowledge/types.ts +3 -2
  129. package/src/lib/alertContract.ts +2 -2
  130. package/src/lib/apiClient.ts +30 -7
  131. package/src/lib/apiFormat.ts +29 -0
  132. package/src/lib/basePath.ts +31 -7
  133. package/src/lib/browserRuntimeContract.ts +124 -0
  134. package/src/lib/browserRuntimeResolver.ts +244 -0
  135. package/src/{proxy → lib}/claudeCodeStrip.ts +6 -7
  136. package/src/lib/codingAgentEndpoints.ts +54 -0
  137. package/src/lib/instanceContract.ts +236 -0
  138. package/src/lib/managedInstance.ts +104 -0
  139. package/src/lib/piAgentContract.ts +3 -2
  140. package/src/lib/publicBasePathContext.ts +137 -0
  141. package/src/lib/resourceLimits.ts +2 -0
  142. package/src/lib/runContract.ts +3 -3
  143. package/src/lib/sessionInfoContract.ts +3 -2
  144. package/src/mcp/instanceHandlers.ts +150 -0
  145. package/src/mcp/loopback.ts +16 -5
  146. package/src/mcp/mode.ts +25 -0
  147. package/src/mcp/server.ts +274 -39
  148. package/src/mcp/toolHandlers.ts +2 -2
  149. package/src/proxy/config.ts +25 -30
  150. package/src/proxy/dataDir.ts +43 -7
  151. package/src/proxy/ecosystemTasks.ts +161 -70
  152. package/src/proxy/formats/registry.ts +6 -21
  153. package/src/proxy/handler.ts +129 -29
  154. package/src/proxy/identityProxy.ts +1049 -50
  155. package/src/proxy/jsonlRecovery.ts +554 -0
  156. package/src/proxy/logFinalizer.ts +25 -10
  157. package/src/proxy/logImporter.ts +2 -1
  158. package/src/proxy/logIndex.ts +191 -95
  159. package/src/proxy/logger.ts +77 -14
  160. package/src/proxy/platformCommands.ts +41 -0
  161. package/src/proxy/privateDataPath.ts +310 -88
  162. package/src/proxy/rawStreamCapture.ts +194 -13
  163. package/src/proxy/runtimeAdmission.ts +5 -2
  164. package/src/proxy/runtimeHealth.ts +14 -1
  165. package/src/proxy/runtimeShutdown.ts +84 -2
  166. package/src/proxy/schemas.ts +7 -1
  167. package/src/proxy/sessionArchive.ts +78 -14
  168. package/src/proxy/sessionInfo.ts +5 -4
  169. package/src/proxy/sqliteLogIndex.ts +65 -2
  170. package/src/proxy/store.ts +141 -34
  171. package/src/proxy/uiAssetServer.ts +106 -0
  172. package/src/proxy/upstream.ts +29 -2
  173. package/src/ui/bootstrap.ts +167 -0
  174. package/src/ui/index.html +38 -0
  175. package/src/ui/logsStreamClient.ts +20 -0
  176. package/src/ui/main.tsx +13 -0
  177. package/src/ui/public/runtime-config.js +2 -0
  178. package/src/ui/router.tsx +13 -0
  179. package/src/ui/routes/__root.tsx +69 -0
  180. package/src/{routes → ui/routes}/index.tsx +2 -3
  181. package/src/{routes → ui/routes}/session/$sessionId.tsx +5 -11
  182. package/src/ui/runtimeDiscovery.ts +50 -0
  183. package/styles/globals.css +1 -0
  184. package/.output/public/assets/ProxyViewerContainer-BhpIgfBi.js +0 -126
  185. package/.output/public/assets/ResponseView-DUfrajCm.js +0 -2
  186. package/.output/public/assets/StreamingChunkSequence-nbeCQqOz.js +0 -1
  187. package/.output/public/assets/index-BWjeqxbk.css +0 -1
  188. package/.output/public/assets/index-C6qZwYlR.js +0 -70
  189. package/.output/public/assets/json-viewer-BLmF1sOZ.js +0 -1
  190. package/.output/server/_libs/@radix-ui/react-accessible-icon+[...].mjs +0 -1
  191. package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +0 -344
  192. package/.output/server/_libs/@radix-ui/react-navigation-menu+[...].mjs +0 -2
  193. package/.output/server/_libs/@radix-ui/react-one-time-password-field+[...].mjs +0 -2
  194. package/.output/server/_libs/@radix-ui/react-password-toggle-field+[...].mjs +0 -2
  195. package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +0 -11
  196. package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +0 -69
  197. package/.output/server/_libs/@radix-ui/react-use-effect-event+[...].mjs +0 -1
  198. package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +0 -28
  199. package/.output/server/_libs/@radix-ui/react-use-layout-effect+[...].mjs +0 -6
  200. package/.output/server/_libs/@radix-ui/react-visually-hidden+[...].mjs +0 -34
  201. package/.output/server/_libs/aria-hidden.mjs +0 -122
  202. package/.output/server/_libs/bail.mjs +0 -8
  203. package/.output/server/_libs/character-entities.mjs +0 -2130
  204. package/.output/server/_libs/class-variance-authority.mjs +0 -44
  205. package/.output/server/_libs/clsx.mjs +0 -16
  206. package/.output/server/_libs/comma-separated-tokens.mjs +0 -10
  207. package/.output/server/_libs/decode-named-character-reference+[...].mjs +0 -8
  208. package/.output/server/_libs/dequal.mjs +0 -27
  209. package/.output/server/_libs/detect-node-es.mjs +0 -1
  210. package/.output/server/_libs/devlop.mjs +0 -8
  211. package/.output/server/_libs/diff.mjs +0 -320
  212. package/.output/server/_libs/estree-util-is-identifier-name.mjs +0 -11
  213. package/.output/server/_libs/floating-ui__core.mjs +0 -725
  214. package/.output/server/_libs/floating-ui__dom.mjs +0 -622
  215. package/.output/server/_libs/floating-ui__react-dom.mjs +0 -292
  216. package/.output/server/_libs/floating-ui__utils.mjs +0 -320
  217. package/.output/server/_libs/get-nonce.mjs +0 -9
  218. package/.output/server/_libs/hast-util-to-jsx-runtime.mjs +0 -388
  219. package/.output/server/_libs/hast-util-whitespace.mjs +0 -10
  220. package/.output/server/_libs/html-url-attributes.mjs +0 -26
  221. package/.output/server/_libs/inline-style-parser.mjs +0 -142
  222. package/.output/server/_libs/is-plain-obj.mjs +0 -10
  223. package/.output/server/_libs/lucide-react.mjs +0 -1027
  224. package/.output/server/_libs/mdast-util-from-markdown.mjs +0 -717
  225. package/.output/server/_libs/mdast-util-to-hast.mjs +0 -710
  226. package/.output/server/_libs/mdast-util-to-string.mjs +0 -38
  227. package/.output/server/_libs/micromark-core-commonmark.mjs +0 -2259
  228. package/.output/server/_libs/micromark-factory-destination.mjs +0 -94
  229. package/.output/server/_libs/micromark-factory-label.mjs +0 -63
  230. package/.output/server/_libs/micromark-factory-space.mjs +0 -24
  231. package/.output/server/_libs/micromark-factory-title.mjs +0 -65
  232. package/.output/server/_libs/micromark-factory-whitespace.mjs +0 -22
  233. package/.output/server/_libs/micromark-util-character.mjs +0 -44
  234. package/.output/server/_libs/micromark-util-chunked.mjs +0 -36
  235. package/.output/server/_libs/micromark-util-classify-character+[...].mjs +0 -12
  236. package/.output/server/_libs/micromark-util-combine-extensions+[...].mjs +0 -41
  237. package/.output/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +0 -19
  238. package/.output/server/_libs/micromark-util-decode-string.mjs +0 -21
  239. package/.output/server/_libs/micromark-util-encode.mjs +0 -1
  240. package/.output/server/_libs/micromark-util-html-tag-name.mjs +0 -69
  241. package/.output/server/_libs/micromark-util-normalize-identifier+[...].mjs +0 -6
  242. package/.output/server/_libs/micromark-util-resolve-all.mjs +0 -15
  243. package/.output/server/_libs/micromark-util-sanitize-uri.mjs +0 -41
  244. package/.output/server/_libs/micromark-util-subtokenize.mjs +0 -346
  245. package/.output/server/_libs/micromark.mjs +0 -906
  246. package/.output/server/_libs/property-information.mjs +0 -1209
  247. package/.output/server/_libs/radix-ui.mjs +0 -1
  248. package/.output/server/_libs/radix-ui__number.mjs +0 -6
  249. package/.output/server/_libs/radix-ui__primitive.mjs +0 -11
  250. package/.output/server/_libs/radix-ui__react-accordion.mjs +0 -1
  251. package/.output/server/_libs/radix-ui__react-alert-dialog.mjs +0 -1
  252. package/.output/server/_libs/radix-ui__react-arrow.mjs +0 -23
  253. package/.output/server/_libs/radix-ui__react-aspect-ratio.mjs +0 -1
  254. package/.output/server/_libs/radix-ui__react-avatar.mjs +0 -1
  255. package/.output/server/_libs/radix-ui__react-checkbox.mjs +0 -1
  256. package/.output/server/_libs/radix-ui__react-collapsible.mjs +0 -144
  257. package/.output/server/_libs/radix-ui__react-collection.mjs +0 -69
  258. package/.output/server/_libs/radix-ui__react-compose-refs.mjs +0 -38
  259. package/.output/server/_libs/radix-ui__react-context-menu.mjs +0 -1
  260. package/.output/server/_libs/radix-ui__react-context.mjs +0 -64
  261. package/.output/server/_libs/radix-ui__react-dialog.mjs +0 -280
  262. package/.output/server/_libs/radix-ui__react-direction.mjs +0 -9
  263. package/.output/server/_libs/radix-ui__react-dropdown-menu.mjs +0 -1
  264. package/.output/server/_libs/radix-ui__react-focus-guards.mjs +0 -39
  265. package/.output/server/_libs/radix-ui__react-focus-scope.mjs +0 -210
  266. package/.output/server/_libs/radix-ui__react-form.mjs +0 -1
  267. package/.output/server/_libs/radix-ui__react-hover-card.mjs +0 -1
  268. package/.output/server/_libs/radix-ui__react-id.mjs +0 -14
  269. package/.output/server/_libs/radix-ui__react-label.mjs +0 -1
  270. package/.output/server/_libs/radix-ui__react-menu.mjs +0 -1
  271. package/.output/server/_libs/radix-ui__react-menubar.mjs +0 -1
  272. package/.output/server/_libs/radix-ui__react-popover.mjs +0 -1
  273. package/.output/server/_libs/radix-ui__react-popper.mjs +0 -340
  274. package/.output/server/_libs/radix-ui__react-portal.mjs +0 -16
  275. package/.output/server/_libs/radix-ui__react-presence.mjs +0 -173
  276. package/.output/server/_libs/radix-ui__react-primitive.mjs +0 -42
  277. package/.output/server/_libs/radix-ui__react-progress.mjs +0 -1
  278. package/.output/server/_libs/radix-ui__react-radio-group.mjs +0 -1
  279. package/.output/server/_libs/radix-ui__react-roving-focus.mjs +0 -235
  280. package/.output/server/_libs/radix-ui__react-scroll-area.mjs +0 -731
  281. package/.output/server/_libs/radix-ui__react-select.mjs +0 -1207
  282. package/.output/server/_libs/radix-ui__react-separator.mjs +0 -28
  283. package/.output/server/_libs/radix-ui__react-slider.mjs +0 -1
  284. package/.output/server/_libs/radix-ui__react-slot.mjs +0 -132
  285. package/.output/server/_libs/radix-ui__react-switch.mjs +0 -1
  286. package/.output/server/_libs/radix-ui__react-tabs.mjs +0 -194
  287. package/.output/server/_libs/radix-ui__react-toast.mjs +0 -2
  288. package/.output/server/_libs/radix-ui__react-toggle-group.mjs +0 -1
  289. package/.output/server/_libs/radix-ui__react-toggle.mjs +0 -1
  290. package/.output/server/_libs/radix-ui__react-toolbar.mjs +0 -1
  291. package/.output/server/_libs/radix-ui__react-tooltip.mjs +0 -498
  292. package/.output/server/_libs/radix-ui__react-use-previous.mjs +0 -14
  293. package/.output/server/_libs/radix-ui__react-use-size.mjs +0 -39
  294. package/.output/server/_libs/react-markdown.mjs +0 -235
  295. package/.output/server/_libs/react-remove-scroll-bar.mjs +0 -82
  296. package/.output/server/_libs/react-remove-scroll.mjs +0 -328
  297. package/.output/server/_libs/react-style-singleton.mjs +0 -69
  298. package/.output/server/_libs/remark-parse.mjs +0 -19
  299. package/.output/server/_libs/remark-rehype.mjs +0 -21
  300. package/.output/server/_libs/space-separated-tokens.mjs +0 -6
  301. package/.output/server/_libs/style-to-js.mjs +0 -72
  302. package/.output/server/_libs/style-to-object.mjs +0 -38
  303. package/.output/server/_libs/swr.mjs +0 -947
  304. package/.output/server/_libs/tailwind-merge.mjs +0 -3255
  305. package/.output/server/_libs/tanstack__react-virtual.mjs +0 -130
  306. package/.output/server/_libs/tanstack__virtual-core.mjs +0 -1319
  307. package/.output/server/_libs/three.mjs +0 -26016
  308. package/.output/server/_libs/trim-lines.mjs +0 -41
  309. package/.output/server/_libs/trough.mjs +0 -85
  310. package/.output/server/_libs/tslib.mjs +0 -1
  311. package/.output/server/_libs/ungap__structured-clone.mjs +0 -212
  312. package/.output/server/_libs/unified.mjs +0 -661
  313. package/.output/server/_libs/unist-util-is.mjs +0 -100
  314. package/.output/server/_libs/unist-util-position.mjs +0 -27
  315. package/.output/server/_libs/unist-util-stringify-position.mjs +0 -27
  316. package/.output/server/_libs/unist-util-visit-parents.mjs +0 -82
  317. package/.output/server/_libs/unist-util-visit.mjs +0 -24
  318. package/.output/server/_libs/use-callback-ref.mjs +0 -66
  319. package/.output/server/_libs/use-sidecar.mjs +0 -106
  320. package/.output/server/_libs/vfile-message.mjs +0 -138
  321. package/.output/server/_libs/vfile.mjs +0 -467
  322. package/.output/server/_sessionId-E_Dmopc-.mjs +0 -144
  323. package/.output/server/_sessionId-U54BAqdp.mjs +0 -82
  324. package/.output/server/_ssr/CompareDrawer-CksatPed.mjs +0 -1058
  325. package/.output/server/_ssr/InspectorPet-DNc4GQ7z.mjs +0 -936
  326. package/.output/server/_ssr/ProxyViewerContainer-B02Ey0p_.mjs +0 -17607
  327. package/.output/server/_ssr/ReplayDialog-DdMvHJF1.mjs +0 -723
  328. package/.output/server/_ssr/RequestAnatomy--vh2Z8__.mjs +0 -835
  329. package/.output/server/_ssr/ResponseView-Dhxc-cKC.mjs +0 -755
  330. package/.output/server/_ssr/StreamingChunkSequence-BG0EQmaD.mjs +0 -272
  331. package/.output/server/_ssr/index-D0At9nfd.mjs +0 -82
  332. package/.output/server/_ssr/index-lcfulIXa.mjs +0 -133
  333. package/.output/server/_ssr/json-viewer-My1J1_5R.mjs +0 -481
  334. package/.output/server/_ssr/start-HYkvq4Ni.mjs +0 -4
  335. package/.output/server/_tanstack-start-manifest_v-B2chR8ef.mjs +0 -4
  336. package/.output/server/node_modules/tslib/modules/index.js +0 -70
  337. package/.output/server/node_modules/tslib/modules/package.json +0 -3
  338. package/.output/server/node_modules/tslib/package.json +0 -47
  339. package/.output/server/node_modules/tslib/tslib.js +0 -484
  340. package/.output/server/package.json +0 -9
  341. package/src/routes/__root.tsx +0 -170
  342. /package/.output/{public → ui}/assets/agent-inspector-58K1_MsC.ico +0 -0
  343. /package/.output/{public → ui}/assets/alibaba-TTwafVwX.svg +0 -0
  344. /package/.output/{public → ui}/assets/minimax-BPMzvuL-.jpeg +0 -0
  345. /package/.output/{public → ui}/assets/qwen-mMn3f5ul.webp +0 -0
  346. /package/.output/{public → ui}/assets/zhipuai-BPNAnxo-.svg +0 -0
  347. /package/src/{routes → backend/routes}/livez.ts +0 -0
@@ -1,947 +0,0 @@
1
- import { r as reactExports, R as React } from "./react.mjs";
2
- import { s as shimExports } from "./use-sync-external-store.mjs";
3
- import { d as dequal } from "./dequal.mjs";
4
- const FOCUS_EVENT = 0;
5
- const RECONNECT_EVENT = 1;
6
- const MUTATE_EVENT = 2;
7
- const ERROR_REVALIDATE_EVENT = 3;
8
- const SWRGlobalState = /* @__PURE__ */ new WeakMap();
9
- const noop = () => {
10
- };
11
- const UNDEFINED = (
12
- /*#__NOINLINE__*/
13
- noop()
14
- );
15
- const OBJECT = Object;
16
- const isUndefined = (v) => v === UNDEFINED;
17
- const isFunction = (v) => typeof v == "function";
18
- const mergeObjects = (a, b) => ({
19
- ...a,
20
- ...b
21
- });
22
- const isPromiseLike = (x) => isFunction(x.then);
23
- const EMPTY_CACHE = {};
24
- const INITIAL_CACHE = {};
25
- const STR_UNDEFINED = "undefined";
26
- const isWindowDefined = typeof window != STR_UNDEFINED;
27
- const isDocumentDefined = typeof document != STR_UNDEFINED;
28
- const isLegacyDeno = isWindowDefined && "Deno" in window;
29
- const hasRequestAnimationFrame = () => isWindowDefined && typeof window["requestAnimationFrame"] != STR_UNDEFINED;
30
- const createCacheHelper = (cache2, key) => {
31
- const state = SWRGlobalState.get(cache2);
32
- return [
33
- // Getter
34
- () => !isUndefined(key) && cache2.get(key) || EMPTY_CACHE,
35
- // Setter
36
- (info) => {
37
- if (!isUndefined(key)) {
38
- const prev = cache2.get(key);
39
- if (!(key in INITIAL_CACHE)) {
40
- INITIAL_CACHE[key] = prev;
41
- }
42
- state[5](key, mergeObjects(prev, info), prev || EMPTY_CACHE);
43
- }
44
- },
45
- // Subscriber
46
- state[6],
47
- // Get server cache snapshot
48
- () => {
49
- if (!isUndefined(key)) {
50
- if (key in INITIAL_CACHE) return INITIAL_CACHE[key];
51
- }
52
- return !isUndefined(key) && cache2.get(key) || EMPTY_CACHE;
53
- }
54
- ];
55
- };
56
- let online = true;
57
- const isOnline = () => online;
58
- const [onWindowEvent, offWindowEvent] = isWindowDefined && window.addEventListener ? [
59
- window.addEventListener.bind(window),
60
- window.removeEventListener.bind(window)
61
- ] : [
62
- noop,
63
- noop
64
- ];
65
- const isVisible = () => {
66
- const visibilityState = isDocumentDefined && document.visibilityState;
67
- return isUndefined(visibilityState) || visibilityState !== "hidden";
68
- };
69
- const initFocus = (callback) => {
70
- if (isDocumentDefined) {
71
- document.addEventListener("visibilitychange", callback);
72
- }
73
- onWindowEvent("focus", callback);
74
- return () => {
75
- if (isDocumentDefined) {
76
- document.removeEventListener("visibilitychange", callback);
77
- }
78
- offWindowEvent("focus", callback);
79
- };
80
- };
81
- const initReconnect = (callback) => {
82
- const onOnline = () => {
83
- online = true;
84
- callback();
85
- };
86
- const onOffline = () => {
87
- online = false;
88
- };
89
- onWindowEvent("online", onOnline);
90
- onWindowEvent("offline", onOffline);
91
- return () => {
92
- offWindowEvent("online", onOnline);
93
- offWindowEvent("offline", onOffline);
94
- };
95
- };
96
- const preset = {
97
- isOnline,
98
- isVisible
99
- };
100
- const defaultConfigOptions = {
101
- initFocus,
102
- initReconnect
103
- };
104
- const IS_REACT_LEGACY = !React.useId;
105
- const IS_SERVER = !isWindowDefined || isLegacyDeno;
106
- const rAF = (f) => hasRequestAnimationFrame() ? window["requestAnimationFrame"](f) : setTimeout(f, 1);
107
- const useIsomorphicLayoutEffect = IS_SERVER ? reactExports.useEffect : reactExports.useLayoutEffect;
108
- const navigatorConnection = typeof navigator !== "undefined" && navigator.connection;
109
- const slowConnection = !IS_SERVER && navigatorConnection && ([
110
- "slow-2g",
111
- "2g"
112
- ].includes(navigatorConnection.effectiveType) || navigatorConnection.saveData);
113
- const table = /* @__PURE__ */ new WeakMap();
114
- const getTypeName = (value) => OBJECT.prototype.toString.call(value);
115
- const isObjectTypeName = (typeName, type) => typeName === `[object ${type}]`;
116
- let counter = 0;
117
- const stableHash = (arg) => {
118
- const type = typeof arg;
119
- const typeName = getTypeName(arg);
120
- const isDate = isObjectTypeName(typeName, "Date");
121
- const isRegex = isObjectTypeName(typeName, "RegExp");
122
- const isPlainObject = isObjectTypeName(typeName, "Object");
123
- let result;
124
- let index;
125
- if (OBJECT(arg) === arg && !isDate && !isRegex) {
126
- result = table.get(arg);
127
- if (result) return result;
128
- result = ++counter + "~";
129
- table.set(arg, result);
130
- if (Array.isArray(arg)) {
131
- result = "@";
132
- for (index = 0; index < arg.length; index++) {
133
- result += stableHash(arg[index]) + ",";
134
- }
135
- table.set(arg, result);
136
- }
137
- if (isPlainObject) {
138
- result = "#";
139
- const keys = OBJECT.keys(arg).sort();
140
- while (!isUndefined(index = keys.pop())) {
141
- if (!isUndefined(arg[index])) {
142
- result += index + ":" + stableHash(arg[index]) + ",";
143
- }
144
- }
145
- table.set(arg, result);
146
- }
147
- } else {
148
- result = isDate ? arg.toJSON() : type == "symbol" ? arg.toString() : type == "string" ? JSON.stringify(arg) : "" + arg;
149
- }
150
- return result;
151
- };
152
- const serialize = (key) => {
153
- if (isFunction(key)) {
154
- try {
155
- key = key();
156
- } catch (err) {
157
- key = "";
158
- }
159
- }
160
- const args = key;
161
- key = typeof key == "string" ? key : (Array.isArray(key) ? key.length : key) ? stableHash(key) : "";
162
- return [
163
- key,
164
- args
165
- ];
166
- };
167
- let __timestamp = 0;
168
- const getTimestamp = () => ++__timestamp;
169
- async function internalMutate(...args) {
170
- const [cache2, _key, _data, _opts] = args;
171
- const options = mergeObjects({
172
- populateCache: true,
173
- throwOnError: true
174
- }, typeof _opts === "boolean" ? {
175
- revalidate: _opts
176
- } : _opts || {});
177
- let populateCache = options.populateCache;
178
- const rollbackOnErrorOption = options.rollbackOnError;
179
- let optimisticData = options.optimisticData;
180
- const rollbackOnError = (error) => {
181
- return typeof rollbackOnErrorOption === "function" ? rollbackOnErrorOption(error) : rollbackOnErrorOption !== false;
182
- };
183
- const throwOnError = options.throwOnError;
184
- if (isFunction(_key)) {
185
- const keyFilter = _key;
186
- const matchedKeys = [];
187
- const it = cache2.keys();
188
- for (const key of it) {
189
- if (
190
- // Skip the special useSWRInfinite and useSWRSubscription keys.
191
- !/^\$(inf|sub)\$/.test(key) && keyFilter(cache2.get(key)._k)
192
- ) {
193
- matchedKeys.push(key);
194
- }
195
- }
196
- return Promise.all(matchedKeys.map(mutateByKey));
197
- }
198
- return mutateByKey(_key);
199
- async function mutateByKey(_k) {
200
- const [key] = serialize(_k);
201
- if (!key) return;
202
- const [get, set] = createCacheHelper(cache2, key);
203
- const [EVENT_REVALIDATORS, MUTATION, FETCH, PRELOAD] = SWRGlobalState.get(cache2);
204
- const startRevalidate = () => {
205
- const revalidators = EVENT_REVALIDATORS[key];
206
- const revalidate = isFunction(options.revalidate) ? options.revalidate(get().data, _k) : options.revalidate !== false;
207
- if (revalidate) {
208
- delete FETCH[key];
209
- delete PRELOAD[key];
210
- if (revalidators && revalidators[0]) {
211
- return revalidators[0](MUTATE_EVENT).then(() => get().data);
212
- }
213
- }
214
- return get().data;
215
- };
216
- if (args.length < 3) {
217
- return startRevalidate();
218
- }
219
- let data = _data;
220
- let error;
221
- let isError = false;
222
- const beforeMutationTs = getTimestamp();
223
- MUTATION[key] = [
224
- beforeMutationTs,
225
- 0
226
- ];
227
- const hasOptimisticData = !isUndefined(optimisticData);
228
- const state = get();
229
- const displayedData = state.data;
230
- const currentData = state._c;
231
- const committedData = isUndefined(currentData) ? displayedData : currentData;
232
- if (hasOptimisticData) {
233
- optimisticData = isFunction(optimisticData) ? optimisticData(committedData, displayedData) : optimisticData;
234
- set({
235
- data: optimisticData,
236
- _c: committedData
237
- });
238
- }
239
- if (isFunction(data)) {
240
- try {
241
- data = data(committedData);
242
- } catch (err) {
243
- error = err;
244
- isError = true;
245
- }
246
- }
247
- if (data && isPromiseLike(data)) {
248
- data = await data.catch((err) => {
249
- error = err;
250
- isError = true;
251
- });
252
- if (beforeMutationTs !== MUTATION[key][0]) {
253
- if (isError) throw error;
254
- return data;
255
- } else if (isError && hasOptimisticData && rollbackOnError(error)) {
256
- populateCache = true;
257
- set({
258
- data: committedData,
259
- _c: UNDEFINED
260
- });
261
- }
262
- }
263
- if (populateCache) {
264
- if (!isError) {
265
- if (isFunction(populateCache)) {
266
- const populateCachedData = populateCache(data, committedData);
267
- set({
268
- data: populateCachedData,
269
- error: UNDEFINED,
270
- _c: UNDEFINED
271
- });
272
- } else {
273
- set({
274
- data,
275
- error: UNDEFINED,
276
- _c: UNDEFINED
277
- });
278
- }
279
- }
280
- }
281
- MUTATION[key][1] = getTimestamp();
282
- Promise.resolve(startRevalidate()).then(() => {
283
- set({
284
- _c: UNDEFINED
285
- });
286
- });
287
- if (isError) {
288
- if (throwOnError) throw error;
289
- return;
290
- }
291
- return data;
292
- }
293
- }
294
- const revalidateAllKeys = (revalidators, type) => {
295
- for (const key in revalidators) {
296
- if (revalidators[key][0]) revalidators[key][0](type);
297
- }
298
- };
299
- const initCache = (provider, options) => {
300
- if (!SWRGlobalState.has(provider)) {
301
- const opts = mergeObjects(defaultConfigOptions, options);
302
- const EVENT_REVALIDATORS = /* @__PURE__ */ Object.create(null);
303
- const mutate2 = internalMutate.bind(UNDEFINED, provider);
304
- let unmount = noop;
305
- const subscriptions = /* @__PURE__ */ Object.create(null);
306
- const subscribe = (key, callback) => {
307
- const subs = subscriptions[key] || [];
308
- subscriptions[key] = subs;
309
- subs.push(callback);
310
- return () => {
311
- const index = subs.indexOf(callback);
312
- if (index >= 0) {
313
- subs[index] = subs[subs.length - 1];
314
- subs.pop();
315
- }
316
- };
317
- };
318
- const setter = (key, value, prev) => {
319
- provider.set(key, value);
320
- const subs = subscriptions[key];
321
- if (subs) {
322
- for (const fn of subs) {
323
- fn(value, prev);
324
- }
325
- }
326
- };
327
- const initProvider = () => {
328
- if (!SWRGlobalState.has(provider)) {
329
- SWRGlobalState.set(provider, [
330
- EVENT_REVALIDATORS,
331
- /* @__PURE__ */ Object.create(null),
332
- /* @__PURE__ */ Object.create(null),
333
- /* @__PURE__ */ Object.create(null),
334
- mutate2,
335
- setter,
336
- subscribe
337
- ]);
338
- if (!IS_SERVER) {
339
- const releaseFocus = opts.initFocus(setTimeout.bind(UNDEFINED, revalidateAllKeys.bind(UNDEFINED, EVENT_REVALIDATORS, FOCUS_EVENT)));
340
- const releaseReconnect = opts.initReconnect(setTimeout.bind(UNDEFINED, revalidateAllKeys.bind(UNDEFINED, EVENT_REVALIDATORS, RECONNECT_EVENT)));
341
- unmount = () => {
342
- releaseFocus && releaseFocus();
343
- releaseReconnect && releaseReconnect();
344
- SWRGlobalState.delete(provider);
345
- };
346
- }
347
- }
348
- };
349
- initProvider();
350
- return [
351
- provider,
352
- mutate2,
353
- initProvider,
354
- unmount
355
- ];
356
- }
357
- return [
358
- provider,
359
- SWRGlobalState.get(provider)[4]
360
- ];
361
- };
362
- const onErrorRetry = (_, __, config, revalidate, opts) => {
363
- const maxRetryCount = config.errorRetryCount;
364
- const currentRetryCount = opts.retryCount;
365
- const timeout = ~~((Math.random() + 0.5) * (1 << (currentRetryCount < 8 ? currentRetryCount : 8))) * config.errorRetryInterval;
366
- if (!isUndefined(maxRetryCount) && currentRetryCount > maxRetryCount) {
367
- return;
368
- }
369
- setTimeout(revalidate, timeout, opts);
370
- };
371
- const compare = dequal;
372
- const [cache, mutate] = initCache(/* @__PURE__ */ new Map());
373
- const defaultConfig = mergeObjects(
374
- {
375
- // events
376
- onLoadingSlow: noop,
377
- onSuccess: noop,
378
- onError: noop,
379
- onErrorRetry,
380
- onDiscarded: noop,
381
- // switches
382
- revalidateOnFocus: true,
383
- revalidateOnReconnect: true,
384
- revalidateIfStale: true,
385
- shouldRetryOnError: true,
386
- // timeouts
387
- errorRetryInterval: slowConnection ? 1e4 : 5e3,
388
- focusThrottleInterval: 5 * 1e3,
389
- dedupingInterval: 2 * 1e3,
390
- loadingTimeout: slowConnection ? 5e3 : 3e3,
391
- // providers
392
- compare,
393
- isPaused: () => false,
394
- cache,
395
- mutate,
396
- fallback: {}
397
- },
398
- // use web preset by default
399
- preset
400
- );
401
- const mergeConfigs = (a, b) => {
402
- const v = mergeObjects(a, b);
403
- if (b) {
404
- const { use: u1, fallback: f1 } = a;
405
- const { use: u2, fallback: f2 } = b;
406
- if (u1 && u2) {
407
- v.use = u1.concat(u2);
408
- }
409
- if (f1 && f2) {
410
- v.fallback = mergeObjects(f1, f2);
411
- }
412
- }
413
- return v;
414
- };
415
- const SWRConfigContext = reactExports.createContext({});
416
- const SWRConfig$1 = (props) => {
417
- const { value } = props;
418
- const parentConfig = reactExports.useContext(SWRConfigContext);
419
- const isFunctionalConfig = isFunction(value);
420
- const config = reactExports.useMemo(() => isFunctionalConfig ? value(parentConfig) : value, [
421
- isFunctionalConfig,
422
- parentConfig,
423
- value
424
- ]);
425
- const extendedConfig = reactExports.useMemo(() => isFunctionalConfig ? config : mergeConfigs(parentConfig, config), [
426
- isFunctionalConfig,
427
- parentConfig,
428
- config
429
- ]);
430
- const provider = config && config.provider;
431
- const cacheContextRef = reactExports.useRef(UNDEFINED);
432
- if (provider && !cacheContextRef.current) {
433
- cacheContextRef.current = initCache(provider(extendedConfig.cache || cache), config);
434
- }
435
- const cacheContext = cacheContextRef.current;
436
- if (cacheContext) {
437
- extendedConfig.cache = cacheContext[0];
438
- extendedConfig.mutate = cacheContext[1];
439
- }
440
- useIsomorphicLayoutEffect(() => {
441
- if (cacheContext) {
442
- cacheContext[2] && cacheContext[2]();
443
- return cacheContext[3];
444
- }
445
- }, []);
446
- return reactExports.createElement(SWRConfigContext.Provider, mergeObjects(props, {
447
- value: extendedConfig
448
- }));
449
- };
450
- const INFINITE_PREFIX = "$inf$";
451
- const enableDevtools = isWindowDefined && window.__SWR_DEVTOOLS_USE__;
452
- const use$1 = enableDevtools ? window.__SWR_DEVTOOLS_USE__ : [];
453
- const setupDevTools = () => {
454
- if (enableDevtools) {
455
- window.__SWR_DEVTOOLS_REACT__ = React;
456
- }
457
- };
458
- const normalize = (args) => {
459
- return isFunction(args[1]) ? [
460
- args[0],
461
- args[1],
462
- args[2] || {}
463
- ] : [
464
- args[0],
465
- null,
466
- (args[1] === null ? args[2] : args[1]) || {}
467
- ];
468
- };
469
- const useSWRConfig = () => {
470
- const parentConfig = reactExports.useContext(SWRConfigContext);
471
- const mergedConfig = reactExports.useMemo(() => mergeObjects(defaultConfig, parentConfig), [
472
- parentConfig
473
- ]);
474
- return mergedConfig;
475
- };
476
- const middleware = (useSWRNext) => (key_, fetcher_, config) => {
477
- const fetcher = fetcher_ && ((...args) => {
478
- const [key] = serialize(key_);
479
- const [, , , PRELOAD] = SWRGlobalState.get(cache);
480
- if (key.startsWith(INFINITE_PREFIX)) {
481
- return fetcher_(...args);
482
- }
483
- const req = PRELOAD[key];
484
- if (isUndefined(req)) return fetcher_(...args);
485
- delete PRELOAD[key];
486
- return req;
487
- });
488
- return useSWRNext(key_, fetcher, config);
489
- };
490
- const BUILT_IN_MIDDLEWARE = use$1.concat(middleware);
491
- const withArgs = (hook) => {
492
- return function useSWRArgs(...args) {
493
- const fallbackConfig = useSWRConfig();
494
- const [key, fn, _config] = normalize(args);
495
- const config = mergeConfigs(fallbackConfig, _config);
496
- let next = hook;
497
- const { use: use2 } = config;
498
- const middleware2 = (use2 || []).concat(BUILT_IN_MIDDLEWARE);
499
- for (let i = middleware2.length; i--; ) {
500
- next = middleware2[i](next);
501
- }
502
- return next(key, fn || config.fetcher || null, config);
503
- };
504
- };
505
- const subscribeCallback = (key, callbacks, callback) => {
506
- const keyedRevalidators = callbacks[key] || (callbacks[key] = []);
507
- keyedRevalidators.push(callback);
508
- return () => {
509
- const index = keyedRevalidators.indexOf(callback);
510
- if (index >= 0) {
511
- keyedRevalidators[index] = keyedRevalidators[keyedRevalidators.length - 1];
512
- keyedRevalidators.pop();
513
- }
514
- };
515
- };
516
- setupDevTools();
517
- const use = React.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax
518
- // and emitting an error.
519
- // We assume that this is only for the `use(thenable)` case, not `use(context)`.
520
- // https://github.com/facebook/react/blob/aed00dacfb79d17c53218404c52b1c7aa59c4a89/packages/react-server/src/ReactFizzThenable.js#L45
521
- ((thenable) => {
522
- switch (thenable.status) {
523
- case "pending":
524
- throw thenable;
525
- case "fulfilled":
526
- return thenable.value;
527
- case "rejected":
528
- throw thenable.reason;
529
- default:
530
- thenable.status = "pending";
531
- thenable.then((v) => {
532
- thenable.status = "fulfilled";
533
- thenable.value = v;
534
- }, (e) => {
535
- thenable.status = "rejected";
536
- thenable.reason = e;
537
- });
538
- throw thenable;
539
- }
540
- });
541
- const WITH_DEDUPE = {
542
- dedupe: true
543
- };
544
- const resolvedUndef = Promise.resolve(UNDEFINED);
545
- resolvedUndef.status = "fulfilled";
546
- resolvedUndef.value = UNDEFINED;
547
- const sub = () => noop;
548
- const useSWRHandler = (_key, fetcher, config) => {
549
- const { cache: cache2, compare: compare2, suspense, fallbackData, revalidateOnMount, revalidateIfStale, refreshInterval, refreshWhenHidden, refreshWhenOffline, keepPreviousData, strictServerPrefetchWarning } = config;
550
- const [EVENT_REVALIDATORS, MUTATION, FETCH, PRELOAD] = SWRGlobalState.get(cache2);
551
- const [key, fnArg] = serialize(_key);
552
- const initialMountedRef = reactExports.useRef(false);
553
- const unmountedRef = reactExports.useRef(false);
554
- const keyRef = reactExports.useRef(key);
555
- const fetcherRef = reactExports.useRef(fetcher);
556
- const configRef = reactExports.useRef(config);
557
- const getConfig = () => configRef.current;
558
- const isActive = () => getConfig().isVisible() && getConfig().isOnline();
559
- const [getCache, setCache, subscribeCache, getInitialCache] = createCacheHelper(cache2, key);
560
- const stateDependencies = reactExports.useRef({}).current;
561
- const fallback = isUndefined(fallbackData) ? isUndefined(config.fallback) ? UNDEFINED : config.fallback[key] : fallbackData;
562
- const isEqual = (prev, current) => {
563
- for (const _ in stateDependencies) {
564
- const t = _;
565
- if (t === "data") {
566
- if (!compare2(prev[t], current[t])) {
567
- if (!isUndefined(prev[t])) {
568
- return false;
569
- }
570
- if (!compare2(returnedData, current[t])) {
571
- return false;
572
- }
573
- }
574
- } else {
575
- if (current[t] !== prev[t]) {
576
- return false;
577
- }
578
- }
579
- }
580
- return true;
581
- };
582
- const isInitialMount = !initialMountedRef.current;
583
- const getSnapshot = reactExports.useMemo(() => {
584
- const cachedData2 = getCache();
585
- const initialData = getInitialCache();
586
- const getSelectedCache = (state) => {
587
- const snapshot = mergeObjects(state);
588
- delete snapshot._k;
589
- const shouldStartRequest = (() => {
590
- if (!key) return false;
591
- if (!fetcher) return false;
592
- if (getConfig().isPaused()) return false;
593
- if (isInitialMount && !isUndefined(revalidateOnMount)) return revalidateOnMount;
594
- const data2 = !isUndefined(fallback) ? fallback : snapshot.data;
595
- if (suspense) return isUndefined(data2) || revalidateIfStale;
596
- return isUndefined(data2) || revalidateIfStale;
597
- })();
598
- if (!shouldStartRequest) {
599
- return snapshot;
600
- }
601
- return {
602
- isValidating: true,
603
- isLoading: true,
604
- ...snapshot
605
- };
606
- };
607
- const clientSnapshot = getSelectedCache(cachedData2);
608
- const serverSnapshot = cachedData2 === initialData ? clientSnapshot : getSelectedCache(initialData);
609
- let memorizedSnapshot = clientSnapshot;
610
- return [
611
- () => {
612
- const newSnapshot = getSelectedCache(getCache());
613
- const compareResult = isEqual(newSnapshot, memorizedSnapshot);
614
- if (compareResult) {
615
- memorizedSnapshot.data = newSnapshot.data;
616
- memorizedSnapshot.isLoading = newSnapshot.isLoading;
617
- memorizedSnapshot.isValidating = newSnapshot.isValidating;
618
- memorizedSnapshot.error = newSnapshot.error;
619
- return memorizedSnapshot;
620
- } else {
621
- memorizedSnapshot = newSnapshot;
622
- return newSnapshot;
623
- }
624
- },
625
- () => serverSnapshot
626
- ];
627
- }, [
628
- cache2,
629
- key
630
- ]);
631
- const cached = shimExports.useSyncExternalStore(reactExports.useCallback(
632
- (callback) => subscribeCache(key, (current, prev) => {
633
- if (!isEqual(prev, current)) callback();
634
- }),
635
- // eslint-disable-next-line react-hooks/exhaustive-deps
636
- [
637
- cache2,
638
- key
639
- ]
640
- ), getSnapshot[0], getSnapshot[1]);
641
- const hasRevalidator = EVENT_REVALIDATORS[key] && EVENT_REVALIDATORS[key].length > 0;
642
- const cachedData = cached.data;
643
- const data = isUndefined(cachedData) ? fallback && isPromiseLike(fallback) ? use(fallback) : fallback : cachedData;
644
- const error = cached.error;
645
- const laggyDataRef = reactExports.useRef(data);
646
- const returnedData = keepPreviousData ? isUndefined(cachedData) ? isUndefined(laggyDataRef.current) ? data : laggyDataRef.current : cachedData : data;
647
- const hasKeyButNoData = key && isUndefined(data);
648
- const hydrationRef = reactExports.useRef(null);
649
- !IS_SERVER && // getServerSnapshot is only called during hydration
650
- // eslint-disable-next-line react-hooks/rules-of-hooks
651
- shimExports.useSyncExternalStore(sub, () => {
652
- hydrationRef.current = false;
653
- return hydrationRef;
654
- }, () => {
655
- hydrationRef.current = true;
656
- return hydrationRef;
657
- });
658
- const isHydration = hydrationRef.current;
659
- if (strictServerPrefetchWarning && isHydration && !suspense && hasKeyButNoData) {
660
- console.warn(`Missing pre-initiated data for serialized key "${key}" during server-side rendering. Data fetching should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);
661
- }
662
- const shouldDoInitialRevalidation = (() => {
663
- if (!key || !fetcher) return false;
664
- if (getConfig().isPaused()) return false;
665
- if (hasRevalidator && !isUndefined(error)) return false;
666
- if (isInitialMount && !isUndefined(revalidateOnMount)) return revalidateOnMount;
667
- if (suspense) return isUndefined(data) ? false : revalidateIfStale;
668
- return isUndefined(data) || revalidateIfStale;
669
- })();
670
- const defaultValidatingState = isInitialMount && shouldDoInitialRevalidation;
671
- const isValidating = isUndefined(cached.isValidating) ? defaultValidatingState : cached.isValidating;
672
- const isLoading = isUndefined(cached.isLoading) ? defaultValidatingState : cached.isLoading;
673
- const revalidate = reactExports.useCallback(
674
- async (revalidateOpts) => {
675
- const currentFetcher = fetcherRef.current;
676
- if (!key || !currentFetcher || unmountedRef.current || getConfig().isPaused()) {
677
- return false;
678
- }
679
- let newData;
680
- let startAt;
681
- let loading = true;
682
- const opts = revalidateOpts || {};
683
- const shouldStartNewRequest = !FETCH[key] || !opts.dedupe;
684
- const callbackSafeguard = () => {
685
- if (IS_REACT_LEGACY) {
686
- return !unmountedRef.current && key === keyRef.current && initialMountedRef.current;
687
- }
688
- return key === keyRef.current;
689
- };
690
- const finalState = {
691
- isValidating: false,
692
- isLoading: false
693
- };
694
- const finishRequestAndUpdateState = () => {
695
- setCache(finalState);
696
- };
697
- const cleanupState = () => {
698
- const requestInfo = FETCH[key];
699
- if (requestInfo && requestInfo[1] === startAt) {
700
- delete FETCH[key];
701
- }
702
- };
703
- const initialState = {
704
- isValidating: true
705
- };
706
- if (isUndefined(getCache().data)) {
707
- initialState.isLoading = true;
708
- }
709
- try {
710
- if (shouldStartNewRequest) {
711
- setCache(initialState);
712
- if (config.loadingTimeout && isUndefined(getCache().data)) {
713
- setTimeout(() => {
714
- if (loading && callbackSafeguard()) {
715
- getConfig().onLoadingSlow(key, config);
716
- }
717
- }, config.loadingTimeout);
718
- }
719
- FETCH[key] = [
720
- currentFetcher(fnArg),
721
- getTimestamp()
722
- ];
723
- }
724
- ;
725
- [newData, startAt] = FETCH[key];
726
- newData = await newData;
727
- if (shouldStartNewRequest) {
728
- setTimeout(cleanupState, config.dedupingInterval);
729
- }
730
- if (!FETCH[key] || FETCH[key][1] !== startAt) {
731
- if (shouldStartNewRequest) {
732
- if (callbackSafeguard()) {
733
- getConfig().onDiscarded(key);
734
- }
735
- }
736
- return false;
737
- }
738
- finalState.error = UNDEFINED;
739
- const mutationInfo = MUTATION[key];
740
- if (!isUndefined(mutationInfo) && // case 1
741
- (startAt <= mutationInfo[0] || // case 2
742
- startAt <= mutationInfo[1] || // case 3
743
- mutationInfo[1] === 0)) {
744
- finishRequestAndUpdateState();
745
- if (shouldStartNewRequest) {
746
- if (callbackSafeguard()) {
747
- getConfig().onDiscarded(key);
748
- }
749
- }
750
- return false;
751
- }
752
- const cacheData = getCache().data;
753
- finalState.data = compare2(cacheData, newData) ? cacheData : newData;
754
- if (shouldStartNewRequest) {
755
- if (callbackSafeguard()) {
756
- getConfig().onSuccess(newData, key, config);
757
- }
758
- }
759
- } catch (err) {
760
- cleanupState();
761
- const currentConfig = getConfig();
762
- const { shouldRetryOnError } = currentConfig;
763
- if (!currentConfig.isPaused()) {
764
- finalState.error = err;
765
- if (shouldStartNewRequest && callbackSafeguard()) {
766
- currentConfig.onError(err, key, currentConfig);
767
- if (shouldRetryOnError === true || isFunction(shouldRetryOnError) && shouldRetryOnError(err)) {
768
- if (!getConfig().revalidateOnFocus || !getConfig().revalidateOnReconnect || isActive()) {
769
- currentConfig.onErrorRetry(err, key, currentConfig, (_opts) => {
770
- const revalidators = EVENT_REVALIDATORS[key];
771
- if (revalidators && revalidators[0]) {
772
- revalidators[0](ERROR_REVALIDATE_EVENT, _opts);
773
- }
774
- }, {
775
- retryCount: (opts.retryCount || 0) + 1,
776
- dedupe: true
777
- });
778
- }
779
- }
780
- }
781
- }
782
- }
783
- loading = false;
784
- finishRequestAndUpdateState();
785
- return true;
786
- },
787
- // `setState` is immutable, and `eventsCallback`, `fnArg`, and
788
- // `keyValidating` are depending on `key`, so we can exclude them from
789
- // the deps array.
790
- //
791
- // FIXME:
792
- // `fn` and `config` might be changed during the lifecycle,
793
- // but they might be changed every render like this.
794
- // `useSWR('key', () => fetch('/api/'), { suspense: true })`
795
- // So we omit the values from the deps array
796
- // even though it might cause unexpected behaviors.
797
- // eslint-disable-next-line react-hooks/exhaustive-deps
798
- [
799
- key,
800
- cache2
801
- ]
802
- );
803
- const boundMutate = reactExports.useCallback(
804
- // Use callback to make sure `keyRef.current` returns latest result every time
805
- (...args) => {
806
- return internalMutate(cache2, keyRef.current, ...args);
807
- },
808
- // eslint-disable-next-line react-hooks/exhaustive-deps
809
- []
810
- );
811
- useIsomorphicLayoutEffect(() => {
812
- fetcherRef.current = fetcher;
813
- configRef.current = config;
814
- if (!isUndefined(cachedData)) {
815
- laggyDataRef.current = cachedData;
816
- }
817
- });
818
- useIsomorphicLayoutEffect(() => {
819
- if (!key) return;
820
- const softRevalidate = revalidate.bind(UNDEFINED, WITH_DEDUPE);
821
- let nextFocusRevalidatedAt = 0;
822
- if (getConfig().revalidateOnFocus) {
823
- const initNow = Date.now();
824
- nextFocusRevalidatedAt = initNow + getConfig().focusThrottleInterval;
825
- }
826
- const onRevalidate = (type, opts = {}) => {
827
- if (type == FOCUS_EVENT) {
828
- const now = Date.now();
829
- if (getConfig().revalidateOnFocus && now > nextFocusRevalidatedAt && isActive()) {
830
- nextFocusRevalidatedAt = now + getConfig().focusThrottleInterval;
831
- softRevalidate();
832
- }
833
- } else if (type == RECONNECT_EVENT) {
834
- if (getConfig().revalidateOnReconnect && isActive()) {
835
- softRevalidate();
836
- }
837
- } else if (type == MUTATE_EVENT) {
838
- return revalidate();
839
- } else if (type == ERROR_REVALIDATE_EVENT) {
840
- return revalidate(opts);
841
- }
842
- return;
843
- };
844
- const unsubEvents = subscribeCallback(key, EVENT_REVALIDATORS, onRevalidate);
845
- unmountedRef.current = false;
846
- keyRef.current = key;
847
- initialMountedRef.current = true;
848
- setCache({
849
- _k: fnArg
850
- });
851
- if (shouldDoInitialRevalidation) {
852
- if (!FETCH[key]) {
853
- if (isUndefined(data) || IS_SERVER) {
854
- softRevalidate();
855
- } else {
856
- rAF(softRevalidate);
857
- }
858
- }
859
- }
860
- return () => {
861
- unmountedRef.current = true;
862
- unsubEvents();
863
- };
864
- }, [
865
- key
866
- ]);
867
- useIsomorphicLayoutEffect(() => {
868
- let timer;
869
- function next() {
870
- const interval = isFunction(refreshInterval) ? refreshInterval(getCache().data) : refreshInterval;
871
- if (interval && timer !== -1) {
872
- timer = setTimeout(execute, interval);
873
- }
874
- }
875
- function execute() {
876
- if (!getCache().error && (refreshWhenHidden || getConfig().isVisible()) && (refreshWhenOffline || getConfig().isOnline())) {
877
- revalidate(WITH_DEDUPE).then(next);
878
- } else {
879
- next();
880
- }
881
- }
882
- next();
883
- return () => {
884
- if (timer) {
885
- clearTimeout(timer);
886
- timer = -1;
887
- }
888
- };
889
- }, [
890
- refreshInterval,
891
- refreshWhenHidden,
892
- refreshWhenOffline,
893
- key
894
- ]);
895
- reactExports.useDebugValue(returnedData);
896
- if (suspense) {
897
- if (!IS_REACT_LEGACY && IS_SERVER && hasKeyButNoData) {
898
- throw new Error("Fallback data is required when using Suspense in SSR.");
899
- }
900
- if (hasKeyButNoData) {
901
- fetcherRef.current = fetcher;
902
- configRef.current = config;
903
- unmountedRef.current = false;
904
- }
905
- const req = PRELOAD[key];
906
- const mutateReq = !isUndefined(req) && hasKeyButNoData ? boundMutate(req) : resolvedUndef;
907
- use(mutateReq);
908
- if (!isUndefined(error) && hasKeyButNoData) {
909
- throw error;
910
- }
911
- const revalidation = hasKeyButNoData ? revalidate(WITH_DEDUPE) : resolvedUndef;
912
- if (!isUndefined(returnedData) && hasKeyButNoData) {
913
- revalidation.status = "fulfilled";
914
- revalidation.value = true;
915
- }
916
- use(revalidation);
917
- }
918
- const swrResponse = {
919
- mutate: boundMutate,
920
- get data() {
921
- stateDependencies.data = true;
922
- return returnedData;
923
- },
924
- get error() {
925
- stateDependencies.error = true;
926
- return error;
927
- },
928
- get isValidating() {
929
- stateDependencies.isValidating = true;
930
- return isValidating;
931
- },
932
- get isLoading() {
933
- stateDependencies.isLoading = true;
934
- return isLoading;
935
- }
936
- };
937
- return swrResponse;
938
- };
939
- const SWRConfig = OBJECT.defineProperty(SWRConfig$1, "defaultValue", {
940
- value: defaultConfig
941
- });
942
- const useSWR = withArgs(useSWRHandler);
943
- export {
944
- SWRConfig as S,
945
- useSWRConfig as a,
946
- useSWR as u
947
- };