hyperclaw 5.2.8 → 5.2.9

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 (138) hide show
  1. package/dist/a2ui-protocol-DEsfqO7h.js +75 -0
  2. package/dist/agents-routing-ChorJKFL.js +6 -0
  3. package/dist/agents-routing-Cpg20-1e.js +398 -0
  4. package/dist/api-key-validation-DgOBmp8Y.js +64 -0
  5. package/dist/api-keys-guide--73Bq0Ey.js +149 -0
  6. package/dist/audit-Dntx9fG9.js +445 -0
  7. package/dist/banner-B_rR7FPO.js +7 -0
  8. package/dist/banner-Bb7CderS.js +143 -0
  9. package/dist/bounty-tools-Dn9Yq7V1.js +211 -0
  10. package/dist/browser-tools-CJ9M9o22.js +179 -0
  11. package/dist/browser-tools-CXxWxA1c.js +5 -0
  12. package/dist/chat-D1Zc73I5.js +513 -0
  13. package/dist/claw-tasks-ChqkHdFs.js +80 -0
  14. package/dist/config-Bzues-G2.js +7 -0
  15. package/dist/config-DGAAJ49A.js +261 -0
  16. package/dist/connector-1efnZgQN.js +566 -0
  17. package/dist/connector-B5q1_srT.js +286 -0
  18. package/dist/connector-BMFLJ4fr.js +508 -0
  19. package/dist/connector-BZYv9siY.js +189 -0
  20. package/dist/connector-B_XkXm-j.js +218 -0
  21. package/dist/connector-BkY1I6gf.js +189 -0
  22. package/dist/connector-C2Z3RN1z.js +350 -0
  23. package/dist/connector-C7aYvVzU.js +225 -0
  24. package/dist/connector-CXXYOyHw.js +164 -0
  25. package/dist/connector-Ca1J23HX.js +167 -0
  26. package/dist/connector-Cjqc656I.js +181 -0
  27. package/dist/connector-CluRienN.js +425 -0
  28. package/dist/connector-CuNz2eP-.js +305 -0
  29. package/dist/connector-DHL_oeHy.js +552 -0
  30. package/dist/connector-DJ79rd1L.js +173 -0
  31. package/dist/connector-DcLE6xCZ.js +239 -0
  32. package/dist/connector-DcyQTJnJ.js +162 -0
  33. package/dist/connector-DgyX9qSc.js +192 -0
  34. package/dist/connector-DnDXXZ7L.js +182 -0
  35. package/dist/connector-DqUslg-X.js +213 -0
  36. package/dist/connector-Duc-HmRZ.js +85 -0
  37. package/dist/connector-IV0QFer8.js +498 -0
  38. package/dist/connector-OnsLxE8G.js +194 -0
  39. package/dist/connector-UYu_TS0X.js +204 -0
  40. package/dist/connector-cCA5ffmp.js +340 -0
  41. package/dist/connector-fbNfx4_L.js +568 -0
  42. package/dist/connector-fi2vlwbO.js +276 -0
  43. package/dist/connector-l3LD8IDN.js +419 -0
  44. package/dist/cost-tracker-DCXDUzBI.js +103 -0
  45. package/dist/credentials-store-Bmm9e1SS.js +7 -0
  46. package/dist/credentials-store-D8ERbGR2.js +89 -0
  47. package/dist/cron-tasks-OQbgmenS.js +85 -0
  48. package/dist/daemon-aVX-WGz1.js +421 -0
  49. package/dist/daemon-iFmVBPXN.js +7 -0
  50. package/dist/delivery-Pko6sSkt.js +4 -0
  51. package/dist/delivery-hMHFRZwy.js +95 -0
  52. package/dist/destructive-gate-C2TrWsp2.js +101 -0
  53. package/dist/developer-keys-BWXHaWxY.js +127 -0
  54. package/dist/developer-keys-CzDxVczE.js +8 -0
  55. package/dist/device-auth-store-C1bCwXO2.js +7 -0
  56. package/dist/device-auth-store-DIZTOz4V.js +88 -0
  57. package/dist/doctor-C6nAGdH8.js +233 -0
  58. package/dist/doctor-mgWumA25.js +6 -0
  59. package/dist/engine-BGRTi0fo.js +327 -0
  60. package/dist/engine-BvCEhaUn.js +7 -0
  61. package/dist/env-resolve-CHxjGo8u.js +151 -0
  62. package/dist/env-resolve-pIETNTpQ.js +10 -0
  63. package/dist/extraction-tools-BE6z_Yw5.js +91 -0
  64. package/dist/extraction-tools-CJsdyBST.js +5 -0
  65. package/dist/form_data-B2_0EoWj.js +8657 -0
  66. package/dist/gmail-watch-setup-1RGIHNdu.js +42 -0
  67. package/dist/health-BMUmUNoe.js +152 -0
  68. package/dist/health-C8n9RH5O.js +6 -0
  69. package/dist/heartbeat-engine-aRbab8a5.js +89 -0
  70. package/dist/hub-BJM2KXLO.js +6 -0
  71. package/dist/hub-Bb_dYECE.js +512 -0
  72. package/dist/hyperclawbot-CgrV46DA.js +516 -0
  73. package/dist/inference-CFBkvLpE.js +2854 -0
  74. package/dist/inference-G4MbdErG.js +8 -0
  75. package/dist/knowledge-graph-9UNrsiIY.js +134 -0
  76. package/dist/loader-DIPs649t.js +410 -0
  77. package/dist/loader-Dq_cDlOW.js +6 -0
  78. package/dist/logger-CG38Idq4.js +86 -0
  79. package/dist/manager--wG9JdFW.js +120 -0
  80. package/dist/manager-BNc21xgG.js +6 -0
  81. package/dist/manager-DWJ7WZcY.js +250 -0
  82. package/dist/manager-DYfzqckn.js +35 -0
  83. package/dist/mcp-SsMEvl28.js +142 -0
  84. package/dist/mcp-loader-DLrp_oZJ.js +93 -0
  85. package/dist/memory-BCYvdqwo.js +273 -0
  86. package/dist/memory-BGgCBSx1.js +6 -0
  87. package/dist/memory-auto-Bh52cQJP.js +5 -0
  88. package/dist/memory-auto-BupvVwNd.js +306 -0
  89. package/dist/memory-integration-4oGqX6rr.js +91 -0
  90. package/dist/moltbook-B3DNdh40.js +81 -0
  91. package/dist/node-C4esBfbX.js +226 -0
  92. package/dist/nodes-registry-DLUZhEMS.js +52 -0
  93. package/dist/oauth-flow-BbLQTzZk.js +148 -0
  94. package/dist/oauth-provider-UZyG84s7.js +111 -0
  95. package/dist/observability-BtLyuxcz.js +89 -0
  96. package/dist/onboard-B3drurt-.js +3812 -0
  97. package/dist/onboard-DEwuHrMj.js +14 -0
  98. package/dist/orchestrator-BXyIgAeH.js +189 -0
  99. package/dist/orchestrator-MLTc4NYu.js +6 -0
  100. package/dist/osint-Bsf6RGPv.js +283 -0
  101. package/dist/osint-chat-Ark94iFc.js +789 -0
  102. package/dist/pairing-2vAiDBjN.js +6 -0
  103. package/dist/pairing-B4NoBvyE.js +207 -0
  104. package/dist/pc-access-BLnc-DYp.js +858 -0
  105. package/dist/pc-access-CTNtG2LD.js +8 -0
  106. package/dist/pending-approval-C4ZaHHWl.js +22 -0
  107. package/dist/reminders-store-BixTWL1h.js +58 -0
  108. package/dist/renderer-B1ToXngl.js +228 -0
  109. package/dist/rules-Cqen1Mpt.js +106 -0
  110. package/dist/run-main.js +94 -93
  111. package/dist/runner-Cr1_mwnU.js +1274 -0
  112. package/dist/security-B4vH02lO.js +4 -0
  113. package/dist/security-HOOGCw5z.js +90 -0
  114. package/dist/server-CRhXiGI9.js +4 -0
  115. package/dist/server-De4H45Ju.js +1365 -0
  116. package/dist/session-store-7sEPyV16.js +5 -0
  117. package/dist/session-store-Ce2QMSL_.js +141 -0
  118. package/dist/sessions-tools-CWr_pDtp.js +5 -0
  119. package/dist/sessions-tools-DKVu9aIN.js +95 -0
  120. package/dist/skill-loader-DK19Jm4e.js +7 -0
  121. package/dist/skill-loader-Dfs9VNM-.js +160 -0
  122. package/dist/skill-runtime-BeKh2rD_.js +5 -0
  123. package/dist/skill-runtime-CcpC2Zfc.js +104 -0
  124. package/dist/src-BxmkZ9RH.js +63 -0
  125. package/dist/src-DjTtmSRg.js +20 -0
  126. package/dist/src-n_46LPDi.js +458 -0
  127. package/dist/sub-agent-tools-q5JqEze_.js +39 -0
  128. package/dist/tool-policy-QXF3MMxu.js +189 -0
  129. package/dist/tts-elevenlabs-y6HGWWDS.js +64 -0
  130. package/dist/update-check-C4te7JmY.js +6 -0
  131. package/dist/update-check-GDue_it1.js +98 -0
  132. package/dist/vision-tools-CbVfyTZT.js +5 -0
  133. package/dist/vision-tools-DieVQp6s.js +51 -0
  134. package/dist/vision-u4kMThdo.js +167 -0
  135. package/dist/voice-transcription-DgON5qaF.js +170 -0
  136. package/dist/website-watch-tools-B8L_NgwT.js +5 -0
  137. package/dist/website-watch-tools-Drm5HjIX.js +176 -0
  138. package/package.json +1 -1
