@theronap/cortex-mcp 0.9.129 → 0.9.130
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/diagnose.mjs +14 -4
- package/lib/server.mjs +45 -0
- package/package.json +1 -1
package/lib/diagnose.mjs
CHANGED
|
@@ -119,8 +119,18 @@ export function wiredDistTag() {
|
|
|
119
119
|
return null
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
// The production
|
|
123
|
-
|
|
122
|
+
// The canonical production host — exempt from Vercel Deployment Protection.
|
|
123
|
+
//
|
|
124
|
+
// ⚠ cortex-console.vercel.app IS STILL A LIVE ALIAS AND MUST STAY IN THE EXEMPT SET BELOW. It was
|
|
125
|
+
// the canonical host until agnoclast.com; installed clients, frozen generated scripts and hook
|
|
126
|
+
// commands on machines nobody can reach still send it. Removing it from the set would make
|
|
127
|
+
// resolveBase() treat a WORKING production alias as a protected deployment URL and silently redirect
|
|
128
|
+
// those clients — the exact failure this function exists to prevent, caused by the fix for it.
|
|
129
|
+
export const CANONICAL_BASE = 'https://agnoclast.com'
|
|
130
|
+
|
|
131
|
+
// Production aliases: real hosts that serve the app and are exempt from Deployment Protection, as
|
|
132
|
+
// opposed to per-deployment URLs (cortex-console-<hash>-<team>.vercel.app) which are NOT.
|
|
133
|
+
const PRODUCTION_ALIASES = new Set(['agnoclast.com', 'cortex-console.vercel.app'])
|
|
124
134
|
|
|
125
135
|
// Resolve the API base from CORTEX_URL. A Vercel *deployment* URL
|
|
126
136
|
// (cortex-console-<hash>-<team>.vercel.app, or any non-canonical *.vercel.app) is guarded by
|
|
@@ -134,7 +144,7 @@ export function resolveBase(rawUrl) {
|
|
|
134
144
|
if (!raw) return CANONICAL_BASE
|
|
135
145
|
let host
|
|
136
146
|
try { host = new URL(raw).host } catch { return CANONICAL_BASE }
|
|
137
|
-
if (host.endsWith('.vercel.app') && host
|
|
147
|
+
if (host.endsWith('.vercel.app') && !PRODUCTION_ALIASES.has(host)) {
|
|
138
148
|
process.stderr.write(
|
|
139
149
|
`cortex: CORTEX_URL (${raw}) is a protected Vercel deployment URL; using ${CANONICAL_BASE} instead.\n`,
|
|
140
150
|
)
|
|
@@ -317,7 +327,7 @@ export async function checkToken(token, base) {
|
|
|
317
327
|
message: `Token "${String(token).slice(0, 8)}…" is not a valid Agnoclast token (expected a UUID). ` +
|
|
318
328
|
`Re-run setup with the token from the console.` } }
|
|
319
329
|
}
|
|
320
|
-
const url = `${(base ??
|
|
330
|
+
const url = `${(base ?? CANONICAL_BASE).replace(/\/$/, '')}/api/mcp-context`
|
|
321
331
|
let res
|
|
322
332
|
try {
|
|
323
333
|
res = await fetchCortex(url, { headers: { Authorization: `Bearer ${token}` } })
|
package/lib/server.mjs
CHANGED
|
@@ -2167,6 +2167,51 @@ function renderNudge(payload) {
|
|
|
2167
2167
|
},
|
|
2168
2168
|
)
|
|
2169
2169
|
|
|
2170
|
+
server.registerTool(
|
|
2171
|
+
'capture_record',
|
|
2172
|
+
{
|
|
2173
|
+
title: 'Hand something over and get it into the brain',
|
|
2174
|
+
description: "Put a document, transcript, notes or any pasted content into the brain as a real record, routed to where it belongs. USE THIS WHEN THERE IS NO CONNECTOR — a lecture recording, an export from a tool nobody has wired up, something a person just handed you. ⚠ `identifiers` IS HOW IT REACHES A PAGE: a record routes to whatever page CLAIMS an identifier it carries (series:… for a class or recurring meeting, repo:owner/name, project:slug, email:someone@example.com). WITHOUT ONE IT REACHES NO PAGE — that is not an error, but it means nobody will find it, so say so rather than reporting success. `occurred_at` is WHEN THE THING HAPPENED, not now: a transcript handed over today may belong to yesterday's class, and filing it under today puts it in the wrong interval invisibly. `container_record_id` additionally places it INSIDE a specific event (a class session, a meeting) — that is an explicit human decision and is recorded as one; overlap alone never places anything.",
|
|
2175
|
+
inputSchema: {
|
|
2176
|
+
title: z.string().describe('a short name for this record'),
|
|
2177
|
+
content: z.string().describe('the actual content — transcript, notes, document text. Summarized server-side.'),
|
|
2178
|
+
occurred_at: z.string().describe('when the thing HAPPENED, ISO 8601 — not when you are uploading it'),
|
|
2179
|
+
ends_at: z.string().optional().describe('when it ended, ISO 8601. Omit if unknown; NEVER guess one.'),
|
|
2180
|
+
identifiers: z.array(z.string()).optional().describe('routing identifiers — how it reaches a page. e.g. ["series:geol-100-001-f2026"]'),
|
|
2181
|
+
container_record_id: z.string().optional().describe('put it INSIDE this event (the record id of a class session or meeting that has a container)'),
|
|
2182
|
+
summary: z.string().optional().describe('your own summary; if given, the content is stored but not sent for summarization'),
|
|
2183
|
+
source: z.string().optional().describe("where it came from, for provenance — e.g. 'granola', 'learning-suite'. Default 'handoff'."),
|
|
2184
|
+
brain: z.string().optional().describe('which brain, by name or org id. REQUIRED if you belong to more than one — placing a record IS a disclosure decision.'),
|
|
2185
|
+
},
|
|
2186
|
+
},
|
|
2187
|
+
async ({ title, content, occurred_at, ends_at, identifiers, container_record_id, summary, source, brain }) => {
|
|
2188
|
+
let res
|
|
2189
|
+
try {
|
|
2190
|
+
res = await fetchCortex(`${BASE}/api/records/capture`, {
|
|
2191
|
+
method: 'POST',
|
|
2192
|
+
headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
|
|
2193
|
+
body: JSON.stringify({
|
|
2194
|
+
title, content, occurredAt: occurred_at, endsAt: ends_at, identifiers,
|
|
2195
|
+
containerRecordId: container_record_id, summary, source, brain,
|
|
2196
|
+
}),
|
|
2197
|
+
})
|
|
2198
|
+
} catch (e) {
|
|
2199
|
+
return toolError(`Could not reach Agnoclast to capture "${title}": ${e.message}`)
|
|
2200
|
+
}
|
|
2201
|
+
const body = await res.json().catch(() => ({}))
|
|
2202
|
+
if (!res.ok || !body?.ok) {
|
|
2203
|
+
return toolError(`Could not capture "${title}": ${body?.error ?? res.status}${body?.detail ? ` — ${body.detail}` : ''}`)
|
|
2204
|
+
}
|
|
2205
|
+
const lines = [`Captured "${title}" as record ${body.id}.`]
|
|
2206
|
+
// ⚠ AN UNROUTED RECORD IS REPORTED AS SUCH. It was stored, but nothing will find it — reporting
|
|
2207
|
+
// that as a plain success is how a record becomes invisible while looking filed.
|
|
2208
|
+
if (body.routed_by?.length) lines.push(`Routes via: ${body.routed_by.join(', ')} — it reaches whatever page claims those.`)
|
|
2209
|
+
else lines.push('⚠ NO IDENTIFIERS — this record reaches no page. Nobody will find it unless you give it one (identifiers) or attach it by hand.')
|
|
2210
|
+
if (body.contained) lines.push('Placed inside the container you named.')
|
|
2211
|
+
return { content: [{ type: 'text', text: lines.join('\n') }] }
|
|
2212
|
+
},
|
|
2213
|
+
)
|
|
2214
|
+
|
|
2170
2215
|
server.registerTool(
|
|
2171
2216
|
'capture_meeting',
|
|
2172
2217
|
{
|
package/package.json
CHANGED