@theronap/agnoclast-mcp 0.9.328 → 0.9.330

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.
@@ -0,0 +1,11 @@
1
+ // WHO IS WRITING A SESSION LOG (agent conversation capture, step 2; obligation de216454).
2
+ // log_session sends source claude-code from every agent, so Muse and Hermes logs read as Claude Code sessions.
3
+ // It now also sends the agent's name, which the server records as capturedBy (web/lib/engine/session_log_writer.ts).
4
+
5
+ /** AGNOCLAST_CLIENT when the runner sets it (Muse, Hermes), Claude Code when its own session id is present, else
6
+ * null, and the server names the token's connection instead. */
7
+ export function logAgent(env) {
8
+ const declared = typeof env?.AGNOCLAST_CLIENT === 'string' ? env.AGNOCLAST_CLIENT.trim().slice(0, 60) : ''
9
+ if (declared) return declared
10
+ return env?.CLAUDE_CODE_SESSION_ID ? 'Claude Code' : null
11
+ }
@@ -22,9 +22,19 @@ const SOURCE_LABEL = {
22
22
  handoff: 'Transcript or document', meeting: 'Meeting',
23
23
  // Every remote connector's saves, not only claude.ai's: which AI made one is rec.capturedBy (header line below).
24
24
  'claude-connector': 'Saved through a connector',
25
+ // An agent's text conversation, kept word for word as a session (web/lib/engine/agent_conversation_log.ts).
26
+ 'agent-chat': 'Agent conversation',
25
27
  }
26
28
 
27
29
  const label = (source) => SOURCE_LABEL[source] ?? source
30
+
31
+ /** PURE. A session log written by another agent (Muse, Hermes) is named for that agent, not "Claude Code session":
32
+ * log_session keeps the claude-code source for routing and tier, and the server records who wrote it as capturedBy. */
33
+ export function sourceLine(source, capturedBy, by = '') {
34
+ const agent = typeof capturedBy === 'string' ? capturedBy.trim() : ''
35
+ if (source === 'claude-code' && agent && !/claude code/i.test(agent)) return `${agent} session`
36
+ return `${label(source)}${by}`
37
+ }
28
38
  const line = (e) => ` · ${e.title || '(untitled)'} — ${label(e.source)} · ${e.occurredAt} — id ${e.id}`
29
39
 
