okengine 0.18.4 → 0.19.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 (512) hide show
  1. package/AGENTS.md +18 -10
  2. package/README.md +2 -2
  3. package/package.json +51 -50
  4. package/site/content/docs/ai/index.mdx +25 -6
  5. package/site/content/docs/ai/llms-txt.mdx +1 -1
  6. package/site/content/docs/ai/meta.json +1 -1
  7. package/site/content/docs/ai/skills.mdx +4 -1
  8. package/site/content/docs/ai/try-it.mdx +58 -0
  9. package/site/content/docs/client/auth.mdx +208 -0
  10. package/site/content/docs/client/calling.mdx +451 -0
  11. package/site/content/docs/client/index.mdx +209 -0
  12. package/site/content/docs/client/live.mdx +234 -0
  13. package/site/content/docs/client/meta.json +5 -0
  14. package/site/content/docs/client/react.mdx +249 -0
  15. package/site/content/docs/elements/ai/agents.mdx +232 -0
  16. package/site/content/docs/elements/ai/index.mdx +341 -0
  17. package/site/content/docs/elements/ai/mcp.mdx +275 -0
  18. package/site/content/docs/elements/ai/meta.json +5 -0
  19. package/site/content/docs/elements/ai/models.mdx +283 -0
  20. package/site/content/docs/elements/ai/prompts.mdx +256 -0
  21. package/site/content/docs/elements/channel/email.mdx +266 -0
  22. package/site/content/docs/elements/channel/index.mdx +344 -0
  23. package/site/content/docs/elements/channel/meta.json +5 -0
  24. package/site/content/docs/elements/channel/push.mdx +218 -0
  25. package/site/content/docs/elements/channel/receipts.mdx +206 -0
  26. package/site/content/docs/elements/channel/sms.mdx +264 -0
  27. package/site/content/docs/elements/channel/whatsapp.mdx +220 -0
  28. package/site/content/docs/elements/clock/index.mdx +300 -0
  29. package/site/content/docs/elements/clock/meta.json +5 -0
  30. package/site/content/docs/elements/clock/schedules.mdx +508 -0
  31. package/site/content/docs/elements/clock/sleep.mdx +445 -0
  32. package/site/content/docs/elements/flow/consumers.mdx +707 -0
  33. package/site/content/docs/elements/flow/http.mdx +1080 -0
  34. package/site/content/docs/elements/flow/index.mdx +618 -0
  35. package/site/content/docs/elements/flow/meta.json +5 -0
  36. package/site/content/docs/elements/flow/routing.mdx +559 -0
  37. package/site/content/docs/elements/flow/workflows.mdx +640 -0
  38. package/site/content/docs/elements/gate/auth.mdx +371 -0
  39. package/site/content/docs/elements/gate/authorization.mdx +298 -0
  40. package/site/content/docs/elements/gate/index.mdx +418 -0
  41. package/site/content/docs/elements/gate/meta.json +5 -0
  42. package/site/content/docs/elements/gate/rate-limits.mdx +365 -0
  43. package/site/content/docs/elements/gate/rls.mdx +303 -0
  44. package/site/content/docs/elements/gate/tenancy.mdx +372 -0
  45. package/site/content/docs/elements/index.mdx +52 -11
  46. package/site/content/docs/elements/signal/broadcast.mdx +517 -0
  47. package/site/content/docs/elements/signal/index.mdx +352 -0
  48. package/site/content/docs/elements/signal/live.mdx +590 -0
  49. package/site/content/docs/elements/signal/meta.json +5 -0
  50. package/site/content/docs/elements/signal/once.mdx +596 -0
  51. package/site/content/docs/elements/store/files.mdx +659 -0
  52. package/site/content/docs/elements/store/index.mdx +310 -0
  53. package/site/content/docs/elements/store/kv.mdx +629 -0
  54. package/site/content/docs/elements/store/meta.json +5 -0
  55. package/site/content/docs/elements/store/search.mdx +946 -0
  56. package/site/content/docs/elements/store/sql.mdx +937 -0
  57. package/site/content/docs/elements/vault/config.mdx +256 -0
  58. package/site/content/docs/elements/vault/index.mdx +356 -0
  59. package/site/content/docs/elements/vault/meta.json +5 -0
  60. package/site/content/docs/elements/vault/rotation.mdx +273 -0
  61. package/site/content/docs/elements/vault/secrets.mdx +285 -0
  62. package/site/content/docs/index.mdx +78 -30
  63. package/site/content/docs/meta.json +11 -8
  64. package/site/content/docs/plugins/cors.mdx +2 -1
  65. package/site/content/docs/plugins/csrf.mdx +4 -1
  66. package/site/content/docs/plugins/headers.mdx +2 -1
  67. package/site/content/docs/plugins/ip-allowlist.mdx +2 -1
  68. package/site/content/docs/plugins/magic-link.mdx +6 -0
  69. package/site/content/docs/plugins/maintenance-mode.mdx +2 -1
  70. package/site/content/docs/plugins/oauth.mdx +1 -1
  71. package/site/content/docs/plugins/otp.mdx +12 -1
  72. package/site/content/docs/plugins/passkey.mdx +39 -15
  73. package/site/content/docs/plugins/two-factor.mdx +91 -34
  74. package/site/content/docs/plugins/username.mdx +1 -1
  75. package/site/content/docs/recipes/caddy.mdx +3 -3
  76. package/site/content/docs/recipes/index.mdx +18 -28
  77. package/site/content/docs/recipes/mailpit.mdx +1 -1
  78. package/site/content/docs/recipes/meilisearch.mdx +3 -3
  79. package/site/content/docs/recipes/meta.json +1 -4
  80. package/site/content/docs/recipes/nginx.mdx +2 -2
  81. package/site/content/docs/recipes/openrouter.mdx +283 -0
  82. package/site/content/docs/recipes/pgdog.mdx +3 -3
  83. package/site/content/docs/recipes/postgres.mdx +1 -2
  84. package/site/content/docs/recipes/rustfs.mdx +2 -2
  85. package/site/content/docs/recipes/traefik.mdx +3 -3
  86. package/site/content/docs/reference/cli.mdx +231 -0
  87. package/site/content/docs/reference/configuration.mdx +30 -10
  88. package/site/content/docs/reference/environment-variables.mdx +93 -20
  89. package/site/content/docs/reference/errors.mdx +132 -29
  90. package/site/content/docs/reference/fx.mdx +137 -73
  91. package/site/content/docs/reference/index.mdx +13 -21
  92. package/site/content/docs/reference/meta.json +4 -5
  93. package/site/content/docs/reference/okid.mdx +42 -17
  94. package/site/content/docs/reference/plugins.mdx +4 -3
  95. package/site/content/docs/reference/security.mdx +197 -0
  96. package/site/content/docs/understand/meta.json +5 -0
  97. package/site/content/docs/understand/the-anatomy.mdx +132 -0
  98. package/site/content/docs/understand/the-model.mdx +32 -0
  99. package/site/content/docs/understand/the-problem.mdx +74 -0
  100. package/site/content/docs/understand/the-vocabulary.mdx +26 -0
  101. package/src/auth/api-keys.ts +2 -1
  102. package/src/auth/bindings.ts +64 -16
  103. package/src/auth/gate-auth.test.ts +6 -1
  104. package/src/auth/identity.ts +152 -5
  105. package/src/auth/index.ts +29 -0
  106. package/src/auth/invites.ts +2 -1
  107. package/src/auth/method-context.ts +41 -0
  108. package/src/auth/oauth-as/crypto.ts +2 -1
  109. package/src/auth/oauth-as/stores.ts +2 -1
  110. package/src/auth/operator.ts +2 -1
  111. package/src/auth/sessions-jwt.test.ts +77 -0
  112. package/src/auth/sessions.ts +20 -4
  113. package/src/auth/tenants.ts +3 -2
  114. package/src/auth/two-factor-challenge.test.ts +61 -0
  115. package/src/auth/two-factor-challenge.ts +284 -0
  116. package/src/auth/verification.ts +5 -0
  117. package/src/bench/REPORT.md +49 -0
  118. package/src/bench/g03-signal-once.bench.ts +1 -1
  119. package/src/bench/g10-observability-contention.bench.ts +1 -1
  120. package/src/bench/g17-hybrid-search.bench.ts +572 -0
  121. package/src/bench/load-app.ts +2 -10
  122. package/src/cli/ai-setup/ai-setup.test.ts +331 -42
  123. package/src/cli/ai-setup/apply.ts +294 -52
  124. package/src/cli/ai-setup/catalog.ts +238 -1342
  125. package/src/cli/ai-setup/index.ts +14 -99
  126. package/src/cli/ai-setup/prompts.ts +60 -443
  127. package/src/cli/ask-seed.test.ts +96 -0
  128. package/src/cli/ask-seed.ts +82 -0
  129. package/src/cli/ask-vault-gaps.test.ts +84 -0
  130. package/src/cli/ask-vault-gaps.ts +146 -0
  131. package/src/cli/build.ts +2 -2
  132. package/src/cli/client-add.test.ts +26 -1
  133. package/src/cli/client-add.ts +106 -27
  134. package/src/cli/competitor-mention-removal.test.ts +1 -1
  135. package/src/cli/db-seed.ts +2 -0
  136. package/src/cli/db.ts +150 -11
  137. package/src/cli/dev.ts +119 -211
  138. package/src/cli/docker-clean.ts +2 -2
  139. package/src/cli/docker-cli.test.ts +1 -1
  140. package/src/cli/doctor-diff.ts +4 -2
  141. package/src/cli/doctor-pii.test.ts +1 -1
  142. package/src/cli/doctor.ts +14 -1
  143. package/src/cli/hero-meta.test.ts +4 -2
  144. package/src/cli/load-config.images.test.ts +8 -10
  145. package/src/cli/load-config.ts +1 -1
  146. package/src/cli/registry.ts +22 -10
  147. package/src/cli/replay.ts +3 -1
  148. package/src/cli/start.ts +1 -1
  149. package/src/cli/tui/keys.ts +2 -3
  150. package/src/client/auth/cookies.ts +74 -0
  151. package/src/client/auth/create-auth-client.ts +636 -0
  152. package/src/client/auth/denials.ts +99 -0
  153. package/src/client/auth/session.ts +283 -0
  154. package/src/client/auth.test.ts +251 -0
  155. package/src/client/auth.ts +39 -114
  156. package/src/client/create-with-session.ts +245 -0
  157. package/src/client/create.ts +51 -5
  158. package/src/client/index.ts +11 -1
  159. package/src/client/live.ts +11 -79
  160. package/src/client/notes-contract.test.ts +5 -10
  161. package/src/client/sse.ts +137 -0
  162. package/src/client/stream.ts +147 -0
  163. package/src/client/transport.test.ts +32 -0
  164. package/src/client/transport.ts +123 -26
  165. package/src/client/types.ts +118 -14
  166. package/src/client-react/index.ts +185 -24
  167. package/src/client-react/use-live-query.ts +13 -3
  168. package/src/compiler/aot.test.ts +7 -4
  169. package/src/compiler/effects-embed.test.ts +56 -0
  170. package/src/compiler/effects-fetch.test.ts +43 -0
  171. package/src/compiler/effects-infer.ts +58 -2
  172. package/src/compiler/extract.test.ts +258 -44
  173. package/src/compiler/extract.ts +566 -48
  174. package/src/compiler/fixtures/skyport/src/flows/bookings/index.ts +7 -4
  175. package/src/compiler/fixtures/skyport/src/flows/bookings/signals.ts +2 -8
  176. package/src/compiler/fixtures/skyport.expected.json +4 -4
  177. package/src/compiler/fixtures/triggers/five-triggers.ts +14 -10
  178. package/src/compiler/response.ts +2 -2
  179. package/src/compiler/search-writer-isolation.test.ts +40 -0
  180. package/src/config/index.ts +11 -0
  181. package/src/console/server/app.ts +17 -23
  182. package/src/console/server/bind.ts +4 -0
  183. package/src/console/server/console.test.ts +2 -2
  184. package/src/console/server/flows-invoke.test.ts +50 -34
  185. package/src/console/server/flows.ts +436 -255
  186. package/src/console/server/runs-ingest.test.ts +6 -3
  187. package/src/console/server/serve.ts +1 -1
  188. package/src/console/server/signals.test.ts +1 -5
  189. package/src/console/server/signals.ts +8 -6
  190. package/src/console/server/state.ts +6 -1
  191. package/src/console/server/store.ts +1 -1
  192. package/src/console/ui-next/dist/assets/FileExportIcon-Ck-5od4R.js +1 -0
  193. package/src/console/ui-next/dist/assets/MoreHorizontalCircle01Icon-gMNGsE37.js +1 -0
  194. package/src/console/ui-next/dist/assets/PlusSignIcon-CwG3nxfu.js +1 -0
  195. package/src/console/ui-next/dist/assets/UnavailableIcon-D9cvHVPr.js +1 -0
  196. package/src/console/ui-next/dist/assets/UserIcon-DaE2PB5_.js +1 -0
  197. package/src/console/ui-next/dist/assets/access-page-DFeymU07.js +4 -0
  198. package/src/console/ui-next/dist/assets/agent-disclosure-U1rdfblp.js +1 -0
  199. package/src/console/ui-next/dist/assets/cache-glyph-BeFJeqBG.js +1 -0
  200. package/src/console/ui-next/dist/assets/call-pii-button-CVAONPii.js +1 -0
  201. package/src/console/ui-next/dist/assets/collapsible-D2A6NJ-3.js +1 -0
  202. package/src/console/ui-next/dist/assets/copy-inline-button-CAYD18cr.js +1 -0
  203. package/src/console/ui-next/dist/assets/dagre.esm-B1_XeuLP.js +1 -0
  204. package/src/console/ui-next/dist/assets/detail-header-DVWNjWjg.js +1 -0
  205. package/src/console/ui-next/dist/assets/dropdown-menu-4h2LOVXM.js +1 -0
  206. package/src/console/ui-next/dist/assets/duration-tone-Cgk_h5ja.js +9 -0
  207. package/src/console/ui-next/dist/assets/element-icons-BI8cJgdh.js +1 -0
  208. package/src/console/ui-next/dist/assets/explorer-empty-CJs5A-wm.js +1 -0
  209. package/src/console/ui-next/dist/assets/flows-page-Dss7941e.js +1 -0
  210. package/src/console/ui-next/dist/assets/highlighted-json-MYZQtRnw.js +154 -0
  211. package/src/console/ui-next/dist/assets/http-method-Jrh39p7A.js +1 -0
  212. package/src/console/ui-next/dist/assets/index-D0zS5rKO.css +2 -0
  213. package/src/console/ui-next/dist/assets/index-DXP2dBIF.js +63 -0
  214. package/src/console/ui-next/dist/assets/observability-page-HvolXxTI.js +4 -0
  215. package/src/console/ui-next/dist/assets/react-dom-Ddte4I-Q.js +9 -0
  216. package/src/console/ui-next/dist/assets/replica-lag-CSh2dzrb.js +18 -0
  217. package/src/console/ui-next/dist/assets/request-meta-BatF8KrK.js +1 -0
  218. package/src/console/ui-next/dist/assets/shortcut-keys-3ILd8oGn.js +1 -0
  219. package/src/console/ui-next/dist/assets/{sql-BskegiFM.js → sql-BsFa4tDR.js} +1 -1
  220. package/src/console/ui-next/dist/assets/store-page-eiKiHnNe.js +41 -0
  221. package/src/console/ui-next/dist/assets/trace-detail-sheet-CZkMeKS-.js +2 -0
  222. package/src/console/ui-next/dist/assets/tree-expand-toggle-CW8y5A2h.js +55 -0
  223. package/src/console/ui-next/dist/assets/units-page-B_RWJrEO.js +1 -0
  224. package/src/console/ui-next/dist/assets/{use-vault-list-uk4WVboC.js → use-vault-list-CT4-gajj.js} +1 -1
  225. package/src/console/ui-next/dist/assets/vault-page-CWrg-A68.js +2 -0
  226. package/src/console/ui-next/dist/assets/xyflow-CSyC6ryz.css +1 -0
  227. package/src/console/ui-next/dist/assets/xyflow-yApv7D4e.js +7 -0
  228. package/src/console/ui-next/dist/index.html +6 -13
  229. package/src/console/ui-next/seed-invoke-host.ts +21 -18
  230. package/src/console/ui-next/src/client.ts +7 -2
  231. package/src/console/ui-next/src/features/flows/graph/element-map.ts +2 -0
  232. package/src/console/ui-next/src/features/flows/traces/effect-kind.ts +12 -2
  233. package/src/console/ui-next/src/features/flows/traces/effect-summary.ts +4 -0
  234. package/src/console/ui-next/src/features/flows/traces/trace-detail-sheet.tsx +8 -0
  235. package/src/console/ui-next/src/features/flows/traces/waterfall-bars.ts +4 -0
  236. package/src/console/ui-next/src/features/flows/traces/waterfall-tooltip.ts +9 -3
  237. package/src/console/ui-next/src/features/store/detail/reveal-cell.tsx +7 -11
  238. package/src/console/ui-next/src/features/store/detail/store-row-detail-sheet.tsx +2 -2
  239. package/src/console/ui-next/src/features/store/lib/fields-from-table.ts +2 -0
  240. package/src/console/ui-next/src/features/store/lib/grid-model.test.ts +25 -1
  241. package/src/console/ui-next/src/features/store/lib/grid-model.ts +36 -1
  242. package/src/console/ui-next/src/features/store/query/query-results.tsx +3 -3
  243. package/src/console/ui-next/src/features/units/detail/effects-summary.tsx +2 -0
  244. package/src/console/ui-next/src/features/units/lib/call-read-safe.ts +3 -1
  245. package/src/console/ui-next/src/features/units/lib/fields-from-schema.ts +6 -0
  246. package/src/docker/ai-model-status.test.ts +1 -12
  247. package/src/docker/ai-model-status.ts +10 -38
  248. package/src/docker/compose-up.test.ts +100 -0
  249. package/src/docker/compose-up.ts +292 -0
  250. package/src/docker/compose.ts +4 -14
  251. package/src/docker/derive.ts +9 -34
  252. package/src/docker/docker.test.ts +16 -261
  253. package/src/docker/images-config.test.ts +13 -25
  254. package/src/docker/index.ts +1 -24
  255. package/src/docker/recipes/index.ts +0 -23
  256. package/src/docker/recipes/pgdog.ts +6 -4
  257. package/src/docker/stack-id.test.ts +2 -2
  258. package/src/docker/stack-id.ts +0 -1
  259. package/src/docker/types.ts +2 -2
  260. package/src/drivers/ai-anthropic.ts +10 -0
  261. package/src/drivers/ai-openai-compatible.ts +34 -7
  262. package/src/drivers/ai-providers.test.ts +0 -107
  263. package/src/drivers/ai-stream.test.ts +0 -34
  264. package/src/drivers/ai-types.ts +17 -8
  265. package/src/drivers/channel-fcm.ts +6 -1
  266. package/src/drivers/channel-msegat.ts +6 -1
  267. package/src/drivers/channel-resend.ts +5 -1
  268. package/src/drivers/channel-smtp.ts +5 -1
  269. package/src/drivers/channel-sndr.ts +10 -1
  270. package/src/drivers/channel-taqnyat-mail.ts +5 -1
  271. package/src/drivers/channel-taqnyat-whatsapp.ts +6 -1
  272. package/src/drivers/channel-taqnyat.ts +6 -1
  273. package/src/drivers/channel-types.ts +10 -0
  274. package/src/drivers/channel-unifonic.ts +6 -1
  275. package/src/drivers/channel-wa-cloud.ts +6 -1
  276. package/src/drivers/channel-webpush.ts +6 -1
  277. package/src/drivers/external.ts +33 -0
  278. package/src/drivers/index.ts +0 -10
  279. package/src/drivers/meilisearch.ts +6 -0
  280. package/src/drivers/oauth-types.ts +4 -0
  281. package/src/drivers/postgres.test.ts +74 -3
  282. package/src/drivers/postgres.ts +175 -6
  283. package/src/drivers/signal-types.ts +5 -5
  284. package/src/drivers/types.ts +7 -0
  285. package/src/drivers/vault-types.ts +5 -0
  286. package/src/elements/ai/declare.ts +17 -4
  287. package/src/elements/ai/eval.ts +1 -1
  288. package/src/elements/ai/mcp-http.ts +1 -1
  289. package/src/elements/ai/pii.ts +1 -1
  290. package/src/elements/ai/providers.test.ts +289 -0
  291. package/src/elements/ai/providers.ts +169 -0
  292. package/src/elements/ai/runtime.ts +68 -5
  293. package/src/elements/ai/schema.ts +2 -2
  294. package/src/elements/ai.test.ts +7 -7
  295. package/src/elements/ai.ts +17 -1
  296. package/src/elements/channel/runtime.ts +105 -12
  297. package/src/elements/clock/cron-fields.test.ts +144 -0
  298. package/src/elements/clock/cron-fields.ts +185 -0
  299. package/src/elements/clock/declare.ts +247 -3
  300. package/src/elements/clock.ts +21 -1
  301. package/src/elements/index.ts +15 -0
  302. package/src/elements/signal/chaos-child.ts +1 -2
  303. package/src/elements/signal/declare.ts +65 -37
  304. package/src/elements/signal/delivery-modes.test.ts +11 -31
  305. package/src/elements/signal/dry-run-replay.test.ts +1 -7
  306. package/src/elements/signal/dry-run-write-isolation.test.ts +1 -7
  307. package/src/elements/signal/key-ordering.test.ts +6 -26
  308. package/src/elements/signal/lease-reclaim.test.ts +2 -6
  309. package/src/elements/signal/optional-emit.test.ts +6 -9
  310. package/src/elements/signal/order-lifecycle.test.ts +4 -17
  311. package/src/elements/signal/orphan-messages.test.ts +4 -15
  312. package/src/elements/signal/reconcile.test.ts +2 -2
  313. package/src/elements/signal/runtime.ts +1 -1
  314. package/src/elements/signal/schema-emit.test.ts +4 -8
  315. package/src/elements/signal.test.ts +24 -49
  316. package/src/elements/signal.ts +9 -2
  317. package/src/elements/store/domain-ddl.test.ts +1 -1
  318. package/src/elements/store/live-http.test.ts +9 -4
  319. package/src/elements/store/prepare-row.test.ts +123 -0
  320. package/src/elements/store/resource.ts +43 -12
  321. package/src/elements/store/schema-decl.ts +117 -0
  322. package/src/elements/store/search-backfill.ts +205 -0
  323. package/src/elements/store/search-bind.ts +66 -0
  324. package/src/elements/store/search-bm25.ts +78 -0
  325. package/src/elements/store/search-ddl.ts +156 -0
  326. package/src/elements/store/search-embed-flow.ts +141 -0
  327. package/src/elements/store/search-errors.ts +34 -0
  328. package/src/elements/store/search-fusion.ts +112 -0
  329. package/src/elements/store/search-lsh.ts +179 -0
  330. package/src/elements/store/search-runtime.ts +300 -0
  331. package/src/elements/store/search.test.ts +144 -0
  332. package/src/elements/store/sql-session.test.ts +1 -0
  333. package/src/elements/store/sql-session.ts +83 -3
  334. package/src/elements/store/table.ts +23 -2
  335. package/src/elements/store/upsert-app.test.ts +1 -3
  336. package/src/elements/store.ts +50 -0
  337. package/src/full.ts +4 -2
  338. package/src/http.ts +4 -1
  339. package/src/i18n/catalogs/ar.ts +14 -6
  340. package/src/i18n/catalogs/en.ts +14 -6
  341. package/src/index.ts +6 -1
  342. package/src/kernel/adopt-barrel-fresh.test.ts +7 -7
  343. package/src/kernel/adopt-routes.ts +9 -1
  344. package/src/kernel/app-auth.ts +5 -0
  345. package/src/kernel/app.ts +102 -9
  346. package/src/kernel/auto-cache.test.ts +6 -12
  347. package/src/kernel/auto-registry.test.ts +3 -3
  348. package/src/kernel/boot-bind/ai.test.ts +22 -19
  349. package/src/kernel/boot-bind/ai.ts +5 -43
  350. package/src/kernel/boot-bind/clock.ts +23 -5
  351. package/src/kernel/boot-bind/honor-config.test.ts +4 -4
  352. package/src/kernel/boot.test.ts +11 -6
  353. package/src/kernel/boot.ts +66 -16
  354. package/src/kernel/boundary-contract.ts +93 -0
  355. package/src/kernel/budget.test.ts +1 -1
  356. package/src/kernel/call.ts +89 -0
  357. package/src/kernel/capability.ts +6 -0
  358. package/src/kernel/client-descriptor.ts +123 -0
  359. package/src/kernel/clock-timezone.test.ts +80 -0
  360. package/src/kernel/correlation.test.ts +1 -1
  361. package/src/kernel/dry-run.ts +11 -8
  362. package/src/kernel/effects-stamping.test.ts +42 -9
  363. package/src/kernel/effects.test.ts +4 -2
  364. package/src/kernel/effects.ts +51 -9
  365. package/src/kernel/errors-channel.ts +17 -0
  366. package/src/kernel/errors-live-resume.ts +3 -2
  367. package/src/kernel/errors-tenant.ts +7 -4
  368. package/src/kernel/errors.registry-helpers.ts +96 -0
  369. package/src/kernel/errors.registry.test.ts +139 -25
  370. package/src/kernel/errors.ts +102 -23
  371. package/src/kernel/external-effects.test.ts +196 -0
  372. package/src/kernel/flow.test.ts +13 -4
  373. package/src/kernel/flow.ts +69 -71
  374. package/src/kernel/fx-ask-telemetry.test.ts +2 -2
  375. package/src/kernel/fx-dead-letters.test.ts +3 -3
  376. package/src/kernel/fx-fetch.ts +55 -0
  377. package/src/kernel/fx-live-stream.ts +2 -2
  378. package/src/kernel/fx-live.test.ts +8 -8
  379. package/src/kernel/fx.test.ts +17 -11
  380. package/src/kernel/fx.ts +180 -57
  381. package/src/kernel/horizontal-child.ts +1 -1
  382. package/src/kernel/http-query.test.ts +3 -6
  383. package/src/kernel/index.ts +13 -3
  384. package/src/kernel/instance-id.ts +1 -1
  385. package/src/kernel/instances.test.ts +40 -0
  386. package/src/kernel/instances.ts +47 -9
  387. package/src/kernel/live-http.test.ts +6 -7
  388. package/src/kernel/live-http.ts +6 -2
  389. package/src/kernel/live-resume.test.ts +1 -1
  390. package/src/kernel/mcp-tool.test.ts +3 -3
  391. package/src/kernel/on.ts +98 -4
  392. package/src/kernel/pipeline.test.ts +12 -15
  393. package/src/kernel/plugin-elements.test.ts +1 -1
  394. package/src/kernel/stamp-http.test.ts +3 -3
  395. package/src/kernel/triggers.ts +210 -95
  396. package/src/kernel-entry.ts +0 -1
  397. package/src/manifest/diff.ts +11 -1
  398. package/src/manifest/fixtures/skyport.excerpt.json +1 -1
  399. package/src/manifest/types.ts +46 -2
  400. package/src/mcp/docs-index.ts +3 -3
  401. package/src/mcp/docs-mcp.test.ts +2 -2
  402. package/src/mcp/docs-tools.ts +1 -1
  403. package/src/okid.test.ts +56 -0
  404. package/src/okid.ts +55 -11
  405. package/src/plugins/anonymous.ts +8 -4
  406. package/src/plugins/auth/shared.ts +27 -3
  407. package/src/plugins/auth-delivery.mailpit.integration.test.ts +1 -1
  408. package/src/plugins/auth-methods.security.test.ts +561 -23
  409. package/src/plugins/config-source.ts +1 -1
  410. package/src/plugins/csrf.test.ts +65 -0
  411. package/src/plugins/index.ts +2 -0
  412. package/src/plugins/magic-link.ts +36 -16
  413. package/src/plugins/oauth/shared.ts +3 -1
  414. package/src/plugins/oauth.ts +22 -14
  415. package/src/plugins/otp.ts +37 -21
  416. package/src/plugins/passkey-webauthn.ts +9 -6
  417. package/src/plugins/passkey.ts +98 -26
  418. package/src/plugins/pre-account-hijack.test.ts +223 -0
  419. package/src/plugins/two-factor.ts +466 -37
  420. package/src/plugins/username.ts +19 -7
  421. package/src/release/build-lib.ts +1 -0
  422. package/src/release/limits.ts +2 -2
  423. package/src/release/measure.ts +1 -1
  424. package/src/runs/collect.test.ts +0 -2
  425. package/src/runtime/json-code-block.test.ts +250 -20
  426. package/src/runtime/json-code-block.ts +1261 -41
  427. package/src/term.test.ts +1 -1
  428. package/src/test/create-test-app.test.ts +12 -12
  429. package/src/test/live-signals.test.ts +6 -6
  430. package/src/test/provisions.integration.test.ts +10 -14
  431. package/src/test/reset-element-registries.ts +1 -1
  432. package/src/test/tenant-isolation.test.ts +12 -6
  433. package/site/content/docs/deployment/docker-swarm.mdx +0 -164
  434. package/site/content/docs/deployment/docker.mdx +0 -227
  435. package/site/content/docs/deployment/index.mdx +0 -83
  436. package/site/content/docs/deployment/kubernetes.mdx +0 -176
  437. package/site/content/docs/deployment/meta.json +0 -5
  438. package/site/content/docs/deployment/reverse-proxy.mdx +0 -234
  439. package/site/content/docs/elements/ai.mdx +0 -385
  440. package/site/content/docs/elements/channel.mdx +0 -346
  441. package/site/content/docs/elements/clock.mdx +0 -244
  442. package/site/content/docs/elements/flow.mdx +0 -420
  443. package/site/content/docs/elements/gate.mdx +0 -436
  444. package/site/content/docs/elements/signal.mdx +0 -380
  445. package/site/content/docs/elements/store.mdx +0 -1099
  446. package/site/content/docs/elements/vault.mdx +0 -405
  447. package/site/content/docs/get-started/basic-usage.mdx +0 -173
  448. package/site/content/docs/get-started/index.mdx +0 -43
  449. package/site/content/docs/get-started/installation.mdx +0 -220
  450. package/site/content/docs/get-started/introduction.mdx +0 -132
  451. package/site/content/docs/get-started/meta.json +0 -13
  452. package/site/content/docs/get-started/project-structure.mdx +0 -925
  453. package/site/content/docs/get-started/testing.mdx +0 -328
  454. package/site/content/docs/get-started/why.mdx +0 -162
  455. package/site/content/docs/recipes/llama-cpp.mdx +0 -151
  456. package/site/content/docs/recipes/ollama.mdx +0 -142
  457. package/site/content/docs/recipes/sglang.mdx +0 -105
  458. package/site/content/docs/recipes/vllm.mdx +0 -106
  459. package/site/content/docs/reference/cli.md +0 -232
  460. package/site/content/docs/reference/client.mdx +0 -469
  461. package/site/content/docs/reference/security.md +0 -74
  462. package/src/cli/ai-setup/detect-ollama.ts +0 -213
  463. package/src/cli/ai-setup/recommend.test.ts +0 -225
  464. package/src/cli/ai-setup/recommend.ts +0 -225
  465. package/src/cli/dev-controls.test.ts +0 -122
  466. package/src/cli/dev-controls.ts +0 -164
  467. package/src/cli/tui/DevLive.tsx +0 -126
  468. package/src/console/ui-next/dist/assets/access-page-De7Lc2JC.js +0 -4
  469. package/src/console/ui-next/dist/assets/agent-disclosure-BP0Y0Sux.js +0 -1
  470. package/src/console/ui-next/dist/assets/cache-glyph-B5X-NM0-.js +0 -1
  471. package/src/console/ui-next/dist/assets/call-pii-button-ChAUiLo9.js +0 -1
  472. package/src/console/ui-next/dist/assets/collapsible-DGnOM2ph.js +0 -1
  473. package/src/console/ui-next/dist/assets/copy-inline-button-DBHhgHKP.js +0 -1
  474. package/src/console/ui-next/dist/assets/dagre.esm-ZwcdTuZZ.js +0 -1
  475. package/src/console/ui-next/dist/assets/detail-header-DhHM1iaZ.js +0 -1
  476. package/src/console/ui-next/dist/assets/dropdown-menu-_NjTEo5_.js +0 -1
  477. package/src/console/ui-next/dist/assets/duration-tone-sC3lGABz.js +0 -9
  478. package/src/console/ui-next/dist/assets/element-icons-BVXtRyd3.js +0 -1
  479. package/src/console/ui-next/dist/assets/explorer-empty-2uIhBu0_.js +0 -1
  480. package/src/console/ui-next/dist/assets/flows-page-RGy7VEA_.js +0 -1
  481. package/src/console/ui-next/dist/assets/highlighted-json-Awq7gYdu.js +0 -154
  482. package/src/console/ui-next/dist/assets/http-method-_UHM2ODJ.js +0 -1
  483. package/src/console/ui-next/dist/assets/index-Ck88Jmv8.css +0 -2
  484. package/src/console/ui-next/dist/assets/index-_rgpdVzo.js +0 -66
  485. package/src/console/ui-next/dist/assets/link-BX6Vqztd.js +0 -1
  486. package/src/console/ui-next/dist/assets/observability-page-Ds6pcnh-.js +0 -4
  487. package/src/console/ui-next/dist/assets/preload-helper-oH4irX4C.js +0 -1
  488. package/src/console/ui-next/dist/assets/react-D8E3mtu1.js +0 -1
  489. package/src/console/ui-next/dist/assets/react-dom-Bph1y7z7.js +0 -9
  490. package/src/console/ui-next/dist/assets/replica-lag-DKRrbvdo.js +0 -18
  491. package/src/console/ui-next/dist/assets/request-meta-DV0ywz7t.js +0 -1
  492. package/src/console/ui-next/dist/assets/shortcut-JQIZlWfm.js +0 -1
  493. package/src/console/ui-next/dist/assets/shortcut-keys-DKxNTe_m.js +0 -1
  494. package/src/console/ui-next/dist/assets/skeleton-D-czQJT6.js +0 -1
  495. package/src/console/ui-next/dist/assets/store-page-02xOiqIK.js +0 -41
  496. package/src/console/ui-next/dist/assets/trace-detail-sheet-B09O8rA6.js +0 -2
  497. package/src/console/ui-next/dist/assets/tree-expand-toggle-BtyhmWb4.js +0 -55
  498. package/src/console/ui-next/dist/assets/units-page-4rHOePuE.js +0 -1
  499. package/src/console/ui-next/dist/assets/useMutation-B8EO02Ej.js +0 -1
  500. package/src/console/ui-next/dist/assets/useRender-BE2A9BWC.js +0 -1
  501. package/src/console/ui-next/dist/assets/vault-page-DISPgxLM.js +0 -2
  502. package/src/console/ui-next/dist/assets/xyflow-D7n4g6go.js +0 -7
  503. package/src/console/ui-next/dist/assets/xyflow-DZ0Ws1xk.css +0 -1
  504. package/src/docker/ollama-pull.ts +0 -232
  505. package/src/docker/recipes/llama-cpp.ts +0 -298
  506. package/src/docker/recipes/ollama.ts +0 -44
  507. package/src/docker/recipes/sglang.ts +0 -55
  508. package/src/docker/recipes/vllm.ts +0 -44
  509. package/src/drivers/ai-ollama-tools.integration.test.ts +0 -109
  510. package/src/drivers/ai-ollama.integration.test.ts +0 -184
  511. package/src/drivers/ai-ollama.ts +0 -389
  512. package/src/drivers/ollama.ts +0 -14
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: "OKID"
3
- description: "OKE's native id generator — compact, URL-safe, cryptographically random ids from okengine/okid, with an opt-in time-sortable and alphabet-controlled variant."
3
+ description: "OKE's native id generator — compact, URL-safe, cryptographically random ids from okengine/okid, with opt-in prefix, time-sortable, and alphabet-controlled variants."
4
4
  icon: "Hash"
