@theronap/agnoclast-mcp 0.9.341 → 0.9.342

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.
@@ -1,7 +1,7 @@
1
1
  import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, unlinkSync } from 'fs'
2
2
  import { homedir } from 'os'
3
3
  import { join } from 'path'
4
- import { fetchCortex, classify, resolveBase, resolveTokenSource } from './diagnose.mjs'
4
+ import { fetchCortex, CONTEXT_TIMEOUT_MS, classify, resolveBase, resolveTokenSource } from './diagnose.mjs'
5
5
  import { repoFullNameFrom } from './capture.mjs'
6
6
  import { compactBlocks } from './session_start_compact.mjs'
7
7
 
@@ -97,7 +97,7 @@ export async function runSnapshotContext() {
97
97
  const repo = repoFullNameFrom(process.cwd())
98
98
  let res
99
99
  try {
100
- res = await fetchCortex(`${base}/api/mcp-context${repo ? `?repo=${encodeURIComponent(repo)}` : ''}`, { headers: { Authorization: `Bearer ${token}` } })
100
+ res = await fetchCortex(`${base}/api/mcp-context${repo ? `?repo=${encodeURIComponent(repo)}` : ''}`, { headers: { Authorization: `Bearer ${token}` }, timeoutMs: CONTEXT_TIMEOUT_MS })
101
101
  } catch (e) {
102
102
  out(`Agnoclast: context snapshot failed — ${e?.message ?? String(e)}`)
103
103
  return 0
package/lib/diagnose.mjs CHANGED
@@ -359,6 +359,12 @@ export const RETRY_AFTER_CAP_MS = 30_000
359
359
  export const RETRY_AFTER_SPREAD_MS = 1_000
360
360
  /** Beyond the first attempt's own timeout, how long retries may add (default overall budget). */
361
361
  export const DEFAULT_RETRY_BUDGET_MS = 30_000
362
+ /** Per-attempt timeout for the FULL session-start context (/api/mcp-context), longer than the 15 s default.
363
+ * 2026-11-12: production served that endpoint at 9–41 s an hour (median), so a 15 s attempt gave up on
364
+ * answers that were on their way, and the retry started the same slow work again. The server-side fix
365
+ * (per-person caches in mcp_context.ts) is the real cure; this stops the client throwing away a start
366
+ * that would have finished. Only the two full-context fetches use it. */
367
+ export const CONTEXT_TIMEOUT_MS = 40_000
362
368
 
363
369
  const CONNECT_ERROR_CODES = new Set([
364
370
  // node / undici — carried on err.cause.code (an AggregateError carries it too, when happy-eyeballs
@@ -11,7 +11,7 @@
11
11
  // That is safe because hiding a tool is a courtesy, and every gated route checks its own flag on the server.
12
12
 
13
13
  /** Tools any release flag gates — hidden when the server cannot be asked. Mirror of allGatedTools(). */
14
- export const GATED_FALLBACK = ['arrivals', 'attach_document', 'document_diff', 'download_file', 'end_demo', 'export_page', 'file_arrival', 'file_document', 'find_documents', 'finish_task', 'get_document', 'hand_task', 'handed_tasks', 'hold_task', 'import_document_as_page', 'intake_shadow', 'list_documents', 'log_work', 'merge_pages', 'my_messages', 'my_tasks', 'pin_document', 'place_split_records', 'read_conversation', 'read_document', 'relink_links', 'send_message', 'set_manager', 'set_working_hours', 'split_page', 'split_records', 'start_demo', 'store_file', 'tasks_waiting', 'undo_merge', 'undo_relink', 'undo_split', 'upload_document_version', 'work_log']
14
+ export const GATED_FALLBACK = ['arrivals', 'attach_document', 'checkpoint', 'document_diff', 'download_file', 'end_demo', 'export_page', 'file_arrival', 'file_document', 'find_documents', 'finish_task', 'get_document', 'hand_task', 'handed_tasks', 'hold_task', 'import_document_as_page', 'intake_shadow', 'list_documents', 'log_work', 'merge_pages', 'my_messages', 'my_tasks', 'pin_document', 'place_split_records', 'read_conversation', 'read_document', 'relink_links', 'send_message', 'set_manager', 'set_working_hours', 'split_page', 'split_records', 'start_demo', 'store_file', 'tasks_waiting', 'undo_merge', 'undo_relink', 'undo_split', 'upload_document_version', 'work_log']
15
15
 
16
16
  export const RELEASE_FETCH_TIMEOUT_MS = 2500
17
17
  /** A remembered answer older than this is not trusted: a week covers a quiet weekend without hiding tools for long. */
package/lib/server.mjs CHANGED
@@ -7,7 +7,7 @@ import { homedir } from 'os'
7
7
  import { join } from 'path'
8
8
  import { createHash, randomUUID } from 'crypto'
9
9
  import { seatChargeRefusal, seatChargeQuestion } from './seat_charge.mjs'
10
- import { fetchCortex, classify, resolveBase, resolveEnvToken, setSessionKey, setAiAccount, setClientVersion, runWithTool, heartbeatPolicy, nextPingFailures, clockMark, sleptBetween, internetReachable } from './diagnose.mjs'
10
+ import { fetchCortex, CONTEXT_TIMEOUT_MS, classify, resolveBase, resolveEnvToken, setSessionKey, setAiAccount, setClientVersion, runWithTool, heartbeatPolicy, nextPingFailures, clockMark, sleptBetween, internetReachable } from './diagnose.mjs'
11
11
  import { REPORT_KINDS, REPORT_ISSUE_DESCRIPTION, fileIssue } from './report_issue.mjs'
12
12
  import { folderClaimLine } from './folder_claims.mjs'
13
13
  import { renderFolderClaimOffers, renderIdentifierResolution, renderUnroutedPathStamps } from './identifier_routes.mjs'
@@ -450,7 +450,7 @@ export async function runServer(version) {
450
450
  // fetchCortex retries transient infra/5xx; classify turns a failure into an honest message
451
451
  // (token vs infra-block vs network) instead of a bare "Agnoclast API 403: unknown".
452
452
  const url = `${BASE}/api/mcp-context${repo ? `?repo=${encodeURIComponent(repo)}` : ''}`
453
- const res = await fetchCortex(url, { headers: { Authorization: `Bearer ${TOKEN}` } })
453
+ const res = await fetchCortex(url, { headers: { Authorization: `Bearer ${TOKEN}` }, timeoutMs: CONTEXT_TIMEOUT_MS })
454
454
  if (!res.ok) {
455
455
  const body = await res.text()
456
456
  throw new Error(classify(res.status, res.headers.get('content-type'), body, res.headers.get('x-vercel-id')).message)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/agnoclast-mcp",
3
- "version": "0.9.341",
3
+ "version": "0.9.342",
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": {