@gamaze/hicortex 0.7.0 → 0.10.0
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 +57 -39
- package/dist/claude-md.d.ts +9 -21
- package/dist/claude-md.js +9 -241
- package/dist/cli.d.ts +3 -2
- package/dist/cli.js +29 -11
- package/dist/consolidate.js +76 -26
- package/dist/db.js +24 -0
- package/dist/embedder.d.ts +11 -0
- package/dist/embedder.js +27 -0
- package/dist/extensions.d.ts +41 -88
- package/dist/extensions.js +36 -61
- package/dist/features.d.ts +21 -25
- package/dist/features.js +47 -83
- package/dist/graph.d.ts +1 -1
- package/dist/graph.js +13 -7
- package/dist/hermes-transcript-reader.d.ts +27 -0
- package/dist/hermes-transcript-reader.js +134 -0
- package/dist/index.d.ts +16 -4
- package/dist/index.js +252 -344
- package/dist/init.d.ts +41 -1
- package/dist/init.js +545 -190
- package/dist/lesson-selection.d.ts +62 -0
- package/dist/lesson-selection.js +159 -0
- package/dist/lessons-context.d.ts +17 -0
- package/dist/lessons-context.js +96 -0
- package/dist/llm.d.ts +42 -29
- package/dist/llm.js +89 -270
- package/dist/mcp-server.d.ts +0 -1
- package/dist/mcp-server.js +407 -88
- package/dist/nightly.d.ts +9 -6
- package/dist/nightly.js +197 -357
- package/dist/oc-transcript-reader.d.ts +20 -0
- package/dist/oc-transcript-reader.js +61 -0
- package/dist/pi-transcript-reader.d.ts +1 -0
- package/dist/prompts.d.ts +5 -0
- package/dist/prompts.js +29 -0
- package/dist/status.js +22 -2
- package/dist/storage.d.ts +7 -1
- package/dist/storage.js +28 -7
- package/dist/transcript-reader.d.ts +19 -0
- package/dist/transcript-reader.js +17 -3
- package/dist/types.d.ts +16 -0
- package/dist/types.js +7 -0
- package/dist/uninstall.js +31 -1
- package/hermes-plugin/hicortex/README.md +77 -0
- package/hermes-plugin/hicortex/__init__.py +17 -0
- package/hermes-plugin/hicortex/client.py +162 -0
- package/hermes-plugin/hicortex/config.py +105 -0
- package/hermes-plugin/hicortex/plugin.yaml +12 -0
- package/hermes-plugin/hicortex/provider.py +432 -0
- package/openclaw.plugin.json +17 -44
- package/package.json +7 -5
- package/dist/pro-loader.d.ts +0 -33
- package/dist/pro-loader.js +0 -187
package/dist/pro-loader.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Pro extension loader.
|
|
4
|
-
*
|
|
5
|
-
* Called from features.ts at boot when a valid paid license is detected.
|
|
6
|
-
* Responsibilities:
|
|
7
|
-
* 1. Check ~/.hicortex/pro/installed.json for the currently-installed
|
|
8
|
-
* Pro version (if any).
|
|
9
|
-
* 2. Fetch GET /api/pro/meta from hicortex.gamaze.com to discover the
|
|
10
|
-
* latest available version for the caller's license tier.
|
|
11
|
-
* 3. If the installed version is older (or missing), download the
|
|
12
|
-
* tarball, verify the sha256 sidecar, and extract to ~/.hicortex/pro/.
|
|
13
|
-
* 4. Dynamic-import ~/.hicortex/pro/package/index.js and call activate()
|
|
14
|
-
* on its default export with a ProActivationContext.
|
|
15
|
-
*
|
|
16
|
-
* Failure modes (all soft — OSS host keeps running with defaults):
|
|
17
|
-
* - Network to /api/pro/meta fails → use whatever is already installed
|
|
18
|
-
* - No cached Pro and network fails → Pro not activated, OSS defaults apply
|
|
19
|
-
* - Downloaded tarball fails sha256 → abort download, keep old version
|
|
20
|
-
* - import() of activated module throws → log warning, keep defaults
|
|
21
|
-
*
|
|
22
|
-
* The loader is strictly best-effort. It must NEVER crash the OSS host.
|
|
23
|
-
*/
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.loadPro = loadPro;
|
|
26
|
-
const node_crypto_1 = require("node:crypto");
|
|
27
|
-
const node_fs_1 = require("node:fs");
|
|
28
|
-
const node_path_1 = require("node:path");
|
|
29
|
-
const node_url_1 = require("node:url");
|
|
30
|
-
const node_child_process_1 = require("node:child_process");
|
|
31
|
-
const extensions_js_1 = require("./extensions.js");
|
|
32
|
-
const VALIDATE_URL = "https://hicortex.gamaze.com";
|
|
33
|
-
/**
|
|
34
|
-
* Entry point called from features.ts at boot.
|
|
35
|
-
*
|
|
36
|
-
* @param licenseKey The Pro license key (hctx-...) from config
|
|
37
|
-
* @param stateDir Usually ~/.hicortex/
|
|
38
|
-
* @param hostVersion The version of the OSS host (from package.json) — passed
|
|
39
|
-
* to the Pro activate() for compatibility gating
|
|
40
|
-
* @param serverUrl Override for the Pro meta/download endpoint (defaults
|
|
41
|
-
* to https://hicortex.gamaze.com). Useful for testing.
|
|
42
|
-
*/
|
|
43
|
-
async function loadPro(licenseKey, stateDir, hostVersion, serverUrl = VALIDATE_URL) {
|
|
44
|
-
const proRoot = (0, node_path_1.join)(stateDir, "pro");
|
|
45
|
-
try {
|
|
46
|
-
(0, node_fs_1.mkdirSync)(proRoot, { recursive: true });
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
// If we can't even create the dir, there's nothing to load
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
// Step 1: read installed state (if any)
|
|
53
|
-
const installedStatePath = (0, node_path_1.join)(proRoot, "installed.json");
|
|
54
|
-
const installed = readInstalledState(installedStatePath);
|
|
55
|
-
// Step 2: try to fetch the latest meta. Network failure is soft.
|
|
56
|
-
let meta = null;
|
|
57
|
-
try {
|
|
58
|
-
meta = await fetchProMeta(serverUrl, licenseKey);
|
|
59
|
-
}
|
|
60
|
-
catch (err) {
|
|
61
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
62
|
-
console.warn(`[hicortex][pro] Could not fetch Pro metadata (${msg}) — using cached version if present`);
|
|
63
|
-
}
|
|
64
|
-
// Step 3: if meta is newer than installed, download and extract
|
|
65
|
-
if (meta && (!installed || installed.version !== meta.version)) {
|
|
66
|
-
try {
|
|
67
|
-
await downloadAndExtract(serverUrl, licenseKey, meta, proRoot);
|
|
68
|
-
writeInstalledState(installedStatePath, {
|
|
69
|
-
version: meta.version,
|
|
70
|
-
installedAt: new Date().toISOString(),
|
|
71
|
-
sha256: meta.sha256,
|
|
72
|
-
});
|
|
73
|
-
console.log(`[hicortex][pro] Installed Pro v${meta.version}`);
|
|
74
|
-
}
|
|
75
|
-
catch (err) {
|
|
76
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
77
|
-
console.warn(`[hicortex][pro] Pro download failed: ${msg}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// Step 4: activate whatever is installed (if anything)
|
|
81
|
-
const indexPath = (0, node_path_1.join)(proRoot, "package", "index.js");
|
|
82
|
-
if (!(0, node_fs_1.existsSync)(indexPath)) {
|
|
83
|
-
// No Pro installed and meta fetch couldn't install one
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
const mod = await import((0, node_url_1.pathToFileURL)(indexPath).href);
|
|
88
|
-
const pkg = (mod.default ?? mod);
|
|
89
|
-
if (typeof pkg?.activate !== "function") {
|
|
90
|
-
console.warn(`[hicortex][pro] Pro package has no activate() function`);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const ctx = (0, extensions_js_1.createProActivationContext)(hostVersion);
|
|
94
|
-
await pkg.activate(ctx);
|
|
95
|
-
}
|
|
96
|
-
catch (err) {
|
|
97
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
98
|
-
console.warn(`[hicortex][pro] Pro activation failed: ${msg}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// ---------------------------------------------------------------------------
|
|
102
|
-
// Implementation helpers
|
|
103
|
-
// ---------------------------------------------------------------------------
|
|
104
|
-
function readInstalledState(path) {
|
|
105
|
-
try {
|
|
106
|
-
const raw = (0, node_fs_1.readFileSync)(path, "utf-8");
|
|
107
|
-
return JSON.parse(raw);
|
|
108
|
-
}
|
|
109
|
-
catch {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function writeInstalledState(path, state) {
|
|
114
|
-
try {
|
|
115
|
-
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(path), { recursive: true });
|
|
116
|
-
(0, node_fs_1.writeFileSync)(path, JSON.stringify(state, null, 2));
|
|
117
|
-
}
|
|
118
|
-
catch {
|
|
119
|
-
// Non-fatal — we'll just re-download next boot
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
async function fetchProMeta(serverUrl, licenseKey) {
|
|
123
|
-
const url = `${serverUrl.replace(/\/$/, "")}/api/pro/meta`;
|
|
124
|
-
const resp = await fetch(url, {
|
|
125
|
-
headers: { Authorization: `Bearer ${licenseKey}` },
|
|
126
|
-
signal: AbortSignal.timeout(10_000),
|
|
127
|
-
});
|
|
128
|
-
if (resp.status === 401 || resp.status === 403) {
|
|
129
|
-
throw new Error(`Pro access denied (HTTP ${resp.status}) — check license key`);
|
|
130
|
-
}
|
|
131
|
-
if (resp.status === 404) {
|
|
132
|
-
throw new Error("No Pro release available yet");
|
|
133
|
-
}
|
|
134
|
-
if (!resp.ok) {
|
|
135
|
-
throw new Error(`HTTP ${resp.status}`);
|
|
136
|
-
}
|
|
137
|
-
const data = (await resp.json());
|
|
138
|
-
if (!data.version || !data.url) {
|
|
139
|
-
throw new Error("Malformed /api/pro/meta response");
|
|
140
|
-
}
|
|
141
|
-
return data;
|
|
142
|
-
}
|
|
143
|
-
async function downloadAndExtract(serverUrl, licenseKey, meta, proRoot) {
|
|
144
|
-
const downloadUrl = `${serverUrl.replace(/\/$/, "")}${meta.url.startsWith("/") ? "" : "/"}${meta.url}`;
|
|
145
|
-
const resp = await fetch(downloadUrl, {
|
|
146
|
-
headers: { Authorization: `Bearer ${licenseKey}` },
|
|
147
|
-
signal: AbortSignal.timeout(60_000),
|
|
148
|
-
});
|
|
149
|
-
if (!resp.ok) {
|
|
150
|
-
throw new Error(`Download failed with HTTP ${resp.status}`);
|
|
151
|
-
}
|
|
152
|
-
// Stream to a temp file so we can verify the hash before extracting
|
|
153
|
-
const tmpPath = (0, node_path_1.join)(proRoot, `.pro-download-${Date.now()}.tgz`);
|
|
154
|
-
const buf = Buffer.from(await resp.arrayBuffer());
|
|
155
|
-
(0, node_fs_1.writeFileSync)(tmpPath, buf);
|
|
156
|
-
// Verify sha256 if the server provided one
|
|
157
|
-
if (meta.sha256) {
|
|
158
|
-
const hash = (0, node_crypto_1.createHash)("sha256").update(buf).digest("hex");
|
|
159
|
-
if (hash !== meta.sha256) {
|
|
160
|
-
try {
|
|
161
|
-
(0, node_fs_1.rmSync)(tmpPath);
|
|
162
|
-
}
|
|
163
|
-
catch { /* non-fatal */ }
|
|
164
|
-
throw new Error(`sha256 mismatch: expected ${meta.sha256}, got ${hash}`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
// Extract to proRoot (overwrites existing package/ directory)
|
|
168
|
-
const existingPackageDir = (0, node_path_1.join)(proRoot, "package");
|
|
169
|
-
if ((0, node_fs_1.existsSync)(existingPackageDir)) {
|
|
170
|
-
try {
|
|
171
|
-
(0, node_fs_1.rmSync)(existingPackageDir, { recursive: true, force: true });
|
|
172
|
-
}
|
|
173
|
-
catch { /* non-fatal */ }
|
|
174
|
-
}
|
|
175
|
-
// Use the system tar to extract (cross-platform, no new dependency)
|
|
176
|
-
const result = (0, node_child_process_1.spawnSync)("tar", ["-xzf", tmpPath, "-C", proRoot], {
|
|
177
|
-
encoding: "utf-8",
|
|
178
|
-
});
|
|
179
|
-
if (result.status !== 0) {
|
|
180
|
-
throw new Error(`tar extraction failed: ${result.stderr || "unknown error"}`);
|
|
181
|
-
}
|
|
182
|
-
// Clean up the temp tarball
|
|
183
|
-
try {
|
|
184
|
-
(0, node_fs_1.rmSync)(tmpPath);
|
|
185
|
-
}
|
|
186
|
-
catch { /* non-fatal */ }
|
|
187
|
-
}
|