@wipcomputer/memory-crystal 0.7.34-alpha.2 → 0.7.34-alpha.4
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/LICENSE +1 -1
- package/dist/bridge.js +64 -7
- package/dist/bulk-copy.js +67 -16
- package/dist/cc-hook.js +2163 -62
- package/dist/cc-poller.js +1967 -70
- package/dist/cli.js +4538 -139
- package/dist/core.js +1789 -6
- package/dist/crypto.js +153 -14
- package/dist/crystal-serve.js +64 -12
- package/dist/doctor.js +517 -52
- package/dist/dream-weaver.js +1755 -7
- package/dist/file-sync.js +407 -9
- package/dist/installer.js +840 -145
- package/dist/ldm.js +231 -16
- package/dist/mcp-server.js +1882 -17
- package/dist/migrate.js +1707 -11
- package/dist/mirror-sync.js +2052 -34
- package/dist/openclaw.js +1895 -84
- package/dist/pair.js +112 -16
- package/dist/poller.js +2275 -80
- package/dist/role.js +159 -7
- package/dist/staging.js +235 -10
- package/dist/summarize.js +142 -5
- package/package.json +7 -4
- package/dist/chunk-25LXQJ4Z.js +0 -110
- package/dist/chunk-2DRXIRQW.js +0 -97
- package/dist/chunk-2GBYLMEF.js +0 -1385
- package/dist/chunk-2ZNH5F6E.js +0 -1281
- package/dist/chunk-3G3SFYYI.js +0 -288
- package/dist/chunk-3RG5ZIWI.js +0 -10
- package/dist/chunk-3S6TI23B.js +0 -97
- package/dist/chunk-3VFIJYS4.js +0 -818
- package/dist/chunk-437F27T6.js +0 -97
- package/dist/chunk-52QE3YI3.js +0 -1169
- package/dist/chunk-57RP3DIN.js +0 -1205
- package/dist/chunk-5HSZ4W2P.js +0 -62
- package/dist/chunk-5I7GMRDN.js +0 -146
- package/dist/chunk-645IPXW3.js +0 -290
- package/dist/chunk-7A7ELD4C.js +0 -1205
- package/dist/chunk-7FYY4GZM.js +0 -1205
- package/dist/chunk-7IUE7ODU.js +0 -254
- package/dist/chunk-7RMLKZIS.js +0 -108
- package/dist/chunk-AA3OPP4Z.js +0 -432
- package/dist/chunk-AEWLSYPH.js +0 -72
- package/dist/chunk-ASSZDR6I.js +0 -108
- package/dist/chunk-AYRJVWUC.js +0 -1205
- package/dist/chunk-CCYI5O3D.js +0 -148
- package/dist/chunk-CGIDSAJB.js +0 -288
- package/dist/chunk-D3I3ZSE2.js +0 -411
- package/dist/chunk-D3MACYZ4.js +0 -108
- package/dist/chunk-DACSKLY6.js +0 -219
- package/dist/chunk-DFQ72B7M.js +0 -248
- package/dist/chunk-DW5B4BL7.js +0 -108
- package/dist/chunk-EKSACBTJ.js +0 -1070
- package/dist/chunk-EXEZZADG.js +0 -248
- package/dist/chunk-F3Y7EL7K.js +0 -83
- package/dist/chunk-FBQWSDPC.js +0 -1328
- package/dist/chunk-FHRZNOMW.js +0 -1205
- package/dist/chunk-IM7N24MT.js +0 -129
- package/dist/chunk-IPNYIXFK.js +0 -1178
- package/dist/chunk-J7MRSZIO.js +0 -167
- package/dist/chunk-JITKI2OI.js +0 -106
- package/dist/chunk-JWZXYVET.js +0 -1068
- package/dist/chunk-KCQUXVYT.js +0 -108
- package/dist/chunk-KOQ43OX6.js +0 -1281
- package/dist/chunk-KYVWO6ZM.js +0 -1069
- package/dist/chunk-L3VHARQH.js +0 -413
- package/dist/chunk-LBWDS6BE.js +0 -288
- package/dist/chunk-LOVAHSQV.js +0 -411
- package/dist/chunk-LQOYCAGG.js +0 -446
- package/dist/chunk-LWAIPJ2W.js +0 -146
- package/dist/chunk-M5DHKW7M.js +0 -127
- package/dist/chunk-MBKCIJHM.js +0 -1328
- package/dist/chunk-MK42FMEG.js +0 -147
- package/dist/chunk-MOBMYHKL.js +0 -1205
- package/dist/chunk-MPLTNMRG.js +0 -67
- package/dist/chunk-NIJCVN3O.js +0 -147
- package/dist/chunk-NX647OM3.js +0 -310
- package/dist/chunk-NZCFSZQ7.js +0 -1205
- package/dist/chunk-O2UITJGH.js +0 -465
- package/dist/chunk-OCRA44AZ.js +0 -108
- package/dist/chunk-P3KJR66H.js +0 -117
- package/dist/chunk-PEK6JH65.js +0 -432
- package/dist/chunk-PJ6FFKEX.js +0 -77
- package/dist/chunk-PLUBBZYR.js +0 -800
- package/dist/chunk-PNKVD2UK.js +0 -26
- package/dist/chunk-PSQZURHO.js +0 -229
- package/dist/chunk-SGL6ISBJ.js +0 -1061
- package/dist/chunk-SJABZZT5.js +0 -97
- package/dist/chunk-TD3P3K32.js +0 -1199
- package/dist/chunk-TMDZJJKV.js +0 -288
- package/dist/chunk-UNHVZB5G.js +0 -411
- package/dist/chunk-VAFTWSTE.js +0 -1061
- package/dist/chunk-VNFXFQBB.js +0 -217
- package/dist/chunk-X3GVFKSJ.js +0 -1205
- package/dist/chunk-XZ3S56RQ.js +0 -1061
- package/dist/chunk-Y72C7F6O.js +0 -148
- package/dist/chunk-YLICP577.js +0 -1205
- package/dist/chunk-YX6AXLVK.js +0 -159
- package/dist/chunk-ZCQYHTNU.js +0 -146
- package/dist/cloud-crystal.js +0 -6
- package/dist/dev-update-SZ2Z4WCQ.js +0 -6
- package/dist/llm-XXLYPIOF.js +0 -16
- package/dist/mlx-setup-XKU67WCT.js +0 -289
- package/dist/search-pipeline-4K4OJSSS.js +0 -255
- package/dist/search-pipeline-4PRS6LI7.js +0 -280
- package/dist/search-pipeline-7UJMXPLO.js +0 -280
- package/dist/search-pipeline-CBV25NX7.js +0 -99
- package/dist/search-pipeline-DQTRLGBH.js +0 -74
- package/dist/search-pipeline-HNG37REH.js +0 -282
- package/dist/search-pipeline-IZFPLBUB.js +0 -280
- package/dist/search-pipeline-MID6F26Q.js +0 -73
- package/dist/search-pipeline-N52JZFNN.js +0 -282
- package/dist/search-pipeline-OPB2PRQQ.js +0 -280
- package/dist/search-pipeline-VXTE5HAD.js +0 -262
- package/dist/search-pipeline-XHFKADRG.js +0 -73
- package/dist/worker-demo.js +0 -186
- package/dist/worker-mcp.js +0 -404
- package/scripts/crystal-capture 2.sh +0 -29
- package/scripts/deploy-cloud 2.sh +0 -153
package/dist/chunk-KCQUXVYT.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
resolveSecretPath
|
|
3
|
-
} from "./chunk-EXEZZADG.js";
|
|
4
|
-
|
|
5
|
-
// src/crypto.ts
|
|
6
|
-
import { readFileSync, existsSync } from "fs";
|
|
7
|
-
import { createCipheriv, createDecipheriv, createHmac, randomBytes, hkdfSync } from "crypto";
|
|
8
|
-
import { createHash } from "crypto";
|
|
9
|
-
var KEY_PATH = process.env.CRYSTAL_RELAY_KEY_PATH || resolveSecretPath("crystal-relay-key");
|
|
10
|
-
function loadRelayKey() {
|
|
11
|
-
if (!existsSync(KEY_PATH)) {
|
|
12
|
-
throw new Error(
|
|
13
|
-
`Relay key not found at ${KEY_PATH}
|
|
14
|
-
Generate one: mkdir -p ~/.ldm/secrets && openssl rand -base64 32 > ~/.ldm/secrets/crystal-relay-key && chmod 600 ~/.ldm/secrets/crystal-relay-key
|
|
15
|
-
Or run: crystal pair`
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
const raw = readFileSync(KEY_PATH, "utf-8").trim();
|
|
19
|
-
const key = Buffer.from(raw, "base64");
|
|
20
|
-
if (key.length !== 32) {
|
|
21
|
-
throw new Error(`Relay key must be 32 bytes (256 bits). Got ${key.length} bytes. Regenerate with: openssl rand -base64 32`);
|
|
22
|
-
}
|
|
23
|
-
return key;
|
|
24
|
-
}
|
|
25
|
-
function deriveSigningKey(masterKey) {
|
|
26
|
-
return Buffer.from(hkdfSync("sha256", masterKey, "", "crystal-relay-sign", 32));
|
|
27
|
-
}
|
|
28
|
-
function encrypt(plaintext, masterKey) {
|
|
29
|
-
const nonce = randomBytes(12);
|
|
30
|
-
const cipher = createCipheriv("aes-256-gcm", masterKey, nonce);
|
|
31
|
-
const ciphertext = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
32
|
-
const tag = cipher.getAuthTag();
|
|
33
|
-
const signingKey = deriveSigningKey(masterKey);
|
|
34
|
-
const hmacData = Buffer.concat([nonce, ciphertext, tag]);
|
|
35
|
-
const hmac = createHmac("sha256", signingKey).update(hmacData).digest("hex");
|
|
36
|
-
return {
|
|
37
|
-
v: 1,
|
|
38
|
-
nonce: nonce.toString("base64"),
|
|
39
|
-
ciphertext: ciphertext.toString("base64"),
|
|
40
|
-
tag: tag.toString("base64"),
|
|
41
|
-
hmac
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function decrypt(payload, masterKey) {
|
|
45
|
-
if (payload.v !== 1) {
|
|
46
|
-
throw new Error(`Unknown payload version: ${payload.v}`);
|
|
47
|
-
}
|
|
48
|
-
const nonce = Buffer.from(payload.nonce, "base64");
|
|
49
|
-
const ciphertext = Buffer.from(payload.ciphertext, "base64");
|
|
50
|
-
const tag = Buffer.from(payload.tag, "base64");
|
|
51
|
-
const signingKey = deriveSigningKey(masterKey);
|
|
52
|
-
const hmacData = Buffer.concat([nonce, ciphertext, tag]);
|
|
53
|
-
const expectedHmac = createHmac("sha256", signingKey).update(hmacData).digest("hex");
|
|
54
|
-
if (payload.hmac !== expectedHmac) {
|
|
55
|
-
throw new Error("HMAC verification failed \u2014 blob rejected (tampered or wrong key)");
|
|
56
|
-
}
|
|
57
|
-
const decipher = createDecipheriv("aes-256-gcm", masterKey, nonce);
|
|
58
|
-
decipher.setAuthTag(tag);
|
|
59
|
-
return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
|
60
|
-
}
|
|
61
|
-
function encryptJSON(data, masterKey) {
|
|
62
|
-
const plaintext = Buffer.from(JSON.stringify(data), "utf-8");
|
|
63
|
-
return encrypt(plaintext, masterKey);
|
|
64
|
-
}
|
|
65
|
-
function decryptJSON(payload, masterKey) {
|
|
66
|
-
const plaintext = decrypt(payload, masterKey);
|
|
67
|
-
return JSON.parse(plaintext.toString("utf-8"));
|
|
68
|
-
}
|
|
69
|
-
function encryptFile(filePath, masterKey) {
|
|
70
|
-
const plaintext = readFileSync(filePath);
|
|
71
|
-
return encrypt(plaintext, masterKey);
|
|
72
|
-
}
|
|
73
|
-
var RELAY_KEY_PATH = KEY_PATH;
|
|
74
|
-
function generateRelayKey() {
|
|
75
|
-
return randomBytes(32);
|
|
76
|
-
}
|
|
77
|
-
function encodePairingString(key) {
|
|
78
|
-
if (key.length !== 32) throw new Error("Key must be 32 bytes");
|
|
79
|
-
return `mc1:${key.toString("base64")}`;
|
|
80
|
-
}
|
|
81
|
-
function decodePairingString(str) {
|
|
82
|
-
const trimmed = str.trim();
|
|
83
|
-
if (!trimmed.startsWith("mc1:")) {
|
|
84
|
-
throw new Error("Invalid pairing string (expected mc1: prefix)");
|
|
85
|
-
}
|
|
86
|
-
const key = Buffer.from(trimmed.slice(4), "base64");
|
|
87
|
-
if (key.length !== 32) {
|
|
88
|
-
throw new Error(`Invalid key length: expected 32 bytes, got ${key.length}`);
|
|
89
|
-
}
|
|
90
|
-
return key;
|
|
91
|
-
}
|
|
92
|
-
function hashBuffer(data) {
|
|
93
|
-
return createHash("sha256").update(data).digest("hex");
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export {
|
|
97
|
-
loadRelayKey,
|
|
98
|
-
encrypt,
|
|
99
|
-
decrypt,
|
|
100
|
-
encryptJSON,
|
|
101
|
-
decryptJSON,
|
|
102
|
-
encryptFile,
|
|
103
|
-
RELAY_KEY_PATH,
|
|
104
|
-
generateRelayKey,
|
|
105
|
-
encodePairingString,
|
|
106
|
-
decodePairingString,
|
|
107
|
-
hashBuffer
|
|
108
|
-
};
|