@abide/abide 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (562) hide show
  1. package/CHANGELOG.md +607 -0
  2. package/LICENSE +21 -0
  3. package/README.md +154 -0
  4. package/bin/abide.ts +212 -0
  5. package/package.json +155 -0
  6. package/src/abideLsp.ts +211 -0
  7. package/src/abideModules.d.ts +8 -0
  8. package/src/abideResolverPlugin.ts +923 -0
  9. package/src/appEntry.ts +151 -0
  10. package/src/assets/app.html +12 -0
  11. package/src/build.ts +143 -0
  12. package/src/buildCli.ts +127 -0
  13. package/src/buildDisconnected.ts +118 -0
  14. package/src/bundleApp.ts +147 -0
  15. package/src/bundleDisconnectedEntry.ts +14 -0
  16. package/src/checkAbide.ts +77 -0
  17. package/src/cliEntry.ts +25 -0
  18. package/src/clientBuildPlugins.ts +33 -0
  19. package/src/clientEntry.ts +17 -0
  20. package/src/compile.ts +63 -0
  21. package/src/controlServerWorker.ts +426 -0
  22. package/src/devEntry.ts +250 -0
  23. package/src/discoveryEntry.ts +81 -0
  24. package/src/lib/bundle/BundleMenu.ts +12 -0
  25. package/src/lib/bundle/BundleMenuItem.ts +25 -0
  26. package/src/lib/bundle/BundleWindow.ts +37 -0
  27. package/src/lib/bundle/WEBVIEW_BUILD_REVISION.ts +9 -0
  28. package/src/lib/bundle/WEBVIEW_VERSION.ts +7 -0
  29. package/src/lib/bundle/bindConnectedFlag.ts +29 -0
  30. package/src/lib/bundle/bindRequestNavigate.ts +34 -0
  31. package/src/lib/bundle/buildWebviewLib.ts +111 -0
  32. package/src/lib/bundle/bundled.ts +35 -0
  33. package/src/lib/bundle/disconnected.abide +236 -0
  34. package/src/lib/bundle/disconnected.css +9 -0
  35. package/src/lib/bundle/ensureWebviewLib.ts +20 -0
  36. package/src/lib/bundle/exitWithParent.ts +28 -0
  37. package/src/lib/bundle/infoPlist.ts +46 -0
  38. package/src/lib/bundle/installDownloads.ts +24 -0
  39. package/src/lib/bundle/installMacMenu.ts +39 -0
  40. package/src/lib/bundle/listenLocalControlServer.ts +19 -0
  41. package/src/lib/bundle/native/abideMenu.mm +422 -0
  42. package/src/lib/bundle/native/webview.h +4557 -0
  43. package/src/lib/bundle/onMenu.ts +42 -0
  44. package/src/lib/bundle/openWebview.ts +104 -0
  45. package/src/lib/bundle/pngToIcns.ts +47 -0
  46. package/src/lib/bundle/probeAbideServer.ts +57 -0
  47. package/src/lib/bundle/resolveServerBinary.ts +12 -0
  48. package/src/lib/bundle/resolveWebviewLib.ts +53 -0
  49. package/src/lib/bundle/serverBinaryFilename.ts +8 -0
  50. package/src/lib/bundle/signMacApp.ts +37 -0
  51. package/src/lib/bundle/spawnEmbeddedServer.ts +64 -0
  52. package/src/lib/bundle/stableLocalPort.ts +19 -0
  53. package/src/lib/bundle/waitForServer.ts +23 -0
  54. package/src/lib/bundle/webviewCachePath.ts +23 -0
  55. package/src/lib/bundle/webviewLibName.ts +11 -0
  56. package/src/lib/cli/connectToServer.ts +23 -0
  57. package/src/lib/cli/createClient.ts +108 -0
  58. package/src/lib/cli/dispatchCommand.ts +71 -0
  59. package/src/lib/cli/loadEnvFromBinaryDir.ts +15 -0
  60. package/src/lib/cli/parseArgvForRpc.ts +100 -0
  61. package/src/lib/cli/printHelp.ts +119 -0
  62. package/src/lib/cli/printSessionHelp.ts +27 -0
  63. package/src/lib/cli/printSessionStatus.ts +21 -0
  64. package/src/lib/cli/printTrimmed.ts +8 -0
  65. package/src/lib/cli/printValue.ts +10 -0
  66. package/src/lib/cli/resolveCliTarget.ts +48 -0
  67. package/src/lib/cli/runCli.ts +176 -0
  68. package/src/lib/cli/runSession.ts +108 -0
  69. package/src/lib/cli/startLocalInstance.ts +14 -0
  70. package/src/lib/cli/tokenizeLine.ts +51 -0
  71. package/src/lib/cli/types/CliManifest.ts +9 -0
  72. package/src/lib/cli/types/CliManifestEntry.ts +17 -0
  73. package/src/lib/cli/types/CliTarget.ts +13 -0
  74. package/src/lib/mcp/annotationsForMethod.ts +29 -0
  75. package/src/lib/mcp/createMcpResourceServer.ts +102 -0
  76. package/src/lib/mcp/createMcpServer.ts +48 -0
  77. package/src/lib/mcp/dispatchMcpRequest.ts +138 -0
  78. package/src/lib/mcp/mcpResourceServerSlot.ts +18 -0
  79. package/src/lib/mcp/mcpSurface.ts +295 -0
  80. package/src/lib/mcp/toolResultFromResponse.ts +66 -0
  81. package/src/lib/mcp/types/JsonRpcRequest.ts +12 -0
  82. package/src/lib/mcp/types/JsonRpcResponse.ts +20 -0
  83. package/src/lib/mcp/types/McpResourceContents.ts +10 -0
  84. package/src/lib/mcp/types/McpResourceDescriptor.ts +6 -0
  85. package/src/lib/mcp/types/McpResourceServer.ts +12 -0
  86. package/src/lib/mcp/types/McpServer.ts +9 -0
  87. package/src/lib/mcp/types/McpServerOptions.ts +16 -0
  88. package/src/lib/server/AppModule.ts +47 -0
  89. package/src/lib/server/DELETE.ts +10 -0
  90. package/src/lib/server/GET.ts +10 -0
  91. package/src/lib/server/HEAD.ts +10 -0
  92. package/src/lib/server/PATCH.ts +10 -0
  93. package/src/lib/server/POST.ts +10 -0
  94. package/src/lib/server/PUT.ts +10 -0
  95. package/src/lib/server/agent.ts +86 -0
  96. package/src/lib/server/appDataDir.ts +16 -0
  97. package/src/lib/server/cli/buildEnvContent.ts +19 -0
  98. package/src/lib/server/cli/createTarGz.ts +77 -0
  99. package/src/lib/server/cli/handleCliDownload.ts +150 -0
  100. package/src/lib/server/cli/handleCliInstall.ts +37 -0
  101. package/src/lib/server/cli/installScript.ts +31 -0
  102. package/src/lib/server/cli/maxSourceMtime.ts +26 -0
  103. package/src/lib/server/cookies.ts +30 -0
  104. package/src/lib/server/env.ts +51 -0
  105. package/src/lib/server/error.ts +73 -0
  106. package/src/lib/server/json.ts +42 -0
  107. package/src/lib/server/jsonl.ts +47 -0
  108. package/src/lib/server/prompts/definePrompt.ts +21 -0
  109. package/src/lib/server/prompts/promptRegistry.ts +9 -0
  110. package/src/lib/server/prompts/registerPrompt.ts +6 -0
  111. package/src/lib/server/prompts/renderPromptTemplate.ts +17 -0
  112. package/src/lib/server/prompts/types/Prompt.ts +13 -0
  113. package/src/lib/server/prompts/types/PromptOptions.ts +12 -0
  114. package/src/lib/server/prompts/types/PromptRegistryEntry.ts +13 -0
  115. package/src/lib/server/prompts/types/PromptRoutes.ts +10 -0
  116. package/src/lib/server/reachable.ts +45 -0
  117. package/src/lib/server/redirect.ts +43 -0
  118. package/src/lib/server/request.ts +19 -0
  119. package/src/lib/server/rpc/defineVerb.ts +210 -0
  120. package/src/lib/server/rpc/dispatchVerbInProcess.ts +46 -0
  121. package/src/lib/server/rpc/findVerbByCommandName.ts +18 -0
  122. package/src/lib/server/rpc/parseArgs.ts +127 -0
  123. package/src/lib/server/rpc/readBodyWithinLimit.ts +44 -0
  124. package/src/lib/server/rpc/registerVerb.ts +6 -0
  125. package/src/lib/server/rpc/runWithVerbTimeout.ts +49 -0
  126. package/src/lib/server/rpc/types/RemoteHandler.ts +27 -0
  127. package/src/lib/server/rpc/types/RemoteRoutes.ts +13 -0
  128. package/src/lib/server/rpc/types/TypedResponse.ts +18 -0
  129. package/src/lib/server/rpc/types/VerbHelper.ts +87 -0
  130. package/src/lib/server/rpc/types/VerbRegistryEntry.ts +35 -0
  131. package/src/lib/server/rpc/unprocessed.ts +14 -0
  132. package/src/lib/server/rpc/verbRegistry.ts +11 -0
  133. package/src/lib/server/runtime/DEFAULT_PORT.ts +6 -0
  134. package/src/lib/server/runtime/DEV_READY_MESSAGE.ts +6 -0
  135. package/src/lib/server/runtime/DEV_REBUILD_MESSAGE.ts +4 -0
  136. package/src/lib/server/runtime/DEV_RELOAD_CLIENT_SCRIPT.ts +107 -0
  137. package/src/lib/server/runtime/SSR_SWAP_SCRIPT.ts +16 -0
  138. package/src/lib/server/runtime/acceptsGzip.ts +24 -0
  139. package/src/lib/server/runtime/buildCacheSnapshot.ts +61 -0
  140. package/src/lib/server/runtime/buildHealthPayload.ts +34 -0
  141. package/src/lib/server/runtime/buildInspectorSurface.ts +37 -0
  142. package/src/lib/server/runtime/buildOpenApiSpec.ts +106 -0
  143. package/src/lib/server/runtime/cacheControlForAsset.ts +22 -0
  144. package/src/lib/server/runtime/containsTraversal.ts +37 -0
  145. package/src/lib/server/runtime/createAppAssetServer.ts +76 -0
  146. package/src/lib/server/runtime/createAssetHeaderCache.ts +31 -0
  147. package/src/lib/server/runtime/createPublicAssetServer.ts +67 -0
  148. package/src/lib/server/runtime/createReachable.ts +109 -0
  149. package/src/lib/server/runtime/createRouteDispatcher.ts +127 -0
  150. package/src/lib/server/runtime/createServer.ts +674 -0
  151. package/src/lib/server/runtime/createUiPageRenderer.ts +181 -0
  152. package/src/lib/server/runtime/crossOriginForbidden.ts +17 -0
  153. package/src/lib/server/runtime/crossOriginGate.ts +29 -0
  154. package/src/lib/server/runtime/devClientFingerprint.ts +117 -0
  155. package/src/lib/server/runtime/devHotModuleResponse.ts +40 -0
  156. package/src/lib/server/runtime/devReloadResponse.ts +41 -0
  157. package/src/lib/server/runtime/disableIdleTimeoutForStream.ts +27 -0
  158. package/src/lib/server/runtime/envSchemaStore.ts +15 -0
  159. package/src/lib/server/runtime/findOpenPort.ts +21 -0
  160. package/src/lib/server/runtime/getActiveServer.ts +6 -0
  161. package/src/lib/server/runtime/globToPathSet.ts +29 -0
  162. package/src/lib/server/runtime/gzipResponse.ts +46 -0
  163. package/src/lib/server/runtime/inProcessServer.ts +20 -0
  164. package/src/lib/server/runtime/internalErrorResponse.ts +25 -0
  165. package/src/lib/server/runtime/isCrossOriginRequest.ts +23 -0
  166. package/src/lib/server/runtime/listenOnOpenPort.ts +36 -0
  167. package/src/lib/server/runtime/logExposedSurfaces.ts +156 -0
  168. package/src/lib/server/runtime/maybeMountInspector.ts +97 -0
  169. package/src/lib/server/runtime/mimeForExtension.ts +14 -0
  170. package/src/lib/server/runtime/pageUrlFromStore.ts +15 -0
  171. package/src/lib/server/runtime/parseIdleTimeout.ts +10 -0
  172. package/src/lib/server/runtime/parsePort.ts +11 -0
  173. package/src/lib/server/runtime/registryManifests.ts +66 -0
  174. package/src/lib/server/runtime/requestContext.ts +5 -0
  175. package/src/lib/server/runtime/resolvePageSnapshot.ts +25 -0
  176. package/src/lib/server/runtime/respondWithEmbeddedAsset.ts +18 -0
  177. package/src/lib/server/runtime/runWithRequestScope.ts +150 -0
  178. package/src/lib/server/runtime/safeJsonForScript.ts +17 -0
  179. package/src/lib/server/runtime/serializeCacheSnapshot.ts +45 -0
  180. package/src/lib/server/runtime/serverSlot.ts +13 -0
  181. package/src/lib/server/runtime/setActiveServer.ts +6 -0
  182. package/src/lib/server/runtime/snapshotEntryFromCache.ts +83 -0
  183. package/src/lib/server/runtime/streamCacheResolutions.ts +37 -0
  184. package/src/lib/server/runtime/streamFromIterator.ts +86 -0
  185. package/src/lib/server/runtime/types/Assets.ts +6 -0
  186. package/src/lib/server/runtime/types/DevReloadStamp.ts +18 -0
  187. package/src/lib/server/runtime/types/InspectorCacheEntry.ts +24 -0
  188. package/src/lib/server/runtime/types/InspectorCacheSnapshot.ts +11 -0
  189. package/src/lib/server/runtime/types/InspectorContext.ts +30 -0
  190. package/src/lib/server/runtime/types/InspectorSocket.ts +17 -0
  191. package/src/lib/server/runtime/types/InspectorSurface.ts +13 -0
  192. package/src/lib/server/runtime/types/InspectorVerb.ts +27 -0
  193. package/src/lib/server/runtime/types/RequestStore.ts +55 -0
  194. package/src/lib/server/runtime/warnUnguardedMcp.ts +32 -0
  195. package/src/lib/server/runtime/withResponseDefaults.ts +24 -0
  196. package/src/lib/server/server.ts +33 -0
  197. package/src/lib/server/socket.ts +32 -0
  198. package/src/lib/server/sockets/createSocketDispatcher.ts +337 -0
  199. package/src/lib/server/sockets/defineSocket.ts +179 -0
  200. package/src/lib/server/sockets/lookupSocket.ts +6 -0
  201. package/src/lib/server/sockets/registerSocket.ts +6 -0
  202. package/src/lib/server/sockets/socketOperations.ts +36 -0
  203. package/src/lib/server/sockets/socketRegistry.ts +9 -0
  204. package/src/lib/server/sockets/types/Socket.ts +23 -0
  205. package/src/lib/server/sockets/types/SocketClientFrame.ts +19 -0
  206. package/src/lib/server/sockets/types/SocketOperation.ts +22 -0
  207. package/src/lib/server/sockets/types/SocketOptions.ts +26 -0
  208. package/src/lib/server/sockets/types/SocketRegistryEntry.ts +19 -0
  209. package/src/lib/server/sockets/types/SocketRoutes.ts +10 -0
  210. package/src/lib/server/sockets/types/SocketServerFrame.ts +24 -0
  211. package/src/lib/server/sse.ts +54 -0
  212. package/src/lib/shared/ABIDE_PACKAGE_NAME.ts +7 -0
  213. package/src/lib/shared/ABIDE_VERSION.ts +9 -0
  214. package/src/lib/shared/CACHE_CONTROL_VALUES.ts +16 -0
  215. package/src/lib/shared/CACHE_WRAPPED.ts +8 -0
  216. package/src/lib/shared/CLI_PATH.ts +7 -0
  217. package/src/lib/shared/DEV_HOT_PREFIX.ts +7 -0
  218. package/src/lib/shared/DEV_RELOAD_PATH.ts +6 -0
  219. package/src/lib/shared/HEALTH_PATH.ts +7 -0
  220. package/src/lib/shared/HttpError.ts +20 -0
  221. package/src/lib/shared/IDENTITY_PATH.ts +6 -0
  222. package/src/lib/shared/INSPECTOR_PATH.ts +7 -0
  223. package/src/lib/shared/NAV_HEADER.ts +8 -0
  224. package/src/lib/shared/OFFLINE_HEADER.ts +8 -0
  225. package/src/lib/shared/REMOTE_FUNCTION.ts +8 -0
  226. package/src/lib/shared/REPLAYABLE_METHODS.ts +12 -0
  227. package/src/lib/shared/SOCKETS_PATH.ts +7 -0
  228. package/src/lib/shared/STREAMING_CONTENT_TYPES.ts +11 -0
  229. package/src/lib/shared/SocketDisconnectedError.ts +13 -0
  230. package/src/lib/shared/TEXT_PLAIN.ts +7 -0
  231. package/src/lib/shared/abideImportName.ts +44 -0
  232. package/src/lib/shared/abideLog.ts +38 -0
  233. package/src/lib/shared/activeCacheStore.ts +20 -0
  234. package/src/lib/shared/activePage.ts +25 -0
  235. package/src/lib/shared/appDataDir.ts +34 -0
  236. package/src/lib/shared/appNameSlot.ts +10 -0
  237. package/src/lib/shared/basePath.ts +10 -0
  238. package/src/lib/shared/basePathFromAppUrl.ts +20 -0
  239. package/src/lib/shared/baseSlot.ts +14 -0
  240. package/src/lib/shared/binaryDirEnvPath.ts +12 -0
  241. package/src/lib/shared/browserClientFlags.ts +10 -0
  242. package/src/lib/shared/buildRpcProxy.ts +39 -0
  243. package/src/lib/shared/buildRpcRequest.ts +70 -0
  244. package/src/lib/shared/buildSocketOverChannel.ts +58 -0
  245. package/src/lib/shared/bundleLayout.ts +36 -0
  246. package/src/lib/shared/cache.ts +951 -0
  247. package/src/lib/shared/cacheEntryFromSnapshot.ts +59 -0
  248. package/src/lib/shared/cacheStoreSlot.ts +16 -0
  249. package/src/lib/shared/cacheStores.ts +10 -0
  250. package/src/lib/shared/canonicalJson.ts +63 -0
  251. package/src/lib/shared/carriesBodyArgs.ts +13 -0
  252. package/src/lib/shared/clearLastConnection.ts +7 -0
  253. package/src/lib/shared/commandNameForUrl.ts +17 -0
  254. package/src/lib/shared/createCacheStore.ts +104 -0
  255. package/src/lib/shared/createChannelLog.ts +122 -0
  256. package/src/lib/shared/createLifecycleChannel.ts +56 -0
  257. package/src/lib/shared/createLivenessWatch.ts +118 -0
  258. package/src/lib/shared/createPushIterator.ts +127 -0
  259. package/src/lib/shared/createRemoteFunction.ts +122 -0
  260. package/src/lib/shared/createSubscriber.ts +55 -0
  261. package/src/lib/shared/createTraceContext.ts +21 -0
  262. package/src/lib/shared/dataDirEnvPath.ts +12 -0
  263. package/src/lib/shared/decodeResponse.ts +47 -0
  264. package/src/lib/shared/detectTarget.ts +27 -0
  265. package/src/lib/shared/detectVerbMethod.ts +17 -0
  266. package/src/lib/shared/emitLogRecord.ts +190 -0
  267. package/src/lib/shared/exeSuffix.ts +9 -0
  268. package/src/lib/shared/exitOnBuildFailure.ts +17 -0
  269. package/src/lib/shared/extraForwardHeaders.ts +16 -0
  270. package/src/lib/shared/fileStem.ts +9 -0
  271. package/src/lib/shared/findExportCallSite.ts +476 -0
  272. package/src/lib/shared/formatTraceparent.ts +6 -0
  273. package/src/lib/shared/forwardHeaders.ts +44 -0
  274. package/src/lib/shared/getRemoteMeta.ts +5 -0
  275. package/src/lib/shared/globalCacheStore.ts +15 -0
  276. package/src/lib/shared/globalCacheStoreSlot.ts +14 -0
  277. package/src/lib/shared/health.ts +179 -0
  278. package/src/lib/shared/healthReadSlot.ts +11 -0
  279. package/src/lib/shared/healthSeedSlot.ts +12 -0
  280. package/src/lib/shared/html.ts +38 -0
  281. package/src/lib/shared/importNamesToStrip.ts +13 -0
  282. package/src/lib/shared/invalidateEvent.ts +11 -0
  283. package/src/lib/shared/invalidateTripwire.ts +40 -0
  284. package/src/lib/shared/isAbideHealthPayload.ts +11 -0
  285. package/src/lib/shared/isCompileTarget.ts +15 -0
  286. package/src/lib/shared/isDebugEnabled.ts +26 -0
  287. package/src/lib/shared/isDebugNegated.ts +19 -0
  288. package/src/lib/shared/isModuleNotFound.ts +16 -0
  289. package/src/lib/shared/isReadOnlyMethod.ts +14 -0
  290. package/src/lib/shared/isReplayableMethod.ts +7 -0
  291. package/src/lib/shared/isStreamingResponse.ts +11 -0
  292. package/src/lib/shared/isSubscribable.ts +15 -0
  293. package/src/lib/shared/jsonSchemaForPromptArguments.ts +29 -0
  294. package/src/lib/shared/jsonSchemaForSchema.ts +39 -0
  295. package/src/lib/shared/jsonlErrorFrame.ts +24 -0
  296. package/src/lib/shared/keyForRemoteCall.ts +29 -0
  297. package/src/lib/shared/keyMatchesPrefix.ts +9 -0
  298. package/src/lib/shared/lastConnectionPath.ts +7 -0
  299. package/src/lib/shared/layoutChainForRoute.ts +22 -0
  300. package/src/lib/shared/loadEnvFile.ts +17 -0
  301. package/src/lib/shared/loadEnvFromDataDir.ts +14 -0
  302. package/src/lib/shared/log.ts +24 -0
  303. package/src/lib/shared/logClosingRecord.ts +28 -0
  304. package/src/lib/shared/logTapSlot.ts +13 -0
  305. package/src/lib/shared/manifestModule.ts +39 -0
  306. package/src/lib/shared/matchesDebugPattern.ts +16 -0
  307. package/src/lib/shared/memoizeByKey.ts +32 -0
  308. package/src/lib/shared/normalizeTarget.ts +10 -0
  309. package/src/lib/shared/online.ts +51 -0
  310. package/src/lib/shared/page.ts +30 -0
  311. package/src/lib/shared/pageSlot.ts +17 -0
  312. package/src/lib/shared/pageUrlForFile.ts +14 -0
  313. package/src/lib/shared/parseBoundedEnvInt.ts +20 -0
  314. package/src/lib/shared/parseDebugPatterns.ts +21 -0
  315. package/src/lib/shared/parseEnv.ts +30 -0
  316. package/src/lib/shared/parsePromptMarkdown.ts +35 -0
  317. package/src/lib/shared/parseRouteSegments.ts +22 -0
  318. package/src/lib/shared/parseTraceparent.ts +26 -0
  319. package/src/lib/shared/pending.ts +30 -0
  320. package/src/lib/shared/prepareRpcModule.ts +59 -0
  321. package/src/lib/shared/prepareSocketModule.ts +49 -0
  322. package/src/lib/shared/probeRegistries.ts +68 -0
  323. package/src/lib/shared/producerKey.ts +32 -0
  324. package/src/lib/shared/programNameForPackage.ts +14 -0
  325. package/src/lib/shared/promptNameForFile.ts +10 -0
  326. package/src/lib/shared/queryStringFromArgs.ts +27 -0
  327. package/src/lib/shared/randomHexId.ts +14 -0
  328. package/src/lib/shared/readEnvFile.ts +15 -0
  329. package/src/lib/shared/readLastConnection.ts +18 -0
  330. package/src/lib/shared/readPackageJson.ts +9 -0
  331. package/src/lib/shared/recordRemoteMeta.ts +5 -0
  332. package/src/lib/shared/refreshing.ts +31 -0
  333. package/src/lib/shared/remoteMetaStore.ts +16 -0
  334. package/src/lib/shared/requestScopeSlot.ts +15 -0
  335. package/src/lib/shared/resolveClientFlags.ts +20 -0
  336. package/src/lib/shared/responseErrorText.ts +9 -0
  337. package/src/lib/shared/rpcTimeoutSlot.ts +9 -0
  338. package/src/lib/shared/rpcUrlForFile.ts +19 -0
  339. package/src/lib/shared/runningAsStandaloneBinary.ts +13 -0
  340. package/src/lib/shared/selectorMatcher.ts +68 -0
  341. package/src/lib/shared/selectorPrefix.ts +39 -0
  342. package/src/lib/shared/serializeEnv.ts +18 -0
  343. package/src/lib/shared/setAppName.ts +5 -0
  344. package/src/lib/shared/setBaseResolver.ts +6 -0
  345. package/src/lib/shared/setCacheStoreResolver.ts +6 -0
  346. package/src/lib/shared/setGlobalCacheStoreResolver.ts +6 -0
  347. package/src/lib/shared/setPageResolver.ts +7 -0
  348. package/src/lib/shared/setRequestScopeResolver.ts +6 -0
  349. package/src/lib/shared/snippet.ts +25 -0
  350. package/src/lib/shared/socketNameForFile.ts +11 -0
  351. package/src/lib/shared/socketTapSlot.ts +12 -0
  352. package/src/lib/shared/sseErrorFrame.ts +29 -0
  353. package/src/lib/shared/streamResponse.ts +169 -0
  354. package/src/lib/shared/stripImport.ts +27 -0
  355. package/src/lib/shared/subscribableFromResponse.ts +51 -0
  356. package/src/lib/shared/tailProbeSlot.ts +16 -0
  357. package/src/lib/shared/toBunRoutePattern.ts +28 -0
  358. package/src/lib/shared/toScopeSet.ts +4 -0
  359. package/src/lib/shared/trace.ts +16 -0
  360. package/src/lib/shared/types/CacheEntry.ts +84 -0
  361. package/src/lib/shared/types/CacheInvalidation.ts +9 -0
  362. package/src/lib/shared/types/CacheOnContext.ts +25 -0
  363. package/src/lib/shared/types/CacheOptions.ts +39 -0
  364. package/src/lib/shared/types/CacheSelector.ts +17 -0
  365. package/src/lib/shared/types/CacheSnapshot.ts +16 -0
  366. package/src/lib/shared/types/CacheSnapshotEntry.ts +17 -0
  367. package/src/lib/shared/types/CacheStats.ts +13 -0
  368. package/src/lib/shared/types/CacheStore.ts +39 -0
  369. package/src/lib/shared/types/ChannelLog.ts +13 -0
  370. package/src/lib/shared/types/ClientFlags.ts +11 -0
  371. package/src/lib/shared/types/CompileTarget.ts +6 -0
  372. package/src/lib/shared/types/FrameworkLog.ts +13 -0
  373. package/src/lib/shared/types/HttpVerb.ts +1 -0
  374. package/src/lib/shared/types/LastConnection.ts +9 -0
  375. package/src/lib/shared/types/Log.ts +13 -0
  376. package/src/lib/shared/types/LogRecord.ts +42 -0
  377. package/src/lib/shared/types/LogVoice.ts +7 -0
  378. package/src/lib/shared/types/PageSnapshot.ts +14 -0
  379. package/src/lib/shared/types/PromptArgument.ts +12 -0
  380. package/src/lib/shared/types/RawRemoteFunction.ts +14 -0
  381. package/src/lib/shared/types/RemoteCallable.ts +12 -0
  382. package/src/lib/shared/types/RemoteFunction.ts +47 -0
  383. package/src/lib/shared/types/ReplayableMethod.ts +7 -0
  384. package/src/lib/shared/types/RequestScopeInfo.ts +16 -0
  385. package/src/lib/shared/types/RpcInvoker.ts +6 -0
  386. package/src/lib/shared/types/SocketChannel.ts +17 -0
  387. package/src/lib/shared/types/SocketSubCallbacks.ts +13 -0
  388. package/src/lib/shared/types/StandardSchemaV1.ts +56 -0
  389. package/src/lib/shared/types/StreamedResolution.ts +10 -0
  390. package/src/lib/shared/types/Subscribable.ts +26 -0
  391. package/src/lib/shared/types/TailHooks.ts +12 -0
  392. package/src/lib/shared/types/TailOptions.ts +10 -0
  393. package/src/lib/shared/types/TraceContext.ts +17 -0
  394. package/src/lib/shared/url.ts +118 -0
  395. package/src/lib/shared/withBase.ts +11 -0
  396. package/src/lib/shared/withBaseUrl.ts +17 -0
  397. package/src/lib/shared/withJsonSchema.ts +21 -0
  398. package/src/lib/shared/writeDts.ts +12 -0
  399. package/src/lib/shared/writeHealthDts.ts +36 -0
  400. package/src/lib/shared/writeLastConnection.ts +13 -0
  401. package/src/lib/shared/writePublicAssetsDts.ts +31 -0
  402. package/src/lib/shared/writeRoutesDts.ts +73 -0
  403. package/src/lib/shared/writeRpcDts.ts +49 -0
  404. package/src/lib/shared/writeTestRpcDts.ts +45 -0
  405. package/src/lib/shared/writeTestSocketsDts.ts +34 -0
  406. package/src/lib/test/assertAgentFrameConformance.ts +73 -0
  407. package/src/lib/test/createScriptedSurface.ts +45 -0
  408. package/src/lib/test/createTestApp.ts +203 -0
  409. package/src/lib/test/createTestSocketChannel.ts +142 -0
  410. package/src/lib/ui/README.md +86 -0
  411. package/src/lib/ui/compile/SSR_ESCAPE.ts +25 -0
  412. package/src/lib/ui/compile/UI_RUNTIME_IMPORTS.ts +36 -0
  413. package/src/lib/ui/compile/VOID_TAGS.ts +21 -0
  414. package/src/lib/ui/compile/abideUiPlugin.ts +65 -0
  415. package/src/lib/ui/compile/analyzeComponent.ts +117 -0
  416. package/src/lib/ui/compile/assetModulesFile.ts +32 -0
  417. package/src/lib/ui/compile/branchElements.ts +50 -0
  418. package/src/lib/ui/compile/collectAbideDiagnostics.ts +59 -0
  419. package/src/lib/ui/compile/compileComponent.ts +20 -0
  420. package/src/lib/ui/compile/compileModule.ts +116 -0
  421. package/src/lib/ui/compile/compileSSR.ts +36 -0
  422. package/src/lib/ui/compile/compileShadow.ts +352 -0
  423. package/src/lib/ui/compile/createShadowLanguageService.ts +197 -0
  424. package/src/lib/ui/compile/createShadowProgram.ts +96 -0
  425. package/src/lib/ui/compile/decodeHtmlEntities.ts +49 -0
  426. package/src/lib/ui/compile/desugarSignals.ts +133 -0
  427. package/src/lib/ui/compile/escapeHtml.ts +15 -0
  428. package/src/lib/ui/compile/generateBuild.ts +638 -0
  429. package/src/lib/ui/compile/generateSSR.ts +380 -0
  430. package/src/lib/ui/compile/groupBindParts.ts +28 -0
  431. package/src/lib/ui/compile/hoistCells.ts +120 -0
  432. package/src/lib/ui/compile/loadShadowTsConfig.ts +31 -0
  433. package/src/lib/ui/compile/lowerDocAccess.ts +202 -0
  434. package/src/lib/ui/compile/nearestProjectRoot.ts +16 -0
  435. package/src/lib/ui/compile/parseTemplate.ts +396 -0
  436. package/src/lib/ui/compile/partitionSlots.ts +36 -0
  437. package/src/lib/ui/compile/prepareNestedScript.ts +42 -0
  438. package/src/lib/ui/compile/remapShadowDiagnostic.ts +30 -0
  439. package/src/lib/ui/compile/renameSignalRefs.ts +85 -0
  440. package/src/lib/ui/compile/resolveAbideImports.ts +29 -0
  441. package/src/lib/ui/compile/scopeCss.ts +115 -0
  442. package/src/lib/ui/compile/shadowNaming.ts +11 -0
  443. package/src/lib/ui/compile/sourceToShadowOffset.ts +24 -0
  444. package/src/lib/ui/compile/staticAttrValue.ts +13 -0
  445. package/src/lib/ui/compile/stripEffects.ts +32 -0
  446. package/src/lib/ui/compile/types/AbideDiagnostic.ts +14 -0
  447. package/src/lib/ui/compile/types/AnalyzedComponent.ts +25 -0
  448. package/src/lib/ui/compile/types/CompiledShadow.ts +15 -0
  449. package/src/lib/ui/compile/types/TemplateAttr.ts +16 -0
  450. package/src/lib/ui/compile/types/TemplateNode.ts +78 -0
  451. package/src/lib/ui/compile/types/TextPart.ts +8 -0
  452. package/src/lib/ui/derived.ts +28 -0
  453. package/src/lib/ui/doc.ts +15 -0
  454. package/src/lib/ui/dom/appendSnippet.ts +34 -0
  455. package/src/lib/ui/dom/appendStatic.ts +27 -0
  456. package/src/lib/ui/dom/appendText.ts +114 -0
  457. package/src/lib/ui/dom/applyResolved.ts +72 -0
  458. package/src/lib/ui/dom/attach.ts +20 -0
  459. package/src/lib/ui/dom/attr.ts +19 -0
  460. package/src/lib/ui/dom/awaitBlock.ts +224 -0
  461. package/src/lib/ui/dom/cloneStatic.ts +52 -0
  462. package/src/lib/ui/dom/each.ts +115 -0
  463. package/src/lib/ui/dom/eachAsync.ts +153 -0
  464. package/src/lib/ui/dom/hydrate.ts +35 -0
  465. package/src/lib/ui/dom/mount.ts +29 -0
  466. package/src/lib/ui/dom/mountChild.ts +33 -0
  467. package/src/lib/ui/dom/on.ts +15 -0
  468. package/src/lib/ui/dom/openChild.ts +22 -0
  469. package/src/lib/ui/dom/openRoot.ts +20 -0
  470. package/src/lib/ui/dom/switchBlock.ts +75 -0
  471. package/src/lib/ui/dom/text.ts +20 -0
  472. package/src/lib/ui/dom/tryBlock.ts +112 -0
  473. package/src/lib/ui/dom/types/EachRow.ts +3 -0
  474. package/src/lib/ui/dom/types/SwitchCase.ts +6 -0
  475. package/src/lib/ui/dom/when.ts +73 -0
  476. package/src/lib/ui/effect.ts +16 -0
  477. package/src/lib/ui/installHotBridge.ts +73 -0
  478. package/src/lib/ui/matchRoute.ts +89 -0
  479. package/src/lib/ui/navigate.ts +17 -0
  480. package/src/lib/ui/probeNavigation.ts +33 -0
  481. package/src/lib/ui/remoteProxy.ts +97 -0
  482. package/src/lib/ui/renderChain.ts +50 -0
  483. package/src/lib/ui/renderToStream.ts +104 -0
  484. package/src/lib/ui/router.ts +286 -0
  485. package/src/lib/ui/runtime/OUTLET_TAG.ts +8 -0
  486. package/src/lib/ui/runtime/OWNER.ts +8 -0
  487. package/src/lib/ui/runtime/REACTIVE_CONTEXT.ts +14 -0
  488. package/src/lib/ui/runtime/RENDER.ts +23 -0
  489. package/src/lib/ui/runtime/RESUME.ts +16 -0
  490. package/src/lib/ui/runtime/applyPatchToTree.ts +41 -0
  491. package/src/lib/ui/runtime/claimChild.ts +10 -0
  492. package/src/lib/ui/runtime/clientPage.ts +16 -0
  493. package/src/lib/ui/runtime/createComputedNode.ts +16 -0
  494. package/src/lib/ui/runtime/createDoc.ts +177 -0
  495. package/src/lib/ui/runtime/createEffectNode.ts +58 -0
  496. package/src/lib/ui/runtime/createSignalNode.ts +16 -0
  497. package/src/lib/ui/runtime/detachLink.ts +21 -0
  498. package/src/lib/ui/runtime/endTracking.ts +24 -0
  499. package/src/lib/ui/runtime/enterRenderPass.ts +12 -0
  500. package/src/lib/ui/runtime/exitRenderPass.ts +7 -0
  501. package/src/lib/ui/runtime/firstOutlet.ts +22 -0
  502. package/src/lib/ui/runtime/flushEffects.ts +17 -0
  503. package/src/lib/ui/runtime/hotInstances.ts +10 -0
  504. package/src/lib/ui/runtime/hotReloadEnabled.ts +8 -0
  505. package/src/lib/ui/runtime/hotReplace.ts +25 -0
  506. package/src/lib/ui/runtime/nextBlockId.ts +11 -0
  507. package/src/lib/ui/runtime/pathExists.ts +23 -0
  508. package/src/lib/ui/runtime/readNode.ts +17 -0
  509. package/src/lib/ui/runtime/registerHotInstance.ts +23 -0
  510. package/src/lib/ui/runtime/runNode.ts +28 -0
  511. package/src/lib/ui/runtime/runtimePath.ts +9 -0
  512. package/src/lib/ui/runtime/scope.ts +24 -0
  513. package/src/lib/ui/runtime/toTeardown.ts +26 -0
  514. package/src/lib/ui/runtime/track.ts +58 -0
  515. package/src/lib/ui/runtime/trigger.ts +44 -0
  516. package/src/lib/ui/runtime/types/Cell.ts +5 -0
  517. package/src/lib/ui/runtime/types/Derived.ts +3 -0
  518. package/src/lib/ui/runtime/types/Doc.ts +19 -0
  519. package/src/lib/ui/runtime/types/EffectResult.ts +10 -0
  520. package/src/lib/ui/runtime/types/HotInstance.ts +14 -0
  521. package/src/lib/ui/runtime/types/NavVerdict.ts +9 -0
  522. package/src/lib/ui/runtime/types/Patch.ts +11 -0
  523. package/src/lib/ui/runtime/types/ReactiveLink.ts +21 -0
  524. package/src/lib/ui/runtime/types/ReactiveNode.ts +25 -0
  525. package/src/lib/ui/runtime/types/Route.ts +8 -0
  526. package/src/lib/ui/runtime/types/RouteLoader.ts +7 -0
  527. package/src/lib/ui/runtime/types/SsrRender.ts +22 -0
  528. package/src/lib/ui/runtime/types/State.ts +3 -0
  529. package/src/lib/ui/runtime/types/Teardown.ts +5 -0
  530. package/src/lib/ui/runtime/types/UiComponent.ts +16 -0
  531. package/src/lib/ui/runtime/types/UiProps.ts +15 -0
  532. package/src/lib/ui/runtime/unlinkDeps.ts +20 -0
  533. package/src/lib/ui/runtime/untrack.ts +20 -0
  534. package/src/lib/ui/runtime/valueAtPath.ts +18 -0
  535. package/src/lib/ui/runtime/writeNode.ts +16 -0
  536. package/src/lib/ui/socketChannel.ts +227 -0
  537. package/src/lib/ui/socketProxy.ts +25 -0
  538. package/src/lib/ui/startClient.ts +58 -0
  539. package/src/lib/ui/state.ts +25 -0
  540. package/src/lib/ui/tail.ts +324 -0
  541. package/src/lib/ui/types/Layouts.ts +9 -0
  542. package/src/lib/ui/types/Pages.ts +8 -0
  543. package/src/preload.ts +19 -0
  544. package/src/scaffold.ts +153 -0
  545. package/src/serverBuildPlugins.ts +19 -0
  546. package/src/serverEntry.ts +95 -0
  547. package/template/bunfig.toml +4 -0
  548. package/template/package.json +18 -0
  549. package/template/src/app.ts +28 -0
  550. package/template/src/bundle/icon.png +0 -0
  551. package/template/src/cli/banner.txt +3 -0
  552. package/template/src/cli/footer.txt +1 -0
  553. package/template/src/server/config.ts +17 -0
  554. package/template/src/server/rpc/getHello.ts +36 -0
  555. package/template/src/ui/Layout.abide +19 -0
  556. package/template/src/ui/app.css +21 -0
  557. package/template/src/ui/app.html +24 -0
  558. package/template/src/ui/pages/about/page.abide +9 -0
  559. package/template/src/ui/pages/page.abide +22 -0
  560. package/template/test/app.test.ts +30 -0
  561. package/template/tsconfig.json +18 -0
  562. package/tsconfig.app.json +17 -0