30
40
  /**
@@ -41,7 +51,7 @@ export function renderRecord(rec, maxChars = READ_RECORD_DEFAULT_CHARS, part = '
41
51
  const out = []
42
52
  out.push(`# ${rec.title || '(untitled record)'}`)
43
53
  const by = typeof rec.capturedBy === 'string' && rec.capturedBy ? ` (${rec.capturedBy})` : ''
44
- out.push(`${label(rec.source)}${by} · ${rec.occurredAt} · brain ${rec.brain?.name ?? rec.brain ?? '?'}${rec.superseded ? ' · ⚠ superseded by a newer version' : ''}`)
54
+ out.push(`${sourceLine(rec.source, rec.capturedBy, by)} · ${rec.occurredAt} · brain ${rec.brain?.name ?? rec.brain ?? '?'}${rec.superseded ? ' · ⚠ superseded by a newer version' : ''}`)
45
55
  out.push(`id: ${rec.id}`)
46
56
  out.push('')
47
57
  const content = typeof rec.content === 'string' ? rec.content : ''
package/lib/server.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
2
2
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
3
3
  import { z } from 'zod'
4
+ import { logAgent } from './log_agent.mjs'
4
5
  import { writeFileSync, mkdirSync, readFileSync, statSync } from 'fs'
5
6
  import { homedir } from 'os'
6
7
  import { join } from 'path'
@@ -885,7 +886,10 @@ function renderNudge(payload) {
885
886
  // org. Measured 2026-08-09: 86 staged rows, not drainable by /api/staged/promote.
886
887
  ...(seg.brain ? { brain: seg.brain } : {}),
887
888
  ...(privacy ? { privacy } : {}),
888
- payload: { via: 'log_session' },
889
+ // WHICH AGENT wrote this log. The source stays claude-code (routing and the tier floor key on it), so
890
+ // Muse or Hermes says who it is here and the server records it as capturedBy (session_log_writer.ts).
891
+ // Without either, the server names the token's connection instead.
892
+ payload: { via: 'log_session', ...(logAgent(process.env) ? { agent: logAgent(process.env) } : {}) },
889
893
  }),
890
894
  })
891
895
  } catch (e) {
@@ -2407,12 +2411,14 @@ function renderNudge(payload) {
2407
2411
  history: z.boolean().optional().describe('node names only: return the node\'s TIMELINE (events joined via its [[repo:…]] stamps, reverse-chron, viewer-visible) instead of the page body. The page is the present; this is the history.'),
2408
2412
  version: z.string().optional().describe('read a HISTORICAL version of this page instead of the current one: a rev_no (e.g. "3") or a content_hash from page_history. Use page_history first to see the versions, then rollback_page to restore one.'),
2409
2413
  ref: z.string().optional().describe('the page\'s ref (read_page prints it as `ref:`). Addresses exactly one page, so use it when a name exists in more than one brain — history and version reads refuse an ambiguous name and list the refs to choose from.'),
2414
+ brain: z.string().optional().describe('a brain name from my_brains: read only THAT brain\'s page when the same name exists in several brains. Naming a 🔒 confidential brain also locks this session to it.'),
2410
2415
  },
2411
2416
  },
2412
- async ({ name, kind, expand, history, version, ref }) => {
2417
+ async ({ name, kind, expand, history, version, ref, brain }) => {
2413
2418
  const k = kind ?? 'project'
2414
- // A ref addresses exactly one page; a name can match one page in each of several brains.
2415
- const address = (extra = {}) => new URLSearchParams(ref ? { ref, ...extra } : { kind: k, key: name, ...extra })
2419
+ // A ref addresses exactly one page; a name can match one page in each of several brains. `brain`
2420
+ // narrows to one brain's copy (dry-run bug 4: before 0.9.x it only ever opened confidential brains).
2421
+ const address = (extra = {}) => new URLSearchParams({ ...(ref ? { ref } : { kind: k, key: name }), ...(brain ? { brain } : {}), ...extra })
2416
2422
  // PAGE HISTORY (Part A): a specific version reads one historical body, resolved within this page's
2417
2423
  // own history. Not for identifier-shaped names (those are join keys, handled below).
2418
2424
  if (version && !/^[a-z][a-z0-9_-]*:.+/i.test(name)) {
@@ -2517,6 +2523,7 @@ function renderNudge(payload) {
2517
2523
  } catch (e) {
2518
2524
  return toolError(`Could not read "${name}": ${e.message}`)
2519
2525
  }
2526
+ if (res.status === 400 && brain) return { content: [{ type: 'text', text: `"${brain}" is not one of your brains. my_brains lists them.` }] }
2520
2527
  if (res.status === 404) {
2521
2528
  return { content: [{ type: 'text', text: `No ${k} page named "${name}". If it's a person or team, pass kind (person/org).${await redLinkTriage(BASE, TOKEN, name)}` }] }
2522
2529
  }
@@ -2534,6 +2541,9 @@ function renderNudge(payload) {
2534
2541
  if (!matches.length && page?.authored && Array.isArray(page.tiers) && page.tiers.length) {
2535
2542
  matches = [{ brain: null, authored: true, ref: page.ref, title: page.title, tiers: page.tiers }]
2536
2543
  }
2544
+ if (!matches.length && brain) {
2545
+ return { content: [{ type: 'text', text: `No authored page named "${name}" in the brain "${brain}". Leave out \`brain\` to search every brain you belong to.` }] }
2546
+ }
2537
2547
  if (!matches.length) {
2538
2548
  // ⚠ This used to say: `No authored ${k} page named "X" ... If it's a person or team, pass
2539
2549
  // kind (person/org).` Both halves misled. resolveNodeByTitle matches EVERY kind and uses the
@@ -2640,7 +2650,7 @@ function renderNudge(payload) {
2640
2650
  if (matches.length === 1) {
2641
2651
  return { content: [{ type: 'text', text: renderMatch(matches[0], false) + nudgeBlock }] }
2642
2652
  }
2643
- const header = `"${name}" is authored in ${matches.length} of your brains — all shown (each tagged with its brain, newest tier first):`
2653
+ const header = `"${name}" is authored in ${matches.length} of your brains — all shown (each tagged with its brain, newest tier first). They are DIFFERENT pages: to read or change one, pass its \`ref\` (or \`brain\`).`
2644
2654
  return { content: [{ type: 'text', text: [header, ...matches.map((m) => renderMatch(m, true))].join('\n\n═══════════════════\n\n') + nudgeBlock }] }
2645
2655
  },
2646
2656
  )
@@ -2654,18 +2664,30 @@ function renderNudge(payload) {
2654
2664
  name: z.string().describe('the canonical node name exactly as written (e.g. "Agnoclast", "Ben")'),
2655
2665
  kind: z.enum(['project', 'person', 'org', 'user']).optional().describe('node kind (default project)'),
2656
2666
  limit: z.number().int().optional().describe('how many recent versions to show (default 20, max 200)'),
2667
+ ref: z.string().optional().describe('the page\'s ref (read_page prints it as `ref:`). Addresses exactly one page — use it when the name exists in more than one brain.'),
2668
+ brain: z.string().optional().describe('a brain name from my_brains: that brain\'s page, when the same name exists in several brains'),
2657
2669
  },
2658
2670
  },
2659
- async ({ name, kind, limit }) => {
2671
+ async ({ name, kind, limit, ref, brain }) => {
2660
2672
  const k = kind ?? 'project'
2661
2673
  let res
2662
2674
  try {
2663
- const qs = new URLSearchParams({ kind: k, key: name, ...(limit ? { limit: String(limit) } : {}) })
2675
+ // Dry-run bug 4 (2026-11-07): this sent only the name, so for a name in several brains the server
2676
+ // picked one — the Hermes lane asked for its results page and got the Grok lane's history.
2677
+ const qs = new URLSearchParams({ kind: k, key: name, ...(ref ? { ref } : {}), ...(brain ? { brain } : {}), ...(limit ? { limit: String(limit) } : {}) })
2664
2678
  res = await fetchCortex(`${BASE}/api/brain/page-history?${qs}`, { headers: { Authorization: `Bearer ${TOKEN}` } })
2665
2679
  } catch (e) {
2666
2680
  return toolError(`Could not read history for "${name}": ${e.message}`)
2667
2681
  }
2668
- if (res.status === 404) return { content: [{ type: 'text', text: `No ${k} named "${name}". Pass kind (person/org) if it isn't a project.` }] }
2682
+ if (res.status === 409) {
2683
+ const body = await res.json().catch(() => null)
2684
+ const c = Array.isArray(body?.candidates) ? body.candidates : []
2685
+ return { content: [{ type: 'text', text: c.length
2686
+ ? [`"${name}" names a page in ${c.length} of your brains, and one history list can only be one page's — call page_history again with the ref of the one you mean:`, ...c.map((m) => ` - in ${m.brain} — ref: ${m.ref}`)].join('\n')
2687
+ : await ambiguousPageHint(BASE, TOKEN, k, name) }] }
2688
+ }
2689
+ if (res.status === 400 && brain) return { content: [{ type: 'text', text: `"${brain}" is not one of your brains. my_brains lists them.` }] }
2690
+ if (res.status === 404) return { content: [{ type: 'text', text: brain ? `No ${k} "${name}" in the brain "${brain}".` : `No ${k} named "${name}". Pass kind (person/org) if it isn't a project.` }] }
2669
2691
  if (!res.ok) {
2670
2692
  const d = classify(res.status, res.headers.get('content-type'), await res.text(), res.headers.get('x-vercel-id'))
2671
2693
  return toolError(`Could not read history for "${name}": ${d.message}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/agnoclast-mcp",
3
- "version": "0.9.328",
3
+ "version": "0.9.330",
4
4
  "description": "Connect your AI assistant to Cortex — your org's projects, activity, gaps, and directives, scoped to you.",
5
5
  "type": "module",
6
6
  "bin": {