@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.
Files changed (120) hide show
  1. package/LICENSE +1 -1
  2. package/dist/bridge.js +64 -7
  3. package/dist/bulk-copy.js +67 -16
  4. package/dist/cc-hook.js +2163 -62
  5. package/dist/cc-poller.js +1967 -70
  6. package/dist/cli.js +4538 -139
  7. package/dist/core.js +1789 -6
  8. package/dist/crypto.js +153 -14
  9. package/dist/crystal-serve.js +64 -12
  10. package/dist/doctor.js +517 -52
  11. package/dist/dream-weaver.js +1755 -7
  12. package/dist/file-sync.js +407 -9
  13. package/dist/installer.js +840 -145
  14. package/dist/ldm.js +231 -16
  15. package/dist/mcp-server.js +1882 -17
  16. package/dist/migrate.js +1707 -11
  17. package/dist/mirror-sync.js +2052 -34
  18. package/dist/openclaw.js +1895 -84
  19. package/dist/pair.js +112 -16
  20. package/dist/poller.js +2275 -80
  21. package/dist/role.js +159 -7
  22. package/dist/staging.js +235 -10
  23. package/dist/summarize.js +142 -5
  24. package/package.json +7 -4
  25. package/dist/chunk-25LXQJ4Z.js +0 -110
  26. package/dist/chunk-2DRXIRQW.js +0 -97
  27. package/dist/chunk-2GBYLMEF.js +0 -1385
  28. package/dist/chunk-2ZNH5F6E.js +0 -1281
  29. package/dist/chunk-3G3SFYYI.js +0 -288
  30. package/dist/chunk-3RG5ZIWI.js +0 -10
  31. package/dist/chunk-3S6TI23B.js +0 -97
  32. package/dist/chunk-3VFIJYS4.js +0 -818
  33. package/dist/chunk-437F27T6.js +0 -97
  34. package/dist/chunk-52QE3YI3.js +0 -1169
  35. package/dist/chunk-57RP3DIN.js +0 -1205
  36. package/dist/chunk-5HSZ4W2P.js +0 -62
  37. package/dist/chunk-5I7GMRDN.js +0 -146
  38. package/dist/chunk-645IPXW3.js +0 -290
  39. package/dist/chunk-7A7ELD4C.js +0 -1205
  40. package/dist/chunk-7FYY4GZM.js +0 -1205
  41. package/dist/chunk-7IUE7ODU.js +0 -254
  42. package/dist/chunk-7RMLKZIS.js +0 -108
  43. package/dist/chunk-AA3OPP4Z.js +0 -432
  44. package/dist/chunk-AEWLSYPH.js +0 -72
  45. package/dist/chunk-ASSZDR6I.js +0 -108
  46. package/dist/chunk-AYRJVWUC.js +0 -1205
  47. package/dist/chunk-CCYI5O3D.js +0 -148
  48. package/dist/chunk-CGIDSAJB.js +0 -288
  49. package/dist/chunk-D3I3ZSE2.js +0 -411
  50. package/dist/chunk-D3MACYZ4.js +0 -108
  51. package/dist/chunk-DACSKLY6.js +0 -219
  52. package/dist/chunk-DFQ72B7M.js +0 -248
  53. package/dist/chunk-DW5B4BL7.js +0 -108
  54. package/dist/chunk-EKSACBTJ.js +0 -1070
  55. package/dist/chunk-EXEZZADG.js +0 -248
  56. package/dist/chunk-F3Y7EL7K.js +0 -83
  57. package/dist/chunk-FBQWSDPC.js +0 -1328
  58. package/dist/chunk-FHRZNOMW.js +0 -1205
  59. package/dist/chunk-IM7N24MT.js +0 -129
  60. package/dist/chunk-IPNYIXFK.js +0 -1178
  61. package/dist/chunk-J7MRSZIO.js +0 -167
  62. package/dist/chunk-JITKI2OI.js +0 -106
  63. package/dist/chunk-JWZXYVET.js +0 -1068
  64. package/dist/chunk-KCQUXVYT.js +0 -108
  65. package/dist/chunk-KOQ43OX6.js +0 -1281
  66. package/dist/chunk-KYVWO6ZM.js +0 -1069
  67. package/dist/chunk-L3VHARQH.js +0 -413
  68. package/dist/chunk-LBWDS6BE.js +0 -288
  69. package/dist/chunk-LOVAHSQV.js +0 -411
  70. package/dist/chunk-LQOYCAGG.js +0 -446
  71. package/dist/chunk-LWAIPJ2W.js +0 -146
  72. package/dist/chunk-M5DHKW7M.js +0 -127
  73. package/dist/chunk-MBKCIJHM.js +0 -1328
  74. package/dist/chunk-MK42FMEG.js +0 -147
  75. package/dist/chunk-MOBMYHKL.js +0 -1205
  76. package/dist/chunk-MPLTNMRG.js +0 -67
  77. package/dist/chunk-NIJCVN3O.js +0 -147
  78. package/dist/chunk-NX647OM3.js +0 -310
  79. package/dist/chunk-NZCFSZQ7.js +0 -1205
  80. package/dist/chunk-O2UITJGH.js +0 -465
  81. package/dist/chunk-OCRA44AZ.js +0 -108
  82. package/dist/chunk-P3KJR66H.js +0 -117
  83. package/dist/chunk-PEK6JH65.js +0 -432
  84. package/dist/chunk-PJ6FFKEX.js +0 -77
  85. package/dist/chunk-PLUBBZYR.js +0 -800
  86. package/dist/chunk-PNKVD2UK.js +0 -26
  87. package/dist/chunk-PSQZURHO.js +0 -229
  88. package/dist/chunk-SGL6ISBJ.js +0 -1061
  89. package/dist/chunk-SJABZZT5.js +0 -97
  90. package/dist/chunk-TD3P3K32.js +0 -1199
  91. package/dist/chunk-TMDZJJKV.js +0 -288
  92. package/dist/chunk-UNHVZB5G.js +0 -411
  93. package/dist/chunk-VAFTWSTE.js +0 -1061
  94. package/dist/chunk-VNFXFQBB.js +0 -217
  95. package/dist/chunk-X3GVFKSJ.js +0 -1205
  96. package/dist/chunk-XZ3S56RQ.js +0 -1061
  97. package/dist/chunk-Y72C7F6O.js +0 -148
  98. package/dist/chunk-YLICP577.js +0 -1205
  99. package/dist/chunk-YX6AXLVK.js +0 -159
  100. package/dist/chunk-ZCQYHTNU.js +0 -146
  101. package/dist/cloud-crystal.js +0 -6
  102. package/dist/dev-update-SZ2Z4WCQ.js +0 -6
  103. package/dist/llm-XXLYPIOF.js +0 -16
  104. package/dist/mlx-setup-XKU67WCT.js +0 -289
  105. package/dist/search-pipeline-4K4OJSSS.js +0 -255
  106. package/dist/search-pipeline-4PRS6LI7.js +0 -280
  107. package/dist/search-pipeline-7UJMXPLO.js +0 -280
  108. package/dist/search-pipeline-CBV25NX7.js +0 -99
  109. package/dist/search-pipeline-DQTRLGBH.js +0 -74
  110. package/dist/search-pipeline-HNG37REH.js +0 -282
  111. package/dist/search-pipeline-IZFPLBUB.js +0 -280
  112. package/dist/search-pipeline-MID6F26Q.js +0 -73
  113. package/dist/search-pipeline-N52JZFNN.js +0 -282
  114. package/dist/search-pipeline-OPB2PRQQ.js +0 -280
  115. package/dist/search-pipeline-VXTE5HAD.js +0 -262
  116. package/dist/search-pipeline-XHFKADRG.js +0 -73
  117. package/dist/worker-demo.js +0 -186
  118. package/dist/worker-mcp.js +0 -404
  119. package/scripts/crystal-capture 2.sh +0 -29
  120. package/scripts/deploy-cloud 2.sh +0 -153
