@gamaze/hicortex 0.3.0 → 0.3.2
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/init.js +19 -7
- package/dist/mcp-server.js +35 -2
- package/dist/nightly.js +14 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/init.js
CHANGED
|
@@ -156,17 +156,29 @@ Tell them: "Get a license key at https://hicortex.gamaze.com/ — after purchase
|
|
|
156
156
|
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(CC_COMMANDS_DIR, "hicortex-activate.md"), activateContent);
|
|
157
157
|
console.log(` ✓ Installed /learn and /hicortex-activate commands in ${CC_COMMANDS_DIR}`);
|
|
158
158
|
}
|
|
159
|
+
function getPackageVersion() {
|
|
160
|
+
try {
|
|
161
|
+
const pkgPath = (0, node_path_1.join)(__dirname, "..", "package.json");
|
|
162
|
+
const pkg = JSON.parse((0, node_fs_1.readFileSync)(pkgPath, "utf-8"));
|
|
163
|
+
return pkg.version ?? "latest";
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return "latest";
|
|
167
|
+
}
|
|
168
|
+
}
|
|
159
169
|
function installDaemon() {
|
|
160
170
|
const os = (0, node_os_1.platform)();
|
|
161
171
|
const npxPath = findNpxPath();
|
|
172
|
+
const version = getPackageVersion();
|
|
173
|
+
const packageSpec = `@gamaze/hicortex@${version}`;
|
|
162
174
|
if (os === "darwin") {
|
|
163
|
-
return installLaunchd(npxPath);
|
|
175
|
+
return installLaunchd(npxPath, packageSpec);
|
|
164
176
|
}
|
|
165
177
|
else if (os === "linux") {
|
|
166
|
-
return installSystemd(npxPath);
|
|
178
|
+
return installSystemd(npxPath, packageSpec);
|
|
167
179
|
}
|
|
168
180
|
else {
|
|
169
|
-
console.log(` ⚠ Unsupported platform: ${os}. Start the server manually: npx
|
|
181
|
+
console.log(` ⚠ Unsupported platform: ${os}. Start the server manually: npx ${packageSpec} server`);
|
|
170
182
|
return false;
|
|
171
183
|
}
|
|
172
184
|
}
|
|
@@ -178,7 +190,7 @@ function findNpxPath() {
|
|
|
178
190
|
return "/usr/local/bin/npx";
|
|
179
191
|
}
|
|
180
192
|
}
|
|
181
|
-
function installLaunchd(npxPath) {
|
|
193
|
+
function installLaunchd(npxPath, packageSpec) {
|
|
182
194
|
const plistDir = (0, node_path_1.join)((0, node_os_1.homedir)(), "Library", "LaunchAgents");
|
|
183
195
|
const plistPath = (0, node_path_1.join)(plistDir, "com.gamaze.hicortex.plist");
|
|
184
196
|
const logPath = (0, node_path_1.join)(HICORTEX_HOME, "server.log");
|
|
@@ -193,7 +205,7 @@ function installLaunchd(npxPath) {
|
|
|
193
205
|
<array>
|
|
194
206
|
<string>${npxPath}</string>
|
|
195
207
|
<string>-y</string>
|
|
196
|
-
<string
|
|
208
|
+
<string>${packageSpec}</string>
|
|
197
209
|
<string>server</string>
|
|
198
210
|
</array>
|
|
199
211
|
<key>KeepAlive</key>
|
|
@@ -229,7 +241,7 @@ function installLaunchd(npxPath) {
|
|
|
229
241
|
return false;
|
|
230
242
|
}
|
|
231
243
|
}
|
|
232
|
-
function installSystemd(npxPath) {
|
|
244
|
+
function installSystemd(npxPath, packageSpec) {
|
|
233
245
|
const unitDir = (0, node_path_1.join)((0, node_os_1.homedir)(), ".config", "systemd", "user");
|
|
234
246
|
const servicePath = (0, node_path_1.join)(unitDir, "hicortex.service");
|
|
235
247
|
const service = `[Unit]
|
|
@@ -237,7 +249,7 @@ Description=Hicortex MCP server — long-term memory for AI agents
|
|
|
237
249
|
|
|
238
250
|
[Service]
|
|
239
251
|
Type=simple
|
|
240
|
-
ExecStart=${npxPath} -y
|
|
252
|
+
ExecStart=${npxPath} -y ${packageSpec} server
|
|
241
253
|
Restart=on-failure
|
|
242
254
|
RestartSec=10
|
|
243
255
|
StandardOutput=journal
|
package/dist/mcp-server.js
CHANGED
|
@@ -177,8 +177,14 @@ async function startServer(options = {}) {
|
|
|
177
177
|
const llmConfig = (0, llm_js_1.resolveLlmConfigForCC)();
|
|
178
178
|
llm = new llm_js_1.LlmClient(llmConfig);
|
|
179
179
|
console.log(`[hicortex] LLM: ${llmConfig.provider}/${llmConfig.model} (reflect: ${llmConfig.reflectModel})`);
|
|
180
|
-
// License
|
|
181
|
-
|
|
180
|
+
// License: read from options, config file, or env var
|
|
181
|
+
const licenseKey = options.licenseKey
|
|
182
|
+
?? readConfigLicenseKey(stateDir)
|
|
183
|
+
?? process.env.HICORTEX_LICENSE_KEY;
|
|
184
|
+
(0, license_js_1.validateLicense)(licenseKey, stateDir).catch((err) => console.log(`[hicortex] License validation failed: ${err}`));
|
|
185
|
+
if (licenseKey) {
|
|
186
|
+
console.log(`[hicortex] License key configured`);
|
|
187
|
+
}
|
|
182
188
|
// Schedule nightly consolidation
|
|
183
189
|
const consolidateHour = options.consolidateHour ?? 2;
|
|
184
190
|
cancelConsolidation = (0, consolidate_js_1.scheduleConsolidation)(db, llm, embedder_js_1.embed, consolidateHour);
|
|
@@ -231,6 +237,16 @@ async function startServer(options = {}) {
|
|
|
231
237
|
console.log(`[hicortex] SSE endpoint: http://${host}:${port}/sse`);
|
|
232
238
|
console.log(`[hicortex] Health: http://${host}:${port}/health`);
|
|
233
239
|
});
|
|
240
|
+
server.on("error", (err) => {
|
|
241
|
+
if (err.code === "EADDRINUSE") {
|
|
242
|
+
console.error(`[hicortex] Port ${port} is already in use. ` +
|
|
243
|
+
`Another Hicortex server or service may be running.\n` +
|
|
244
|
+
` Check: lsof -i :${port}\n` +
|
|
245
|
+
` Use a different port: npx @gamaze/hicortex server --port ${port + 1}`);
|
|
246
|
+
process.exit(1);
|
|
247
|
+
}
|
|
248
|
+
throw err;
|
|
249
|
+
});
|
|
234
250
|
// Graceful shutdown
|
|
235
251
|
const shutdown = () => {
|
|
236
252
|
console.log("[hicortex] Shutting down...");
|
|
@@ -257,6 +273,23 @@ async function startServer(options = {}) {
|
|
|
257
273
|
// ---------------------------------------------------------------------------
|
|
258
274
|
// Helpers
|
|
259
275
|
// ---------------------------------------------------------------------------
|
|
276
|
+
/**
|
|
277
|
+
* Read license key from ~/.hicortex/config.json.
|
|
278
|
+
* Written by /hicortex-activate CC command.
|
|
279
|
+
*/
|
|
280
|
+
function readConfigLicenseKey(stateDir) {
|
|
281
|
+
try {
|
|
282
|
+
const { readFileSync } = require("node:fs");
|
|
283
|
+
const { join } = require("node:path");
|
|
284
|
+
const configPath = join(stateDir, "config.json");
|
|
285
|
+
const raw = readFileSync(configPath, "utf-8");
|
|
286
|
+
const config = JSON.parse(raw);
|
|
287
|
+
return config.licenseKey || undefined;
|
|
288
|
+
}
|
|
289
|
+
catch {
|
|
290
|
+
return undefined;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
260
293
|
function formatResults(results) {
|
|
261
294
|
if (results.length === 0)
|
|
262
295
|
return "No memories found.";
|
package/dist/nightly.js
CHANGED
|
@@ -58,6 +58,17 @@ const claude_md_js_1 = require("./claude-md.js");
|
|
|
58
58
|
const license_js_1 = require("./license.js");
|
|
59
59
|
const HICORTEX_HOME = (0, node_path_1.join)((0, node_os_1.homedir)(), ".hicortex");
|
|
60
60
|
const LAST_RUN_PATH = (0, node_path_1.join)(HICORTEX_HOME, "nightly-last-run.txt");
|
|
61
|
+
function readConfigLicenseKey(stateDir) {
|
|
62
|
+
try {
|
|
63
|
+
const configPath = (0, node_path_1.join)(stateDir, "config.json");
|
|
64
|
+
const raw = (0, node_fs_1.readFileSync)(configPath, "utf-8");
|
|
65
|
+
const config = JSON.parse(raw);
|
|
66
|
+
return config.licenseKey || undefined;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
61
72
|
function readLastRun() {
|
|
62
73
|
try {
|
|
63
74
|
const ts = (0, node_fs_1.readFileSync)(LAST_RUN_PATH, "utf-8").trim();
|
|
@@ -83,6 +94,9 @@ async function runNightly(options = {}) {
|
|
|
83
94
|
// Init DB
|
|
84
95
|
const db = (0, db_js_1.initDb)(dbPath);
|
|
85
96
|
try {
|
|
97
|
+
// License: read from config file or env var
|
|
98
|
+
const licenseKey = readConfigLicenseKey(stateDir) ?? process.env.HICORTEX_LICENSE_KEY;
|
|
99
|
+
await (0, license_js_1.validateLicense)(licenseKey, stateDir);
|
|
86
100
|
// Init LLM
|
|
87
101
|
const llmConfig = (0, llm_js_1.resolveLlmConfigForCC)();
|
|
88
102
|
const llm = new llm_js_1.LlmClient(llmConfig);
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "hicortex",
|
|
3
3
|
"name": "Hicortex — Long-term Memory That Learns",
|
|
4
4
|
"description": "Your agents remember past decisions, avoid repeated mistakes, and get smarter every day. Nightly reflection generates actionable lessons that automatically update agent behavior.",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.2",
|
|
6
6
|
"kind": "lifecycle",
|
|
7
7
|
"skills": ["./skills/hicortex-memory", "./skills/hicortex-learn", "./skills/hicortex-activate"],
|
|
8
8
|
"configSchema": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamaze/hicortex",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Human-like memory for self-improving AI agents. Automatic capturing, nightly reflection, and cross-agent learning. Works with Claude Code and OpenClaw.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|