5
5
  source: "docs/spec/unified-theory.md"
6
6
  ---
@@ -31,6 +31,7 @@ import { okid } from "okengine/okid";
31
31
  ```typescript
32
32
  const userId = okid();
33
33
  const requestId = okid(16);
34
+ const typedId = okid({ prefix: "usr_" });
34
35
  const eventKey = okid({ sortable: true });
35
36
  const inviteCode = okid({ lookAlikes: false, uppercase: false });
36
37
  ```
@@ -55,21 +56,23 @@ The same 21-character id lands in your SQL primary keys, KV keys, and trace ids.
55
56
 
56
57
  ## Reference
57
58
 
58
- | Call | Result | Notes |
59
- | -------------------------------------------------- | ----------------------------------------- | --------------------------------------- |
60
- | `okid()` | 21-char URL-safe id, 126 bits of entropy | 64-char alphabet, `a-zA-Z0-9-_` |
61
- | `okid(length)` | id of exactly `length` characters | integer between 8 and 128 |
62
- | `okid({ length })` | options form, id of `length` | default 21 |
63
- | `okid({ sortable })` | time-prefixed id, 8 prefix + `length − 8` | lexicographic order creation order |
64
- | `okid({ numbers, lowercase, uppercase, symbols })` | charset control | each group defaults to on |
65
- | `okid({ lookAlikes })` | confusable-char control | `lookAlikes: false` drops `1lI0Oouv5Ss` |
59
+ | Call | Result | Notes |
60
+ | -------------------------------------------------- | ---------------------------------------- | --------------------------------------- |
61
+ | `okid()` | 21-char URL-safe id, 126 bits of entropy | 64-char alphabet, `a-zA-Z0-9-_` |
62
+ | `okid(length)` | id of exactly `length` characters | integer between 8 and 128 |
63
+ | `okid({ length })` | options form, body of `length` | default 21 |
64
+ | `okid({ prefix })` | `prefix` + body | body length unchanged; see Options |
65
+ | `okid({ sortable })` | time-prefixed body, 8 + `length 8` | lexicographic order creation order |
66
+ | `okid({ numbers, lowercase, uppercase, symbols })` | charset control | each group defaults to on |
67
+ | `okid({ lookAlikes })` | confusable-char control | `lookAlikes: false` drops `1lI0Oouv5Ss` |
66
68
 
