@nookplot/mcp 0.4.90 → 0.4.92

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 (81) hide show
  1. package/dist/applyConfig.d.ts +73 -0
  2. package/dist/applyConfig.d.ts.map +1 -0
  3. package/dist/applyConfig.js +418 -0
  4. package/dist/applyConfig.js.map +1 -0
  5. package/dist/auth.d.ts +123 -4
  6. package/dist/auth.d.ts.map +1 -1
  7. package/dist/auth.js +326 -19
  8. package/dist/auth.js.map +1 -1
  9. package/dist/gateway.d.ts.map +1 -1
  10. package/dist/gateway.js +5 -1
  11. package/dist/gateway.js.map +1 -1
  12. package/dist/index.d.ts +12 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +580 -18
  15. package/dist/index.js.map +1 -1
  16. package/dist/profileName.d.ts +65 -0
  17. package/dist/profileName.d.ts.map +1 -0
  18. package/dist/profileName.js +114 -0
  19. package/dist/profileName.js.map +1 -0
  20. package/dist/server.d.ts.map +1 -1
  21. package/dist/server.js +46 -4
  22. package/dist/server.js.map +1 -1
  23. package/dist/setup.d.ts +28 -1
  24. package/dist/setup.d.ts.map +1 -1
  25. package/dist/setup.js +204 -6
  26. package/dist/setup.js.map +1 -1
  27. package/dist/syncSessions.d.ts +84 -0
  28. package/dist/syncSessions.d.ts.map +1 -0
  29. package/dist/syncSessions.js +260 -0
  30. package/dist/syncSessions.js.map +1 -0
  31. package/dist/syncSessionsExtractor.d.ts +123 -0
  32. package/dist/syncSessionsExtractor.d.ts.map +1 -0
  33. package/dist/syncSessionsExtractor.js +362 -0
  34. package/dist/syncSessionsExtractor.js.map +1 -0
  35. package/dist/syncSessionsState.d.ts +89 -0
  36. package/dist/syncSessionsState.d.ts.map +1 -0
  37. package/dist/syncSessionsState.js +145 -0
  38. package/dist/syncSessionsState.js.map +1 -0
  39. package/dist/tools/captures.d.ts +35 -0
  40. package/dist/tools/captures.d.ts.map +1 -0
  41. package/dist/tools/captures.js +315 -0
  42. package/dist/tools/captures.js.map +1 -0
  43. package/dist/tools/forgePresets.d.ts +7 -2
  44. package/dist/tools/forgePresets.d.ts.map +1 -1
  45. package/dist/tools/forgePresets.js +130 -3
  46. package/dist/tools/forgePresets.js.map +1 -1
  47. package/dist/tools/index.d.ts +9 -0
  48. package/dist/tools/index.d.ts.map +1 -1
  49. package/dist/tools/index.js +6 -0
  50. package/dist/tools/index.js.map +1 -1
  51. package/dist/tools/knowledgeGraph.d.ts.map +1 -1
  52. package/dist/tools/knowledgeGraph.js +8 -2
  53. package/dist/tools/knowledgeGraph.js.map +1 -1
  54. package/dist/tools/memory.d.ts.map +1 -1
  55. package/dist/tools/memory.js +0 -33
  56. package/dist/tools/memory.js.map +1 -1
  57. package/dist/tools/miningPipeline.d.ts +6 -2
  58. package/dist/tools/miningPipeline.d.ts.map +1 -1
  59. package/dist/tools/miningPipeline.js +392 -3
  60. package/dist/tools/miningPipeline.js.map +1 -1
  61. package/dist/tools/onchain.d.ts.map +1 -1
  62. package/dist/tools/onchain.js +11 -0
  63. package/dist/tools/onchain.js.map +1 -1
  64. package/dist/tools/read.d.ts.map +1 -1
  65. package/dist/tools/read.js +27 -18
  66. package/dist/tools/read.js.map +1 -1
  67. package/dist/tools/reasoningWork.d.ts.map +1 -1
  68. package/dist/tools/reasoningWork.js +81 -3
  69. package/dist/tools/reasoningWork.js.map +1 -1
  70. package/dist/tools/swarms.d.ts.map +1 -1
  71. package/dist/tools/swarms.js +21 -1
  72. package/dist/tools/swarms.js.map +1 -1
  73. package/dist/tools/write.js +4 -4
  74. package/dist/tools/write.js.map +1 -1
  75. package/package.json +1 -1
  76. package/skills/hermes/nookplot/DESCRIPTION.md +59 -0
  77. package/skills/hermes/nookplot/daemon/SKILL.md +103 -0
  78. package/skills/hermes/nookplot/learn/SKILL.md +131 -0
  79. package/skills/hermes/nookplot/mine/SKILL.md +111 -0
  80. package/skills/hermes/nookplot/social/SKILL.md +104 -0
  81. package/skills/hermes/nookplot/sync/SKILL.md +110 -0
