veryfront 0.1.128 → 0.1.129

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 (382) hide show
  1. package/esm/cli/router.d.ts +0 -5
  2. package/esm/cli/router.d.ts.map +1 -1
  3. package/esm/cli/router.js +30 -2
  4. package/esm/cli/shared/update-check.d.ts +4 -0
  5. package/esm/cli/shared/update-check.d.ts.map +1 -0
  6. package/esm/cli/shared/update-check.js +97 -0
  7. package/esm/deno.d.ts +5 -0
  8. package/esm/deno.js +13 -8
  9. package/esm/src/channels/control-plane.d.ts.map +1 -1
  10. package/esm/src/channels/control-plane.js +5 -5
  11. package/esm/src/channels/invoke.d.ts +1 -1
  12. package/esm/src/channels/invoke.d.ts.map +1 -1
  13. package/esm/src/channels/invoke.js +6 -6
  14. package/esm/src/chat/index.d.ts +12 -24
  15. package/esm/src/chat/index.d.ts.map +1 -1
  16. package/esm/src/chat/index.js +5 -25
  17. package/esm/src/config/env.d.ts.map +1 -1
  18. package/esm/src/config/env.js +18 -10
  19. package/esm/src/data/static-data-fetcher.d.ts +3 -0
  20. package/esm/src/data/static-data-fetcher.d.ts.map +1 -1
  21. package/esm/src/data/static-data-fetcher.js +29 -25
  22. package/esm/src/data/static-paths-fetcher.d.ts.map +1 -1
  23. package/esm/src/data/static-paths-fetcher.js +3 -2
  24. package/esm/src/errors/logging.d.ts.map +1 -1
  25. package/esm/src/errors/logging.js +16 -7
  26. package/esm/src/errors/user-friendly/error-formatter.d.ts.map +1 -1
  27. package/esm/src/errors/user-friendly/error-formatter.js +9 -25
  28. package/esm/src/fs/index.d.ts +11 -12
  29. package/esm/src/fs/index.d.ts.map +1 -1
  30. package/esm/src/fs/index.js +11 -24
  31. package/esm/src/html/dev-scripts.d.ts.map +1 -1
  32. package/esm/src/html/dev-scripts.js +5 -8
  33. package/esm/src/html/html-escape.d.ts +1 -0
  34. package/esm/src/html/html-escape.d.ts.map +1 -1
  35. package/esm/src/html/html-escape.js +3 -0
  36. package/esm/src/html/html-injection.js +2 -2
  37. package/esm/src/html/html-shell-generator.d.ts +5 -2
  38. package/esm/src/html/html-shell-generator.d.ts.map +1 -1
  39. package/esm/src/html/html-shell-generator.js +41 -30
  40. package/esm/src/html/hydration-script-builder/dev-client-renderer.js +2 -2
  41. package/esm/src/html/hydration-script-builder/dev-component-manifest.js +2 -2
  42. package/esm/src/html/hydration-script-builder/dev-error-logger.d.ts.map +1 -1
  43. package/esm/src/html/hydration-script-builder/dev-error-logger.js +2 -6
  44. package/esm/src/html/hydration-script-builder/dev-scripts.js +2 -2
  45. package/esm/src/html/hydration-script-builder/hydration-data-generator.d.ts +3 -1
  46. package/esm/src/html/hydration-script-builder/hydration-data-generator.d.ts.map +1 -1
  47. package/esm/src/html/hydration-script-builder/hydration-data-generator.js +2 -2
  48. package/esm/src/html/hydration-script-builder/index.d.ts +1 -1
  49. package/esm/src/html/hydration-script-builder/index.d.ts.map +1 -1
  50. package/esm/src/html/hydration-script-builder/index.js +1 -1
  51. package/esm/src/html/hydration-script-builder/prod-hydration.js +2 -2
  52. package/esm/src/html/hydration-script-builder/prod-scripts.d.ts +2 -0
  53. package/esm/src/html/hydration-script-builder/prod-scripts.d.ts.map +1 -1
  54. package/esm/src/html/hydration-script-builder/prod-scripts.js +14 -14
  55. package/esm/src/html/schemas/html.schema.d.ts +2 -0
  56. package/esm/src/html/schemas/html.schema.d.ts.map +1 -1
  57. package/esm/src/html/schemas/html.schema.js +2 -0
  58. package/esm/src/html/styles-builder/css-pregeneration.d.ts +17 -1
  59. package/esm/src/html/styles-builder/css-pregeneration.d.ts.map +1 -1
  60. package/esm/src/html/styles-builder/css-pregeneration.js +103 -1
  61. package/esm/src/html/styles-builder/dev-styles.js +2 -2
  62. package/esm/src/html/utils.d.ts +2 -0
  63. package/esm/src/html/utils.d.ts.map +1 -1
  64. package/esm/src/html/utils.js +49 -28
  65. package/esm/src/integrations/remote-tools.d.ts.map +1 -1
  66. package/esm/src/integrations/remote-tools.js +32 -39
  67. package/esm/src/internal-agents/ag-ui-sse.d.ts +0 -1
  68. package/esm/src/internal-agents/ag-ui-sse.d.ts.map +1 -1
  69. package/esm/src/internal-agents/ag-ui-sse.js +2 -16
  70. package/esm/src/internal-agents/control-plane-auth.d.ts.map +1 -1
  71. package/esm/src/internal-agents/control-plane-auth.js +5 -3
  72. package/esm/src/internal-agents/request-body.d.ts.map +1 -1
  73. package/esm/src/internal-agents/request-body.js +6 -3
  74. package/esm/src/internal-agents/session-manager.d.ts +1 -0
  75. package/esm/src/internal-agents/session-manager.d.ts.map +1 -1
  76. package/esm/src/internal-agents/session-manager.js +12 -18
  77. package/esm/src/issues/core.d.ts.map +1 -1
  78. package/esm/src/issues/core.js +24 -23
  79. package/esm/src/issues/schemas/issue.schema.d.ts.map +1 -1
  80. package/esm/src/issues/schemas/issue.schema.js +2 -1
  81. package/esm/src/jobs/runtime-env.d.ts.map +1 -1
  82. package/esm/src/jobs/runtime-env.js +21 -44
  83. package/esm/src/markdown/index.d.ts +1 -2
  84. package/esm/src/markdown/index.d.ts.map +1 -1
  85. package/esm/src/markdown/index.js +1 -6
  86. package/esm/src/mcp/server.d.ts +0 -1
  87. package/esm/src/mcp/server.d.ts.map +1 -1
  88. package/esm/src/mcp/server.js +40 -41
  89. package/esm/src/mdx/index.d.ts +3 -2
  90. package/esm/src/mdx/index.d.ts.map +1 -1
  91. package/esm/src/mdx/index.js +3 -5
  92. package/esm/src/middleware/builtin/logger.d.ts.map +1 -1
  93. package/esm/src/middleware/builtin/logger.js +31 -28
  94. package/esm/src/middleware/builtin/security/rate-limit.d.ts.map +1 -1
  95. package/esm/src/middleware/builtin/security/rate-limit.js +17 -12
  96. package/esm/src/middleware/builtin/timeout.d.ts.map +1 -1
  97. package/esm/src/middleware/builtin/timeout.js +17 -10
  98. package/esm/src/modules/import-map/default-import-map.d.ts.map +1 -1
  99. package/esm/src/modules/import-map/default-import-map.js +4 -3
  100. package/esm/src/oauth/handlers/callback-handler.d.ts +0 -5
  101. package/esm/src/oauth/handlers/callback-handler.d.ts.map +1 -1
  102. package/esm/src/oauth/handlers/callback-handler.js +9 -14
  103. package/esm/src/oauth/handlers/index.d.ts +1 -1
  104. package/esm/src/oauth/handlers/index.js +1 -1
  105. package/esm/src/oauth/handlers/init-handler.d.ts.map +1 -1
  106. package/esm/src/oauth/handlers/init-handler.js +32 -20
  107. package/esm/src/oauth/providers/index.d.ts +1 -1
  108. package/esm/src/oauth/providers/index.js +1 -1
  109. package/esm/src/oauth/schemas/index.d.ts +1 -1
  110. package/esm/src/oauth/schemas/index.js +1 -1
  111. package/esm/src/oauth/token-store/index.d.ts +1 -1
  112. package/esm/src/oauth/token-store/index.js +1 -1
  113. package/esm/src/oauth/token-store/memory.d.ts +1 -1
  114. package/esm/src/oauth/token-store/memory.d.ts.map +1 -1
  115. package/esm/src/oauth/token-store/memory.js +8 -8
  116. package/esm/src/observability/request-profiler.d.ts +31 -0
  117. package/esm/src/observability/request-profiler.d.ts.map +1 -0
  118. package/esm/src/observability/request-profiler.js +94 -0
  119. package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -1
  120. package/esm/src/observability/tracing/otlp-setup.js +16 -21
  121. package/esm/src/prompt/factory.d.ts.map +1 -1
  122. package/esm/src/prompt/factory.js +10 -12
  123. package/esm/src/prompt/registry.d.ts.map +1 -1
  124. package/esm/src/prompt/registry.js +12 -10
  125. package/esm/src/prompt/schemas/prompt.schema.d.ts.map +1 -1
  126. package/esm/src/prompt/schemas/prompt.schema.js +0 -2
  127. package/esm/src/prompt/types.d.ts +1 -1
  128. package/esm/src/prompt/types.d.ts.map +1 -1
  129. package/esm/src/provider/local/ai-sdk-adapter.d.ts.map +1 -1
  130. package/esm/src/provider/local/ai-sdk-adapter.js +3 -8
  131. package/esm/src/provider/local/env.d.ts +4 -6
  132. package/esm/src/provider/local/env.d.ts.map +1 -1
  133. package/esm/src/provider/local/env.js +14 -1
  134. package/esm/src/provider/local/local-engine.d.ts.map +1 -1
  135. package/esm/src/provider/local/local-engine.js +2 -7
  136. package/esm/src/provider/model-registry.d.ts.map +1 -1
  137. package/esm/src/provider/model-registry.js +2 -7
  138. package/esm/src/provider/veryfront-cloud/provider.d.ts.map +1 -1
  139. package/esm/src/provider/veryfront-cloud/provider.js +1 -7
  140. package/esm/src/provider/veryfront-cloud/shared.d.ts.map +1 -1
  141. package/esm/src/provider/veryfront-cloud/shared.js +9 -11
  142. package/esm/src/proxy/handler.d.ts.map +1 -1
  143. package/esm/src/proxy/handler.js +56 -57
  144. package/esm/src/react/compat/hooks-adapter.d.ts +1 -7
  145. package/esm/src/react/compat/hooks-adapter.d.ts.map +1 -1
  146. package/esm/src/react/compat/hooks-adapter.js +35 -40
  147. package/esm/src/react/components/Head.d.ts +1 -26
  148. package/esm/src/react/components/Head.d.ts.map +1 -1
  149. package/esm/src/react/components/Head.js +1 -172
  150. package/esm/src/react/context/index.d.ts +2 -46
  151. package/esm/src/react/context/index.d.ts.map +1 -1
  152. package/esm/src/react/context/index.js +1 -44
  153. package/esm/src/react/head-collector.d.ts +1 -10
  154. package/esm/src/react/head-collector.d.ts.map +1 -1
  155. package/esm/src/react/head-collector.js +4 -0
  156. package/esm/src/react/router/index.d.ts +2 -45
  157. package/esm/src/react/router/index.d.ts.map +1 -1
  158. package/esm/src/react/router/index.js +1 -49
  159. package/esm/src/react/runtime/core.d.ts +49 -0
  160. package/esm/src/react/runtime/core.d.ts.map +1 -0
  161. package/esm/src/react/runtime/core.js +200 -0
  162. package/esm/src/rendering/orchestrator/html.d.ts +2 -0
  163. package/esm/src/rendering/orchestrator/html.d.ts.map +1 -1
  164. package/esm/src/rendering/orchestrator/html.js +69 -12
  165. package/esm/src/rendering/orchestrator/ssr-orchestrator.d.ts.map +1 -1
  166. package/esm/src/rendering/orchestrator/ssr-orchestrator.js +4 -0
  167. package/esm/src/rendering/orchestrator/types.d.ts +4 -0
  168. package/esm/src/rendering/orchestrator/types.d.ts.map +1 -1
  169. package/esm/src/repositories/types.d.ts.map +1 -1
  170. package/esm/src/resource/factory.d.ts.map +1 -1
  171. package/esm/src/resource/factory.js +12 -9
  172. package/esm/src/resource/registry.d.ts +3 -3
  173. package/esm/src/resource/registry.d.ts.map +1 -1
  174. package/esm/src/resource/registry.js +7 -7
  175. package/esm/src/schemas/common.d.ts.map +1 -1
  176. package/esm/src/schemas/common.js +7 -4
  177. package/esm/src/security/http/config.d.ts +0 -1
  178. package/esm/src/security/http/config.d.ts.map +1 -1
  179. package/esm/src/security/http/config.js +3 -16
  180. package/esm/src/security/http/response/security-handler.d.ts +1 -0
  181. package/esm/src/security/http/response/security-handler.d.ts.map +1 -1
  182. package/esm/src/security/http/response/security-handler.js +17 -12
  183. package/esm/src/security/index.d.ts +4 -2
  184. package/esm/src/security/index.d.ts.map +1 -1
  185. package/esm/src/security/index.js +3 -1
  186. package/esm/src/server/handlers/dev/styles-css.handler.d.ts.map +1 -1
  187. package/esm/src/server/handlers/dev/styles-css.handler.js +8 -7
  188. package/esm/src/server/handlers/monitoring/metrics.handler.d.ts.map +1 -1
  189. package/esm/src/server/handlers/monitoring/metrics.handler.js +3 -1
  190. package/esm/src/server/handlers/request/module/module-server-handler.d.ts.map +1 -1
  191. package/esm/src/server/handlers/request/module/module-server-handler.js +18 -15
  192. package/esm/src/server/handlers/request/prod-hydration-module.handler.d.ts +8 -0
  193. package/esm/src/server/handlers/request/prod-hydration-module.handler.d.ts.map +1 -0
  194. package/esm/src/server/handlers/request/prod-hydration-module.handler.js +41 -0
  195. package/esm/src/server/handlers/request/ssr/ssr.handler.d.ts.map +1 -1
  196. package/esm/src/server/handlers/request/ssr/ssr.handler.js +3 -0
  197. package/esm/src/server/production-server.d.ts.map +1 -1
  198. package/esm/src/server/production-server.js +65 -0
  199. package/esm/src/server/runtime-handler/handler-context-builder.d.ts +1 -1
  200. package/esm/src/server/runtime-handler/handler-context-builder.d.ts.map +1 -1
  201. package/esm/src/server/runtime-handler/index.d.ts +1 -1
  202. package/esm/src/server/runtime-handler/index.d.ts.map +1 -1
  203. package/esm/src/server/runtime-handler/index.js +36 -11
  204. package/esm/src/server/runtime-handler/request-utils.d.ts +7 -0
  205. package/esm/src/server/runtime-handler/request-utils.d.ts.map +1 -1
  206. package/esm/src/server/runtime-handler/request-utils.js +10 -0
  207. package/esm/src/server/services/rendering/ssr.service.d.ts +1 -0
  208. package/esm/src/server/services/rendering/ssr.service.d.ts.map +1 -1
  209. package/esm/src/server/services/rendering/ssr.service.js +12 -5
  210. package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.js +1 -1
  211. package/esm/src/skill/allowed-tools.d.ts +3 -8
  212. package/esm/src/skill/allowed-tools.d.ts.map +1 -1
  213. package/esm/src/skill/executor.js +2 -2
  214. package/esm/src/skill/parser.d.ts.map +1 -1
  215. package/esm/src/skill/parser.js +12 -12
  216. package/esm/src/skill/path-safety.js +1 -1
  217. package/esm/src/skill/tools.d.ts.map +1 -1
  218. package/esm/src/skill/tools.js +18 -11
  219. package/esm/src/studio/bridge/bridge-bundle.generated.d.ts.map +1 -1
  220. package/esm/src/studio/bridge/bridge-bundle.generated.js +1 -1
  221. package/esm/src/task/discovery.d.ts.map +1 -1
  222. package/esm/src/task/discovery.js +73 -95
  223. package/esm/src/tool/executor.d.ts.map +1 -1
  224. package/esm/src/tool/executor.js +8 -7
  225. package/esm/src/tool/factory.d.ts.map +1 -1
  226. package/esm/src/tool/factory.js +13 -16
  227. package/esm/src/transforms/esm/package-registry.d.ts +4 -0
  228. package/esm/src/transforms/esm/package-registry.d.ts.map +1 -1
  229. package/esm/src/transforms/esm/package-registry.js +34 -17
  230. package/esm/src/transforms/import-rewriter/strategies/veryfront-strategy.d.ts.map +1 -1
  231. package/esm/src/transforms/import-rewriter/strategies/veryfront-strategy.js +2 -1
  232. package/esm/src/transforms/mdx/esm-module-loader/cache-format.d.ts.map +1 -1
  233. package/esm/src/transforms/mdx/esm-module-loader/cache-format.js +26 -1
  234. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts +1 -1
  235. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts.map +1 -1
  236. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.js +1 -1
  237. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.d.ts +1 -0
  238. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.d.ts.map +1 -1
  239. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.js +3 -0
  240. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/index.d.ts +1 -1
  241. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/index.js +1 -1
  242. package/esm/src/transforms/veryfront-module-urls.d.ts.map +1 -1
  243. package/esm/src/transforms/veryfront-module-urls.js +7 -3
  244. package/esm/src/types/entities/getEntityInfo.d.ts.map +1 -1
  245. package/esm/src/types/entities/getEntityInfo.js +79 -127
  246. package/esm/src/utils/path-utils.d.ts +1 -1
  247. package/esm/src/utils/path-utils.d.ts.map +1 -1
  248. package/esm/src/utils/path-utils.js +16 -7
  249. package/esm/src/utils/version-constant.d.ts +1 -1
  250. package/esm/src/utils/version-constant.js +1 -1
  251. package/esm/src/utils/version.d.ts.map +1 -1
  252. package/esm/src/utils/version.js +0 -1
  253. package/esm/src/workflow/worker/dynamic-job-entrypoint.d.ts.map +1 -1
  254. package/esm/src/workflow/worker/dynamic-job-entrypoint.js +5 -72
  255. package/esm/src/workflow/worker/job-entrypoint.d.ts.map +1 -1
  256. package/esm/src/workflow/worker/job-entrypoint.js +5 -72
  257. package/esm/src/workflow/worker/shared.d.ts +18 -0
  258. package/esm/src/workflow/worker/shared.d.ts.map +1 -0
  259. package/esm/src/workflow/worker/shared.js +77 -0
  260. package/package.json +1 -1
  261. package/src/cli/router.ts +41 -2
  262. package/src/cli/shared/update-check.ts +110 -0
  263. package/src/deno.js +13 -8
  264. package/src/src/channels/control-plane.ts +6 -10
  265. package/src/src/channels/invoke.ts +7 -7
  266. package/src/src/chat/index.ts +96 -132
  267. package/src/src/config/env.ts +24 -11
  268. package/src/src/data/static-data-fetcher.ts +59 -34
  269. package/src/src/data/static-paths-fetcher.ts +4 -2
  270. package/src/src/errors/logging.ts +21 -7
  271. package/src/src/errors/user-friendly/error-formatter.ts +14 -29
  272. package/src/src/fs/index.ts +21 -30
  273. package/src/src/html/dev-scripts.ts +5 -9
  274. package/src/src/html/html-escape.ts +4 -0
  275. package/src/src/html/html-injection.ts +2 -2
  276. package/src/src/html/html-shell-generator.ts +60 -26
  277. package/src/src/html/hydration-script-builder/dev-client-renderer.ts +2 -2
  278. package/src/src/html/hydration-script-builder/dev-component-manifest.ts +2 -2
  279. package/src/src/html/hydration-script-builder/dev-error-logger.ts +2 -8
  280. package/src/src/html/hydration-script-builder/dev-scripts.ts +2 -2
  281. package/src/src/html/hydration-script-builder/hydration-data-generator.ts +2 -1
  282. package/src/src/html/hydration-script-builder/index.ts +5 -1
  283. package/src/src/html/hydration-script-builder/prod-hydration.ts +2 -2
  284. package/src/src/html/hydration-script-builder/prod-scripts.ts +16 -15
  285. package/src/src/html/schemas/html.schema.ts +2 -0
  286. package/src/src/html/styles-builder/css-pregeneration.ts +133 -1
  287. package/src/src/html/styles-builder/dev-styles.ts +2 -2
  288. package/src/src/html/utils.ts +62 -29
  289. package/src/src/integrations/remote-tools.ts +39 -37
  290. package/src/src/internal-agents/ag-ui-sse.ts +2 -17
  291. package/src/src/internal-agents/control-plane-auth.ts +8 -6
  292. package/src/src/internal-agents/request-body.ts +7 -5
  293. package/src/src/internal-agents/session-manager.ts +16 -20
  294. package/src/src/issues/core.ts +24 -27
  295. package/src/src/issues/schemas/issue.schema.ts +3 -1
  296. package/src/src/jobs/runtime-env.ts +24 -50
  297. package/src/src/markdown/index.ts +5 -8
  298. package/src/src/mcp/server.ts +50 -53
  299. package/src/src/mdx/index.ts +7 -8
  300. package/src/src/middleware/builtin/logger.ts +44 -29
  301. package/src/src/middleware/builtin/security/rate-limit.ts +20 -11
  302. package/src/src/middleware/builtin/timeout.ts +22 -13
  303. package/src/src/modules/import-map/default-import-map.ts +4 -3
  304. package/src/src/oauth/handlers/callback-handler.ts +9 -16
  305. package/src/src/oauth/handlers/index.ts +1 -1
  306. package/src/src/oauth/handlers/init-handler.ts +56 -27
  307. package/src/src/oauth/providers/index.ts +1 -1
  308. package/src/src/oauth/schemas/index.ts +1 -1
  309. package/src/src/oauth/token-store/index.ts +1 -1
  310. package/src/src/oauth/token-store/memory.ts +8 -8
  311. package/src/src/observability/request-profiler.ts +140 -0
  312. package/src/src/observability/tracing/otlp-setup.ts +16 -22
  313. package/src/src/prompt/factory.ts +16 -14
  314. package/src/src/prompt/registry.ts +14 -13
  315. package/src/src/prompt/schemas/prompt.schema.ts +0 -4
  316. package/src/src/prompt/types.ts +1 -2
  317. package/src/src/provider/local/ai-sdk-adapter.ts +3 -10
  318. package/src/src/provider/local/env.ts +22 -2
  319. package/src/src/provider/local/local-engine.ts +2 -9
  320. package/src/src/provider/model-registry.ts +2 -9
  321. package/src/src/provider/veryfront-cloud/provider.ts +1 -8
  322. package/src/src/provider/veryfront-cloud/shared.ts +12 -15
  323. package/src/src/proxy/handler.ts +90 -74
  324. package/src/src/react/compat/hooks-adapter.ts +43 -44
  325. package/src/src/react/components/Head.tsx +1 -181
  326. package/src/src/react/context/index.tsx +2 -83
  327. package/src/src/react/head-collector.ts +9 -0
  328. package/src/src/react/router/index.tsx +2 -100
  329. package/src/src/react/runtime/core.ts +303 -0
  330. package/src/src/rendering/orchestrator/html.ts +122 -18
  331. package/src/src/rendering/orchestrator/ssr-orchestrator.ts +8 -0
  332. package/src/src/rendering/orchestrator/types.ts +4 -0
  333. package/src/src/repositories/types.ts +0 -4
  334. package/src/src/resource/factory.ts +15 -11
  335. package/src/src/resource/registry.ts +7 -7
  336. package/src/src/schemas/common.ts +8 -5
  337. package/src/src/security/http/config.ts +3 -19
  338. package/src/src/security/http/response/security-handler.ts +22 -13
  339. package/src/src/security/index.ts +4 -7
  340. package/src/src/server/handlers/dev/styles-css.handler.ts +32 -14
  341. package/src/src/server/handlers/monitoring/metrics.handler.ts +3 -1
  342. package/src/src/server/handlers/request/module/module-server-handler.ts +24 -17
  343. package/src/src/server/handlers/request/prod-hydration-module.handler.ts +61 -0
  344. package/src/src/server/handlers/request/ssr/ssr.handler.ts +3 -0
  345. package/src/src/server/production-server.ts +84 -0
  346. package/src/src/server/runtime-handler/handler-context-builder.ts +1 -1
  347. package/src/src/server/runtime-handler/index.ts +44 -13
  348. package/src/src/server/runtime-handler/request-utils.ts +11 -0
  349. package/src/src/server/services/rendering/ssr.service.ts +31 -18
  350. package/src/src/server/services/rsc/endpoints/rsc-bundles.generated.ts +1 -1
  351. package/src/src/skill/allowed-tools.ts +1 -8
  352. package/src/src/skill/executor.ts +2 -2
  353. package/src/src/skill/parser.ts +13 -20
  354. package/src/src/skill/path-safety.ts +1 -1
  355. package/src/src/skill/tools.ts +27 -20
  356. package/src/src/studio/bridge/bridge-bundle.generated.ts +1 -1
  357. package/src/src/task/discovery.ts +97 -97
  358. package/src/src/tool/executor.ts +10 -8
  359. package/src/src/tool/factory.ts +21 -22
  360. package/src/src/tool/types.ts +0 -17
  361. package/src/src/transforms/esm/package-registry.ts +52 -20
  362. package/src/src/transforms/import-rewriter/strategies/veryfront-strategy.ts +2 -1
  363. package/src/src/transforms/mdx/esm-module-loader/cache-format.ts +34 -1
  364. package/src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts +1 -1
  365. package/src/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.ts +4 -0
  366. package/src/src/transforms/pipeline/stages/ssr-vf-modules/index.ts +1 -1
  367. package/src/src/transforms/veryfront-module-urls.ts +6 -2
  368. package/src/src/types/entities/getEntityInfo.ts +131 -152
  369. package/src/src/utils/path-utils.ts +16 -7
  370. package/src/src/utils/version-constant.ts +1 -1
  371. package/src/src/utils/version.ts +0 -1
  372. package/src/src/workflow/worker/dynamic-job-entrypoint.ts +18 -84
  373. package/src/src/workflow/worker/job-entrypoint.ts +18 -85
  374. package/src/src/workflow/worker/shared.ts +127 -0
  375. package/esm/src/prompt/schemas/index.d.ts +0 -7
  376. package/esm/src/prompt/schemas/index.d.ts.map +0 -1
  377. package/esm/src/prompt/schemas/index.js +0 -6
  378. package/esm/src/security/http/handlers-index.d.ts +0 -5
  379. package/esm/src/security/http/handlers-index.d.ts.map +0 -1
  380. package/esm/src/security/http/handlers-index.js +0 -3
  381. package/src/src/prompt/schemas/index.ts +0 -7
  382. package/src/src/security/http/handlers-index.ts +0 -4
