okengine 0.2.1 → 0.2.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.
- package/README.md +8 -8
- package/package.json +2 -1
- package/src/cli/dev-app-runner.ts +6 -2
- package/src/cli/dev.ts +16 -9
- package/src/console/server/claim.test.ts +7 -4
- package/src/console/server/claim.ts +2 -7
- package/src/console/ui/dist/assets/index-B71Yl_SS.js +10 -0
- package/src/console/ui/dist/assets/panel-access-Dd37LU2c.js +64 -0
- package/src/console/ui/dist/assets/panel-ai-CC7LR6-J.js +1 -0
- package/src/console/ui/dist/assets/panel-architecture-B5b3iKCz.js +1 -0
- package/src/console/ui/dist/assets/panel-channels-CeNjTKXp.js +1 -0
- package/src/console/ui/dist/assets/panel-clock-DgFTLoHV.js +1 -0
- package/src/console/ui/dist/assets/panel-diff-DxehccqB.js +1 -0
- package/src/console/ui/dist/assets/panel-flows-BtrVn-Eg.js +45 -0
- package/src/console/ui/dist/assets/panel-gates-Z9MKRGdH.js +1 -0
- package/src/console/ui/dist/assets/panel-overview-Bd48d9km.js +1 -0
- package/src/console/ui/dist/assets/panel-plugins-DWd0TowH.js +1 -0
- package/src/console/ui/dist/assets/panel-runs-BwsWqKeB.js +1 -0
- package/src/console/ui/dist/assets/panel-signals-9najbZY2.js +1 -0
- package/src/console/ui/dist/assets/panel-store-OHkP2pDp.js +1 -0
- package/src/console/ui/dist/assets/panel-traces-tn2JoY8U.js +1 -0
- package/src/console/ui/dist/assets/panel-vault-BbfWdox0.js +1 -0
- package/src/console/ui/dist/assets/rolldown-runtime-CNC7AqOf.js +1 -0
- package/src/console/ui/dist/assets/style-Cnl7WLya.css +3 -0
- package/src/console/ui/dist/index.html +14 -0
- package/src/docs-origin.ts +19 -0
- package/src/kernel/errors.registry.test.ts +4 -2
- package/src/kernel/errors.ts +3 -1
- package/src/kernel/fx.test.ts +2 -2
- package/src/term.test.ts +51 -0
- package/src/term.ts +158 -0
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
[](https://bun.sh)
|
|
10
10
|
|
|
11
|
-
**Framework:** [`okengine`](https://www.npmjs.com/package/okengine) · **CLI:** `oke` · **Scaffold:** [`create-oke`](https://www.npmjs.com/package/create-oke) · **Docs:** [
|
|
11
|
+
**Framework:** [`okengine`](https://www.npmjs.com/package/okengine) · **CLI:** `oke` · **Scaffold:** [`create-oke`](https://www.npmjs.com/package/create-oke) · **Docs:** [okengine.vercel.app](https://okengine.vercel.app) · **License:** MIT
|
|
12
12
|
|
|
13
13
|
### Install
|
|
14
14
|
|
|
@@ -35,7 +35,7 @@ Eight elements cover what a backend needs. Ten exports are the whole public voca
|
|
|
35
35
|
import { on, flow, signal, store, clock, gate, vault, channel, ai, plugin } from "okengine";
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Batteries included for the Bun era: contract-first APIs, typed client, infrastructure primitives, Console, auth — pure TypeScript, MIT, self-hostable, no cloud lock-in. Handbook: [
|
|
38
|
+
Batteries included for the Bun era: contract-first APIs, typed client, infrastructure primitives, Console, auth — pure TypeScript, MIT, self-hostable, no cloud lock-in. Handbook: [handbook](https://okengine.vercel.app/docs). Spec depth: [`docs/spec/unified-theory.md`](https://github.com/omqkhafi/okengine/blob/main/docs/spec/unified-theory.md).
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
@@ -131,7 +131,7 @@ The rest of the scaffold is small and ordinary: `oke.config.ts` (drivers by prot
|
|
|
131
131
|
|
|
132
132
|
## How to learn (read in order)
|
|
133
133
|
|
|
134
|
-
Start on the site if you want the handbook path: [Introduction](https://
|
|
134
|
+
Start on the site if you want the handbook path: [Introduction](https://okengine.vercel.app/docs/get-started/introduction) → [Installation](https://okengine.vercel.app/docs/get-started/installation) → [Basic usage](https://okengine.vercel.app/docs/get-started/basic-usage).
|
|
135
135
|
|
|
136
136
|
Each teaching app adds the smallest next set of ideas. Do not skip ahead.
|
|
137
137
|
|
|
@@ -153,8 +153,8 @@ Same path in the spec: [`docs/spec/four-applications.md`](docs/spec/four-applica
|
|
|
153
153
|
|
|
154
154
|
## Documentation
|
|
155
155
|
|
|
156
|
-
- **Site** — [
|
|
157
|
-
- **Agents on the site** — [`/llms.txt`](https://
|
|
156
|
+
- **Site** — [okengine.vercel.app](https://okengine.vercel.app) (landing) · [handbook](https://okengine.vercel.app/docs) (handbook) · [changelog](https://okengine.vercel.app/changelog)
|
|
157
|
+
- **Agents on the site** — [`/llms.txt`](https://okengine.vercel.app/llms.txt) index · [`/llms-full.txt`](https://okengine.vercel.app/llms-full.txt) full text · `/llms.mdx/docs/...` per-page markdown
|
|
158
158
|
- **Docs MCP** — `:6536` · tools `oke.docs.search` / `oke.docs.get` (read-only; Host/Origin validated like the other surfaces)
|
|
159
159
|
- **App MCP** — `:6535` · live Manifest, schemas, effects, traces, Console-safe actions (Bearer + confirmation for writes)
|
|
160
160
|
- **Canonical specs in-repo** — [`docs/spec/`](docs/spec) (unified theory, four applications, Console)
|
|
@@ -204,7 +204,7 @@ flowchart TD
|
|
|
204
204
|
|
|
205
205
|
Seventeen panels on `:6533` (app `:6530`, MCP `:6535`): Overview, Flows, Signals, Store, Clock, Gates, Vault, Channels, AI, Architecture, Traces, Runs, Manifest Diff, Access, Plugins — plus Privacy and Tenancy when those plugins are plugged.
|
|
206
206
|
|
|
207
|
-
Operator and user planes stay separate. Every Console action is a real flow through `fx`, so the audit log is the trace. Spec: [`docs/spec/console.md`](docs/spec/console.md) · handbook: [
|
|
207
|
+
Operator and user planes stay separate. Every Console action is a real flow through `fx`, so the audit log is the trace. Spec: [`docs/spec/console.md`](docs/spec/console.md) · handbook: [console handbook](https://okengine.vercel.app/docs/console/overview).
|
|
208
208
|
|
|
209
209
|
---
|
|
210
210
|
|
|
@@ -348,11 +348,11 @@ Measured size and latency caps — see [`BUDGETS.md`](BUDGETS.md). Refresh with
|
|
|
348
348
|
|
|
349
349
|
## Status
|
|
350
350
|
|
|
351
|
-
Pre-1.0. Published on [npm](https://www.npmjs.com/package/okengine) and [JSR](https://jsr.io/@omqkhafi/okengine) (`okengine` + `create-oke`, lockstep). Docs at [
|
|
351
|
+
Pre-1.0. Published on [npm](https://www.npmjs.com/package/okengine) and [JSR](https://jsr.io/@omqkhafi/okengine) (`okengine` + `create-oke`, lockstep). Docs at [okengine.vercel.app](https://okengine.vercel.app). MIT. No `CONTRIBUTING` yet — issues and PRs welcome.
|
|
352
352
|
|
|
353
353
|
| Resource | Path |
|
|
354
354
|
|---|---|
|
|
355
|
-
| Docs site | [
|
|
355
|
+
| Docs site | [okengine.vercel.app](https://okengine.vercel.app) · [handbook](https://okengine.vercel.app/docs) · [changelog](https://okengine.vercel.app/changelog) |
|
|
356
356
|
| Unified theory | [`docs/spec/unified-theory.md`](https://github.com/omqkhafi/okengine/blob/main/docs/spec/unified-theory.md) |
|
|
357
357
|
| Four applications | [`docs/spec/four-applications.md`](https://github.com/omqkhafi/okengine/blob/main/docs/spec/four-applications.md) |
|
|
358
358
|
| Console | [`docs/spec/console.md`](https://github.com/omqkhafi/okengine/blob/main/docs/spec/console.md) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "okengine",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "One law. Eight elements. Ten exports. One package. One manifest. Every backend need is derived, never added.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"test:mcp": "bun test src/mcp",
|
|
36
36
|
"test:console:smoke": "bunx playwright test tests/console/smoke.spec.ts",
|
|
37
37
|
"build:console": "bunx vite build --config src/console/ui/vite.config.ts",
|
|
38
|
+
"prepack": "bun run build:console",
|
|
38
39
|
"bench:cold-start": "bun test ./src/runtime/cold-start.bench.ts",
|
|
39
40
|
"bench:client": "bun test src/client/budget.test.ts",
|
|
40
41
|
"bench:console": "bun test src/console/budget.test.ts",
|
|
@@ -17,6 +17,7 @@ import { resolve } from "node:path";
|
|
|
17
17
|
import { pathToFileURL } from "node:url";
|
|
18
18
|
import { createBunRuntime } from "../runtime/bun.ts";
|
|
19
19
|
import { APP_PORT, type FetchApp } from "../runtime/types.ts";
|
|
20
|
+
import { formatAppReadyLine } from "../term.ts";
|
|
20
21
|
|
|
21
22
|
/** Stable Bun.serve id so `--hot` reuses the socket across soft reloads. */
|
|
22
23
|
export const DEV_APP_SERVE_ID = "oke-dev-app";
|
|
@@ -59,8 +60,11 @@ const handle = createBunRuntime().serve(mod.app, {
|
|
|
59
60
|
id: DEV_APP_SERVE_ID,
|
|
60
61
|
});
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
process.stdout.write(
|
|
64
|
+
formatAppReadyLine(
|
|
65
|
+
`http://${formatHostForUrl(hostname)}:${handle.port}`,
|
|
66
|
+
),
|
|
67
|
+
);
|
|
64
68
|
|
|
65
69
|
if (readyPath !== undefined && readyPath.length > 0) {
|
|
66
70
|
await Bun.write(readyPath, `${handle.port}\n`);
|
package/src/cli/dev.ts
CHANGED
|
@@ -23,6 +23,11 @@ import {
|
|
|
23
23
|
CONSOLE_PORT,
|
|
24
24
|
MCP_PORT,
|
|
25
25
|
} from "../runtime/types.ts";
|
|
26
|
+
import {
|
|
27
|
+
formatDevBanner,
|
|
28
|
+
formatServiceLine,
|
|
29
|
+
formatStatusLine,
|
|
30
|
+
} from "../term.ts";
|
|
26
31
|
import { clientAdd } from "./client-add.ts";
|
|
27
32
|
import { loadManifest, loadOkeConfig, resolveImages } from "./load-config.ts";
|
|
28
33
|
import { mcpContextFromConsole } from "./mcp-from-console.ts";
|
|
@@ -258,7 +263,7 @@ export async function runDev(options: DevOptions = {}): Promise<DevResult> {
|
|
|
258
263
|
}
|
|
259
264
|
});
|
|
260
265
|
await up(composeFiles, cwd);
|
|
261
|
-
write(`
|
|
266
|
+
write(formatStatusLine(`stack up (${stackRoles.join(", ")})`));
|
|
262
267
|
}
|
|
263
268
|
}
|
|
264
269
|
|
|
@@ -272,10 +277,7 @@ export async function runDev(options: DevOptions = {}): Promise<DevResult> {
|
|
|
272
277
|
stackEnv,
|
|
273
278
|
};
|
|
274
279
|
|
|
275
|
-
write(
|
|
276
|
-
`oke dev: app :${appPort} · Console :${consolePort} · MCP :${mcpPort}\n`,
|
|
277
|
-
);
|
|
278
|
-
write("oke dev: watching — client types regenerate on save\n");
|
|
280
|
+
write(formatDevBanner());
|
|
279
281
|
|
|
280
282
|
if (options.dryRun) return { code: 0, plan };
|
|
281
283
|
|
|
@@ -312,7 +314,12 @@ export async function runDev(options: DevOptions = {}): Promise<DevResult> {
|
|
|
312
314
|
? { manifest: seedManifest }
|
|
313
315
|
: {}),
|
|
314
316
|
});
|
|
315
|
-
write(
|
|
317
|
+
write(
|
|
318
|
+
formatServiceLine(
|
|
319
|
+
"Console",
|
|
320
|
+
`http://127.0.0.1:${server.port}`,
|
|
321
|
+
),
|
|
322
|
+
);
|
|
316
323
|
return {
|
|
317
324
|
console: server.console,
|
|
318
325
|
port: server.port,
|
|
@@ -334,7 +341,7 @@ export async function runDev(options: DevOptions = {}): Promise<DevResult> {
|
|
|
334
341
|
context: mcpOptions.context,
|
|
335
342
|
now: mcpOptions.now,
|
|
336
343
|
});
|
|
337
|
-
write(
|
|
344
|
+
write(formatServiceLine("MCP", `http://127.0.0.1:${server.port}`));
|
|
338
345
|
return {
|
|
339
346
|
port: server.port,
|
|
340
347
|
url: server.url,
|
|
@@ -352,7 +359,7 @@ export async function runDev(options: DevOptions = {}): Promise<DevResult> {
|
|
|
352
359
|
url: appUrl,
|
|
353
360
|
out: resolve(cwd, "oke-client.d.ts"),
|
|
354
361
|
});
|
|
355
|
-
write("
|
|
362
|
+
write(formatStatusLine("regenerated oke-client.d.ts"));
|
|
356
363
|
} catch {
|
|
357
364
|
// App may not be ready yet — ignore until next save.
|
|
358
365
|
}
|
|
@@ -515,7 +522,7 @@ async function startAppHot(
|
|
|
515
522
|
proc,
|
|
516
523
|
APP_READY_TIMEOUT_MS,
|
|
517
524
|
);
|
|
518
|
-
// Child prints
|
|
525
|
+
// Child prints the App ready line (again on each soft reload).
|
|
519
526
|
const url = new URL(`http://${hostname}:${boundPort}/`);
|
|
520
527
|
return { stop, port: boundPort, url };
|
|
521
528
|
} catch (err) {
|
|
@@ -52,10 +52,13 @@ describe("claim code", () => {
|
|
|
52
52
|
|
|
53
53
|
test("prints to boot log exactly once", () => {
|
|
54
54
|
const state = mintClaimCode(() => 1);
|
|
55
|
-
const
|
|
56
|
-
printClaimCodeOnce(state, (l) =>
|
|
57
|
-
printClaimCodeOnce(state, (l) =>
|
|
58
|
-
|
|
55
|
+
const chunks: string[] = [];
|
|
56
|
+
printClaimCodeOnce(state, (l) => chunks.push(l));
|
|
57
|
+
printClaimCodeOnce(state, (l) => chunks.push(l));
|
|
58
|
+
const joined = chunks.join("");
|
|
59
|
+
expect(joined).toContain(state.code);
|
|
60
|
+
expect(joined).toContain("Claim code");
|
|
61
|
+
expect(chunks.length).toBe(1);
|
|
59
62
|
});
|
|
60
63
|
|
|
61
64
|
test("constantTimeEqual is length-safe", () => {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* and rate-limited (console §2.5 · §10.4).
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { formatClaimNote } from "../../term.ts";
|
|
8
9
|
import {
|
|
9
10
|
AUTH_RATE_LIMIT,
|
|
10
11
|
AUTH_RATE_WINDOW_MS,
|
|
@@ -67,13 +68,7 @@ export function printClaimCodeOnce(
|
|
|
67
68
|
): void {
|
|
68
69
|
if (state.printed) return;
|
|
69
70
|
state.printed = true;
|
|
70
|
-
write(
|
|
71
|
-
write("┌─────────────────────────────────────────────────────────┐");
|
|
72
|
-
write("│ oke Console — first-admin claim code (expires 30 min) │");
|
|
73
|
-
write(`│ ${state.code} │`);
|
|
74
|
-
write("│ Whoever can read this log already owns the server. │");
|
|
75
|
-
write("└─────────────────────────────────────────────────────────┘");
|
|
76
|
-
write("");
|
|
71
|
+
write(formatClaimNote(state.code));
|
|
77
72
|
}
|
|
78
73
|
|
|
79
74
|
/** Result of {@link verifyClaimCode}. */
|