@kayjs/kay 1.104.3 → 1.105.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1090) hide show
  1. package/dist/eslint.js +5231 -2529
  2. package/editors/vscode/syntaxes/kay.tmLanguage.json +1 -1
  3. package/editors/zed/extension.toml +2 -2
  4. package/llms/action-protection.md +10 -10
  5. package/llms/actions-from-islands.md +26 -29
  6. package/llms/actions-refused-fields.md +18 -4
  7. package/llms/actions.md +36 -27
  8. package/llms/analytics.md +1 -1
  9. package/llms/api-from-islands.md +14 -15
  10. package/llms/api-routes.md +10 -8
  11. package/llms/browser-only.md +12 -10
  12. package/llms/cdn-caching.md +7 -6
  13. package/llms/check-and-tools.md +6 -6
  14. package/llms/checks.md +1 -1
  15. package/llms/code-lints.md +6 -6
  16. package/llms/commands.md +42 -0
  17. package/llms/component-libraries.md +1 -1
  18. package/llms/component-library-conventions.md +11 -5
  19. package/llms/components.md +14 -14
  20. package/llms/content-markdown-to-caching.md +2 -2
  21. package/llms/deprecated-lints-1-105-libraries.md +30 -0
  22. package/llms/deprecated-lints-1-105.md +58 -0
  23. package/llms/deprecated-lints.md +7 -5
  24. package/llms/dev-tool.md +1 -1
  25. package/llms/eco-design.md +3 -3
  26. package/llms/editor-and-agent-commands.md +1 -1
  27. package/llms/effects.md +7 -7
  28. package/llms/environment.md +6 -5
  29. package/llms/errors-runtime.md +4 -4
  30. package/llms/errors.md +12 -8
  31. package/llms/events.md +15 -12
  32. package/llms/files.md +6 -4
  33. package/llms/guards.md +18 -15
  34. package/llms/head.md +38 -6
  35. package/llms/hooks.md +27 -25
  36. package/llms/images-runtime-and-remote.md +12 -12
  37. package/llms/images.md +29 -29
  38. package/llms/island-and-form-lints.md +8 -8
  39. package/llms/island-sources.md +31 -24
  40. package/llms/islands-state-to-ids.md +8 -10
  41. package/llms/islands.md +16 -14
  42. package/llms/lints.md +1 -1
  43. package/llms/live-values.md +12 -9
  44. package/llms/local-collections.md +11 -11
  45. package/llms/locales-texts.md +1 -1
  46. package/llms/locales.md +12 -11
  47. package/llms/mcp.md +8 -8
  48. package/llms/metrics.md +24 -0
  49. package/llms/navigation-from-code.md +16 -15
  50. package/llms/navigation.md +5 -3
  51. package/llms/prerendering.md +4 -4
  52. package/llms/privacy.md +4 -4
  53. package/llms/production.md +28 -38
  54. package/llms/project-new-and-add.md +2 -2
  55. package/llms/project.md +17 -40
  56. package/llms/proxy-and-security.md +5 -5
  57. package/llms/queues.md +19 -24
  58. package/llms/rate-limits.md +21 -10
  59. package/llms/recipes.md +7 -6
  60. package/llms/rendering.md +8 -7
  61. package/llms/request-values.md +2 -2
  62. package/llms/rooms.md +9 -9
  63. package/llms/routing-endpoints-and-base.md +3 -3
  64. package/llms/routing-special-pages.md +4 -4
  65. package/llms/routing.md +16 -18
  66. package/llms/security-and-i18n-lints.md +1 -1
  67. package/llms/seo-lints.md +1 -1
  68. package/llms/server-islands.md +12 -7
  69. package/llms/server.md +33 -18
  70. package/llms/site.md +12 -10
  71. package/llms/sitemap-search-fonts.md +50 -44
  72. package/llms/stores.md +7 -5
  73. package/llms/styles-and-assets.md +8 -8
  74. package/llms/templates-elements-slots-snippets.md +5 -9
  75. package/llms/templates.md +4 -4
  76. package/llms/testing-browser.md +1 -0
  77. package/llms/testing-requests-jobs-sockets.md +27 -4
  78. package/llms/testing.md +7 -7
  79. package/llms/tracing.md +9 -7
  80. package/llms/upgrading-1-105-config.md +71 -0
  81. package/llms/upgrading-archive.md +74 -114
  82. package/llms/upgrading.md +41 -131
  83. package/llms/whats-new-archive.md +59 -57
  84. package/llms/whats-new.md +32 -54
  85. package/llms/workers.md +2 -2
  86. package/llms.txt +18 -13
  87. package/package.json +9 -9
  88. package/src/add.ts +1 -1
  89. package/src/build/await-alert.ts +34 -0
  90. package/src/build/client.ts +15 -13
  91. package/src/build/compile.ts +9 -6
  92. package/src/build/pipeline.ts +19 -16
  93. package/src/build/server-record.ts +2 -1
  94. package/src/build/sourcemap.ts +1 -1
  95. package/src/build/static.ts +10 -8
  96. package/src/build/styles.ts +7 -1
  97. package/src/build/transform.ts +3 -2
  98. package/src/build/verify.ts +8 -5
  99. package/src/check/action-readers.ts +115 -0
  100. package/src/check/action-type.ts +44 -0
  101. package/src/check/ai-language.ts +56 -0
  102. package/src/check/app-hooks.ts +90 -0
  103. package/src/check/auth-methods.ts +85 -0
  104. package/src/check/auth-rate-limits.ts +99 -0
  105. package/src/check/boot.ts +9 -8
  106. package/src/check/browser-global-reads.ts +4 -4
  107. package/src/check/client-keys.ts +10 -0
  108. package/src/check/cms-options.ts +81 -0
  109. package/src/check/config-groups.ts +22 -0
  110. package/src/check/config-objects.ts +83 -0
  111. package/src/check/config-switches.ts +38 -0
  112. package/src/check/context-import.ts +51 -0
  113. package/src/check/diagnose.ts +16 -6
  114. package/src/check/env-files.ts +31 -0
  115. package/src/check/env-types.ts +10 -8
  116. package/src/check/format-duration.ts +75 -0
  117. package/src/check/generated.ts +23 -4
  118. package/src/check/guard-options.ts +58 -0
  119. package/src/check/guards.ts +4 -4
  120. package/src/check/hook-context.ts +94 -0
  121. package/src/check/hook-names.ts +104 -0
  122. package/src/check/i18n-keys.ts +50 -0
  123. package/src/check/images-keys.ts +54 -0
  124. package/src/check/index.ts +38 -22
  125. package/src/check/job-shapes.ts +273 -0
  126. package/src/check/layout-facts.ts +1 -1
  127. package/src/check/live-api.ts +137 -0
  128. package/src/check/mail-api.ts +67 -0
  129. package/src/check/messages.ts +7 -7
  130. package/src/check/moved-keys.ts +49 -0
  131. package/src/check/one-state-api.ts +357 -0
  132. package/src/check/open-settings.ts +1 -1
  133. package/src/check/output-schema.ts +3 -1
  134. package/src/check/page-heads.ts +31 -5
  135. package/src/check/pages-options.ts +35 -0
  136. package/src/check/project.ts +5 -1
  137. package/src/check/rate-enforce.ts +53 -0
  138. package/src/check/refusal-calls.ts +185 -0
  139. package/src/check/regroup.ts +92 -0
  140. package/src/check/renamed-packages.ts +32 -0
  141. package/src/check/retired-lints.ts +49 -0
  142. package/src/check/route-keys.ts +166 -0
  143. package/src/check/route-shadow.ts +174 -0
  144. package/src/check/secret-keys.ts +70 -0
  145. package/src/check/seo.ts +3 -3
  146. package/src/check/shadow-types.ts +110 -4
  147. package/src/check/shadow.ts +4 -1
  148. package/src/check/socket-frames.ts +102 -0
  149. package/src/check/source-readers.ts +257 -0
  150. package/src/check/store-ms.ts +72 -0
  151. package/src/check/store-names.ts +88 -0
  152. package/src/check/template-hints.ts +70 -6
  153. package/src/check/test-helpers.ts +98 -0
  154. package/src/check/ttl-names.ts +142 -0
  155. package/src/check/unmounted-jobs.ts +2 -2
  156. package/src/commands/a11y.ts +1 -1
  157. package/src/commands/check.ts +4 -2
  158. package/src/commands/env-compare.ts +2 -2
  159. package/src/commands/env-declare.ts +1 -1
  160. package/src/commands/env.ts +19 -16
  161. package/src/commands/explain-island.ts +27 -1
  162. package/src/commands/i18n.ts +2 -2
  163. package/src/commands/routes.ts +23 -17
  164. package/src/compiler/a11y.ts +56 -41
  165. package/src/compiler/aria.ts +1 -1
  166. package/src/compiler/ast.ts +54 -136
  167. package/src/compiler/bound-props.ts +75 -0
  168. package/src/compiler/browser.ts +12 -11
  169. package/src/compiler/button-forms.ts +33 -0
  170. package/src/compiler/codegen.ts +51 -137
  171. package/src/compiler/deprecated-ai-labels.ts +97 -0
  172. package/src/compiler/deprecated-ai-links.ts +63 -0
  173. package/src/compiler/deprecated-allow.ts +50 -0
  174. package/src/compiler/deprecated-auth-lints.ts +14 -0
  175. package/src/compiler/deprecated-auth-signed.ts +29 -0
  176. package/src/compiler/deprecated-children.ts +66 -0
  177. package/src/compiler/deprecated-image.ts +116 -0
  178. package/src/compiler/deprecated-island.ts +155 -0
  179. package/src/compiler/deprecated-library.ts +20 -0
  180. package/src/compiler/deprecated-lints.ts +523 -22
  181. package/src/compiler/deprecated-page.ts +125 -0
  182. package/src/compiler/deprecated-parts.ts +22 -0
  183. package/src/compiler/deprecated-ui-callbacks.ts +66 -0
  184. package/src/compiler/deprecated-ui-input.ts +97 -0
  185. package/src/compiler/deprecated-ui-items.ts +47 -0
  186. package/src/compiler/deprecated-ui-props.ts +3 -3
  187. package/src/compiler/dom-fields.ts +67 -0
  188. package/src/compiler/dom.ts +29 -27
  189. package/src/compiler/errors.ts +37 -27
  190. package/src/compiler/event-modifiers.ts +2 -2
  191. package/src/compiler/fence-checks.ts +29 -69
  192. package/src/compiler/form-action.ts +18 -0
  193. package/src/compiler/form-info.ts +154 -0
  194. package/src/compiler/head-shorthand.ts +118 -0
  195. package/src/compiler/head-tags.ts +64 -0
  196. package/src/compiler/helper-imports.ts +33 -0
  197. package/src/compiler/html-initial.ts +68 -0
  198. package/src/compiler/html-parts.ts +40 -0
  199. package/src/compiler/html.ts +41 -91
  200. package/src/compiler/if-alias.ts +2 -47
  201. package/src/compiler/image-attributes.ts +69 -0
  202. package/src/compiler/index.ts +33 -9
  203. package/src/compiler/island-arguments.ts +38 -10
  204. package/src/compiler/island-cause.ts +5 -5
  205. package/src/compiler/island-declaration.ts +181 -0
  206. package/src/compiler/island-marker.ts +10 -15
  207. package/src/compiler/items.ts +5 -0
  208. package/src/compiler/jsx-class.ts +25 -1
  209. package/src/compiler/jsx-field.ts +58 -0
  210. package/src/compiler/jsx.ts +24 -29
  211. package/src/compiler/kay-exports.ts +2 -0
  212. package/src/compiler/link-flags.ts +106 -0
  213. package/src/compiler/lints.ts +27 -60
  214. package/src/compiler/live-reads.ts +160 -0
  215. package/src/compiler/loop-lints.ts +6 -5
  216. package/src/compiler/markup-fields.ts +34 -0
  217. package/src/compiler/markup.ts +75 -77
  218. package/src/compiler/module-signals.ts +1 -1
  219. package/src/compiler/names.ts +7 -1
  220. package/src/compiler/nesting.ts +7 -0
  221. package/src/compiler/old-parts.ts +84 -0
  222. package/src/compiler/page-settings.ts +2 -0
  223. package/src/compiler/parser.ts +7 -8
  224. package/src/compiler/plan.ts +13 -1
  225. package/src/compiler/rewrite-reads.ts +29 -0
  226. package/src/compiler/rewrite-types.ts +2 -0
  227. package/src/compiler/rewrite.ts +35 -33
  228. package/src/compiler/route-lints.ts +4 -2
  229. package/src/compiler/script-props.ts +34 -5
  230. package/src/compiler/script-server.ts +26 -3
  231. package/src/compiler/script-shared.ts +7 -0
  232. package/src/compiler/script.ts +7 -0
  233. package/src/compiler/server-imports.ts +52 -0
  234. package/src/compiler/slot-types.ts +46 -0
  235. package/src/compiler/style-arguments.ts +20 -0
  236. package/src/compiler/template-walk.ts +72 -0
  237. package/src/compiler/type-parameters.ts +45 -0
  238. package/src/compiler/validate-fields.ts +68 -0
  239. package/src/compiler/validate.ts +51 -45
  240. package/src/config-extensions.ts +53 -6
  241. package/src/config-loader.ts +31 -16
  242. package/src/config-resolve.ts +194 -0
  243. package/src/config-shape.ts +81 -38
  244. package/src/config-switch.ts +14 -0
  245. package/src/config.ts +287 -102
  246. package/src/content/problems.ts +1 -1
  247. package/src/generate-resource.ts +5 -4
  248. package/src/generate.ts +2 -2
  249. package/src/lsp/code-actions.ts +1 -1
  250. package/src/lsp/completions.ts +2 -2
  251. package/src/lsp/diagnostics.ts +4 -2
  252. package/src/lsp/document-links.ts +1 -1
  253. package/src/lsp/navigation.ts +1 -1
  254. package/src/lsp/route-documents.ts +21 -0
  255. package/src/lsp/server.ts +60 -8
  256. package/src/lsp/template-completion.ts +4 -4
  257. package/src/lsp/ui-completion.ts +1 -1
  258. package/src/migrate/astro.ts +1 -1
  259. package/src/migrate/project.ts +1 -1
  260. package/src/project.ts +20 -11
  261. package/src/runtime/action-call.ts +179 -41
  262. package/src/runtime/action-encode.ts +2 -1
  263. package/src/runtime/action-error.ts +2 -1
  264. package/src/runtime/action-form.ts +159 -17
  265. package/src/runtime/action-navigate.ts +19 -0
  266. package/src/runtime/action-owner.ts +2 -0
  267. package/src/runtime/action-post.ts +22 -4
  268. package/src/runtime/action-protection.ts +4 -3
  269. package/src/runtime/action-shared.ts +86 -28
  270. package/src/runtime/action-stream.ts +43 -9
  271. package/src/runtime/action.ts +8 -7
  272. package/src/runtime/api-error-class.ts +1 -1
  273. package/src/runtime/api-url.ts +5 -4
  274. package/src/runtime/await-failed.ts +9 -0
  275. package/src/runtime/await.server.ts +14 -4
  276. package/src/runtime/await.ts +3 -3
  277. package/src/runtime/button-form.ts +5 -0
  278. package/src/runtime/cache-hooks.ts +54 -0
  279. package/src/runtime/cache-live-id.ts +3 -0
  280. package/src/runtime/cache.ts +12 -36
  281. package/src/runtime/call-result.ts +86 -21
  282. package/src/runtime/checks.ts +27 -17
  283. package/src/runtime/consent.ts +3 -2
  284. package/src/runtime/core.ts +99 -27
  285. package/src/runtime/dispatch.ts +11 -0
  286. package/src/runtime/dom-await.ts +39 -9
  287. package/src/runtime/dom-image.ts +2 -2
  288. package/src/runtime/duration-words.ts +2 -1
  289. package/src/runtime/duration.ts +5 -3
  290. package/src/runtime/edit.ts +3 -2
  291. package/src/runtime/env.ts +2 -1
  292. package/src/runtime/forms.ts +15 -5
  293. package/src/runtime/head.ts +3 -1
  294. package/src/runtime/html.ts +10 -6
  295. package/src/runtime/i18n.client.ts +12 -6
  296. package/src/runtime/i18n.server.ts +12 -6
  297. package/src/runtime/i18n.ts +28 -8
  298. package/src/runtime/image.ts +16 -18
  299. package/src/runtime/index.ts +9 -8
  300. package/src/runtime/internal.ts +2 -1
  301. package/src/runtime/invalidated-keys.ts +11 -0
  302. package/src/runtime/island.server.ts +18 -10
  303. package/src/runtime/jsx.ts +6 -1
  304. package/src/runtime/kay-error.ts +29 -0
  305. package/src/runtime/leave.ts +1 -0
  306. package/src/runtime/live-cache.ts +8 -1
  307. package/src/runtime/live-resource.server.ts +1 -0
  308. package/src/runtime/live-revalidate.ts +53 -0
  309. package/src/runtime/live-value.client.ts +36 -3
  310. package/src/runtime/live-value.server.ts +10 -6
  311. package/src/runtime/live-value.shared.ts +50 -10
  312. package/src/runtime/live-value.ts +16 -4
  313. package/src/runtime/live.ts +92 -137
  314. package/src/runtime/local-types.ts +106 -0
  315. package/src/runtime/local.ts +31 -109
  316. package/src/runtime/log.ts +3 -1
  317. package/src/runtime/mount.compat.ts +8 -0
  318. package/src/runtime/navigate-api.ts +17 -8
  319. package/src/runtime/navigation-state.ts +50 -13
  320. package/src/runtime/navigation.ts +3 -3
  321. package/src/runtime/optimistic.ts +1 -1
  322. package/src/runtime/page-swap.ts +11 -6
  323. package/src/runtime/persist.ts +2 -1
  324. package/src/runtime/persisted.ts +43 -38
  325. package/src/runtime/presence.ts +15 -9
  326. package/src/runtime/queue-jobs.ts +2 -1
  327. package/src/runtime/reactive.ts +4 -5
  328. package/src/runtime/refuse.ts +23 -6
  329. package/src/runtime/resource-tags.ts +35 -0
  330. package/src/runtime/route.ts +3 -2
  331. package/src/runtime/sanitize.ts +4 -3
  332. package/src/runtime/schema.client.ts +2 -1
  333. package/src/runtime/schema.ts +2 -1
  334. package/src/runtime/send.ts +2 -1
  335. package/src/runtime/shortcut.ts +10 -3
  336. package/src/runtime/socket-message.ts +26 -0
  337. package/src/runtime/store-base.ts +22 -0
  338. package/src/runtime/swap-fetch.ts +2 -1
  339. package/src/runtime/swap.ts +4 -0
  340. package/src/runtime/template-context.ts +4 -2
  341. package/src/runtime/values.ts +28 -10
  342. package/src/runtime/wire.ts +13 -3
  343. package/src/runtime/with-query.ts +3 -2
  344. package/src/runtime/work.ts +4 -2
  345. package/src/server/action-hooks.ts +15 -8
  346. package/src/server/action-iterable.ts +18 -3
  347. package/src/server/actions.ts +31 -18
  348. package/src/server/address.ts +1 -1
  349. package/src/server/analytics-server.ts +2 -1
  350. package/src/server/api-modules.ts +38 -26
  351. package/src/server/api.ts +17 -96
  352. package/src/server/app-database.ts +11 -0
  353. package/src/server/app-hooks.ts +25 -6
  354. package/src/server/app-stages.ts +91 -60
  355. package/src/server/app.ts +25 -13
  356. package/src/server/auth-mails.ts +2 -0
  357. package/src/server/basic-auth.ts +27 -7
  358. package/src/server/bundle.ts +2 -0
  359. package/src/server/button-form-rule.ts +20 -0
  360. package/src/server/card.ts +2 -2
  361. package/src/server/ceiling.ts +1 -1
  362. package/src/server/client.ts +2 -2
  363. package/src/server/config-error.ts +2 -2
  364. package/src/server/config-limits.ts +37 -17
  365. package/src/server/context-values.ts +4 -3
  366. package/src/server/cookies.ts +4 -2
  367. package/src/server/endpoints.ts +5 -2
  368. package/src/server/entry-drafts.ts +1 -1
  369. package/src/server/errors.ts +4 -3
  370. package/src/server/event-stream.ts +7 -4
  371. package/src/server/favicon.ts +59 -10
  372. package/src/server/fetch-public.ts +4 -3
  373. package/src/server/file-answer.ts +89 -0
  374. package/src/server/forms.ts +1 -1
  375. package/src/server/guard-requirement.ts +7 -0
  376. package/src/server/guards.ts +74 -2
  377. package/src/server/hooks.ts +10 -10
  378. package/src/server/i18n.ts +8 -9
  379. package/src/server/image-limits.ts +4 -3
  380. package/src/server/image.ts +17 -15
  381. package/src/server/index.ts +15 -9
  382. package/src/server/job-context.ts +35 -0
  383. package/src/server/jobs-page.ts +14 -8
  384. package/src/server/jobs.ts +48 -13
  385. package/src/server/kept-exports.ts +3 -1
  386. package/src/server/kv.ts +34 -18
  387. package/src/server/lazy-guard.ts +4 -1
  388. package/src/server/library.ts +5 -2
  389. package/src/server/lifecycle.ts +5 -5
  390. package/src/server/link-schemes.ts +5 -5
  391. package/src/server/live.ts +79 -7
  392. package/src/server/load-budget.ts +2 -2
  393. package/src/server/loader.ts +4 -2
  394. package/src/server/log.ts +18 -3
  395. package/src/server/maintenance.ts +1 -1
  396. package/src/server/mcp-key.ts +27 -24
  397. package/src/server/mcp.ts +21 -8
  398. package/src/server/message-drafts.ts +2 -2
  399. package/src/server/metrics.ts +42 -14
  400. package/src/server/moved-exports.ts +17 -0
  401. package/src/server/not-found-config.ts +4 -3
  402. package/src/server/notifications.ts +2 -2
  403. package/src/server/openapi.ts +9 -13
  404. package/src/server/over-limit.ts +29 -0
  405. package/src/server/page-limits.ts +1 -1
  406. package/src/server/page-routes.ts +2 -2
  407. package/src/server/page-seo.ts +29 -0
  408. package/src/server/page-settings.ts +69 -8
  409. package/src/server/pg-data.ts +3 -2
  410. package/src/server/pg-jobs.ts +3 -2
  411. package/src/server/pg-limit.ts +4 -3
  412. package/src/server/pg-live.ts +3 -1
  413. package/src/server/pg-not-found.ts +2 -1
  414. package/src/server/pg-poll.ts +3 -3
  415. package/src/server/pg-redirects.ts +3 -2
  416. package/src/server/pg-stores.ts +9 -7
  417. package/src/server/prerender.ts +21 -10
  418. package/src/server/preview.ts +3 -1
  419. package/src/server/protection.ts +20 -44
  420. package/src/server/proxy-key.ts +17 -39
  421. package/src/server/pure-page.ts +2 -29
  422. package/src/server/push-crypto.ts +3 -2
  423. package/src/server/push-server.ts +2 -1
  424. package/src/server/push.ts +6 -6
  425. package/src/server/queue-scheduler.ts +5 -0
  426. package/src/server/queue.ts +21 -29
  427. package/src/server/rate-limit.ts +21 -13
  428. package/src/server/rate-windows.ts +14 -0
  429. package/src/server/redirects.ts +29 -2
  430. package/src/server/remote.ts +5 -4
  431. package/src/server/render-document.ts +32 -11
  432. package/src/server/render.ts +6 -6
  433. package/src/server/report.ts +5 -5
  434. package/src/server/request-record.ts +2 -0
  435. package/src/server/resources.ts +2 -1
  436. package/src/server/rooms.ts +177 -23
  437. package/src/server/route-settings.ts +236 -0
  438. package/src/server/routes.ts +25 -195
  439. package/src/server/save-data.ts +1 -1
  440. package/src/server/scope.ts +1 -1
  441. package/src/server/secret.ts +76 -0
  442. package/src/server/security.ts +15 -10
  443. package/src/server/seo.ts +19 -7
  444. package/src/server/served-paths.ts +2 -1
  445. package/src/server/session.ts +39 -18
  446. package/src/server/setup.ts +17 -10
  447. package/src/server/signals.ts +23 -3
  448. package/src/server/signed.ts +7 -4
  449. package/src/server/sitemap.ts +6 -4
  450. package/src/server/socket.ts +371 -0
  451. package/src/server/source.ts +13 -7
  452. package/src/server/sqlite-live.ts +3 -1
  453. package/src/server/storage.ts +21 -48
  454. package/src/server/stream.ts +23 -14
  455. package/src/server/translations.ts +2 -2
  456. package/src/server/uncaught.ts +2 -2
  457. package/src/server/violations.ts +4 -3
  458. package/src/server/vitals-routes/_guard.ts +1 -1
  459. package/src/server/vitals-server.ts +2 -1
  460. package/src/server/vitals.ts +5 -2
  461. package/src/server/words.ts +4 -0
  462. package/src/server/work-scope.ts +4 -2
  463. package/src/server/work.ts +4 -3
  464. package/src/server/workers.ts +2 -1
  465. package/src/server/workflow.ts +19 -11
  466. package/src/server/ws-limits.ts +51 -69
  467. package/src/template-config.ts +1 -1
  468. package/src/template-docker.ts +1 -1
  469. package/src/template-starter.ts +2 -2
  470. package/src/template-styles.ts +1 -1
  471. package/src/template-ws.ts +1 -1
  472. package/src/test/a11y.ts +55 -0
  473. package/src/test/browser.ts +5 -48
  474. package/src/test/index.ts +31 -39
  475. package/src/test/mount.ts +5 -4
  476. package/src/test/outgoing.ts +138 -0
  477. package/src/test/page-types.ts +3 -0
  478. package/src/test/screenshot-match.ts +69 -0
  479. package/src/test/service.ts +11 -5
  480. package/src/test/site-actions.ts +22 -19
  481. package/src/test/site-keys.ts +49 -0
  482. package/src/test/site-socket.ts +42 -38
  483. package/src/test/site-types.ts +41 -12
  484. package/src/test/site-world.ts +86 -0
  485. package/types/build/await-alert.d.ts +4 -0
  486. package/types/build/await-alert.d.ts.map +1 -0
  487. package/types/build/client.d.ts.map +1 -1
  488. package/types/build/compile.d.ts +1 -0
  489. package/types/build/compile.d.ts.map +1 -1
  490. package/types/build/server-record.d.ts.map +1 -1
  491. package/types/build/static.d.ts.map +1 -1
  492. package/types/build/styles.d.ts.map +1 -1
  493. package/types/build/transform.d.ts.map +1 -1
  494. package/types/build/verify.d.ts +3 -2
  495. package/types/build/verify.d.ts.map +1 -1
  496. package/types/check/action-readers.d.ts +3 -0
  497. package/types/check/action-readers.d.ts.map +1 -0
  498. package/types/check/action-type.d.ts +3 -0
  499. package/types/check/action-type.d.ts.map +1 -0
  500. package/types/check/ai-language.d.ts +3 -0
  501. package/types/check/ai-language.d.ts.map +1 -0
  502. package/types/check/app-hooks.d.ts +3 -0
  503. package/types/check/app-hooks.d.ts.map +1 -0
  504. package/types/check/auth-methods.d.ts +3 -0
  505. package/types/check/auth-methods.d.ts.map +1 -0
  506. package/types/check/auth-rate-limits.d.ts +3 -0
  507. package/types/check/auth-rate-limits.d.ts.map +1 -0
  508. package/types/check/boot.d.ts.map +1 -1
  509. package/types/check/client-keys.d.ts +3 -0
  510. package/types/check/client-keys.d.ts.map +1 -0
  511. package/types/check/cms-options.d.ts +3 -0
  512. package/types/check/cms-options.d.ts.map +1 -0
  513. package/types/check/config-groups.d.ts +3 -0
  514. package/types/check/config-groups.d.ts.map +1 -0
  515. package/types/check/config-objects.d.ts +16 -0
  516. package/types/check/config-objects.d.ts.map +1 -0
  517. package/types/check/config-switches.d.ts +3 -0
  518. package/types/check/config-switches.d.ts.map +1 -0
  519. package/types/check/context-import.d.ts +3 -0
  520. package/types/check/context-import.d.ts.map +1 -0
  521. package/types/check/diagnose.d.ts +1 -1
  522. package/types/check/diagnose.d.ts.map +1 -1
  523. package/types/check/env-files.d.ts +3 -0
  524. package/types/check/env-files.d.ts.map +1 -0
  525. package/types/check/env-types.d.ts.map +1 -1
  526. package/types/check/format-duration.d.ts +5 -0
  527. package/types/check/format-duration.d.ts.map +1 -0
  528. package/types/check/generated.d.ts +2 -0
  529. package/types/check/generated.d.ts.map +1 -1
  530. package/types/check/guard-options.d.ts +3 -0
  531. package/types/check/guard-options.d.ts.map +1 -0
  532. package/types/check/hook-context.d.ts +3 -0
  533. package/types/check/hook-context.d.ts.map +1 -0
  534. package/types/check/hook-names.d.ts +3 -0
  535. package/types/check/hook-names.d.ts.map +1 -0
  536. package/types/check/i18n-keys.d.ts +3 -0
  537. package/types/check/i18n-keys.d.ts.map +1 -0
  538. package/types/check/images-keys.d.ts +3 -0
  539. package/types/check/images-keys.d.ts.map +1 -0
  540. package/types/check/index.d.ts +7 -4
  541. package/types/check/index.d.ts.map +1 -1
  542. package/types/check/job-shapes.d.ts +6 -0
  543. package/types/check/job-shapes.d.ts.map +1 -0
  544. package/types/check/live-api.d.ts +3 -0
  545. package/types/check/live-api.d.ts.map +1 -0
  546. package/types/check/mail-api.d.ts +3 -0
  547. package/types/check/mail-api.d.ts.map +1 -0
  548. package/types/check/moved-keys.d.ts +10 -0
  549. package/types/check/moved-keys.d.ts.map +1 -0
  550. package/types/check/one-state-api.d.ts +9 -0
  551. package/types/check/one-state-api.d.ts.map +1 -0
  552. package/types/check/output-schema.d.ts +1 -1
  553. package/types/check/output-schema.d.ts.map +1 -1
  554. package/types/check/page-heads.d.ts.map +1 -1
  555. package/types/check/pages-options.d.ts +3 -0
  556. package/types/check/pages-options.d.ts.map +1 -0
  557. package/types/check/project.d.ts.map +1 -1
  558. package/types/check/rate-enforce.d.ts +3 -0
  559. package/types/check/rate-enforce.d.ts.map +1 -0
  560. package/types/check/refusal-calls.d.ts +3 -0
  561. package/types/check/refusal-calls.d.ts.map +1 -0
  562. package/types/check/regroup.d.ts +8 -0
  563. package/types/check/regroup.d.ts.map +1 -0
  564. package/types/check/renamed-packages.d.ts.map +1 -1
  565. package/types/check/retired-lints.d.ts +3 -0
  566. package/types/check/retired-lints.d.ts.map +1 -0
  567. package/types/check/route-keys.d.ts +3 -0
  568. package/types/check/route-keys.d.ts.map +1 -0
  569. package/types/check/route-shadow.d.ts +12 -0
  570. package/types/check/route-shadow.d.ts.map +1 -0
  571. package/types/check/secret-keys.d.ts +3 -0
  572. package/types/check/secret-keys.d.ts.map +1 -0
  573. package/types/check/seo.d.ts +3 -1
  574. package/types/check/seo.d.ts.map +1 -1
  575. package/types/check/shadow-types.d.ts +1 -0
  576. package/types/check/shadow-types.d.ts.map +1 -1
  577. package/types/check/shadow.d.ts +1 -0
  578. package/types/check/shadow.d.ts.map +1 -1
  579. package/types/check/socket-frames.d.ts +3 -0
  580. package/types/check/socket-frames.d.ts.map +1 -0
  581. package/types/check/source-readers.d.ts +3 -0
  582. package/types/check/source-readers.d.ts.map +1 -0
  583. package/types/check/store-ms.d.ts +3 -0
  584. package/types/check/store-ms.d.ts.map +1 -0
  585. package/types/check/store-names.d.ts +3 -0
  586. package/types/check/store-names.d.ts.map +1 -0
  587. package/types/check/template-hints.d.ts +2 -0
  588. package/types/check/template-hints.d.ts.map +1 -1
  589. package/types/check/test-helpers.d.ts +3 -0
  590. package/types/check/test-helpers.d.ts.map +1 -0
  591. package/types/check/ttl-names.d.ts +3 -0
  592. package/types/check/ttl-names.d.ts.map +1 -0
  593. package/types/commands/check.d.ts.map +1 -1
  594. package/types/commands/env.d.ts.map +1 -1
  595. package/types/commands/explain-island.d.ts.map +1 -1
  596. package/types/commands/routes.d.ts.map +1 -1
  597. package/types/compiler/a11y.d.ts.map +1 -1
  598. package/types/compiler/aria.d.ts +1 -0
  599. package/types/compiler/aria.d.ts.map +1 -1
  600. package/types/compiler/ast.d.ts +13 -16
  601. package/types/compiler/ast.d.ts.map +1 -1
  602. package/types/compiler/bound-props.d.ts +16 -0
  603. package/types/compiler/bound-props.d.ts.map +1 -0
  604. package/types/compiler/browser.d.ts.map +1 -1
  605. package/types/compiler/button-forms.d.ts +3 -0
  606. package/types/compiler/button-forms.d.ts.map +1 -0
  607. package/types/compiler/codegen.d.ts +2 -1
  608. package/types/compiler/codegen.d.ts.map +1 -1
  609. package/types/compiler/deprecated-ai-labels.d.ts +5 -0
  610. package/types/compiler/deprecated-ai-labels.d.ts.map +1 -0
  611. package/types/compiler/deprecated-ai-links.d.ts +5 -0
  612. package/types/compiler/deprecated-ai-links.d.ts.map +1 -0
  613. package/types/compiler/deprecated-allow.d.ts +5 -0
  614. package/types/compiler/deprecated-allow.d.ts.map +1 -0
  615. package/types/compiler/deprecated-auth-lints.d.ts +12 -0
  616. package/types/compiler/deprecated-auth-lints.d.ts.map +1 -0
  617. package/types/compiler/deprecated-auth-signed.d.ts +5 -0
  618. package/types/compiler/deprecated-auth-signed.d.ts.map +1 -0
  619. package/types/compiler/deprecated-children.d.ts +4 -0
  620. package/types/compiler/deprecated-children.d.ts.map +1 -0
  621. package/types/compiler/deprecated-image.d.ts +5 -0
  622. package/types/compiler/deprecated-image.d.ts.map +1 -0
  623. package/types/compiler/deprecated-island.d.ts +9 -0
  624. package/types/compiler/deprecated-island.d.ts.map +1 -0
  625. package/types/compiler/deprecated-library.d.ts +4 -0
  626. package/types/compiler/deprecated-library.d.ts.map +1 -0
  627. package/types/compiler/deprecated-lints.d.ts +527 -20
  628. package/types/compiler/deprecated-lints.d.ts.map +1 -1
  629. package/types/compiler/deprecated-page.d.ts +4 -0
  630. package/types/compiler/deprecated-page.d.ts.map +1 -0
  631. package/types/compiler/deprecated-parts.d.ts +3 -0
  632. package/types/compiler/deprecated-parts.d.ts.map +1 -0
  633. package/types/compiler/deprecated-ui-callbacks.d.ts +5 -0
  634. package/types/compiler/deprecated-ui-callbacks.d.ts.map +1 -0
  635. package/types/compiler/deprecated-ui-input.d.ts +5 -0
  636. package/types/compiler/deprecated-ui-input.d.ts.map +1 -0
  637. package/types/compiler/deprecated-ui-items.d.ts +5 -0
  638. package/types/compiler/deprecated-ui-items.d.ts.map +1 -0
  639. package/types/compiler/deprecated-ui-props.d.ts.map +1 -1
  640. package/types/compiler/dom-fields.d.ts +7 -0
  641. package/types/compiler/dom-fields.d.ts.map +1 -0
  642. package/types/compiler/dom.d.ts +4 -2
  643. package/types/compiler/dom.d.ts.map +1 -1
  644. package/types/compiler/errors.d.ts +43 -18
  645. package/types/compiler/errors.d.ts.map +1 -1
  646. package/types/compiler/fence-checks.d.ts.map +1 -1
  647. package/types/compiler/form-action.d.ts +8 -0
  648. package/types/compiler/form-action.d.ts.map +1 -0
  649. package/types/compiler/form-info.d.ts +29 -0
  650. package/types/compiler/form-info.d.ts.map +1 -0
  651. package/types/compiler/head-shorthand.d.ts +16 -0
  652. package/types/compiler/head-shorthand.d.ts.map +1 -0
  653. package/types/compiler/head-tags.d.ts +7 -0
  654. package/types/compiler/head-tags.d.ts.map +1 -0
  655. package/types/compiler/helper-imports.d.ts +5 -0
  656. package/types/compiler/helper-imports.d.ts.map +1 -0
  657. package/types/compiler/html-initial.d.ts +16 -0
  658. package/types/compiler/html-initial.d.ts.map +1 -0
  659. package/types/compiler/html-parts.d.ts +13 -0
  660. package/types/compiler/html-parts.d.ts.map +1 -0
  661. package/types/compiler/html.d.ts +3 -2
  662. package/types/compiler/html.d.ts.map +1 -1
  663. package/types/compiler/if-alias.d.ts.map +1 -1
  664. package/types/compiler/image-attributes.d.ts +22 -0
  665. package/types/compiler/image-attributes.d.ts.map +1 -0
  666. package/types/compiler/index.d.ts +2 -0
  667. package/types/compiler/index.d.ts.map +1 -1
  668. package/types/compiler/island-arguments.d.ts +6 -1
  669. package/types/compiler/island-arguments.d.ts.map +1 -1
  670. package/types/compiler/island-cause.d.ts +1 -1
  671. package/types/compiler/island-cause.d.ts.map +1 -1
  672. package/types/compiler/island-declaration.d.ts +30 -0
  673. package/types/compiler/island-declaration.d.ts.map +1 -0
  674. package/types/compiler/island-marker.d.ts.map +1 -1
  675. package/types/compiler/items.d.ts +3 -0
  676. package/types/compiler/items.d.ts.map +1 -1
  677. package/types/compiler/jsx-class.d.ts +2 -1
  678. package/types/compiler/jsx-class.d.ts.map +1 -1
  679. package/types/compiler/jsx-field.d.ts +13 -0
  680. package/types/compiler/jsx-field.d.ts.map +1 -0
  681. package/types/compiler/jsx.d.ts +1 -0
  682. package/types/compiler/jsx.d.ts.map +1 -1
  683. package/types/compiler/kay-exports.d.ts.map +1 -1
  684. package/types/compiler/link-flags.d.ts +12 -0
  685. package/types/compiler/link-flags.d.ts.map +1 -0
  686. package/types/compiler/lints.d.ts +562 -54
  687. package/types/compiler/lints.d.ts.map +1 -1
  688. package/types/compiler/live-reads.d.ts +13 -0
  689. package/types/compiler/live-reads.d.ts.map +1 -0
  690. package/types/compiler/loop-lints.d.ts +4 -4
  691. package/types/compiler/loop-lints.d.ts.map +1 -1
  692. package/types/compiler/markup-fields.d.ts +8 -0
  693. package/types/compiler/markup-fields.d.ts.map +1 -0
  694. package/types/compiler/markup.d.ts +9 -5
  695. package/types/compiler/markup.d.ts.map +1 -1
  696. package/types/compiler/module-signals.d.ts.map +1 -1
  697. package/types/compiler/names.d.ts +4 -0
  698. package/types/compiler/names.d.ts.map +1 -1
  699. package/types/compiler/old-parts.d.ts +9 -0
  700. package/types/compiler/old-parts.d.ts.map +1 -0
  701. package/types/compiler/page-settings.d.ts +1 -0
  702. package/types/compiler/page-settings.d.ts.map +1 -1
  703. package/types/compiler/parser.d.ts.map +1 -1
  704. package/types/compiler/plan.d.ts +1 -0
  705. package/types/compiler/plan.d.ts.map +1 -1
  706. package/types/compiler/rewrite-reads.d.ts +8 -0
  707. package/types/compiler/rewrite-reads.d.ts.map +1 -1
  708. package/types/compiler/rewrite-types.d.ts +1 -0
  709. package/types/compiler/rewrite-types.d.ts.map +1 -1
  710. package/types/compiler/rewrite.d.ts.map +1 -1
  711. package/types/compiler/route-lints.d.ts +13 -6
  712. package/types/compiler/route-lints.d.ts.map +1 -1
  713. package/types/compiler/script-props.d.ts.map +1 -1
  714. package/types/compiler/script-server.d.ts.map +1 -1
  715. package/types/compiler/script-shared.d.ts +8 -0
  716. package/types/compiler/script-shared.d.ts.map +1 -1
  717. package/types/compiler/script.d.ts.map +1 -1
  718. package/types/compiler/server-imports.d.ts +4 -0
  719. package/types/compiler/server-imports.d.ts.map +1 -0
  720. package/types/compiler/slot-types.d.ts +13 -0
  721. package/types/compiler/slot-types.d.ts.map +1 -0
  722. package/types/compiler/style-arguments.d.ts +6 -0
  723. package/types/compiler/style-arguments.d.ts.map +1 -0
  724. package/types/compiler/template-walk.d.ts +7 -0
  725. package/types/compiler/template-walk.d.ts.map +1 -0
  726. package/types/compiler/type-parameters.d.ts +3 -0
  727. package/types/compiler/type-parameters.d.ts.map +1 -0
  728. package/types/compiler/validate-fields.d.ts +10 -0
  729. package/types/compiler/validate-fields.d.ts.map +1 -0
  730. package/types/compiler/validate.d.ts.map +1 -1
  731. package/types/config-extensions.d.ts +3 -1
  732. package/types/config-extensions.d.ts.map +1 -1
  733. package/types/config-loader.d.ts +2 -2
  734. package/types/config-loader.d.ts.map +1 -1
  735. package/types/config-resolve.d.ts +3 -0
  736. package/types/config-resolve.d.ts.map +1 -0
  737. package/types/config-shape.d.ts +2 -1
  738. package/types/config-shape.d.ts.map +1 -1
  739. package/types/config-switch.d.ts +10 -0
  740. package/types/config-switch.d.ts.map +1 -0
  741. package/types/config.d.ts +228 -67
  742. package/types/config.d.ts.map +1 -1
  743. package/types/generate-resource.d.ts.map +1 -1
  744. package/types/lsp/diagnostics.d.ts.map +1 -1
  745. package/types/lsp/route-documents.d.ts +4 -0
  746. package/types/lsp/route-documents.d.ts.map +1 -0
  747. package/types/lsp/server.d.ts +3 -0
  748. package/types/lsp/server.d.ts.map +1 -1
  749. package/types/project.d.ts +7 -4
  750. package/types/project.d.ts.map +1 -1
  751. package/types/runtime/action-call.d.ts +11 -3
  752. package/types/runtime/action-call.d.ts.map +1 -1
  753. package/types/runtime/action-encode.d.ts.map +1 -1
  754. package/types/runtime/action-error.d.ts.map +1 -1
  755. package/types/runtime/action-form.d.ts +10 -3
  756. package/types/runtime/action-form.d.ts.map +1 -1
  757. package/types/runtime/action-navigate.d.ts +1 -0
  758. package/types/runtime/action-navigate.d.ts.map +1 -1
  759. package/types/runtime/action-owner.d.ts +1 -0
  760. package/types/runtime/action-owner.d.ts.map +1 -1
  761. package/types/runtime/action-post.d.ts.map +1 -1
  762. package/types/runtime/action-protection.d.ts.map +1 -1
  763. package/types/runtime/action-shared.d.ts +76 -15
  764. package/types/runtime/action-shared.d.ts.map +1 -1
  765. package/types/runtime/action-stream.d.ts +1 -1
  766. package/types/runtime/action-stream.d.ts.map +1 -1
  767. package/types/runtime/action.d.ts +5 -5
  768. package/types/runtime/action.d.ts.map +1 -1
  769. package/types/runtime/api-url.d.ts.map +1 -1
  770. package/types/runtime/await-failed.d.ts +8 -0
  771. package/types/runtime/await-failed.d.ts.map +1 -0
  772. package/types/runtime/await.d.ts +2 -2
  773. package/types/runtime/await.d.ts.map +1 -1
  774. package/types/runtime/await.server.d.ts +6 -3
  775. package/types/runtime/await.server.d.ts.map +1 -1
  776. package/types/runtime/button-form.d.ts +3 -0
  777. package/types/runtime/button-form.d.ts.map +1 -0
  778. package/types/runtime/cache-hooks.d.ts +10 -0
  779. package/types/runtime/cache-hooks.d.ts.map +1 -0
  780. package/types/runtime/cache-live-id.d.ts +3 -0
  781. package/types/runtime/cache-live-id.d.ts.map +1 -1
  782. package/types/runtime/cache.d.ts +1 -5
  783. package/types/runtime/cache.d.ts.map +1 -1
  784. package/types/runtime/call-result.d.ts +18 -9
  785. package/types/runtime/call-result.d.ts.map +1 -1
  786. package/types/runtime/checks.d.ts +13 -10
  787. package/types/runtime/checks.d.ts.map +1 -1
  788. package/types/runtime/consent.d.ts.map +1 -1
  789. package/types/runtime/core.d.ts +48 -9
  790. package/types/runtime/core.d.ts.map +1 -1
  791. package/types/runtime/dispatch.d.ts +8 -0
  792. package/types/runtime/dispatch.d.ts.map +1 -0
  793. package/types/runtime/dom-await.d.ts +1 -1
  794. package/types/runtime/dom-await.d.ts.map +1 -1
  795. package/types/runtime/dom-image.d.ts +1 -1
  796. package/types/runtime/dom-image.d.ts.map +1 -1
  797. package/types/runtime/duration-words.d.ts.map +1 -1
  798. package/types/runtime/duration.d.ts.map +1 -1
  799. package/types/runtime/edit.d.ts.map +1 -1
  800. package/types/runtime/env.d.ts.map +1 -1
  801. package/types/runtime/forms.d.ts.map +1 -1
  802. package/types/runtime/head.d.ts.map +1 -1
  803. package/types/runtime/html.d.ts +3 -2
  804. package/types/runtime/html.d.ts.map +1 -1
  805. package/types/runtime/i18n.client.d.ts +4 -1
  806. package/types/runtime/i18n.client.d.ts.map +1 -1
  807. package/types/runtime/i18n.d.ts +22 -7
  808. package/types/runtime/i18n.d.ts.map +1 -1
  809. package/types/runtime/i18n.server.d.ts +4 -1
  810. package/types/runtime/i18n.server.d.ts.map +1 -1
  811. package/types/runtime/image.d.ts +1 -1
  812. package/types/runtime/image.d.ts.map +1 -1
  813. package/types/runtime/index.d.ts +9 -8
  814. package/types/runtime/index.d.ts.map +1 -1
  815. package/types/runtime/internal.d.ts +2 -1
  816. package/types/runtime/internal.d.ts.map +1 -1
  817. package/types/runtime/invalidated-keys.d.ts +2 -0
  818. package/types/runtime/invalidated-keys.d.ts.map +1 -0
  819. package/types/runtime/island.server.d.ts.map +1 -1
  820. package/types/runtime/jsx.d.ts +7 -0
  821. package/types/runtime/jsx.d.ts.map +1 -1
  822. package/types/runtime/kay-error.d.ts +14 -0
  823. package/types/runtime/kay-error.d.ts.map +1 -0
  824. package/types/runtime/leave.d.ts.map +1 -1
  825. package/types/runtime/live-cache.d.ts +1 -0
  826. package/types/runtime/live-cache.d.ts.map +1 -1
  827. package/types/runtime/live-resource.server.d.ts.map +1 -1
  828. package/types/runtime/live-revalidate.d.ts +9 -0
  829. package/types/runtime/live-revalidate.d.ts.map +1 -0
  830. package/types/runtime/live-value.client.d.ts.map +1 -1
  831. package/types/runtime/live-value.d.ts +3 -0
  832. package/types/runtime/live-value.d.ts.map +1 -1
  833. package/types/runtime/live-value.server.d.ts.map +1 -1
  834. package/types/runtime/live-value.shared.d.ts +38 -6
  835. package/types/runtime/live-value.shared.d.ts.map +1 -1
  836. package/types/runtime/live.d.ts +41 -42
  837. package/types/runtime/live.d.ts.map +1 -1
  838. package/types/runtime/local-types.d.ts +86 -0
  839. package/types/runtime/local-types.d.ts.map +1 -0
  840. package/types/runtime/local.d.ts +1 -70
  841. package/types/runtime/local.d.ts.map +1 -1
  842. package/types/runtime/log.d.ts.map +1 -1
  843. package/types/runtime/mount.compat.d.ts +7 -0
  844. package/types/runtime/mount.compat.d.ts.map +1 -0
  845. package/types/runtime/navigate-api.d.ts +10 -4
  846. package/types/runtime/navigate-api.d.ts.map +1 -1
  847. package/types/runtime/navigation-state.d.ts +19 -0
  848. package/types/runtime/navigation-state.d.ts.map +1 -1
  849. package/types/runtime/page-swap.d.ts.map +1 -1
  850. package/types/runtime/persist.d.ts.map +1 -1
  851. package/types/runtime/persisted.d.ts +25 -29
  852. package/types/runtime/persisted.d.ts.map +1 -1
  853. package/types/runtime/presence.d.ts +6 -3
  854. package/types/runtime/presence.d.ts.map +1 -1
  855. package/types/runtime/queue-jobs.d.ts.map +1 -1
  856. package/types/runtime/reactive.d.ts.map +1 -1
  857. package/types/runtime/refuse.d.ts +8 -1
  858. package/types/runtime/refuse.d.ts.map +1 -1
  859. package/types/runtime/resource-tags.d.ts +4 -0
  860. package/types/runtime/resource-tags.d.ts.map +1 -0
  861. package/types/runtime/route.d.ts.map +1 -1
  862. package/types/runtime/sanitize.d.ts.map +1 -1
  863. package/types/runtime/schema.client.d.ts.map +1 -1
  864. package/types/runtime/schema.d.ts.map +1 -1
  865. package/types/runtime/send.d.ts.map +1 -1
  866. package/types/runtime/shortcut.d.ts +1 -0
  867. package/types/runtime/shortcut.d.ts.map +1 -1
  868. package/types/runtime/socket-message.d.ts +7 -0
  869. package/types/runtime/socket-message.d.ts.map +1 -0
  870. package/types/runtime/store-base.d.ts +4 -0
  871. package/types/runtime/store-base.d.ts.map +1 -1
  872. package/types/runtime/swap-fetch.d.ts.map +1 -1
  873. package/types/runtime/swap.d.ts +2 -0
  874. package/types/runtime/swap.d.ts.map +1 -1
  875. package/types/runtime/template-context.d.ts.map +1 -1
  876. package/types/runtime/values.d.ts.map +1 -1
  877. package/types/runtime/wire.d.ts +1 -0
  878. package/types/runtime/wire.d.ts.map +1 -1
  879. package/types/runtime/with-query.d.ts.map +1 -1
  880. package/types/runtime/work.d.ts.map +1 -1
  881. package/types/server/action-hooks.d.ts +4 -4
  882. package/types/server/action-hooks.d.ts.map +1 -1
  883. package/types/server/action-iterable.d.ts +2 -1
  884. package/types/server/action-iterable.d.ts.map +1 -1
  885. package/types/server/actions.d.ts +3 -2
  886. package/types/server/actions.d.ts.map +1 -1
  887. package/types/server/analytics-server.d.ts.map +1 -1
  888. package/types/server/api-modules.d.ts +16 -13
  889. package/types/server/api-modules.d.ts.map +1 -1
  890. package/types/server/api.d.ts +6 -3
  891. package/types/server/api.d.ts.map +1 -1
  892. package/types/server/app-database.d.ts +2 -0
  893. package/types/server/app-database.d.ts.map +1 -1
  894. package/types/server/app-hooks.d.ts +10 -2
  895. package/types/server/app-hooks.d.ts.map +1 -1
  896. package/types/server/app-stages.d.ts +21 -26
  897. package/types/server/app-stages.d.ts.map +1 -1
  898. package/types/server/app.d.ts +21 -24
  899. package/types/server/app.d.ts.map +1 -1
  900. package/types/server/auth-mails.d.ts +5 -0
  901. package/types/server/auth-mails.d.ts.map +1 -1
  902. package/types/server/basic-auth.d.ts +2 -5
  903. package/types/server/basic-auth.d.ts.map +1 -1
  904. package/types/server/bundle.d.ts +1 -0
  905. package/types/server/bundle.d.ts.map +1 -1
  906. package/types/server/button-form-rule.d.ts +4 -0
  907. package/types/server/button-form-rule.d.ts.map +1 -0
  908. package/types/server/card.d.ts +1 -1
  909. package/types/server/card.d.ts.map +1 -1
  910. package/types/server/config-limits.d.ts +5 -5
  911. package/types/server/config-limits.d.ts.map +1 -1
  912. package/types/server/context-values.d.ts.map +1 -1
  913. package/types/server/cookies.d.ts +2 -2
  914. package/types/server/cookies.d.ts.map +1 -1
  915. package/types/server/endpoints.d.ts.map +1 -1
  916. package/types/server/errors.d.ts +2 -2
  917. package/types/server/errors.d.ts.map +1 -1
  918. package/types/server/event-stream.d.ts +1 -1
  919. package/types/server/event-stream.d.ts.map +1 -1
  920. package/types/server/favicon.d.ts +7 -3
  921. package/types/server/favicon.d.ts.map +1 -1
  922. package/types/server/fetch-public.d.ts.map +1 -1
  923. package/types/server/file-answer.d.ts +17 -0
  924. package/types/server/file-answer.d.ts.map +1 -0
  925. package/types/server/forms.d.ts +1 -1
  926. package/types/server/forms.d.ts.map +1 -1
  927. package/types/server/guard-requirement.d.ts +6 -0
  928. package/types/server/guard-requirement.d.ts.map +1 -1
  929. package/types/server/guards.d.ts +11 -0
  930. package/types/server/guards.d.ts.map +1 -1
  931. package/types/server/hooks.d.ts +8 -8
  932. package/types/server/hooks.d.ts.map +1 -1
  933. package/types/server/i18n.d.ts.map +1 -1
  934. package/types/server/image-limits.d.ts.map +1 -1
  935. package/types/server/image.d.ts +8 -13
  936. package/types/server/image.d.ts.map +1 -1
  937. package/types/server/index.d.ts +12 -8
  938. package/types/server/index.d.ts.map +1 -1
  939. package/types/server/job-context.d.ts +16 -0
  940. package/types/server/job-context.d.ts.map +1 -0
  941. package/types/server/jobs-page.d.ts +1 -1
  942. package/types/server/jobs-page.d.ts.map +1 -1
  943. package/types/server/jobs.d.ts +22 -4
  944. package/types/server/jobs.d.ts.map +1 -1
  945. package/types/server/kept-exports.d.ts.map +1 -1
  946. package/types/server/kv.d.ts +5 -4
  947. package/types/server/kv.d.ts.map +1 -1
  948. package/types/server/lazy-guard.d.ts +2 -1
  949. package/types/server/lazy-guard.d.ts.map +1 -1
  950. package/types/server/library.d.ts +5 -2
  951. package/types/server/library.d.ts.map +1 -1
  952. package/types/server/lifecycle.d.ts +2 -2
  953. package/types/server/lifecycle.d.ts.map +1 -1
  954. package/types/server/link-schemes.d.ts +1 -1
  955. package/types/server/link-schemes.d.ts.map +1 -1
  956. package/types/server/live.d.ts +5 -0
  957. package/types/server/live.d.ts.map +1 -1
  958. package/types/server/loader.d.ts.map +1 -1
  959. package/types/server/log.d.ts +7 -1
  960. package/types/server/log.d.ts.map +1 -1
  961. package/types/server/mcp-key.d.ts +2 -3
  962. package/types/server/mcp-key.d.ts.map +1 -1
  963. package/types/server/mcp.d.ts +1 -0
  964. package/types/server/mcp.d.ts.map +1 -1
  965. package/types/server/metrics.d.ts +9 -2
  966. package/types/server/metrics.d.ts.map +1 -1
  967. package/types/server/moved-exports.d.ts +12 -0
  968. package/types/server/moved-exports.d.ts.map +1 -0
  969. package/types/server/not-found-config.d.ts.map +1 -1
  970. package/types/server/openapi.d.ts +5 -5
  971. package/types/server/openapi.d.ts.map +1 -1
  972. package/types/server/over-limit.d.ts +9 -0
  973. package/types/server/over-limit.d.ts.map +1 -0
  974. package/types/server/page-seo.d.ts +3 -0
  975. package/types/server/page-seo.d.ts.map +1 -0
  976. package/types/server/page-settings.d.ts +5 -1
  977. package/types/server/page-settings.d.ts.map +1 -1
  978. package/types/server/pg-data.d.ts.map +1 -1
  979. package/types/server/pg-jobs.d.ts.map +1 -1
  980. package/types/server/pg-limit.d.ts.map +1 -1
  981. package/types/server/pg-live.d.ts.map +1 -1
  982. package/types/server/pg-not-found.d.ts.map +1 -1
  983. package/types/server/pg-poll.d.ts +2 -2
  984. package/types/server/pg-poll.d.ts.map +1 -1
  985. package/types/server/pg-redirects.d.ts.map +1 -1
  986. package/types/server/pg-stores.d.ts.map +1 -1
  987. package/types/server/prerender.d.ts.map +1 -1
  988. package/types/server/preview.d.ts +1 -1
  989. package/types/server/preview.d.ts.map +1 -1
  990. package/types/server/protection.d.ts +1 -2
  991. package/types/server/protection.d.ts.map +1 -1
  992. package/types/server/proxy-key.d.ts +3 -3
  993. package/types/server/proxy-key.d.ts.map +1 -1
  994. package/types/server/pure-page.d.ts.map +1 -1
  995. package/types/server/push-crypto.d.ts.map +1 -1
  996. package/types/server/push-server.d.ts.map +1 -1
  997. package/types/server/queue-scheduler.d.ts +1 -0
  998. package/types/server/queue-scheduler.d.ts.map +1 -1
  999. package/types/server/queue.d.ts +6 -7
  1000. package/types/server/queue.d.ts.map +1 -1
  1001. package/types/server/rate-limit.d.ts +6 -1
  1002. package/types/server/rate-limit.d.ts.map +1 -1
  1003. package/types/server/rate-windows.d.ts +3 -0
  1004. package/types/server/rate-windows.d.ts.map +1 -0
  1005. package/types/server/redirects.d.ts.map +1 -1
  1006. package/types/server/remote.d.ts.map +1 -1
  1007. package/types/server/render-document.d.ts +1 -0
  1008. package/types/server/render-document.d.ts.map +1 -1
  1009. package/types/server/report.d.ts +3 -3
  1010. package/types/server/report.d.ts.map +1 -1
  1011. package/types/server/request-record.d.ts +1 -0
  1012. package/types/server/request-record.d.ts.map +1 -1
  1013. package/types/server/resources.d.ts.map +1 -1
  1014. package/types/server/rooms.d.ts +34 -4
  1015. package/types/server/rooms.d.ts.map +1 -1
  1016. package/types/server/route-settings.d.ts +9 -0
  1017. package/types/server/route-settings.d.ts.map +1 -0
  1018. package/types/server/routes.d.ts +1 -6
  1019. package/types/server/routes.d.ts.map +1 -1
  1020. package/types/server/secret.d.ts +12 -0
  1021. package/types/server/secret.d.ts.map +1 -0
  1022. package/types/server/security.d.ts +4 -5
  1023. package/types/server/security.d.ts.map +1 -1
  1024. package/types/server/seo.d.ts.map +1 -1
  1025. package/types/server/served-paths.d.ts.map +1 -1
  1026. package/types/server/session.d.ts +8 -2
  1027. package/types/server/session.d.ts.map +1 -1
  1028. package/types/server/setup.d.ts.map +1 -1
  1029. package/types/server/signals.d.ts +3 -1
  1030. package/types/server/signals.d.ts.map +1 -1
  1031. package/types/server/signed.d.ts +2 -0
  1032. package/types/server/signed.d.ts.map +1 -1
  1033. package/types/server/sitemap.d.ts +4 -3
  1034. package/types/server/sitemap.d.ts.map +1 -1
  1035. package/types/server/socket.d.ts +51 -0
  1036. package/types/server/socket.d.ts.map +1 -0
  1037. package/types/server/source.d.ts +4 -3
  1038. package/types/server/source.d.ts.map +1 -1
  1039. package/types/server/sqlite-live.d.ts.map +1 -1
  1040. package/types/server/storage.d.ts +10 -2
  1041. package/types/server/storage.d.ts.map +1 -1
  1042. package/types/server/stream.d.ts +3 -3
  1043. package/types/server/stream.d.ts.map +1 -1
  1044. package/types/server/uncaught.d.ts +2 -2
  1045. package/types/server/uncaught.d.ts.map +1 -1
  1046. package/types/server/violations.d.ts +2 -2
  1047. package/types/server/violations.d.ts.map +1 -1
  1048. package/types/server/vitals-server.d.ts.map +1 -1
  1049. package/types/server/vitals.d.ts +1 -0
  1050. package/types/server/vitals.d.ts.map +1 -1
  1051. package/types/server/words.d.ts +3 -0
  1052. package/types/server/words.d.ts.map +1 -1
  1053. package/types/server/work-scope.d.ts +2 -0
  1054. package/types/server/work-scope.d.ts.map +1 -1
  1055. package/types/server/work.d.ts +2 -2
  1056. package/types/server/work.d.ts.map +1 -1
  1057. package/types/server/workers.d.ts.map +1 -1
  1058. package/types/server/workflow.d.ts +4 -5
  1059. package/types/server/workflow.d.ts.map +1 -1
  1060. package/types/server/ws-limits.d.ts +15 -6
  1061. package/types/server/ws-limits.d.ts.map +1 -1
  1062. package/types/test/a11y.d.ts +3 -0
  1063. package/types/test/a11y.d.ts.map +1 -0
  1064. package/types/test/browser.d.ts.map +1 -1
  1065. package/types/test/index.d.ts +8 -2
  1066. package/types/test/index.d.ts.map +1 -1
  1067. package/types/test/mount.d.ts.map +1 -1
  1068. package/types/test/outgoing.d.ts +12 -0
  1069. package/types/test/outgoing.d.ts.map +1 -0
  1070. package/types/test/page-types.d.ts +2 -0
  1071. package/types/test/page-types.d.ts.map +1 -1
  1072. package/types/test/screenshot-match.d.ts +7 -0
  1073. package/types/test/screenshot-match.d.ts.map +1 -0
  1074. package/types/test/service.d.ts +2 -0
  1075. package/types/test/service.d.ts.map +1 -1
  1076. package/types/test/site-actions.d.ts +2 -2
  1077. package/types/test/site-actions.d.ts.map +1 -1
  1078. package/types/test/site-keys.d.ts +10 -0
  1079. package/types/test/site-keys.d.ts.map +1 -0
  1080. package/types/test/site-socket.d.ts.map +1 -1
  1081. package/types/test/site-types.d.ts +32 -9
  1082. package/types/test/site-types.d.ts.map +1 -1
  1083. package/types/test/site-world.d.ts +11 -0
  1084. package/types/test/site-world.d.ts.map +1 -0
  1085. package/src/check/local-state.ts +0 -132
  1086. package/src/check/persisted-storage.ts +0 -87
  1087. package/types/check/local-state.d.ts +0 -3
  1088. package/types/check/local-state.d.ts.map +0 -1
  1089. package/types/check/persisted-storage.d.ts +0 -3
  1090. package/types/check/persisted-storage.d.ts.map +0 -1
