@nervur.org/installer-node 0.0.0-stage → 0.37.1

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 (362) hide show
  1. package/LICENSE +105 -0
  2. package/README.md +158 -2
  3. package/SECURITY.md +8 -0
  4. package/bin/nervur.js +5 -0
  5. package/cargo/emscripten-module.wasm +0 -0
  6. package/cargo/manifest.json +1 -0
  7. package/cargo/sqlite3.wasm +0 -0
  8. package/cargo/table-i-i.wasm +0 -0
  9. package/cargo/table-i-ii.wasm +0 -0
  10. package/cargo/table-i-iii.wasm +0 -0
  11. package/cargo/table-i-iiii.wasm +0 -0
  12. package/cargo/table-i-iiiii.wasm +0 -0
  13. package/cargo/table-i-iiij.wasm +0 -0
  14. package/cargo/table-i-ij.wasm +0 -0
  15. package/cargo/table-v-ii.wasm +0 -0
  16. package/cargo/table-v-iii.wasm +0 -0
  17. package/cargo/worker.js +30756 -0
  18. package/organs/console/node/guard.d.ts +10 -0
  19. package/organs/console/node/guard.js +52 -0
  20. package/organs/console/node/index.d.ts +4 -0
  21. package/organs/console/node/index.js +5 -0
  22. package/organs/console/node/line.d.ts +16 -0
  23. package/organs/console/node/line.js +150 -0
  24. package/organs/console/node/main.js +51 -0
  25. package/organs/console/node/program.d.ts +1 -0
  26. package/organs/console/node/program.js +5 -0
  27. package/organs/console/node/proof.d.ts +15 -0
  28. package/organs/console/node/proof.js +84 -0
  29. package/organs/console/node/socket.d.ts +15 -0
  30. package/organs/console/node/socket.js +99 -0
  31. package/organs/disk/index.d.ts +1 -0
  32. package/organs/disk/index.js +2 -0
  33. package/organs/disk/node/files.js +162 -0
  34. package/organs/disk/node/main.js +20 -0
  35. package/organs/disk/node/program.d.ts +1 -0
  36. package/organs/disk/node/program.js +5 -0
  37. package/organs/disk/organ.d.ts +5 -0
  38. package/organs/disk/organ.js +69 -0
  39. package/organs/network/node/fill.d.ts +21 -0
  40. package/organs/network/node/fill.js +195 -0
  41. package/organs/network/node/flows.js +66 -0
  42. package/organs/network/node/half.js +260 -0
  43. package/organs/network/node/lines.d.ts +29 -0
  44. package/organs/network/node/lines.js +236 -0
  45. package/organs/network/node/link.d.ts +24 -0
  46. package/organs/network/node/link.js +215 -0
  47. package/organs/network/node/main.js +41 -0
  48. package/organs/network/node/moved.d.ts +2 -0
  49. package/organs/network/node/moved.js +20 -0
  50. package/organs/network/node/near.d.ts +63 -0
  51. package/organs/network/node/near.js +263 -0
  52. package/organs/network/node/program.d.ts +1 -0
  53. package/organs/network/node/program.js +5 -0
  54. package/organs/network/node/schemes.d.ts +1 -0
  55. package/organs/network/node/schemes.js +2 -0
  56. package/organs/network/node/sent.d.ts +13 -0
  57. package/organs/network/node/sent.js +101 -0
  58. package/organs/network/node/served.d.ts +19 -0
  59. package/organs/network/node/served.js +237 -0
  60. package/organs/screen/node/client.js +3 -0
  61. package/organs/screen/node/follow.js +266 -0
  62. package/organs/screen/node/frames.js +26 -0
  63. package/organs/screen/node/held.js +27 -0
  64. package/organs/screen/node/http.js +179 -0
  65. package/organs/screen/node/lay.js +116 -0
  66. package/organs/screen/node/leave.js +27 -0
  67. package/organs/screen/node/linked.js +69 -0
  68. package/organs/screen/node/listen.js +61 -0
  69. package/organs/screen/node/look.js +121 -0
  70. package/organs/screen/node/loop.js +154 -0
  71. package/organs/screen/node/main.js +74 -0
  72. package/organs/screen/node/mirror.js +112 -0
  73. package/organs/screen/node/notice.js +44 -0
  74. package/organs/screen/node/presser.js +11 -0
  75. package/organs/screen/node/presses.js +108 -0
  76. package/organs/screen/node/program.d.ts +1 -0
  77. package/organs/screen/node/program.js +5 -0
  78. package/organs/screen/node/shown.js +205 -0
  79. package/organs/screen/node/standing.js +29 -0
  80. package/organs/screen/node/state.js +80 -0
  81. package/organs/screen/node/tell.js +47 -0
  82. package/organs/screen/node/uid.js +65 -0
  83. package/organs/screen/node/worn.js +23 -0
  84. package/organs/shell/index.d.ts +1 -0
  85. package/organs/shell/index.js +2 -0
  86. package/organs/shell/node/main.js +26 -0
  87. package/organs/shell/node/output.js +70 -0
  88. package/organs/shell/node/pressure.js +14 -0
  89. package/organs/shell/node/program.d.ts +1 -0
  90. package/organs/shell/node/program.js +5 -0
  91. package/organs/shell/node/runs.js +220 -0
  92. package/organs/shell/node/told.js +70 -0
  93. package/organs/shell/organ.d.ts +5 -0
  94. package/organs/shell/organ.js +59 -0
  95. package/package.json +43 -4
  96. package/src/command/act.d.ts +31 -0
  97. package/src/command/act.js +256 -0
  98. package/src/command/answers.d.ts +3 -0
  99. package/src/command/answers.js +232 -0
  100. package/src/command/args.d.ts +14 -0
  101. package/src/command/args.js +220 -0
  102. package/src/command/arrive.d.ts +2 -0
  103. package/src/command/arrive.js +21 -0
  104. package/src/command/asked.d.ts +18 -0
  105. package/src/command/asked.js +49 -0
  106. package/src/command/backup.d.ts +18 -0
  107. package/src/command/backup.js +261 -0
  108. package/src/command/before.d.ts +41 -0
  109. package/src/command/before.js +237 -0
  110. package/src/command/born.d.ts +27 -0
  111. package/src/command/born.js +103 -0
  112. package/src/command/bridge.d.ts +19 -0
  113. package/src/command/bridge.js +152 -0
  114. package/src/command/chain.d.ts +9 -0
  115. package/src/command/chain.js +48 -0
  116. package/src/command/channel.d.ts +29 -0
  117. package/src/command/channel.js +263 -0
  118. package/src/command/choices.d.ts +35 -0
  119. package/src/command/choices.js +173 -0
  120. package/src/command/claim.d.ts +12 -0
  121. package/src/command/claim.js +46 -0
  122. package/src/command/commands.d.ts +16 -0
  123. package/src/command/commands.js +257 -0
  124. package/src/command/ends.d.ts +16 -0
  125. package/src/command/ends.js +78 -0
  126. package/src/command/follow.d.ts +12 -0
  127. package/src/command/follow.js +66 -0
  128. package/src/command/given.d.ts +39 -0
  129. package/src/command/given.js +53 -0
  130. package/src/command/held.d.ts +15 -0
  131. package/src/command/held.js +56 -0
  132. package/src/command/index.d.ts +1 -0
  133. package/src/command/index.js +203 -0
  134. package/src/command/jailer.d.ts +28 -0
  135. package/src/command/jailer.js +135 -0
  136. package/src/command/laid.d.ts +6 -0
  137. package/src/command/laid.js +31 -0
  138. package/src/command/left.d.ts +9 -0
  139. package/src/command/left.js +34 -0
  140. package/src/command/line.d.ts +7 -0
  141. package/src/command/line.js +39 -0
  142. package/src/command/link.d.ts +30 -0
  143. package/src/command/link.js +123 -0
  144. package/src/command/lobes.d.ts +1 -0
  145. package/src/command/lobes.js +10 -0
  146. package/src/command/locks.d.ts +17 -0
  147. package/src/command/locks.js +76 -0
  148. package/src/command/mcp/calls.d.ts +27 -0
  149. package/src/command/mcp/calls.js +155 -0
  150. package/src/command/mcp/notices.d.ts +22 -0
  151. package/src/command/mcp/notices.js +203 -0
  152. package/src/command/mcp/resources.d.ts +31 -0
  153. package/src/command/mcp/resources.js +108 -0
  154. package/src/command/mcp/server.d.ts +19 -0
  155. package/src/command/mcp/server.js +149 -0
  156. package/src/command/mcp/tools.d.ts +39 -0
  157. package/src/command/mcp/tools.js +131 -0
  158. package/src/command/mcp.d.ts +8 -0
  159. package/src/command/mcp.js +39 -0
  160. package/src/command/noticed.d.ts +11 -0
  161. package/src/command/noticed.js +55 -0
  162. package/src/command/older.d.ts +11 -0
  163. package/src/command/older.js +45 -0
  164. package/src/command/open.d.ts +24 -0
  165. package/src/command/open.js +107 -0
  166. package/src/command/passphrase.d.ts +6 -0
  167. package/src/command/passphrase.js +82 -0
  168. package/src/command/reclaim.d.ts +7 -0
  169. package/src/command/reclaim.js +47 -0
  170. package/src/command/refused.d.ts +4 -0
  171. package/src/command/refused.js +27 -0
  172. package/src/command/release.d.ts +27 -0
  173. package/src/command/release.js +153 -0
  174. package/src/command/repo.d.ts +31 -0
  175. package/src/command/repo.js +133 -0
  176. package/src/command/rewrap.d.ts +16 -0
  177. package/src/command/rewrap.js +175 -0
  178. package/src/command/runtime.d.ts +25 -0
  179. package/src/command/runtime.js +175 -0
  180. package/src/command/salvage.d.ts +4 -0
  181. package/src/command/salvage.js +42 -0
  182. package/src/command/screen.d.ts +14 -0
  183. package/src/command/screen.js +62 -0
  184. package/src/command/spawn.d.ts +23 -0
  185. package/src/command/spawn.js +213 -0
  186. package/src/command/start.d.ts +34 -0
  187. package/src/command/start.js +246 -0
  188. package/src/command/state.d.ts +5 -0
  189. package/src/command/state.js +39 -0
  190. package/src/command/token.d.ts +1 -0
  191. package/src/command/token.js +9 -0
  192. package/src/command/trial.d.ts +17 -0
  193. package/src/command/trial.js +92 -0
  194. package/src/command/vouch.d.ts +1 -0
  195. package/src/command/vouch.js +15 -0
  196. package/src/command/windows-processes.d.ts +2 -0
  197. package/src/command/windows-processes.js +22 -0
  198. package/src/command/wipe.d.ts +9 -0
  199. package/src/command/wipe.js +105 -0
  200. package/src/command/words.d.ts +5 -0
  201. package/src/command/words.js +53 -0
  202. package/src/door/claim.d.ts +5 -0
  203. package/src/door/claim.js +21 -0
  204. package/src/door/claimed.d.ts +7 -0
  205. package/src/door/claimed.js +110 -0
  206. package/src/door/configuration.d.ts +40 -0
  207. package/src/door/configuration.js +206 -0
  208. package/src/door/design.d.ts +13 -0
  209. package/src/door/design.js +71 -0
  210. package/src/door/digests.d.ts +7 -0
  211. package/src/door/digests.js +36 -0
  212. package/src/door/distribution.d.ts +25 -0
  213. package/src/door/distribution.js +88 -0
  214. package/src/door/door.d.ts +41 -0
  215. package/src/door/door.js +219 -0
  216. package/src/door/dressed.d.ts +34 -0
  217. package/src/door/dressed.js +182 -0
  218. package/src/door/faculties.d.ts +29 -0
  219. package/src/door/faculties.js +88 -0
  220. package/src/door/longest.d.ts +6 -0
  221. package/src/door/longest.js +25 -0
  222. package/src/fills/account-only.d.ts +3 -0
  223. package/src/fills/account-only.js +24 -0
  224. package/src/fills/boot-key.d.ts +21 -0
  225. package/src/fills/boot-key.js +70 -0
  226. package/src/fills/boot-move.d.ts +25 -0
  227. package/src/fills/boot-move.js +86 -0
  228. package/src/fills/bridge.d.ts +13 -0
  229. package/src/fills/bridge.js +86 -0
  230. package/src/fills/chance.d.ts +2 -0
  231. package/src/fills/chance.js +7 -0
  232. package/src/fills/crypto.d.ts +2 -0
  233. package/src/fills/crypto.js +94 -0
  234. package/src/fills/flushed.d.ts +9 -0
  235. package/src/fills/flushed.js +80 -0
  236. package/src/fills/hardware.d.ts +18 -0
  237. package/src/fills/hardware.js +70 -0
  238. package/src/fills/held.d.ts +31 -0
  239. package/src/fills/held.js +171 -0
  240. package/src/fills/keepers.d.ts +23 -0
  241. package/src/fills/keepers.js +151 -0
  242. package/src/fills/keyring.d.ts +19 -0
  243. package/src/fills/keyring.js +131 -0
  244. package/src/fills/pages.d.ts +3 -0
  245. package/src/fills/pages.js +260 -0
  246. package/src/fills/reserve.d.ts +11 -0
  247. package/src/fills/reserve.js +72 -0
  248. package/src/fills/time.d.ts +2 -0
  249. package/src/fills/time.js +29 -0
  250. package/src/fills/unlocker.d.ts +6 -0
  251. package/src/fills/unlocker.js +26 -0
  252. package/src/fills/vitals.d.ts +8 -0
  253. package/src/fills/vitals.js +100 -0
  254. package/src/fills/windows-start.d.ts +2 -0
  255. package/src/fills/windows-start.js +21 -0
  256. package/src/halves/build.d.ts +10 -0
  257. package/src/halves/build.js +219 -0
  258. package/src/halves/end.d.ts +17 -0
  259. package/src/halves/end.js +157 -0
  260. package/src/halves/genome.d.ts +3 -0
  261. package/src/halves/genome.js +21 -0
  262. package/src/halves/handler.d.ts +8 -0
  263. package/src/halves/handler.js +40 -0
  264. package/src/halves/index.d.ts +5 -0
  265. package/src/halves/index.js +6 -0
  266. package/src/halves/laid.d.ts +12 -0
  267. package/src/halves/laid.js +103 -0
  268. package/src/halves/lent.d.ts +6 -0
  269. package/src/halves/lent.js +147 -0
  270. package/src/halves/native.d.ts +12 -0
  271. package/src/halves/native.js +53 -0
  272. package/src/halves/statements.d.ts +23 -0
  273. package/src/halves/statements.js +165 -0
  274. package/src/halves/tokens.d.ts +22 -0
  275. package/src/halves/tokens.js +135 -0
  276. package/src/link/link.d.ts +4 -0
  277. package/src/link/link.js +4 -0
  278. package/src/link/placeholder.d.ts +1 -0
  279. package/src/link/placeholder.js +21 -0
  280. package/src/link/steps.d.ts +52 -0
  281. package/src/link/steps.js +118 -0
  282. package/src/lobes/calls.d.ts +76 -0
  283. package/src/lobes/calls.js +61 -0
  284. package/src/lobes/channel.d.ts +76 -0
  285. package/src/lobes/channel.js +202 -0
  286. package/src/lobes/index.d.ts +1 -0
  287. package/src/lobes/index.js +2 -0
  288. package/src/lobes/lobes.d.ts +15 -0
  289. package/src/lobes/lobes.js +244 -0
  290. package/src/lobes/main.js +107 -0
  291. package/src/lobes/thread.d.ts +22 -0
  292. package/src/lobes/thread.js +270 -0
  293. package/src/organism/act.d.ts +8 -0
  294. package/src/organism/act.js +63 -0
  295. package/src/organism/beat.d.ts +5 -0
  296. package/src/organism/beat.js +45 -0
  297. package/src/organism/compiled.d.ts +2 -0
  298. package/src/organism/compiled.js +24 -0
  299. package/src/organism/folder.d.ts +88 -0
  300. package/src/organism/folder.js +259 -0
  301. package/src/organism/main.d.ts +1 -0
  302. package/src/organism/main.js +11 -0
  303. package/src/organism/organism.d.ts +1 -0
  304. package/src/organism/organism.js +219 -0
  305. package/src/organism/said.d.ts +12 -0
  306. package/src/organism/said.js +30 -0
  307. package/src/organism/told.d.ts +5 -0
  308. package/src/organism/told.js +110 -0
  309. package/src/organism/unlock.d.ts +8 -0
  310. package/src/organism/unlock.js +95 -0
  311. package/src/organism/upgrade.d.ts +24 -0
  312. package/src/organism/upgrade.js +145 -0
  313. package/src/organism/via.d.ts +7 -0
  314. package/src/organism/via.js +20 -0
  315. package/src/service/body.d.ts +8 -0
  316. package/src/service/body.js +34 -0
  317. package/src/service/handler.d.ts +20 -0
  318. package/src/service/handler.js +128 -0
  319. package/src/service/index.d.ts +4 -0
  320. package/src/service/index.js +16 -0
  321. package/src/service/manager.d.ts +18 -0
  322. package/src/service/manager.js +185 -0
  323. package/src/service/service.d.ts +24 -0
  324. package/src/service/service.js +200 -0
  325. package/src/service/swap.d.ts +12 -0
  326. package/src/service/swap.js +74 -0
  327. package/src/service/watchdog.d.ts +6 -0
  328. package/src/service/watchdog.js +31 -0
  329. package/src/tcp/crowd.d.ts +18 -0
  330. package/src/tcp/crowd.js +85 -0
  331. package/src/tcp/dial.d.ts +23 -0
  332. package/src/tcp/dial.js +102 -0
  333. package/src/tcp/frame.d.ts +23 -0
  334. package/src/tcp/frame.js +159 -0
  335. package/src/tcp/listen.d.ts +50 -0
  336. package/src/tcp/listen.js +207 -0
  337. package/src/tcp/source.d.ts +2 -0
  338. package/src/tcp/source.js +26 -0
  339. package/src/version/index.d.ts +1 -0
  340. package/src/version/index.js +2 -0
  341. package/src/version/version.d.ts +1 -0
  342. package/src/version/version.js +2 -0
  343. package/src/work/first.d.ts +11 -0
  344. package/src/work/first.js +91 -0
  345. package/src/work/index.d.ts +2 -0
  346. package/src/work/index.js +15 -0
  347. package/src/work/work.d.ts +20 -0
  348. package/src/work/work.js +136 -0
  349. package/src/ws/dial.d.ts +7 -0
  350. package/src/ws/dial.js +252 -0
  351. package/src/ws/dialing.d.ts +50 -0
  352. package/src/ws/dialing.js +72 -0
  353. package/src/ws/frame.d.ts +32 -0
  354. package/src/ws/frame.js +124 -0
  355. package/src/ws/handshake.d.ts +4 -0
  356. package/src/ws/handshake.js +27 -0
  357. package/src/ws/line.d.ts +45 -0
  358. package/src/ws/line.js +250 -0
  359. package/src/ws/listen.d.ts +42 -0
  360. package/src/ws/listen.js +272 -0
  361. package/src/ws/rfc6455.d.ts +18 -0
  362. package/src/ws/rfc6455.js +187 -0
