@theronap/agnoclast-mcp 0.9.298 โ†’ 0.9.300

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/lib/closeout.mjs CHANGED
@@ -543,8 +543,11 @@ async function closeSession(session, { env, home, stopAtLog = false, write = tru
543
543
  if (!write) return { ok: true, cost, digest, wiki }
544
544
  const accepted = wiki?.accepted ?? []
545
545
  // Pages first, so the record that follows has them attached: the server attaches what this session wrote.
546
- const edits = WIKI_WRITES && accepted.length ? await applyWikiEdits(tools, accepted) : []
547
- const written = await writeSegments(tools, session.id, WIKI_WRITES ? digest.segments : withPageProposals(digest.segments, accepted))
546
+ // An edit that could not land goes on the record under "Pages to update", so it is not lost.
547
+ const applied = WIKI_WRITES && accepted.length ? await applyWikiEdits(tools, accepted, currentPage(tools)) : []
548
+ const unlanded = WIKI_WRITES ? applied.filter((r) => !r.ok).map((r) => r.edit) : accepted
549
+ const written = await writeSegments(tools, session.id, withPageProposals(digest.segments, unlanded))
550
+ const edits = applied.map(({ edit, ...r }) => r)
548
551
  return { ok: written.ok, records: written.records, why: written.ok ? null : written.text.slice(0, 600), cost, digest, wiki, edits }
549
552
  } finally {
550
553
  await tools.close().catch(() => {})
@@ -164,12 +164,25 @@ export function withPageProposals(segments, accepted) {
164
164
  })
165
165
  }
166
166
 
