@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,13 @@
1
+ import type { ChannelLog } from './ChannelLog.ts'
2
+
3
+ /*
4
+ The public logger: a ChannelLog on the app's own always-on channel (named
5
+ after the app, so every record carries who spoke), plus the factory for
6
+ DEBUG-gated diagnostic channels. Framework voices live on the internal
7
+ abideLog; the closing request record is emitted via internal
8
+ logClosingRecord — neither is part of this surface.
9
+ */
10
+ export type Log = ChannelLog & {
11
+ /* Diagnostic channel: same shape, tagged with `name`, emits only when DEBUG matches. */
12
+ channel(name: string): ChannelLog
13
+ }
@@ -0,0 +1,42 @@
1
+ /*
2
+ One log event, built once per emission and rendered by either formatter
3
+ (tab-separated tsv line or ABIDE_LOG_FORMAT=json). The json rendering of these
4
+ keys is a documented contract — ingestion pipelines (Splunk, Loki) extract
5
+ fields by these names, so renames are breaking changes. Absent context is
6
+ omitted, never null: trace/elapsedMs/method/path exist only inside a request
7
+ scope, status/durationMs only on closing request records, name/spanId only on
8
+ log.trace operation records, stack only when an Error was captured.
9
+ */
10
+ export type LogRecord = {
11
+ /* Epoch ms; the json format renders it as an ISO timestamp. */
12
+ ts: number
13
+ level: 'info' | 'warn' | 'error'
14
+ msg: string
15
+ /* DEBUG-gated diagnostic channel that emitted this record. */
16
+ channel?: string
17
+ /* Full 32-hex trace id; tsv mode prints the first 8 chars. */
18
+ trace?: string
19
+ /* The emitting request's own trace span id (TraceContext.spanId). Stable across
20
+ every record one request emits, so a consumer can split a multi-request trace
21
+ (a propagated session) back into its individual requests. */
22
+ requestSpan?: string
23
+ /* The span this request descends from (TraceContext.parentSpanId); absent when
24
+ abide started the trace — the journey's root request. Lets a consumer nest
25
+ requests within a trace. */
26
+ parentSpan?: string
27
+ /* Ms since the request scope opened (navigation start in the browser). */
28
+ elapsedMs?: number
29
+ method?: string
30
+ path?: string
31
+ /* Structured payload passed as the second argument. */
32
+ data?: unknown
33
+ /* Closing request record: response status + total duration at settle. */
34
+ status?: number
35
+ durationMs?: number
36
+ /* Closing request record: the request's cache read tallies, frozen at settle. */
37
+ cache?: { hits: number; misses: number; coalesced: number }
38
+ /* log.trace operation record: chosen operation name + minted span id. */
39
+ name?: string
40
+ spanId?: string
41
+ stack?: string
42
+ }
@@ -0,0 +1,7 @@
1
+ /*
2
+ Presentation hints for the tsv formatter only — the framework's styling
3
+ voices on the 'abide' channel: 'success' paints green, 'detail' dims
4
+ secondary text. Never serialised: the json format renders these records as
5
+ ordinary info lines.
6
+ */
7
+ export type LogVoice = 'success' | 'detail'
@@ -0,0 +1,14 @@
1
+ /*
2
+ Side-agnostic shape of the active page state: the matched route, its decoded
3
+ params, the live request/location URL, and whether a client SPA navigation is
4
+ in flight. The browser `page` proxy reads its public fields through this; the
5
+ server resolver reads them off the per-request store, the client resolver off
6
+ the module singleton. `navigating` is always false server-side — there is no
7
+ in-flight navigation during a synchronous render.
8
+ */
9
+ export type PageSnapshot = {
10
+ route: string
11
+ params: Record<string, string>
12
+ url: URL
13
+ navigating: boolean
14
+ }
@@ -0,0 +1,12 @@
1
+ /*
2
+ A single declared argument of a markdown prompt, parsed from the file's
3
+ YAML frontmatter `arguments:` list. `name` is the placeholder the body
4
+ interpolates via `{{name}}`; `description` + `required` feed the argument
5
+ list MCP advertises in `prompts/list`. Build-time only — markdown prompts
6
+ carry no runtime schema object, so this drives the generated JSON Schema.
7
+ */
8
+ export type PromptArgument = {
9
+ name: string
10
+ description?: string
11
+ required?: boolean
12
+ }
@@ -0,0 +1,14 @@
1
+ import type { HttpVerb } from './HttpVerb.ts'
2
+ import type { RemoteCallable } from './RemoteCallable.ts'
3
+
4
+ /*
5
+ Bare-response remote function — same call shape as RemoteFunction but
6
+ resolves to the underlying Response without Content-Type decode and
7
+ without throwing on non-2xx. Produced as `.raw` on every RemoteFunction
8
+ so callers that need status / headers / body streaming or want to
9
+ implement custom error handling can opt out of the decode.
10
+ */
11
+ export type RawRemoteFunction<Args> = RemoteCallable<Args, Response> & {
12
+ readonly method: HttpVerb
13
+ readonly url: string
14
+ }
@@ -0,0 +1,12 @@
1
+ /*
2
+ Call signature shared by RemoteFunction and RawRemoteFunction. The base
3
+ signature keeps `args` required so a schema'd verb can't silently drop its
4
+ input; when `Args` admits undefined (no-input verbs) an intersected
5
+ optional-arg signature lets call sites write `fn()` instead of
6
+ `fn(undefined)`. Intersection rather than a bare conditional so the type
7
+ stays callable while `Args` is still generic (cache() invokes producers
8
+ before `Args` resolves). FormData is the multipart upload escape hatch —
9
+ see RemoteFunction.
10
+ */
11
+ export type RemoteCallable<Args, Resolved> = ((args: Args | FormData) => Promise<Resolved>) &
12
+ (undefined extends Args ? (args?: Args | FormData) => Promise<Resolved> : unknown)
@@ -0,0 +1,47 @@
1
+ import type { ClientFlags } from './ClientFlags.ts'
2
+ import type { HttpVerb } from './HttpVerb.ts'
3
+ import type { RawRemoteFunction } from './RawRemoteFunction.ts'
4
+ import type { RemoteCallable } from './RemoteCallable.ts'
5
+ import type { Subscribable } from './Subscribable.ts'
6
+
7
+ /*
8
+ Remote function reference produced by GET/POST/... inside an `$rpc/**`
9
+ module and consumed by rpc dispatch, cache(), SSR auto-hydration, and
10
+ direct calls. Same callable signature on server and client — the bundler
11
+ swaps the implementation for browser builds.
12
+
13
+ The plain call resolves to the decoded body shape (sniffed from
14
+ Content-Type) and throws HttpError on non-2xx. `.raw` is a sibling
15
+ RemoteFunction whose call resolves to the underlying Response — same
16
+ method, same url, same args, no decode. Pass `fn.raw` to cache() to
17
+ memoise raw Responses against the same cache key as `fn` (both share one
18
+ stored entry — the decode just happens on the way out for callers of
19
+ `fn`). `.stream(args)` returns an iterable view of the Response body:
20
+ SSE / JSONL handlers yield each frame; non-streaming handlers yield the
21
+ decoded body once then complete. The result is a Subscribable, so it
22
+ can be passed to tail() and shared across reactive consumers.
23
+ For sustained broadcast / pub-sub use the `abide/server/socket` primitive —
24
+ HTTP rpc isn't the place for long-lived multi-publisher subscriptions.
25
+ `.fetch(req)` is the framework's request-dispatch entry point — used by
26
+ the router to invoke the handler from an incoming HTTP request, not
27
+ for user code.
28
+ `crossOrigin` (server-side only, set via the verb's opts) exempts a
29
+ mutating verb from the router's same-origin CSRF gate, accepting browser
30
+ requests whose Origin doesn't match the app's own host.
31
+ */
32
+ /*
33
+ A body verb (POST/PUT/PATCH) also accepts a FormData in place of typed args:
34
+ buildRpcRequest ships it as a multipart body and the server splits text fields
35
+ into args (still schema-validated) and File parts into files(). FormData is
36
+ stringly-typed, so this is the upload escape hatch — typed object args remain
37
+ the default for everything else.
38
+ */
39
+ export type RemoteFunction<Args, Return> = RemoteCallable<Args, Return> & {
40
+ readonly method: HttpVerb
41
+ readonly url: string
42
+ readonly clients: ClientFlags
43
+ readonly crossOrigin?: boolean
44
+ readonly raw: RawRemoteFunction<Args>
45
+ stream(args?: Args | FormData): Subscribable<Return>
46
+ fetch(request: Request): Promise<Response>
47
+ }
@@ -0,0 +1,7 @@
1
+ /*
2
+ Method of a cache entry that may re-fire unprompted — snapshot replay on the
3
+ client, invalidate-policy refetch. Mirrors REPLAYABLE_METHODS (the runtime
4
+ gate; narrow via isReplayableMethod): only GET qualifies, the one safe
5
+ read-only method.
6
+ */
7
+ export type ReplayableMethod = 'GET'
@@ -0,0 +1,16 @@
1
+ import type { TraceContext } from './TraceContext.ts'
2
+
3
+ /*
4
+ The request-scope facts the shared layer reads through requestScopeSlot:
5
+ trace position, elapsed ms since the scope opened (request start on the
6
+ server, navigation start in the browser), and the verb+path that anchors log
7
+ lines. Resolved fresh per read so `elapsedMs` is current at the call.
8
+ */
9
+ export type RequestScopeInfo = {
10
+ trace: TraceContext
11
+ elapsedMs: number
12
+ method: string
13
+ path: string
14
+ /* The calling client's reported connectivity (server only, from OFFLINE_HEADER); drives server-side online(). Omitted client-side — online() reads navigator there. */
15
+ online?: boolean
16
+ }
@@ -0,0 +1,6 @@
1
+ /* A verb invoker mirrors the verb's own call: a plain call decodes the body
2
+ (throws HttpError on non-2xx), `.raw` returns the Response untouched. Shared
3
+ by every name→callable RPC proxy (the CLI client, the test harness). */
4
+ export type RpcInvoker = ((args?: unknown) => Promise<unknown>) & {
5
+ raw: (args?: unknown) => Promise<Response>
6
+ }
@@ -0,0 +1,17 @@
1
+ import type { SocketSubCallbacks } from './SocketSubCallbacks.ts'
2
+
3
+ /* The multiplexed-ws abstraction a Socket<T> drives: open/close a per-sub
4
+ subscription and publish to a topic. The browser singleton (socketChannel)
5
+ and the test harness (createTestSocketChannel) each implement it;
6
+ buildSocketOverChannel turns either into Socket<T> objects, so the two
7
+ surfaces can't drift on the Socket contract. */
8
+ export type SocketChannel = {
9
+ subscribe(
10
+ sub: string,
11
+ socket: string,
12
+ replay: number | undefined,
13
+ callbacks: SocketSubCallbacks,
14
+ ): void
15
+ unsubscribe(sub: string): void
16
+ publish(socket: string, message: unknown): void
17
+ }
@@ -0,0 +1,13 @@
1
+ /* The callback contract a SocketChannel drives per subscription — how the
2
+ channel hands a sub its frames and lifecycle. Shared by every channel
3
+ implementation (the browser multiplex, the test harness) and the Socket<T>
4
+ builder that wires these onto a push iterator. */
5
+ export type SocketSubCallbacks = {
6
+ onMessage(message: unknown): void
7
+ /* The sub's batched seed from the retained tail (possibly empty) — the replay/live boundary. */
8
+ onReplay(messages: unknown[]): void
9
+ onError(message: string): void
10
+ onEnd(): void
11
+ /* Transport loss (ws close), as opposed to a per-sub server `err` frame — recoverable. */
12
+ onDisconnect(): void
13
+ }
@@ -0,0 +1,56 @@
1
+ /*
2
+ Mirror of the Standard Schema v1 spec interface (standardschema.dev). Any
3
+ library that implements the spec — zod, valibot, arktype, etc. — produces
4
+ values whose `~standard` property structurally matches this shape, so users
5
+ can pass their existing schemas to verb helpers without an adapter.
6
+
7
+ Kept inline (no `@standard-schema/spec` dep) because the spec is type-only
8
+ and tiny; adding a package for ~30 lines of interface would be churn. The
9
+ namespace pattern below is the spec's own convention — `InferInput` /
10
+ `InferOutput` ride along the same export.
11
+ */
12
+ export interface StandardSchemaV1<Input = unknown, Output = Input> {
13
+ readonly '~standard': StandardSchemaV1.Props<Input, Output>
14
+ }
15
+
16
+ export namespace StandardSchemaV1 {
17
+ export interface Props<Input = unknown, Output = Input> {
18
+ readonly version: 1
19
+ readonly vendor: string
20
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>
21
+ readonly types?: Types<Input, Output> | undefined
22
+ }
23
+
24
+ export type Result<Output> = SuccessResult<Output> | FailureResult
25
+
26
+ export interface SuccessResult<Output> {
27
+ readonly value: Output
28
+ readonly issues?: undefined
29
+ }
30
+
31
+ export interface FailureResult {
32
+ readonly issues: ReadonlyArray<Issue>
33
+ }
34
+
35
+ export interface Issue {
36
+ readonly message: string
37
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined
38
+ }
39
+
40
+ export interface PathSegment {
41
+ readonly key: PropertyKey
42
+ }
43
+
44
+ export interface Types<Input = unknown, Output = Input> {
45
+ readonly input: Input
46
+ readonly output: Output
47
+ }
48
+
49
+ export type InferInput<Schema extends StandardSchemaV1> = NonNullable<
50
+ Schema['~standard']['types']
51
+ >['input']
52
+
53
+ export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<
54
+ Schema['~standard']['types']
55
+ >['output']
56
+ }
@@ -0,0 +1,10 @@
1
+ import type { CacheSnapshotEntry } from './CacheSnapshotEntry.ts'
2
+
3
+ /*
4
+ Payload of one streamed `window.__abideResolve(...)` call. A full
5
+ `CacheSnapshotEntry` settles the placeholder with warm data; a `{ key, miss }`
6
+ marker means the server couldn't snapshot that body (binary, rejected, evicted)
7
+ so the client settles the placeholder with a live re-fetch instead. Discriminate
8
+ on the `miss` field.
9
+ */
10
+ export type StreamedResolution = CacheSnapshotEntry | { key: string; miss: true }
@@ -0,0 +1,26 @@
1
+ import type { TailHooks } from './TailHooks.ts'
2
+
3
+ /*
4
+ The thing `tail()` reads from: an AsyncIterable carrying a stable `name`
5
+ used as the subscription registry key. Both `Socket<T>` (the declared
6
+ broadcast primitive) and the result of `fn.stream(args)` (per-call HTTP
7
+ stream consumer) satisfy this shape, so tail() can share one iterator
8
+ across multiple readers regardless of source.
9
+
10
+ The name on a Socket comes from the file path under `src/server/sockets/`.
11
+ The name on an fn.stream(args) result is `keyForRemoteCall(method, url,
12
+ args)` — the same key cache() uses — so two readers of the same remote-call
13
+ args dedupe to one underlying fetch.
14
+
15
+ `tail` is the optional retention capability: a source that keeps a tail of
16
+ recent frames hands back an iterable seeded with at most the last `count`
17
+ before going live. Sockets implement it verbatim; one-shot rpc streams omit
18
+ it. The tail() consumer uses it to bound replay to what the reader will
19
+ keep — it never requires it. Implementers must signal `hooks.replayed`
20
+ in-band once the seed portion is delivered (even when empty) so window
21
+ readers can commit atomically; see TailHooks.
22
+ */
23
+ export interface Subscribable<T> extends AsyncIterable<T> {
24
+ readonly name: string
25
+ tail?(count: number, hooks?: TailHooks): AsyncIterable<T>
26
+ }
@@ -0,0 +1,12 @@
1
+ /*
2
+ Hooks a tail() reader passes to a Subscribable's retention capability.
3
+ `replayed` must be signalled in-band exactly once per iteration — after the
4
+ last replayed frame, before any live frame, and even when nothing was
5
+ replayed — so a window reader can commit its seed atomically instead of
6
+ guessing where replay ends (an empty replay keeps the reader's held window;
7
+ nothing was replayed, so nothing can duplicate). Sources without the
8
+ capability never see hooks.
9
+ */
10
+ export interface TailHooks {
11
+ readonly replayed?: () => void
12
+ }
@@ -0,0 +1,10 @@
1
+ /*
2
+ Window form of `tail()`: `last` is the rolling window size — the reader holds
3
+ the last ≤`last` frames, however they arrived. A source that retains a tail
4
+ (a socket declared with `{ tail: n }`) seeds the window by replaying up to
5
+ `last` retained frames; a source with no retention (an rpc stream, an
6
+ undeclared socket) fills it from live frames only. Integer ≥ 1.
7
+ */
8
+ export interface TailOptions {
9
+ readonly last: number
10
+ }
@@ -0,0 +1,17 @@
1
+ /*
2
+ The request's W3C Trace Context position. `traceId` identifies the whole
3
+ end-to-end operation (inherited from an inbound `traceparent` or minted at the
4
+ boundary); `spanId` is the id abide mints for this request — it rides outbound
5
+ `traceparent` headers as the parent of downstream work, and a future span
6
+ exporter materialises the request's root span under this exact id.
7
+ `parentSpanId` preserves the inbound header's span id so that root span can
8
+ parent under the upstream caller; absent when abide started the trace.
9
+ `flags` echo the inbound sampling flags ('01' when abide starts the trace, so
10
+ downstream recorders don't drop what the developer is trying to see).
11
+ */
12
+ export type TraceContext = {
13
+ traceId: string
14
+ spanId: string
15
+ parentSpanId?: string
16
+ flags: string
17
+ }
@@ -0,0 +1,118 @@
1
+ import { basePath } from './basePath.ts'
2
+ import type { RouteSegment } from './parseRouteSegments.ts'
3
+ import { parseRouteSegments } from './parseRouteSegments.ts'
4
+ import { queryStringFromArgs } from './queryStringFromArgs.ts'
5
+
6
+ /* `undefined` is allowed and dropped (queryStringFromArgs skips it), so an
7
+ optional field — url('/p', { ref: maybeUndefined }) — types without a guard. */
8
+ type QueryValue = string | number | boolean | undefined
9
+ type Query = Record<string, QueryValue>
10
+
11
+ /*
12
+ Augmentable rpc map. Codegen emits a `declare module '<importName>/shared/url'`
13
+ block filling this with `'/rpc/<file>': args` for each query-carrying (GET)
14
+ verb, so url('/rpc/search', { q }) types its args against the verb's own
15
+ signature. Empty by default — an absent entry falls through to the page/asset
16
+ branch, so the helper works before the generated d.ts lands.
17
+ */
18
+ // @readme url
19
+ // biome-ignore lint/suspicious/noEmptyInterface: augmented by the generated rpc.d.ts
20
+ export interface RpcRoutes {}
21
+
22
+ /*
23
+ Augmentable autocomplete sets — keys only, values unused. The page codegen
24
+ (writeRoutesDts) fills PageRoutes with each route path, the public codegen
25
+ (writePublicAssetsDts) fills PublicAssets with each `public/` file path. They
26
+ exist purely so editors suggest known paths; PathParams still derives a page's
27
+ params from the literal, so neither map drives typing.
28
+ */
29
+ // biome-ignore lint/suspicious/noEmptyInterface: augmented by the generated routes.d.ts
30
+ export interface PageRoutes {}
31
+ // biome-ignore lint/suspicious/noEmptyInterface: augmented by the generated publicAssets.d.ts
32
+ export interface PublicAssets {}
33
+
34
+ /*
35
+ Known in-app paths for autocomplete. `(string & {})` at the call site keeps any
36
+ string accepted (dynamic/raw/external paths) — there's no hard route-existence
37
+ error, which would reject assets and interpolated strings — while these light
38
+ up suggestions once codegen lands.
39
+ */
40
+ type KnownPath = keyof PageRoutes | keyof RpcRoutes | keyof PublicAssets
41
+
42
+ /*
43
+ Pulls the `[name]` / `[...rest]` params a route literal declares straight from
44
+ the path type, so url('/product/[id]', …) requires `id` without a generated
45
+ shape map. Values accept string | number (stringified on output). A path with
46
+ no bracket segments yields {}, which collapses the params slot away. The
47
+ catch-all branch recurses on its head too, so `[name]` segments before a
48
+ `[...rest]` are kept.
49
+ */
50
+ type PathParams<P extends string> = P extends `${infer Head}[...${infer Rest}]${infer Tail}`
51
+ ? PathParams<Head> & { [K in Rest]: string | number } & PathParams<Tail>
52
+ : P extends `${string}[${infer Name}]${infer Tail}`
53
+ ? { [K in Name]: string | number } & PathParams<Tail>
54
+ : // biome-ignore lint/complexity/noBannedTypes: {} is the "no params" base case — keyof {} is never, which collapses the params slot; Record<string, never> would not (keyof is string)
55
+ {}
56
+
57
+ /*
58
+ Resolves any in-app URL to its base-correct, typed form — the single chokepoint
59
+ so a project mounted under APP_URL's subpath (e.g. /v2) generates links, asset
60
+ refs, and rpc hrefs that stay within the mount. Three disjoint URL kinds, keyed
61
+ off the path:
62
+ - rpc (flat /rpc/*, present in RpcRoutes): the verb's args, serialised to query.
63
+ - page route (has [name] segments): path params, then optional query.
64
+ - asset / paramless / raw: bare path, then optional query.
65
+ External URLs (scheme-qualified or protocol-relative) skip the base untouched,
66
+ as do non-rooted specifiers — base only ever prefixes a rooted internal path.
67
+ */
68
+ export function url<P extends KnownPath | (string & {})>(
69
+ path: P,
70
+ ...args: P extends keyof RpcRoutes
71
+ ? undefined extends RpcRoutes[P]
72
+ ? [args?: RpcRoutes[P]]
73
+ : [args: RpcRoutes[P]]
74
+ : keyof PathParams<P> extends never
75
+ ? [query?: Query]
76
+ : [params: PathParams<P>, query?: Query]
77
+ ): string
78
+ export function url(path: string, first?: Query, second?: Query): string {
79
+ // Scheme-qualified (http:, mailto:) or protocol-relative URLs are external — leave them whole.
80
+ if (/^[a-z][a-z0-9+.-]*:/i.test(path) || path.startsWith('//')) {
81
+ return appendQuery(path, first)
82
+ }
83
+ const segments = parseRouteSegments(path)
84
+ const hasParams = segments.some((segment) => segment.kind === 'param')
85
+ // With path params the second arg is the query; without, the first arg is.
86
+ const query = hasParams ? second : first
87
+ const resolved = hasParams ? interpolate(segments, first ?? {}) : path
88
+ // Base only prefixes rooted internal paths; relative specifiers are left alone.
89
+ const prefixed = resolved.startsWith('/') ? basePath() + resolved : resolved
90
+ return appendQuery(prefixed, query)
91
+ }
92
+
93
+ /* Substitutes `[name]` / `[...rest]` segments with their stringified, URL-encoded
94
+ param values (matching the query side, which encodes too). A `[name]` value is
95
+ encoded whole so `/`, `?`, `#`, and spaces can't alter the path structure; a
96
+ `[...rest]` catch-all keeps its `/` separators and encodes each sub-segment. */
97
+ function interpolate(segments: RouteSegment[], params: Query): string {
98
+ return segments
99
+ .map((segment) => {
100
+ if (segment.kind === 'literal') {
101
+ return segment.value
102
+ }
103
+ const value = String(params[segment.name])
104
+ return segment.catchAll
105
+ ? value.split('/').map(encodeURIComponent).join('/')
106
+ : encodeURIComponent(value)
107
+ })
108
+ .join('/')
109
+ }
110
+
111
+ /* Appends a `?`-query built from the same encoder buildRpcRequest uses, or nothing. */
112
+ function appendQuery(target: string, query: Query | undefined): string {
113
+ if (!query) {
114
+ return target
115
+ }
116
+ const queryString = queryStringFromArgs(query, false)
117
+ return queryString ? `${target}?${queryString}` : target
118
+ }
@@ -0,0 +1,11 @@
1
+ import { basePath } from './basePath.ts'
2
+
3
+ /*
4
+ Prefixes a rooted internal path (`/rpc/…`, `/__abide/…`) with the mount base
5
+ so the client's framework requests route through the proxy (`/v2/rpc/…`). The
6
+ single rule the runtime fetch sites (remoteProxy, openResolveStream,
7
+ socketChannel, the streaming placeholders) share — '' at root is a no-op.
8
+ */
9
+ export function withBase(path: string): string {
10
+ return `${basePath()}${path}`
11
+ }
@@ -0,0 +1,17 @@
1
+ import { basePath } from './basePath.ts'
2
+
3
+ /*
4
+ Re-homes a URL under the mount base by prefixing its pathname (`/people` →
5
+ `/v2/people`) — the URL-level counterpart of withBase for sites that carry
6
+ whole URLs rather than rooted paths. Identity at root mount, so there is no
7
+ allocation (and no behaviour change) when no base is set.
8
+ */
9
+ export function withBaseUrl(url: URL): URL {
10
+ const base = basePath()
11
+ if (!base) {
12
+ return url
13
+ }
14
+ const prefixed = new URL(url)
15
+ prefixed.pathname = base + url.pathname
16
+ return prefixed
17
+ }
@@ -0,0 +1,21 @@
1
+ import type { StandardSchemaV1 } from './types/StandardSchemaV1.ts'
2
+
3
+ /*
4
+ Attaches a `toJSONSchema()` projection to a Standard Schema whose library
5
+ doesn't expose one natively. jsonSchemaForSchema probes that method to feed the
6
+ OpenAPI document, the MCP tool schemas, the CLI flag help, and the bundle setup
7
+ form. Zod 4 / Effect / Arktype carry their own; everything else wraps once where
8
+ the schema is declared:
9
+
10
+ export const config = env(withJsonSchema(vSchema, (s) => toJsonSchema(s)))
11
+
12
+ Mutates and returns the same schema with the method attached, so the wrapped
13
+ value stays usable everywhere the bare schema was.
14
+ */
15
+ // @readme rpc
16
+ export function withJsonSchema<Schema extends StandardSchemaV1>(
17
+ schema: Schema,
18
+ toJsonSchema: (schema: Schema) => Record<string, unknown>,
19
+ ): Schema & { toJSONSchema: () => Record<string, unknown> } {
20
+ return Object.assign(schema, { toJSONSchema: () => toJsonSchema(schema) })
21
+ }
@@ -0,0 +1,12 @@
1
+ /* The banner every generated abide `.d.ts` carries, warning off hand edits. */
2
+ const DTS_BANNER = '// Generated by abide. Do not edit by hand.'
3
+
4
+ /*
5
+ Writes a generated `.d.ts` to `src/.abide/<name>.d.ts` (the path the consumer's
6
+ src tsconfig include picks up), wrapping `body` in the shared banner + the
7
+ `export {}` footer that makes the file a module. The three codegen writers
8
+ (routes, rpc, public assets) differ only in `body`, so the envelope lives here.
9
+ */
10
+ export async function writeDts(cwd: string, name: string, body: string): Promise<void> {
11
+ await Bun.write(`${cwd}/src/.abide/${name}.d.ts`, `${DTS_BANNER}\n${body}\n\nexport {}\n`)
12
+ }
@@ -0,0 +1,36 @@
1
+ import { writeDts } from './writeDts.ts'
2
+
3
+ /*
4
+ Emits a `.d.ts` that augments abide's `AppHealthMap` interface with the app
5
+ health() hook's resolved return type, so the client `health()` read types
6
+ against the project's own hook (e.g. `health().authenticated`). Conditional
7
+ over `typeof import('../app.ts')` because the hook is optional — absent, the
8
+ fields resolve empty; a non-object return is ignored, matching the runtime
9
+ merge. With no src/app.ts at all the import would be an error, so the file
10
+ carries only the framework shape. Written to `src/.abide/health.d.ts` like
11
+ its routes/rpc siblings.
12
+ */
13
+ export async function writeHealthDts({
14
+ cwd,
15
+ hasAppModule,
16
+ importName,
17
+ }: {
18
+ cwd: string
19
+ hasAppModule: boolean
20
+ importName: string
21
+ }): Promise<void> {
22
+ const body = hasAppModule
23
+ ? `type AppHealthFields<App> = App extends { health: (...args: never[]) => infer Result }
24
+ ? Awaited<Result> extends object
25
+ ? Awaited<Result>
26
+ : Record<never, never>
27
+ : Record<never, never>
28
+
29
+ declare module '${importName}/shared/health' {
30
+ interface AppHealthMap {
31
+ fields: AppHealthFields<typeof import('../app.ts')>
32
+ }
33
+ }`
34
+ : '// src/app.ts absent — health() carries only the framework fields.'
35
+ await writeDts(cwd, 'health', body)
36
+ }
@@ -0,0 +1,13 @@
1
+ import { mkdir } from 'node:fs/promises'
2
+ import { appDataDir } from './appDataDir.ts'
3
+ import { lastConnectionPath } from './lastConnectionPath.ts'
4
+ import type { LastConnection } from './types/LastConnection.ts'
5
+
6
+ // Persists the connection intent, creating the data dir on first write.
7
+ export async function writeLastConnection(
8
+ programName: string,
9
+ value: LastConnection,
10
+ ): Promise<void> {
11
+ await mkdir(appDataDir(programName), { recursive: true })
12
+ await Bun.write(lastConnectionPath(programName), JSON.stringify(value))
13
+ }
@@ -0,0 +1,31 @@
1
+ import { writeDts } from './writeDts.ts'
2
+
3
+ /*
4
+ Emits a `.d.ts` that augments abide's `PublicAssets` interface with one entry
5
+ per file under `public/`, keyed by its site-root path (`/logo.png`) — the same
6
+ key createPublicAssetServer serves it at. Keys only (value `true`): the map
7
+ exists purely so `url('/logo.png')` autocompletes known assets; it carries no
8
+ type beyond the path. Written to `src/.abide/publicAssets.d.ts` so the
9
+ consumer's src tsconfig include picks it up, keyed on the project's abide
10
+ import name like writeRoutesDts / writeRpcDts.
11
+ */
12
+ export async function writePublicAssetsDts({
13
+ cwd,
14
+ publicFiles,
15
+ importName,
16
+ }: {
17
+ cwd: string
18
+ publicFiles: string[]
19
+ importName: string
20
+ }): Promise<void> {
21
+ const entries = publicFiles
22
+ .map((file) => ` ${JSON.stringify(`/${file}`)}: true`)
23
+ .toSorted()
24
+ .join('\n')
25
+ const body = `declare module '${importName}/shared/url' {
26
+ interface PublicAssets {
27
+ ${entries}
28
+ }
29
+ }`
30
+ await writeDts(cwd, 'publicAssets', body)
31
+ }