@theronap/agnoclast-mcp 0.9.330 → 0.9.331

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.
@@ -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', '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', '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', 'store_file', 'tasks_waiting', 'undo_merge', 'undo_relink', 'undo_split', 'upload_document_version']
14
+ export const GATED_FALLBACK = ['arrivals', 'attach_document', 'document_diff', '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', '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
@@ -47,6 +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
51
  import { fileSealedCapture } from './file_sealed_capture.mjs'
51
52
 
52
53
  // PAGE tiers (ADR-0071). Six for a PAGE; a RECORD keeps three (`privacy` on log_session and
@@ -509,6 +510,28 @@ export async function runServer(version) {
509
510
  return lines.length ? lines.join('\n') : null
510
511
  } catch { return null }
511
512
  }
513
+ // The daily work log (web/lib/engine/agent_work_log.ts; design page "Upkeep without Claude Code (design)" v3):
514
+ // changes this agent made that no log_work line covers, once they have waited. The server decides and throttles
515
+ // (one nudge per agent per window); here we only ask, on a process's first result and then at most every five
516
+ // minutes. Not inside Claude Code, whose hooks and close-out already log its sessions.
517
+ let workLogLookedAt = 0
518
+ const workLogNudge = async (name) => {
519
+ if (process.env.CLAUDE_CODE_SESSION_ID || name === 'log_work' || name === 'work_log') return null
520
+ const now = Date.now()
521
+ if (workLogLookedAt && now - workLogLookedAt < 300_000) return null
522
+ workLogLookedAt = now
523
+ try {
524
+ if (!toolHandles.has('log_work')) return null // behind a release flag this caller's brains lack
525
+ const res = await Promise.race([
526
+ fetchCortex(`${BASE}/api/me/work-log?nudge=1`, { headers: { Authorization: `Bearer ${TOKEN}` } }),
527
+ new Promise((resolve) => setTimeout(resolve, 2000, null).unref()),
528
+ ])
529
+ if (!res) return null
530
+ if (!res.ok) { try { await res.body?.cancel() } catch { /* nothing to drain */ } return null }
531
+ const { nudge } = await res.json()
532
+ return typeof nudge === 'string' && nudge ? nudge : null
533
+ } catch { return null }
534
+ }
512
535
  // ADR-0070: every tool runs with its NAME in async context, so an outage fetchCortex auto-files is
513
536
  // attributed to the tool that hit it rather than guessed from a URL shared by several tools.
514
537
  const registerTool = server.registerTool.bind(server)
