okengine 0.2.8 → 0.3.2

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 (180) hide show
  1. package/AGENTS.md +17 -15
  2. package/README.md +57 -29
  3. package/package.json +11 -16
  4. package/site/content/docs/ai/llms-txt.mdx +54 -0
  5. package/site/content/docs/ai/mcp.mdx +123 -0
  6. package/site/content/docs/ai/meta.json +5 -0
  7. package/site/content/docs/ai/skills.mdx +53 -0
  8. package/site/content/docs/console/access.mdx +29 -0
  9. package/site/content/docs/console/ai.mdx +35 -0
  10. package/site/content/docs/console/architecture.mdx +35 -0
  11. package/site/content/docs/console/channels.mdx +37 -0
  12. package/site/content/docs/console/clock.mdx +31 -0
  13. package/site/content/docs/console/flows.mdx +31 -0
  14. package/site/content/docs/console/gates.mdx +35 -0
  15. package/site/content/docs/console/manifest-diff.mdx +34 -0
  16. package/site/content/docs/console/meta.json +23 -0
  17. package/site/content/docs/console/overview.mdx +40 -0
  18. package/site/content/docs/console/plugins.mdx +41 -0
  19. package/site/content/docs/console/privacy.mdx +32 -0
  20. package/site/content/docs/console/runs.mdx +40 -0
  21. package/site/content/docs/console/signals.mdx +31 -0
  22. package/site/content/docs/console/store.mdx +32 -0
  23. package/site/content/docs/console/tenancy.mdx +32 -0
  24. package/site/content/docs/console/traces.mdx +34 -0
  25. package/site/content/docs/console/vault.mdx +37 -0
  26. package/site/content/docs/elements/ai.mdx +180 -0
  27. package/site/content/docs/elements/channel.mdx +167 -0
  28. package/site/content/docs/elements/clock.mdx +182 -0
  29. package/site/content/docs/elements/flow.mdx +288 -0
  30. package/site/content/docs/elements/gate.mdx +171 -0
  31. package/site/content/docs/elements/meta.json +5 -0
  32. package/site/content/docs/elements/signal.mdx +171 -0
  33. package/site/content/docs/elements/store.mdx +320 -0
  34. package/site/content/docs/elements/vault.mdx +263 -0
  35. package/site/content/docs/get-started/basic-usage.mdx +124 -0
  36. package/site/content/docs/get-started/comparison.mdx +65 -0
  37. package/site/content/docs/get-started/installation.mdx +113 -0
  38. package/site/content/docs/get-started/introduction.mdx +123 -0
  39. package/site/content/docs/get-started/meta.json +5 -0
  40. package/site/content/docs/index.mdx +63 -0
  41. package/site/content/docs/meta.json +5 -0
  42. package/site/content/docs/plugins/compression.mdx +60 -0
  43. package/site/content/docs/plugins/cors.mdx +92 -0
  44. package/site/content/docs/plugins/csrf.mdx +96 -0
  45. package/site/content/docs/plugins/ip-allowlist.mdx +92 -0
  46. package/site/content/docs/plugins/maintenance-mode.mdx +101 -0
  47. package/site/content/docs/plugins/meta.json +15 -0
  48. package/site/content/docs/plugins/security-headers.mdx +136 -0
  49. package/site/content/docs/reference/cli.md +101 -0
  50. package/site/content/docs/reference/configuration.mdx +159 -0
  51. package/site/content/docs/reference/environment-variables.mdx +87 -0
  52. package/site/content/docs/reference/errors.mdx +80 -0
  53. package/site/content/docs/reference/fx.mdx +117 -0
  54. package/site/content/docs/reference/meta.json +5 -0
  55. package/site/content/docs/reference/plugins.mdx +249 -0
  56. package/site/content/docs/reference/security.md +63 -0
  57. package/src/auth/auth.test.ts +3 -0
  58. package/src/cli/ask-dev-mode.ts +1 -1
  59. package/src/cli/db.ts +87 -17
  60. package/src/cli/dev-db-push.test.ts +32 -2
  61. package/src/cli/dev-schema-sync.test.ts +66 -0
  62. package/src/cli/dev-schema-sync.ts +139 -0
  63. package/src/cli/dev.test.ts +123 -1
  64. package/src/cli/dev.ts +150 -8
  65. package/src/cli/doc-staleness.test.ts +4 -4
  66. package/src/cli/docker-cli.test.ts +20 -0
  67. package/src/cli/docker.ts +10 -0
  68. package/src/cli/drizzle-env.test.ts +67 -0
  69. package/src/cli/drizzle-env.ts +78 -0
  70. package/src/cli/ensure-drizzle-config.ts +50 -0
  71. package/src/cli/hero-meta.test.ts +1 -1
  72. package/src/cli/load-config.ts +6 -0
  73. package/src/cli/mode.ts +24 -4
  74. package/src/cli/openbao-bootstrap.test.ts +147 -0
  75. package/src/cli/openbao-bootstrap.ts +280 -0
  76. package/src/cli/openbao-restart.integration.test.ts +136 -0
  77. package/src/cli/ports.test.ts +7 -5
  78. package/src/cli/ports.ts +6 -2
  79. package/src/cli/resolve-dev-sql-env.test.ts +48 -0
  80. package/src/cli/resolve-dev-sql-env.ts +42 -0
  81. package/src/cli/stack.ts +7 -4
  82. package/src/cli/vault-cmd.ts +63 -0
  83. package/src/client/types.ts +7 -1
  84. package/src/compiler/extract.test.ts +40 -0
  85. package/src/compiler/extract.ts +123 -1
  86. package/src/compiler/fixtures/skyport/oke.config.ts +2 -2
  87. package/src/compiler/fixtures/skyport.expected.json +1 -1
  88. package/src/compiler/response.ts +12 -0
  89. package/src/config/define-config.test.ts +4 -6
  90. package/src/config/index.ts +2 -15
  91. package/src/console/server/app.ts +2 -0
  92. package/src/console/server/vault.ts +21 -6
  93. package/src/docker/compose.ts +112 -16
  94. package/src/docker/derive.ts +7 -1
  95. package/src/docker/docker.test.ts +103 -0
  96. package/src/docker/index.ts +11 -1
  97. package/src/docker/recipes/index.ts +3 -2
  98. package/src/docker/recipes/openbao.ts +47 -0
  99. package/src/docker/recipes/redis.ts +5 -1
  100. package/src/docker/recipes/rustfs.ts +2 -3
  101. package/src/docker/stack-id.test.ts +43 -8
  102. package/src/docker/stack-id.ts +99 -20
  103. package/src/docker/stack.ts +36 -4
  104. package/src/docker/types.ts +3 -0
  105. package/src/docs-origin.ts +4 -4
  106. package/src/drivers/drizzle-dialect.test.ts +20 -0
  107. package/src/drivers/drizzle-dialect.ts +37 -0
  108. package/src/drivers/index.ts +1 -2
  109. package/src/drivers/memory.ts +278 -39
  110. package/src/drivers/s3.ts +10 -1
  111. package/src/drivers/vault-driver-removal.test.ts +55 -0
  112. package/src/drivers/vault-openbao.test.ts +97 -0
  113. package/src/drivers/vault-openbao.ts +102 -35
  114. package/src/drivers/vault-types.ts +3 -10
  115. package/src/elements/store/declare.ts +4 -1
  116. package/src/elements/store/resource-list-docs.fixture.ts +56 -0
  117. package/src/elements/store/resource-list-docs.test.ts +79 -0
  118. package/src/elements/store/resource.test.ts +253 -0
  119. package/src/elements/store/resource.ts +786 -0
  120. package/src/elements/store/sql-condition.test.ts +132 -0
  121. package/src/elements/store/sql-condition.ts +284 -46
  122. package/src/elements/store/sql-session.test.ts +86 -1
  123. package/src/elements/store/sql-session.ts +187 -27
  124. package/src/elements/store/table.ts +34 -4
  125. package/src/elements/store.ts +16 -0
  126. package/src/elements/vault/runtime.ts +1 -1
  127. package/src/elements/vault.test.ts +1 -28
  128. package/src/elements/vault.ts +1 -1
  129. package/src/kernel/app.ts +59 -25
  130. package/src/kernel/boot-bind/channel.test.ts +60 -0
  131. package/src/kernel/boot-bind/channel.ts +64 -2
  132. package/src/kernel/boot-bind/store.test.ts +10 -1
  133. package/src/kernel/boot-bind/store.ts +49 -2
  134. package/src/kernel/boot.test.ts +0 -1
  135. package/src/kernel/boot.ts +1 -1
  136. package/src/kernel/edge.test.ts +68 -0
  137. package/src/kernel/errors.registry.test.ts +1 -1
  138. package/src/kernel/flow.ts +8 -0
  139. package/src/kernel/fx.test.ts +23 -3
  140. package/src/kernel/fx.ts +115 -18
  141. package/src/kernel/hooks.test.ts +33 -0
  142. package/src/kernel/hooks.ts +22 -0
  143. package/src/kernel/index.ts +7 -0
  144. package/src/kernel/on.ts +44 -3
  145. package/src/kernel/plugin.ts +33 -3
  146. package/src/kernel/registry-isolation.test.ts +74 -0
  147. package/src/kernel/registry.ts +22 -1
  148. package/src/kernel/triggers.ts +59 -0
  149. package/src/manifest/fixtures/skyport.excerpt.json +1 -1
  150. package/src/manifest/fixtures/skyport.manifest.json +1 -1
  151. package/src/manifest/index.ts +1 -1
  152. package/src/manifest/types.ts +1 -1
  153. package/src/manifest/validate.ts +2 -2
  154. package/src/plugins/compression.test.ts +127 -0
  155. package/src/plugins/compression.ts +94 -0
  156. package/src/plugins/config-source.test.ts +204 -0
  157. package/src/plugins/config-source.ts +209 -0
  158. package/src/plugins/cors.test.ts +138 -0
  159. package/src/plugins/cors.ts +129 -0
  160. package/src/plugins/csrf.test.ts +102 -0
  161. package/src/plugins/csrf.ts +86 -0
  162. package/src/plugins/headers.ts +54 -0
  163. package/src/plugins/index.ts +26 -0
  164. package/src/plugins/ip-allowlist.test.ts +105 -0
  165. package/src/plugins/ip-allowlist.ts +76 -0
  166. package/src/plugins/maintenance-mode.test.ts +91 -0
  167. package/src/plugins/maintenance-mode.ts +85 -0
  168. package/src/plugins/security-headers.test.ts +243 -0
  169. package/src/plugins/security-headers.ts +255 -0
  170. package/src/release/measure.ts +1 -2
  171. package/src/test/create-test-app.ts +14 -2
  172. package/docs/spec/console.md +0 -762
  173. package/docs/spec/example.md +0 -1374
  174. package/docs/spec/four-applications.md +0 -1376
  175. package/docs/spec/unified-theory.md +0 -498
  176. package/src/cli/doc-drift.test.ts +0 -147
  177. package/src/cli/doc-drift.ts +0 -401
  178. package/src/cli/doctor-diff-examples.ts +0 -90
  179. package/src/drivers/vault-sops.ts +0 -246
  180. /package/{spec/manifest.v1.schema.json → manifest.v1.schema.json} +0 -0
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: "Clock"
3
+ description: "Upcoming crons, sleeping durable flows, journal."
4
+ icon: "Clock"
5
+ source: "docs/spec/console.md"
6
+ ---
7
+
8
+ Answers: **upcoming crons, sleeping durable flows, journal**
9
+
10
+ <Callout title="Governing rule">
11
+ Looks like time — a forward timeline for schedules and pending wakes, not a flat grid.
12
+ </Callout>
13
+
14
+ ## What this panel shows
15
+
16
+ <Cards>
17
+ <Card
18
+ title="Schedules"
19
+ description="Recurring crons with drift, overdue, catch-up, lease holder."
20
+ />
21
+ <Card title="Pending wakes" description="Every sleeping durable flow and when it wakes." />
22
+ <Card title="DST warnings" description="Only when the schedule falls in an ambiguous window." />
23
+ <Card title="Actions" description="Run now, wake early, pause, edit when overridable." />
24
+ </Cards>
25
+
26
+ ## Catalog
27
+
28
+ <Cards>
29
+ <Card title="Dev" description="full" />
30
+ <Card title="Prod" description="trigger/pause; edit if `overridable`" />
31
+ </Cards>
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: "Flows"
3
+ description: "What exists; call it; read its contract."
4
+ icon: "GitBranch"
5
+ source: "docs/spec/console.md"
6
+ ---
7
+
8
+ Answers: **what exists; call it; read its contract**
9
+
10
+ <Callout title="Governing rule">
11
+ Renders the one law as three columns: `Causes ← Flows → Effects` — not a tree.
12
+ </Callout>
13
+
14
+ ## What this panel shows
15
+
16
+ <Cards>
17
+ <Card title="Causes column" description="Triggers and callers — what runs this." />
18
+ <Card title="Flows column" description="Context-adaptive centre with contracts and invoke." />
19
+ <Card title="Effects column" description="What changes — store, signal, channel, AI, vault." />
20
+ <Card
21
+ title="Flow drawer"
22
+ description="Workshop peek/expand — save as bun:test from a real response."
23
+ />
24
+ </Cards>
25
+
26
+ ## Catalog
27
+
28
+ <Cards>
29
+ <Card title="Dev" description="full + source links" />
30
+ <Card title="Prod" description="read + invoke per gates" />
31
+ </Cards>
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: "Gates"
3
+ description: "Permission matrix, rate counters, MFA map."
4
+ icon: "Shield"
5
+ source: "docs/spec/console.md"
6
+ ---
7
+
8
+ Answers: **permission matrix, rate counters, MFA map**
9
+
10
+ <Callout title="Governing rule">
11
+ Refuse the giant roles×permissions matrix as the entry point — inquire from principal or from
12
+ flow.
13
+ </Callout>
14
+
15
+ ## What this panel shows
16
+
17
+ <Cards>
18
+ <Card title="Simulator" description="Gate chain in evaluation order — where a 403 stopped." />
19
+ <Card
20
+ title="Unguarded flows"
21
+ description="Continuous audit: public user-plane flows after deploy."
22
+ />
23
+ <Card title="Deploy diff" description="Permission widening caught from Manifest Diff." />
24
+ <Card
25
+ title="Plane separation"
26
+ description="Operator holding an application scope is a violation."
27
+ />
28
+ </Cards>
29
+
30
+ ## Catalog
31
+
32
+ <Cards>
33
+ <Card title="Dev" description="full" />
34
+ <Card title="Prod" description="limits if `overridable`" />
35
+ </Cards>
@@ -0,0 +1,34 @@
1
+ ---
2
+ title: "Manifest Diff"
3
+ description: "Blast radius of a deploy: new effects, widened permissions."
4
+ icon: "Diff"
5
+ source: "docs/spec/console.md"
6
+ ---
7
+
8
+ Answers: **blast radius of a deploy: new effects, widened permissions**
9
+
10
+ <Callout title="Governing rule">
11
+ Compares meaning rather than lines — behaviour change, sorted by blast radius.
12
+ </Callout>
13
+
14
+ ## What this panel shows
15
+
16
+ <Cards>
17
+ <Card title="Contract breaking" description="Existing clients will fail." />
18
+ <Card
19
+ title="Permission widening"
20
+ description="Attack surface grew — gate removed or scope widened."
21
+ />
22
+ <Card title="Effect widening" description="New write, external effect, or secret read." />
23
+ <Card
24
+ title="CI gate"
25
+ description="Blocks undeclared breaks; intended breaks need `breaking: true`."
26
+ />
27
+ </Cards>
28
+
29
+ ## Catalog
30
+
31
+ <Cards>
32
+ <Card title="Dev" description="✓" />
33
+ <Card title="Prod" description="✓" />
34
+ </Cards>
@@ -0,0 +1,23 @@
1
+ {
2
+ "title": "Console",
3
+ "icon": "LayoutDashboard",
4
+ "pages": [
5
+ "overview",
6
+ "flows",
7
+ "signals",
8
+ "store",
9
+ "clock",
10
+ "gates",
11
+ "vault",
12
+ "channels",
13
+ "ai",
14
+ "architecture",
15
+ "traces",
16
+ "runs",
17
+ "manifest-diff",
18
+ "access",
19
+ "plugins",
20
+ "privacy",
21
+ "tenancy"
22
+ ]
23
+ }
@@ -0,0 +1,40 @@
1
+ ---
2
+ title: "Overview"
3
+ description: "Is the system healthy right now?"
4
+ icon: "Activity"
5
+ source: "docs/spec/console.md"
6
+ ---
7
+
8
+ Answers: **is the system healthy right now?**
9
+
10
+ <Callout title="Governing rule">
11
+ Built on declared objectives — burn rate and ranked findings, not a wall of charts nobody reads.
12
+ </Callout>
13
+
14
+ ## What this panel shows
15
+
16
+ <Cards>
17
+ <Card
18
+ title="Declared SLOs"
19
+ description="Objectives enter the Manifest; lowering a target is a reviewable code change."
20
+ />
21
+ <Card
22
+ title="Burn rate"
23
+ description="Error rate over tolerable rate — pages and investigates with clear thresholds."
24
+ />
25
+ <Card
26
+ title="Journeys"
27
+ description="Causal paths, not service lists — impossible compositions rejected at compile."
28
+ />
29
+ <Card
30
+ title="Ranked findings"
31
+ description="Union of panel findings: user harm first, then irreversibility, then trend."
32
+ />
33
+ </Cards>
34
+
35
+ ## Catalog
36
+
37
+ <Cards>
38
+ <Card title="Dev" description="✓" />
39
+ <Card title="Prod" description="✓" />
40
+ </Cards>
@@ -0,0 +1,41 @@
1
+ ---
2
+ title: "Plugins"
3
+ description: "Installed plugins and their contributed panels."
4
+ icon: "Puzzle"
5
+ source: "docs/spec/console.md"
6
+ ---
7
+
8
+ Answers: **installed plugins and their contributed panels**
9
+
10
+ <Callout title="Governing rule">
11
+ Scope is the attachment point — `app.plug()` / `unit.plug()` / `flow.plug()`. The Console never
12
+ installs anything.
13
+ </Callout>
14
+
15
+ ## What this panel shows
16
+
17
+ <Cards>
18
+ <Card
19
+ title="Origin × state"
20
+ description="Core / Local / Community; state derived from code, not a flag."
21
+ />
22
+ <Card
23
+ title="Declares vs intercepts"
24
+ description="Boot contributions vs per-request hooks with measured cost."
25
+ />
26
+ <Card
27
+ title="Supply chain"
28
+ description="No lifecycle scripts; capability widening hits Manifest Diff."
29
+ />
30
+ <Card
31
+ title="Install path"
32
+ description="Shows state and hands you the command — no browser install."
33
+ />
34
+ </Cards>
35
+
36
+ ## Catalog
37
+
38
+ <Cards>
39
+ <Card title="Dev" description="✓" />
40
+ <Card title="Prod" description="✓" />
41
+ </Cards>
@@ -0,0 +1,32 @@
1
+ ---
2
+ title: "Privacy"
3
+ description: "Where PII lives, who touches it, export/erase (conditional)."
4
+ icon: "EyeOff"
5
+ source: "docs/spec/console.md"
6
+ ---
7
+
8
+ Answers: **where PII lives, who touches it, export/erase**
9
+
10
+ <Callout title="Governing rule">
11
+ Conditional panel — appears when the privacy plugin is plugged. Catalog row is the durable
12
+ reference.
13
+ </Callout>
14
+
15
+ ## What this panel shows
16
+
17
+ <Cards>
18
+ <Card title="PII map" description="Where personal data lives and who touches it." />
19
+ <Card title="Export / erase" description="`oke privacy export|erase --subject` across stores." />
20
+ </Cards>
21
+
22
+ ## Catalog
23
+
24
+ <Cards>
25
+ <Card title="Dev" description="✓" />
26
+ <Card title="Prod" description="✓" />
27
+ </Cards>
28
+
29
+ <Callout title="Conditional">
30
+ This panel appears when the optional core plugin is plugged. There is no separate detailed
31
+ subsection beyond the catalog row.
32
+ </Callout>
@@ -0,0 +1,40 @@
1
+ ---
2
+ title: "Runs"
3
+ description: "Wide events — one record per flow execution."
4
+ icon: "Play"
5
+ source: "docs/spec/console.md"
6
+ ---
7
+
8
+ Answers: **wide events — one record per flow execution, queried by dimension**
9
+
10
+ <Callout title="Governing rule">
11
+ One flow execution = one wide event = one span. Analysis by dimension, not a text search box.
12
+ </Callout>
13
+
14
+ ## What this panel shows
15
+
16
+ <Cards>
17
+ <Card
18
+ title="Wide events"
19
+ description="Dimensions from effects — no manual instrumentation tax."
20
+ />
21
+ <Card
22
+ title="Outlier explanation"
23
+ description="Compare all dimensions between slow and baseline populations."
24
+ />
25
+ <Card
26
+ title="Storage tiers"
27
+ description="Default Parquet + DuckDB; optional postgres / clickhouse."
28
+ />
29
+ <Card
30
+ title="Lifecycle"
31
+ description="Retain by default; redaction and crypto-shredding for compliance."
32
+ />
33
+ </Cards>
34
+
35
+ ## Catalog
36
+
37
+ <Cards>
38
+ <Card title="Dev" description="✓" />
39
+ <Card title="Prod" description="✓" />
40
+ </Cards>
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: "Signals"
3
+ description: "Queue depth, in-flight, DLQ, live monitors."
4
+ icon: "Radio"
5
+ source: "docs/spec/console.md"
6
+ ---
7
+
8
+ Answers: **queue depth, in-flight, DLQ, live monitors**
9
+
10
+ <Callout title="Governing rule">
11
+ One list grouped by delivery physics — not three tabs that re-split the element.
12
+ </Callout>
13
+
14
+ ## What this panel shows
15
+
16
+ <Cards>
17
+ <Card title="once" description="Pending, in-flight, DLQ, retry policy." />
18
+ <Card title="broadcast" description="Per-subscriber lag and targeted replay." />
19
+ <Card title="live" description="Connection count, throughput, payload monitor." />
20
+ <Card
21
+ title="DLQ repair"
22
+ description="Schema form, typed errors, causal chain, dry-run bulk replay."
23
+ />
24
+ </Cards>
25
+
26
+ ## Catalog
27
+
28
+ <Cards>
29
+ <Card title="Dev" description="full" />
30
+ <Card title="Prod" description="replay/purge per gates" />
31
+ </Cards>
@@ -0,0 +1,32 @@
1
+ ---
2
+ title: "Store"
3
+ description: "Browse sql/kv/files/index; cache keys; replica lag."
4
+ icon: "Database"
5
+ source: "docs/spec/console.md"
6
+ ---
7
+
8
+ Answers: **browse sql/kv/files/index; cache keys; replica lag**
9
+
10
+ <Callout title="Governing rule">
11
+ The most dangerous panel in production — gates, tenant isolation, PII masking, and audit on the
12
+ data path.
13
+ </Callout>
14
+
15
+ ## What this panel shows
16
+
17
+ <Cards>
18
+ <Card title="Four facets" description="sql · kv · files · index with adaptive detail." />
19
+ <Card title="PII masking" description="Follows schema classification, including raw SQL." />
20
+ <Card title="Cache keys" description="Which read produced a key; which write invalidates it." />
21
+ <Card
22
+ title="Direct edit warning"
23
+ description="Names what will not happen — not a silent row patch."
24
+ />
25
+ </Cards>
26
+
27
+ ## Catalog
28
+
29
+ <Cards>
30
+ <Card title="Dev" description="full + Studio link" />
31
+ <Card title="Prod" description="masked, gated, audited" />
32
+ </Cards>
@@ -0,0 +1,32 @@
1
+ ---
2
+ title: "Tenancy"
3
+ description: "Per-tenant usage, limits, isolation checks (conditional)."
4
+ icon: "Building2"
5
+ source: "docs/spec/console.md"
6
+ ---
7
+
8
+ Answers: **per-tenant usage, limits, isolation checks**
9
+
10
+ <Callout title="Governing rule">
11
+ Conditional panel — appears when the tenancy plugin is plugged. Catalog row is the durable
12
+ reference.
13
+ </Callout>
14
+
15
+ ## What this panel shows
16
+
17
+ <Cards>
18
+ <Card title="Usage &amp; limits" description="Per-tenant usage and configured limits." />
19
+ <Card title="Isolation" description="Checks that tenant boundaries hold." />
20
+ </Cards>
21
+
22
+ ## Catalog
23
+
24
+ <Cards>
25
+ <Card title="Dev" description="✓" />
26
+ <Card title="Prod" description="✓" />
27
+ </Cards>
28
+
29
+ <Callout title="Conditional">
30
+ This panel appears when the optional core plugin is plugged. There is no separate detailed
31
+ subsection beyond the catalog row.
32
+ </Callout>
@@ -0,0 +1,34 @@
1
+ ---
2
+ title: "Traces"
3
+ description: "One timeline across http → store → signal → durable steps."
4
+ icon: "Route"
5
+ source: "docs/spec/console.md"
6
+ ---
7
+
8
+ Answers: **one timeline across http → store → signal → durable steps**
9
+
10
+ <Callout title="Governing rule">
11
+ Folded time across async boundaries — a seven-day sleep is not 99.99% empty waterfall.
12
+ </Callout>
13
+
14
+ ## What this panel shows
15
+
16
+ <Cards>
17
+ <Card title="Causal chain" description="Join parent/child across emit boundaries." />
18
+ <Card title="Effect tiers" description="Spans coloured by the same vocabulary as Flows." />
19
+ <Card
20
+ title="Filter by effect"
21
+ description="Everything that wrote a table, sent mail, or cost more than X."
22
+ />
23
+ <Card
24
+ title="Why slow / why fail"
25
+ description="Critical path highlight; open on the failing span."
26
+ />
27
+ </Cards>
28
+
29
+ ## Catalog
30
+
31
+ <Cards>
32
+ <Card title="Dev" description="✓" />
33
+ <Card title="Prod" description="✓" />
34
+ </Cards>
@@ -0,0 +1,37 @@
1
+ ---
2
+ title: "Vault"
3
+ description: "Secret contracts, who can read each, rotation due."
4
+ icon: "KeyRound"
5
+ source: "docs/spec/console.md"
6
+ ---
7
+
8
+ Answers: **secret contracts, who can read each, rotation due**
9
+
10
+ <Callout title="Governing rule">
11
+ Secrets are write-only — the panel can set and rotate; it can never reveal.
12
+ </Callout>
13
+
14
+ ## What this panel shows
15
+
16
+ <Cards>
17
+ <Card
18
+ title="Fingerprints"
19
+ description="Salted hash per environment — rotation and drift without exposure."
20
+ />
21
+ <Card
22
+ title="Resolution chain"
23
+ description="Which source won: env, files, vault driver, or fallback."
24
+ />
25
+ <Card title="Who can read" description="Derived from effects that declare `fx.vault`." />
26
+ <Card
27
+ title="Rotation blast radius"
28
+ description="In-flight durable runs that wake with a new key."
29
+ />
30
+ </Cards>
31
+
32
+ ## Catalog
33
+
34
+ <Cards>
35
+ <Card title="Dev" description="full" />
36
+ <Card title="Prod" description="set/rotate only, never reveal" />
37
+ </Cards>
@@ -0,0 +1,180 @@
1
+ ---
2
+ title: "AI"
3
+ description: "Reaching machine intelligence — models, versioned prompts, embeddings, and bounded agents, with cost and PII egress as first-class constraints."
4
+ icon: "Bot"
5
+ source: "docs/spec/unified-theory.md"
6
+ ---
7
+
8
+ AI is how your app calls **machine intelligence**: triage a ticket, embed a knowledge base, let an agent resolve a support case. Model calls differ from every other effect — they are nondeterministic, they cost money per call, and your data leaves the building — so prompts are **versioned artifacts**, not strings buried in a handler.
9
+
10
+ <Callout title="The one rule">
11
+ The production model is **declared, never guessed** — there is no prod default. Development uses
12
+ `mock` for determinism, and sending PII to a third-party model fails the **build** unless you
13
+ explicitly acknowledge it.
14
+ </Callout>
15
+
16
+ ## Quick start
17
+
18
+ <Steps>
19
+
20
+ <Step>
21
+ ### Declare a model and a prompt
22
+
23
+ The model is a logical binding (`smart`, `fast`); the prompt is a versioned artifact with a typed output:
24
+
25
+ ```typescript title="src/ai.ts"
26
+ import { ai } from "okengine";
27
+ import { z } from "zod";
28
+
29
+ export const smart = ai.model("smart", { provider: "anthropic", tier: "opus" });
30
+
31
+ export const triage = smart.prompt("ticket-triage", {
32
+ in: z.object({ subject: z.string(), body: z.string() }),
33
+ out: z.object({ urgency: z.enum(["low", "high"]), team: z.string(), summary: z.string() }),
34
+ version: 3,
35
+ budget: { maxCostPerCall: 0.02 },
36
+ });
37
+ ```
38
+
39
+ </Step>
40
+
41
+ <Step>
42
+ ### Ask it from a Flow
43
+
44
+ `fx.ask` routes the call through the declared model and validates the response against `out`:
45
+
46
+ ```typescript title="src/flows/support/triage.ts"
47
+ do: async (input, fx) => {
48
+ const result = await fx.ask(triage, { subject: input.subject, body: input.body });
49
+ // result is typed by the prompt's `out` schema
50
+ };
51
+ ```
52
+
53
+ </Step>
54
+
55
+ <Step>
56
+ ### Gate regressions in CI
57
+
58
+ Point the prompt at an eval set and it becomes a CI check — a prompt change that degrades answers fails the build like a broken test:
59
+
60
+ ```typescript
61
+ export const triage = smart.prompt("ticket-triage", {
62
+ // …
63
+ evals: "./evals/triage.jsonl", // run with `oke eval`
64
+ });
65
+ ```
66
+
67
+ </Step>
68
+
69
+ </Steps>
70
+
71
+ ## The four building blocks
72
+
73
+ | Declaration | Produces |
74
+ | -------------------------- | ------------------------------------------------------------------ |
75
+ | `ai.model(name, opts)` | Logical model binding — provider / tier / concrete model id |
76
+ | `model.prompt(name, opts)` | Versioned prompt with typed in/out, evals, budget |
77
+ | `ai.embed(name, opts)` | Embedding pipeline into a `store.index` (searched via `fx.search`) |
78
+ | `ai.agent(name, opts)` | Bounded agent whose tools are **your own flows** |
79
+
80
+ ### Prompt options
81
+
82
+ | Option | Type | Meaning |
83
+ | ------------ | --------------------- | -------------------------------------------------------------- |
84
+ | `in` / `out` | zod / Standard Schema | Input and output contracts — responses validated against `out` |
85
+ | `version` | number | Artifact version — diffs and regressions tracked per version |
86
+ | `evals` | string | Path to a `.jsonl` eval set, regression-gated via `oke eval` |
87
+ | `budget` | object | `maxCostPerCall` — cost is a first-class dimension |
88
+
89
+ ## Agents with real guardrails
90
+
91
+ An agent's tools are your flows — each carrying its own gates, effects, and typed errors, so the agent can never do anything a flow couldn't:
92
+
93
+ ```typescript
94
+ export const support = ai.agent("support", {
95
+ model: smart,
96
+ tools: [getBooking, refundBooking], // flows, with their gates attached
97
+ maxSteps: 6,
98
+ budget: { maxCostPerRun: 0.25 },
99
+ });
100
+ ```
101
+
102
+ `maxSteps` bounds the loop; `budget.maxCostPerRun` bounds the spend. Both are declared, so "the agent ran away" is a violated contract, not a surprise.
103
+
104
+ ## PII cannot leak by accident
105
+
106
+ At build time, OKE checks which fields each `fx.ask` sends against your store classifications. If a PII field (`.pii()` in your schema) would reach a third-party model, the build fails:
107
+
108
+ ```text
109
+ build failed: flow "ticket-triage" sends pii field(s) [email] to a third-party model without allowPii
110
+ ```
111
+
112
+ The escape hatch is explicit acknowledgment — `allowPii: true` (or `pii: "allow"`) on the flow — so egress is a decision that shows up in code review. The `mock` driver and local models are not third-party; the check targets external providers.
113
+
114
+ ## Nondeterminism is priced in
115
+
116
+ Because `fx.ask` is nondeterministic, the runtime adjusts around it: journaling is **forced** on (durable flows can replay), and auto-caching is disabled for the call. In development and tests the `mock` driver makes model calls deterministic — your suite never hits a network, and CI never flakes on a provider.
117
+
118
+ ## Per-environment drivers
119
+
120
+ | Driver | What it is |
121
+ | ------------------- | ----------------------------------------------------- |
122
+ | `mock` | Deterministic fake — dev + test default |
123
+ | `anthropic` | Anthropic API |
124
+ | `openai-compatible` | Any OpenAI-compatible endpoint |
125
+ | `bedrock` | AWS Bedrock |
126
+ | `vertex` | Google Vertex AI |
127
+ | `ollama` | Local models — counts as on-premise for the PII check |
128
+
129
+ There is deliberately **no production default**: `prod` must name a driver, which keeps the model choice visible in `oke.config.ts` where review can see it.
130
+
131
+ ## Troubleshooting
132
+
133
+ <Accordions>
134
+ <Accordion title="Build fails with AiPiiBuildError">
135
+
136
+ A flow sends a classified PII field to a third-party model. Either stop sending that field (drop it from the `fx.ask` input), or acknowledge the egress with `allowPii: true` on the flow — the error message names the exact fields.
137
+
138
+ </Accordion>
139
+ <Accordion title="Which model will prod actually call?">
140
+
141
+ The one you declared. There is no fallback or guess — if `prod` has no AI driver configured, that's a configuration gap to fix, not a silent default.
142
+
143
+ </Accordion>
144
+ <Accordion title="A prompt edit made answers worse — how do I catch that pre-merge?">
145
+
146
+ Attach `evals: "./evals/<name>.jsonl"` to the prompt and run `oke eval` in CI. The suite replays the eval cases and fails on regressions, per prompt version.
147
+
148
+ </Accordion>
149
+ <Accordion title="An agent looped and burned budget">
150
+
151
+ Bound it at declaration: `maxSteps` caps iterations, `budget.maxCostPerRun` caps spend. The Console's AI view shows cost per run so you can tune both against real numbers.
152
+
153
+ </Accordion>
154
+ </Accordions>
155
+
156
+ ## Learn more
157
+
158
+ - [Flow](/docs/elements/flow) — `fx.ask` and `fx.search` inside `do`
159
+ - [Store](/docs/elements/store) — `store.index`, the home of embeddings
160
+ - [Console · AI](/docs/console/ai) — prompts, versions, cost per run
161
+
162
+ ## Next
163
+
164
+ <Cards>
165
+ <Card
166
+ title="Basic Usage"
167
+ description="Build from the standard starter."
168
+ href="/docs/get-started/basic-usage"
169
+ />
170
+ <Card
171
+ title="Introduction"
172
+ description="Eight elements overview."
173
+ href="/docs/get-started/introduction"
174
+ />
175
+ <Card
176
+ title="Console"
177
+ description="Panels derived from the Manifest."
178
+ href="/docs/console/overview"
179
+ />
180
+ </Cards>