import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);

// ../shared/dist/index.js
import { z } from "zod";
import { z as z2 } from "zod";
import { z as z3 } from "zod";
import { z as z4 } from "zod";
var ANALYTICS_EVENTS = {
  // App lifecycle
  APP_STARTED: "App started",
  APP_QUIT: "App quit",
  // Authentication
  USER_LOGGED_IN: "User logged in",
  USER_LOGGED_OUT: "User logged out",
  // Task management
  TASK_LIST_VIEWED: "Task list viewed",
  TASK_CREATED: "Task created",
  TASK_VIEWED: "Task viewed",
  TASK_RUN: "Task run",
  TASK_RUN_STARTED: "Task run started",
  TASK_RUN_COMPLETED: "Task run completed",
  TASK_RUN_CANCELLED: "Task run cancelled",
  TASK_RUN_STOPPED: "Task run stopped",
  PROMPT_SENT: "Prompt sent",
  // Claude Code session import
  CLAUDE_SESSIONS_SHOWN: "Claude Code sessions shown",
  CLAUDE_SESSION_IMPORTED: "Claude Code session imported",
  CLAUDE_SESSION_IMPORT_FAILED: "Claude Code session import failed",
  // Repository
  REPOSITORY_SELECTED: "Repository selected",
  // Git operations
  GIT_ACTION_EXECUTED: "Git action executed",
  PR_CREATED: "PR created",
  AGENT_FILE_ACTIVITY: "Agent file activity",
  BRANCH_LINKED: "Branch linked",
  BRANCH_UNLINKED: "Branch unlinked",
  BRANCH_LINK_DEFAULT_BRANCH_UNKNOWN: "Branch link default branch unknown",
  // File interactions
  FILE_OPENED: "File opened",
  FILE_DIFF_VIEWED: "File diff viewed",
  REVIEW_PANEL_VIEWED: "Review panel viewed",
  DIFF_VIEW_MODE_CHANGED: "Diff view mode changed",
  // Workspace events
  WORKSPACE_CREATED: "Workspace created",
  WORKSPACE_SCRIPTS_STARTED: "Workspace scripts started",
  FOLDER_REGISTERED: "Folder registered",
  // Navigation events
  SETTINGS_VIEWED: "Settings viewed",
  COMMAND_MENU_OPENED: "Command menu opened",
  COMMAND_MENU_ACTION: "Command menu action",
  COMMAND_CENTER_VIEWED: "Command center viewed",
  BRAINROT_ACTIVATED: "Brainrot activated",
  SKILL_BUTTON_TRIGGERED: "Skill button triggered",
  POSTHOG_WEB_OPENED: "PostHog web opened",
  // Permission events
  PERMISSION_RESPONDED: "Permission responded",
  PERMISSION_CANCELLED: "Permission cancelled",
  // Session config events
  SESSION_CONFIG_CHANGED: "Session config changed",
  // Settings events
  SETTING_CHANGED: "Setting changed",
  CUSTOM_SOUND_ADDED: "Custom sound added",
  CUSTOM_SOUND_RECORDING_SILENT: "Custom sound recording silent",
  // Feedback events
  TASK_FEEDBACK: "Task feedback",
  // Branch mismatch events
  BRANCH_MISMATCH_WARNING_SHOWN: "Branch mismatch warning shown",
  BRANCH_MISMATCH_ACTION: "Branch mismatch action",
  // Tour events
  TOUR_EVENT: "Tour event",
  // Onboarding events
  ONBOARDING_STARTED: "Onboarding started",
  ONBOARDING_STEP_VIEWED: "Onboarding step viewed",
  ONBOARDING_STEP_COMPLETED: "Onboarding step completed",
  ONBOARDING_STEP_SKIPPED: "Onboarding step skipped",
  ONBOARDING_SIGN_IN_INITIATED: "Onboarding sign in initiated",
  ONBOARDING_PROJECT_SELECTED: "Onboarding project selected",
  ONBOARDING_INVITE_CODE_SUBMITTED: "Onboarding invite code submitted",
  ONBOARDING_FOLDER_SELECTED: "Onboarding folder selected",
  ONBOARDING_GITHUB_CONNECT_STARTED: "Onboarding github connect started",
  ONBOARDING_GITHUB_CONNECT_FAILED: "Onboarding github connect failed",
  ONBOARDING_GITHUB_CONNECTED: "Onboarding github connected",
  ONBOARDING_CLI_CHECK_COMPLETED: "Onboarding cli check completed",
  ONBOARDING_CLI_RUN_COMPLETED: "Onboarding cli run completed",
  ONBOARDING_COMPLETED: "Onboarding completed",
  ONBOARDING_ABANDONED: "Onboarding abandoned",
  AI_CONSENT_GATE_SHOWN: "Ai consent gate shown",
  AI_CONSENT_APPROVED: "Ai consent approved",
  AI_CONSENT_GRANTED_INAPP: "Ai consent granted in-app",
  // Setup / onboarding events
  SETUP_DISCOVERY_STARTED: "Setup discovery started",
  SETUP_DISCOVERY_COMPLETED: "Setup discovery completed",
  SETUP_DISCOVERY_FAILED: "Setup discovery failed",
  SETUP_TASK_SELECTED: "Setup task selected",
  SETUP_TASK_DISMISSED: "Setup task dismissed",
  // Deep link events
  DEEP_LINK_NEW_TASK: "Deep link new task",
  DEEP_LINK_PLAN: "Deep link plan",
  DEEP_LINK_ISSUE: "Deep link issue",
  DEEP_LINK_ISSUE_FAILED: "Deep link issue failed",
  DEEP_LINK_CANVAS: "Deep link canvas",
  DEEP_LINK_CHANNEL: "Deep link channel",
  // Error events
  TASK_CREATION_FAILED: "Task creation failed",
  AGENT_SESSION_ERROR: "Agent session error",
  CLOUD_STREAM_DISCONNECTED: "Cloud stream disconnected",
  // Inbox events
  INBOX_VIEWED: "Inbox viewed",
  INBOX_REPORT_OPENED: "Inbox report opened",
  INBOX_REPORT_CLOSED: "Inbox report closed",
  INBOX_REPORT_ACTION: "Inbox report action",
  INBOX_REPORT_SCROLLED: "Inbox report scrolled",
  SIGNAL_SOURCE_CONNECTED: "Signal source connected",
  // Agents page events
  AGENTS_VIEWED: "Agents viewed",
  AGENTS_ACTION: "Agents action",
  // Scout events
  SCOUT_FLEET_VIEWED: "Scout fleet viewed",
  SCOUT_DETAIL_VIEWED: "Scout detail viewed",
  SCOUT_CONFIG_CHANGED: "Scout config changed",
  SCOUT_CHAT_STARTED: "Scout chat started",
  SCOUT_ACTION: "Scout action",
  // Usage and spend analysis events
  USAGE_VIEWED: "Usage viewed",
  SPEND_ANALYSIS_TASK_OPENED: "Spend analysis task opened",
  // Prompt history events
  PROMPT_HISTORY_OPENED: "Prompt history opened",
  PROMPT_HISTORY_SELECTED: "Prompt history selected",
  // Subscription events
  UPGRADE_PROMPT_SHOWN: "Upgrade prompt shown",
  UPGRADE_PROMPT_CLICKED: "Upgrade prompt clicked",
  CLOUD_TASK_USAGE_BLOCKED: "Cloud task usage blocked",
  SUBSCRIPTION_STARTED: "Subscription started",
  SUBSCRIPTION_CANCELLED: "Subscription cancelled",
  USAGE_BILLING_ANNOUNCEMENT_ACKNOWLEDGED: "Usage billing announcement acknowledged",
  // Project Bluebird (Channels) events
  CHANNELS_SPACE_VIEWED: "Channels space viewed",
  CHANNEL_ACTION: "Channel action",
  DASHBOARD_ACTION: "Dashboard action",
  CANVAS_PROMPT_SENT: "Canvas prompt sent",
  CONTEXT_ACTION: "Context action",
  // Autoresearch events
  AUTORESEARCH_ARMED: "Autoresearch armed",
  AUTORESEARCH_RUN_STARTED: "Autoresearch run started"
};
var INBOX_ANALYTICS_EVENT_NAMES = /* @__PURE__ */ new Set([
  ANALYTICS_EVENTS.INBOX_VIEWED,
  ANALYTICS_EVENTS.INBOX_REPORT_OPENED,
  ANALYTICS_EVENTS.INBOX_REPORT_CLOSED,
  ANALYTICS_EVENTS.INBOX_REPORT_ACTION,
  ANALYTICS_EVENTS.INBOX_REPORT_SCROLLED,
  ANALYTICS_EVENTS.SIGNAL_SOURCE_CONNECTED
]);
var archivedTaskSchema = z.object({
  taskId: z.string(),
  archivedAt: z.string(),
  folderId: z.string(),
  mode: z.enum(["worktree", "local", "cloud"]),
  worktreeName: z.string().nullable(),
  branchName: z.string().nullable(),
  checkpointId: z.string().nullable()
});
var IMAGE_MIME_TYPES = {
  png: "image/png",
  jpg: "image/jpeg",
  jpeg: "image/jpeg",
  gif: "image/gif",
  webp: "image/webp",
  bmp: "image/bmp",
  ico: "image/x-icon",
  tiff: "image/tiff",
  tif: "image/tiff",
  svg: "image/svg+xml",
  heic: "image/heic",
  heif: "image/heif",
  avif: "image/avif"
};
var IMAGE_EXTENSIONS = new Set(
  Object.keys(IMAGE_MIME_TYPES)
);
var MAX_DATA_URL_LENGTH = 20 * 1024 * 1024;
var MAX_IMAGE_BASE64_LENGTH = 15 * 1024 * 1024;
var MAX_CLAUDE_IMAGE_BYTES = 5 * 1024 * 1024;
var AUDIO_VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([
  "mp3",
  "mp4",
  "wav",
  "avi",
  "mov",
  "mkv",
  "webm",
  "mpg",
  "mpeg",
  "flac",
  "ogg",
  "ogv",
  "m4a",
  "m4v",
  "aac"
]);
var ARCHIVE_EXTENSIONS = /* @__PURE__ */ new Set([
  "zip",
  "tar",
  "gz",
  "tgz",
  "bz2",
  "xz",
  "rar",
  "7z"
]);
var EXECUTABLE_EXTENSIONS = /* @__PURE__ */ new Set([
  "exe",
  "dll",
  "so",
  "dylib",
  "wasm",
  "bin",
  "o"
]);
var FONT_EXTENSIONS = /* @__PURE__ */ new Set([
  "ttf",
  "otf",
  "woff",
  "woff2",
  "eot"
]);
var DOCUMENT_BINARY_EXTENSIONS = /* @__PURE__ */ new Set(["pdf"]);
var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
  ...Object.keys(IMAGE_MIME_TYPES).filter((ext) => ext !== "svg"),
  ...AUDIO_VIDEO_EXTENSIONS,
  ...ARCHIVE_EXTENSIONS,
  ...EXECUTABLE_EXTENSIONS,
  ...FONT_EXTENSIONS,
  ...DOCUMENT_BINARY_EXTENSIONS
]);
var browserTabSchema = z2.object({
  id: z2.string(),
  windowId: z2.string(),
  /** Canvas this tab shows. Null for a task tab or a blank tab. */
  dashboardId: z2.string().nullable(),
  /** Task this tab shows. Null for a canvas tab or a blank tab. */
  taskId: z2.string().nullable().default(null),
  channelId: z2.string().nullable().default(null),
  /**
   * Channel sub-section this tab fronts (`artifacts` / `history` /
   * `context`). Null = the channel home, or a non-channel tab (canvas / task /
   * blank). Pairs with `channelId`: the two together identify a channel tab.
   */
  channelSection: z2.string().nullable().default(null),
  /**
   * Top-level app page this tab shows (`inbox` / `agents` / `skills` /
   * `mcp-servers` / `command-center` / `home`). Null for a canvas / task /
   * channel / blank tab. These pages have no channel, task, or dashboard id, so
   * this is what lets them be a real tab target (label + restore-on-refocus).
   */
  appView: z2.string().nullable().default(null),
  /** Gap-spaced ordering key within a window. Reindexed on collision. */
  position: z2.number(),
  /**
   * Reserved/unwired. Opaque per-tab state for future scroll restoration etc.
   * Plain `z.unknown()` (not `.default(null)`) so the inferred shape matches
   * the tRPC-wire inference on the client — keeps the renderer facade type and
   * the transport type identical.
   */
  scrollState: z2.unknown().optional(),
  createdAt: z2.number(),
  lastActiveAt: z2.number()
});
var windowBoundsSchema = z2.object({
  x: z2.number(),
  y: z2.number(),
  width: z2.number(),
  height: z2.number()
});
var browserWindowSchema = z2.object({
  id: z2.string(),
  isPrimary: z2.boolean(),
  /** Saved geometry for session restore. Null on web / before first persist. */
  bounds: windowBoundsSchema.nullable().default(null),
  /** Which tab is focused in this window. Null = channels landing. */
  activeTabId: z2.string().nullable().default(null)
});
var tabsSnapshotSchema = z2.object({
  windows: z2.array(browserWindowSchema),
  tabs: z2.array(browserTabSchema)
});
var CODEX_MODE_PRESETS = [
  {
    id: "plan",
    name: "Plan",
    description: "Plan first \u2014 inspect and propose; makes no changes"
  },
  {
    id: "read-only",
    name: "Read only",
    description: "Read-only \u2014 can inspect but not modify files"
  },
  {
    id: "auto",
    name: "Auto",
    description: "Edits the workspace; asks before risky operations"
  },
  {
    id: "full-access",
    name: "Full access",
    description: "Auto-approves all operations"
  }
];
var prReviewCommentUserSchema = z3.object({
  login: z3.string(),
  avatar_url: z3.string()
});
var prReviewCommentSchema = z3.object({
  id: z3.number(),
  body: z3.string(),
  path: z3.string(),
  line: z3.number().nullable(),
  original_line: z3.number().nullable(),
  side: z3.enum(["LEFT", "RIGHT"]),
  start_line: z3.number().nullable(),
  start_side: z3.enum(["LEFT", "RIGHT"]).nullable(),
  diff_hunk: z3.string(),
  in_reply_to_id: z3.number().nullish(),
  user: prReviewCommentUserSchema,
  created_at: z3.string(),
  updated_at: z3.string(),
  subject_type: z3.enum(["line", "file"]).nullable()
});
var prReviewThreadSchema = z3.object({
  nodeId: z3.string(),
  isResolved: z3.boolean(),
  rootId: z3.number(),
  filePath: z3.string(),
  comments: z3.array(prReviewCommentSchema)
});
var githubRefKindSchema = z3.enum(["issue", "pr"]);
var githubRefStateSchema = z3.enum(["OPEN", "CLOSED", "MERGED"]);
var githubRefSchema = z3.object({
  kind: githubRefKindSchema,
  number: z3.number(),
  title: z3.string(),
  state: githubRefStateSchema,
  labels: z3.array(z3.string()),
  url: z3.string(),
  repo: z3.string(),
  isDraft: z3.boolean().optional()
});
var prActionTypeSchema = z3.enum(["close", "reopen", "ready", "draft"]);
var getPrInfoByUrlInput = z3.object({ prUrl: z3.string() });
var getPrInfoByUrlOutput = z3.object({
  number: z3.number(),
  title: z3.string(),
  body: z3.string(),
  author: z3.string().nullable(),
  state: z3.string(),
  merged: z3.boolean(),
  draft: z3.boolean(),
  /** GitHub computes mergeability asynchronously; null until it settles. */
  mergeable: z3.boolean().nullable(),
  /**
   * GitHub's `mergeable_state`: "clean" | "unstable" | "blocked" | "dirty" |
   * "behind" | "draft" | "unknown". "blocked" means branch protection forbids
   * the merge for this viewer — e.g. a required approving review is missing
   * (authors can't approve their own PRs) or required checks are failing.
   * Kept as a plain string so an undocumented value can't fail the parse.
   */
  mergeStateStatus: z3.string().catch("unknown"),
  baseRefName: z3.string().nullable(),
  headRefName: z3.string().nullable(),
  additions: z3.number(),
  deletions: z3.number(),
  changedFiles: z3.number()
});
var approvePrInput = z3.object({ prUrl: z3.string() });
var approvePrOutput = z3.object({
  success: z3.boolean(),
  message: z3.string()
});
var prMergeMethodSchema = z3.enum(["merge", "squash", "rebase"]);
var mergePrInput = z3.object({
  prUrl: z3.string(),
  method: prMergeMethodSchema
});
var mergePrOutput = z3.object({
  success: z3.boolean(),
  message: z3.string()
});
var prCheckBucketSchema = z3.enum([
  "fail",
  "cancel",
  "pending",
  "pass",
  "skipping"
]);
var prCheckSchema = z3.object({
  name: z3.string(),
  bucket: prCheckBucketSchema,
  link: z3.string().nullable(),
  workflow: z3.string().nullable(),
  description: z3.string().nullable()
});
var getPrChecksInput = z3.object({ prUrl: z3.string() });
var getPrChecksOutput = z3.array(prCheckSchema).nullable();
var prConversationCommentSchema = z3.object({
  id: z3.number(),
  author: z3.string(),
  avatarUrl: z3.string().nullable(),
  body: z3.string(),
  createdAt: z3.string(),
  url: z3.string().nullable()
});
var getPrCommentsInput = z3.object({ prUrl: z3.string() });
var getPrCommentsOutput = z3.array(prConversationCommentSchema).nullable();
var TOKEN_REFRESH_BUFFER_MS = 30 * 60 * 1e3;
var TOKEN_REFRESH_FORCE_MS = 60 * 1e3;
var VIDEO_MIME_TYPES = {
  mp4: "video/mp4",
  m4v: "video/mp4",
  mov: "video/quicktime",
  webm: "video/webm",
  ogv: "video/ogg"
};
var PLAYABLE_VIDEO_EXTENSIONS = new Set(
  Object.keys(VIDEO_MIME_TYPES)
);
var ALLOWED_VIDEO_MIME_TYPES = new Set(
  Object.values(VIDEO_MIME_TYPES)
);
var MAX_VIDEO_BASE64_LENGTH = 50 * 1024 * 1024;
var workspaceModeSchema = z4.enum(["worktree", "local", "cloud", "root"]).transform((val) => val === "root" ? "local" : val);
var worktreeInfoSchema = z4.object({
  worktreePath: z4.string(),
  worktreeName: z4.string(),
  branchName: z4.string().nullable(),
  baseBranch: z4.string(),
  createdAt: z4.string(),
  output: z4.string().optional()
});
var workspaceInfoSchema = z4.object({
  taskId: z4.string(),
  mode: workspaceModeSchema,
  worktree: worktreeInfoSchema.nullable(),
  branchName: z4.string().nullable(),
  linkedBranch: z4.string().nullable()
});
var workspaceSchema = z4.object({
  taskId: z4.string(),
  folderId: z4.string(),
  folderPath: z4.string(),
  mode: workspaceModeSchema,
  worktreePath: z4.string().nullable(),
  worktreeName: z4.string().nullable(),
  branchName: z4.string().nullable(),
  baseBranch: z4.string().nullable(),
  linkedBranch: z4.string().nullable(),
  createdAt: z4.string(),
  /**
   * Synthetic workspace for a repo-less channel task: its folderPath is a
   * scratch dir, not a registered folder. Marks it so callers (e.g. the
   * navigation task binder) don't try to register it as a folder or git-init it.
   */
  isScratch: z4.boolean().optional()
});

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

