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.
- package/AGENTS.md +22 -151
- package/CHANGELOG.md +263 -29
- package/LICENSE +202 -22
- package/LICENSES/agentlytics-MIT.txt +21 -0
- package/LICENSES/memhouse-MIT-until-0.18.11.txt +22 -0
- package/LICENSES/models.dev-MIT.txt +22 -0
- package/NOTICE +28 -0
- package/README.md +42 -20
- package/SECURITY.md +21 -8
- package/bin/memhouse.js +2223 -311
- package/docs/README.md +11 -9
- package/docs/guides/admin-password.md +37 -10
- package/docs/guides/configuration.md +13 -6
- package/docs/guides/daemons.md +64 -3
- package/docs/guides/import-claude-ai.md +204 -0
- package/docs/guides/install.md +11 -6
- package/docs/guides/invite.md +21 -7
- package/docs/guides/operate.md +114 -7
- package/docs/guides/search-and-resume.md +72 -3
- package/docs/guides/share.md +91 -52
- package/docs/guides/storage.md +44 -4
- package/docs/guides/troubleshooting.md +121 -14
- package/docs/guides/uninstall.md +4 -3
- package/docs/guides/update.md +16 -0
- package/docs/guides/upgrade-to-0.20.md +188 -0
- package/docs/releases/README.md +2 -1
- package/docs/releases/v0.18.10.md +5 -5
- package/docs/releases/v0.18.11.md +3 -3
- package/docs/releases/v0.20.0.md +627 -0
- package/docs/releases/v0.20.1.md +114 -0
- package/docs/tutorials/01-first-house.md +10 -7
- package/docs/tutorials/02-join-a-house.md +24 -15
- package/docs/tutorials/03-share-your-memory.md +40 -31
- package/editors/antigravity.js +1 -80
- package/editors/base.js +463 -9
- package/editors/bridge.js +119 -0
- package/editors/claude.js +273 -105
- package/editors/codex.js +278 -52
- package/editors/copilot.js +1 -70
- package/editors/cursor.js +1 -75
- package/editors/derive-fingerprints.json +18 -0
- package/editors/harness-paths.js +69 -0
- package/editors/index.js +1 -20
- package/editors/normalise/agy.js +910 -0
- package/editors/normalise/copilot-cli.js +321 -0
- package/editors/normalise/cursor-agent.js +852 -0
- package/editors/normalise/cursor.js +474 -0
- package/editors/normalise/devin.js +575 -0
- package/editors/normalise/gemini-cli.js +602 -0
- package/editors/normalise/goose.js +673 -0
- package/editors/normalise/opencode.js +633 -0
- package/editors/normalise/vscode.js +549 -0
- package/editors/normalise/zed.js +473 -0
- package/editors/opencode-v4.js +119 -0
- package/editors/scope.js +14 -3
- package/editors/sessions-log.js +349 -0
- package/editors/sqlite.js +28 -1
- package/editors/vscode.js +1 -72
- package/editors/windsurf.js +1 -143
- package/examples/01-local-one-machine/README.md +24 -19
- package/examples/01-local-one-machine/run.sh +1 -1
- package/examples/02-existing-clickhouse/README.md +30 -22
- package/examples/02-existing-clickhouse/run.sh +5 -4
- package/examples/03-team-house/README.md +44 -37
- package/examples/03-team-house/run.sh +35 -18
- package/examples/04-self-hosted-team/README.md +29 -14
- package/examples/04-self-hosted-team/compose.yml +5 -2
- package/examples/04-self-hosted-team/smoke.sh +26 -12
- package/examples/README.md +8 -4
- package/examples/fixtures/README.md +4 -1
- package/examples/fixtures/make-sessions.js +8 -5
- package/memhouse/admin-secret.js +89 -24
- package/memhouse/argv-secrets.js +64 -0
- package/memhouse/channel.js +49 -9
- package/memhouse/codex-plugin.js +194 -0
- package/memhouse/delivery/AGENT-INSTALL-PROMPT.md +2 -1
- package/memhouse/delivery/AGENT-INSTALL.md +22 -11
- package/memhouse/delivery/INVITATION.md.tpl +44 -45
- package/memhouse/delivery/PROMPT.md +53 -5
- package/memhouse/delivery/UPGRADE.md.tpl +1 -1
- package/memhouse/delivery/codex/AGENTS-BLOCK.md +11 -0
- package/memhouse/delivery/codex/SKILL.md +50 -0
- package/memhouse/delivery/kernel-install.md +17 -9
- package/memhouse/delivery/plugin/.claude-plugin/plugin.json +2 -2
- package/memhouse/delivery/plugin/reference/HOUSE.md +168 -41
- package/memhouse/delivery/plugin/skills/access/SKILL.md +13 -5
- package/memhouse/delivery/plugin/skills/admin/SKILL.md +14 -6
- package/memhouse/delivery/plugin/skills/house/SKILL.md +25 -8
- package/memhouse/delivery/plugin/skills/recall/SKILL.md +66 -8
- package/memhouse/delivery/plugin/skills/sql/SKILL.md +66 -7
- package/memhouse/deploy.js +1 -1
- package/memhouse/flags.js +35 -18
- package/memhouse/help.js +37 -0
- package/memhouse/host.js +82 -2
- package/memhouse/house/HOUSE.md +2 -2
- package/memhouse/house/convert-profile.js +638 -0
- package/memhouse/house/convert-v3.js +742 -0
- package/memhouse/house/doctor-v3.js +324 -0
- package/memhouse/house/host-alias.js +85 -0
- package/memhouse/house/house.js +3 -3
- package/memhouse/house/migrate.js +2 -2
- package/memhouse/house/profile-dedupe.js +183 -0
- package/memhouse/house/profile-edges.js +554 -0
- package/memhouse/house/profile-house.js +430 -0
- package/memhouse/house/profile-rollup.js +190 -0
- package/memhouse/house/q-cli.js +863 -0
- package/memhouse/house/queries-v3.js +1013 -0
- package/memhouse/house/reconcile-v3.js +192 -0
- package/memhouse/house/records-to-profile.js +174 -0
- package/memhouse/house/records-to-rows.js +169 -0
- package/memhouse/house/relocate.js +2 -1
- package/memhouse/house/schema-choice.js +121 -0
- package/memhouse/house/schema-profile.js +290 -0
- package/memhouse/house/schema-profile.sql.tpl +398 -0
- package/memhouse/house/schema-v3.js +267 -0
- package/memhouse/house/schema-v3.sql.tpl +213 -0
- package/memhouse/import/claude-ai.js +420 -0
- package/memhouse/import/import.js +372 -0
- package/memhouse/import/pyjson.js +206 -0
- package/memhouse/import/records.js +64 -0
- package/memhouse/import/writer-profile.js +192 -0
- package/memhouse/import/writer-v3.js +240 -0
- package/memhouse/import/zip.js +112 -0
- package/memhouse/invitation.js +102 -0
- package/memhouse/invitefile.js +5 -2
- package/memhouse/plugin-copies.js +176 -0
- package/memhouse/provision.js +7 -2
- package/memhouse/release-hint.js +24 -0
- package/memhouse/resume.js +4 -4
- package/memhouse/server/api-v3.js +632 -0
- package/memhouse/server/dashboard-auth.js +181 -0
- package/memhouse/server/dashboard-port.js +91 -0
- package/memhouse/server/queries.js +30 -0
- package/memhouse/server/server.js +118 -20
- package/memhouse/service.js +1 -1
- package/memhouse/share.js +687 -1
- package/memhouse/shipper/adapter-capture.js +756 -0
- package/memhouse/shipper/capture.js +2571 -0
- package/memhouse/shipper/dedupe-profile.js +237 -0
- package/memhouse/shipper/dedupe-v3.js +1027 -0
- package/memhouse/shipper/forks.js +233 -0
- package/memhouse/shipper/log-adapter.js +219 -0
- package/memhouse/shipper/maintenance.js +49 -0
- package/memhouse/shipper/normalise-run.js +148 -0
- package/memhouse/shipper/passlog.js +68 -5
- package/memhouse/shipper/profile-capture.js +903 -0
- package/memhouse/shipper/ship.js +91 -8
- package/memhouse/shipper/snapshots.js +193 -0
- package/memhouse/shipper/source-roots.js +111 -0
- package/memhouse/version-notice.js +66 -0
- package/package.json +14 -7
- package/public/THIRD_PARTY_NOTICES.txt +2 -2
- package/public/assets/index-CcNnhfM3.js +78 -0
- package/public/index.html +1 -1
- package/ui/package-lock.json +56 -37
- package/ui/package.json +1 -0
- package/ui/src/App.jsx +29 -14
- package/ui/src/components/ChatSidebar.jsx +69 -12
- package/ui/src/lib/api.js +76 -0
- package/ui/src/lib/dashboard-token.js +41 -0
- package/ui/src/main.jsx +22 -5
- package/ui/src/pages/Dashboard.jsx +22 -36
- package/ui/third-party-notices.js +119 -0
- package/ui/vite.config.js +5 -1
- package/docs/releases/v0.18.12.md +0 -59
- package/memhouse/COMPETITION.md +0 -221
- package/memhouse/DESIGN.md +0 -222
- package/memhouse/RESUME-AND-UPDATE.md +0 -182
- 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
|
|
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', '
|
|
24
|
-
'editors', 'claude-roots', 'channel'],
|
|
25
|
-
setup: ['url', 'user', 'password', 'db', 'port', 'admin-user', 'admin
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
32
|
-
'allow-local', 'member-password'],
|
|
33
|
-
passwd: ['password', '
|
|
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'
|
|
36
|
-
|
|
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 };
|
package/memhouse/help.js
ADDED
|
@@ -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
|
|
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
|
-
|
|
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 };
|
package/memhouse/house/HOUSE.md
CHANGED
|
@@ -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
|
|
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
|