@wipcomputer/memory-crystal 0.7.34-alpha.3 → 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.
Files changed (97) hide show
  1. package/package.json +7 -4
  2. package/dist/chunk-25LXQJ4Z.js +0 -110
  3. package/dist/chunk-2DRXIRQW.js +0 -97
  4. package/dist/chunk-2GBYLMEF.js +0 -1385
  5. package/dist/chunk-2ZNH5F6E.js +0 -1281
  6. package/dist/chunk-3G3SFYYI.js +0 -288
  7. package/dist/chunk-3RG5ZIWI.js +0 -10
  8. package/dist/chunk-3S6TI23B.js +0 -97
  9. package/dist/chunk-3VFIJYS4.js +0 -818
  10. package/dist/chunk-437F27T6.js +0 -97
  11. package/dist/chunk-52QE3YI3.js +0 -1169
  12. package/dist/chunk-57RP3DIN.js +0 -1205
  13. package/dist/chunk-5HSZ4W2P.js +0 -62
  14. package/dist/chunk-5I7GMRDN.js +0 -146
  15. package/dist/chunk-645IPXW3.js +0 -290
  16. package/dist/chunk-7A7ELD4C.js +0 -1205
  17. package/dist/chunk-7FYY4GZM.js +0 -1205
  18. package/dist/chunk-7IUE7ODU.js +0 -254
  19. package/dist/chunk-7RMLKZIS.js +0 -108
  20. package/dist/chunk-AA3OPP4Z.js +0 -432
  21. package/dist/chunk-AEWLSYPH.js +0 -72
  22. package/dist/chunk-ASSZDR6I.js +0 -108
  23. package/dist/chunk-AYRJVWUC.js +0 -1205
  24. package/dist/chunk-CCYI5O3D.js +0 -148
  25. package/dist/chunk-CGIDSAJB.js +0 -288
  26. package/dist/chunk-D3I3ZSE2.js +0 -411
  27. package/dist/chunk-D3MACYZ4.js +0 -108
  28. package/dist/chunk-DACSKLY6.js +0 -219
  29. package/dist/chunk-DFQ72B7M.js +0 -248
  30. package/dist/chunk-DW5B4BL7.js +0 -108
  31. package/dist/chunk-EKSACBTJ.js +0 -1070
  32. package/dist/chunk-EXEZZADG.js +0 -248
  33. package/dist/chunk-F3Y7EL7K.js +0 -83
  34. package/dist/chunk-FBQWSDPC.js +0 -1328
  35. package/dist/chunk-FHRZNOMW.js +0 -1205
  36. package/dist/chunk-IM7N24MT.js +0 -129
  37. package/dist/chunk-IPNYIXFK.js +0 -1178
  38. package/dist/chunk-J7MRSZIO.js +0 -167
  39. package/dist/chunk-JITKI2OI.js +0 -106
  40. package/dist/chunk-JWZXYVET.js +0 -1068
  41. package/dist/chunk-KCQUXVYT.js +0 -108
  42. package/dist/chunk-KOQ43OX6.js +0 -1281
  43. package/dist/chunk-KYVWO6ZM.js +0 -1069
  44. package/dist/chunk-L3VHARQH.js +0 -413
  45. package/dist/chunk-LBWDS6BE.js +0 -288
  46. package/dist/chunk-LOVAHSQV.js +0 -411
  47. package/dist/chunk-LQOYCAGG.js +0 -446
  48. package/dist/chunk-LWAIPJ2W.js +0 -146
  49. package/dist/chunk-M5DHKW7M.js +0 -127
  50. package/dist/chunk-MBKCIJHM.js +0 -1328
  51. package/dist/chunk-MK42FMEG.js +0 -147
  52. package/dist/chunk-MOBMYHKL.js +0 -1205
  53. package/dist/chunk-MPLTNMRG.js +0 -67
  54. package/dist/chunk-NIJCVN3O.js +0 -147
  55. package/dist/chunk-NX647OM3.js +0 -310
  56. package/dist/chunk-NZCFSZQ7.js +0 -1205
  57. package/dist/chunk-O2UITJGH.js +0 -465
  58. package/dist/chunk-OCRA44AZ.js +0 -108
  59. package/dist/chunk-P3KJR66H.js +0 -117
  60. package/dist/chunk-PEK6JH65.js +0 -432
  61. package/dist/chunk-PJ6FFKEX.js +0 -77
  62. package/dist/chunk-PLUBBZYR.js +0 -800
  63. package/dist/chunk-PNKVD2UK.js +0 -26
  64. package/dist/chunk-PSQZURHO.js +0 -229
  65. package/dist/chunk-SGL6ISBJ.js +0 -1061
  66. package/dist/chunk-SJABZZT5.js +0 -97
  67. package/dist/chunk-TD3P3K32.js +0 -1199
  68. package/dist/chunk-TMDZJJKV.js +0 -288
  69. package/dist/chunk-UNHVZB5G.js +0 -411
  70. package/dist/chunk-VAFTWSTE.js +0 -1061
  71. package/dist/chunk-VNFXFQBB.js +0 -217
  72. package/dist/chunk-X3GVFKSJ.js +0 -1205
  73. package/dist/chunk-XZ3S56RQ.js +0 -1061
  74. package/dist/chunk-Y72C7F6O.js +0 -148
  75. package/dist/chunk-YLICP577.js +0 -1205
  76. package/dist/chunk-YX6AXLVK.js +0 -159
  77. package/dist/chunk-ZCQYHTNU.js +0 -146
  78. package/dist/cloud-crystal.js +0 -6
  79. package/dist/dev-update-SZ2Z4WCQ.js +0 -6
  80. package/dist/llm-XXLYPIOF.js +0 -16
  81. package/dist/mlx-setup-XKU67WCT.js +0 -289
  82. package/dist/search-pipeline-4K4OJSSS.js +0 -255
  83. package/dist/search-pipeline-4PRS6LI7.js +0 -280
  84. package/dist/search-pipeline-7UJMXPLO.js +0 -280
  85. package/dist/search-pipeline-CBV25NX7.js +0 -99
  86. package/dist/search-pipeline-DQTRLGBH.js +0 -74
  87. package/dist/search-pipeline-HNG37REH.js +0 -282
  88. package/dist/search-pipeline-IZFPLBUB.js +0 -280
  89. package/dist/search-pipeline-MID6F26Q.js +0 -73
  90. package/dist/search-pipeline-N52JZFNN.js +0 -282
  91. package/dist/search-pipeline-OPB2PRQQ.js +0 -280
  92. package/dist/search-pipeline-VXTE5HAD.js +0 -262
  93. package/dist/search-pipeline-XHFKADRG.js +0 -73
  94. package/dist/worker-demo.js +0 -186
  95. package/dist/worker-mcp.js +0 -404
  96. package/scripts/crystal-capture 2.sh +0 -29
  97. package/scripts/deploy-cloud 2.sh +0 -153
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wipcomputer/memory-crystal",
3
- "version": "0.7.34-alpha.3",
3
+ "version": "0.7.34-alpha.4",
4
4
  "description": "Sovereign memory system — local-first with ephemeral encrypted relay. Your memory, your machine, your rules.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,10 @@
