@memnexus-ai/cli 1.7.223 → 1.7.225
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/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +27 -6
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +66 -5
- package/dist/commands/setup.js.map +1 -1
- package/dist/lib/setup/detector.d.ts.map +1 -1
- package/dist/lib/setup/detector.js +33 -17
- package/dist/lib/setup/detector.js.map +1 -1
- package/dist/lib/setup/index.d.ts +2 -1
- package/dist/lib/setup/index.d.ts.map +1 -1
- package/dist/lib/setup/index.js +5 -1
- package/dist/lib/setup/index.js.map +1 -1
- package/dist/lib/setup/rules-templates.d.ts +8 -0
- package/dist/lib/setup/rules-templates.d.ts.map +1 -1
- package/dist/lib/setup/rules-templates.js +9 -1
- package/dist/lib/setup/rules-templates.js.map +1 -1
- package/dist/lib/setup/scope.d.ts +36 -0
- package/dist/lib/setup/scope.d.ts.map +1 -0
- package/dist/lib/setup/scope.js +52 -0
- package/dist/lib/setup/scope.js.map +1 -0
- package/dist/lib/setup/verifier.d.ts +19 -2
- package/dist/lib/setup/verifier.d.ts.map +1 -1
- package/dist/lib/setup/verifier.js +129 -36
- package/dist/lib/setup/verifier.js.map +1 -1
- package/dist/lib/terminal-safe.d.ts +32 -0
- package/dist/lib/terminal-safe.d.ts.map +1 -0
- package/dist/lib/terminal-safe.js +47 -0
- package/dist/lib/terminal-safe.js.map +1 -0
- package/package.json +2 -2
|
@@ -39,21 +39,66 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.displayPath = displayPath;
|
|
42
43
|
exports.verifyAgent = verifyAgent;
|
|
43
44
|
exports.verifyAll = verifyAll;
|
|
44
45
|
const node_fs_1 = require("node:fs");
|
|
45
46
|
const node_os_1 = __importDefault(require("node:os"));
|
|
47
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
46
48
|
const registry_js_1 = require("./registry.js");
|
|
47
49
|
const detector_js_1 = require("./detector.js");
|
|
48
50
|
const rules_writer_js_1 = require("./rules-writer.js");
|
|
49
51
|
const rules_templates_js_1 = require("./rules-templates.js");
|
|
50
52
|
const promises_1 = require("node:fs/promises");
|
|
53
|
+
/**
|
|
54
|
+
* Largest steering file the verifier will read. The CLI's own steering output is
|
|
55
|
+
* a few KB; this is roughly 50x that, so it bounds attacker-chosen work without
|
|
56
|
+
* rejecting anything we produce or a user plausibly hand-writes.
|
|
57
|
+
*/
|
|
58
|
+
const MAX_STEERING_FILE_BYTES = 256 * 1024;
|
|
51
59
|
const config_js_1 = require("../config.js");
|
|
52
60
|
const package_json_1 = __importDefault(require("../../../package.json"));
|
|
61
|
+
/**
|
|
62
|
+
* Resolve an agent's project-scoped MCP config path, or undefined when the agent
|
|
63
|
+
* has no project form (registry uses '' for global-only agents) or we are not
|
|
64
|
+
* inside a project.
|
|
65
|
+
*
|
|
66
|
+
* Read-only mirror of the path `mx setup` writes at project scope. This file must
|
|
67
|
+
* never import from config-writer.ts — verification is a read path (#4919).
|
|
68
|
+
*/
|
|
69
|
+
function resolveProjectConfigPath(agent, projectDir) {
|
|
70
|
+
if (!projectDir)
|
|
71
|
+
return undefined;
|
|
72
|
+
if (!agent.mcp.projectConfigPath)
|
|
73
|
+
return undefined;
|
|
74
|
+
return node_path_1.default.join(projectDir, agent.mcp.projectConfigPath);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Render a path for display without leaking the user's home directory or
|
|
78
|
+
* username. `mx mcp doctor --json` gets pasted into issue reports and into agent
|
|
79
|
+
* context, and global paths are already shown `~`-relative, so an absolute
|
|
80
|
+
* project path would be the only place identifying the machine.
|
|
81
|
+
*/
|
|
82
|
+
function displayPath(absolute, projectDir) {
|
|
83
|
+
if (projectDir && (absolute === projectDir || absolute.startsWith(projectDir + node_path_1.default.sep))) {
|
|
84
|
+
const relative = node_path_1.default.relative(projectDir, absolute);
|
|
85
|
+
return relative === '' ? '.' : `./${relative}`;
|
|
86
|
+
}
|
|
87
|
+
const home = node_os_1.default.homedir();
|
|
88
|
+
if (home && (absolute === home || absolute.startsWith(home + node_path_1.default.sep))) {
|
|
89
|
+
return `~${absolute.slice(home.length)}`;
|
|
90
|
+
}
|
|
91
|
+
return absolute;
|
|
92
|
+
}
|
|
53
93
|
/**
|
|
54
94
|
* Verify a single agent's setup.
|
|
95
|
+
*
|
|
96
|
+
* @param projectDir When set, project-scoped config and steering files are checked
|
|
97
|
+
* IN ADDITION TO the global ones. `mx setup` defaults to project scope inside a
|
|
98
|
+
* git project (setup.ts:203-207), so a global-only check reported working
|
|
99
|
+
* project installs as broken (#4919). Either location passing is a pass.
|
|
55
100
|
*/
|
|
56
|
-
async function verifyAgent(agent) {
|
|
101
|
+
async function verifyAgent(agent, projectDir) {
|
|
57
102
|
const checks = [];
|
|
58
103
|
const platform = node_os_1.default.platform();
|
|
59
104
|
// Manual config format (e.g., ChatGPT Desktop) — skip file checks,
|
|
@@ -91,15 +136,26 @@ async function verifyAgent(agent) {
|
|
|
91
136
|
}
|
|
92
137
|
}
|
|
93
138
|
else {
|
|
94
|
-
// 1. Check config file exists
|
|
139
|
+
// 1. Check config file exists — global OR project scope
|
|
95
140
|
const globalPath = agent.mcp.globalConfigPath[platform];
|
|
96
|
-
const
|
|
141
|
+
const globalExists = globalPath !== undefined && globalPath !== '' && (0, node_fs_1.existsSync)((0, detector_js_1.resolvePath)(globalPath));
|
|
142
|
+
const projectPath = resolveProjectConfigPath(agent, projectDir);
|
|
143
|
+
const projectExists = projectPath !== undefined && (0, node_fs_1.existsSync)(projectPath);
|
|
144
|
+
const foundPaths = [];
|
|
145
|
+
if (globalExists && globalPath)
|
|
146
|
+
foundPaths.push(`${globalPath} (global)`);
|
|
147
|
+
if (projectExists && projectPath)
|
|
148
|
+
foundPaths.push(`${displayPath(projectPath, projectDir)} (project)`);
|
|
149
|
+
const searched = [globalPath || '(no global path for this platform)'];
|
|
150
|
+
if (projectPath)
|
|
151
|
+
searched.push(displayPath(projectPath, projectDir));
|
|
152
|
+
const configExists = globalExists || projectExists;
|
|
97
153
|
checks.push({
|
|
98
154
|
name: 'Config file exists',
|
|
99
155
|
passed: configExists,
|
|
100
156
|
message: configExists
|
|
101
|
-
? `Found: ${
|
|
102
|
-
: `Not found: ${
|
|
157
|
+
? `Found: ${foundPaths.join(', ')}`
|
|
158
|
+
: `Not found: ${searched.join(', ')}`,
|
|
103
159
|
});
|
|
104
160
|
}
|
|
105
161
|
// 2. Check MCP bridge availability
|
|
@@ -113,44 +169,73 @@ async function verifyAgent(agent) {
|
|
|
113
169
|
}
|
|
114
170
|
// 4. Check steering file (if agent supports it)
|
|
115
171
|
if (agent.steering) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
172
|
+
// Decided on CONTENT, not file existence. `CLAUDE.md` and `AGENTS.md` are
|
|
173
|
+
// ordinary project files that many repositories have for their own reasons —
|
|
174
|
+
// this repository has both. Selecting the project file merely because it
|
|
175
|
+
// exists would fail a perfectly good global install for anyone who runs
|
|
176
|
+
// `mx mcp doctor` inside such a repo: the same false-failure #4919 exists to
|
|
177
|
+
// remove, aimed at a different group. Project is preferred only when it
|
|
178
|
+
// actually carries MemNexus rules, because that is what a project-scoped
|
|
179
|
+
// install writes (setup.ts:396-408).
|
|
180
|
+
const candidates = [
|
|
181
|
+
projectDir ? (0, rules_writer_js_1.resolveSteeringPath)(agent, 'project', projectDir) : null,
|
|
182
|
+
(0, rules_writer_js_1.resolveSteeringPath)(agent, 'global'),
|
|
183
|
+
].filter((p) => p !== null);
|
|
184
|
+
if (candidates.length > 0) {
|
|
185
|
+
let version = null;
|
|
186
|
+
let versionPath;
|
|
187
|
+
let anyExists = false;
|
|
188
|
+
let anyUnreadable = false;
|
|
189
|
+
for (const candidate of candidates) {
|
|
190
|
+
if (!(0, node_fs_1.existsSync)(candidate))
|
|
191
|
+
continue;
|
|
192
|
+
anyExists = true;
|
|
120
193
|
try {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
194
|
+
// Bound the read before doing it. Content checking means we now read a
|
|
195
|
+
// file a cloned repository controls the size of, on a command users run
|
|
196
|
+
// casually. Unbounded, a 64 MB CLAUDE.md costs ~133 MB of heap and a
|
|
197
|
+
// symlink to /dev/zero reaches ~721 MB RSS — an out-of-memory kill on a
|
|
198
|
+
// constrained runner. `stat` (not `lstat`) resolves symlinks on purpose:
|
|
199
|
+
// we want the size of what we would actually read. Rejecting anything
|
|
200
|
+
// that is not a regular file removes the character-device case entirely.
|
|
201
|
+
// 256 KB is ~50x the largest steering file the CLI itself writes. The
|
|
202
|
+
// same bounding exists for the bridge log at mcp.ts (KI-SEC-007).
|
|
203
|
+
const stats = await (0, promises_1.stat)(candidate);
|
|
204
|
+
if (!stats.isFile() || stats.size > MAX_STEERING_FILE_BYTES) {
|
|
205
|
+
anyUnreadable = true;
|
|
206
|
+
continue;
|
|
132
207
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
});
|
|
208
|
+
const parsed = (0, rules_templates_js_1.parseSteeringVersion)(await (0, promises_1.readFile)(candidate, 'utf-8'));
|
|
209
|
+
// First candidate wins — the array is already in preference order.
|
|
210
|
+
if (parsed && version === null) {
|
|
211
|
+
version = parsed;
|
|
212
|
+
versionPath = candidate;
|
|
139
213
|
}
|
|
140
214
|
}
|
|
141
215
|
catch {
|
|
142
|
-
|
|
143
|
-
name: 'Steering rules',
|
|
144
|
-
passed: false,
|
|
145
|
-
message: `Failed to read: ${steeringPath}`,
|
|
146
|
-
});
|
|
216
|
+
anyUnreadable = true;
|
|
147
217
|
}
|
|
148
218
|
}
|
|
219
|
+
if (version) {
|
|
220
|
+
const isCurrent = version === package_json_1.default.version;
|
|
221
|
+
checks.push({
|
|
222
|
+
name: 'Steering rules',
|
|
223
|
+
passed: true,
|
|
224
|
+
message: isCurrent
|
|
225
|
+
? `Found (v${version}, current): ${displayPath(versionPath, projectDir)}`
|
|
226
|
+
: `Found (v${version}, CLI is v${package_json_1.default.version} — run \`mx setup rules --agent ${agent.id}\` to update): ${displayPath(versionPath, projectDir)}`,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
149
229
|
else {
|
|
230
|
+
const where = candidates.map((c) => displayPath(c, projectDir)).join(', ');
|
|
150
231
|
checks.push({
|
|
151
232
|
name: 'Steering rules',
|
|
152
233
|
passed: false,
|
|
153
|
-
message:
|
|
234
|
+
message: anyUnreadable
|
|
235
|
+
? `Failed to read: ${where}. Run: mx setup rules --agent ${agent.id}`
|
|
236
|
+
: anyExists
|
|
237
|
+
? `No MemNexus section found in: ${where}. Run: mx setup rules --agent ${agent.id}`
|
|
238
|
+
: `Not found: ${where}. Run: mx setup rules --agent ${agent.id}`,
|
|
154
239
|
});
|
|
155
240
|
}
|
|
156
241
|
}
|
|
@@ -193,8 +278,13 @@ async function verifyAgent(agent) {
|
|
|
193
278
|
}
|
|
194
279
|
/**
|
|
195
280
|
* Verify all configured agents.
|
|
281
|
+
*
|
|
282
|
+
* @param projectDir When set (callers pass the detected git project root), agents
|
|
283
|
+
* configured at project scope are verified too. Without it this only ever saw
|
|
284
|
+
* global installs, so the onboarding flow's project-scoped install was reported
|
|
285
|
+
* as missing (#4919).
|
|
196
286
|
*/
|
|
197
|
-
async function verifyAll() {
|
|
287
|
+
async function verifyAll(projectDir) {
|
|
198
288
|
const agents = (0, registry_js_1.getSortedAgents)();
|
|
199
289
|
const platform = node_os_1.default.platform();
|
|
200
290
|
const results = [];
|
|
@@ -205,10 +295,13 @@ async function verifyAll() {
|
|
|
205
295
|
if (agent.mcp.configFormat === 'manual') {
|
|
206
296
|
continue;
|
|
207
297
|
}
|
|
208
|
-
// Only verify agents that have a config file present
|
|
298
|
+
// Only verify agents that have a config file present — in either scope
|
|
209
299
|
const globalPath = agent.mcp.globalConfigPath[platform];
|
|
210
|
-
|
|
211
|
-
|
|
300
|
+
const globalExists = !!globalPath && (0, node_fs_1.existsSync)((0, detector_js_1.resolvePath)(globalPath));
|
|
301
|
+
const projectPath = resolveProjectConfigPath(agent, projectDir);
|
|
302
|
+
const projectExists = !!projectPath && (0, node_fs_1.existsSync)(projectPath);
|
|
303
|
+
if (globalExists || projectExists) {
|
|
304
|
+
results.push(await verifyAgent(agent, projectDir));
|
|
212
305
|
}
|
|
213
306
|
}
|
|
214
307
|
return results;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifier.js","sourceRoot":"","sources":["../../../src/lib/setup/verifier.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"verifier.js","sourceRoot":"","sources":["../../../src/lib/setup/verifier.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCH,kCAUC;AAUD,kCA2LC;AAUD,8BAuBC;AAvRD,qCAAqC;AACrC,sDAAyB;AACzB,0DAA6B;AAE7B,+CAAgD;AAChD,+CAA4C;AAC5C,uDAAwD;AACxD,6DAA4D;AAC5D,+CAAkD;AAElD;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,GAAG,GAAG,IAAI,CAAC;AAC3C,4CAAsC;AACtC,yEAAgD;AAEhD;;;;;;;GAOG;AACH,SAAS,wBAAwB,CAAC,KAAsB,EAAE,UAAmB;IAC3E,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IAClC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAiB;QAAE,OAAO,SAAS,CAAC;IACnD,O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EAA4E;QAC5E,IAAI,KAAK,CAAC,GAAG,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;YACxC,SAAS;QACX,CAAC;QACD,uEAAuE;QACvE,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACxD,MAAM,YAAY,GAAG,CAAC,CAAC,UAAU,IAAI,IAAA,oBAAU,EAAC,IAAA,yBAAW,EAAC,UAAU,CAAC,CAAC,CAAC;QACzE,MAAM,WAAW,GAAG,wBAAwB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAChE,MAAM,aAAa,GAAG,CAAC,CAAC,WAAW,IAAI,IAAA,oBAAU,EAAC,WAAW,CAAC,CAAC;QAC/D,IAAI,YAAY,IAAI,aAAa,EAAE,CAAC;YAClC,OAAO,CAAC,IAAI,CAAC,MAAM,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal output sanitation (KI-SEC-007).
|
|
3
|
+
*
|
|
4
|
+
* Anything we print that originated in a file, a log line or a network response
|
|
5
|
+
* can carry ANSI/OSC control sequences. `ESC[2J ESC[1;1H` clears the screen and
|
|
6
|
+
* repositions the cursor, which lets attacker-controlled text scroll away real
|
|
7
|
+
* output and paint replacement text — in `mx mcp doctor`, whose entire job is to
|
|
8
|
+
* tell the user whether their setup is healthy. On terminals with OSC 52 the same
|
|
9
|
+
* class of sequence reaches the clipboard.
|
|
10
|
+
*
|
|
11
|
+
* `mx mcp doctor` printed bridge log lines through an inline copy of this filter
|
|
12
|
+
* (mcp.ts). Verification now also reads a PROJECT steering file, which can belong
|
|
13
|
+
* to a repository the user cloned but did not write, so the filter is shared here
|
|
14
|
+
* and applied at every render site rather than duplicated per call site.
|
|
15
|
+
*/
|
|
16
|
+
import type { VerifyResult } from './setup/types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Strip C0 control characters and DEL. Tab, newline and carriage return are
|
|
19
|
+
* removed too: these values are rendered inline in single-line status output, so
|
|
20
|
+
* a newline is layout forgery rather than formatting.
|
|
21
|
+
*/
|
|
22
|
+
export declare function sanitizeTerminalText(text: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Sanitize every message in a set of verification results.
|
|
25
|
+
*
|
|
26
|
+
* Applied once, immediately after `verifyAll()` returns, so the human renderer,
|
|
27
|
+
* the `--json` output and any future consumer are all covered by construction.
|
|
28
|
+
* Deliberately NOT done inside the verifier: the verifier's job is to report what
|
|
29
|
+
* it found, and a value that is safe for a terminal is a property of rendering.
|
|
30
|
+
*/
|
|
31
|
+
export declare function sanitizeVerifyResults(results: VerifyResult[]): VerifyResult[];
|
|
32
|
+
//# sourceMappingURL=terminal-safe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-safe.d.ts","sourceRoot":"","sources":["../../src/lib/terminal-safe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAS7E"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Terminal output sanitation (KI-SEC-007).
|
|
4
|
+
*
|
|
5
|
+
* Anything we print that originated in a file, a log line or a network response
|
|
6
|
+
* can carry ANSI/OSC control sequences. `ESC[2J ESC[1;1H` clears the screen and
|
|
7
|
+
* repositions the cursor, which lets attacker-controlled text scroll away real
|
|
8
|
+
* output and paint replacement text — in `mx mcp doctor`, whose entire job is to
|
|
9
|
+
* tell the user whether their setup is healthy. On terminals with OSC 52 the same
|
|
10
|
+
* class of sequence reaches the clipboard.
|
|
11
|
+
*
|
|
12
|
+
* `mx mcp doctor` printed bridge log lines through an inline copy of this filter
|
|
13
|
+
* (mcp.ts). Verification now also reads a PROJECT steering file, which can belong
|
|
14
|
+
* to a repository the user cloned but did not write, so the filter is shared here
|
|
15
|
+
* and applied at every render site rather than duplicated per call site.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.sanitizeTerminalText = sanitizeTerminalText;
|
|
19
|
+
exports.sanitizeVerifyResults = sanitizeVerifyResults;
|
|
20
|
+
/**
|
|
21
|
+
* Strip C0 control characters and DEL. Tab, newline and carriage return are
|
|
22
|
+
* removed too: these values are rendered inline in single-line status output, so
|
|
23
|
+
* a newline is layout forgery rather than formatting.
|
|
24
|
+
*/
|
|
25
|
+
function sanitizeTerminalText(text) {
|
|
26
|
+
// eslint-disable-next-line no-control-regex
|
|
27
|
+
return text.replace(/[\x00-\x1f\x7f]/g, '');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Sanitize every message in a set of verification results.
|
|
31
|
+
*
|
|
32
|
+
* Applied once, immediately after `verifyAll()` returns, so the human renderer,
|
|
33
|
+
* the `--json` output and any future consumer are all covered by construction.
|
|
34
|
+
* Deliberately NOT done inside the verifier: the verifier's job is to report what
|
|
35
|
+
* it found, and a value that is safe for a terminal is a property of rendering.
|
|
36
|
+
*/
|
|
37
|
+
function sanitizeVerifyResults(results) {
|
|
38
|
+
return results.map((result) => ({
|
|
39
|
+
...result,
|
|
40
|
+
agentName: sanitizeTerminalText(result.agentName),
|
|
41
|
+
checks: result.checks.map((check) => ({
|
|
42
|
+
...check,
|
|
43
|
+
message: sanitizeTerminalText(check.message),
|
|
44
|
+
})),
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=terminal-safe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-safe.js","sourceRoot":"","sources":["../../src/lib/terminal-safe.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AASH,oDAGC;AAUD,sDASC;AA3BD;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,4CAA4C;IAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CAAC,OAAuB;IAC3D,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC9B,GAAG,MAAM;QACT,SAAS,EAAE,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC;QACjD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACpC,GAAG,KAAK;YACR,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,OAAO,CAAC;SAC7C,CAAC,CAAC;KACJ,CAAC,CAAC,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memnexus-ai/cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.225",
|
|
4
4
|
"description": "Command-line interface for MemNexus Core API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"node": ">=18.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@memnexus-ai/typescript-sdk": "^1.73.
|
|
37
|
+
"@memnexus-ai/typescript-sdk": "^1.73.3",
|
|
38
38
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
39
39
|
"axios": "^1.13.6",
|
|
40
40
|
"chalk": "^5.3.0",
|