@theronap/agnoclast-mcp 0.9.329 → 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.
- package/lib/record_render.mjs +1 -1
- package/lib/release_gate.mjs +1 -1
- package/lib/server.mjs +102 -7
- package/lib/work_log_render.mjs +25 -0
- package/package.json +1 -1
package/lib/record_render.mjs
CHANGED
|
@@ -22,7 +22,7 @@ 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,
|
|
25
|
+
// An agent's text conversation, kept word for word as a session (web/lib/engine/agent_conversation_log.ts).
|
|
26
26
|
'agent-chat': 'Agent conversation',
|
|
27
27
|
}
|
|
28
28
|
|
package/lib/release_gate.mjs
CHANGED
|
@@ -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)
|
|
@@ -2411,12 +2436,14 @@ function renderNudge(payload) {
|
|
|
2411
2436
|
history: z.boolean().optional().describe('node names only: return the node\'s TIMELINE (events joined via its [[repo:…]] stamps, reverse-chron, viewer-visible) instead of the page body. The page is the present; this is the history.'),
|
|
2412
2437
|
version: z.string().optional().describe('read a HISTORICAL version of this page instead of the current one: a rev_no (e.g. "3") or a content_hash from page_history. Use page_history first to see the versions, then rollback_page to restore one.'),
|
|
2413
2438
|
ref: z.string().optional().describe('the page\'s ref (read_page prints it as `ref:`). Addresses exactly one page, so use it when a name exists in more than one brain — history and version reads refuse an ambiguous name and list the refs to choose from.'),
|
|
2439
|
+
brain: z.string().optional().describe('a brain name from my_brains: read only THAT brain\'s page when the same name exists in several brains. Naming a 🔒 confidential brain also locks this session to it.'),
|
|
2414
2440
|
},
|
|
2415
2441
|
},
|
|
2416
|
-
async ({ name, kind, expand, history, version, ref }) => {
|
|
2442
|
+
async ({ name, kind, expand, history, version, ref, brain }) => {
|
|
2417
2443
|
const k = kind ?? 'project'
|
|
2418
|
-
// A ref addresses exactly one page; a name can match one page in each of several brains.
|
|
2419
|
-
|
|
2444
|
+
// A ref addresses exactly one page; a name can match one page in each of several brains. `brain`
|
|
2445
|
+
// narrows to one brain's copy (dry-run bug 4: before 0.9.x it only ever opened confidential brains).
|
|
2446
|
+
const address = (extra = {}) => new URLSearchParams({ ...(ref ? { ref } : { kind: k, key: name }), ...(brain ? { brain } : {}), ...extra })
|
|
2420
2447
|
// PAGE HISTORY (Part A): a specific version reads one historical body, resolved within this page's
|
|
2421
2448
|
// own history. Not for identifier-shaped names (those are join keys, handled below).
|
|
2422
2449
|
if (version && !/^[a-z][a-z0-9_-]*:.+/i.test(name)) {
|
|
@@ -2521,6 +2548,7 @@ function renderNudge(payload) {
|
|
|
2521
2548
|
} catch (e) {
|
|
2522
2549
|
return toolError(`Could not read "${name}": ${e.message}`)
|
|
2523
2550
|
}
|
|
2551
|
+
if (res.status === 400 && brain) return { content: [{ type: 'text', text: `"${brain}" is not one of your brains. my_brains lists them.` }] }
|
|
2524
2552
|
if (res.status === 404) {
|
|
2525
2553
|
return { content: [{ type: 'text', text: `No ${k} page named "${name}". If it's a person or team, pass kind (person/org).${await redLinkTriage(BASE, TOKEN, name)}` }] }
|
|
2526
2554
|
}
|
|
@@ -2538,6 +2566,9 @@ function renderNudge(payload) {
|
|
|
2538
2566
|
if (!matches.length && page?.authored && Array.isArray(page.tiers) && page.tiers.length) {
|
|
2539
2567
|
matches = [{ brain: null, authored: true, ref: page.ref, title: page.title, tiers: page.tiers }]
|
|
2540
2568
|
}
|
|
2569
|
+
if (!matches.length && brain) {
|
|
2570
|
+
return { content: [{ type: 'text', text: `No authored page named "${name}" in the brain "${brain}". Leave out \`brain\` to search every brain you belong to.` }] }
|
|
2571
|
+
}
|
|
2541
2572
|
if (!matches.length) {
|
|
2542
2573
|
// ⚠ This used to say: `No authored ${k} page named "X" ... If it's a person or team, pass
|
|
2543
2574
|
// kind (person/org).` Both halves misled. resolveNodeByTitle matches EVERY kind and uses the
|
|
@@ -2644,7 +2675,7 @@ function renderNudge(payload) {
|
|
|
2644
2675
|
if (matches.length === 1) {
|
|
2645
2676
|
return { content: [{ type: 'text', text: renderMatch(matches[0], false) + nudgeBlock }] }
|
|
2646
2677
|
}
|
|
2647
|
-
const header = `"${name}" is authored in ${matches.length} of your brains — all shown (each tagged with its brain, newest tier first)
|
|
2678
|
+
const header = `"${name}" is authored in ${matches.length} of your brains — all shown (each tagged with its brain, newest tier first). They are DIFFERENT pages: to read or change one, pass its \`ref\` (or \`brain\`).`
|
|
2648
2679
|
return { content: [{ type: 'text', text: [header, ...matches.map((m) => renderMatch(m, true))].join('\n\n═══════════════════\n\n') + nudgeBlock }] }
|
|
2649
2680
|
},
|
|
2650
2681
|
)
|
|
@@ -2658,18 +2689,30 @@ function renderNudge(payload) {
|
|
|
2658
2689
|
name: z.string().describe('the canonical node name exactly as written (e.g. "Agnoclast", "Ben")'),
|
|
2659
2690
|
kind: z.enum(['project', 'person', 'org', 'user']).optional().describe('node kind (default project)'),
|
|
2660
2691
|
limit: z.number().int().optional().describe('how many recent versions to show (default 20, max 200)'),
|
|
2692
|
+
ref: z.string().optional().describe('the page\'s ref (read_page prints it as `ref:`). Addresses exactly one page — use it when the name exists in more than one brain.'),
|
|
2693
|
+
brain: z.string().optional().describe('a brain name from my_brains: that brain\'s page, when the same name exists in several brains'),
|
|
2661
2694
|
},
|
|
2662
2695
|
},
|
|
2663
|
-
async ({ name, kind, limit }) => {
|
|
2696
|
+
async ({ name, kind, limit, ref, brain }) => {
|
|
2664
2697
|
const k = kind ?? 'project'
|
|
2665
2698
|
let res
|
|
2666
2699
|
try {
|
|
2667
|
-
|
|
2700
|
+
// Dry-run bug 4 (2026-11-07): this sent only the name, so for a name in several brains the server
|
|
2701
|
+
// picked one — the Hermes lane asked for its results page and got the Grok lane's history.
|
|
2702
|
+
const qs = new URLSearchParams({ kind: k, key: name, ...(ref ? { ref } : {}), ...(brain ? { brain } : {}), ...(limit ? { limit: String(limit) } : {}) })
|
|
2668
2703
|
res = await fetchCortex(`${BASE}/api/brain/page-history?${qs}`, { headers: { Authorization: `Bearer ${TOKEN}` } })
|
|
2669
2704
|
} catch (e) {
|
|
2670
2705
|
return toolError(`Could not read history for "${name}": ${e.message}`)
|
|
2671
2706
|
}
|
|
2672
|
-
if (res.status ===
|
|
2707
|
+
if (res.status === 409) {
|
|
2708
|
+
const body = await res.json().catch(() => null)
|
|
2709
|
+
const c = Array.isArray(body?.candidates) ? body.candidates : []
|
|
2710
|
+
return { content: [{ type: 'text', text: c.length
|
|
2711
|
+
? [`"${name}" names a page in ${c.length} of your brains, and one history list can only be one page's — call page_history again with the ref of the one you mean:`, ...c.map((m) => ` - in ${m.brain} — ref: ${m.ref}`)].join('\n')
|
|
2712
|
+
: await ambiguousPageHint(BASE, TOKEN, k, name) }] }
|
|
2713
|
+
}
|
|
2714
|
+
if (res.status === 400 && brain) return { content: [{ type: 'text', text: `"${brain}" is not one of your brains. my_brains lists them.` }] }
|
|
2715
|
+
if (res.status === 404) return { content: [{ type: 'text', text: brain ? `No ${k} "${name}" in the brain "${brain}".` : `No ${k} named "${name}". Pass kind (person/org) if it isn't a project.` }] }
|
|
2673
2716
|
if (!res.ok) {
|
|
2674
2717
|
const d = classify(res.status, res.headers.get('content-type'), await res.text(), res.headers.get('x-vercel-id'))
|
|
2675
2718
|
return toolError(`Could not read history for "${name}": ${d.message}`)
|
|
@@ -6537,6 +6580,58 @@ function renderNudge(payload) {
|
|
|
6537
6580
|
},
|
|
6538
6581
|
)
|
|
6539
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
|
+
|
|
6540
6635
|
server.registerTool(
|
|
6541
6636
|
'token_activity',
|
|
6542
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