@theronap/agnoclast-mcp 0.9.340 → 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'
@@ -47,7 +47,7 @@ import {
47
47
  UPDATE_EVENT_DESCRIPTION, UPDATE_SERIES_DESCRIPTION, renderEventCancelled, renderSeriesRevised, seriesPatchBody,
48
48
  } from './calendar_events.mjs'
49
49
  import { formatFoundDocuments } from './found_documents.mjs'
50
- import { renderWorkLog } from './work_log_render.mjs'
50
+ import { renderLogWorkResult, renderWorkLog } from './work_log_render.mjs'
51
51
  import { fileSealedCapture } from './file_sealed_capture.mjs'
52
52
 
53
53
  // PAGE tiers (ADR-0071). Six for a PAGE; a RECORD keeps three (`privacy` on log_session and
@@ -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)
@@ -2280,7 +2280,7 @@ function renderNudge(payload) {
2280
2280
  text: z.string().min(1).describe('the message body, as plain text'),
2281
2281
  cc: z.array(z.string()).optional().describe('cc addresses'),
2282
2282
  bcc: z.array(z.string()).optional().describe('bcc addresses'),
2283
- replyToRecordId: z.string().optional().describe('reply in the thread of this Agnoclast email record'),
2283
+ replyToRecordId: z.string().optional().describe('the Agnoclast email record you are answering. ALWAYS pass it (or replyToMessageId) when replying to someone\'s email, so the answer stays in their thread; without it they get a new, unconnected email'),
2284
2284
  replyToMessageId: z.string().optional().describe('reply in the thread of this message id (Gmail or Outlook)'),
2285
2285
  account: z.string().email().optional().describe('which connected mailbox (Gmail or Outlook) to send from, when the user has more than one'),
2286
2286
  from: z.enum(['own', 'overseer']).optional().describe("AI member agents only: 'own' (default) = your own address; 'overseer' = the mailbox an overseer opened to you"),
@@ -6634,7 +6634,8 @@ function renderNudge(payload) {
6634
6634
  const d = classify(res.status, res.headers.get('content-type'), await res.text(), res.headers.get('x-vercel-id'))
6635
6635
  return toolError(`Could not add to your work log: ${d.message}`)
6636
6636
  }
6637
- return { content: [{ type: 'text', text: 'Added to your work log for today.' }] }
6637
+ const out = await res.json().catch(() => null)
6638
+ return { content: [{ type: 'text', text: renderLogWorkResult(out?.pagesBehind) }] }
6638
6639
  },
6639
6640
  )
6640
6641
 
@@ -1,7 +1,10 @@
1
1
  // Renders GET /api/me/work-log for the `work_log` tool. Mirrors renderWorkLog in web/lib/engine/agent_work_log.ts
2
2
  // (the hosted connector's copy), which this package cannot import.
3
3
  const TZ = 'America/Denver'
4
- const KIND_WORD = { edit: 'edited', placement: 'filed', discard: 'discarded an arrival from' }
4
+ const KIND_WORD = { edit: 'edited', placement: 'filed', discard: 'discarded an arrival from', send: 'emailed' }
5
+
6
+ const PAGE_DEBT_HOW = 'A work-log line does not catch a page up. Read each one and fold in what the newer records change with edit_page. '
7
+ + 'If they change nothing on a page, name that page in log_work\'s `pages` and say so in the line; that clears it.'
5
8
 
6
9
  const time = (iso) => new Date(iso).toLocaleTimeString('en-US', { timeZone: TZ, hour: 'numeric', minute: '2-digit' })
7
10
  const stub = (a) => `${KIND_WORD[a.kind] ?? a.kind} ${a.what ? `"${a.what}"` : 'an item'}${a.reason ? ` (${a.reason})` : ''}`
@@ -20,7 +23,7 @@ export function renderWorkLog(log) {
20
23
  if (behind.length) {
21
24
  out.push('', `Agnoclast pages: ${behind.length} page${behind.length === 1 ? '' : 's'} you work on ${behind.length === 1 ? 'has' : 'have'} records newer than the page itself:`,
22
25
  ...behind.slice(0, 20).map((p) => `- "${p.title}": ${p.newer} record${p.newer === 1 ? '' : 's'} filed on it since its last edit (edit_page base_version ${p.version ?? '(read_page for it)'})`),
23
- 'Fold in what they change with edit_page, and say so in your log_work line.')
26
+ PAGE_DEBT_HOW)
24
27
  }
25
28
  if (uncovered.length) {
26
29
  out.push('', `Not yet covered by a line (${uncovered.length}):`,
@@ -29,3 +32,12 @@ export function renderWorkLog(log) {
29
32
  }
30
33
  return out.join('\n')
31
34
  }
35
+
36
+ /** What log_work answers (mirrors renderLogWorkResult): the line is saved, and any page still behind is named. */
37
+ export function renderLogWorkResult(pagesBehind) {
38
+ if (!pagesBehind?.length) return 'Added to your work log for today.'
39
+ const shown = pagesBehind.slice(0, 5).map((p) =>
40
+ ` - "${p.title}": ${p.newer} record${p.newer === 1 ? '' : 's'} filed on it since its last edit (edit_page base_version ${p.version ?? '(read_page for it)'})`).join('\n')
41
+ const more = pagesBehind.length > 5 ? `\n - …and ${pagesBehind.length - 5} more` : ''
42
+ return `Added to your work log for today. It did not catch these pages up:\n\n${shown}${more}\n${PAGE_DEBT_HOW}`
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/agnoclast-mcp",
3
- "version": "0.9.340",
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": {