@theronap/agnoclast-mcp 0.9.326 → 0.9.328

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
@@ -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', () => {})
@@ -499,7 +499,7 @@ const SERVER_BIN = join(dirname(fileURLToPath(import.meta.url)), '..', 'bin', 'c
499
499
  export async function openTools(sessionId, env = process.env, home = homedir()) {
500
500
  const { token } = resolveTokenSource(env, home)
501
501
  if (!token) throw new Error('no Agnoclast token on this machine')
502
- const transport = new StdioClientTransport({ command: process.execPath, args: [SERVER_BIN], env: { ...edgeSafeEnv(env), CORTEX_TOKEN: token, CLAUDE_CODE_SESSION_ID: sessionId, CORTEX_SUMMARIZING: '1' }, stderr: 'ignore' })
502
+ const transport = new StdioClientTransport({ command: process.execPath, args: [SERVER_BIN], env: { ...edgeSafeEnv(env), CORTEX_TOKEN: token, CLAUDE_CODE_SESSION_ID: sessionId, CORTEX_SUMMARIZING: '1', CORTEX_CLIENT_ROLE: 'closeout' }, stderr: 'ignore' })
503
503
  const client = new Client({ name: 'agnoclast-closeout', version: '1' })
504
504
  await client.connect(transport)
505
505
  return {
package/lib/diagnose.mjs CHANGED
@@ -303,8 +303,15 @@ export function setAiAccount(v) { AI_ACCOUNT = v || null }
303
303
  // say so, and be visible as one, not disguise itself as a script.
304
304
  let CLIENT_ID = 'cortex-mcp/unknown'
305
305
  let CLIENT_VERSION = null
306
+ // The background close-out (closeout.mjs) runs this same server AS the closed session, so its calls carry that
307
+ // session's key on purpose (its log attaches there). It says what it is in the client instead: `+closeout`, a semver
308
+ // build suffix, so every `^cortex-mcp/x.y.z` reader still parses it, and /ops leaves it out of people's usage.
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' : ''
306
313
  export function setClientVersion(version) {
307
- CLIENT_ID = `cortex-mcp/${version || 'unknown'}`
314
+ CLIENT_ID = `cortex-mcp/${version || 'unknown'}${closeoutClientSuffix()}`
308
315
  CLIENT_VERSION = version || null
309
316
  }
310
317
  export const clientVersion = () => CLIENT_VERSION
@@ -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
- ['--print', '--model', process.env.CORTEX_SUMMARY_MODEL ?? 'claude-haiku-4-5'],
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)
@@ -41,7 +41,8 @@ export function extractTyped(transcript, registry, opts = {}) {
41
41
  try {
42
42
  const r = spawnSync(
43
43
  'claude',
44
- ['--print', '--model', opts.model ?? process.env.CORTEX_SUMMARY_MODEL ?? 'claude-haiku-4-5', prompt],
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
@@ -137,7 +137,8 @@ export function applyReview(cands, decisions) {
137
137
  }
138
138
 
139
139
  function runClaude(prompt, model) {
140
- return spawnSync('claude', ['--print', '--model', model], {
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/agnoclast-mcp",
3
- "version": "0.9.326",
3
+ "version": "0.9.328",
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": {