dsh-mnemon-source-memory-spaces 0.5.11 → 0.5.12
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/lib/index.js +4 -5
- package/lib/native-cli.d.ts +7 -1
- package/lib/native-cli.js +38 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { findMnemonCommand, isMnemonExecutable,
|
|
1
|
+
import { findMnemonCommand, isMnemonExecutable, resolveMnemonInvocation } from "./native-cli.js";
|
|
2
2
|
import { CATEGORIES as CATEGORIES$1, EDGE_TYPES, INTENTS as INTENTS$1, MNEMON_EMBEDDING_PROTOCOLS, SOURCES as SOURCES$1 } from "./contracts.js";
|
|
3
3
|
import { a as MemoryProviderCatalog, i as EMPTY_MEMORY_PROVIDER_CATALOG, n as PrivateMemorySpaceProviderHost, r as MemoryProviderAdapterRegistry, t as createMemorySpaceProviderPlugin } from "./plugin-DlsNeZbQ.js";
|
|
4
4
|
import { t as runProcess } from "./process-BvrgxPNP.js";
|
|
@@ -2387,11 +2387,10 @@ function createRunner(config, processRunner = runProcess) {
|
|
|
2387
2387
|
};
|
|
2388
2388
|
let result;
|
|
2389
2389
|
try {
|
|
2390
|
-
const
|
|
2391
|
-
|
|
2392
|
-
result = await processRunner(launcher === void 0 ? command : process.execPath, launcher === void 0 ? argv : [launcher, ...argv], launcher === void 0 ? processOptions : {
|
|
2390
|
+
const invocation = resolveMnemonInvocation(currentCommand(), argv, environment);
|
|
2391
|
+
result = await processRunner(invocation.command, invocation.args, {
|
|
2393
2392
|
...processOptions,
|
|
2394
|
-
env:
|
|
2393
|
+
...invocation.env === void 0 ? {} : { env: invocation.env }
|
|
2395
2394
|
});
|
|
2396
2395
|
} catch (error) {
|
|
2397
2396
|
throw new MnemonCliError(`${error instanceof Error ? error.message : String(error)}. ${process.platform === "win32" ? "Install the official Mnemon Windows release, ensure mnemon.exe is on PATH or under %LOCALAPPDATA%\\Programs\\mnemon, or set MNEMON_CLI_PATH or mnemon.cliPath to its absolute path." : "Install Mnemon and ensure \"mnemon\" is on PATH, or set MNEMON_CLI_PATH or mnemon.cliPath."}`);
|
package/lib/native-cli.d.ts
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
/** Execute JavaScript with the Host binary even when it is Electron's GUI executable. */
|
|
3
3
|
declare function nodeLauncherEnvironment(environment?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
4
4
|
declare function mnemonNpmLauncher(command: string): string | undefined;
|
|
5
|
+
/** Keep CLI subprocesses under our windowsHide, timeout and cancellation policy. */
|
|
6
|
+
declare function resolveMnemonInvocation(command: string, args: readonly string[], env?: NodeJS.ProcessEnv): {
|
|
7
|
+
command: string;
|
|
8
|
+
args: string[];
|
|
9
|
+
env?: NodeJS.ProcessEnv;
|
|
10
|
+
};
|
|
5
11
|
interface CommandDiscoveryOptions {
|
|
6
12
|
platform?: NodeJS.Platform;
|
|
7
13
|
env?: NodeJS.ProcessEnv;
|
|
@@ -14,4 +20,4 @@ declare function findMnemonCommand(config: {
|
|
|
14
20
|
cliPath?: string | undefined;
|
|
15
21
|
}, options?: CommandDiscoveryOptions): string | undefined;
|
|
16
22
|
//#endregion
|
|
17
|
-
export { CommandDiscoveryOptions, findMnemonCommand, isMnemonExecutable, mnemonNpmLauncher, nodeLauncherEnvironment };
|
|
23
|
+
export { CommandDiscoveryOptions, findMnemonCommand, isMnemonExecutable, mnemonNpmLauncher, nodeLauncherEnvironment, resolveMnemonInvocation };
|
package/lib/native-cli.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { accessSync, constants, existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
2
3
|
import { homedir } from "node:os";
|
|
3
4
|
import { dirname, join, posix, win32 } from "node:path";
|
|
@@ -38,6 +39,42 @@ function mnemonNpmLauncher(command) {
|
|
|
38
39
|
} catch {}
|
|
39
40
|
}
|
|
40
41
|
}
|
|
42
|
+
/** Resolve only the platform package pinned by the recognized official launcher. */
|
|
43
|
+
function npmNativeBinary(launcher) {
|
|
44
|
+
const pkg = manifest(join(dirname(dirname(launcher)), "package.json"));
|
|
45
|
+
const target = `${process.platform}-${process.arch}`;
|
|
46
|
+
const alias = `${MNEMON_NPM_PACKAGE}-${target}`;
|
|
47
|
+
const version = typeof pkg?.version === "string" ? `${pkg.version}-${target}` : void 0;
|
|
48
|
+
if (version === void 0 || pkg?.optionalDependencies?.[alias] !== `npm:${MNEMON_NPM_PACKAGE}@${version}`) return void 0;
|
|
49
|
+
try {
|
|
50
|
+
const packagePath = createRequire(launcher).resolve.paths(alias)?.map((path) => join(path, alias, "package.json")).find(existsSync);
|
|
51
|
+
if (packagePath === void 0) return void 0;
|
|
52
|
+
const native = manifest(packagePath);
|
|
53
|
+
if (native?.name !== MNEMON_NPM_PACKAGE || native.version !== version) return void 0;
|
|
54
|
+
const binary = join(dirname(packagePath), "bin", process.platform === "win32" ? "mnemon.exe" : "mnemon");
|
|
55
|
+
return isMnemonExecutable(binary) ? binary : void 0;
|
|
56
|
+
} catch {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Keep CLI subprocesses under our windowsHide, timeout and cancellation policy. */
|
|
61
|
+
function resolveMnemonInvocation(command, args, env) {
|
|
62
|
+
const launcher = mnemonNpmLauncher(command);
|
|
63
|
+
if (launcher !== void 0) {
|
|
64
|
+
const binary = args.length === 1 && args[0] === "update" ? void 0 : npmNativeBinary(launcher);
|
|
65
|
+
if (binary === void 0) return {
|
|
66
|
+
command: process.execPath,
|
|
67
|
+
args: [launcher, ...args],
|
|
68
|
+
env: nodeLauncherEnvironment(env)
|
|
69
|
+
};
|
|
70
|
+
command = binary;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
command,
|
|
74
|
+
args: [...args],
|
|
75
|
+
...env === void 0 ? {} : { env }
|
|
76
|
+
};
|
|
77
|
+
}
|
|
41
78
|
const UNIX_COMMON_CLI_PATHS = [
|
|
42
79
|
"~/.local/bin/mnemon",
|
|
43
80
|
"/opt/homebrew/bin/mnemon",
|
|
@@ -112,4 +149,4 @@ function findMnemonCommand(config, options = {}) {
|
|
|
112
149
|
for (const path of commonCliPaths(platform, env, home)) if (isExecutable(path)) return path;
|
|
113
150
|
}
|
|
114
151
|
//#endregion
|
|
115
|
-
export { findMnemonCommand, isMnemonExecutable, mnemonNpmLauncher, nodeLauncherEnvironment };
|
|
152
|
+
export { findMnemonCommand, isMnemonExecutable, mnemonNpmLauncher, nodeLauncherEnvironment, resolveMnemonInvocation };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mnemon-source-memory-spaces",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.12",
|
|
4
4
|
"description": "Memory Spaces Source and its private Provider SDK.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@types/node": "^22.0.0",
|
|
66
66
|
"@types/react": "^18.3.0",
|
|
67
67
|
"@types/react-dom": "^18.3.0",
|
|
68
|
-
"dsh-mnemon": "^0.5.
|
|
68
|
+
"dsh-mnemon": "^0.5.18",
|
|
69
69
|
"dsh-mnemon-provider-byterover": "^0.5.5",
|
|
70
70
|
"dsh-mnemon-provider-hindsight": "^0.5.5",
|
|
71
71
|
"dsh-mnemon-provider-holographic": "^0.5.5",
|