nervur 0.21.4 → 0.22.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 (339) hide show
  1. package/README.md +215 -158
  2. package/dist/browser.js +4 -3
  3. package/dist/cli.js +16 -0
  4. package/dist/{being → core/being}/being.js +10 -0
  5. package/dist/{being → core/being}/faculty.js +5 -2
  6. package/dist/{being → core/being}/index.d.ts +1 -1
  7. package/dist/{being → core/being}/index.js +1 -1
  8. package/dist/{being → core/being}/kind.d.ts +2 -0
  9. package/dist/{being → core/being}/kind.js +6 -0
  10. package/dist/{being → core/being}/types.js +1 -1
  11. package/dist/{browser → core/browser}/index.d.ts +6 -5
  12. package/dist/{browser → core/browser}/index.js +10 -10
  13. package/dist/{browser → core/browser}/worker.d.ts +2 -3
  14. package/dist/{browser → core/browser}/worker.js +8 -11
  15. package/dist/{cli → core/cli}/command.d.ts +4 -4
  16. package/dist/{cli → core/cli}/command.js +116 -66
  17. package/dist/{cli → core/cli}/edge.js +4 -2
  18. package/dist/core/cli/harbor.d.ts +25 -0
  19. package/dist/{cli → core/cli}/harbor.js +45 -33
  20. package/dist/{contract → core/contract}/index.d.ts +6 -5
  21. package/dist/{contract → core/contract}/index.js +8 -9
  22. package/dist/core/contract/link.d.ts +4 -0
  23. package/dist/core/contract/link.js +45 -0
  24. package/dist/{crypto → core/crypto}/ed25519.js +22 -14
  25. package/dist/core/crypto/subtle.d.ts +3 -0
  26. package/dist/core/crypto/subtle.js +11 -0
  27. package/dist/core/crypto/x25519.js +24 -0
  28. package/dist/core/edge/index.d.ts +164 -0
  29. package/dist/core/edge/index.js +739 -0
  30. package/dist/core/edge/kit.d.ts +2 -0
  31. package/dist/core/edge/kit.js +2 -0
  32. package/dist/core/git/http.d.ts +6 -0
  33. package/dist/core/git/http.js +102 -0
  34. package/dist/core/git/index.d.ts +5 -0
  35. package/dist/core/git/index.js +10 -0
  36. package/dist/core/git/object.d.ts +40 -0
  37. package/dist/core/git/object.js +103 -0
  38. package/dist/core/git/pack.d.ts +9 -0
  39. package/dist/core/git/pack.js +171 -0
  40. package/dist/core/git/store.d.ts +23 -0
  41. package/dist/core/git/store.js +120 -0
  42. package/dist/core/git/zlib.d.ts +6 -0
  43. package/dist/core/git/zlib.js +210 -0
  44. package/dist/core/harbor/carrying.d.ts +51 -0
  45. package/dist/core/harbor/carrying.js +69 -0
  46. package/dist/core/harbor/catalogue.d.ts +33 -0
  47. package/dist/core/harbor/catalogue.js +365 -0
  48. package/dist/core/harbor/dna.d.ts +13 -0
  49. package/dist/core/harbor/dna.js +120 -0
  50. package/dist/{harbor → core/harbor}/dock.d.ts +22 -13
  51. package/dist/core/harbor/dock.js +381 -0
  52. package/dist/core/harbor/harbor.d.ts +16 -0
  53. package/dist/core/harbor/harbor.js +438 -0
  54. package/dist/core/harbor/index.d.ts +11 -0
  55. package/dist/{harbor → core/harbor}/index.js +5 -5
  56. package/dist/core/harbor/memory.d.ts +10 -0
  57. package/dist/core/harbor/memory.js +25 -0
  58. package/dist/{harbor → core/harbor}/package.d.ts +0 -1
  59. package/dist/{harbor → core/harbor}/package.js +9 -9
  60. package/dist/core/harbor/probe.d.ts +22 -0
  61. package/dist/core/harbor/probe.js +15 -0
  62. package/dist/core/harbor/registry.d.ts +15 -0
  63. package/dist/{harbor → core/harbor}/registry.js +26 -10
  64. package/dist/core/harbor/root-line.d.ts +7 -0
  65. package/dist/core/harbor/root-line.js +9 -0
  66. package/dist/{harbor → core/harbor}/terrain.d.ts +9 -6
  67. package/dist/{harbor → core/harbor}/terrain.js +5 -4
  68. package/dist/core/http/index.d.ts +2 -0
  69. package/dist/{http → core/http}/index.js +3 -5
  70. package/dist/{line → core/line}/answer.d.ts +2 -2
  71. package/dist/{line → core/line}/frame.d.ts +0 -5
  72. package/dist/{line → core/line}/frame.js +0 -4
  73. package/dist/core/line/ground.js +7 -0
  74. package/dist/core/line/index.d.ts +4 -0
  75. package/dist/core/line/index.js +8 -0
  76. package/dist/core/line/web.d.ts +12 -0
  77. package/dist/{line → core/line}/web.js +13 -77
  78. package/dist/{node → core/node}/index.d.ts +2 -15
  79. package/dist/core/node/index.js +124 -0
  80. package/dist/{pointer → core/pointer}/bodies.d.ts +7 -5
  81. package/dist/core/pointer/bodies.js +118 -0
  82. package/dist/core/pointer/index.d.ts +2 -0
  83. package/dist/{pointer → core/pointer}/index.js +1 -1
  84. package/dist/{pointer → core/pointer}/world.d.ts +13 -9
  85. package/dist/{pointer → core/pointer}/world.js +31 -16
  86. package/dist/{proof → core/proof}/contracts.d.ts +6 -2
  87. package/dist/{proof → core/proof}/contracts.js +11 -10
  88. package/dist/core/proof/index.d.ts +3 -0
  89. package/dist/{proof → core/proof}/index.js +2 -2
  90. package/dist/core/proof/law.d.ts +25 -0
  91. package/dist/core/proof/law.js +715 -0
  92. package/dist/{tcp → core/tcp}/index.d.ts +7 -4
  93. package/dist/{tcp → core/tcp}/index.js +11 -62
  94. package/dist/{ward/ward.d.ts → core/ward/house.d.ts} +24 -10
  95. package/dist/core/ward/house.js +473 -0
  96. package/dist/core/ward/index.d.ts +5 -0
  97. package/dist/core/ward/index.js +7 -0
  98. package/dist/{ward → core/ward}/partition.d.ts +1 -0
  99. package/dist/{ward → core/ward}/stance.d.ts +2 -2
  100. package/dist/{ward → core/ward}/stance.js +5 -2
  101. package/dist/{ward/ward-being.d.ts → core/ward/ward.d.ts} +14 -6
  102. package/dist/core/ward/ward.js +140 -0
  103. package/dist/core.d.ts +10 -0
  104. package/dist/core.js +19 -0
  105. package/dist/defaults/dock/index.d.ts +4 -0
  106. package/dist/defaults/dock/index.js +11 -0
  107. package/dist/defaults/index.d.ts +5 -0
  108. package/dist/defaults/index.js +10 -0
  109. package/dist/defaults/memory/index.d.ts +12 -0
  110. package/dist/defaults/memory/index.js +39 -0
  111. package/dist/defaults/tcp/index.d.ts +16 -0
  112. package/dist/defaults/tcp/index.js +82 -0
  113. package/dist/defaults/ward/index.d.ts +4 -0
  114. package/dist/defaults/ward/index.js +11 -0
  115. package/dist/defaults/web/index.d.ts +15 -0
  116. package/dist/defaults/web/index.js +90 -0
  117. package/dist/edge.js +4 -3
  118. package/dist/index.d.ts +1 -8
  119. package/dist/index.js +13 -18
  120. package/dist/kit.d.ts +4 -0
  121. package/dist/kit.js +12 -0
  122. package/dist/node.js +4 -3
  123. package/package.json +23 -18
  124. package/src/browser.ts +4 -3
  125. package/src/cli.ts +15 -0
  126. package/src/{being → core/being}/being.ts +4 -0
  127. package/src/{being → core/being}/faculty.ts +5 -2
  128. package/src/{being → core/being}/index.ts +1 -1
  129. package/src/{being → core/being}/kind.ts +7 -0
  130. package/src/{being → core/being}/types.ts +1 -1
  131. package/src/{browser → core/browser}/index.ts +16 -13
  132. package/src/{browser → core/browser}/worker.ts +11 -14
  133. package/src/{cli → core/cli}/command.ts +113 -66
  134. package/src/{cli → core/cli}/edge.ts +4 -2
  135. package/src/{cli → core/cli}/harbor.ts +48 -31
  136. package/src/{contract → core/contract}/index.ts +14 -14
  137. package/src/core/contract/link.ts +58 -0
  138. package/src/{crypto → core/crypto}/ed25519.ts +22 -14
  139. package/src/core/crypto/subtle.ts +13 -0
  140. package/src/core/crypto/x25519.ts +23 -0
  141. package/src/core/edge/index.ts +865 -0
  142. package/src/core/git/http.ts +103 -0
  143. package/src/core/git/index.ts +10 -0
  144. package/src/core/git/object.ts +116 -0
  145. package/src/core/git/pack.ts +147 -0
  146. package/src/core/git/store.ts +122 -0
  147. package/src/core/git/zlib.ts +197 -0
  148. package/src/core/harbor/carrying.ts +124 -0
  149. package/src/core/harbor/catalogue.ts +386 -0
  150. package/src/core/harbor/dna.ts +116 -0
  151. package/src/core/harbor/dock.ts +420 -0
  152. package/src/core/harbor/harbor.ts +433 -0
  153. package/src/core/harbor/index.ts +14 -0
  154. package/src/core/harbor/memory.ts +31 -0
  155. package/src/{harbor → core/harbor}/package.ts +15 -15
  156. package/src/core/harbor/probe.ts +39 -0
  157. package/src/{harbor → core/harbor}/registry.ts +28 -11
  158. package/src/core/harbor/root-line.ts +19 -0
  159. package/src/{harbor → core/harbor}/terrain.ts +14 -7
  160. package/src/{http → core/http}/index.ts +5 -8
  161. package/src/{line → core/line}/answer.ts +3 -2
  162. package/src/{line → core/line}/frame.ts +0 -5
  163. package/src/core/line/ground.ts +18 -0
  164. package/src/core/line/index.ts +8 -0
  165. package/src/{line → core/line}/web.ts +1 -105
  166. package/src/core/node/index.ts +139 -0
  167. package/src/core/pointer/bodies.ts +122 -0
  168. package/src/core/pointer/index.ts +4 -0
  169. package/src/{pointer → core/pointer}/world.ts +45 -21
  170. package/src/{proof → core/proof}/contracts.ts +18 -13
  171. package/src/{proof → core/proof}/index.ts +3 -3
  172. package/src/core/proof/law.ts +742 -0
  173. package/src/{stand → core/stand}/stand.ts +2 -2
  174. package/src/{tcp → core/tcp}/index.ts +17 -74
  175. package/src/core/ward/house.ts +524 -0
  176. package/src/core/ward/index.ts +7 -0
  177. package/src/{ward → core/ward}/partition.ts +5 -1
  178. package/src/{ward → core/ward}/stance.ts +5 -2
  179. package/src/core/ward/ward.ts +166 -0
  180. package/src/core.ts +55 -0
  181. package/src/defaults/dock/index.ts +12 -0
  182. package/src/defaults/index.ts +10 -0
  183. package/src/defaults/memory/index.ts +50 -0
  184. package/src/defaults/tcp/index.ts +89 -0
  185. package/src/defaults/ward/index.ts +12 -0
  186. package/src/defaults/web/index.ts +97 -0
  187. package/src/edge.ts +4 -3
  188. package/src/index.ts +13 -50
  189. package/src/kit.ts +15 -0
  190. package/src/node.ts +4 -3
  191. package/dist/cli/harbor.d.ts +0 -16
  192. package/dist/cli/main.js +0 -14
  193. package/dist/crypto/subtle.d.ts +0 -10
  194. package/dist/crypto/subtle.js +0 -29
  195. package/dist/crypto/x25519.js +0 -21
  196. package/dist/edge/index.d.ts +0 -81
  197. package/dist/edge/index.js +0 -400
  198. package/dist/harbor/carrying.d.ts +0 -17
  199. package/dist/harbor/carrying.js +0 -38
  200. package/dist/harbor/catalogue.d.ts +0 -28
  201. package/dist/harbor/catalogue.js +0 -109
  202. package/dist/harbor/dock.js +0 -236
  203. package/dist/harbor/harbor.d.ts +0 -45
  204. package/dist/harbor/harbor.js +0 -347
  205. package/dist/harbor/index.d.ts +0 -11
  206. package/dist/harbor/probe.d.ts +0 -18
  207. package/dist/harbor/probe.js +0 -15
  208. package/dist/harbor/registry.d.ts +0 -10
  209. package/dist/harbor/relay.d.ts +0 -15
  210. package/dist/harbor/relay.js +0 -406
  211. package/dist/harbor/root-line.d.ts +0 -9
  212. package/dist/harbor/root-line.js +0 -38
  213. package/dist/harbor/store.d.ts +0 -13
  214. package/dist/harbor/store.js +0 -53
  215. package/dist/http/index.d.ts +0 -4
  216. package/dist/line/ground.js +0 -9
  217. package/dist/line/index.d.ts +0 -5
  218. package/dist/line/index.js +0 -9
  219. package/dist/line/push.d.ts +0 -7
  220. package/dist/line/push.js +0 -92
  221. package/dist/line/web.d.ts +0 -30
  222. package/dist/node/index.js +0 -236
  223. package/dist/pointer/bodies.js +0 -80
  224. package/dist/pointer/index.d.ts +0 -2
  225. package/dist/proof/index.d.ts +0 -3
  226. package/dist/proof/law.d.ts +0 -90
  227. package/dist/proof/law.js +0 -591
  228. package/dist/tcp/frame.d.ts +0 -25
  229. package/dist/tcp/frame.js +0 -64
  230. package/dist/ward/index.d.ts +0 -6
  231. package/dist/ward/index.js +0 -8
  232. package/dist/ward/pilot.d.ts +0 -8
  233. package/dist/ward/pilot.js +0 -50
  234. package/dist/ward/ward-being.js +0 -82
  235. package/dist/ward/ward.js +0 -290
  236. package/src/cli/main.ts +0 -13
  237. package/src/crypto/subtle.ts +0 -33
  238. package/src/crypto/x25519.ts +0 -21
  239. package/src/edge/index.ts +0 -490
  240. package/src/harbor/carrying.ts +0 -56
  241. package/src/harbor/catalogue.ts +0 -134
  242. package/src/harbor/dock.ts +0 -265
  243. package/src/harbor/harbor.ts +0 -381
  244. package/src/harbor/index.ts +0 -14
  245. package/src/harbor/probe.ts +0 -34
  246. package/src/harbor/relay.ts +0 -418
  247. package/src/harbor/root-line.ts +0 -39
  248. package/src/harbor/store.ts +0 -69
  249. package/src/line/ground.ts +0 -19
  250. package/src/line/index.ts +0 -9
  251. package/src/line/push.ts +0 -112
  252. package/src/node/index.ts +0 -241
  253. package/src/pointer/bodies.ts +0 -82
  254. package/src/pointer/index.ts +0 -4
  255. package/src/proof/law.ts +0 -591
  256. package/src/ward/index.ts +0 -8
  257. package/src/ward/pilot.ts +0 -50
  258. package/src/ward/ward-being.ts +0 -103
  259. package/src/ward/ward.ts +0 -328
  260. /package/dist/{cli/main.d.ts → cli.d.ts} +0 -0
  261. /package/dist/{being → core/being}/being.d.ts +0 -0
  262. /package/dist/{being → core/being}/digest.d.ts +0 -0
  263. /package/dist/{being → core/being}/digest.js +0 -0
  264. /package/dist/{being → core/being}/faculty.d.ts +0 -0
  265. /package/dist/{being → core/being}/types.d.ts +0 -0
  266. /package/dist/{being → core/being}/words.d.ts +0 -0
  267. /package/dist/{being → core/being}/words.js +0 -0
  268. /package/dist/{cli → core/cli}/edge.d.ts +0 -0
  269. /package/dist/{crypto → core/crypto}/aes.d.ts +0 -0
  270. /package/dist/{crypto → core/crypto}/aes.js +0 -0
  271. /package/dist/{crypto → core/crypto}/bytes.d.ts +0 -0
  272. /package/dist/{crypto → core/crypto}/bytes.js +0 -0
  273. /package/dist/{crypto → core/crypto}/ed25519.d.ts +0 -0
  274. /package/dist/{crypto → core/crypto}/hash.d.ts +0 -0
  275. /package/dist/{crypto → core/crypto}/hash.js +0 -0
  276. /package/dist/{crypto → core/crypto}/index.d.ts +0 -0
  277. /package/dist/{crypto → core/crypto}/index.js +0 -0
  278. /package/dist/{crypto → core/crypto}/json.d.ts +0 -0
  279. /package/dist/{crypto → core/crypto}/json.js +0 -0
  280. /package/dist/{crypto → core/crypto}/mlkem.d.ts +0 -0
  281. /package/dist/{crypto → core/crypto}/mlkem.js +0 -0
  282. /package/dist/{crypto → core/crypto}/x25519.d.ts +0 -0
  283. /package/dist/{folder → core/folder}/index.d.ts +0 -0
  284. /package/dist/{folder → core/folder}/index.js +0 -0
  285. /package/dist/{http → core/http}/websocket.d.ts +0 -0
  286. /package/dist/{http → core/http}/websocket.js +0 -0
  287. /package/dist/{line → core/line}/answer.js +0 -0
  288. /package/dist/{line → core/line}/ground.d.ts +0 -0
  289. /package/dist/{proof → core/proof}/expect.d.ts +0 -0
  290. /package/dist/{proof → core/proof}/expect.js +0 -0
  291. /package/dist/{quo → core/quo}/address.d.ts +0 -0
  292. /package/dist/{quo → core/quo}/address.js +0 -0
  293. /package/dist/{quo → core/quo}/door.d.ts +0 -0
  294. /package/dist/{quo → core/quo}/door.js +0 -0
  295. /package/dist/{quo → core/quo}/index.d.ts +0 -0
  296. /package/dist/{quo → core/quo}/index.js +0 -0
  297. /package/dist/{quo → core/quo}/invitation.d.ts +0 -0
  298. /package/dist/{quo → core/quo}/invitation.js +0 -0
  299. /package/dist/{quo → core/quo}/keys.d.ts +0 -0
  300. /package/dist/{quo → core/quo}/keys.js +0 -0
  301. /package/dist/{quo → core/quo}/payload.d.ts +0 -0
  302. /package/dist/{quo → core/quo}/payload.js +0 -0
  303. /package/dist/{quo → core/quo}/relations.d.ts +0 -0
  304. /package/dist/{quo → core/quo}/relations.js +0 -0
  305. /package/dist/{quo → core/quo}/reply.d.ts +0 -0
  306. /package/dist/{quo → core/quo}/reply.js +0 -0
  307. /package/dist/{quo → core/quo}/seal.d.ts +0 -0
  308. /package/dist/{quo → core/quo}/seal.js +0 -0
  309. /package/dist/{quo → core/quo}/standing.d.ts +0 -0
  310. /package/dist/{quo → core/quo}/standing.js +0 -0
  311. /package/dist/{ward → core/ward}/allowance.d.ts +0 -0
  312. /package/dist/{ward → core/ward}/allowance.js +0 -0
  313. /package/dist/{ward → core/ward}/cells.d.ts +0 -0
  314. /package/dist/{ward → core/ward}/cells.js +0 -0
  315. /package/dist/{ward → core/ward}/partition.js +0 -0
  316. /package/src/{being → core/being}/digest.ts +0 -0
  317. /package/src/{being → core/being}/words.ts +0 -0
  318. /package/src/{crypto → core/crypto}/aes.ts +0 -0
  319. /package/src/{crypto → core/crypto}/bytes.ts +0 -0
  320. /package/src/{crypto → core/crypto}/hash.ts +0 -0
  321. /package/src/{crypto → core/crypto}/index.ts +0 -0
  322. /package/src/{crypto → core/crypto}/json.ts +0 -0
  323. /package/src/{crypto → core/crypto}/mlkem.ts +0 -0
  324. /package/src/{folder → core/folder}/index.ts +0 -0
  325. /package/src/{http → core/http}/websocket.ts +0 -0
  326. /package/src/{proof → core/proof}/expect.ts +0 -0
  327. /package/src/{quo → core/quo}/address.ts +0 -0
  328. /package/src/{quo → core/quo}/door.ts +0 -0
  329. /package/src/{quo → core/quo}/index.ts +0 -0
  330. /package/src/{quo → core/quo}/invitation.ts +0 -0
  331. /package/src/{quo → core/quo}/keys.ts +0 -0
  332. /package/src/{quo → core/quo}/payload.ts +0 -0
  333. /package/src/{quo → core/quo}/relations.ts +0 -0
  334. /package/src/{quo → core/quo}/reply.ts +0 -0
  335. /package/src/{quo → core/quo}/seal.ts +0 -0
  336. /package/src/{quo → core/quo}/standing.ts +0 -0
  337. /package/src/{stand → core/stand}/main.ts +0 -0
  338. /package/src/{ward → core/ward}/allowance.ts +0 -0
  339. /package/src/{ward → core/ward}/cells.ts +0 -0
