memhouse 0.18.12 → 0.20.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 (169) hide show
  1. package/AGENTS.md +22 -151
  2. package/CHANGELOG.md +263 -29
  3. package/LICENSE +202 -22
  4. package/LICENSES/agentlytics-MIT.txt +21 -0
  5. package/LICENSES/memhouse-MIT-until-0.18.11.txt +22 -0
  6. package/LICENSES/models.dev-MIT.txt +22 -0
  7. package/NOTICE +28 -0
  8. package/README.md +42 -20
  9. package/SECURITY.md +21 -8
  10. package/bin/memhouse.js +2223 -311
  11. package/docs/README.md +11 -9
  12. package/docs/guides/admin-password.md +37 -10
  13. package/docs/guides/configuration.md +13 -6
  14. package/docs/guides/daemons.md +64 -3
  15. package/docs/guides/import-claude-ai.md +204 -0
  16. package/docs/guides/install.md +11 -6
  17. package/docs/guides/invite.md +21 -7
  18. package/docs/guides/operate.md +114 -7
  19. package/docs/guides/search-and-resume.md +72 -3
  20. package/docs/guides/share.md +91 -52
  21. package/docs/guides/storage.md +44 -4
  22. package/docs/guides/troubleshooting.md +121 -14
  23. package/docs/guides/uninstall.md +4 -3
  24. package/docs/guides/update.md +16 -0
  25. package/docs/guides/upgrade-to-0.20.md +188 -0
  26. package/docs/releases/README.md +2 -1
  27. package/docs/releases/v0.18.10.md +5 -5
  28. package/docs/releases/v0.18.11.md +3 -3
  29. package/docs/releases/v0.20.0.md +627 -0
  30. package/docs/releases/v0.20.1.md +114 -0
  31. package/docs/tutorials/01-first-house.md +10 -7
  32. package/docs/tutorials/02-join-a-house.md +24 -15
  33. package/docs/tutorials/03-share-your-memory.md +40 -31
  34. package/editors/antigravity.js +1 -80
  35. package/editors/base.js +463 -9
  36. package/editors/bridge.js +119 -0
  37. package/editors/claude.js +273 -105
  38. package/editors/codex.js +278 -52
  39. package/editors/copilot.js +1 -70
  40. package/editors/cursor.js +1 -75
  41. package/editors/derive-fingerprints.json +18 -0
  42. package/editors/harness-paths.js +69 -0
  43. package/editors/index.js +1 -20
  44. package/editors/normalise/agy.js +910 -0
  45. package/editors/normalise/copilot-cli.js +321 -0
  46. package/editors/normalise/cursor-agent.js +852 -0
  47. package/editors/normalise/cursor.js +474 -0
  48. package/editors/normalise/devin.js +575 -0
  49. package/editors/normalise/gemini-cli.js +602 -0
  50. package/editors/normalise/goose.js +673 -0
  51. package/editors/normalise/opencode.js +633 -0
  52. package/editors/normalise/vscode.js +549 -0
  53. package/editors/normalise/zed.js +473 -0
  54. package/editors/opencode-v4.js +119 -0
  55. package/editors/scope.js +14 -3
  56. package/editors/sessions-log.js +349 -0
  57. package/editors/sqlite.js +28 -1
  58. package/editors/vscode.js +1 -72
  59. package/editors/windsurf.js +1 -143
  60. package/examples/01-local-one-machine/README.md +24 -19
  61. package/examples/01-local-one-machine/run.sh +1 -1
  62. package/examples/02-existing-clickhouse/README.md +30 -22
  63. package/examples/02-existing-clickhouse/run.sh +5 -4
  64. package/examples/03-team-house/README.md +44 -37
  65. package/examples/03-team-house/run.sh +35 -18
  66. package/examples/04-self-hosted-team/README.md +29 -14
  67. package/examples/04-self-hosted-team/compose.yml +5 -2
  68. package/examples/04-self-hosted-team/smoke.sh +26 -12
  69. package/examples/README.md +8 -4
  70. package/examples/fixtures/README.md +4 -1
  71. package/examples/fixtures/make-sessions.js +8 -5
  72. package/memhouse/admin-secret.js +89 -24
  73. package/memhouse/argv-secrets.js +64 -0
  74. package/memhouse/channel.js +49 -9
  75. package/memhouse/codex-plugin.js +194 -0
  76. package/memhouse/delivery/AGENT-INSTALL-PROMPT.md +2 -1
  77. package/memhouse/delivery/AGENT-INSTALL.md +22 -11
  78. package/memhouse/delivery/INVITATION.md.tpl +44 -45
  79. package/memhouse/delivery/PROMPT.md +53 -5
  80. package/memhouse/delivery/UPGRADE.md.tpl +1 -1
  81. package/memhouse/delivery/codex/AGENTS-BLOCK.md +11 -0
  82. package/memhouse/delivery/codex/SKILL.md +50 -0
  83. package/memhouse/delivery/kernel-install.md +17 -9
  84. package/memhouse/delivery/plugin/.claude-plugin/plugin.json +2 -2
  85. package/memhouse/delivery/plugin/reference/HOUSE.md +168 -41
  86. package/memhouse/delivery/plugin/skills/access/SKILL.md +13 -5
  87. package/memhouse/delivery/plugin/skills/admin/SKILL.md +14 -6
  88. package/memhouse/delivery/plugin/skills/house/SKILL.md +25 -8
  89. package/memhouse/delivery/plugin/skills/recall/SKILL.md +66 -8
  90. package/memhouse/delivery/plugin/skills/sql/SKILL.md +66 -7
  91. package/memhouse/deploy.js +1 -1
  92. package/memhouse/flags.js +35 -18
  93. package/memhouse/help.js +37 -0
  94. package/memhouse/host.js +82 -2
  95. package/memhouse/house/HOUSE.md +2 -2
  96. package/memhouse/house/convert-profile.js +638 -0
  97. package/memhouse/house/convert-v3.js +742 -0
  98. package/memhouse/house/doctor-v3.js +324 -0
  99. package/memhouse/house/host-alias.js +85 -0
  100. package/memhouse/house/house.js +3 -3
  101. package/memhouse/house/migrate.js +2 -2
  102. package/memhouse/house/profile-dedupe.js +183 -0
  103. package/memhouse/house/profile-edges.js +554 -0
  104. package/memhouse/house/profile-house.js +430 -0
  105. package/memhouse/house/profile-rollup.js +190 -0
  106. package/memhouse/house/q-cli.js +863 -0
  107. package/memhouse/house/queries-v3.js +1013 -0
  108. package/memhouse/house/reconcile-v3.js +192 -0
  109. package/memhouse/house/records-to-profile.js +174 -0
  110. package/memhouse/house/records-to-rows.js +169 -0
  111. package/memhouse/house/relocate.js +2 -1
  112. package/memhouse/house/schema-choice.js +121 -0
  113. package/memhouse/house/schema-profile.js +290 -0
  114. package/memhouse/house/schema-profile.sql.tpl +398 -0
  115. package/memhouse/house/schema-v3.js +267 -0
  116. package/memhouse/house/schema-v3.sql.tpl +213 -0
  117. package/memhouse/import/claude-ai.js +420 -0
  118. package/memhouse/import/import.js +372 -0
  119. package/memhouse/import/pyjson.js +206 -0
  120. package/memhouse/import/records.js +64 -0
  121. package/memhouse/import/writer-profile.js +192 -0
  122. package/memhouse/import/writer-v3.js +240 -0
  123. package/memhouse/import/zip.js +112 -0
  124. package/memhouse/invitation.js +102 -0
  125. package/memhouse/invitefile.js +5 -2
  126. package/memhouse/plugin-copies.js +176 -0
  127. package/memhouse/provision.js +7 -2
  128. package/memhouse/release-hint.js +24 -0
  129. package/memhouse/resume.js +4 -4
  130. package/memhouse/server/api-v3.js +632 -0
  131. package/memhouse/server/dashboard-auth.js +181 -0
  132. package/memhouse/server/dashboard-port.js +91 -0
  133. package/memhouse/server/queries.js +30 -0
  134. package/memhouse/server/server.js +118 -20
  135. package/memhouse/service.js +1 -1
  136. package/memhouse/share.js +687 -1
  137. package/memhouse/shipper/adapter-capture.js +756 -0
  138. package/memhouse/shipper/capture.js +2571 -0
  139. package/memhouse/shipper/dedupe-profile.js +237 -0
  140. package/memhouse/shipper/dedupe-v3.js +1027 -0
  141. package/memhouse/shipper/forks.js +233 -0
  142. package/memhouse/shipper/log-adapter.js +219 -0
  143. package/memhouse/shipper/maintenance.js +49 -0
  144. package/memhouse/shipper/normalise-run.js +148 -0
  145. package/memhouse/shipper/passlog.js +68 -5
  146. package/memhouse/shipper/profile-capture.js +903 -0
  147. package/memhouse/shipper/ship.js +91 -8
  148. package/memhouse/shipper/snapshots.js +193 -0
  149. package/memhouse/shipper/source-roots.js +111 -0
  150. package/memhouse/version-notice.js +66 -0
  151. package/package.json +14 -7
  152. package/public/THIRD_PARTY_NOTICES.txt +2 -2
  153. package/public/assets/index-CcNnhfM3.js +78 -0
  154. package/public/index.html +1 -1
  155. package/ui/package-lock.json +56 -37
  156. package/ui/package.json +1 -0
  157. package/ui/src/App.jsx +29 -14
  158. package/ui/src/components/ChatSidebar.jsx +69 -12
  159. package/ui/src/lib/api.js +76 -0
  160. package/ui/src/lib/dashboard-token.js +41 -0
  161. package/ui/src/main.jsx +22 -5
  162. package/ui/src/pages/Dashboard.jsx +22 -36
  163. package/ui/third-party-notices.js +119 -0
  164. package/ui/vite.config.js +5 -1
  165. package/docs/releases/v0.18.12.md +0 -59
  166. package/memhouse/COMPETITION.md +0 -221
  167. package/memhouse/DESIGN.md +0 -222
  168. package/memhouse/RESUME-AND-UPDATE.md +0 -182
  169. package/public/assets/index-CnWzrjF3.js +0 -78
