@nexus-cortex/cli 4.133.1 → 4.133.3

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/.env.defaults CHANGED
@@ -2221,6 +2221,17 @@ PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=
2221
2221
  # 6c460bfc3 with default 2 — corrected to 1 the same day after finding the 10-19 design.) Unit tests
2222
2222
  # browseAgentPolicy.test.ts; live check: the Browse delegate runs with CORTEX_BROWSE_AGENT=true.
2223
2223
  #CORTEX_MAX_AGENT_DEPTH=
2224
+ # CORTEX_TOOL_PARENT_DEPTH — INTERNAL marker (do not set by hand): every process an agent's tool starts (Bash, …; core toolChildEnv) carries
2225
+ # the depth of the agent that started it. bin/cortex.js refuses to start ANOTHER agent from such a process (prompt / agent / run / TUI,
2226
+ # and the agent-launching subcommands autoresearch, message, tmux; exit 3, "use the Task tool"); info commands still work. Closes the
2227
+ # gap where a sub-agent ran `cortex …` through Bash and got an unbounded fresh agent (often on the parent's shared :4000 server at
2228
+ # depth 0). Empty = unmarked (the vitest configs blank it so suites run from an agent's Bash behave).
2229
+ # [LEDGER 2026-11-12 @4.133.3 SHIPPED ON] (4.133.2 CI-failed, never on npm) operator 11-12 "fix the sub-agent nesting gap". Evidence: bin refusal + toolChildEnv marker tests.
2230
+ #CORTEX_TOOL_PARENT_DEPTH=
2231
+ # CORTEX_ALLOW_NESTED_AGENT — operator override for the guard above: true (REAL env only) lets a tool-started process launch cortex
2232
+ # agents again. Default unset = refused.
2233
+ # [LEDGER 2026-11-12 @4.133.3 SHIPPED ON] default unset (guard on).
2234
+ #CORTEX_ALLOW_NESTED_AGENT=
2224
2235
  TMUX_BIN=
2225
2236
  # Google Vertex AI project (only when using Vertex instead of the Gemini API)
2226
2237
  GOOGLE_CLOUD_PROJECT=
package/bin/cortex.js CHANGED
@@ -124,6 +124,21 @@ const COMMANDER_SUBCOMMANDS = new Set([
124
124
  'secrets', 'canon', 'features', 'sessions', 'server', 'browser', 'desktop',
125
125
  ]);
126
126
  const __firstPositional = args.find((a) => !a.startsWith('-'));
127
+ // 2026-11-12 sub-agent NESTING GUARD: an agent's tool (Bash …) marks its children with CORTEX_TOOL_PARENT_DEPTH (core toolChildEnv). From
128
+ // there, anything that would start ANOTHER agent conversation is refused: a prompt / `agent` / `run` / the TUI, and the agent-launching
129
+ // subcommands (autoresearch, message, tmux). Info commands (--version, --help, --sessions, --stats, config, secrets, canon, update …) still
130
+ // work. Sub-agents go through the bounded Task tool. CORTEX_ALLOW_NESTED_AGENT=true (real env) is the operator override.
131
+ {
132
+ const __parent = process.env.CORTEX_TOOL_PARENT_DEPTH;
133
+ const __infoOnly = args.some((a) => ['--help', '-h', '--sessions', '--stats', '--list-models', '--models'].includes(a));
134
+ const __launches = !__infoOnly && (!__firstPositional || !COMMANDER_SUBCOMMANDS.has(__firstPositional) || ['autoresearch', 'message', 'tmux'].includes(__firstPositional));
135
+ if (__parent && __launches && process.env.CORTEX_ALLOW_NESTED_AGENT !== 'true') {
136
+ process.stderr.write(`cortex: refused — this command was started by an agent's tool (agent depth ${__parent}), and it would start another agent. `
137
+ + 'Use the Task tool to delegate to a sub-agent (it is depth-bounded); do not launch cortex from a shell inside an agent. '
138
+ + '(Operator override: CORTEX_ALLOW_NESTED_AGENT=true.)\n');
139
+ process.exit(3);
140
+ }
141
+ }
127
142
  if (__firstPositional && COMMANDER_SUBCOMMANDS.has(__firstPositional)) {
128
143
  // A few delegated subcommands talk to the cortex server over HTTP (they connect via
129
144
  // CortexClient to localhost:PORT). Auto-start the server first so e.g.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexus-cortex/cli",
3
- "version": "4.133.1",
3
+ "version": "4.133.3",
4
4
  "description": "Nexus Cortex CLI - Terminal interface for multi-provider LLM orchestration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "prepack": "node ../../scripts/copy-pkg-cortex-scaffold.mjs"
20
20
  },
21
21
  "dependencies": {
22
- "@nexus-cortex/core": "4.133.1",
22
+ "@nexus-cortex/core": "4.133.3",
23
23
  "chalk": "^4.1.2",
24
24
  "cli-spinners": "^2.9.0",
25
25
  "commander": "^11.0.0",