claudish 10.6.2 → 10.6.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.
Files changed (2) hide show
  1. package/dist/index.js +61 -20
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -112,9 +112,25 @@ import { realpathSync } from "fs";
112
112
  function isPaneShellManagedKey(key) {
113
113
  return key.startsWith("MAGMUX_") || PANE_SHELL_MANAGED_KEYS.includes(key);
114
114
  }
115
- function isPaneChild(env = process.env) {
115
+ function inMcpSession(env = process.env) {
116
116
  return env[ENV.CLAUDISH_PANE_CHILD] === "1";
117
117
  }
118
+ function isPaneChild(env = process.env) {
119
+ return inMcpSession(env) && Boolean(env[ENV.CLAUDISH_PANE_CWD]);
120
+ }
121
+ function nestedLaunchRefusal(env = process.env) {
122
+ if (!inMcpSession(env) || isPaneChild(env))
123
+ return null;
124
+ return NESTED_SESSION_REFUSAL;
125
+ }
126
+ function assertNotNested(env = process.env) {
127
+ const reason = nestedLaunchRefusal(env);
128
+ if (reason === null)
129
+ return;
130
+ process.stderr.write(`claudish: nested session refused: ${reason}
131
+ `);
132
+ process.exit(PANE_CHILD_REFUSED_EXIT);
133
+ }
118
134
  function applyPaneEnvSnapshot(env) {
119
135
  const raw = env[ENV.CLAUDISH_PANE_ENV];
120
136
  if (raw === undefined)
@@ -207,14 +223,10 @@ function assertPaneChildInteractive(config, env = process.env) {
207
223
  if (reason !== null)
208
224
  refuse(reason);
209
225
  }
210
- var PANE_CHILD_REFUSED_EXIT = 64, PANE_MARKER_VARS, PANE_SHELL_MANAGED_KEYS, processCwdOps, bootNotes, bootstrapped = false;
226
+ var PANE_CHILD_REFUSED_EXIT = 64, PANE_LAUNCH_VARS, PANE_SHELL_MANAGED_KEYS, NESTED_SESSION_REFUSAL = "already inside a session started by the claudish MCP server; one level of nesting is the limit", processCwdOps, bootNotes, bootstrapped = false;
211
227
  var init_child_env = __esm(() => {
212
228
  init_config();
213
- PANE_MARKER_VARS = [
214
- ENV.CLAUDISH_PANE_CHILD,
215
- ENV.CLAUDISH_PANE_ENV,
216
- ENV.CLAUDISH_PANE_CWD
217
- ];
229
+ PANE_LAUNCH_VARS = [ENV.CLAUDISH_PANE_ENV, ENV.CLAUDISH_PANE_CWD];
218
230
  PANE_SHELL_MANAGED_KEYS = [
219
231
  "COLUMNS",
220
232
  "LINES",
@@ -889,7 +901,7 @@ var init_onepassword_config = __esm(() => {
889
901
  });
890
902
 
891
903
  // src/version.ts
892
- var VERSION = "10.6.2";
904
+ var VERSION = "10.6.3";
893
905
 
894
906
  // src/logger.ts
895
907
  import { appendFile, existsSync as existsSync2, mkdirSync, readdirSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
@@ -61914,7 +61926,7 @@ function buildLauncherScript(claudeBinary, claudeArgs, deltas) {
61914
61926
  }
61915
61927
  function magmuxPaneCapability(input) {
61916
61928
  const parentEnv = input.parentEnv ?? process.env;
61917
- if (isPaneChild(parentEnv))
61929
+ if (inMcpSession(parentEnv))
61918
61930
  return { kind: "none", reason: "pane-child" };
61919
61931
  if (!input.interactive)
61920
61932
  return { kind: "none", reason: "not-interactive" };
@@ -68881,6 +68893,26 @@ var init_channel = __esm(() => {
68881
68893
  init_types3();
68882
68894
  });
68883
68895
 
68896
+ // src/mcp/nested-mode.ts
68897
+ var NESTED_MCP_TOOL_NAMES, NESTED_INSTRUCTIONS = `Claudish MCP server provides access to external AI models for one-shot calls.
68898
+
68899
+ ## Nested mode \u2014 no sessions
68900
+
68901
+ This server runs inside a session that a claudish MCP server started (CLAUDISH_PANE_CHILD=1). One level of nesting is the limit, so these tools are not registered: create_session, team, send_input, get_output, cancel_session, list_sessions, get_diagnostics, capture_session, preflight, report_error. No channel notifications are sent.
68902
+
68903
+ - run_prompt or compare_models: a one-shot answer from another model.
68904
+ - list_models, search_models: find a model.
68905
+
68906
+ Do not start a claudish session another way: \`claudish -p\`, an interactive claudish or \`claudish team\` run from this session's shell exits 64 with "nested session refused".`;
68907
+ var init_nested_mode = __esm(() => {
68908
+ NESTED_MCP_TOOL_NAMES = [
68909
+ "run_prompt",
68910
+ "list_models",
68911
+ "search_models",
68912
+ "compare_models"
68913
+ ];
68914
+ });
68915
+
68884
68916
  // src/mcp/progress-heartbeat.ts
68885
68917
  function isProgressToken(v) {
68886
68918
  return typeof v === "string" || typeof v === "number" && Number.isFinite(v);
@@ -69278,8 +69310,9 @@ async function teamContractVerb(mode, args) {
69278
69310
  return contractErrorAnswer(e);
69279
69311
  }
69280
69312
  }
69281
- function defineTools(sessionManager, notifyChannel) {
69313
+ function defineTools(sessionManager, notifyChannel, nested) {
69282
69314
  const tools = [];
69315
+ const reportHint = (text) => nested ? "" : text;
69283
69316
  function withOpFailureContext(message, subject) {
69284
69317
  const block = renderOpFailureBlock(subject);
69285
69318
  return block.length === 0 ? message : `${message}
@@ -69322,10 +69355,10 @@ Tokens: ${result.usage.input} input, ${result.usage.output} output`;
69322
69355
  content: [
69323
69356
  {
69324
69357
  type: "text",
69325
- text: withOpFailureContext(`Error: ${errMsg}
69358
+ text: withOpFailureContext(`Error: ${errMsg}${reportHint(`
69326
69359
 
69327
69360
  ---
69328
- **To report this error**, use the \`report_error\` tool with \`error_type: "provider_failure"\` and \`model: "${args.model}"\`.`, `while routing ${args.model}`)
69361
+ **To report this error**, use the \`report_error\` tool with \`error_type: "provider_failure"\` and \`model: "${args.model}"\`.`)}`, `while routing ${args.model}`)
69329
69362
  }
69330
69363
  ],
69331
69364
  isError: true
@@ -69536,7 +69569,7 @@ Use with: run_prompt(model="${suggested}", prompt="your prompt")`;
69536
69569
  }
69537
69570
  const failed = results.filter((r) => r.error);
69538
69571
  if (failed.length > 0) {
69539
- output += '---\n**To report failed model(s)**, use the `report_error` tool with `error_type: "provider_failure"` and the model ID(s) above.\n';
69572
+ output += reportHint('---\n**To report failed model(s)**, use the `report_error` tool with `error_type: "provider_failure"` and the model ID(s) above.\n');
69540
69573
  }
69541
69574
  return { content: [{ type: "text", text: output }] };
69542
69575
  }
@@ -70312,13 +70345,15 @@ function mapEventToTaskStatus(event) {
70312
70345
  }
70313
70346
  async function main() {
70314
70347
  const toolMode = (process.env.CLAUDISH_MCP_TOOLS || "all").toLowerCase();
70348
+ const nested = inMcpSession();
70315
70349
  const enabledGroups = resolveToolGroups(toolMode);
70350
+ const channelEnabled = !nested && enabledGroups.has("channel");
70316
70351
  const server = new Server({ name: "claudish", version: "9.0.0" }, {
70317
70352
  capabilities: {
70318
- ...enabledGroups.has("channel") ? { experimental: { "claude/channel": {} } } : {},
70353
+ ...channelEnabled ? { experimental: { "claude/channel": {} } } : {},
70319
70354
  tools: {}
70320
70355
  },
70321
- instructions: INSTRUCTIONS
70356
+ instructions: nested ? NESTED_INSTRUCTIONS : INSTRUCTIONS
70322
70357
  });
70323
70358
  const sessionManager = new SessionManager({
70324
70359
  onStateChange: wrapStateChange((sessionId, event) => {
@@ -70345,7 +70380,6 @@ Call get_diagnostics with session_id: "${sessionId}" for the final screen, the u
70345
70380
  watchNotificationResult(result, { sessionId, eventType: event.type });
70346
70381
  })
70347
70382
  });
70348
- const channelEnabled = enabledGroups.has("channel");
70349
70383
  const notifyChannel = (p) => {
70350
70384
  if (!channelEnabled)
70351
70385
  return;
@@ -70370,10 +70404,11 @@ Call get_diagnostics with session_id: "${sessionId}" for the final screen, the u
70370
70404
  } catch {}
70371
70405
  };
70372
70406
  const progressIntervalMs = resolveProgressIntervalMs();
70373
- const allTools = defineTools(sessionManager, notifyChannel);
70374
- const enabledTools = allTools.filter((t) => enabledGroups.has(t.group));
70407
+ const allTools = defineTools(sessionManager, notifyChannel, nested);
70408
+ const nestedNames = NESTED_MCP_TOOL_NAMES;
70409
+ const enabledTools = allTools.filter((t) => enabledGroups.has(t.group) && (!nested || nestedNames.includes(t.name)));
70375
70410
  const toolMap = new Map(enabledTools.map((t) => [t.name, t]));
70376
- console.error(`[claudish] MCP server started (tools: ${toolMode}, ${enabledTools.length} tools)`);
70411
+ console.error(`[claudish] MCP server started (tools: ${nested ? "nested" : toolMode}, ${enabledTools.length} tools)`);
70377
70412
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
70378
70413
  tools: enabledTools.map((t) => ({
70379
70414
  name: t.name,
@@ -70477,8 +70512,10 @@ var init_mcp_server = __esm(() => {
70477
70512
  init_channel();
70478
70513
  init_parent_session();
70479
70514
  init_remote_provider_types();
70515
+ init_nested_mode();
70480
70516
  init_progress_heartbeat();
70481
70517
  init_model_loader();
70518
+ init_child_env();
70482
70519
  init_pane();
70483
70520
  init_port_manager();
70484
70521
  init_endpoint_registration();
@@ -71114,6 +71151,8 @@ async function teamCommand(args) {
71114
71151
  const firstArg = args[0] ?? "";
71115
71152
  const legacySubs = ["run", "judge", "run-and-judge", "status"];
71116
71153
  const subcommand = legacySubs.includes(firstArg) ? firstArg : "run";
71154
+ if (subcommand !== "status")
71155
+ assertNotNested();
71117
71156
  const rawSessionPath = getFlag(args, "--path") ?? ".";
71118
71157
  let sessionPath;
71119
71158
  try {
@@ -71200,6 +71239,7 @@ async function teamCommand(args) {
71200
71239
  }
71201
71240
  }
71202
71241
  var init_team_cli = __esm(() => {
71242
+ init_child_env();
71203
71243
  init_pane();
71204
71244
  init_team_orchestrator();
71205
71245
  });
@@ -80553,7 +80593,7 @@ function scrubChildEnv(env, opts) {
80553
80593
  for (const key of STRIPPED_CHILD_VARS)
80554
80594
  delete env[key];
80555
80595
  }
80556
- for (const key of PANE_MARKER_VARS)
80596
+ for (const key of PANE_LAUNCH_VARS)
80557
80597
  delete env[key];
80558
80598
  }
80559
80599
  function buildClaudishSettingsOverlay(statusLine, proxyAuthMode, paneChild = isPaneChild()) {
@@ -83974,6 +84014,7 @@ async function runCli() {
83974
84014
  await detectAndSetThemeMode();
83975
84015
  });
83976
84016
  const cliConfig = await traceSpan("startup:parse-args", () => parseArgs(process.argv.slice(2)));
84017
+ assertNotNested();
83977
84018
  assertPaneChildInteractive(cliConfig);
83978
84019
  await traceSpan("startup:endpoint-registration", async () => {
83979
84020
  await Promise.resolve().then(() => init_endpoint_registration());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudish",
3
- "version": "10.6.2",
3
+ "version": "10.6.3",
4
4
  "description": "Run Claude Code with any model - OpenRouter, Ollama, LM Studio & local models",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -60,10 +60,10 @@
60
60
  "ai"
61
61
  ],
62
62
  "optionalDependencies": {
63
- "@claudish/magmux-darwin-arm64": "10.6.2",
64
- "@claudish/magmux-darwin-x64": "10.6.2",
65
- "@claudish/magmux-linux-arm64": "10.6.2",
66
- "@claudish/magmux-linux-x64": "10.6.2"
63
+ "@claudish/magmux-darwin-arm64": "10.6.3",
64
+ "@claudish/magmux-darwin-x64": "10.6.3",
65
+ "@claudish/magmux-linux-arm64": "10.6.3",
66
+ "@claudish/magmux-linux-x64": "10.6.3"
67
67
  },
68
68
  "author": "Jack Rudenko <i@madappgang.com>",
69
69
  "license": "MIT",