package/dist/pair.js CHANGED
@@ -1,15 +1,111 @@
1
- import {
2
- RELAY_KEY_PATH,
3
- decodePairingString,
4
- encodePairingString,
5
- generateRelayKey,
6
- loadRelayKey
7
- } from "./chunk-D3MACYZ4.js";
8
- import "./chunk-DFQ72B7M.js";
1
+ // src/pair.ts
2
+ import { existsSync as existsSync3, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2, chmodSync as chmodSync2 } from "fs";
3
+ import { dirname as dirname2 } from "path";
4
+
5
+ // src/crypto.ts
6
+ import { readFileSync as readFileSync2, existsSync as existsSync2 } from "fs";
7
+ import { createCipheriv, createDecipheriv, createHmac, randomBytes, hkdfSync } from "crypto";
8
+
9
+ // src/ldm.ts
10
+ import { existsSync, mkdirSync, readFileSync, writeFileSync, copyFileSync, chmodSync, readdirSync } from "fs";
11
+ import { join, dirname } from "path";
12
+ import { execSync } from "child_process";
13
+ import { fileURLToPath } from "url";
14
+ var HOME = process.env.HOME || "";
15
+ var LDM_ROOT = join(HOME, ".ldm");
16
+ function loadAgentConfig(id) {
17
+ const cfgPath = join(LDM_ROOT, "agents", id, "config.json");
18
+ try {
19
+ if (existsSync(cfgPath)) return JSON.parse(readFileSync(cfgPath, "utf-8"));
20
+ } catch {
21
+ }
22
+ return null;
23
+ }
24
+ function getAgentId(harnessHint) {
25
+ if (process.env.CRYSTAL_AGENT_ID) return process.env.CRYSTAL_AGENT_ID;
26
+ const agentsDir = join(LDM_ROOT, "agents");
27
+ if (existsSync(agentsDir)) {
28
+ try {
29
+ for (const d of readdirSync(agentsDir)) {
30
+ const cfg = loadAgentConfig(d);
31
+ if (!cfg || !cfg.agentId) continue;
32
+ if (!harnessHint) return cfg.agentId;
33
+ if (harnessHint === "claude-code" && cfg.harness === "claude-code-cli") return cfg.agentId;
34
+ if (harnessHint === "openclaw" && cfg.harness === "openclaw") return cfg.agentId;
35
+ }
36
+ } catch {
37
+ }
38
+ }
39
+ return harnessHint === "openclaw" ? "oc-lesa-mini" : "cc-mini";
40
+ }
41
+ function ldmPaths(agentId) {
42
+ const id = agentId || getAgentId();
43
+ const agentRoot = join(LDM_ROOT, "agents", id);
44
+ return {
45
+ root: LDM_ROOT,
46
+ bin: join(LDM_ROOT, "bin"),
47
+ secrets: join(LDM_ROOT, "secrets"),
48
+ state: join(LDM_ROOT, "state"),
49
+ config: join(LDM_ROOT, "config.json"),
50
+ crystalDb: join(LDM_ROOT, "memory", "crystal.db"),
51
+ crystalLance: join(LDM_ROOT, "memory", "lance"),
52
+ agentRoot,
53
+ transcripts: join(agentRoot, "memory", "transcripts"),
54
+ sessions: join(agentRoot, "memory", "sessions"),
55
+ daily: join(agentRoot, "memory", "daily"),
56
+ journals: join(agentRoot, "memory", "journals"),
57
+ workspace: join(agentRoot, "memory", "workspace")
58
+ };
59
+ }
60
+ var LEGACY_OC_DIR = join(HOME, ".openclaw");
61
+ function resolveSecretPath(filename) {
62
+ const paths = ldmPaths();
63
+ const ldmPath = join(paths.secrets, filename);
64
+ if (existsSync(ldmPath)) return ldmPath;
65
+ const legacyPath = join(LEGACY_OC_DIR, "secrets", filename);
66
+ if (existsSync(legacyPath)) return legacyPath;
67
+ return ldmPath;
68
+ }
69
+
70
+ // src/crypto.ts
71
+ import { createHash } from "crypto";
72
+ var KEY_PATH = process.env.CRYSTAL_RELAY_KEY_PATH || resolveSecretPath("crystal-relay-key");
73
+ function loadRelayKey() {
74
+ if (!existsSync2(KEY_PATH)) {
75
+ throw new Error(
76
+ `Relay key not found at ${KEY_PATH}
77
+ Generate one: mkdir -p ~/.ldm/secrets && openssl rand -base64 32 > ~/.ldm/secrets/crystal-relay-key && chmod 600 ~/.ldm/secrets/crystal-relay-key
78
+ Or run: crystal pair`
79
+ );
80
+ }
81
+ const raw = readFileSync2(KEY_PATH, "utf-8").trim();
82
+ const key = Buffer.from(raw, "base64");
83
+ if (key.length !== 32) {
84
+ throw new Error(`Relay key must be 32 bytes (256 bits). Got ${key.length} bytes. Regenerate with: openssl rand -base64 32`);
85
+ }
86
+ return key;
87
+ }
88
+ var RELAY_KEY_PATH = KEY_PATH;
89
+ function generateRelayKey() {
90
+ return randomBytes(32);
91
+ }
92
+ function encodePairingString(key) {
93
+ if (key.length !== 32) throw new Error("Key must be 32 bytes");
94
+ return `mc1:${key.toString("base64")}`;
95
+ }
96
+ function decodePairingString(str) {
97
+ const trimmed = str.trim();
98
+ if (!trimmed.startsWith("mc1:")) {
99
+ throw new Error("Invalid pairing string (expected mc1: prefix)");
100
+ }
101
+ const key = Buffer.from(trimmed.slice(4), "base64");
102
+ if (key.length !== 32) {
103
+ throw new Error(`Invalid key length: expected 32 bytes, got ${key.length}`);
104
+ }
105
+ return key;
106
+ }
9
107
 
