akanjs 3.3.0-rc.9 → 3.3.1-rc.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 (623) hide show
  1. package/README.ko.md +9 -5
  2. package/README.md +7 -5
  3. package/base/utils.ts +2 -0
  4. package/client/appOpenedTab.ts +2 -1
  5. package/client/clientRuntime.ts +2 -0
  6. package/client/cookie.ts +15 -6
  7. package/client/csrLocation.ts +61 -9
  8. package/client/csrRuntimeParams.ts +33 -0
  9. package/client/csrTypes.ts +29 -2
  10. package/client/deepLinkStack.ts +97 -0
  11. package/client/device.ts +18 -3
  12. package/client/dictionaryAsset.ts +103 -25
  13. package/client/dictionaryGroups.ts +113 -0
  14. package/client/dictionaryModule.ts +23 -0
  15. package/client/dictionaryPart.ts +113 -0
  16. package/client/frameConfig.ts +15 -0
  17. package/client/index.ts +10 -0
  18. package/client/keyboardRide.ts +336 -28
  19. package/client/makePageProto.tsx +22 -2
  20. package/client/nativeBoot.ts +3 -0
  21. package/client/nativeErrorReport.ts +55 -0
  22. package/client/nativeHost.ts +2 -31
  23. package/client/nativeShell.ts +32 -0
  24. package/client/notFoundView.ts +9 -0
  25. package/client/pendingNavigation.ts +103 -0
  26. package/client/pressLoading.ts +29 -0
  27. package/client/redirectMove.ts +13 -0
  28. package/client/reportText.ts +27 -0
  29. package/client/route/RouteDefinition.ts +33 -7
  30. package/client/router.ts +65 -50
  31. package/client/rscClientErrorSender.ts +85 -0
  32. package/client/rscNavigation.ts +8 -1
  33. package/client/scriptPolicy.ts +14 -0
  34. package/client/sharedContext.ts +3 -1
  35. package/client/sharedContextKey.ts +2 -0
  36. package/client/shellState.ts +151 -0
  37. package/client/shellStateHooks.ts +2 -0
  38. package/client/translator.ts +7 -1
  39. package/client/translatorState.ts +18 -1
  40. package/client/usePendingNavigation.ts +38 -0
  41. package/common/Logger.ts +1 -1
  42. package/common/TraceContext.ts +5 -3
  43. package/common/index.ts +1 -0
  44. package/common/sessionTokenContract.ts +7 -0
  45. package/common/websocketContract.ts +5 -2
  46. package/constant/constantRegistry.ts +36 -33
  47. package/constant/immerable.ts +2 -0
  48. package/constant/immerify.ts +1 -1
  49. package/constant/index.ts +1 -0
  50. package/constant/inputParser.ts +7 -0
  51. package/constant/types.ts +10 -9
  52. package/constant/via.ts +1 -1
  53. package/dictionary/agent.dictionary.ts +4 -0
  54. package/fetch/client/fetchClient.ts +22 -42
  55. package/fetch/client/fetchHandle.ts +3 -1
  56. package/fetch/client/httpClient.ts +15 -1
  57. package/fetch/client/modelRuntimes.ts +89 -0
  58. package/fetch/client/requestScope.ts +4 -1
  59. package/fetch/client/signalCatalog.ts +9 -4
  60. package/fetch/client/sliceInitHandle.ts +5 -3
  61. package/fetch/client/wsClient.ts +10 -1
  62. package/fetch/fetchType/appliedReturn.type.ts +4 -2
  63. package/fetch/requestStorage.ts +20 -0
  64. package/index.ts +58 -1
  65. package/package.json +17 -2
  66. package/server/SSR_MEMORY_DIAGNOSIS.md +4 -0
  67. package/server/akanApp.ts +21 -5
  68. package/server/akanOption.ts +28 -0
  69. package/server/akanServer.ts +136 -40
  70. package/server/appWorker.ts +177 -0
  71. package/server/appWorkerError.ts +5 -0
  72. package/server/appWorkerPath.ts +22 -0
  73. package/server/artifact/builderRpc.ts +1 -0
  74. package/server/artifact/ipcTypes.ts +4 -0
  75. package/server/artifact/routeClientCache.ts +4 -0
  76. package/server/assetHeaders.ts +11 -8
  77. package/server/clientErrorReport.ts +248 -0
  78. package/server/clientReportId.ts +54 -0
  79. package/server/devtools/devtoolsRouter.ts +27 -16
  80. package/server/devtools/signalSerializer.ts +18 -1
  81. package/server/devtools/studio/studioDocument.tsx +3 -1
  82. package/server/devtools/studio/studioRoute.ts +5 -2
  83. package/server/devtools/types.ts +6 -0
  84. package/server/di/diLifecycle.ts +25 -186
  85. package/server/di/moduleSelection.ts +202 -0
  86. package/server/flightSanitizeRecorded.fixture.json +36 -34
  87. package/server/forwardedError.ts +43 -0
  88. package/server/gateway/childSupervisor.ts +8 -4
  89. package/server/gateway/gatewayChildren.ts +1 -0
  90. package/server/gateway/gatewayConfig.ts +5 -0
  91. package/server/gateway/gatewayHttpProxy.ts +1 -1
  92. package/server/gateway/gatewayStatus.ts +11 -1
  93. package/server/gateway/gatewayStatusPage.ts +18 -11
  94. package/server/headSplice.ts +73 -0
  95. package/server/hmr/clientReport.ts +9 -9
  96. package/server/hmr/clientScript.ts +4 -1
  97. package/server/hmr/csrDevShell.ts +7 -4
  98. package/server/hmr/devArtifactPruner.ts +7 -1
  99. package/server/hmr/devBaseArtifact.ts +5 -1
  100. package/server/hmr/wsHub.ts +1 -0
  101. package/server/htmlResultCache.ts +107 -39
  102. package/server/index.ts +5 -0
  103. package/server/lifecycle/buildEnv.ts +2 -0
  104. package/server/lifecycle/envProfile.ts +27 -0
  105. package/server/lifecycle/parentChannel.ts +11 -4
  106. package/server/lifecycle/secretEnv.ts +98 -0
  107. package/server/lifecycle/shutdownManager.ts +6 -0
  108. package/server/logging/logForwarder.ts +2 -2
  109. package/server/logging/serverLogging.ts +24 -10
  110. package/server/mcp/McpAppFrame.ts +42 -0
  111. package/server/mcp/McpAuth.ts +12 -2
  112. package/server/mcp/McpDispatcher.ts +20 -3
  113. package/server/mcp/McpFoundTools.ts +69 -0
  114. package/server/mcp/McpRouter.ts +165 -166
  115. package/server/mcp/McpSearch.ts +161 -0
  116. package/server/mcp/McpShelves.ts +95 -0
  117. package/server/mcp/McpWire.ts +92 -0
  118. package/server/mcp/index.ts +2 -0
  119. package/server/metrics/metricMerge.ts +1 -1
  120. package/server/metrics/pubsubGauges.ts +27 -0
  121. package/server/metrics/slowStatementLog.ts +63 -0
  122. package/server/metrics/statementMetrics.ts +259 -0
  123. package/server/metrics/statementPlanCheck.ts +141 -0
  124. package/server/metrics/statementReport.ts +105 -0
  125. package/server/migration/migrationRunner.ts +13 -10
  126. package/server/oauth/OAuthAuthorize.ts +8 -3
  127. package/server/oauth/OAuthErrors.ts +5 -1
  128. package/server/ops/statusAccess.ts +10 -2
  129. package/server/otlp/otlpBatcher.ts +221 -0
  130. package/server/otlp/otlpConfig.ts +185 -0
  131. package/server/otlp/otlpEncode.ts +114 -0
  132. package/server/otlp/otlpExporter.ts +98 -0
  133. package/server/otlp/otlpSampler.ts +50 -0
  134. package/server/pageFailure.ts +33 -0
  135. package/server/renderBusyResponse.ts +7 -2
  136. package/server/resolver/timedQuery.ts +7 -3
  137. package/server/resolver/unmountedRoutes.ts +55 -0
  138. package/server/routeCacheTally.ts +6 -0
  139. package/server/routeElementComposer.tsx +38 -3
  140. package/server/routeLevelRuns.ts +72 -0
  141. package/server/routeState.ts +1 -1
  142. package/server/routeTreeBuilder.ts +30 -1
  143. package/server/routing/apiRouter.ts +24 -7
  144. package/server/routing/appWsData.ts +4 -1
  145. package/server/routing/builtinRoutes.ts +13 -1
  146. package/server/routing/devBuild.ts +4 -0
  147. package/server/routing/devSurfacePolicy.ts +2 -1
  148. package/server/routing/devSurfaces.ts +4 -0
  149. package/server/routing/roomReplay.ts +4 -0
  150. package/server/routing/serverListener.ts +125 -55
  151. package/server/routing/soloAppRoutes.ts +7 -1
  152. package/server/routing/webSurfaceHold.ts +117 -0
  153. package/server/routing/wsCredentialRevocation.ts +55 -0
  154. package/server/rscClient.tsx +74 -7
  155. package/server/rscClientChunks.ts +8 -1
  156. package/server/rscClientErrors.ts +28 -0
  157. package/server/rscFirstRenderMemory.ts +49 -0
  158. package/server/rscFlightRenderer.ts +21 -4
  159. package/server/rscFlightStream.ts +2 -2
  160. package/server/rscPatchPlanner.ts +35 -9
  161. package/server/rscPrefetchCache.ts +19 -5
  162. package/server/rscPressLoading.tsx +40 -0
  163. package/server/rscRenderAdmission.ts +8 -2
  164. package/server/rscRenderHandler.ts +19 -3
  165. package/server/rscRenderStats.ts +3 -0
  166. package/server/rscRouteDocument.tsx +2 -2
  167. package/server/rscSegmentOutlet.tsx +21 -1
  168. package/server/rscSegmentOutletReference.ts +2 -1
  169. package/server/rscWorker.tsx +13 -2
  170. package/server/rscWorkerCache.ts +3 -1
  171. package/server/rscWorkerHost.ts +19 -2
  172. package/server/rscWorkerProcess.ts +24 -0
  173. package/server/rscWorkerRecycler.ts +3 -3
  174. package/server/scriptPolicy.ts +161 -0
  175. package/server/scriptPolicyReport.ts +147 -0
  176. package/server/selfExec.ts +13 -1
  177. package/server/serverConfig.ts +12 -0
  178. package/server/serverMetrics.ts +21 -2
  179. package/server/ssrFromRscRenderer.tsx +29 -201
  180. package/server/ssrInlineScripts.ts +202 -0
  181. package/server/ssrTypes.ts +9 -2
  182. package/server/systemPageDocument.tsx +6 -2
  183. package/server/systemPages.tsx +9 -4
  184. package/server/types.tsx +12 -0
  185. package/server/vendor/akanjs-client.ts +1 -0
  186. package/server/webArtifact.ts +16 -5
  187. package/server/webCsrSurface.ts +34 -12
  188. package/server/webDocumentRoute.ts +48 -18
  189. package/server/webRouteContext.ts +34 -7
  190. package/server/webRouter.ts +8 -0
  191. package/server/webRscRoute.ts +6 -3
  192. package/server/wellKnownRoutes.ts +4 -4
  193. package/service/agent.service.ts +1 -0
  194. package/service/agentLoop/agentLoop.ts +58 -19
  195. package/service/agentLoop/agentLoopTypes.ts +45 -0
  196. package/service/agentLoop/loopCompaction.ts +14 -4
  197. package/service/agentLoop/loopContext.ts +5 -2
  198. package/service/agentLoop/loopLent.ts +80 -0
  199. package/service/agentLoop/loopRequest.ts +25 -2
  200. package/service/agentLoop/loopToolBudget.ts +37 -0
  201. package/service/agentLoop/loopToolSearch.ts +85 -0
  202. package/service/agentLoop/loopToolkits.ts +223 -32
  203. package/service/agentLoop/loopTranscript.ts +1 -1
  204. package/service/ipcTypes.ts +38 -1
  205. package/service/predefinedAdaptor/anthropicLlm.ts +336 -56
  206. package/service/predefinedAdaptor/anthropicTools.ts +59 -0
  207. package/service/predefinedAdaptor/database.adaptor.ts +41 -9
  208. package/service/predefinedAdaptor/index.ts +1 -0
  209. package/service/predefinedAdaptor/llm.adaptor.ts +34 -0
  210. package/service/predefinedAdaptor/llmOverflow.ts +19 -0
  211. package/service/predefinedAdaptor/openaiDialect.ts +27 -13
  212. package/service/predefinedAdaptor/openaiLlm.ts +1 -2
  213. package/service/predefinedAdaptor/solidPubsub.adaptor.ts +16 -0
  214. package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +49 -11
  215. package/service/predefinedAdaptor/sql/driver/postgres.ts +47 -10
  216. package/service/predefinedAdaptor/sql/statementFingerprint.ts +117 -0
  217. package/service/predefinedAdaptor/sql/statementPlans.ts +71 -0
  218. package/service/predefinedAdaptor/sql/statementProbe.ts +110 -0
  219. package/service/predefinedAdaptor/sql/statementScrub.ts +149 -0
  220. package/service/predefinedAdaptor/websocket.adaptor.ts +62 -16
  221. package/service/toolNames.ts +7 -1
  222. package/signal/CrossSiteGuard.ts +5 -0
  223. package/signal/browserError.ts +28 -0
  224. package/signal/endpointInfo.ts +2 -1
  225. package/signal/errorReporting.ts +168 -0
  226. package/signal/index.ts +2 -0
  227. package/signal/internalInfo.ts +2 -2
  228. package/signal/mcp/McpDocument.ts +13 -4
  229. package/signal/mcp/mcpProtocol.ts +6 -0
  230. package/signal/requestTrace.ts +40 -3
  231. package/signal/roomKey.ts +3 -6
  232. package/signal/signalContext.ts +4 -4
  233. package/signal/spanExport.ts +137 -0
  234. package/signal/trace.ts +41 -10
  235. package/store/actionErrorMessage.ts +15 -1
  236. package/store/agent/AgentContext.ts +48 -8
  237. package/store/agent/AgentInline.ts +50 -0
  238. package/store/agent/AgentVisual.ts +3 -2
  239. package/store/agent/NavigateMove.ts +44 -0
  240. package/store/agent/ScreenReader.ts +7 -1
  241. package/store/agent/ScreenSettle.ts +35 -0
  242. package/store/agent/ScreenTarget.ts +2 -2
  243. package/store/agent/StoreCatalogue.ts +1 -1
  244. package/store/agent/StoreSurfaceSource.ts +89 -38
  245. package/store/agentic/AgentNavigate.ts +20 -0
  246. package/store/agentic/fieldToolEntries.ts +374 -0
  247. package/store/agentic/fieldTools.ts +49 -0
  248. package/store/agentic/formFields.ts +7 -2
  249. package/store/agentic/formFieldsReexport.ts +2 -0
  250. package/store/agentic/index.ts +2 -1
  251. package/store/agentic/useFieldTool.ts +3 -248
  252. package/store/agentic/useFormTools.ts +3 -45
  253. package/store/agentic/useRelationFieldTool.ts +2 -60
  254. package/store/baseSt.ts +7 -6
  255. package/store/draftStore.ts +2 -2
  256. package/store/formUploadOf.ts +6 -3
  257. package/store/index.ts +2 -0
  258. package/store/shellMirror.ts +49 -0
  259. package/store/sliceLiveActions.ts +4 -3
  260. package/store/storeFacade.ts +50 -0
  261. package/store/storeInstance.ts +92 -72
  262. package/test/signalTestRuntime.ts +9 -2
  263. package/test/testServer.ts +7 -1
  264. package/types/base/utils.d.ts +1 -0
  265. package/types/client/clientRuntime.d.ts +4 -0
  266. package/types/client/cookie.d.ts +4 -3
  267. package/types/client/csrLocation.d.ts +11 -3
  268. package/types/client/csrRuntimeParams.d.ts +6 -0
  269. package/types/client/csrTypes.d.ts +28 -2
  270. package/types/client/deepLinkStack.d.ts +13 -0
  271. package/types/client/device.d.ts +3 -1
  272. package/types/client/dictionaryAsset.d.ts +4 -1
  273. package/types/client/dictionaryGroups.d.ts +7 -0
  274. package/types/client/dictionaryModule.d.ts +10 -0
  275. package/types/client/dictionaryPart.d.ts +13 -0
  276. package/types/client/index.d.ts +8 -3
  277. package/types/client/keyboardRide.d.ts +14 -5
  278. package/types/client/makePageProto.d.ts +1 -1
  279. package/types/client/nativeErrorReport.d.ts +10 -0
  280. package/types/client/nativeHost.d.ts +1 -6
  281. package/types/client/nativeShell.d.ts +10 -0
  282. package/types/client/notFoundView.d.ts +8 -0
  283. package/types/client/pendingNavigation.d.ts +35 -0
  284. package/types/client/pressLoading.d.ts +4 -0
  285. package/types/client/redirectMove.d.ts +5 -0
  286. package/types/client/reportText.d.ts +4 -0
  287. package/types/client/route/RouteDefinition.d.ts +12 -1
  288. package/types/client/router.d.ts +13 -1
  289. package/types/client/rscClientErrorSender.d.ts +12 -0
  290. package/types/client/rscNavigation.d.ts +2 -0
  291. package/types/client/scriptPolicy.d.ts +4 -0
  292. package/types/client/sharedContextKey.d.ts +2 -0
  293. package/types/client/shellState.d.ts +54 -0
  294. package/types/client/shellStateHooks.d.ts +1 -0
  295. package/types/client/translator.d.ts +1 -0
  296. package/types/client/translatorState.d.ts +9 -1
  297. package/types/client/usePendingNavigation.d.ts +10 -0
  298. package/types/common/TraceContext.d.ts +1 -0
  299. package/types/common/index.d.ts +1 -0
  300. package/types/common/sessionTokenContract.d.ts +6 -0
  301. package/types/common/websocketContract.d.ts +1 -0
  302. package/types/constant/immerable.d.ts +1 -0
  303. package/types/constant/index.d.ts +1 -1
  304. package/types/constant/types.d.ts +6 -5
  305. package/types/dictionary/agent.dictionary.d.ts +1 -1
  306. package/types/dictionary/dictionary.d.ts +4 -4
  307. package/types/fetch/client/fetchClient.d.ts +3 -0
  308. package/types/fetch/client/httpClient.d.ts +1 -0
  309. package/types/fetch/client/modelRuntimes.d.ts +17 -0
  310. package/types/fetch/client/signalCatalog.d.ts +2 -1
  311. package/types/fetch/client/wsClient.d.ts +3 -1
  312. package/types/fetch/fetchType/appliedReturn.type.d.ts +4 -0
  313. package/types/fetch/requestStorage.d.ts +6 -0
  314. package/types/index.d.ts +58 -1
  315. package/types/server/akanOption.d.ts +16 -1
  316. package/types/server/akanServer.d.ts +15 -1
  317. package/types/server/appWorker.d.ts +40 -0
  318. package/types/server/appWorkerError.d.ts +4 -0
  319. package/types/server/appWorkerPath.d.ts +9 -0
  320. package/types/server/artifact/ipcTypes.d.ts +4 -0
  321. package/types/server/artifact/routeClientCache.d.ts +1 -0
  322. package/types/server/assetHeaders.d.ts +7 -4
  323. package/types/server/clientErrorReport.d.ts +28 -0
  324. package/types/server/clientReportId.d.ts +9 -0
  325. package/types/server/devtools/signalSerializer.d.ts +3 -1
  326. package/types/server/devtools/studio/studioDocument.d.ts +1 -0
  327. package/types/server/devtools/types.d.ts +5 -0
  328. package/types/server/di/diLifecycle.d.ts +2 -1
  329. package/types/server/di/moduleSelection.d.ts +22 -0
  330. package/types/server/forwardedError.d.ts +13 -0
  331. package/types/server/gateway/gatewayChildren.d.ts +1 -0
  332. package/types/server/gateway/gatewayConfig.d.ts +1 -0
  333. package/types/server/gateway/gatewayStatus.d.ts +1 -0
  334. package/types/server/headSplice.d.ts +11 -0
  335. package/types/server/hmr/clientReport.d.ts +2 -0
  336. package/types/server/hmr/csrDevShell.d.ts +3 -1
  337. package/types/server/hmr/devBaseArtifact.d.ts +1 -0
  338. package/types/server/hmr/wsHub.d.ts +1 -0
  339. package/types/server/htmlResultCache.d.ts +8 -1
  340. package/types/server/index.d.ts +5 -1
  341. package/types/server/lifecycle/buildEnv.d.ts +1 -0
  342. package/types/server/lifecycle/envProfile.d.ts +7 -0
  343. package/types/server/lifecycle/parentChannel.d.ts +2 -2
  344. package/types/server/lifecycle/secretEnv.d.ts +20 -0
  345. package/types/server/logging/logForwarder.d.ts +1 -0
  346. package/types/server/logging/rotatingLogWriter.d.ts +1 -1
  347. package/types/server/logging/serverLogging.d.ts +1 -0
  348. package/types/server/mcp/McpAppFrame.d.ts +9 -0
  349. package/types/server/mcp/McpAuth.d.ts +2 -0
  350. package/types/server/mcp/McpDispatcher.d.ts +7 -2
  351. package/types/server/mcp/McpFoundTools.d.ts +14 -0
  352. package/types/server/mcp/McpRouter.d.ts +6 -0
  353. package/types/server/mcp/McpSearch.d.ts +40 -0
  354. package/types/server/mcp/McpShelves.d.ts +30 -0
  355. package/types/server/mcp/McpWire.d.ts +39 -0
  356. package/types/server/mcp/index.d.ts +2 -0
  357. package/types/server/metrics/pubsubGauges.d.ts +6 -0
  358. package/types/server/metrics/slowStatementLog.d.ts +18 -0
  359. package/types/server/metrics/statementMetrics.d.ts +45 -0
  360. package/types/server/metrics/statementPlanCheck.d.ts +16 -0
  361. package/types/server/metrics/statementReport.d.ts +28 -0
  362. package/types/server/oauth/OAuthAuthorize.d.ts +5 -2
  363. package/types/server/ops/statusAccess.d.ts +1 -0
  364. package/types/server/otlp/otlpBatcher.d.ts +18 -0
  365. package/types/server/otlp/otlpConfig.d.ts +25 -0
  366. package/types/server/otlp/otlpEncode.d.ts +13 -0
  367. package/types/server/otlp/otlpExporter.d.ts +18 -0
  368. package/types/server/otlp/otlpSampler.d.ts +10 -0
  369. package/types/server/pageFailure.d.ts +14 -0
  370. package/types/server/resolver/timedQuery.d.ts +1 -0
  371. package/types/server/resolver/unmountedRoutes.d.ts +6 -0
  372. package/types/server/routeCacheTally.d.ts +1 -1
  373. package/types/server/routeElementComposer.d.ts +8 -2
  374. package/types/server/routeLevelRuns.d.ts +12 -0
  375. package/types/server/routing/apiRouter.d.ts +1 -0
  376. package/types/server/routing/appWsData.d.ts +1 -0
  377. package/types/server/routing/devBuild.d.ts +3 -0
  378. package/types/server/routing/roomReplay.d.ts +1 -0
  379. package/types/server/routing/serverListener.d.ts +6 -1
  380. package/types/server/routing/soloAppRoutes.d.ts +2 -1
  381. package/types/server/routing/webSurfaceHold.d.ts +13 -0
  382. package/types/server/routing/wsCredentialRevocation.d.ts +13 -0
  383. package/types/server/rscClient.d.ts +2 -0
  384. package/types/server/rscClientChunks.d.ts +3 -1
  385. package/types/server/rscClientErrors.d.ts +3 -0
  386. package/types/server/rscFirstRenderMemory.d.ts +16 -0
  387. package/types/server/rscFlightStream.d.ts +1 -1
  388. package/types/server/rscPatchPlanner.d.ts +1 -1
  389. package/types/server/rscPrefetchCache.d.ts +1 -0
  390. package/types/server/rscPressLoading.d.ts +5 -0
  391. package/types/server/rscRenderStats.d.ts +2 -0
  392. package/types/server/rscSegmentOutlet.d.ts +4 -1
  393. package/types/server/rscSegmentOutletReference.d.ts +2 -1
  394. package/types/server/rscWorkerCache.d.ts +3 -1
  395. package/types/server/rscWorkerProcess.d.ts +1 -0
  396. package/types/server/rscWorkerRecycler.d.ts +1 -1
  397. package/types/server/scriptPolicy.d.ts +38 -0
  398. package/types/server/scriptPolicyReport.d.ts +18 -0
  399. package/types/server/selfExec.d.ts +1 -0
  400. package/types/server/serverConfig.d.ts +1 -0
  401. package/types/server/serverMetrics.d.ts +3 -1
  402. package/types/server/ssrFromRscRenderer.d.ts +2 -6
  403. package/types/server/ssrInlineScripts.d.ts +42 -0
  404. package/types/server/ssrTypes.d.ts +9 -2
  405. package/types/server/systemPageDocument.d.ts +3 -1
  406. package/types/server/systemPages.d.ts +2 -1
  407. package/types/server/types.d.ts +25 -0
  408. package/types/server/vendor/akanjs-client.d.ts +1 -0
  409. package/types/server/webRouteContext.d.ts +5 -4
  410. package/types/server/webRouter.d.ts +1 -0
  411. package/types/service/agent.service.d.ts +1 -0
  412. package/types/service/agentLoop/agentLoop.d.ts +2 -1
  413. package/types/service/agentLoop/agentLoopTypes.d.ts +43 -0
  414. package/types/service/agentLoop/loopCompaction.d.ts +2 -2
  415. package/types/service/agentLoop/loopLent.d.ts +16 -0
  416. package/types/service/agentLoop/loopToolBudget.d.ts +8 -0
  417. package/types/service/agentLoop/loopToolSearch.d.ts +13 -0
  418. package/types/service/agentLoop/loopToolkits.d.ts +9 -2
  419. package/types/service/ipcTypes.d.ts +39 -1
  420. package/types/service/predefinedAdaptor/anthropicLlm.d.ts +85 -18
  421. package/types/service/predefinedAdaptor/anthropicTools.d.ts +32 -0
  422. package/types/service/predefinedAdaptor/database.adaptor.d.ts +2 -0
  423. package/types/service/predefinedAdaptor/index.d.ts +1 -0
  424. package/types/service/predefinedAdaptor/llm.adaptor.d.ts +33 -0
  425. package/types/service/predefinedAdaptor/llmOverflow.d.ts +7 -0
  426. package/types/service/predefinedAdaptor/solidPubsub.adaptor.d.ts +3 -1
  427. package/types/service/predefinedAdaptor/sql/driver/bunSqlite.d.ts +3 -1
  428. package/types/service/predefinedAdaptor/sql/driver/postgres.d.ts +3 -1
  429. package/types/service/predefinedAdaptor/sql/statementFingerprint.d.ts +21 -0
  430. package/types/service/predefinedAdaptor/sql/statementPlans.d.ts +17 -0
  431. package/types/service/predefinedAdaptor/sql/statementProbe.d.ts +37 -0
  432. package/types/service/predefinedAdaptor/sql/statementScrub.d.ts +5 -0
  433. package/types/service/predefinedAdaptor/websocket.adaptor.d.ts +10 -0
  434. package/types/signal/CrossSiteGuard.d.ts +1 -0
  435. package/types/signal/agent.signal.d.ts +1 -0
  436. package/types/signal/browserError.d.ts +20 -0
  437. package/types/signal/endpointInfo.d.ts +2 -2
  438. package/types/signal/errorReporting.d.ts +27 -0
  439. package/types/signal/index.d.ts +2 -0
  440. package/types/signal/internalInfo.d.ts +2 -2
  441. package/types/signal/mcp/McpDocument.d.ts +3 -0
  442. package/types/signal/mcp/mcpProtocol.d.ts +5 -0
  443. package/types/signal/requestTrace.d.ts +3 -1
  444. package/types/signal/spanExport.d.ts +47 -0
  445. package/types/signal/trace.d.ts +8 -2
  446. package/types/store/actionErrorMessage.d.ts +1 -0
  447. package/types/store/agent/AgentContext.d.ts +2 -0
  448. package/types/store/agent/AgentInline.d.ts +5 -0
  449. package/types/store/agent/NavigateMove.d.ts +7 -0
  450. package/types/store/agent/ScreenReader.d.ts +2 -0
  451. package/types/store/agent/ScreenSettle.d.ts +7 -0
  452. package/types/store/agent/StoreSurfaceSource.d.ts +1 -1
  453. package/types/store/agentic/AgentNavigate.d.ts +10 -0
  454. package/types/store/agentic/fieldToolEntries.d.ts +28 -0
  455. package/types/store/agentic/fieldTools.d.ts +5 -0
  456. package/types/store/agentic/formFieldsReexport.d.ts +1 -0
  457. package/types/store/agentic/index.d.ts +2 -1
  458. package/types/store/baseSt.d.ts +1 -1
  459. package/types/store/index.d.ts +1 -1
  460. package/types/store/shellMirror.d.ts +8 -0
  461. package/types/store/storeFacade.d.ts +9 -0
  462. package/types/test/signalTestRuntime.d.ts +1 -1
  463. package/types/test/testServer.d.ts +2 -0
  464. package/types/ui/Constant/schemaDoc.d.ts +1 -0
  465. package/types/ui/Data/Dashboard.d.ts +1 -0
  466. package/types/ui/Data/ListContainer.d.ts +1 -0
  467. package/types/ui/Data/QueryMaker.d.ts +1 -0
  468. package/types/ui/Data/RefPicker.d.ts +1 -0
  469. package/types/ui/Dialog/LazyLegacyModal.d.ts +1 -0
  470. package/types/ui/DismissDragGesture.d.ts +9 -0
  471. package/types/ui/Field/Text.d.ts +2 -2
  472. package/types/ui/Field/lightRefCache.d.ts +2 -1
  473. package/types/ui/Field/useRelationWindow.d.ts +2 -1
  474. package/types/ui/Link/Anchor.d.ts +4 -2
  475. package/types/ui/Load/LoadingMark.d.ts +4 -0
  476. package/types/ui/Load/Stream.d.ts +1 -1
  477. package/types/ui/Load/StreamDeferred.d.ts +11 -0
  478. package/types/ui/Load/sliceClaim.d.ts +4 -3
  479. package/types/ui/Model/resetModels.d.ts +1 -0
  480. package/types/ui/Signal/Arg.d.ts +1 -0
  481. package/types/ui/Signal/Doc.d.ts +1 -0
  482. package/types/ui/Signal/Endpoint.d.ts +1 -0
  483. package/types/ui/Signal/RestApi.d.ts +1 -0
  484. package/types/ui/Signal/WebSocket.d.ts +1 -0
  485. package/types/ui/Signal/endpointEntries.d.ts +1 -0
  486. package/types/ui/Signal/makeExample.d.ts +1 -0
  487. package/types/ui/Signal/useApiDescriptions.d.ts +1 -0
  488. package/types/ui/System/isSamePathValue.d.ts +2 -0
  489. package/types/ui/modelRuntime.d.ts +1 -0
  490. package/types/ui/useDismissDrag.d.ts +10 -3
  491. package/types/ui/useLeave.d.ts +9 -0
  492. package/types/vendor/@akanjs/native/packages/cli/src/config.d.ts +9 -0
  493. package/types/vendor/@akanjs/native/packages/cli/src/lib/debugsuffix.d.ts +3 -0
  494. package/types/vendor/@akanjs/native/packages/cli/src/lib/maven.d.ts +2 -2
  495. package/types/vendor/@akanjs/native/packages/cli/src/lib/prepare.d.ts +4 -0
  496. package/types/vendor/@akanjs/native/packages/core/src/boot.d.ts +2 -2
  497. package/types/vendor/@akanjs/native/plugins/keyboard/src/index.d.ts +3 -2
  498. package/types/vendor/use-agentic/types.d.ts +2 -0
  499. package/types/webkit/CsrMoves.d.ts +7 -0
  500. package/types/webkit/CsrStack.d.ts +2 -1
  501. package/types/webkit/McpAppHost.d.ts +4 -1
  502. package/types/webkit/csrPageReadiness.d.ts +18 -0
  503. package/types/webkit/csrPendingNavigation.d.ts +7 -0
  504. package/types/webkit/csrSlide.d.ts +37 -0
  505. package/types/webkit/isDragLift.d.ts +5 -0
  506. package/types/webkit/nativeNavigation.d.ts +4 -2
  507. package/types/webkit/nativeSplash.d.ts +6 -0
  508. package/types/webkit/openSurfaces.d.ts +13 -0
  509. package/types/webkit/scrollerTakesDrag.d.ts +4 -0
  510. package/types/webkit/useCsrNavigation.d.ts +2 -2
  511. package/types/webkit/useEscapeKey.d.ts +7 -2
  512. package/types/webkit/useFrameRuntime.d.ts +5 -2
  513. package/types/webkit/useResolvedFrame.d.ts +2 -0
  514. package/ui/Agent/Chat.tsx +65 -46
  515. package/ui/Agent/agentSessionOf.ts +2 -1
  516. package/ui/Agent/fetchRunner.ts +5 -1
  517. package/ui/Agent/useKeyboardFrame.ts +4 -2
  518. package/ui/BottomSheet.tsx +3 -7
  519. package/ui/Constant/schemaDoc.ts +1 -0
  520. package/ui/Copy.tsx +5 -3
  521. package/ui/Data/Dashboard.tsx +1 -0
  522. package/ui/Data/ListContainer.tsx +1 -0
  523. package/ui/Data/QueryMaker.tsx +1 -0
  524. package/ui/Data/RefPicker.tsx +1 -0
  525. package/ui/Dialog/LazyLegacyModal.tsx +5 -0
  526. package/ui/Dialog/LegacyModal.tsx +3 -4
  527. package/ui/Dialog/Modal.tsx +40 -22
  528. package/ui/Dialog/index.tsx +2 -2
  529. package/ui/Dialog/modalSurface.ts +6 -4
  530. package/ui/DismissDragGesture.tsx +19 -0
  531. package/ui/DragAction.tsx +9 -4
  532. package/ui/Field/Label.tsx +5 -2
  533. package/ui/Field/Text.tsx +7 -4
  534. package/ui/Field/index.tsx +2 -3
  535. package/ui/Field/lightRefCache.ts +9 -8
  536. package/ui/Field/useRelationOptions.ts +2 -2
  537. package/ui/Field/useRelationWindow.ts +9 -4
  538. package/ui/Input.tsx +1 -1
  539. package/ui/Link/Anchor.tsx +34 -5
  540. package/ui/Link/activePath.ts +2 -3
  541. package/ui/Link/index.tsx +11 -1
  542. package/ui/Load/LoadingMark.tsx +8 -0
  543. package/ui/Load/PageCSR.tsx +3 -1
  544. package/ui/Load/Stream.tsx +11 -1
  545. package/ui/Load/StreamDeferred.tsx +27 -0
  546. package/ui/Load/Units.tsx +4 -3
  547. package/ui/Load/sliceClaim.ts +11 -5
  548. package/ui/Model/EditModal.tsx +6 -7
  549. package/ui/Model/EditWrapper.tsx +2 -3
  550. package/ui/Model/NewWrapper_Client.tsx +2 -3
  551. package/ui/Model/ViewEditModal.tsx +4 -5
  552. package/ui/Model/ViewModal.tsx +2 -3
  553. package/ui/Model/ViewWrapper.tsx +2 -3
  554. package/ui/Model/editSeed.ts +1 -1
  555. package/ui/Model/resetModels.ts +11 -0
  556. package/ui/Signal/Arg.tsx +4 -1
  557. package/ui/Signal/Doc.tsx +12 -3
  558. package/ui/Signal/Endpoint.tsx +4 -1
  559. package/ui/Signal/RestApi.tsx +1 -0
  560. package/ui/Signal/WebSocket.tsx +1 -0
  561. package/ui/Signal/endpointEntries.ts +1 -0
  562. package/ui/Signal/makeExample.ts +1 -0
  563. package/ui/Signal/useApiDescriptions.ts +10 -0
  564. package/ui/System/CSR.tsx +41 -13
  565. package/ui/System/Client.tsx +75 -61
  566. package/ui/System/Messages.tsx +31 -47
  567. package/ui/System/isSamePathValue.ts +13 -0
  568. package/ui/Tooltip.tsx +1 -1
  569. package/ui/agentAttrs.ts +1 -1
  570. package/ui/modelRuntime.ts +2 -0
  571. package/ui/styles.css +14 -0
  572. package/ui/useDismissDrag.ts +135 -5
  573. package/ui/useLeave.ts +42 -0
  574. package/vendor/@akanjs/native/README.ko.md +1 -1
  575. package/vendor/@akanjs/native/README.md +1 -1
  576. package/vendor/@akanjs/native/THIRD_PARTY_NOTICES.md +78 -56
  577. package/vendor/@akanjs/native/native/android/maven.lock.json +462 -1
  578. package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeActivity.kt +27 -14
  579. package/vendor/@akanjs/native/native/ios/Sources/AkanNativePlugin.swift +9 -0
  580. package/vendor/@akanjs/native/packages/cli/src/config.ts +9 -0
  581. package/vendor/@akanjs/native/packages/cli/src/lib/compat.ts +1 -1
  582. package/vendor/@akanjs/native/packages/cli/src/lib/configkeys.ts +8 -2
  583. package/vendor/@akanjs/native/packages/cli/src/lib/debugsuffix.ts +18 -0
  584. package/vendor/@akanjs/native/packages/cli/src/lib/distribution.ts +1 -1
  585. package/vendor/@akanjs/native/packages/cli/src/lib/maven.ts +12 -4
  586. package/vendor/@akanjs/native/packages/cli/src/lib/prepare.ts +12 -0
  587. package/vendor/@akanjs/native/packages/cli/src/lib/project.ts +2 -4
  588. package/vendor/@akanjs/native/packages/cli/src/platforms/android.ts +4 -4
  589. package/vendor/@akanjs/native/packages/cli/src/platforms/ios.ts +10 -10
  590. package/vendor/@akanjs/native/packages/core/src/boot.ts +2 -2
  591. package/vendor/@akanjs/native/plugins/browser/ios/BrowserPlugin.swift +4 -3
  592. package/vendor/@akanjs/native/plugins/camera/ios/CameraPlugin.swift +3 -0
  593. package/vendor/@akanjs/native/plugins/keyboard/src/index.ts +3 -2
  594. package/vendor/use-agentic/types.ts +2 -0
  595. package/webkit/CsrMoves.ts +30 -0
  596. package/webkit/CsrRouteTable.ts +2 -1
  597. package/webkit/CsrStack.ts +17 -9
  598. package/webkit/McpAppAgent.ts +1 -1
  599. package/webkit/McpAppFetchBridge.ts +1 -1
  600. package/webkit/McpAppHost.ts +14 -2
  601. package/webkit/RenderLayer.tsx +177 -79
  602. package/webkit/bootCsr.tsx +27 -9
  603. package/webkit/csrPageReadiness.ts +43 -0
  604. package/webkit/csrPendingNavigation.ts +24 -0
  605. package/webkit/csrSlide.ts +190 -0
  606. package/webkit/isDragLift.ts +7 -0
  607. package/webkit/nativeNavigation.ts +42 -4
  608. package/webkit/nativeSplash.ts +30 -0
  609. package/webkit/openSurfaces.ts +54 -0
  610. package/webkit/scrollerTakesDrag.ts +34 -0
  611. package/webkit/useCsrNavigation.ts +109 -36
  612. package/webkit/useCsrStackLifecycle.ts +2 -1
  613. package/webkit/useCsrTransitions.ts +190 -44
  614. package/webkit/useCsrValues.ts +55 -33
  615. package/webkit/useEscapeKey.tsx +10 -23
  616. package/webkit/useFrameRuntime.ts +11 -5
  617. package/webkit/usePageLocation.ts +4 -5
  618. package/ARCHITECTURE.md +0 -199
  619. package/CHANGELOG.md +0 -5265
  620. package/CODE_OF_CONDUCT.md +0 -54
  621. package/CONTRIBUTING.md +0 -109
  622. package/vendor/@akanjs/native/CHANGELOG.md +0 -32
  623. package/vendor/use-agentic/CHANGELOG.md +0 -708
