akanjs 3.0.0-alpha.2 → 3.0.0-alpha.21

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 (388) hide show
  1. package/README.ko.md +1 -1
  2. package/README.md +1 -1
  3. package/base/symbols.ts +4 -0
  4. package/client/clientRuntime.ts +8 -0
  5. package/client/cn.ts +7 -0
  6. package/client/csrTypes.ts +2 -0
  7. package/client/frameDebug.ts +3 -2
  8. package/common/Logger.ts +4 -0
  9. package/common/deepObjectify.ts +21 -7
  10. package/common/index.ts +14 -0
  11. package/common/mcpExposure.ts +99 -0
  12. package/common/pathSet.ts +17 -5
  13. package/common/routeConvention.ts +30 -0
  14. package/constant/crystalize.ts +3 -1
  15. package/constant/fieldInfo.ts +6 -0
  16. package/constant/getDefault.ts +37 -9
  17. package/constant/immerify.ts +1 -1
  18. package/constant/index.ts +2 -0
  19. package/constant/labelOf.ts +17 -0
  20. package/constant/mask.ts +60 -0
  21. package/constant/purify.ts +17 -11
  22. package/constant/types.ts +14 -12
  23. package/dictionary/DictionaryLookup.ts +30 -0
  24. package/dictionary/agent.dictionary.ts +31 -0
  25. package/dictionary/agentTurn.dictionary.ts +29 -0
  26. package/dictionary/base.dictionary.ts +8 -0
  27. package/dictionary/dictInfo.ts +8 -0
  28. package/dictionary/dictionary.ts +9 -3
  29. package/dictionary/index.ts +1 -0
  30. package/document/database.ts +21 -0
  31. package/document/filterMeta.ts +7 -0
  32. package/document/index.ts +1 -0
  33. package/document/into.ts +7 -1
  34. package/document/noDocumentError.ts +12 -0
  35. package/fetch/agentTurn.ts +19 -0
  36. package/fetch/client/fetchClient.ts +71 -13
  37. package/fetch/client/wsClient.ts +17 -2
  38. package/fetch/fetchType/endpointFetch.type.ts +10 -4
  39. package/fetch/index.ts +1 -0
  40. package/local/apps/serverLifecycle/serverLifecycle-local.db +0 -0
  41. package/local/apps/serverLifecycle/serverLifecycle-local.db-shm +0 -0
  42. package/local/apps/serverLifecycle/serverLifecycle-local.db-wal +0 -0
  43. package/local/apps/serverLifecycle/serverLifecycle-local_solid.db +0 -0
  44. package/local/apps/serverLifecycle/serverLifecycle-local_solid.db-shm +0 -0
  45. package/local/apps/serverLifecycle/serverLifecycle-local_solid.db-wal +0 -0
  46. package/package.json +11 -9
  47. package/server/akanApp.ts +30 -34
  48. package/server/akanOption.ts +65 -7
  49. package/server/akanServer.ts +172 -7
  50. package/server/animatedImage.ts +83 -0
  51. package/server/artifact/routeClientCache.ts +14 -0
  52. package/server/assetEncoding.ts +47 -0
  53. package/server/devtools/signalSerializer.ts +2 -2
  54. package/server/devtools/types.ts +2 -2
  55. package/server/di/diLifecycle.ts +31 -3
  56. package/server/di/predefinedAdaptor.ts +6 -0
  57. package/server/imageOptimizer.ts +33 -46
  58. package/server/index.ts +1 -2
  59. package/server/mcp/McpAuth.ts +177 -0
  60. package/server/mcp/McpDispatcher.ts +245 -0
  61. package/server/mcp/McpEventStream.ts +76 -0
  62. package/server/mcp/McpExecutionContext.ts +105 -0
  63. package/server/mcp/McpRouter.ts +591 -0
  64. package/server/mcp/index.ts +5 -0
  65. package/server/resolver/CascadeRunner.ts +1 -1
  66. package/server/resolver/database.resolver.ts +42 -5
  67. package/server/resolver/service.resolver.ts +29 -0
  68. package/server/resolver/signal.resolver.ts +16 -1
  69. package/server/routeTreeBuilder.ts +2 -44
  70. package/server/rscWorker.tsx +6 -2
  71. package/server/subRouteIndexDocument.tsx +61 -0
  72. package/server/systemPageDocument.tsx +2 -2
  73. package/server/systemPages.tsx +49 -16
  74. package/server/vendor/akanjs-fetch.ts +1 -0
  75. package/server/webRouter.ts +159 -35
  76. package/service/agent.service.ts +14 -0
  77. package/service/base.service.ts +2 -1
  78. package/service/index.ts +1 -0
  79. package/service/predefinedAdaptor/database.adaptor.ts +78 -24
  80. package/service/predefinedAdaptor/deepseekLlm.ts +230 -0
  81. package/service/predefinedAdaptor/index.ts +3 -0
  82. package/service/predefinedAdaptor/insightQuery.ts +183 -0
  83. package/service/predefinedAdaptor/llm.adaptor.ts +76 -0
  84. package/service/predefinedAdaptor/role.adaptor.ts +2 -0
  85. package/service/predefinedAdaptor/schedule.adaptor.ts +12 -5
  86. package/service/serviceModule.ts +17 -0
  87. package/service/types.ts +4 -0
  88. package/signal/agent/AgentCatalogue.ts +165 -0
  89. package/signal/agent/index.ts +1 -0
  90. package/signal/agent.signal.ts +42 -0
  91. package/signal/agentTurn.ts +8 -0
  92. package/signal/agentTurnStream.ts +48 -0
  93. package/signal/base.signal.ts +2 -1
  94. package/signal/endpointInfo.ts +38 -2
  95. package/signal/guard.ts +13 -1
  96. package/signal/guards.ts +52 -1
  97. package/signal/index.ts +6 -0
  98. package/signal/mcp/McpDocument.ts +286 -0
  99. package/signal/mcp/McpProgress.ts +106 -0
  100. package/signal/mcp/McpUriTemplate.ts +85 -0
  101. package/signal/mcp/Msg.ts +368 -0
  102. package/signal/mcp/index.ts +5 -0
  103. package/signal/mcp/mcpProtocol.ts +120 -0
  104. package/signal/middleware.ts +7 -3
  105. package/signal/openapi/openapi.ts +32 -171
  106. package/signal/schema/JsonSchemaBuilder.ts +211 -0
  107. package/signal/schema/index.ts +1 -0
  108. package/signal/signalContext.ts +85 -9
  109. package/signal/slice.ts +9 -9
  110. package/signal/types.ts +1 -1
  111. package/store/action.ts +11 -22
  112. package/store/actionTag.ts +33 -0
  113. package/store/agent/AgentBridge.ts +323 -0
  114. package/store/agent/AgentContext.ts +74 -0
  115. package/store/agent/AgentPrompts.ts +82 -0
  116. package/store/agent/AgentVisibility.ts +68 -0
  117. package/store/agent/ScreenReader.ts +208 -0
  118. package/store/agent/StoreCatalogue.ts +351 -0
  119. package/store/agent/StoreSurfaceSource.ts +122 -0
  120. package/store/agent/index.ts +9 -0
  121. package/store/agent/storeSurface.ts +28 -0
  122. package/store/agent/types.ts +50 -0
  123. package/store/agentic/StToolBuilder.ts +199 -0
  124. package/store/agentic/attachAgentic.ts +22 -0
  125. package/store/agentic/index.ts +5 -0
  126. package/store/agentic/readableValue.ts +17 -0
  127. package/store/agentic/useStExpose.ts +18 -0
  128. package/store/agentic/useStState.ts +35 -0
  129. package/store/baseSt.ts +7 -0
  130. package/store/databaseStateNames.ts +31 -0
  131. package/store/formSetterNames.ts +21 -0
  132. package/store/index.ts +8 -0
  133. package/store/rootStore.ts +3 -1
  134. package/store/sliceRole.ts +36 -0
  135. package/store/state.ts +2 -12
  136. package/store/store.ts +19 -1
  137. package/store/storeInstance.ts +165 -20
  138. package/store/storeRegistry.ts +16 -1
  139. package/store/types.ts +18 -0
  140. package/store/withSelector.ts +7 -8
  141. package/test/registerDom.ts +4 -0
  142. package/types/base/symbols.d.ts +4 -0
  143. package/types/client/cn.d.ts +5 -0
  144. package/types/client/csrTypes.d.ts +2 -0
  145. package/types/common/Logger.d.ts +2 -0
  146. package/types/common/deepObjectify.d.ts +4 -2
  147. package/types/common/index.d.ts +2 -1
  148. package/types/common/mcpExposure.d.ts +60 -0
  149. package/types/common/routeConvention.d.ts +8 -0
  150. package/types/constant/fieldInfo.d.ts +1 -0
  151. package/types/constant/getDefault.d.ts +5 -0
  152. package/types/constant/index.d.ts +2 -0
  153. package/types/constant/labelOf.d.ts +6 -0
  154. package/types/constant/mask.d.ts +34 -0
  155. package/types/constant/purify.d.ts +2 -2
  156. package/types/constant/types.d.ts +2 -2
  157. package/types/dictionary/DictionaryLookup.d.ts +14 -0
  158. package/types/dictionary/agent.dictionary.d.ts +1 -0
  159. package/types/dictionary/agentTurn.dictionary.d.ts +1 -0
  160. package/types/dictionary/base.dictionary.d.ts +1 -1
  161. package/types/dictionary/dictInfo.d.ts +6 -0
  162. package/types/dictionary/dictionary.d.ts +11 -9
  163. package/types/dictionary/index.d.ts +1 -0
  164. package/types/document/database.d.ts +20 -0
  165. package/types/document/filterMeta.d.ts +1 -0
  166. package/types/document/index.d.ts +1 -0
  167. package/types/document/into.d.ts +6 -1
  168. package/types/document/noDocumentError.d.ts +12 -0
  169. package/types/fetch/agentTurn.d.ts +593 -0
  170. package/types/fetch/client/fetchClient.d.ts +10 -0
  171. package/types/fetch/fetchType/endpointFetch.type.d.ts +5 -3
  172. package/types/fetch/index.d.ts +1 -0
  173. package/types/server/akanOption.d.ts +35 -7
  174. package/types/server/akanServer.d.ts +44 -1
  175. package/types/server/animatedImage.d.ts +7 -0
  176. package/types/server/artifact/routeClientCache.d.ts +6 -0
  177. package/types/server/assetEncoding.d.ts +7 -0
  178. package/types/server/devtools/types.d.ts +2 -2
  179. package/types/server/di/predefinedAdaptor.d.ts +4 -1
  180. package/types/server/index.d.ts +0 -2
  181. package/types/server/mcp/McpAuth.d.ts +62 -0
  182. package/types/server/mcp/McpDispatcher.d.ts +54 -0
  183. package/types/server/mcp/McpEventStream.d.ts +18 -0
  184. package/types/server/mcp/McpExecutionContext.d.ts +44 -0
  185. package/types/server/mcp/McpRouter.d.ts +60 -0
  186. package/types/server/mcp/index.d.ts +5 -0
  187. package/types/server/mcp.d.ts +1 -0
  188. package/types/server/subRouteIndexDocument.d.ts +8 -0
  189. package/types/server/systemPageDocument.d.ts +1 -0
  190. package/types/server/systemPages.d.ts +5 -0
  191. package/types/server/vendor/akanjs-fetch.d.ts +1 -0
  192. package/types/service/agent.service.d.ts +12 -0
  193. package/types/service/base.service.d.ts +4 -0
  194. package/types/service/index.d.ts +1 -0
  195. package/types/service/predefinedAdaptor/database.adaptor.d.ts +24 -2
  196. package/types/service/predefinedAdaptor/deepseekLlm.d.ts +64 -0
  197. package/types/service/predefinedAdaptor/index.d.ts +3 -0
  198. package/types/service/predefinedAdaptor/insightQuery.d.ts +50 -0
  199. package/types/service/predefinedAdaptor/llm.adaptor.d.ts +68 -0
  200. package/types/service/predefinedAdaptor/role.adaptor.d.ts +2 -0
  201. package/types/service/predefinedAdaptor/schedule.adaptor.d.ts +10 -6
  202. package/types/service/types.d.ts +4 -1
  203. package/types/signal/agent/AgentCatalogue.d.ts +100 -0
  204. package/types/signal/agent/index.d.ts +1 -0
  205. package/types/signal/agent.d.ts +1 -0
  206. package/types/signal/agent.signal.d.ts +29 -0
  207. package/types/signal/agentTurn.d.ts +9 -0
  208. package/types/signal/agentTurnStream.d.ts +16 -0
  209. package/types/signal/base.signal.d.ts +1 -1
  210. package/types/signal/endpointInfo.d.ts +21 -3
  211. package/types/signal/guard.d.ts +11 -0
  212. package/types/signal/guards.d.ts +22 -1
  213. package/types/signal/index.d.ts +6 -0
  214. package/types/signal/mcp/McpDocument.d.ts +65 -0
  215. package/types/signal/mcp/McpProgress.d.ts +40 -0
  216. package/types/signal/mcp/McpUriTemplate.d.ts +26 -0
  217. package/types/signal/mcp/Msg.d.ts +143 -0
  218. package/types/signal/mcp/index.d.ts +5 -0
  219. package/types/signal/mcp/mcpProtocol.d.ts +107 -0
  220. package/types/signal/mcp.d.ts +1 -0
  221. package/types/signal/openapi/openapi.d.ts +3 -3
  222. package/types/signal/schema/JsonSchemaBuilder.d.ts +47 -0
  223. package/types/signal/schema/index.d.ts +1 -0
  224. package/types/signal/schema.d.ts +1 -0
  225. package/types/signal/signalContext.d.ts +16 -1
  226. package/types/signal/slice.d.ts +8 -8
  227. package/types/signal/types.d.ts +1 -1
  228. package/types/store/actionTag.d.ts +21 -0
  229. package/types/store/agent/AgentBridge.d.ts +77 -0
  230. package/types/store/agent/AgentContext.d.ts +16 -0
  231. package/types/store/agent/AgentPrompts.d.ts +31 -0
  232. package/types/store/agent/AgentVisibility.d.ts +21 -0
  233. package/types/store/agent/ScreenReader.d.ts +11 -0
  234. package/types/store/agent/StoreCatalogue.d.ts +26 -0
  235. package/types/store/agent/StoreSurfaceSource.d.ts +18 -0
  236. package/types/store/agent/index.d.ts +9 -0
  237. package/types/store/agent/storeSurface.d.ts +14 -0
  238. package/types/store/agent/types.d.ts +49 -0
  239. package/types/store/agent.d.ts +1 -0
  240. package/types/store/agentic/StToolBuilder.d.ts +41 -0
  241. package/types/store/agentic/attachAgentic.d.ts +14 -0
  242. package/types/store/agentic/index.d.ts +5 -0
  243. package/types/store/agentic/readableValue.d.ts +3 -0
  244. package/types/store/agentic/useStExpose.d.ts +8 -0
  245. package/types/store/agentic/useStState.d.ts +12 -0
  246. package/types/store/agentic.d.ts +1 -0
  247. package/types/store/baseSt.d.ts +29 -22
  248. package/types/store/databaseStateNames.d.ts +25 -0
  249. package/types/store/formSetterNames.d.ts +16 -0
  250. package/types/store/index.d.ts +7 -0
  251. package/types/store/rootStore.d.ts +5 -1
  252. package/types/store/sliceRole.d.ts +25 -0
  253. package/types/store/store.d.ts +7 -2
  254. package/types/store/storeInstance.d.ts +33 -1
  255. package/types/store/storeRegistry.d.ts +5 -0
  256. package/types/store/types.d.ts +15 -0
  257. package/types/store/withSelector.d.ts +7 -8
  258. package/types/test/registerDom.d.ts +1 -0
  259. package/types/ui/Agent/Approval.d.ts +7 -0
  260. package/types/ui/Agent/Bubble.d.ts +13 -0
  261. package/types/ui/Agent/Chat.d.ts +24 -0
  262. package/types/ui/Agent/Context.d.ts +9 -0
  263. package/types/ui/Agent/Dock.d.ts +16 -0
  264. package/types/ui/Agent/Guide.d.ts +9 -0
  265. package/types/ui/Agent/Section.d.ts +10 -0
  266. package/types/ui/Agent/StateKey.d.ts +16 -0
  267. package/types/ui/Agent/Tool.d.ts +15 -0
  268. package/types/ui/Agent/Transcript.d.ts +13 -0
  269. package/types/ui/Agent/Zone.d.ts +23 -0
  270. package/types/ui/Agent/fetchRunner.d.ts +12 -0
  271. package/types/ui/Agent/index.d.ts +17 -0
  272. package/types/ui/Agent/index_.d.ts +1 -0
  273. package/types/ui/Agent/sessionHistory.d.ts +12 -0
  274. package/types/ui/Agent.d.ts +1 -0
  275. package/types/ui/Badge.d.ts +1 -1
  276. package/types/ui/Button.d.ts +1 -1
  277. package/types/ui/CsrImage.d.ts +1 -1
  278. package/types/ui/Dropdown.d.ts +2 -0
  279. package/types/ui/Image.d.ts +3 -3
  280. package/types/ui/Layout/BottomInset.d.ts +2 -1
  281. package/types/ui/Layout/index.d.ts +1 -1
  282. package/types/ui/Signal/style.d.ts +4 -1
  283. package/types/ui/UiOverride/context.d.ts +14 -2
  284. package/types/ui/agentAttrs.d.ts +14 -0
  285. package/types/ui/index.d.ts +4 -1
  286. package/types/ui/overlayLayer.d.ts +24 -0
  287. package/types/ui/recipe/badgeRecipe.d.ts +7 -3
  288. package/types/ui/recipe/buttonRecipe.d.ts +7 -3
  289. package/types/ui/recipe/inputRecipe.d.ts +5 -1
  290. package/types/vendor/use-agentic/AgentProvider.d.ts +18 -0
  291. package/types/vendor/use-agentic/AgentScope.d.ts +9 -0
  292. package/types/vendor/use-agentic/AgentSession.d.ts +50 -0
  293. package/types/vendor/use-agentic/Agentic.d.ts +21 -0
  294. package/types/vendor/use-agentic/AgenticSurface.d.ts +44 -0
  295. package/types/vendor/use-agentic/httpRunner.d.ts +15 -0
  296. package/types/vendor/use-agentic/index.d.ts +13 -0
  297. package/types/vendor/use-agentic/surfaceContext.d.ts +5 -0
  298. package/types/vendor/use-agentic/types.d.ts +133 -0
  299. package/types/vendor/use-agentic/useAgent.d.ts +4 -0
  300. package/types/vendor/use-agentic/useAgentGuide.d.ts +6 -0
  301. package/types/vendor/use-agentic/useAgentResource.d.ts +7 -0
  302. package/types/vendor/use-agentic/useAgentState.d.ts +13 -0
  303. package/types/vendor/use-agentic/useAgentTool.d.ts +16 -0
  304. package/types/vendor/use-agentic.d.ts +1 -0
  305. package/types/webkit/index.d.ts +3 -0
  306. package/types/webkit/lazy.d.ts +12 -0
  307. package/types/webkit/useCsrValues.d.ts +3 -3
  308. package/types/webkit/useEscapeKey.d.ts +5 -0
  309. package/types/webkit/useFrameRuntime.d.ts +6 -1
  310. package/types/webkit/useScreenScope.d.ts +18 -0
  311. package/ui/Agent/Approval.tsx +29 -0
  312. package/ui/Agent/Bubble.tsx +74 -0
  313. package/ui/Agent/Chat.tsx +225 -0
  314. package/ui/Agent/Context.tsx +38 -0
  315. package/ui/Agent/Dock.tsx +72 -0
  316. package/ui/Agent/Guide.tsx +16 -0
  317. package/ui/Agent/Section.tsx +24 -0
  318. package/ui/Agent/StateKey.tsx +44 -0
  319. package/ui/Agent/Tool.tsx +66 -0
  320. package/ui/Agent/Transcript.tsx +33 -0
  321. package/ui/Agent/Zone.tsx +48 -0
  322. package/ui/Agent/fetchRunner.ts +30 -0
  323. package/ui/Agent/index.ts +12 -0
  324. package/ui/Agent/index_.tsx +4 -0
  325. package/ui/Agent/sessionHistory.ts +33 -0
  326. package/ui/Badge.tsx +3 -3
  327. package/ui/BottomSheet.tsx +5 -0
  328. package/ui/Button.tsx +6 -2
  329. package/ui/Constant/Doc.tsx +1 -1
  330. package/ui/CsrImage.tsx +1 -1
  331. package/ui/Data/ListContainer.tsx +1 -1
  332. package/ui/DatePicker.tsx +5 -4
  333. package/ui/Dialog/Modal.tsx +12 -15
  334. package/ui/DraggableList.tsx +3 -1
  335. package/ui/Dropdown.tsx +33 -11
  336. package/ui/Field.tsx +30 -16
  337. package/ui/Image.tsx +3 -3
  338. package/ui/Input.tsx +14 -5
  339. package/ui/Layout/BottomInset.tsx +6 -1
  340. package/ui/Load/Units.tsx +11 -2
  341. package/ui/Load/View.tsx +7 -2
  342. package/ui/Loading/ProgressBar.tsx +8 -1
  343. package/ui/Menu.tsx +7 -8
  344. package/ui/Model/EditModal.tsx +37 -2
  345. package/ui/Model/SureToRemove.tsx +2 -1
  346. package/ui/Model/index_.tsx +42 -15
  347. package/ui/ObjectId.tsx +3 -4
  348. package/ui/Pagination.tsx +3 -4
  349. package/ui/Popconfirm.tsx +8 -7
  350. package/ui/Select.tsx +6 -4
  351. package/ui/Signal/RestApi.tsx +43 -16
  352. package/ui/Signal/WebSocket.tsx +1 -1
  353. package/ui/Signal/style.ts +6 -1
  354. package/ui/Switch.tsx +2 -0
  355. package/ui/System/CSR.tsx +6 -2
  356. package/ui/System/ThemeToggle.tsx +55 -33
  357. package/ui/ToggleSelect.tsx +4 -3
  358. package/ui/Tooltip.tsx +2 -1
  359. package/ui/UiOverride/context.ts +14 -2
  360. package/ui/agentAttrs.ts +19 -0
  361. package/ui/index.ts +10 -1
  362. package/ui/overlayLayer.ts +39 -0
  363. package/ui/recipe/badgeRecipe.ts +22 -3
  364. package/ui/recipe/buttonRecipe.ts +51 -2
  365. package/ui/recipe/factory.ts +2 -2
  366. package/ui/recipe/inputRecipe.ts +18 -4
  367. package/vendor/use-agentic/AgentProvider.tsx +39 -0
  368. package/vendor/use-agentic/AgentScope.tsx +20 -0
  369. package/vendor/use-agentic/AgentSession.ts +292 -0
  370. package/vendor/use-agentic/Agentic.tsx +44 -0
  371. package/vendor/use-agentic/AgenticSurface.ts +294 -0
  372. package/vendor/use-agentic/WIRE.md +57 -0
  373. package/vendor/use-agentic/httpRunner.ts +115 -0
  374. package/vendor/use-agentic/index.ts +14 -0
  375. package/vendor/use-agentic/surfaceContext.ts +9 -0
  376. package/vendor/use-agentic/types.ts +144 -0
  377. package/vendor/use-agentic/useAgent.ts +17 -0
  378. package/vendor/use-agentic/useAgentGuide.ts +16 -0
  379. package/vendor/use-agentic/useAgentResource.ts +30 -0
  380. package/vendor/use-agentic/useAgentState.ts +61 -0
  381. package/vendor/use-agentic/useAgentTool.ts +55 -0
  382. package/webkit/bootCsr.tsx +2 -33
  383. package/webkit/index.ts +3 -0
  384. package/webkit/lazy.tsx +27 -3
  385. package/webkit/useCsrValues.ts +121 -4
  386. package/webkit/useEscapeKey.tsx +42 -0
  387. package/webkit/useFrameRuntime.ts +65 -32
  388. package/webkit/useScreenScope.tsx +49 -0