67
69
  ### Options
68
70
 
69
71
  | Option | Type | Default | Meaning |
70
72
  | ------------ | --------- | ------- | ----------------------------------------------------------- |
71
- | `length` | `number` | `21` | total id length in characters, between 8 and 128 |
72
- | `sortable` | `boolean` | `false` | prefix an 8-char epoch-ms timestamp so sorting follows time |
73
+ | `length` | `number` | `21` | generated body length (8–128); does not include `prefix` |
74
+ | `prefix` | `string` | `""` | fixed label prepended to the body (e.g. `"usr_"`, `"evt_"`) |
75
+ | `sortable` | `boolean` | `false` | prefix the body with an 8-char epoch-ms timestamp |
73
76
  | `numbers` | `boolean` | `true` | include `0-9` |
74
77
  | `lowercase` | `boolean` | `true` | include `a-z` |
75
78
  | `uppercase` | `boolean` | `true` | include `A-Z` |
@@ -83,10 +86,11 @@ The same 21-character id lands in your SQL primary keys, KV keys, and trace ids.
83
86
  | `OKID_ALPHABET` | `a-zA-Z0-9-_` | default, Base64URL order |
84
87
  | `OKID_SORTABLE_ALPHABET` | alphabet sorted by code unit (same chars) | used by the sortable encoder |
