@memnexus-ai/cli 1.7.228 → 1.7.229
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/dist/lib/setup/detector.d.ts.map +1 -1
- package/dist/lib/setup/detector.js +12 -4
- package/dist/lib/setup/detector.js.map +1 -1
- package/dist/lib/setup/index.d.ts +2 -0
- package/dist/lib/setup/index.d.ts.map +1 -1
- package/dist/lib/setup/index.js +7 -1
- package/dist/lib/setup/index.js.map +1 -1
- package/dist/lib/setup/verify-ours.d.ts +71 -0
- package/dist/lib/setup/verify-ours.d.ts.map +1 -0
- package/dist/lib/setup/verify-ours.js +302 -0
- package/dist/lib/setup/verify-ours.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../../src/lib/setup/detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAmB,aAAa,EAAY,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../../src/lib/setup/detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAmB,aAAa,EAAY,MAAM,YAAY,CAAC;AAI3E,wCAAwC;AACxC,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAS7C;AA8GD;;;GAGG;AACH,wBAAsB,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAqEhF"}
|
|
@@ -15,6 +15,7 @@ const node_child_process_1 = require("node:child_process");
|
|
|
15
15
|
const node_path_1 = __importDefault(require("node:path"));
|
|
16
16
|
const node_os_1 = __importDefault(require("node:os"));
|
|
17
17
|
const registry_js_1 = require("./registry.js");
|
|
18
|
+
const verify_ours_js_1 = require("./verify-ours.js");
|
|
18
19
|
/** Resolve ~ and %APPDATA% in paths. */
|
|
19
20
|
function resolvePath(p) {
|
|
20
21
|
if (p.startsWith('~')) {
|
|
@@ -93,18 +94,25 @@ async function checkExistingConfig(configPath, agent) {
|
|
|
93
94
|
try {
|
|
94
95
|
const content = await (0, promises_1.readFile)(configPath, 'utf-8');
|
|
95
96
|
if (agent.mcp.configFormat === 'toml') {
|
|
96
|
-
//
|
|
97
|
+
// Real section parse (not substring): read the [mcp_servers.memnexus] block's
|
|
98
|
+
// command/args and verify it runs our bridge. A commented-out header or a
|
|
99
|
+
// foreign command is NOT configured (#5177).
|
|
100
|
+
const block = (0, verify_ours_js_1.parseMemnexusTomlBlock)(content);
|
|
97
101
|
return {
|
|
98
102
|
exists: true,
|
|
99
|
-
hasMemnexus:
|
|
103
|
+
hasMemnexus: (0, verify_ours_js_1.isOursTomlBlock)(block),
|
|
100
104
|
};
|
|
101
105
|
}
|
|
102
|
-
// JSON —
|
|
106
|
+
// JSON — the entry counts as configured only when it is structurally ours
|
|
107
|
+
// (command basename `mx`, a node runner delegating to @memnexus-ai/, or a URL at
|
|
108
|
+
// our MCP server). Key presence alone let a cloned repo suppress a real install
|
|
109
|
+
// by shipping a foreign `memnexus` entry (#5177).
|
|
103
110
|
const parsed = JSON.parse(content);
|
|
104
111
|
const servers = parsed[agent.mcp.serversKey] || {};
|
|
112
|
+
const entry = servers.memnexus;
|
|
105
113
|
return {
|
|
106
114
|
exists: true,
|
|
107
|
-
hasMemnexus: 'memnexus' in servers,
|
|
115
|
+
hasMemnexus: 'memnexus' in servers && (0, verify_ours_js_1.isOursJsonEntry)(entry),
|
|
108
116
|
};
|
|
109
117
|
}
|
|
110
118
|
catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detector.js","sourceRoot":"","sources":["../../../src/lib/setup/detector.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;
|
|
1
|
+
{"version":3,"file":"detector.js","sourceRoot":"","sources":["../../../src/lib/setup/detector.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAYH,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AAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;QAE1C,MAAM,eAAe,GACnB,UAAU,IAAI,KAAK,CAAC,GAAG,CAAC,iBAAiB;YACvC,CAAC,CAAC,mBAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC;YACpD,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,YAAY,GAAG,eAAe;YAClC,CAAC,CAAC,MAAM,mBAAmB,CAAC,eAAe,EAAE,KAAK,CAAC;YACnD,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;QAE1C,iBAAiB,GAAG,WAAW,CAAC,WAAW,IAAI,YAAY,CAAC,WAAW,CAAC;QAExE,2EAA2E;QAC3E,yEAAyE;QACzE,2EAA2E;QAC3E,iCAAiC;QACjC,IAAI,YAAY,CAAC,WAAW,EAAE,CAAC;YAC7B,kBAAkB,GAAG,eAAe,CAAC;QACvC,CAAC;aAAM,IAAI,WAAW,CAAC,WAAW,EAAE,CAAC;YACnC,kBAAkB,GAAG,cAAc,CAAC;QACtC,CAAC;aAAM,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;YAC/B,kBAAkB,GAAG,eAAe,CAAC;QACvC,CAAC;aAAM,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;YAC9B,kBAAkB,GAAG,cAAc,CAAC;QACtC,CAAC;QAED,OAAO,CAAC,IAAI,CAAC;YACX,KAAK;YACL,UAAU;YACV,kBAAkB;YAClB,iBAAiB;SAClB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -9,5 +9,7 @@ export { writeAllSkills, removeAllSkills, listSkills, resolveSkillsDir, resolveS
|
|
|
9
9
|
export { SKILLS, parseSkillVersion } from './skills-templates.js';
|
|
10
10
|
export { installHooks, removeHooks } from './hooks-writer.js';
|
|
11
11
|
export type { HooksWriteResult } from './hooks-writer.js';
|
|
12
|
+
export { isOursJsonEntry, isOursTomlBlock, parseMemnexusTomlBlock, oursMcpHosts, exeBase, } from './verify-ours.js';
|
|
13
|
+
export type { TomlMemnexusBlock } from './verify-ours.js';
|
|
12
14
|
export type * from './types.js';
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/setup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9D,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,mBAAmB,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/setup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9D,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACL,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,OAAO,GACR,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,mBAAmB,YAAY,CAAC"}
|
package/dist/lib/setup/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeHooks = exports.installHooks = exports.parseSkillVersion = exports.SKILLS = exports.resolveSkillPath = exports.resolveSkillsDir = exports.listSkills = exports.removeAllSkills = exports.writeAllSkills = exports.wasDowngradedToGlobal = exports.resolveEffectiveScope = exports.AGENTS = exports.getSortedAgents = exports.getAgentIds = exports.getAgent = exports.parseSteeringVersion = exports.composeRules = exports.resolveSteeringPath = exports.getSteeringVersion = exports.removeSteeringSection = exports.writeSteeringFile = exports.displayPath = exports.verifyAll = exports.verifyAgent = exports.resolveConfigPath = exports.removeAgentConfig = exports.writeAgentConfig = exports.resolvePath = exports.detectAgents = void 0;
|
|
3
|
+
exports.exeBase = exports.oursMcpHosts = exports.parseMemnexusTomlBlock = exports.isOursTomlBlock = exports.isOursJsonEntry = exports.removeHooks = exports.installHooks = exports.parseSkillVersion = exports.SKILLS = exports.resolveSkillPath = exports.resolveSkillsDir = exports.listSkills = exports.removeAllSkills = exports.writeAllSkills = exports.wasDowngradedToGlobal = exports.resolveEffectiveScope = exports.AGENTS = exports.getSortedAgents = exports.getAgentIds = exports.getAgent = exports.parseSteeringVersion = exports.composeRules = exports.resolveSteeringPath = exports.getSteeringVersion = exports.removeSteeringSection = exports.writeSteeringFile = exports.displayPath = exports.verifyAll = exports.verifyAgent = exports.resolveConfigPath = exports.removeAgentConfig = exports.writeAgentConfig = exports.resolvePath = exports.detectAgents = void 0;
|
|
4
4
|
var detector_js_1 = require("./detector.js");
|
|
5
5
|
Object.defineProperty(exports, "detectAgents", { enumerable: true, get: function () { return detector_js_1.detectAgents; } });
|
|
6
6
|
Object.defineProperty(exports, "resolvePath", { enumerable: true, get: function () { return detector_js_1.resolvePath; } });
|
|
@@ -40,4 +40,10 @@ Object.defineProperty(exports, "parseSkillVersion", { enumerable: true, get: fun
|
|
|
40
40
|
var hooks_writer_js_1 = require("./hooks-writer.js");
|
|
41
41
|
Object.defineProperty(exports, "installHooks", { enumerable: true, get: function () { return hooks_writer_js_1.installHooks; } });
|
|
42
42
|
Object.defineProperty(exports, "removeHooks", { enumerable: true, get: function () { return hooks_writer_js_1.removeHooks; } });
|
|
43
|
+
var verify_ours_js_1 = require("./verify-ours.js");
|
|
44
|
+
Object.defineProperty(exports, "isOursJsonEntry", { enumerable: true, get: function () { return verify_ours_js_1.isOursJsonEntry; } });
|
|
45
|
+
Object.defineProperty(exports, "isOursTomlBlock", { enumerable: true, get: function () { return verify_ours_js_1.isOursTomlBlock; } });
|
|
46
|
+
Object.defineProperty(exports, "parseMemnexusTomlBlock", { enumerable: true, get: function () { return verify_ours_js_1.parseMemnexusTomlBlock; } });
|
|
47
|
+
Object.defineProperty(exports, "oursMcpHosts", { enumerable: true, get: function () { return verify_ours_js_1.oursMcpHosts; } });
|
|
48
|
+
Object.defineProperty(exports, "exeBase", { enumerable: true, get: function () { return verify_ours_js_1.exeBase; } });
|
|
43
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/setup/index.ts"],"names":[],"mappings":";;;AAAA,6CAA0D;AAAjD,2GAAA,YAAY,OAAA;AAAE,0GAAA,WAAW,OAAA;AAClC,uDAA4F;AAAnF,oHAAA,gBAAgB,OAAA;AAAE,qHAAA,iBAAiB,OAAA;AAAE,qHAAA,iBAAiB,OAAA;AAC/D,6CAAoE;AAA3D,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAAE,0GAAA,WAAW,OAAA;AAC5C,qDAK2B;AAJzB,oHAAA,iBAAiB,OAAA;AACjB,wHAAA,qBAAqB,OAAA;AACrB,qHAAA,kBAAkB,OAAA;AAClB,sHAAA,mBAAmB,OAAA;AAErB,2DAA0E;AAAjE,kHAAA,YAAY,OAAA;AAAE,0HAAA,oBAAoB,OAAA;AAC3C,6CAA+E;AAAtE,uGAAA,QAAQ,OAAA;AAAE,0GAAA,WAAW,OAAA;AAAE,8GAAA,eAAe,OAAA;AAAE,qGAAA,MAAM,OAAA;AACvD,uCAA0E;AAAjE,iHAAA,qBAAqB,OAAA;AAAE,iHAAA,qBAAqB,OAAA;AACrD,uDAM4B;AAL1B,kHAAA,cAAc,OAAA;AACd,mHAA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ElC,mDAM0B;AALxB,iHAAA,eAAe,OAAA;AACf,iHAAA,eAAe,OAAA;AACf,wHAAA,sBAAsB,OAAA;AACtB,8GAAA,YAAY,OAAA;AACZ,yGAAA,OAAO,OAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* verify-ours — structural ownership check for an existing `memnexus` config entry.
|
|
3
|
+
*
|
|
4
|
+
* `mx setup` decides an agent is "already configured" when it finds a config entry
|
|
5
|
+
* named `memnexus`. Key presence alone is not proof the entry is ours: a cloned
|
|
6
|
+
* repository can ship a `memnexus`-named entry pointing anywhere, which suppresses a
|
|
7
|
+
* real install (#5177). These predicates answer one question — does the entry
|
|
8
|
+
* structurally execute our bridge? — binding on the executed TARGET (command binary,
|
|
9
|
+
* delegated package, or remote host).
|
|
10
|
+
*
|
|
11
|
+
* Terminal rule: every EXECUTABLE arm requires the genuine ours-TARGET AND the bridge
|
|
12
|
+
* invocation; the remote-url arm requires an exact host.
|
|
13
|
+
* - (A) `mx` arm: command basename is `mx` AND the bridge invocation `mcp serve` is at
|
|
14
|
+
* the START of args (`args[0]==='mcp' && args[1]==='serve'`; a trailing
|
|
15
|
+
* `--inject-rules` is allowed). Checking the invocation POSITION, not anywhere in
|
|
16
|
+
* args, rejects a decoy: `mx status mcp serve` runs `mx status`.
|
|
17
|
+
* - (B) node-runner arm: the EXECUTED package (first non-flag positional token, deno's
|
|
18
|
+
* `run` subcommand skipped) IS our scoped package as a token PREFIX (`@memnexus-ai/`,
|
|
19
|
+
* or deno's `npm:@memnexus-ai/`), AND `mcp serve` comes IMMEDIATELY AFTER that
|
|
20
|
+
* package token. Binding the package to the executed position rejects a decoy
|
|
21
|
+
* (`npx evil-pkg @memnexus-ai/cli mcp serve` runs evil-pkg); binding on a prefix (not
|
|
22
|
+
* a substring anywhere) rejects a foreign package that merely mentions our scope in a
|
|
23
|
+
* flag value; binding the invocation to right-after-the-package rejects
|
|
24
|
+
* `npx @memnexus-ai/cli status mcp serve` (runs `@memnexus-ai/cli status`).
|
|
25
|
+
* - (C) remote-url arm: a url/serverUrl/remoteUrl host EXACTLY equals our MCP server.
|
|
26
|
+
* Args are never a positive signal for a foreign command: these refinements only make
|
|
27
|
+
* each arm stricter, and a foreign command reaches no executable arm.
|
|
28
|
+
*
|
|
29
|
+
* Anything not positively recognized as ours returns false (safe error direction:
|
|
30
|
+
* worst case is a harmless re-write with a `.bak` backup; a false "true" is the
|
|
31
|
+
* suppression bug).
|
|
32
|
+
*
|
|
33
|
+
* SEVERITY CONTEXT: this predicate is a DEFAULT-SELECTION nudge — it sets
|
|
34
|
+
* `alreadyConfigured`, which only pre-unchecks a re-selectable install checkbox. It is
|
|
35
|
+
* NOT an execution gate: it cannot grant execution to any entry, it can only fail to
|
|
36
|
+
* auto-remediate a pre-existing one. The write path is unchanged (FR-5).
|
|
37
|
+
*/
|
|
38
|
+
/** Hosts that count as our MCP server (remote-url agents). */
|
|
39
|
+
export declare function oursMcpHosts(): Set<string>;
|
|
40
|
+
/** basename without a Windows executable extension, lowercased. */
|
|
41
|
+
export declare function exeBase(cmd: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* PERMISSIVE-STRUCTURAL ownership check for a JSON server entry.
|
|
44
|
+
*
|
|
45
|
+
* Recognizes every real ours-shape across all agents and past `mx` versions —
|
|
46
|
+
* including customized ones (extra `env`, extra args, older versions with no `type`
|
|
47
|
+
* field, absolute/`.exe` command path, and OpenCode's array-form command). Returns
|
|
48
|
+
* false for foreign commands and for anything it cannot positively recognize.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isOursJsonEntry(entry: unknown): boolean;
|
|
51
|
+
/** Parsed [mcp_servers.memnexus] fields (command + args), or null if absent/malformed. */
|
|
52
|
+
export interface TomlMemnexusBlock {
|
|
53
|
+
command?: string;
|
|
54
|
+
args?: string[];
|
|
55
|
+
}
|
|
56
|
+
/** Same ownership rule applied to a parsed TOML block. */
|
|
57
|
+
export declare function isOursTomlBlock(block: TomlMemnexusBlock | null): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Minimal line-based section parse of the `[mcp_servers.memnexus]` block.
|
|
60
|
+
*
|
|
61
|
+
* Replaces the previous raw-substring check (which fired on a commented-out header and
|
|
62
|
+
* could not read `command`). Strips comments first, locates the real section header
|
|
63
|
+
* (a line whose trimmed value is exactly `[mcp_servers.memnexus]`), then reads
|
|
64
|
+
* `key = value` lines until the next `[section]` header or EOF, extracting `command`
|
|
65
|
+
* (quoted string) and `args` (array of quoted strings).
|
|
66
|
+
*
|
|
67
|
+
* Returns null when there is no live section header. A full TOML library is not
|
|
68
|
+
* required; the block grammar is fixed by what `buildTomlBlock` writes.
|
|
69
|
+
*/
|
|
70
|
+
export declare function parseMemnexusTomlBlock(content: string): TomlMemnexusBlock | null;
|
|
71
|
+
//# sourceMappingURL=verify-ours.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-ours.d.ts","sourceRoot":"","sources":["../../../src/lib/setup/verify-ours.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAQH,8DAA8D;AAC9D,wBAAgB,YAAY,IAAI,GAAG,CAAC,MAAM,CAAC,CAY1C;AA+CD,mEAAmE;AACnE,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG3C;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CA0CvD;AAED,0FAA0F;AAC1F,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAUxE;AAoED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAsChF"}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* verify-ours — structural ownership check for an existing `memnexus` config entry.
|
|
4
|
+
*
|
|
5
|
+
* `mx setup` decides an agent is "already configured" when it finds a config entry
|
|
6
|
+
* named `memnexus`. Key presence alone is not proof the entry is ours: a cloned
|
|
7
|
+
* repository can ship a `memnexus`-named entry pointing anywhere, which suppresses a
|
|
8
|
+
* real install (#5177). These predicates answer one question — does the entry
|
|
9
|
+
* structurally execute our bridge? — binding on the executed TARGET (command binary,
|
|
10
|
+
* delegated package, or remote host).
|
|
11
|
+
*
|
|
12
|
+
* Terminal rule: every EXECUTABLE arm requires the genuine ours-TARGET AND the bridge
|
|
13
|
+
* invocation; the remote-url arm requires an exact host.
|
|
14
|
+
* - (A) `mx` arm: command basename is `mx` AND the bridge invocation `mcp serve` is at
|
|
15
|
+
* the START of args (`args[0]==='mcp' && args[1]==='serve'`; a trailing
|
|
16
|
+
* `--inject-rules` is allowed). Checking the invocation POSITION, not anywhere in
|
|
17
|
+
* args, rejects a decoy: `mx status mcp serve` runs `mx status`.
|
|
18
|
+
* - (B) node-runner arm: the EXECUTED package (first non-flag positional token, deno's
|
|
19
|
+
* `run` subcommand skipped) IS our scoped package as a token PREFIX (`@memnexus-ai/`,
|
|
20
|
+
* or deno's `npm:@memnexus-ai/`), AND `mcp serve` comes IMMEDIATELY AFTER that
|
|
21
|
+
* package token. Binding the package to the executed position rejects a decoy
|
|
22
|
+
* (`npx evil-pkg @memnexus-ai/cli mcp serve` runs evil-pkg); binding on a prefix (not
|
|
23
|
+
* a substring anywhere) rejects a foreign package that merely mentions our scope in a
|
|
24
|
+
* flag value; binding the invocation to right-after-the-package rejects
|
|
25
|
+
* `npx @memnexus-ai/cli status mcp serve` (runs `@memnexus-ai/cli status`).
|
|
26
|
+
* - (C) remote-url arm: a url/serverUrl/remoteUrl host EXACTLY equals our MCP server.
|
|
27
|
+
* Args are never a positive signal for a foreign command: these refinements only make
|
|
28
|
+
* each arm stricter, and a foreign command reaches no executable arm.
|
|
29
|
+
*
|
|
30
|
+
* Anything not positively recognized as ours returns false (safe error direction:
|
|
31
|
+
* worst case is a harmless re-write with a `.bak` backup; a false "true" is the
|
|
32
|
+
* suppression bug).
|
|
33
|
+
*
|
|
34
|
+
* SEVERITY CONTEXT: this predicate is a DEFAULT-SELECTION nudge — it sets
|
|
35
|
+
* `alreadyConfigured`, which only pre-unchecks a re-selectable install checkbox. It is
|
|
36
|
+
* NOT an execution gate: it cannot grant execution to any entry, it can only fail to
|
|
37
|
+
* auto-remediate a pre-existing one. The write path is unchanged (FR-5).
|
|
38
|
+
*/
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.oursMcpHosts = oursMcpHosts;
|
|
41
|
+
exports.exeBase = exeBase;
|
|
42
|
+
exports.isOursJsonEntry = isOursJsonEntry;
|
|
43
|
+
exports.isOursTomlBlock = isOursTomlBlock;
|
|
44
|
+
exports.parseMemnexusTomlBlock = parseMemnexusTomlBlock;
|
|
45
|
+
/** The package our JSON npx-fallback and TOML entries delegate to. */
|
|
46
|
+
const OURS_PACKAGE = '@memnexus-ai/'; // matches @memnexus-ai/cli (and future scoped pkgs)
|
|
47
|
+
/** Node runners that delegate to our published package in the fallback shapes. */
|
|
48
|
+
const NODE_RUNNERS = new Set(['npx', 'node', 'bunx', 'pnpm', 'yarn', 'deno']);
|
|
49
|
+
/** Hosts that count as our MCP server (remote-url agents). */
|
|
50
|
+
function oursMcpHosts() {
|
|
51
|
+
const hosts = new Set(['mcp.memnexus.ai']);
|
|
52
|
+
for (const raw of [process.env.MX_MCP_URL, process.env.MX_MCP_RESOURCE_URL]) {
|
|
53
|
+
if (raw) {
|
|
54
|
+
try {
|
|
55
|
+
hosts.add(new URL(raw).host);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
/* ignore an unparseable env override */
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return hosts;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* True when the bridge invocation `mcp serve` appears at the exact position `pos`
|
|
66
|
+
* (`tail[pos] === 'mcp' && tail[pos + 1] === 'serve'`). Position-bound, not
|
|
67
|
+
* anywhere-in-tail: a decoy `mcp serve` trailing an inert subcommand
|
|
68
|
+
* (`mx status mcp serve`, which runs `mx status`) must not qualify. Trailing tokens
|
|
69
|
+
* after `serve` (e.g. `--inject-rules`) are allowed.
|
|
70
|
+
*/
|
|
71
|
+
function bridgeInvokedAt(tail, pos) {
|
|
72
|
+
return tail[pos] === 'mcp' && tail[pos + 1] === 'serve';
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* True when some token IS our scoped package (a prefix match), not merely a token
|
|
76
|
+
* that contains our scope somewhere (which a foreign package could carry in a flag
|
|
77
|
+
* value). Accepts the deno `npm:@memnexus-ai/cli` form since deno is a node runner.
|
|
78
|
+
*/
|
|
79
|
+
function refsOursPackage(tokens) {
|
|
80
|
+
return tokens.some((t) => t.startsWith(OURS_PACKAGE) || t.startsWith('npm:' + OURS_PACKAGE));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The package a node runner actually EXECUTES = the first non-flag positional token.
|
|
84
|
+
* A bare ours-token in a later position is a decoy (`npx evil-pkg @memnexus-ai/cli` runs
|
|
85
|
+
* evil-pkg), so ownership must bind on the executed position, not any-position.
|
|
86
|
+
*
|
|
87
|
+
* Returns the INDEX in `tail` of the executed package token, or -1 if none. The caller
|
|
88
|
+
* both checks that token is ours AND that `mcp serve` immediately follows it, so the
|
|
89
|
+
* invocation position is bound to the actual package (see bridgeInvokedAt).
|
|
90
|
+
*
|
|
91
|
+
* deno is the one runner whose first non-flag token is a subcommand rather than the
|
|
92
|
+
* package (`deno run <script>`); we skip a leading `run` so the executed script is
|
|
93
|
+
* evaluated. deno support is purely DEFENSIVE — config-writer only ever writes `mx` or
|
|
94
|
+
* `npx` (config-writer.ts:38-51), never deno — so this keeps a hand-written
|
|
95
|
+
* `deno run npm:@memnexus-ai/cli` entry recognized rather than false-negatived (which
|
|
96
|
+
* would only cost a harmless re-write anyway). The decoy protection still holds for
|
|
97
|
+
* deno: `deno run evil.js npm:@memnexus-ai/cli` resolves to `evil.js`, not ours.
|
|
98
|
+
*/
|
|
99
|
+
function executedRunnerPackageIndex(base, tail) {
|
|
100
|
+
const start = base === 'deno' && tail[0] === 'run' ? 1 : 0;
|
|
101
|
+
for (let i = start; i < tail.length; i++) {
|
|
102
|
+
if (!tail[i].startsWith('-'))
|
|
103
|
+
return i;
|
|
104
|
+
}
|
|
105
|
+
return -1;
|
|
106
|
+
}
|
|
107
|
+
/** basename without a Windows executable extension, lowercased. */
|
|
108
|
+
function exeBase(cmd) {
|
|
109
|
+
const base = cmd.split(/[\\/]/).pop() ?? cmd;
|
|
110
|
+
return base.toLowerCase().replace(/\.(exe|cmd|bat)$/, '');
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* PERMISSIVE-STRUCTURAL ownership check for a JSON server entry.
|
|
114
|
+
*
|
|
115
|
+
* Recognizes every real ours-shape across all agents and past `mx` versions —
|
|
116
|
+
* including customized ones (extra `env`, extra args, older versions with no `type`
|
|
117
|
+
* field, absolute/`.exe` command path, and OpenCode's array-form command). Returns
|
|
118
|
+
* false for foreign commands and for anything it cannot positively recognize.
|
|
119
|
+
*/
|
|
120
|
+
function isOursJsonEntry(entry) {
|
|
121
|
+
if (!entry || typeof entry !== 'object')
|
|
122
|
+
return false;
|
|
123
|
+
const e = entry;
|
|
124
|
+
// Resolve the executed binary + trailing tokens. `command` is a string for most
|
|
125
|
+
// agents and an array for OpenCode's "local" transport (command = [exe, ...args]).
|
|
126
|
+
let exe;
|
|
127
|
+
let tail = [];
|
|
128
|
+
if (typeof e.command === 'string') {
|
|
129
|
+
exe = e.command;
|
|
130
|
+
tail = Array.isArray(e.args) ? e.args.map(String) : [];
|
|
131
|
+
}
|
|
132
|
+
else if (Array.isArray(e.command)) {
|
|
133
|
+
const arr = e.command.map(String);
|
|
134
|
+
exe = arr[0];
|
|
135
|
+
tail = arr.slice(1);
|
|
136
|
+
}
|
|
137
|
+
if (exe) {
|
|
138
|
+
const base = exeBase(exe);
|
|
139
|
+
// (A) our bridge binary + invocation at the START of args.
|
|
140
|
+
if (base === 'mx' && bridgeInvokedAt(tail, 0))
|
|
141
|
+
return true;
|
|
142
|
+
// (B) runner → our package in the EXECUTED position, with `mcp serve` immediately after it.
|
|
143
|
+
if (NODE_RUNNERS.has(base)) {
|
|
144
|
+
const idx = executedRunnerPackageIndex(base, tail);
|
|
145
|
+
if (idx !== -1 && refsOursPackage([tail[idx]]) && bridgeInvokedAt(tail, idx + 1))
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// (C) remote-url form: url/serverUrl/remoteUrl host is our MCP server.
|
|
150
|
+
const hosts = oursMcpHosts();
|
|
151
|
+
for (const key of ['url', 'serverUrl', 'remoteUrl']) {
|
|
152
|
+
const v = e[key];
|
|
153
|
+
if (typeof v === 'string') {
|
|
154
|
+
try {
|
|
155
|
+
if (hosts.has(new URL(v).host))
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
/* ignore an unparseable url field */
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return false; // foreign / unrecognized
|
|
164
|
+
}
|
|
165
|
+
/** Same ownership rule applied to a parsed TOML block. */
|
|
166
|
+
function isOursTomlBlock(block) {
|
|
167
|
+
if (!block || typeof block.command !== 'string')
|
|
168
|
+
return false;
|
|
169
|
+
const base = exeBase(block.command);
|
|
170
|
+
const args = block.args ?? [];
|
|
171
|
+
if (base === 'mx' && bridgeInvokedAt(args, 0))
|
|
172
|
+
return true;
|
|
173
|
+
if (NODE_RUNNERS.has(base)) {
|
|
174
|
+
const idx = executedRunnerPackageIndex(base, args);
|
|
175
|
+
if (idx !== -1 && refsOursPackage([args[idx]]) && bridgeInvokedAt(args, idx + 1))
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Strip a trailing `#` comment from a single TOML line, respecting quoted strings so
|
|
182
|
+
* a `#` inside a value is not treated as a comment start. Minimal: handles single and
|
|
183
|
+
* double quotes; the block grammar we read is fixed by what `buildTomlBlock` writes.
|
|
184
|
+
*/
|
|
185
|
+
function stripTomlComment(line) {
|
|
186
|
+
let inSingle = false;
|
|
187
|
+
let inDouble = false;
|
|
188
|
+
for (let i = 0; i < line.length; i++) {
|
|
189
|
+
const ch = line[i];
|
|
190
|
+
if (ch === "'" && !inDouble) {
|
|
191
|
+
inSingle = !inSingle;
|
|
192
|
+
}
|
|
193
|
+
else if (ch === '"' && !inSingle) {
|
|
194
|
+
inDouble = !inDouble;
|
|
195
|
+
}
|
|
196
|
+
else if (ch === '#' && !inSingle && !inDouble) {
|
|
197
|
+
return line.slice(0, i);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return line;
|
|
201
|
+
}
|
|
202
|
+
/** Parse a double- or single-quoted TOML string value. Returns undefined if not a quoted string. */
|
|
203
|
+
function parseTomlString(raw) {
|
|
204
|
+
const v = raw.trim();
|
|
205
|
+
if (v.length >= 2 && v[0] === '"' && v[v.length - 1] === '"') {
|
|
206
|
+
return v.slice(1, -1);
|
|
207
|
+
}
|
|
208
|
+
if (v.length >= 2 && v[0] === "'" && v[v.length - 1] === "'") {
|
|
209
|
+
return v.slice(1, -1);
|
|
210
|
+
}
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Parse a TOML inline array of quoted strings, e.g. `["mcp", "serve"]`.
|
|
215
|
+
* Returns the string elements; non-string elements are dropped. Returns undefined
|
|
216
|
+
* if the value is not an array literal.
|
|
217
|
+
*/
|
|
218
|
+
function parseTomlStringArray(raw) {
|
|
219
|
+
const v = raw.trim();
|
|
220
|
+
if (v[0] !== '[' || v[v.length - 1] !== ']')
|
|
221
|
+
return undefined;
|
|
222
|
+
const inner = v.slice(1, -1);
|
|
223
|
+
const out = [];
|
|
224
|
+
// Split on commas that are not inside quotes.
|
|
225
|
+
let cur = '';
|
|
226
|
+
let inSingle = false;
|
|
227
|
+
let inDouble = false;
|
|
228
|
+
for (let i = 0; i < inner.length; i++) {
|
|
229
|
+
const ch = inner[i];
|
|
230
|
+
if (ch === "'" && !inDouble)
|
|
231
|
+
inSingle = !inSingle;
|
|
232
|
+
else if (ch === '"' && !inSingle)
|
|
233
|
+
inDouble = !inDouble;
|
|
234
|
+
if (ch === ',' && !inSingle && !inDouble) {
|
|
235
|
+
const s = parseTomlString(cur);
|
|
236
|
+
if (s !== undefined)
|
|
237
|
+
out.push(s);
|
|
238
|
+
cur = '';
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
cur += ch;
|
|
242
|
+
}
|
|
243
|
+
if (cur.trim().length > 0) {
|
|
244
|
+
const s = parseTomlString(cur);
|
|
245
|
+
if (s !== undefined)
|
|
246
|
+
out.push(s);
|
|
247
|
+
}
|
|
248
|
+
return out;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Minimal line-based section parse of the `[mcp_servers.memnexus]` block.
|
|
252
|
+
*
|
|
253
|
+
* Replaces the previous raw-substring check (which fired on a commented-out header and
|
|
254
|
+
* could not read `command`). Strips comments first, locates the real section header
|
|
255
|
+
* (a line whose trimmed value is exactly `[mcp_servers.memnexus]`), then reads
|
|
256
|
+
* `key = value` lines until the next `[section]` header or EOF, extracting `command`
|
|
257
|
+
* (quoted string) and `args` (array of quoted strings).
|
|
258
|
+
*
|
|
259
|
+
* Returns null when there is no live section header. A full TOML library is not
|
|
260
|
+
* required; the block grammar is fixed by what `buildTomlBlock` writes.
|
|
261
|
+
*/
|
|
262
|
+
function parseMemnexusTomlBlock(content) {
|
|
263
|
+
const lines = content.split('\n');
|
|
264
|
+
let inSection = false;
|
|
265
|
+
let found = false;
|
|
266
|
+
const block = {};
|
|
267
|
+
for (const rawLine of lines) {
|
|
268
|
+
const line = stripTomlComment(rawLine).trim();
|
|
269
|
+
if (line.length === 0)
|
|
270
|
+
continue;
|
|
271
|
+
if (line.startsWith('[')) {
|
|
272
|
+
if (line === '[mcp_servers.memnexus]') {
|
|
273
|
+
inSection = true;
|
|
274
|
+
found = true;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
// Any other section header ends the memnexus block.
|
|
278
|
+
if (inSection)
|
|
279
|
+
inSection = false;
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (!inSection)
|
|
283
|
+
continue;
|
|
284
|
+
const eq = line.indexOf('=');
|
|
285
|
+
if (eq === -1)
|
|
286
|
+
continue;
|
|
287
|
+
const key = line.slice(0, eq).trim();
|
|
288
|
+
const value = line.slice(eq + 1).trim();
|
|
289
|
+
if (key === 'command') {
|
|
290
|
+
const s = parseTomlString(value);
|
|
291
|
+
if (s !== undefined)
|
|
292
|
+
block.command = s;
|
|
293
|
+
}
|
|
294
|
+
else if (key === 'args') {
|
|
295
|
+
const arr = parseTomlStringArray(value);
|
|
296
|
+
if (arr !== undefined)
|
|
297
|
+
block.args = arr;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return found ? block : null;
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=verify-ours.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-ours.js","sourceRoot":"","sources":["../../../src/lib/setup/verify-ours.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;;AASH,oCAYC;AAgDD,0BAGC;AAUD,0CA0CC;AASD,0CAUC;AAgFD,wDAsCC;AAnQD,sEAAsE;AACtE,MAAM,YAAY,GAAG,eAAe,CAAC,CAAC,oDAAoD;AAE1F,kFAAkF;AAClF,MAAM,YAAY,GAAG,IAAI,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