package/README.ko.md CHANGED
@@ -47,10 +47,13 @@ akan start <app-name> --open
47
47
  ### 기존 저장소 안에서 시작하기
48
48
 
49
49
  앱이 놓일 폴더와 실행 방식이 정해진 작업이라면, 예를 들어 다른 저장소의 하위 폴더, Node와 npm만 있는 호스트, 스펙이 정한
50
- URL이라면, 코딩 에이전트는 묻지 않고 아래대로 진행하면 됩니다.
50
+ URL이라면, 코딩 에이전트는 묻지 않고 아래대로 진행하면 됩니다. 스캐폴드에 필요한 것은 아래가 전부라서 다른 패키지의
51
+ README나 코드를 먼저 읽을 필요가 없습니다.
51
52
 
52
53
  - **그 폴더에 바로 만들기:** `bunx create-akan-workspace@latest . --app <app> --dir <folder> --sample false`.
53
- `<folder>` 자체에 쓰고, 이미 있는 파일은 덮어쓰지 않고 멈추며, 샘플 모듈과 페이지는 만들지 않습니다. 함께 생기는
54
+ `<folder>` 자체에 쓰고, 이미 있는 파일은 덮어쓰지 않고 멈추며, 샘플 모듈과 페이지는 만들지 않습니다. `akan` CLI는
55
+ Bun의 전역 폴더(`~/.bun`, `PATH`에는 아무것도 넣지 않음)에 설치하고 `bun install`을 실행할 뿐, 빌드도 서버 실행도
56
+ 하지 않으며, 다른 git 저장소가 추적하는 폴더에서는 `git init`도 커밋도 하지 않습니다. 함께 생기는
54
57
  `AGENTS.md`, `CLAUDE.md`, `.claude/`, `.agents/`, `.cursor/`, `.mcp.json`은 지우지 마세요. 에이전트가 따를 규칙과
