@wipcomputer/memory-crystal 0.7.29 → 0.7.32

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 (146) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/SKILL.md +1 -1
  3. package/package.json +1 -1
  4. package/scripts/migrate-lance-to-sqlite.mjs +2 -1
  5. package/_trash/RELEASE-NOTES-v0-7-23.md +0 -48
  6. package/_trash/RELEASE-NOTES-v0-7-25.md +0 -24
  7. package/_trash/RELEASE-NOTES-v0-7-26.md +0 -7
  8. package/_trash/RELEASE-NOTES-v0-7-28.md +0 -31
  9. package/_trash/RELEASE-NOTES-v0-7-29.md +0 -28
  10. package/_trash/RELEASE-NOTES-v0-7-4.md +0 -64
  11. package/_trash/RELEASE-NOTES-v0-7-5.md +0 -19
  12. package/dist/bridge.d.ts +0 -7
  13. package/dist/bridge.js +0 -14
  14. package/dist/bulk-copy.d.ts +0 -17
  15. package/dist/bulk-copy.js +0 -90
  16. package/dist/cc-hook.d.ts +0 -8
  17. package/dist/cc-hook.js +0 -368
  18. package/dist/cc-poller.d.ts +0 -1
  19. package/dist/cc-poller.js +0 -550
  20. package/dist/chunk-25LXQJ4Z.js +0 -110
  21. package/dist/chunk-2DRXIRQW.js +0 -97
  22. package/dist/chunk-2ZNH5F6E.js +0 -1281
  23. package/dist/chunk-3G3SFYYI.js +0 -288
  24. package/dist/chunk-3RG5ZIWI.js +0 -10
  25. package/dist/chunk-3S6TI23B.js +0 -97
  26. package/dist/chunk-3VFIJYS4.js +0 -818
  27. package/dist/chunk-52QE3YI3.js +0 -1169
  28. package/dist/chunk-57RP3DIN.js +0 -1205
  29. package/dist/chunk-5HSZ4W2P.js +0 -62
  30. package/dist/chunk-645IPXW3.js +0 -290
  31. package/dist/chunk-7A7ELD4C.js +0 -1205
  32. package/dist/chunk-7FYY4GZM.js +0 -1205
  33. package/dist/chunk-7IUE7ODU.js +0 -254
  34. package/dist/chunk-7RMLKZIS.js +0 -108
  35. package/dist/chunk-AA3OPP4Z.js +0 -432
  36. package/dist/chunk-AEWLSYPH.js +0 -72
  37. package/dist/chunk-ASSZDR6I.js +0 -108
  38. package/dist/chunk-AYRJVWUC.js +0 -1205
  39. package/dist/chunk-CCYI5O3D.js +0 -148
  40. package/dist/chunk-D3I3ZSE2.js +0 -411
  41. package/dist/chunk-DACSKLY6.js +0 -219
  42. package/dist/chunk-DW5B4BL7.js +0 -108
  43. package/dist/chunk-EKSACBTJ.js +0 -1070
  44. package/dist/chunk-EXEZZADG.js +0 -248
  45. package/dist/chunk-F3Y7EL7K.js +0 -83
  46. package/dist/chunk-FBQWSDPC.js +0 -1328
  47. package/dist/chunk-FHRZNOMW.js +0 -1205
  48. package/dist/chunk-IM7N24MT.js +0 -129
  49. package/dist/chunk-IPNYIXFK.js +0 -1178
  50. package/dist/chunk-J7MRSZIO.js +0 -167
  51. package/dist/chunk-JITKI2OI.js +0 -106
  52. package/dist/chunk-JWZXYVET.js +0 -1068
  53. package/dist/chunk-KCQUXVYT.js +0 -108
  54. package/dist/chunk-KOQ43OX6.js +0 -1281
  55. package/dist/chunk-KYVWO6ZM.js +0 -1069
  56. package/dist/chunk-L3VHARQH.js +0 -413
  57. package/dist/chunk-LBWDS6BE.js +0 -288
  58. package/dist/chunk-LOVAHSQV.js +0 -411
  59. package/dist/chunk-LQOYCAGG.js +0 -446
  60. package/dist/chunk-LWAIPJ2W.js +0 -146
  61. package/dist/chunk-M5DHKW7M.js +0 -127
  62. package/dist/chunk-MBKCIJHM.js +0 -1328
  63. package/dist/chunk-MK42FMEG.js +0 -147
  64. package/dist/chunk-MOBMYHKL.js +0 -1205
  65. package/dist/chunk-MPLTNMRG.js +0 -67
  66. package/dist/chunk-NIJCVN3O.js +0 -147
  67. package/dist/chunk-NZCFSZQ7.js +0 -1205
  68. package/dist/chunk-O2UITJGH.js +0 -465
  69. package/dist/chunk-OCRA44AZ.js +0 -108
  70. package/dist/chunk-P3KJR66H.js +0 -117
  71. package/dist/chunk-PEK6JH65.js +0 -432
  72. package/dist/chunk-PJ6FFKEX.js +0 -77
  73. package/dist/chunk-PLUBBZYR.js +0 -800
  74. package/dist/chunk-PNKVD2UK.js +0 -26
  75. package/dist/chunk-PSQZURHO.js +0 -229
  76. package/dist/chunk-SGL6ISBJ.js +0 -1061
  77. package/dist/chunk-SJABZZT5.js +0 -97
  78. package/dist/chunk-TD3P3K32.js +0 -1199
  79. package/dist/chunk-TMDZJJKV.js +0 -288
  80. package/dist/chunk-UNHVZB5G.js +0 -411
  81. package/dist/chunk-VAFTWSTE.js +0 -1061
  82. package/dist/chunk-VNFXFQBB.js +0 -217
  83. package/dist/chunk-X3GVFKSJ.js +0 -1205
  84. package/dist/chunk-XZ3S56RQ.js +0 -1061
  85. package/dist/chunk-Y72C7F6O.js +0 -148
  86. package/dist/chunk-YLICP577.js +0 -1205
  87. package/dist/chunk-YX6AXLVK.js +0 -159
  88. package/dist/chunk-ZCQYHTNU.js +0 -146
  89. package/dist/cli.d.ts +0 -1
  90. package/dist/cli.js +0 -1105
  91. package/dist/cloud-crystal.js +0 -6
  92. package/dist/core.d.ts +0 -232
  93. package/dist/core.js +0 -12
  94. package/dist/crypto.d.ts +0 -20
  95. package/dist/crypto.js +0 -27
  96. package/dist/crystal-capture.sh +0 -29
  97. package/dist/crystal-serve.d.ts +0 -4
  98. package/dist/crystal-serve.js +0 -252
  99. package/dist/dev-update-SZ2Z4WCQ.js +0 -6
  100. package/dist/discover.d.ts +0 -30
  101. package/dist/discover.js +0 -177
  102. package/dist/doctor.d.ts +0 -9
  103. package/dist/doctor.js +0 -334
  104. package/dist/dream-weaver.d.ts +0 -8
  105. package/dist/dream-weaver.js +0 -56
  106. package/dist/file-sync.d.ts +0 -48
  107. package/dist/file-sync.js +0 -18
  108. package/dist/installer.d.ts +0 -61
  109. package/dist/installer.js +0 -676
  110. package/dist/ldm-backup.sh +0 -116
  111. package/dist/ldm.d.ts +0 -50
  112. package/dist/ldm.js +0 -32
  113. package/dist/mcp-server.d.ts +0 -1
  114. package/dist/mcp-server.js +0 -265
  115. package/dist/migrate.d.ts +0 -1
  116. package/dist/migrate.js +0 -89
  117. package/dist/mirror-sync.d.ts +0 -1
  118. package/dist/mirror-sync.js +0 -159
  119. package/dist/oc-backfill.d.ts +0 -19
  120. package/dist/oc-backfill.js +0 -74
  121. package/dist/openclaw.d.ts +0 -5
  122. package/dist/openclaw.js +0 -423
  123. package/dist/pair.d.ts +0 -4
  124. package/dist/pair.js +0 -75
  125. package/dist/poller.d.ts +0 -1
  126. package/dist/poller.js +0 -634
  127. package/dist/role.d.ts +0 -24
  128. package/dist/role.js +0 -13
  129. package/dist/search-pipeline-4K4OJSSS.js +0 -255
  130. package/dist/search-pipeline-4PRS6LI7.js +0 -280
  131. package/dist/search-pipeline-7UJMXPLO.js +0 -280
  132. package/dist/search-pipeline-DQTRLGBH.js +0 -74
  133. package/dist/search-pipeline-HNG37REH.js +0 -282
  134. package/dist/search-pipeline-IZFPLBUB.js +0 -280
  135. package/dist/search-pipeline-MID6F26Q.js +0 -73
  136. package/dist/search-pipeline-N52JZFNN.js +0 -282
  137. package/dist/search-pipeline-OPB2PRQQ.js +0 -280
  138. package/dist/search-pipeline-VXTE5HAD.js +0 -262
  139. package/dist/search-pipeline-XHFKADRG.js +0 -73
  140. package/dist/staging.d.ts +0 -29
  141. package/dist/staging.js +0 -21
  142. package/dist/summarize.d.ts +0 -19
  143. package/dist/summarize.js +0 -10
  144. package/dist/worker-demo.js +0 -186
  145. package/dist/worker-mcp.js +0 -404
  146. package/dist/worker.js +0 -137