@@ -0,0 +1,273 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const require_paths = require('./paths-AIyBxIzm.js');
3
+ const require_paths$1 = require('./paths-DPovhojT.js');
4
+ const chalk = require_chunk.__toESM(require("chalk"));
5
+ const ora = require_chunk.__toESM(require("ora"));
6
+ const fs_extra = require_chunk.__toESM(require("fs-extra"));
7
+ const path = require_chunk.__toESM(require("path"));
8
+
9
+ //#region src/agents/memory.ts
10
+ require_paths$1.init_paths();
11
+ var MemoryManager = class {
12
+ baseDir;
13
+ agentsFile;
14
+ memoryFile;
15
+ logFile;
16
+ constructor(workspaceDir) {
17
+ this.baseDir = workspaceDir || require_paths.getHyperClawDir();
18
+ this.agentsFile = path.default.join(this.baseDir, "AGENTS.md");
19
+ this.memoryFile = path.default.join(this.baseDir, "MEMORY.md");
20
+ this.logFile = path.default.join(this.baseDir, "logs", `${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.md`);
21
+ }
22
+ async init(identity) {
23
+ await fs_extra.default.ensureDir(this.baseDir);
24
+ await fs_extra.default.ensureDir(path.default.join(this.baseDir, "logs"));
25
+ const spinner = (0, ora.default)("Initializing memory and agent identity...").start();
26
+ await this.writeAgentsMd(identity);
27
+ await this.writeMemoryMd(identity);
28
+ await this.initDailyLog();
29
+ spinner.succeed("AGENTS.md, MEMORY.md and daily log created");
30
+ console.log(chalk.default.gray(` 📁 Workspace: ${this.baseDir}`));
31
+ console.log(chalk.default.gray(` 📄 AGENTS.md: ${this.agentsFile}`));
32
+ console.log(chalk.default.gray(` 🧠 MEMORY.md: ${this.memoryFile}`));
33
+ console.log();
34
+ }
35
+ async writeAgentsMd(id) {
36
+ const content = `# AGENTS.md — HyperClaw Global Agent Rules
37
+ > Generated: ${(/* @__PURE__ */ new Date()).toISOString()}
38
+ > This file is read by ALL sessions and subagents.
39
+
40
+ ## Identity
41
+ - **Agent Name:** ${id.agentName}
42
+ - **User Name:** ${id.userName}
43
+ - **Personality:** ${id.personality}
44
+ - **Language:** ${id.language}
45
+
46
+ ## Global Rules
47
+ ${id.rules.map((r, i) => `${i + 1}. ${r}`).join("\n")}
48
+
49
+ ## Subagent Hierarchy
50
+ - Parent: HyperClaw Core
51
+ - Children: Channel Agents (Telegram, Discord, etc.)
52
+ - All subagents MUST inherit these rules
53
+ - No subagent may override global safety rules
54
+
55
+ ## Memory Protocol
56
+ - Write significant events to MEMORY.md
57
+ - Log daily interactions to logs/YYYY-MM-DD.md
58
+ - Always read AGENTS.md at session start
59
+
60
+ ## Safety Boundaries
61
+ - Never reveal the auth token
62
+ - Never execute code outside the sandbox skill
63
+ - Always ask for confirmation before irreversible actions
64
+ - Refuse requests that violate user privacy
65
+
66
+ ## Cross-Session Persistence
67
+ - Session state is stored in ~/.hyperclaw/sessions/
68
+ - Use memory tools to recall past interactions
69
+ `;
70
+ await fs_extra.default.writeFile(this.agentsFile, content, "utf8");
71
+ }
72
+ async writeMemoryMd(id) {
73
+ const content = `# MEMORY.md — HyperClaw Persistent Memory
74
+ > Initialized: ${(/* @__PURE__ */ new Date()).toISOString()}
75
+
76
+ ## User Profile
77
+ - Name: ${id.userName}
78
+ - Preferred language: ${id.language}
79
+ - Agent alias: ${id.agentName}
80
+
81
+ ## Session History
82
+ *(Populated automatically during sessions)*
83
+
84
+ ## Key Facts
85
+ *(Write important information here for future sessions)*
86
+
87
+ ## Reminders
88
+ *(Active reminders are listed here)*
89
+ `;
90
+ await fs_extra.default.writeFile(this.memoryFile, content, "utf8");
91
+ }
92
+ async initDailyLog() {
93
+ const today = (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
94
+ weekday: "long",
95
+ year: "numeric",
96
+ month: "long",
97
+ day: "numeric"
98
+ });
99
+ const content = `# Daily Log — ${today}
100
+
101
+ ## Sessions
102
+ - ${(/* @__PURE__ */ new Date()).toLocaleTimeString()} — Session initialized
103
+
104
+ ## Notes
105
+ `;
106
+ await fs_extra.default.ensureDir(path.default.dirname(this.logFile));
107
+ await fs_extra.default.writeFile(this.logFile, content, "utf8");
108
+ }
109
+ async appendRule(rule) {
110
+ const spinner = (0, ora.default)("Writing rule to AGENTS.md...").start();
111
+ const content = await fs_extra.default.readFile(this.agentsFile, "utf8");
112
+ const updated = content.replace("*(Populated automatically during sessions)*", `*(Populated automatically during sessions)*\n\n### Added Rule\n- ${rule}`);
113
+ await fs_extra.default.writeFile(this.agentsFile, updated, "utf8");
114
+ spinner.succeed(`Rule added to AGENTS.md`);
115
+ }
116
+ async addMemory(fact) {
117
+ const spinner = (0, ora.default)("Writing to MEMORY.md...").start();
118
+ const content = await fs_extra.default.readFile(this.memoryFile, "utf8");
119
+ const entry = `\n- [${(/* @__PURE__ */ new Date()).toISOString()}] ${fact}`;
120
+ const updated = content.replace("*(Write important information here for future sessions)*", `*(Write important information here for future sessions)*${entry}`);
121
+ await fs_extra.default.writeFile(this.memoryFile, updated, "utf8");
122
+ spinner.succeed(`Memory updated`);
123
+ }
124
+ async load() {
125
+ try {
126
+ const agents = await fs_extra.default.readFile(this.agentsFile, "utf8");
127
+ const memory = await fs_extra.default.readFile(this.memoryFile, "utf8");
128
+ return {
129
+ agents,
130
+ memory
131
+ };
132
+ } catch {
133
+ return null;
134
+ }
135
+ }
136
+ getBaseDir() {
137
+ return this.baseDir;
138
+ }
139
+ };
140
+ async function initWorkspaceFiles(identity, workspaceDir, only) {
141
+ const files = {
142
+ "SOUL.md": generateSoul(identity),
143
+ "USER.md": generateUser(identity),
144
+ "TOOLS.md": generateTools(),
145
+ "HEARTBEAT.md": generateHeartbeat(),
146
+ "BOOTSTRAP.md": generateBootstrap(identity)
147
+ };
148
+ await fs_extra.default.ensureDir(workspaceDir);
149
+ for (const [fname, content] of Object.entries(files)) {
150
+ if (only && !only.some((sel) => fname.startsWith(sel))) continue;
151
+ const fpath = path.default.join(workspaceDir, fname);
152
+ if (!await fs_extra.default.pathExists(fpath)) await fs_extra.default.writeFile(fpath, content, "utf8");
153
+ }
154
+ }
155
+ function generateSoul(id) {
156
+ return `# SOUL.md — Agent Personality & Values
157
+ > Generated: ${(/* @__PURE__ */ new Date()).toISOString()}
158
+
159
+ ## Core Identity
160
+ - **Name:** ${id.agentName}
161
+ - **Personality:** ${id.personality}
162
+ - **Primary language:** ${id.language}
163
+
164
+ ## Values
165
+ - Honesty over flattery
166
+ - Brevity — get to the point
167
+ - Respect autonomy — suggest, never demand
168
+ - Always confirm before irreversible actions
169
+
170
+ ## Boundaries
171
+ - Never reveal gateway tokens or API keys
172
+ - Always ask confirmation before destructive actions
173
+ - Never claim to be human when sincerely asked
174
+ `;
175
+ }
176
+ function generateUser(id) {
177
+ return `# USER.md — About the Person I Work For
178
+ > Generated: ${(/* @__PURE__ */ new Date()).toISOString()}
179
+
180
+ ## Identity
181
+ - **Name:** ${id.userName}
182
+ - **Preferred language:** ${id.language}
183
+
184
+ ## Communication Preferences
185
+ - Tone: casual
186
+ - Response length: auto
187
+
188
+ ## What I'm Working On
189
+ *(Update this regularly — agent uses it for context)*
190
+
191
+ ## My Stack
192
+ *(Add your tools here)*
193
+
194
+ ## Do NOT do these things
195
+ - Pad responses with unnecessary filler
196
+
197
+ ## Always do these things
198
+ - Respond in ${id.language} unless I write in another language
199
+ `;
200
+ }
201
+ function generateTools() {
202
+ return `# TOOLS.md — Available Skills & Tools
203
+ > Generated: ${(/* @__PURE__ */ new Date()).toISOString()}
204
+
205
+ ## Active Skills
206
+ | ID | Name | Status |
207
+ |----|------|--------|
208
+ | reminders | Smart Reminders | ✅ enabled |
209
+ | translator | Real-time Translator | ✅ enabled |
210
+
211
+ ## Add More Skills
212
+ \`\`\`
213
+ hyperclaw hub # Browse available skills
214
+ hyperclaw hub --install web-search
215
+ \`\`\`
216
+
217
+ ## MCP Servers
218
+ No MCP servers configured. Add with: \`hyperclaw mcp add\`
219
+ `;
220
+ }
221
+ function generateHeartbeat() {
222
+ return `# HEARTBEAT.md — System Health Log
223
+ > Initialized: ${(/* @__PURE__ */ new Date()).toISOString()}
224
+
225
+ Auto-written by the gateway-health hook every 5 minutes.
226
+ Enable with: \`hyperclaw hooks enable gateway-health\`
227
+
228
+ ## Last Status
229
+ Pending first heartbeat...
230
+ `;
231
+ }
232
+ function generateBootstrap(id) {
233
+ return `# BOOTSTRAP.md β€” Fast Start Context
234
+ > Generated: ${(/* @__PURE__ */ new Date()).toISOString()}
235
+
236
+ ## Mission
237
+ Help ${id.userName} move the current task forward with minimal setup friction.
238
+
239
+ ## First Tasks
240
+ 1. Read AGENTS.md, USER.md, TOOLS.md, and MEMORY.md if present.
241
+ 2. Confirm the current repo / project shape before editing anything.
242
+ 3. Prefer the smallest change that unblocks progress.
243
+
244
+ ## Environment
245
+ - Agent: ${id.agentName}
246
+ - User: ${id.userName}
247
+ - Language: ${id.language}
248
+
249
+ ## Current Constraints
250
+ - Ask before irreversible actions.
251
+ - Keep secrets out of workspace markdown files.
252
+ - Update docs when behavior changes.
253
+
254
+ ## Definition Of Done
255
+ - Requested change is implemented.
256
+ - Relevant checks or verifications are run when available.
257
+ - Important follow-up risks are documented briefly.
258
+ `;
259
+ }
260
+
261
+ //#endregion
262
+ Object.defineProperty(exports, 'MemoryManager', {
263
+ enumerable: true,
264
+ get: function () {
265
+ return MemoryManager;
266
+ }
267
+ });
268
+ Object.defineProperty(exports, 'initWorkspaceFiles', {
269
+ enumerable: true,
270
+ get: function () {
271
+ return initWorkspaceFiles;
272
+ }
273
+ });
@@ -0,0 +1,6 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ require('./paths-AIyBxIzm.js');
3
+ require('./paths-DPovhojT.js');
4
+ const require_memory = require('./memory-BCYvdqwo.js');
5
+
6
+ exports.initWorkspaceFiles = require_memory.initWorkspaceFiles;
@@ -0,0 +1,5 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const require_memory_auto = require('./memory-auto-BupvVwNd.js');
3
+
4
+ require_memory_auto.init_memory_auto();
5
+ exports.AutoMemory = require_memory_auto.AutoMemory;
@@ -0,0 +1,306 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const chalk = require_chunk.__toESM(require("chalk"));
3
+ const fs_extra = require_chunk.__toESM(require("fs-extra"));
4
+ const path = require_chunk.__toESM(require("path"));
5
+ const os = require_chunk.__toESM(require("os"));
6
+
7
+ //#region packages/core/src/agent/memory-auto.ts
8
+ function isSensitive(text) {
9
+ return SENSITIVE_PATTERNS.some((p) => p.test(text));
10
+ }
11
+ function extractFactsLocally(turns) {
12
+ const facts = [];
13
+ const userMessages = turns.filter((t) => t.role === "user").map((t) => t.content);
14
+ for (const msg of userMessages) {
15
+ if (isSensitive(msg)) continue;
16
+ for (const pattern of PREFERENCE_PATTERNS) {
17
+ const m = msg.match(pattern);
18
+ if (m?.[1] && m[1].length > 4) facts.push({
19
+ fact: `User preference: ${m[1].trim()}`,
20
+ category: "preference",
21
+ confidence: "high"
22
+ });
23
+ }
24
+ for (const pattern of IDENTITY_PATTERNS) {
25
+ const m = msg.match(pattern);
26
+ if (m?.[1] && m[1].length > 2) facts.push({
27
+ fact: `About user: ${m[1].trim()}`,
28
+ category: "identity",
29
+ confidence: "high"
30
+ });
31
+ }
32
+ for (const pattern of GOAL_PATTERNS) {
33
+ const m = msg.match(pattern);
34
+ if (m?.[1] && m[1].length > 8) facts.push({
35
+ fact: `User goal: ${m[1].trim()}`,
36
+ category: "goal",
37
+ confidence: "medium"
38
+ });
39
+ }
40
+ }
41
+ const seen = /* @__PURE__ */ new Set();
42
+ return facts.filter((f) => {
43
+ const key = f.fact.toLowerCase().slice(0, 40);
44
+ if (seen.has(key)) return false;
45
+ seen.add(key);
46
+ return true;
47
+ });
48
+ }
49
+ async function readMemory() {
50
+ try {
51
+ return await fs_extra.default.readFile(MEMORY_FILE, "utf8");
52
+ } catch {
53
+ return "";
54
+ }
55
+ }
56
+ async function appendMemory(facts) {
57
+ if (facts.length === 0) return 0;
58
+ const existing = await readMemory();
59
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
60
+ let added = 0;
61
+ const newLines = [];
62
+ const addedFacts = [];
63
+ for (const f of facts) {
64
+ if (existing.toLowerCase().includes(f.fact.toLowerCase().slice(0, 30))) continue;
65
+ newLines.push(`- ${today} [${f.category}] ${f.fact}`);
66
+ addedFacts.push(f);
67
+ added++;
68
+ }
69
+ if (newLines.length === 0) return 0;
70
+ await fs_extra.default.ensureDir(HC_DIR);
71
+ if (!await fs_extra.default.pathExists(MEMORY_FILE)) await fs_extra.default.writeFile(MEMORY_FILE, "# HyperClaw Memory\n\n");
72
+ await fs_extra.default.appendFile(MEMORY_FILE, "\n" + newLines.join("\n") + "\n");
73
+ try {
74
+ const { onMemoryAppended } = await Promise.resolve().then(() => require("./memory-integration-4oGqX6rr.js"));
75
+ await onMemoryAppended(addedFacts.map((f) => ({ fact: f.fact })));
76
+ } catch {}
77
+ return added;
78
+ }
79
+ async function saveMemoryDirect(text) {
80
+ await fs_extra.default.ensureDir(HC_DIR);
81
+ if (!await fs_extra.default.pathExists(MEMORY_FILE)) await fs_extra.default.writeFile(MEMORY_FILE, "# HyperClaw Memory\n\n");
82
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
83
+ await fs_extra.default.appendFile(MEMORY_FILE, `\n- ${today} ${text}\n`);
84
+ try {
85
+ const { onMemoryAppended } = await Promise.resolve().then(() => require("./memory-integration-4oGqX6rr.js"));
86
+ await onMemoryAppended([{ fact: text }]);
87
+ } catch {}
88
+ }
89
+ async function extractFactsWithAI(turns, inferenceOpts) {
90
+ const totalText = turns.map((t) => t.content).join(" ");
91
+ if (totalText.length < 100) return [];
92
+ const localFacts = extractFactsLocally(turns);
93
+ const hasPersonalContext = /\b(I|my|me|mine|myself)\b/i.test(totalText);
94
+ if (!hasPersonalContext) return localFacts;
95
+ try {
96
+ const { InferenceEngine } = await Promise.resolve().then(() => require("./inference-G4MbdErG.js"));
97
+ const engine = new InferenceEngine({
98
+ model: inferenceOpts.model,
99
+ apiKey: inferenceOpts.apiKey,
100
+ provider: inferenceOpts.provider,
101
+ maxTokens: 512,
102
+ tools: []
103
+ });
104
+ const conversationSummary = turns.slice(-6).map((t) => `${t.role === "user" ? "User" : "AI"}: ${t.content.slice(0, 300)}`).join("\n");
105
+ const result = await engine.run([{
106
+ role: "user",
107
+ content: `Extract ONLY concrete, reusable facts about the USER from this conversation.
108
+ Skip: passwords, API keys, one-off questions, assistant responses.
109
+ Include: name, job, preferences, ongoing projects, locations, recurring tasks.
110
+
111
+ Conversation:
112
+ ${conversationSummary}
113
+
114
+ Respond with a JSON array of strings, each a short fact starting with "User".
115
+ If nothing worth saving, respond: []
116
+ Example: ["User's name is Alex", "User prefers TypeScript over JavaScript", "User is building a SaaS app"]`
117
+ }]);
118
+ const clean = result.text.replace(/```json|```/g, "").trim();
119
+ const aiFactStrings = JSON.parse(clean);
120
+ const allFacts = [...localFacts];
121
+ const existingFactText = localFacts.map((f) => f.fact.toLowerCase());
122
+ for (const factStr of aiFactStrings) {
123
+ if (!factStr || factStr.length < 5) continue;
124
+ if (isSensitive(factStr)) continue;
125
+ if (existingFactText.some((e) => e.includes(factStr.toLowerCase().slice(0, 20)))) continue;
126
+ const cat = /prefer|like|hate|always|never|don't/i.test(factStr) ? "preference" : /goal|want|trying|working on|building/i.test(factStr) ? "goal" : /name|job|work|role|from|based/i.test(factStr) ? "identity" : "context";
127
+ allFacts.push({
128
+ fact: factStr,
129
+ category: cat,
130
+ confidence: "medium"
131
+ });
132
+ }
133
+ return allFacts;
134
+ } catch {
135
+ return localFacts;
136
+ }
137
+ }
138
+ async function showMemory() {
139
+ const content = await readMemory();
140
+ if (!content.trim()) {
141
+ console.log(chalk.default.gray("\n 🧠 MEMORY.md is empty\n"));
142
+ return;
143
+ }
144
+ console.log(chalk.default.bold.cyan("\n 🧠 MEMORY\n"));
145
+ const lines = content.split("\n").filter((l) => l.trim());
146
+ for (const line of lines) if (line.startsWith("#")) console.log(chalk.default.bold.white(line));
147
+ else if (line.startsWith("-")) {
148
+ const parts = line.match(/^-\s+(\S+)\s+\[(\w+)\]\s+(.+)$/);
149
+ if (parts) {
150
+ const [, date, cat, fact] = parts;
151
+ const catColor = cat === "preference" ? chalk.default.cyan : cat === "identity" ? chalk.default.yellow : cat === "goal" ? chalk.default.green : chalk.default.gray;
152
+ console.log(` ${chalk.default.gray(date)} ${catColor(`[${cat}]`)} ${fact}`);
153
+ } else console.log(` ${line}`);
154
+ }
155
+ console.log();
156
+ }
157
+ async function clearMemory() {
158
+ await fs_extra.default.writeFile(MEMORY_FILE, "# HyperClaw Memory\n\n");
159
+ console.log(chalk.default.green(" ✅ Memory cleared\n"));
160
+ }
161
+ async function searchMemory(query) {
162
+ const content = await readMemory();
163
+ const lines = content.split("\n").filter((l) => l.toLowerCase().includes(query.toLowerCase()));
164
+ if (lines.length === 0) {
165
+ console.log(chalk.default.gray(` No memories found for: "${query}"\n`));
166
+ return;
167
+ }
168
+ console.log(chalk.default.bold.cyan(`\n 🔍 Memory search: "${query}"\n`));
169
+ for (const line of lines) console.log(` ${line}`);
170
+ console.log();
171
+ }
172
+ var HC_DIR, MEMORY_FILE, SOUL_FILE, PREFERENCE_PATTERNS, IDENTITY_PATTERNS, GOAL_PATTERNS, SENSITIVE_PATTERNS, AutoMemory;
173
+ var init_memory_auto = require_chunk.__esm({ "packages/core/src/agent/memory-auto.ts"() {
174
+ HC_DIR = path.default.join(os.default.homedir(), ".hyperclaw");
175
+ MEMORY_FILE = path.default.join(HC_DIR, "MEMORY.md");
176
+ SOUL_FILE = path.default.join(HC_DIR, "SOUL.md");
177
+ PREFERENCE_PATTERNS = [
178
+ /i (?:prefer|like|love|hate|dislike|always|never)\s+(.{5,80})/i,
179
+ /(?:my favorite|my preferred)\s+(.{5,80})/i,
180
+ /(?:please )?always\s+((?:use|do|write|respond|answer|format|reply)\s+.{5,60})/i,
181
+ /don'?t (?:ever )?(.{5,60})/i,
182
+ /(?:i want you to always)\s+(.{5,80})/i
183
+ ];
184
+ IDENTITY_PATTERNS = [
185
+ /(?:my name is|i'?m called|call me)\s+([A-ZΑ-Ωa-zα-ω][a-zα-ω]{1,30})/i,
186
+ /i(?:'m| am) (?:a |an )?([A-Za-zΑ-Ωα-ω][\w\s]{3,40}?)(?:\.|,|$)/i,
187
+ /i work (?:at|for|as)\s+(.{5,60})/i,
188
+ /i(?:'m| am) (?:from|in|based in)\s+(.{3,40})/i,
189
+ /my (?:job|role|position|title) is\s+(.{5,60})/i
190
+ ];
191
+ GOAL_PATTERNS = [
192
+ /i(?:'m| am) (?:working on|building|creating|developing)\s+(.{10,100})/i,
193
+ /i want to\s+(.{10,100})/i,
194
+ /my goal is (?:to\s+)?(.{10,100})/i,
195
+ /i'?m trying to\s+(.{10,100})/i
196
+ ];
197
+ SENSITIVE_PATTERNS = [
198
+ /password/i,
199
+ /passwd/i,
200
+ /secret key/i,
201
+ /api.?key/i,
202
+ /credit.?card/i,
203
+ /\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,
204
+ /ssn|social security/i,
205
+ /\b\d{3}-\d{2}-\d{4}\b/
206
+ ];
207
+ AutoMemory = class {
208
+ turns = [];
209
+ turnsSinceLastExtract = 0;
210
+ extractEveryNTurns;
211
+ useAI;
212
+ aiOpts;
213
+ constructor(opts = {}) {
214
+ this.extractEveryNTurns = opts.extractEveryNTurns ?? 4;
215
+ this.useAI = opts.useAI ?? false;
216
+ this.aiOpts = opts.aiOpts;
217
+ }
218
+ addTurn(role, content) {
219
+ this.turns.push({
220
+ role,
221
+ content,
222
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
223
+ });
224
+ this.turnsSinceLastExtract++;
225
+ }
226
+ async maybeExtract() {
227
+ if (this.turnsSinceLastExtract < this.extractEveryNTurns) return 0;
228
+ this.turnsSinceLastExtract = 0;
229
+ return this.extract();
230
+ }
231
+ async extract() {
232
+ const facts = this.useAI && this.aiOpts ? await extractFactsWithAI(this.turns, this.aiOpts) : extractFactsLocally(this.turns);
233
+ const saved = await appendMemory(facts);
234
+ if (saved > 0) console.log(chalk.default.gray(` 🧠 Auto-saved ${saved} fact${saved === 1 ? "" : "s"} to MEMORY.md`));
235
+ return saved;
236
+ }
237
+ clearTurns() {
238
+ this.turns = [];
239
+ }
240
+ getTurns() {
241
+ return [...this.turns];
242
+ }
243
+ };
244
+ } });
245
+
246
+ //#endregion
247
+ Object.defineProperty(exports, 'AutoMemory', {
248
+ enumerable: true,
249
+ get: function () {
250
+ return AutoMemory;
251
+ }
252
+ });
253
+ Object.defineProperty(exports, 'appendMemory', {
254
+ enumerable: true,
255
+ get: function () {
256
+ return appendMemory;
257
+ }
258
+ });
259
+ Object.defineProperty(exports, 'clearMemory', {
260
+ enumerable: true,
261
+ get: function () {
262
+ return clearMemory;
263
+ }
264
+ });
265
+ Object.defineProperty(exports, 'extractFactsLocally', {
266
+ enumerable: true,
267
+ get: function () {
268
+ return extractFactsLocally;
269
+ }
270
+ });
271
+ Object.defineProperty(exports, 'extractFactsWithAI', {
272
+ enumerable: true,
273
+ get: function () {
274
+ return extractFactsWithAI;
275
+ }
276
+ });
277
+ Object.defineProperty(exports, 'init_memory_auto', {
278
+ enumerable: true,
279
+ get: function () {
280
+ return init_memory_auto;
281
+ }
282
+ });
283
+ Object.defineProperty(exports, 'readMemory', {
284
+ enumerable: true,
285
+ get: function () {
286
+ return readMemory;
287
+ }
288
+ });
289
+ Object.defineProperty(exports, 'saveMemoryDirect', {
290
+ enumerable: true,
291
+ get: function () {
292
+ return saveMemoryDirect;
293
+ }
294
+ });
295
+ Object.defineProperty(exports, 'searchMemory', {
296
+ enumerable: true,
297
+ get: function () {
298
+ return searchMemory;
299
+ }
300
+ });
301
+ Object.defineProperty(exports, 'showMemory', {
302
+ enumerable: true,
303
+ get: function () {
304
+ return showMemory;
305
+ }
306
+ });
@@ -0,0 +1,91 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const require_paths = require('./paths-AIyBxIzm.js');
3
+ const require_paths$1 = require('./paths-DPovhojT.js');
4
+ const fs_extra = require_chunk.__toESM(require("fs-extra"));
5
+ const path = require_chunk.__toESM(require("path"));
6
+
7
+ //#region src/services/memory-integration.ts
8
+ async function getConfig() {
9
+ try {
10
+ const cfg = await fs_extra.default.readJson(require_paths.getConfigPath());
11
+ return cfg.memoryIntegration ?? {};
12
+ } catch {
13
+ return {};
14
+ }
15
+ }
16
+ /** Sync MEMORY.md to vault (Obsidian / Raycast / Hazel). */
17
+ async function syncMemoryToVault(vaultDir) {
18
+ const target = path.default.join(vaultDir, "HyperClaw-MEMORY.md");
19
+ if (await fs_extra.default.pathExists(MEMORY_FILE)) {
20
+ await fs_extra.default.ensureDir(vaultDir);
21
+ await fs_extra.default.copy(MEMORY_FILE, target, { overwrite: true });
22
+ }
23
+ }
24
+ /** Write daily note with session summary and new facts. */
25
+ async function writeDailyNote(vaultDir, date, content) {
26
+ const filename = `${date}.md`;
27
+ const target = path.default.join(vaultDir, "HyperClaw", filename);
28
+ await fs_extra.default.ensureDir(path.default.dirname(target));
29
+ const lines = [
30
+ `# HyperClaw — ${date}`,
31
+ "",
32
+ `> Auto-generated daily note from HyperClaw interactions.`,
33
+ ""
34
+ ];
35
+ if (content.sessionId && (content.turnCount ?? 0) > 0) {
36
+ lines.push(`## Session ${content.sessionId}`);
37
+ lines.push(`- Turns: ${content.turnCount}`);
38
+ lines.push("");
39
+ }
40
+ if (content.newFacts?.length) {
41
+ lines.push("## New memories");
42
+ for (const f of content.newFacts) lines.push(`- ${f}`);
43
+ lines.push("");
44
+ }
45
+ const body = lines.join("\n");
46
+ if (await fs_extra.default.pathExists(target)) await fs_extra.default.appendFile(target, "\n---\n" + body);
47
+ else await fs_extra.default.writeFile(target, body);
48
+ }
49
+ /** Append new fact to daily note (for incremental updates). */
50
+ async function appendToDailyNote(vaultDir, date, fact) {
51
+ const filename = `${date}.md`;
52
+ const target = path.default.join(vaultDir, "HyperClaw", filename);
53
+ await fs_extra.default.ensureDir(path.default.dirname(target));
54
+ const line = `- ${(/* @__PURE__ */ new Date()).toISOString().slice(11, 19)} ${fact}\n`;
55
+ if (!await fs_extra.default.pathExists(target)) await fs_extra.default.writeFile(target, `# HyperClaw — ${date}\n\n`);
56
+ await fs_extra.default.appendFile(target, line);
57
+ }
58
+ /** Called after MEMORY.md append — sync to vault + optionally add to daily note. */
59
+ async function onMemoryAppended(facts) {
60
+ const cfg = await getConfig();
61
+ const vaultDir = cfg.vaultDir;
62
+ if (!vaultDir) return;
63
+ if (cfg.syncOnAppend !== false) await syncMemoryToVault(vaultDir);
64
+ if (cfg.dailyNotes && facts.length > 0) {
65
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
66
+ for (const f of facts) await appendToDailyNote(vaultDir, today, f.fact);
67
+ }
68
+ }
69
+ /** Called on session end — sync + write session summary to daily note. */
70
+ async function onSessionEnd(payload) {
71
+ const cfg = await getConfig();
72
+ const vaultDir = cfg.vaultDir;
73
+ if (!vaultDir || !cfg.dailyNotes) return;
74
+ await syncMemoryToVault(vaultDir);
75
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
76
+ await writeDailyNote(vaultDir, today, {
77
+ sessionId: payload.sessionId,
78
+ turnCount: payload.turnCount,
79
+ newFacts: payload.newFacts
80
+ });
81
+ }
82
+ var MEMORY_FILE;
83
+ var init_memory_integration = require_chunk.__esm({ "src/services/memory-integration.ts"() {
84
+ require_paths$1.init_paths();
85
+ MEMORY_FILE = path.default.join(require_paths.getHyperClawDir(), "MEMORY.md");
86
+ } });
87
+
88
+ //#endregion
89
+ init_memory_integration();
90
+ exports.onMemoryAppended = onMemoryAppended;
91
+ exports.onSessionEnd = onSessionEnd;