10
108
  // src/pair.ts
11
- import { existsSync, writeFileSync, mkdirSync, chmodSync } from "fs";
12
- import { dirname } from "path";
13
109
  import qrcode from "qrcode-terminal";
14
110
  function generateQR(text) {
15
111
  return new Promise((resolve) => {
@@ -19,13 +115,13 @@ function generateQR(text) {
19
115
  });
20
116
  }
21
117
  function saveKey(key) {
22
- const dir = dirname(RELAY_KEY_PATH);
23
- if (!existsSync(dir)) {
24
- mkdirSync(dir, { recursive: true });
118
+ const dir = dirname2(RELAY_KEY_PATH);
119
+ if (!existsSync3(dir)) {
120
+ mkdirSync2(dir, { recursive: true });
25
121
  }
26
- writeFileSync(RELAY_KEY_PATH, key.toString("base64") + "\n", { mode: 384 });
122
+ writeFileSync2(RELAY_KEY_PATH, key.toString("base64") + "\n", { mode: 384 });
27
123
  try {
28
- chmodSync(RELAY_KEY_PATH, 384);
124
+ chmodSync2(RELAY_KEY_PATH, 384);
29
125
  } catch {
30
126
  }
31
127
  }
@@ -54,7 +150,7 @@ async function pairShow() {
54
150
  }
55
151
  function pairReceive(code) {
56
152
  const key = decodePairingString(code);
57
- if (existsSync(RELAY_KEY_PATH)) {
153
+ if (existsSync3(RELAY_KEY_PATH)) {
58
154
  try {
59
155
  const existing = loadRelayKey();
60
156
  if (existing.equals(key)) {