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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (364) hide show
  1. package/LICENSE +105 -0
  2. package/README.md +159 -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 +30808 -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 +261 -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 +40 -0
  109. package/src/command/before.js +249 -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 +18 -0
  193. package/src/command/trial.js +108 -0
  194. package/src/command/undone.d.ts +3 -0
  195. package/src/command/undone.js +21 -0
  196. package/src/command/vouch.d.ts +1 -0
  197. package/src/command/vouch.js +15 -0
  198. package/src/command/windows-processes.d.ts +2 -0
  199. package/src/command/windows-processes.js +22 -0
  200. package/src/command/wipe.d.ts +9 -0
  201. package/src/command/wipe.js +105 -0
  202. package/src/command/words.d.ts +5 -0
  203. package/src/command/words.js +53 -0
  204. package/src/door/claim.d.ts +5 -0
  205. package/src/door/claim.js +21 -0
  206. package/src/door/claimed.d.ts +7 -0
  207. package/src/door/claimed.js +110 -0
  208. package/src/door/configuration.d.ts +40 -0
  209. package/src/door/configuration.js +206 -0
  210. package/src/door/design.d.ts +13 -0
  211. package/src/door/design.js +71 -0
  212. package/src/door/digests.d.ts +7 -0
  213. package/src/door/digests.js +36 -0
  214. package/src/door/distribution.d.ts +25 -0
  215. package/src/door/distribution.js +88 -0
  216. package/src/door/door.d.ts +41 -0
  217. package/src/door/door.js +219 -0
  218. package/src/door/dressed.d.ts +34 -0
  219. package/src/door/dressed.js +182 -0
  220. package/src/door/faculties.d.ts +29 -0
  221. package/src/door/faculties.js +88 -0
  222. package/src/door/longest.d.ts +6 -0
  223. package/src/door/longest.js +25 -0
  224. package/src/fills/account-only.d.ts +3 -0
  225. package/src/fills/account-only.js +24 -0
  226. package/src/fills/boot-key.d.ts +21 -0
  227. package/src/fills/boot-key.js +70 -0
  228. package/src/fills/boot-move.d.ts +25 -0
  229. package/src/fills/boot-move.js +86 -0
  230. package/src/fills/bridge.d.ts +13 -0
  231. package/src/fills/bridge.js +86 -0
  232. package/src/fills/chance.d.ts +2 -0
  233. package/src/fills/chance.js +7 -0
  234. package/src/fills/crypto.d.ts +2 -0
  235. package/src/fills/crypto.js +94 -0
  236. package/src/fills/flushed.d.ts +9 -0
  237. package/src/fills/flushed.js +80 -0
  238. package/src/fills/hardware.d.ts +18 -0
  239. package/src/fills/hardware.js +70 -0
  240. package/src/fills/held.d.ts +31 -0
  241. package/src/fills/held.js +171 -0
  242. package/src/fills/keepers.d.ts +23 -0
  243. package/src/fills/keepers.js +151 -0
  244. package/src/fills/keyring.d.ts +19 -0
  245. package/src/fills/keyring.js +131 -0
  246. package/src/fills/pages.d.ts +3 -0
  247. package/src/fills/pages.js +260 -0
  248. package/src/fills/reserve.d.ts +11 -0
  249. package/src/fills/reserve.js +72 -0
  250. package/src/fills/time.d.ts +2 -0
  251. package/src/fills/time.js +29 -0
  252. package/src/fills/unlocker.d.ts +6 -0
  253. package/src/fills/unlocker.js +26 -0
  254. package/src/fills/vitals.d.ts +8 -0
  255. package/src/fills/vitals.js +100 -0
  256. package/src/fills/windows-start.d.ts +2 -0
  257. package/src/fills/windows-start.js +21 -0
  258. package/src/halves/build.d.ts +10 -0
  259. package/src/halves/build.js +219 -0
  260. package/src/halves/end.d.ts +17 -0
  261. package/src/halves/end.js +157 -0
  262. package/src/halves/genome.d.ts +3 -0
  263. package/src/halves/genome.js +21 -0
  264. package/src/halves/handler.d.ts +8 -0
  265. package/src/halves/handler.js +40 -0
  266. package/src/halves/index.d.ts +5 -0
  267. package/src/halves/index.js +6 -0
  268. package/src/halves/laid.d.ts +12 -0
  269. package/src/halves/laid.js +103 -0
  270. package/src/halves/lent.d.ts +6 -0
  271. package/src/halves/lent.js +147 -0
  272. package/src/halves/native.d.ts +12 -0
  273. package/src/halves/native.js +53 -0
  274. package/src/halves/statements.d.ts +23 -0
  275. package/src/halves/statements.js +165 -0
  276. package/src/halves/tokens.d.ts +22 -0
  277. package/src/halves/tokens.js +135 -0
  278. package/src/link/link.d.ts +4 -0
  279. package/src/link/link.js +4 -0
  280. package/src/link/placeholder.d.ts +1 -0
  281. package/src/link/placeholder.js +21 -0
  282. package/src/link/steps.d.ts +52 -0
  283. package/src/link/steps.js +118 -0
  284. package/src/lobes/calls.d.ts +76 -0
  285. package/src/lobes/calls.js +61 -0
  286. package/src/lobes/channel.d.ts +76 -0
  287. package/src/lobes/channel.js +202 -0
  288. package/src/lobes/index.d.ts +1 -0
  289. package/src/lobes/index.js +2 -0
  290. package/src/lobes/lobes.d.ts +15 -0
  291. package/src/lobes/lobes.js +244 -0
  292. package/src/lobes/main.js +107 -0
  293. package/src/lobes/thread.d.ts +22 -0
  294. package/src/lobes/thread.js +270 -0
  295. package/src/organism/act.d.ts +8 -0
  296. package/src/organism/act.js +63 -0
  297. package/src/organism/beat.d.ts +5 -0
  298. package/src/organism/beat.js +45 -0
  299. package/src/organism/compiled.d.ts +2 -0
  300. package/src/organism/compiled.js +24 -0
  301. package/src/organism/folder.d.ts +88 -0
  302. package/src/organism/folder.js +259 -0
  303. package/src/organism/main.d.ts +1 -0
  304. package/src/organism/main.js +11 -0
  305. package/src/organism/organism.d.ts +1 -0
  306. package/src/organism/organism.js +220 -0
  307. package/src/organism/said.d.ts +12 -0
  308. package/src/organism/said.js +30 -0
  309. package/src/organism/told.d.ts +5 -0
  310. package/src/organism/told.js +110 -0
  311. package/src/organism/unlock.d.ts +8 -0
  312. package/src/organism/unlock.js +95 -0
  313. package/src/organism/upgrade.d.ts +24 -0
  314. package/src/organism/upgrade.js +145 -0
  315. package/src/organism/via.d.ts +7 -0
  316. package/src/organism/via.js +20 -0
  317. package/src/service/body.d.ts +8 -0
  318. package/src/service/body.js +34 -0
  319. package/src/service/handler.d.ts +20 -0
  320. package/src/service/handler.js +128 -0
  321. package/src/service/index.d.ts +4 -0
  322. package/src/service/index.js +16 -0
  323. package/src/service/manager.d.ts +18 -0
  324. package/src/service/manager.js +185 -0
  325. package/src/service/service.d.ts +24 -0
  326. package/src/service/service.js +200 -0
  327. package/src/service/swap.d.ts +12 -0
  328. package/src/service/swap.js +74 -0
  329. package/src/service/watchdog.d.ts +6 -0
  330. package/src/service/watchdog.js +31 -0
  331. package/src/tcp/crowd.d.ts +18 -0
  332. package/src/tcp/crowd.js +85 -0
  333. package/src/tcp/dial.d.ts +23 -0
  334. package/src/tcp/dial.js +102 -0
  335. package/src/tcp/frame.d.ts +23 -0
  336. package/src/tcp/frame.js +159 -0
  337. package/src/tcp/listen.d.ts +50 -0
  338. package/src/tcp/listen.js +207 -0
  339. package/src/tcp/source.d.ts +2 -0
  340. package/src/tcp/source.js +26 -0
  341. package/src/version/index.d.ts +1 -0
  342. package/src/version/index.js +2 -0
  343. package/src/version/version.d.ts +1 -0
  344. package/src/version/version.js +2 -0
  345. package/src/work/first.d.ts +11 -0
  346. package/src/work/first.js +91 -0
  347. package/src/work/index.d.ts +2 -0
  348. package/src/work/index.js +15 -0
  349. package/src/work/work.d.ts +20 -0
  350. package/src/work/work.js +136 -0
  351. package/src/ws/dial.d.ts +7 -0
  352. package/src/ws/dial.js +252 -0
  353. package/src/ws/dialing.d.ts +50 -0
  354. package/src/ws/dialing.js +72 -0
  355. package/src/ws/frame.d.ts +32 -0
  356. package/src/ws/frame.js +124 -0
  357. package/src/ws/handshake.d.ts +4 -0
  358. package/src/ws/handshake.js +27 -0
  359. package/src/ws/line.d.ts +45 -0
  360. package/src/ws/line.js +250 -0
  361. package/src/ws/listen.d.ts +42 -0
  362. package/src/ws/listen.js +272 -0
  363. package/src/ws/rfc6455.d.ts +18 -0
  364. package/src/ws/rfc6455.js +187 -0
