@theronap/agnoclast-mcp 0.9.320 → 0.9.321
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/release_gate.mjs +1 -1
- package/lib/server.mjs +58 -1
- package/lib/split_render.mjs +34 -0
- package/package.json +1 -1
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', 'my_messages', 'my_tasks', 'pin_document', 'place_split_records', 'read_conversation', 'read_document', 'send_message', 'set_manager', 'set_working_hours', 'split_page', 'split_records', 'store_file', 'tasks_waiting', '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', 'merge_pages', 'my_messages', 'my_tasks', 'pin_document', 'place_split_records', 'read_conversation', 'read_document', 'send_message', 'set_manager', 'set_working_hours', 'split_page', 'split_records', 'store_file', 'tasks_waiting', 'undo_merge', 'undo_split', 'upload_document_version']
|
|
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
|
@@ -36,7 +36,7 @@ import { formatSeriesRefusal, formatSeriesUpdated } from './series_render.mjs'
|
|
|
36
36
|
import { formatSends } from './sends_render.mjs'
|
|
37
37
|
import { applyLock, fetchLockState, lockedAnswerFor, lockStateWithin } from './locked_tools.mjs'
|
|
38
38
|
import { applyRelease, fetchReleaseState, releaseStateWithin, rememberReleaseState, rememberedReleaseState } from './release_gate.mjs'
|
|
39
|
-
import { renderPlacement, renderSplitRefusal, renderUndo, renderWorklist } from './split_render.mjs'
|
|
39
|
+
import { renderMerge, renderMergeUndo, renderPlacement, renderSplitRefusal, renderUndo, renderWorklist } from './split_render.mjs'
|
|
40
40
|
import { filterUnshownSettling, renderSettlingV2 } from './settling_shown.mjs'
|
|
41
41
|
import { renderContactBriefing, renderContactCandidates, renderContactList } from './contacts_render.mjs'
|
|
42
42
|
import { renderConversation, renderMessageInbox } from './messages_render.mjs'
|
|
@@ -3057,6 +3057,63 @@ function renderNudge(payload) {
|
|
|
3057
3057
|
},
|
|
3058
3058
|
)
|
|
3059
3059
|
|
|
3060
|
+
server.registerTool(
|
|
3061
|
+
'merge_pages',
|
|
3062
|
+
{
|
|
3063
|
+
title: 'Merge one topic page into another',
|
|
3064
|
+
description: 'Fold one topic page (the SOURCE) into another (the TARGET), in ONE transaction. Preview first (mode:\'preview\', writes nothing), then apply the plan it returns (mode:\'apply\', plan). What a merge does: the source\'s sections are appended to the target WORD FOR WORD, each under "Merged from <source> — <heading>", keeping their dates (condense the overlap afterwards with merge_sections or edit_page); EVERY record on the source is attached to the target too and the target becomes the governing page of the records the source governed — nothing needs reading, a merge has one destination; the source\'s routing claims move to the target; the source is retired (superseded by the target, never deleted), so links to its title read as superseded. Refused at preview: a person page (use request_person_page_merge), pages in different brains, a page you do not own, and pages with a different tier or different grants — a merge must not change who can read anything, so align them first. undo_merge reverses all of it while neither page has changed.',
|
|
3065
|
+
inputSchema: {
|
|
3066
|
+
source_version: z.string().describe('the `version` read_page prints for the page being folded in (it is retired)'),
|
|
3067
|
+
target_version: z.string().describe('the `version` read_page prints for the page that survives'),
|
|
3068
|
+
mode: z.enum(['preview', 'apply']).describe("'preview' first; then 'apply' with the plan it returned"),
|
|
3069
|
+
plan: z.string().optional().describe('the plan token a preview returned (apply only)'),
|
|
3070
|
+
reason: z.string().describe('why, in one phrase — recorded in page_history on both pages'),
|
|
3071
|
+
},
|
|
3072
|
+
},
|
|
3073
|
+
async ({ source_version, target_version, mode, plan, reason }) => {
|
|
3074
|
+
let res
|
|
3075
|
+
try {
|
|
3076
|
+
res = await fetchCortex(`${BASE}/api/brain/merge-pages`, {
|
|
3077
|
+
method: 'POST',
|
|
3078
|
+
headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
|
|
3079
|
+
body: JSON.stringify({ source_version, target_version, mode, reason, ...(plan ? { plan } : {}) }),
|
|
3080
|
+
})
|
|
3081
|
+
} catch (e) {
|
|
3082
|
+
return toolError(`Could not merge the pages: ${e.message}`)
|
|
3083
|
+
}
|
|
3084
|
+
const out = await res.json().catch(() => null)
|
|
3085
|
+
if (!res.ok || !out?.ok) return toolError(renderSplitRefusal('merge the pages', out, res.status))
|
|
3086
|
+
return { content: [{ type: 'text', text: renderMerge(out) }] }
|
|
3087
|
+
},
|
|
3088
|
+
)
|
|
3089
|
+
|
|
3090
|
+
server.registerTool(
|
|
3091
|
+
'undo_merge',
|
|
3092
|
+
{
|
|
3093
|
+
title: 'Undo a page merge',
|
|
3094
|
+
description: 'Undo a page merge you applied, in ONE transaction: the appended sections come off the target, the source page is current again, governance and routing claims go back to it, and the record attachments the merge added are removed. Refused when either page changed after the merge. Only the member who applied it, and only once.',
|
|
3095
|
+
inputSchema: {
|
|
3096
|
+
plan: z.string().describe('the `plan` token of the applied merge'),
|
|
3097
|
+
reason: z.string().optional().describe('why, in one phrase — recorded in page_history'),
|
|
3098
|
+
},
|
|
3099
|
+
},
|
|
3100
|
+
async ({ plan, reason }) => {
|
|
3101
|
+
let res
|
|
3102
|
+
try {
|
|
3103
|
+
res = await fetchCortex(`${BASE}/api/brain/merge-undo`, {
|
|
3104
|
+
method: 'POST',
|
|
3105
|
+
headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
|
|
3106
|
+
body: JSON.stringify({ plan, ...(reason ? { reason } : {}) }),
|
|
3107
|
+
})
|
|
3108
|
+
} catch (e) {
|
|
3109
|
+
return toolError(`Could not undo the merge: ${e.message}`)
|
|
3110
|
+
}
|
|
3111
|
+
const out = await res.json().catch(() => null)
|
|
3112
|
+
if (!res.ok || !out?.ok) return toolError(renderSplitRefusal('undo the merge', out, res.status))
|
|
3113
|
+
return { content: [{ type: 'text', text: renderMergeUndo(out) }] }
|
|
3114
|
+
},
|
|
3115
|
+
)
|
|
3116
|
+
|
|
3060
3117
|
server.registerTool(
|
|
3061
3118
|
'snooze_routing_claim',
|
|
3062
3119
|
{
|
package/lib/split_render.mjs
CHANGED
|
@@ -86,3 +86,37 @@ export function renderSplitRefusal(what, out, status) {
|
|
|
86
86
|
const detail = Array.isArray(out?.detail) && out.detail.length ? `\n${out.detail.map((d) => `· ${d}`).join('\n')}` : ''
|
|
87
87
|
return `Could not ${what}: ${out?.error ?? status}${out?.message ? ` — ${out.message}` : ''}${detail}${out?.hint ? `\n${out.hint}` : ''}`
|
|
88
88
|
}
|
|
89
|
+
|
|
90
|
+
// ── Page merge (ADR-0036 phase 3) ──────────────────────────────────────────────────────────────────
|
|
91
|
+
|
|
92
|
+
export function renderMerge(out) {
|
|
93
|
+
const lines = []
|
|
94
|
+
const verb = out.preview ? 'PREVIEW — nothing written' : out.replayed ? 'already applied (this is its first result)' : 'APPLIED'
|
|
95
|
+
lines.push(`Merge "${out.source}" → "${out.target}" (${out.brain}, ${out.tier}) — ${verb}.`)
|
|
96
|
+
lines.push(`Text: ${out.appendedHeadings.length} section(s) appended to "${out.target}" word for word, each under "Merged from ${out.source} — …", with their own dates.`)
|
|
97
|
+
if (out.preview) {
|
|
98
|
+
lines.push(`Records: all ${out.records} on "${out.source}" will also attach to "${out.target}"${out.governed ? `; "${out.target}" becomes the governing page of ${out.governed}` : ''}. No reading needed — a merge has one destination.`)
|
|
99
|
+
lines.push(`Routing claims moving to "${out.target}": ${out.claims.length ? out.claims.join(', ') : 'none'}.`)
|
|
100
|
+
lines.push(`"${out.source}" will be retired (superseded by "${out.target}", never deleted); links to it read as superseded.`)
|
|
101
|
+
lines.push(`Audience unchanged: same tier, same ${out.grants} grant(s).`)
|
|
102
|
+
lines.push(`plan: ${out.plan}`)
|
|
103
|
+
lines.push(`Next: merge_pages with mode:'apply' and plan:'${out.plan}'. Afterwards, condense overlapping sections with merge_sections.`)
|
|
104
|
+
} else {
|
|
105
|
+
lines.push(`Records newly attached to "${out.target}": ${out.records}${out.recordsAlreadyOnTarget ? ` (${out.recordsAlreadyOnTarget} were already there)` : ''}; governance moved: ${out.governed}.`)
|
|
106
|
+
lines.push(`Routing claims moved: ${out.claims.length ? out.claims.join(', ') : 'none'}.`)
|
|
107
|
+
lines.push(`"${out.source}" is retired, superseded by "${out.target}".`)
|
|
108
|
+
lines.push(`"${out.target}" is now version ${out.targetVersion}.`)
|
|
109
|
+
lines.push(`plan: ${out.plan} — undo_merge with this plan reverses all of it while neither page has changed.`)
|
|
110
|
+
lines.push(`Next: read "${out.target}" and condense the "Merged from" sections into the page with merge_sections or edit_page.`)
|
|
111
|
+
}
|
|
112
|
+
return lines.join('\n')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function renderMergeUndo(out) {
|
|
116
|
+
return [
|
|
117
|
+
`Merge undone (${out.brain}): "${out.source}" is current again; "${out.target}" lost the ${out.sectionsRemoved} appended section(s).`,
|
|
118
|
+
`Record attachments the merge added, removed: ${out.recordsDetached}. Governance returned: ${out.governanceRestored}. Routing claims returned: ${out.claimsRestored}.`,
|
|
119
|
+
...(out.laterTargetRecords ? [`${out.laterTargetRecords} record(s) reached "${out.target}" after the merge and stay there.`] : []),
|
|
120
|
+
`Versions now: "${out.source}" ${out.sourceVersion} · "${out.target}" ${out.targetVersion}.`,
|
|
121
|
+
].join('\n')
|
|
122
|
+
}
|
package/package.json
CHANGED