@hyperspell/openclaw-hyperspell 0.4.1 → 0.5.0

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/client.ts CHANGED
@@ -195,6 +195,45 @@ export class HyperspellClient {
195
195
  }
196
196
  }
197
197
 
198
+ async *listMemories(
199
+ options?: { source?: HyperspellSource; collection?: string; pageSize?: number },
200
+ ): AsyncGenerator<{
201
+ resourceId: string
202
+ source: HyperspellSource
203
+ title: string | null
204
+ metadata: Record<string, unknown>
205
+ }> {
206
+ log.debugRequest("memories.list", { source: options?.source, collection: options?.collection })
207
+
208
+ const params: Record<string, unknown> = {
209
+ size: options?.pageSize ?? 100,
210
+ }
211
+ if (options?.source) params.source = options.source
212
+ if (options?.collection) params.collection = options.collection
213
+
214
+ for await (const memory of this.client.memories.list(params as any)) {
215
+ yield {
216
+ resourceId: memory.resource_id,
217
+ source: memory.source as HyperspellSource,
218
+ title: memory.title ?? null,
219
+ metadata: (memory.metadata ?? {}) as Record<string, unknown>,
220
+ }
221
+ }
222
+ }
223
+
224
+ async getMemory(
225
+ resourceId: string,
226
+ source: HyperspellSource,
227
+ ): Promise<Record<string, unknown>> {
228
+ log.debugRequest("memories.get", { resourceId, source })
229
+
230
+ const response = await this.client.memories.get(resourceId, { source })
231
+ const raw = response as unknown as Record<string, unknown>
232
+
233
+ log.debugResponse("memories.get", { resourceId, hasData: "data" in raw })
234
+ return raw
235
+ }
236
+
198
237
  async listConnections(): Promise<Connection[]> {
199
238
  log.debugRequest("connections.list", {})
200
239
 
package/commands/setup.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { exec } from "node:child_process"
1
+ import { exec, execFileSync } from "node:child_process"
2
2
  import * as fs from "node:fs"
3
3
  import * as path from "node:path"
4
4
  import { homedir, platform, userInfo } from "node:os"
@@ -7,7 +7,10 @@ import type { Command } from "commander"
7
7
  import Hyperspell from "hyperspell"
8
8
  import { syncAllMemoryFiles, getMemoryFiles } from "../sync/markdown.ts"
9
9
  import { HyperspellClient } from "../client.ts"
10
- import { getWorkspaceDir } from "../config.ts"
10
+ import { getWorkspaceDir, parseConfig } from "../config.ts"
11
+ import { buildExtractionPrompt, CRON_JOB_NAME } from "../graph/cron.ts"
12
+ import { NetworkStateManager } from "../graph/state.ts"
13
+ import { scanMemories, formatScanResults, completeMemories } from "../graph/ops.ts"
11
14
 
12
15
  /**
13
16
  * Resolve OpenClaw state directory, matching OpenClaw's logic.
@@ -380,6 +383,7 @@ async function runSetup(): Promise<void> {
380
383
  sources: [],
381
384
  maxResults: 10,
382
385
  debug: false,
386
+ knowledgeGraph: { enabled: false, scanIntervalMinutes: 60, batchSize: 20 },
383
387
  })
384
388
 
385
389
  const result = await syncAllMemoryFiles(hyperspellClient, workspaceDir)
@@ -397,18 +401,129 @@ async function runSetup(): Promise<void> {
397
401
  }
398
402
  }
399
403
 
404
+ // Step 8: Memory Network setup
405
+ p.note(
406
+ "The Memory Network automatically extracts entities (people, projects,\n" +
407
+ "organizations, topics) from your memories into structured markdown\n" +
408
+ "files. This runs as a periodic cron job in the main session.",
409
+ "Memory Network",
410
+ )
411
+
412
+ const enableNetwork = await p.confirm({
413
+ message: "Enable the Memory Network?",
414
+ initialValue: false,
415
+ })
416
+
417
+ if (!p.isCancel(enableNetwork) && enableNetwork) {
418
+ // Update config to enable knowledgeGraph
419
+ try {
420
+ const configPath = resolveConfigPath()
421
+ if (fs.existsSync(configPath)) {
422
+ const configContent = fs.readFileSync(configPath, "utf-8")
423
+ const config = JSON.parse(configContent)
424
+ const pluginEntry = config?.plugins?.entries?.["openclaw-hyperspell"]?.config
425
+ if (pluginEntry) {
426
+ pluginEntry.knowledgeGraph = { enabled: true }
427
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n")
428
+ }
429
+ }
430
+ p.log.success("Memory Network enabled in config")
431
+ } catch {
432
+ p.log.warn("Could not update config — add knowledgeGraph.enabled: true manually")
433
+ }
434
+
435
+ // Write the extraction prompt to a file and create the cron job
436
+ const networkWorkspaceDir = getWorkspaceDir()
437
+ const promptPath = path.join(networkWorkspaceDir, "HYPERSPELL-MEMORY-NETWORK.md")
438
+ const prompt = buildExtractionPrompt(networkWorkspaceDir)
439
+ fs.mkdirSync(path.dirname(promptPath), { recursive: true })
440
+ fs.writeFileSync(promptPath, prompt)
441
+
442
+ const s4 = p.spinner()
443
+ s4.start("Creating Memory Network cron job")
444
+
445
+ let cronJobId: string | null = null
446
+ try {
447
+ const output = execFileSync("openclaw", [
448
+ "cron", "add",
449
+ "--name", CRON_JOB_NAME,
450
+ "--every", "1h",
451
+ "--session", "isolated",
452
+ "--message", `Read the file at ${promptPath} and follow the instructions inside it.`,
453
+ ], { stdio: ["pipe", "pipe", "pipe"], timeout: 10_000 })
454
+
455
+ // Extract job ID from the JSON output
456
+ const text = output.toString().trim()
457
+ // Find the JSON object in the output (skip any non-JSON prefix lines)
458
+ const jsonStart = text.indexOf("{")
459
+ if (jsonStart >= 0) {
460
+ try {
461
+ const job = JSON.parse(text.slice(jsonStart))
462
+ cronJobId = job?.id || null
463
+ } catch {}
464
+ }
465
+
466
+ s4.stop("Cron job created — Memory Network will scan every hour")
467
+ } catch (cronErr) {
468
+ s4.stop("Could not create cron job automatically")
469
+
470
+ p.log.warn(`Cron creation failed. Create it manually:`)
471
+
472
+ p.note(
473
+ `openclaw cron add \\\n` +
474
+ ` --name "${CRON_JOB_NAME}" \\\n` +
475
+ ` --every 1h \\\n` +
476
+ ` --session isolated \\\n` +
477
+ ` --message "Read the file at ${promptPath} and follow the instructions inside it."`,
478
+ "Manual cron setup",
479
+ )
480
+ }
481
+
482
+ // Ask if they want to run the first extraction now
483
+ const runNow = await p.confirm({
484
+ message: "Run the Memory Network now? (If not, it will run automatically on the next cron cycle)",
485
+ initialValue: true,
486
+ })
487
+
488
+ if (!p.isCancel(runNow) && runNow) {
489
+ if (cronJobId) {
490
+ const s5 = p.spinner()
491
+ s5.start("Triggering Memory Network extraction")
492
+
493
+ try {
494
+ execFileSync("openclaw", [
495
+ "cron", "run", cronJobId,
496
+ ], { stdio: "pipe", timeout: 10_000 })
497
+
498
+ s5.stop("Memory Network extraction triggered — running in the background")
499
+ } catch {
500
+ s5.stop("Could not trigger automatically")
501
+ p.log.info(`You can trigger it manually with: openclaw cron run ${cronJobId}`)
502
+ }
503
+ } else {
504
+ p.log.info("Create the cron job first, then run it with: openclaw cron run <job-id>")
505
+ }
506
+ }
507
+ }
508
+
400
509
  const syncNote = syncMemories
401
510
  ? "\n\nMemory sync is enabled — markdown files in memory/ will be\n" +
402
511
  "automatically synced to Hyperspell when they change."
403
512
  : ""
404
513
 
514
+ const networkNote = !p.isCancel(enableNetwork) && enableNetwork
515
+ ? "\n\nMemory Network is enabled — entities will be extracted into\n" +
516
+ "memory/people/, memory/projects/, memory/organizations/, memory/topics/"
517
+ : ""
518
+
405
519
  p.note(
406
520
  "/getcontext <query> Search your memories for relevant context\n" +
407
521
  "/remember <text> Save something directly to your vault\n\n" +
408
522
  "To connect more apps, run: openclaw openclaw-hyperspell connect\n\n" +
409
523
  "Auto-context is enabled by default — relevant memories are\n" +
410
524
  "automatically injected before each AI response." +
411
- syncNote,
525
+ syncNote +
526
+ networkNote,
412
527
  "How to use Hyperspell",
413
528
  )
414
529
 
@@ -533,4 +648,70 @@ export function registerCliCommands(program: Command, pluginConfig: unknown): vo
533
648
  .action(async () => {
534
649
  await runConnect(pluginConfig)
535
650
  })
651
+
652
+ // Memory Network CLI commands (used by isolated cron sessions via exec)
653
+ const networkCmd = hyperspellCmd
654
+ .command("network")
655
+ .description("Memory Network operations")
656
+
657
+ networkCmd
658
+ .command("scan")
659
+ .description("Scan for unprocessed memories and output summaries")
660
+ .option("--batch-size <n>", "Max memories to return", "20")
661
+ .action(async (opts) => {
662
+ try {
663
+ const cfg = parseConfig(pluginConfig)
664
+ const client = new HyperspellClient(cfg)
665
+ const workspaceDir = getWorkspaceDir()
666
+ const stateManager = new NetworkStateManager(workspaceDir)
667
+ const batchSize = Number.parseInt(opts.batchSize, 10) || 20
668
+
669
+ const memories = await scanMemories(client, stateManager, batchSize)
670
+ const text = formatScanResults(memories, stateManager.getProcessedCount(), stateManager.getLastScanAt())
671
+ process.stdout.write(text + "\n")
672
+ } catch (err) {
673
+ process.stderr.write(`Scan failed: ${err instanceof Error ? err.message : String(err)}\n`)
674
+ process.exit(1)
675
+ }
676
+ })
677
+
678
+ networkCmd
679
+ .command("complete")
680
+ .description("Mark memory IDs as processed")
681
+ .requiredOption("--ids <ids>", "Comma-separated resource_ids")
682
+ .action((opts) => {
683
+ try {
684
+ const workspaceDir = getWorkspaceDir()
685
+ const stateManager = new NetworkStateManager(workspaceDir)
686
+ const memoryIds = (opts.ids as string).split(",").map((s: string) => s.trim()).filter(Boolean)
687
+
688
+ const { newCount, totalCount } = completeMemories(stateManager, memoryIds)
689
+ process.stdout.write(`Marked ${newCount} new memories as processed (${totalCount} total)\n`)
690
+ } catch (err) {
691
+ process.stderr.write(`Complete failed: ${err instanceof Error ? err.message : String(err)}\n`)
692
+ process.exit(1)
693
+ }
694
+ })
695
+
696
+ networkCmd
697
+ .command("sync")
698
+ .description("Sync entity files in memory/ to Hyperspell")
699
+ .action(async () => {
700
+ try {
701
+ const cfg = parseConfig(pluginConfig)
702
+ const client = new HyperspellClient(cfg)
703
+ const workspaceDir = getWorkspaceDir()
704
+
705
+ const result = await syncAllMemoryFiles(client, workspaceDir)
706
+ process.stdout.write(`Synced ${result.synced} files, ${result.failed} failed\n`)
707
+ if (result.errors.length > 0) {
708
+ for (const error of result.errors) {
709
+ process.stderr.write(` ${error}\n`)
710
+ }
711
+ }
712
+ } catch (err) {
713
+ process.stderr.write(`Sync failed: ${err instanceof Error ? err.message : String(err)}\n`)
714
+ process.exit(1)
715
+ }
716
+ })
536
717
  }
package/config.ts CHANGED
@@ -10,6 +10,12 @@ export type HyperspellSource =
10
10
  | "vault"
11
11
  | "web_crawler"
12
12
 
13
+ export type KnowledgeGraphConfig = {
14
+ enabled: boolean
15
+ scanIntervalMinutes: number
16
+ batchSize: number
17
+ }
18
+
13
19
  export type HyperspellConfig = {
14
20
  apiKey: string
15
21
  userId?: string
@@ -18,6 +24,7 @@ export type HyperspellConfig = {
18
24
  sources: HyperspellSource[]
19
25
  maxResults: number
20
26
  debug: boolean
27
+ knowledgeGraph: KnowledgeGraphConfig
21
28
  }
22
29
 
23
30
  const ALLOWED_KEYS = [
@@ -28,6 +35,7 @@ const ALLOWED_KEYS = [
28
35
  "sources",
29
36
  "maxResults",
30
37
  "debug",
38
+ "knowledgeGraph",
31
39
  ]
32
40
 
33
41
  const VALID_SOURCES: HyperspellSource[] = [
@@ -128,6 +136,8 @@ export function parseConfig(raw: unknown): HyperspellConfig {
128
136
  )
129
137
  }
130
138
 
139
+ const kgRaw = (cfg.knowledgeGraph ?? {}) as Record<string, unknown>
140
+
131
141
  return {
132
142
  apiKey,
133
143
  userId: cfg.userId as string | undefined,
@@ -136,6 +146,11 @@ export function parseConfig(raw: unknown): HyperspellConfig {
136
146
  sources: parseSources(cfg.sources as string | string[] | undefined),
137
147
  maxResults: (cfg.maxResults as number) ?? 10,
138
148
  debug: (cfg.debug as boolean) ?? false,
149
+ knowledgeGraph: {
150
+ enabled: (kgRaw.enabled as boolean) ?? false,
151
+ scanIntervalMinutes: (kgRaw.scanIntervalMinutes as number) ?? 60,
152
+ batchSize: (kgRaw.batchSize as number) ?? 20,
153
+ },
139
154
  }
140
155
  }
141
156
 
package/graph/cron.ts ADDED
@@ -0,0 +1,364 @@
1
+ export const CRON_JOB_NAME = "Hyperspell Memory Network"
2
+
3
+ export function buildExtractionPrompt(workspaceDir: string): string {
4
+ const memoryDir = `${workspaceDir}/memory`
5
+
6
+ return `You are a memory network builder. Your job is to scan memories and extract structured entities into markdown files.
7
+
8
+ ## How it works
9
+
10
+ This runs in an isolated session. Use \`exec\` for data access (scan/complete/sync) and use \`write\` to create entity files directly.
11
+
12
+ ## Steps
13
+
14
+ 1. Run \`openclaw openclaw-hyperspell network scan\` to get a batch of unprocessed memories with content summaries.
15
+ 2. Analyze each memory's title, source, participants, and content summary.
16
+ 3. Extract entities into these directories:
17
+ - \`${memoryDir}/people/\` — individuals (include email, phone if known)
18
+ - \`${memoryDir}/projects/\` — products, initiatives, workstreams
19
+ - \`${memoryDir}/organizations/\` — companies, teams, groups (include domain)
20
+ - \`${memoryDir}/topics/\` — technologies, concepts, recurring themes
21
+ 4. For each entity, write a markdown file using the format below. If the file already exists, read it first and merge the new data (add new source_memories, relationships, update description if richer).
22
+ 5. After extracting all entities from a batch, mark them processed:
23
+ \`\`\`
24
+ openclaw openclaw-hyperspell network complete --ids <comma-separated-resource-ids>
25
+ \`\`\`
26
+ 6. **Repeat from step 1** — keep scanning and extracting until the scan returns "No unprocessed memories found." Process ALL available memories, not just one batch.
27
+ 7. Once all memories are processed, sync the entity files to Hyperspell:
28
+ \`\`\`
29
+ openclaw openclaw-hyperspell network sync
30
+ \`\`\`
31
+ 8. Report a brief summary of what you extracted.
32
+
33
+ ## Entity file format
34
+
35
+ File names should be lowercase with hyphens, e.g. \`alice-chen.md\`, \`hyperspell.md\`.
36
+
37
+ ---
38
+
39
+ ### People (\`${memoryDir}/people/<slug>.md\`)
40
+
41
+ Always include email when available. Extract it from sender info, participant lists, and message signatures.
42
+
43
+ #### Example: Team member with full contact info
44
+
45
+ \`\`\`markdown
46
+ ---
47
+ title: Alice Chen
48
+ type: person
49
+ graph_entity: true
50
+ email: alice@hyperspell.com
51
+ phone: +1-555-123-4567
52
+ source_memories: {"slack":["C073WR69EPM","C074KNCREMN"],"google_mail":["19bbe68026553623"]}
53
+ relationships: ["works-at:organizations/hyperspell","leads:projects/memory-network","collaborates-with:people/bob-martinez"]
54
+ last_extracted: 2026-02-10T12:00:00Z
55
+ ---
56
+ # Alice Chen
57
+
58
+ Engineering Manager at Hyperspell. Leads the Memory Network project. Active in #dev and #general Slack channels. Frequent collaborator with Bob Martinez on architecture decisions.
59
+
60
+ ## Contact
61
+
62
+ - Email: alice@hyperspell.com
63
+ - Phone: +1-555-123-4567
64
+
65
+ ## Relationships
66
+
67
+ - works-at: [hyperspell](../organizations/hyperspell.md)
68
+ - leads: [memory network](../projects/memory-network.md)
69
+ - collaborates-with: [bob martinez](../people/bob-martinez.md)
70
+ \`\`\`
71
+
72
+ #### Example: External contact from email
73
+
74
+ \`\`\`markdown
75
+ ---
76
+ title: Greg Thompson
77
+ type: person
78
+ graph_entity: true
79
+ email: greg@sentry.io
80
+ source_memories: {"google_mail":["19bbe68026553623","19bf6954484abf9f"]}
81
+ relationships: ["works-at:organizations/sentry"]
82
+ last_extracted: 2026-02-10T12:00:00Z
83
+ ---
84
+ # Greg Thompson
85
+
86
+ Contact at Sentry. Organized dinner events with Databricks and Neon teams. Communicated via email about networking meetups.
87
+
88
+ ## Contact
89
+
90
+ - Email: greg@sentry.io
91
+
92
+ ## Relationships
93
+
94
+ - works-at: [sentry](../organizations/sentry.md)
95
+ \`\`\`
96
+
97
+ #### Example: Colleague with minimal info
98
+
99
+ \`\`\`markdown
100
+ ---
101
+ title: Conor Brennan-Burke
102
+ type: person
103
+ graph_entity: true
104
+ email: conor@hyperspell.com
105
+ source_memories: {"slack":["C073WR69EPM","C073WUPLQAW"]}
106
+ relationships: ["works-at:organizations/hyperspell"]
107
+ last_extracted: 2026-02-10T12:00:00Z
108
+ ---
109
+ # Conor Brennan-Burke
110
+
111
+ Team member at Hyperspell. Active in #general and #dev Slack channels.
112
+
113
+ ## Contact
114
+
115
+ - Email: conor@hyperspell.com
116
+
117
+ ## Relationships
118
+
119
+ - works-at: [hyperspell](../organizations/hyperspell.md)
120
+ \`\`\`
121
+
122
+ ---
123
+
124
+ ### Organizations (\`${memoryDir}/organizations/<slug>.md\`)
125
+
126
+ Always include the domain. Derive it from email addresses (e.g. alice@hyperspell.com → hyperspell.com).
127
+
128
+ #### Example: Own company with many connections
129
+
130
+ \`\`\`markdown
131
+ ---
132
+ title: Hyperspell
133
+ type: organization
134
+ graph_entity: true
135
+ domain: hyperspell.com
136
+ source_memories: {"slack":["C073WR69EPM","C073WUPLQAW","C074KNCREMN"],"notion":["2ef17898-857d-8040-bd94-c03ec8b35a13","2f017898-857d-807e-9ebc-f6ce00fa585f"]}
137
+ relationships: ["employs:people/alice-chen","employs:people/conor-brennan-burke","owns:projects/memory-network","works-on-topic:topics/ai-agents"]
138
+ last_extracted: 2026-02-10T12:00:00Z
139
+ ---
140
+ # Hyperspell
141
+
142
+ AI memory and context platform for agents. Building tools for RAG, knowledge graphs, and multi-source memory integration.
143
+
144
+ ## Contact
145
+
146
+ - Domain: hyperspell.com
147
+
148
+ ## Relationships
149
+
150
+ - employs: [alice chen](../people/alice-chen.md)
151
+ - employs: [conor brennan burke](../people/conor-brennan-burke.md)
152
+ - owns: [memory network](../projects/memory-network.md)
153
+ - works-on-topic: [ai agents](../topics/ai-agents.md)
154
+ \`\`\`
155
+
156
+ #### Example: External company from emails
157
+
158
+ \`\`\`markdown
159
+ ---
160
+ title: Sentry
161
+ type: organization
162
+ graph_entity: true
163
+ domain: sentry.io
164
+ source_memories: {"google_mail":["19bbe68026553623"]}
165
+ relationships: ["employs:people/greg-thompson"]
166
+ last_extracted: 2026-02-10T12:00:00Z
167
+ ---
168
+ # Sentry
169
+
170
+ Application monitoring and error tracking platform. Connected through networking events and industry meetups.
171
+
172
+ ## Contact
173
+
174
+ - Domain: sentry.io
175
+
176
+ ## Relationships
177
+
178
+ - employs: [greg thompson](../people/greg-thompson.md)
179
+ \`\`\`
180
+
181
+ #### Example: Partner company mentioned in docs
182
+
183
+ \`\`\`markdown
184
+ ---
185
+ title: Grove Trials
186
+ type: organization
187
+ graph_entity: true
188
+ domain: grovetrials.com
189
+ source_memories: {"slack":["C073WR69EPM"]}
190
+ relationships: ["employs:people/tran-nguyen","employs:people/sohit-patel"]
191
+ last_extracted: 2026-02-10T12:00:00Z
192
+ ---
193
+ # Grove Trials
194
+
195
+ Partner organization. Team members active in shared Slack channels.
196
+
197
+ ## Contact
198
+
199
+ - Domain: grovetrials.com
200
+
201
+ ## Relationships
202
+
203
+ - employs: [tran nguyen](../people/tran-nguyen.md)
204
+ - employs: [sohit patel](../people/sohit-patel.md)
205
+ \`\`\`
206
+
207
+ ---
208
+
209
+ ### Projects (\`${memoryDir}/projects/<slug>.md\`)
210
+
211
+ #### Example: Internal product initiative
212
+
213
+ \`\`\`markdown
214
+ ---
215
+ title: Memory Network
216
+ type: project
217
+ graph_entity: true
218
+ source_memories: {"notion":["2f017898-857d-807e-9ebc-f6ce00fa585f"],"slack":["C073WUPLQAW"]}
219
+ relationships: ["owned-by:organizations/hyperspell","led-by:people/alice-chen","uses:topics/knowledge-graphs","uses:topics/rag"]
220
+ last_extracted: 2026-02-10T12:00:00Z
221
+ ---
222
+ # Memory Network
223
+
224
+ Feature for automatically extracting entities (people, projects, orgs, topics) from indexed memories and building a structured knowledge graph as markdown files.
225
+
226
+ ## Relationships
227
+
228
+ - owned-by: [hyperspell](../organizations/hyperspell.md)
229
+ - led-by: [alice chen](../people/alice-chen.md)
230
+ - uses: [knowledge graphs](../topics/knowledge-graphs.md)
231
+ - uses: [rag](../topics/rag.md)
232
+ \`\`\`
233
+
234
+ #### Example: Hiring initiative from docs
235
+
236
+ \`\`\`markdown
237
+ ---
238
+ title: Hiring Plan
239
+ type: project
240
+ graph_entity: true
241
+ source_memories: {"notion":["2f017898-857d-807e-9ebc-f6ce00fa585f"]}
242
+ relationships: ["owned-by:organizations/hyperspell"]
243
+ last_extracted: 2026-02-10T12:00:00Z
244
+ ---
245
+ # Hiring Plan
246
+
247
+ Company hiring initiative documented in Notion. Covers open roles, recruiting pipeline, and growth targets.
248
+
249
+ ## Relationships
250
+
251
+ - owned-by: [hyperspell](../organizations/hyperspell.md)
252
+ \`\`\`
253
+
254
+ #### Example: Competitive analysis
255
+
256
+ \`\`\`markdown
257
+ ---
258
+ title: Competitor Analysis
259
+ type: project
260
+ graph_entity: true
261
+ source_memories: {"notion":["2ef17898-857d-8040-bd94-c03ec8b35a13"]}
262
+ relationships: ["owned-by:organizations/hyperspell","covers:topics/rag","covers:topics/ai-agents"]
263
+ last_extracted: 2026-02-10T12:00:00Z
264
+ ---
265
+ # Competitor Analysis
266
+
267
+ Analysis of memory and context competitors in the AI agent space. Covers feature comparisons, data processing capabilities, and market positioning.
268
+
269
+ ## Relationships
270
+
271
+ - owned-by: [hyperspell](../organizations/hyperspell.md)
272
+ - covers: [rag](../topics/rag.md)
273
+ - covers: [ai agents](../topics/ai-agents.md)
274
+ \`\`\`
275
+
276
+ ---
277
+
278
+ ### Topics (\`${memoryDir}/topics/<slug>.md\`)
279
+
280
+ #### Example: Core technology
281
+
282
+ \`\`\`markdown
283
+ ---
284
+ title: Knowledge Graphs
285
+ type: topic
286
+ graph_entity: true
287
+ source_memories: {"notion":["2ef17898-857d-8040-bd94-c03ec8b35a13"],"slack":["C073WUPLQAW"]}
288
+ relationships: ["used-by:projects/memory-network","discussed-by:organizations/hyperspell"]
289
+ last_extracted: 2026-02-10T12:00:00Z
290
+ ---
291
+ # Knowledge Graphs
292
+
293
+ Entity extraction and relationship mapping for building structured knowledge from unstructured data. Central to the Memory Network project.
294
+
295
+ ## Relationships
296
+
297
+ - used-by: [memory network](../projects/memory-network.md)
298
+ - discussed-by: [hyperspell](../organizations/hyperspell.md)
299
+ \`\`\`
300
+
301
+ #### Example: Broad domain topic
302
+
303
+ \`\`\`markdown
304
+ ---
305
+ title: AI Agents
306
+ type: topic
307
+ graph_entity: true
308
+ source_memories: {"notion":["2ef17898-857d-8040-bd94-c03ec8b35a13","2f017898-857d-807e-9ebc-f6ce00fa585f"],"slack":["C073WUPLQAW"]}
309
+ relationships: ["discussed-by:organizations/hyperspell","related-to:topics/rag","related-to:topics/knowledge-graphs"]
310
+ last_extracted: 2026-02-10T12:00:00Z
311
+ ---
312
+ # AI Agents
313
+
314
+ Autonomous AI systems that use tools, memory, and context to accomplish tasks. Core focus area for Hyperspell's product.
315
+
316
+ ## Relationships
317
+
318
+ - discussed-by: [hyperspell](../organizations/hyperspell.md)
319
+ - related-to: [rag](../topics/rag.md)
320
+ - related-to: [knowledge graphs](../topics/knowledge-graphs.md)
321
+ \`\`\`
322
+
323
+ #### Example: Specific technology
324
+
325
+ \`\`\`markdown
326
+ ---
327
+ title: RAG
328
+ type: topic
329
+ graph_entity: true
330
+ source_memories: {"notion":["2ef17898-857d-8040-bd94-c03ec8b35a13"]}
331
+ relationships: ["used-by:projects/memory-network","related-to:topics/knowledge-graphs"]
332
+ last_extracted: 2026-02-10T12:00:00Z
333
+ ---
334
+ # RAG
335
+
336
+ Retrieval-Augmented Generation — technique for grounding LLM responses in retrieved documents. Used across Hyperspell's search and context injection features.
337
+
338
+ ## Relationships
339
+
340
+ - used-by: [memory network](../projects/memory-network.md)
341
+ - related-to: [knowledge graphs](../topics/knowledge-graphs.md)
342
+ \`\`\`
343
+
344
+ ## Guidelines
345
+
346
+ - **Process everything**: On the first run there may be hundreds of memories. Keep looping through scan → extract → complete until done.
347
+ - **Merge, don't duplicate**: If a file already exists, read it, merge source_memories and relationships, and write back. Preserve the existing hyperspell_id if present.
348
+ - **Skip noise**: Ignore automated notifications, bot messages, join/leave events, and system messages.
349
+ - **Be selective**: Only extract entities that are meaningful and identifiable. Don't create entities for vague references.
350
+ - **Cross-reference**: Use relationships to connect people to organizations, projects to topics, etc.
351
+ - **Contact info is critical**: For people, always capture email addresses from sender/participant data. For organizations, derive their domain from email addresses (e.g. alice@hyperspell.com → hyperspell.com).
352
+ - **source_memories format**: JSON object with source provider as key and array of resource_ids as value.
353
+ - **graph_entity: true**: Always include this — it prevents the scan from re-processing entity files that get synced back to Hyperspell.`
354
+ }
355
+
356
+ export function getCronSetupCommand(workspaceDir: string, interval: string = "1h"): string {
357
+ const prompt = buildExtractionPrompt(workspaceDir)
358
+ const escaped = prompt.replace(/'/g, "'\\''")
359
+ return `openclaw cron add --name '${CRON_JOB_NAME}' --every ${interval} --session isolated --message '${escaped}'`
360
+ }
361
+
362
+ export function getCronRemoveCommand(): string {
363
+ return `openclaw cron remove --name '${CRON_JOB_NAME}'`
364
+ }
package/graph/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { NetworkStateManager } from "./state.ts"
2
+ export { registerNetworkTools } from "./tools.ts"
3
+ export { scanMemories, formatScanResults, writeEntity, completeMemories, slugify } from "./ops.ts"
4
+ export type { EntityType, SourceMemories, ScannedMemory, WriteEntityParams } from "./ops.ts"
5
+ export { buildExtractionPrompt, getCronSetupCommand, getCronRemoveCommand, CRON_JOB_NAME } from "./cron.ts"