@theronap/agnoclast-mcp 0.9.283 → 0.9.284
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/publish_targets.mjs +12 -4
- package/lib/rolling_log.mjs +62 -0
- package/lib/server.mjs +22 -2
- package/lib/session_key.mjs +3 -1
- package/package.json +1 -1
package/lib/publish_targets.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// The names this package is published under, and how to derive each variant's package.json.
|
|
2
2
|
//
|
|
3
|
-
// ⚠ SUPERSEDED by ADR-0102 (2026-10-29): `cortex-mcp` is
|
|
4
|
-
//
|
|
3
|
+
// ⚠ SUPERSEDED by ADR-0102 (2026-10-29): `cortex-mcp` is RETIRED (see RETIRED_TARGETS). 0.9.283 was its last
|
|
4
|
+
// release; that build rewrites every machine to the new name on start. The rest of this note is the ADR-0033 §3
|
|
5
|
+
// history, kept because VARIANT_FIELDS and the bin rule still govern any future second name.
|
|
5
6
|
//
|
|
6
7
|
// ADR-0033 §3. Phase B publishes the SAME build under two names: `@theronap/agnoclast-mcp` going
|
|
7
8
|
// forward, and `@theronap/cortex-mcp` in perpetuity, because the old name is hardcoded in hook
|
|
@@ -21,10 +22,17 @@
|
|
|
21
22
|
/** The fields that may legitimately differ between variants. Anything else differing is a bug. */
|
|
22
23
|
export const VARIANT_FIELDS = ['name', 'bin']
|
|
23
24
|
|
|
24
|
-
/** Publish targets, primary first.
|
|
25
|
+
/** Publish targets, primary first. */
|
|
25
26
|
export const PUBLISH_TARGETS = [
|
|
26
27
|
{ name: '@theronap/agnoclast-mcp', bin: 'agnoclast-mcp', role: 'primary' },
|
|
27
|
-
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
/** Names this package USED to publish under, and the last version each received. Never publish to these
|
|
31
|
+
* again: a retired name's @stable/@latest are frozen on a build that moves the machine to the new name
|
|
32
|
+
* (ADR-0102), and a newer release there would be one nobody can migrate away from. Deprecated, never
|
|
33
|
+
* unpublished, so anything pinned to them still installs. */
|
|
34
|
+
export const RETIRED_TARGETS = [
|
|
35
|
+
{ name: '@theronap/cortex-mcp', bin: 'cortex-mcp', lastVersion: '0.9.283', retired: '2026-10-29', adr: 'ADR-0102' },
|
|
28
36
|
]
|
|
29
37
|
|
|
30
38
|
/** The entry point every variant's bin points at. One file, many names. */
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// THE SESSION LOG, for an AI outside Claude Code. Pure — see rolling_log.test.mjs.
|
|
2
|
+
//
|
|
3
|
+
// Most AI hosts have no session-end event, so a log written "at close" never happens (Theron, 2026-10-31). The
|
|
4
|
+
// server writes the log itself from the reasons on the session's page edits (web/lib/engine/session_work_log.ts),
|
|
5
|
+
// which costs no model call. An extra turn is the real cost of asking an AI for a log, because that turn re-reads
|
|
6
|
+
// its whole context ("I'm worried about costs, speed, and efficiency"). So this asks only when the reasons leave a
|
|
7
|
+
// gap, at most once per stretch of work, and never in Claude Code, where the capture hook logs the session.
|
|
8
|
+
// The ask rides on a tool result: the one channel every host shares.
|
|
9
|
+
//
|
|
10
|
+
// ⚠ NOT IN THE CLAUDE.AI CONNECTOR. Anthropic's directory policy forbids a connector that stores conversation
|
|
11
|
+
// history (web/lib/mcp/tools.ts), so this lives only here. See ADR-0106.
|
|
12
|
+
|
|
13
|
+
const IDLE_NEW_SESSION_MS = 4 * 60 * 60 * 1000
|
|
14
|
+
const WEAK_EDITS_BEFORE_ASKING = 2
|
|
15
|
+
const WEAK_REASON_CHARS = 15
|
|
16
|
+
const MAX_NOTES_CHARS = 8000
|
|
17
|
+
|
|
18
|
+
const PAGE_EDIT_TOOLS = new Set(['author', 'edit_page', 'merge_sections', 'rename_page', 'rename_section'])
|
|
19
|
+
|
|
20
|
+
export function newRollingLog(baseKey, hostNamesSession) {
|
|
21
|
+
return { baseKey, hostNamesSession, generation: 0, sessionId: baseKey, lastCallAt: null, weakEdits: 0, asked: false, notes: [] }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Called before each tool runs. A long-lived agent's process outlives its work, so a long silence starts a new
|
|
26
|
+
* session; otherwise one record would keep being replaced for weeks. Returns the new id when it rotated.
|
|
27
|
+
*/
|
|
28
|
+
export function rotateIfIdle(s, now) {
|
|
29
|
+
const idle = s.lastCallAt !== null && now - s.lastCallAt >= IDLE_NEW_SESSION_MS
|
|
30
|
+
s.lastCallAt = now
|
|
31
|
+
if (!idle || s.hostNamesSession) return null
|
|
32
|
+
s.generation += 1
|
|
33
|
+
s.sessionId = `${s.baseKey}-${s.generation}`
|
|
34
|
+
s.weakEdits = 0
|
|
35
|
+
s.asked = false
|
|
36
|
+
s.notes = []
|
|
37
|
+
return s.sessionId
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A page edit whose reason says too little for the server to build a log from. */
|
|
41
|
+
export function noteWork(s, tool, args) {
|
|
42
|
+
if (!PAGE_EDIT_TOOLS.has(tool)) return
|
|
43
|
+
if (String(args?.reason ?? '').trim().length < WEAK_REASON_CHARS) s.weakEdits += 1
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function noteLogged(s, summary) {
|
|
47
|
+
s.weakEdits = 0
|
|
48
|
+
if (!s.hostNamesSession && summary) s.notes.push(summary)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** An AI sends only what is new, so a log costs the same on the tenth call as on the first. */
|
|
52
|
+
export function withEarlierNotes(s, summary) {
|
|
53
|
+
if (s.hostNamesSession) return summary
|
|
54
|
+
return [...s.notes, summary].join('\n\n').slice(-MAX_NOTES_CHARS)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The line to add to this tool result, or ''. */
|
|
58
|
+
export function reminderLine(s) {
|
|
59
|
+
if (s.hostNamesSession || s.asked || s.weakEdits < WEAK_EDITS_BEFORE_ASKING) return ''
|
|
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.`
|
|
62
|
+
}
|
package/lib/server.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { folderClaimLine } from './folder_claims.mjs'
|
|
|
12
12
|
import { renderFolderClaimOffers, renderIdentifierResolution, renderUnroutedPathStamps } from './identifier_routes.mjs'
|
|
13
13
|
import { renderDeclines, renderFolderDecisionsApplied, renderFolderQuestions } from './folder_decisions.mjs'
|
|
14
14
|
import { resolveSessionKey, resolveLogSessionId } from './session_key.mjs'
|
|
15
|
+
import { newRollingLog, rotateIfIdle, noteWork, noteLogged, reminderLine, withEarlierNotes } from './rolling_log.mjs'
|
|
15
16
|
import { aiAccountOf, confidentialBrainNamed, fetchMyConfidential, gatherAgentProof, lockStateLine, lockedNotFoundNote, markLockedIn, requestSeatToken } from './confidential_session.mjs'
|
|
16
17
|
import { runSendImessage } from './imessage_send.mjs'
|
|
17
18
|
import { formatGrepHits } from './grep_cli.mjs'
|
|
@@ -291,6 +292,7 @@ export async function runServer(version) {
|
|
|
291
292
|
// resolve THIS session's brain pointer. Must be set BEFORE the first fetchCortex call below —
|
|
292
293
|
// otherwise the opening requests of a session would silently resolve by the account pointer.
|
|
293
294
|
setSessionKey(SESSION_KEY)
|
|
295
|
+
const rolling = newRollingLog(SESSION_KEY, !!process.env.CLAUDE_CODE_SESSION_ID)
|
|
294
296
|
|
|
295
297
|
// ── CONFIDENTIAL BRAINS: THE FIRST-TOUCH LOCK (Theron, 2026-10-28) ─────────────────────────────────────────
|
|
296
298
|
// Only for a person who holds a confidential seat; for everyone else `confidential.brains` is empty and nothing
|
|
@@ -511,7 +513,20 @@ export async function runServer(version) {
|
|
|
511
513
|
const check = await lockedAnswerFor(BASE, TOKEN, name, takesArgs ? args[0] : {}, fetchCortex)
|
|
512
514
|
if (!check.run) return { content: [{ type: 'text', text: check.text }] }
|
|
513
515
|
}
|
|
516
|
+
const startedAt = Date.now()
|
|
517
|
+
const rotated = rotateIfIdle(rolling, startedAt)
|
|
518
|
+
// The header stamps page revisions, so a new id here keeps a log joined to the pages it wrote.
|
|
519
|
+
if (rotated) setSessionKey(rotated)
|
|
514
520
|
const result = await handler(...args)
|
|
521
|
+
if (!result?.isError) {
|
|
522
|
+
if (name === 'log_session') {
|
|
523
|
+
if (result?.content?.[0]?.text?.startsWith('Logged')) noteLogged(rolling, takesArgs ? args[0]?.summary : null)
|
|
524
|
+
} else {
|
|
525
|
+
noteWork(rolling, name, takesArgs ? args[0] : null)
|
|
526
|
+
const remind = !lockedInto && reminderLine(rolling)
|
|
527
|
+
if (remind && Array.isArray(result?.content)) result.content = [...result.content, { type: 'text', text: remind }]
|
|
528
|
+
}
|
|
529
|
+
}
|
|
515
530
|
// Locked in: every result says so (Theron, 2026-10-28), so an AI never mistakes which state the session is in.
|
|
516
531
|
if (lockedInto && Array.isArray(result?.content)) {
|
|
517
532
|
const text = result.content.map((c) => (c?.type === 'text' ? c.text : '')).join('\n')
|
|
@@ -719,7 +734,7 @@ function renderNudge(payload) {
|
|
|
719
734
|
'log_session',
|
|
720
735
|
{
|
|
721
736
|
title: 'Log this session to Agnoclast',
|
|
722
|
-
description: 'Persist a CURATED summary of this work session as its durable Agnoclast record (authoritative — supersedes the auto-capture hook). Call at session close
|
|
737
|
+
description: 'Persist a CURATED summary of this work session as its durable Agnoclast record (authoritative — supersedes the auto-capture hook). Call after meaningful work and at session close: each call replaces the earlier log for this session. Outside Claude Code, send only what is new: earlier notes are kept for you. `sessionId` now defaults to this session automatically (from CLAUDE_CODE_SESSION_ID) so the log dedupes with the auto-capture of the same session — pass it explicitly only to log on behalf of a DIFFERENT session, e.g. recovering one whose own close-out failed. If you belong to more than one brain you MUST name one — without a brain a session log has no route and is STAGED rather than recorded. **If the session touched work belonging to different brains, pass `segments` instead of `summary` and split it** — one segment per brain, each summary standing on its own and never alluding to the others. Reports every segment individually; a partial result is reported as PARTIAL, never as success.',
|
|
723
738
|
inputSchema: {
|
|
724
739
|
summary: z.string().optional().describe('the curated session summary — the single-brain form. Omit when passing `segments`'),
|
|
725
740
|
segments: z.array(z.object({
|
|
@@ -761,7 +776,12 @@ function renderNudge(payload) {
|
|
|
761
776
|
// confident-looking join that is silently wrong. A missing id is honest; an invented one is not.
|
|
762
777
|
// Hosts that do not set the var keep today's timestamp behaviour. Negative-controlled in
|
|
763
778
|
// session_key.test.mjs.
|
|
764
|
-
|
|
779
|
+
//
|
|
780
|
+
// ⚠ A host with no conversation id logs under this process's rolling id. That is not the invented value
|
|
781
|
+
// warned about above: every write this process made carries it as x-cortex-session-key, so it joins to
|
|
782
|
+
// the pages those writes touched. See rolling_log.mjs.
|
|
783
|
+
sessionId = resolveLogSessionId(sessionId, process.env) ?? rolling.sessionId
|
|
784
|
+
if (summary) summary = withEarlierNotes(rolling, summary)
|
|
765
785
|
// A session is a container of TIME, not a topic (ADR-0029 step 4). Normalize to a list of
|
|
766
786
|
// segments; the single-brain call is just a one-segment list.
|
|
767
787
|
const list = Array.isArray(segments) && segments.length
|
package/lib/session_key.mjs
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
// with no session_write_pointers row of its own. Any other MCP host that doesn't set the var gets
|
|
10
10
|
// today's unchanged per-process-random behavior.
|
|
11
11
|
export function resolveSessionKey(env, randomUUID) {
|
|
12
|
-
|
|
12
|
+
// The `agent-` prefix is how the server knows no capture hook will log this session, so it writes the
|
|
13
|
+
// log itself from the session's page edits (lib/engine/session_work_log.ts).
|
|
14
|
+
return env.CLAUDE_CODE_SESSION_ID || `agent-${randomUUID()}`
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
// Which session id a `log_session` call should RECORD. Pure — see session_key.test.mjs.
|
package/package.json
CHANGED