nervur 0.22.2-8 → 0.23.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.
package/AUTHORING.md CHANGED
@@ -641,8 +641,8 @@ export const faculties = {
641
641
  A ground is the process houses run in, and you write none. `nervur up`
642
642
  runs one on a folder of code: a folder for each house, and each module
643
643
  your entries name. It holds one key in `state/`, and keeps every entry
644
- sealed in its drawer: which faculties stand, and which houses open on
645
- which bodies.
644
+ sealed as the cells of its dock's beings: which faculties stand, and
645
+ which houses open on which bodies.
646
646
 
647
647
  ### The shop's folder
648
648
 
@@ -681,31 +681,44 @@ npx nervur up .
681
681
  The ground boots in one order, and a stop is that order reversed, on an
682
682
  interrupt and on `SIGTERM`.
683
683
 
684
- 1. **Lock.** One ground to its state.
685
- 2. **Primordial.** Its unlock, its ledger, crypto and tools go up. Its
686
- key is read from `state/key`, drawn there on the first start.
687
- 3. **Drawer.** The key opens its drawer in the ledger.
688
- 4. **Entries.** The drawer's entries join the defaults its environment
689
- gives, the drawer's winning by name.
690
- 5. **Ladder.** Each body is installed where its entry is new, and goes
691
- up. One that fails stays down, and says why.
692
- 6. **Houses.** Each house of the drawer opens on its bodies, and its
693
- door joins the carry.
694
- 7. **Ready.** The hand takes its socket, and it tells systemd it is up.
695
-
696
- It is set by its environment.
697
-
698
- | Setting | What it sets |
684
+ 1. **Primordial.** Its ledger goes up and takes the lock on its state,
685
+ so one ground runs on it. Its unlock, crypto and tools go up. Its key
686
+ is read from `state/key`, drawn there on the first start.
687
+ 2. **The ground's work.** The library's `ground` faculty goes up, which
688
+ the dock alone reaches.
689
+ 3. **Dock.** The ground's own house opens in the ledger, under a seed
690
+ its key derives. Its beings hold every entry, seed, secret and
691
+ setting as their cells.
692
+ 4. **Ladder.** The dock's steward joins your entries to the defaults its
693
+ code fixes, yours winning by name. Each entry is held to what its
694
+ faculty takes. Each body is installed where its entry is new, and
695
+ goes up. One that fails stays down, and says why.
696
+ 5. **Houses.** Each house opens on its bodies, and its door joins the
697
+ carry.
698
+ 6. **Hand.** The hand takes its socket, and the ground tells systemd it
699
+ is up.
700
+
701
+ Its environment names what opens its memory, its key and its hand, and
702
+ nothing else.
703
+
704
+ | Variable | What it names |
699
705
  | --- | --- |
700
- | `NERVUR_TCP_PORT` | its TCP port, 9110 where unset |
701
- | `NERVUR_HTTP_PORT` | its HTTP port, for Quo over the web and every handler; no HTTP where unset |
702
- | `NERVUR_ADDRESSES` | the public addresses it writes into invitations, by commas: `tcp`, `https`, `http`, `wss` or `ws` |
703
- | `NERVUR_ORIGINS` | the pages of other origins it answers on the web, by commas; a page of its own host needs none |
704
- | `NERVUR_ALLOW_PRIVATE` | `1` to dial private and loopback addresses, as two grounds on one machine do |
705
- | `NERVUR_BIND` | the address it listens on, `0.0.0.0` where unset |
706
706
  | `NERVUR_STATE` | its state, `state/` in its folder where unset |
707
707
  | `NERVUR_UNLOCK` | `keychain:<account>` keeps its key in the macOS keychain, in place of `state/key` |
708
- | `NERVUR_WAIT` | its bound on every ask, in milliseconds |
708
+ | `NERVUR_HAND` | its hand's socket, `state/hand` where unset |
709
+
710
+ Every other setting is an arg of an entry its dock keeps, set through
711
+ the hand. Its `tcp` entry listens on every address at 9110. Its `web`
712
+ entry serves the ground's one listener over HTTP, for Quo over the web
713
+ and every handler, once its args name a `port`. It names that listener
714
+ in its `faculties`. Both take `bind`, the public `addresses` written
715
+ into invitations, and `allowPrivate` to dial loopback addresses, as two
716
+ grounds on one machine do. `web` also takes the `origins` of pages it
717
+ answers. `wait set` keeps its bound on every ask.
718
+
719
+ ```bash
720
+ npx nervur faculties update name=web make=web faculties='["listener"]' args='{"port":8080}'
721
+ ```
709
722
 
710
723
  The state holds the key in a file its owner alone reads, and the
711
724
  ground's ledger. Every house keeps its rows in that ledger, sealed. A
@@ -717,10 +730,11 @@ lost key is a lost ground.
717
730
 
718
731
  The ladder stands once, and the ground stands it again at every start.
719
732
  The first entry stands the folder's `recipe.ts` as a registry, by the
720
- ground's own faculty `module`. The second raises the payments from it.
733
+ faculty `module` the folder's registry holds. The second raises the
734
+ payments from it. An entry names only faculties that stand already.
721
735
 
722
736
  ```bash
723
- npx nervur faculties add name=recipe make=module args='{"at":"recipe.ts"}'
737
+ npx nervur faculties add name=recipe from=folder make=module args='{"at":"recipe.ts"}'
724
738
  ```
725
739
 
726
740
  ```bash
@@ -743,8 +757,8 @@ write, and `faculties restart` takes a body down and up again.
743
757
 
744
758
  A secret reaches a faculty the same way, and never through the
745
759
  environment. `npx nervur secrets set -` reads `{ name, value }` from
746
- standard input into the ground's sealed drawer. A faculty's entry names
747
- the secrets its `up` receives in `secrets`.
760
+ standard input into a being of the dock, whose cells no one reads. A
761
+ faculty's entry names the secrets its `up` receives in `secrets`.
748
762
 
749
763
  ### The hand
750
764
 
@@ -756,8 +770,10 @@ describes.
756
770
  npx nervur help
757
771
  ```
758
772
 
759
- A faculty's method is called as its owner calls it, and a faculty named
760
- alone shows its methods. Args are one JSON object, or words `key=value`.
773
+ Two words ask the dock, the ground's own steward, so `houses list` asks
774
+ her `housesList`. A faculty named alone shows its methods, and a method
775
+ after it is called through the dock. Args are one JSON object, or words
776
+ `key=value`.
761
777
 
762
778
  ```bash
763
779
  npx nervur houses list
@@ -810,9 +826,10 @@ with `loginctl enable-linger`. On macOS, the agent goes to
810
826
  houses in a page. Every tab and the service worker of one origin share
811
827
  one ground: the one holding the Web Lock runs it, and the others reach
812
828
  its hand over a `BroadcastChannel`. When it closes, the next opens the
813
- ground from the same storage. `hand` answers the same three requests
814
- the command sends: `describe`, a faculty's method, and an ask of a being
815
- in a named house.
829
+ ground from the same storage. `hand` takes the same requests the
830
+ command sends: `describe`, and an ask of a being in a named house. A
831
+ request that names no house asks the dock's steward, as
832
+ `{ method: 'housesList' }`.
816
833
 
817
834
  Its bodies are the browser's. The ground's key is sealed under an AES
818
835
  key that IndexedDB holds unextractable, and its memory is IndexedDB.
@@ -907,5 +924,12 @@ at her call, or where an ask arrives.
907
924
  - A secret read by a being, a describe or anyone but a faculty whose
908
925
  entry names it.
909
926
  - A faculty raised any way but its `up`, foundation or custom.
910
- - A faculty entry for `secrets` or `moves`, which the hand alone reaches.
927
+ - An entry named `dock`, for a house or a faculty. The dock is the
928
+ library's.
929
+ - A secret or a move asked by anyone but the hand.
930
+ - A grant naming a faculty or a secret the ground does not hold.
931
+ - A secret's cells read through the hand.
932
+ - An entry naming, making or granting `ground` or `shell`. Both are the
933
+ dock's alone.
934
+ - A second ground on the state one runs on.
911
935
  - A ground an owner must write. Each terrain's ships.
package/COMMAND.md CHANGED
@@ -17,11 +17,11 @@ alone reads.
17
17
  npx nervur up .
18
18
  ```
19
19
 
20
- The ground stops cleanly on an interrupt and on `SIGTERM`. It takes a
21
- lock on its state, so a second `nervur up` on the same folder refuses to
22
- start. Keep `state/` as you keep an ssh key: whoever holds its key and
23
- its ledger holds the ground, and without the key the ledger opens
24
- nothing.
20
+ The ground stops cleanly on an interrupt and on `SIGTERM`. Its ledger
21
+ holds a lock on its state while it stands, so a second `nervur up` on
22
+ the same folder refuses to start. Keep `state/` as you keep an ssh key:
23
+ whoever holds its key and its ledger holds the ground, and without the
24
+ key the ledger opens nothing.
25
25
 
26
26
  `nervur service` prints what keeps the ground running across reboots: a
27
27
  systemd unit on Linux, a launchd job on macOS. Nothing is installed; you
@@ -33,20 +33,38 @@ npx nervur service /srv/shop
33
33
 
34
34
  ## Settings
35
35
 
36
- A ground reads its settings from the environment.
36
+ The environment names only what opens the ground's memory, its key and
37
+ its hand.
37
38
 
38
- | Setting | What it sets |
39
+ | Variable | What it names |
39
40
  | --- | --- |
40
41
  | `NERVUR_STATE` | the state folder, `state/` in the ground's folder where unset |
41
- | `NERVUR_TCP_PORT` | the TCP port Quo listens on, 9110 where unset |
42
- | `NERVUR_HTTP_PORT` | the port of the web listener, which faces and Quo over the web share; none where unset |
43
- | `NERVUR_BIND` | the address both listen on, every interface where unset |
44
- | `NERVUR_ADDRESSES` | the public addresses written into invitations, by commas |
45
- | `NERVUR_ORIGINS` | the page origins the web listener answers, by commas |
46
- | `NERVUR_ALLOW_PRIVATE` | `1` to let the ground dial a private or loopback address |
47
42
  | `NERVUR_UNLOCK` | on macOS, `keychain:<account>` keeps the key in the keychain in place of `state/key` |
48
43
  | `NERVUR_HAND` | where the hand's socket is, `state/hand` where unset; a relative path is read from where the command runs |
49
- | `NERVUR_WAIT` | the longest any ask may run, in milliseconds |
44
+
45
+ Every other setting is an entry the ground's dock keeps, set through the
46
+ hand and kept across a restart. The `tcp` entry listens on the loopback
47
+ at 9110 until you name another bind, and the `web` entry listens on no
48
+ port until one is named. The web serves the ground's one listener,
49
+ which its entry names in `faculties`.
50
+
51
+ | Arg | Of | What it sets |
52
+ | --- | --- | --- |
53
+ | `port` | `tcp`, `web` | the port it listens on; with none, it only dials |
54
+ | `bind` | `tcp`, `web` | the address it listens on, every interface where unset |
55
+ | `addresses` | `tcp`, `web` | the public addresses written into invitations |
56
+ | `origins` | `web` | the page origins the web listener answers |
57
+ | `allowPrivate` | `tcp`, `web` | `true` to let the ground dial a private or loopback address |
58
+
59
+ ```bash
60
+ npx nervur faculties update name=web make=web faculties='["listener"]' args='{"port":8080,"addresses":["https://shop.example/quo"]}'
61
+ npx nervur wait set wait=30000
62
+ ```
63
+
64
+ `faculties catalog` prints every faculty the ground can raise and what
65
+ each takes, so an entry it refuses says which arg failed. `wait set`
66
+ keeps the longest any ask may run, in milliseconds, and `wait show`
67
+ prints it.
50
68
 
51
69
  A ground that people reach names its public addresses. Without them, it
52
70
  writes only the addresses it listens on, which a stranger cannot reach.
@@ -62,22 +80,29 @@ Every other word goes to the ground's hand, a socket in `state/` that
62
80
  your user alone may open. Run the command in the ground's folder, or
63
81
  name the socket with `--at <socket>` or `NERVUR_HAND`.
64
82
 
65
- `help` prints what the ground holds: each faculty with its methods, or
66
- why it is down, and each house.
83
+ `help` prints what the ground holds: the asks of its dock, each faculty
84
+ with its methods or why it is down, and each house.
67
85
 
68
86
  ```bash
69
87
  npx nervur help
70
88
  ```
71
89
 
72
- A faculty is called by its name and a method. Named alone, it prints its
73
- methods. Four faculties are the ground's own. `secrets` keeps a secret
74
- in the ground's sealed drawer. `faculties` raises a faculty by the `up`
75
- its entry names, and `houses` opens a house on its entry. Each takes
76
- `update` to land a new entry in one write, and `faculties restart`
77
- takes a body down and up again.
90
+ The dock is the ground's own house, and its steward changes the ground.
91
+ Two words ask her, so `houses add` asks `housesAdd`. One word alone
92
+ prints the asks it begins. `secrets set` keeps a secret in a being of
93
+ the dock, whose cells no one reads. `faculties add` raises a faculty by
94
+ the `up` its entry names, and `houses add` opens a house on its entry.
95
+ Each answers why the body is down or the house closed, where it is.
96
+ Each `update` lands a new entry in one write, and `faculties restart`
97
+ takes a body down and up again. A faculty named with a method is called
98
+ through the dock, and named alone it prints its methods.
99
+
100
+ An entry names only faculties and secrets the ground holds already. A
101
+ module and a program stand on the folder's registry, so their entries
102
+ say `from=folder`.
78
103
 
79
104
  ```bash
80
- npx nervur faculties add name=recipe make=module args='{"at":"recipe.ts"}'
105
+ npx nervur faculties add name=recipe from=folder make=module args='{"at":"recipe.ts"}'
81
106
  npx nervur faculties add name=payments from=recipe make=payments secrets='["stripe-key"]'
82
107
  npx nervur houses add name=main classes='{"faculty":"folder","at":"house"}' faculties='["payments"]'
83
108
  ```
@@ -98,6 +123,22 @@ repair, or a look at what her asks do not show.
98
123
  npx nervur ask main --cells
99
124
  ```
100
125
 
126
+ `ask dock` asks the dock's own beings, since no house takes that name.
127
+ `faculty.<name>`, `house.<name>` and the steward hold every entry, seed
128
+ and setting, and a secret's cells are shown to no one.
129
+
130
+ ```bash
131
+ npx nervur ask dock --id faculty.web --cells
132
+ ```
133
+
134
+ `shell run` runs a command on the ground's machine, in its code folder,
135
+ and prints its exit code and what it printed. The words after `--` are
136
+ the command line. Its environment holds nothing of the ground's.
137
+
138
+ ```bash
139
+ npx nervur shell run -- git status
140
+ ```
141
+
101
142
  The command asks no watch. A watch is held by a being on her standing,
102
143
  or by a page through a face, where something waits on its answer.
103
144
 
@@ -118,6 +159,14 @@ secret never stands on a command line or in a shell's history.
118
159
  npx nervur secrets set - < stripe-key.json
119
160
  ```
120
161
 
162
+ `--call <id>`, before the words, names the ask's call id. The same ask
163
+ sent again with the same id answers what the first answered, and runs
164
+ nothing twice. So a script that lost an answer sends its ask again.
165
+
166
+ ```bash
167
+ npx nervur --call deploy-42 houses update name=main classes='{"faculty":"folder","at":"house"}'
168
+ ```
169
+
121
170
  Each word prints one JSON value, the answer, and its exit code says what
122
171
  came back.
123
172
 
package/FACES.md CHANGED
@@ -127,7 +127,6 @@ export const FaceBlueprint = need('face', {
127
127
  export class Api {
128
128
  #context: Calls | undefined;
129
129
  #signup = '';
130
- #calls = 0;
131
130
 
132
131
  arm({ signup }: { signup: string }, context: FacultyContext): Promise<Answer> {
133
132
  this.#context = context;
@@ -145,9 +144,9 @@ export class Api {
145
144
  return this.#context;
146
145
  }
147
146
 
148
- // Each call its own id, so a call the house retries acts once.
147
+ // Each call an id drawn afresh, so no life of the face repeats one.
149
148
  #ask(token: string, method: string, args: Json): Promise<Answer> {
150
- return this.#held().call({ token, method, args, id: `api:${++this.#calls}` });
149
+ return this.#held().call({ token, method, args, id: `api:${crypto.randomUUID()}` });
151
150
  }
152
151
 
153
152
  async #tools(token: string): Promise<Json> {
@@ -213,7 +212,7 @@ export const faculties = {
213
212
  ```
214
213
 
215
214
  ```bash
216
- npx nervur faculties add name=recipe make=module args='{"at":"recipe.ts"}'
215
+ npx nervur faculties add name=recipe from=folder make=module args='{"at":"recipe.ts"}'
217
216
  npx nervur faculties add name=face from=recipe make=face
218
217
  ```
219
218
 
@@ -235,7 +234,7 @@ import { faculties } from './recipe.ts';
235
234
  test('A person signs up at the face, and reaches their member as an API and as tools', async (t) => {
236
235
  const ground = await BenchGround.open({ network: new FakeNetwork(), host: 'desk', modules: { desk }, registry: { faculties } });
237
236
  t.after(() => ground.down());
238
- await ground.hand({ faculty: 'faculties', method: 'add', args: { name: 'face', make: 'face' } });
237
+ await ground.hand({ method: 'facultiesAdd', args: { name: 'face', make: 'face' } });
239
238
  await ground.add('desk', 'desk', { faculties: ['face'] });
240
239
  await ground.ask({ house: 'desk', method: 'arm' });
241
240
  const web = async (path: string, body?: unknown, token?: string) =>
package/FACULTIES.md CHANGED
@@ -15,16 +15,22 @@ the package's own tests run.
15
15
  ## What a faculty owes
16
16
 
17
17
  A faculty answers a blueprint: a name, and methods with their schemas.
18
- A registry holds it by name as `{ up, install? }`. The ground raises it
19
- by its `up` into a body, and hands the body to its houses as an offer,
20
- with the kinds its entry grants.
18
+ A registry holds it by name as `{ takes?, up, install? }`. The ground
19
+ raises it by its `up` into a body, and hands the body to its houses as
20
+ an offer, with the kinds its entry grants.
21
21
 
22
22
  ```text
23
- faculty = { install?, up }
23
+ faculty = { takes?, install?, up }
24
+ takes = { args?: schema, secrets?: { [name]: what it holds } }
24
25
  body = { blueprint?, object?, window?, handler?, registry?, down? }
25
26
  offer = { blueprint, object, kinds?, window? }
26
27
  ```
27
28
 
29
+ - **It declares what it takes.** `takes.args` is a schema built with
30
+ `s` from `nervur/being`, which its entry's args meet. `takes.secrets`
31
+ names each secret its entry must name, with a line saying what it
32
+ holds. The hand refuses an entry that fails either, before it lands,
33
+ and `facultiesCatalog` shows it to whoever writes the entry.
28
34
  - **The object has the blueprint's methods.** Each takes one args object
29
35
  and a context, and answers `{ result }` or `{ error: { message } }`.
30
36
  - **An error is final, and a throw is not.** An error reaches the being
@@ -93,7 +99,8 @@ receives four things beside the faculty's name.
93
99
 
94
100
  - **`args`** are its entry's, as the owner wrote them.
95
101
  - **`secrets`** are the secrets its entry names, set through the hand
96
- and kept sealed in the ground's drawer. No other code reads them.
102
+ and kept sealed in a being of the ground's dock. No other code reads
103
+ them.
97
104
  - **`memory`** is the faculty's own, a view of the ground's memory
98
105
  sealed under a key the ground derives for it. Its call ids live there,
99
106
  so they move with the ground.
@@ -378,11 +385,11 @@ it later, once.
378
385
 
379
386
  The Pi's folder holds the program and a folder of classes for its
380
387
  house, and no code of the ground's. The relay stands from its entry,
381
- raised by the NodeGround's own faculty `bridge`, and granted to the
382
- twin's class alone.
388
+ raised by the faculty `bridge` of the NodeGround's folder, and granted
389
+ to the twin's class alone.
383
390
 
384
391
  ```bash
385
- npx nervur faculties add name=relay make=bridge args='{"command":"python3","args":["relay.py"]}' kinds='["org.example.garage"]'
392
+ npx nervur faculties add name=relay from=folder make=bridge args='{"command":"python3","args":["relay.py"]}' kinds='["org.example.garage"]'
386
393
  ```
387
394
 
388
395
  The house is added once, and names the relay among the faculties it
@@ -392,8 +399,8 @@ receives.
392
399
  npx nervur houses add name=garage classes='{"faculty":"folder","at":"classes"}' faculties='["relay"]'
393
400
  ```
394
401
 
395
- Both entries rest sealed in the ground's drawer, so the ground stands
396
- the relay again at every start.
402
+ Both entries rest sealed as cells of the ground's dock, so the ground
403
+ stands the relay again at every start.
397
404
 
398
405
  ## In JavaScript
399
406
 
@@ -493,7 +500,7 @@ test('Each tap on the phone pulses the relay once, whatever fails between', { ti
493
500
  });
494
501
  t.after(() => garage.down());
495
502
  // The relay, granted to the twin's class alone.
496
- await garage.hand({ faculty: 'faculties', method: 'add', args: { name: 'relay', make: 'bridge', kinds: ['org.example.garage'] } });
503
+ await garage.hand({ method: 'facultiesAdd', args: { name: 'relay', make: 'bridge', kinds: ['org.example.garage'] } });
497
504
  await garage.add('garage', 'pi', { faculties: ['relay'] });
498
505
  await garage.ask({ house: 'garage', method: 'bear', args: { kind: 'org.example.garage', id: 'door' } });
499
506