@@ -547,6 +570,8 @@ export async function runServer(version) {
547
570
  const result = await handler(...args)
548
571
  const taskLine = name === 'my_tasks' || name === 'handed_tasks' || name === 'tasks_waiting' ? null : await taskNotice()
549
572
  if (taskLine && Array.isArray(result?.content)) result.content = [...result.content, { type: 'text', text: taskLine }]
573
+ const workLine = result?.isError ? null : await workLogNudge(name)
574
+ if (workLine && Array.isArray(result?.content)) result.content = [...result.content, { type: 'text', text: workLine }]
550
575
  if (!result?.isError) {
551
576
  if (name === 'log_session') {
552
577
  if (result?.content?.[0]?.text?.startsWith('Logged')) noteLogged(rolling, takesArgs ? args[0]?.summary : null)
@@ -6555,6 +6580,58 @@ function renderNudge(payload) {
6555
6580
  },
6556
6581
  )
6557
6582
 
6583
+ server.registerTool(
6584
+ 'log_work',
6585
+ {
6586
+ title: 'Add a line to my work log',
6587
+ description: 'Add ONE short line to YOUR daily work log saying what you just did and why, right after you do it, e.g. "answered 38 routine refund emails from the FAQ page" or "escalated the Ortiz insurance claim to Theron; updated Refund log". One line may cover many actions, so write it at each natural stopping point, not per call. Name the wiki pages you changed in `pages`. A summary of the work, never a transcript of the conversation. Agnoclast shows the changes you have made that no line covers yet, in work_log and as a note on your results.',
6588
+ inputSchema: {
6589
+ line: z.string().describe('what you did and why, in one sentence'),
6590
+ pages: z.array(z.string()).optional().describe('titles of the wiki pages this work changed'),
6591
+ asked: z.string().optional().describe('what the person asked for, in a few words, if this came from a request'),
6592
+ },
6593
+ },
6594
+ async ({ line, pages, asked }) => {
6595
+ let res
6596
+ try {
6597
+ res = await fetchCortex(`${BASE}/api/me/work-log`, {
6598
+ method: 'POST',
6599
+ headers: { Authorization: `Bearer ${TOKEN}`, 'content-type': 'application/json' },
6600
+ body: JSON.stringify({ line, pages, asked }),
6601
+ })
6602
+ } catch (e) {
6603
+ return toolError(`Could not add to your work log: ${e.message}`)
6604
+ }
6605
+ if (res.status === 400) return toolError('log_work needs a non-empty `line`, and an agent token (console sessions have none).')
6606
+ if (!res.ok) {
6607
+ const d = classify(res.status, res.headers.get('content-type'), await res.text(), res.headers.get('x-vercel-id'))
6608
+ return toolError(`Could not add to your work log: ${d.message}`)
6609
+ }
6610
+ return { content: [{ type: 'text', text: 'Added to your work log for today.' }] }
6611
+ },
6612
+ )
6613
+
6614
+ server.registerTool(
6615
+ 'work_log',
6616
+ {
6617
+ title: 'My work log today',
6618
+ description: 'Read YOUR OWN work log for today: the lines you wrote with log_work, then the changes you made (page edits, filings, discards) that no line covers yet. Use it to answer "what have you done today?", or before you stop, to cover anything left with one log_work line.',
6619
+ },
6620
+ async () => {
6621
+ let res
6622
+ try {
6623
+ res = await fetchCortex(`${BASE}/api/me/work-log`, { headers: { Authorization: `Bearer ${TOKEN}` } })
6624
+ } catch (e) {
6625
+ return toolError(`Could not read your work log: ${e.message}`)
6626
+ }
6627
+ if (!res.ok) {
6628
+ const d = classify(res.status, res.headers.get('content-type'), await res.text(), res.headers.get('x-vercel-id'))
6629
+ return toolError(`Could not read your work log: ${d.message}`)
6630
+ }
6631
+ return { content: [{ type: 'text', text: renderWorkLog(await res.json()) }] }
6632
+ },
6633
+ )
6634
+
6558
6635
  server.registerTool(
6559
6636
  'token_activity',
6560
6637
  {
@@ -0,0 +1,25 @@
1
+ // Renders GET /api/me/work-log for the `work_log` tool. Mirrors renderWorkLog in web/lib/engine/agent_work_log.ts
2
+ // (the hosted connector's copy), which this package cannot import.
3
+ const TZ = 'America/Denver'
4
+ const KIND_WORD = { edit: 'edited', placement: 'filed', discard: 'discarded an arrival from' }
5
+
6
+ const time = (iso) => new Date(iso).toLocaleTimeString('en-US', { timeZone: TZ, hour: 'numeric', minute: '2-digit' })
7
+ const stub = (a) => `${KIND_WORD[a.kind] ?? a.kind} ${a.what ? `"${a.what}"` : 'an item'}${a.reason ? ` (${a.reason})` : ''}`
8
+
9
+ export function renderWorkLog(log) {
10
+ const who = log?.agent?.label ?? 'this connection'
11
+ const lines = log?.lines ?? []
12
+ const uncovered = log?.uncovered ?? []
13
+ const out = [
14
+ `Work log for ${who}, ${log?.day ?? 'today'} (${TZ}):`,
15
+ lines.length
16
+ ? lines.map((l) => `- ${time(l.at)} ${l.line}${l.pages?.length ? ` [pages: ${l.pages.join(', ')}]` : ''}`).join('\n')
17
+ : '(no lines yet today)',
18
+ ]
19
+ if (uncovered.length) {
20
+ out.push('', `Not yet covered by a line (${uncovered.length}):`,
21
+ ...uncovered.slice(0, 20).map((a) => `- ${time(a.at)} ${stub(a)}`),
22
+ 'Cover them with log_work.')
23
+ }
24
+ return out.join('\n')
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/agnoclast-mcp",
3
- "version": "0.9.330",
3
+ "version": "0.9.331",
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": {