@theronap/cortex-mcp 0.9.38 → 0.9.39

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.
Files changed (2) hide show
  1. package/lib/diagnose.mjs +12 -2
  2. package/package.json +1 -1
package/lib/diagnose.mjs CHANGED
@@ -68,10 +68,20 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms))
68
68
  // 'app' → a real Cortex API error with a JSON message (retriable only if 5xx)
69
69
  export function classify(status, contentType, bodyText, requestId) {
70
70
  const isJson = (contentType ?? '').includes('application/json')
71
- let appError = null
72
- if (isJson) { try { appError = JSON.parse(bodyText)?.error ?? null } catch { /* not json after all */ } }
71
+ let body = null
72
+ if (isJson) { try { body = JSON.parse(bodyText) } catch { /* not json after all */ } }
73
+ const appError = body?.error ?? null
73
74
  const rid = requestId ? ` [request id: ${requestId}]` : ''
74
75
 
76
+ // Multi-brain: 409 no_active_brain means the caller belongs to >1 brain and hasn't chosen one. It is
77
+ // NOT an auth failure — surface the action (set_active_brain) directly, not a "Cortex API 409:" wrapper.
78
+ if (status === 409 && body?.code === 'no_active_brain') {
79
+ return {
80
+ kind: 'app', retriable: false,
81
+ message: `${appError ?? 'You belong to more than one brain — call set_active_brain to choose where your writes land.'} (see my_brains for your options)${rid}`,
82
+ }
83
+ }
84
+
75
85
  if (status === 401 || (isJson && appError === 'invalid token')) {
76
86
  return {
77
87
  kind: 'auth', retriable: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/cortex-mcp",
3
- "version": "0.9.38",
3
+ "version": "0.9.39",
4
4
  "description": "Connect your AI assistant to Cortex — your org's projects, activity, gaps, and directives, scoped to you.",
5
5
  "type": "module",
6
6
  "bin": {