85
88
  | `OKID_LOOKALIKE_CHARS` | `1lI0Oouv5Ss` | dropped when `lookAlikes: false` |
86
- | `OKID_DEFAULT_LENGTH` | `21` | default length |
87
- | `OKID_MIN_LENGTH` | `8` | shortest non-sortable length |
88
- | `OKID_MAX_LENGTH` | `128` | longest length |
89
- | `OKID_SORTABLE_MIN_LENGTH` | `16` | shortest sortable length (8+8) |
89
+ | `OKID_DEFAULT_LENGTH` | `21` | default body length |
90
+ | `OKID_MIN_LENGTH` | `8` | shortest non-sortable body |
91
+ | `OKID_MAX_LENGTH` | `128` | longest body |
92
+ | `OKID_SORTABLE_MIN_LENGTH` | `16` | shortest sortable body (8+8) |
93
+ | `OKID_MAX_PREFIX_LENGTH` | `32` | longest semantic `prefix` |
90
94
 
91
95
  ## Collision resistance
92
96
 
@@ -94,6 +98,12 @@ Every character is drawn uniformly from the alphabet with `crypto.getRandomValue
94
98
 
95
99
  **Consequence:** two ids minted at the same millisecond are still distinct — the timestamp prefix never replaces entropy, it prefixes it.
96
100
 
101
+ ## Semantic prefixes
102
+
103
+ `prefix` is a fixed label (`"usr_"`, `"evt_"`, `"inst-"`) prepended to the generated body. Characters must belong to `OKID_ALPHABET` (max 32). `length` stays the body size; the returned string is `prefix + body`.
104
+
105
+ **Consequence:** `okid({ prefix: "usr_", sortable: true })` yields `usr_` + 8-char timestamp + random tail — the label sorts first, then time.
106
+
97
107
  ## Sortable ids
98
108
 
99
109
  `sortable: true` prepends 48 bits of `Date.now()` encoded in exactly 8 characters, in an alphabet whose sort order matches time order. Sorting a batch of these ids reproduces the creation order across milliseconds.
@@ -108,7 +118,7 @@ Turning groups off shrinks the alphabet. With a non-power-of-two alphabet, OKID
108
118
 
109
119
  ## Under the hood
110
120
 
111
- The generator is a pure function: no counters, no process or machine fingerprint, no shared mutable state. It is safe to call concurrently from any number of workers, and every id uses only the bytes it needs — no hidden timestamp, no hidden prefix.
121
+ The generator is a pure function: no counters, no process or machine fingerprint, no shared mutable state. It is safe to call concurrently from any number of workers, and every body uses only the bytes it needs — no hidden timestamp unless `sortable` is on.
112
122
 
113
123
  ## Troubleshooting
114
124
 
@@ -122,6 +132,13 @@ Passing `numbers: false, lowercase: false, uppercase: false, symbols: false` at
122
132
 
123
133
  `okid(0)`, `okid(-1)`, `okid(7)`, `okid(129)`, and non-integer lengths throw a `RangeError`. Sortable ids have a higher floor: passing a sortable length below 16 throws. Keep lengths between 8 and 128 (16–128 for sortable).
124
134
 
135
+ </Accordion>
136
+ <Accordion title="I get a RangeError for a prefix">
137
+
138
+ Characters outside `OKID_ALPHABET` (for example `usr:` or a space) throw
139
+ `okid: prefix contains invalid character … — use characters from OKID_ALPHABET`.
140
+ A prefix longer than 32 throws `okid: prefix length … exceeds max 32` — stick to `A-Za-z0-9-_`.
141
+
125
142
  </Accordion>
126
143
  <Accordion title="My ids are not sortable by the alphabet order I expected">
127
144
 
@@ -130,8 +147,16 @@ The default alphabet order is not lexicographic; `_` sorts between uppercase and
130
147
  </Accordion>
131
148
  </Accordions>
132
149
 
133
- ## References
150
+ ## Learn more
134
151
 
135
152
  - [Store](/docs/elements/store) — `defaultFn(id)` in table declarations delegates to `okid()`
136
153
  - [fx](/docs/reference/fx) — `fx.id()` in the runtime uses `okid()`
137
154
  - [Clock](/docs/elements/clock) — process `instanceId` (`inst-<okid>`) is an OKID
155
+
156
+ ## Next
157
+
158
+ <Cards>
159
+ <Card title="fx" description="fx.id() in Flows." href="/docs/reference/fx" />
160
+ <Card title="Store" description="defaultFn(id) on columns." href="/docs/elements/store" />
161
+ <Card title="Client" description="Ids round-trip on typed routes." href="/docs/client" />
162
+ </Cards>
@@ -82,7 +82,7 @@ Every method below exists on both the fluent definition and the boot-time builde
82
82
  | `.image(role, recipe)` | An image recipe for a docker role |
83
83
  | `.table(name, columns, options)` | A whole DB table, merged into the generated schema (`options.description` / `plane` optional) |
84
84
  | `.errors(map)` | Typed errors flows can fail with |
85
- | `.client(name, ext)` | A typed client extension (reserved seam — not yet merged into `createClient`) |
85
+ | `.client(name, ext)` | Reserved plugin seam — prefer `createAuthClient` method helpers for auth |
86
86
  | `.consolePanel(panel)` | A Console panel (ESM entry loaded at runtime) |
87
87
  | `.cli(name, handler)` | An `oke <name>` CLI command |
88
88
  | `.config(schema)` | A config schema; values live on the plugin identity |
@@ -133,7 +133,7 @@ Plugin options are static by default — changing them means a redeploy. Every o
133
133
  ### Declare the source and its sync flow
134
134
 
135
135
  ```typescript title="src/app.ts"
