@niscorp/moss 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 CHANGED
@@ -4,22 +4,26 @@ The nisc application server. A principal logs in, a charter resolves, and what a
4
4
 
5
5
  Moss does not host code and guard it. It serves *existence*: a resolved catalog **is** the application. The warehouse kiosk granted two actions is not a locked-down app; it is a two-action app. There is nothing else to render, invoke, or attack.
6
6
 
7
- > Early stages. The data/policy plane, the socket, per-principal server shells, ring-2 served layout variants, the in-process function seam, and the canvas terminal (the wire plus swappable render targets) are built and tested — except the terminal's render targets, which have no tests yet. The fn *host* (`/fns`), the artifact library, the projection model, and scale-out are specified and pending. See [DESIGN.md](DESIGN.md) for the thesis and the unbuilt ladder.
7
+ > On npm, and still early. The data/policy plane, the socket, per-principal server shells, ring-2 served layout variants, the in-process function seam, server-drawn documents and pages, and the canvas terminal (the wire plus swappable render targets) are built and tested — except the ink render target, which has no tests yet. The fn *host* (`/fns`), the artifact library, the projection model, and scale-out are specified and pending. See [DESIGN.md](DESIGN.md) for the thesis and the unbuilt ladder.
8
8
 
9
9
  ## Install
10
10
 
11
11
  ```bash
12
- pnpm add @niscorp/moss zod
13
- # everything moss composes (charter, vex, nova, prism, hono, the Node
14
- # listener) comes with it as regular dependencies. The one optional peer
15
- # pair is React, needed only for the ./terminal/react render target:
16
- pnpm add react react-dom
17
- # (or Vue, needed only for the ./terminal/vue render target: pnpm add vue)
12
+ pnpm add @niscorp/moss @niscorp/charter @niscorp/nova @niscorp/prism @niscorp/strata @niscorp/tide @niscorp/vex zod
13
+ # the nisc packages moss composes and zod are required peers — the app owns
14
+ # the one copy of each. hono, the Node listener and ws come with moss as
15
+ # regular dependencies. The optional peers, each needed by one subpath only:
16
+ pnpm add react react-dom # ./terminal/react (and its /server)
17
+ pnpm add vue # ./terminal/vue (and its /server)
18
+ pnpm add ink react # ./terminal/ink
19
+ pnpm add -D vite # ./vite
18
20
  ```
19
21
 
22
+ Node ≥ 22.12.
23
+
20
24
  ## The shape
21
25
 
22
- An app hands moss its **artifacts** (`defineApp`) and an **environment** (`NiscRuntime` — a database, optionally a cache and a session verifier). Everything mechanical is derived: the data layer from the schema, per-principal policy and catalogs from the charter, the server shells from the manifest. The server refuses to boot on an incoherent charter.
26
+ An app hands moss its **artifacts** (`defineApp`) and an **environment** (`NiscRuntime` — a database and how a session token is verified, optionally a cache). Everything mechanical is derived: the data layer from the schema, per-principal policy and catalogs from the charter, the server shells from the manifest. The server refuses to boot on an incoherent charter.
23
27
 
24
28
  ```typescript
25
29
  import { defineApp } from '@niscorp/moss';
@@ -41,7 +45,9 @@ const app = defineApp({
41
45
  functions, // the in-process fn seam (agents, sign-in) — optional
42
46
  });
43
47
 
44
- const server = await serve(app, { pool, db, port: 3000 });
48
+ const server = await serve(app, { pool, db, session: 'sessions', port: 3000 });
49
+ // `session` is required: 'sessions' (moss's stored credential), 'dev-open'
50
+ // (every well-formed token trusted — harnesses), or the app's own verifier.
45
51
  // boot refusal here (createServer runs inside serve); HTTP + ws in one
46
52
  ```
47
53
 
@@ -125,7 +131,7 @@ never in moss core.
125
131
  ## Subpaths
126
132
 
127
133
  - **`@niscorp/moss`** — the server: `defineApp`, `createServer`, the resolution and shell-host internals, the socket protocol types.
128
- - **`@niscorp/moss/node`** — the Node listener: `serve` + `attachSocket` (raw `ws`). Bun swaps this file, never the app.
134
+ - **`@niscorp/moss/node`** — the Node listener: `serve` + `attachSocket` (raw `ws`), and `mountSite(server, { dist, draw })` — the built terminal served by the same process, every page drawn. Bun swaps this file, never the app.
129
135
  - **`@niscorp/moss/vite`** — `mossDev({ app })`: the app server inside vite's dev process — loaded through vite (an edit re-boots it), the socket attached once, pages drawn, moss's paths answered, a dev-only `/dev/as/<who>`. `nisc dev` adds it for an app behind moss; `vite` is an optional peer.
