@theronap/cortex-mcp 0.9.158 → 0.9.159
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/server.mjs +58 -3
- package/package.json +1 -1
package/lib/server.mjs
CHANGED
|
@@ -264,6 +264,27 @@ export async function runServer(version) {
|
|
|
264
264
|
//
|
|
265
265
|
// The SERVER decides who gets this; it only sends `nudge` to a session holding a matching identifier.
|
|
266
266
|
// No threshold logic here to drift out of sync with it.
|
|
267
|
+
// ADR-0066 §8 — THE DELTA LINE. "Each turn, when something arrived since the last turn: a delta
|
|
268
|
+
// line only; silent when empty."
|
|
269
|
+
//
|
|
270
|
+
// ⚠ ONE LINE, AND NO LIST. The whole point is that it costs almost nothing to read, so it can be
|
|
271
|
+
// shown often without training its reader to skip it. The pile itself is one tool call away and the
|
|
272
|
+
// session-start block already rendered it in full.
|
|
273
|
+
//
|
|
274
|
+
// ⚠ DIFFERENT FROM renderNudge, WHICH SITS DIRECTLY BELOW IT. That block is identifier-matched — the
|
|
275
|
+
// cascade believes those records are THIS session's business, and it names them. This claims nothing
|
|
276
|
+
// about relevance; it says the queue moved. Both can be silent and both can fire.
|
|
277
|
+
//
|
|
278
|
+
// Server-decided, like the nudge: it is silent when the session is muted, on a session's first
|
|
279
|
+
// sight, and when nothing arrived — so there is no threshold logic here to drift out of sync.
|
|
280
|
+
function renderArrival(payload) {
|
|
281
|
+
const a = payload?.arrival
|
|
282
|
+
const n = Number(a?.count ?? 0)
|
|
283
|
+
if (!a || !n) return ''
|
|
284
|
+
return `\n\n⚡ ${n} new arrival${n === 1 ? '' : 's'} in your pile since this session was last told` +
|
|
285
|
+
` — \`staged_records\` lists them. Not offered to you, just counted; \`ignore_arrivals\` if this is noise right now.`
|
|
286
|
+
}
|
|
287
|
+
|
|
267
288
|
function renderNudge(payload) {
|
|
268
289
|
const n = Array.isArray(payload?.nudge) ? payload.nudge : []
|
|
269
290
|
if (!n.length) return ''
|
|
@@ -1368,7 +1389,7 @@ function renderNudge(payload) {
|
|
|
1368
1389
|
throw new Error(classify(res.status, res.headers.get('content-type'), body, res.headers.get('x-vercel-id')).message)
|
|
1369
1390
|
}
|
|
1370
1391
|
const payload = await res.json()
|
|
1371
|
-
return { content: [{ type: 'text', text: formatGrepHits(payload, query) + renderNudge(payload) }] }
|
|
1392
|
+
return { content: [{ type: 'text', text: formatGrepHits(payload, query) + renderArrival(payload) + renderNudge(payload) }] }
|
|
1372
1393
|
},
|
|
1373
1394
|
)
|
|
1374
1395
|
|
|
@@ -1677,7 +1698,7 @@ function renderNudge(payload) {
|
|
|
1677
1698
|
// `k` is stated rather than hidden. "Only you" and "you and two others" call for different
|
|
1678
1699
|
// behaviour, and a nudge that claimed certainty it did not have is how an agent learns to stop
|
|
1679
1700
|
// reading them.
|
|
1680
|
-
const nudgeBlock = renderNudge(page)
|
|
1701
|
+
const nudgeBlock = renderArrival(page) + renderNudge(page)
|
|
1681
1702
|
|
|
1682
1703
|
if (matches.length === 1) {
|
|
1683
1704
|
return { content: [{ type: 'text', text: renderMatch(matches[0], false) + nudgeBlock }] }
|
|
@@ -2750,6 +2771,40 @@ function renderNudge(payload) {
|
|
|
2750
2771
|
},
|
|
2751
2772
|
)
|
|
2752
2773
|
|
|
2774
|
+
server.registerTool(
|
|
2775
|
+
'ignore_arrivals',
|
|
2776
|
+
{
|
|
2777
|
+
title: 'Stop offering me arrivals for the rest of this session',
|
|
2778
|
+
description: 'Silence the ⚡ ARRIVED block for THIS session. Use it when you are mid-task and the offers are noise right now — declining is per record (not_mine) and that is not a usable answer to a list of nine. ⚠ THIS IS NOT A DECISION ABOUT THE RECORDS AND IT IS NOT A SUPPRESSION. Every one of them stays unclaimed, stays on the general timeline, and stays offerable to every other session — including your own other sessions. You are saying "stop telling me, here", never "nobody\'s business", and nothing is marked handled. ⚠ IT IS ALSO NOT not_mine: use that one when you LOOKED and a record is not yours, because that answers "why did nobody take this" and this does not. Reversible any time with resume:true, and it dies with this session — a new session is never born muted.',
|
|
2779
|
+
inputSchema: {
|
|
2780
|
+
reason: z.string().optional().describe('optional — why now ("mid-task", "deep in a build"). Unlike not_mine this does not require one, because no ownership question is being answered'),
|
|
2781
|
+
resume: z.boolean().optional().describe('true to start hearing about arrivals again in this session'),
|
|
2782
|
+
},
|
|
2783
|
+
},
|
|
2784
|
+
async ({ reason, resume }) => {
|
|
2785
|
+
let res
|
|
2786
|
+
try {
|
|
2787
|
+
res = await fetchCortex(`${BASE}/api/nudge/mute`, {
|
|
2788
|
+
method: 'POST',
|
|
2789
|
+
headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
|
|
2790
|
+
body: JSON.stringify({ on: resume === true ? false : true, reason }),
|
|
2791
|
+
})
|
|
2792
|
+
} catch (e) {
|
|
2793
|
+
return toolError(`Could not change arrival notices: ${e.message}`)
|
|
2794
|
+
}
|
|
2795
|
+
const out = await res.json().catch(() => null)
|
|
2796
|
+
if (!res.ok) return toolError(`Could not change arrival notices: ${out?.error ?? res.status}${out?.detail ? `\n${out.detail}` : ''}`)
|
|
2797
|
+
return {
|
|
2798
|
+
content: [{
|
|
2799
|
+
type: 'text',
|
|
2800
|
+
text: resume === true
|
|
2801
|
+
? 'Arrivals will be offered to this session again.'
|
|
2802
|
+
: 'Quiet for the rest of this session. Nothing was decided about those records — they stay unclaimed, stay on the general timeline, and other sessions still see them. `ignore_arrivals resume:true` turns them back on.',
|
|
2803
|
+
}],
|
|
2804
|
+
}
|
|
2805
|
+
},
|
|
2806
|
+
)
|
|
2807
|
+
|
|
2753
2808
|
server.registerTool(
|
|
2754
2809
|
'my_source_routes',
|
|
2755
2810
|
{
|
|
@@ -3349,7 +3404,7 @@ function renderNudge(payload) {
|
|
|
3349
3404
|
return toolError(`Could not list records: ${d.message}`)
|
|
3350
3405
|
}
|
|
3351
3406
|
const payload = await res.json()
|
|
3352
|
-
return { content: [{ type: 'text', text: (payload?.text ?? '') + renderNudge(payload) }] }
|
|
3407
|
+
return { content: [{ type: 'text', text: (payload?.text ?? '') + renderArrival(payload) + renderNudge(payload) }] }
|
|
3353
3408
|
},
|
|
3354
3409
|
)
|
|
3355
3410
|
|
package/package.json
CHANGED