@theronap/agnoclast-mcp 0.9.273 → 0.9.274
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/confidential_session.mjs +20 -12
- package/package.json +1 -1
|
@@ -21,28 +21,36 @@ export const CONFIDENTIAL_BRAIN_ENV = 'AGNOCLAST_CONFIDENTIAL_BRAIN'
|
|
|
21
21
|
// stand down under it, so nothing from this session is captured into, or read from, another brain.
|
|
22
22
|
export const CONFIDENTIAL_SESSION_ENV = 'AGNOCLAST_CONFIDENTIAL'
|
|
23
23
|
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The NEAREST coding agent above this process: 'codex', 'claude', or null. Nearest, because agents nest — a
|
|
26
|
+
* Codex started from a terminal inside Claude Code inherits CLAUDECODE and Claude's account variables, and
|
|
27
|
+
* the agent actually running the model is the one closest to this server. Unix only; anywhere else, null.
|
|
28
|
+
*/
|
|
29
|
+
export function nearestAgent({ pid = process.ppid, exec = execFileSync, platform = process.platform } = {}) {
|
|
30
|
+
if (platform === 'win32') return null
|
|
27
31
|
let cur = pid
|
|
28
32
|
for (let i = 0; i < 16 && cur > 1; i++) {
|
|
29
33
|
let line
|
|
30
|
-
try { line = String(exec('ps', ['-o', 'ppid=,comm=', '-p', String(cur)], { encoding: 'utf8', windowsHide: true })).trim() } catch { return
|
|
34
|
+
try { line = String(exec('ps', ['-o', 'ppid=,comm=', '-p', String(cur)], { encoding: 'utf8', windowsHide: true })).trim() } catch { return null }
|
|
31
35
|
const m = line.match(/^(\d+)\s+(.*)$/)
|
|
32
|
-
if (!m) return
|
|
33
|
-
|
|
36
|
+
if (!m) return null
|
|
37
|
+
const comm = m[2].trim()
|
|
38
|
+
if (/(^|\/)codex[^/]*$/i.test(comm)) return 'codex'
|
|
39
|
+
if (/(^|\/)claude$/.test(comm)) return 'claude' // lower-case: the desktop app's own binary is 'Claude'
|
|
34
40
|
cur = Number(m[1])
|
|
35
41
|
}
|
|
36
|
-
return
|
|
42
|
+
return null
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
/**
|
|
40
46
|
* Which AI account runs this agent, as a proof the server can check — or { refused } saying why there is none.
|
|
41
|
-
*
|
|
42
|
-
*
|
|
47
|
+
* The nearest agent decides (see nearestAgent). Claude Code is also recognised by its environment alone when no
|
|
48
|
+
* agent shows in the process tree, because that environment is set by the process running; a Codex auth file
|
|
49
|
+
* is used only when Codex is the nearest agent, since it can sit on a machine whose agent is something else.
|
|
43
50
|
*/
|
|
44
|
-
export function gatherAgentProof({ env = process.env, readFile = readFileSync, home = homedir(),
|
|
45
|
-
|
|
51
|
+
export function gatherAgentProof({ env = process.env, readFile = readFileSync, home = homedir(), agent = nearestAgent } = {}) {
|
|
52
|
+
const nearest = agent()
|
|
53
|
+
if (env.CLAUDECODE && nearest !== 'codex') {
|
|
46
54
|
if (env.ANTHROPIC_API_KEY || env.CLAUDE_CODE_USE_BEDROCK || env.CLAUDE_CODE_USE_VERTEX || env.ANTHROPIC_AUTH_TOKEN) {
|
|
47
55
|
return { refused: 'Claude Code is running on an API key or a cloud provider, so it cannot say which Claude account runs the model. Sign in with your approved Claude account (/login) and start again.' }
|
|
48
56
|
}
|
|
@@ -52,7 +60,7 @@ export function gatherAgentProof({ env = process.env, readFile = readFileSync, h
|
|
|
52
60
|
}
|
|
53
61
|
return { proof: { kind: 'claude-code', accountUuid, organizationUuid, email: env.CLAUDE_CODE_USER_EMAIL || null } }
|
|
54
62
|
}
|
|
55
|
-
if (
|
|
63
|
+
if (nearest === 'codex') {
|
|
56
64
|
let auth
|
|
57
65
|
try { auth = JSON.parse(readFile(join(env.CODEX_HOME || join(home, '.codex'), 'auth.json'), 'utf8')) } catch {
|
|
58
66
|
return { refused: 'Codex is not signed in on this machine (no ~/.codex/auth.json). Run `codex login` with your approved ChatGPT account.' }
|
package/package.json
CHANGED