@remnic/cli 1.0.8 → 1.0.10
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 +8 -2
- package/assets/download-datasets.sh +662 -0
- package/bin/engram.cjs +29 -11
- package/bin/remnic.cjs +29 -10
- package/dist/assets/download-datasets.sh +17 -2
- package/dist/index.js +2976 -680
- package/package.json +10 -6
package/bin/engram.cjs
CHANGED
|
@@ -7,15 +7,23 @@
|
|
|
7
7
|
const { resolve } = require("node:path");
|
|
8
8
|
const { existsSync } = require("node:fs");
|
|
9
9
|
const { execFileSync } = require("node:child_process");
|
|
10
|
+
const { constants: osConstants } = require("node:os");
|
|
10
11
|
|
|
11
12
|
const cwd = __dirname;
|
|
12
13
|
const distEntry = resolve(cwd, "../dist/index.js");
|
|
13
14
|
const srcEntry = resolve(cwd, "../src/index.ts");
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
function exitCodeForSignal(signal) {
|
|
17
|
+
const signalNumber = osConstants.signals?.[signal];
|
|
18
|
+
return typeof signalNumber === "number" ? 128 + signalNumber : 1;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function resolveLocalTsx() {
|
|
22
|
+
const tsxCandidates = [
|
|
23
|
+
resolve(cwd, "../node_modules/.bin/tsx"),
|
|
24
|
+
resolve(cwd, "../../../node_modules/.bin/tsx"),
|
|
25
|
+
];
|
|
26
|
+
return tsxCandidates.find((c) => existsSync(c));
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
try {
|
|
@@ -26,22 +34,29 @@ try {
|
|
|
26
34
|
[distEntry, ...process.argv.slice(2)],
|
|
27
35
|
{
|
|
28
36
|
stdio: "inherit",
|
|
29
|
-
env: { ...process.env, REMNIC_CLI_BIN: "1", ENGRAM_CLI_BIN: "1"
|
|
37
|
+
env: { ...process.env, REMNIC_CLI_BIN: "1", ENGRAM_CLI_BIN: "1" },
|
|
30
38
|
},
|
|
31
39
|
);
|
|
32
40
|
} else {
|
|
33
41
|
// Development: run TypeScript source via tsx
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
const hasSrcEntry = existsSync(srcEntry);
|
|
43
|
+
const tsxCmd = hasSrcEntry ? resolveLocalTsx() : undefined;
|
|
44
|
+
if (!tsxCmd) {
|
|
45
|
+
if (hasSrcEntry) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`tsx runtime is missing for source CLI entrypoint: ${srcEntry}. Install dependencies or rebuild @remnic/cli.`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
throw new Error(
|
|
51
|
+
`built CLI entrypoint is missing: ${distEntry}. Rebuild or reinstall @remnic/cli.`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
39
54
|
execFileSync(
|
|
40
55
|
tsxCmd,
|
|
41
56
|
[srcEntry, ...process.argv.slice(2)],
|
|
42
57
|
{
|
|
43
58
|
stdio: "inherit",
|
|
44
|
-
env: { ...process.env, REMNIC_CLI_BIN: "1", ENGRAM_CLI_BIN: "1"
|
|
59
|
+
env: { ...process.env, REMNIC_CLI_BIN: "1", ENGRAM_CLI_BIN: "1" },
|
|
45
60
|
},
|
|
46
61
|
);
|
|
47
62
|
}
|
|
@@ -49,6 +64,9 @@ try {
|
|
|
49
64
|
// execFileSync throws on non-zero exit — propagate the child's exit code.
|
|
50
65
|
if (err.status != null) {
|
|
51
66
|
process.exitCode = err.status;
|
|
67
|
+
} else if (err.signal) {
|
|
68
|
+
process.exitCode = exitCodeForSignal(err.signal);
|
|
69
|
+
process.kill(process.pid, err.signal);
|
|
52
70
|
} else {
|
|
53
71
|
process.stderr.write(`Fatal: ${err.message}\n`);
|
|
54
72
|
process.exitCode = 1;
|
package/bin/remnic.cjs
CHANGED
|
@@ -7,36 +7,55 @@
|
|
|
7
7
|
const { resolve } = require("node:path");
|
|
8
8
|
const { existsSync } = require("node:fs");
|
|
9
9
|
const { execFileSync } = require("node:child_process");
|
|
10
|
+
const { constants: osConstants } = require("node:os");
|
|
10
11
|
|
|
11
12
|
const cwd = __dirname;
|
|
12
13
|
const distEntry = resolve(cwd, "../dist/index.js");
|
|
13
14
|
const srcEntry = resolve(cwd, "../src/index.ts");
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
function exitCodeForSignal(signal) {
|
|
17
|
+
const signalNumber = osConstants.signals?.[signal];
|
|
18
|
+
return typeof signalNumber === "number" ? 128 + signalNumber : 1;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function resolveLocalTsx() {
|
|
22
|
+
const tsxCandidates = [
|
|
23
|
+
resolve(cwd, "../node_modules/.bin/tsx"),
|
|
24
|
+
resolve(cwd, "../../../node_modules/.bin/tsx"),
|
|
25
|
+
];
|
|
26
|
+
return tsxCandidates.find((c) => existsSync(c));
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
try {
|
|
21
30
|
if (existsSync(distEntry)) {
|
|
22
31
|
execFileSync(process.execPath, [distEntry, ...process.argv.slice(2)], {
|
|
23
32
|
stdio: "inherit",
|
|
24
|
-
env: { ...process.env, REMNIC_CLI_BIN: "1"
|
|
33
|
+
env: { ...process.env, REMNIC_CLI_BIN: "1" },
|
|
25
34
|
});
|
|
26
35
|
} else {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
const hasSrcEntry = existsSync(srcEntry);
|
|
37
|
+
const tsxCmd = hasSrcEntry ? resolveLocalTsx() : undefined;
|
|
38
|
+
if (!tsxCmd) {
|
|
39
|
+
if (hasSrcEntry) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`tsx runtime is missing for source CLI entrypoint: ${srcEntry}. Install dependencies or rebuild @remnic/cli.`,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
throw new Error(
|
|
45
|
+
`built CLI entrypoint is missing: ${distEntry}. Rebuild or reinstall @remnic/cli.`,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
32
48
|
execFileSync(tsxCmd, [srcEntry, ...process.argv.slice(2)], {
|
|
33
49
|
stdio: "inherit",
|
|
34
|
-
env: { ...process.env, REMNIC_CLI_BIN: "1"
|
|
50
|
+
env: { ...process.env, REMNIC_CLI_BIN: "1" },
|
|
35
51
|
});
|
|
36
52
|
}
|
|
37
53
|
} catch (err) {
|
|
38
54
|
if (err.status != null) {
|
|
39
55
|
process.exitCode = err.status;
|
|
56
|
+
} else if (err.signal) {
|
|
57
|
+
process.exitCode = exitCodeForSignal(err.signal);
|
|
58
|
+
process.kill(process.pid, err.signal);
|
|
40
59
|
} else {
|
|
41
60
|
process.stderr.write(`Fatal: ${err.message}\n`);
|
|
42
61
|
process.exitCode = 1;
|
|
@@ -562,11 +562,11 @@ PY
|
|
|
562
562
|
|
|
563
563
|
download_memoryagentbench() {
|
|
564
564
|
local dir="$DATASETS_DIR/memoryagentbench"
|
|
565
|
-
if [[ -f "$dir/Accurate_Retrieval.json" && -f "$dir/Test_Time_Learning.json" && -f "$dir/Long_Range_Understanding.json" && -f "$dir/Conflict_Resolution.json" ]]; then
|
|
565
|
+
if [[ -f "$dir/Accurate_Retrieval.json" && -f "$dir/Test_Time_Learning.json" && -f "$dir/Long_Range_Understanding.json" && -f "$dir/Conflict_Resolution.json" && -f "$dir/entity2id.json" ]]; then
|
|
566
566
|
echo "[memoryagentbench] Already downloaded at $dir"
|
|
567
567
|
return
|
|
568
568
|
fi
|
|
569
|
-
echo "[memoryagentbench] Downloading from Hugging Face
|
|
569
|
+
echo "[memoryagentbench] Downloading from Hugging Face sources (ai-hyz/MemoryAgentBench)..."
|
|
570
570
|
mkdir -p "$dir"
|
|
571
571
|
require_python_modules huggingface_hub pyarrow
|
|
572
572
|
local python_bin
|
|
@@ -606,6 +606,21 @@ for parquet_file, output_name in targets:
|
|
|
606
606
|
with output_path.open("w", encoding="utf-8") as handle:
|
|
607
607
|
json.dump(rows, handle, ensure_ascii=False)
|
|
608
608
|
print(f"[memoryagentbench] Wrote {output_name} ({len(rows)} samples)")
|
|
609
|
+
|
|
610
|
+
entity_output_path = out_dir / "entity2id.json"
|
|
611
|
+
if entity_output_path.exists() and entity_output_path.stat().st_size > 0:
|
|
612
|
+
print("[memoryagentbench] Reusing entity2id.json")
|
|
613
|
+
else:
|
|
614
|
+
entity_path = hf_hub_download(
|
|
615
|
+
repo_id="ai-hyz/MemoryAgentBench",
|
|
616
|
+
repo_type="dataset",
|
|
617
|
+
filename="entity2id.json",
|
|
618
|
+
)
|
|
619
|
+
with open(entity_path, "r", encoding="utf-8") as source:
|
|
620
|
+
entity_mapping = json.load(source)
|
|
621
|
+
with entity_output_path.open("w", encoding="utf-8") as handle:
|
|
622
|
+
json.dump(entity_mapping, handle, ensure_ascii=False)
|
|
623
|
+
print(f"[memoryagentbench] Wrote entity2id.json ({len(entity_mapping)} mappings)")
|
|
609
624
|
PY
|
|
610
625
|
echo "[memoryagentbench] Downloaded to $dir"
|
|
611
626
|
}
|