130
136
  - **`@niscorp/moss/client`** — the wire: `createWire()`, the app end of the socket. Plain TypeScript, zero React, zero globals — the host comes in as a `WireEnv` (default: `browserEnv()`, localStorage + location).
131
137
  - **`@niscorp/moss/client/node`** — the Node host env: `nodeEnv({ url, tokenFile? })` runs the same wire on a plain Node (or Bun) process — token in a file, the runtime's WHATWG WebSocket.
@@ -133,6 +139,7 @@ never in moss core.
133
139
  - **`@niscorp/moss/terminal/react`** — the React render target: `reactTarget({ root, registry, slotWrapper? })` binds the app's component registry to the wire via nova's React adapter.
134
140
  - **`@niscorp/moss/terminal/vue`** — the Vue render target: `vueTarget({ root, registry, slotWrapper? })` binds the app's Vue component registry to the wire via nova's Vue adapter; updates re-render reactively, never remount.
135
141
  - **`@niscorp/moss/terminal/dom`** — the plain-DOM render target: `domTarget({ root })` renders with nova's DOM adapter and default kit. Zero framework.
142
+ - **`@niscorp/moss/terminal/react/server`**, **`/vue/server`**, **`/dom/server`** — `renderSnapshot(...)`: a shell snapshot drawn to a string by the same kit, for `renderDocument`'s `draw`.
136
143
  - **`@niscorp/moss/terminal/tty`** — the line-terminal render target: `ttyTarget({ input, output })` runs the app as a REPL in a real terminal — served frames print as text with numbered markers, typing acts on them (numbers tap, words fill), and the same events ride the wire. Zero framework, zero DOM.
137
144
  - **`@niscorp/moss/terminal/ink`** — the full-screen terminal render target: `inkTarget()` runs the app as a TUI — nova's Ink kit on the React adapter's walker. Same `[n]` addressing as the REPL (typed digits click/flip/focus), plus Tab/arrows and live typing. ESM-only, like ink.
138
145
 
@@ -144,10 +151,12 @@ never in moss core.
144
151
 
145
152
  ## Tables and documents, versioned
146
153
 
147
- moss creates no table on its own: its tables (`MOSS_SEQUENCE`,
148
- `SESSIONS_SEQUENCE`, `TIDE_SEQUENCE`) and the vex cache's go through one
149
- [strata](../strata/README.md) ledger run at boot — once, recorded, refused if
150
- the ledger was edited or written by newer code. `migrations: 'verify'` on the
154
+ moss creates no table on its own: its tables (`MOSS_SEQUENCE`, plus
155
+ `SESSIONS_SEQUENCE` when the runtime's `session` is `'sessions'`) and the vex
156
+ cache's go through one [strata](../strata/README.md) ledger run at boot — once,
157
+ recorded, refused if the ledger was edited or written by newer code. The tide
158
+ store's tables (`TIDE_SEQUENCE`) go through the same ledger when
159
+ `createTideStore(pool)` is called. `migrations: 'verify'` on the
151
160
  runtime refuses to boot with anything pending. Stored integration actions carry
152
161
  a grammar stamp and are upgraded at boot, at intake and on read — through
153
162
  nova's and Prism's grammars plus the app's own (`NiscApp.grammars`); a bundle or
@@ -593,6 +593,13 @@ type NiscApp = {
593
593
  wire: FetchFn;
594
594
  }) => Phrasebook | undefined | Promise<Phrasebook | undefined>;
595
595
  phraseKeys?: PhraseKeys;
596
+ /**
597
+ * @deprecated Never called. Which integrations are live for a principal's
598
+ * tenant is `installed` on the record `identity.resolve` returns; without
599
+ * `identity`, every registered integration is live for everybody. Kept on
600
+ * the type so a manifest that still names it compiles; removed at the next
601
+ * breaking release.
602
+ */
596
603
  installedIntegrations?: (principal: string | null) => readonly string[] | Promise<readonly string[]>;
597
604
  integrationActor?: (integration: string, actsFor: string) => string | null | Promise<string | null>;
598
605
  attachable?: Record<string, Record<string, string>>;
@@ -593,6 +593,13 @@ type NiscApp = {
593
593
  wire: FetchFn;
594
594
  }) => Phrasebook | undefined | Promise<Phrasebook | undefined>;
595
595
  phraseKeys?: PhraseKeys;
596
+ /**
597
+ * @deprecated Never called. Which integrations are live for a principal's
598
+ * tenant is `installed` on the record `identity.resolve` returns; without
599
+ * `identity`, every registered integration is live for everybody. Kept on
600
+ * the type so a manifest that still names it compiles; removed at the next
601
+ * breaking release.
602
+ */
596
603
  installedIntegrations?: (principal: string | null) => readonly string[] | Promise<readonly string[]>;
597
604
  integrationActor?: (integration: string, actsFor: string) => string | null | Promise<string | null>;
598
605
  attachable?: Record<string, Record<string, string>>;