@gamaze/hicortex 0.4.4 → 0.4.5

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/index.js CHANGED
@@ -466,28 +466,7 @@ async function autoConfigureLlm(pluginConfig, log) {
466
466
  const msg = err instanceof Error ? err.message : String(err);
467
467
  log(`[hicortex] LLM test failed (${llmConfig.baseUrl}): ${msg}`);
468
468
  }
469
- // Step 4: If test failed and this is z.ai, try the alternate endpoint
470
- if (llmConfig.provider === "zai") {
471
- const altUrl = llmConfig.baseUrl.includes("/coding/")
472
- ? llmConfig.baseUrl.replace("/coding/", "/")
473
- : llmConfig.baseUrl.replace("/api/paas/", "/api/coding/paas/");
474
- log(`[hicortex] Trying alternate z.ai endpoint: ${altUrl}`);
475
- llmConfig.baseUrl = altUrl;
476
- const altClient = new llm_js_1.LlmClient(llmConfig);
477
- try {
478
- const response = await altClient.completeFast("Respond with just the word OK", 10);
479
- if (response && response.length > 0) {
480
- log(`[hicortex] LLM connection verified on alternate endpoint`);
481
- persistProviderConfig(llmConfig, log);
482
- return llmConfig;
483
- }
484
- }
485
- catch (err) {
486
- const msg = err instanceof Error ? err.message : String(err);
487
- log(`[hicortex] Alternate z.ai endpoint also failed: ${msg}`);
488
- }
489
- }
490
- // Step 5: Fall back — return the config anyway, log instructions
469
+ // Step 4: Fall back return the config anyway, log instructions
491
470
  log(`[hicortex] WARNING: Could not verify LLM connection. ` +
492
471
  `Distillation and consolidation may fail. ` +
493
472
  `To fix: add models.providers.${llmConfig.provider}.baseUrl to ~/.openclaw/openclaw.json ` +
package/dist/init.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Detection:
5
5
  * 1. Local HC server running (localhost:8787)
6
- * 2. Remote HC server (HICORTEX_SERVER_URL or bedrock:8787)
6
+ * 2. Remote HC server (HICORTEX_SERVER_URL any reachable host:port)
7
7
  * 3. OC plugin installed (~/.openclaw/openclaw.json)
8
8
  * 4. CC MCP already registered (~/.claude/settings.json)
9
9
  * 5. Existing DB (~/.hicortex/ or ~/.openclaw/data/)
package/dist/init.js CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Detection:
6
6
  * 1. Local HC server running (localhost:8787)
7
- * 2. Remote HC server (HICORTEX_SERVER_URL or bedrock:8787)
7
+ * 2. Remote HC server (HICORTEX_SERVER_URL any reachable host:port)
8
8
  * 3. OC plugin installed (~/.openclaw/openclaw.json)
9
9
  * 4. CC MCP already registered (~/.claude/settings.json)
10
10
  * 5. Existing DB (~/.hicortex/ or ~/.openclaw/data/)
@@ -185,10 +185,10 @@ When invoked with \`/learn <text>\`, store the learning in long-term memory via
185
185
 
186
186
  ## Example
187
187
 
188
- \`/learn z.ai API uses Bearer auth on all endpoints, not x-api-key\`
188
+ \`/learn always check provider docs before assuming an API uses the same auth scheme as OpenAI\`
189
189
 
190
190
  Becomes a call to hicortex_ingest with:
191
- - content: "LEARNING: z.ai API uses Bearer auth on all three endpoints (paas, coding, anthropic). Not x-api-key. (2026-03-26)"
191
+ - content: "LEARNING: always check provider docs before assuming an API uses the same auth scheme as OpenAI header names and token formats vary widely (Bearer vs x-api-key vs custom)."
192
192
  - memory_type: "lesson"
193
193
  `;
194
194
  const learnPath = (0, node_path_1.join)(CC_COMMANDS_DIR, "learn.md");
@@ -402,7 +402,7 @@ async function persistLlmConfig() {
402
402
  options.push({
403
403
  label: "Other provider (requires API key)",
404
404
  save: async () => {
405
- console.log("\n Providers: Anthropic, OpenAI, Google, z.ai, OpenRouter, or any OpenAI-compatible");
405
+ console.log("\n Providers: Anthropic, OpenAI, Google, OpenRouter, or any OpenAI-compatible endpoint");
406
406
  const baseUrl = await ask(" Provider base URL: ");
407
407
  if (!baseUrl) {
408
408
  console.log(" ⚠ Cancelled.");
package/dist/llm.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * Multi-provider LLM client for consolidation and distillation.
3
- * Ported from hicortex/consolidate/llm.py.
4
3
  *
5
4
  * Resolution for OC adapter (resolveLlmConfig):
6
5
  * 1. Plugin config (llmBaseUrl, llmApiKey, llmModel)
@@ -10,12 +9,14 @@
10
9
  *
11
10
  * Resolution for CC adapter (resolveLlmConfigForCC):
12
11
  * 1. Explicit env vars (HICORTEX_LLM_BASE_URL + HICORTEX_LLM_API_KEY + HICORTEX_LLM_MODEL)
13
- * 2. ANTHROPIC_API_KEY → Haiku (cheap, CC users always have this)
14
- * 3. OPENAI_API_KEY → gpt-4o-mini
15
- * 4. GOOGLE_API_KEY → gemini-2.0-flash
16
- * 5. Fallback: Ollama at http://localhost:11434
12
+ * 2. ANTHROPIC_API_KEY → Claude Haiku (cheap, CC users always have this)
13
+ * 3. OPENAI_API_KEY → gpt-5.4-nano
14
+ * 4. GOOGLE_API_KEY → gemini-2.5-flash
15
+ * 5. Claude CLI fallback (uses subscription, no API key needed)
16
+ * 6. Fallback: Ollama at http://localhost:11434
17
17
  *
18
- * Supports: OpenAI, Anthropic, Google, OpenRouter, Ollama, z.ai, and 15+ more
18
+ * Supports any OpenAI-compatible endpoint plus first-class support for
19
+ * OpenAI, Anthropic, Google, Ollama, OpenRouter, and Claude CLI.
19
20
  */
20
21
  export interface LlmConfig {
21
22
  baseUrl: string;
@@ -116,7 +117,7 @@ export declare class LlmClient {
116
117
  */
117
118
  private completeOllama;
118
119
  /**
119
- * Anthropic Messages API (/v1/messages). Used for Anthropic and z.ai.
120
+ * Anthropic Messages API (/v1/messages).
120
121
  * Auth via x-api-key header.
121
122
  */
122
123
  private completeAnthropic;
package/dist/llm.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
3
  * Multi-provider LLM client for consolidation and distillation.
4
- * Ported from hicortex/consolidate/llm.py.
5
4
  *
6
5
  * Resolution for OC adapter (resolveLlmConfig):
7
6
  * 1. Plugin config (llmBaseUrl, llmApiKey, llmModel)
@@ -11,12 +10,14 @@
11
10
  *
12
11
  * Resolution for CC adapter (resolveLlmConfigForCC):
13
12
  * 1. Explicit env vars (HICORTEX_LLM_BASE_URL + HICORTEX_LLM_API_KEY + HICORTEX_LLM_MODEL)
14
- * 2. ANTHROPIC_API_KEY → Haiku (cheap, CC users always have this)
15
- * 3. OPENAI_API_KEY → gpt-4o-mini
16
- * 4. GOOGLE_API_KEY → gemini-2.0-flash
17
- * 5. Fallback: Ollama at http://localhost:11434
13
+ * 2. ANTHROPIC_API_KEY → Claude Haiku (cheap, CC users always have this)
14
+ * 3. OPENAI_API_KEY → gpt-5.4-nano
15
+ * 4. GOOGLE_API_KEY → gemini-2.5-flash
16
+ * 5. Claude CLI fallback (uses subscription, no API key needed)
17
+ * 6. Fallback: Ollama at http://localhost:11434
18
18
  *
19
- * Supports: OpenAI, Anthropic, Google, OpenRouter, Ollama, z.ai, and 15+ more
19
+ * Supports any OpenAI-compatible endpoint plus first-class support for
20
+ * OpenAI, Anthropic, Google, Ollama, OpenRouter, and Claude CLI.
20
21
  */
21
22
  Object.defineProperty(exports, "__esModule", { value: true });
22
23
  exports.LlmClient = exports.RateLimitError = void 0;
@@ -76,7 +77,7 @@ function resolveLlmConfigForCC(overrides) {
76
77
  baseUrl: overrides.llmBaseUrl,
77
78
  apiKey: overrides.llmApiKey,
78
79
  model: overrides.llmModel ?? "claude-haiku-4-5-20251001",
79
- reflectModel: overrides.reflectModel ?? overrides.llmModel ?? "claude-sonnet-4-5-20250514",
80
+ reflectModel: overrides.reflectModel ?? overrides.llmModel ?? "claude-sonnet-4-6",
80
81
  provider,
81
82
  };
82
83
  }
@@ -90,7 +91,7 @@ function resolveLlmConfigForCC(overrides) {
90
91
  baseUrl: hcBaseUrl,
91
92
  apiKey: hcApiKey,
92
93
  model: hcModel ?? "claude-haiku-4-5-20251001",
93
- reflectModel: process.env.HICORTEX_REFLECT_MODEL ?? hcModel ?? "claude-sonnet-4-5-20250514",
94
+ reflectModel: process.env.HICORTEX_REFLECT_MODEL ?? hcModel ?? "claude-sonnet-4-6",
94
95
  provider,
95
96
  };
96
97
  }
@@ -101,7 +102,7 @@ function resolveLlmConfigForCC(overrides) {
101
102
  baseUrl: process.env.ANTHROPIC_BASE_URL ?? "https://api.anthropic.com",
102
103
  apiKey: anthropicKey,
103
104
  model: "claude-haiku-4-5-20251001",
104
- reflectModel: "claude-sonnet-4-5-20250514",
105
+ reflectModel: "claude-sonnet-4-6",
105
106
  provider: "anthropic",
106
107
  };
107
108
  }
@@ -111,8 +112,8 @@ function resolveLlmConfigForCC(overrides) {
111
112
  return {
112
113
  baseUrl,
113
114
  apiKey: openaiKey,
114
- model: "gpt-4o-mini",
115
- reflectModel: "gpt-4o-mini",
115
+ model: "gpt-5.4-nano",
116
+ reflectModel: "gpt-5.4-nano",
116
117
  provider: detectProvider(baseUrl),
117
118
  };
118
119
  }
@@ -121,8 +122,8 @@ function resolveLlmConfigForCC(overrides) {
121
122
  return {
122
123
  baseUrl: "https://generativelanguage.googleapis.com/v1beta",
123
124
  apiKey: googleKey,
124
- model: "gemini-2.0-flash",
125
- reflectModel: "gemini-2.0-flash",
125
+ model: "gemini-2.5-flash",
126
+ reflectModel: "gemini-2.5-flash",
126
127
  provider: "google",
127
128
  };
128
129
  }
@@ -150,8 +151,6 @@ function detectProvider(url) {
150
151
  return "openrouter";
151
152
  if (u.includes("googleapis") || u.includes("generativelanguage"))
152
153
  return "google";
153
- if (u.includes("z.ai") || u.includes("zai"))
154
- return "zai";
155
154
  return "openai";
156
155
  }
157
156
  function readOpenClawConfig() {
@@ -162,7 +161,7 @@ function readOpenClawConfig() {
162
161
  const primary = config?.agents?.defaults?.model?.primary;
163
162
  if (!primary)
164
163
  return null;
165
- // primary format is "provider/model" (e.g. "zai/glm-5-turbo", "openai/gpt-4o")
164
+ // primary format is "provider/model" (e.g. "openai/gpt-5", "anthropic/claude-sonnet-4-6")
166
165
  if (typeof primary === "string" && (primary.includes("/") || primary.includes(":"))) {
167
166
  const sep = primary.includes("/") ? "/" : ":";
168
167
  const [providerHint, ...rest] = primary.split(sep);
@@ -216,7 +215,7 @@ function readOcAuthKey(provider) {
216
215
  const raw = (0, node_fs_1.readFileSync)(authPath, "utf-8");
217
216
  const auth = JSON.parse(raw);
218
217
  const profiles = auth?.profiles ?? {};
219
- // Look for a profile matching the provider (e.g. "zai:default")
218
+ // Look for a profile matching the provider (e.g. "openai:default")
220
219
  for (const [profileId, profile] of Object.entries(profiles)) {
221
220
  const p = profile;
222
221
  if (p?.provider === provider ||
@@ -245,8 +244,8 @@ function resolveFromEnv() {
245
244
  return {
246
245
  baseUrl,
247
246
  apiKey: openaiKey,
248
- model: process.env.OPENAI_MODEL ?? "gpt-4o-mini",
249
- reflectModel: process.env.OPENAI_MODEL ?? "gpt-4o-mini",
247
+ model: process.env.OPENAI_MODEL ?? "gpt-5.4-nano",
248
+ reflectModel: process.env.OPENAI_MODEL ?? "gpt-5.4-nano",
250
249
  provider,
251
250
  };
252
251
  }
@@ -255,8 +254,8 @@ function resolveFromEnv() {
255
254
  return {
256
255
  baseUrl: process.env.ANTHROPIC_BASE_URL ?? "https://api.anthropic.com",
257
256
  apiKey: anthropicKey,
258
- model: "claude-sonnet-4-20250514",
259
- reflectModel: "claude-sonnet-4-20250514",
257
+ model: "claude-sonnet-4-6",
258
+ reflectModel: "claude-sonnet-4-6",
260
259
  provider: "anthropic",
261
260
  };
262
261
  }
@@ -265,8 +264,8 @@ function resolveFromEnv() {
265
264
  return {
266
265
  baseUrl: "https://generativelanguage.googleapis.com/v1beta",
267
266
  apiKey: googleKey,
268
- model: "gemini-2.0-flash",
269
- reflectModel: "gemini-2.0-flash",
267
+ model: "gemini-2.5-flash",
268
+ reflectModel: "gemini-2.5-flash",
270
269
  provider: "google",
271
270
  };
272
271
  }
@@ -280,33 +279,23 @@ function getEnvKeyForProvider(provider) {
280
279
  return process.env.ANTHROPIC_API_KEY;
281
280
  case "google":
282
281
  return process.env.GOOGLE_API_KEY;
283
- case "zai":
284
- return process.env.ZAI_API_KEY ?? process.env.LLM_API_KEY;
285
282
  default:
286
283
  return undefined;
287
284
  }
288
285
  }
289
- /** Default base URLs for all OC-supported providers (from OC gateway binary). */
286
+ /**
287
+ * Default base URLs for first-class supported providers.
288
+ *
289
+ * For any other provider, set llmBaseUrl explicitly in your config or use
290
+ * an OpenAI-compatible endpoint. The detectProvider() function will treat
291
+ * unknown URLs as openai-compatible by default.
292
+ */
290
293
  const PROVIDER_BASE_URLS = {
291
294
  openai: "https://api.openai.com/v1",
292
295
  anthropic: "https://api.anthropic.com",
293
296
  google: "https://generativelanguage.googleapis.com/v1beta",
294
297
  ollama: "http://localhost:11434",
295
298
  openrouter: "https://openrouter.ai/api",
296
- zai: "https://api.z.ai/api/anthropic",
297
- groq: "https://api.groq.com/openai/v1",
298
- deepseek: "https://api.deepseek.com",
299
- mistral: "https://api.mistral.ai/v1",
300
- together: "https://api.together.xyz/v1",
301
- perplexity: "https://api.perplexity.ai",
302
- nvidia: "https://integrate.api.nvidia.com/v1",
303
- xai: "https://api.x.ai/v1",
304
- venice: "https://api.venice.ai/api/v1",
305
- minimax: "https://api.minimaxi.com/v1",
306
- moonshot: "https://api.moonshot.ai/v1",
307
- kimi: "https://api.kimi.com/coding",
308
- chutes: "https://api.chutes.ai",
309
- kilo: "https://api.kilo.ai/api/gateway",
310
299
  };
311
300
  function getDefaultUrlForProvider(provider) {
312
301
  return PROVIDER_BASE_URLS[provider.toLowerCase()] ?? "https://api.openai.com/v1";
@@ -505,7 +494,7 @@ class LlmClient {
505
494
  if (this.config.provider === "ollama") {
506
495
  return this.completeOllama(model, prompt, maxTokens, timeoutMs);
507
496
  }
508
- if (this.config.provider === "anthropic" || this.config.provider === "zai") {
497
+ if (this.config.provider === "anthropic") {
509
498
  return this.completeAnthropic(model, prompt, maxTokens, timeoutMs);
510
499
  }
511
500
  return this.completeOpenAiCompat(model, prompt, maxTokens, timeoutMs);
@@ -586,7 +575,7 @@ class LlmClient {
586
575
  return result.trim();
587
576
  }
588
577
  /**
589
- * Anthropic Messages API (/v1/messages). Used for Anthropic and z.ai.
578
+ * Anthropic Messages API (/v1/messages).
590
579
  * Auth via x-api-key header.
591
580
  */
592
581
  async completeAnthropic(model, prompt, maxTokens, timeoutMs) {
@@ -622,8 +611,8 @@ class LlmClient {
622
611
  */
623
612
  async completeOpenAiCompat(model, prompt, maxTokens, timeoutMs) {
624
613
  const baseUrl = this.config.baseUrl.replace(/\/$/, "");
625
- // Some providers (z.ai) include version in base URL already
626
- const hasVersion = /\/v\d+\/?$/.test(baseUrl) || baseUrl.includes("/paas/v");
614
+ // Some providers include the API version in the base URL already
615
+ const hasVersion = /\/v\d+\/?$/.test(baseUrl);
627
616
  const url = hasVersion
628
617
  ? `${baseUrl}/chat/completions`
629
618
  : `${baseUrl}/v1/chat/completions`;
@@ -647,10 +636,6 @@ class LlmClient {
647
636
  this.handleRateLimit(resp);
648
637
  if (!resp.ok) {
649
638
  const text = await resp.text().catch(() => "");
650
- // z.ai: "Insufficient balance" likely means wrong endpoint (coding vs paas)
651
- if (text.includes("1113") || text.includes("Insufficient balance")) {
652
- console.log(`[hicortex] LLM billing error. Check that llmBaseUrl matches your plan. Current: ${baseUrl}`);
653
- }
654
639
  throw new Error(`LLM API error ${resp.status}: ${text}`);
655
640
  }
656
641
  const data = (await resp.json());
@@ -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.11",
5
+ "version": "0.4.5",
6
6
  "kind": "lifecycle",
7
7
  "skills": ["./skills/hicortex-memory", "./skills/hicortex-learn", "./skills/hicortex-activate"],
8
8
  "configSchema": {
@@ -10,7 +10,7 @@
10
10
  "properties": {
11
11
  "licenseKey": {
12
12
  "type": "string",
13
- "description": "Hicortex license key (hctx-...). Leave empty for free tier (100 memory cap)."
13
+ "description": "Hicortex license key (hctx-...). Leave empty for free tier (250 memory cap)."
14
14
  },
15
15
  "llmBaseUrl": {
16
16
  "type": "string",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamaze/hicortex",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
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": {
@@ -23,12 +23,12 @@ When invoked with `/learn <text>`, store the learning in long-term memory via hi
23
23
  ## Example
24
24
 
25
25
  ```
26
- /learn z.ai API uses Bearer auth on all endpoints, not x-api-key
26
+ /learn always check provider docs before assuming an API uses the same auth scheme as OpenAI
27
27
  ```
28
28
 
29
29
  Becomes:
30
30
  ```
31
- hicortex_ingest(content="LEARNING: z.ai API uses Bearer auth on all three endpoints (paas, coding, anthropic). Not x-api-key. (2026-03-24)", project="global", memory_type="lesson")
31
+ hicortex_ingest(content="LEARNING: always check provider docs before assuming an API uses the same auth scheme as OpenAI header names and token formats vary widely (Bearer vs x-api-key vs custom). (2026-04-07)", project="global", memory_type="lesson")
32
32
  ```
33
33
 
34
34
  ## Rules