19
19
  },
20
20
  "files": [
21
21
  "dist/",
22
- "scripts/",
22
+ "scripts/crystal-capture.sh",
23
+ "scripts/deploy-cloud.sh",
24
+ "scripts/ldm-backup.sh",
25
+ "scripts/migrate-lance-to-sqlite.mjs",
23
26
  "skills/",
24
27
  "migrations/",
25
28
  "cloud/",
@@ -32,8 +35,8 @@
32
35
  ],
33
36
  "scripts": {
34
37
  "prepublishOnly": "npm run build",
35
- "build": "tsup src/core.ts src/cli.ts src/mcp-server.ts src/openclaw.ts src/migrate.ts src/cc-hook.ts src/cc-poller.ts src/crypto.ts src/pair.ts src/poller.ts src/mirror-sync.ts src/file-sync.ts src/ldm.ts src/summarize.ts src/role.ts src/doctor.ts src/bridge.ts src/discover.ts src/bulk-copy.ts src/oc-backfill.ts src/dream-weaver.ts src/crystal-serve.ts src/staging.ts src/installer.ts --format esm --dts --outDir dist --no-splitting && tsup src/worker.ts --format esm --outDir dist --no-dts --no-splitting && cp scripts/crystal-capture.sh scripts/ldm-backup.sh dist/",
36
- "build:local": "tsup src/core.ts src/cli.ts src/mcp-server.ts src/openclaw.ts src/migrate.ts src/cc-hook.ts src/cc-poller.ts src/crypto.ts src/pair.ts src/poller.ts src/mirror-sync.ts src/file-sync.ts src/ldm.ts src/summarize.ts src/role.ts src/doctor.ts src/bridge.ts src/discover.ts src/bulk-copy.ts src/oc-backfill.ts src/dream-weaver.ts src/crystal-serve.ts src/staging.ts src/installer.ts --format esm --dts --outDir dist --no-splitting",
38
+ "build": "tsup src/core.ts src/cli.ts src/mcp-server.ts src/openclaw.ts src/migrate.ts src/cc-hook.ts src/cc-poller.ts src/crypto.ts src/pair.ts src/poller.ts src/mirror-sync.ts src/file-sync.ts src/ldm.ts src/summarize.ts src/role.ts src/doctor.ts src/bridge.ts src/discover.ts src/bulk-copy.ts src/oc-backfill.ts src/dream-weaver.ts src/crystal-serve.ts src/staging.ts src/installer.ts --format esm --dts --outDir dist --no-splitting --clean && tsup src/worker.ts --format esm --outDir dist --no-dts --no-splitting && cp scripts/crystal-capture.sh scripts/ldm-backup.sh dist/",
39
+ "build:local": "tsup src/core.ts src/cli.ts src/mcp-server.ts src/openclaw.ts src/migrate.ts src/cc-hook.ts src/cc-poller.ts src/crypto.ts src/pair.ts src/poller.ts src/mirror-sync.ts src/file-sync.ts src/ldm.ts src/summarize.ts src/role.ts src/doctor.ts src/bridge.ts src/discover.ts src/bulk-copy.ts src/oc-backfill.ts src/dream-weaver.ts src/crystal-serve.ts src/staging.ts src/installer.ts --format esm --dts --outDir dist --no-splitting --clean",
37
40
  "build:worker": "tsup src/worker.ts --format esm --outDir dist --no-dts",
38
41
  "build:cloud": "tsup src/worker-mcp.ts src/cloud-crystal.ts --format esm --outDir dist --no-dts",
39
42
  "deploy:cloud": "bash -c 'git diff --quiet HEAD -- src/ wrangler-mcp.toml || (echo \"ERROR: uncommitted changes. commit before deploying.\" && exit 1)' && wrangler deploy --config wrangler-mcp.toml",
@@ -1,110 +0,0 @@
1
- import {
2
- init_ldm,
3
- resolveSecretPath
4
- } from "./chunk-PSQZURHO.js";
5
-
6
- // src/crypto.ts
7
- init_ldm();
8
- import { readFileSync, existsSync } from "fs";
9
- import { createCipheriv, createDecipheriv, createHmac, randomBytes, hkdfSync } from "crypto";
10
- import { createHash } from "crypto";
11
- var KEY_PATH = process.env.CRYSTAL_RELAY_KEY_PATH || resolveSecretPath("crystal-relay-key");
12
- function loadRelayKey() {
13
- if (!existsSync(KEY_PATH)) {
14
- throw new Error(
15
- `Relay key not found at ${KEY_PATH}
16
- Generate one: openssl rand -base64 32 > ${KEY_PATH} && chmod 600 ${KEY_PATH}
17
- Copy the same key to all trusted machines.`
18
- );
19
- }
20
- const raw = readFileSync(KEY_PATH, "utf-8").trim();
21
- const key = Buffer.from(raw, "base64");
22
- if (key.length !== 32) {
23
- throw new Error(`Relay key must be 32 bytes (256 bits). Got ${key.length} bytes. Regenerate with: openssl rand -base64 32`);
24
- }
25
- return key;
26
- }
27
- function deriveSigningKey(masterKey) {
28
- return Buffer.from(hkdfSync("sha256", masterKey, "", "crystal-relay-sign", 32));
29
- }
30
- function encrypt(plaintext, masterKey) {
31
- const nonce = randomBytes(12);
32
- const cipher = createCipheriv("aes-256-gcm", masterKey, nonce);
33
- const ciphertext = Buffer.concat([cipher.update(plaintext), cipher.final()]);
34
- const tag = cipher.getAuthTag();
35
- const signingKey = deriveSigningKey(masterKey);
36
- const hmacData = Buffer.concat([nonce, ciphertext, tag]);
37
- const hmac = createHmac("sha256", signingKey).update(hmacData).digest("hex");
38
- return {
39
- v: 1,
40
- nonce: nonce.toString("base64"),
41
- ciphertext: ciphertext.toString("base64"),
42
- tag: tag.toString("base64"),
43
- hmac
44
- };
45
- }
46
- function decrypt(payload, masterKey) {
47
- if (payload.v !== 1) {
48
- throw new Error(`Unknown payload version: ${payload.v}`);
49
- }
50
- const nonce = Buffer.from(payload.nonce, "base64");
51
- const ciphertext = Buffer.from(payload.ciphertext, "base64");
52
- const tag = Buffer.from(payload.tag, "base64");
53
- const signingKey = deriveSigningKey(masterKey);
54
- const hmacData = Buffer.concat([nonce, ciphertext, tag]);
55
- const expectedHmac = createHmac("sha256", signingKey).update(hmacData).digest("hex");
56
- if (payload.hmac !== expectedHmac) {
57
- throw new Error("HMAC verification failed \u2014 blob rejected (tampered or wrong key)");
58
- }
59
- const decipher = createDecipheriv("aes-256-gcm", masterKey, nonce);
60
- decipher.setAuthTag(tag);
61
- return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
62
- }
63
- function encryptJSON(data, masterKey) {
64
- const plaintext = Buffer.from(JSON.stringify(data), "utf-8");
65
- return encrypt(plaintext, masterKey);
66
- }
67
- function decryptJSON(payload, masterKey) {
68
- const plaintext = decrypt(payload, masterKey);
69
- return JSON.parse(plaintext.toString("utf-8"));
70
- }
71
- function encryptFile(filePath, masterKey) {
72
- const plaintext = readFileSync(filePath);
73
- return encrypt(plaintext, masterKey);
74
- }
75
- var RELAY_KEY_PATH = KEY_PATH;
76
- function generateRelayKey() {
77
- return randomBytes(32);
78
- }
79
- function encodePairingString(key) {
80
- if (key.length !== 32) throw new Error("Key must be 32 bytes");
81
- return `mc1:${key.toString("base64")}`;
82
- }
83
- function decodePairingString(str) {
84
- const trimmed = str.trim();
85
- if (!trimmed.startsWith("mc1:")) {
86
- throw new Error("Invalid pairing string (expected mc1: prefix)");
87
- }
88
- const key = Buffer.from(trimmed.slice(4), "base64");
89
- if (key.length !== 32) {
90
- throw new Error(`Invalid key length: expected 32 bytes, got ${key.length}`);
91
- }
92
- return key;
93
- }
94
- function hashBuffer(data) {
95
- return createHash("sha256").update(data).digest("hex");
96
- }
97
-
98
- export {
99
- loadRelayKey,
100
- encrypt,
101
- decrypt,
102
- encryptJSON,
103
- decryptJSON,
104
- encryptFile,
105
- RELAY_KEY_PATH,
106
- generateRelayKey,
107
- encodePairingString,
108
- decodePairingString,
109
- hashBuffer
110
- };
@@ -1,97 +0,0 @@
1
- import {
2
- getAgentId,
3
- ldmPaths,
4
- resolveSecretPath,
5
- resolveStatePath,
6
- stateWritePath
7
- } from "./chunk-DACSKLY6.js";
8
-
9
- // src/role.ts
10
- import { existsSync, readFileSync, writeFileSync } from "fs";
11
- var STATE_FILE = "crystal-role.json";
12
- function loadRoleState() {
13
- try {
14
- const path = resolveStatePath(STATE_FILE);
15
- if (existsSync(path)) {
16
- return JSON.parse(readFileSync(path, "utf-8"));
17
- }
18
- } catch {
19
- }
20
- return null;
21
- }
22
- function saveRoleState(state) {
23
- const writePath = stateWritePath(STATE_FILE);
24
- writeFileSync(writePath, JSON.stringify(state, null, 2) + "\n");
25
- }
26
- function hasLocalEmbeddingProvider() {
27
- if (process.env.OPENAI_API_KEY) return true;
28
- if (process.env.GOOGLE_API_KEY && process.env.CRYSTAL_EMBEDDING_PROVIDER === "google") return true;
29
- if (process.env.CRYSTAL_EMBEDDING_PROVIDER === "ollama") return true;
30
- return false;
31
- }
32
- function hasRelayKey() {
33
- const keyPath = resolveSecretPath("crystal-relay-key");
34
- return existsSync(keyPath);
35
- }
36
- function detectRole() {
37
- const agentId = getAgentId();
38
- const paths = ldmPaths(agentId);
39
- const relayUrl = process.env.CRYSTAL_RELAY_URL || null;
40
- const relayToken = !!process.env.CRYSTAL_RELAY_TOKEN;
41
- const relayKeyExists = hasRelayKey();
42
- const localEmbeddings = hasLocalEmbeddingProvider();
43
- const localDb = existsSync(paths.crystalDb);
44
- const state = loadRoleState();
45
- if (state && state.override) {
46
- return {
47
- role: state.role,
48
- source: "state-file",
49
- relayUrl,
50
- relayToken,
51
- relayKeyExists,
52
- agentId,
53
- hasLocalEmbeddings: localEmbeddings,
54
- hasLocalDb: localDb
55
- };
56
- }
57
- let role = "standalone";
58
- if (relayUrl && !localEmbeddings) {
59
- role = "node";
60
- } else if (relayUrl && localEmbeddings) {
61
- role = "core";
62
- }
63
- return {
64
- role,
65
- source: "auto-detected",
66
- relayUrl,
67
- relayToken,
68
- relayKeyExists,
69
- agentId,
70
- hasLocalEmbeddings: localEmbeddings,
71
- hasLocalDb: localDb
72
- };
73
- }
74
- function promoteToCore() {
75
- saveRoleState({
76
- role: "core",
77
- override: true,
78
- agentId: getAgentId(),
79
- setAt: (/* @__PURE__ */ new Date()).toISOString()
80
- });
81
- }
82
- function demoteToNode(relayUrl) {
83
- saveRoleState({
84
- role: "node",
85
- override: true,
86
- relayUrl,
87
- agentId: getAgentId(),
88
- setAt: (/* @__PURE__ */ new Date()).toISOString()
89
- });
90
- }
91
-
92
- export {
93
- loadRoleState,
94
- detectRole,
95
- promoteToCore,
96
- demoteToNode
97
- };