@@ -0,0 +1,108 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { dataText, isFields, } from '@nervur.org/genome/standard';
3
+
4
+
5
+
6
+
7
+
8
+
9
+ const JSON_TYPE = 'application/json';
10
+ const MARKDOWN = 'text/markdown';
11
+
12
+ export const RESOURCES = [
13
+ { uri: 'nervur://portrait', name: 'portrait', title: 'The organism’s portrait', mimeType: JSON_TYPE },
14
+ { uri: 'nervur://guide', name: 'guide', title: 'Nervur’s guide', mimeType: MARKDOWN },
15
+ { uri: 'nervur://state', name: 'state', title: 'The brain’s state, its first page', mimeType: JSON_TYPE },
16
+ ];
17
+
18
+ export const TEMPLATES = [
19
+ {
20
+ uriTemplate: 'nervur://node/{placeholder}',
21
+ name: 'node',
22
+ title: 'A node the console holds, its describe',
23
+ mimeType: JSON_TYPE,
24
+ },
25
+ {
26
+ uriTemplate: 'nervur://lobe/{id}',
27
+ name: 'lobe',
28
+ title: 'A lobe of the organism, its describe',
29
+ mimeType: JSON_TYPE,
30
+ },
31
+ ];
32
+
33
+
34
+
35
+
36
+
37
+ export const lobesOf = async (type , cursor ) => {
38
+ const heard = await type(['ask', 'brain', 'state', dataText(cursor === null ? {} : { cursor })]);
39
+ if ('why' in heard) return { why: heard.why };
40
+ if ('error' in heard.answer) return { why: `${heard.answer.error.code}: ${heard.answer.error.message}` };
41
+ const { nodes, cursor: next } = isFields(heard.answer.result) ? heard.answer.result : {};
42
+ const lobes = (Array.isArray(nodes) ? nodes : []).flatMap((node) => {
43
+ if (!isFields(node) || node['kind'] !== 'lobe' || typeof node['id'] !== 'string') return [];
44
+ const { id, blueprint, faculty } = node;
45
+ return [
46
+ {
47
+ id,
48
+ blueprint: typeof blueprint === 'string' ? blueprint : '',
49
+ faculty: typeof faculty === 'string' ? faculty : null,
50
+ },
51
+ ];
52
+ });
53
+ return { lobes, next: typeof next === 'string' ? next : null };
54
+ };
55
+
56
+ export const allLobesOf = async (type ) => {
57
+ const all = [];
58
+ const seen = new Set ();
59
+ for (let cursor = null; ;) {
60
+ const page = await lobesOf(type, cursor);
61
+ if ('why' in page) return page;
62
+ all.push(...page.lobes);
63
+ if (page.next === null || seen.has(page.next)) return all;
64
+ seen.add(page.next);
65
+ cursor = page.next;
66
+ }
67
+ };
68
+
69
+ export const lobeResource = ({ id, blueprint } ) => ({ ...lobeLink(id), title: `${blueprint}, ${id}` });
70
+
71
+ export const lobeLink = (id ) => ({
72
+ type: 'resource_link',
73
+ uri: `nervur://lobe/${id}`,
74
+ name: id,
75
+ description: `the lobe ${id}`,
76
+ mimeType: JSON_TYPE,
77
+ });
78
+
79
+ const found = (uri , mimeType , text ) => ({ contents: [{ uri, mimeType, text }] });
80
+
81
+ const answered = async (
82
+ type ,
83
+ uri ,
84
+ words ,
85
+ take ,
86
+ ) => {
87
+ const heard = await type(words);
88
+ if ('why' in heard) return { code: -32603, why: heard.why };
89
+ if ('error' in heard.answer)
90
+ return { code: -32603, why: `${heard.answer.error.code}: ${heard.answer.error.message}` };
91
+ const read = take(heard.answer.result);
92
+ return typeof read === 'string' ? found(uri, MARKDOWN, read) : found(uri, JSON_TYPE, dataText(read));
93
+ };
94
+
95
+ const SEGMENT = /^[A-Za-z0-9-]{1,64}$/u;
96
+
97
+ export const readOf = async ({ type } , uri ) => {
98
+ if (uri === 'nervur://portrait') return answered(type, uri, ['ask', 'brain', 'portrait'], (result) => result);
99
+ if (uri === 'nervur://guide')
100
+ return answered(type, uri, ['ask', 'brain', 'portrait'], (result) =>
101
+ isFields(result) && typeof result['guide'] === 'string' ? result['guide'] : null,
102
+ );
103
+ if (uri === 'nervur://state') return answered(type, uri, ['ask', 'brain', 'state'], (result) => result);
104
+ const [, kind, name] = /^nervur:\/\/(node|lobe)\/(.+)$/u.exec(uri) ?? [];
105
+ if (name !== undefined && SEGMENT.test(name))
106
+ return answered(type, uri, kind === 'node' ? ['ask', name] : ['lobe', name], (result) => result);
107
+ return { code: -32602, why: `no resource ${uri}` };
108
+ };
@@ -0,0 +1,19 @@
1
+ import { type Data } from '@nervur.org/genome/standard';
2
+ import type { Watch } from '../../../organs/console/node/index.js';
3
+ import { type Calling } from './calls.js';
4
+ import { type Lending } from './resources.js';
5
+ export declare const MODERN = "2026-07-28";
6
+ export declare const LEGACY = "2025-11-25";
7
+ export declare const TASKS = "io.modelcontextprotocol/tasks";
8
+ export type Gear = Lending & Calling & {
9
+ readonly watch: Watch;
10
+ readonly send: (message: Data) => void;
11
+ readonly note: (line: string) => void;
12
+ };
13
+ type Server = {
14
+ readonly answer: (message: Data) => Promise<Data | null>;
15
+ readonly settled: () => Promise<void>;
16
+ readonly close: () => Promise<void>;
17
+ };
18
+ export declare const serverOf: (gear: Gear) => Server;
19
+ export {};
@@ -0,0 +1,149 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { dataText, isFields, } from '@nervur.org/genome/standard';
3
+
4
+ import { INSTALLER_VERSION } from '../../version/index.js';
5
+ import { Calls, } from './calls.js';
6
+ import { Notices } from './notices.js';
7
+ import { lobeResource, lobesOf, readOf, RESOURCES, TEMPLATES, } from './resources.js';
8
+ import { heldOf, toolsOf, } from './tools.js';
9
+
10
+ export const MODERN = '2026-07-28';
11
+ export const LEGACY = '2025-11-25';
12
+
13
+ const VERSION = 'io.modelcontextprotocol/protocolVersion';
14
+ const CLIENT = 'io.modelcontextprotocol/clientCapabilities';
15
+ export const TASKS = 'io.modelcontextprotocol/tasks';
16
+ const SERVER = { name: 'nervur', version: INSTALLER_VERSION };
17
+ const LEGACY_CAPABILITIES = { tools: { listChanged: true }, resources: { listChanged: true } };
18
+ const CAPABILITIES = { ...LEGACY_CAPABILITIES, extensions: { [TASKS]: {} } };
19
+ const LISTED = { ttlMs: 30_000, cacheScope: 'private' };
20
+ const FRESH = { ttlMs: 0, cacheScope: 'private' };
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+ const fieldOf = (data , field ) => (isFields(data) ? data[field] : undefined);
30
+
31
+ const instructionsOf = (heard ) => {
32
+ if ('why' in heard) return `The organism gave no portrait: ${heard.why}`;
33
+ if (!('result' in heard.answer) || !isFields(heard.answer.result)) return heard.text;
34
+ const { guide, ...rest } = heard.answer.result;
35
+ return typeof guide === 'string' ? `${guide}\n\n## This organism\n\n${dataText(rest)}\n` : heard.text;
36
+ };
37
+ const portraitOf = async (type ) => instructionsOf(await type(['ask', 'brain', 'portrait']));
38
+
39
+ const clientOf = (params ) => ({
40
+ tasks: isFields(fieldOf(fieldOf(fieldOf(fieldOf(params, '_meta'), CLIENT), 'extensions'), TASKS)),
41
+ });
42
+
43
+
44
+
45
+
46
+ const complete = (result ) => ({ resultType: 'complete', result });
47
+
48
+ const calledOf = async (calls , method , params ) => {
49
+ if (method === 'tools/call') {
50
+ const called = await calls.call(params, clientOf(params));
51
+ if ('invalid' in called) return { code: -32602, why: called.invalid };
52
+ return 'task' in called ? { resultType: 'task', result: called.task } : complete(called.called);
53
+ }
54
+ if (method === 'tasks/get') {
55
+ const read = await calls.task(params['taskId']);
56
+ return 'invalid' in read ? { code: -32602, why: read.invalid } : complete(read.task);
57
+ }
58
+ if (method === 'tasks/update') return { code: -32602, why: 'a task of a job asks for no input' };
59
+ return { code: -32602, why: 'a job is stopped by its node’s own method, never by its task' };
60
+ };
61
+
62
+ const listedOf = async (type , cursor ) => {
63
+ if (cursor !== undefined && typeof cursor !== 'string') return { code: -32602, why: 'a cursor is a text' };
64
+ const page = await lobesOf(type, cursor ?? null);
65
+ if ('why' in page) return { code: -32603, why: `the lobes read not: ${page.why}` };
66
+ return complete({
67
+ resources: [...(cursor === undefined ? RESOURCES : []), ...page.lobes.map(lobeResource)],
68
+ ...(page.next === null ? {} : { nextCursor: page.next }),
69
+ ...LISTED,
70
+ });
71
+ };
72
+
73
+ const servedOf = async (gear , calls , method , params ) => {
74
+ if (method === 'server/discover')
75
+ return complete({
76
+ supportedVersions: [MODERN],
77
+ capabilities: CAPABILITIES,
78
+ instructions: await portraitOf(gear.type),
79
+ ...FRESH,
80
+ });
81
+ if (method === 'tools/list') {
82
+ const held = await heldOf(gear.type, gear.note);
83
+ if ('why' in held) return { code: -32603, why: `the tools read not: ${held.why}` };
84
+ return complete({ tools: toolsOf(held), ...LISTED });
85
+ }
86
+ if (method === 'tools/call' || method === 'tasks/get' || method === 'tasks/update' || method === 'tasks/cancel')
87
+ return calledOf(calls, method, params);
88
+ if (method === 'resources/list') return listedOf(gear.type, params['cursor']);
89
+ if (method === 'resources/templates/list') return complete({ resourceTemplates: TEMPLATES, ...LISTED });
90
+ if (method === 'resources/read') {
91
+ const uri = params['uri'];
92
+ const read = typeof uri === 'string' ? await readOf(gear, uri) : { code: -32602, why: 'a read names its uri' };
93
+ return 'code' in read ? { ...read, data: { uri: uri ?? null } } : complete({ ...read, ...FRESH });
94
+ }
95
+ return { code: -32601, why: `no method ${dataText(method ?? null)}` };
96
+ };
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+ export const serverOf = (gear ) => {
105
+ let legacy = false;
106
+ const calls = new Calls(gear);
107
+ const notices = new Notices({ ...gear, tasks: calls, server: SERVER });
108
+ return {
109
+ settled: () => notices.settled(),
110
+ close: () => notices.close(),
111
+ answer: async (message) => {
112
+ notices.heard();
113
+ const [id, method, params] = ['id', 'method', 'params'].map((field) => fieldOf(message, field));
114
+ if (method === 'notifications/cancelled') await notices.cancelled(fieldOf(params, 'requestId'));
115
+ if (id === undefined) return null;
116
+ const reply = (result ) => ({ jsonrpc: '2.0', id, result });
117
+ const fault = (code , why , data ) => ({
118
+ jsonrpc: '2.0',
119
+ id,
120
+ error: { code, message: why, ...(data === undefined ? {} : { data }) },
121
+ });
122
+ if (method === 'initialize') {
123
+ legacy = true;
124
+ void notices.opened();
125
+ return reply({
126
+ protocolVersion: LEGACY,
127
+ capabilities: LEGACY_CAPABILITIES,
128
+ serverInfo: SERVER,
129
+ instructions: await portraitOf(gear.type),
130
+ });
131
+ }
132
+ const asked = fieldOf(fieldOf(params, '_meta'), VERSION);
133
+ if (asked === undefined ? !legacy : asked !== MODERN)
134
+ return fault(-32022, 'Unsupported protocol version', { supported: [MODERN], requested: asked ?? null });
135
+ if (method === 'ping' && asked === undefined) return reply({});
136
+ if (method === 'subscriptions/listen' && (typeof id === 'string' || typeof id === 'number')) {
137
+ await notices.listen(id, fieldOf(params, 'notifications'));
138
+ return null;
139
+ }
140
+ const served = await servedOf(gear, calls, method, isFields(params) ? params : {});
141
+ if ('code' in served) return fault(served.code, served.why, served.data);
142
+ return reply({
143
+ resultType: served.resultType,
144
+ ...served.result,
145
+ _meta: { 'io.modelcontextprotocol/serverInfo': SERVER },
146
+ });
147
+ },
148
+ };
149
+ };
@@ -0,0 +1,39 @@
1
+ import { type Data, type Fields } from '@nervur.org/genome/standard';
2
+ import type { Heard } from '../../../organs/console/node/index.js';
3
+ export type Typed = (words: readonly string[]) => Promise<Heard | {
4
+ readonly why: string;
5
+ }>;
6
+ export type Held = {
7
+ readonly placeholder: string;
8
+ readonly far: boolean;
9
+ readonly describe: Data;
10
+ };
11
+ export type Tool = {
12
+ readonly name: string;
13
+ readonly title?: string;
14
+ readonly description: string;
15
+ readonly inputSchema: Fields;
16
+ readonly outputSchema?: Fields;
17
+ readonly annotations: {
18
+ readonly readOnlyHint: boolean;
19
+ readonly destructiveHint: boolean;
20
+ readonly openWorldHint: boolean;
21
+ };
22
+ };
23
+ export declare const methodsOf: (describe: Data) => readonly (readonly [string, Fields])[];
24
+ export declare const toolOf: (held: Held, name: string, method: Fields) => Tool | null;
25
+ export declare const toolsOf: (held: readonly Held[]) => readonly Tool[];
26
+ export type Kept = Map<string, {
27
+ readonly describe: Data;
28
+ } | null>;
29
+ export declare const heldOf: (type: Typed, note: (line: string) => void, kept?: Kept) => Promise<readonly Held[] | {
30
+ readonly why: string;
31
+ }>;
32
+ export type Call = {
33
+ readonly placeholder: string;
34
+ readonly method: string;
35
+ readonly args: Fields;
36
+ };
37
+ export declare const callOf: (name: Data | undefined, args: Data | undefined) => Call | {
38
+ readonly why: string;
39
+ };
@@ -0,0 +1,131 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { dataText, isFields, } from '@nervur.org/genome/standard';
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+ const NO_ARGS = { type: 'object', properties: {}, additionalProperties: false };
23
+
24
+ const textOf = (data ) => (typeof data === 'string' ? data : undefined);
25
+
26
+ const resultOf = (heard ) =>
27
+ 'answer' in heard && 'result' in heard.answer ? heard.answer.result : undefined;
28
+ const whyOf = (heard ) =>
29
+ 'why' in heard ? heard.why : dataText(heard.answer);
30
+
31
+ export const methodsOf = (describe ) => {
32
+ if (!isFields(describe)) return [];
33
+ const { methods, asks } = describe;
34
+ const named = isFields(methods)
35
+ ? Object.entries(methods).flatMap(([name, method]) => (isFields(method) ? [[name, method] ] : []))
36
+ : Array.isArray(asks)
37
+ ? asks.flatMap((one) => {
38
+ const name = isFields(one) ? textOf(one['method']) : undefined;
39
+ return name === undefined || !isFields(one) ? [] : [[name, one] ];
40
+ })
41
+ : [];
42
+ return named.toSorted(([one], [other]) => (one < other ? -1 : one > other ? 1 : 0));
43
+ };
44
+
45
+ const titleOf = (method ) => {
46
+ const seat = method['seat'];
47
+ const label = isFields(seat) ? seat['label'] : undefined;
48
+ return isFields(label)
49
+ ? Object.values(label)
50
+ .map(textOf)
51
+ .find((one) => one !== undefined)
52
+ : undefined;
53
+ };
54
+
55
+ export const toolOf = (held , name , method ) => {
56
+ if (method['askers'] !== undefined) return null;
57
+ const destructive = method['irreversible'] !== undefined || (held.placeholder === 'brain' && name === 'ask');
58
+ const title = titleOf(method);
59
+ const args = method['args'];
60
+ const result = method['result'];
61
+ return {
62
+ name: `${held.placeholder}.${name}`,
63
+ ...(title === undefined ? {} : { title }),
64
+ description: textOf(method['description']) ?? `${name}, of ${held.placeholder}.`,
65
+ inputSchema: isFields(args) ? args : NO_ARGS,
66
+ ...(isFields(result) && result['type'] === 'object' ? { outputSchema: result } : {}),
67
+ annotations: {
68
+ readOnlyHint: method['kind'] === 'reading' && !destructive,
69
+ destructiveHint: destructive,
70
+ openWorldHint: held.far,
71
+ },
72
+ };
73
+ };
74
+
75
+ export const toolsOf = (held ) =>
76
+ held.flatMap((one) =>
77
+ methodsOf(one.describe).flatMap(([name, method]) => {
78
+ const tool = toolOf(one, name, method);
79
+ return tool === null ? [] : [tool];
80
+ }),
81
+ );
82
+
83
+
84
+
85
+ export const heldOf = async (
86
+ type ,
87
+ note ,
88
+ kept ,
89
+ ) => {
90
+ const heard = await type(['relations']);
91
+ const relations = resultOf(heard);
92
+ if (!Array.isArray(relations)) return { why: `the relations read not: ${whyOf(heard)}` };
93
+ const accepted = relations
94
+ .flatMap((one) => {
95
+ const placeholder = isFields(one) ? textOf(one['placeholder']) : undefined;
96
+ const far = isFields(one) ? (textOf(one['far']) ?? '') : '';
97
+ return placeholder === undefined ? [] : [{ placeholder, key: `${placeholder} ${far}` }];
98
+ })
99
+ .toSorted((one, other) => (one.placeholder < other.placeholder ? -1 : one.placeholder > other.placeholder ? 1 : 0));
100
+ const brain = await type(['ask', 'brain']);
101
+ const describe = resultOf(brain);
102
+ if (describe === undefined) return { why: `the brain gave no describe: ${whyOf(brain)}` };
103
+ const found = await Promise.all(
104
+ accepted.map(async ({ placeholder, key }) => {
105
+ const known = kept?.get(key);
106
+ if (known !== undefined) return { placeholder, key, read: known };
107
+ const asked = await type(['ask', placeholder]);
108
+ const far = resultOf(asked);
109
+ if (far === undefined) note(`nervur mcp: ${placeholder} gave no describe: ${whyOf(asked)}`);
110
+ return { placeholder, key, read: far === undefined ? null : { describe: far } };
111
+ }),
112
+ );
113
+ kept?.clear();
114
+ for (const { key, read } of found) kept?.set(key, read);
115
+ return [
116
+ { placeholder: 'brain', far: false, describe },
117
+ ...found.flatMap(({ placeholder, read }) =>
118
+ read === null ? [] : [{ placeholder, far: true, describe: read.describe }],
119
+ ),
120
+ ];
121
+ };
122
+
123
+
124
+
125
+ export const callOf = (name , args ) => {
126
+ const named = textOf(name);
127
+ const at = named?.indexOf('.') ?? -1;
128
+ if (named === undefined || at < 1 || at === named.length - 1) return { why: `no tool ${dataText(name ?? null)}` };
129
+ if (args !== undefined && !isFields(args)) return { why: `the arguments of ${named} are no object` };
130
+ return { placeholder: named.slice(0, at), method: named.slice(at + 1), args: args ?? {} };
131
+ };
@@ -0,0 +1,8 @@
1
+ import { type Data } from '@nervur.org/genome/standard';
2
+ import { type Given, type Outcome } from './given.js';
3
+ export declare const serverAt: (organism: string, send: (message: Data) => void, note: (line: string) => void) => {
4
+ readonly answer: (message: Data) => Promise<Data | null>;
5
+ readonly settled: () => Promise<void>;
6
+ readonly close: () => Promise<void>;
7
+ };
8
+ export declare const mcp: ({ home }: Given) => Promise<Outcome>;
@@ -0,0 +1,39 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { createInterface } from 'node:readline';
3
+ import { dataText, readText, } from '@nervur.org/genome/standard';
4
+ import { socketOf, typeLine, watchConsole } from '../../organs/console/node/index.js';
5
+ import { organismOf, } from './given.js';
6
+ import { serverOf } from './mcp/server.js';
7
+ import { runningOf } from './spawn.js';
8
+ import { LONGEST_TIMEOUT } from '../door/longest.js';
9
+
10
+ export const serverAt = (organism , send , note ) =>
11
+ serverOf({
12
+ type: (words) => typeLine(socketOf(organism), words, LONGEST_TIMEOUT),
13
+ now: Date.now,
14
+ watch: (changed, ended) => watchConsole(socketOf(organism), LONGEST_TIMEOUT, changed, ended),
15
+ send,
16
+ note,
17
+ });
18
+
19
+ export const mcp = async ({ home } ) => {
20
+ const organism = organismOf(home);
21
+ if (runningOf(organism) === null) return { why: 'the organism is not running' };
22
+ const server = serverAt(
23
+ organism,
24
+ (message) => void process.stdout.write(`${dataText(message)}\n`),
25
+ (line) => void process.stderr.write(`${line}\n`),
26
+ );
27
+ const lines = createInterface({ input: process.stdin, crlfDelay: Infinity });
28
+ for await (const line of lines) {
29
+ if (line.trim() === '') continue;
30
+ const read = readText(line);
31
+ const answer =
32
+ 'why' in read
33
+ ? { jsonrpc: '2.0', id: null, error: { code: -32700, message: read.why } }
34
+ : await server.answer(read.data);
35
+ if (answer !== null) process.stdout.write(`${dataText(answer)}\n`);
36
+ }
37
+ await server.close();
38
+ return null;
39
+ };
@@ -0,0 +1,11 @@
1
+ import { type Moved, type Watch } from '../../organs/console/node/index.js';
2
+ type Why = {
3
+ readonly why: string;
4
+ };
5
+ export type Telling = {
6
+ readonly watch: Watch;
7
+ readonly after: (ms: number, ring: () => void) => () => void;
8
+ };
9
+ export declare const tellingAt: (home: string) => Telling;
10
+ export declare const toldWithin: <Value extends object>(telling: Telling, within: number, names: (moved: Moved) => boolean, look: () => Promise<Value | null>) => Promise<Value | Why | null>;
11
+ export {};
@@ -0,0 +1,55 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { socketOf, watchConsole, } from '../../organs/console/node/index.js';
3
+ import { LONGEST_TIMEOUT } from '../door/longest.js';
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ export const tellingAt = (home ) => ({
13
+ watch: (moved, ended) => watchConsole(socketOf(home), LONGEST_TIMEOUT, moved, ended),
14
+ after: (ms, ring) => {
15
+ const timer = setTimeout(ring, ms);
16
+ return () => clearTimeout(timer);
17
+ },
18
+ });
19
+
20
+ export const toldWithin = async (
21
+ telling ,
22
+ within ,
23
+ names ,
24
+ look ,
25
+ ) => {
26
+ let wake = Promise.withResolvers ();
27
+ let [ended, past] = [false, false];
28
+ const watching = await telling.watch(
29
+ (moved) => {
30
+ if (names(moved)) wake.resolve();
31
+ },
32
+ () => {
33
+ ended = true;
34
+ wake.resolve();
35
+ },
36
+ );
37
+ if ('why' in watching) return watching;
38
+ const calledOff = telling.after(within, () => {
39
+ past = true;
40
+ wake.resolve();
41
+ });
42
+ try {
43
+ for (;;) {
44
+ wake = Promise.withResolvers();
45
+ const value = await look();
46
+ if (value !== null) return value;
47
+ if (ended) return { why: "the console's watch ended" };
48
+ if (past) return null;
49
+ await wake.promise;
50
+ }
51
+ } finally {
52
+ calledOff();
53
+ watching.close();
54
+ }
55
+ };
@@ -0,0 +1,11 @@
1
+ type Why = {
2
+ readonly why: string;
3
+ };
4
+ export type Sealing = (home: string, args: {
5
+ readonly to: string;
6
+ readonly file: string;
7
+ readonly genome: string;
8
+ }) => Promise<null | Why>;
9
+ export declare const sealAt: Sealing;
10
+ export declare const sealedBack: (home: string, genome: string, seal?: Sealing) => Promise<string | Why>;
11
+ export {};
@@ -0,0 +1,45 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { randomBytes } from 'node:crypto';
3
+ import { rmSync, writeFileSync } from 'node:fs';
4
+ import { join } from 'node:path';
5
+ import { namedKeyOf } from '@nervur.org/genome';
6
+ import { nobleCrypto } from '@nervur.org/genome/quo';
7
+ import { dataText, hex } from '@nervur.org/genome/standard';
8
+ import { typeLine } from '../../organs/console/node/index.js';
9
+ import { LONGEST_TIMEOUT, LONGEST_WAIT } from '../door/longest.js';
10
+ import { actOf } from '../organism/act.js';
11
+ import { stoppedOf } from '../organism/folder.js';
12
+ import { arrivalIn, beforeOf, sealing, storeAside } from './before.js';
13
+ import { runningOf } from './spawn.js';
14
+ import { stopped } from './start.js';
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+ export const sealAt = async (home, args) => {
24
+ const heard = await typeLine(actOf(home), ['seal', dataText({ ...args })], LONGEST_TIMEOUT, LONGEST_WAIT);
25
+ if ('why' in heard) return { why: `the organism hears no move at ${actOf(home)}: ${heard.why}` };
26
+ return 'error' in heard.answer ? { why: heard.answer.error.message } : null;
27
+ };
28
+
29
+ export const sealedBack = async (home , genome , seal = sealAt) => {
30
+ const secret = randomBytes(32);
31
+ writeFileSync(arrivalIn(home), secret, { mode: 0o600 });
32
+ const file = join(beforeOf(home), 'moved.backup');
33
+ sealing(home);
34
+ const why = await seal(home, { to: hex(namedKeyOf(nobleCrypto, secret)), file, genome });
35
+ if (why !== null) {
36
+ rmSync(arrivalIn(home), { force: true });
37
+ return why;
38
+ }
39
+ const running = runningOf(home);
40
+ const down = running === null ? null : await stopped(home, running);
41
+ if (down !== null) return down;
42
+ rmSync(stoppedOf(home), { force: true });
43
+ storeAside(home);
44
+ return file;
45
+ };
@@ -0,0 +1,24 @@
1
+ import { type Given, type Outcome } from './given.js';
2
+ type Why = {
3
+ readonly why: string;
4
+ };
5
+ export type Reaches = {
6
+ readonly screen: () => Promise<{
7
+ readonly address: string;
8
+ } | Why>;
9
+ readonly show: (address: string) => Promise<string | null>;
10
+ readonly write: (file: string, text: string) => void;
11
+ };
12
+ export declare const openerOf: (platform: NodeJS.Platform) => readonly string[] | null;
13
+ export declare const screenIn: (home: string) => Promise<{
14
+ readonly address: string;
15
+ } | Why>;
16
+ export declare const reachesOf: (home: string) => Reaches;
17
+ export declare const notTaken: (why: string) => string;
18
+ export declare const openLink: (link: string | undefined, home: string, reaches: Reaches) => Promise<{
19
+ readonly opened: string;
20
+ } | {
21
+ readonly told: string;
22
+ } | Why>;
23
+ export declare const open: (given: Given, reaches?: Reaches) => Promise<Outcome>;
24
+ export {};