@gamaze/hicortex 0.7.1 → 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.
Files changed (49) hide show
  1. package/README.md +57 -39
  2. package/dist/claude-md.d.ts +9 -21
  3. package/dist/claude-md.js +9 -241
  4. package/dist/cli.d.ts +3 -2
  5. package/dist/cli.js +29 -11
  6. package/dist/consolidate.js +0 -7
  7. package/dist/db.js +24 -0
  8. package/dist/embedder.d.ts +11 -0
  9. package/dist/embedder.js +27 -0
  10. package/dist/extensions.d.ts +41 -88
  11. package/dist/extensions.js +36 -61
  12. package/dist/features.d.ts +21 -25
  13. package/dist/features.js +47 -83
  14. package/dist/hermes-transcript-reader.d.ts +27 -0
  15. package/dist/hermes-transcript-reader.js +134 -0
  16. package/dist/index.d.ts +16 -4
  17. package/dist/index.js +252 -344
  18. package/dist/init.d.ts +41 -1
  19. package/dist/init.js +545 -190
  20. package/dist/lesson-selection.d.ts +62 -0
  21. package/dist/lesson-selection.js +159 -0
  22. package/dist/lessons-context.d.ts +17 -0
  23. package/dist/lessons-context.js +96 -0
  24. package/dist/llm.d.ts +42 -29
  25. package/dist/llm.js +89 -270
  26. package/dist/mcp-server.d.ts +0 -1
  27. package/dist/mcp-server.js +404 -86
  28. package/dist/nightly.d.ts +9 -6
  29. package/dist/nightly.js +197 -357
  30. package/dist/oc-transcript-reader.d.ts +20 -0
  31. package/dist/oc-transcript-reader.js +61 -0
  32. package/dist/pi-transcript-reader.d.ts +1 -0
  33. package/dist/status.js +22 -2
  34. package/dist/storage.d.ts +7 -1
  35. package/dist/storage.js +28 -7
  36. package/dist/transcript-reader.d.ts +19 -0
  37. package/dist/transcript-reader.js +17 -3
  38. package/dist/types.d.ts +10 -0
  39. package/dist/uninstall.js +31 -1
  40. package/hermes-plugin/hicortex/README.md +77 -0
  41. package/hermes-plugin/hicortex/__init__.py +17 -0
  42. package/hermes-plugin/hicortex/client.py +162 -0
  43. package/hermes-plugin/hicortex/config.py +105 -0
  44. package/hermes-plugin/hicortex/plugin.yaml +12 -0
  45. package/hermes-plugin/hicortex/provider.py +432 -0
  46. package/openclaw.plugin.json +17 -44
  47. package/package.json +7 -5
  48. package/dist/pro-loader.d.ts +0 -33
  49. package/dist/pro-loader.js +0 -187
@@ -1,33 +0,0 @@
1
- /**
2
- * Pro extension loader.
3
- *
4
- * Called from features.ts at boot when a valid paid license is detected.
5
- * Responsibilities:
6
- * 1. Check ~/.hicortex/pro/installed.json for the currently-installed
7
- * Pro version (if any).
8
- * 2. Fetch GET /api/pro/meta from hicortex.gamaze.com to discover the
9
- * latest available version for the caller's license tier.
10
- * 3. If the installed version is older (or missing), download the
11
- * tarball, verify the sha256 sidecar, and extract to ~/.hicortex/pro/.
12
- * 4. Dynamic-import ~/.hicortex/pro/package/index.js and call activate()
13
- * on its default export with a ProActivationContext.
14
- *
15
- * Failure modes (all soft — OSS host keeps running with defaults):
16
- * - Network to /api/pro/meta fails → use whatever is already installed
17
- * - No cached Pro and network fails → Pro not activated, OSS defaults apply
18
- * - Downloaded tarball fails sha256 → abort download, keep old version
19
- * - import() of activated module throws → log warning, keep defaults
20
- *
21
- * The loader is strictly best-effort. It must NEVER crash the OSS host.
22
- */
23
- /**
24
- * Entry point called from features.ts at boot.
25
- *
26
- * @param licenseKey The Pro license key (hctx-...) from config
27
- * @param stateDir Usually ~/.hicortex/
28
- * @param hostVersion The version of the OSS host (from package.json) — passed
29
- * to the Pro activate() for compatibility gating
30
- * @param serverUrl Override for the Pro meta/download endpoint (defaults
31
- * to https://hicortex.gamaze.com). Useful for testing.
32
- */
33
- export declare function loadPro(licenseKey: string, stateDir: string, hostVersion: string, serverUrl?: string): Promise<void>;
@@ -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
- }