@@ -1,148 +0,0 @@
1
- // src/summarize.ts
2
- import { writeFileSync, existsSync, mkdirSync } from "fs";
3
- import { join } from "path";
4
- import https from "https";
5
- import http from "http";
6
- var SUMMARY_MODE = process.env.CRYSTAL_SUMMARY_MODE || "simple";
7
- var SUMMARY_PROVIDER = process.env.CRYSTAL_SUMMARY_PROVIDER || "openai";
8
- var SUMMARY_MODEL = process.env.CRYSTAL_SUMMARY_MODEL || "gpt-4o-mini";
9
- function generateSimpleSummary(messages) {
10
- const firstUser = messages.find((m) => m.role === "user");
11
- const title = firstUser ? firstUser.text.slice(0, 80).replace(/\n/g, " ").trim() : "Untitled Session";
12
- const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 50);
13
- const preview = messages.slice(0, 10).map((m) => {
14
- const roleLabel = m.role === "user" ? "User" : "Assistant";
15
- const snippet = m.text.slice(0, 200).replace(/\n/g, " ").trim();
16
- return `**${roleLabel}:** ${snippet}${m.text.length > 200 ? "..." : ""}`;
17
- }).join("\n\n");
18
- const date = messages[0]?.timestamp?.slice(0, 10) || (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
19
- return {
20
- title,
21
- slug,
22
- summary: preview,
23
- topics: [],
24
- messageCount: messages.length,
25
- date
26
- };
27
- }
28
- async function generateLlmSummary(messages) {
29
- const condensed = messages.slice(0, 30).map((m) => {
30
- const roleLabel = m.role === "user" ? "User" : "Assistant";
31
- const text = m.text.slice(0, 500);
32
- return `${roleLabel}: ${text}`;
33
- }).join("\n\n");
34
- const prompt = `Summarize this conversation. Return JSON only, no markdown fences.
35
-
36
- Format:
37
- {"title": "short title", "slug": "url-safe-slug", "summary": "2-4 sentences", "topics": ["topic1", "topic2"]}
38
-
39
- Conversation:
40
- ${condensed}`;
41
- const apiKey = process.env.OPENAI_API_KEY;
42
- if (!apiKey) {
43
- return generateSimpleSummary(messages);
44
- }
45
- try {
46
- const body = JSON.stringify({
47
- model: SUMMARY_MODEL,
48
- messages: [{ role: "user", content: prompt }],
49
- temperature: 0.3,
50
- max_tokens: 300
51
- });
52
- const result = await httpPost("https://api.openai.com/v1/chat/completions", body, {
53
- "Authorization": `Bearer ${apiKey}`,
54
- "Content-Type": "application/json"
55
- });
56
- const parsed = JSON.parse(result);
57
- const content = parsed.choices?.[0]?.message?.content || "";
58
- const jsonStr = content.replace(/```json?\n?/g, "").replace(/```/g, "").trim();
59
- const data = JSON.parse(jsonStr);
60
- const date = messages[0]?.timestamp?.slice(0, 10) || (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
61
- return {
62
- title: data.title || "Untitled",
63
- slug: (data.slug || "untitled").slice(0, 50),
64
- summary: data.summary || "",
65
- topics: data.topics || [],
66
- messageCount: messages.length,
67
- date
68
- };
69
- } catch {
70
- return generateSimpleSummary(messages);
71
- }
72
- }
73
- function httpPost(url, body, headers) {
74
- return new Promise((resolve, reject) => {
75
- const parsed = new URL(url);
76
- const client = parsed.protocol === "https:" ? https : http;
77
- const req = client.request({
78
- hostname: parsed.hostname,
79
- port: parsed.port,
80
- path: parsed.pathname + parsed.search,
81
- method: "POST",
82
- headers: { ...headers, "Content-Length": Buffer.byteLength(body) },
83
- timeout: 3e4
84
- }, (res) => {
85
- let data = "";
86
- res.on("data", (chunk) => {
87
- data += chunk;
88
- });
89
- res.on("end", () => {
90
- if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
91
- resolve(data);
92
- } else {
93
- reject(new Error(`HTTP ${res.statusCode}: ${data.slice(0, 200)}`));
94
- }
95
- });
96
- });
97
- req.on("error", reject);
98
- req.on("timeout", () => {
99
- req.destroy();
100
- reject(new Error("Request timeout"));
101
- });
102
- req.write(body);
103
- req.end();
104
- });
105
- }
106
- async function generateSessionSummary(messages) {
107
- if (SUMMARY_MODE === "llm") {
108
- return generateLlmSummary(messages);
109
- }
110
- return generateSimpleSummary(messages);
111
- }
112
- function formatSummaryMarkdown(summary, sessionId) {
113
- const lines = [];
114
- lines.push(`# ${summary.title}`);
115
- lines.push("");
116
- lines.push(`**Session:** ${sessionId} **Date:** ${summary.date} **Messages:** ${summary.messageCount}`);
117
- lines.push("");
118
- lines.push("## Summary");
119
- lines.push("");
120
- lines.push(summary.summary);
121
- if (summary.topics.length > 0) {
122
- lines.push("");
123
- lines.push("## Key Topics");
124
- lines.push("");
125
- for (const topic of summary.topics) {
126
- lines.push(`- ${topic}`);
127
- }
128
- }
129
- lines.push("");
130
- return lines.join("\n");
131
- }
132
- function writeSummaryFile(sessionsDir, summary, agentId, sessionId) {
133
- if (!existsSync(sessionsDir)) mkdirSync(sessionsDir, { recursive: true });
134
- const now = /* @__PURE__ */ new Date();
135
- const dateStr = now.toISOString().slice(0, 10);
136
- const timeStr = now.toISOString().slice(11, 19).replace(/:/g, "-");
137
- const filename = `${dateStr}--${timeStr}--${agentId}--${summary.slug}.md`;
138
- const filepath = join(sessionsDir, filename);
139
- const content = formatSummaryMarkdown(summary, sessionId);
140
- writeFileSync(filepath, content);
141
- return filepath;
142
- }
143
-
144
- export {
145
- generateSessionSummary,
146
- formatSummaryMarkdown,
147
- writeSummaryFile
148
- };