@@ -57,7 +57,7 @@ const answerOf = (read: Read): Answer => {
57
57
  return readValue(read.object, DEPTH) ?? silence;
58
58
  };
59
59
 
60
- export class WardStance implements Stance {
60
+ export class HouseStance implements Stance {
61
61
  readonly key: string;
62
62
  readonly occupants: Occupants;
63
63
  readonly standings: Standings;
@@ -66,7 +66,10 @@ export class WardStance implements Stance {
66
66
  readonly #lanes = new Lanes();
67
67
  readonly #cells = new Cells(() => this.#told());
68
68
 
69
- constructor(inside: Inside, key: string, row: BeingRow) {
69
+ // `carries` is what every stance of the house holds beside her own, for
70
+ // the class born of it.
71
+ constructor(inside: Inside, key: string, row: BeingRow, carries: Readonly<Record<string, unknown>> = {}) {
72
+ Object.assign(this, carries);
70
73
  this.key = key;
71
74
  this.#inside = inside;
72
75
  this.#row = row;
@@ -0,0 +1,166 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // The ward: the contract of the being that stewards one Quo ward through
3
+ // its house, the first being of every ward. Her asks are the root's, shown
4
+ // and answered to whoever pilots. The core names no class of it. Her class
5
+ // is her row's kind, and `become` names another.
6
+ //
7
+ // Every ward also holds far beings as their owner, each under a name: `hold`
8
+ // takes an owner invitation on any being of any harbor, `pilot` asks it, and
9
+ // `drop` lets it go. A held being is an ordinary standing of the ward's,
10
+ // under `held:<name>`, kept in her partition, so it moves its keys and
11
+ // survives a restart as every relation does.
12
+ import { Being, isSilence, isWord, kindOf, OWNER, shipped, ships, told, type Answer, type Asker, type AskSpec, type BeingClass, type Blueprint, type Invitation, type JsonObject, type Stance } from '../being/index.ts';
13
+ import { readInvitation } from '../quo/index.ts';
14
+
15
+ // What the house lends its ward, and no other being.
16
+ export interface Steward {
17
+ pk(): string;
18
+ classOf(name: string, registry?: string): BeingClass | undefined;
19
+ beings(): Record<string, { class: string; registry?: string; public: boolean; absent: boolean }>;
20
+ // A new being, her class resolved through the registry named, or the
21
+ // house's own.
22
+ boot(key: string, className: string, registry?: string): Promise<'booted' | 'key taken' | 'no such class' | 'threw at birth'>;
23
+ // A being her row names, stood where she does not stand yet, in a house
24
+ // whose beings stand: the box ward's faculties.
25
+ stand(key: string): 'booted' | 'stands' | 'no such being' | 'no such class' | 'threw at birth';
26
+ unboot(key: string): boolean;
27
+ publish(key: string | null): boolean;
28
+ invite(being: string, id: string, notes: JsonObject): Promise<Invitation | null>;
29
+ ask(being: string | null, method: string | undefined, args: JsonObject): Promise<Answer>;
30
+ // The ward born again of the class of this kind, on her stance, resolved
31
+ // through the registry named or the house's own: null, or why not.
32
+ become(kind: string, registry?: string): string | null;
33
+ }
34
+
35
+ export type WardStance = Stance & { readonly steward: Steward };
36
+
37
+ // Whoever pilots a ward: the root, holding its unsealed ask, or an owner,
38
+ // an occupant of the ward the root invited as one.
39
+ export const pilots = (asker: Asker, notes: JsonObject | undefined): boolean => asker.id === OWNER || notes?.owner === true;
40
+
41
+ // An ask whoever pilots the ward may make.
42
+ export const ownerAsk = (description: string, input: JsonObject = {}): AskSpec => ({ description, input: { type: 'object', ...input }, for: pilots });
43
+
44
+ // An ask the root alone may make, so a carried key pilots but never hands
45
+ // piloting on.
46
+ export const rootAsk = (description: string, input: JsonObject = {}): AskSpec => ({ description, input: { type: 'object', ...input }, for: (asker: Asker) => asker.id === OWNER });
47
+
48
+ // The standing a far being held under a name is kept under. No other
49
+ // standing of a ward takes this prefix: the dock's are her faculties' keys
50
+ // and a hosted ward's is `dock`, and a take under an id already held is
51
+ // refused, so a collision is refused and never overwrites.
52
+ export const HELD = 'held:';
53
+
54
+ const text = (v: unknown): v is string => typeof v === 'string';
55
+ const object = (v: unknown): v is JsonObject => typeof v === 'object' && v !== null && !Array.isArray(v);
56
+
57
+ export abstract class Ward extends Being {
58
+ static override readonly kind: string = 'org.nervur.ward';
59
+ static {
60
+ ships(this);
61
+ }
62
+ static override asks: Record<string, AskSpec> = {
63
+ boot: ownerAsk('a new being of this ward', { required: ['key', 'class'] }),
64
+ unboot: ownerAsk('a being out, with every relation she holds', { required: ['being'] }),
65
+ public: ownerAsk('the being a stranger reaches, or none', { required: ['key'] }),
66
+ invite: ownerAsk('an invitation on a being of this ward', { required: ['being', 'id'] }),
67
+ ask: ownerAsk('a being of this ward, asked as the owner; with no being, the public being asked as nobody'),
68
+ own: rootAsk('an invitation for an owner of this ward, under an id', { required: ['id'] }),
69
+ disown: rootAsk('an owner no more', { required: ['id'] }),
70
+ become: ownerAsk('this ward born again of the class of a kind, her cells and relations kept', { required: ['class'] }),
71
+ hold: ownerAsk('an owner invitation on a far being, held under a name from now on', { required: ['name', 'invitation'] }),
72
+ pilot: ownerAsk('the far being held under a name, asked as its owner', { required: ['name'] }),
73
+ drop: ownerAsk('the far being held under a name, let go', { required: ['name'] }),
74
+ };
75
+
76
+ readonly steward: Steward;
77
+
78
+ // A ward is born of her stance alone, and a ward's stance carries her
79
+ // steward.
80
+ constructor(stance: Stance) {
81
+ super(stance);
82
+ this.steward = (stance as WardStance).steward;
83
+ }
84
+
85
+ // Whether a class fulfils this contract: this class, or one below it.
86
+ static fulfils(C: unknown): C is BeingClass {
87
+ return typeof C === 'function' && C.prototype instanceof this;
88
+ }
89
+
90
+ become(args: JsonObject): JsonObject {
91
+ if (!text(args.class)) return { error: 'class is text' };
92
+ const refused = this.steward.become(args.class);
93
+ return refused === null ? { became: args.class } : { error: refused };
94
+ }
95
+
96
+ override describe(asker: Asker): Blueprint {
97
+ const { asks } = super.describe(asker);
98
+ return { asks, notes: pilots(asker, this.notes(asker)) ? { pk: this.steward.pk(), class: kindOf(this.constructor), beings: this.steward.beings() } : {} };
99
+ }
100
+
101
+ async own(args: JsonObject): Promise<JsonObject> {
102
+ if (!text(args.id)) return { error: 'id is text' };
103
+ return (await this.stance.occupants.invite(args.id, { owner: true })) ?? { error: 'id taken' };
104
+ }
105
+
106
+ disown(args: JsonObject): JsonObject {
107
+ if (!text(args.id) || this.stance.occupants.notes(args.id)?.owner !== true) return { error: 'no such owner' };
108
+ this.stance.occupants.remove(args.id);
109
+ return { disowned: args.id };
110
+ }
111
+
112
+ async boot(args: JsonObject): Promise<JsonObject> {
113
+ if (!text(args.key) || !text(args.class)) return { error: 'key and class are text' };
114
+ if (shipped(this.steward.classOf(args.class))) return { error: 'no such class' };
115
+ const out = await this.steward.boot(args.key, args.class);
116
+ return out === 'booted' ? { booted: args.key } : { error: out };
117
+ }
118
+
119
+ unboot(args: JsonObject): JsonObject | Promise<JsonObject> {
120
+ return text(args.being) && this.steward.unboot(args.being) ? { unbooted: args.being } : { error: 'no such being' };
121
+ }
122
+
123
+ public(args: JsonObject): JsonObject {
124
+ if (args.key !== null && !text(args.key)) return { error: 'key is text or null' };
125
+ return this.steward.publish(args.key) ? { public: args.key } : { error: 'no such being' };
126
+ }
127
+
128
+ async invite(args: JsonObject): Promise<JsonObject> {
129
+ if (!text(args.being) || !text(args.id) || (args.notes !== undefined && !object(args.notes))) return { error: 'being and id are text, notes an object' };
130
+ const invitation = await this.steward.invite(args.being, args.id, args.notes ?? {});
131
+ return invitation ?? { error: 'not invited' };
132
+ }
133
+
134
+ async ask(args: JsonObject): Promise<JsonObject> {
135
+ if ((args.being !== undefined && !text(args.being)) || (args.method !== undefined && !text(args.method)) || (args.args !== undefined && !object(args.args))) {
136
+ return { error: 'being and method are text, args an object' };
137
+ }
138
+ const out = await this.steward.ask(args.being ?? null, args.method, args.args ?? {});
139
+ if (isSilence(out)) return { error: 'silence' };
140
+ if (isWord(out)) return { error: told(out) as string };
141
+ return { answer: out };
142
+ }
143
+
144
+ async hold(args: JsonObject): Promise<JsonObject> {
145
+ if (!text(args.name)) return { error: 'name is text' };
146
+ const invitation = readInvitation(args.invitation);
147
+ if (invitation === null) return { error: 'no invitation' };
148
+ if (this.stance.standings.get(HELD + args.name)) return { error: `${args.name} is held` };
149
+ return (await this.stance.standings.take(HELD + args.name, invitation)) === null ? { error: 'not taken' } : { held: args.name, ward: invitation.ward };
150
+ }
151
+
152
+ async pilot(args: JsonObject): Promise<JsonObject> {
153
+ if (!text(args.name) || (args.method !== undefined && !text(args.method)) || (args.args !== undefined && !object(args.args))) return { error: 'name and method are text, args an object' };
154
+ const standing = this.stance.standings.get(HELD + args.name);
155
+ if (!standing) return { error: `${args.name} is not held` };
156
+ const out = await standing.ask(args.method, args.args ?? {});
157
+ if (isSilence(out)) return { error: 'silence' };
158
+ if (isWord(out)) return { error: told(out) as string };
159
+ return { answer: out };
160
+ }
161
+
162
+ drop(args: JsonObject): JsonObject {
163
+ if (!text(args.name)) return { error: 'name is text' };
164
+ return this.stance.standings.remove(HELD + args.name) ? { dropped: args.name } : { error: `${args.name} is not held` };
165
+ }
166
+ }
package/src/core.ts ADDED
@@ -0,0 +1,55 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // The core as a stranger's code reads it: every export of the kit that is
3
+ // no default. It names no platform, so it runs wherever JavaScript runs.
4
+ // `kit.ts` joins it with the defaults; the core's own suites bind it with
5
+ // classes written for them, so a module they load reads the core alone.
6
+
7
+ // Beings, faculties, and what they are told.
8
+ export { Being, canonical, digest, Faculty, isSilence, isWord, OWNER, silence, told, WARD, word } from './core/being/index.ts';
9
+ export type { Answer, Ask, Asker, AskSpec, BeingClass, BeingLike, Blueprint, Invitation, Json, JsonObject, Occupants, Reply, Schema, Silence, Stance, Standing, Standings, Wanted, Word, WordName } from './core/being/index.ts';
10
+ export { readInvitation } from './core/quo/index.ts';
11
+
12
+ // What a terrain gives a harbor.
13
+ export { Carrier, Clock, Custody, Entropy, Loader, Memory, type Bundled, type Module, type Rows } from './core/contract/index.ts';
14
+
15
+ // Wards and the ward.
16
+ export { CEILING, DEFAULT, DEPTH, ownerAsk, pilots, Ward, type Steward, type WardStance } from './core/ward/index.ts';
17
+
18
+ // The onion, and the one line its root's asks cross from any front.
19
+ export {
20
+ BOX,
21
+ CarrierFaculty,
22
+ Catalogue,
23
+ copyPackage,
24
+ Dock,
25
+ Harbor,
26
+ addGround,
27
+ groundOf,
28
+ grounds,
29
+ readRootRequest,
30
+ Registry,
31
+ REGISTRY,
32
+ RegistryFaculty,
33
+ MemoryFaculty,
34
+ MEMORY,
35
+ Terrain,
36
+ UNDIALED,
37
+ type Defaults,
38
+ type Dialed,
39
+ type Failures,
40
+ type Ground,
41
+ type GroundProbe,
42
+ type Probing,
43
+ type RootRequest,
44
+ type Sockets,
45
+ type TcpListening,
46
+ type WebListen,
47
+ type WebListener,
48
+ type WebServe,
49
+ } from './core/harbor/index.ts';
50
+
51
+ // The pointer dock: a whole world in one process, and the loaders of code.
52
+ export { BundleLoader, CryptoEntropy, HeldCustody, SourceLoader, NoCarrier, PointerCarrier, PointerTerrain, SystemClock, VolatileMemory, World, type PointerParts, type WorldParts } from './core/pointer/index.ts';
53
+ export { answerPost } from './core/line/answer.ts';
54
+ export { NEUTRAL } from './core/line/ground.ts';
55
+ export { WebDialer } from './core/line/index.ts';
@@ -0,0 +1,12 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // The default dock: the `Dock` contract as it stands, for an owner who
3
+ // writes no dock of her own.
4
+ import { ships } from '../../core/being/index.ts';
5
+ import { Dock } from '../../core/harbor/index.ts';
6
+
7
+ export class DefaultDock extends Dock {
8
+ static override readonly kind: string = 'org.nervur.default-dock';
9
+ static {
10
+ ships(this);
11
+ }
12
+ }
@@ -0,0 +1,10 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // The defaults: beings and faculties an owner gets where she writes none of
3
+ // her own, one folder each. Each extends a contract of the core, the core
4
+ // names none, and none names a platform: what a carrier needs of one, its
5
+ // terrain hands it.
6
+ export { DefaultDock } from './dock/index.ts';
7
+ export { GroundMemory } from './memory/index.ts';
8
+ export { TcpFaculty } from './tcp/index.ts';
9
+ export { DefaultWard } from './ward/index.ts';
10
+ export { WebFaculty } from './web/index.ts';
@@ -0,0 +1,50 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // The default memory faculty: places of the terrain's own memory under the
3
+ // faculty's key, so a memory faculty stands wherever a harbor does. Its
4
+ // places are the package's, behind the hex of the faculty's key, so two
5
+ // memory faculties and the root never meet in one place.
6
+ import { ships, type Stance } from '../../core/being/index.ts';
7
+ import type { Memory } from '../../core/contract/index.ts';
8
+ import { hex, utf8 } from '../../core/crypto/index.ts';
9
+ import { groundOf, MemoryFaculty } from '../../core/harbor/index.ts';
10
+
11
+ // A place of the package is thirty-two hex digits.
12
+ const PLACE = 32;
13
+
14
+ export class GroundMemory extends MemoryFaculty {
15
+ static override readonly kind: string = 'org.nervur.ground-memory';
16
+ static {
17
+ ships(this);
18
+ }
19
+
20
+ readonly #memory: Memory;
21
+
22
+ constructor(stance: Stance) {
23
+ super(stance);
24
+ this.#memory = groundOf(stance).terrain.memory;
25
+ }
26
+
27
+ get #prefix(): string {
28
+ return hex(utf8(this.stance.key));
29
+ }
30
+
31
+ override occupies(place: string): boolean {
32
+ return place.length === this.#prefix.length + PLACE && place.startsWith(this.#prefix);
33
+ }
34
+
35
+ read(place: string): Promise<Map<string, Uint8Array>> {
36
+ return this.#memory.read(this.#prefix + place);
37
+ }
38
+
39
+ write(place: string, entries: ReadonlyMap<string, Uint8Array | null>): Promise<void> {
40
+ return this.#memory.write(this.#prefix + place, entries);
41
+ }
42
+
43
+ async places(): Promise<string[]> {
44
+ return (await this.#memory.places()).filter((place) => this.occupies(place)).map((place) => place.slice(this.#prefix.length));
45
+ }
46
+
47
+ forget(place: string): Promise<void> {
48
+ return this.#memory.forget(this.#prefix + place);
49
+ }
50
+ }
@@ -0,0 +1,89 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Quo over TCP as a carrier faculty. It dials every `tcp://` address the
3
+ // harbor routes, and listens where its cells say, handing what it hears to
4
+ // its ground, on the sockets its terrain hands it:
5
+ //
6
+ // listen { host?, port? } listen there from now on, 127.0.0.1 and a
7
+ // free port unless named, and on every wake
8
+ // at the port it bound
9
+ // deaf listen nowhere from now on
10
+ import { ships, type AskSpec, type JsonObject, type Stance } from '../../core/being/index.ts';
11
+ import { CarrierFaculty, groundOf, type Dialed, type Sockets, type TcpListening } from '../../core/harbor/index.ts';
12
+ import { tcpAddress } from '../../core/quo/index.ts';
13
+ import { ownerAsk } from '../../core/ward/index.ts';
14
+
15
+ type Listen = { host: string; port: number };
16
+ const listenOf = (value: unknown): Listen | null => {
17
+ if (typeof value !== 'object' || value === null) return null;
18
+ const { host, port } = value as Record<string, unknown>;
19
+ return typeof host === 'string' && Number.isInteger(port) && (port as number) >= 0 && (port as number) <= 65_535 ? { host, port: port as number } : null;
20
+ };
21
+
22
+ export class TcpFaculty extends CarrierFaculty {
23
+ static override readonly kind: string = 'org.nervur.tcp';
24
+ static override readonly carries: string = 'tcp';
25
+ static {
26
+ ships(this);
27
+ }
28
+ static override asks: Record<string, AskSpec> = {
29
+ listen: ownerAsk('listen for Quo over TCP, and on every wake', { properties: { host: { type: 'string' }, port: { type: 'integer' } } }),
30
+ deaf: ownerAsk('listen nowhere'),
31
+ };
32
+
33
+ readonly #sockets: Sockets;
34
+ #listener: TcpListening | undefined;
35
+
36
+ // A ground with no sockets speaks no TCP, and no TCP faculty stands on it.
37
+ constructor(stance: Stance) {
38
+ super(stance);
39
+ const sockets = groundOf(stance).terrain.tcp;
40
+ if (!sockets) throw new Error('this ground speaks no TCP');
41
+ this.#sockets = sockets();
42
+ }
43
+
44
+ accepts(address: string): boolean {
45
+ return tcpAddress(address) !== null;
46
+ }
47
+
48
+ dial(address: string, pk: string, bytes: Uint8Array): Promise<Dialed> {
49
+ return this.#sockets.dial(address, pk, bytes);
50
+ }
51
+
52
+ override listening(): string[] {
53
+ return this.#listener ? [this.#listener.at] : [];
54
+ }
55
+
56
+ override async awake(): Promise<void> {
57
+ const at = listenOf(this.cells.listen);
58
+ if (at && !this.#listener) this.#listener = await this.#sockets.listen(groundOf(this.stance), at.host, at.port);
59
+ }
60
+
61
+ override async sleep(): Promise<void> {
62
+ await this.#sockets.close();
63
+ await this.#listener?.close();
64
+ this.#listener = undefined;
65
+ }
66
+
67
+ async listen(args: JsonObject): Promise<JsonObject> {
68
+ const at = listenOf({ host: args.host ?? '127.0.0.1', port: args.port ?? 0 });
69
+ if (at === null) return { error: 'host is text and port a port' };
70
+ await this.#listener?.close();
71
+ this.#listener = undefined;
72
+ try {
73
+ this.#listener = await this.#sockets.listen(groundOf(this.stance), at.host, at.port);
74
+ } catch (e) {
75
+ return { error: (e as Error).message };
76
+ }
77
+ // The port it bound, so a wake listens where every route and every
78
+ // invitation already points.
79
+ this.cells.listen = { host: at.host, port: tcpAddress(this.#listener.at)!.port };
80
+ return { at: this.#listener.at };
81
+ }
82
+
83
+ async deaf(): Promise<JsonObject> {
84
+ await this.#listener?.close();
85
+ this.#listener = undefined;
86
+ delete this.cells.listen;
87
+ return { deaf: true };
88
+ }
89
+ }
@@ -0,0 +1,12 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // The default ward: the `Ward` contract as it stands, for a hosted ward
3
+ // whose owner names no class of her own.
4
+ import { ships } from '../../core/being/index.ts';
5
+ import { Ward } from '../../core/ward/index.ts';
6
+
7
+ export class DefaultWard extends Ward {
8
+ static override readonly kind: string = 'org.nervur.default-ward';
9
+ static {
10
+ ships(this);
11
+ }
12
+ }
@@ -0,0 +1,97 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Quo over the web as a carrier faculty. It dials every `http`, `https`,
3
+ // `ws` and `wss` address the harbor routes, on fetch and the WebSocket
4
+ // client, and listens where its cells say through the listener its
5
+ // terrain runs, where the terrain runs one:
6
+ //
7
+ // listen { host?, port?, path?, origins? }
8
+ // listen there from now on, 127.0.0.1, a free port, `/`
9
+ // and every origin unless named, and on every wake at the
10
+ // port it bound
11
+ // deaf listen nowhere from now on
12
+ import { ships, type AskSpec, type JsonObject } from '../../core/being/index.ts';
13
+ import { CarrierFaculty, groundOf, type Dialed, type Ground, type WebListen, type WebListener } from '../../core/harbor/index.ts';
14
+ import { WebDialer } from '../../core/line/index.ts';
15
+ import { webAddress } from '../../core/quo/index.ts';
16
+ import { ownerAsk } from '../../core/ward/index.ts';
17
+
18
+ const listenOf = (value: unknown): WebListen | null => {
19
+ if (typeof value !== 'object' || value === null) return null;
20
+ const { host, port, path, origins } = value as Record<string, unknown>;
21
+ const fine =
22
+ typeof host === 'string' &&
23
+ Number.isInteger(port) &&
24
+ (port as number) >= 0 &&
25
+ (port as number) <= 65_535 &&
26
+ typeof path === 'string' &&
27
+ path.startsWith('/') &&
28
+ Array.isArray(origins) &&
29
+ origins.every((o) => typeof o === 'string');
30
+ return fine ? { host, port: port as number, path, origins: origins as string[] } : null;
31
+ };
32
+
33
+ export class WebFaculty extends CarrierFaculty {
34
+ static override readonly kind: string = 'org.nervur.web';
35
+ static override readonly carries: string = 'web';
36
+ static {
37
+ ships(this);
38
+ }
39
+ static override asks: Record<string, AskSpec> = {
40
+ listen: ownerAsk('listen for Quo over the web, and on every wake'),
41
+ deaf: ownerAsk('listen nowhere'),
42
+ };
43
+
44
+ readonly #dialer = new WebDialer();
45
+ #listener: WebListener | undefined;
46
+
47
+ get #ground(): Ground {
48
+ return groundOf(this.stance);
49
+ }
50
+
51
+ accepts(address: string): boolean {
52
+ return webAddress(address) !== null;
53
+ }
54
+
55
+ dial(address: string, pk: string, bytes: Uint8Array): Promise<Dialed> {
56
+ return this.#dialer.dial(address, pk, bytes);
57
+ }
58
+
59
+ override listening(): string[] {
60
+ return this.#listener ? [...this.#listener.at] : [];
61
+ }
62
+
63
+ override async awake(): Promise<void> {
64
+ const at = listenOf(this.cells.listen);
65
+ const serve = this.#ground.terrain.web;
66
+ if (at && serve && !this.#listener) this.#listener = await serve(this.#ground, at);
67
+ }
68
+
69
+ override async sleep(): Promise<void> {
70
+ await this.#dialer.close();
71
+ await this.#listener?.close();
72
+ this.#listener = undefined;
73
+ }
74
+
75
+ async listen(args: JsonObject): Promise<JsonObject> {
76
+ const serve = this.#ground.terrain.web;
77
+ if (!serve) return { error: 'this ground listens nowhere on the web' };
78
+ const at = listenOf({ host: args.host ?? '127.0.0.1', port: args.port ?? 0, path: args.path ?? '/', origins: args.origins ?? ['*'] });
79
+ if (at === null) return { error: 'host is text, port a port, path a path and origins a list' };
80
+ await this.#listener?.close();
81
+ this.#listener = undefined;
82
+ try {
83
+ this.#listener = await serve(this.#ground, at);
84
+ } catch (e) {
85
+ return { error: (e as Error).message };
86
+ }
87
+ this.cells.listen = { ...at, port: this.#listener.port };
88
+ return { at: [...this.#listener.at] };
89
+ }
90
+
91
+ async deaf(): Promise<JsonObject> {
92
+ await this.#listener?.close();
93
+ this.#listener = undefined;
94
+ delete this.cells.listen;
95
+ return { deaf: true };
96
+ }
97
+ }
package/src/edge.ts CHANGED
@@ -2,9 +2,10 @@
2
2
  // `nervur` as a Workers bundle reads it: the main entry, with the edge
3
3
  // ground added, so `Harbor.open({ given: { state, env } })` in a Durable
4
4
  // Object keeps a harbor in its storage.
5
- import { edgeGround } from './edge/index.ts';
6
- import { addGround } from './harbor/index.ts';
5
+ import { edgeGround } from './core/edge/index.ts';
6
+ import { addGround } from './core/harbor/index.ts';
7
+ import { DEFAULTS } from './index.ts';
7
8
 
8
9
  export * from './index.ts';
9
10
 
10
- addGround(edgeGround);
11
+ addGround(edgeGround, DEFAULTS);
package/src/index.ts CHANGED
@@ -1,55 +1,18 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- // `nervur`: what a stranger writes a world with. It imports no platform, so
3
- // it runs wherever JavaScript runs. A disk is `nervur/folder`. Node reads
4
- // `node.ts` under this name instead, which adds the Node ground.
5
- import { addGround } from './harbor/index.ts';
6
- import { neutralGround } from './line/index.ts';
2
+ // `nervur`: what a stranger writes a world with, the kit of `kit.ts`. It
3
+ // imports no platform, so it runs wherever JavaScript runs. A disk is
4
+ // `nervur/folder`. Node reads `node.ts` under this name instead, which
5
+ // adds the Node ground. It binds the kit, so wherever a ground stands, a
6
+ // module's `'nervur'` is this copy's.
7
+ import { bindKit } from './core/contract/index.ts';
8
+ import { addGround } from './core/harbor/index.ts';
9
+ import { neutralGround } from './core/line/index.ts';
10
+ import * as kit from './kit.ts';
11
+ import { DEFAULTS } from './kit.ts';
7
12
 
8
- // Beings, faculties, and what they are told.
9
- export { Being, canonical, digest, Faculty, isSilence, isWord, OWNER, silence, told, WARD, word } from './being/index.ts';
10
- export type { Answer, Ask, Asker, AskSpec, BeingClass, BeingLike, Blueprint, Invitation, Json, JsonObject, Occupants, Reply, Schema, Silence, Stance, Standing, Standings, Wanted, Word, WordName } from './being/index.ts';
11
- export { readInvitation } from './quo/index.ts';
13
+ export * from './kit.ts';
12
14
 
13
- // What a terrain gives a harbor.
14
- export { Carrier, Clock, Custody, Entropy, Loader, Memory, type Loaded, type Module, type Rows } from './contract/index.ts';
15
-
16
- // Wards and the ward-being.
17
- export { CEILING, DEFAULT, DEPTH, ownerAsk, Pilot, pilots, WardBeing, type Steward, type WardBeingStance } from './ward/index.ts';
18
-
19
- // The onion, and the one line its root's asks cross from any front.
20
- export {
21
- BOX,
22
- CarrierFaculty,
23
- Catalogue,
24
- copyPackage,
25
- Dock,
26
- Harbor,
27
- addGround,
28
- grounds,
29
- readRootRequest,
30
- Registry,
31
- Push,
32
- PUSH,
33
- RELAY,
34
- RELAY_CLIENT,
35
- rootLine,
36
- Store,
37
- STORE,
38
- Terrain,
39
- UNDIALED,
40
- type Dialed,
41
- type Failures,
42
- type Ground,
43
- type GroundFaculty,
44
- type GroundProbe,
45
- type Opening,
46
- type Probing,
47
- type RootRequest,
48
- } from './harbor/index.ts';
49
-
50
- // The pointer dock: a whole world in one process.
51
- export { CryptoEntropy, HeldCustody, HeldLoader, NoCarrier, PointerCarrier, PointerTerrain, SystemClock, VolatileMemory, World, type PointerParts } from './pointer/index.ts';
52
- export { answerPost, NEUTRAL, WEB, WEB_OPENING, WEB_PUSH, WebDialer, webFaculty, webPush, type WebListen, type WebListener, type WebServe } from './line/index.ts';
15
+ bindKit(kit);
53
16
 
54
17
  // The ground that fits everywhere, tried after any a platform entry adds.
55
- addGround(neutralGround);
18
+ addGround(neutralGround, DEFAULTS);
package/src/kit.ts ADDED
@@ -0,0 +1,15 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // The kit a stranger writes a world with, and what a module's `'nervur'`
3
+ // reads: the core of `core.ts` and the defaults joined. It names no
4
+ // platform, so it runs wherever JavaScript runs. The main entry binds it as
5
+ // the kit a loader links a module against, so every ground and the command
6
+ // bind it.
7
+ import { DefaultDock, DefaultWard, GroundMemory, TcpFaculty, WebFaculty } from './defaults/index.ts';
8
+ import type { Defaults } from './core/harbor/index.ts';
9
+
10
+ export * from './core.ts';
11
+
12
+ // The defaults: the beings and faculties a harbor runs where its owner
13
+ // writes none, and the list every ground runs them from.
14
+ export { DefaultDock, DefaultWard, GroundMemory, TcpFaculty, WebFaculty } from './defaults/index.ts';
15
+ export const DEFAULTS: Defaults = { dock: DefaultDock, ward: DefaultWard, classes: [GroundMemory, TcpFaculty, WebFaculty] };
package/src/node.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  // `nervur` as Node reads it: the main entry, with the Node ground added, so
3
3
  // `Harbor.open()` keeps a harbor in a folder and serves its root line.
4
- import { addGround } from './harbor/index.ts';
5
- import { nodeGround } from './node/index.ts';
4
+ import { addGround } from './core/harbor/index.ts';
5
+ import { nodeGround } from './core/node/index.ts';
6
+ import { DEFAULTS } from './index.ts';
6
7
 
7
8
  export * from './index.ts';
8
9
 
9
- addGround(nodeGround);
10
+ addGround(nodeGround, DEFAULTS);
@@ -1,16 +0,0 @@
1
- import type { JsonObject } from '../being/index.ts';
2
- import { Harbor, type Carried, type RootRequest } from '../harbor/index.ts';
3
- export declare const open: (dir: string) => Promise<Harbor>;
4
- export declare const isServed: (dir: string) => Promise<boolean>;
5
- export declare const request: (dir: string, req: RootRequest) => Promise<JsonObject>;
6
- export declare const carry: (dir: string, seed: boolean) => Promise<Carried>;
7
- export declare const pack: (dir: string, file: string, name: string, secret: string | undefined) => Promise<JsonObject>;
8
- export declare const land: (dir: string, value: unknown) => Promise<string[]>;
9
- export type Served = {
10
- pk: string;
11
- at: string;
12
- listening: string[];
13
- root: string;
14
- close(): Promise<void>;
15
- };
16
- export declare const serve: (dir: string, host?: string, port?: number) => Promise<Served>;