@@ -4,13 +4,13 @@
4
4
 
5
5
  ### Log requests as JSON for a log collector
6
6
 
7
- `observe: { log: 'json' }` in kay.config.ts writes one JSON object per line, requests included, on stdout for info and on stderr for warnings and errors:
7
+ `ops: { observe: { log: { format: 'json' } } }` in kay.config.ts writes one JSON object per line, requests included, on stdout for info and on stderr for warnings and errors; `log: { sink }` hands each entry to a function instead, and `requests: false` keeps kay's messages and logs no request line (`log: 'json'` and a bare function work until 1.108, `deprecated-app-hooks` rewrites them):
8
8
 
9
9
  ```ts
10
10
  import { defineConfig } from 'kay/server'
11
11
 
12
12
  export default defineConfig({
13
- observe: { log: 'json' },
13
+ ops: { observe: { log: { format: 'json' } } },
14
14
  })
15
15
  ```
16
16
 
@@ -30,13 +30,14 @@ log.error('failed', new Error('refused'))
30
30
 
31
31
  ### Check the database in the health route
32
32
 
33
- `health` moves the route and adds a check, which answers 503 when it returns `false`, throws or takes over 5 s, or when the `ping` of a store ([Stores](stores.md)) rejects, and runs at most once every 3 s, probes between sharing its answer, which `timeout` changes (`health: { timeout: '10s' }`, a duration such as `'250ms'`, which `./server --health` and the build's check of the executable wait for too, though the Dockerfile `kay new` writes cuts a probe off at 6 s: raise its `--timeout` with it):
33
+ `ops.health` moves the route and adds a check, which answers 503 when it returns `false`, throws or takes over 5 s, or when the `ping` of a store ([Stores](stores.md)) rejects, and runs at most once every 3 s, probes between sharing its answer, which `timeout` changes (`ops: { health: { timeout: '10s' } }`, a duration such as `'250ms'`, which `./server --health` and the build's check of the executable wait for too, though the Dockerfile `kay new` writes cuts a probe off at 6 s: raise its `--timeout` with it):
34
34
 
35
35
  ```ts
36
36
  import { defineConfig } from 'kay/server'
37
37
 
38
38
  export default defineConfig({
39
- health: { path: '/up', check: async () => await db.ping() },
39
+ endpoints: { health: '/up' },
40
+ ops: { health: { check: async () => await db.ping() } },
40
41
  })
41
42
  ```
42
43
 
@@ -65,24 +66,24 @@ kay build --compile server --verify
65
66
  - A failed verify writes no record of the executable, so `kay start` runs the entry instead.
66
67
  - The server runs in a process group of its own and everything it started is stopped with it. On Linux an answer only counts when the listening socket belongs to the server or a process it started, so another process holding the port cannot pass the verify; where /proc cannot be read, the check is left out. An interrupted build stops the server too.
67
68
  - It costs the server's startup plus 250 ms, usually well under a second, and `--format json` carries it as `compiled.verifiedMs`.
68
- - `health: false` leaves no route to ask, so any answer on the port counts and `--health` is not run.
69
+ - `ops: { health: false }` leaves no route to ask, so any answer on the port counts and `--health` is not run.
69
70
 
70
71
  ### Set a library's secrets
71
72
 
72
73
  - A provider key, kayjs-ai's `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`, or the password in kayjs-mail's `MAIL_URL`, is a production secret: an environment variable of the container or a `.env` beside the executable, never in the image or the repository.
73
- - `kay env` lists what each library in `extensions` reads and which of it production requires, such as `AI_MODEL`; `env: { compose, example }` in kay.config.ts has `kay check` compare it with the compose file and `.env.example` ([Server](server.md)).
74
+ - `kay env` lists what each library in `extensions` reads and which of it production requires, such as `AI_MODEL`; `envFiles: { compose, example }` in kay.config.ts has `kay check` compare it with the compose file and `.env.example` ([Server](server.md)).
74
75
 
75
76
  ### Run a job on a schedule
76
77
 
77
- `schedule` from `kay/server` is an Elysia plugin taking a cron or a length, and runs in the server's process:
78
+ `schedule` from `kay/server` is an Elysia plugin taking `{ cron }` or `{ every }` and the job, and runs in the server's process:
78
79
 
79
80
  ```ts
80
81
  import { Elysia } from 'elysia'
81
82
  import { pages, schedule } from 'kay/server'
82
83
 
83
84
  new Elysia()
84
- .use(schedule('30 2 * * MON', sendWeeklyReport, { timeZone: 'Europe/Paris' }))
85
- .use(schedule('30s', collectMetrics))
85
+ .use(schedule({ cron: '30 2 * * MON', timeZone: 'Europe/Paris' }, sendWeeklyReport))
86
+ .use(schedule({ every: '30s' }, collectMetrics))
86
87
  .use(await pages())
87
88
  ```
88
89
 
@@ -91,7 +92,7 @@ new Elysia()
91
92
  A `queue` runs its jobs in the background, after a restart or a deploy if need be, and an action enqueues one and goes on:
92
93
 
93
94
  ```ts
94
- // src/plugins/jobs.ts
95
+ // src/jobs/mail.ts: every queue, workflow and schedule a file of src/jobs exports is mounted
95
96
  import { queue } from 'kay/server'
96
97
 
97
98
  export const welcomeMails = queue(
@@ -99,8 +100,6 @@ export const welcomeMails = queue(
99
100
  async ({ to }: { to: string }) => sendWelcome(to),
100
101
  { attempts: 5, backoff: '30s' },
101
102
  )
102
-
103
- export default welcomeMails
104
103
  ```
105
104
 
106
105
  Then `await welcomeMails.enqueue({ to: email })` in an action, or `enqueue(payload, { delay: '1h' })` to run it later., and more in [Queues](queues.md).
@@ -113,8 +112,8 @@ Then `await welcomeMails.enqueue({ to: email })` in an action, or `enqueue(paylo
113
112
  - A server started with no NODE_ENV warns as it boots, as it then bundles its browser code at boot and Elysia answers a request refused before kay's own check, such as a response failing its schema, with the schema it failed: set NODE_ENV=production where the app is deployed.
114
113
  - With NODE_ENV=production, a server's first line, once it listens, says where it listens and what runs: `kay: listening on http://localhost:3000, kay 1.30.0 in production, 12 pages prerendered`.
115
114
  - Then every request kay or the app's routes registered after `.use(await pages())` answer is logged to stdout as one line: `GET /blog/hello 200 12ms AZnLe0vUe9qD0uXq9vLwZw`, the method, the path without its query string, which may carry tokens, the status, the milliseconds until the response was made, a streamed one's headers, and the request's id.
116
- - kay's own `/_kay/` routes, assets included (an extension's API modules served there, kayjs-cms's `/_kay/cms`, are logged), and the health route, wherever `health.path` puts it, are left out.
117
- - `true` in kay.config.ts's `observe.log` logs them outside production too, `false` never.
115
+ - kay's own `/_kay/` routes, assets included (an extension's API modules served there, kayjs-cms's `/_kay/cms`, are logged, and so is the MCP endpoint), and the health route, wherever `endpoints.health` puts it, are left out.
116
+ - `true` in kay.config.ts's `ops.observe.log` logs them outside production too, `false` never.
118
117
  - kay's own messages, an error it caught, a warning about the app, a shutdown notice, go out in any mode, as `kay: ` and the message, an error's source-mapped stack on the lines below.
119
118
  - `log` sets the format of both: `'json'` writes one JSON object per line for a log collector, on stdout for info and on stderr for warnings and errors, and a function receives each entry instead, typed `LogEntry` from `kay/server`:
120
119
  - a request, `{ type: 'request', time, level: 'info', method, path, status, duration, id }`;
@@ -126,20 +125,11 @@ Then `await welcomeMails.enqueue({ to: email })` in an action, or `enqueue(paylo
126
125
  - An error logged while answering a request is headed by the request, `kay: GET /blog/hello, request AZnLe0vUe9qD0uXq9vLwZw`, then its stack, so a line from a user or a log search finds both.
127
126
  - `requestId(request)` from `kay/server` gives it, in `onError` or a route, and a server span carries it as `kay.request.id` ([Tracing](tracing.md)).
128
127
 
129
- ### Metrics for a collector
130
-
131
- - `metrics: true` in kay.config.ts serves `/metrics` in the Prometheus text format, for Prometheus or any compatible collector (Grafana Alloy, the OpenTelemetry collector's Prometheus receiver): `metrics: { path: '/_internal/metrics' }` moves it. It is off by default, and a server run by `kay dev` or a static export serves none.
132
- - It holds `kay_http_requests_total{method,route,status}` and the histogram `kay_http_request_duration_seconds{method,route}`, `kay_queue_runs_total{queue,result}` (`ok`, `retried`, `failed`; a workflow is `workflow:<name>`), `kay_job_runs_total{schedule,result}` (`ok`, `failed`, `skipped` when another process held the lock), `kay_session_events_total{event}` (`created`, `destroyed`), `kay_file_events_total{event}` (`written`, `deleted`), `kay_cache_reads_total{result}` (`hit` or `miss` of `cached` and `cache`), `kay_live_connections`, `kay_process_resident_memory_bytes` and `kay_process_uptime_seconds`.
133
- - A page counts under its pattern, `/shop/:item`, an API route under its route, and a path nothing serves under `unmatched`, so a scan adds no series; at most 500 routes are kept, the rest read `other`. The scrape itself and the health route are not counted, nor a request an earlier hook answers (a redirect, a refusal by `proxy.key`), and a method no server knows reads `OTHER`.
134
- - It is never public by default: only a request that reached the socket from this machine or a private network (a collector in the same compose network, a sidecar) and carries no `X-Forwarded-*`, `X-Real-IP`, `Forwarded`, `Via` or `CF-Connecting-IP` header, nor the headers `proxy.header` and `proxy.key` name, is answered; every other gets 403, a trailing slash, a query or the `base` in the path included. Do not forward the path from the reverse proxy: one that adds none of those headers cannot be told from a collector.
135
- - With `KAY_METRICS_TOKEN` set, only a request with `Authorization: Bearer <token>` is answered, from any address, for a collector reaching the server across networks. With no token the boot always logs a warning, as any peer on a private network reads the metrics, and a proxy on this host that forwards the path unmarked reads as a collector. `kay routes` lists the route and `kay env` the variable.
136
- - `proxy.key` lets a request on this path past the key, as it does the health route, since the collector does not go through the proxy; the rules above still apply. An app file or page at `/metrics` keeps the path, and kay serves none there.
137
-
138
128
  ### Health and shutdown
139
129
 
140
130
  - `/_kay/health` answers `200 ok` while the server takes requests, for a load balancer or a container's health check.
141
- - `health: { path: '/up', check: async () => await db.ping() }` in kay.config.ts moves it and adds a check: one returning `false`, throwing, or taking over 5 s answers 503, the error logged.
142
- - `health: false` leaves the route out.
131
+ - `endpoints: { health: '/up' }` in kay.config.ts moves it, and `ops: { health: { check: async () => await db.ping() } }` adds a check: one returning `false`, throwing, or taking over 5 s answers 503, the error logged.
132
+ - `ops: { health: false }` leaves the route out.
143
133
  - An executable `kay build --compile` made checks a server it started, rather than starting one, when run as `./server --health`: it exits with 0 when the health route on `PORT`, 3000 by default, at `HOST` when it names an address and on loopback otherwise, answers 200, else 1, for a container image with no curl: `HEALTHCHECK CMD ["./server", "--health"]`.
144
134
  - On SIGTERM, SIGINT or SIGHUP, a server that listens stops taking connections, lets open requests finish, ends every open event stream (live values, presence, `stream()`) and, once no request is left, every websocket (close code 1001), so browsers reconnect to the next instance, then runs the app's `onStop` hooks, each given `serve.shutdownTimeout` at most, and exits with 0. A queue handler or schedule ignoring its signal is given 3 seconds (at most 40% of `serve.shutdownTimeout`), all of them together, then its job is handed back untouched, and the `store` config's `rooms` store is closed so a stopped replica leaves no member behind (a store given only to `rooms({ store })` is not).
145
135
  - New connections are refused from the signal on, so a load balancer stops sending any; a client on a connection kept alive gets 503 from the health route meanwhile.
@@ -149,11 +139,11 @@ Then `await welcomeMails.enqueue({ to: email })` in an action, or `enqueue(paylo
149
139
  ### Request timeouts
150
140
 
151
141
  - `serve: { timeout: '15s' }` in kay.config.ts holds every page, action, `api()` route and endpoint to that time; none by default. A hung database call otherwise keeps its request, and the connection, until the client leaves.
152
- - Past it a page answers 504 through the nearest `_error.kay` (`ctx.error.status` is 504), an action call fails with 504 and the message `kay.action.timeout`, an API route or endpoint answers `504 Gateway Timeout` as text. It is logged and handed to `observe.onError` as a `RequestTimeoutError` from `kay/server`.
142
+ - Past it a page answers 504 through the nearest `_error.kay` (`ctx.error.status` is 504), an action call fails with 504 and the message `kay.action.timeout`, an API route or endpoint answers `504 Gateway Timeout` as text. It is logged and handed to `onError` as a `RequestTimeoutError` from `kay/server`.
153
143
  - `ctx.signal` is on the page, guard, endpoint and action contexts, and aborts at the timeout and when the client leaves; pass it to `fetch`, a database call or anything that takes a signal, so the work stops with the request. An `api()` route reads it as `request.signal`, which aborts at the timeout too (only under a timeout).
154
144
  - A page sets its own in `export const page = { timeout: '30s' }` (the innermost layout or page wins), an `api({ timeout })` module and an action's options likewise, one route of an API module as `detail: { timeout }`; `false` is none.
155
145
  - The clock counts from the request's arrival. Work that cannot be stopped, a handler ignoring the signal, goes on after the 504. A streamed page whose headers went out is cut at the time: the body ends with an error, the status stays 200, and the timeout is reported. An API route that returns a stream or a generator is not cut, nor an event stream.
156
- - A job has no request, so no `ctx.signal`: a `schedule` takes its own `timeout`, and a queue handler gets an `AbortSignal` that aborts at `lostAfter` (see [Queues](queues.md)).
146
+ - A job has no request, so no `ctx.signal`: a job's `ctx.signal` aborts at its `timeout` and as the server stops (see [Queues](queues.md)).
157
147
 
158
148
  ### A deploy under open tabs
159
149
 
@@ -170,17 +160,17 @@ Then `await welcomeMails.enqueue({ to: email })` in an action, or `enqueue(paylo
170
160
 
171
161
  ### Background jobs
172
162
 
173
- - `schedule(cron, job)` and `background(work)` from `kay/server` are Elysia plugins, so a job runs in the server's process, from the server listening to its stopping, once across the processes sharing the job store in production, else once per process:
163
+ - `schedule({ cron }, job)` and `background(work)` from `kay/server` are Elysia plugins, so a job runs in the server's process, from the server listening to its stopping, once across the processes sharing the job store in production, else once per process:
174
164
 
175
165
  ```ts
176
166
  import { Elysia } from 'elysia'
177
167
  import { background, pages, schedule } from 'kay/server'
178
168
 
179
169
  new Elysia()
180
- .use(schedule('@hourly', async () => purgeExpiredCarts()))
181
- .use(schedule('30 2 * * MON', sendWeeklyReport, { timeZone: 'Europe/Paris' }))
182
- .use(schedule('30s', collectMetrics))
183
- .use(background(async (signal) => {
170
+ .use(schedule({ cron: '@hourly' }, async () => purgeExpiredCarts()))
171
+ .use(schedule({ cron: '30 2 * * MON', timeZone: 'Europe/Paris' }, sendWeeklyReport))
172
+ .use(schedule({ every: '30s' }, collectMetrics))
173
+ .use(background(async (_, { signal }) => {
184
174
  while (!signal.aborted)
185
175
  await handleNextEmail(signal)
186
176
  }))
@@ -191,7 +181,7 @@ new Elysia()
191
181
  - A literal one with another number of fields, an unknown nickname or a day its month never has, `0 0 30 2 *`, is a type error; a computed one it cannot read, or that never comes, fails the boot.
192
182
  - Runs never overlap: the next is planned once the last settles.
193
183
  - A run that throws is logged and the next one comes as planned.
194
- - `schedule('30s', job)` runs every so long in place of a cron, at the multiples of that length since the epoch, `'1h'` on the hour and `'1d'` at UTC midnight, so it takes no `timeZone`; a run outlasting its length skips the runs it overlaps.
184
+ - `schedule({ every: '30s' }, job)` runs every so long in place of a cron, at the multiples of that length since the epoch, `'1h'` on the hour and `'1d'` at UTC midnight, so it takes no `timeZone`; a run outlasting its length skips the runs it overlaps.
195
185
  - A length that is not positive is a type error, or fails the boot when computed.
196
186
  - `lock`, `store`, the overlap and the shutdown work as for a cron. `lock` is not a `key` of `enqueue()` or `start()`: it is taken afresh for each time the schedule falls due, one process runs it, and it takes `false`, where a `key` makes a repeated start a no-op while it lives.
197
187
  - `background` starts `work` with the server, for a queue consumer or anything else that runs the whole time.
@@ -200,11 +190,11 @@ new Elysia()
200
190
  - Stopping on a signal waits for a scheduled run in progress, and for every `onStop` hook the app registers, async ones included, in turn, the `onStop` key of `kay.config.ts` after the plugins' own.
201
191
  - `shutdown(app)` from `kay/server` stops a server the same way, as a test does; Elysia's own `app.stop()` does not wait for the hooks.
202
192
  - A production server (`NODE_ENV=production`) locks every schedule by default, named `auto:<schedule>:<hash of the job's source>` (a twin with the same schedule and source takes `#2` by start order, which every process of one app shares), so each run happens once across processes sharing the store; a dev or test server runs each schedule in every process. `lock: false` opts out. If the store cannot give that default lock, one warning is logged and the run goes on unlocked, once per process; a `lock` the app named skips the run instead.
203
- - A run still going after `timeout` (`'10m'` by default, `false` for none) is logged as failed and left, so it no longer blocks the next run; a stop aborts the signal and waits at most 3 s (less with a short `serve.shutdownTimeout`) for a run ignoring it, without reporting it. The job takes an `AbortSignal` that aborts at the timeout and as the server stops. Every job is called with the signal, so one with an optional first parameter gets it. The lock name hashes the job's source, so during a rolling deploy old and new builds with changed jobs both run.
204
- - `schedule(cron, [jobA, jobB])` gives each job of the list that schedule, and `schedule({ '* * * * *': [jobA, jobB], '@hourly': jobC, '30s': jobD }, options)` several schedules at once, each key checked as a literal schedule is and `timeZone` read by the crons alone, all in one plugin: with several jobs, `lock` names each `<lock>:<its schedule>:<its place in that schedule's list>`, `report:@hourly:0`.
205
- - `schedule(cron, job, { boot: true })` runs the jobs once as the server starts too, the first scheduled run waiting for it and a stop too, so a job needing a first run does not start itself by hand; processes starting within the same minute (the schedule's length if shorter) run it once, two either side of the boundary possibly twice (it takes the lock `<lock>:boot` for a slot of a minute at most, a skipped one is logged), while a restart minutes later runs it again, each restart of `kay dev`, `kay render` and `--verify` included.
206
- - `schedule(cron, job, { lock: 'weekly-report' })` runs each time once across every process sharing the job store ([Queues](queues.md)), the first to reach it taking it; `store` names another store than the default one.
193
+ - A run still going after `timeout` (`'10m'` by default, `false` for none) is logged as failed and left, so it no longer blocks the next run; a stop aborts the signal and waits at most 3 s (less with a short `serve.shutdownTimeout`) for a run ignoring it, without reporting it. A job is `(run, ctx)`, as every job is `(input, ctx)`: `run` is `{ schedule, boot }`, and `ctx.signal` aborts at the timeout and as the server stops, beside `ctx.job`, `ctx.log` and `ctx.locale`; `background(work)` gets `(undefined, ctx)`. The lock name hashes the job's source, so during a rolling deploy old and new builds with changed jobs both run.
194
+ - `schedule({ cron }, [jobA, jobB])` gives each job of the list that schedule, and `schedule({ '* * * * *': [jobA, jobB], '@hourly': jobC, '30s': jobD }, options)` several schedules at once, each key checked as a literal schedule is and `timeZone` read by the crons alone, all in one plugin: with several jobs, `lock` names each `<lock>:<its schedule>:<its place in that schedule's list>`, `report:@hourly:0`.
195
+ - `schedule({ cron, boot: true }, job)` runs the jobs once as the server starts too, the first scheduled run waiting for it and a stop too, so a job needing a first run does not start itself by hand; processes starting within the same minute (the schedule's length if shorter) run it once, two either side of the boundary possibly twice (it takes the lock `<lock>:boot` for a slot of a minute at most, a skipped one is logged), while a restart minutes later runs it again, each restart of `kay dev`, `kay render` and `--verify` included.
196
+ - `schedule({ cron, lock: 'weekly-report' }, job)` runs each time once across every process sharing the job store ([Queues](queues.md)), the first to reach it taking it; `store` names another store than the default one.
207
197
  - The upkeep kay and its libraries run on a timer (expired sessions and notifications on Postgres, kayjs-auth's prune, kayjs-mail's list sweep, kayjs-cms's history sweep) goes through the same lock, signal and stop handling as a schedule, so with several processes behind one database each pass runs once; it counts in `kay_job_runs_total` as `maintenance:<name>`, shows under Maintenance in the dev tool's Jobs tab, ends with the server, and a test's `runJobs()` waits for a pass going. `KAY_LOCK_SCHEDULES=false` turns its lock off as it does a schedule's. Upkeep of a file on one host (the sqlite session and notification stores) and the caches each process keeps (image variants, loader watchers) stay per process.
208
- - `KAY_LOCK_SCHEDULES=false` makes `lock: false` the default of every schedule, for an app running one process; a `lock` it names still locks. `schedule(..., { enabled: false })` and `background(work, { enabled: false })` add nothing, so `enabled: env.ZIGBEE_URL !== undefined` switches a job on its setting with no conditional plugin; a job's first parameter must accept an `AbortSignal`, which the types enforce.
198
+ - `KAY_LOCK_SCHEDULES=false` makes `lock: false` the default of every schedule, for an app running one process; a `lock` it names still locks. `enabled: false` in the options of a schedule, `background`, `queue` or `workflow` starts nothing, so `enabled: env.ZIGBEE_URL !== undefined` switches a job on its setting with no conditional plugin.
209
199
 
210
200
  The queue, its stores and its retries are in [Queues](queues.md).
@@ -46,7 +46,7 @@ kay generate resource post title:string body:text published:boolean
46
46
  - `server`, the default, is an Elysia server, with a `Dockerfile` and `compose.prod.yaml` running the executable `bun run compile` makes; the compose requires `SITE_URL`, which `.env.example` lists.
47
47
  - `site` is a static site whose `bun run build` runs `kay build --static`, with a Forgejo Pages workflow publishing `dist` to the `gitea-pages` branch under `/<owner>/<repo>`, its `SITE_URL` the forge's own address until a repository variable named `SITE_URL` gives the host the Forgejo instance publishes Pages on (`--forge github`: a workflow deploying `dist` with GitHub Pages, `SITE_URL` and `SITE_BASE` read from the repository), and a `Dockerfile` serving it with `nginxinc/nginx-unprivileged` on port 8080 instead.
48
48
  - `app` is the server with kayjs-auth as `kay add auth` writes it (`auth({ name })` and `ui()` in `kay.config.ts`, a root `src/routes/_guard.ts` exporting kayjs-auth's `authGuard()` to put every page behind sign-in, and no `src/auth.ts`), an API module and an island over its websocket, its session secret written to a `.env` git ignores, `.env.test` holding a test-only secret, and `.env.example` naming what production sets (`SESSION_SECRET`, `SITE_URL`);
49
- - The default `app` needs Bun alone: kayjs-auth keeps its users in `data/auth.sqlite` and creates its tables when the app starts, `data` is ignored by git and docker, and `compose.prod.yaml` bind-mounts `data-prod`, a git- and docker-ignored folder to create owned by `nobody` (uid 65534), the user the image runs as, at `/app/data`, with no database service and no migration;
49
+ - The default `app` needs Bun alone: kayjs-auth keeps its users in `data/app.sqlite` and creates its tables when the app starts, `data` is ignored by git and docker, and `compose.prod.yaml` bind-mounts `data-prod`, a git- and docker-ignored folder to create owned by `nobody` (uid 65534), the user the image runs as, at `/app/data`, with no database service and no migration;
50
50
  - `--with postgres` (with `auth`, as in `--template app --with postgres`) swaps SQLite for Postgres: `src/db/tables.ts` lists `...authTables` among the tables, which `src/db/index.ts` builds `db` over and `pg-orm.config.ts` imports on their own, so the test preload points `DATABASE_URL` at its copy before anything builds `db`, `docker compose up -d --wait` starts the database `compose.dev.yaml` describes (on a port of its own per app name, its data in the git-ignored `data/postgres`), `bun run db:generate` writes the first migration for kayjs-auth's tables as the installed version declares them (and the next ones for yours), `bun run db:migrate` applies `migrations/`, its `bun run test` gives each test file a copy of the migrated database (see [Testing](testing.md)), its workflow runs Postgres as a service, and `compose.prod.yaml` runs the database (its data in `data-prod/postgres`, to create owned by the image's postgres uid 70) and a one-shot service applying the migrations before the app. Two Postgres roles split the work: the owner (`POSTGRES_USER`, connected by `MIGRATE_DATABASE_URL`, which `pg-orm.config.ts` reads before `DATABASE_URL`) changes the schema, and `app_rw` (the app's `DATABASE_URL`, password `APP_DB_PASSWORD`) reads and writes rows and cannot drop, alter or create anything. The database image creates `app_rw` from `db/roles.sh` when it first creates the database, with default privileges on tables, sequences and schemas, so a table a later migration creates needs no `GRANT`. An existing database runs `db/roles.sh` once, see [Upgrading](upgrading.md);
51
51
  - Every server preset's compose publishes the app on 127.0.0.1 alone, for a reverse proxy serving it over HTTPS, and its `kay.config.ts` sets `proxy: true` so rate limits count the visitor and not the proxy, its images and workflow use the Bun `kay new` ran under, and `.env` is ignored by git and docker and written readable by its owner alone;
52
52
  - `--kay` sets the `kay` dependency, by default `npm:@kayjs/kay@~<its version>`, or a packed copy when run from a checkout of kay.
@@ -62,6 +62,6 @@ kay generate resource post title:string body:text published:boolean
62
62
  - What it writes passes `kay check` and the lint. `--dry-run` lists the files and writes none, and `--format json` prints `{ kind, name, written, dryRun }`.
63
63
  - `kay add <features> [dir] [--no-install] [--dry-run] [--format text|json] [--quiet]`:
64
64
  - Applies `kay new` features, comma-separated, to the project in `dir` (the current directory by default): the files and edits `kay new --with` would have made, then `bun install`.
65
- - The features the project holds are read off its files. A feature missing what it needs is refused naming the command that adds them together (`kay add server,ws`); `kay add postgres` on a project without kayjs-auth plans it too, `kay add auth,postgres` writes both in one run, and `postgres` over an app whose `data/auth.db` exists stops there, as that file holds the users.
65
+ - The features the project holds are read off its files. A feature missing what it needs is refused naming the command that adds them together (`kay add server,ws`); `kay add postgres` on a project without kayjs-auth plans it too, `kay add auth,postgres` writes both in one run, and `postgres` over an app whose `data/app.sqlite`, `data/auth.sqlite` or `data/auth.db` exists stops there, as that file holds the users.
66
66
  - It writes only when every file has the shape `kay new` writes: a file both feature sets write differently (`_layout.kay`, `bunfig.toml`, `kay.config.ts`) is replaced while it is still what `kay new` wrote, `package.json` gets the scripts and dependencies it lacks (a script is replaced only while it is still the generated one), `.gitignore`, `.dockerignore` and `.env` get the lines or keys they lack, and `AGENTS.md` is left once edited; a deleted file is not written back and is named in the output. The CI workflow follows the `origin` remote (`.github` for GitHub, `.forgejo` otherwise), else the folder the project has, and the runner label is the one its workflow already runs on. Any other file, or a file that exists with other content, stops it with `kay add: nothing was written` and the lines to remove (`-`) and add (`+`) by hand.
67
67
  - `ai`, `mail`, `cms`, `ui` and `auth` are features of kay's libraries (`auth` is kayjs-auth, which `kay new --with auth` writes the same files for; `kay new --with ai,mail,cms` runs this same step after scaffolding): it adds `@kayjs/ai`, `@kayjs/mail`, `@kayjs/cms`, `@kayjs/ui` or `@kayjs/auth` (the last two with `@iconify-json/tabler`, kayjs-auth with `@kaynooo/pg-orm` and kayjs-ui) at kay's own minor, then writes what the package's `add` export says (`{ description, files?, edits?, env?, example?, ignore?, extension?: { import, expression }, notes? }`, or a function of the project returning it) and adds the extension to `extensions` in `kay.config.ts`, which needs a plain `defineConfig({ ... })`. `ui` needs `tailwind` and `auth` needs `server` and `tailwind`, refused like a core feature; `kay add ui` writes only `ui()`, or in a static site the `@kayjs/ui/theme.css` import in `src/app.css` (see [Extensions](component-libraries.md#extensions)), and `kay add auth` writes `auth({ name })` in `kay.config.ts` (no `src/auth.ts`: the mailer of `src/mail.ts`, themed when `mail()` is registered, is found by `auth()`; over the app's pg-orm `Database` it adds `store: async () => pgAuth(...)` and `...authTables` to its `tables`, else users live in SQLite, `AUTH_DATABASE_URL` in `.env.example`; `.gitignore` is created when absent and `data` is added unless `/data` or `data/` is there), `src/routes/_guard.ts` exporting `authGuard()` from kayjs-auth to guard every page, `ui()`, and `KAY_SECRET` and `SITE_URL` in `.env.example`. The import goes where the app's `perfectionist/sort-imports` puts it (groups, then natural order), so a config with sorted imports passes `kay lint` with no fixer run.
package/llms/project.md CHANGED
@@ -52,7 +52,7 @@ kay migrate astro ../my-astro-site --outdir ../my-kay-site
52
52
  ### Project setup
53
53
 
54
54
  - kay is published as `@kayjs/kay` to npm, and as a mirror to the Forgejo registry at `https://git.kaynooo.fr/api/packages/kaynooo/npm/`, its libraries as `@kayjs/ui`, `@kayjs/auth`, `@kayjs/mail`, `@kayjs/cms` and `@kayjs/ai` (`@kaynooo/kayjs*` up to 1.103, which `kay upgrade` moves an app off), and installed under the name its imports use: `"kay": "npm:@kayjs/kay@~<version>"` in `package.json`, a tilde since a minor release may break what the one before it took, each break listed in [Upgrading](upgrading.md) and every one `kay check` can recognise a `deprecated` lint with a fix, which `kay upgrade` applies as it moves the app, and a major is a rewrite. Every package a project installs, pg-orm and eslint included, is on npm, so a project carries no `.npmrc` and Bun needs no registry setup.
55
- - `bunx -p @kayjs/kay kay new my-app` writes a project that, after `cd my-app && bun install`, checks, builds and runs (`bun run dev`), both of those included: this setup, a layout, a page, a `_404.kay` and islands, or only what is picked of them (see [Commands](#commands) for the presets and features).
55
+ - `bunx -p @kayjs/kay kay new my-app` writes a project that, after `cd my-app && bun install`, checks, builds and runs (`bun run dev`), both of those included: this setup, a layout, a page, a `_404.kay` and islands, or only what is picked of them (see [Commands](commands.md#commands) for the presets and features).
56
56
 
57
57
  - kay runs on Bun 1.4.4 or later, as its `engines` says: the CLI and `pages()` refuse an older one, naming its version, its path and the fix, `bun update bun` when it is the project's npm `bun` package, which a plugin's peer dependency installs and package scripts run ahead of the system Bun.
58
58
 
@@ -75,10 +75,10 @@ export const app = new Elysia()
75
75
  - An entry other than `src/server.ts` is named once, as `entry: 'src/main.ts'` in `kay.config.ts`, which `kay dev`, `start`, `render`, `check`, `build` and `build --compile` all read; `--entry` on a command wins over it, `kay build --entry` also pointing its check step at that entry.
76
76
  - An entry `kay check` does not read registers it instead: `declare module 'kay' { interface Register { app: typeof app } }`.
77
77
 
78
- - A key kay does not know in `kay.config.ts`, at its top or in any option bag (`security`, `i18n`, `images`, `markdown`, `jobs`, `cors`, `links` and the rest), stops every command with the nearest known name (`` `trailingslash`, did you mean `trailingSlash`? ``), and `defineConfig` types it as an error, since a mistyped key would otherwise leave kay's default in place with nothing said.
79
- - A value that is not the kind its key takes (`trailingSlash: 'sometimes'`, `compress: 7`, `lang: 5`, a `defaultLocale` outside the `locales`) stops them the same way, once, as the config loads: `` `trailingSlash` is "sometimes", expected one of "never", "always" or "ignore" ``, the path through bags and lists, with the nearest allowed value for a mistyped text. The options of `pages()` and `testSite()` are checked as they merge, and an extension's `config` as it loads.
78
+ - A key kay does not know in `kay.config.ts`, at its top or in any option bag (`security`, `i18n`, `assets`, `markdown`, `ops`, `cors`, `client` and the rest), stops every command with the nearest known name (`` `trailingslash`, did you mean `trailingSlash`? ``), and `defineConfig` types it as an error, since a mistyped key would otherwise leave kay's default in place with nothing said.
79
+ - A value that is not the kind its key takes (`trailingSlash: 'sometimes'`, `compress: 7`, `lang: 5`, a `default` locale outside the `locales`) stops them the same way, once, as the config loads: `` `trailingSlash` is "sometimes", expected one of "never", "always" or "ignore" ``, the path through bags and lists, with the nearest allowed value for a mistyped text. The options of `pages()` and `testSite()` are checked as they merge, and an extension's `config` as it loads.
80
80
  - `auth()`, `cms()`, `mail()` and `ai()` refuse an option they do not take with the nearest one, as `kay.config.ts` does; a library adds the same to its own factory with `checkOptionKeys` from `kay/library`, over a `Record<keyof ItsOptions, true>`.
81
- - Project settings live in an optional `kay.config.ts` at the root, read by `pages()` and every command; options passed to `pages()` or `testSite()` win over it key by key, an `undefined` option leaving the file's value, and in an executable `kay build --compile` wrote, the root, routes and public directory it was built with win over both.
81
+ - Project settings live in an optional `kay.config.ts` at the root, read by `pages()` and every command; the `config` passed to `pages({ config })` or `testSite({ config })` wins over it key by key, an `undefined` key leaving the file's value (the config's keys written beside `root` work until 1.108, `deprecated-pages-options` rewrites them), and in an executable `kay build --compile` wrote, the root, routes and public directory it was built with win over both.
82
82
  - It must `export default` its config, or the command fails with a message saying so.
83
83
 
84
84
  ```ts
@@ -95,17 +95,23 @@ export default defineConfig({
95
95
 
96
96
  - A directory inside the project holding a `kay.config.ts` of its own, such as an example app or a documentation site, is another project: its components are never the outer one's islands, and it checks and builds from its own root.
97
97
 
98
- - `proxy: false` is none, `proxy: true` is one proxy in front, `proxy: 2` two, `{ header }` a header the proxy sets, `{ key: 'x-upstream-key', open }` refuses requests without the shared key ([Production](proxy-and-security.md#behind-a-proxy)).
98
+ - A feature key is `false` for off, `true` for its defaults or an object of options: `robots`, `sitemap`, `assets.favicon`, `security`, `ops.health`, `preview`, `client.offline`, `ops.metrics`, `openapi`, `mcp`, `proxy`, `assets.images.formats.avif` and the rate limits. `defineConfig` refuses a key it does not know in any option bag, as a type error.
99
+ - A list that may come from a CMS or a database is the list, or a function returning it (or a promise of it): `cors.origins`, `security.hosts`, `assets.images.remote.hosts`, `proxy.trusted`, `redirects`, `robots.disallow`, `robots.allow` and `i18n.paths`. Kay calls it once as the config loads, `kay dev` again after a change to the file.
100
+ - Keys are grouped by concern: `client` (what the browser is given: `links`, `offline`, `search`, ...), `assets` (`images`, `fonts`, `favicon`, `manifest`, `publicCache`), `ops` (`observe`, `health`, `metrics`, `jobs`), `endpoints` (where the app's API and each feature are served) and `i18n: { locales, default, mode }`, where `mode` is `'prefix'` (the default locale unprefixed), `'always'` or `{ domains }`. The old top-level keys work until 1.108 (`deprecated-client-keys`, `deprecated-config-groups`, `deprecated-i18n-keys` rewrite them).
101
+ - `endpoints` holds every route the config moves, in one place: `{ api: '/api', openapi: '/api/openapi.json', mcp: '/_kay/mcp', health: '/_kay/health', metrics: '/_kay/metrics', jobs: '/_kay/jobs' }`, each an absolute path of plain segments with no trailing slash, and `api`, `openapi` and `mcp` none under `/_kay` when you set them. Every default is under `/_kay` but the app's API (and its OpenAPI document and reference page, which follow it). The reference page is `openapi: { reference: true }` or `{ reference: { path } }`. `serve.apiPrefix` and the `path` of `openapi`, `mcp`, `health`, `metrics` and `jobs`, and `openapi.referencePath`, work until 1.108 (`deprecated-route-keys` rewrites them). An app that did not move `mcp` or `metrics` keeps `/mcp` (a 308 to the new path) and `/metrics` (answered as well) until 1.108.
102
+ - `assets.images` is `{ remote: { hosts, maxSize, timeout }, formats: { quality, webp, avif }, limits: { variants, queue }, rateLimit, ttl, widths, ... }`; `remote: [...]` is hosts alone.
103
+ - A duration key is `ttl` for how long data lives, `timeout` for how long to wait and `maxAge` only for the HTTP or cookie attribute of that name.
104
+ - `proxy: false` is none, `proxy: true` is one proxy in front, `proxy: { hops: 2 }` two, `{ header }` a header the proxy sets, `{ key: { header: 'x-upstream-key' }, open }` refuses requests without the shared key ([Production](proxy-and-security.md#behind-a-proxy)).
99
105
  - `extensions` lists what libraries add to the app, one value each, such as `extensions: [auth()]`: pages laid over `src/routes` and API modules over `src/api` under a prefix, message catalogs under `src/messages`, an app file at the same path or an app key winning, config laid under the app's, such as Bun plugins or head tags (see [Extensions](component-libraries.md#extensions)), and a hook rewriting each prerendered page (see [Page hooks](prerendering.md#page-hooks)).
100
106
 
101
107
  - `minify` is on for `kay build` unless set to `false`, and off for `kay dev` and a server bundling at boot unless set to `true`.
102
108
  - `lang`, the `<html lang>` of every page when `i18n` is not set, defaults to `en`.
103
109
  - `timeZone: 'Europe/Paris'` is the zone `formatDate` and message dates write in, on the server and in islands alike, instead of the server's and the visitor's ([Locales](locales.md)).
104
110
  - `typography: false` leaves a French page's spaces before `: ; ! ?` and inside `« »` as typed instead of making them non-breaking ([Locales](locales.md#french-typography)).
105
- - `links: { outside: 'same-tab' }` keeps a link to another origin in the same tab, where it opens in a new one by default ([Navigation](navigation.md#navigation)); `links: { schemes: ['webcal'] }` lets a bound URL keep a scheme beyond the web's, mail, phone and sms ([Security](proxy-and-security.md)).
111
+ - `client.links: { outside: 'same-tab' }` keeps a link to another origin in the same tab, where it opens in a new one by default ([Navigation](navigation.md#navigation)); `client.links: { schemes: ['webcal'] }` lets a bound URL keep a scheme beyond the web's, mail, phone and sms ([Security](proxy-and-security.md)).
106
112
 
107
113
  - A page without kay's script carries speculation rules, and one shipping it a `kay-prefetch` meta naming the setting alone, as the swap prefetches its links itself (see [Navigation](navigation.md#navigation)): Chromium, or the swap, prefetches the page a link points at once it is hovered (`prefetch: 'moderate'`), on press with `'conservative'`, as soon as it can with `'eager'` (every link on a page without the script, the links scrolled into view, three at a time, on one with it), never with `false`; `data-prefetch="eager|moderate|conservative"` on a link or a container sets its own level where the script runs, `data-prefetch="false"` opts out everywhere; a page with no `data-prefetch` in it carries the shorter rules without the selector that follows the nearest one.
108
- - Links under `/_kay/` or `/api/`, with `download` or with `rel="nofollow"` are never prefetched; any other link that changes something on GET, such as a logout, takes `data-no-prefetch`.
114
+ - Links under `/_kay/` or `/api/`, with `download` or with `rel="nofollow"` are never prefetched; any other link that changes something on GET, such as a logout, takes `data-prefetch="false"`.
109
115
  - A stylesheet holding `@view-transition { navigation: auto; }` animates from page to page where the browser supports it, swaps included; `kay new` writes one inside `@media (prefers-reduced-motion: no-preference)`.
110
116
 
111
117
  - `pages()` also takes `root`, `dev` (default: `NODE_ENV` is `development`) and `prebuilt` (default: `NODE_ENV` is `production`), which serves what `kay build` wrote instead of bundling at boot.
@@ -124,41 +130,12 @@ export default defineConfig({
124
130
 
125
131
  - `kay/html`, `kay/dom`, `kay/dom-loop`, `kay/dom-await`, `kay/dom-try`, `kay/dom-spread`, `kay/dom-image`, `kay/pending`, `kay/i18n-links`, `kay/island`, `kay/await`, `kay/client`, `kay/arrival`, `kay/internal`, `kay/internal/title` and `kay/internal/server` are what compiled `.kay` files and kay's generated entries import, and `kay/jsx-runtime` is where TypeScript finds the JSX types of `jsxImportSource: "kay"`: the compiler's output contract rather than API, free to change in any release, never imported by an app. The root `kay` export also holds the compile-time types behind the generated shadow types, none of them for an app to name: `BindableMark`, `IslandBrand`, `HandedPart`, `HandsPart`, `HandedSignal`, `UnresolvedParameter`, `WidenedProps`, `CheckedHref`, `CheckedHtml`, `CheckedComputedHtml`, `BoundProp`, `BoundValue`, `PlainIslandProp`, `FunctionProp`, `Inferred`, `TemplateHelpers`, `TemplateValues` and `Truthy`, free to change in any release too.
126
132
  - A few entries also hold plumbing no page tells an app to call, free to change in any release: the paths, providers and tracker tags of `kay/analytics` (`ANALYTICS_PATH`, `ANALYTICS_SCRIPT_PATH`, `ANALYTICS_PROVIDERS`, `CUSTOM_COLLECT_PATH`, `CUSTOM_SCRIPT_PATH`, `NOTICE_SCRIPT_PATH`, `INTEGRITY`, `TRACKER_TAGS`, `isGated`, `LazyGuard`), the collection marker, publish times and cache key of `kay/content`, and the preview session reader of `kay/server`.
127
- - A name has one home: an entry beside a package's root exists for browser safety (`@kayjs/auth/rules`, `@kayjs/cms/form`, which an island imports without the server) and the root does not repeat its names, apart from `mount` (`kay`, `kay/mount`) and `sqliteCache` (`kay/server`, `kay/cache`).
133
+ - A name has one home: an entry beside a package's root exists for browser safety (`@kayjs/auth/rules`, `@kayjs/cms/form`, which an island imports without the server) and the root does not repeat its names. The copies in `kay/mount` and `kay/server` that 1.105 moved (`mount`, `s`, `RateLimit`, `sqliteCache`) stay as deprecated shims until 1.108.
128
134
  - `kay/library` is what kay's own libraries (kayjs-auth, kayjs-ui, kayjs-mail, kayjs-cms, kayjs-ai) share with kay for their server code, such as the sanitizer's lists, sealing, locale matching, escaping and the user a library names for a request (`nameUser(request, () => id)`, read back by `userOf(request)`: kayjs-auth names the signed-in user and kayjs-ai counts them) and `configError(option, value, takes)`, the `config-invalid` `KayError` a library throws for a setting it refuses at boot, so neither keeps a copy: not API either, free to change with any minor, never imported by an app. The libraries are released in lockstep with kay, each one's peer range on kay's minor, so the same holds for what a library imports from it.
129
135
 
130
136
  ### Reserved paths
131
137
 
132
- - Naming rule: a file kay reads for one thing is singular (`server.ts`, `auth.ts`, `mail.ts`, `ui.ts`, `context.ts`, `env.ts`, `theme.ts`); a folder with one file per page, plugin, template, matcher or catalog is plural (`routes/`, `plugins/`, `mails/`, `messages/`, `params/`); a mass noun or acronym stays as is (`api/`, `content/`, `db/`); a file inside a plural folder is named after what it holds (`plugins/jobs.ts`). A route is `/_kay/<noun>` for an endpoint and `/_kay/<nouns>/` for files; the image resizer shares its variants' prefix, `/_kay/images` and `/_kay/images/<file>`.
138
+ - Naming rule: a file kay reads for one thing is singular (`server.ts`, `auth.ts`, `mail.ts`, `ui.ts`, `context.ts`, `env.ts`, `theme.ts`); a folder with one file per page, plugin, template, matcher or catalog is plural (`routes/`, `plugins/`, `mails/`, `messages/`, `params/`); a mass noun or acronym stays as is (`api/`, `content/`, `db/`); a file inside a plural folder is named after what it holds (`plugins/metrics.ts`). A route is `/_kay/<noun>` for an endpoint and `/_kay/<nouns>/` for files; the image resizer shares its variants' prefix, `/_kay/images` and `/_kay/images/<file>`.
133
139
  - At the root: `kay.config.ts`, `public/` (served as is), `data/` (default SQLite and file stores, ignored by git and docker).
134
- - Under `src/`: `routes/` (pages, layouts, endpoints, `_guard.ts`), `api/`, `plugins/` (server plugins; `plugins/jobs.ts` is the one home of queues, workflows and schedules), `messages/<locale>.ts`, `params/<name>.ts`, `content/` with `content.config.ts`, `mails/<name>.kay` with `<name>.preview.ts` beside it and `mail.ts` for the mailer, `db/index.ts` and `tables.ts`, `server.ts`, `auth.ts`, `ui.ts`, `context.ts`, `env.ts`, `theme.ts`, `app.css`, `logo.svg` (the card logo, where `card.logo` names it).
135
- - Under `/_kay/`: `assets/` (browser build, imported files), `images` and `images/` (resizer, variants), `card`, `files/`, `action/`, `live`, `health`, `jobs` (with `jobs: { guard }`), `error`, `csp`, `vitals`, `analytics`, `push`, `search.json` and `search/`, `preview`, `draft`, `env.js`.
136
-
137
- ### Commands
138
-
139
- - `kay new`, `kay add` and `kay generate` are in [Scaffold with kay new and kay add](project-new-and-add.md).
140
-
141
- - The other commands: `kay dev` is in [The dev server](dev-server.md), `kay build` and `kay start` in [Building and starting](build-and-start.md), and `kay check`, `kay render`, `kay screenshot`, `kay a11y`, `kay routes`, `kay env`, `kay doctor`, `kay completion`, `kay i18n`, `kay upgrade`, `kay explain`, `kay fmt`, `kay lint`, `kay types`, `kay lsp`, `kay mcp` and `kay docs` in [Check, inspect and tool commands](check-and-tools.md).
142
- - `kay migrate astro [dir] [--outdir <dir>] [--dry-run] [--format text|json] [--quiet]`:
143
- - Translate an Astro project's `.astro` files into `.kay` ones, `src/pages` into `src/routes` (`404` as `_404`, `500` as `_error`), components and layouts kept in their folder with kebab-case names and the imports of them rewritten, and `src/content.config.ts` into kay's, its zod schemas written in `s`.
144
- - The frontmatter becomes the fence, a page's `--- server` with `Astro.url`, `params`, `cookies` and `redirect` read from `ctx`, `Astro.props` becomes `props<Props>()`, and the markup the indented template: static classes as the `.class` shorthand, `class:list` as `class`, `&&`, ternaries and `.map` as `if` and `for`, slots as `slot` and `@name` blocks, `client:idle` and `client:visible` as `hydrate`, `set:html` as `innerHTML` through `trustHtml`, a layout's `head` as a `head` block.
145
- - It writes into the project, or into `--outdir`, never over a file that exists, formats what it writes, and lists what it could not translate at its line in the Astro file: a script Astro bundles, an `await` or `Astro.url` in a component, an endpoint, markup written another way, each commented out under a `// kay migrate:` line where it stays in the code, and Tailwind 3, as kay builds with Tailwind 4.
146
- - An `--outdir` directory with no `package.json` gets the kay project around the pages, as `kay new` writes it without its home page, layout and stylesheet: a `package.json` with kay's scripts and the Astro project's packages, Astro's own left out, a `kay.config.ts` with the `site` and `base` of the Astro config and the layout's `<html lang>`, without `seo` defaults since the pages write their own head, a `tsconfig.json` keeping its `paths`, a server entry when the Astro config renders on demand (`output: 'server'` or an `adapter`), a static site otherwise, and Tailwind, ESLint, the Forgejo workflow and the Dockerfile when the Astro project had them;
147
- - Its other files under `src` and `public` are copied as they are, but for `src/env.d.ts`, which only Astro reads, those beside the pages moving with them into `src/routes`, where kay routes only `.kay` and endpoint files.
148
- - Beyond the `.astro` files: a script or markup after the layout's `</html>` is kept, `<Icon name="set:name" />` from astro-icon becomes the icon imported from `~icons/set/name`, a `?raw` import takes `with { type: 'text' }`, and the Fontsource stylesheets a file imports become `fonts` entries in the `kay.config.ts` it writes (listed instead when migrated in place); `Astro.self`, `import.meta.env` (in `.astro` files and in `src` modules), a script from another host (kay's Content-Security-Policy blocks it until `security.csp` allows it) and UnoCSS (its packages are left out, its classes pass through) are listed. The `.gitignore` it writes keeps the Astro project's own entries, its ESLint packages are left out for `@kaynooo/eslint`, and a carried `@kaynooo/*` range is listed, as the registry may hold no version in it.
149
- - A Markdown page in `src/pages` is listed, to become a content collection's entry, and so is a `site` or `base` written as anything but a string.
150
- - Migrated in place, the Astro project's `package.json` stays as it is, listed with the Astro packages to remove, and the `lang`, `site`, `base` and tsconfig `paths` are listed to carry over by hand.
151
- - `kay migrate content [dir] [--dry-run]`: rewrites the files of folder collections whose `migrations` carried entries over ([details](content-cms.md#loaded-collections)).
152
- - Every command prints its usage and options for `--help` or `-h`, and `kay --help` lists every command; `kay --version` prints the version, `--plain` or `--color never|always` set the colour of any command but `lint` and `test`, which pass every argument on, `kay` alone prints the help, and `kay __complete <words>` answers a shell's completion, which `kay completion bash|zsh|fish` wires up (`source <(kay completion bash)` in ~/.bashrc, `kay completion fish > ~/.config/fish/completions/kay.fish`, `source <(kay completion zsh)` in ~/.zshrc after `compinit`).
153
- - A usage error, an unknown command, an option or argument a command does not take or a `refuse(reason)` from a command, prints `error: kay <command>: <reason>` with a `hint:` line (the nearest command or option for a typo, else where `--help` is) and exits 2; a command that ran and failed exits 1.
154
- - Every command takes `--quiet`, `--format json` and `--dry-run`, or refuses it for a reason `SHARED_REFUSALS` in `src/commands/command.ts` lists, and `tests/command-options.test.ts` holds both: `--quiet` prints the problems and one summary line, without the size report, the files one by one or the next step; `--format json` prints one JSON document on one line; `--dry-run` lists what the command would write and writes nothing. A command refuses what it has nothing to do with: `kay lint` and `kay test` pass every argument on but `--format json`, and refuse `--quiet` and `--dry-run`, `kay lsp` and `kay mcp` speak a protocol, `kay types`, `kay build` and `kay dev` write generated output only, `--quiet` of `kay doctor`, `kay env` and `kay i18n missing` leaves out what passes, and `kay fmt --check` stays the verify-only form and refuses `--dry-run` beside it. `kay <command> --help` lists the options it takes.
155
- - Colour only goes to a terminal, never under `NO_COLOR` or `TERM=dumb`, and `FORCE_COLOR` brings it back to a pipe; a redrawn line or a cleared screen only ever goes to a terminal.
156
- - `kay build`, `kay routes`, `kay env`, `kay doctor`, `kay i18n missing`, `kay explain`, `kay fmt`, `kay migrate`, `kay not-found`, `kay screenshot` and `kay a11y` take `--format json`, as `kay check` does: stdout holds one JSON document on one line, what the app's own code prints through the console or `process.stdout` going to stderr (a write straight to file descriptor 1 is not caught), and the exit code is the text output's.
157
- - `kay build`: `{ errors, warnings, problems }` as `kay check` prints them, a template that does not compile at its place and any other failure as one problem with `code: null`, then `failed: { stage }` when a stage stopped it, `built: { islands, stylesheets, prerendered, entries, ms, sizes, routes, stages, caches }` (`sizes` the entry's and each island's `raw` and `gzip` bytes, `modules` under `--analyze`, and per island `why` it is one, and its `cause` (`kind`, `name`, `line`); `routes` each route's `js` and `css` gzip bytes, the `islands` its pages render, `pages` prerendered, `kept` pages the build kept on its own and for a route rendered per request the `stop` that decided it and whether the scripts are an `estimated` reach; `stages` `{ name, ms }`; `caches` `{ name, cached, made }`), `exported: { pages, files, dir, ms }` and `compiled: { executable, ms }`; code that ends the process mid-build leaves the problems so far, one saying it ended and the stage, and exit code 1 for its `process.exit(0)`; `--format github` annotates the check's problems as `kay check` does, and a template that does not compile or a failed stage too.
158
- - `kay routes`: `{ routes, unlisted }`, each route's `methods`, `path`, `kind`, `by`, and `file`, `notes`, `layouts`, `guards` when it has them, every locale's copy with its chains.
159
- - `kay doctor`: `{ checks }`, each check's `name`, `ok`, `message`, `warning` (ok, but worth a look: no browser) and, on a failure, `fix`.
160
- - `kay env`: `{ variables, unread }`, and `findings` (problems, as `kay check` prints them) with `--compose`, `--example` or `env` in the config, each variable's `name`, `source`, `type`, `required` (`'always'`, `'production'` or `false`), and `default`, `description` and `secret: true` when it has them; `unread` the `file` and `error` of each module that failed to load.
161
- - `kay explain`: `{ groups, lints, errorGroups, errors }` with each lint's `name`, `group`, `level`, `since` when it has one and whole `summary`, and each error code's `name`, `group`, `summary` and `fix`; the errors only without a lint group named; or one lint's fields, its `wrong` and `right` examples included.
162
- - `kay fmt`: `{ errors, warnings, problems, written, changed }`, what does not parse as problems.
163
- - `kay migrate`: `{ written, kept, copied, notes }`, each note's `file`, `line`, `target` and `message`.
164
- - A command that cannot run, options that do not go together included, prints `{ errors: 1, warnings: 0, problems: [{ severity, code: null, message }] }`.
140
+ - Under `src/`: `routes/` (pages, layouts, endpoints, `_guard.ts`), `api/`, `plugins/` (server plugins), `jobs/` (queues, workflows and schedules, each export mounted), `messages/<locale>.ts`, `params/<name>.ts`, `content/` with `content.config.ts`, `mails/<name>.kay` with `<name>.preview.ts` beside it and `mail.ts` for the mailer, `db/index.ts` and `tables.ts`, `server.ts`, `auth.ts`, `ui.ts`, `context.ts`, `env.ts`, `theme.ts`, `app.css`, `logo.svg` (the card logo, where `card.logo` names it).
141
+ - Under `/_kay/`: `assets/` (browser build, imported files), `images` and `images/` (resizer, variants), `card`, `files/`, `action/`, `live`, `health`, `mcp`, `metrics`, `jobs` (with `ops: { jobs: { guards } }`), `error`, `csp`, `vitals`, `analytics`, `push`, `search.json` and `search/`, `preview`, `draft`, `env.js`.
@@ -71,7 +71,7 @@ export default defineConfig({
71
71
  })
72
72
  ```
73
73
 
74
- - `proxy: false` is none, as left out; `proxy: true` is one proxy in front, `proxy: 2` two: the short forms of `{ hops: 1 }` and `{ hops: 2 }`.
74
+ - `proxy: false` is none, as left out; `proxy: true` is one proxy in front, `{ hops: 2 }` two; a bare `proxy: 2` still works until 1.108, `deprecated-config-switch` rewriting it.
75
75
  - `hops` is the number of proxies in front, each appending the address it was reached from to `X-Forwarded-For`, so the visitor is the entry `hops` from its end: 1 for nginx or Caddy alone, 2 for Cloudflare then nginx.
76
76
  - A request with fewer entries skipped an outer proxy, and its first entry is who reached the inner one.
77
77
  - `header` names a header a proxy sets to the visitor's address, read instead: `{ header: 'cf-connecting-ip' }`, or `{ header: 'x-real-ip' }` for nginx's `proxy_set_header X-Real-IP $remote_addr`.
@@ -82,9 +82,9 @@ export default defineConfig({
82
82
  - A forwarded entry that is no IP address (a port is dropped, `[v6]:port` too) is ignored, and the client counts by the address it reached the server from.
83
83
  - A request from a public address outside them that carries the header warns once, as such a CDN setup misses its `trusted`, and counts by its own address.
84
84
  - A setting holding both `hops` and `header` stops the server, and so does one holding neither without a `key`.
85
- - `key` names a header the proxy sets to a key shared with the server, `proxy: { key: 'x-upstream-key' }`: a request without it, or with another value, answers 403 with the security headers before anything else runs (the refusal is logged with its request id, never the key), so a process or container reaching the port directly skips nothing the proxy does. The proxy sends the key (nginx: `proxy_set_header X-Upstream-Key $upstream_key`). `key` alone counts as one proxy in front.
86
- - The key is read from `KAY_PROXY_KEY`, else from the trimmed file `KAY_PROXY_KEY_FILE` names (a container secret), at boot, and compared in constant time. A production server with `key` and neither, or an empty one, does not boot. Off under `kay dev`, in `kay build --static`, and outside production when none is given (a warning says so, except in a test run, where an unset key is expected); `testSite({ proxyKey })` turns it on for one test site without touching the environment, sending the header by default ([Testing](testing.md)). `kay build --compile --verify` stands in a throwaway key when the build has none, as the health route it asks is open. The server's own requests (an MCP tool call, a CMS edit-URL probe) pass.
87
- - The health route (`health.path`) is open, as the container asks it without the key, and so is the `metrics` route, which answers by its own rule (see [Metrics for a collector](production.md#metrics-for-a-collector)). `open: ['/api/push']` lists more paths, each open with what is under it; they are read after the `base` is taken off, whether the proxy did or not, and a path that merely starts like one (`/api/pushy`) stays closed. The MCP endpoint is open to this check too while `mcp.key` guards it with a bearer, its path alone ([API routes](mcp.md)).
85
+ - `key` names a header the proxy sets to a key shared with the server, `proxy: { key: { header: 'x-upstream-key' } }` (a bare string is the 1.104 form, which `kay upgrade` rewrites): a request without it, or with another value, answers 403 with the security headers before anything else runs (the refusal is logged with its request id, never the key), so a process or container reaching the port directly skips nothing the proxy does. The proxy sends the key (nginx: `proxy_set_header X-Upstream-Key $upstream_key`). `key` alone counts as one proxy in front.
86
+ - The key is read from `KAY_PROXY_KEY`, else from the trimmed file `KAY_PROXY_KEY_FILE` names (a container secret), or from `key: { header, secret }` where `secret` is a string, `{ env: 'NAME' }` or `{ file: 'path' }` (the same shape as `mcp.token` and `metrics.token`, a relative `{ file }` read from the project folder), at boot, and compared in constant time. A production server with `key` and neither, or an empty one, does not boot. Off under `kay dev`, in `kay build --static`, and outside production when none is given (a warning says so, except in a test run, where an unset key is expected); `testSite({ config: { proxy: { key: { secret } } } })` turns it on for one test site without touching the environment, sending the header by default ([Testing](testing.md)). `kay build --compile --verify` stands in a throwaway key for any secret of the config that gives nothing on the build host (a variable unset, a `{ file }` only the deploy host holds), as the health route it asks is open. The server's own requests (an MCP tool call, a CMS edit-URL probe) pass.
87
+ - The health route (`endpoints.health`) is open, as the container asks it without the key, and so is the `metrics` route, which answers by its own rule (see [Metrics for a collector](metrics.md)). `open: ['/api/push']` lists more paths, each open with what is under it; they are read after the `base` is taken off, whether the proxy did or not, and a path that merely starts like one (`/api/pushy`) stays closed. The MCP endpoint is open to this check too while `mcp.token` guards it with a bearer, its path alone ([API routes](mcp.md)).
88
88
  - The proxy passes `X-Forwarded-Proto` on every location, websockets included (nginx: `proxy_set_header X-Forwarded-Proto $scheme`), as kay's cookies are `Secure` and the session's named `__Host-kay_session` over https: a request that says `http` reads no session.
89
89
  - A request without the header counts as https in production when `site` is https; with no `site`, production warns once that cookies go out without `Secure`.
90
90
  - A post goes back to its page as a path and never reads a forwarded header for it, so the swap works behind a proxy that ends TLS with nothing declared for it.
@@ -163,7 +163,7 @@ export default defineConfig({
163
163
  - A static export has no server to send them: `kay build --static` writes the page without its `security` and `reload`, which the host's own headers stand in for.
164
164
  - `inlineScriptHashes({ prefetch, dev, base, offline })` from `kay/server` gives the hashes, for a policy written elsewhere, such as by a proxy.
165
165
  - Whatever the policy, a URL with any scheme but `http`, `https`, `mailto`, `tel`, `sms` and `blob` (and `data:` image, audio and video but not SVG, which passes only on `src` and `poster`, plain text, CSV, PDF and JSON), such as `javascript:`, bound to an `href`, `src`, `action`, `formaction`, `xlink:href`, `poster` or `data`, as a user-supplied link would be, goes out prefixed with `unsafe:`, on the server and in islands, so following it does nothing. A relative URL has no scheme and is kept.
166
- - `links: { schemes: ['webcal', 'geo'] }` in `kay.config.ts` lists the other schemes the app trusts in a bound URL (`whatsapp`, `webcal`, `geo`, `spotify`, its own `myapp`), on the server and in islands, which read the list from a `kay-link-schemes` meta; a name is lowercase with no colon, and `javascript`, `vbscript` and `data` are refused when the config loads. A literal `a(href="webcal://...")` was never rewritten. `kay dev` logs, once per attribute, URL and page, each bound URL rewritten to `unsafe:`, naming the scheme and this option; an island's own rewrite is not logged.
166
+ - `client: { links: { schemes: ['webcal', 'geo'] } }` in `kay.config.ts` lists the other schemes the app trusts in a bound URL (`whatsapp`, `webcal`, `geo`, `spotify`, its own `myapp`), on the server and in islands, which read the list from a `kay-link-schemes` meta; a name is lowercase with no colon, and `javascript`, `vbscript` and `data` are refused when the config loads. A literal `a(href="webcal://...")` was never rewritten. `kay dev` logs, once per attribute, URL and page, each bound URL rewritten to `unsafe:`, naming the scheme and this option; an island's own rewrite is not logged.
167
167
  - One written out as text in the template is left as it is.
168
168
 
169
169
  ### Compression
package/llms/queues.md CHANGED
@@ -9,7 +9,7 @@ A `queue` runs jobs in the background, a `workflow` is a multi-step flow that sl
9
9
  A queue holds jobs that must not be lost: an action enqueues one and goes on, and the server runs it:
10
10
 
11
11
  ```ts
12
- // src/plugins/jobs.ts
12
+ // src/jobs/mail.ts
13
13
  import { queue } from 'kay/server'
14
14
 
15
15
  export const welcomeMails = queue(
@@ -17,11 +17,9 @@ export const welcomeMails = queue(
17
17
  async ({ to }: { to: string }) => sendWelcome(to),
18
18
  { attempts: 5, backoff: '30s' },
19
19
  )
20
-
21
- export default welcomeMails
22
20
  ```
23
21
 
24
- `src/plugins/jobs.ts` is the one home of jobs: `pages()` mounts its default export (`new Elysia().use(a).use(b)` for several), and an action imports the queue from it. `kay check` warns of a `src/jobs.ts` nothing imports.
22
+ `src/jobs/*.ts` is the one home of jobs, read like `src/routes`: each queue, workflow, schedule and `background` a file exports by name is mounted by the server, with no default export and no `.use`, and an action imports the queue from it. Nested folders are read, a name starting with `_` or `.` is not, and `enabled: false` on any of them starts none, as a process that only enqueues wants. `kay check` warns of a `src/jobs.ts` nothing imports.
25
23
 
26
24
  ### Delay a job or keep one per key
27
25
 
@@ -36,7 +34,7 @@ await welcomeMails.enqueue({ to: email }, { delay: '1h', key: email })
36
34
  `live` on a queue lets an island list its waiting and running jobs, following them as they change, with no route or `live()` value written:
37
35
 
38
36
  ```ts
39
- // src/plugins/jobs.ts: `live: true` would send the whole payload, key, progress and last error
37
+ // src/jobs/scans.ts: `live: true` would send the whole payload, key, progress and last error
40
38
  export const scans = queue('scans', scan, { live: ({ target }: { target: string }) => ({ target }) })
41
39
  ```
42
40
 
@@ -50,13 +48,13 @@ for job of jobs<{ target: string }>('scans')
50
48
 
51
49
  ### Write a flow that sleeps and waits
52
50
 
53
- A `workflow` runs steps, keeps their results in the job store and survives restarts. `start` and `send` are one call, the `id` names the run, and it is mounted like a queue.
51
+ A `workflow` runs steps, keeps their results in the job store and survives restarts. `start` and `send` are one call, and it is mounted like a queue.
54
52
 
55
53
  ```ts
56
- // src/plugins/jobs.ts
54
+ // src/jobs/onboarding.ts
57
55
  import { workflow } from 'kay/server'
58
56
 
59
- export const onboarding = workflow<{ userId: string }, { visited: undefined }>('onboarding', async ({ input, step }) => {
57
+ export const onboarding = workflow<{ userId: string }, { visited: undefined }>('onboarding', async (input, { step }) => {
60
58
  await step.run('welcome', () => sendWelcome(input.userId))
61
59
 
62
60
  const visit = await step.waitFor('visited', { timeout: '3d' })
@@ -73,41 +71,38 @@ await onboarding.send(userId, 'visited')
73
71
 
74
72
  ## Reference
75
73
 
76
- - `workflow<Input, Events>(name, ({ id, input, step }) => ..., options)` is an Elysia plugin like `queue`, `options` those of a queue (`store`, `attempts`, `backoff`, `concurrency`, `lostAfter`, `idlePoll`, `failedTtl`) and the run hooks below. A run is one job of the queue `workflow:<name>`, kept under its id as its `key`, on the same stores as queues, each result a row beside the job, so a step writes what its result weighs: no table of its own.
77
- - `start(input, { key?, delay? })` resolves with the run's id (random unless a `key` is given, as for `enqueue`; the old `id` works): while a run with that `key` is live it starts nothing. `send(id, event, data?)` resolves with whether the run was waiting for that event, waking it at once in this process and within `idlePoll` in others; an event sent while the run waits for another, sleeps or has not started is kept in the run for the wait that names it, one sent while a worker holds the run is dropped; `send` resolves with whether it was taken. `status(id)` resolves with `{ status: 'running' | 'sleeping' | 'waiting' | 'failed', steps, event?, error? }`, undefined once completed. `cancel(id)` ends a run, a running one at its next step. `drain()` is a queue's.
74
+ - `workflow<Input, Events>(name, (input, { step, job, signal }) => ..., options)` is an Elysia plugin like `queue` (`job.id` is the run's id), `options` those of a queue (`store`, `attempts`, `backoff`, `concurrency`, `timeout`, `enabled`, `idlePoll`, `failedTtl`) and the run hooks below. A run is one job of the queue `workflow:<name>`, kept under its id as its `key`, on the same stores as queues, each result a row beside the job, so a step writes what its result weighs: no table of its own.
75
+ - `start(input, { key?, delay? })` resolves with the run's id (random unless a `key` is given, as for `enqueue`): while a run with that `key` is live it starts nothing. `send(id, event, data?)` resolves with whether the run was waiting for that event, waking it at once in this process and within `idlePoll` in others; an event sent while the run waits for another, sleeps or has not started is kept in the run for the wait that names it, one sent while a worker holds the run is dropped; `send` resolves with whether it was taken. `status(id)` resolves with `{ status: 'running' | 'sleeping' | 'waiting' | 'failed', steps, event?, error? }`, undefined once completed. `cancel(id)` ends a run, a running one at its next step. `drain()` is a queue's.
78
76
  - The function runs again from its top each time a process takes the run, and a finished step returns its kept result: so code between steps must be deterministic. Await a step before the next (two at once throw); a renamed or reordered step under a live run fails it at once, naming the step, with no retry; a result devalue cannot keep throws.
79
77
  - `step.run(name, work)` runs `work(signal, { key })` and keeps its result: at least once, as a crash before the result is written runs `work` again, so pass `key` (run id and step place, stable across runs) as a charge's or mail's idempotency key. `step.sleep('3d')` and `step.waitFor(event, { timeout? })` write the run's state and give its hold back (due at the wake time, never for a wait without timeout), so the code after them runs in whichever process takes the run; their promise never settles in the claim that suspended, so a `try` around it catches nothing. `waitFor(event)` resolves with the data, with `timeout` with `{ ok: true, data }` or `{ ok: false, error }` (`timedOut` is `!ok`). `Events` types `waitFor` and `send`.
80
- - A step that throws, or a run that dies, uses the queue's retries: a stop hands the run back at once, a dead process holds it until `lostAfter`, and a retry replays from the first step with no kept result. A kept step starts the attempts count again, so a long flow does not spend its attempts across steps. A stop or lost hold ends the run before its next step. A run keeps at most 50 events no wait named yet, the oldest dropped and logged, and a flow edited to end earlier than its kept steps completes without an error. `lostAfter` bounds the time between two sleeps or waits. `retryLater` works in a step. A worker reads every result when it takes the run, so a run keeps 2 MB of them at most (past it the run fails, no retry: return an id, keep a large result elsewhere) and no secrets. An error is kept to 2,000 characters. In tests `site.runJobs()` runs the due steps, and `setSystemTime` moves a sleep or a timeout along.
78
+ - A step that throws, or a run that dies, uses the queue's retries: a stop hands the run back at once, a dead process holds it until `timeout`, and a retry replays from the first step with no kept result. A kept step starts the attempts count again, so a long flow does not spend its attempts across steps. A stop or lost hold ends the run before its next step. A run keeps at most 50 events no wait named yet, the oldest dropped and logged, and a flow edited to end earlier than its kept steps completes without an error. `timeout` bounds the time between two sleeps or waits. `retryLater` works in a step. A worker reads every result when it takes the run, so a run keeps 2 MB of them at most (past it the run fails, no retry: return an id, keep a large result elsewhere) and no secrets. An error is kept to 2,000 characters. In tests `site.runJobs()` runs the due steps, and `setSystemTime` moves a sleep or a timeout along.
81
79
  - A `JobStore` needs `update`, `release` and `state` for a workflow, as `memoryJobs`, `sqliteJobs` and `pgJobs` have (no schema change): `update(id, { payload, runAt? }, { until })` writes only while `until` is the job's hold and counts the run as started once, `update(id, change, { payload, now })` writes only while the job is not held and its payload is still that text, which is how an event wakes a run once against a timeout. `steps(id)` and `update`'s `change.steps` (`{ from, values }`, dropped with the job) keep each result once; a store without them keeps them in the payload, and a run kept so moves to rows at its next step.
82
80
 
83
81
  - An action calls `await welcomeMails.enqueue({ to: email })`, or `enqueue(payload, { delay: '1h' })` to run it later.
84
82
  - `queue(name, handler, options)` is an Elysia plugin: the server using it runs the queue's jobs from start to stop, `concurrency` at a time, 1 by default, and waits on stop for the runs in progress.
85
- - A process that only enqueues, a script say, need not use it.
86
- - Jobs wait in a store shared by every process of the machine opening it: `sqliteJobs('data/jobs.sqlite')` by default, its file and directory created by the first job enqueued or schedule locked, which every schedule of a production server does by default, so its `data/` must be writable there; a dev or test server whose queues never get a job writes nothing.
83
+ - Jobs wait in a store shared by every process of the machine: `sqliteJobs('data/app.sqlite')` by default (`data/jobs.sqlite` where it exists), its file made by the first job enqueued or schedule locked (every schedule of a production server does, so its `data/` must be writable); a dev or test server whose queues get no job writes nothing.
87
84
  - `sqliteJobs(path)` and `memoryJobs()` from `kay/server` make a `store` of another file or one kept in the process, and `JobStore` is the shape of an app's own.
88
85
  - `pgJobs(db)` keeps the jobs in Postgres, for replicas on several machines: `db` is a Bun `SQL`, a pg-orm `Database` or a connection URL, and `store: { jobs: pgJobs(db) }` in kay.config.ts gives it to every queue and locked schedule. On pg-orm it needs nothing but the tables in the app's schema: `import { jobTables } from 'kay/pg-orm'` and `new Database({ tables: [...yourTables, ...jobTables] })` (pg-orm is an optional peer of kay, which installs and builds without it), and `db.sync()` or `pg-orm generate` creates `kay_jobs` and `kay_locks` with their indexes, matching what the store expects, for the owner's migration to run, so the app template's `app_rw`, which creates nothing, finds them (`import { pgJobs } from 'kay/server'` then `pgJobs(db)`). Without pg-orm migrations, `pgJobs` looks for them and creates them only when missing, which takes a role that may create tables, else the owner runs `import { createJobTables } from 'kay/server'` then `await createJobTables(db)` (idempotent, safe from replicas at once: an index missing on tables already there is built by one replica at a time, under a Postgres session lock, and the others wait for the unique ones before enqueuing, which needs a direct or session-mode connection, not a transaction-mode pooler) in a boot script; pg-orm then sees those two as unknown tables, so name them in `ignoreTables`: `import { jobTableNames } from 'kay/server'` lists their names, `ignoreTables: [...jobTableNames]`. A claim is one `UPDATE` over `FOR UPDATE SKIP LOCKED`, and a hold lasts from the database's clock, whichever replica claims, so replicas' clocks need not agree.
89
86
  - `pgData(db)` is `sqliteData(path)` on Postgres, for replicas on several machines: `import { pgData } from 'kay/server'` then `store: pgData(db)` in kay.config.ts keeps the sessions, `cached` values, jobs, schedule locks, rate counts, presence members, `live()` values, Web Vitals, `store.kv`, the 404 log and the redirects added while the site runs in `kay_*` tables of the same database, `db` a Bun `SQL`, a pg-orm `Database` or a connection URL as `pgJobs` takes. The tables are created when missing, which takes a role that may create tables; else the owner awaits `createDataTables(db)` from `kay/server` (idempotent, safe from replicas at once, the jobs' tables included) in a boot script and names `dataTableNames` from `kay/server` in pg-orm's `ignoreTables`. Replicas hear each other's `invalidate`, `live()` changes, room messages and queued jobs within a second through `NOTIFY`, polling as the fallback ([Stores](stores.md#postgres-notifications)), so a pooler in front of Postgres is fine (a missing index is built on a session connection). One timer per connection serves all three, a read or write that takes over 30 seconds is given up, and live writes waiting behind a database that stopped answering are dropped (logged) past 10,000. Every call of the job, session, rate, cache, notification, vitals and rooms stores is given up after 8 seconds (inside the default `serve.shutdownTimeout`) with a logged error rather than hanging, the sweeps, `deleteWhere`, `prune` and the job listings after 150 seconds as they scan a table, a rooms `state` or `update` within 8 seconds however many writes are queued before it, room writes waiting behind it are dropped past 1,000, and a connection `pgData` or `pgJobs` opens from a URL times out connecting after 10 seconds, closes when idle for 60 and is replaced after 30 minutes. A silent database holds no 404 over 1 second (the redirects last read answer, one warning logged), and `kay dev` makes no table. A room's state is kept in `kay_room_state` too, changed one update at a time across replicas, so `rooms({ store: pgData(db).rooms, state })` works with `state` and `update` resolving promises ([Rooms](rooms.md)). One database belongs to one app: the first app to boot on it records its package.json `name` in `kay_meta`, and another app starting on it fails its boot naming both, since `kay_*` tables carry no app scope and a `mail` queue, a `live()` id or a cache key would be shared; give each app its own database. A renamed app takes its database over by starting once with `KAY_ADOPT_DATABASE=<the old name>`; an app with no package.json name claims nothing. Rate keys are pseudonymised by the app secret, else by a random key in `kay_meta` every replica reads. `pgData(db).sessions` has `deleteWhere` like `sqliteSessions`. A store opened outside `kay dev` (a script, a test, a one-off process) is closed with `await store.close()`, or `await using store = pgData(url)`, which ends the polling, timers and room membership of every kind and closes the pool when `db` was a URL, within about 5 seconds whatever a statement in flight holds; a `SQL` or a pg-orm `Database` handed in stays open, as it is the caller's. A `kay dev` reload closes the store of the module that ran again by itself.
90
- - `jobs: { guard }` in kay.config.ts serves `/_kay/jobs` in production: each queue's waiting, running and failed jobs with payload and error, and forms to retry or delete one. A `workflow()` run shows its state (running, sleeping until a time, waiting for an event, failed) and its kept steps, with a form to send the event it waits for (a field takes its data as JSON) and one to cancel it, in the Jobs tab and on this page alike. `guard` is a guard, a list or `{ load }`, such as `ctx => ctx.locals.auth.requireAdmin()`, run on every request; without one the boot stops. The page is plain HTML with no script, answers `no-store` and `noindex`, `jobs: { guard, path }` moves it, and `kay dev` serves none (its Jobs tab covers it).
87
+ - `ops: { jobs: { guards } }` in kay.config.ts serves `/_kay/jobs` in production: each queue's waiting, running and failed jobs with payload and error, and forms to retry or delete one. A `workflow()` run shows its state (running, sleeping until a time, waiting for an event, failed) and its kept steps, with a form to send the event it waits for (a field takes its data as JSON) and one to cancel it, in the Jobs tab and on this page alike. `guards` is a guard, a list or `{ load }`, such as `ctx => ctx.locals.auth.admin.require()`, run on every request; without one the page answers 403, and `guards: false` opens it. The page is plain HTML with no script, answers `no-store` and `noindex`, `jobs: { guards, path }` moves it, and `kay dev` serves none (its Jobs tab covers it).
91
88
  - A `JobStore` may also have `revive(id, runAt)`, which puts a failed job back to wait with its attempts given back and resolves with whether it did (false for a job not failed, or whose key a live job holds since), as `sqliteJobs`, `memoryJobs` and `pgJobs` do: the dev tool's Jobs tab retries a failed job with it ([The dev tool](dev-tool.md#reference)). `jobs(queue, { limit?, failed? })` and `failed(queue, limit?)` list the jobs by when they are due, the earliest first, and may cut their result in the store's query: the Jobs tab and page ask for 101 of each, so a long queue is not read whole, and a store ignoring the options is cut after.
92
- - A `JobStore` may also have `state(queue, ref, now)`, `progress(id, until, progress)` and `release(id, until, runAt?)`, and its `add(job)` may resolve with the id of the live job already holding `job.key`, in which case it stored nothing: `sqliteJobs` and `memoryJobs` do all of these. A file made by an older kay gains the columns on first open. A run's writes about its job are matched against the hold it was claimed with, so one that outlived its hold changes nothing of the job another process holds: `claim` may return the hold it stored in the job's `heldUntil` (`pgJobs` does, from the database's clock; the `until` asked for stands otherwise), and `complete(id, until?)`, `retry(id, runAt, error, until?)` and `fail(id, error, payload?, until?)` write only while `until` is still the job's, `remove()` and the purge naming none. A store ignoring the extra argument keeps working, without the guard. `retry` and `fail` may resolve with `false` for a write the guard refused, and the run then logs nothing and calls no `onError`, the job being the other process's now; resolving with nothing counts as applied.
89
+ - A `JobStore` may also have `state(queue, ref, now)`, `progress(id, until, progress)` and `release(id, until, runAt?)`, and its `add(job)` may resolve with the id of the live job already holding `job.key`, in which case it stored nothing: `sqliteJobs` and `memoryJobs` do all of these. A file made by an older kay gains the columns on first open. A run's writes about its job are matched against the hold it was claimed with, so one that outlived its hold changes nothing of the job another process holds: `claim` may return the hold it stored in the job's `heldUntil` (`pgJobs` does, from the database's clock; the `until` asked for stands otherwise), and `complete(id, until?)`, `retry(id, runAt, error, until?)` and `fail(id, error, payload?, until?)` write only while `until` is still the job's, `remove()` and the purge naming none. `retry` and `fail` may resolve with `false` for a write the guard refused, and the run then logs nothing and calls no `onError`, the job being the other process's now; resolving with nothing counts as applied.
93
90
  - `store` in kay.config.ts is the one store of the app, `import { sqliteData } from 'kay/server'` then `store: sqliteData('data/app.sqlite')`, which keeps the data of every `session()`, the values of every `cached` and `live()`, the jobs of every queue and locked schedule, and the counts of every rate limit, each naming no `store` of its own, the members of presence rooms and the Web Vitals of `vitals()`, in one SQLite file, so replicas sharing it count together. `store: { sessions, cache, live, jobs, rates, rooms, vitals, notifications }` takes a `SessionStore`, a `CacheStore`, a `LiveStore`, a `JobStore`, a `RateStore`, a `RoomStore`, a `VitalsStore` and a `NotificationStore` of your own, each optional, Redis say; `rooms` is where `presence()` keeps who has a page open ([Presence](live-values.md#presence)). A `store` on a session, a `cached` call, a queue, a schedule or a limit wins, the proof-of-work solutions already used count there too, a `store.rates` needs `peek` for a limit counting only the posts that went through, kay's limits (actions, API routes, `rateLimit()`, proof of work, its own routes) and kayjs-auth's count in memory when their rates store fails, and for ten seconds after one takes over 8 seconds ([Rate limits](rate-limits.md#reference)), and a `bun test` site keeps all of them in memory.
94
91
  - `enqueue(payload, { key })` keeps one job per key: while a job of the queue with that key is waiting or running, it stores nothing and resolves with that job's id, whichever process holds it; the duplicate's payload is dropped, even one enqueued while the run goes, so an app that needs a rerun after it enqueues without a key. Once the job completed or was kept as failed the key is free. The key is a non-empty string, apart per queue, and needs a store with `state`, which `sqliteJobs`, `memoryJobs` and `pgJobs` have; a custom store without it throws a `config-invalid` error rather than not dedupe.
95
92
  - `job(key)` or `job({ id })` resolves with `{ id, status, attempts, error? }`, `status` `'waiting'` (due, or waiting for a retry, its `error` the last run's), `'running'` or `'failed'`: the live job of the key, else its last failed one, `undefined` once it completed. An action returning it is what a page polls.
96
93
  - `throw retryLater('30s')` from a handler (`retryLater(wait)` from `kay/server`, a positive duration) runs the job again after the wait without spending an attempt: the store's `release(id, until, runAt)` gives the claim's attempt back and makes it due then, so a job asking 10 times with `attempts: 3` is still waiting, logged at info, never `onError`. It repeats as long as the handler throws it, so one that should stop throws an error of its own; a store without `release` counts it as a failed attempt, with a warning.
97
- - A handler is `(payload, signal, job)`: `job.id`, `job.attempts` (runs started, this one included) and `job.progress(value)`, which reports how far the run is, any devalue value, typed by `queue<Payload, Progress>`'s second argument. Reports are written in the background, one write at a time with the latest waiting, so reporting per item is cheap; `job(key)` reads the latest back as `progress` while the job runs, after it failed too, and a retried job's next claim clears it. A report after the run ended is dropped, as the store writes it only while the run's hold is the job's; a failed write is logged, not thrown. A store without `progress` logs once that nothing is kept.
98
- - To show it, an action returns `job(key)` and a page or island polls it, as `export const syncState = action(async () => sync.job('anilist'))` called from an island: kay adds no route of its own, so the app decides who may see a job. The method is `job`, not `state`, which Elysia's own `.state()` already is.
99
- - `live: true` on a queue lets `jobs<Payload, Progress>(name)` from `kay` read its waiting and running jobs in an island, the earliest due first, 100 at most: `{ id, key?, status: 'waiting' | 'running', attempts, runAt, error?, progress?, payload }`, `runAt` a `Date`. `live: (payload, { key, error, progress }) => shown` sends `{ id, status, attempts, runAt, payload: shown }` alone, so a secret in the payload, the key or a run's error stays on the server; a job whose function throws is left out of the list, logged once. The page proves the queue it read as any live value ([Live values](live-values.md#live-values)), so whoever may render the page may follow the list, its guard deciding; a queue without `live` cannot be read, a `config-invalid` error at the render. The process changing a job tells its tabs within 50 ms, a burst of changes read once; one a tab follows the list through reads the store again every second, which is how what another worker or replica did reaches it. A render after a change, or of a list older than a second, reads it again: at once from `memoryJobs` and `sqliteJobs`, while a render on `pgJobs` or a store answering with promises shows the list as last read, the page's connection then bringing it up to date. A `JobStore` may have `live(queue, now, limit?)`, the waiting and running jobs with their status in one query, as `sqliteJobs`, `memoryJobs` and `pgJobs` do; a store without it is listed with `jobs` and asked `state` job by job. No start time is kept: `status` and `attempts` tell a run started. A `workflow()` has no `live`.
100
- - Under `bun test` the default is in memory.
101
- - Each job runs in one process.
94
+ - A handler is `(payload, ctx)`, as every job's is `(input, ctx)`: `ctx.signal`, `ctx.log`, `ctx.locale` (the site's default) and `ctx.job`, `{ id, attempts, progress(value) }`, `attempts` the runs started, this one included, and `progress` reporting how far the run is, any devalue value, typed by `queue<Payload, Progress>`'s second argument. Reports are written in the background, one write at a time with the latest waiting, so reporting per item is cheap; `job(key)` reads the latest back as `progress` while the job runs, after it failed too, and a retried job's next claim clears it. A report after the run ended is dropped, as the store writes it only while the run's hold is the job's; a failed write is logged, not thrown. A store without `progress` logs once that nothing is kept.
95
+ - To show it, an action returns `job(key)` and a page or island polls it, as `export const syncState = action(async () => sync.job('anilist'))` called from an island: kay adds no route, so the app decides who may see a job.
96
+ - `live: true` on a queue lets `jobs<Payload, Progress>(name)` from `kay` read its waiting and running jobs in an island, the earliest due first, 100 at most: `{ id, key?, status: 'waiting' | 'running', attempts, runAt, error?, progress?, payload }`, `runAt` a `Date`. `live: (payload, { key, error, progress }) => shown` sends `{ id, status, attempts, runAt, payload: shown }` alone, so a secret in the payload, the key or a run's error stays on the server; a job whose function throws is left out of the list, logged once. The page proves the queue it read as any live value ([Live values](live-values.md#live-values)), so whoever may render the page may follow the list, its guard deciding; a queue without `live` cannot be read, a `config-invalid` error at the render. The process changing a job tells its tabs within 50 ms, a burst of changes read once; one a tab follows the list through reads the store again every second, which is how what another worker or replica did reaches it. A render after a change, or of a list older than a second, reads it again: at once from `memoryJobs` and `sqliteJobs`, while a render on `pgJobs` or a store answering with promises shows the list as last read, the page's connection then bringing it up to date. A `JobStore` may have `live(queue, now, limit?)`, the waiting and running jobs with their status in one query, as `sqliteJobs`, `memoryJobs` and `pgJobs` do; a store without it is listed with `jobs` and asked `state` job by job. A `workflow()` has no `live`.
102
97
  - The payload goes through devalue, as cached values do: dates, maps and sets survive, a function or a class instance throws from `enqueue`.
103
98
  - A run that throws is retried: `backoff` after the first failure, 10 seconds by default, twice as long after each next one, until `attempts` runs in all, 5 by default, each failure retried logged as a one-line warning with its attempt, its wait and the error's message.
104
- - Hooks, told as [hooks](hooks.md) say (a throw is reported with source `queue.onStart` and never fails the job): `onStart({ id, payload, attempts })` before each run, `onSuccess({ id, payload, attempts })` once it ran, `onRetry({ id, payload, attempts, error, wait })` for a failed attempt that runs again, and `onError({ id, payload, attempts, error })` after the last. A workflow's (source `workflow.*`) get `{ id, input }` (`onRetry` and `onError` also `attempts` and `error`, `onRetry` `wait`), `onStart` once per run, not after a sleep, a wait or a retry; a stop in the first attempt before any step is kept, or a run from an older kay, may tell it again. A schedule takes `onStart({ schedule, boot })`, `onSuccess` and `onError` (with `duration` ms, `onError` also `error`) in its options, source `schedule.*`. Hooks are awaited (10 s each) in the worker slot and spend `lostAfter`, counted from the claim; a job's hooks share one `payload`, read-only; and with `concurrency` above 1 a retry's `onStart` may run before the previous `onRetry` finished; `context.request` is undefined in a job, and an `AsyncLocalStorage` or OpenTelemetry span the app entered around `listen()` does not reach workers.
99
+ - Hooks, told as [hooks](hooks.md) say (a throw is reported with source `queue.onStart` and never fails the job): `onStart({ id, payload, attempts })` before each run, `onSuccess({ id, payload, attempts })` once it ran, `onRetry({ id, payload, attempts, error, wait })` for a failed attempt that runs again, and `onError({ id, payload, attempts, error })` after the last. A workflow's (source `workflow.*`) get `{ id, input }` (`onRetry` and `onError` also `attempts` and `error`, `onRetry` `wait`), `onStart` once per run, not after a sleep, a wait or a retry; a stop in the first attempt before any step is kept, or a run from an older kay, may tell it again. A schedule takes `onStart({ schedule, boot })`, `onSuccess` and `onError` (with `duration` ms, `onError` also `error`) in its options, source `schedule.*`. Hooks are awaited (10 s each) in the worker slot and spend `timeout`, counted from the claim; a job's hooks share one `payload`, read-only; and with `concurrency` above 1 a retry's `onStart` may run before the previous `onRetry` finished; `context.request` is undefined in a job, and an `AsyncLocalStorage` or OpenTelemetry span the app entered around `listen()` does not reach workers.
105
100
  - The last failure keeps the job as failed, logs it with its stack and hands `{ payload, error }` to `onError`; `failed()` lists the failed jobs, oldest first.
106
101
  - `lazy: true` starts no worker with the server: the first `enqueue`, or `queue.activate()`, does, so a queue an app may never use has no idle poll; a job already stored waits until then (kayjs-mail's list queue).
107
102
  - A failed job is kept 30 days from when its last attempt was due, payload included, then dropped by the workers, and by any `enqueue`, `failed()` or `remove()` of the queue in a process running none; `failedTtl` sets another duration, or `false` to keep it until removed. `redact(payload)` gives what a job keeps in place of its payload once it is given up, such as a mail without its body; `onError` still gets the whole payload. A custom `JobStore.fail(id, error, payload?)` stores that payload, and a store ignoring it keeps the job whole.
108
103
  - `remove(id)` removes a job, and `remove(match)` every waiting or failed job whose payload `match` returns true for, such as a person's mails once they asked to be erased, resolving with how many went; an app's own `JobStore` takes a function only when it has `jobs(queue)`.
109
104
  - An idle queue looks at the store from one worker, which is how a job another process enqueued is noticed: 1 second after a job, then twice as long after each empty look up to `idlePoll`, 10 seconds by default, so such a job waits 10 seconds at worst. On Postgres it is told within a second. A job enqueued in this process, or delayed to a time the store knows, still runs at once, and a retry is picked up when due. `idlePoll: '1s'` looks every second, `'30s'` asks the database less often; it takes at least `1s`. A custom `JobStore` may have `prune(queue, before)` to drop the expired failed jobs in one call.
110
105
  - A store that fails, a SQLite file locked past its timeout say, is logged once as the outage starts and once as it ends, its workers asking it again later and later meanwhile, up to a minute apart.
111
- - A handler takes `(payload, signal, job)`, `job` below: the `AbortSignal` aborts at `lostAfter`, so a handler passing it on stops instead of running beside the retry, and as the server stops, when a job it gives up on is released with `release(id, until)` of the `JobStore`, clearing the hold only while `until`, the one it was claimed with, is still the job's (optional): back without waiting out `lostAfter`, its attempt not counted, instead of held until `lostAfter` and retried after its backoff. Without `release` the job is retried as before.
112
- - A process that dies running a job leaves it held: it runs again once `lostAfter` has passed since it started, 10 minutes by default. A run still going as `lostAfter` ends counts as a failed attempt, so its worker moves on, its handler's signal aborted, so a handler ignoring it runs on beside the retry, and a job longer than `lostAfter` needs a longer one, and a job whose process died during each of its `attempts` is kept as failed without running again, rather than crash every process that takes it.
113
- - `drain()` runs every job whose time has come, here and now, until none is left, and waits for a run a worker already took (up to its `lostAfter` for one that never ends), except inside a job, which includes work the job spawned (a timer, a promise left running) and then does not wait, and a run counts once however many drains waited for it; in tests `site.runJobs()` from `kay/test` does it for every queue.
106
+ - `ctx.signal` aborts at `timeout` (`lostAfter` until 1.108), so a handler passing it on stops instead of running beside the retry, and as the server stops, when a job it gives up on is released with `release(id, until)` of the `JobStore`, clearing the hold only while `until`, the one it was claimed with, is still the job's (optional): back without waiting out `timeout`, its attempt not counted, instead of held until `timeout` and retried after its backoff. Without `release` the job is retried as before.
107
+ - A process that dies running a job leaves it held: it runs again once `timeout` has passed since it started, 10 minutes by default. A run still going as `timeout` ends counts as a failed attempt, so its worker moves on, its handler's signal aborted, so a handler ignoring it runs on beside the retry, and a job longer than `timeout` needs a longer one, and a job whose process died during each of its `attempts` is kept as failed without running again, rather than crash every process that takes it.
108
+ - `drain()` runs every job whose time has come, here and now, until none is left, and waits for a run a worker already took (up to its `timeout` for one that never ends), except inside a job, which includes work the job spawned (a timer, a promise left running) and then does not wait, and a run counts once however many drains waited for it; in tests `site.runJobs()` from `kay/test` does it for every queue.