@theronap/agnoclast-mcp 0.9.267 → 0.9.269
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 +60 -0
- package/package.json +1 -1
package/lib/release_gate.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// that web/lib/engine/release.test.ts pins to the server's registry.
|
|
6
6
|
|
|
7
7
|
/** Tools any release flag gates — hidden when the server cannot be asked. Mirror of allGatedTools(). */
|
|
8
|
-
export const GATED_FALLBACK = ['attach_document', 'document_diff', 'get_document', 'intake_shadow', 'list_documents', 'my_messages', 'pin_document', 'read_conversation', 'read_document', 'send_message', 'set_manager', 'upload_document_version']
|
|
8
|
+
export const GATED_FALLBACK = ['attach_document', 'document_diff', 'export_page', 'get_document', 'import_document_as_page', 'intake_shadow', 'list_documents', 'my_messages', 'pin_document', 'read_conversation', 'read_document', 'send_message', 'set_manager', 'upload_document_version']
|
|
9
9
|
|
|
10
10
|
export const RELEASE_FETCH_TIMEOUT_MS = 2500
|
|
11
11
|
|
package/lib/server.mjs
CHANGED
|
@@ -7416,6 +7416,66 @@ function renderNudge(payload) {
|
|
|
7416
7416
|
},
|
|
7417
7417
|
)
|
|
7418
7418
|
|
|
7419
|
+
// TEXT-FIRST TEST, slice A (2026-10-26): a page rendered as a styled Word doc, in its brain's style.
|
|
7420
|
+
server.registerTool(
|
|
7421
|
+
'export_page',
|
|
7422
|
+
{
|
|
7423
|
+
title: 'Export a page as a styled Word document',
|
|
7424
|
+
description: 'Render a wiki page as a .docx in its brain\'s document style (set by the brain\'s owner or admins in the console) and save it to ~/Downloads/cortex/. Use it when someone needs to SEND or print a page: the page stays the master; the Word file is a copy of it. For PDF, the person uses Export ▸ PDF on the page in Agnoclast.',
|
|
7425
|
+
inputSchema: {
|
|
7426
|
+
page: z.string().describe('the page: its exact title, its `ref:` from read_page, or a document id'),
|
|
7427
|
+
tier: z.string().optional().describe('which copy of a two-copy page (e.g. "scoped"); default the most recently written'),
|
|
7428
|
+
},
|
|
7429
|
+
},
|
|
7430
|
+
async ({ page, tier }) => {
|
|
7431
|
+
const q = new URLSearchParams({ page })
|
|
7432
|
+
if (tier) q.set('tier', tier)
|
|
7433
|
+
let res
|
|
7434
|
+
try { res = await fetchCortex(`${BASE}/api/brain/page/export?${q}`, { headers: { Authorization: `Bearer ${TOKEN}` } }) }
|
|
7435
|
+
catch (e) { return toolError(`Could not export: ${e.message}`) }
|
|
7436
|
+
if (!res.ok) return docFail('export the page', res)
|
|
7437
|
+
const buf = Buffer.from(await res.arrayBuffer())
|
|
7438
|
+
const m = /filename="([^"]+)"/.exec(res.headers.get('content-disposition') ?? '')
|
|
7439
|
+
const name = (m ? m[1] : 'page.docx').replace(/[^\w.\- ]/g, '_')
|
|
7440
|
+
const dir = join(homedir(), 'Downloads', 'cortex')
|
|
7441
|
+
mkdirSync(dir, { recursive: true })
|
|
7442
|
+
const path = join(dir, name)
|
|
7443
|
+
writeFileSync(path, buf)
|
|
7444
|
+
return { content: [{ type: 'text', text: `Saved "${page}" as a styled Word document: ${path} (${Math.round(buf.length / 1024)} KB).` }] }
|
|
7445
|
+
},
|
|
7446
|
+
)
|
|
7447
|
+
|
|
7448
|
+
// TEXT-FIRST TEST, slice B (2026-10-26): a stored Word document becomes a page; the .docx moves onto it, pinned.
|
|
7449
|
+
server.registerTool(
|
|
7450
|
+
'import_document_as_page',
|
|
7451
|
+
{
|
|
7452
|
+
title: 'Turn a stored Word document into a page',
|
|
7453
|
+
description: 'Convert a stored .docx into an editable wiki page — headings become sections, lists/tables/bold/links survive, images are left out (the original keeps them). The new page is created at the same visibility as the file\'s current page, the .docx moves onto it pinned as the original, and the old page gets one line linking to it. Needs edit access to the file\'s page. After this the PAGE is the master: edit the page, and export it with export_page when someone needs a Word copy.',
|
|
7454
|
+
inputSchema: {
|
|
7455
|
+
file_id: z.string().describe('the stored file\'s id (from list_documents or read_page\'s 📌/📎 lines)'),
|
|
7456
|
+
title: z.string().optional().describe('the new page\'s name; default the file\'s title'),
|
|
7457
|
+
},
|
|
7458
|
+
},
|
|
7459
|
+
async ({ file_id, title }) => {
|
|
7460
|
+
let res
|
|
7461
|
+
try {
|
|
7462
|
+
res = await fetchCortex(`${BASE}/api/stored-files/${encodeURIComponent(file_id)}/import-page`, {
|
|
7463
|
+
method: 'POST', headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
|
|
7464
|
+
body: JSON.stringify(title ? { title } : {}),
|
|
7465
|
+
})
|
|
7466
|
+
} catch (e) { return toolError(`Could not import: ${e.message}`) }
|
|
7467
|
+
if (!res.ok) return docFail('import the document', res)
|
|
7468
|
+
const o = await res.json()
|
|
7469
|
+
const lines = [`Made the page "${o.title}" (ref ${o.ref}, ${o.tier}) with ${o.sections} section${o.sections === 1 ? '' : 's'}; the .docx is pinned on it as the original.`]
|
|
7470
|
+
if (o.images) lines.push(`${o.images} image${o.images === 1 ? ' was' : 's were'} left out — the original file keeps ${o.images === 1 ? 'it' : 'them'}.`)
|
|
7471
|
+
if (o.shortenedHeadings) lines.push(`${o.shortenedHeadings} heading${o.shortenedHeadings === 1 ? ' was' : 's were'} over 80 characters and shortened.`)
|
|
7472
|
+
if (o.splitSections) lines.push(`${o.splitSections} very long section${o.splitSections === 1 ? ' was' : 's were'} split into parts.`)
|
|
7473
|
+
lines.push(o.linkedFromOldPage ? 'The old page now links to it.' : 'The old page could not be given a link line; add one with edit_page if it matters.')
|
|
7474
|
+
lines.push(`Read it with read_page "${o.title}".`)
|
|
7475
|
+
return { content: [{ type: 'text', text: lines.join('\n') }] }
|
|
7476
|
+
},
|
|
7477
|
+
)
|
|
7478
|
+
|
|
7419
7479
|
// UPLOADS (slice 4). The server refuses an assistant unless the person turned on "Let assistants upload
|
|
7420
7480
|
// files" in Agnoclast → Settings — a switch only the console can flip. These tools never ask for it.
|
|
7421
7481
|
// Bytes go straight to storage on the signed URL the server hands out, then the server reads them back.
|
package/package.json
CHANGED