@@ -12,6 +12,7 @@ const logger = serverLogger.component("timeout");
12
12
 
13
13
  const DEFAULT_TIMEOUT_MS = 60_000;
14
14
  const TIMEOUT_SENTINEL = Symbol("timeout");
15
+ const DEFAULT_EXCLUDE_PATHS = ["/healthz", "/readyz", "/_health"];
15
16
 
16
17
  export interface TimeoutOptions {
17
18
  /** Timeout in milliseconds (default: 60000) */
@@ -24,6 +25,24 @@ export interface TimeoutOptions {
24
25
  exclude?: string[];
25
26
  }
26
27
 
28
+ function isExcludedPath(pathname: string, exclude: string[]): boolean {
29
+ return exclude.some((path) => pathname === path || pathname.startsWith(path));
30
+ }
31
+
32
+ function timeoutResponse(pathname: string, timeoutMs: number, message: string): dntShim.Response {
33
+ return new dntShim.Response(
34
+ JSON.stringify({
35
+ error: message,
36
+ timeoutMs,
37
+ path: pathname,
38
+ }),
39
+ {
40
+ status: HTTP_GATEWAY_TIMEOUT,
41
+ headers: { "Content-Type": "application/json" },
42
+ },
43
+ );
44
+ }
45
+
27
46
  /**
28
47
  * Creates a middleware that enforces request timeouts.
29
48
  *
@@ -33,13 +52,13 @@ export interface TimeoutOptions {
33
52
  export function timeout(options?: TimeoutOptions): Middleware {
34
53
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
35
54
  const message = options?.message ?? "Request timeout";
36
- const exclude = options?.exclude ?? ["/healthz", "/readyz", "/_health"];
55
+ const exclude = options?.exclude ?? DEFAULT_EXCLUDE_PATHS;
37
56
 
38
57
  return async (ctx, next) => {
39
58
  const req = getRequest(ctx);
40
59
  const { pathname } = new URL(req.url);
41
60
 
42
- if (exclude.some((path) => pathname === path || pathname.startsWith(path))) {
61
+ if (isExcludedPath(pathname, exclude)) {
43
62
  return next();
44
63
  }
45
64
 
@@ -60,17 +79,7 @@ export function timeout(options?: TimeoutOptions): Middleware {
60
79
  timeoutMs,
61
80
  });
62
81
 
63
- return new dntShim.Response(
64
- JSON.stringify({
65
- error: message,
66
- timeoutMs,
67
- path: pathname,
68
- }),
69
- {
70
- status: HTTP_GATEWAY_TIMEOUT,
71
- headers: { "Content-Type": "application/json" },
72
- },
73
- );
82
+ return timeoutResponse(pathname, timeoutMs, message);
74
83
  } finally {
75
84
  if (timeoutId) clearTimeout(timeoutId);
76
85
  }
@@ -12,10 +12,11 @@ import { getReactImportMap } from "../../transforms/esm/package-registry.js";
12
12
  function getVeryfrontSsrImportMap(): Record<string, string> {
13
13
  const base = "/_vf_modules/_veryfront";
14
14
  const ssr = "?ssr=true";
15
+ const coreReact = `${base}/react/runtime/core.js${ssr}`;
15
16
 
16
- const head = `${base}/react/components/Head.js${ssr}`;
17
- const router = `${base}/react/router/index.js${ssr}`;
18
- const context = `${base}/react/context/index.js${ssr}`;
17
+ const head = coreReact;
18
+ const router = coreReact;
19
+ const context = coreReact;
19
20
  const fonts = `${base}/react/fonts/index.js${ssr}`;
20
21
 
21
22
  const markdown = `${base}/markdown/index.js${ssr}`;
@@ -1,11 +1,4 @@
1
- /**************************************************
2
- * OAuth Callback Handler
3
- *
4
- * Reusable handler for OAuth callback routes.
5
- **************************************************/
6
1
  import * as dntShim from "../../../_dnt.shims.js";
7
-
8
-
9
2
  import { logger as baseLogger } from "../../utils/index.js";
10
3
  import { getEnv } from "../../platform/compat/process.js";
11
4
  import {
@@ -93,24 +86,24 @@ export function createOAuthCallbackHandler(
93
86
  const url = new URL(request.url);
94
87
  const code = url.searchParams.get("code");
95
88
  const state = url.searchParams.get("state");
96
- const oauthError = url.searchParams.get("error");
89
+ const providerError = url.searchParams.get("error");
97
90
  const errorDescription = url.searchParams.get("error_description");
98
91
 
99
92
  const appUrl = getAppUrl();
100
93
 
101
- if (oauthError) {
94
+ if (providerError) {
102
95
  logger.error("Callback error", {
103
96
  serviceId: config.serviceId,
104
- error: oauthError,
97
+ error: providerError,
105
98
  description: errorDescription,
106
99
  });
107
- await onError?.(config.serviceId, oauthError);
108
- return redirectWithError(appUrl, oauthError, errorDescription);
100
+ await onError?.(config.serviceId, providerError);
101
+ return redirectWithError(appUrl, providerError, errorDescription);
109
102
  }
110
103
 
111
104
  if (!code) return handleError(appUrl, "no_code");
112
105
 
113
- let oauthState: OAuthState | null = null;
106
+ let storedState: OAuthState | null = null;
114
107
 
115
108
  if (!skipStateValidation && !state) {
116
109
  return handleError(appUrl, "invalid_state", "Missing state parameter", {
@@ -119,8 +112,8 @@ export function createOAuthCallbackHandler(
119
112
  }
120
113
 
121
114
  if (state) {
122
- oauthState = await tokenStore.getState(state);
123
- if (!skipStateValidation && !oauthState) {
115
+ storedState = await tokenStore.getState(state);
116
+ if (!skipStateValidation && !storedState) {
124
117
  return handleError(appUrl, "invalid_state", "Invalid or expired state", {
125
118
  serviceId: config.serviceId,
126
119
  });
@@ -134,7 +127,7 @@ export function createOAuthCallbackHandler(
134
127
  const result = await service.exchangeCode({
135
128
  code,
136
129
  redirectUri,
137
- codeVerifier: oauthState?.codeVerifier,
130
+ codeVerifier: storedState?.codeVerifier,
138
131
  });
139
132
 
140
133
  if (!result.success || !result.tokens) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Oauth Handlers
2
+ * OAuth Handlers
3
3
  *
4
4
  * @module oauth/handlers
5
5
  */
@@ -10,6 +10,42 @@ import type { AuthorizationUrlOptions, OAuthServiceConfig, TokenStore } from "..
10
10
  import { memoryTokenStore } from "../token-store/memory.js";
11
11
 
12
12
  const logger = baseLogger.component("o-auth");
13
+ const DEFAULT_APP_URL = "http://localhost:3000";
14
+
15
+ function createUnauthorizedResponse(): dntShim.Response {
16
+ return dntShim.Response.json({ error: "Unauthorized" }, { status: 401 });
17
+ }
18
+
19
+ async function isRequestUnauthorized(
20
+ req: dntShim.Request,
21
+ isAuthenticated?: (req: dntShim.Request) => boolean | Promise<boolean>,
22
+ ): Promise<boolean> {
23
+ return isAuthenticated ? !(await isAuthenticated(req)) : false;
24
+ }
25
+
26
+ function resolveAppUrl(baseUrl: string | undefined, env: EnvironmentConfig): string {
27
+ return baseUrl ?? env.appUrl ?? DEFAULT_APP_URL;
28
+ }
29
+
30
+ function createNotConfiguredResponse(config: OAuthServiceConfig): dntShim.Response {
31
+ return dntShim.Response.json(
32
+ {
33
+ error: `${config.displayName} OAuth not configured`,
34
+ details: `Missing ${config.clientIdEnvVar} or ${config.clientSecretEnvVar}`,
35
+ },
36
+ { status: 500 },
37
+ );
38
+ }
39
+
40
+ function createInitErrorResponse(error: unknown): dntShim.Response {
41
+ return dntShim.Response.json(
42
+ {
43
+ error: "Failed to initiate OAuth flow",
44
+ details: error instanceof Error ? error.message : "Unknown error",
45
+ },
46
+ { status: 500 },
47
+ );
48
+ }
13
49
 
14
50
  export interface OAuthInitHandlerOptions {
15
51
  /** Token store to use (defaults to memory store) */
@@ -32,25 +68,22 @@ export function createOAuthInitHandler(
32
68
  config: OAuthServiceConfig,
33
69
  options: OAuthInitHandlerOptions = {},
34
70
  ): () => Promise<dntShim.Response> {
35
- const tokenStore = options.tokenStore ?? memoryTokenStore;
36
- const authOptions = options.authOptions ?? {};
37
- const env = options.env ?? getEnvironmentConfig();
38
- const envReader = options.envReader ?? getEnv;
71
+ const {
72
+ tokenStore = memoryTokenStore,
73
+ baseUrl,
74
+ authOptions = {},
75
+ env = getEnvironmentConfig(),
76
+ envReader = getEnv,
77
+ } = options;
39
78
 
40
79
  return async function handler(): Promise<dntShim.Response> {
41
80
  const service = new OAuthService(config, tokenStore, envReader);
42
81
 
43
82
  if (!service.isConfigured()) {
44
- return dntShim.Response.json(
45
- {
46
- error: `${config.displayName} OAuth not configured`,
47
- details: `Missing ${config.clientIdEnvVar} or ${config.clientSecretEnvVar}`,
48
- },
49
- { status: 500 },
50
- );
83
+ return createNotConfiguredResponse(config);
51
84
  }
52
85
 
53
- const appUrl = options.baseUrl ?? env.appUrl ?? "http://localhost:3000";
86
+ const appUrl = resolveAppUrl(baseUrl, env);
54
87
  const redirectUri = `${appUrl}/api/auth/${config.serviceId}/callback`;
55
88
 
56
89
  try {
@@ -59,14 +92,7 @@ export function createOAuthInitHandler(
59
92
  return dntShim.Response.redirect(url);
60
93
  } catch (error) {
61
94
  logger.error("Init error", { serviceId: config.serviceId }, error);
62
-
63
- return dntShim.Response.json(
64
- {
65
- error: "Failed to initiate OAuth flow",
66
- details: error instanceof Error ? error.message : "Unknown error",
67
- },
68
- { status: 500 },
69
- );
95
+ return createInitErrorResponse(error);
70
96
  }
71
97
  };
72
98
  }
@@ -86,12 +112,15 @@ export function createOAuthStatusHandler(
86
112
  config: OAuthServiceConfig,
87
113
  options: OAuthStatusHandlerOptions = {},
88
114
  ): (req: dntShim.Request) => Promise<dntShim.Response> {
89
- const tokenStore = options.tokenStore ?? memoryTokenStore;
90
- const envReader = options.envReader ?? getEnv;
115
+ const {
116
+ tokenStore = memoryTokenStore,
117
+ envReader = getEnv,
118
+ isAuthenticated,
119
+ } = options;
91
120
 
92
121
  return async function handler(req: dntShim.Request): Promise<dntShim.Response> {
93
- if (options.isAuthenticated && !(await options.isAuthenticated(req))) {
94
- return dntShim.Response.json({ error: "Unauthorized" }, { status: 401 });
122
+ if (await isRequestUnauthorized(req, isAuthenticated)) {
123
+ return createUnauthorizedResponse();
95
124
  }
96
125
 
97
126
  const tokens = await tokenStore.getTokens(config.serviceId);
@@ -119,11 +148,11 @@ export function createOAuthDisconnectHandler(
119
148
  isAuthenticated?: (req: dntShim.Request) => boolean | Promise<boolean>;
120
149
  } = {},
121
150
  ): (req: dntShim.Request) => Promise<dntShim.Response> {
122
- const tokenStore = options.tokenStore ?? memoryTokenStore;
151
+ const { tokenStore = memoryTokenStore, isAuthenticated } = options;
123
152
 
124
153
  return async function handler(req: dntShim.Request): Promise<dntShim.Response> {
125
- if (options.isAuthenticated && !(await options.isAuthenticated(req))) {
126
- return dntShim.Response.json({ error: "Unauthorized" }, { status: 401 });
154
+ if (await isRequestUnauthorized(req, isAuthenticated)) {
155
+ return createUnauthorizedResponse();
127
156
  }
128
157
 
129
158
  await tokenStore.clearTokens(config.serviceId);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Oauth Providers
2
+ * OAuth Providers
3
3
  *
4
4
  * @module oauth/providers
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Oauth Schemas
2
+ * OAuth Schemas
3
3
  *
4
4
  * @module oauth/schemas
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Oauth Token Store
2
+ * OAuth Token Store
3
3
  *
4
4
  * @module oauth/token-store
5
5
  */
@@ -29,19 +29,19 @@ export class MemoryTokenStore implements TokenStore {
29
29
  }
30
30
 
31
31
  async getState(state: string): Promise<OAuthState | null> {
32
- const oauthState = this.states.get(state);
33
- if (!oauthState) return null;
32
+ const storedState = this.states.get(state);
33
+ if (!storedState) return null;
34
34
 
35
- if (Date.now() - oauthState.createdAt > STATE_EXPIRATION_MS) {
35
+ if (Date.now() - storedState.createdAt > STATE_EXPIRATION_MS) {
36
36
  this.states.delete(state);
37
37
  return null;
38
38
  }
39
39
 
40
- return oauthState;
40
+ return storedState;
41
41
  }
42
42
 
43
- async setState(oauthState: OAuthState): Promise<void> {
44
- this.states.set(oauthState.state, oauthState);
43
+ async setState(storedState: OAuthState): Promise<void> {
44
+ this.states.set(storedState.state, storedState);
45
45
  this.cleanupExpiredStates();
46
46
  }
47
47
 
@@ -51,8 +51,8 @@ export class MemoryTokenStore implements TokenStore {
51
51
 
52
52
  private cleanupExpiredStates(): void {
53
53
  const now = Date.now();
54
- for (const [state, oauthState] of this.states) {
55
- if (now - oauthState.createdAt > STATE_EXPIRATION_MS) {
54
+ for (const [state, storedState] of this.states) {
55
+ if (now - storedState.createdAt > STATE_EXPIRATION_MS) {
56
56
  this.states.delete(state);
57
57
  }
58
58
  }
@@ -0,0 +1,140 @@
1
+ import * as dntShim from "../../_dnt.shims.js";
2
+ import { AsyncLocalStorage } from "node:async_hooks";
3
+
4
+ export interface RequestProfileRecord {
5
+ sequence: number;
6
+ category: string;
7
+ method: string;
8
+ pathname: string;
9
+ projectSlug?: string;
10
+ requestMode?: string;
11
+ status?: number;
12
+ startedAt: string;
13
+ completedAt: string;
14
+ totalMs: number;
15
+ phases: Record<string, number>;
16
+ }
17
+
18
+ interface RequestProfileSession {
19
+ category: string;
20
+ method: string;
21
+ pathname: string;
22
+ projectSlug?: string;
23
+ requestMode?: string;
24
+ startedAt: number;
25
+ phases: Map<string, number>;
26
+ }
27
+
28
+ const storage = new AsyncLocalStorage<RequestProfileSession>();
29
+ const records: RequestProfileRecord[] = [];
30
+ const MAX_RECORDS = 200;
31
+ let sequence = 0;
32
+
33
+ function roundMs(value: number): number {
34
+ return Math.round(value * 100) / 100;
35
+ }
36
+
37
+ function shouldEnableProfiling(): boolean {
38
+ return dntShim.Deno.env.get("VERYFRONT_ENABLE_PERF_PROFILING") === "1";
39
+ }
40
+
41
+ function shouldProfilePath(pathname: string): boolean {
42
+ return pathname.startsWith("/bench/") ||
43
+ pathname.startsWith("/api/bench/") ||
44
+ pathname.startsWith("/_vf_styles/") ||
45
+ pathname.startsWith("/_vf_modules/");
46
+ }
47
+
48
+ export function isRequestProfilingEnabled(pathname?: string): boolean {
49
+ if (!shouldEnableProfiling()) return false;
50
+ if (!pathname) return true;
51
+ return shouldProfilePath(pathname);
52
+ }
53
+
54
+ export async function runWithRequestProfiling<T>(
55
+ options: {
56
+ category: string;
57
+ method: string;
58
+ pathname: string;
59
+ projectSlug?: string;
60
+ requestMode?: string;
61
+ },
62
+ fn: () => Promise<T>,
63
+ ): Promise<T> {
64
+ if (!isRequestProfilingEnabled(options.pathname)) {
65
+ return await fn();
66
+ }
67
+
68
+ const session: RequestProfileSession = {
69
+ ...options,
70
+ startedAt: performance.now(),
71
+ phases: new Map(),
72
+ };
73
+
74
+ return await storage.run(session, fn);
75
+ }
76
+
77
+ export async function profilePhase<T>(name: string, fn: () => Promise<T>): Promise<T> {
78
+ const session = storage.getStore();
79
+ if (!session) return await fn();
80
+
81
+ const startedAt = performance.now();
82
+ try {
83
+ return await fn();
84
+ } finally {
85
+ const duration = performance.now() - startedAt;
86
+ session.phases.set(name, roundMs((session.phases.get(name) ?? 0) + duration));
87
+ }
88
+ }
89
+
90
+ export function profileSyncPhase<T>(name: string, fn: () => T): T {
91
+ const session = storage.getStore();
92
+ if (!session) return fn();
93
+
94
+ const startedAt = performance.now();
95
+ try {
96
+ return fn();
97
+ } finally {
98
+ const duration = performance.now() - startedAt;
99
+ session.phases.set(name, roundMs((session.phases.get(name) ?? 0) + duration));
100
+ }
101
+ }
102
+
103
+ export function finalizeRequestProfiling(status?: number): void {
104
+ const session = storage.getStore();
105
+ if (!session) return;
106
+
107
+ const record: RequestProfileRecord = {
108
+ sequence: ++sequence,
109
+ category: session.category,
110
+ method: session.method,
111
+ pathname: session.pathname,
112
+ projectSlug: session.projectSlug,
113
+ requestMode: session.requestMode,
114
+ status,
115
+ startedAt: new Date(Date.now() - (performance.now() - session.startedAt)).toISOString(),
116
+ completedAt: new Date().toISOString(),
117
+ totalMs: roundMs(performance.now() - session.startedAt),
118
+ phases: Object.fromEntries(session.phases.entries()),
119
+ };
120
+
121
+ records.push(record);
122
+ while (records.length > MAX_RECORDS) records.shift();
123
+ }
124
+
125
+ export function snapshotRequestProfiles(): {
126
+ enabled: boolean;
127
+ last_sequence: number;
128
+ records: RequestProfileRecord[];
129
+ } {
130
+ return {
131
+ enabled: shouldEnableProfiling(),
132
+ last_sequence: sequence,
133
+ records: [...records],
134
+ };
135
+ }
136
+
137
+ export function resetRequestProfiles(): void {
138
+ records.length = 0;
139
+ sequence = 0;
140
+ }
@@ -69,11 +69,6 @@ async function ensureApis(): Promise<void> {
69
69
  propagationApi = await import("@opentelemetry/core");
70
70
  }
71
71
 
72
- function getServiceName(): string {
73
- const tracingConfig = getOtelTracingConfig();
74
- return tracingConfig.serviceName || "veryfront";
75
- }
76
-
77
72
  function setSpanErrorStatus(span: import("@opentelemetry/api").Span, error: unknown): void {
78
73
  if (!traceApi) return;
79
74
 
@@ -183,9 +178,9 @@ export async function withSpan<T>(
183
178
  fn: () => Promise<T>,
184
179
  attributes?: Record<string, string | number | boolean>,
185
180
  ): Promise<T> {
186
- if (!traceApi || !isOTLPEnabled()) return await fn();
181
+ if (!traceApi || !isOTLPEnabled()) return fn();
187
182
 
188
- const tracer = traceApi.trace.getTracer(getServiceName());
183
+ const tracer = traceApi.trace.getTracer(getConfig().serviceName);
189
184
  const parentContext = traceApi.context.active();
190
185
 
191
186
  const span = tracer.startSpan(
@@ -215,7 +210,7 @@ export function withSpanSync<T>(
215
210
  ): T {
216
211
  if (!traceApi || !isOTLPEnabled()) return fn();
217
212
 
218
- const tracer = traceApi.trace.getTracer(getServiceName());
213
+ const tracer = traceApi.trace.getTracer(getConfig().serviceName);
219
214
  const parentContext = traceApi.context.active();
220
215
 
221
216
  const span = tracer.startSpan(
@@ -271,7 +266,7 @@ export function startServerSpan(
271
266
  ): { span: unknown; context: unknown } | null {
272
267
  if (!traceApi || !isOTLPEnabled()) return null;
273
268
 
274
- const tracer = traceApi.trace.getTracer(getServiceName());
269
+ const tracer = traceApi.trace.getTracer(getConfig().serviceName);
275
270
  const ctx = (parentContext || traceApi.context.active()) as import("@opentelemetry/api").Context;
276
271
 
277
272
  const span = tracer.startSpan(`${method} ${path}`, { kind: traceApi.SpanKind.SERVER }, ctx);
@@ -284,24 +279,23 @@ export function startServerSpan(
284
279
  export function endServerSpan(span: unknown, statusCode: number, error?: Error): void {
285
280
  if (!span || !traceApi) return;
286
281
 
287
- const s = span as import("@opentelemetry/api").Span;
288
- s.setAttribute("http.status_code", statusCode);
282
+ const otelSpan = span as import("@opentelemetry/api").Span;
283
+ otelSpan.setAttribute("http.status_code", statusCode);
289
284
 
290
285
  if (error) {
291
- s.setStatus({ code: traceApi.SpanStatusCode.ERROR, message: error.message });
292
- s.recordException(error);
293
- s.end();
286
+ setSpanErrorStatus(otelSpan, error);
287
+ otelSpan.end();
294
288
  return;
295
289
  }
296
290
 
297
291
  if (statusCode >= 400) {
298
- s.setStatus({ code: traceApi.SpanStatusCode.ERROR });
299
- s.end();
292
+ otelSpan.setStatus({ code: traceApi.SpanStatusCode.ERROR });
293
+ otelSpan.end();
300
294
  return;
301
295
  }
302
296
 
303
- s.setStatus({ code: traceApi.SpanStatusCode.OK });
304
- s.end();
297
+ otelSpan.setStatus({ code: traceApi.SpanStatusCode.OK });
298
+ otelSpan.end();
305
299
  }
306
300
 
307
301
  export function setSpanAttributes(
@@ -310,8 +304,8 @@ export function setSpanAttributes(
310
304
  ): void {
311
305
  if (!span || !traceApi) return;
312
306
 
313
- const s = span as import("@opentelemetry/api").Span;
314
- for (const [key, value] of Object.entries(attributes)) s.setAttribute(key, value);
307
+ const otelSpan = span as import("@opentelemetry/api").Span;
308
+ for (const [key, value] of Object.entries(attributes)) otelSpan.setAttribute(key, value);
315
309
  }
316
310
 
317
311
  export function setActiveSpanAttributes(
@@ -326,8 +320,8 @@ export function setActiveSpanAttributes(
326
320
  }
327
321
 
328
322
  export async function withContext<T>(spanContext: unknown, fn: () => Promise<T>): Promise<T> {
329
- if (!traceApi) return await fn();
330
- return await traceApi.context.with(spanContext as import("@opentelemetry/api").Context, fn);
323
+ if (!traceApi) return fn();
324
+ return traceApi.context.with(spanContext as import("@opentelemetry/api").Context, fn);
331
325
  }
332
326
 
333
327
  export function getTraceContext(): { traceId?: string; spanId?: string } {
@@ -2,24 +2,27 @@ import type { Prompt, PromptConfig } from "./types.js";
2
2
  import { createError, toError } from "../errors/veryfront-error.js";
3
3
  import { COMMON_BLOCKED_PATTERNS } from "../agent/middleware/security/validator.js";
4
4
 
5
+ type PromptGenerateFn = (variables: Record<string, unknown>) => string | Promise<string>;
6
+
7
+ const BLOCKED_PROMPT_PATTERNS = COMMON_BLOCKED_PATTERNS.promptInjection;
8
+
5
9
  export function prompt(config: PromptConfig): Prompt {
10
+ const { content, description, generate, suggestion } = config;
6
11
  const id = config.id ?? generatePromptId();
7
12
 
8
13
  return {
9
14
  id,
10
- description: config.description,
11
- suggestion: config.suggestion,
15
+ description,
16
+ suggestion,
12
17
  async getContent(variables?: Record<string, unknown>): Promise<string> {
13
- const vars = variables ?? {};
18
+ const resolvedVariables = variables ?? {};
14
19
 
15
- if (config.content) {
16
- return interpolateVariables(config.content, vars);
20
+ if (content) {
21
+ return interpolateVariables(content, resolvedVariables);
17
22
  }
18
23
 
19
- if (config.generate) {
20
- // z.function() in v4 doesn't carry arg/return types — cast to expected signature
21
- type GenerateFn = (vars: Record<string, unknown>) => string | Promise<string>;
22
- return (config.generate as GenerateFn)(vars);
24
+ if (generate) {
25
+ return (generate as PromptGenerateFn)(resolvedVariables);
23
26
  }
24
27
 
25
28
  throw toError(
@@ -39,11 +42,10 @@ function generatePromptId(): string {
39
42
  }
40
43
 
41
44
  function sanitizeVariableValue(value: string): string {
42
- let sanitized = value;
43
- for (const pattern of COMMON_BLOCKED_PATTERNS.promptInjection) {
44
- sanitized = sanitized.replace(pattern, "");
45
- }
46
- return sanitized;
45
+ return BLOCKED_PROMPT_PATTERNS.reduce(
46
+ (sanitizedValue, pattern) => sanitizedValue.replace(pattern, ""),
47
+ value,
48
+ );
47
49
  }
48
50
 
49
51
  function interpolateVariables(
@@ -3,21 +3,22 @@ import { createError, toError } from "../errors/veryfront-error.js";
3
3
  import { ProjectScopedRegistryManager } from "../ai/registry-manager.js";
4
4
  import { ScopedRegistryFacade } from "../ai/registry-facade.js";
5
5
 
6
- const promptManager = new ProjectScopedRegistryManager<Prompt>("prompt");
6
+ const promptRegistryManager = new ProjectScopedRegistryManager<Prompt>("prompt");
7
+
8
+ function createMissingPromptError(id: string): Error {
9
+ return toError(
10
+ createError({
11
+ type: "agent",
12
+ message: `Prompt "${id}" not found`,
13
+ }),
14
+ );
15
+ }
7
16
 
8
17
  class PromptRegistryClass extends ScopedRegistryFacade<Prompt> {
9
18
  getContent(id: string, variables?: Record<string, unknown>): Promise<string> {
10
- const promptInstance = this.get(id);
11
- if (!promptInstance) {
12
- throw toError(
13
- createError({
14
- type: "agent",
15
- message: `Prompt "${id}" not found`,
16
- }),
17
- );
18
- }
19
-
20
- return promptInstance.getContent(variables);
19
+ const registeredPrompt = this.get(id);
20
+ if (registeredPrompt) return registeredPrompt.getContent(variables);
21
+ throw createMissingPromptError(id);
21
22
  }
22
23
 
23
24
  list(): string[] {
@@ -25,4 +26,4 @@ class PromptRegistryClass extends ScopedRegistryFacade<Prompt> {
25
26
  }
26
27
  }
27
28
 
28
- export const promptRegistry = new PromptRegistryClass(promptManager);
29
+ export const promptRegistry = new PromptRegistryClass(promptRegistryManager);
@@ -9,8 +9,4 @@ export const PromptConfigSchema = z.object({
9
9
  suggestion: z.string().optional(),
10
10
  });
11
11
 
12
- // Inferred type
13
12
  export type PromptConfig = z.infer<typeof PromptConfigSchema>;
14
-
15
- // Note: Prompt interface with getContent method stays as TypeScript interface
16
- // since it includes a method that returns a Promise