136
- import { every, oke, on, store } from "okengine";
136
+ import { clock, oke, on, store } from "okengine";
137
137
  import { configSource, maintenanceMode } from "okengine/plugins";
138
138
 
139
139
  const db = store.sql("app");
@@ -146,7 +146,8 @@ const maintenance = configSource({
146
146
  kv: cache, // read-through cache (optional)
147
147
  });
148
148
 
149
- on(every("30s"), maintenance.sync()); // one clock flow refreshes the box
149
+ const maintenanceSyncClock = clock("maintenance.sync", { every: "30s" });
150
+ on(maintenanceSyncClock, maintenance.sync()); // one clock flow refreshes the box
150
151
 
151
152
  export const app = oke({ name: "shop", env: "dev" }).plug(maintenanceMode(maintenance));
152
153
  ```
@@ -0,0 +1,197 @@
1
+ ---
2
+ title: "Security"
3
+ description: "Host and Origin allow-lists, user vs operator planes, Console and MCP posture."
4
+ icon: "Shield"
5
+ source: "docs/spec/unified-theory.md"
6
+ ---
7
+
8
+ Every served request on the backend, Console, and app MCP passes Host / Origin checks
9
+ before your Flow runs. Private bind addresses are not a substitute for that check.
10
+
11
+ Reach for this page when you put a public hostname in front of the app, open Console
12
+ in production, or wire MCP tokens.
13
+
14
+ <Callout title="The one rule">
15
+ Pass every public hostname in `allowedHosts` on `createBunRuntime().serve` (and the Console / MCP
16
+ serve options). Loopback is always allowed; `Origin: null` is always rejected. Failures return
17
+ **403**.
18
+ </Callout>
19
+
20
+ ## Smallest Example
21
+
22
+ <Steps>
23
+
24
+ <Step>
25
+ ### Serve with an explicit host allow-list
26
+
27
+ ```typescript title="src/app.ts"
28
+ import { createBunRuntime } from "okengine/http";
29
+ import { app } from "./app";
30
+
31
+ createBunRuntime().serve(app, {
32
+ port: Number(process.env.PORT ?? 6530),
33
+ hostname: "0.0.0.0",
34
+ allowedHosts: ["app.example.com", ".example.com"],
35
+ });
36
+ ```
37
+
38
+ `.example.com` allows `a.example.com` (Vite-style suffix). Always merged with
39
+ `localhost` · `127.0.0.1` · `::1` and the listen hostname when it is not a
40
+ wildcard bind.
41
+
42
+ </Step>
43
+
44
+ <Step>
45
+ ### Confirm a bad Host is refused
46
+
47
+ ```bash
48
+ curl -i http://127.0.0.1:6530/health -H "Host: evil.example"
49
+ ```
50
+
51
+ Expect `403` with body `Forbidden: unexpected Host header`.
52
+
53
+ </Step>
54
+
55
+ </Steps>
56
+
57
+ ## Progressive Patterns
58
+
59
+ <Tabs items={["Reverse proxy", "Planes", "MCP"]}>
60
+
61
+ <Tab value="Reverse proxy">
62
+
63
+ Edge terminates TLS and forwards to the app. The `Host` the app sees must be on
64
+ the allow-list — usually the public name, not the container hostname.
65
+
66
+ ```typescript
67
+ createBunRuntime().serve(app, {
68
+ hostname: "0.0.0.0",
69
+ allowedHosts: ["app.example.com"],
70
+ });
71
+ ```
72
+
73
+ **Consequence:** omitting the public name behind Caddy / nginx / Traefik looks
74
+ like a random 403 to browsers that send the site's `Host`.
75
+
76
+ </Tab>
77
+
78
+ <Tab value="Planes">
79
+
80
+ Only two planes exist: **user** (application Flows, `fx.auth`) and **operator**
81
+ (Console / MCP capability, `fx.operator`). Declare `plane: "operator"` on Flows
82
+ that must stay off the public API.
83
+
84
+ A user-plane token on an operator Flow (or the reverse) throws `CrossPlaneError`.
85
+ API keys and Console `invoke-as` are attenuated — a derived principal never
86
+ exceeds the creator's scopes.
87
+
88
+ </Tab>
89
+
90
+ <Tab value="MCP">
91
+
92
+ | Surface | Port | Auth |
93
+ | -------- | -------- | --------------------------------------------------------- |
94
+ | App MCP | **6535** | Bearer required **even on localhost**; audience `oke-mcp` |
95
+ | Docs MCP | **6536** | Host / Origin only — public docs, not a live Manifest |
96
+
97
+ App MCP inherits **operator-plane** capability and never exceeds it. Tokens are
98
+ never forwarded upstream. Tools declare scopes; writes need confirmation.
99
+
100
+ </Tab>
101
+
102
+ </Tabs>
103
+
104
+ ## Host / Origin Rules
105
+
106
+ | Check | Behavior |
107
+ | -------- | -------------------------------------------------------------------- |
108
+ | `Host` | Required; must match the effective allow-list |
109
+ | `Origin` | When present, host must match; `Origin: null` → 403 |
110
+ | Defaults | Always includes loopback + listen hostname (unless `0.0.0.0` / `::`) |
111
+ | Extras | `ServeOptions.allowedHosts` — never replaces the mandatory check |
112
+
113
+ `allowedHosts` lives on **serve options**, not in `oke.config.ts`. Pass it wherever
114
+ you call `serve` for **6530**, Console **6533**, and app MCP **6535**.
115
+
116
+ ## Console Posture
117
+
118
+ | Control | Meaning |
119
+ | ------------- | -------------------------------------------------------------------------- |
120
+ | Host / Origin | Same allow-list logic as the backend |
121
+ | CSP | `default-src 'self'`; `frame-ancestors 'none'` |
122
+ | Cookies | `SameSite=Strict` |
123
+ | Claim code | Printed on `oke dev` TTY; `oke console claim-code` while setup is open |
124
+ | PII | Store / Call API mask classified fields unless `revealPii: true` (audited) |
125
+
126
+ Production Console: set `OKE_CONSOLE_SECRET` and configure
127
+ `console.prod` in [Configuration](/docs/reference/configuration#console).
128
+
129
+ ## Sessions and Audiences
130
+
131
+ | Audience | Surface |
132
+ | ------------- | -------------------- |
133
+ | `oke-app` | Application sessions |
134
+ | `oke-console` | Console operators |
135
+ | `oke-mcp` | App MCP |
136
+
137
+ Short access JWT (default ~14m) + rotating refresh. Refresh-token reuse revokes
138
+ the family.
139
+
140
+ ## Troubleshooting
141
+
142
+ <Accordions>
143
+
144
+ <Accordion title="403 Forbidden: unexpected Host header">
145
+ The request `Host` is not on the allow-list. Add the public hostname to `allowedHosts`, or hit
146
+ loopback (`localhost` / `127.0.0.1`) during local `oke dev`.
147
+ </Accordion>
148
+
149
+ <Accordion title="403 Forbidden: unexpected Origin header">
150
+ Browser sent an `Origin` whose host is not allowed, or `Origin: null`. Align the page origin with
151
+ `allowedHosts`, or call same-origin / non-browser clients without a spoofed Origin.
152
+ </Accordion>
153
+
154
+ <Accordion title="MCP tools refuse without Bearer on localhost">
155
+ App MCP on **6535** requires a Bearer with audience `oke-mcp` even on loopback. Docs MCP on
156
+ **6536** does not — it serves documentation only.
157
+ </Accordion>
158
+
159
+ <Accordion title="CrossPlaneError">
160
+ A user-plane token reached an operator Flow (or the reverse). Use the principal that matches the
161
+ Flow's `plane`.
162
+ </Accordion>
163
+
164
+ <Accordion title="AttenuationError">
165
+ A derived key or invoke-as identity requested a scope the creator cannot grant. Re-issue with a
166
+ subset of the creator's scopes.
167
+ </Accordion>
168
+
169
+ </Accordions>
170
+
171
+ ## Learn more
172
+
173
+ - [CLI](/docs/reference/cli) — `oke dev`, `oke console claim-code`
174
+ - [Gate](/docs/elements/gate) — policies, API keys, tenancy
175
+ - [The Model](/docs/understand/the-model) — one shape, one door, fixed vocabulary
176
+ - [Errors](/docs/reference/errors) — `CrossPlaneError`, `SessionError`, `AttenuationError`
177
+ - [Environment Variables](/docs/reference/environment-variables) — `OKE_CONSOLE_SECRET`
178
+
179
+ ## Next
180
+
181
+ <Cards>
182
+ <Card
183
+ title="Gate"
184
+ description="Auth, authorization, and rate limits."
185
+ href="/docs/elements/gate"
186
+ />
187
+ <Card
188
+ title="CLI"
189
+ description="oke and create-oke command catalogue."
190
+ href="/docs/reference/cli"
191
+ />
192
+ <Card
193
+ title="The Model"
194
+ description="One shape for every trigger, one door for every effect."
195
+ href="/docs/understand/the-model"
196
+ />
197
+ </Cards>
@@ -0,0 +1,5 @@
1
+ {
2
+ "title": "Understand",
3
+ "icon": "Compass",
4
+ "pages": ["the-problem", "the-model", "the-vocabulary", "the-anatomy"]
5
+ }
@@ -0,0 +1,132 @@
1
+ ---
2
+ title: "The Anatomy"
3
+ description: "The five pieces behind on(trigger, flow) — on, trigger, flow, do, and fx — explained one at a time, then combined."
4
+ icon: "PenTool"
5
+ ---
6
+
7
+ Everything a Flow does reduces to one line:
8
+
9
+ ```typescript
10
+ on(
11
+ trigger,
12
+ flow({
13
+ do: (input, fx) => {
14
+ /* ... */
15
+ },
16
+ }),
17
+ );
18
+ ```
19
+
20
+ If that line doesn't mean much yet, that's what this page is for. Five pieces make it up. We'll take them one at a time, then put them together using a complete signup example.
21
+
22
+ ## `on(...)` — wires a trigger to a flow
23
+
24
+ `on` does exactly one thing: it connects "something that can happen" to "code that should run when it does." Nothing executes until this connection exists.
25
+
26
+ ```typescript
27
+ on(someTrigger, someFlow);
28
+ ```
29
+
30
+ That's the whole job. The interesting parts are what goes in each slot.
31
+
32
+ ## A trigger — the answer to "when"
33
+
34
+ The first argument to `on` is the trigger: whatever wakes the code up. A trigger doesn't run any of your logic — it only answers one question: _when should this happen?_
35
+
36
+ ```typescript
37
+ http.post(); // path from the file tree — e.g. src/flows/users/signup.ts → POST /users/signup
38
+ ```
39
+
40
+ There are five kinds of trigger in total — the table at the end of this page lists them. For now: the trigger is the _when_, and it's the only thing that changes between an endpoint, a scheduled job, and everything else.
41
+
42
+ ## `flow(...)` — the actual unit of work
43
+
44
+ The second argument to `on` is a Flow — declared with the `flow()` function. It answers _what_: what work is this, and what does it promise about its inputs and outputs?
45
+
46
+ ```typescript
47
+ flow({
48
+ do: /* the actual code — next */,
49
+ });
50
+ ```
51
+
52
+ Omit the name on tree files — the compiler stamps `unit.export` (e.g. `users.signup`).
53
+ Pass `flow("users.signup", { … })` only for control: barrels, stable names across
54
+ moves, or call-only Flows you `fx.call` by name.
55
+
56
+ ## `do` — the code that actually runs
57
+
58
+ `do` is a function you write. It answers _how_. It receives two things: `input` (your data) and `fx` (next). Everything your Flow actually does lives here.
59
+
60
+ ```typescript
61
+ do: async (input, fx) => {
62
+ return { ok: true };
63
+ };
64
+ ```
65
+
66
+ ## `fx` — the only door to the outside world
67
+
68
+ `fx` is the second argument to `do`, and it's the piece the other four exist to protect. The rule is simple and absolute: **your Flow is not allowed to read a database, send an email, check a clock, or touch anything outside itself except through `fx`.**
69
+
70
+ ```typescript
71
+ do: async (input, fx) => {
72
+ const user = await fx.store(db).insert(users).values(input); // the database, through fx
73
+ await fx.send(welcomeEmail, { to: user.email }); // another system, through fx
74
+ return user;
75
+ };
76
+ ```
77
+
78
+ This one rule is what made the Month 8 drift from The Problem avoidable: if `fx` is the only door, retries, auditing, and idempotency stop being separate systems teams build by hand, and become properties of the one boundary everything already passes through.
79
+
80
+ ## Putting the five pieces together
81
+
82
+ Here is the complete signup flow, with every piece labeled where it sits:
83
+
84
+ ```typescript title="src/flows/users/signup.ts"
85
+ export const signup = on(
86
+ http.post(), // ← trigger: when (stamped POST /users/signup)
87
+ flow({
88
+ // ↑ flow: what (stamped users.signup)
89
+ do: async (input, fx) => {
90
+ // ← do: how
91
+ const user = await fx.store(db).insert(users).values(input); // ← fx: the only way out
92
+ await fx.send(welcomeEmail, { to: user.email, data: { name: user.name } });
93
+ return user;
94
+ },
95
+ }),
96
+ );
97
+ ```
98
+
99
+ <Callout title="Call-only flows">
100
+ A `flow(...)` declared without `on(...)` around it is internal — nothing outside your code can
101
+ start it. Other flows invoke it directly with `fx.call(flowRef, input)`.
102
+ </Callout>
103
+ ## Checking it against the timeline
104
+
105
+ Nothing about the code above looks more complicated than the four lines that started the drift on The Problem — because it isn't. The difference only shows up when the same pressure from that timeline hits it.
106
+
107
+ Every fork from that timeline was really the same question, asked at a different point: _is this thing that touches the outside world safe to retry, safe to audit, safe to run twice?_ On The Problem, each answer required a new system, because each system had to invent its own answer. Here, the question has one home:
108
+
109
+ - **The traffic spike from Week 2** doesn't need a queue you build and wire up by hand — running this later, safely, is something you ask of the trigger or the effect itself, not infrastructure you assemble.
110
+ - **The silent failure from Month 2** doesn't need a hand-picked retry count living in a worker nobody remembers the reasoning for. Retries are a property of the `fx` boundary every effect already passes through.
111
+ - **The compliance question from Month 4** doesn't need a `sent_emails` table written by hand from inside a background job. What was sent, and when, is something the system already knows, because nothing was allowed to send anything outside of `fx` in the first place.
112
+ - **The double-submit from Month 6** doesn't need dedup logic split across a queue and a database that never check each other. There's one call, through one door — there's no second path left for a duplicate to sneak through.
113
+
114
+ None of that required new code beyond what's above. It required the four lines to already be the kind of thing where those questions have a fixed answer, instead of a new one invented per team, per incident.
115
+
116
+ ## Five kinds of trigger
117
+
118
+ `flow`, `do`, and `fx` never change shape. Only the trigger does — and there are exactly five kinds, one per element that can independently wake a Flow up:
119
+
120
+ | Trigger | Element | Starts When |
121
+ | --------------------------------------------------- | ------- | -------------------------------- |
122
+ | `http.post()` (path from file tree) | Flow | A request arrives |
123
+ | `clock("name", { every: "10m" })` | Clock | A time interval elapses |
124
+ | `signal.once("name", {…})` / `.broadcast` / `.live` | Signal | Another flow announces something |
125
+ | `db.table(users).changed("email")` | Store | A database row changes |
126
+ | `mcp.tool("name")` | AI | An AI agent calls it |
127
+
128
+ The next section walks through each element in depth — this is just enough to recognize them when you see them.
129
+
130
+ ## Where this goes next
131
+
132
+ You've seen the problem, the model, the vocabulary, and now the exact anatomy behind every Flow — proven against the timeline that motivated it. The next step is running it yourself: from an empty folder to this exact Flow answering a real request, in one sitting.
@@ -0,0 +1,32 @@
1
+ ---
2
+ title: "The Model"
3
+ description: "The one rule that removes the disagreement between systems — stated plainly, in two parts."
4
+ icon: "Compass"
5
+ ---
6
+
7
+ ## The fix, stated as a rule
8
+
9
+ Every seam on the last page came from the same root cause: each system involved had its own idea of when it should run and what it was allowed to touch, and nothing forced those ideas to agree with each other.
10
+
11
+ OKE removes the disagreement by removing the choice. It's one rule, in two parts.
12
+
13
+ **First: every trigger reduces to the same shape.** An HTTP request, a scheduled tick, a queue message, a database change — whatever wakes the code up, what follows has one identical anatomy: `on(Trigger) → Effects`. Not four systems that happen to look similar. One system, with four ways to wake it up.
14
+
15
+ **Second: every effect passes through one door.** Nothing is allowed to touch a database, send an email, check a permission, or read the clock on its own — all of it goes through a single surface. Not because that's tidier. Because it's the only way retries, auditing, idempotency, and permission checks stop being infrastructure every team reinvents at the exact moment they get burned by not having it. Build the door once, correctly, and every trigger that walks through it inherits the same guarantees automatically.
16
+
17
+ That's the whole model. Not a bigger toolbox — a smaller number of things that are allowed to happen at all.
18
+
19
+ ## Why the door has a fixed vocabulary
20
+
21
+ A door that lets anything through isn't actually closed. So the door recognizes a fixed set of things it's willing to do, and nothing new gets added to that set unless it does something none of the existing ones can. What that set is, and why it stops at eight, is the next page.
22
+
23
+ ## What this project is called
24
+
25
+ One shape for every trigger, one door for every effect, a fixed vocabulary for what the door allows — that's what this project built. It's called **OKE**.
26
+
27
+ ---
28
+
29
+ <sub>
30
+ *OKE isn't an acronym for anything in the code. It comes from Omq Khafi — the organization this
31
+ engine grew out of — with "Engine" appended: **O**mq **K**hafi **E**ngine.*
32
+ </sub>
@@ -0,0 +1,74 @@
1
+ ---
2
+ title: "The Problem"
3
+ description: "Three unrelated features that hit the exact same wall, and the timeline that shows why."
4
+ icon: "TriangleAlert"
5
+ ---
6
+
7
+ ## Three features, same wall
8
+
9
+ **A signup flow.** A user registers. Send them a welcome email. Four lines of code — until traffic spikes, the mail provider starts rate-limiting, and "send an email" quietly needs a queue, a worker, and a retry policy nobody designed on purpose.
10
+
11
+ **A payment webhook.** A provider confirms a charge. Mark the order paid. Simple — until the provider retries the same webhook twice during a network hiccup, and "mark the order paid" needs to somehow know it already ran.
12
+
13
+ **A nightly report.** Summarize yesterday's activity and email it to managers. Trivial — until a manager's access gets revoked at 11:58pm and the report that runs at midnight has no idea the permission it checked when the feature was built isn't the permission that holds right now.
14
+
15
+ Three teams. Three domains. Nobody on any of them talked to the other two. And all three land on the identical fork: **something has to happen later, exactly once, provably — and nothing in the original four lines said what "provably" would end up costing.**
16
+
17
+ ## Follow one all the way through
18
+
19
+ Take the first one. Just the signup flow, from the day it shipped.
20
+
21
+ ```typescript
22
+ app.post("/signup", async (req, res) => {
23
+ const user = await db.users.create(req.body);
24
+ await sendMail(user.email, "Welcome!", welcomeTemplate(user));
25
+ res.json(user);
26
+ });
27
+ ```
28
+
29
+ It works. It ships. Two weeks later, a launch drives a traffic spike, the mail provider starts returning `429`, and signups start failing because an unrelated email is slow. You move the send off the request path:
30
+
31
+ ```typescript
32
+ app.post("/signup", async (req, res) => {
33
+ const user = await db.users.create(req.body);
34
+ emailQueue.add("welcome", { userId: user.id });
35
+ res.json(user);
36
+ });
37
+ ```
38
+
39
+ The endpoint is fast again. It's also no longer one system — it's an endpoint, a queue, a worker, and a Redis connection nobody else on the team knew existed until a missing `REDIS_URL` broke staging.
40
+
41
+ From here the same pattern repeats on a longer clock. A support ticket reveals a job failed silently — nobody had configured retries, so you add them, and now a specific number (3? 5? with what backoff?) lives in a file that nobody will remember the reasoning for in six weeks. Compliance asks for proof of every email sent — you add a table written to from inside the worker, and now that worker has two jobs instead of one, quietly capable of disagreeing with itself if the second write fails. Someone double-clicks submit — two jobs enqueue, two emails send, and idempotency becomes a fact that has to live in two systems that were never introduced to each other.
42
+
43
+ <SixSystemsDrift />
44
+
45
+ None of these were mistakes. Each one was the correct call, made by a competent engineer, in direct response to something that actually happened. That's what makes the drift invisible while it's happening — there's no bad decision anywhere in this story to point at.
46
+
47
+ ## What's actually going on
48
+
49
+ Look at what the six resulting files have in common: none of them agree with each other about the same three things. What counts as "done." What happens on failure. Who's allowed to do this at all.
50
+
51
+ That's the real cost — not the number of tools, but what sits between them:
52
+
53
+ - **Failure means something different in each one.** A queue retry, an HTTP 500, and a rejected promise from a mail SDK are three unrelated shapes that all happen to mean "this didn't work."
54
+ - **Permission has no fixed address.** It lives wherever whoever wrote that file remembered to put it — which means a reviewer can't point at one place and ask "is this checked?"
55
+ - **Two systems both think they own the same fact.** The database says an order is paid. The already-running webhook handler doesn't know that yet. Nothing keeps them honest with each other in the gap.
56
+ - **Nobody can see the whole thing at once.** There is no file, diagram, or dashboard where "the signup flow" exists as one object — only as the sum of files that happen to call each other.
57
+
58
+ ## If you've been doing this a while
59
+
60
+ None of the three stories above are hypothetical to you. You've shipped at least one of them — maybe with a different provider, a different table name, a different Slack channel where the incident got triaged. You've sat in the postmortem. You've written the line in the retro doc that says "we should have thought about retries from the start," knowing full well that thinking about it from the start wouldn't have told you which of forty possible failure modes was going to be the one that mattered.
61
+
62
+ That's not a criticism of your judgment. It's the actual shape of the problem: every decision in that timeline was locally correct and still added a system that doesn't speak the same language as the five before it. You didn't do this wrong. The tools you were given don't leave room to do it any other way.
63
+
64
+ ## If you haven't yet
65
+
66
+ If your code right now still looks like the four lines from Day 1 — on any feature, in any domain — this is the part that matters most: **you will hit this fork.** Not "might." Every one of the three stories above started as a sentence a product manager could say out loud in one breath. The traffic spike, the silent retry, the compliance question, the double-submit — these aren't edge cases that happen to unlucky teams. They're what happens to any trigger that lives long enough to matter, and right now you simply haven't reached that point in the timeline yet.
67
+
68
+ The four lines were never wrong. They were just the first data point on a line that already knew where it was going.
69
+
70
+ ## The actual question
71
+
72
+ Nothing above was avoidable by writing cleaner code inside any single file. The problem was never inside a file — it was that several files had to agree on things none of them were ever designed to agree on.
73
+
74
+ What would have to be true on day one for month eight to never happen?
@@ -0,0 +1,26 @@
1
+ ---
2
+ title: "The Vocabulary"
3
+ description: "The eight things the door recognizes — what each one replaces, and why nothing else made the cut."
4
+ icon: "Boxes"
5
+ ---
6
+
7
+ ## What the door recognizes
8
+
9
+ The door from the last page isn't open-ended — it recognizes a fixed set of things it's willing to do. Each one made the cut because it has _irreducible physics_: behavior that breaks if you tried to fake it using one of the others. A queue's retry and lease semantics aren't a database's job. A secret's rotation lifecycle isn't a config value's job. Where that distinction is real, it gets a name. Where it isn't, it doesn't — which is why the list stops at eight instead of growing indefinitely.
10
+
11
+ | Element | What it is | What it replaces |
12
+ | ----------- | -------------------- | ----------------------------------------------------------------------- |
13
+ | **Flow** | Execution & behavior | endpoint, handler, consumer, job, workflow, webhook |
14
+ | **Signal** | Data in motion | queue, pub/sub, stream, websocket, SSE, event bus |
15
+ | **Store** | Data at rest | relational database, cache, key-value store, file storage, search index |
16
+ | **Clock** | Time & schedules | cron, delay, timeout, durable sleep, TTL |
17
+ | **Gate** | Permission to act | auth, session, tenancy, RBAC, rate limit, quota |
18
+ | **Vault** | Protected knowledge | secrets, encryption keys, rotation, environment variables |
19
+ | **Channel** | Reaching a human | transactional email, SMS, push notifications, receipts |
20
+ | **AI** | Machine intelligence | model calls, structured prompts, agents, MCP tools |
21
+
22
+ Read the right column as the honest answer to "what would I have reached for before this?" Every item in it is a separate tool with its own configuration, its own failure modes, and its own place to go wrong. The left column is the same ground, covered by something with one shared door and one shared set of guarantees.
23
+
24
+ ## Where this goes next
25
+
26
+ The next step is breaking down the five pieces behind every Flow — the exact anatomy that connects a trigger to its effects.
@@ -13,6 +13,7 @@ import { parseDurationMs } from "../elements/clock/duration.ts";
13
13
  import { assertAttenuated } from "./attenuation.ts";
14
14
  import type { AuthPlane } from "./planes.ts";
15
15
  import type { ApiKeyRow } from "./tables.ts";
16
+ import { okid } from "../okid.ts";
16
17
 
17
18
  /** Capability / Manifest resource for `fx.auth` key methods. */
18
19
  export const AUTH_API_KEYS_RESOURCE = "auth:api-keys";
@@ -145,7 +146,7 @@ export async function createApiKey(
145
146
  assertAttenuated(options.creatorScopes, options.scopes, "api key");
146
147
 
147
148
  const now = options.now ?? (() => Date.now());
148
- const id = options.id ?? crypto.randomUUID();
149
+ const id = options.id ?? okid();
149
150
  const secret = options.secret ?? `oke_${id.replace(/-/g, "")}_${randomSecret()}`;
150
151
  const pepper = options.pepper ?? store.pepper ?? DEFAULT_PEPPER;
151
152
  const hash = options.hash ?? (await hashApiKeySecret(secret, pepper));