@@ -0,0 +1,27 @@
1
+ import type { TypedResponse } from './TypedResponse.ts'
2
+
3
+ /*
4
+ Handler signature for verb-defined remote functions. Args is `undefined` for
5
+ GETs/DELETEs with no query, JSON-shaped objects for json bodies, and
6
+ form-shaped objects for form-encoded bodies. For a multipart upload it's the
7
+ text fields (`inputSchema`) intersected with the validated File parts
8
+ (`filesSchema`), merged into one bag. For a raw binary body Args is `undefined`
9
+ — read the stream via `request()` from `abide/server` instead.
10
+
11
+ Return is the value type the call site sees after Content-Type-driven
12
+ decoding (a parsed object for JSON, a string for text/*, a Blob otherwise,
13
+ `undefined` for 204). The handler must return a Response at runtime; the
14
+ `TypedResponse<Return>` brand on `json`/`error`/`redirect`/`jsonl`/`sse`
15
+ carries the body shape through the function's inferred return type so the
16
+ verb helper can infer `Return` automatically — no need to annotate
17
+ `GET<Args, Return>` when the handler returns one of the respond helpers.
18
+ A bare `new Response(...)` is still acceptable: the brand is optional, so
19
+ untagged Responses fall back to `Return = unknown`.
20
+
21
+ Handlers that need the inbound Request (headers, `request.signal`, …) read
22
+ it via `request()` from `abide/server` rather than a handler parameter, so
23
+ the signature stays a single parsed-`args` bag.
24
+ */
25
+ export type RemoteHandler<Args, Return> = (
26
+ args: Args,
27
+ ) => TypedResponse<Return> | Promise<TypedResponse<Return>>
@@ -0,0 +1,13 @@
1
+ import type { RemoteFunction } from '../../../shared/types/RemoteFunction.ts'
2
+
3
+ /*
4
+ Manifest of RPC URL → module loader. Produced by the resolver plugin from
5
+ every `.ts` under src/server/rpc — each file maps to one URL (derived from its
6
+ path under `$rpc`, prefixed with `/rpc/`). Each module has exactly one
7
+ named export, a RemoteFunction whose `.method` and `.url` were stamped in
8
+ by the bundler rewrite.
9
+ */
10
+ export type RemoteRoutes = Record<
11
+ string,
12
+ () => Promise<Record<string, RemoteFunction<unknown, unknown>>>
13
+ >
@@ -0,0 +1,18 @@
1
+ /*
2
+ A `Response` tagged with the body type the framework will hand back to
3
+ callers after Content-Type-driven decoding. The tag is phantom — it
4
+ adds no runtime field, only a type-level slot so the verb helpers can
5
+ infer `Return` from the handler's return type instead of forcing every
6
+ route to annotate it via `GET<Args, Return>`.
7
+
8
+ The respond helpers (`json<T>`, `error`, `redirect`, `jsonl<F>`,
9
+ `sse<F>`) all return a `TypedResponse<T>`, so a handler ending in
10
+ `return json({ user })` exposes `{ user: ... }` as its body type; the
11
+ verb overload picks it up via `RemoteHandler<Args, Return>`.
12
+
13
+ `T` is optional on the brand so a plain `new Response(...)` (untagged)
14
+ remains assignable to `TypedResponse<unknown>`; in that case `Return`
15
+ just falls back to its `unknown` default, matching pre-existing
16
+ behaviour for handlers that build Responses by hand.
17
+ */
18
+ export type TypedResponse<T> = Response & { readonly __body?: T }
@@ -0,0 +1,87 @@
1
+ import type { ClientFlags } from '../../../shared/types/ClientFlags.ts'
2
+ import type { RemoteFunction } from '../../../shared/types/RemoteFunction.ts'
3
+ import type { StandardSchemaV1 } from '../../../shared/types/StandardSchemaV1.ts'
4
+ import type { RemoteHandler } from './RemoteHandler.ts'
5
+
6
+ /*
7
+ Shared signature for every verb helper (GET / POST / …). Three overloads:
8
+
9
+ - `Verb(fn, { inputSchema, outputSchema?, clients? })` — `Args` infers
10
+ from `InferInput<InputSchema>`, the handler receives
11
+ `InferOutput<InputSchema>`. Generic order is `<Return, InputSchema>` so
12
+ users can override `Return` while letting `InputSchema` infer from
13
+ `opts.inputSchema`. `outputSchema` is an optional Standard Schema for
14
+ the success body — it feeds the OpenAPI 200 response and the MCP tool
15
+ `outputSchema`. JSON Schema is projected from each schema's own
16
+ `toJSONSchema()` (wrap with withJsonSchema if the library lacks one).
17
+ `clients` controls which surfaces (browser / mcp / cli) expose this verb.
18
+ `crossOrigin: true` exempts a mutating verb from the router's same-origin
19
+ CSRF gate — by default a browser request whose Origin doesn't match the
20
+ app's own host is refused with 403 on every non-GET/HEAD verb.
21
+ `maxBodySize` caps the body's actual received bytes (413 past it),
22
+ enforced before parsing; omitted, the only ceiling is Bun.serve's
23
+ server-wide maxRequestBodySize. `timeout` (ms) bounds the handler's
24
+ execution on every surface (SSR / MCP / CLI / network) — a 504 once
25
+ exceeded; on the network path it also aborts request().signal so a
26
+ handler's `fetch(ext, { signal: request().signal })` is cancelled, not
27
+ just abandoned.
28
+ - `Verb(fn, { clients })` — schemaless but with explicit client
29
+ targeting (e.g. server-internal RPC with `clients: { browser: false }`).
30
+ - `Verb(fn)` — bare handler. `Args` and `Return` come from the handler
31
+ type; `Return` is usually inferred via the `TypedResponse<T>` brand on
32
+ `json`/`error`/`redirect`/`jsonl`/`sse`.
33
+ */
34
+ export type VerbHelper = {
35
+ /*
36
+ `Verb(fn, { inputSchema, filesSchema, … })` — multipart upload. The
37
+ handler receives the text fields (`InferOutput<InputSchema>`) intersected
38
+ with the validated File parts (`InferOutput<FilesSchema>`); both are merged
39
+ into one args bag. The call site sends a FormData (RemoteFunction's call
40
+ accepts it), since a File can't ride a JSON body. filesSchema stays off the
41
+ JSON-Schema projection — a File has no honest conversion (see
42
+ jsonSchemaForSchema) — so only inputSchema feeds MCP/CLI/OpenAPI.
43
+ */
44
+ <
45
+ Return = unknown,
46
+ InputSchema extends StandardSchemaV1 = StandardSchemaV1,
47
+ FilesSchema extends StandardSchemaV1 = StandardSchemaV1,
48
+ >(
49
+ fn: RemoteHandler<
50
+ StandardSchemaV1.InferOutput<InputSchema> & StandardSchemaV1.InferOutput<FilesSchema>,
51
+ Return
52
+ >,
53
+ opts: {
54
+ inputSchema: InputSchema
55
+ filesSchema: FilesSchema
56
+ outputSchema?: StandardSchemaV1
57
+ clients?: Partial<ClientFlags>
58
+ crossOrigin?: boolean
59
+ maxBodySize?: number
60
+ timeout?: number
61
+ },
62
+ ): RemoteFunction<StandardSchemaV1.InferInput<InputSchema>, Return>
63
+ <Return = unknown, InputSchema extends StandardSchemaV1 = StandardSchemaV1>(
64
+ fn: RemoteHandler<StandardSchemaV1.InferOutput<InputSchema>, Return>,
65
+ opts: {
66
+ inputSchema: InputSchema
67
+ outputSchema?: StandardSchemaV1
68
+ clients?: Partial<ClientFlags>
69
+ crossOrigin?: boolean
70
+ maxBodySize?: number
71
+ timeout?: number
72
+ },
73
+ ): RemoteFunction<StandardSchemaV1.InferInput<InputSchema>, Return>
74
+ <Args = undefined, Return = unknown>(
75
+ fn: RemoteHandler<Args, Return>,
76
+ opts: {
77
+ outputSchema?: StandardSchemaV1
78
+ clients?: Partial<ClientFlags>
79
+ crossOrigin?: boolean
80
+ maxBodySize?: number
81
+ timeout?: number
82
+ },
83
+ ): RemoteFunction<Args, Return>
84
+ <Args = undefined, Return = unknown>(
85
+ fn: RemoteHandler<Args, Return>,
86
+ ): RemoteFunction<Args, Return>
87
+ }
@@ -0,0 +1,35 @@
1
+ import type { ClientFlags } from '../../../shared/types/ClientFlags.ts'
2
+ import type { RemoteFunction } from '../../../shared/types/RemoteFunction.ts'
3
+ import type { StandardSchemaV1 } from '../../../shared/types/StandardSchemaV1.ts'
4
+
5
+ /*
6
+ Per-verb registry record on the server side. MCP and CLI enumerate this
7
+ to discover which RPCs are advertised (clients flags) and what shapes
8
+ they expect/return. The schemas and resolved clients stay off the public
9
+ RemoteFunction shape so the browser-side proxy doesn't need to carry
10
+ server-only state.
11
+
12
+ `inputSchema` validates the argument bag and feeds the MCP tool
13
+ `inputSchema` / OpenAPI parameters; `outputSchema` describes the success
14
+ body and feeds the OpenAPI 200 response + MCP tool `outputSchema`. Each
15
+ projects to JSON Schema via its own `toJSONSchema()` (jsonSchemaForSchema) —
16
+ schemas whose library lacks one are wrapped with withJsonSchema.
17
+
18
+ `filesSchema` validates the File parts of a multipart body, kept separate
19
+ from `inputSchema` because a File has no honest JSON-Schema conversion — it
20
+ stays out of the MCP/CLI projection that `inputSchema` feeds, and the OpenAPI
21
+ multipart body advertises the file parts generically as binary.
22
+ */
23
+ export type VerbRegistryEntry = {
24
+ remote: RemoteFunction<unknown, unknown>
25
+ inputSchema: StandardSchemaV1 | undefined
26
+ outputSchema: StandardSchemaV1 | undefined
27
+ filesSchema: StandardSchemaV1 | undefined
28
+ clients: ClientFlags
29
+ /* The verb's declared opts, recorded so introspection (inspector) can report
30
+ the deadline/body-cap/CSRF-exemption a handler runs under. Undefined = the
31
+ framework default (no deadline, Bun's server-wide body ceiling, gated). */
32
+ timeout: number | undefined
33
+ maxBodySize: number | undefined
34
+ crossOrigin: boolean | undefined
35
+ }
@@ -0,0 +1,14 @@
1
+ import type { RemoteFunction } from '../../shared/types/RemoteFunction.ts'
2
+
3
+ /*
4
+ Verb helpers (GET / POST / …) are placeholders — the bundler rewrites every
5
+ `export const x = GET(fn)` inside `src/server/rpc/<file>.ts` into a call to
6
+ defineVerb (server target) or remoteProxy (client target). If a call slips
7
+ through, the bundler plugin didn't process the file; throwing here surfaces
8
+ that cleanly instead of silently returning undefined.
9
+ */
10
+ export function unprocessed<Args, Return>(verb: string): RemoteFunction<Args, Return> {
11
+ throw new Error(
12
+ `[abide] \`${verb}\` was called outside an $rpc module — verb helpers are only valid as the value of \`export const <filename> = ...\` inside a file under src/server/rpc/`,
13
+ )
14
+ }
@@ -0,0 +1,11 @@
1
+ import type { VerbRegistryEntry } from './types/VerbRegistryEntry.ts'
2
+
3
+ /*
4
+ Process-wide registry of every verb-bound RPC declared in the app.
5
+ defineVerb inserts on first construction (which happens at module-load
6
+ time inside the rpc dispatcher cache or eagerly when MCP / CLI walks the
7
+ rpc manifest). MCP server reads this to build its tools list; the CLI
8
+ binary reads it to generate subcommands. The browser path never touches
9
+ this — the client stub has no schema or clients metadata to register.
10
+ */
11
+ export const verbRegistry = new Map<string, VerbRegistryEntry>()
@@ -0,0 +1,6 @@
1
+ /*
2
+ The port scanning starts from when no PORT is configured. Every selector (the
3
+ real listener, the embedded launcher, the dev orchestrator) scans upward from
4
+ here so all modes land on the same predictable 3000+ address.
5
+ */
6
+ export const DEFAULT_PORT = 3000
@@ -0,0 +1,6 @@
1
+ // IPC payload the dev server sends its orchestrator parent (via process.send)
2
+ // once its listener is up and init() has run. The orchestrator retires the
3
+ // previous worker only after this arrives — workers overlap on the dev port via
4
+ // reusePort, so the port never goes dark across a restart. Shared so producer
5
+ // (createServer) and consumer (devEntry) can't drift.
6
+ export const DEV_READY_MESSAGE = 'abide:ready'
@@ -0,0 +1,4 @@
1
+ // IPC payload the dev server sends its orchestrator parent (via process.send) to
2
+ // request a rebuild + restart. Shared so producer (createServer) and consumer
3
+ // (devEntry) can't drift.
4
+ export const DEV_REBUILD_MESSAGE = 'abide:reload'
@@ -0,0 +1,107 @@
1
+ /*
2
+ Dev-only live-reload client, injected into the served shell when the server
3
+ runs under `abide dev`. It opens an EventSource to /__abide/dev; each
4
+ connection's first event carries the worker's reload stamp — `{ structure,
5
+ cssHref }` (devClientFingerprint). The channel only drops when the dev
6
+ orchestrator swaps the server after a rebuild, and on reconnect:
7
+ - `structure` changed → reload (any non-CSS edit).
8
+ - only `cssHref` changed → swap the entry stylesheet's `<link>` in place,
9
+ so a CSS edit restyles the live page with no reload and no state loss.
10
+ - both equal (server-only edit) → keep the page alive.
11
+ Self-managed retry keeps the first reconnect fast (250ms) so a rebuild swap
12
+ recovers quickly, then backs off exponentially up to a 5s cap — a server that
13
+ stays down (dev stopped) settles to one attempt every 5s instead of flooding
14
+ the network, and still reconnects on its own if the server comes back. The
15
+ backoff resets once a connection opens.
16
+
17
+ Hidden tabs hold no connection: the channel closes on `visibilitychange:
18
+ hidden` and reopens on visible, where the reconnect's first event carries
19
+ whatever the current worker announces — a rebuild that happened while the tab
20
+ slept still reloads it. The initial connect runs even when the page loads
21
+ hidden (the baseline must be the serving worker's stamp, captured before a swap
22
+ can replace it) and releases itself once that first event lands.
23
+ */
24
+ import { DEV_HOT_PREFIX } from '../../shared/DEV_HOT_PREFIX.ts'
25
+ import { DEV_RELOAD_PATH } from '../../shared/DEV_RELOAD_PATH.ts'
26
+
27
+ export const DEV_RELOAD_CLIENT_SCRIPT = `<script>
28
+ window.__abideDev = true;
29
+ ;(() => {
30
+ let stamp
31
+ let source
32
+ let retryTimer
33
+ let retryDelay = 250
34
+ function disconnect() {
35
+ clearTimeout(retryTimer)
36
+ if (source) {
37
+ source.close()
38
+ source = undefined
39
+ }
40
+ }
41
+ function swapCss(href) {
42
+ const links = document.querySelectorAll('link[rel="stylesheet"]')
43
+ for (const link of links) {
44
+ const current = link.getAttribute('href') || ''
45
+ if (current.indexOf('/_app/') !== -1 && current.slice(-4) === '.css') {
46
+ link.href = href
47
+ return
48
+ }
49
+ }
50
+ }
51
+ function swapComponents(next, prev) {
52
+ const components = next.components || {}
53
+ const before = prev.components || {}
54
+ for (const id in components) {
55
+ if (components[id] !== before[id]) {
56
+ // The hot module sources its runtime from window.__abide and self-invokes
57
+ // hotReplace; a load/compile failure or a component with no live instance
58
+ // falls back to a reload.
59
+ import('${DEV_HOT_PREFIX}' + id + '?v=' + components[id]).catch(() => location.reload())
60
+ }
61
+ }
62
+ }
63
+ function connect() {
64
+ if (source) {
65
+ return
66
+ }
67
+ source = new EventSource('${DEV_RELOAD_PATH}')
68
+ source.onopen = () => {
69
+ retryDelay = 250
70
+ }
71
+ source.onmessage = (event) => {
72
+ const next = JSON.parse(event.data)
73
+ if (stamp === undefined) {
74
+ stamp = next
75
+ if (document.hidden) {
76
+ disconnect()
77
+ }
78
+ return
79
+ }
80
+ if (next.structure !== stamp.structure) {
81
+ location.reload()
82
+ return
83
+ }
84
+ if (next.cssHref && next.cssHref !== stamp.cssHref) {
85
+ swapCss(next.cssHref)
86
+ }
87
+ swapComponents(next, stamp)
88
+ stamp = next
89
+ }
90
+ source.onerror = () => {
91
+ disconnect()
92
+ if (!document.hidden) {
93
+ retryTimer = setTimeout(connect, retryDelay)
94
+ retryDelay = Math.min(retryDelay * 2, 5000)
95
+ }
96
+ }
97
+ }
98
+ document.addEventListener('visibilitychange', () => {
99
+ if (document.hidden) {
100
+ disconnect()
101
+ } else {
102
+ connect()
103
+ }
104
+ })
105
+ connect()
106
+ })()
107
+ </script>`
@@ -0,0 +1,16 @@
1
+ /*
2
+ The tiny inline script the abide-ui SSR stream ships in <head>. For each streamed
3
+ `<abide-resolve data-id data-resume>` frame it registers the resolved value into
4
+ `window.__abideResume` (the resume manifest hydration reads) and swaps the resolved
5
+ markup into the matching `<!--abide:await:ID-->…<!--/abide:await:ID-->` boundary —
6
+ so the pending shell paints instantly and each value lands as it arrives, before
7
+ the client bundle even loads. Vanilla and self-contained (no framework runtime),
8
+ minified to one line so it inlines cheaply ahead of the document body.
9
+ */
10
+ export const SSR_SWAP_SCRIPT =
11
+ "function __abideSwap(){var f=document.querySelector('abide-resolve');while(f){" +
12
+ "var id=f.getAttribute('data-id'),w=document.createTreeWalker(document.body,NodeFilter.SHOW_COMMENT),o=null,c;" +
13
+ "try{(window.__abideResume=window.__abideResume||{})[id]=JSON.parse(f.getAttribute('data-resume')||'null');}catch(e){}" +
14
+ "while((c=w.nextNode())){if(c.data==='abide:await:'+id){o=c;break;}}" +
15
+ "if(o){var n=o.nextSibling;while(n&&!(n.nodeType===8&&n.data==='/abide:await:'+id)){var x=n.nextSibling;n.remove();n=x;}" +
16
+ "while(f.firstChild){o.parentNode.insertBefore(f.firstChild,n);}}f.remove();f=document.querySelector('abide-resolve');}}"
@@ -0,0 +1,24 @@
1
+ /*
2
+ Whether the client advertised gzip in Accept-Encoding. The static-asset
3
+ servers and the dynamic-response gzip wrapper gate compressed output on this,
4
+ so the check lives in one place. Effectively always true for browsers and most
5
+ HTTP clients; a bare client that omits the header gets identity bytes.
6
+ */
7
+ export function acceptsGzip(req: Request): boolean {
8
+ const header = (req.headers.get('accept-encoding') ?? '').toLowerCase()
9
+ /*
10
+ Honour q-values: `gzip;q=0` is an explicit refusal even though the substring
11
+ is present. Find the gzip (or wildcard) directive and reject only when its
12
+ quality is zero.
13
+ */
14
+ const directives = header.split(',').map((part) => part.trim())
15
+ // An explicit gzip directive wins over the wildcard; fall back to `*` otherwise.
16
+ const directive =
17
+ directives.find((part) => part === 'gzip' || part.startsWith('gzip;')) ??
18
+ directives.find((part) => part === '*' || part.startsWith('*;'))
19
+ if (directive === undefined) {
20
+ return false
21
+ }
22
+ const quality = directive.match(/;\s*q=([\d.]+)/)
23
+ return quality === null || Number(quality[1]) > 0
24
+ }
@@ -0,0 +1,61 @@
1
+ import { globalCacheStore } from '../../shared/globalCacheStore.ts'
2
+ import type { CacheEntry } from '../../shared/types/CacheEntry.ts'
3
+ import type { InspectorCacheEntry } from './types/InspectorCacheEntry.ts'
4
+ import type { InspectorCacheSnapshot } from './types/InspectorCacheSnapshot.ts'
5
+
6
+ const PREVIEW_LIMIT = 200
7
+
8
+ /* A short JSON peek at a warm value, degrading non-serializable values to String. */
9
+ function preview(value: unknown): string | undefined {
10
+ if (value === undefined) {
11
+ return undefined
12
+ }
13
+ try {
14
+ const json = JSON.stringify(value)
15
+ return json.length > PREVIEW_LIMIT ? `${json.slice(0, PREVIEW_LIMIT)}…` : json
16
+ } catch {
17
+ return String(value)
18
+ }
19
+ }
20
+
21
+ /* The entry's armed invalidate policy as a label, if it declared one. */
22
+ function policyLabel(entry: CacheEntry): string | undefined {
23
+ const policy = entry.invalidation
24
+ if (!policy) {
25
+ return undefined
26
+ }
27
+ if (policy.debounce !== undefined) {
28
+ return `debounce ${policy.debounce}ms`
29
+ }
30
+ if (policy.throttle !== undefined) {
31
+ return `throttle ${policy.throttle}ms`
32
+ }
33
+ return undefined
34
+ }
35
+
36
+ function projectEntry(entry: CacheEntry, now: number): InspectorCacheEntry {
37
+ return {
38
+ key: entry.key,
39
+ status: entry.refreshing ? 'refreshing' : entry.settled ? 'settled' : 'in-flight',
40
+ remote: entry.request !== undefined,
41
+ ttl: entry.ttl,
42
+ expiresInMs: entry.expiresAt !== undefined ? entry.expiresAt - now : undefined,
43
+ scope: entry.scope ? [...entry.scope] : [],
44
+ value: preview(entry.value),
45
+ policy: policyLabel(entry),
46
+ }
47
+ }
48
+
49
+ /*
50
+ Snapshots the process-level cache store (the persistent one `cache(fn, { global:
51
+ true })` writes to) for the inspector. Read at call time, so it reflects the
52
+ store as it stands; request-scoped stores are deliberately excluded — they're
53
+ ephemeral and already visible as per-request cache tallies.
54
+ */
55
+ export function buildCacheSnapshot(): InspectorCacheSnapshot {
56
+ const now = Date.now()
57
+ const entries = Array.from(globalCacheStore().entries.values(), (entry) =>
58
+ projectEntry(entry, now),
59
+ )
60
+ return { entries }
61
+ }
@@ -0,0 +1,34 @@
1
+ import { ABIDE_VERSION } from '../../shared/ABIDE_VERSION.ts'
2
+ import { abideLog } from '../../shared/abideLog.ts'
3
+ import type { AppModule } from '../AppModule.ts'
4
+
5
+ /*
6
+ The canonical /__abide/health payload: the app health(request) hook's fields
7
+ under the framework identity keys, which win on collision. A thrown or
8
+ non-object hook degrades to no fields — an app bug must not masquerade as an
9
+ unreachable server, so the base payload always builds. Shared by the
10
+ health/identity routes and the SSR renderer's __SSR__.health seed so the
11
+ wire and the seed can't drift.
12
+ */
13
+ export async function buildHealthPayload(
14
+ request: Request,
15
+ opts: { app?: AppModule; appName: string; appVersion: string },
16
+ ): Promise<Record<string, unknown>> {
17
+ let fields: Record<string, unknown> = {}
18
+ if (opts.app?.health) {
19
+ try {
20
+ const result = await opts.app.health(request)
21
+ if (result && typeof result === 'object' && !Array.isArray(result)) {
22
+ fields = result as Record<string, unknown>
23
+ }
24
+ } catch (error) {
25
+ abideLog.error(error)
26
+ }
27
+ }
28
+ /*
29
+ `abide` carries the framework version — truthy for the probe check,
30
+ informative for skew diagnosis. The IDENTITY_PATH alias overrides it to
31
+ the legacy `abide: true` shape at its call site.
32
+ */
33
+ return { ...fields, abide: ABIDE_VERSION, name: opts.appName, version: opts.appVersion }
34
+ }
@@ -0,0 +1,37 @@
1
+ import { jsonSchemaForSchema } from '../../shared/jsonSchemaForSchema.ts'
2
+ import { verbRegistry } from '../rpc/verbRegistry.ts'
3
+ import { socketOperations } from '../sockets/socketOperations.ts'
4
+ import { socketRegistry } from '../sockets/socketRegistry.ts'
5
+ import type { InspectorSurface } from './types/InspectorSurface.ts'
6
+
7
+ /*
8
+ Projects the live verb + socket registries into the inspector's catalog. Read
9
+ at call time (not cached) so verbs constructed after boot — lazily on first
10
+ hit, or eagerly once ensureRegistriesLoaded walked the manifest — show up.
11
+ Schemas go through jsonSchemaForSchema, the same projection MCP and OpenAPI
12
+ use, so the three can't disagree on a verb's shape; a missing schema stays
13
+ undefined to mark a verb that carries no machine-advertisable contract.
14
+ */
15
+ export function buildInspectorSurface(): InspectorSurface {
16
+ const verbs = Array.from(verbRegistry.values()).map((entry) => ({
17
+ url: entry.remote.url,
18
+ method: entry.remote.method,
19
+ clients: { ...entry.remote.clients },
20
+ inputSchema: entry.inputSchema ? jsonSchemaForSchema(entry.inputSchema) : undefined,
21
+ outputSchema: entry.outputSchema ? jsonSchemaForSchema(entry.outputSchema) : undefined,
22
+ files: entry.filesSchema !== undefined,
23
+ timeout: entry.timeout,
24
+ maxBodySize: entry.maxBodySize,
25
+ crossOrigin: entry.crossOrigin,
26
+ }))
27
+ const sockets = Array.from(socketRegistry.values()).map((entry) => ({
28
+ name: entry.socket.name,
29
+ operations: socketOperations(entry).map((operation) => ({
30
+ kind: operation.kind,
31
+ name: operation.name,
32
+ method: operation.method,
33
+ restUrl: operation.restUrl,
34
+ })),
35
+ }))
36
+ return { verbs, sockets }
37
+ }
@@ -0,0 +1,106 @@
1
+ import { carriesBodyArgs } from '../../shared/carriesBodyArgs.ts'
2
+ import { commandNameForUrl } from '../../shared/commandNameForUrl.ts'
3
+ import { jsonSchemaForSchema } from '../../shared/jsonSchemaForSchema.ts'
4
+ import { verbRegistry } from '../rpc/verbRegistry.ts'
5
+
6
+ /*
7
+ Turns a verb's resolved JSON Schema into OpenAPI query parameters — one
8
+ per top-level property, marked required when the schema lists it. Used
9
+ for GET/DELETE/HEAD operations, which carry their args on the query
10
+ string (mirroring buildRpcRequest).
11
+ */
12
+ function queryParameters(jsonSchema: Record<string, unknown>): Array<Record<string, unknown>> {
13
+ const properties = jsonSchema.properties as Record<string, unknown> | undefined
14
+ if (!properties) {
15
+ return []
16
+ }
17
+ const required = new Set((jsonSchema.required as string[] | undefined) ?? [])
18
+ return Object.entries(properties).map(([name, schema]) => ({
19
+ name,
20
+ in: 'query',
21
+ required: required.has(name),
22
+ schema,
23
+ }))
24
+ }
25
+
26
+ /*
27
+ Request body schema for a multipart upload verb: the text fields from
28
+ inputSchema, plus the binary parts. A File has no honest
29
+ Standard-Schema→JSON-Schema conversion, so the file parts are advertised
30
+ generically as additional binary properties rather than named per field.
31
+ */
32
+ function multipartBodySchema(textSchema: Record<string, unknown>): Record<string, unknown> {
33
+ const textProperties = (textSchema.properties as Record<string, unknown> | undefined) ?? {}
34
+ const schema: Record<string, unknown> = {
35
+ type: 'object',
36
+ properties: { ...textProperties },
37
+ additionalProperties: { type: 'string', format: 'binary' },
38
+ }
39
+ const required = (textSchema.required as string[] | undefined) ?? []
40
+ if (required.length > 0) {
41
+ schema.required = required
42
+ }
43
+ return schema
44
+ }
45
+
46
+ /*
47
+ Builds an OpenAPI 3.1 document from the verb registry — the HTTP surface
48
+ every rpc exposes regardless of which non-browser clients it advertises.
49
+ GET/DELETE/HEAD args become query parameters; POST/PUT/PATCH args become
50
+ a JSON request body. operationId is the folder-prefixed command name so
51
+ it lines up with the MCP tool / CLI subcommand identifiers.
52
+ */
53
+ export function buildOpenApiSpec(info: {
54
+ title: string
55
+ version: string
56
+ }): Record<string, unknown> {
57
+ const paths: Record<string, Record<string, unknown>> = {}
58
+ for (const entry of verbRegistry.values()) {
59
+ const url = entry.remote.url
60
+ const method = entry.remote.method
61
+ const jsonSchema = jsonSchemaForSchema(entry.inputSchema)
62
+ const description = jsonSchema.description as string | undefined
63
+ /*
64
+ When the verb declares an `outputSchema`, describe the 200 body
65
+ with it so external tooling sees the real return shape; otherwise
66
+ fall back to a bare OK.
67
+ */
68
+ const okResponse: Record<string, unknown> = { description: 'OK' }
69
+ if (entry.outputSchema) {
70
+ okResponse.content = {
71
+ 'application/json': {
72
+ schema: jsonSchemaForSchema(entry.outputSchema),
73
+ },
74
+ }
75
+ }
76
+ const operation: Record<string, unknown> = {
77
+ operationId: commandNameForUrl(url),
78
+ ...(description ? { description } : {}),
79
+ responses: { '200': okResponse },
80
+ }
81
+ if (carriesBodyArgs(method)) {
82
+ operation.requestBody = entry.filesSchema
83
+ ? {
84
+ content: {
85
+ 'multipart/form-data': {
86
+ schema: multipartBodySchema(jsonSchema),
87
+ },
88
+ },
89
+ }
90
+ : { content: { 'application/json': { schema: jsonSchema } } }
91
+ } else {
92
+ const parameters = queryParameters(jsonSchema)
93
+ if (parameters.length > 0) {
94
+ operation.parameters = parameters
95
+ }
96
+ }
97
+ paths[url] ??= {}
98
+ const path = paths[url]
99
+ path[method.toLowerCase()] = operation
100
+ }
101
+ return {
102
+ openapi: '3.1.0',
103
+ info: { title: info.title, version: info.version },
104
+ paths,
105
+ }
106
+ }
@@ -0,0 +1,22 @@
1
+ import {
2
+ IMMUTABLE_ASSET_CACHE_CONTROL,
3
+ REVALIDATE_ASSET_CACHE_CONTROL,
4
+ } from '../../shared/CACHE_CONTROL_VALUES.ts'
5
+
6
+ /*
7
+ Bun.build emits `[name]-[hash].[ext]` for chunks; hash is alnum and >=8 chars.
8
+ Source maps inherit the same name (e.g. foo-abc12345.js.map), so the suffix may be `.map`.
9
+ */
10
+ const HASHED = /-[a-z0-9]{8,}\.[a-z0-9]+(\.map)?$/i
11
+
12
+ /*
13
+ Returns the right `Cache-Control` for an asset path served under `/_app/`.
14
+ Hashed chunk filenames are content-addressed and immutable; everything else
15
+ (the entry bundle, the html shell, etc.) must revalidate every time.
16
+ */
17
+ export function cacheControlForAsset(pathname: string): string {
18
+ if (HASHED.test(pathname)) {
19
+ return IMMUTABLE_ASSET_CACHE_CONTROL
20
+ }
21
+ return REVALIDATE_ASSET_CACHE_CONTROL
22
+ }