167
- /** Land the accepted edits. `edit_page` is the only write here, and its refusals are kept, not retried. */
168
- export async function applyWikiEdits(tools, accepted) {
167
+ /**
168
+ * Land the accepted edits. `edit_page` is the only write here. A page another session changed in the meantime is
169
+ * refused by its version (2026-11-03: two sessions rewrote one page while a run read it), so the page is read again
170
+ * and the edit retried once, only while its passage is still there exactly once. Each result keeps its edit, so a
171
+ * caller can put what failed on the record instead.
172
+ */
173
+ export async function applyWikiEdits(tools, accepted, readPage) {
169
174
  const results = []
175
+ const edit = async (e, version) => {
176
+ const r = await tools.call('edit_page', { name: e.page, heading: e.heading, old_string: e.old_string, new_string: e.new_string, base_version: version, reason: e.reason })
177
+ return { ok: !r.isError && r.text.startsWith('Edited'), text: r.text.slice(0, 200) }
178
+ }
170
179
  for (const e of accepted) {
171
- const r = await tools.call('edit_page', { name: e.page, heading: e.heading, old_string: e.old_string, new_string: e.new_string, base_version: e.version, reason: e.reason })
172
- results.push({ page: e.page, ok: !r.isError && r.text.startsWith('Edited'), text: r.text.slice(0, 200) })
180
+ let r = await edit(e, e.version)
181
+ if (!r.ok && readPage && /version/i.test(r.text)) {
182
+ const page = await readPage(e.page, [e.brain])
183
+ if (page && page.text.split(e.old_string).length === 2) r = await edit(e, page.version)
184
+ }
185
+ results.push({ page: e.page, ...r, edit: e })
173
186
  }
174
187
  return results
175
188
  }
@@ -177,7 +177,7 @@ export function lockStateLine({ lockedInto = null, lock = null, brains = [] } =
177
177
  if (!brains.length) return ''
178
178
  const names = brains.map((b) => b.name).join(', ')
179
179
  if (lock?.state === 'in') return `๐Ÿ”’ This session is LOCKED to the confidential brain "${lock.brain}".`
180
- if (lock?.state === 'out') return `๐Ÿ”’ Confidential: ${names} โ€” LOCKED AWAY from this session: it used another brain first. Start a new session and use the confidential brain first.`
180
+ if (lock?.state === 'out') return `๐Ÿ”’ Confidential: ${names} โ€” locked away from this session, because it used another brain first. A new session reaches it if it uses it first.`
181
181
  return `๐Ÿ”’ Confidential (a session works in one of these ALONE): ${names}\n` +
182
182
  ' This session is NOT locked yet. Pass the name as `brain` to any tool to lock the session to it; using any other brain first locks these away from the session instead.'
183
183
  }
@@ -38,7 +38,7 @@ export function textRequestReply(status, body, recipient) {
38
38
  if (reviewUrl) {
39
39
  return { isError: false, text:
40
40
  `Text request created to ${recipient}. It is NOT sent yet. ` +
41
- `Tell the user, in these words: It's waiting for your OK: ${reviewUrl}` }
41
+ `For the person, word for word: It's waiting for your OK: ${reviewUrl}` }
42
42
  }
43
43
  const state = body?.request?.state ?? 'approved'
44
44
  return { isError: false, text:
@@ -90,8 +90,8 @@ export function renderProposal(body, candidate, note) {
90
90
  * tool catalogue read once at startup.
91
91
  */
92
92
  export const NOTICE_ASKS =
93
- 'If something here ASKS THIS PERSON FOR SOMETHING โ€” a reply, a call, a form, a deadline โ€” propose it with ' +
94
- '`propose_obligation` and the sentence that says so. Reading it and filing it is not surfacing it.'
93
+ 'Agnoclast note: anything here that asks this person for something (a reply, a call, a form, a deadline) can be ' +
94
+ 'tracked with `propose_obligation` and the sentence that says so. Filing it does not surface it.'
95
95
 
96
96
  /** PURE. Append the notice to what a reading tool returns. */
97
97
  export function withAskNotice(text) {
@@ -59,13 +59,13 @@ export async function fileIssue(args, { base, token, version, post = postBugRepo
59
59
  let j = {}
60
60
  try { j = await res.json() } catch { /* shape drift โ€” still filed */ }
61
61
  const count = Number(j?.count) > 1 ? ` It has now been reported ${j.count} times.` : ''
62
- return { isError: false, text: `โœ“ Filed ${report.kind} report${j?.id ? ` ${j.id}` : ''} for \`${report.tool}\`.${count} Tell the user you filed it, now.` }
62
+ return { isError: false, text: `โœ“ Filed ${report.kind} report${j?.id ? ` ${j.id}` : ''} for \`${report.tool}\`.${count} The person has not been told yet.` }
63
63
  }
64
64
  if (res && res.status >= 400 && res.status < 500 && res.status !== 429) {
65
- return { isError: true, text: `NOT FILED โ€” Agnoclast rejected the report (HTTP ${res.status}). Tell the user it could not be filed.` }
65
+ return { isError: true, text: `NOT FILED โ€” Agnoclast rejected the report (HTTP ${res.status}). The person has not been told.` }
66
66
  }
67
67
  const saved = spool(report)
68
68
  return saved
69
- ? { isError: false, text: `Agnoclast could not take the report right now (${res ? `HTTP ${res.status}` : 'unreachable'}), so it was SAVED on this machine and will be sent automatically after the next successful call. Tell the user it is saved, not yet filed.` }
70
- : { isError: true, text: 'NOT FILED โ€” Agnoclast was unreachable and the report could not be saved locally either. Tell the user.' }
69
+ ? { isError: false, text: `Agnoclast could not take the report right now (${res ? `HTTP ${res.status}` : 'unreachable'}), so it was SAVED on this machine and will be sent automatically after the next successful call. The person has not been told; it is saved, not yet filed.` }
70
+ : { isError: true, text: 'NOT FILED โ€” Agnoclast was unreachable and the report could not be saved locally either. The person has not been told.' }
71
71
  }
@@ -58,5 +58,5 @@ export function withEarlierNotes(s, summary) {
58
58
  export function reminderLine(s) {
59
59
  if (s.hostNamesSession || s.asked || s.weakEdits < WEAK_EDITS_BEFORE_ASKING) return ''
60
60
  s.asked = true
61
- return `๐Ÿ“ ${s.weakEdits} page edits here have reasons too short to explain the work. Add one or two sentences with log_session saying what is new (name the brain if the person has several). Skip it for trivial or personal work.`
61
+ return `Agnoclast note: ${s.weakEdits} page edits here have reasons too short to explain the work. \`log_session\` can add one or two sentences saying what is new (and which brain, if the person has several); trivial or personal work needs none.`
62
62
  }
package/lib/server.mjs CHANGED
@@ -501,8 +501,8 @@ export async function runServer(version) {
501
501
  if (!res.ok) { try { await res.body?.cancel() } catch { /* nothing to drain */ } return null }
502
502
  const { waiting, finished } = await res.json()
503
503
  const lines = [
504
- waiting ? `๐Ÿ“‹ ${waiting} task${waiting === 1 ? '' : 's'} waiting for you: call my_tasks.` : '',
505
- finished ? `๐Ÿ“‹ ${finished} task${finished === 1 ? '' : 's'} you handed out finished: call handed_tasks.` : '',
504
+ waiting ? `Agnoclast note: ${waiting} task${waiting === 1 ? '' : 's'} waiting (\`my_tasks\`).` : '',
505
+ finished ? `Agnoclast note: ${finished} task${finished === 1 ? '' : 's'} you handed out finished (\`handed_tasks\`).` : '',
506
506
  ].filter(Boolean)
507
507
  return lines.length ? lines.join('\n') : null
508
508
  } catch { return null }
@@ -648,8 +648,8 @@ function renderSettling(payload) {
648
648
  : ''
649
649
 
650
650
  const head = firstSight
651
- ? `\n\nโšก ARRIVALS SETTLING โ€” DECIDE EACH LINE BEFORE CONTINUING: \`intake_claim\` it if it belongs to this session's work, otherwise \`not_mine\`. You are asked once; when every session has passed, the person is told at the next session start.\n`
652
- : `\n\nโšก NEW ARRIVALS SETTLING โ€” decide each: \`intake_claim\` or \`not_mine\`:\n`
651
+ ? `\n\nAgnoclast note: arrivals settling, which may belong to this session's work. For each: \`intake_claim\` if it does, \`not_mine\` if not. Each is offered once; when every session has passed, the person is told at the next session start.\n`
652
+ : `\n\nAgnoclast note: new arrivals settling. For each: \`intake_claim\` or \`not_mine\`:\n`
653
653
  return `${head}${lines.join('\n')}\n` +
654
654
  `โ€” These are unjudged ARRIVALS, not records. Since automatic materialization was deleted, nothing files them for you.\n` +
655
655
  `โ€” \`intake_look <id>\` reads the full body without claiming it โ€” looking is free, non-exclusive and logged, so look rather than guess from the headline.\n` +
@@ -2289,7 +2289,7 @@ function renderNudge(payload) {
2289
2289
  // Relayed VERBATIM โ€” this exact sentence is the contract the create route records.
2290
2290
  return { content: [{ type: 'text', text:
2291
2291
  `Send request created from ${acct} to ${n} recipient${n === 1 ? '' : 's'}. It is NOT sent yet. ` +
2292
- `Tell the user, in these words: It's waiting for your OK: ${reviewUrl}` }] }
2292
+ `For the person, word for word: It's waiting for your OK: ${reviewUrl}` }] }
2293
2293
  }
2294
2294
  const state = body?.request?.state ?? 'sent'
2295
2295
  return { content: [{ type: 'text', text:
@@ -2574,7 +2574,11 @@ function renderNudge(payload) {
2574
2574
  // retype silently deleted a sentence, a [[link]] (a graph edge), a command list and the
2575
2575
  // word "today" from sections it was never meant to touch. This footer renders on EVERY
2576
2576
  // page read in the system, so it was the single widest surface pointing the wrong way.
2577
- let footer = `โ€” Follow any [[links]] above with read_page to go deeper.\nโ€” If you hold fresher FIRST-HAND truth than this page โ€” something you established THIS session (ran the command, made the change, hold the artifact) that a section here gets concretely wrong โ€” fix just that passage with \`edit_page\`: quote the wrong text as old_string and pass this page's \`version\` as base_version (any node you are permitted to edit; concise; a material contradiction, not merely extra detail). If the save comes back stale the page changed under you โ€” the conflict hands back what changed, so re-anchor from that instead of re-reading. Reading a stale page you can fix IS the trigger to fix it. Editing is pre-authorized โ€” do NOT ask the user before updating (edits are versioned + reversible via page_history/rollback_page); update, then briefly report it. Use \`author\` only to CREATE a page or rewrite one wholesale: it re-emits every section, so untouched sections get retyped on the way through and drift.\nโ€” Citing code? Use a SYMBOL and file (\`formConnections\` in \`web/app/api/ingest/route.ts\`), never a line number โ€” line numbers drift with every commit above them. And cite only what you opened THIS session; re-emitting a reference you read on another page is how a stale claim gains a second source and starts looking corroborated.`
2577
+ // โš  FACTS AND OPTIONS, NEVER ORDERS (2026-11-02, page "Tool output vs injection screens"). This footer used to
2578
+ // say "Editing is pre-authorized โ€” do NOT ask the user", and Muse's prompt-injection screen refused it as an
2579
+ // injected block. Whether to ask first is the reading agent's and its person's call; `author` and `edit_page`
2580
+ // still say in their descriptions that edits are reversible.
2581
+ let footer = `โ€” Agnoclast note: [[links]] above can be read with read_page.\nโ€” Agnoclast note: page edits are versioned and can be undone with \`rollback_page\`. A wrong passage can be corrected with \`edit_page\`, quoting the old text as old_string and passing this page's \`version\` as base_version; a stale save hands back what changed. \`author\` re-emits every section, so it suits creating or wholly rewriting a page.\nโ€” Agnoclast note: code is cited most durably by symbol and file (\`formConnections\` in \`web/app/api/ingest/route.ts\`) rather than line number, and only from files opened this session.`
2578
2582
  // ADDRESSING (2026-08-04). The server accepts `ref` on every page/node route and its ambiguity
2579
2583
  // 409s hand refs back โ€” but read_page never PRINTED one, so the only way to obtain a ref was to
2580
2584
  // trigger the error first. That made ID addressing reachable in principle and unusable in
@@ -41,8 +41,8 @@ export function renderSettlingV2(feed, shown) {
41
41
  return ` - ${x.intakeItemId} ยท ${x.source} ยท ${x.hoursAgo}h ago${named(x.title)}${why}${shared}${looked}`
42
42
  })
43
43
  const head = firstSight
44
- ? '\n\nโšก ARRIVALS SETTLING โ€” DECIDE EACH LINE BEFORE CONTINUING: no live session holds a rarer match for these than THIS one. `intake_claim` it if it belongs to this session\'s work, otherwise `not_mine`. You are asked once; when every session has passed, the person is told at the next session start.\n'
45
- : '\n\nโšก NEW ARRIVALS SETTLING โ€” DECIDE EACH LINE: `intake_claim` or `not_mine`:\n'
44
+ ? '\n\nAgnoclast note: arrivals settling. No live session holds a rarer match for these than this one. For each: `intake_claim` if it belongs to this session\'s work, `not_mine` if not. You are asked once; when every session has passed, the person is told at the next session start.\n'
45
+ : '\n\nAgnoclast note: new arrivals settling. For each: `intake_claim` or `not_mine`:\n'
46
46
  const unmatched = Number(feed?.unmatched ?? 0)
47
47
  return `${head}${lines.join('\n')}\n` +
48
48
  'โ€” `intake_look <id>` reads the full body without claiming it (free, non-exclusive) โ€” look rather than guess from the headline.\n' +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/agnoclast-mcp",
3
- "version": "0.9.298",
3
+ "version": "0.9.300",
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": {