55
58
  도구가 들어 있습니다.
56
59
  - **`<folder>`에서 작업하기.** `akan`은 워크스페이스 루트에서만 실행되고, 그곳에서 연 에이전트 세션이 워크스페이스의
@@ -61,9 +64,9 @@ URL이라면, 코딩 에이전트는 묻지 않고 아래대로 진행하면 됩
61
64
  (`/books/OL45804W`)로 내보내려면 `akan.config.ts`에 `i18n: { defaultLocale: "en", locales: ["en"], localePrefix:
62
65
  "as-needed" }`를 두세요. `<Link>`도 따라갑니다.
63
66
  - **Node와 npm만 있는 호스트:** `npx -y bun@1.4.4 x create-akan-workspace@latest . --app <app> --dir <folder> --sample false`를
64
- 실행한 뒤 `npm run build`, `PORT=3000 npm start`로 빌드하고 띄웁니다. 생성기가 쓰는 script와 새로 clone한 사본에
65
- 필요한 것은 [`create-akan-workspace` README](https://github.com/akan-team/akanjs/blob/main/pkgs/create-akan-workspace/README.ko.md#node와-npm만-있을-때)에
66
- 있습니다.
67
+ 실행한 뒤 `npm run build`, `PORT=3000 npm start`로 빌드하고 띄우고, 나머지는 `npx akan <command>`로 실행합니다.
68
+ 워크스페이스가 `bun`을 의존성에 넣어 둡니다. `npm i -g bun`으로 설치한 Bun으로 실행해도 같습니다. 새로 clone한 사본도 그대로 빌드됩니다. 빌드가 git이 무시하는 파일 중 없는
69
+ 것을 먼저 씁니다.
67
70
  - **실행할 곳에 맞게 빌드하기.** 셸이나 Bun이 읽는 `.env.local`에서 지정한 변수가 워크스페이스 `.env`보다 우선하고(빈
68
71
  값은 지정하지 않은 것으로 보며, 빌드는 그렇게 가져간 값을 하나씩 알려 줍니다), `AKAN_PUBLIC_ENV`는 `--env`가 둘보다
69
72
  우선합니다. 새 워크스페이스의 `.env`는 `local`이라 내 컴퓨터나 테스트 러너에서는 이대로 맞지만, 서버가
@@ -107,6 +110,7 @@ cd dist/apps/<app> && PORT=3000 bun main.js
107
110
  - `akanjs`는 npm 패키지 하나입니다. subpath(`akanjs/base`, `akanjs/client`, `akanjs/signal`, `akanjs/ui`, …)가 서버
108
111
  전용, 클라이언트 전용, UI, 툴링 코드를 나누고([패키지 레퍼런스](https://akanjs.com/references/akanjs/base)), 툴링은
109
112
  `@akanjs/cli`와 `@akanjs/devkit`으로 나옵니다.
113
+ - 버전별 변경: [`CHANGELOG.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CHANGELOG.md).
110
114
  - 기여: [`CONTRIBUTING.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CONTRIBUTING.md)와
111
115
  [행동 강령](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CODE_OF_CONDUCT.md). 라이선스: MIT
112
116
  ([`LICENSE`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/LICENSE)).
package/README.md CHANGED
@@ -46,11 +46,13 @@ generates a sample app. The app opens on `http://localhost:8282`.
46
46
  ### Inside an existing repository
47
47
 
48
48
  When a task fixes where the app lives and how it runs, for example a folder in another repository, a host with only
49
- Node and npm, or URLs given by a spec, a coding agent needs these, and nothing has to ask:
49
+ Node and npm, or URLs given by a spec, a coding agent needs these, and nothing has to ask. They are the whole
50
+ scaffold: no other package's README or code has to be read first.
50
51
 
51
52
  - **Create the workspace in that folder:** `bunx create-akan-workspace@latest . --app <app> --dir <folder> --sample false`.
52
53
  It writes into `<folder>` itself, refuses to overwrite a file already there, and leaves out the sample module and
53
- pages. Keep the `AGENTS.md`, `CLAUDE.md`, `.claude/`, `.agents/`, `.cursor/` and `.mcp.json` it writes: they carry
54
+ pages. It also puts the `akan` CLI in Bun's global folder (`~/.bun`, nothing on `PATH`) and runs `bun install`; it
55
+ builds and starts nothing, and in a folder another git repository tracks it neither runs `git init` nor commits. Keep the `AGENTS.md`, `CLAUDE.md`, `.claude/`, `.agents/`, `.cursor/` and `.mcp.json` it writes: they carry
54
56
  the rules and tools an agent works through.
55
57
  - **Work from `<folder>`.** `akan` runs only from the workspace root, and an agent session opened there loads the
56
58
  workspace's rules and MCP server.
@@ -60,9 +62,8 @@ Node and npm, or URLs given by a spec, a coding agent needs these, and nothing h
60
62
  set `i18n: { defaultLocale: "en", locales: ["en"], localePrefix: "as-needed" }` in `akan.config.ts`; `<Link>`
61
63
  follows.
62
64
  - **A host with only Node and npm:** `npx -y bun@1.4.4 x create-akan-workspace@latest . --app <app> --dir <folder> --sample false`,
63
- then `npm run build` and `PORT=3000 npm start`. The
64
- [`create-akan-workspace` README](https://www.npmjs.com/package/create-akan-workspace#with-only-node-and-npm) has the
65
- scripts it writes and what a fresh clone needs.
65
+ then `npm run build` and `PORT=3000 npm start`, and `npx akan <command>` for the rest: the workspace lists `bun` in
66
+ its dependencies, as it does under a Bun from `npm i -g bun`. A fresh clone builds as is, since the build writes the git-ignored files it lacks.
66
67
  - **Build for where it runs.** A variable set in the shell, or in a `.env.local` Bun loads, outranks the workspace `.env`
67
68
  (an empty one counts as unset, and the build names each one it took), and `--env` outranks both for `AKAN_PUBLIC_ENV`. A new workspace's `.env` says `local`, which suits your own machine or a test runner, but the
68
69
  server runs without endpoint rate limits and on local defaults. For a host others can reach, run
@@ -106,6 +107,7 @@ you are running on a public URL.
106
107
  - `akanjs` is one npm package. Its subpaths (`akanjs/base`, `akanjs/client`, `akanjs/signal`, `akanjs/ui`, …) keep
107
108
  server-only, client-only, UI and tooling code apart, and the [package reference](https://akanjs.com/references/akanjs/base)
108
109
  covers them; the tooling ships as `@akanjs/cli` and `@akanjs/devkit`.
110
+ - Changes by version: [`CHANGELOG.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CHANGELOG.md).
109
111
  - Contributing: [`CONTRIBUTING.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CONTRIBUTING.md) and
110
112
  the [code of conduct](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CODE_OF_CONDUCT.md). License: MIT
111
113
  ([`LICENSE`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/LICENSE)).
package/base/utils.ts CHANGED
@@ -25,3 +25,5 @@ export const applyFnToArrayObjects = <Input, Fn extends (arg: never) => unknown>
25
25
  if (Array.isArray(arraiedData)) return arraiedData.map((data) => applyFnToArrayObjects(data, fn)) as Result;
26
26
  return fn(arraiedData as never) as Result;
27
27
  };
28
+
29
+ export const loadedAfter = (..._modules: unknown[]): void => {};
@@ -1,5 +1,6 @@
1
1
  import { Href } from "./href";
2
- import { isNativeShell } from "./nativeHost";
2
+
3
+ import { isNativeShell } from "./nativeShell";
3
4
 
4
5
  export const closeAppOpenedTab = (): boolean => {
5
6
  const win = globalThis.window;
@@ -38,6 +38,8 @@ type RuntimeErr = {
38
38
 
39
39
  type RuntimeWs = {
40
40
  connected: boolean;
41
+ state?: "connecting" | "open" | "closed" | "gaveUp";
42
+ connect?: (option?: { fresh?: boolean }) => void;
41
43
  on: (event: string, handler: (...args: unknown[]) => void) => void;
42
44
  off: (event: string, handler: (...args: unknown[]) => void) => void;
43
45
  };
package/client/cookie.ts CHANGED
@@ -153,25 +153,34 @@ export interface GetOption {
153
153
  unauthorize: string;
154
154
  }
155
155
  interface SetAuthOption {
156
- jwt: string;
156
+ jwt?: string | null;
157
157
  }
158
158
  const announceAuth = () => {
159
159
  if (typeof window !== "undefined") window.dispatchEvent(new Event("akan:auth"));
160
160
  };
161
+
162
+ const reopenSocket = () => {
163
+ const { ws } = fetch;
164
+ if (ws?.state === "open" || ws?.state === "connecting") ws.connect?.({ fresh: true });
165
+ };
161
166
  /** Sets the active auth token on fetch, then keeps it where the next launch finds it: client storage on a CSR client,
162
- * the session cookie elsewhere unless the server already holds it there (`SessionCookie.issue`). */
163
- export const setAuth = ({ jwt }: SetAuthOption) => {
164
- fetch.setJwt(jwt);
167
+ * the session cookie elsewhere unless the server already holds it there (`SessionCookie.issue`). An answer with no
168
+ * token beside a session the server holds is a cookie-only session: fetch sends no token and the socket reconnects. */
169
+ export const setAuth = ({ jwt }: SetAuthOption = {}) => {
170
+ const token = jwt ?? "";
171
+ const cookieOnly = !token && serverHoldsSession();
172
+ fetch.setJwt(cookieOnly ? null : token);
165
173
 
166
- if (isCsrClient()) void secretStorage.setItem(storedAuthTokenKey(), jwt);
174
+ if (isCsrClient()) void secretStorage.setItem(storedAuthTokenKey(), token);
167
175
  else {
168
176
 
169
177
  void secretStorage.removeItem(storedAuthTokenKey());
170
- if (!serverHoldsSession()) setCookie(authTokenKey(), jwt);
178
+ if (!serverHoldsSession()) setCookie(authTokenKey(), token);
171
179
  }
172
180
 
173
181
  for (const key of retiredAuthTokenKeys()) removeCookie(key);
174
182
  void secretStorage.removeItem(legacyAuthTokenKey);
183
+ if (cookieOnly) reopenSocket();
175
184
  announceAuth();
176
185
  };
177
186
 
@@ -4,12 +4,16 @@ declare global {
4
4
  var __AKAN_EMBED__: { kind: "mcp-app"; origin?: string; account?: Record<string, unknown> | null } | undefined;
5
5
  }
6
6
 
7
+ const popWaitMs = 1000;
8
+
7
9
  /** The document's location and history, as the routers read and move them. */
8
10
  export class CsrLocation {
9
11
 
10
12
  #view: URL | null = null;
11
- #entry: { idx: number | undefined; href: string } | null = null;
13
+ #entry: { idx: number | undefined; href: string; from: string | undefined } | null = null;
12
14
  #onBack: ((idx: number) => void) | null = null;
15
+ #backAsked: object | null = null;
16
+ #backSent: object | null = null;
13
17
 
14
18
  /** Reads `href`, a path on the app's origin, as this document's location from now on; a view never moves. */
15
19
  view(href: string) {
@@ -44,25 +48,28 @@ export class CsrLocation {
44
48
  }
45
49
 
46
50
  /**
47
- * The entry on screen as of the last write or traversal, and its index; during a `popstate` it is still the entry
48
- * left, which `state` no longer reads.
51
+ * The entry on screen as of the last write or traversal, its index, and `from`, the address a push stacked it on
52
+ * (none for an entry a document load or a fragment link made); during a `popstate` it is still the entry left,
53
+ * which `state` no longer reads.
49
54
  */
50
55
  entry() {
51
56
  return this.#entry ?? this.observe();
52
57
  }
53
58
 
54
59
  observe() {
55
- this.#entry = { idx: CsrLocation.idxOf(window.history?.state), href: this.href };
60
+ const state = window.history?.state;
61
+ this.#entry = { idx: CsrLocation.idxOf(state), href: this.href, from: CsrLocation.#fromOf(state) };
56
62
  return this.#entry;
57
63
  }
58
64
 
59
65
  push(state: unknown, href: string) {
60
- window.history.pushState(CsrLocation.#indexed(state, (this.entry().idx ?? 0) + 1), "", href);
66
+ const stacked = CsrLocation.#indexed(state, (this.entry().idx ?? 0) + 1) as { __akanRouter?: object };
67
+ window.history.pushState({ ...stacked, __akanRouter: { ...stacked.__akanRouter, from: this.href } }, "", href);
61
68
  this.observe();
62
69
  }
63
70
 
64
71
  replace(state: unknown, href?: string) {
65
- const indexed = CsrLocation.#indexed(state, this.entry().idx ?? 0);
72
+ const indexed = CsrLocation.#rewritten(CsrLocation.#indexed(state, this.entry().idx ?? 0), window.history.state);
66
73
  if (href === undefined) window.history.replaceState(indexed, "");
67
74
  else window.history.replaceState(indexed, "", href);
68
75
  this.observe();
@@ -73,6 +80,18 @@ export class CsrLocation {
73
80
  return Number.isInteger(idx) ? (idx as number) : undefined;
74
81
  }
75
82
 
83
+ static #fromOf(state: unknown) {
84
+ const from = (state as { __akanRouter?: { from?: unknown } } | null)?.__akanRouter?.from;
85
+ return typeof from === "string" ? from : undefined;
86
+ }
87
+
88
+ static #rewritten(state: unknown, live: unknown) {
89
+ const from = CsrLocation.#fromOf(live);
90
+ if (from === undefined || CsrLocation.#fromOf(state) !== undefined) return state;
91
+ const record = (state ?? {}) as { __akanRouter?: object };
92
+ return { ...record, __akanRouter: { ...record.__akanRouter, from } };
93
+ }
94
+
76
95
  static #indexed(state: unknown, idx: number) {
77
96
  if (CsrLocation.idxOf(state) !== undefined) return state;
78
97
  const record = (state ?? {}) as { __akanRouter?: object };
@@ -84,10 +103,43 @@ export class CsrLocation {
84
103
  this.#onBack = listener;
85
104
  }
86
105
 
87
- back() {
88
- const idx = this.entry().idx;
89
- if (idx !== undefined) this.#onBack?.(idx - 1);
106
+ /** Holds the entry on screen as left until `moving`, a shell's back, settles; `back()` holds it until the pop lands. */
107
+ leaving(moving: unknown) {
108
+ const entry = this.entry();
109
+ this.#backAsked = entry;
110
+ const release = () => {
111
+ if (this.#backAsked === entry) this.#backAsked = null;
112
+ };
113
+ void Promise.resolve(moving).then(release, release);
114
+ }
115
+
116
+ /** Whether a back has left the entry on screen and not landed yet. */
117
+ isLeaving() {
118
+ const entry = this.entry();
119
+ return entry === this.#backAsked || entry === this.#backSent;
120
+ }
121
+
122
+ /** Settles once the back's pop has moved the address, or at once when no entry of this document is under it. */
123
+ back(): Promise<void> {
124
+ const entry = this.entry();
125
+ if (entry.idx !== undefined) this.#onBack?.(entry.idx - 1);
126
+
127
+ const pops = entry.idx !== undefined && entry.idx > 0;
128
+ if (pops) this.#backSent = entry;
129
+ const landed = pops ? CsrLocation.#nextPop() : Promise.resolve();
90
130
  window.history.back();
131
+ return landed;
132
+ }
133
+
134
+ static #nextPop() {
135
+ return new Promise<void>((resolve) => {
136
+ const land = () => {
137
+ clearTimeout(cap);
138
+ resolve();
139
+ };
140
+ const cap = setTimeout(land, popWaitMs);
141
+ window.addEventListener("popstate", land, { once: true });
142
+ });
91
143
  }
92
144
 
93
145
  assign(href: string) {
@@ -0,0 +1,33 @@
1
+ import { csrLocation } from "./csrLocation";
2
+ import { Href } from "./href";
3
+
4
+ /** The params a CSR boot reads off its address (`?csr=true`), which every address it moves to carries along. */
5
+ export class CsrRuntimeParams {
6
+ static readonly #names = ["csr", "akanMobileTarget", "akanMobileBasePath", "akanMobileIndexPath"] as const;
7
+
8
+ static carry(href: string) {
9
+ const currentSearch = new URLSearchParams(csrLocation.search);
10
+ if (currentSearch.get("csr") !== "true" || Href.hasWebScheme(href)) return href;
11
+
12
+ const [hrefWithoutHash, hash = ""] = href.split("#");
13
+ const [pathname, search = ""] = hrefWithoutHash.split("?");
14
+ const nextSearch = new URLSearchParams(search);
15
+ for (const param of CsrRuntimeParams.#names) {
16
+ if (nextSearch.has(param)) continue;
17
+ const value = currentSearch.get(param);
18
+ if (value !== null) nextSearch.set(param, value);
19
+ }
20
+ const query = nextSearch.toString();
21
+ return `${pathname}${query ? `?${query}` : ""}${hash ? `#${hash}` : ""}`;
22
+ }
23
+
24
+ static sameRoute(a: string, b: string) {
25
+ const [left, right] = [a, b].map((href) => {
26
+ const url = new URL(href, "http://route.invalid");
27
+ for (const param of CsrRuntimeParams.#names) url.searchParams.delete(param);
28
+ url.searchParams.sort();
29
+ return `${url.pathname}?${url.searchParams.toString()}${url.hash}`;
30
+ });
31
+ return left === right;
32
+ }
33
+ }
@@ -21,6 +21,9 @@ export type PageSafeAreaConfig =
21
21
  };
22
22
  /** The sides whose chrome the page runs under instead of below. */
23
23
  export type PageOverlayConfig = boolean | "top" | "bottom";
24
+
25
+ /** How a page's navbar moves when it transitions; see `PageConfig.navbarMotion`. */
26
+ export type NavbarMotion = "crossfade" | "page";
24
27
  /** `"stream"` flushes the shell (`Loading` included) then streams; a redirect in suspended content becomes a client one.
25
28
  * `"block"` buffers the whole document, so an error in slow content can still render a clean error page. */
26
29
  export type SsrRenderMode = "stream" | "block";
@@ -42,14 +45,23 @@ export interface PageConfig {
42
45
  * and an overlaid side's safe area defaults to transparent.
43
46
  */
44
47
  overlay?: PageOverlayConfig;
48
+ /**
49
+ * How the navbar (`Layout.Navbar`'s top inset and its back button) moves when this page transitions.
50
+ * `"crossfade"`, the default, keeps one bar in place and crossfades the two pages' bars, as UIKit's does; between a
51
+ * page with a bar and one without, the bar's height folds away. `"page"` moves each bar with its page, as a part of
52
+ * the page, for a bar that is the page's own surface (translucent, or with no fill of its own).
53
+ */
54
+ navbarMotion?: NavbarMotion;
45
55
  gesture?: boolean;
46
56
  cache?: boolean;
47
57
  /** Initial full-document SSR strategy. Defaults to `"stream"`. */
48
58
  ssr?: SsrRenderMode;
49
59
  /**
50
60
  * Opt-in suffix-only RSC commits under `AKAN_PUBLIC_RSC_PARTIAL_COMMIT=1`: the page's `.head()` is plain `title`,
51
- * `meta` and `link` tags, and the layouts above it render the same for each sibling page, apart from what they
52
- * read through `usePathCtx()`.
61
+ * `meta` and `link` tags, and the layouts above it draw on the server only from the args they declare. A move to a
62
+ * sibling page, or to another param or query of this page that no layout above declares with `.param()` or
63
+ * `.search()`, then renders the page alone and keeps those layouts as drawn; what follows the path in them is read
64
+ * on the client (`usePathCtx()`, `Link`'s `activeClassName`).
53
65
  */
54
66
  rscPatchHeadSafe?: boolean;
55
67
  /** `false` answers a `Link` prefetch of the page (on a layout, of every page under it) without rendering it, for a
@@ -59,6 +71,13 @@ export interface PageConfig {
59
71
  * page under it), for a page whose output follows parameter order or a tracking parameter it reads without declaring
60
72
  * it with `.search()`. By default the key sorts the query and leaves out `AKAN_ROUTE_CACHE_TRACKING_PARAMS`. */
61
73
  canonicalQuery?: boolean;
74
+ /**
75
+ * The screen a native app's deep link lays under the page when it opens the app on it with nothing behind, so Back
76
+ * and the edge swipe go where a person who walked there would: a route pattern whose params come from the link
77
+ * (`"/org/:orgId"`), and its own `stackOn` chains on. On a layout it holds for every page below it, the route it
78
+ * names included, where it ends the chain. Left out, the link's leading segments that are routes stack under it.
79
+ */
80
+ stackOn?: string;
62
81
  topSafeAreaColor?: string;
63
82
  bottomSafeAreaColor?: string;
64
83
  /** Keeps the route (on a `_layout`, its whole directory) out of `akan build` while `akan start` serves it. Write a
@@ -77,6 +96,8 @@ export interface CsrState {
77
96
  /** Web only: the sides whose safe area `env(safe-area-inset-*)` measures, since a browser tells script nothing. */
78
97
  safeAreaEnv?: { top: boolean; bottom: boolean };
79
98
  overlay?: { top: boolean; bottom: boolean };
99
+ /** Set when the page declares one; left out, the navbar crossfades. */
100
+ navbarMotion?: NavbarMotion;
80
101
  gesture: boolean;
81
102
  cache: boolean;
82
103
  ssr: SsrRenderMode;
@@ -168,6 +189,8 @@ export interface RouteRender {
168
189
  getRouteDefinition?: () => PromiseOrObject<RouteDefinition | undefined>;
169
190
  /** The query names the level reads; `undefined` for a legacy module, which receives every one. */
170
191
  getSearchNames?: () => PromiseOrObject<string[] | undefined>;
192
+ /** The params the level reads beyond `lang`; `undefined` for a legacy module, which receives every one. */
193
+ getParamNames?: () => PromiseOrObject<string[] | undefined>;
171
194
  }
172
195
  export interface RouteViewport {
173
196
  /** `viewport-fit=cover`: the page runs under the notch and home indicator, and `env(safe-area-inset-*)` measures them. */
@@ -416,6 +439,10 @@ export const pageActivityContext = sharedContext<PageActivityState>("pageActivit
416
439
  export interface PathRoute {
417
440
  path: string;
418
441
  pathSegments: string[];
442
+ /** The not-found view a path no page matches draws, under the layouts it reached. */
443
+ notFound?: true;
444
+ /** The pages matched ahead of this one that take some of its paths, as `/:lang/chat/new` does of `/:lang/chat/:id`. */
445
+ shadowedBy?: string[];
419
446
  renderPage: RouteRender;
420
447
  pageState: PageState;
421
448
  pageConfigChain?: PageConfig[];
@@ -0,0 +1,97 @@
1
+ interface RouteMatch {
2
+ path: string;
3
+ route: string;
4
+ params: { [param: string]: string };
5
+ }
6
+
7
+ /** The route patterns a deep link resolves against, and the screen each one names to lay under it (`stackOn`). */
8
+ export class DeepLinkStack {
9
+
10
+ static readonly #depthLimit = 8;
11
+ readonly #routes: string[][];
12
+ readonly #stackOn: Map<string, string>;
13
+
14
+ constructor(routes: string[], stackOn: [route: string, under: string][] = []) {
15
+ this.#routes = [...new Set(routes)].map(DeepLinkStack.#segmentsOf).sort(DeepLinkStack.#bySpecificity);
16
+ this.#stackOn = new Map(stackOn);
17
+ }
18
+
19
+ get size() {
20
+ return this.#routes.length;
21
+ }
22
+
23
+ has(path: string) {
24
+ return this.#match(path) !== null;
25
+ }
26
+
27
+ /** The concrete paths of `path`'s leading segments that are routes themselves, `path` last; with no routes, `path`. */
28
+ prefixesOf(path: string) {
29
+ if (this.#routes.length === 0) return [path];
30
+ const segments = DeepLinkStack.#segmentsOf(path);
31
+ if (segments.length === 0) return this.has("/") ? ["/"] : [];
32
+ return segments
33
+ .map((_, idx) => `/${segments.slice(0, idx + 1).join("/")}`)
34
+ .filter((candidate) => this.has(candidate));
35
+ }
36
+
37
+ /** The screens `path`'s route names under it through `stackOn`, bottom first; a route naming itself ends the chain. */
38
+ underOf(path: string) {
39
+ const under: string[] = [];
40
+ let current = this.#match(path);
41
+ while (current && under.length < DeepLinkStack.#depthLimit) {
42
+ const pattern = this.#stackOn.get(current.route);
43
+ const parentPath = pattern ? DeepLinkStack.#fill(pattern, current.params) : null;
44
+ if (!parentPath || parentPath === current.path || under.includes(parentPath)) break;
45
+ const parent = this.#match(parentPath);
46
+ if (!parent) break;
47
+ under.unshift(parentPath);
48
+ current = parent;
49
+ }
50
+ return under;
51
+ }
52
+
53
+ /** The part of `path`'s `stackOn` chain above `currentPath`, the screen on view: all of it when that is not in it. */
54
+ missingUnder(path: string, currentPath: string) {
55
+ if (currentPath === path) return [];
56
+ const under = this.underOf(path);
57
+ return under.slice(under.indexOf(currentPath) + 1);
58
+ }
59
+
60
+ #match(path: string): RouteMatch | null {
61
+ const segments = DeepLinkStack.#segmentsOf(path);
62
+ for (const route of this.#routes) {
63
+ if (route.length !== segments.length) continue;
64
+ const params: { [param: string]: string } = {};
65
+ const isMatch = route.every((part, idx) => {
66
+ const value = segments[idx] ?? "";
67
+ if (!part.startsWith(":")) return part === value;
68
+ params[part.slice(1)] = value;
69
+ return true;
70
+ });
71
+ if (isMatch) return { path, route: `/${route.join("/")}`, params };
72
+ }
73
+ return null;
74
+ }
75
+
76
+ static #segmentsOf(path: string) {
77
+ return path.split("/").filter(Boolean);
78
+ }
79
+
80
+ static #bySpecificity(a: string[], b: string[]) {
81
+ for (let idx = 0; idx < Math.min(a.length, b.length); idx++) {
82
+ const isParamA = (a[idx] ?? "").startsWith(":");
83
+ if (isParamA !== (b[idx] ?? "").startsWith(":")) return isParamA ? 1 : -1;
84
+ }
85
+ return 0;
86
+ }
87
+
88
+ static #fill(pattern: string, params: { [param: string]: string }) {
89
+ const segments: string[] = [];
90
+ for (const segment of DeepLinkStack.#segmentsOf(pattern)) {
91
+ const value = segment.startsWith(":") ? params[segment.slice(1)] : segment;
92
+ if (value === undefined) return null;
93
+ segments.push(value);
94
+ }
95
+ return `/${segments.join("/")}`;
96
+ }
97
+ }
package/client/device.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { parseAkanI18nEnv } from "akanjs/common";
2
3
  import type { RefObject } from "react";
3
4
  import { csrLocation } from "./csrLocation";
4
5
  import { readCssSafeAreaInsets } from "./frameConfig";
@@ -12,12 +13,18 @@ type DebugPayload = Record<string, unknown>;
12
13
 
13
14
  const globalWithProcess = globalThis as typeof globalThis & { process?: ProcessEnvLike };
14
15
 
15
- /** Whether the iOS shell left the keyboard to the page; an older shell still pans to the field, so the page must not. */
16
+ /** Whether the shell left the keyboard to the page; an older shell still pans to the field, so the page must not. */
16
17
  export const isPageKeyboardAvoidance = () =>
17
18
  (globalThis as { __AKAN_NATIVE__?: { keyboardAvoidance?: string } }).__AKAN_NATIVE__?.keyboardAvoidance === "page";
18
19
 
19
20
  export const IOS_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.38, 0.7, 0.125, 1)";
20
21
 
22
+ export const ANDROID_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.2, 0, 0, 1)";
23
+ export const nativeKeyboardEasing = () =>
24
+ (globalThis as { __AKAN_NATIVE__?: { platform?: string } }).__AKAN_NATIVE__?.platform === "android"
25
+ ? ANDROID_KEYBOARD_ANIMATION_EASING
26
+ : IOS_KEYBOARD_ANIMATION_EASING;
27
+
21
28
  const debugSessionId = crypto.getRandomValues(new Uint32Array(1))[0].toString(36);
22
29
  let debugSeq = 0;
23
30
 
@@ -99,6 +106,12 @@ const langInPath = (pathname: string, supportLanguages: string[] | readonly stri
99
106
  return supportLanguages.find((language) => language === predefinedLangPath);
100
107
  };
101
108
 
109
+ const supportedLang = (code: string, supportLanguages: string[] | readonly string[]) => {
110
+ if (supportLanguages.length === 0 || supportLanguages.includes(code)) return code;
111
+ const { defaultLocale } = parseAkanI18nEnv();
112
+ return supportLanguages.includes(defaultLocale) ? defaultLocale : (supportLanguages[0] ?? code);
113
+ };
114
+
102
115
  const createWebDevice = ({
103
116
  lang,
104
117
  supportLanguages,
@@ -108,7 +121,7 @@ const createWebDevice = ({
108
121
  }) => {
109
122
  const pathname = typeof window === "undefined" ? "" : csrLocation.pathname;
110
123
  return new Device({
111
- lang: lang ?? langInPath(pathname, supportLanguages) ?? getBrowserLanguage(),
124
+ lang: lang ?? langInPath(pathname, supportLanguages) ?? supportedLang(getBrowserLanguage(), supportLanguages),
112
125
  info: webDeviceInfo,
113
126
  topSafeArea: 0,
114
127
  bottomSafeArea: 0,
@@ -140,7 +153,8 @@ export class Device {
140
153
 
141
154
  const { top: topSafeArea, bottom: bottomSafeArea } = readCssSafeAreaInsets();
142
155
  Device.instance = new Device({
143
- lang: lang ?? langInPath(window.location.pathname, supportLanguages) ?? languageCode,
156
+ lang:
157
+ lang ?? langInPath(window.location.pathname, supportLanguages) ?? supportedLang(languageCode, supportLanguages),
144
158
  info,
145
159
  topSafeArea,
146
160
  bottomSafeArea,
@@ -186,6 +200,7 @@ export class Device {
186
200
  if (isPageKeyboardAvoidance())
187
201
  void import("./keyboardRide").then(({ KeyboardRide }) => {
188
202
  Device.#keyboardRide = KeyboardRide;
203
+ KeyboardRide.watchFocus();
189
204
  });
190
205
  let currentHeight = 0;
191
206
  const emitKeyboardHeight = (event: string, height: number) => {