// src/utils/common.ts
var IS_ROOT = typeof process !== "undefined" && (process.geteuid?.() ?? process.getuid?.()) === 0;

// src/execution-mode.ts
var ALLOW_BYPASS = !IS_ROOT;
var availableModes = [
  {
    id: "default",
    name: "Default",
    description: "Standard behavior, prompts for dangerous operations"
  },
  {
    id: "acceptEdits",
    name: "Accept Edits",
    description: "Auto-accept file edit operations"
  },
  {
    id: "plan",
    name: "Plan Mode",
    description: "Planning mode, no actual tool execution"
  }
  // {
  //   id: "dontAsk",
  //   name: "Don't Ask",
  //   description: "Don't prompt for permissions, deny if not pre-approved",
  // },
];
if (ALLOW_BYPASS) {
  availableModes.push({
    id: "bypassPermissions",
    name: "Bypass Permissions",
    description: "Bypass all permission checks"
  });
}
var CODE_EXECUTION_MODES = [
  "default",
  "acceptEdits",
  "plan",
  // "dontAsk",
  "bypassPermissions"
];
function getAvailableModes() {
  return IS_ROOT ? availableModes.filter((m) => m.id !== "bypassPermissions") : availableModes;
}

// src/adapters/claude/mcp/tool-metadata.ts
var mcpToolMetadataCache = /* @__PURE__ */ new Map();
function isMcpToolReadOnly(toolName) {
  const metadata = mcpToolMetadataCache.get(toolName);
  return metadata?.readOnly === true;
}

// src/adapters/claude/tools.ts
var READ_TOOLS = /* @__PURE__ */ new Set(["Read", "NotebookRead"]);
var WRITE_TOOLS = /* @__PURE__ */ new Set([
  "Edit",
  "Write",
  "NotebookEdit"
]);
var BASH_TOOLS = /* @__PURE__ */ new Set([
  "Bash",
  "BashOutput",
  "KillShell"
]);
var SEARCH_TOOLS = /* @__PURE__ */ new Set(["Glob", "Grep", "LS"]);
var WEB_TOOLS = /* @__PURE__ */ new Set(["WebSearch", "WebFetch"]);
var AGENT_TOOLS = /* @__PURE__ */ new Set(["Task", "TodoWrite", "Skill"]);
var BASE_ALLOWED_TOOLS = [
  ...READ_TOOLS,
  ...SEARCH_TOOLS,
  ...WEB_TOOLS,
  ...AGENT_TOOLS
];
var AUTO_ALLOWED_TOOLS = {
  default: new Set(BASE_ALLOWED_TOOLS),
  acceptEdits: /* @__PURE__ */ new Set([...BASE_ALLOWED_TOOLS, ...WRITE_TOOLS]),
  plan: new Set(BASE_ALLOWED_TOOLS)
  // dontAsk: new Set(BASE_ALLOWED_TOOLS),
};
function isToolAllowedForMode(toolName, mode) {
  if (mode === "bypassPermissions") {
    return true;
  }
  if (AUTO_ALLOWED_TOOLS[mode]?.has(toolName) === true) {
    return true;
  }
  if (isMcpToolReadOnly(toolName)) {
    return true;
  }
  return false;
}
export {
  AGENT_TOOLS,
  BASH_TOOLS,
  CODE_EXECUTION_MODES,
  READ_TOOLS,
  SEARCH_TOOLS,
  WEB_TOOLS,
  WRITE_TOOLS,
  getAvailableModes,
  isToolAllowedForMode
};
//# sourceMappingURL=tools.js.map