@@ -0,0 +1,40 @@
1
+ export interface McpProgressOption {
2
+ /** Denominator for the ratio a client renders. Omit when the amount of work is not known up front. */
3
+ total?: number;
4
+ /** One short line describing the current step. Shown to the user, so keep it prose rather than a status code. */
5
+ message?: string;
6
+ }
7
+ export interface McpProgressReport extends McpProgressOption {
8
+ progress: number;
9
+ }
10
+ /**
11
+ * The progress channel for one streamed MCP call.
12
+ *
13
+ * Reached through `AsyncLocalStorage` rather than a parameter so an endpoint reports progress from wherever the
14
+ * work actually happens — a service, an adapter, a loop several frames down — without every signature between
15
+ * here and there growing a channel argument. Outside a streamed call `report` is a no-op, so the same endpoint
16
+ * code runs unchanged over plain HTTP, a websocket, or a test.
17
+ */
18
+ export declare class McpProgress {
19
+ #private;
20
+ /**
21
+ * Reports progress for the call running on this stack. Silent when nothing is listening, which is every call
22
+ * that did not ask for a stream.
23
+ */
24
+ static report(progress: number, option?: McpProgressOption): void;
25
+ /** True while the caller is streaming, so an expensive progress message can be skipped when nobody reads it. */
26
+ static get streaming(): boolean;
27
+ static run<T>(channel: McpProgress, exec: () => Promise<T>): Promise<T>;
28
+ /** Resolves on the first report and never otherwise — a call that reports nothing has nothing to stream. */
29
+ readonly started: Promise<void>;
30
+ constructor();
31
+ /**
32
+ * Aborted when the client closes the response stream, which is how cancellation is signalled over this
33
+ * transport. Long-running work may watch it; the framework cannot force an `exec` already in flight to stop.
34
+ */
35
+ get signal(): AbortSignal;
36
+ /** Yields every report until the call finishes. Buffered ones come out first, so none is lost to a late reader. */
37
+ reports(): AsyncGenerator<McpProgressReport>;
38
+ end(): void;
39
+ abort(): void;
40
+ }
@@ -0,0 +1,26 @@
1
+ export interface McpResourceTarget {
2
+ endpointKey: string;
3
+ args: Record<string, string | string[]>;
4
+ }
5
+ /**
6
+ * Two-way map between an `akan://` resource URI and the endpoint that answers it.
7
+ *
8
+ * Parsing is done by hand rather than through `URL`: `akan:` is a non-special scheme, and how a runtime
9
+ * normalizes the authority of one (case, percent-decoding) is exactly where a camelCase refName like
10
+ * `agentSession` would quietly stop matching its model.
11
+ */
12
+ export declare class McpUriTemplate {
13
+ #private;
14
+ static readonly scheme = "akan";
15
+ static model(refName: string): string;
16
+ static light(refName: string): string;
17
+ /**
18
+ * The model's own unfiltered list is the bare `…/list`, never `…/list/<token>`. A named slice occupies the
19
+ * third segment, and a slice key is an author-chosen identifier — so any token put there for the root list
20
+ * would be one a slice could also be called, and the two would publish the same uri with only one of them
21
+ * readable. `list` in the *second* segment is already reserved against a model id, so there is nothing to
22
+ * collide with here.
23
+ */
24
+ static list(refName: string, sliceKey: string, argNames: string[]): string;
25
+ static parse(uri: string): McpResourceTarget | null;
26
+ }
@@ -0,0 +1,143 @@
1
+ import { type MaskModel } from "akanjs/constant";
2
+ import type { JsonSchema } from "../schema.d.ts";
3
+ export type PromptRole = "user" | "assistant";
4
+ /**
5
+ * What a client may do with a block when it cannot keep all of them.
6
+ *
7
+ * `priority` is the field that matters here: a prompt this server assembles is often mostly context — a document
8
+ * embedded beside the one line asking for something — and a client with a full window drops blocks by this number
9
+ * rather than by position. Leaving it off means every block is equally droppable, so the instruction can go and
10
+ * the attachment stay.
11
+ */
12
+ export interface PromptAnnotations {
13
+ /** Who the block is for. A note meant only for the model is `["assistant"]`, so a UI need not render it. */
14
+ audience?: PromptRole[];
15
+ /** 0 is "drop this first", 1 is "this is the point of the prompt". Anything outside the range is refused. */
16
+ priority?: number;
17
+ /** ISO 8601. Lets a client tell a re-fetched resource from the copy it already holds. */
18
+ lastModified?: string;
19
+ }
20
+ export interface PromptTextContent {
21
+ type: "text";
22
+ text: string;
23
+ annotations?: PromptAnnotations;
24
+ }
25
+ export interface PromptBinaryContent {
26
+ type: "image" | "audio";
27
+ data: string;
28
+ mimeType: string;
29
+ annotations?: PromptAnnotations;
30
+ }
31
+ export interface PromptResourceLinkContent {
32
+ type: "resource_link";
33
+ uri: string;
34
+ /** Required by the spec: `ResourceLink` extends `BaseMetadata`, whose `name` is not optional. */
35
+ name: string;
36
+ description?: string;
37
+ mimeType?: string;
38
+ annotations?: PromptAnnotations;
39
+ }
40
+ export interface PromptEmbeddedResourceContent {
41
+ type: "resource";
42
+ resource: {
43
+ uri: string;
44
+ mimeType: string;
45
+ text: string;
46
+ };
47
+ annotations?: PromptAnnotations;
48
+ }
49
+ export type PromptContent = PromptTextContent | PromptBinaryContent | PromptResourceLinkContent | PromptEmbeddedResourceContent;
50
+ export interface PromptMessage {
51
+ role: PromptRole;
52
+ content: PromptContent;
53
+ }
54
+ /** What a `prompt()` exec may return. A bare string is the 80% case and is wrapped into one user message. */
55
+ export type PromptResult = string | PromptMessage[];
56
+ /** Enough of the `File` model to link or inline it, structural so the framework does not depend on the lib. */
57
+ export interface PromptFileSource {
58
+ url: string;
59
+ filename?: string;
60
+ mimetype?: string;
61
+ }
62
+ /**
63
+ * A model class, named by the caller so an attachment can be masked by what it *is* rather than by what it still
64
+ * carries at runtime. The same model any other audience masks by — see `mask` in `akanjs/constant`.
65
+ */
66
+ export type PromptModel = MaskModel;
67
+ /**
68
+ * Builds the messages a `prompt()` endpoint returns.
69
+ *
70
+ * Named `Msg` rather than `msg` because `akanjs/dictionary` already exports a `msg` for toasts.
71
+ *
72
+ * Every attachment builder carries the `user` role. Content the server assembles is context handed *to* the
73
+ * model, which is what the user role means; an assistant-role attachment would be the server putting words in the
74
+ * model's mouth. That is only meaningful for few-shot text, which `Msg.assistant` covers.
75
+ */
76
+ export declare class Msg {
77
+ #private;
78
+ /**
79
+ * What every `prompt()` route answers with, as JSON Schema, for the app's OpenAPI document.
80
+ *
81
+ * A prompt declares `Any` on the wire, so the generated response schema was `{}` — a documented `GET` whose body
82
+ * the document could not describe, which is half of the agreement the HTTP route was mounted for. The shape is
83
+ * fixed by the protocol rather than by the endpoint, so it is written once, here: the block types and the fields
84
+ * each must carry come off `contentFields`, so a type added to one cannot describe itself out of the other.
85
+ */
86
+ static readonly schema: JsonSchema;
87
+ static user(text: string, annotations?: PromptAnnotations): PromptMessage;
88
+ static assistant(text: string, annotations?: PromptAnnotations): PromptMessage;
89
+ /**
90
+ * Embeds the value itself. The payload travels in the prompt, so prefer `link` for anything large.
91
+ *
92
+ * Name the model it is an instance of and the `hidden`/`secret` fields are stripped before it goes out:
93
+ * `Msg.resource(uri, order, { model: cnst.Order })`. A payload you assembled yourself needs no model and is
94
+ * embedded as given — but one that still carries a document's secret fields is refused rather than sent, so
95
+ * the rule is the same either way: a document travels masked, or it does not travel.
96
+ */
97
+ static resource(uri: string, value: unknown, { model, ...annotations }?: {
98
+ model?: PromptModel;
99
+ } & PromptAnnotations): PromptMessage;
100
+ /**
101
+ * Strips what a model marks `hidden` or `secret`, by the model the caller names rather than by the one the
102
+ * value happens to still carry.
103
+ *
104
+ * That distinction is the whole fix. A check that reads the class off the value can only mask what arrives as an
105
+ * instance, so a `{ ...doc }` spread, a `toJSON()`, or a round-trip through `JSON.stringify` reached the wire
106
+ * with the metadata already gone and nothing could be done about it. A named model is metadata the value cannot
107
+ * lose, so a hydrated document and a plain object copied out of one mask identically.
108
+ *
109
+ * This is the field half of `resolveReturn` and deliberately not the whole of it. That one also loads every
110
+ * relation it walks past, which is right for a query's return value and wrong for an attachment, where it would
111
+ * turn embedding one document into a fan of queries nobody asked for. So a populated relation is masked in
112
+ * place and one that is still an id is left as an id.
113
+ *
114
+ * Public because a payload can be an assembly of several documents — `{ order, customer }` names no single
115
+ * model, so each piece is masked on its way in.
116
+ *
117
+ * Returns `unknown` rather than the argument's type, because what comes back is missing fields that type still
118
+ * promises. The value's only destination is a JSON payload, so nothing downstream wanted the type anyway.
119
+ */
120
+ static mask(model: PromptModel, value: unknown): unknown;
121
+ /**
122
+ * Points at something without paying for it. The client decides whether to fetch, and skips what it already
123
+ * holds — so a prompt that references twenty documents costs twenty URIs rather than twenty payloads.
124
+ */
125
+ static link(source: string | PromptFileSource, { name, description, ...annotations }?: {
126
+ name?: string;
127
+ description?: string;
128
+ } & PromptAnnotations): PromptMessage;
129
+ static image(data: string, mimeType: string, annotations?: PromptAnnotations): PromptMessage;
130
+ static audio(data: string, mimeType: string, annotations?: PromptAnnotations): PromptMessage;
131
+ /**
132
+ * Inlines a file as base64, costing roughly 1.33× its bytes in the prompt. Worth it only when the client
133
+ * cannot fetch the URL itself — a public asset is cheaper as `Msg.link`. Fetched as this process, so a file
134
+ * behind a caller-scoped signed URL needs its bytes passed to `Msg.image` instead.
135
+ */
136
+ static imageOf(file: PromptFileSource, annotations?: PromptAnnotations): Promise<PromptMessage>;
137
+ /**
138
+ * The one runtime check on a prompt's return value. `prompt()` carries `Any` on the wire so the signal
139
+ * pipeline hands the value back untouched — nothing upstream would notice a malformed message, and the client
140
+ * would receive it as a valid prompt.
141
+ */
142
+ static normalize(value: unknown): PromptMessage[];
143
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./McpDocument.d.ts";
2
+ export * from "./McpProgress.d.ts";
3
+ export * from "./McpUriTemplate.d.ts";
4
+ export * from "./Msg.d.ts";
5
+ export * from "./mcpProtocol.d.ts";
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Wire vocabulary for the MCP revisions this server answers.
3
+ *
4
+ * `2026-07-28` made the protocol stateless — no `initialize`, no session id, no server-opened stream — which is
5
+ * what makes a single `POST /mcp` route sufficient. Everything before it is the *legacy* era, still what shipping
6
+ * clients speak (measured: Claude Code 2.1.226 negotiates `2025-11-25`), and supporting it costs almost nothing
7
+ * here because a legacy server *may* decline to issue `Mcp-Session-Id`: without one the client sends no session
8
+ * header and never asks to resume a stream, so both eras run over the same stateless handler.
9
+ *
10
+ * `2025-06-18` is listed for the same reason. The surface this server actually implements — POST-only Streamable
11
+ * HTTP, no sessions, no server-initiated requests — is wire-identical between the two legacy revisions, and a
12
+ * client that proposes a version the server does not list is told to disconnect. Naming only the one revision that
13
+ * was measured turned "we tested against this" into "we refuse everything else".
14
+ */
15
+ export declare const MCP_MODERN_VERSION = "2026-07-28";
16
+ export declare const MCP_LEGACY_VERSION = "2025-11-25";
17
+ export declare const MCP_LEGACY_PRIOR_VERSION = "2025-06-18";
18
+ /** Newest first — `server/discover` and `initialize` both answer with this order, and `#negotiate` reads the ends. */
19
+ export declare const MCP_SUPPORTED_VERSIONS: readonly ["2026-07-28", "2025-11-25", "2025-06-18"];
20
+ export type McpProtocolVersion = (typeof MCP_SUPPORTED_VERSIONS)[number];
21
+ export type McpEra = "modern" | "legacy";
22
+ export declare const MCP_META_PREFIX = "io.modelcontextprotocol/";
23
+ export declare const MCP_META_PROTOCOL_VERSION = "io.modelcontextprotocol/protocolVersion";
24
+ export declare const MCP_META_CLIENT_CAPABILITIES = "io.modelcontextprotocol/clientCapabilities";
25
+ export declare const MCP_META_CLIENT_INFO = "io.modelcontextprotocol/clientInfo";
26
+ export declare const MCP_META_SERVER_INFO = "io.modelcontextprotocol/serverInfo";
27
+ /**
28
+ * `-32020`..`-32099` is reserved by the spec, so nothing outside this table may be minted in that band.
29
+ * `-32002` (resource not found) is retired in the modern revision; unknown resources are `invalidParams`.
30
+ *
31
+ * The band also defines `-32021 missingRequiredClientCapability`, which is absent because this server requires
32
+ * none: it never samples, elicits, or reads roots. It belongs here the day one of those appears, not before — a
33
+ * constant nothing emits reads as a check someone forgot to write.
34
+ */
35
+ export declare const McpErrorCode: {
36
+ readonly parse: -32700;
37
+ readonly invalidRequest: -32600;
38
+ readonly methodNotFound: -32601;
39
+ readonly invalidParams: -32602;
40
+ readonly internal: -32603;
41
+ readonly headerMismatch: -32020;
42
+ readonly unsupportedProtocolVersion: -32022;
43
+ };
44
+ export type McpErrorCodeValue = (typeof McpErrorCode)[keyof typeof McpErrorCode];
45
+ export interface McpJsonRpcRequest {
46
+ jsonrpc: "2.0";
47
+ id?: string | number | null;
48
+ method?: string;
49
+ params?: Record<string, unknown>;
50
+ }
51
+ export interface McpToolAnnotations {
52
+ readOnlyHint?: boolean;
53
+ destructiveHint?: boolean;
54
+ idempotentHint?: boolean;
55
+ openWorldHint?: boolean;
56
+ }
57
+ export interface McpTool {
58
+ name: string;
59
+ title?: string;
60
+ description?: string;
61
+ inputSchema: Record<string, unknown>;
62
+ outputSchema?: Record<string, unknown>;
63
+ annotations?: McpToolAnnotations;
64
+ }
65
+ export interface McpResourceTemplate {
66
+ uriTemplate: string;
67
+ name: string;
68
+ title?: string;
69
+ description?: string;
70
+ mimeType?: string;
71
+ }
72
+ export interface McpResource {
73
+ uri: string;
74
+ name: string;
75
+ title?: string;
76
+ description?: string;
77
+ mimeType?: string;
78
+ }
79
+ export interface McpPromptArgument {
80
+ name: string;
81
+ description?: string;
82
+ required?: boolean;
83
+ }
84
+ /**
85
+ * A prompt is user-controlled — the client offers it as a slash command and the model never invokes it — so its
86
+ * `title` and `description` are read by a person, not inferred from a schema the way a tool's are.
87
+ */
88
+ export interface McpPrompt {
89
+ name: string;
90
+ title?: string;
91
+ description?: string;
92
+ arguments?: McpPromptArgument[];
93
+ }
94
+ export interface McpTextContent {
95
+ type: "text";
96
+ text: string;
97
+ }
98
+ export interface McpToolResult {
99
+ content: McpTextContent[];
100
+ structuredContent?: unknown;
101
+ isError?: boolean;
102
+ }
103
+ export interface McpResourceContents {
104
+ uri: string;
105
+ mimeType: string;
106
+ text: string;
107
+ }
@@ -0,0 +1 @@
1
+ export * from "./mcp/index.d.ts";
@@ -1,5 +1,5 @@
1
+ import { type JsonSchema } from "../schema.d.ts";
1
2
  import type { SerializedSignal } from "../types.d.ts";
2
- type OpenApiSchema = Record<string, unknown>;
3
3
  type OpenApiOperation = Record<string, unknown>;
4
4
  type OpenApiPathItem = Record<string, OpenApiOperation>;
5
5
  export interface OpenApiDocumentOptions {
@@ -27,8 +27,8 @@ export interface OpenApiDocument {
27
27
  }[];
28
28
  paths: Record<string, OpenApiPathItem>;
29
29
  components: {
30
- schemas: Record<string, OpenApiSchema>;
31
- securitySchemes?: Record<string, OpenApiSchema>;
30
+ schemas: Record<string, JsonSchema>;
31
+ securitySchemes?: Record<string, JsonSchema>;
32
32
  };
33
33
  }
34
34
  export declare const createOpenApiDocument: (serializedSignal: Record<string, SerializedSignal>, options?: OpenApiDocumentOptions) => OpenApiDocument;
@@ -0,0 +1,47 @@
1
+ import { type ConstantCls } from "akanjs/constant";
2
+ import type { SerializedArg, SerializedReturns } from "../types.d.ts";
3
+ export type JsonSchema = Record<string, unknown>;
4
+ export interface JsonSchemaBuilderOptions {
5
+ /**
6
+ * Where a model `$ref` points. OpenAPI collects every model under `components/schemas`, while MCP requires each
7
+ * tool schema to resolve on its own and so embeds its models in a per-schema `$defs`.
8
+ */
9
+ refPrefix?: string;
10
+ }
11
+ export interface JsonSchemaModelOptions {
12
+ /**
13
+ * Drops `hidden` and `secret` fields. `SignalContext.resolveReturn` strips both from every response, so naming
14
+ * them describes a value the caller can never read — and on a model like `user` the names are themselves the
15
+ * leak: `password`, `accountId`, `phone` published as readable properties of the model. This is the one place a
16
+ * field the framework blocks on every value path is still visible, so it is scoped to schemas that describe a
17
+ * *response*. A request body is a different shape and legitimately carries both.
18
+ */
19
+ readable?: boolean;
20
+ }
21
+ /**
22
+ * Turns serialized signal metadata and Akan constants into JSON Schema (2020-12 by default, which is also what
23
+ * OpenAPI 3.1 uses). One builder per output dialect target — `new` it at the call site, it holds no shared state.
24
+ */
25
+ export declare class JsonSchemaBuilder {
26
+ #private;
27
+ constructor({ refPrefix }?: JsonSchemaBuilderOptions);
28
+ arg(arg: SerializedArg): JsonSchema;
29
+ upload(arg: SerializedArg): JsonSchema;
30
+ returns(returns: SerializedReturns): JsonSchema;
31
+ model(modelRef: ConstantCls, { readable }?: JsonSchemaModelOptions): JsonSchema;
32
+ /** Every registered model, keyed by schema name. Callers narrow this with `referencedSchemas`. */
33
+ allModelSchemas(options?: JsonSchemaModelOptions): Record<string, JsonSchema>;
34
+ /**
35
+ * The models `seed` references, plus everything those transitively reference, sorted by name.
36
+ *
37
+ * `allSchemas` is derived from the registry, so a caller that narrows many seeds against the same registry —
38
+ * MCP builds one per tool schema and one per output schema — passes its own copy rather than rebuilding every
39
+ * registered model each time. Holding it here instead would make this builder stateful, and the one in
40
+ * `openapi.ts` lives at module scope for the life of the process.
41
+ */
42
+ referencedSchemas(seed: unknown, allSchemas?: Record<string, JsonSchema>): {
43
+ [k: string]: JsonSchema;
44
+ };
45
+ collectRefNames(value: unknown): Set<string>;
46
+ static primitive(refName: string): JsonSchema;
47
+ }
@@ -0,0 +1 @@
1
+ export * from "./JsonSchemaBuilder.d.ts";
@@ -0,0 +1 @@
1
+ export * from "./schema/index.d.ts";
@@ -21,13 +21,19 @@ export declare class SignalContext<Ctx extends HttpExecutionContext | WebSocketE
21
21
  args: unknown[];
22
22
  internalArgs: unknown[];
23
23
  trace: SignalTrace | null;
24
- constructor(key: string, reqOrWsReq: Bun.BunRequest | WebSocketRequest, { endpointInfo, adaptor, registry, env, live, middleware, }: {
24
+ constructor(key: string, reqOrWsReq: Bun.BunRequest | WebSocketRequest, { endpointInfo, adaptor, registry, env, live, middleware, ctx, }: {
25
25
  endpointInfo: EndpointInfo;
26
26
  adaptor: Adaptor;
27
27
  registry: InjectRegistry;
28
28
  env: Env;
29
29
  live: LiveRegistry;
30
30
  middleware: Map<string, MiddlewareCls>;
31
+ /**
32
+ * Runs the endpoint against a caller-built context instead of one derived from the request. MCP needs it:
33
+ * its arguments arrive as one named object rather than in a URL, but every guard, middleware and
34
+ * internalArg reads the request through this context, so the transport has to stay the same one.
35
+ */
36
+ ctx?: Ctx;
31
37
  });
32
38
  getAdaptor<T extends Adaptor>(adaptorCls: AdaptorCls<T>): T;
33
39
  getService<T>(refName: string): T;
@@ -38,6 +44,15 @@ export declare class SignalContext<Ctx extends HttpExecutionContext | WebSocketE
38
44
  * while endpoint middlewares (cache/timeout/retry) would observe a call that never executes.
39
45
  */
40
46
  authorize(): Promise<boolean>;
47
+ /**
48
+ * Evaluates only the guards marked `static scope = "account"` — the ones that read the caller and nothing
49
+ * else — so a catalogue can hide entries the caller certainly cannot use.
50
+ *
51
+ * **Never an access gate.** An endpoint whose guards are all resource-scoped passes here and is stopped later
52
+ * by `#checkGuards` with the arguments those guards need. Erring visible is deliberate: a resource guard fails
53
+ * closed with no arguments, so evaluating one here would delete every legitimate entry from the listing.
54
+ */
55
+ canListForAccount(): Promise<boolean>;
41
56
  exec(): Promise<Response | undefined>;
42
57
  static try(endpoint: Adaptor, endpointInfo: EndpointInfo, key: string, fn: () => Promise<Response | undefined>): Promise<Response | undefined>;
43
58
  static resolveReturn(value: unknown, { signalContext, returnRef, arrDepth, registry, live, }: {
@@ -1,8 +1,8 @@
1
- import { type Assign, type Cls, type MergeAllKeyOfObjects, SLICE_DICT_SHAPE, SLICE_META } from "akanjs/base";
1
+ import { type Assign, type MergeAllKeyOfObjects, SLICE_DICT_SHAPE, SLICE_META } from "akanjs/base";
2
2
  import type { DocumentModel, QueryOf } from "akanjs/constant";
3
3
  import type { FilterInstance } from "akanjs/document";
4
4
  import { type Adaptor, type AdaptorCls, type ServiceModel } from "akanjs/service";
5
- import type { Guard, GuardCls } from "./guard.d.ts";
5
+ import type { GuardCls } from "./guard.d.ts";
6
6
  import { type SliceBuilder, type SliceInfo, type SliceInfoArgNames, type SliceInfoArgs, type SliceInfoInternalArgs, type SliceInfoServerArgs, type SliceInfoSrvs } from "./sliceInfo.d.ts";
7
7
  import type { CnstFull, CnstInput, CnstInsight, CnstLight, DbFilter, SrvMap, SrvRefName } from "./types.d.ts";
8
8
  export type SliceDictArgShape = {
@@ -33,12 +33,12 @@ export type SliceCls<SrvModule extends ServiceModel = ServiceModel, SliceInfoObj
33
33
  };
34
34
  interface RootSliceOption {
35
35
  guards?: {
36
- root?: Cls<Guard> | Cls<Guard>[];
37
- get?: Cls<Guard> | Cls<Guard>[];
38
- cru?: Cls<Guard> | Cls<Guard>[];
39
- create?: Cls<Guard> | Cls<Guard>[];
40
- update?: Cls<Guard> | Cls<Guard>[];
41
- remove?: Cls<Guard> | Cls<Guard>[];
36
+ root?: GuardCls | GuardCls[];
37
+ get?: GuardCls | GuardCls[];
38
+ cru?: GuardCls | GuardCls[];
39
+ create?: GuardCls | GuardCls[];
40
+ update?: GuardCls | GuardCls[];
41
+ remove?: GuardCls | GuardCls[];
42
42
  };
43
43
  prefix?: string;
44
44
  }
@@ -102,7 +102,7 @@ export interface SerializedArg {
102
102
  enum?: string;
103
103
  }
104
104
  export interface SerializedEndpoint extends SerializedSignalOption {
105
- type: "query" | "mutation" | "pubsub" | "message";
105
+ type: "query" | "mutation" | "pubsub" | "message" | "prompt";
106
106
  returns: SerializedReturns;
107
107
  }
108
108
  export interface SerializedFilter {
@@ -0,0 +1,21 @@
1
+ /** Which module declared an action. The dictionary node its words live in is named after it. */
2
+ export interface ActionOwner {
3
+ refName: string;
4
+ }
5
+ export interface ActionTag {
6
+ /** The `st.do` key this function is. */
7
+ action: string;
8
+ /** The state path it writes, when it writes exactly one — `userForm.name` for a field setter. */
9
+ state?: string;
10
+ }
11
+ /**
12
+ * Marks a dispatcher with what it does, so a component handed one by reference can say so in the DOM.
13
+ *
14
+ * `onChange={st.do.setNameOnUser}` is the house form for every model field, which means the component already holds
15
+ * everything an annotation needs — it just has no way to read it off a function. This is that way, and it is why
16
+ * `data-akan-*` costs an app no code at all: nobody writes the attribute, the setter carries its own name.
17
+ *
18
+ * Non-enumerable, so it survives neither `{...fn}` nor `JSON.stringify` and shows up in no spread.
19
+ */
20
+ export declare const tagAction: <T extends (...args: never[]) => unknown>(fn: T, tag: ActionTag) => T;
21
+ export declare const actionTagOf: (value: unknown) => ActionTag | undefined;
@@ -0,0 +1,77 @@
1
+ import type { AgentRefusal, JsonSchema, SerializedSignal } from "akanjs/signal";
2
+ import type { StoreInstance } from "../storeInstance.d.ts";
3
+ import type { AgentVisibility } from "./AgentVisibility.d.ts";
4
+ import type { SerializedStoreState, StoreActionEffect } from "./types.d.ts";
5
+ export interface AgentTool {
6
+ name: string;
7
+ title?: string;
8
+ description?: string;
9
+ /** One flat named object, the shape MCP publishes. The bridge maps it onto the action's positional parameters. */
10
+ inputSchema: JsonSchema;
11
+ effect: StoreActionEffect;
12
+ }
13
+ /** One call the agent made, in the order it made them. */
14
+ export interface AgentCall {
15
+ name: string;
16
+ args: Record<string, unknown>;
17
+ at: Date;
18
+ error?: string;
19
+ }
20
+ export interface AgentBridgeOptions {
21
+ /** Resolves a dictionary key to its text. Defaults to the seeded `Translator` in the active locale. */
22
+ resolveDescription?: (key: string) => string | undefined;
23
+ }
24
+ /**
25
+ * What an in-page agent may do to the app the user is looking at.
26
+ *
27
+ * Every call goes through `st.do`, which is the same single dispatch point a click goes through — so the agent
28
+ * cannot reach past what the UI already lets this user do, the app re-renders from the write, and the user watches
29
+ * the result rather than being told about it. That is why the exposure default here is the opposite of the MCP
30
+ * catalogue's: an external agent's `tools/list` is an attack surface built out of names the operator never chose to
31
+ * publish, while this one is the user's own session, under their own credential, with them watching.
32
+ *
33
+ * It is deliberately not an agent. There is no model, no provider, and no key here — an app wires whichever it uses
34
+ * to `tools`, `call`, and `read`. The framework's half is the catalogue, the argument checking, the masking, and the
35
+ * transcript; the conversation is the app's.
36
+ */
37
+ export declare class AgentBridge {
38
+ #private;
39
+ readonly refusals: AgentRefusal[];
40
+ /**
41
+ * The bridge for the app running in this process: the one store every `st.do` goes through, and every signal any
42
+ * client has applied. An app needs no arguments to reach its own agent surface.
43
+ */
44
+ static of(options?: AgentBridgeOptions): AgentBridge;
45
+ constructor(instance: StoreInstance, serializedSignal: Record<string, SerializedSignal>, options?: AgentBridgeOptions);
46
+ /**
47
+ * The catalogued actions of the stores the rendered screen is reading right now — the live view, recomputed as
48
+ * components mount and unmount. Global exposure was the first cut's behavior and it published levers the screen
49
+ * does not respond to; the screen's own subscriptions are the honest boundary.
50
+ */
51
+ get tools(): AgentTool[];
52
+ /** The live view one zone session reads: owners counted from the keys that zone's own subtree subscribes. */
53
+ toolsFor(viewKey: string): AgentTool[];
54
+ get visibility(): AgentVisibility;
55
+ get state(): {
56
+ [key: string]: SerializedStoreState;
57
+ };
58
+ get transcript(): readonly AgentCall[];
59
+ subscribe(listener: () => void): () => void;
60
+ /**
61
+ * The value behind a state key, stripped of what the model marks `hidden` or `secret`.
62
+ *
63
+ * Masking is not optional here even though the data mostly came from the server already masked: `<model>Form`
64
+ * holds what the *user* typed, credentials included, and an in-page agent ships what it reads to a remote model.
65
+ * The mask is by the declared model rather than by the value's class, because `immerify` copies a form into a
66
+ * plain object and the class is gone by the time anyone can ask.
67
+ */
68
+ read(key: string, viewKey?: string): unknown;
69
+ /**
70
+ * Dispatches through `st.do`, so what happens is what happens when the user clicks.
71
+ *
72
+ * Arguments arrive named and are mapped onto the action's parameters in declared order. An omitted optional one
73
+ * becomes `null`, which is what the slice query builders already expect; an omitted required one is refused,
74
+ * because the alternative is a call that writes `undefined` into state and reports success.
75
+ */
76
+ call(name: string, args?: Record<string, unknown>, viewKey?: string): Promise<void>;
77
+ }
@@ -0,0 +1,16 @@
1
+ import type { ContextBlock, SurfaceView } from "../../vendor/use-agentic.d.ts";
2
+ import type { StoreInstance } from "../storeInstance.d.ts";
3
+ import type { AgentBridge } from "./AgentBridge.d.ts";
4
+ /**
5
+ * The akan default context for a turn: where the user is (route), what is on screen (scopes and their curated
6
+ * resources), and which store keys the mounted components are reading (live keys). Live entries carry names and
7
+ * small primitives only — anything bigger is one `readState` call away, masked — so the block cannot bloat with
8
+ * what happens to be in the store. Base-store keys are excluded by the base store's own `agent: false`
9
+ * declaration, and the route block carries the three of them that matter.
10
+ */
11
+ export declare class AgentContext {
12
+ #private;
13
+ static of(): AgentContext;
14
+ constructor(instance: StoreInstance, bridge: AgentBridge);
15
+ blocks(surface: SurfaceView, view?: string[]): ContextBlock[];
16
+ }
@@ -0,0 +1,31 @@
1
+ import type { PromptContent, PromptResult, SerializedSignal } from "akanjs/signal";
2
+ import type { ChatMessage } from "../../vendor/use-agentic.d.ts";
3
+ export interface AgentPrompt {
4
+ name: string;
5
+ refName: string;
6
+ description?: string;
7
+ args: {
8
+ name: string;
9
+ required: boolean;
10
+ }[];
11
+ }
12
+ /**
13
+ * The user-invokable `prompt()` endpoints of the mounted app, read off the serialized signals the client already
14
+ * holds — the same catalogue MCP lists them from, so a chat needs no listing endpoint. Guards are not evaluated
15
+ * here: a prompt's own GET enforces them at call time, and the refusal lands in the transcript like any failure.
16
+ */
17
+ export declare class AgentPrompts {
18
+ #private;
19
+ static of(): AgentPrompts;
20
+ constructor(signals: Record<string, SerializedSignal>);
21
+ list(): AgentPrompt[];
22
+ find(name: string): AgentPrompt | null;
23
+ /** `/name arg1 arg2` — positional because a prompt's arguments are flat strings by protocol. */
24
+ static parseCommand(draft: string): {
25
+ name: string;
26
+ args: string[];
27
+ } | null;
28
+ /** The messages a prompt returns become the user's turn, the way an MCP client sends a `prompts/get` result. */
29
+ static messagesOf(result: PromptResult): ChatMessage[];
30
+ static textOf(content: PromptContent): string;
31
+ }
@@ -0,0 +1,21 @@
1
+ import type { StoreAgentExposure } from "../types.d.ts";
2
+ /**
3
+ * Which stores the agent surface may show, derived from the registry: every registered store's state keys name
4
+ * their owner, and a store's `static agent` declaration is its own exposure decision. Liveness rides on top —
5
+ * `liveOwners` maps the subscribed keys back to store refNames, so the published surface follows the rendered
6
+ * screen instead of the whole bundle.
7
+ */
8
+ export declare class AgentVisibility {
9
+ #private;
10
+ stateOwner(key: string): string | undefined;
11
+ /** The stores that declared an exposure of their own, for the catalogue's refusal lines. */
12
+ declaredExposures(): Map<string, StoreAgentExposure>;
13
+ visibleKey(key: string): boolean;
14
+ visibleAction(name: string, ownerRefName?: string): boolean;
15
+ /**
16
+ * The stores the rendered screen is reading right now: owners of the subscribed, still-visible keys. A key no
17
+ * registered store owns has no module to activate, and an action with no owner stays published — only fabricated
18
+ * stores outside the registry produce either.
19
+ */
20
+ liveOwners(liveKeys: ReadonlyMap<string, number>): Set<string>;
21
+ }