// src/execution-mode.ts
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"
  }
];
if (ALLOW_BYPASS) {
  availableModes.push(
    {
      id: "bypassPermissions",
      name: "Bypass Permissions",
      description: "Auto-accept all permission requests"
    },
    {
      id: "auto",
      name: "Auto Mode",
      description: "Auto-approve file edits and shell commands"
    }
  );
}
var CODE_EXECUTION_MODES = [
  "default",
  "acceptEdits",
  "plan",
  "bypassPermissions",
  "auto"
];
function isCodeExecutionMode(mode) {
  return CODE_EXECUTION_MODES.includes(mode);
}
function getAvailableModes() {
  return ALLOW_BYPASS ? availableModes : availableModes.filter((m) => m.id !== "bypassPermissions");
}
var CODEX_NATIVE_MODES = ["auto", "read-only", "full-access"];
function isCodexNativeMode(mode) {
  return CODEX_NATIVE_MODES.includes(mode);
}
function getAvailableCodexModes() {
  return ALLOW_BYPASS ? [...CODEX_MODE_PRESETS] : CODEX_MODE_PRESETS.filter((m) => m.id !== "full-access");
}
export {
  CODEX_NATIVE_MODES,
  CODE_EXECUTION_MODES,
  getAvailableCodexModes,
  getAvailableModes,
  isCodeExecutionMode,
  isCodexNativeMode
};
//# sourceMappingURL=execution-mode.js.map