@theronap/agnoclast-mcp 0.9.295 → 0.9.296
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 +37 -0
- package/lib/server.mjs +4 -3
- package/package.json +1 -1
package/lib/release_gate.mjs
CHANGED
|
@@ -3,11 +3,48 @@
|
|
|
3
3
|
// once at start-up, which tools this caller must NOT see (GET /api/me/release) and removes them before the
|
|
4
4
|
// first tools/list. Fails CLOSED: no answer within the budget → hide GATED_FALLBACK, a copy of every gated tool
|
|
5
5
|
// that web/lib/engine/release.test.ts pins to the server's registry.
|
|
6
|
+
//
|
|
7
|
+
// ⚠ UNLESS THIS MACHINE HAS HEARD AN ANSWER BEFORE (2026-11-02). A runner that starts a process per call (Frack on
|
|
8
|
+
// Muse) meets a slow server often, and each slow start hid every gated tool, so a poller saw "tasks_waiting not
|
|
9
|
+
// found" and its tasks went unseen. The last answer is kept in ~/.cortex/release-state.json and used when the server
|
|
10
|
+
// does not answer in time. It is keyed by server, not token: Muse hands each process a fresh stand-in for the token.
|
|
11
|
+
// That is safe because hiding a tool is a courtesy, and every gated route checks its own flag on the server.
|
|
6
12
|
|
|
7
13
|
/** Tools any release flag gates — hidden when the server cannot be asked. Mirror of allGatedTools(). */
|
|
8
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', 'read_conversation', 'read_document', 'send_message', 'set_manager', 'tasks_waiting', 'upload_document_version']
|
|
9
15
|
|
|
10
16
|
export const RELEASE_FETCH_TIMEOUT_MS = 2500
|
|
17
|
+
/** A remembered answer older than this is not trusted: a week covers a quiet weekend without hiding tools for long. */
|
|
18
|
+
export const RELEASE_CACHE_MAX_AGE_MS = 7 * 24 * 3600_000
|
|
19
|
+
|
|
20
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
21
|
+
import { homedir } from 'node:os'
|
|
22
|
+
import { join } from 'node:path'
|
|
23
|
+
|
|
24
|
+
const cachePath = (home) => join(home, '.cortex', 'release-state.json')
|
|
25
|
+
|
|
26
|
+
/** Keep a fresh answer for the next slow start. Never throws. */
|
|
27
|
+
export function rememberReleaseState(base, state, { home = homedir(), nowMs = Date.now() } = {}) {
|
|
28
|
+
if (!state?.known) return
|
|
29
|
+
try {
|
|
30
|
+
let all = {}
|
|
31
|
+
try { all = JSON.parse(readFileSync(cachePath(home), 'utf8')) ?? {} } catch { /* first answer */ }
|
|
32
|
+
all[base] = { hidden: state.hidden, at: nowMs }
|
|
33
|
+
mkdirSync(join(home, '.cortex'), { recursive: true })
|
|
34
|
+
writeFileSync(cachePath(home), JSON.stringify(all))
|
|
35
|
+
} catch { /* a cache that cannot be written only means the next slow start falls back */ }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The last answer this machine heard from `base`, if recent. Null otherwise. Never throws. */
|
|
39
|
+
export function rememberedReleaseState(base, { home = homedir(), nowMs = Date.now() } = {}) {
|
|
40
|
+
try {
|
|
41
|
+
const e = JSON.parse(readFileSync(cachePath(home), 'utf8'))?.[base]
|
|
42
|
+
if (!e || !Array.isArray(e.hidden) || typeof e.at !== 'number' || nowMs - e.at > RELEASE_CACHE_MAX_AGE_MS) return null
|
|
43
|
+
return { known: true, hidden: e.hidden.filter((t) => typeof t === 'string') }
|
|
44
|
+
} catch {
|
|
45
|
+
return null
|
|
46
|
+
}
|
|
47
|
+
}
|
|
11
48
|
|
|
12
49
|
/** → { known: true, hidden: string[] } | { known: false }. 404 (server predates cohorts) = nothing hidden. Never throws. */
|
|
13
50
|
export async function fetchReleaseState(base, token, fetchImpl) {
|
package/lib/server.mjs
CHANGED
|
@@ -35,7 +35,7 @@ import { formatCreated, formatDryRun, formatSources, homeFromArgs, pickSource, r
|
|
|
35
35
|
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
|
-
import { applyRelease, fetchReleaseState, releaseStateWithin } from './release_gate.mjs'
|
|
38
|
+
import { applyRelease, fetchReleaseState, releaseStateWithin, rememberReleaseState, rememberedReleaseState } from './release_gate.mjs'
|
|
39
39
|
import { filterUnshownSettling, renderSettlingV2 } from './settling_shown.mjs'
|
|
40
40
|
import { renderContactBriefing, renderContactCandidates, renderContactList } from './contacts_render.mjs'
|
|
41
41
|
import { renderConversation, renderMessageInbox } from './messages_render.mjs'
|
|
@@ -479,7 +479,7 @@ export async function runServer(version) {
|
|
|
479
479
|
// Lite account's AI sees already marks the Regular-only tools 🔒. Regular accounts: nothing changes.
|
|
480
480
|
const lockP = fetchLockState(BASE, TOKEN, fetchCortex)
|
|
481
481
|
// RELEASE COHORTS (lib/release_gate.mjs): tools behind a flag this caller's brains lack are removed before the handshake.
|
|
482
|
-
const releaseP = fetchReleaseState(BASE, TOKEN, fetchCortex)
|
|
482
|
+
const releaseP = fetchReleaseState(BASE, TOKEN, fetchCortex).then((state) => { rememberReleaseState(BASE, state); return state })
|
|
483
483
|
const toolHandles = new Map()
|
|
484
484
|
let lockedTools = new Set()
|
|
485
485
|
// Nothing wakes a delegate agent, so a waiting task is mentioned on the first result of a process (each Frack call
|
|
@@ -8241,7 +8241,8 @@ function renderNudge(payload) {
|
|
|
8241
8241
|
},
|
|
8242
8242
|
)
|
|
8243
8243
|
|
|
8244
|
-
|
|
8244
|
+
const release = await releaseStateWithin(releaseP)
|
|
8245
|
+
applyRelease(toolHandles, release.known ? release : (rememberedReleaseState(BASE) ?? release))
|
|
8245
8246
|
lockedTools = applyLock(toolHandles, await lockStateWithin(lockP))
|
|
8246
8247
|
// Bounded so a slow lookup never holds up the handshake — but a lookup that is merely LATE still lands: until it
|
|
8247
8248
|
// does, a tool naming a brain waits for it (the wrapper), so a cold start cannot make the confidential brains
|
package/package.json
CHANGED