@@ -0,0 +1,71 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { createHash } from 'node:crypto';
3
+ import { readFileSync } from 'node:fs';
4
+ import { dirname, relative, resolve } from 'node:path';
5
+
6
+ import { hex, readText, unhex, } from '@nervur.org/genome/standard';
7
+ import { dressed, SAID, } from './dressed.js';
8
+
9
+
10
+
11
+ const bytesAt = (path ) => {
12
+ try {
13
+ return new Uint8Array(readFileSync(path));
14
+ } catch {
15
+ return null;
16
+ }
17
+ };
18
+
19
+ const ownOf = (file ) => {
20
+ const folder = dirname(resolve(file));
21
+ return {
22
+ get: (path) => {
23
+ if (path === SAID) return Promise.resolve(bytesAt(resolve(file)));
24
+ const at = resolve(folder, path);
25
+ return Promise.resolve(relative(folder, at).startsWith('..') ? null : bytesAt(at));
26
+ },
27
+ sha256: (bytes) => Promise.resolve(createHash('sha256').update(bytes).digest('hex')),
28
+ domain: '',
29
+ kept: { find: () => Promise.resolve(null), keep: () => Promise.resolve(), only: () => Promise.resolve() },
30
+ };
31
+ };
32
+
33
+ export const designIn = async (file ) => {
34
+ const { design, warnings, size } = await dressed(ownOf(file));
35
+ if (warnings.length > 0) return { why: `--design ${file}: ${warnings.join(' ')}` };
36
+ return design === undefined && size === null
37
+ ? {
38
+ why: `--design ${file} names no design and no size: its organism.design holds a name, a version, a data digest and a look, its size compact, medium or expanded`,
39
+ }
40
+ : {
41
+ ...(design === undefined ? {} : { design }),
42
+ ...(size === null ? {} : { size }),
43
+ };
44
+ };
45
+
46
+ export const designData = ({ faculty, assets = [], settings } ) => ({
47
+ faculty,
48
+ assets: assets.map(([path, content]) => [
49
+ path,
50
+ hex(typeof content === 'string' ? new TextEncoder().encode(content) : content),
51
+ ]),
52
+ ...(settings === undefined ? {} : { settings }),
53
+ });
54
+
55
+ const fieldsOf = (value ) =>
56
+ typeof value === 'object' && value !== null && !Array.isArray(value);
57
+
58
+ export const designOf = (value ) => {
59
+ if (!fieldsOf(value) || typeof value['faculty'] !== 'string') return null;
60
+ const listed = value['assets'];
61
+ if (!Array.isArray(listed)) return null;
62
+ const assets = [];
63
+ for (const one of listed) {
64
+ const bytes = Array.isArray(one) && typeof one[1] === 'string' ? unhex(one[1]) : null;
65
+ if (!Array.isArray(one) || typeof one[0] !== 'string' || bytes === null || 'why' in bytes) return null;
66
+ assets.push([one[0], bytes.bytes]);
67
+ }
68
+ if (value['settings'] === undefined) return { faculty: value['faculty'], assets };
69
+ const settings = readText(JSON.stringify(value['settings']));
70
+ return 'data' in settings ? { faculty: value['faculty'], assets, settings: settings.data } : null;
71
+ };
@@ -0,0 +1,7 @@
1
+ export declare const packageDigest: (folder: string) => string;
2
+ export declare const digestsRunning: () => {
3
+ readonly digests?: {
4
+ readonly genome: string;
5
+ readonly installer: string;
6
+ };
7
+ };
@@ -0,0 +1,36 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { createHash } from 'node:crypto';
3
+ import { existsSync, readFileSync, readdirSync } from 'node:fs';
4
+ import { dirname, join, relative, sep } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { genomeFolder } from '../halves/genome.js';
7
+
8
+ const sha256 = (bytes ) => createHash('sha256').update(bytes).digest('hex');
9
+
10
+ const filesUnder = (folder ) =>
11
+ readdirSync(folder, { withFileTypes: true }).flatMap((entry) => {
12
+ const path = join(folder, entry.name);
13
+ if (entry.isDirectory()) return entry.name === 'node_modules' ? [] : filesUnder(path);
14
+ return entry.isFile() ? [path] : [];
15
+ });
16
+
17
+ export const packageDigest = (folder ) => {
18
+ const pairs = filesUnder(folder).map((path) => [
19
+ relative(folder, path).split(sep).join('/'),
20
+ sha256(readFileSync(path)),
21
+ ]);
22
+ return sha256(JSON.stringify(pairs.toSorted(([one = ''], [other = '']) => (one < other ? -1 : 1))));
23
+ };
24
+
25
+ const installerFolder = () => {
26
+ let folder = dirname(fileURLToPath(import.meta.url));
27
+ while (!existsSync(join(folder, 'package.json')) && folder !== dirname(folder)) folder = dirname(folder);
28
+ return folder;
29
+ };
30
+
31
+ export const digestsRunning = () => {
32
+ const genome = genomeFolder();
33
+ return typeof genome === 'string'
34
+ ? { digests: { genome: packageDigest(genome), installer: packageDigest(installerFolder()) } }
35
+ : {};
36
+ };
@@ -0,0 +1,25 @@
1
+ export type Part = {
2
+ readonly faculty: string;
3
+ readonly label: string;
4
+ readonly wiring: {
5
+ readonly [placeholder: string]: string;
6
+ };
7
+ readonly name: string;
8
+ readonly version: string;
9
+ };
10
+ declare const NAMES: readonly ['TERMINAL', 'WINDOW', 'REPOS', 'REPO'];
11
+ type Name = (typeof NAMES)[number];
12
+ export type Distribution = {
13
+ readonly package: string;
14
+ readonly road: string;
15
+ readonly parts: {
16
+ readonly [name in Name]?: Part;
17
+ };
18
+ };
19
+ type Why = {
20
+ readonly why: string;
21
+ };
22
+ export declare const packageOf: (spec: string) => string;
23
+ export declare const distributionOf: (name: string, version: string, exported: unknown) => Promise<Distribution | Why>;
24
+ export declare const distributionIn: (value: unknown) => Distribution | null;
25
+ export {};
@@ -0,0 +1,88 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { readFaculty } from '@nervur.org/genome/faculty';
3
+ import { loadQuickJS, makeEngine } from '@nervur.org/genome/engine';
4
+ import { LOBE_MEMORY } from '@nervur.org/genome/seams';
5
+ import { isFields, } from '@nervur.org/genome/standard';
6
+ import { nodeCrypto } from '../fills/crypto.js';
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ const NAMES = ['TERMINAL', 'WINDOW', 'REPOS', 'REPO'] ;
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ const fieldsOf = (value ) =>
28
+ typeof value === 'object' && value !== null && !Array.isArray(value);
29
+
30
+ const ORGAN_OF = { TERMINAL: 'console', WINDOW: 'screen' };
31
+
32
+ export const packageOf = (spec ) => {
33
+ const at = spec.indexOf('@', 1);
34
+ return at === -1 ? spec : spec.slice(0, at);
35
+ };
36
+
37
+ const textValued = (entry ) => typeof entry[1] === 'string';
38
+
39
+ const shapeOf = (name , value ) => {
40
+ if (!fieldsOf(value) || typeof value['faculty'] !== 'string' || typeof value['label'] !== 'string')
41
+ return { why: `${name} is no faculty's source and label` };
42
+ const wiring = value['wiring'] ?? {};
43
+ if (!isFields(wiring) || !Object.entries(wiring).every(textValued))
44
+ return { why: `${name}'s wiring is no map of placeholders` };
45
+ return {
46
+ faculty: value['faculty'],
47
+ label: value['label'],
48
+ wiring: Object.fromEntries(Object.entries(wiring).filter(textValued)),
49
+ };
50
+ };
51
+
52
+ export const distributionOf = async (name , version , exported ) => {
53
+ const named = NAMES.filter((one) => fieldsOf(exported) && exported[one] !== undefined);
54
+ if (named.length === 0) return { why: `${name} exports none of ${NAMES.join(', ')}: it names no floor` };
55
+ const engine = makeEngine(await loadQuickJS(), 1);
56
+ const parts = {};
57
+ for (const one of named) {
58
+ const shape = shapeOf(one, fieldsOf(exported) ? exported[one] : undefined);
59
+ if ('why' in shape) return { why: `${name}: ${shape.why}` };
60
+ const read = readFaculty(engine, nodeCrypto, shape.faculty, LOBE_MEMORY);
61
+ if ('why' in read) return { why: `${name}: the text of ${one} reads not: ${read.why}` };
62
+ const organ = ORGAN_OF[one];
63
+ if (organ !== undefined && !Object.hasOwn(read.blueprint.placeholders ?? {}, organ))
64
+ return { why: `${name}: ${one} names no placeholder for the ${organ}` };
65
+ parts[one] = { ...shape, name: read.blueprint.name, version: read.blueprint.version };
66
+ }
67
+ return { package: name, road: `${name}@${version}`, parts };
68
+ };
69
+
70
+ const partHeld = (one ) =>
71
+ fieldsOf(one) &&
72
+ typeof one['faculty'] === 'string' &&
73
+ typeof one['label'] === 'string' &&
74
+ typeof one['name'] === 'string' &&
75
+ typeof one['version'] === 'string' &&
76
+ isFields(one['wiring']);
77
+
78
+ const isDistribution = (value ) => {
79
+ if (!fieldsOf(value) || typeof value['package'] !== 'string' || typeof value['road'] !== 'string') return false;
80
+ const held = value['parts'];
81
+ return (
82
+ isFields(held) &&
83
+ Object.keys(held).every((one) => NAMES.some((name) => name === one)) &&
84
+ Object.values(held).every(partHeld)
85
+ );
86
+ };
87
+
88
+ export const distributionIn = (value ) => (isDistribution(value) ? value : null);
@@ -0,0 +1,41 @@
1
+ import { type Salvaged } from '@nervur.org/genome';
2
+ import type { Configuration, Fills, Init, PureStart, Sealable, Shipped, UnlockerSeam } from '@nervur.org/genome/seams';
3
+ import { type Data } from '@nervur.org/genome/standard';
4
+ import { type Body } from '../service/index.js';
5
+ export type Opening = {
6
+ readonly home: string;
7
+ readonly forms?: Fills['forms'];
8
+ readonly init: Init;
9
+ readonly unlocker: UnlockerSeam;
10
+ readonly configuration: Configuration;
11
+ readonly reserve?: number;
12
+ readonly stopped: (why: string) => void;
13
+ readonly body?: Body;
14
+ readonly firstInvitation?: (invitation: Data) => void;
15
+ readonly claim?: string;
16
+ readonly warned?: (why: string) => void;
17
+ readonly upgrade?: NonNullable<PureStart['upgrade']>;
18
+ };
19
+ export type Door = {
20
+ readonly reached: Promise<readonly string[]>;
21
+ readonly failed: Promise<string>;
22
+ readonly stop: () => Promise<void>;
23
+ readonly rewrap: (next: Uint8Array) => Promise<null | {
24
+ readonly why: string;
25
+ }>;
26
+ readonly rekey: (next: Uint8Array, cipher?: string) => Promise<null | {
27
+ readonly why: string;
28
+ }>;
29
+ readonly seal: Sealable['seal'];
30
+ };
31
+ export declare const storeOf: (home: string) => string;
32
+ export declare const salvageAt: (home: string, key: Uint8Array) => Promise<Salvaged | {
33
+ readonly why: string;
34
+ }>;
35
+ export declare const openDoor: (opening: Opening) => Promise<{
36
+ readonly door: Door;
37
+ readonly shipped: Shipped;
38
+ readonly halves: readonly string[];
39
+ } | {
40
+ readonly why: string;
41
+ }>;
@@ -0,0 +1,219 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { mkdirSync, readFileSync } from 'node:fs';
3
+ import { dirname, join } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { genomeEntry, genomeQueues, salvageStore, } from '@nervur.org/genome';
6
+ import { genomeCodec } from '@nervur.org/genome/cage';
7
+ import { loadQuickJS, makeEngine } from '@nervur.org/genome/engine';
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ import { CONSOLE } from '@nervur.org/genome';
19
+ import { isFields, } from '@nervur.org/genome/standard';
20
+ import { keptBridge, nodeBridge, } from '../fills/bridge.js';
21
+ import { genomeFolder } from '../halves/genome.js';
22
+ import { digestsRunning } from './digests.js';
23
+ import { lendGenome, linkGenome } from '../halves/lent.js';
24
+ import { halvesOf, programOf, sourceHalves } from '../halves/index.js';
25
+ import { inBody, } from '../service/index.js';
26
+ import { nodeLobes } from '../lobes/index.js';
27
+ import { compileIn } from '../organism/compiled.js';
28
+ import { workHalvesOf } from '../work/index.js';
29
+ import { workApartOf } from './configuration.js';
30
+ import { claimedWeb, } from './claimed.js';
31
+ import { nodeChance } from '../fills/chance.js';
32
+ import { nodeCrypto } from '../fills/crypto.js';
33
+ import { nodePages } from '../fills/pages.js';
34
+ import { RESERVE, reserveOf } from '../fills/reserve.js';
35
+ import { nodeTime } from '../fills/time.js';
36
+ import { nodeVitals } from '../fills/vitals.js';
37
+ import { nodeNetwork, } from '../../organs/network/node/fill.js';
38
+
39
+ const FUEL_RATE = 0.5;
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+ const builtHalvesOf = (configuration ) => {
63
+ const reach = configuration.installerOrgans?.['disk']?.reach;
64
+ return isFields(reach) && typeof reach['folder'] === 'string' ? join(reach['folder'], 'halves') : undefined;
65
+ };
66
+
67
+ const boundedBy =
68
+ (body ) =>
69
+ (organ , program ) =>
70
+ body === undefined || organ === CONSOLE.id ? program : inBody(body, program);
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+ export const storeOf = (home ) => join(home, 'store');
86
+
87
+ const sqlite = () =>
88
+ new Uint8Array(readFileSync(fileURLToPath(import.meta.resolve('@nervur.org/genome/sqlite.wasm'))));
89
+
90
+ const networkFilled = (
91
+ opening ,
92
+
93
+
94
+
95
+
96
+
97
+
98
+ ) => {
99
+ const { network } = opening.configuration;
100
+ if (network === undefined) return { why: "Node's configuration names network's half" };
101
+ const found = genomeFolder();
102
+ const apart = workApartOf(opening.configuration);
103
+ const lent = typeof found === 'string' ? lendGenome(dirname(opening.home), found, apart) : undefined;
104
+ if (lent !== undefined && typeof lent !== 'string') return lent;
105
+ const linked = typeof lent === 'string' ? linkGenome(join(opening.home, 'disk'), lent) : null;
106
+ if (linked !== null) return linked;
107
+ const kept = keptBridge(
108
+ nodeBridge(
109
+ programOf(
110
+ halvesOf(opening.home),
111
+ sourceHalves().values(),
112
+ apart ? workHalvesOf(opening.home) : undefined,
113
+ boundedBy(opening.body),
114
+ lent,
115
+ builtHalvesOf(opening.configuration),
116
+ ),
117
+ ),
118
+ );
119
+ const tcp = nodeNetwork(kept.bridge, { ...network.half, reach: network.reach, code: null });
120
+ return {
121
+ tcp,
122
+ bridge: kept.bridge,
123
+ close: async () => {
124
+ await tcp.close();
125
+ await kept.close();
126
+ },
127
+ };
128
+ };
129
+
130
+
131
+
132
+ const untaken = () => console.error('the brain handed a first invitation, which no one takes');
133
+
134
+ const logged = (why ) => console.error(`the boot refused something the configuration named: ${why}`);
135
+
136
+ const claimedCarriers = (carriers , claimed ) =>
137
+ claimed === null
138
+ ? carriers
139
+ : Object.defineProperties(
140
+ { ...carriers },
141
+ { ...Object.getOwnPropertyDescriptors(carriers), web: { value: claimed.web, enumerable: true } },
142
+ );
143
+
144
+ const claimedOf = (opening , web ) =>
145
+ opening.claim === undefined || web === undefined
146
+ ? null
147
+ : claimedWeb(web, opening.claim, opening.configuration.web ?? [], (why) => console.error(why));
148
+
149
+ const fillsOf = async (opening , { tcp, bridge } , claimed ) => ({
150
+ time: nodeTime(),
151
+ chance: nodeChance(),
152
+ pages: nodePages(storeOf(opening.home), reserveOf(opening.home, opening.reserve ?? RESERVE)),
153
+ vitals: await nodeVitals(opening.home),
154
+ engine: makeEngine(await loadQuickJS(), FUEL_RATE),
155
+ unlocker: opening.unlocker,
156
+ carriers: claimedCarriers(tcp.carriers, claimed),
157
+ bridge,
158
+ codec: genomeCodec,
159
+ crypto: nodeCrypto,
160
+ ...(opening.forms === undefined ? {} : { forms: opening.forms }),
161
+ queues: genomeQueues,
162
+ });
163
+
164
+ export const salvageAt = (home , key ) =>
165
+ salvageStore(
166
+ { pages: nodePages(storeOf(home)), time: nodeTime(), chance: nodeChance(), crypto: nodeCrypto, wasm: sqlite() },
167
+ key,
168
+ );
169
+
170
+ export const openDoor = async (
171
+ opening ,
172
+
173
+
174
+ ) => {
175
+ const opened = await opening.unlocker.open();
176
+ if (opened === null) return { why: 'no boot key was given, so the organism does not start' };
177
+ mkdirSync(opening.home, { recursive: true, mode: 0o700 });
178
+ const network = networkFilled(opening);
179
+ if ('why' in network) return network;
180
+ const { tcp, close } = network;
181
+ const claimed = claimedOf(opening, tcp.carriers.web);
182
+ const fills = await fillsOf(opening, network, claimed);
183
+ const compiled = compileIn(opening.home);
184
+ const lobes = nodeLobes({
185
+ memory: opening.configuration.lobeMemory,
186
+ rate: FUEL_RATE,
187
+ ...(compiled === null ? {} : { compiled }),
188
+ });
189
+ const entered = genomeEntry(sqlite(), lobes);
190
+ const started = await entered({
191
+ fills,
192
+ configuration: { ...opening.configuration, ...digestsRunning() },
193
+ init: opening.init,
194
+ key: opened.key,
195
+ firstInvitation: claimed?.keep ?? opening.firstInvitation ?? untaken,
196
+ stopped: opening.stopped,
197
+ ...(opening.upgrade === undefined ? {} : { upgrade: opening.upgrade }),
198
+ });
199
+ if ('why' in started) {
200
+ await close();
201
+ return started;
202
+ }
203
+ for (const why of started.warnings) (opening.warned ?? logged)(why);
204
+ const stop = async () => {
205
+ await started.organism.stop();
206
+ await close();
207
+ await lobes.ended();
208
+ };
209
+ return { door: doorOf(started.organism, tcp, stop), shipped: started.shipped, halves: started.halves };
210
+ };
211
+
212
+ const doorOf = (organism , tcp , stop ) => ({
213
+ reached: tcp.reached,
214
+ failed: tcp.failed,
215
+ stop,
216
+ rewrap: (next) => organism.rewrap(next),
217
+ rekey: (next, cipher) => organism.rekey(next, cipher),
218
+ seal: (to, genome) => organism.seal(to, genome),
219
+ });
@@ -0,0 +1,34 @@
1
+ import type { Told } from '@nervur.org/genome/screen';
2
+ import type { Given } from '@nervur.org/genome/seams';
3
+ export type Kept = {
4
+ readonly find: (digest: string) => Promise<Uint8Array | null>;
5
+ readonly keep: (digest: string, bytes: Uint8Array) => Promise<void>;
6
+ readonly only: (digests: readonly string[]) => Promise<void>;
7
+ };
8
+ export type Own = {
9
+ readonly get: (path: string) => Promise<Uint8Array | null>;
10
+ readonly sha256: (bytes: Uint8Array) => Promise<string>;
11
+ readonly domain: string;
12
+ readonly kept: Kept;
13
+ };
14
+ export type Size = Told['size'];
15
+ export type Reader = (source: string) => Promise<{
16
+ readonly placeholders: readonly string[];
17
+ } | {
18
+ readonly why: string;
19
+ }>;
20
+ export type Window = {
21
+ readonly faculty: string;
22
+ readonly road: string;
23
+ readonly placeholders: readonly string[];
24
+ };
25
+ export type Dressed = {
26
+ readonly design: Given | undefined;
27
+ readonly window: Window | undefined;
28
+ readonly warnings: readonly string[];
29
+ readonly size: Size | null;
30
+ };
31
+ export declare const SAID = "/.well-known/quo";
32
+ export declare const WINDOW_PATH = "window/faculty.js";
33
+ export declare const sizeOf: (named: unknown) => Size | null;
34
+ export declare const dressed: (own: Own, read?: Reader) => Promise<Dressed>;