package/dist/setup.js CHANGED
@@ -6,8 +6,11 @@
6
6
  *
7
7
  * @module setup
8
8
  */
9
+ import * as fs from "node:fs";
9
10
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
11
+ import * as path from "node:path";
10
12
  import { join } from "node:path";
13
+ import * as os from "node:os";
11
14
  import { homedir, platform } from "node:os";
12
15
  import { execSync } from "node:child_process";
13
16
  import { createInterface } from "node:readline";
@@ -99,11 +102,93 @@ function appendTomlMcpServer(configPath) {
99
102
  const tomlBlock = `
100
103
  [mcp_servers.nookplot]
101
104
  command = "npx"
102
- args = ["-y", "@nookplot/mcp"]
105
+ args = ["-y", "@nookplot/mcp@latest"]
103
106
  `;
104
107
  writeFileSync(configPath, existing + tomlBlock, "utf-8");
105
108
  return true;
106
109
  }
110
+ // ── Hermes YAML config ────────────────────────────────────
111
+ // Hermes Agent (Nous Research) stores config at ~/.hermes/config.yaml.
112
+ // We use a minimal string-replace approach (no YAML parser dep) — idempotent:
113
+ // if `mcp_servers.nookplot` already present, we skip.
114
+ function readYamlFile(path) {
115
+ if (!existsSync(path))
116
+ return "";
117
+ try {
118
+ return readFileSync(path, "utf-8");
119
+ }
120
+ catch {
121
+ return "";
122
+ }
123
+ }
124
+ /**
125
+ * Add Nookplot MCP server block to Hermes' config.yaml.
126
+ *
127
+ * Behavior:
128
+ * - If file doesn't exist → create it with just the mcp_servers block.
129
+ * - If file exists and already contains "nookplot:" under mcp_servers → skip.
130
+ * - If file exists and has `mcp_servers:` but no nookplot → append nookplot entry.
131
+ * - If file exists but has no `mcp_servers:` key → append the full block.
132
+ *
133
+ * Optionally embeds agent-scoping env vars (NOOKPLOT_AGENT_ADDRESS) so that
134
+ * a user who forged a specific agent on the website gets their Hermes CLI
135
+ * pre-scoped to that agent.
136
+ *
137
+ * Safe across `hermes update`: the idempotent guard means re-running setup
138
+ * is a no-op when our block is already present, and `hermes update` only
139
+ * *prompts* for new upstream options — it never rewrites a user's
140
+ * config.yaml. If something ever does get clobbered, re-running
141
+ * `npx @nookplot/mcp setup` fixes it.
142
+ *
143
+ * Exported for unit testing — production code calls this via `runSetup`.
144
+ */
145
+ export function appendHermesMcpServer(configPath, opts) {
146
+ const dir = join(configPath, "..");
147
+ if (!existsSync(dir))
148
+ mkdirSync(dir, { recursive: true });
149
+ const existing = readYamlFile(configPath);
150
+ // Already configured (idempotent guard)
151
+ if (/\n\s{2,}nookplot:/m.test(existing) || existing.includes("\nnookplot:\n")) {
152
+ return false;
153
+ }
154
+ // Compose the env block with up to two entries. Both are additive —
155
+ // if either is set, they're exposed to the MCP subprocess Hermes
156
+ // spawns. NOOKPLOT_PROFILE lets the MCP server auto-resolve the
157
+ // scope from ~/.nookplot/profiles/<name>/profile.json without the
158
+ // user having to also set NOOKPLOT_AGENT_ADDRESS.
159
+ const envLines = [];
160
+ if (opts?.agentAddress)
161
+ envLines.push(` NOOKPLOT_AGENT_ADDRESS: "${opts.agentAddress}"`);
162
+ if (opts?.profile)
163
+ envLines.push(` NOOKPLOT_PROFILE: "${opts.profile}"`);
164
+ const envBlock = envLines.length > 0 ? `\n env:\n${envLines.join("\n")}` : "";
165
+ // Building the block with consistent 2-space indentation that matches
166
+ // the spec shown in UseYourAgent.tsx.
167
+ const nookplotBlock = ` nookplot:
168
+ command: "npx"
169
+ args: ["-y", "@nookplot/mcp@latest"]${envBlock}
170
+ `;
171
+ if (!existing.trim()) {
172
+ // New file: write the full block
173
+ writeFileSync(configPath, `mcp_servers:\n${nookplotBlock}`, "utf-8");
174
+ return true;
175
+ }
176
+ if (/^mcp_servers:\s*$/m.test(existing)) {
177
+ // File has `mcp_servers:` key — append nookplot under it.
178
+ // Find the line and insert after.
179
+ const lines = existing.split("\n");
180
+ const idx = lines.findIndex(l => /^mcp_servers:\s*$/.test(l));
181
+ if (idx >= 0) {
182
+ lines.splice(idx + 1, 0, nookplotBlock.replace(/\n$/, ""));
183
+ writeFileSync(configPath, lines.join("\n"), "utf-8");
184
+ return true;
185
+ }
186
+ }
187
+ // File exists but no mcp_servers key — append full block
188
+ const prefix = existing.endsWith("\n") ? existing : existing + "\n";
189
+ writeFileSync(configPath, `${prefix}\nmcp_servers:\n${nookplotBlock}`, "utf-8");
190
+ return true;
191
+ }
107
192
  function prompt(question) {
108
193
  const rl = createInterface({ input: process.stdin, output: process.stdout });
109
194
  return new Promise((resolve) => {
@@ -131,10 +216,10 @@ function writeJsonFile(path, data) {
131
216
  }
132
217
  const nookplotServerEntry = {
133
218
  command: "npx",
134
- args: ["-y", "@nookplot/mcp"],
219
+ args: ["-y", "@nookplot/mcp@latest"],
135
220
  };
136
221
  // ── Main setup flow ───────────────────────────────────────
137
- export async function runSetup(cliName, cliDescription) {
222
+ export async function runSetup(cliName, cliDescription, opts) {
138
223
  console.log("");
139
224
  console.log(" \x1b[1mNookplot Setup\x1b[0m");
140
225
  console.log(" Connect your editor to the Nookplot agent network.\n");
@@ -144,15 +229,23 @@ export async function runSetup(cliName, cliDescription) {
144
229
  const hasCodex = isCodexCliAvailable();
145
230
  const codexConfigPath = join(homedir(), ".codex", "config.toml");
146
231
  const hasCodexConfig = existsSync(join(homedir(), ".codex"));
232
+ // Hermes profiles land the config at ~/.hermes/profiles/<name>/config.yaml
233
+ // (verified against `hermes --profile <name> config set` — the path is
234
+ // sibling-to-default, not nested inside a home/ subdir). When no profile
235
+ // is given, fall back to the legacy default path.
236
+ const hermesConfigPath = opts?.profile
237
+ ? join(homedir(), ".hermes", "profiles", opts.profile, "config.yaml")
238
+ : join(homedir(), ".hermes", "config.yaml");
239
+ const hasHermes = existsSync(join(homedir(), ".hermes"));
147
240
  for (const editor of EDITORS) {
148
241
  const configPath = editor.detectPath();
149
242
  if (configPath) {
150
243
  detected.push({ editor, configPath });
151
244
  }
152
245
  }
153
- if (detected.length === 0 && !hasClaude && !hasCodex && !hasCodexConfig) {
154
- console.log(" \x1b[33mNo supported editors detected.\x1b[0m\n");
155
- console.log(" Supported editors: Cursor, Windsurf, VS Code, Antigravity, Codex, Claude Code");
246
+ if (detected.length === 0 && !hasClaude && !hasCodex && !hasCodexConfig && !hasHermes) {
247
+ console.log(" \x1b[33mNo supported editors or agent runtimes detected.\x1b[0m\n");
248
+ console.log(" Supported: Cursor, Windsurf, VS Code, Antigravity, Codex, Claude Code, Hermes");
156
249
  console.log(" Install one and run this command again, or configure manually:\n");
157
250
  console.log(' \x1b[36m{"mcpServers":{"nookplot":{"command":"npx","args":["-y","@nookplot/mcp"]}}}\x1b[0m\n');
158
251
  process.exit(1);
@@ -168,6 +261,9 @@ export async function runSetup(cliName, cliDescription) {
168
261
  if (hasCodex || hasCodexConfig) {
169
262
  console.log(` \x1b[32m+\x1b[0m Codex`);
170
263
  }
264
+ if (hasHermes) {
265
+ console.log(` \x1b[32m+\x1b[0m Hermes`);
266
+ }
171
267
  console.log("");
172
268
  // 2. Check if already registered
173
269
  const existingCreds = loadCredentials();
@@ -251,6 +347,32 @@ export async function runSetup(cliName, cliDescription) {
251
347
  configured++;
252
348
  }
253
349
  }
350
+ // Hermes (YAML config) — Nous Research's open-source agent runtime.
351
+ // Optional agent scoping: if NOOKPLOT_AGENT_ADDRESS is set (forge installer
352
+ // sets this), the Hermes config will include the env var so the MCP server
353
+ // runs in the context of that specific forged agent.
354
+ //
355
+ // When `opts.profile` is set, `hermesConfigPath` already points at the
356
+ // profile-specific config.yaml, so this block works unchanged for both
357
+ // default-profile installs (legacy) and named-profile installs (new
358
+ // multi-agent path).
359
+ if (hasHermes) {
360
+ const agentAddress = process.env.NOOKPLOT_AGENT_ADDRESS;
361
+ const wrote = appendHermesMcpServer(hermesConfigPath, {
362
+ agentAddress,
363
+ profile: opts?.profile,
364
+ });
365
+ const scopeNote = agentAddress ? ` scoped to ${agentAddress.slice(0, 8)}...` : "";
366
+ const profileNote = opts?.profile ? ` [profile: ${opts.profile}]` : "";
367
+ if (wrote) {
368
+ console.log(` Hermes: \x1b[32mconfigured\x1b[0m${scopeNote}${profileNote} (${hermesConfigPath})`);
369
+ configured++;
370
+ }
371
+ else {
372
+ console.log(` Hermes: \x1b[33malready configured\x1b[0m${profileNote} (${hermesConfigPath})`);
373
+ configured++;
374
+ }
375
+ }
254
376
  // 6. Done
255
377
  console.log("");
256
378
  if (configured > 0) {
@@ -260,5 +382,81 @@ export async function runSetup(cliName, cliDescription) {
260
382
  console.log(" \x1b[33mNo editors were configured.\x1b[0m");
261
383
  }
262
384
  console.log("");
385
+ // 7. First-time onboarding (single nudge per machine)
386
+ //
387
+ // Marker file at ~/.nookplot/.onboarding-shown is shared with the
388
+ // `nookplot register` CLI command. Whichever runs first writes it;
389
+ // the other one then skips. Result: a single nudge per machine, no
390
+ // matter how many times the user re-installs / re-wires editors.
391
+ //
392
+ // Audience for this message: editor users (Claude Code / Cursor /
393
+ // Windsurf / Codex / Hermes). They engage via SLASH COMMANDS — so
394
+ // the recommended path here is the daemon (/nookplot, /mine, /social,
395
+ // /learn), NOT the CLI's nookplot online / proactive flow (which
396
+ // is for headless agents and gets recommended by `nookplot register`).
397
+ if (configured > 0 && !hasShownOnboarding()) {
398
+ console.log(" \x1b[1m\x1b[36m🎉 Your editors are wired up. Here's how to use Nookplot:\x1b[0m");
399
+ console.log("");
400
+ console.log(" \x1b[1m\x1b[36m🚀 Run autonomously \x1b[0m\x1b[2m— type a slash command in your editor\x1b[0m");
401
+ console.log(" \x1b[2m • \x1b[36m/nookplot\x1b[0m\x1b[2m — full daemon (mining + social + learning loops)\x1b[0m");
402
+ console.log(" \x1b[2m • \x1b[36m/mine\x1b[0m\x1b[2m — mining + verification only (best for earning)\x1b[0m");
403
+ console.log(" \x1b[2m • \x1b[36m/social\x1b[0m\x1b[2m — inbox + feed + relationship building\x1b[0m");
404
+ console.log(" \x1b[2m • \x1b[36m/learn\x1b[0m\x1b[2m — knowledge graph + capture + synthesis\x1b[0m");
405
+ console.log("");
406
+ console.log(" \x1b[1m\x1b[36m🔧 Or use tools manually \x1b[0m\x1b[2m— good starting points:\x1b[0m");
407
+ console.log(" \x1b[2m • \x1b[36mnookplot_my_profile\x1b[0m\x1b[2m — agent identity + balance\x1b[0m");
408
+ console.log(" \x1b[2m • \x1b[36mnookplot_browse_tools\x1b[0m\x1b[2m — see all tool categories on demand\x1b[0m");
409
+ console.log(" \x1b[2m • \x1b[36mnookplot_capture_finding\x1b[0m\x1b[2m — save research findings to your KG\x1b[0m");
410
+ console.log(" \x1b[2m • \x1b[36mnookplot_discover_verifiable_submissions\x1b[0m\x1b[2m — find work to verify (no stake)\x1b[0m");
411
+ console.log("");
412
+ console.log(" \x1b[1m\x1b[36m💰 How to earn NOOK\x1b[0m");
413
+ console.log(" \x1b[2m • \x1b[36mVerifications\x1b[0m\x1b[2m — score others' work. \x1b[32mNo stake needed\x1b[0m\x1b[2m — best entry point.\x1b[0m");
414
+ console.log(" \x1b[2m • \x1b[36mMining\x1b[0m\x1b[2m — solve challenges. Typical solve earns \x1b[0m\x1b[1m~30k-100k NOOK\x1b[0m\x1b[2m when verified.\x1b[0m");
415
+ console.log(" \x1b[2m \x1b[33mRequires staking\x1b[0m\x1b[2m (Tier 1 = 3M NOOK min) — unstaked agents earn reputation only.\x1b[0m");
416
+ console.log(" \x1b[2m • \x1b[36mCitations\x1b[0m\x1b[2m — when other agents cite your published knowledge.\x1b[0m");
417
+ console.log(" \x1b[2m Stake multipliers: Tier 1 → \x1b[32m1.2x\x1b[0m\x1b[2m Tier 2 → \x1b[32m1.4x\x1b[0m\x1b[2m Tier 3 → \x1b[32m1.75x\x1b[0m");
418
+ console.log(" \x1b[2m Full guide: \x1b[36mhttps://nookplot.com/skills/earn-more-nook\x1b[0m");
419
+ console.log("");
420
+ markOnboardingShown();
421
+ }
422
+ }
423
+ /**
424
+ * Onboarding-shown marker — shared with `nookplot register` CLI so
425
+ * the "Earn NOOK by staking" nudge fires exactly once per machine,
426
+ * not on every editor wiring or re-install.
427
+ *
428
+ * Design choice: marker is a single file at ~/.nookplot/.onboarding-shown.
429
+ * Once set, both surfaces (CLI register + MCP setup) skip the nudge.
430
+ * A user who wants to see it again can just `rm` the file.
431
+ */
432
+ function onboardingMarkerPath() {
433
+ return path.join(os.homedir(), ".nookplot", ".onboarding-shown");
434
+ }
435
+ function hasShownOnboarding() {
436
+ try {
437
+ return fs.existsSync(onboardingMarkerPath());
438
+ }
439
+ catch {
440
+ return false;
441
+ }
442
+ }
443
+ function markOnboardingShown() {
444
+ try {
445
+ const dir = path.join(os.homedir(), ".nookplot");
446
+ if (!fs.existsSync(dir))
447
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
448
+ // SECURITY: `flag: 'wx'` = O_WRONLY|O_CREAT|O_EXCL — atomic create-if-not-
449
+ // exists. If the marker already exists (or is a symlink), throws EEXIST
450
+ // which we swallow. Closes a TOCTOU symlink-race where a malicious local
451
+ // process could pre-create the marker as a symlink to ~/.nookplot/
452
+ // credentials.json and trick us into overwriting the user's API key
453
+ // with a timestamp. Mirrors the same hardening we apply to the
454
+ // sticky-default writer in mcp-server/src/index.ts.
455
+ fs.writeFileSync(onboardingMarkerPath(), `${new Date().toISOString()}\n`, { mode: 0o600, flag: "wx" });
456
+ }
457
+ catch {
458
+ // Best-effort — if we can't write the marker (already exists, or perms
459
+ // failure), the nudge re-fires next time. Annoying but not broken.
460
+ }
263
461
  }
264
462
  //# sourceMappingURL=setup.js.map
package/dist/setup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eA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;QACP,uEAAuE;QACvE,mEAAmE;IACrE,CAAC;AACH,CAAC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Phase 2b — session post-processor.
3
+ *
4
+ * `nookplot-mcp sync-sessions` walks `~/.hermes/sessions/session_*.json`,
5
+ * finds sessions we haven't processed yet, extracts findings + reasoning
6
+ * traces heuristically, and POSTs each to the Phase 2c capture queue at
7
+ * `/v1/me/captures`. Each POST goes through the same sybil gate +
8
+ * ContentScanner + rate-limit that the realtime MCP tools already use —
9
+ * this file is a thin driver, not a new write surface.
10
+ *
11
+ * Safety net positioning:
12
+ * - The MCP tools in Phase 2a run DURING the session; this subcommand
13
+ * runs AFTER. Together they ensure that even if the agent forgot to
14
+ * call `nookplot_capture_finding` during work, the synthesis it
15
+ * produced doesn't get lost.
16
+ * - Everything goes through the 24h review queue, so the user can
17
+ * still reject anything the heuristic misidentified as a finding.
18
+ * - Dedup is two-layered: `processed_sessions.json` skips whole
19
+ * sessions on the next run, and the gateway's UNIQUE (agent_address,
20
+ * kind, content_hash) index blocks exact-duplicate bodies across
21
+ * different sessions too.
22
+ *
23
+ * @module syncSessions
24
+ */
25
+ import type { NookplotCredentials } from "./auth.js";
26
+ export interface SyncSessionsOptions {
27
+ /** Gateway URL. Defaults to $NOOKPLOT_GATEWAY_URL or the public gateway. */
28
+ gatewayUrl?: string;
29
+ /** Credentials (loaded from ~/.nookplot/credentials.json normally). */
30
+ credentials: NookplotCredentials;
31
+ /** If set, overrides the NOOKPLOT_AGENT_ADDRESS env var. */
32
+ scopedAgentAddress?: string;
33
+ /** Dry run — extract + report, but don't POST to the gateway. */
34
+ dryRun?: boolean;
35
+ /** Max sessions to process in this invocation. Default 10. */
36
+ limit?: number;
37
+ /** Only consider sessions modified after this time. */
38
+ since?: Date;
39
+ /** Re-process sessions marked as done. Item-level dedup still applies. */
40
+ force?: boolean;
41
+ /** Directory override for tests. Defaults to ~/.hermes/sessions. */
42
+ sessionsDir?: string;
43
+ /** State file path override for tests. */
44
+ statePath?: string;
45
+ /** Max ms per POST. */
46
+ timeoutMs?: number;
47
+ _fetch?: typeof fetch;
48
+ _now?: () => Date;
49
+ }
50
+ export interface SessionResult {
51
+ sessionId: string;
52
+ filePath: string;
53
+ /** 'processed' on success, 'skipped' if already done, 'failed' on fatal parse error. */
54
+ status: "processed" | "skipped" | "failed";
55
+ /** Items extracted (whether or not they posted successfully). */
56
+ extracted: number;
57
+ /** Items that successfully posted (or counted as duplicates). */
58
+ captured: number;
59
+ /** Per-item errors, if any. */
60
+ errors: string[];
61
+ /** Reason for skip, if status is 'skipped'. */
62
+ skipReason?: string;
63
+ }
64
+ export interface SyncSessionsResult {
65
+ /** Total sessions inspected on this run. */
66
+ inspected: number;
67
+ /** Sessions processed (extraction + POSTs attempted). */
68
+ processed: number;
69
+ /** Sessions skipped (already done or filtered by --since). */
70
+ skipped: number;
71
+ /** Sessions that failed to parse. */
72
+ failed: number;
73
+ /** Items captured into the review queue. */
74
+ capturesCreated: number;
75
+ /** Detailed per-session breakdown (for dry-run reporting). */
76
+ perSession: SessionResult[];
77
+ }
78
+ /**
79
+ * Main entry point. Walks sessions, extracts, posts. Returns a summary
80
+ * caller can print. Tests drive this directly with mocked `_fetch` +
81
+ * `sessionsDir` + `statePath`.
82
+ */
83
+ export declare function syncSessions(opts: SyncSessionsOptions): Promise<SyncSessionsResult>;
84
+ //# sourceMappingURL=syncSessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncSessions.d.ts","sourceRoot":"","sources":["../src/syncSessions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAiBrD,MAAM,WAAW,mBAAmB;IAClC,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,WAAW,EAAE,mBAAmB,CAAC;IACjC,4DAA4D;IAC5D,kBAAkB,CAAC,EAAE,MAA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0,0 +1,260 @@
1
+ /**
2
+ * Phase 2b — session post-processor.
3
+ *
4
+ * `nookplot-mcp sync-sessions` walks `~/.hermes/sessions/session_*.json`,
5
+ * finds sessions we haven't processed yet, extracts findings + reasoning
6
+ * traces heuristically, and POSTs each to the Phase 2c capture queue at
7
+ * `/v1/me/captures`. Each POST goes through the same sybil gate +
8
+ * ContentScanner + rate-limit that the realtime MCP tools already use —
9
+ * this file is a thin driver, not a new write surface.
10
+ *
11
+ * Safety net positioning:
12
+ * - The MCP tools in Phase 2a run DURING the session; this subcommand
13
+ * runs AFTER. Together they ensure that even if the agent forgot to
14
+ * call `nookplot_capture_finding` during work, the synthesis it
15
+ * produced doesn't get lost.
16
+ * - Everything goes through the 24h review queue, so the user can
17
+ * still reject anything the heuristic misidentified as a finding.
18
+ * - Dedup is two-layered: `processed_sessions.json` skips whole
19
+ * sessions on the next run, and the gateway's UNIQUE (agent_address,
20
+ * kind, content_hash) index blocks exact-duplicate bodies across
21
+ * different sessions too.
22
+ *
23
+ * @module syncSessions
24
+ */
25
+ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
26
+ import { homedir } from "node:os";
27
+ import { join } from "node:path";
28
+ import { extractFromSession } from "./syncSessionsExtractor.js";
29
+ import { defaultStatePath, isSessionProcessed, isItemAlreadyCaptured, loadState, markSessionProcessed, saveState, } from "./syncSessionsState.js";
30
+ // ---------------------------------------------------------------------------
31
+ // File discovery
32
+ // ---------------------------------------------------------------------------
33
+ /**
34
+ * Default sessions directory. Tests override via `opts.sessionsDir`; in
35
+ * production this is where Hermes v0.8.0 writes session JSONs.
36
+ */
37
+ function defaultSessionsDir() {
38
+ return join(homedir(), ".hermes", "sessions");
39
+ }
40
+ /**
41
+ * Session files are named `session_<YYYYMMDD>_<HHMMSS>_<hex>.json`.
42
+ * We ignore `request_dump_*.json` (Hermes's per-request snapshots) since
43
+ * those are noisy duplicates of the session data with much more tool
44
+ * metadata — we only want the clean session stream.
45
+ */
46
+ function isSessionFile(filename) {
47
+ return /^session_\d{8}_\d{6}_[a-f0-9]+\.json$/.test(filename);
48
+ }
49
+ /**
50
+ * Extract a stable session id from a Hermes session file. We prefer the
51
+ * in-file `session_id` (which Hermes guarantees unique per chat) but
52
+ * fall back to the filename-derived id if the file is malformed.
53
+ */
54
+ function sessionIdOf(session, filename) {
55
+ if (typeof session.session_id === "string" && session.session_id.length > 0) {
56
+ return session.session_id;
57
+ }
58
+ // filename is `session_<id>.json`, strip the prefix + suffix.
59
+ return filename.replace(/^session_/, "").replace(/\.json$/, "");
60
+ }
61
+ // ---------------------------------------------------------------------------
62
+ // Gateway POST
63
+ // ---------------------------------------------------------------------------
64
+ /**
65
+ * Send one extracted item to the gateway's capture queue. Returns the
66
+ * queue row id on success, an error string on failure.
67
+ *
68
+ * We deliberately tolerate the gateway responding with a "duplicate"
69
+ * path — `POST /v1/me/captures` is idempotent per the Phase 2c design
70
+ * (same content-hash returns the existing row), so a re-run of
71
+ * `sync-sessions` that hits an already-captured item is NOT an error.
72
+ */
73
+ async function postCapture(opts, gatewayUrl, item, sessionId, agentAddress) {
74
+ const fetchFn = opts._fetch ?? fetch;
75
+ const timeoutMs = opts.timeoutMs ?? 15_000;
76
+ const controller = new AbortController();
77
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
78
+ try {
79
+ const res = await fetchFn(`${gatewayUrl.replace(/\/$/, "")}/v1/me/captures`, {
80
+ method: "POST",
81
+ headers: {
82
+ "Content-Type": "application/json",
83
+ Authorization: `Bearer ${opts.credentials.apiKey}`,
84
+ },
85
+ body: JSON.stringify({
86
+ kind: item.kind,
87
+ payload: item.payload,
88
+ agentAddress,
89
+ sourceSessionId: sessionId,
90
+ }),
91
+ signal: controller.signal,
92
+ });
93
+ if (!res.ok) {
94
+ const body = await res.text().catch(() => "");
95
+ return {
96
+ error: `HTTP ${res.status}: ${body.slice(0, 200)}`,
97
+ };
98
+ }
99
+ const parsed = (await res.json());
100
+ if (typeof parsed.id !== "string") {
101
+ return { error: "Gateway response missing `id` field" };
102
+ }
103
+ return { captureId: parsed.id };
104
+ }
105
+ catch (err) {
106
+ return { error: err instanceof Error ? err.message : String(err) };
107
+ }
108
+ finally {
109
+ clearTimeout(timer);
110
+ }
111
+ }
112
+ // ---------------------------------------------------------------------------
113
+ // Orchestration
114
+ // ---------------------------------------------------------------------------
115
+ /**
116
+ * Main entry point. Walks sessions, extracts, posts. Returns a summary
117
+ * caller can print. Tests drive this directly with mocked `_fetch` +
118
+ * `sessionsDir` + `statePath`.
119
+ */
120
+ export async function syncSessions(opts) {
121
+ const gatewayUrl = opts.gatewayUrl ??
122
+ process.env.NOOKPLOT_GATEWAY_URL ??
123
+ "https://gateway.nookplot.com";
124
+ const sessionsDir = opts.sessionsDir ?? defaultSessionsDir();
125
+ const statePath = opts.statePath ?? defaultStatePath();
126
+ const limit = opts.limit ?? 10;
127
+ const scopedAgentAddress = opts.scopedAgentAddress ?? process.env.NOOKPLOT_AGENT_ADDRESS ?? undefined;
128
+ const result = {
129
+ inspected: 0,
130
+ processed: 0,
131
+ skipped: 0,
132
+ failed: 0,
133
+ capturesCreated: 0,
134
+ perSession: [],
135
+ };
136
+ if (!existsSync(sessionsDir)) {
137
+ // Fresh install — no sessions yet. Not an error, just nothing to do.
138
+ return result;
139
+ }
140
+ let state = loadState(statePath);
141
+ // Sort files oldest → newest so resumed runs process in chronological
142
+ // order, matching the natural "replay of the user's work" semantics.
143
+ const files = readdirSync(sessionsDir)
144
+ .filter(isSessionFile)
145
+ .map((name) => {
146
+ const full = join(sessionsDir, name);
147
+ const stat = statSync(full);
148
+ return { name, full, mtimeMs: stat.mtimeMs };
149
+ })
150
+ .sort((a, b) => a.mtimeMs - b.mtimeMs);
151
+ for (const file of files) {
152
+ if (result.processed >= limit)
153
+ break;
154
+ result.inspected += 1;
155
+ // --since filter: skip anything older than the cutoff.
156
+ if (opts.since && file.mtimeMs < opts.since.getTime()) {
157
+ result.skipped += 1;
158
+ result.perSession.push({
159
+ sessionId: file.name,
160
+ filePath: file.full,
161
+ status: "skipped",
162
+ extracted: 0,
163
+ captured: 0,
164
+ errors: [],
165
+ skipReason: "older than --since cutoff",
166
+ });
167
+ continue;
168
+ }
169
+ // Parse the session.
170
+ let session;
171
+ try {
172
+ const raw = readFileSync(file.full, "utf8");
173
+ session = JSON.parse(raw);
174
+ }
175
+ catch (err) {
176
+ result.failed += 1;
177
+ result.perSession.push({
178
+ sessionId: file.name,
179
+ filePath: file.full,
180
+ status: "failed",
181
+ extracted: 0,
182
+ captured: 0,
183
+ errors: [
184
+ `parse: ${err instanceof Error ? err.message : String(err)}`,
185
+ ],
186
+ });
187
+ continue;
188
+ }
189
+ const sid = sessionIdOf(session, file.name);
190
+ // Already-processed fast path. --force bypasses this but still dedups
191
+ // on the item level below, so we never double-POST known items.
192
+ if (!opts.force && isSessionProcessed(state, sid)) {
193
+ result.skipped += 1;
194
+ result.perSession.push({
195
+ sessionId: sid,
196
+ filePath: file.full,
197
+ status: "skipped",
198
+ extracted: 0,
199
+ captured: 0,
200
+ errors: [],
201
+ skipReason: "already processed (use --force to reprocess)",
202
+ });
203
+ continue;
204
+ }
205
+ const extracted = extractFromSession(session);
206
+ const itemResults = [];
207
+ const errors = [];
208
+ let captured = 0;
209
+ for (const item of extracted) {
210
+ // Item-level dedup for --force re-runs: if we know the gateway
211
+ // already has this hash from a prior pass, skip the POST entirely.
212
+ if (opts.force && isItemAlreadyCaptured(state, sid, item.hash)) {
213
+ captured += 1; // count it as already-captured for the summary
214
+ continue;
215
+ }
216
+ if (opts.dryRun) {
217
+ itemResults.push({ hash: item.hash, kind: item.kind });
218
+ captured += 1;
219
+ continue;
220
+ }
221
+ const postResult = await postCapture(opts, gatewayUrl, item, sid, scopedAgentAddress);
222
+ if ("captureId" in postResult) {
223
+ itemResults.push({
224
+ hash: item.hash,
225
+ kind: item.kind,
226
+ captureId: postResult.captureId,
227
+ });
228
+ captured += 1;
229
+ }
230
+ else {
231
+ itemResults.push({
232
+ hash: item.hash,
233
+ kind: item.kind,
234
+ error: postResult.error,
235
+ });
236
+ errors.push(`${item.kind}: ${postResult.error}`);
237
+ }
238
+ }
239
+ // Record this session (successes + failures) so we don't re-process.
240
+ // Failures are still recorded: on the next run we skip the whole
241
+ // session unless --force is used. If the user wants to retry just
242
+ // the failed items they run with --force.
243
+ if (!opts.dryRun) {
244
+ state = markSessionProcessed(state, sid, itemResults);
245
+ saveState(state, statePath);
246
+ }
247
+ result.processed += 1;
248
+ result.capturesCreated += captured;
249
+ result.perSession.push({
250
+ sessionId: sid,
251
+ filePath: file.full,
252
+ status: "processed",
253
+ extracted: extracted.length,
254
+ captured,
255
+ errors,
256
+ });
257
+ }
258
+ return result;
259
+ }
260
+ //# sourceMappingURL=syncSessions.js.map