@gamaze/hicortex 0.3.8 → 0.3.9

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 CHANGED
@@ -228,6 +228,55 @@ Tell them: "Get a license key at https://hicortex.gamaze.com/ — after purchase
228
228
  (0, node_fs_1.writeFileSync)((0, node_path_1.join)(CC_COMMANDS_DIR, "hicortex-activate.md"), activateContent);
229
229
  console.log(` ✓ Installed /learn and /hicortex-activate commands in ${CC_COMMANDS_DIR}`);
230
230
  }
231
+ /**
232
+ * Read LLM config from OC's openclaw.json + auth-profiles.json.
233
+ * Used as fallback when no env vars are set (e.g. Claude Max subscription users).
234
+ */
235
+ function readOcLlmConfig() {
236
+ try {
237
+ // Read primary model from openclaw.json
238
+ const ocRaw = (0, node_fs_1.readFileSync)(OC_CONFIG, "utf-8");
239
+ const oc = JSON.parse(ocRaw);
240
+ const primary = oc?.agents?.defaults?.model?.primary;
241
+ if (!primary || typeof primary !== "string")
242
+ return null;
243
+ const [providerHint, ...rest] = primary.includes("/") ? primary.split("/") : primary.split(":");
244
+ const model = rest.join("/") || undefined;
245
+ // Read base URL from providers config
246
+ const baseUrl = oc?.models?.providers?.[providerHint]?.baseUrl;
247
+ // Read API key from auth-profiles
248
+ const { readdirSync } = require("node:fs");
249
+ const agentsDir = (0, node_path_1.join)((0, node_os_1.homedir)(), ".openclaw", "agents");
250
+ let apiKey;
251
+ try {
252
+ for (const agentId of readdirSync(agentsDir)) {
253
+ try {
254
+ const authPath = (0, node_path_1.join)(agentsDir, agentId, "agent", "auth-profiles.json");
255
+ const auth = JSON.parse((0, node_fs_1.readFileSync)(authPath, "utf-8"));
256
+ for (const [profileId, profile] of Object.entries(auth?.profiles ?? {})) {
257
+ const p = profile;
258
+ if (p?.provider === providerHint || profileId.startsWith(`${providerHint}:`)) {
259
+ if (p?.key) {
260
+ apiKey = p.key;
261
+ break;
262
+ }
263
+ }
264
+ }
265
+ if (apiKey)
266
+ break;
267
+ }
268
+ catch { /* skip */ }
269
+ }
270
+ }
271
+ catch { /* no agents dir */ }
272
+ if (!apiKey || !baseUrl)
273
+ return null;
274
+ return { apiKey, baseUrl, provider: providerHint, model };
275
+ }
276
+ catch {
277
+ return null;
278
+ }
279
+ }
231
280
  /**
232
281
  * Detect LLM API key from current shell environment and persist to
233
282
  * ~/.hicortex/config.json so the daemon can use it (launchd/systemd
@@ -272,9 +321,20 @@ function persistLlmConfig() {
272
321
  config.llmProvider = "google";
273
322
  }
274
323
  else {
275
- console.log(" ⚠ No LLM API key found in environment. Server will use Ollama fallback.");
276
- console.log(" Set ANTHROPIC_API_KEY and re-run init, or edit ~/.hicortex/config.json");
277
- return;
324
+ // Last resort: try OC auth-profiles if OC is installed
325
+ const ocLlm = readOcLlmConfig();
326
+ if (ocLlm) {
327
+ config.llmApiKey = ocLlm.apiKey;
328
+ config.llmBaseUrl = ocLlm.baseUrl;
329
+ config.llmProvider = ocLlm.provider;
330
+ if (ocLlm.model)
331
+ config.llmModel = ocLlm.model;
332
+ }
333
+ else {
334
+ console.log(" ⚠ No LLM API key found in environment or OC config. Server will use Ollama fallback.");
335
+ console.log(" Set ANTHROPIC_API_KEY and re-run init, or edit ~/.hicortex/config.json");
336
+ return;
337
+ }
278
338
  }
279
339
  (0, node_fs_1.mkdirSync)(HICORTEX_HOME, { recursive: true });
280
340
  (0, node_fs_1.writeFileSync)(configPath, JSON.stringify(config, null, 2));
@@ -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.8",
5
+ "version": "0.3.9",
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.8",
3
+ "version": "0.3.9",
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": {