@theronap/agnoclast-mcp 0.9.327 → 0.9.329
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 +2 -2
- package/lib/diagnose.mjs +4 -1
- package/lib/edge_extract.mjs +5 -1
- package/lib/extract_typed.mjs +2 -1
- package/lib/log_agent.mjs +11 -0
- package/lib/obligation_review.mjs +2 -1
- package/lib/record_render.mjs +11 -1
- package/lib/server.mjs +5 -1
- package/package.json +1 -1
package/lib/closeout.mjs
CHANGED
|
@@ -260,7 +260,7 @@ function llmOnce(prompt, model, system, env) {
|
|
|
260
260
|
return new Promise((resolve) => {
|
|
261
261
|
const args = ['-p', '--no-session-persistence', '--model', model, '--max-budget-usd', LLM_BUDGET_USD, '--output-format', 'json', '--tools', '', '--strict-mcp-config', ...(system ? ['--system-prompt', system] : [])]
|
|
262
262
|
// CORTEX_SUMMARIZING: the capture hook's own recursion guard, so this run is never captured as a session.
|
|
263
|
-
const child = spawn('claude', args, { cwd: tmpdir(), env: edgeSafeEnv(env, { CORTEX_SUMMARIZING: '1' }), stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true })
|
|
263
|
+
const child = spawn('claude', args, { cwd: tmpdir(), env: edgeSafeEnv(env, { CORTEX_SUMMARIZING: '1', CORTEX_CLIENT_ROLE: 'closeout' }), stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true })
|
|
264
264
|
let stdout = ''
|
|
265
265
|
child.stdout.on('data', (b) => { stdout += b })
|
|
266
266
|
child.stderr.on('data', () => {})
|
|
@@ -294,7 +294,7 @@ export function llmExplore(prompt, sessionId, env = process.env) {
|
|
|
294
294
|
writeFileSync(config, JSON.stringify({ mcpServers: { agnoclast: { command: process.execPath, args: [READER_BIN, sessionId] } } }))
|
|
295
295
|
const args = ['-p', '--no-session-persistence', '--model', 'sonnet', '--max-budget-usd', EXPLORE_BUDGET_USD, '--output-format', 'json', '--tools', '', '--mcp-config', config, '--strict-mcp-config', '--allowedTools', 'mcp__agnoclast__grep,mcp__agnoclast__read_page']
|
|
296
296
|
return new Promise((resolve) => {
|
|
297
|
-
const child = spawn('claude', args, { cwd: dir, env: edgeSafeEnv(env, { CORTEX_SUMMARIZING: '1' }), stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true })
|
|
297
|
+
const child = spawn('claude', args, { cwd: dir, env: edgeSafeEnv(env, { CORTEX_SUMMARIZING: '1', CORTEX_CLIENT_ROLE: 'closeout' }), stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true })
|
|
298
298
|
let stdout = ''
|
|
299
299
|
child.stdout.on('data', (b) => { stdout += b })
|
|
300
300
|
child.stderr.on('data', () => {})
|
package/lib/diagnose.mjs
CHANGED
|
@@ -306,7 +306,10 @@ let CLIENT_VERSION = null
|
|
|
306
306
|
// The background close-out (closeout.mjs) runs this same server AS the closed session, so its calls carry that
|
|
307
307
|
// session's key on purpose (its log attaches there). It says what it is in the client instead: `+closeout`, a semver
|
|
308
308
|
// build suffix, so every `^cortex-mcp/x.y.z` reader still parses it, and /ops leaves it out of people's usage.
|
|
309
|
-
|
|
309
|
+
// Any other process started under CORTEX_SUMMARIZING (a headless summarizer run that still loaded MCP servers: an
|
|
310
|
+
// older build, or a host we do not control) says `+summarizer`, which /ops treats the same way.
|
|
311
|
+
export const closeoutClientSuffix = (env = process.env) =>
|
|
312
|
+
env.CORTEX_CLIENT_ROLE === 'closeout' ? '+closeout' : env.CORTEX_SUMMARIZING ? '+summarizer' : ''
|
|
310
313
|
export function setClientVersion(version) {
|
|
311
314
|
CLIENT_ID = `cortex-mcp/${version || 'unknown'}${closeoutClientSuffix()}`
|
|
312
315
|
CLIENT_VERSION = version || null
|
package/lib/edge_extract.mjs
CHANGED
|
@@ -495,7 +495,11 @@ export function extractSession(transcript, opts = {}) {
|
|
|
495
495
|
// broken for the user. `claude --print` reads its prompt from stdin; verified live 2026-09-10.
|
|
496
496
|
const r = spawnSync(
|
|
497
497
|
'claude',
|
|
498
|
-
|
|
498
|
+
// --strict-mcp-config + --no-session-persistence: this headless run needs no MCP server and is not a session.
|
|
499
|
+
// Without them every run started a full Agnoclast MCP server, whose start-up calls /ops counted as a new
|
|
500
|
+
// one-call session (one per turn, ~1,100 a day for one person, 2026-11-07), and the run was saved as a
|
|
501
|
+
// conversation of its own.
|
|
502
|
+
['--print', '--strict-mcp-config', '--no-session-persistence', '--model', process.env.CORTEX_SUMMARY_MODEL ?? 'claude-haiku-4-5'],
|
|
499
503
|
{ input: prompt, env: edgeSafeEnv(process.env, { CORTEX_SUMMARIZING: '1' }), encoding: 'utf8', timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024, windowsHide: true },
|
|
500
504
|
)
|
|
501
505
|
const why = classifyEdgeFailure(r, timeoutMs)
|
package/lib/extract_typed.mjs
CHANGED
|
@@ -41,7 +41,8 @@ export function extractTyped(transcript, registry, opts = {}) {
|
|
|
41
41
|
try {
|
|
42
42
|
const r = spawnSync(
|
|
43
43
|
'claude',
|
|
44
|
-
|
|
44
|
+
// No MCP servers and no saved session: see edge_extract.mjs.
|
|
45
|
+
['--print', '--strict-mcp-config', '--no-session-persistence', '--model', opts.model ?? process.env.CORTEX_SUMMARY_MODEL ?? 'claude-haiku-4-5', prompt],
|
|
45
46
|
{ env: edgeSafeEnv(process.env, { CORTEX_SUMMARIZING: '1' }), encoding: 'utf8', timeout: 120_000, maxBuffer: 8 * 1024 * 1024, windowsHide: true },
|
|
46
47
|
)
|
|
47
48
|
if (r.status !== 0 || !r.stdout) return null
|
|
@@ -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
|
+
}
|
|
@@ -137,7 +137,8 @@ export function applyReview(cands, decisions) {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
function runClaude(prompt, model) {
|
|
140
|
-
|
|
140
|
+
// No MCP servers and no saved session: see edge_extract.mjs.
|
|
141
|
+
return spawnSync('claude', ['--print', '--strict-mcp-config', '--no-session-persistence', '--model', model], {
|
|
141
142
|
input: prompt,
|
|
142
143
|
// CORTEX_SUMMARIZING: the reviewer's own `claude` session must not re-enter the capture hooks.
|
|
143
144
|
env: edgeSafeEnv(process.env, { CORTEX_SUMMARIZING: '1' }),
|
package/lib/record_render.mjs
CHANGED
|
@@ -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, summarised into 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(`${
|
|
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
|
-
|
|
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) {
|
package/package.json
CHANGED