@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.
- package/LICENSE +105 -0
- package/README.md +158 -2
- package/SECURITY.md +8 -0
- package/bin/nervur.js +5 -0
- package/cargo/emscripten-module.wasm +0 -0
- package/cargo/manifest.json +1 -0
- package/cargo/sqlite3.wasm +0 -0
- package/cargo/table-i-i.wasm +0 -0
- package/cargo/table-i-ii.wasm +0 -0
- package/cargo/table-i-iii.wasm +0 -0
- package/cargo/table-i-iiii.wasm +0 -0
- package/cargo/table-i-iiiii.wasm +0 -0
- package/cargo/table-i-iiij.wasm +0 -0
- package/cargo/table-i-ij.wasm +0 -0
- package/cargo/table-v-ii.wasm +0 -0
- package/cargo/table-v-iii.wasm +0 -0
- package/cargo/worker.js +30756 -0
- package/organs/console/node/guard.d.ts +10 -0
- package/organs/console/node/guard.js +52 -0
- package/organs/console/node/index.d.ts +4 -0
- package/organs/console/node/index.js +5 -0
- package/organs/console/node/line.d.ts +16 -0
- package/organs/console/node/line.js +150 -0
- package/organs/console/node/main.js +51 -0
- package/organs/console/node/program.d.ts +1 -0
- package/organs/console/node/program.js +5 -0
- package/organs/console/node/proof.d.ts +15 -0
- package/organs/console/node/proof.js +84 -0
- package/organs/console/node/socket.d.ts +15 -0
- package/organs/console/node/socket.js +99 -0
- package/organs/disk/index.d.ts +1 -0
- package/organs/disk/index.js +2 -0
- package/organs/disk/node/files.js +162 -0
- package/organs/disk/node/main.js +20 -0
- package/organs/disk/node/program.d.ts +1 -0
- package/organs/disk/node/program.js +5 -0
- package/organs/disk/organ.d.ts +5 -0
- package/organs/disk/organ.js +69 -0
- package/organs/network/node/fill.d.ts +21 -0
- package/organs/network/node/fill.js +195 -0
- package/organs/network/node/flows.js +66 -0
- package/organs/network/node/half.js +260 -0
- package/organs/network/node/lines.d.ts +29 -0
- package/organs/network/node/lines.js +236 -0
- package/organs/network/node/link.d.ts +24 -0
- package/organs/network/node/link.js +215 -0
- package/organs/network/node/main.js +41 -0
- package/organs/network/node/moved.d.ts +2 -0
- package/organs/network/node/moved.js +20 -0
- package/organs/network/node/near.d.ts +63 -0
- package/organs/network/node/near.js +263 -0
- package/organs/network/node/program.d.ts +1 -0
- package/organs/network/node/program.js +5 -0
- package/organs/network/node/schemes.d.ts +1 -0
- package/organs/network/node/schemes.js +2 -0
- package/organs/network/node/sent.d.ts +13 -0
- package/organs/network/node/sent.js +101 -0
- package/organs/network/node/served.d.ts +19 -0
- package/organs/network/node/served.js +237 -0
- package/organs/screen/node/client.js +3 -0
- package/organs/screen/node/follow.js +266 -0
- package/organs/screen/node/frames.js +26 -0
- package/organs/screen/node/held.js +27 -0
- package/organs/screen/node/http.js +179 -0
- package/organs/screen/node/lay.js +116 -0
- package/organs/screen/node/leave.js +27 -0
- package/organs/screen/node/linked.js +69 -0
- package/organs/screen/node/listen.js +61 -0
- package/organs/screen/node/look.js +121 -0
- package/organs/screen/node/loop.js +154 -0
- package/organs/screen/node/main.js +74 -0
- package/organs/screen/node/mirror.js +112 -0
- package/organs/screen/node/notice.js +44 -0
- package/organs/screen/node/presser.js +11 -0
- package/organs/screen/node/presses.js +108 -0
- package/organs/screen/node/program.d.ts +1 -0
- package/organs/screen/node/program.js +5 -0
- package/organs/screen/node/shown.js +205 -0
- package/organs/screen/node/standing.js +29 -0
- package/organs/screen/node/state.js +80 -0
- package/organs/screen/node/tell.js +47 -0
- package/organs/screen/node/uid.js +65 -0
- package/organs/screen/node/worn.js +23 -0
- package/organs/shell/index.d.ts +1 -0
- package/organs/shell/index.js +2 -0
- package/organs/shell/node/main.js +26 -0
- package/organs/shell/node/output.js +70 -0
- package/organs/shell/node/pressure.js +14 -0
- package/organs/shell/node/program.d.ts +1 -0
- package/organs/shell/node/program.js +5 -0
- package/organs/shell/node/runs.js +220 -0
- package/organs/shell/node/told.js +70 -0
- package/organs/shell/organ.d.ts +5 -0
- package/organs/shell/organ.js +59 -0
- package/package.json +43 -4
- package/src/command/act.d.ts +31 -0
- package/src/command/act.js +256 -0
- package/src/command/answers.d.ts +3 -0
- package/src/command/answers.js +232 -0
- package/src/command/args.d.ts +14 -0
- package/src/command/args.js +220 -0
- package/src/command/arrive.d.ts +2 -0
- package/src/command/arrive.js +21 -0
- package/src/command/asked.d.ts +18 -0
- package/src/command/asked.js +49 -0
- package/src/command/backup.d.ts +18 -0
- package/src/command/backup.js +261 -0
- package/src/command/before.d.ts +41 -0
- package/src/command/before.js +237 -0
- package/src/command/born.d.ts +27 -0
- package/src/command/born.js +103 -0
- package/src/command/bridge.d.ts +19 -0
- package/src/command/bridge.js +152 -0
- package/src/command/chain.d.ts +9 -0
- package/src/command/chain.js +48 -0
- package/src/command/channel.d.ts +29 -0
- package/src/command/channel.js +263 -0
- package/src/command/choices.d.ts +35 -0
- package/src/command/choices.js +173 -0
- package/src/command/claim.d.ts +12 -0
- package/src/command/claim.js +46 -0
- package/src/command/commands.d.ts +16 -0
- package/src/command/commands.js +257 -0
- package/src/command/ends.d.ts +16 -0
- package/src/command/ends.js +78 -0
- package/src/command/follow.d.ts +12 -0
- package/src/command/follow.js +66 -0
- package/src/command/given.d.ts +39 -0
- package/src/command/given.js +53 -0
- package/src/command/held.d.ts +15 -0
- package/src/command/held.js +56 -0
- package/src/command/index.d.ts +1 -0
- package/src/command/index.js +203 -0
- package/src/command/jailer.d.ts +28 -0
- package/src/command/jailer.js +135 -0
- package/src/command/laid.d.ts +6 -0
- package/src/command/laid.js +31 -0
- package/src/command/left.d.ts +9 -0
- package/src/command/left.js +34 -0
- package/src/command/line.d.ts +7 -0
- package/src/command/line.js +39 -0
- package/src/command/link.d.ts +30 -0
- package/src/command/link.js +123 -0
- package/src/command/lobes.d.ts +1 -0
- package/src/command/lobes.js +10 -0
- package/src/command/locks.d.ts +17 -0
- package/src/command/locks.js +76 -0
- package/src/command/mcp/calls.d.ts +27 -0
- package/src/command/mcp/calls.js +155 -0
- package/src/command/mcp/notices.d.ts +22 -0
- package/src/command/mcp/notices.js +203 -0
- package/src/command/mcp/resources.d.ts +31 -0
- package/src/command/mcp/resources.js +108 -0
- package/src/command/mcp/server.d.ts +19 -0
- package/src/command/mcp/server.js +149 -0
- package/src/command/mcp/tools.d.ts +39 -0
- package/src/command/mcp/tools.js +131 -0
- package/src/command/mcp.d.ts +8 -0
- package/src/command/mcp.js +39 -0
- package/src/command/noticed.d.ts +11 -0
- package/src/command/noticed.js +55 -0
- package/src/command/older.d.ts +11 -0
- package/src/command/older.js +45 -0
- package/src/command/open.d.ts +24 -0
- package/src/command/open.js +107 -0
- package/src/command/passphrase.d.ts +6 -0
- package/src/command/passphrase.js +82 -0
- package/src/command/reclaim.d.ts +7 -0
- package/src/command/reclaim.js +47 -0
- package/src/command/refused.d.ts +4 -0
- package/src/command/refused.js +27 -0
- package/src/command/release.d.ts +27 -0
- package/src/command/release.js +153 -0
- package/src/command/repo.d.ts +31 -0
- package/src/command/repo.js +133 -0
- package/src/command/rewrap.d.ts +16 -0
- package/src/command/rewrap.js +175 -0
- package/src/command/runtime.d.ts +25 -0
- package/src/command/runtime.js +175 -0
- package/src/command/salvage.d.ts +4 -0
- package/src/command/salvage.js +42 -0
- package/src/command/screen.d.ts +14 -0
- package/src/command/screen.js +62 -0
- package/src/command/spawn.d.ts +23 -0
- package/src/command/spawn.js +213 -0
- package/src/command/start.d.ts +34 -0
- package/src/command/start.js +246 -0
- package/src/command/state.d.ts +5 -0
- package/src/command/state.js +39 -0
- package/src/command/token.d.ts +1 -0
- package/src/command/token.js +9 -0
- package/src/command/trial.d.ts +17 -0
- package/src/command/trial.js +92 -0
- package/src/command/vouch.d.ts +1 -0
- package/src/command/vouch.js +15 -0
- package/src/command/windows-processes.d.ts +2 -0
- package/src/command/windows-processes.js +22 -0
- package/src/command/wipe.d.ts +9 -0
- package/src/command/wipe.js +105 -0
- package/src/command/words.d.ts +5 -0
- package/src/command/words.js +53 -0
- package/src/door/claim.d.ts +5 -0
- package/src/door/claim.js +21 -0
- package/src/door/claimed.d.ts +7 -0
- package/src/door/claimed.js +110 -0
- package/src/door/configuration.d.ts +40 -0
- package/src/door/configuration.js +206 -0
- package/src/door/design.d.ts +13 -0
- package/src/door/design.js +71 -0
- package/src/door/digests.d.ts +7 -0
- package/src/door/digests.js +36 -0
- package/src/door/distribution.d.ts +25 -0
- package/src/door/distribution.js +88 -0
- package/src/door/door.d.ts +41 -0
- package/src/door/door.js +219 -0
- package/src/door/dressed.d.ts +34 -0
- package/src/door/dressed.js +182 -0
- package/src/door/faculties.d.ts +29 -0
- package/src/door/faculties.js +88 -0
- package/src/door/longest.d.ts +6 -0
- package/src/door/longest.js +25 -0
- package/src/fills/account-only.d.ts +3 -0
- package/src/fills/account-only.js +24 -0
- package/src/fills/boot-key.d.ts +21 -0
- package/src/fills/boot-key.js +70 -0
- package/src/fills/boot-move.d.ts +25 -0
- package/src/fills/boot-move.js +86 -0
- package/src/fills/bridge.d.ts +13 -0
- package/src/fills/bridge.js +86 -0
- package/src/fills/chance.d.ts +2 -0
- package/src/fills/chance.js +7 -0
- package/src/fills/crypto.d.ts +2 -0
- package/src/fills/crypto.js +94 -0
- package/src/fills/flushed.d.ts +9 -0
- package/src/fills/flushed.js +80 -0
- package/src/fills/hardware.d.ts +18 -0
- package/src/fills/hardware.js +70 -0
- package/src/fills/held.d.ts +31 -0
- package/src/fills/held.js +171 -0
- package/src/fills/keepers.d.ts +23 -0
- package/src/fills/keepers.js +151 -0
- package/src/fills/keyring.d.ts +19 -0
- package/src/fills/keyring.js +131 -0
- package/src/fills/pages.d.ts +3 -0
- package/src/fills/pages.js +260 -0
- package/src/fills/reserve.d.ts +11 -0
- package/src/fills/reserve.js +72 -0
- package/src/fills/time.d.ts +2 -0
- package/src/fills/time.js +29 -0
- package/src/fills/unlocker.d.ts +6 -0
- package/src/fills/unlocker.js +26 -0
- package/src/fills/vitals.d.ts +8 -0
- package/src/fills/vitals.js +100 -0
- package/src/fills/windows-start.d.ts +2 -0
- package/src/fills/windows-start.js +21 -0
- package/src/halves/build.d.ts +10 -0
- package/src/halves/build.js +219 -0
- package/src/halves/end.d.ts +17 -0
- package/src/halves/end.js +157 -0
- package/src/halves/genome.d.ts +3 -0
- package/src/halves/genome.js +21 -0
- package/src/halves/handler.d.ts +8 -0
- package/src/halves/handler.js +40 -0
- package/src/halves/index.d.ts +5 -0
- package/src/halves/index.js +6 -0
- package/src/halves/laid.d.ts +12 -0
- package/src/halves/laid.js +103 -0
- package/src/halves/lent.d.ts +6 -0
- package/src/halves/lent.js +147 -0
- package/src/halves/native.d.ts +12 -0
- package/src/halves/native.js +53 -0
- package/src/halves/statements.d.ts +23 -0
- package/src/halves/statements.js +165 -0
- package/src/halves/tokens.d.ts +22 -0
- package/src/halves/tokens.js +135 -0
- package/src/link/link.d.ts +4 -0
- package/src/link/link.js +4 -0
- package/src/link/placeholder.d.ts +1 -0
- package/src/link/placeholder.js +21 -0
- package/src/link/steps.d.ts +52 -0
- package/src/link/steps.js +118 -0
- package/src/lobes/calls.d.ts +76 -0
- package/src/lobes/calls.js +61 -0
- package/src/lobes/channel.d.ts +76 -0
- package/src/lobes/channel.js +202 -0
- package/src/lobes/index.d.ts +1 -0
- package/src/lobes/index.js +2 -0
- package/src/lobes/lobes.d.ts +15 -0
- package/src/lobes/lobes.js +244 -0
- package/src/lobes/main.js +107 -0
- package/src/lobes/thread.d.ts +22 -0
- package/src/lobes/thread.js +270 -0
- package/src/organism/act.d.ts +8 -0
- package/src/organism/act.js +63 -0
- package/src/organism/beat.d.ts +5 -0
- package/src/organism/beat.js +45 -0
- package/src/organism/compiled.d.ts +2 -0
- package/src/organism/compiled.js +24 -0
- package/src/organism/folder.d.ts +88 -0
- package/src/organism/folder.js +259 -0
- package/src/organism/main.d.ts +1 -0
- package/src/organism/main.js +11 -0
- package/src/organism/organism.d.ts +1 -0
- package/src/organism/organism.js +219 -0
- package/src/organism/said.d.ts +12 -0
- package/src/organism/said.js +30 -0
- package/src/organism/told.d.ts +5 -0
- package/src/organism/told.js +110 -0
- package/src/organism/unlock.d.ts +8 -0
- package/src/organism/unlock.js +95 -0
- package/src/organism/upgrade.d.ts +24 -0
- package/src/organism/upgrade.js +145 -0
- package/src/organism/via.d.ts +7 -0
- package/src/organism/via.js +20 -0
- package/src/service/body.d.ts +8 -0
- package/src/service/body.js +34 -0
- package/src/service/handler.d.ts +20 -0
- package/src/service/handler.js +128 -0
- package/src/service/index.d.ts +4 -0
- package/src/service/index.js +16 -0
- package/src/service/manager.d.ts +18 -0
- package/src/service/manager.js +185 -0
- package/src/service/service.d.ts +24 -0
- package/src/service/service.js +200 -0
- package/src/service/swap.d.ts +12 -0
- package/src/service/swap.js +74 -0
- package/src/service/watchdog.d.ts +6 -0
- package/src/service/watchdog.js +31 -0
- package/src/tcp/crowd.d.ts +18 -0
- package/src/tcp/crowd.js +85 -0
- package/src/tcp/dial.d.ts +23 -0
- package/src/tcp/dial.js +102 -0
- package/src/tcp/frame.d.ts +23 -0
- package/src/tcp/frame.js +159 -0
- package/src/tcp/listen.d.ts +50 -0
- package/src/tcp/listen.js +207 -0
- package/src/tcp/source.d.ts +2 -0
- package/src/tcp/source.js +26 -0
- package/src/version/index.d.ts +1 -0
- package/src/version/index.js +2 -0
- package/src/version/version.d.ts +1 -0
- package/src/version/version.js +2 -0
- package/src/work/first.d.ts +11 -0
- package/src/work/first.js +91 -0
- package/src/work/index.d.ts +2 -0
- package/src/work/index.js +15 -0
- package/src/work/work.d.ts +20 -0
- package/src/work/work.js +136 -0
- package/src/ws/dial.d.ts +7 -0
- package/src/ws/dial.js +252 -0
- package/src/ws/dialing.d.ts +50 -0
- package/src/ws/dialing.js +72 -0
- package/src/ws/frame.d.ts +32 -0
- package/src/ws/frame.js +124 -0
- package/src/ws/handshake.d.ts +4 -0
- package/src/ws/handshake.js +27 -0
- package/src/ws/line.d.ts +45 -0
- package/src/ws/line.js +250 -0
- package/src/ws/listen.d.ts +42 -0
- package/src/ws/listen.js +272 -0
- package/src/ws/rfc6455.d.ts +18 -0
- package/src/ws/rfc6455.js +187 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { writeFileSync } from 'node:fs';
|
|
3
|
+
|
|
4
|
+
const SCORE = '/proc/self/oom_score_adj';
|
|
5
|
+
const HIGHEST = 1000;
|
|
6
|
+
|
|
7
|
+
export const firstUnderPressure = (file = SCORE) => {
|
|
8
|
+
try {
|
|
9
|
+
writeFileSync(file, String(HIGHEST), { flag: 'r+' });
|
|
10
|
+
return true;
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PROGRAM: string;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { spawn, } from 'node:child_process';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { constants } from 'node:os';
|
|
5
|
+
import { FRAME_SIZE } from '../../../src/door/longest.js';
|
|
6
|
+
import { error, isFields, result, utf8Bytes, } from '@nervur.org/genome/standard';
|
|
7
|
+
import { endWithin, outputOf, } from './output.js';
|
|
8
|
+
import { paused, tellingOf, } from './told.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const NOT_FOUND = 127;
|
|
18
|
+
const BY_SIGNAL = 128;
|
|
19
|
+
|
|
20
|
+
const ENVELOPE = 65_536;
|
|
21
|
+
const LONGEST = Math.floor(FRAME_SIZE / 2) - ENVELOPE;
|
|
22
|
+
|
|
23
|
+
const SHORTEST = 1000;
|
|
24
|
+
const PRINTED_CHARACTERS = Math.floor(LONGEST / 8);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const refused = (message ) => error('refused', message);
|
|
29
|
+
|
|
30
|
+
const texts = (data ) =>
|
|
31
|
+
Array.isArray(data) && data.length > 0 && data.every((word) => typeof word === 'string')
|
|
32
|
+
? data.filter((word) => typeof word === 'string')
|
|
33
|
+
: null;
|
|
34
|
+
|
|
35
|
+
const pendingOf = (
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
) => {
|
|
40
|
+
const decoder = new TextDecoder();
|
|
41
|
+
let text = '';
|
|
42
|
+
return {
|
|
43
|
+
add: (chunk) => {
|
|
44
|
+
text += decoder.decode(chunk, { stream: true });
|
|
45
|
+
},
|
|
46
|
+
take: (most) => {
|
|
47
|
+
const taken = text.slice(0, most);
|
|
48
|
+
text = text.slice(taken.length);
|
|
49
|
+
return taken;
|
|
50
|
+
},
|
|
51
|
+
empty: () => text === '',
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
const printerOf = (run , stream ) => {
|
|
64
|
+
const pendingOut = pendingOf();
|
|
65
|
+
const pendingErr = pendingOf();
|
|
66
|
+
const empty = () => pendingOut.empty() && pendingErr.empty();
|
|
67
|
+
let printing = Promise.resolve();
|
|
68
|
+
let busy = false;
|
|
69
|
+
const print = () => {
|
|
70
|
+
if (busy || empty()) return printing;
|
|
71
|
+
busy = true;
|
|
72
|
+
const half = Math.floor(PRINTED_CHARACTERS / 2);
|
|
73
|
+
const one = { run, out: pendingOut.take(half), err: pendingErr.take(half) };
|
|
74
|
+
const settled = () => {
|
|
75
|
+
busy = false;
|
|
76
|
+
};
|
|
77
|
+
printing = stream.printed(one).then(settled, settled);
|
|
78
|
+
return printing;
|
|
79
|
+
};
|
|
80
|
+
const timer = setInterval(() => void print(), stream.every);
|
|
81
|
+
return {
|
|
82
|
+
out: (chunk) => pendingOut.add(chunk),
|
|
83
|
+
err: (chunk) => pendingErr.add(chunk),
|
|
84
|
+
drain: async () => {
|
|
85
|
+
clearInterval(timer);
|
|
86
|
+
await printing;
|
|
87
|
+
while (!empty()) await print();
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const started = (
|
|
93
|
+
run ,
|
|
94
|
+
[command = '', ...rest] ,
|
|
95
|
+
input ,
|
|
96
|
+
options ,
|
|
97
|
+
ended ,
|
|
98
|
+
stream ,
|
|
99
|
+
) => {
|
|
100
|
+
const child = spawn(command, rest, {
|
|
101
|
+
cwd: options.cwd,
|
|
102
|
+
env: options.genome === undefined ? process.env : { ...process.env, NERVUR_GENOME: options.genome },
|
|
103
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
104
|
+
detached: process.platform !== 'win32',
|
|
105
|
+
});
|
|
106
|
+
const out = outputOf(LONGEST);
|
|
107
|
+
const err = outputOf(LONGEST);
|
|
108
|
+
const printer = stream === null ? null : printerOf(run, stream);
|
|
109
|
+
let told = false;
|
|
110
|
+
const tell = (code ) => {
|
|
111
|
+
if (told) return;
|
|
112
|
+
told = true;
|
|
113
|
+
const end = endWithin(run, code, out, err, LONGEST);
|
|
114
|
+
if (printer === null) ended(end);
|
|
115
|
+
else void printer.drain().then(() => ended(end));
|
|
116
|
+
};
|
|
117
|
+
child.stdout.on('data', (chunk ) => {
|
|
118
|
+
out.add(chunk);
|
|
119
|
+
printer?.out(chunk);
|
|
120
|
+
});
|
|
121
|
+
child.stderr.on('data', (chunk ) => {
|
|
122
|
+
err.add(chunk);
|
|
123
|
+
printer?.err(chunk);
|
|
124
|
+
});
|
|
125
|
+
child.on('error', (failed) => {
|
|
126
|
+
err.add(utf8Bytes(failed.message));
|
|
127
|
+
tell(NOT_FOUND);
|
|
128
|
+
});
|
|
129
|
+
child.on('close', (code, signal) => tell(code ?? BY_SIGNAL + (signal === null ? 0 : constants.signals[signal])));
|
|
130
|
+
child.stdin.on('error', () => undefined);
|
|
131
|
+
child.stdin.end(input);
|
|
132
|
+
return child;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const GRACE = 5000;
|
|
136
|
+
|
|
137
|
+
const stopped = (child ) => {
|
|
138
|
+
const group = (signal ) => {
|
|
139
|
+
try {
|
|
140
|
+
if (child.pid !== undefined && process.platform !== 'win32') process.kill(-child.pid, signal);
|
|
141
|
+
else child.kill(signal);
|
|
142
|
+
} catch {
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
group('SIGTERM');
|
|
146
|
+
setTimeout(() => group('SIGKILL'), GRACE).unref();
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
const askedOf = (args ) => {
|
|
156
|
+
const program = isFields(args) ? texts(args['program']) : null;
|
|
157
|
+
const input = isFields(args) ? (args['input'] ?? '') : null;
|
|
158
|
+
if (program === null || typeof input !== 'string')
|
|
159
|
+
return refused('a run is a program of one word or more, and its input');
|
|
160
|
+
const stream = isFields(args) ? args['stream'] : undefined;
|
|
161
|
+
if (stream === undefined) return { program, input, every: null };
|
|
162
|
+
const every = isFields(stream) ? stream['every'] : undefined;
|
|
163
|
+
if (typeof every !== 'number' || !Number.isInteger(every) || every < SHORTEST)
|
|
164
|
+
return refused(`a run streams each ${SHORTEST} ms or more`);
|
|
165
|
+
return { program, input, every };
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
const stop = (going , telling , args , asker ) => {
|
|
171
|
+
const id = isFields(args) ? args['run'] : undefined;
|
|
172
|
+
if (typeof id !== 'string') return refused('no such run goes');
|
|
173
|
+
telling.stop(id, asker);
|
|
174
|
+
const held = going.get(id);
|
|
175
|
+
if (held === undefined || held.asker !== asker) return refused('no such run goes');
|
|
176
|
+
stopped(held.child);
|
|
177
|
+
return result(null);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const goingOf = (going , telling , asker ) => [
|
|
181
|
+
...[...going].flatMap(([id, held]) => (held.asker === asker ? [id] : [])),
|
|
182
|
+
...telling.of(asker),
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
export const runsOf = (
|
|
186
|
+
cwd ,
|
|
187
|
+
ended ,
|
|
188
|
+
printed = () => Promise.resolve(null),
|
|
189
|
+
pause = paused,
|
|
190
|
+
genome ,
|
|
191
|
+
) => {
|
|
192
|
+
const going = new Map ();
|
|
193
|
+
const telling = tellingOf(ended, pause);
|
|
194
|
+
const run = (args , asker ) => {
|
|
195
|
+
const asked = askedOf(args);
|
|
196
|
+
if (!('program' in asked)) return asked;
|
|
197
|
+
if (asker === null) return refused('a run is asked by a skin lobe, which hears its end');
|
|
198
|
+
const id = randomUUID();
|
|
199
|
+
const { program, input, every } = asked;
|
|
200
|
+
const stream = every === null ? null : { every, printed: (print ) => printed(print, asker) };
|
|
201
|
+
const end = (told ) => {
|
|
202
|
+
going.delete(id);
|
|
203
|
+
telling.tell(id, told, asker);
|
|
204
|
+
};
|
|
205
|
+
going.set(id, { child: started(id, program, input, { cwd, genome }, end, stream), asker });
|
|
206
|
+
return result({ run: id });
|
|
207
|
+
};
|
|
208
|
+
return {
|
|
209
|
+
answer: (method, args, asker) => {
|
|
210
|
+
if (method === 'run') return run(args, asker);
|
|
211
|
+
if (method === 'stop') return stop(going, telling, args, asker);
|
|
212
|
+
if (method === 'going') return result({ runs: goingOf(going, telling, asker) });
|
|
213
|
+
return error('unavailable', `the shell holds no method ${method}`);
|
|
214
|
+
},
|
|
215
|
+
stopAll: () => {
|
|
216
|
+
for (const { child } of going.values()) stopped(child);
|
|
217
|
+
telling.clear();
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const AGAIN = new Set(['timeout', 'busy']);
|
|
12
|
+
const GONE = 'unavailable';
|
|
13
|
+
|
|
14
|
+
const PAUSE = 1000;
|
|
15
|
+
|
|
16
|
+
const codeOf = (answer ) => {
|
|
17
|
+
if (typeof answer !== 'object' || answer === null || !('error' in answer)) return null;
|
|
18
|
+
const { error } = answer;
|
|
19
|
+
return typeof error === 'object' && error !== null && 'code' in error && typeof error.code === 'string'
|
|
20
|
+
? error.code
|
|
21
|
+
: null;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const paused = (ms ) =>
|
|
25
|
+
new Promise((done) => {
|
|
26
|
+
setTimeout(done, ms).unref();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export const tellingOf = (
|
|
32
|
+
ended ,
|
|
33
|
+
pause = paused,
|
|
34
|
+
) => {
|
|
35
|
+
const held = new Map ();
|
|
36
|
+
const take = (run , one ) => {
|
|
37
|
+
one.taken = true;
|
|
38
|
+
held.delete(run);
|
|
39
|
+
};
|
|
40
|
+
const tell = (run , end , one ) => {
|
|
41
|
+
const answered = (answer ) => {
|
|
42
|
+
if (one.taken) return;
|
|
43
|
+
const code = codeOf(answer);
|
|
44
|
+
if (code === GONE) {
|
|
45
|
+
one.gone = true;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (code === null || !AGAIN.has(code)) return take(run, one);
|
|
49
|
+
void pause(PAUSE).then(() => {
|
|
50
|
+
if (!one.taken) tell(run, end, one);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
void ended(end, one.asker).then(answered, () => answered(null));
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
tell: (run, end, asker) => {
|
|
57
|
+
const one = { asker, taken: false, gone: false };
|
|
58
|
+
held.set(run, one);
|
|
59
|
+
tell(run, end, one);
|
|
60
|
+
},
|
|
61
|
+
stop: (run, asker) => {
|
|
62
|
+
const one = held.get(run);
|
|
63
|
+
if (one !== undefined && one.asker === asker && one.gone) take(run, one);
|
|
64
|
+
},
|
|
65
|
+
of: (asker) => [...held].flatMap(([run, one]) => (one.asker === asker ? [run] : [])),
|
|
66
|
+
clear: () => {
|
|
67
|
+
for (const [run, one] of held) take(run, one);
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const RUN = {
|
|
5
|
+
type: 'object',
|
|
6
|
+
properties: { run: { type: 'string', minLength: 1 } },
|
|
7
|
+
required: ['run'],
|
|
8
|
+
additionalProperties: false,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const BLUEPRINT = {
|
|
12
|
+
name: 'nervur.shell',
|
|
13
|
+
version: '0.1.42',
|
|
14
|
+
description: "Runs the host's programs under the organism's account, each run answered at once.",
|
|
15
|
+
methods: {
|
|
16
|
+
run: {
|
|
17
|
+
description:
|
|
18
|
+
'Starts a program, its words as the host takes them, with its standard input; with `stream`, the organ asks the skin lobe that asked it back `printed({ run, out, err })` as it goes, what it printed since the last, at most once each `every` ms, before its end.',
|
|
19
|
+
args: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
program: { type: 'array', items: { type: 'string' }, minItems: 1 },
|
|
23
|
+
input: { type: 'string' },
|
|
24
|
+
stream: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
properties: { every: { type: 'integer', minimum: 1000 } },
|
|
27
|
+
required: ['every'],
|
|
28
|
+
additionalProperties: false,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: ['program', 'input'],
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
},
|
|
34
|
+
result: RUN,
|
|
35
|
+
},
|
|
36
|
+
stop: {
|
|
37
|
+
description: "Stops a run still going that the asking lobe started, none else's; it ends as any run does.",
|
|
38
|
+
args: RUN,
|
|
39
|
+
},
|
|
40
|
+
going: {
|
|
41
|
+
description:
|
|
42
|
+
"The asking lobe's runs still going, by their names, each until its end is answered, none of another lobe's; a run lost to a restart of the half is named no more.",
|
|
43
|
+
result: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: { runs: { type: 'array', items: { type: 'string', minLength: 1 } } },
|
|
46
|
+
required: ['runs'],
|
|
47
|
+
additionalProperties: false,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const SHELL
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
= {
|
|
57
|
+
id: 'shell',
|
|
58
|
+
blueprint: BLUEPRINT,
|
|
59
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nervur.org/installer-node",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.37.1",
|
|
4
|
+
"description": "Nervur's installer for Node: the nervur command, the door, the host's organs (console, shell, disk, network) with their blueprints. 0.x, unstable.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"installer",
|
|
8
|
+
"nervur",
|
|
9
|
+
"node",
|
|
10
|
+
"organism",
|
|
11
|
+
"quo"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://nervur.org",
|
|
14
|
+
"license": "FSL-1.1-ALv2",
|
|
15
|
+
"author": "Bookarest Digital SRL",
|
|
16
|
+
"bin": {
|
|
17
|
+
"nervur": "bin/nervur.js"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
"./command": {
|
|
22
|
+
"types": "./src/command/index.d.ts",
|
|
23
|
+
"default": "./src/command/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./shell": {
|
|
26
|
+
"types": "./organs/shell/index.d.ts",
|
|
27
|
+
"default": "./organs/shell/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./disk": {
|
|
30
|
+
"types": "./organs/disk/index.d.ts",
|
|
31
|
+
"default": "./organs/disk/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./cargo/*": "./cargo/*"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@nervur.org/floor": "0.37.1",
|
|
40
|
+
"@nervur.org/genome": "0.37.1"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=22.23.5"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Bridging } from './bridge.js';
|
|
2
|
+
import { type Found, type Taking } from './channel.js';
|
|
3
|
+
import { type Given, type Outcome } from './given.js';
|
|
4
|
+
type Why = {
|
|
5
|
+
readonly why: string;
|
|
6
|
+
};
|
|
7
|
+
export type Reaches = {
|
|
8
|
+
readonly view: (spec: string, taking: Taking) => Promise<Found | Why>;
|
|
9
|
+
readonly take: (version: string, taking: Taking) => Promise<null | Why>;
|
|
10
|
+
readonly keep: (home: string) => Promise<null | Why>;
|
|
11
|
+
readonly moves: (home: string, installer: string) => boolean;
|
|
12
|
+
readonly tried: (given: Given, home: string, installer: string, floor: (given: Given, home: string) => Promise<null | Why>) => Promise<Outcome>;
|
|
13
|
+
readonly back: (given: Given, home: string) => Promise<boolean | Why>;
|
|
14
|
+
readonly handOver: (installer: string, words?: readonly string[]) => Promise<number | Why>;
|
|
15
|
+
readonly sealed: (given: Given, home: string, genome: string) => Promise<string | Why>;
|
|
16
|
+
readonly commit: (home: string) => void;
|
|
17
|
+
readonly left: (home: string) => readonly string[];
|
|
18
|
+
readonly ran: (home: string) => string | null;
|
|
19
|
+
readonly install: (given: Given) => Promise<Outcome>;
|
|
20
|
+
readonly account: (print: (line: string) => void) => Promise<{
|
|
21
|
+
readonly free: () => void;
|
|
22
|
+
} | Why>;
|
|
23
|
+
readonly node: () => null | Why;
|
|
24
|
+
readonly handed: string | null;
|
|
25
|
+
readonly alive: (pid: number) => boolean;
|
|
26
|
+
readonly pid: number;
|
|
27
|
+
readonly parent: number;
|
|
28
|
+
} & Bridging;
|
|
29
|
+
export declare const REAL: Reaches;
|
|
30
|
+
export declare const act: (given: Given, reaches?: Reaches) => Promise<Outcome>;
|
|
31
|
+
export {};
|