raiton 6.8.8-beta.24 → 6.10.0-beta.28

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 (387) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +46 -1
  3. package/benchmarks/README.md +16 -0
  4. package/benchmarks/latest.json +172 -0
  5. package/benchmarks/latest.md +66 -0
  6. package/build/bin/index.mjs +33575 -21723
  7. package/build/types/bin/bootstrapper.d.ts +2 -0
  8. package/build/types/bin/cli-output.d.ts +46 -0
  9. package/build/types/bin/cli-tools.d.ts +13 -0
  10. package/build/types/bin/cli.d.ts +3 -0
  11. package/build/types/bin/commands.registry.d.ts +4 -0
  12. package/build/types/bin/constants.d.ts +3 -0
  13. package/build/types/bin/file-utils.d.ts +21 -0
  14. package/build/types/bin/index.d.ts +2 -0
  15. package/build/types/bin/name-utils.d.ts +4 -0
  16. package/build/types/bin/project-utils.d.ts +12 -0
  17. package/build/types/commands/artifact.command.d.ts +7 -0
  18. package/build/types/commands/build.command.d.ts +8 -0
  19. package/build/types/commands/client.command.d.ts +7 -0
  20. package/build/types/commands/contract.command.d.ts +8 -0
  21. package/build/types/commands/develop.command.d.ts +9 -0
  22. package/build/types/commands/docs.command.d.ts +8 -0
  23. package/build/types/commands/doctor.command.d.ts +9 -0
  24. package/build/types/commands/generate.command.d.ts +7 -0
  25. package/build/types/commands/inspect.command.d.ts +7 -0
  26. package/build/types/commands/mcp.command.d.ts +11 -0
  27. package/build/types/commands/new.command.d.ts +7 -0
  28. package/build/types/commands/openapi.command.d.ts +7 -0
  29. package/build/types/commands/routes.command.d.ts +7 -0
  30. package/build/types/commands/start.command.d.ts +9 -0
  31. package/build/types/commands/why.command.d.ts +7 -0
  32. package/build/types/contracts/decorators.d.ts +41 -0
  33. package/build/types/contracts/errors.d.ts +42 -0
  34. package/build/types/contracts/index.d.ts +4 -0
  35. package/build/types/contracts/schema.d.ts +70 -0
  36. package/build/types/contracts/typebox.d.ts +81 -0
  37. package/build/types/core/application.d.ts +37 -0
  38. package/build/types/core/artifacts/artifact.d.ts +3 -0
  39. package/build/types/core/artifacts/index.d.ts +1 -0
  40. package/build/types/core/artifacts/runner.d.ts +1 -0
  41. package/build/types/core/builder.d.ts +42 -0
  42. package/build/types/core/bytes.util.d.ts +3 -0
  43. package/build/types/core/command.d.ts +13 -0
  44. package/build/types/core/commands.d.ts +10 -0
  45. package/build/types/core/config/config.d.ts +27 -0
  46. package/build/types/core/config/define.d.ts +8 -0
  47. package/build/types/core/config/index.d.ts +3 -0
  48. package/build/types/core/config/schema.d.ts +24 -0
  49. package/build/types/core/context.d.ts +11 -0
  50. package/build/types/core/controller/builder.d.ts +26 -0
  51. package/build/types/core/controller/compiler.d.ts +2 -0
  52. package/build/types/core/controller/index.d.ts +4 -0
  53. package/build/types/core/controller/metadata.d.ts +3 -0
  54. package/build/types/core/controller/tracker.d.ts +9 -0
  55. package/build/types/core/directories.d.ts +10 -0
  56. package/build/types/core/guards.d.ts +11 -0
  57. package/build/types/core/helpers/index.d.ts +1 -0
  58. package/build/types/core/helpers/raiton.d.ts +1 -0
  59. package/build/types/core/hooks.d.ts +14 -0
  60. package/build/types/core/index.d.ts +17 -0
  61. package/build/types/core/injection/index.d.ts +1 -0
  62. package/build/types/core/injection/injection.d.ts +37 -0
  63. package/build/types/core/mcp/builder.d.ts +2 -0
  64. package/build/types/core/mcp/index.d.ts +3 -0
  65. package/build/types/core/mcp/metadata.d.ts +9 -0
  66. package/build/types/core/mcp/tracker.d.ts +9 -0
  67. package/build/types/core/middleware/compose.d.ts +8 -0
  68. package/build/types/core/middleware/index.d.ts +2 -0
  69. package/build/types/core/middleware/pipeline.d.ts +12 -0
  70. package/build/types/core/plugins/index.d.ts +2 -0
  71. package/build/types/core/plugins/plugin.d.ts +2 -0
  72. package/build/types/core/plugins/scope.d.ts +15 -0
  73. package/build/types/core/process.util.d.ts +1 -0
  74. package/build/types/core/raiton.d.ts +15 -0
  75. package/build/types/core/router/handler.d.ts +2 -0
  76. package/build/types/core/router/handler.utils.d.ts +37 -0
  77. package/build/types/core/router/index.d.ts +4 -0
  78. package/build/types/core/router/matcher.d.ts +50 -0
  79. package/build/types/core/router/route.d.ts +52 -0
  80. package/build/types/core/router/router.d.ts +23 -0
  81. package/build/types/core/scheduler/builder.d.ts +2 -0
  82. package/build/types/core/scheduler/cron.d.ts +32 -0
  83. package/build/types/core/scheduler/duration.d.ts +7 -0
  84. package/build/types/core/scheduler/index.d.ts +6 -0
  85. package/build/types/core/scheduler/manager.d.ts +47 -0
  86. package/build/types/core/scheduler/metadata.d.ts +8 -0
  87. package/build/types/core/scheduler/queue/backend.d.ts +42 -0
  88. package/build/types/core/scheduler/queue/index.d.ts +3 -0
  89. package/build/types/core/scheduler/queue/rabbitmq.backend.d.ts +37 -0
  90. package/build/types/core/scheduler/queue/redis.backend.d.ts +38 -0
  91. package/build/types/core/server.d.ts +9 -0
  92. package/build/types/core/socket/builder.d.ts +1 -0
  93. package/build/types/core/socket/index.d.ts +2 -0
  94. package/build/types/core/socket/metadata.d.ts +14 -0
  95. package/build/types/core/thread.d.ts +21 -0
  96. package/build/types/framework/artifacts.d.ts +20 -0
  97. package/build/types/framework/cache/cache.d.ts +84 -0
  98. package/build/types/framework/cache/cache.decorator.d.ts +21 -0
  99. package/build/types/framework/cache/etag.d.ts +62 -0
  100. package/build/types/framework/cache/index.d.ts +4 -0
  101. package/build/types/framework/cache/types.d.ts +89 -0
  102. package/build/types/framework/constants/decorators.constant.d.ts +28 -0
  103. package/build/types/framework/constants/index.d.ts +2 -0
  104. package/build/types/framework/constants/microservices.constant.d.ts +3 -0
  105. package/build/types/framework/controllers.d.ts +2 -0
  106. package/build/types/framework/data-transfer-object.d.ts +5 -0
  107. package/build/types/framework/decorators/access-guard.decorator.d.ts +1 -0
  108. package/build/types/framework/decorators/api-response.decorator.d.ts +66 -0
  109. package/build/types/framework/decorators/api.decorator.d.ts +160 -0
  110. package/build/types/framework/decorators/controllable.decorator.d.ts +3 -0
  111. package/build/types/framework/decorators/csrf-guard.decorator.d.ts +2 -0
  112. package/build/types/framework/decorators/csrf-token.decorator.d.ts +1 -0
  113. package/build/types/framework/decorators/guard.decorator.d.ts +2 -0
  114. package/build/types/framework/decorators/health-check.decorator.d.ts +17 -0
  115. package/build/types/framework/decorators/index.d.ts +15 -0
  116. package/build/types/framework/decorators/injection.decorator.d.ts +5 -0
  117. package/build/types/framework/decorators/mcp.decorator.d.ts +68 -0
  118. package/build/types/framework/decorators/middleware.decorator.d.ts +3 -0
  119. package/build/types/framework/decorators/parametrable.decorator.d.ts +9 -0
  120. package/build/types/framework/decorators/routable.decorator.d.ts +12 -0
  121. package/build/types/framework/decorators/route-interaction.decorator.d.ts +81 -0
  122. package/build/types/framework/decorators/scheduler.decorator.d.ts +54 -0
  123. package/build/types/framework/decorators/socket.decorator.d.ts +5 -0
  124. package/build/types/framework/encryption.d.ts +25 -0
  125. package/build/types/framework/enums/csrf.enum.d.ts +4 -0
  126. package/build/types/framework/enums/encrypted.enum.d.ts +20 -0
  127. package/build/types/framework/enums/event.message.enum.d.ts +4 -0
  128. package/build/types/framework/enums/http-method.enum.d.ts +10 -0
  129. package/build/types/framework/enums/http-parameters.enum.d.ts +11 -0
  130. package/build/types/framework/enums/http-status.enum.d.ts +64 -0
  131. package/build/types/framework/enums/index.d.ts +9 -0
  132. package/build/types/framework/enums/runtime.enum.d.ts +5 -0
  133. package/build/types/framework/enums/scheduler.enum.d.ts +21 -0
  134. package/build/types/framework/enums/timestamp.enum.d.ts +6 -0
  135. package/build/types/framework/env.d.ts +3 -0
  136. package/build/types/framework/errors/catalog.d.ts +42 -0
  137. package/build/types/framework/exceptions/http-exception.d.ts +18 -0
  138. package/build/types/framework/exceptions/index.d.ts +2 -0
  139. package/build/types/framework/exceptions/throwable.d.ts +76 -0
  140. package/build/types/framework/health-check.d.ts +42 -0
  141. package/build/types/framework/index.d.ts +20 -0
  142. package/build/types/framework/mcp/audit.d.ts +12 -0
  143. package/build/types/framework/mcp/conformance.d.ts +31 -0
  144. package/build/types/framework/mcp/handler.d.ts +11 -0
  145. package/build/types/framework/mcp/index.d.ts +5 -0
  146. package/build/types/framework/mcp/protocol.d.ts +17 -0
  147. package/build/types/framework/mcp/rate-limit.d.ts +10 -0
  148. package/build/types/framework/mcp/stdio.d.ts +40 -0
  149. package/build/types/framework/mcp/streamable-http.d.ts +17 -0
  150. package/build/types/framework/observability/index.d.ts +6 -0
  151. package/build/types/framework/observability/metrics.d.ts +23 -0
  152. package/build/types/framework/observability/plugin.d.ts +20 -0
  153. package/build/types/framework/observability/readiness.d.ts +9 -0
  154. package/build/types/framework/observability/request.d.ts +7 -0
  155. package/build/types/framework/observability/shutdown.d.ts +21 -0
  156. package/build/types/framework/observability/trace.d.ts +96 -0
  157. package/build/types/framework/parameter-bag.d.ts +14 -0
  158. package/build/types/framework/plugins/body-parser.plugin.d.ts +3 -0
  159. package/build/types/framework/plugins/dev.plugin.d.ts +12 -0
  160. package/build/types/framework/plugins/index.d.ts +5 -0
  161. package/build/types/framework/plugins/mcp.plugin.d.ts +15 -0
  162. package/build/types/framework/plugins/openapi.plugin.d.ts +58 -0
  163. package/build/types/framework/plugins/security/body-limit.d.ts +1 -0
  164. package/build/types/framework/plugins/security/cors.d.ts +10 -0
  165. package/build/types/framework/plugins/security/csrf.d.ts +2 -0
  166. package/build/types/framework/plugins/security/headers.d.ts +1 -0
  167. package/build/types/framework/plugins/security/index.d.ts +13 -0
  168. package/build/types/framework/plugins/security/method-guard.d.ts +1 -0
  169. package/build/types/framework/plugins/security/rate-limit.d.ts +5 -0
  170. package/build/types/framework/repositories.d.ts +5 -0
  171. package/build/types/framework/responses/error.d.ts +13 -0
  172. package/build/types/framework/responses/helpers.d.ts +7 -0
  173. package/build/types/framework/responses/http-throwable.d.ts +14 -0
  174. package/build/types/framework/responses/http.d.ts +13 -0
  175. package/build/types/framework/responses/index.d.ts +4 -0
  176. package/build/types/framework/runtime/bun/server.d.ts +2 -0
  177. package/build/types/framework/runtime/deno/server.d.ts +2 -0
  178. package/build/types/framework/runtime/index.d.ts +17 -0
  179. package/build/types/framework/runtime/node/reply.d.ts +12 -0
  180. package/build/types/framework/runtime/node/request.d.ts +33 -0
  181. package/build/types/framework/runtime/node/server.d.ts +2 -0
  182. package/build/types/framework/runtime/web/server.d.ts +1 -0
  183. package/build/types/framework/services.d.ts +5 -0
  184. package/build/types/framework/utilities/alias-path.util.d.ts +1 -0
  185. package/build/types/framework/utilities/artifact.util.d.ts +7 -0
  186. package/build/types/framework/utilities/callable.util.d.ts +1 -0
  187. package/build/types/framework/utilities/cookie.util.d.ts +1 -0
  188. package/build/types/framework/utilities/csrf.util.d.ts +26 -0
  189. package/build/types/framework/utilities/https.util.d.ts +49 -0
  190. package/build/types/framework/utilities/index.d.ts +12 -0
  191. package/build/types/framework/utilities/ip.util.d.ts +15 -0
  192. package/build/types/framework/utilities/json.util.d.ts +10 -0
  193. package/build/types/framework/utilities/openapi.utils.d.ts +7 -0
  194. package/build/types/framework/utilities/openapi.utils.impl.d.ts +18 -0
  195. package/build/types/framework/utilities/path.util.d.ts +3 -0
  196. package/build/types/framework/utilities/route-suggestion.util.d.ts +10 -0
  197. package/build/types/framework/utilities/url.util.d.ts +1 -0
  198. package/build/types/framework/utilities/utilities.util.d.ts +3 -0
  199. package/build/types/framework/utilities/validation.util.d.ts +8 -0
  200. package/build/types/framework/view-model.d.ts +4 -0
  201. package/build/types/generators/artifact.templates.d.ts +7 -0
  202. package/build/types/generators/index.d.ts +2 -0
  203. package/build/types/generators/project.templates.d.ts +21 -0
  204. package/build/types/manifest/client.d.ts +12 -0
  205. package/build/types/manifest/contract.d.ts +25 -0
  206. package/build/types/manifest/index.d.ts +5 -0
  207. package/build/types/manifest/introspect.d.ts +18 -0
  208. package/build/types/manifest/manifest.d.ts +18 -0
  209. package/build/types/manifest/schema.d.ts +177 -0
  210. package/build/types/requirements.d.ts +1 -0
  211. package/build/types/types/access-guards.d.ts +4 -0
  212. package/build/types/types/application.d.ts +32 -0
  213. package/build/types/types/artifact.d.ts +8 -0
  214. package/build/types/types/builder.d.ts +37 -0
  215. package/build/types/types/config.d.ts +62 -0
  216. package/build/types/types/controller.d.ts +27 -0
  217. package/build/types/types/contruct.d.ts +1 -0
  218. package/build/types/types/core.d.ts +11 -0
  219. package/build/types/types/csrf.d.ts +33 -0
  220. package/build/types/types/directory.d.ts +6 -0
  221. package/build/types/types/encryption.d.ts +14 -0
  222. package/build/types/types/generic.d.ts +2 -0
  223. package/build/types/types/guard.d.ts +9 -0
  224. package/build/types/types/http-responses.d.ts +7 -0
  225. package/build/types/types/index.d.ts +27 -0
  226. package/build/types/types/injection.d.ts +11 -0
  227. package/build/types/types/lifecycle.d.ts +9 -0
  228. package/build/types/types/mcp.d.ts +148 -0
  229. package/build/types/types/middleware.d.ts +12 -0
  230. package/build/types/types/parseable.d.ts +3 -0
  231. package/build/types/types/plugin.d.ts +6 -0
  232. package/build/types/types/raiton.d.ts +13 -0
  233. package/build/types/types/responses.d.ts +20 -0
  234. package/build/types/types/router.d.ts +13 -0
  235. package/build/types/types/runtime.d.ts +48 -0
  236. package/build/types/types/scheduler.d.ts +140 -0
  237. package/build/types/types/scheme.d.ts +125 -0
  238. package/build/types/types/server.d.ts +10 -0
  239. package/build/types/types/socket.d.ts +11 -0
  240. package/build/types/types/thread.d.ts +25 -0
  241. package/build/types/types/utilities.d.ts +4 -0
  242. package/build/types/types/values.d.ts +2 -0
  243. package/docs/AGENTS.md +55 -0
  244. package/docs/CLAUDE.md +55 -0
  245. package/docs/README.md +5 -0
  246. package/docs/contributors/cli/README.md +17 -3
  247. package/docs/contributors/cli/commands.md +28 -17
  248. package/docs/contributors/framework/plugins/openapi.md +12 -3
  249. package/docs/generated/cli/commands.md +26 -0
  250. package/docs/generated/config-schema.json +150 -0
  251. package/docs/generated/manifest-schema.json +236 -0
  252. package/docs/generated/manifest.json +101 -0
  253. package/docs/llms-full.txt +1271 -0
  254. package/docs/llms.txt +46 -0
  255. package/docs/user-guide/README.md +18 -12
  256. package/docs/user-guide/cli.md +21 -0
  257. package/docs/user-guide/config.md +14 -0
  258. package/docs/user-guide/contracts.md +67 -0
  259. package/docs/user-guide/en/README.md +83 -0
  260. package/docs/user-guide/getting-started.md +13 -1
  261. package/docs/user-guide/mcp.md +45 -2
  262. package/docs/user-guide/observability.md +74 -0
  263. package/docs/user-guide/openapi/plugin.md +10 -0
  264. package/docs/user-guide/recipes/README.md +32 -0
  265. package/docs/user-guide/recipes/contracts.md +52 -0
  266. package/docs/user-guide/recipes/doctor.md +16 -0
  267. package/docs/user-guide/recipes/generate.md +28 -0
  268. package/docs/user-guide/recipes/manifest.md +17 -0
  269. package/docs/user-guide/recipes/mcp-stdio.md +35 -0
  270. package/docs/user-guide/recipes/new-project.md +34 -0
  271. package/docs/user-guide/recipes/observability.md +17 -0
  272. package/package.json +40 -7
  273. package/scripts/bench.ts +586 -0
  274. package/scripts/postinstall.mjs +15 -0
  275. package/source/bin/cli-output.ts +139 -0
  276. package/source/bin/commands.registry.ts +23 -3
  277. package/source/bin/file-utils.ts +95 -0
  278. package/source/bin/name-utils.ts +26 -0
  279. package/source/bin/project-utils.ts +78 -0
  280. package/source/commands/artifact.command.ts +30 -15
  281. package/source/commands/client.command.ts +64 -0
  282. package/source/commands/contract.command.ts +104 -0
  283. package/source/commands/docs.command.ts +263 -0
  284. package/source/commands/doctor.command.ts +226 -0
  285. package/source/commands/generate.command.ts +58 -0
  286. package/source/commands/inspect.command.ts +108 -0
  287. package/source/commands/mcp.command.ts +258 -0
  288. package/source/commands/new.command.ts +135 -0
  289. package/source/commands/openapi.command.ts +95 -0
  290. package/source/commands/routes.command.ts +39 -0
  291. package/source/commands/why.command.ts +61 -0
  292. package/source/contracts/decorators.ts +151 -0
  293. package/source/contracts/errors.ts +76 -0
  294. package/source/contracts/index.ts +4 -0
  295. package/source/contracts/schema.ts +377 -0
  296. package/source/contracts/typebox.ts +193 -0
  297. package/source/core/application.ts +215 -73
  298. package/source/core/builder.ts +6 -2
  299. package/source/core/config/config.ts +144 -26
  300. package/source/core/config/define.ts +35 -8
  301. package/source/core/config/index.ts +2 -1
  302. package/source/core/config/schema.ts +263 -0
  303. package/source/core/controller/builder.ts +38 -13
  304. package/source/core/controller/compiler.ts +14 -7
  305. package/source/core/controller/metadata.ts +1 -1
  306. package/source/core/hooks.ts +13 -1
  307. package/source/core/injection/injection.ts +47 -9
  308. package/source/core/mcp/builder.ts +13 -2
  309. package/source/core/mcp/metadata.ts +2 -1
  310. package/source/core/middleware/compose.ts +48 -0
  311. package/source/core/middleware/pipeline.ts +69 -46
  312. package/source/core/raiton.ts +8 -0
  313. package/source/core/router/handler.ts +91 -31
  314. package/source/core/router/handler.utils.ts +107 -51
  315. package/source/core/router/matcher.ts +195 -24
  316. package/source/core/router/route.ts +100 -31
  317. package/source/core/router/router.ts +27 -2
  318. package/source/core/scheduler/metadata.ts +1 -1
  319. package/source/core/socket/metadata.ts +1 -1
  320. package/source/core/thread.ts +37 -2
  321. package/source/framework/artifacts.ts +92 -19
  322. package/source/framework/cache/cache.ts +48 -3
  323. package/source/framework/constants/decorators.constant.ts +5 -0
  324. package/source/framework/data-transfer-object.ts +4 -3
  325. package/source/framework/decorators/controllable.decorator.ts +3 -3
  326. package/source/framework/decorators/csrf-guard.decorator.ts +3 -2
  327. package/source/framework/decorators/csrf-token.decorator.ts +1 -1
  328. package/source/framework/decorators/guard.decorator.ts +3 -2
  329. package/source/framework/decorators/health-check.decorator.ts +1 -1
  330. package/source/framework/decorators/mcp.decorator.ts +38 -7
  331. package/source/framework/decorators/middleware.decorator.ts +2 -2
  332. package/source/framework/decorators/parametrable.decorator.ts +2 -1
  333. package/source/framework/decorators/routable.decorator.ts +3 -3
  334. package/source/framework/decorators/route-interaction.decorator.ts +2 -2
  335. package/source/framework/decorators/scheduler.decorator.ts +3 -3
  336. package/source/framework/decorators/socket.decorator.ts +3 -3
  337. package/source/framework/encryption.ts +46 -7
  338. package/source/framework/errors/catalog.ts +159 -0
  339. package/source/framework/exceptions/http-exception.ts +1 -1
  340. package/source/framework/health-check.ts +18 -0
  341. package/source/framework/index.ts +2 -0
  342. package/source/framework/mcp/audit.ts +57 -0
  343. package/source/framework/mcp/conformance.ts +195 -0
  344. package/source/framework/mcp/handler.ts +131 -9
  345. package/source/framework/mcp/index.ts +6 -1
  346. package/source/framework/mcp/protocol.ts +6 -0
  347. package/source/framework/mcp/rate-limit.ts +33 -0
  348. package/source/framework/mcp/stdio.ts +150 -0
  349. package/source/framework/mcp/streamable-http.ts +36 -5
  350. package/source/framework/observability/index.ts +6 -0
  351. package/source/framework/observability/metrics.ts +162 -0
  352. package/source/framework/observability/plugin.ts +151 -0
  353. package/source/framework/observability/readiness.ts +22 -0
  354. package/source/framework/observability/request.ts +31 -0
  355. package/source/framework/observability/shutdown.ts +68 -0
  356. package/source/framework/observability/trace.ts +241 -0
  357. package/source/framework/plugins/body-parser.plugin.ts +88 -85
  358. package/source/framework/plugins/dev.plugin.ts +227 -0
  359. package/source/framework/plugins/index.ts +2 -1
  360. package/source/framework/plugins/mcp.plugin.ts +14 -3
  361. package/source/framework/plugins/openapi.plugin.ts +56 -13
  362. package/source/framework/responses/helpers.ts +4 -4
  363. package/source/framework/responses/http-throwable.ts +1 -1
  364. package/source/framework/runtime/bun/server.ts +2 -1
  365. package/source/framework/runtime/deno/server.ts +2 -1
  366. package/source/framework/runtime/index.ts +45 -13
  367. package/source/framework/runtime/node/request.ts +59 -13
  368. package/source/framework/utilities/index.ts +3 -1
  369. package/source/framework/utilities/openapi.utils.impl.ts +705 -0
  370. package/source/framework/utilities/openapi.utils.ts +6 -636
  371. package/source/framework/utilities/route-suggestion.util.ts +59 -0
  372. package/source/framework/utilities/validation.util.ts +20 -0
  373. package/source/generators/artifact.templates.ts +230 -0
  374. package/source/generators/index.ts +2 -0
  375. package/source/generators/project.templates.ts +392 -0
  376. package/source/manifest/client.ts +299 -0
  377. package/source/manifest/contract.ts +138 -0
  378. package/source/manifest/index.ts +5 -0
  379. package/source/manifest/introspect.ts +52 -0
  380. package/source/manifest/manifest.ts +341 -0
  381. package/source/manifest/schema.ts +149 -0
  382. package/source/types/builder.ts +5 -0
  383. package/source/types/config.ts +64 -2
  384. package/source/types/mcp.ts +63 -1
  385. package/tsconfig.build.json +13 -0
  386. package/source/commands/grafts.command.ts +0 -27
  387. package/tests/artifact-resolution.test.ts +0 -60