package/memhouse/flags.js CHANGED
@@ -12,28 +12,43 @@
12
12
 
13
13
  const GLOBAL_FLAGS = ['json', 'yes', 'help', 'version'];
14
14
 
15
+ // Flags the CLI recognises only to refuse them, before any command runs, with a message that
16
+ // says what to do instead. --admin-password put an admin password in `ps` and shell history;
17
+ // it was deprecated in 0.18.10 and removed in 0.20.0 (bin/memhouse.js, memhouse/admin-secret.js).
18
+ const REFUSED_FLAGS = ['admin-password'];
19
+
15
20
  const COMMAND_FLAGS = {
16
21
  null: [], help: [], version: [],
17
22
  whoami: ['admin'],
18
23
  share: ['only', 'revoke', 'list'],
19
- discover: [], stats: [], stop: [], doctor: [], 'sessions-query': [], rooms: [], instance: [], members: ['db','admin-user','admin-password','admin-password-file'], convert: ['url','db','admin-user','admin-password','admin-password-file','member','print-sql','dry-run','guides','out'],
20
- status: ['all'], start: [],
21
- onboard: ['url', 'user', 'password', 'db', 'port', 'no-ship', 'target', 'house-port', 'tag', 'local'],
22
- install: ['url', 'user', 'password', 'db', 'port', 'no-ship', 'env', 'print-sql', 'member',
23
- 'member-password', 'admin-user', 'admin-password', 'admin-password-file', 'keep-admin', 'ensure-schema', 'rotate-password', 'force',
24
- 'editors', 'claude-roots', 'channel'],
25
- setup: ['url', 'user', 'password', 'db', 'port', 'admin-user', 'admin-password', 'editors', 'claude-roots', 'channel'],
26
- ship: ['full', 'loop', 'ensure-schema'],
27
- search: ['limit'],
28
- resume: [],
24
+ discover: [], stats: [], stop: [], doctor: ['full', 'confirm-empty-store'], 'sessions-query': [], rooms: [], instance: [], members: ['db','admin-user','admin-password-file'], convert: ['url','db','admin-user','admin-password-file','member','print-sql','dry-run','guides','out'],
25
+ status: ['all'], start: [], dashboard: ['no-open'],
26
+ onboard: ['url', 'user', 'password', 'password-file', 'db', 'port', 'no-ship', 'target', 'house-port', 'tag', 'local'],
27
+ install: ['url', 'user', 'password', 'password-file', 'db', 'port', 'no-ship', 'env', 'print-sql', 'member',
28
+ 'member-password', 'member-password-file', 'admin-user', 'admin-password-file', 'keep-admin', 'ensure-schema', 'rotate-password', 'force', 'keep-password',
29
+ 'editors', 'claude-roots', 'channel', 'schema', 'source-roots'],
30
+ setup: ['url', 'user', 'password', 'password-file', 'db', 'port', 'admin-user', 'keep-admin', 'editors', 'claude-roots', 'channel',
31
+ 'schema', 'source-roots'],
32
+ ship: ['full', 'loop', 'ensure-schema', 'v3', 'backfill', 'reconcile', 'no-dedupe', 'duplicates', 'redupe', 'no-bridge', 'cleanup', 'no-cleanup', 'dry-run'],
33
+ search: ['limit', 'harness', 'project', 'folder', 'since', 'until', 'match'],
34
+ resume: ['harness'],
35
+ // Schema 3 (memhouse/house/q-cli.js): every flag any named query takes — q-cli refuses the ones
36
+ // a particular name does not take, with its usage line. Held equal to q-cli's allQFlags() by
37
+ // misc/v3-cli-unit.js.
38
+ q: ['after', 'agent', 'all', 'at', 'before', 'by', 'chars', 'cursor', 'days', 'dims', 'dir', 'exclude-models', 'folder', 'grain',
39
+ 'harness', 'host', 'limit', 'list', 'match', 'member', 'metrics', 'min-messages', 'order', 'project', 'schema',
40
+ 'since', 'sort', 'source', 'tz', 'ts', 'until'],
41
+ 'room-sql': ['member', 'print'],
42
+ import: ['write', 'update', 'batch', 'undo', 'list'],
29
43
  update: ['check', 'migrate', 'no-install', 'channel'],
30
44
  reset: ['all-origins'],
31
- invite: ['url', 'db', 'out', 'admin-user', 'admin-password', 'admin-password-file', 'adopt', 'print-sql',
32
- 'allow-local', 'member-password'],
33
- passwd: ['password', 'admin-user', 'admin-password', 'admin-password-file', 'print-sql', 'member'],
45
+ invite: ['url', 'db', 'out', 'admin-user', 'admin-password-file', 'adopt', 'print-sql',
46
+ 'allow-local', 'member-password', 'member-password-file', 'schema', 'expires'],
47
+ passwd: ['password', 'password-file', 'admin-user', 'admin-password-file', 'print-sql', 'member'],
34
48
  nightly: ['out'],
35
- migrate: ['dry-run'], 'migrate-rooms': ['dry-run'],
36
- relocate: ['to', 'to-user', 'to-password', 'to-db', 'from-native-host', 'from-native-port',
49
+ migrate: ['dry-run', 'v3-prepare', 'v3-convert', 'v3-reconcile', 'v3-shares', 'v3-switch', 'member', 'batch-rows', 'force-after-dedupe',
50
+ 'admin-user', 'admin-password-file'], 'migrate-rooms': ['dry-run'],
51
+ relocate: ['to', 'to-user', 'to-password', 'to-password-file', 'to-db', 'from-native-host', 'from-native-port',
37
52
  'insecure-native', 'keep-shipper', 'dry-run'],
38
53
  deploy: ['local', 'down', 'house-port', 'port', 'tag'],
39
54
  service: ['interval'],
@@ -82,9 +97,11 @@ function allowedFlags(cmd) {
82
97
  // stays a positional.
83
98
  const BOOLEAN_FLAGS = new Set([
84
99
  'json', 'yes', 'help', 'version', 'full', 'check', 'migrate', 'no-install', 'all-origins',
85
- 'dry-run', 'print-sql', 'no-ship', 'keep-admin', 'ensure-schema', 'rotate-password', 'force',
100
+ 'dry-run', 'print-sql', 'no-ship', 'keep-admin', 'ensure-schema', 'rotate-password', 'force', 'keep-password',
86
101
  'adopt', 'allow-local', 'local', 'down', 'credentials', 'full-removal', 'insecure-native',
87
- 'keep-shipper', 'guides', 'revoke', 'list', 'admin', 'install', 'all',
102
+ 'keep-shipper', 'guides', 'revoke', 'list', 'admin', 'install', 'all', 'v3-prepare', 'v3-convert', 'v3-reconcile', 'v3-shares', 'v3-switch', 'force-after-dedupe',
103
+ 'v3', 'backfill', 'reconcile', 'no-dedupe', 'duplicates', 'redupe', 'no-bridge', 'cleanup', 'no-cleanup', 'print', 'exclude-models',
104
+ 'write', 'update', 'no-open',
88
105
  ]);
89
106
 
90
107
  /** argv (after the command) -> { flags, positional }. */
@@ -102,4 +119,4 @@ function parseArgv(rest) {
102
119
  return { flags, positional };
103
120
  }
104
121
 
105
- module.exports = { GLOBAL_FLAGS, COMMAND_FLAGS, BOOLEAN_FLAGS, parseArgv, unknownFlags, allowedFlags, suggestFlag, editDistance };
122
+ module.exports = { GLOBAL_FLAGS, REFUSED_FLAGS, COMMAND_FLAGS, BOOLEAN_FLAGS, parseArgv, unknownFlags, allowedFlags, suggestFlag, editDistance };
@@ -0,0 +1,37 @@
1
+ // `memhouse <command> --help`: that command's entries from the full help (bin/memhouse.js HELP),
2
+ // not the whole page. The full help stays the one text: an entry starts in column 13 (after the
3
+ // section label or 13 spaces), and its continuation lines are indented further. Pure.
4
+
5
+ const COL = 13;
6
+
7
+ /** The entries of `help`: [{ words, lines }], `words` being the command names the entry is for. */
8
+ function entries(help) {
9
+ const out = [];
10
+ let cur = null;
11
+ for (const line of String(help).split('\n')) {
12
+ const m = /^([A-Za-z]*)( +)(\S.*)$/.exec(line);
13
+ if (m && m[1].length + m[2].length === COL) {
14
+ // `start | stop | status …` is one entry for three commands.
15
+ const name = m[3].split(/\s{2,}/)[0];
16
+ const words = /^[a-z][a-z-]*( \| [a-z][a-z-]*)+/.test(name)
17
+ ? name.split(/\s*\|\s*/).map((w) => w.split(/\s+/)[0]).filter(Boolean)
18
+ : [name.split(/\s+/)[0]];
19
+ cur = { words, lines: [`${' '.repeat(COL)}${m[3]}`] };
20
+ out.push(cur);
21
+ } else if (cur && /^ {20,}\S/.test(line)) {
22
+ cur.lines.push(line);
23
+ } else {
24
+ cur = null;
25
+ }
26
+ }
27
+ return out;
28
+ }
29
+
30
+ /** The help for `cmd`, or null when no entry names it (the caller prints the full help). */
31
+ function helpFor(help, cmd, version) {
32
+ const mine = entries(help).filter((e) => e.words.includes(cmd));
33
+ if (!mine.length) return null;
34
+ return [`memhouse ${version} — ${cmd}`, '', ...mine.flatMap((e) => e.lines), '', 'Every command: memhouse --help'].join('\n');
35
+ }
36
+
37
+ module.exports = { entries, helpFor };
package/memhouse/host.js CHANGED
@@ -7,7 +7,7 @@
7
7
  // It used to be derived, `sha256(hostname|platform|arch)`, and that fails in both
8
8
  // directions:
9
9
  //
10
- // * Two machines collide. A pilot with two MacBooks that both answer to
10
+ // * Two machines collide. A user with two MacBooks that both answer to
11
11
  // `MacBook-Pro` on the same darwin/arm64 produce the SAME id — their sessions merge
12
12
  // into one apparent host and neither can be told from the other. Default hostnames
13
13
  // are exactly the case where a person owns several.
@@ -156,4 +156,84 @@ function identity(home = homeDir()) {
156
156
  };
157
157
  }
158
158
 
159
- module.exports = { identity, read, filePath, idFrom, machineFingerprint, stableMachineId, FILE };
159
+ // ── sessions-model/host/v0 ────────────────────────────────────────────────────────────────
160
+ // The machine in a session's key, as every reader on it derives it (sessions-model
161
+ // contracts/sessions-model.md §1): the first 32 lowercase hex digits of
162
+ // sha256("sessions-model/host/v0:" + the OS machine id), the id hashed exactly as the OS stores it
163
+ // (surrounding whitespace stripped, nothing else). Never the hostname. Where no machine id of its
164
+ // OS's form can be read, `r-` + a random id persisted at one fixed path per OS user.
165
+ // memhouse's own `<short>-<fp8>` id (identity().id) stays as this machine's alias for rows
166
+ // written before 0.20: the capture's dedupe accepts it.
167
+ const HOST_SALT = 'sessions-model/host/v0';
168
+ const UUID_RE = /^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/;
169
+
170
+ /** The machine id candidates of this OS, in the contract's order, as raw strings (trimmed). */
171
+ function machineIdCandidates(platform = process.platform, { machineIdFile = '/etc/machine-id' } = {}) {
172
+ const run = (cmd, args) => {
173
+ try { return String(require('child_process').execFileSync(cmd, args, { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'], timeout: 4000 }) || ''); } catch { return ''; }
174
+ };
175
+ if (platform === 'darwin') {
176
+ const m = /"IOPlatformUUID"\s*=\s*"([^"]*)"/.exec(run('/usr/sbin/ioreg', ['-rd1', '-c', 'IOPlatformExpertDevice']));
177
+ return m ? [m[1].trim()] : [];
178
+ }
179
+ if (platform === 'linux') {
180
+ // /etc/machine-id only (sessions-model/host/v0). The D-Bus copy is never read: systemd-machine-id-setup
181
+ // copies an inherited /var/lib/dbus/machine-id into an emptied /etc/machine-id, so on a clone the
182
+ // D-Bus file can hold the source machine's id, and falling back to it would give the clone the
183
+ // source's host. Empty or 'uninitialized' goes to the r- value.
184
+ try { return [fs.readFileSync(machineIdFile, 'utf-8').trim()]; } catch { return []; }
185
+ }
186
+ if (platform === 'win32') {
187
+ // The 64-bit registry view, so a 32-bit reader is not redirected to Wow6432Node.
188
+ const m = /MachineGuid\s+REG_SZ\s+(\S+)/.exec(run('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\Cryptography', '/v', 'MachineGuid', '/reg:64']));
189
+ return m ? [m[1].trim()] : [];
190
+ }
191
+ return [];
192
+ }
193
+
194
+ /** A machine id has its OS's form: Linux exactly 32 lowercase hex digits; macOS and Windows a UUID. */
195
+ function machineIdOk(v, platform = process.platform) {
196
+ if (!v || v === 'uninitialized') return false;
197
+ return platform === 'linux' ? /^[0-9a-f]{32}$/.test(v) : UUID_RE.test(v);
198
+ }
199
+
200
+ /** Where the `r-` id lives: $XDG_STATE_HOME/sessions-model/host-id, %LOCALAPPDATA% on Windows. */
201
+ function hostIdFile({ platform = process.platform, env = process.env, home = os.homedir() } = {}) {
202
+ if (platform === 'win32') return path.join(env.LOCALAPPDATA || path.join(home, 'AppData', 'Local'), 'sessions-model', 'host-id');
203
+ return path.join(env.XDG_STATE_HOME || path.join(home, '.local', 'state'), 'sessions-model', 'host-id');
204
+ }
205
+ function readRandomId(file) {
206
+ try { const v = fs.readFileSync(file, 'utf-8').trim(); return /^[0-9a-f]{32}$/.test(v) ? v : null; } catch { return null; }
207
+ }
208
+ /** The persisted random id: read it, or create it exclusively (a reader that loses the race reads the winner's). */
209
+ function randomHostId(opts = {}) {
210
+ const file = hostIdFile(opts);
211
+ const have = readRandomId(file);
212
+ if (have) return have;
213
+ const v = crypto.randomBytes(16).toString('hex');
214
+ try {
215
+ fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
216
+ fs.writeFileSync(file, v, { flag: 'wx', mode: 0o600 });
217
+ return v;
218
+ } catch (e) {
219
+ const won = readRandomId(file);
220
+ if (won) return won;
221
+ throw new Error(`sessions-model host: no machine id, and ${file} cannot be written (${e.code || e.message})`);
222
+ }
223
+ }
224
+
225
+ /** This machine's `host` (sessions-model/host/v0). `ids` overrides the OS read (tests). */
226
+ function sessionsHost({ platform = process.platform, env = process.env, home = os.homedir(), ids = null, machineIdFile } = {}) {
227
+ for (const v of ids || machineIdCandidates(platform, machineIdFile ? { machineIdFile } : {})) {
228
+ if (machineIdOk(v, platform)) return crypto.createHash('sha256').update(Buffer.from(`${HOST_SALT}:${v}`, 'utf-8')).digest('hex').slice(0, 32);
229
+ }
230
+ return `r-${randomHostId({ platform, env, home })}`;
231
+ }
232
+
233
+ /** The display label beside `host`: the machine's short hostname now. Never part of a key. */
234
+ function hostLabel(hostname = os.hostname()) {
235
+ return (hostname || '').split('.')[0].replace(/[^A-Za-z0-9_-]/g, '') || 'host';
236
+ }
237
+
238
+ module.exports = { identity, read, filePath, idFrom, machineFingerprint, stableMachineId, FILE,
239
+ sessionsHost, hostLabel, hostIdFile, machineIdOk, machineIdCandidates, HOST_SALT };
@@ -34,8 +34,8 @@ ALTER USER alice ADD SETTING async_insert = 0 CONST;
34
34
 
35
35
  `ALL` on your own house reaches nothing outside it, and it is what lets alice's own
36
36
  shipper create and evolve the rooms (`ship.js --ensure-schema`) — no admin has to run
37
- memhouse code. Joining a ClickHouse that happens to run a kernel is the same three
38
- statements: a database and a credential, nothing else.
37
+ memhouse code. Joining a ClickHouse that happens to run a kernel (the Ultimagent kernel,
38
+ not yet public) is the same three statements: a database and a credential, nothing else.
39
39
 
40
40
  **Housemates do not have to trust each other with the house.** They used to: everyone
41
41
  held `ALL` on the database, and the isolation mechanism between parties who should not