@mnemon-dev/mnemon 0.2.9-win32-x64 → 0.2.9

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/README.md CHANGED
@@ -1,3 +1,18 @@
1
- # Mnemon win32-x64
1
+ # Mnemon CLI
2
2
 
3
- Native win32/x64 artifact for `@mnemon-dev/mnemon@0.2.9-win32-x64`. Install `@mnemon-dev/mnemon` instead of this platform artifact directly.
3
+ Mnemon gives LLM agents persistent memory and a local authority for durable,
4
+ peer-to-peer work. This npm package installs the native Mnemon executable for
5
+ the current operating system and CPU architecture.
6
+
7
+ ```bash
8
+ npm install --global @mnemon-dev/mnemon
9
+ mnemon --version
10
+ mnemon update
11
+ ```
12
+
13
+ The launcher supports 64-bit Intel and ARM systems on macOS, Linux, and
14
+ Windows. Windows currently supports the Memory commands; Agency remains
15
+ unavailable until its local authority boundary has native Windows security.
16
+
17
+ Project documentation and source code are available at
18
+ <https://github.com/mnemon-dev/mnemon>.
package/bin/mnemon.js ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { existsSync, realpathSync } from "node:fs";
4
+ import { createRequire } from "node:module";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ import { runChild, settle } from "../lib/child.js";
9
+ import { selectTarget } from "../lib/targets.js";
10
+ import { updateNpmInstall } from "../lib/update.js";
11
+
12
+ const require = createRequire(import.meta.url);
13
+
14
+ async function main() {
15
+ const packageRoot = realpathSync(path.join(path.dirname(fileURLToPath(import.meta.url)), ".."));
16
+ const args = process.argv.slice(2);
17
+ if (args.length === 1 && args[0] === "update") {
18
+ settle(await updateNpmInstall({ packageRoot }));
19
+ return;
20
+ }
21
+
22
+ const target = selectTarget(process.platform, process.arch);
23
+ let platformRoot;
24
+ try {
25
+ platformRoot = path.dirname(require.resolve(`${target.alias}/package.json`));
26
+ } catch {
27
+ throw new Error(
28
+ `Missing optional dependency ${target.alias}. Reinstall Mnemon with: ` +
29
+ "npm install --global --include=optional @mnemon-dev/mnemon@latest",
30
+ );
31
+ }
32
+
33
+ const binary = path.join(platformRoot, target.binary);
34
+ if (!existsSync(binary)) {
35
+ throw new Error(
36
+ `Mnemon native binary is missing for ${target.id}. Reinstall with: ` +
37
+ "npm install --global --include=optional @mnemon-dev/mnemon@latest",
38
+ );
39
+ }
40
+ settle(await runChild(binary, args));
41
+ }
42
+
43
+ try {
44
+ await main();
45
+ } catch (error) {
46
+ process.stderr.write(`mnemon: ${error.message}\n`);
47
+ process.exitCode = 1;
48
+ }
package/lib/child.js ADDED
@@ -0,0 +1,38 @@
1
+ import { spawn } from "node:child_process";
2
+
3
+ export async function runChild(command, args, options = {}) {
4
+ const child = spawn(command, args, { stdio: "inherit", ...options });
5
+ const forward = (signal) => {
6
+ if (!child.killed) {
7
+ try {
8
+ child.kill(signal);
9
+ } catch {
10
+ // The child may have settled between the check and signal delivery.
11
+ }
12
+ }
13
+ };
14
+ const handlers = new Map();
15
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
16
+ const handler = () => forward(signal);
17
+ handlers.set(signal, handler);
18
+ process.on(signal, handler);
19
+ }
20
+ try {
21
+ return await new Promise((resolve, reject) => {
22
+ child.once("error", reject);
23
+ child.once("exit", (code, signal) => resolve({ code, signal }));
24
+ });
25
+ } finally {
26
+ for (const [signal, handler] of handlers) {
27
+ process.off(signal, handler);
28
+ }
29
+ }
30
+ }
31
+
32
+ export function settle(result) {
33
+ if (result.signal) {
34
+ process.kill(process.pid, result.signal);
35
+ return;
36
+ }
37
+ process.exitCode = result.code ?? 1;
38
+ }
package/lib/targets.js ADDED
@@ -0,0 +1,42 @@
1
+ import { readFileSync } from "node:fs";
2
+
3
+ const targetFile = new URL("../targets.json", import.meta.url);
4
+ const parsedTargets = JSON.parse(readFileSync(targetFile, "utf8"));
5
+
6
+ export const targets = validateTargets(parsedTargets);
7
+
8
+ export function selectTarget(platform, arch) {
9
+ const target = targets.find(
10
+ (candidate) => candidate.platform === platform && candidate.arch === arch,
11
+ );
12
+ if (!target) {
13
+ throw new Error(`Unsupported platform: ${platform} (${arch})`);
14
+ }
15
+ return target;
16
+ }
17
+
18
+ function validateTargets(value) {
19
+ if (!Array.isArray(value) || value.length === 0) {
20
+ throw new Error("Mnemon target registry is empty");
21
+ }
22
+ const ids = new Set();
23
+ const runtimes = new Set();
24
+ const aliases = new Set();
25
+ return Object.freeze(
26
+ value.map((target) => {
27
+ for (const field of ["id", "platform", "arch", "goos", "goarch", "alias", "binary"]) {
28
+ if (typeof target[field] !== "string" || target[field].length === 0) {
29
+ throw new Error(`Mnemon target has invalid ${field}`);
30
+ }
31
+ }
32
+ const runtime = `${target.platform}/${target.arch}`;
33
+ if (ids.has(target.id) || runtimes.has(runtime) || aliases.has(target.alias)) {
34
+ throw new Error(`Mnemon target registry contains a duplicate: ${target.id}`);
35
+ }
36
+ ids.add(target.id);
37
+ runtimes.add(runtime);
38
+ aliases.add(target.alias);
39
+ return Object.freeze({ ...target });
40
+ }),
41
+ );
42
+ }
package/lib/update.js ADDED
@@ -0,0 +1,178 @@
1
+ import { constants } from "node:fs";
2
+ import { access, readFile, realpath } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { spawnSync } from "node:child_process";
5
+
6
+ import { runChild } from "./child.js";
7
+
8
+ const packageName = "@mnemon-dev/mnemon";
9
+
10
+ export async function updateNpmInstall({
11
+ packageRoot,
12
+ runner = productionRunner(),
13
+ stdout = process.stdout,
14
+ }) {
15
+ const currentRoot = await canonicalPath(packageRoot);
16
+ const current = await readPackage(currentRoot);
17
+ const npm = await resolveNpmInvocation();
18
+
19
+ const globalRoot = await npmPath(runner, npm, ["root", "--global"]);
20
+ let expectedRoot;
21
+ try {
22
+ expectedRoot = await canonicalPath(path.join(globalRoot, ...packageName.split("/")));
23
+ } catch (error) {
24
+ throw notManagedError(`cannot resolve the package in npm's global root: ${error.message}`);
25
+ }
26
+ if (!samePath(expectedRoot, currentRoot)) {
27
+ throw notManagedError("npm on PATH owns a different global installation");
28
+ }
29
+
30
+ const prefix = await npmPath(runner, npm, ["prefix", "--global"]);
31
+ if (!pathWithin(prefix, globalRoot)) {
32
+ throw notManagedError("npm's global package root is outside its prefix");
33
+ }
34
+
35
+ const result = await runner.run(npm.command, [
36
+ ...npm.args,
37
+ "install",
38
+ "--global",
39
+ "--prefix",
40
+ prefix,
41
+ "--include=optional",
42
+ `${packageName}@latest`,
43
+ ]);
44
+ if (result.signal) {
45
+ return result;
46
+ }
47
+ if (result.code !== 0) {
48
+ throw new Error(`npm install exited with status ${result.code ?? "unknown"}`);
49
+ }
50
+
51
+ const updated = await readPackage(currentRoot);
52
+ if (current.version === updated.version) {
53
+ stdout.write(`Mnemon is already up to date (${updated.version}).\n`);
54
+ } else {
55
+ stdout.write(`Updated Mnemon ${current.version} -> ${updated.version}.\n`);
56
+ }
57
+ return { code: 0, signal: null };
58
+ }
59
+
60
+ function productionRunner() {
61
+ return {
62
+ output(command, args) {
63
+ const result = spawnSync(command, args, { encoding: "utf8" });
64
+ if (result.error) {
65
+ throw result.error;
66
+ }
67
+ if (result.status !== 0) {
68
+ throw new Error(
69
+ `${command} ${args.join(" ")} exited with status ${result.status ?? "unknown"}: ` +
70
+ (result.stderr ?? "").trim(),
71
+ );
72
+ }
73
+ return result.stdout;
74
+ },
75
+ run(command, args) {
76
+ return runChild(command, args);
77
+ },
78
+ };
79
+ }
80
+
81
+ async function npmPath(runner, npm, args) {
82
+ try {
83
+ const value = runner.output(npm.command, [...npm.args, ...args]).trim();
84
+ return await canonicalPath(value);
85
+ } catch (error) {
86
+ throw new Error(`cannot inspect npm ${args[0]}: ${error.message}`);
87
+ }
88
+ }
89
+
90
+ async function resolveNpmInvocation() {
91
+ if (process.platform !== "win32") {
92
+ return { command: "npm", args: [] };
93
+ }
94
+
95
+ const pathValue = Object.entries(process.env).find(
96
+ ([name]) => name.toLowerCase() === "path",
97
+ )?.[1];
98
+ for (let entry of pathValue?.split(path.delimiter) ?? []) {
99
+ if (entry.startsWith('"') && entry.endsWith('"')) {
100
+ entry = entry.slice(1, -1);
101
+ }
102
+ if (entry === "") {
103
+ continue;
104
+ }
105
+ const npmExecutable = path.join(entry, "npm.exe");
106
+ try {
107
+ await access(npmExecutable, constants.F_OK);
108
+ return { command: npmExecutable, args: [] };
109
+ } catch {
110
+ // Standard Node.js installations expose npm through npm.cmd instead.
111
+ }
112
+ const npmCommand = path.join(entry, "npm.cmd");
113
+ const npmCLI = path.join(entry, "node_modules", "npm", "bin", "npm-cli.js");
114
+ try {
115
+ await Promise.all([
116
+ access(npmCommand, constants.F_OK),
117
+ access(npmCLI, constants.F_OK),
118
+ ]);
119
+ // A .cmd file cannot be spawned directly without a shell. Invoke npm's
120
+ // JavaScript entry point with the already-running Node executable.
121
+ return { command: process.execPath, args: [npmCLI] };
122
+ } catch {
123
+ // Keep searching PATH for a complete Node.js/npm installation.
124
+ }
125
+ }
126
+ throw new Error("npm is required to update Mnemon but was not found on PATH");
127
+ }
128
+
129
+ async function canonicalPath(value) {
130
+ if (typeof value !== "string" || value.trim() !== value || !path.isAbsolute(value)) {
131
+ throw new Error("path is not absolute and clean");
132
+ }
133
+ const cleaned = path.normalize(value);
134
+ if (cleaned !== value) {
135
+ throw new Error("path is not absolute and clean");
136
+ }
137
+ return realpath(value);
138
+ }
139
+
140
+ async function readPackage(root) {
141
+ let metadata;
142
+ try {
143
+ metadata = JSON.parse(await readFile(path.join(root, "package.json"), "utf8"));
144
+ } catch (error) {
145
+ throw notManagedError(`cannot read package metadata: ${error.message}`);
146
+ }
147
+ if (
148
+ metadata.name !== packageName ||
149
+ typeof metadata.version !== "string" ||
150
+ metadata.version.trim() === ""
151
+ ) {
152
+ throw notManagedError("package name or version is invalid");
153
+ }
154
+ return metadata;
155
+ }
156
+
157
+ function pathWithin(root, candidate) {
158
+ const relative = path.relative(root, candidate);
159
+ return (
160
+ relative !== "" &&
161
+ relative !== ".." &&
162
+ !relative.startsWith(`..${path.sep}`) &&
163
+ !path.isAbsolute(relative)
164
+ );
165
+ }
166
+
167
+ function samePath(left, right) {
168
+ return process.platform === "win32"
169
+ ? left.toLowerCase() === right.toLowerCase()
170
+ : left === right;
171
+ }
172
+
173
+ function notManagedError(reason) {
174
+ return new Error(
175
+ `this Mnemon installation is not managed by npm: ${reason}; ` +
176
+ `migrate once with: npm install --global ${packageName}@latest`,
177
+ );
178
+ }
package/package.json CHANGED
@@ -1,25 +1,48 @@
1
1
  {
2
2
  "name": "@mnemon-dev/mnemon",
3
- "version": "0.2.9-win32-x64",
4
- "description": "Mnemon native binary for win32/x64",
5
- "os": [
6
- "win32"
7
- ],
8
- "cpu": [
9
- "x64"
10
- ],
3
+ "version": "0.2.9",
4
+ "description": "Persistent memory and durable agency for LLM agents",
5
+ "type": "module",
6
+ "bin": {
7
+ "mnemon": "bin/mnemon.js"
8
+ },
11
9
  "files": [
12
10
  "bin",
11
+ "lib",
12
+ "targets.json",
13
13
  "README.md",
14
14
  "LICENSE"
15
15
  ],
16
+ "scripts": {
17
+ "test": "node --test test/*.test.mjs"
18
+ },
19
+ "engines": {
20
+ "node": ">=22"
21
+ },
22
+ "keywords": [
23
+ "mnemon",
24
+ "agent-memory",
25
+ "llm",
26
+ "cli"
27
+ ],
16
28
  "repository": {
17
29
  "type": "git",
18
30
  "url": "git+https://github.com/mnemon-dev/mnemon.git"
19
31
  },
20
32
  "homepage": "https://github.com/mnemon-dev/mnemon",
33
+ "bugs": {
34
+ "url": "https://github.com/mnemon-dev/mnemon/issues"
35
+ },
21
36
  "license": "Apache-2.0",
22
37
  "publishConfig": {
23
38
  "access": "public"
39
+ },
40
+ "optionalDependencies": {
41
+ "@mnemon-dev/mnemon-darwin-x64": "npm:@mnemon-dev/mnemon@0.2.9-darwin-x64",
42
+ "@mnemon-dev/mnemon-darwin-arm64": "npm:@mnemon-dev/mnemon@0.2.9-darwin-arm64",
43
+ "@mnemon-dev/mnemon-linux-x64": "npm:@mnemon-dev/mnemon@0.2.9-linux-x64",
44
+ "@mnemon-dev/mnemon-linux-arm64": "npm:@mnemon-dev/mnemon@0.2.9-linux-arm64",
45
+ "@mnemon-dev/mnemon-win32-x64": "npm:@mnemon-dev/mnemon@0.2.9-win32-x64",
46
+ "@mnemon-dev/mnemon-win32-arm64": "npm:@mnemon-dev/mnemon@0.2.9-win32-arm64"
24
47
  }
25
48
  }