@@ -0,0 +1,341 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import {RaitonConfig} from "../core/config/config.ts";
4
+ import {RaitonThread} from "../core/thread.ts";
5
+ import {Raiton} from "../core/raiton.ts";
6
+ import {Injection} from "../core/injection/injection.ts";
7
+ import {Artifacts} from "../framework/artifacts.ts";
8
+ import {getMcpServerRegistry} from "../core/mcp/metadata.ts";
9
+ import {METADATA_KEYS} from "../framework/constants/index.ts";
10
+ import {contractToJsonSchema, isCompositeInput, type RouteContract} from "../contracts/index.ts";
11
+ import {MANIFEST_SCHEMA_VERSION, type ProjectManifest, type ProjectRouteManifest} from "./schema.ts";
12
+ import {getRouteContract} from "../contracts/decorators.ts";
13
+
14
+ import pkg from "../../package.json" with {type: "json"};
15
+
16
+ export interface GenerateManifestOptions {
17
+ workdir?: string;
18
+ /** Rebuild even when a cached manifest exists. */
19
+ refresh?: boolean;
20
+ }
21
+
22
+ let cachedManifest: ProjectManifest | null = null;
23
+ let cachedWorkdir: string | null = null;
24
+
25
+ export function invalidateManifest(): void {
26
+ cachedManifest = null;
27
+ cachedWorkdir = null;
28
+ }
29
+
30
+ export function manifestCache(): {cached: boolean; workdir: string | null} {
31
+ return {cached: Boolean(cachedManifest), workdir: cachedWorkdir};
32
+ }
33
+
34
+ function describeType(value: any): string {
35
+ if (Array.isArray(value)) return "array";
36
+ if (value === null) return "null";
37
+ return typeof value;
38
+ }
39
+
40
+ function resolveRoot(workdir: string): string {
41
+ return path.resolve(workdir, RaitonConfig.get("rootDir") || "./");
42
+ }
43
+
44
+ function relative(workdir: string, filename: string): string {
45
+ return path.relative(workdir, filename).split(path.sep).join("/");
46
+ }
47
+
48
+ function schemaName(schema: any): string | undefined {
49
+ if (!schema) return undefined;
50
+ return schema.title || schema.$id || schema.type || "object";
51
+ }
52
+
53
+ function routeLine(filename: string, propertyKey: string): number {
54
+ try {
55
+ if (!filename || !fs.existsSync(filename)) return 0;
56
+ const lines = fs.readFileSync(filename, "utf-8").split(/\r?\n/);
57
+ const pattern = new RegExp(`\\b${propertyKey.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*\\(`);
58
+ const index = lines.findIndex(line => pattern.test(line));
59
+ return index >= 0 ? index + 1 : 0;
60
+ } catch {
61
+ return 0;
62
+ }
63
+ }
64
+
65
+ function routeContracts(handler: any, controllerClass: any, propertyKey: string): RouteContract | undefined {
66
+ return (handler as any)?._raitonContract ?? getRouteContract(controllerClass, propertyKey);
67
+ }
68
+
69
+ function buildRoutes(workdir: string): ProjectRouteManifest[] {
70
+ const app: any = RaitonThread.current?.application;
71
+ const router = app?.root?.router;
72
+ if (!router) return [];
73
+
74
+ const output: ProjectRouteManifest[] = [];
75
+
76
+ const metricsPath = RaitonConfig.getObservability().metricsPath;
77
+
78
+ for (const route of router.getRoutes()) {
79
+ const meta = (route.handler as any)?._raitonMeta;
80
+ if (!meta) {
81
+ // Framework routes (health, manual `app.get`, MCP endpoints) carry
82
+ // no controller metadata but are still part of the inventory.
83
+ // Internal tooling routes are excluded from the public inventory.
84
+ if ((route.handler as any)?._raitonInternal) continue;
85
+ if (route.path.startsWith("/__dev") || route.path === metricsPath) continue;
86
+ output.push({
87
+ method: String(route.method).toUpperCase(),
88
+ path: route.version ? `/${route.version}${route.path}` : route.path,
89
+ version: route.version,
90
+ controller: "Application",
91
+ handler: route.name || "handler",
92
+ file: "",
93
+ line: 0,
94
+ });
95
+ continue;
96
+ }
97
+ const {routeMeta, controllerMeta, controllerClass} = meta;
98
+ const controllerName = controllerClass?.name ?? "Controller";
99
+ const file = Injection.getArtifactPath(controllerName) ?? "";
100
+ const contract = routeContracts(route.handler, controllerClass, routeMeta.propertyKey);
101
+
102
+ const inputSchema = contract?.input && !isCompositeInput(contract.input)
103
+ ? contractToJsonSchema(contract.input)
104
+ : contract?.input && isCompositeInput(contract.input) && contract.input.body
105
+ ? contractToJsonSchema(contract.input.body)
106
+ : undefined;
107
+ const outputSchema = contract?.output ? contractToJsonSchema(contract.output) : undefined;
108
+
109
+ output.push({
110
+ method: String(routeMeta.method).toUpperCase(),
111
+ path: `${controllerMeta.prefix ?? ""}${routeMeta.path}`.replace(/\/+/g, "/") || "/",
112
+ version: route.version,
113
+ controller: controllerName,
114
+ handler: String(routeMeta.propertyKey),
115
+ file: file ? relative(workdir, file) : "",
116
+ line: routeLine(file, String(routeMeta.propertyKey)),
117
+ input: schemaName(inputSchema),
118
+ output: schemaName(outputSchema),
119
+ inputSchema,
120
+ outputSchema,
121
+ });
122
+ }
123
+
124
+ output.sort((left, right) => `${left.path}:${left.method}`.localeCompare(`${right.path}:${right.method}`));
125
+ return output;
126
+ }
127
+
128
+ function dependencyName(value: any): string | undefined {
129
+ if (!value) return undefined;
130
+ if (typeof value === "string") return value;
131
+ if (typeof value === "function") {
132
+ const metadata = Reflect.getMetadata(METADATA_KEYS.CONTAINER, value);
133
+ return metadata?.name ?? value.name;
134
+ }
135
+ return undefined;
136
+ }
137
+
138
+ function buildInjection(): Record<string, string[]> {
139
+ const graph: Record<string, string[]> = {};
140
+
141
+ for (const definition of Injection.classes.values()) {
142
+ const dependencies: string[] = [];
143
+ const parameters = Reflect.getMetadata(METADATA_KEYS.INJECT_PARAMETERS, definition.construct) || [];
144
+ const designParameters = Reflect.getMetadata("design:paramtypes", definition.construct) || [];
145
+ const length = Math.max(parameters.length, designParameters.length);
146
+
147
+ for (let index = 0; index < length; index++) {
148
+ const name = dependencyName(parameters[index]) ?? dependencyName(designParameters[index]);
149
+ if (name) dependencies.push(name);
150
+ }
151
+
152
+ const properties = Reflect.getMetadata(METADATA_KEYS.INJECT_PROPERTIES, definition.construct);
153
+ if (properties) {
154
+ for (const value of properties.values()) {
155
+ const name = dependencyName(value);
156
+ if (name) dependencies.push(name);
157
+ }
158
+ }
159
+
160
+ graph[definition.name] = [...new Set(dependencies)];
161
+ }
162
+
163
+ return graph;
164
+ }
165
+
166
+ function buildArtifacts(workdir: string): string[] {
167
+ const root = resolveRoot(workdir);
168
+ if (!fs.existsSync(root)) return [];
169
+ const found = new Set<string>();
170
+
171
+ try {
172
+ for (const entry of fs.readdirSync(root, {recursive: true})) {
173
+ const filename = path.join(root, String(entry));
174
+ const classification = Artifacts.classify(filename);
175
+ if (classification) found.add(classification.artifactType);
176
+ }
177
+ } catch {
178
+ // A missing or unreadable source tree is reported by `doctor`.
179
+ }
180
+
181
+ return [...found].sort();
182
+ }
183
+
184
+ const ENV_PATTERNS = [
185
+ /process\.env\.([A-Z][A-Z0-9_]*)/g,
186
+ /process\.env\[\s*["']([A-Z][A-Z0-9_]*)["']\s*\]/g,
187
+ /\benv\(\s*["']([A-Z][A-Z0-9_]*)["']/g,
188
+ ];
189
+
190
+ function buildEnv(workdir: string): string[] {
191
+ const root = resolveRoot(workdir);
192
+ const names = new Set<string>();
193
+
194
+ const collect = (content: string) => {
195
+ for (const pattern of ENV_PATTERNS) {
196
+ pattern.lastIndex = 0;
197
+ let match: RegExpExecArray | null;
198
+ while ((match = pattern.exec(content))) names.add(match[1]);
199
+ }
200
+ };
201
+
202
+ if (fs.existsSync(root)) {
203
+ try {
204
+ for (const entry of fs.readdirSync(root, {recursive: true})) {
205
+ const file = path.join(root, String(entry));
206
+ if (!/\.(ts|tsx|js|mjs|cjs|mts|cts)$/.test(file)) continue;
207
+ collect(fs.readFileSync(file, "utf-8"));
208
+ }
209
+ } catch {
210
+ // Ignore unreadable files.
211
+ }
212
+ }
213
+
214
+ for (const envFile of [".env.example", ".env.sample"]) {
215
+ const filename = path.join(workdir, envFile);
216
+ if (!fs.existsSync(filename)) continue;
217
+ for (const line of fs.readFileSync(filename, "utf-8").split(/\r?\n/)) {
218
+ const match = line.match(/^\s*([A-Z][A-Z0-9_]*)\s*=/);
219
+ if (match) names.add(match[1]);
220
+ }
221
+ }
222
+
223
+ return [...names].sort();
224
+ }
225
+
226
+ function buildMcp(workdir: string): ProjectManifest["mcp"] {
227
+ const registry = getMcpServerRegistry();
228
+ const exposeDestructive = RaitonConfig.get("mcp")?.exposeDestructive ?? false;
229
+ const output: ProjectManifest["mcp"] = [];
230
+
231
+ for (const entry of registry.values()) {
232
+ const serverFile = Injection.getArtifactPath(entry.construct?.name ?? entry.name)
233
+ ?? Injection.getArtifactPath(entry.name)
234
+ ?? "";
235
+ const tools = entry.metadata.tools.map(tool => {
236
+ const annotations = (tool as any).annotations ?? {};
237
+ const destructive = annotations.destructiveHint === true;
238
+ return {
239
+ name: tool.name,
240
+ description: tool.description,
241
+ file: serverFile ? relative(workdir, serverFile) : "",
242
+ line: routeLine(serverFile, tool.propertyKey),
243
+ inputSchema: (tool as any).inputSchema
244
+ ? contractToJsonSchema((tool as any).inputSchema)
245
+ : argumentsToSchema(tool.arguments),
246
+ outputSchema: (tool as any).outputSchema
247
+ ? contractToJsonSchema((tool as any).outputSchema)
248
+ : undefined,
249
+ annotations,
250
+ exposed: !destructive || exposeDestructive || (entry.metadata as any).exposeDestructive === true,
251
+ };
252
+ });
253
+
254
+ output.push({
255
+ server: entry.name,
256
+ path: entry.path,
257
+ version: entry.version,
258
+ description: entry.description,
259
+ tools,
260
+ prompts: entry.metadata.prompts.map(prompt => ({name: prompt.name, description: prompt.description})),
261
+ resources: [
262
+ ...entry.metadata.resources.map(resource => ({uri: resource.uri, name: resource.name, mimeType: resource.mimeType})),
263
+ ...entry.metadata.resourceTemplates.map(resource => ({uriTemplate: resource.uri, name: resource.name, mimeType: resource.mimeType})),
264
+ ],
265
+ });
266
+ }
267
+
268
+ return output;
269
+ }
270
+
271
+ function argumentsToSchema(args: any[]) {
272
+ const properties: Record<string, any> = {};
273
+ const required: string[] = [];
274
+ for (const arg of args) {
275
+ const schema = arg.schema ? {...arg.schema} : {type: "string"};
276
+ if (arg.description) schema.description = arg.description;
277
+ properties[arg.name] = schema;
278
+ if (arg.required) required.push(arg.name);
279
+ }
280
+ return {
281
+ type: "object",
282
+ properties,
283
+ ...(required.length ? {required} : {}),
284
+ };
285
+ }
286
+
287
+ function buildConfig(): Record<string, string> {
288
+ const output: Record<string, string> = {};
289
+ for (const [key, value] of RaitonConfig.current.entries()) {
290
+ if (value === undefined) continue;
291
+ output[key] = describeType(value);
292
+ }
293
+ return output;
294
+ }
295
+
296
+ /**
297
+ * Generate the machine-readable project inventory. This function is never
298
+ * called on a request hot path: it is used by CLI commands and, in
299
+ * development, by the dev page endpoint.
300
+ */
301
+ export function generateManifest(options: GenerateManifestOptions = {}): ProjectManifest {
302
+ const workdir = options.workdir ?? process.cwd();
303
+
304
+ if (!options.refresh && cachedManifest && cachedWorkdir === workdir) {
305
+ return cachedManifest;
306
+ }
307
+
308
+ const runtime = (RaitonThread.current as any)?.runtime?.type ?? "unknown";
309
+ const sourceRoot = RaitonConfig.get("rootDir") || "./";
310
+ const entry = path.join(sourceRoot, "main.ts").split(path.sep).join("/");
311
+
312
+ const manifest: ProjectManifest = {
313
+ schemaVersion: MANIFEST_SCHEMA_VERSION,
314
+ generatedAt: new Date().toISOString(),
315
+ framework: {
316
+ name: Raiton.identifier,
317
+ version: pkg.version,
318
+ },
319
+ runtime: String(runtime),
320
+ project: {
321
+ rootDir: sourceRoot,
322
+ entry,
323
+ ...(RaitonConfig.source ? {configFile: relative(workdir, RaitonConfig.source)} : {}),
324
+ },
325
+ routes: buildRoutes(workdir),
326
+ injection: buildInjection(),
327
+ artifacts: buildArtifacts(workdir),
328
+ config: buildConfig(),
329
+ env: buildEnv(workdir),
330
+ mcp: buildMcp(workdir),
331
+ };
332
+
333
+ cachedManifest = manifest;
334
+ cachedWorkdir = workdir;
335
+ return manifest;
336
+ }
337
+
338
+ export function writeManifest(filename: string, manifest: ProjectManifest): void {
339
+ fs.mkdirSync(path.dirname(filename), {recursive: true});
340
+ fs.writeFileSync(filename, JSON.stringify(manifest, null, 2) + "\n", "utf-8");
341
+ }
@@ -0,0 +1,149 @@
1
+ import {t} from "../contracts/typebox.ts";
2
+ import {Value} from "@sinclair/typebox/value";
3
+
4
+ export const MANIFEST_SCHEMA_VERSION = "1.0.0";
5
+
6
+ const SchemaRecord = t.record(t.string(), t.any());
7
+
8
+ export const RouteManifestSchema = t.object({
9
+ method: t.string(),
10
+ path: t.string(),
11
+ version: t.optional(t.string()),
12
+ controller: t.string(),
13
+ handler: t.string(),
14
+ file: t.string(),
15
+ line: t.number(),
16
+ input: t.optional(t.string()),
17
+ output: t.optional(t.string()),
18
+ inputSchema: t.optional(SchemaRecord),
19
+ outputSchema: t.optional(SchemaRecord),
20
+ });
21
+
22
+ export const McpToolManifestSchema = t.object({
23
+ name: t.string(),
24
+ description: t.optional(t.string()),
25
+ file: t.optional(t.string()),
26
+ line: t.optional(t.number()),
27
+ inputSchema: t.optional(SchemaRecord),
28
+ outputSchema: t.optional(SchemaRecord),
29
+ annotations: t.optional(t.object({
30
+ readOnlyHint: t.optional(t.boolean()),
31
+ destructiveHint: t.optional(t.boolean()),
32
+ idempotentHint: t.optional(t.boolean()),
33
+ openWorldHint: t.optional(t.boolean()),
34
+ })),
35
+ exposed: t.boolean(),
36
+ });
37
+
38
+ export const McpServerManifestSchema = t.object({
39
+ server: t.string(),
40
+ path: t.string(),
41
+ version: t.optional(t.string()),
42
+ description: t.optional(t.string()),
43
+ tools: t.array(McpToolManifestSchema),
44
+ prompts: t.optional(t.array(t.any())),
45
+ resources: t.optional(t.array(t.any())),
46
+ });
47
+
48
+ export const ProjectManifestSchema = t.object({
49
+ schemaVersion: t.string(),
50
+ generatedAt: t.string(),
51
+ framework: t.object({
52
+ name: t.string(),
53
+ version: t.string(),
54
+ }),
55
+ runtime: t.string(),
56
+ project: t.object({
57
+ rootDir: t.string(),
58
+ entry: t.string(),
59
+ configFile: t.optional(t.string()),
60
+ }),
61
+ routes: t.array(RouteManifestSchema),
62
+ injection: t.record(t.string(), t.array(t.string())),
63
+ artifacts: t.array(t.string()),
64
+ config: t.record(t.string(), t.string()),
65
+ env: t.array(t.string()),
66
+ mcp: t.array(McpServerManifestSchema),
67
+ }, {additionalProperties: true});
68
+
69
+ export interface McpToolAnnotationsManifest {
70
+ title?: string;
71
+ readOnlyHint?: boolean;
72
+ destructiveHint?: boolean;
73
+ idempotentHint?: boolean;
74
+ openWorldHint?: boolean;
75
+ }
76
+
77
+ export interface McpToolManifest {
78
+ name: string;
79
+ description?: string;
80
+ file?: string;
81
+ line?: number;
82
+ inputSchema?: Record<string, any>;
83
+ outputSchema?: Record<string, any>;
84
+ annotations?: McpToolAnnotationsManifest;
85
+ exposed: boolean;
86
+ }
87
+
88
+ export interface McpServerManifest {
89
+ server: string;
90
+ path: string;
91
+ version?: string;
92
+ description?: string;
93
+ tools: McpToolManifest[];
94
+ prompts?: Array<Record<string, any>>;
95
+ resources?: Array<Record<string, any>>;
96
+ }
97
+
98
+ export interface ProjectRouteManifest {
99
+ method: string;
100
+ path: string;
101
+ version?: string;
102
+ controller: string;
103
+ handler: string;
104
+ file: string;
105
+ line: number;
106
+ input?: string;
107
+ output?: string;
108
+ inputSchema?: Record<string, any>;
109
+ outputSchema?: Record<string, any>;
110
+ }
111
+
112
+ export interface ProjectManifest {
113
+ schemaVersion: string;
114
+ generatedAt: string;
115
+ framework: {name: string; version: string};
116
+ runtime: string;
117
+ project: {rootDir: string; entry: string; configFile?: string};
118
+ routes: ProjectRouteManifest[];
119
+ injection: Record<string, string[]>;
120
+ artifacts: string[];
121
+ config: Record<string, string>;
122
+ env: string[];
123
+ mcp: McpServerManifest[];
124
+ }
125
+
126
+ export interface ManifestValidationResult {
127
+ valid: boolean;
128
+ errors: Array<{path: string; message: string}>;
129
+ }
130
+
131
+ /**
132
+ * Validate a manifest against the published, versioned schema.
133
+ */
134
+ export function validateManifest(manifest: unknown): ManifestValidationResult {
135
+ if (!Value.Check(ProjectManifestSchema, manifest)) {
136
+ return {
137
+ valid: false,
138
+ errors: [...Value.Errors(ProjectManifestSchema, manifest)].map(error => ({
139
+ path: error.path,
140
+ message: error.message,
141
+ })),
142
+ };
143
+ }
144
+ return {valid: true, errors: []};
145
+ }
146
+
147
+ export function manifestJsonSchema(): Record<string, any> {
148
+ return JSON.parse(JSON.stringify(ProjectManifestSchema));
149
+ }
@@ -13,6 +13,11 @@ export interface BuildCommandOptionsInterface {
13
13
  export interface BuilderConfigInterface {
14
14
  serve?: boolean;
15
15
  hmr?: boolean;
16
+ /**
17
+ * Compile/typecheck when booting without serving. CLI introspection sets
18
+ * this to `false` so `inspect` and `doctor` never run a build.
19
+ */
20
+ compile?: boolean;
16
21
  }
17
22
 
18
23
  export type BuilderBootCallableType = (builder: BuilderInterface) => Promise<void>
@@ -1,7 +1,69 @@
1
1
  import type {ArtifactsConfigInterface} from "./artifact.ts";
2
+ import type {HttpsConfigInput} from "../framework/utilities/https.util.ts";
3
+
4
+ export type ObservabilityMode = "off" | "metrics" | "traces" | "all";
5
+
6
+ export interface ObservabilityConfigInterface {
7
+ /** Defaults to `off`: no metrics, no traces, no exporter. */
8
+ mode?: ObservabilityMode;
9
+ /** Prometheus exposition path. @default '/metrics' */
10
+ metricsPath?: string;
11
+ /** OTLP HTTP endpoint used when traces are enabled. */
12
+ otelEndpoint?: string;
13
+ /** Header carrying the correlation id. @default 'x-request-id' */
14
+ requestIdHeader?: string;
15
+ /** Service name attached to traces. */
16
+ serviceName?: string;
17
+ }
18
+
19
+ export interface ValidationConfigInterface {
20
+ /**
21
+ * Output validation. `auto` enables it in development and disables it in
22
+ * production. A boolean forces the value.
23
+ * @default 'auto'
24
+ */
25
+ responses?: boolean | "auto";
26
+ }
27
+
28
+ export interface ShutdownConfigInterface {
29
+ /** Maximum time spent draining in-flight requests. @default 10000 */
30
+ timeoutMs?: number;
31
+ }
32
+
33
+ export interface DevPageConfigInterface {
34
+ /** Mount the development page. Defaults to the HMR/dev mode. */
35
+ enabled?: boolean;
36
+ /** Page route. @default '/__dev' */
37
+ path?: string;
38
+ }
39
+
40
+ export interface McpConfigInterface {
41
+ /** Expose destructive tools. Defaults to false. */
42
+ exposeDestructive?: boolean;
43
+ /** Per-tool calls per minute. 0 disables the limiter. */
44
+ rateLimitPerMinute?: number;
45
+ }
2
46
 
3
47
  export interface ConfigurableInterface {
4
48
  rootDir: string;
5
49
  version: string;
6
- artifacts?: ArtifactsConfigInterface
7
- }
50
+ artifacts?: ArtifactsConfigInterface;
51
+ port?: number;
52
+ hostname?: string;
53
+ protocole?: "http" | "https";
54
+ pathname?: string;
55
+ prefix?: string;
56
+ develop?: boolean;
57
+ verbose?: boolean;
58
+ https?: HttpsConfigInput;
59
+ observability?: ObservabilityConfigInterface;
60
+ validation?: ValidationConfigInterface;
61
+ shutdown?: ShutdownConfigInterface;
62
+ devPage?: DevPageConfigInterface;
63
+ mcp?: McpConfigInterface;
64
+ /** Documentation generation options. */
65
+ docs?: {
66
+ dir?: string;
67
+ lang?: "fr" | "en";
68
+ };
69
+ }
@@ -20,6 +20,17 @@ export interface McpArgumentMetaInterface {
20
20
 
21
21
  export type McpElementType = 'tool' | 'prompt' | 'resource' | 'resource-template' | 'read';
22
22
 
23
+ /**
24
+ * MCP tool safety annotations (spec 2024-11-05 / 2025-06-18).
25
+ */
26
+ export interface McpToolAnnotations {
27
+ title?: string;
28
+ readOnlyHint?: boolean;
29
+ destructiveHint?: boolean;
30
+ idempotentHint?: boolean;
31
+ openWorldHint?: boolean;
32
+ }
33
+
23
34
  export interface McpElementMetaInterface {
24
35
  type: McpElementType;
25
36
  name: string;
@@ -29,6 +40,15 @@ export interface McpElementMetaInterface {
29
40
  uri?: string;
30
41
  mimeType?: string;
31
42
  title?: string;
43
+ /** JSON schema or contract schema for tool input. */
44
+ inputSchema?: any;
45
+ /** JSON schema or contract schema for structured tool output. */
46
+ outputSchema?: any;
47
+ annotations?: McpToolAnnotations;
48
+ /** Scopes required to call the tool. Empty means public. */
49
+ scopes?: string[];
50
+ /** Explicit destructive marker. `annotations.destructiveHint` wins. */
51
+ destructive?: boolean;
32
52
  }
33
53
 
34
54
  export interface McpServerMetaInterface {
@@ -41,6 +61,10 @@ export interface McpServerMetaInterface {
41
61
  prompts: McpElementMetaInterface[];
42
62
  resources: McpElementMetaInterface[];
43
63
  resourceTemplates: McpElementMetaInterface[];
64
+ /** Expose destructive tools for this server. Defaults to false. */
65
+ exposeDestructive?: boolean;
66
+ /** Per-tool calls per minute. 0 disables the limiter. */
67
+ rateLimitPerMinute?: number;
44
68
  }
45
69
 
46
70
  export interface McpServerOptionsInterface {
@@ -49,6 +73,18 @@ export interface McpServerOptionsInterface {
49
73
  description?: string;
50
74
  path?: string;
51
75
  instructions?: string;
76
+ exposeDestructive?: boolean;
77
+ rateLimitPerMinute?: number;
78
+ }
79
+
80
+ export interface McpToolOptions {
81
+ name?: string;
82
+ description?: string;
83
+ inputSchema?: any;
84
+ outputSchema?: any;
85
+ annotations?: McpToolAnnotations;
86
+ destructive?: boolean;
87
+ scopes?: string[];
52
88
  }
53
89
 
54
90
  export type McpNodeMethod =
@@ -115,4 +151,30 @@ export interface McpToolResultContent {
115
151
  export interface McpTextContent {
116
152
  type: 'text';
117
153
  text: string;
118
- }
154
+ }
155
+
156
+ /**
157
+ * Invocation context propagated by HTTP and stdio transports. Authentication
158
+ * itself is out of scope for spec 002, but scopes and actor are enforced when
159
+ * present so the future auth spec can plug in without an API change.
160
+ */
161
+ export interface McpInvocationContext {
162
+ actor?: string;
163
+ scopes?: string[];
164
+ headers?: Record<string, string>;
165
+ transport?: McpTransportType;
166
+ sessionId?: string;
167
+ }
168
+
169
+ export interface McpAuditEvent {
170
+ callId: string;
171
+ server: string;
172
+ tool: string;
173
+ actor?: string;
174
+ transport?: McpTransportType;
175
+ durationMs: number;
176
+ success: boolean;
177
+ error?: string;
178
+ arguments?: any;
179
+ result?: any;
180
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "noEmit": false,
5
+ "declaration": true,
6
+ "declarationMap": false,
7
+ "emitDeclarationOnly": true,
8
+ "sourceMap": false,
9
+ "outDir": "build/types"
10
+ },
11
+ "include": ["source"],
12
+ "exclude": ["node_modules", "build", "tests"]
13
+ }