package/targets.json ADDED
@@ -0,0 +1,56 @@
1
+ [
2
+ {
3
+ "id": "darwin-x64",
4
+ "platform": "darwin",
5
+ "arch": "x64",
6
+ "goos": "darwin",
7
+ "goarch": "amd64",
8
+ "alias": "@mnemon-dev/mnemon-darwin-x64",
9
+ "binary": "bin/mnemon"
10
+ },
11
+ {
12
+ "id": "darwin-arm64",
13
+ "platform": "darwin",
14
+ "arch": "arm64",
15
+ "goos": "darwin",
16
+ "goarch": "arm64",
17
+ "alias": "@mnemon-dev/mnemon-darwin-arm64",
18
+ "binary": "bin/mnemon"
19
+ },
20
+ {
21
+ "id": "linux-x64",
22
+ "platform": "linux",
23
+ "arch": "x64",
24
+ "goos": "linux",
25
+ "goarch": "amd64",
26
+ "alias": "@mnemon-dev/mnemon-linux-x64",
27
+ "binary": "bin/mnemon"
28
+ },
29
+ {
30
+ "id": "linux-arm64",
31
+ "platform": "linux",
32
+ "arch": "arm64",
33
+ "goos": "linux",
34
+ "goarch": "arm64",
35
+ "alias": "@mnemon-dev/mnemon-linux-arm64",
36
+ "binary": "bin/mnemon"
37
+ },
38
+ {
39
+ "id": "win32-x64",
40
+ "platform": "win32",
41
+ "arch": "x64",
42
+ "goos": "windows",
43
+ "goarch": "amd64",
44
+ "alias": "@mnemon-dev/mnemon-win32-x64",
45
+ "binary": "bin/mnemon.exe"
46
+ },
47
+ {
48
+ "id": "win32-arm64",
49
+ "platform": "win32",
50
+ "arch": "arm64",
51
+ "goos": "windows",
52
+ "goarch": "arm64",
53
+ "alias": "@mnemon-dev/mnemon-win32-arm64",
54
+ "binary": "bin/mnemon.exe"
55
+ }
56
+ ]
package/bin/mnemon.exe DELETED
Binary file