"use strict";exports.id=7425,exports.ids=[7425],exports.modules={16672:(e,t,s)=>{s.d(t,{ZP:()=>o}),s(92048);var r=s(55315);function o(){let e=(0,r.dirname)(__dirname);return e.includes("/lib/node_modules/")||e.includes("\\node_modules\\")||e.includes("/node_modules/commandmate")}s(19801)},43753:(e,t,s)=>{s.d(t,{F:()=>o});let r=["/etc","/usr","/bin","/sbin","/var","/tmp","/dev","/sys","/proc"];function o(e){return r.some(t=>e.startsWith(t))}},83513:(e,t,s)=>{s.d(t,{Ho:()=>a,Ns:()=>i,Y1:()=>l,ZP:()=>n,_7:()=>o,tK:()=>r});let r=["claude","codex","gemini","vibe-local","opencode"];function o(e){return r.includes(e)}let a=128,i=2097152;function n(e){return"number"==typeof e&&Number.isInteger(e)&&e>=a&&e<=i}let l=/^[a-zA-Z0-9][a-zA-Z0-9._:/-]*$/},97425:(e,t,s)=>{s.r(t),s.d(t,{closeDbInstance:()=>p,getDbInstance:()=>c});var r=s(85890),o=s.n(r),a=s(55315),i=s.n(a),n=s(75748);let l=[{version:1,name:"initial-schema",up:e=>{(0,n.qZ)(e)},down:e=>{e.exec("DROP TABLE IF EXISTS session_states;"),e.exec("DROP TABLE IF EXISTS chat_messages;"),e.exec("DROP TABLE IF EXISTS worktrees;")}},{version:2,name:"add-multi-repo-and-memo-support",up:e=>{e.exec(`
        ALTER TABLE worktrees ADD COLUMN repository_path TEXT;
        ALTER TABLE worktrees ADD COLUMN repository_name TEXT;
        ALTER TABLE worktrees ADD COLUMN memo TEXT;
        ALTER TABLE worktrees ADD COLUMN last_user_message TEXT;
        ALTER TABLE worktrees ADD COLUMN last_user_message_at INTEGER;
      `),e.exec(`
        CREATE INDEX IF NOT EXISTS idx_worktrees_repository
        ON worktrees(repository_path);
      `);let t=e.prepare("SELECT id, path FROM worktrees").all(),s=e.prepare(`
        UPDATE worktrees
        SET repository_path = ?,
            repository_name = ?
        WHERE id = ?
      `);for(let e of t){let t=_(e.path),r=i().basename(t);s.run(t,r,e.id)}let r=e.prepare(`
        UPDATE worktrees
        SET last_user_message = ?,
            last_user_message_at = ?
        WHERE id = ?
      `);for(let s of t){let t=e.prepare(`
          SELECT content, timestamp
          FROM chat_messages
          WHERE worktree_id = ? AND role = 'user'
          ORDER BY timestamp DESC
          LIMIT 1
        `).get(s.id);if(t){let e=t.content.substring(0,200);r.run(e,t.timestamp,s.id)}}},down:e=>{e.exec(`
        -- Create backup table
        CREATE TABLE worktrees_backup AS
        SELECT id, name, path, last_message_summary, updated_at
        FROM worktrees;

        -- Drop original table
        DROP TABLE worktrees;

        -- Recreate original table
        CREATE TABLE worktrees (
          id TEXT PRIMARY KEY,
          name TEXT NOT NULL,
          path TEXT NOT NULL UNIQUE,
          last_message_summary TEXT,
          updated_at INTEGER
        );

        -- Restore data
        INSERT INTO worktrees (id, name, path, last_message_summary, updated_at)
        SELECT id, name, path, last_message_summary, updated_at
        FROM worktrees_backup;

        -- Drop backup table
        DROP TABLE worktrees_backup;

        -- Drop index
        DROP INDEX IF EXISTS idx_worktrees_repository;
      `)}},{version:3,name:"fix-worktree-repository-paths",up:e=>{let t=e.prepare("SELECT id, path FROM worktrees").all(),s=e.prepare(`
        UPDATE worktrees
        SET repository_path = ?,
            repository_name = ?
        WHERE id = ?
      `);for(let e of t){let t=_(e.path),r=i().basename(t);s.run(t,r,e.id)}},down:()=>{console.log("No rollback needed for repository path fix")}},{version:4,name:"add-favorite-field",up:e=>{e.exec(`
        ALTER TABLE worktrees ADD COLUMN favorite INTEGER DEFAULT 0;
      `),e.exec(`
        CREATE INDEX IF NOT EXISTS idx_worktrees_favorite
        ON worktrees(favorite DESC, updated_at DESC);
      `)},down:e=>{e.exec(`
        -- Drop the index first
        DROP INDEX IF EXISTS idx_worktrees_favorite;

        -- Note: In production, you'd need to recreate the table without the favorite column
        -- This is a simplified down migration
      `)}},{version:5,name:"add-status-field",up:e=>{e.exec(`
        ALTER TABLE worktrees ADD COLUMN status TEXT DEFAULT NULL;
      `),e.exec(`
        CREATE INDEX IF NOT EXISTS idx_worktrees_status
        ON worktrees(status);
      `)},down:e=>{e.exec(`
        DROP INDEX IF EXISTS idx_worktrees_status;
      `)}},{version:6,name:"add-link-field",up:e=>{e.exec(`
        ALTER TABLE worktrees ADD COLUMN link TEXT DEFAULT NULL;
      `)},down:()=>{console.log("No rollback needed for link field")}},{version:7,name:"add-cli-tool-id",up:e=>{e.exec(`
        ALTER TABLE worktrees ADD COLUMN cli_tool_id TEXT DEFAULT 'claude';
      `),e.exec(`
        CREATE INDEX IF NOT EXISTS idx_worktrees_cli_tool
        ON worktrees(cli_tool_id);
      `),e.exec(`
        UPDATE worktrees SET cli_tool_id = 'claude' WHERE cli_tool_id IS NULL;
      `)},down:e=>{e.exec(`
        DROP INDEX IF EXISTS idx_worktrees_cli_tool;
      `),console.log("No full rollback for cli_tool_id column (SQLite limitation)")}},{version:8,name:"change-role-claude-to-assistant",up:e=>{e.exec(`
        CREATE TABLE chat_messages_new (
          id TEXT PRIMARY KEY,
          worktree_id TEXT NOT NULL,
          role TEXT NOT NULL CHECK (role IN ('user', 'assistant')),
          content TEXT NOT NULL,
          summary TEXT,
          timestamp INTEGER NOT NULL,
          log_file_name TEXT,
          request_id TEXT,
          message_type TEXT DEFAULT 'normal',
          prompt_data TEXT,
          cli_tool_id TEXT DEFAULT 'claude',
          FOREIGN KEY (worktree_id) REFERENCES worktrees(id) ON DELETE CASCADE
        );
      `),e.exec(`
        INSERT INTO chat_messages_new
        SELECT
          id,
          worktree_id,
          CASE WHEN role = 'claude' THEN 'assistant' ELSE role END as role,
          content,
          summary,
          timestamp,
          log_file_name,
          request_id,
          message_type,
          prompt_data,
          cli_tool_id
        FROM chat_messages;
      `),e.exec("DROP TABLE chat_messages;"),e.exec("ALTER TABLE chat_messages_new RENAME TO chat_messages;"),e.exec(`
        CREATE INDEX IF NOT EXISTS idx_chat_messages_worktree
        ON chat_messages(worktree_id);
      `),e.exec(`
        CREATE INDEX IF NOT EXISTS idx_chat_messages_timestamp
        ON chat_messages(timestamp);
      `),console.log('✓ Changed role constraint from "claude" to "assistant"'),console.log('✓ Updated existing messages with role="claude" to role="assistant"')},down:e=>{e.exec(`
        CREATE TABLE chat_messages_new (
          id TEXT PRIMARY KEY,
          worktree_id TEXT NOT NULL,
          role TEXT NOT NULL CHECK (role IN ('user', 'claude')),
          content TEXT NOT NULL,
          summary TEXT,
          timestamp INTEGER NOT NULL,
          log_file_name TEXT,
          request_id TEXT,
          message_type TEXT DEFAULT 'normal',
          prompt_data TEXT,
          cli_tool_id TEXT DEFAULT 'claude',
          FOREIGN KEY (worktree_id) REFERENCES worktrees(id) ON DELETE CASCADE
        );
      `),e.exec(`
        INSERT INTO chat_messages_new
        SELECT
          id,
          worktree_id,
          CASE WHEN role = 'assistant' THEN 'claude' ELSE role END as role,
          content,
          summary,
          timestamp,
          log_file_name,
          request_id,
          message_type,
          prompt_data,
          cli_tool_id
        FROM chat_messages;
      `),e.exec("DROP TABLE chat_messages;"),e.exec("ALTER TABLE chat_messages_new RENAME TO chat_messages;"),e.exec(`
        CREATE INDEX IF NOT EXISTS idx_chat_messages_worktree
        ON chat_messages(worktree_id);
      `),e.exec(`
        CREATE INDEX IF NOT EXISTS idx_chat_messages_timestamp
        ON chat_messages(timestamp);
      `),console.log('✓ Rolled back: Changed role constraint from "assistant" to "claude"')}},{version:9,name:"add-in-progress-message-id-to-session-states",up:e=>{e.exec(`
        ALTER TABLE session_states ADD COLUMN in_progress_message_id TEXT DEFAULT NULL;
      `),console.log("✓ Added in_progress_message_id column to session_states table")},down:()=>{console.log("No full rollback for in_progress_message_id column (SQLite limitation)")}},{version:10,name:"add-worktree-memos-table",up:e=>{e.exec(`
        CREATE TABLE worktree_memos (
          id TEXT PRIMARY KEY,
          worktree_id TEXT NOT NULL,
          title TEXT NOT NULL DEFAULT 'Memo',
          content TEXT NOT NULL DEFAULT '',
          position INTEGER NOT NULL DEFAULT 0,
          created_at INTEGER NOT NULL,
          updated_at INTEGER NOT NULL,

          FOREIGN KEY (worktree_id) REFERENCES worktrees(id) ON DELETE CASCADE,
          UNIQUE(worktree_id, position)
        );
      `),e.exec(`
        CREATE INDEX idx_worktree_memos_worktree
          ON worktree_memos(worktree_id, position);
      `);let{randomUUID:t}=s(84770),r=e.prepare(`
        SELECT id, memo FROM worktrees WHERE memo IS NOT NULL AND memo != ''
      `).all(),o=e.prepare(`
        INSERT INTO worktree_memos (id, worktree_id, title, content, position, created_at, updated_at)
        VALUES (?, ?, 'Memo', ?, 0, ?, ?)
      `),a=Date.now();for(let e of r)o.run(t(),e.id,e.memo,a,a);console.log(`✓ Created worktree_memos table`),console.log(`✓ Migrated ${r.length} existing memos to new table`)},down:e=>{e.exec("DROP TABLE IF EXISTS worktree_memos"),console.log("✓ Dropped worktree_memos table")}},{version:11,name:"add-viewed-tracking",up:e=>{e.exec(`
        ALTER TABLE worktrees ADD COLUMN last_viewed_at TEXT;
      `),e.exec(`
        CREATE INDEX IF NOT EXISTS idx_chat_messages_assistant_latest
        ON chat_messages(worktree_id, role, timestamp DESC);
      `),console.log("✓ Added last_viewed_at column to worktrees table"),console.log("✓ Created index for assistant message queries")},down:e=>{e.exec("DROP INDEX IF EXISTS idx_chat_messages_assistant_latest"),console.log("✓ Dropped idx_chat_messages_assistant_latest index")}},{version:12,name:"add-external-apps-table",up:e=>{e.exec(`
        CREATE TABLE IF NOT EXISTS external_apps (
          id TEXT PRIMARY KEY,

          -- Basic info
          name TEXT NOT NULL UNIQUE,
          display_name TEXT NOT NULL,
          description TEXT,

          -- Routing config
          path_prefix TEXT NOT NULL UNIQUE,
          target_port INTEGER NOT NULL,
          target_host TEXT DEFAULT 'localhost',

          -- App type
          app_type TEXT NOT NULL CHECK(app_type IN ('sveltekit', 'streamlit', 'nextjs', 'other')),

          -- WebSocket config
          websocket_enabled INTEGER DEFAULT 0,
          websocket_path_pattern TEXT,

          -- Status
          enabled INTEGER DEFAULT 1,

          -- Metadata
          created_at INTEGER NOT NULL,
          updated_at INTEGER NOT NULL
        );
      `),e.exec(`
        CREATE INDEX idx_external_apps_path_prefix ON external_apps(path_prefix);
      `),e.exec(`
        CREATE INDEX idx_external_apps_enabled ON external_apps(enabled);
      `),console.log("✓ Created external_apps table"),console.log("✓ Created indexes for external_apps")},down:e=>{e.exec("DROP INDEX IF EXISTS idx_external_apps_enabled"),e.exec("DROP INDEX IF EXISTS idx_external_apps_path_prefix"),e.exec("DROP TABLE IF EXISTS external_apps"),console.log("✓ Dropped external_apps table and indexes")}},{version:13,name:"rename-worktree-memo-to-description",up:e=>{e.exec(`
        ALTER TABLE worktrees RENAME COLUMN memo TO description;
      `),console.log("✓ Renamed worktrees.memo column to description")},down:e=>{e.exec(`
        ALTER TABLE worktrees RENAME COLUMN description TO memo;
      `),console.log("✓ Rolled back: Renamed worktrees.description column back to memo")}},{version:14,name:"add-repositories-and-clone-jobs-tables",up:e=>{e.exec(`
        CREATE TABLE IF NOT EXISTS repositories (
          id TEXT PRIMARY KEY,
          name TEXT NOT NULL,
          path TEXT NOT NULL UNIQUE,
          enabled INTEGER NOT NULL DEFAULT 1,
          clone_url TEXT,
          normalized_clone_url TEXT,
          clone_source TEXT CHECK(clone_source IN ('local', 'https', 'ssh')) DEFAULT 'local',
          is_env_managed INTEGER NOT NULL DEFAULT 0,
          created_at INTEGER NOT NULL,
          updated_at INTEGER NOT NULL
        );
      `),e.exec(`
        CREATE UNIQUE INDEX IF NOT EXISTS idx_repositories_normalized_clone_url
        ON repositories(normalized_clone_url)
        WHERE normalized_clone_url IS NOT NULL;
      `),e.exec(`
        CREATE INDEX IF NOT EXISTS idx_repositories_path
        ON repositories(path);
      `),e.exec(`
        CREATE TABLE IF NOT EXISTS clone_jobs (
          id TEXT PRIMARY KEY,
          clone_url TEXT NOT NULL,
          normalized_clone_url TEXT NOT NULL,
          target_path TEXT NOT NULL,
          repository_id TEXT,
          status TEXT NOT NULL CHECK(status IN ('pending', 'running', 'completed', 'failed', 'cancelled')) DEFAULT 'pending',
          pid INTEGER,
          progress INTEGER NOT NULL DEFAULT 0,
          error_category TEXT,
          error_code TEXT,
          error_message TEXT,
          started_at INTEGER,
          completed_at INTEGER,
          created_at INTEGER NOT NULL,

          FOREIGN KEY (repository_id) REFERENCES repositories(id) ON DELETE SET NULL
        );
      `),e.exec(`
        CREATE INDEX IF NOT EXISTS idx_clone_jobs_status
        ON clone_jobs(status);
      `),e.exec(`
        CREATE INDEX IF NOT EXISTS idx_clone_jobs_normalized_clone_url
        ON clone_jobs(normalized_clone_url);
      `),console.log("✓ Created repositories table"),console.log("✓ Created clone_jobs table"),console.log("✓ Created indexes for repositories and clone_jobs")},down:e=>{e.exec("DROP INDEX IF EXISTS idx_clone_jobs_normalized_clone_url"),e.exec("DROP INDEX IF EXISTS idx_clone_jobs_status"),e.exec("DROP TABLE IF EXISTS clone_jobs"),e.exec("DROP INDEX IF EXISTS idx_repositories_path"),e.exec("DROP INDEX IF EXISTS idx_repositories_normalized_clone_url"),e.exec("DROP TABLE IF EXISTS repositories"),console.log("✓ Dropped repositories and clone_jobs tables")}},{version:15,name:"add-initial-branch-column",up:e=>{e.exec(`
        ALTER TABLE worktrees ADD COLUMN initial_branch TEXT;
      `),console.log("✓ Added initial_branch column to worktrees table")},down:e=>{e.exec(`
        -- 1. Create backup table without initial_branch
        CREATE TABLE worktrees_backup AS
        SELECT id, name, path, repository_path, repository_name, description,
               last_user_message, last_user_message_at, last_message_summary,
               favorite, status, link, cli_tool_id, updated_at, last_viewed_at
        FROM worktrees;

        -- 2. Drop original table
        DROP TABLE worktrees;

        -- 3. Recreate table without initial_branch
        CREATE TABLE worktrees (
          id TEXT PRIMARY KEY,
          name TEXT NOT NULL,
          path TEXT NOT NULL UNIQUE,
          repository_path TEXT,
          repository_name TEXT,
          description TEXT,
          last_user_message TEXT,
          last_user_message_at INTEGER,
          last_message_summary TEXT,
          favorite INTEGER DEFAULT 0,
          status TEXT DEFAULT NULL,
          link TEXT DEFAULT NULL,
          cli_tool_id TEXT DEFAULT 'claude',
          updated_at INTEGER,
          last_viewed_at TEXT
        );

        -- 4. Restore data
        INSERT INTO worktrees (id, name, path, repository_path, repository_name,
               description, last_user_message, last_user_message_at, last_message_summary,
               favorite, status, link, cli_tool_id, updated_at, last_viewed_at)
        SELECT id, name, path, repository_path, repository_name,
               description, last_user_message, last_user_message_at, last_message_summary,
               favorite, status, link, cli_tool_id, updated_at, last_viewed_at
        FROM worktrees_backup;

        -- 5. Drop backup
        DROP TABLE worktrees_backup;

        -- 6. Recreate indexes
        CREATE INDEX IF NOT EXISTS idx_worktrees_updated_at
        ON worktrees(updated_at DESC);

        CREATE INDEX IF NOT EXISTS idx_worktrees_repository
        ON worktrees(repository_path);

        CREATE INDEX IF NOT EXISTS idx_worktrees_favorite
        ON worktrees(favorite DESC, updated_at DESC);

        CREATE INDEX IF NOT EXISTS idx_worktrees_status
        ON worktrees(status);

        CREATE INDEX IF NOT EXISTS idx_worktrees_cli_tool
        ON worktrees(cli_tool_id);
      `),console.log("✓ Removed initial_branch column from worktrees table")}},{version:16,name:"add-issue-no-to-external-apps",up:e=>{e.exec(`
        ALTER TABLE external_apps ADD COLUMN issue_no INTEGER;
      `),e.exec(`
        CREATE INDEX IF NOT EXISTS idx_external_apps_issue_no ON external_apps(issue_no);
      `),console.log("✓ Added issue_no column to external_apps table"),console.log("✓ Created index idx_external_apps_issue_no")},down:e=>{e.exec(`
        -- 1. Create backup table without issue_no
        CREATE TABLE external_apps_backup AS
        SELECT id, name, display_name, description, path_prefix, target_port,
               target_host, app_type, websocket_enabled, websocket_path_pattern,
               enabled, created_at, updated_at
        FROM external_apps;

        -- 2. Drop original table (this also drops indexes)
        DROP TABLE external_apps;

        -- 3. Recreate table without issue_no
        CREATE TABLE external_apps (
          id TEXT PRIMARY KEY,
          name TEXT NOT NULL UNIQUE,
          display_name TEXT NOT NULL,
          description TEXT,
          path_prefix TEXT NOT NULL UNIQUE,
          target_port INTEGER NOT NULL,
          target_host TEXT DEFAULT 'localhost',
          app_type TEXT NOT NULL CHECK(app_type IN ('sveltekit', 'streamlit', 'nextjs', 'other')),
          websocket_enabled INTEGER DEFAULT 0,
          websocket_path_pattern TEXT,
          enabled INTEGER DEFAULT 1,
          created_at INTEGER NOT NULL,
          updated_at INTEGER NOT NULL
        );

        -- 4. Restore data
        INSERT INTO external_apps (id, name, display_name, description, path_prefix,
               target_port, target_host, app_type, websocket_enabled, websocket_path_pattern,
               enabled, created_at, updated_at)
        SELECT id, name, display_name, description, path_prefix,
               target_port, target_host, app_type, websocket_enabled, websocket_path_pattern,
               enabled, created_at, updated_at
        FROM external_apps_backup;

        -- 5. Drop backup
        DROP TABLE external_apps_backup;

        -- 6. Recreate original indexes
        CREATE INDEX idx_external_apps_path_prefix ON external_apps(path_prefix);
        CREATE INDEX idx_external_apps_enabled ON external_apps(enabled);
      `),console.log("✓ Removed issue_no column from external_apps table")}},{version:17,name:"add-scheduled-executions-and-execution-logs",up:e=>{e.exec(`
        DELETE FROM chat_messages WHERE worktree_id NOT IN (SELECT id FROM worktrees);
      `),e.exec(`
        DELETE FROM session_states WHERE worktree_id NOT IN (SELECT id FROM worktrees);
      `),e.exec(`
        DELETE FROM worktree_memos WHERE worktree_id NOT IN (SELECT id FROM worktrees);
      `),e.exec(`
        UPDATE clone_jobs SET repository_id = NULL
          WHERE repository_id IS NOT NULL AND repository_id NOT IN (SELECT id FROM repositories);
      `),e.exec(`
        CREATE TABLE scheduled_executions (
          id TEXT PRIMARY KEY,
          worktree_id TEXT NOT NULL,
          cli_tool_id TEXT DEFAULT 'claude',
          name TEXT NOT NULL,
          message TEXT NOT NULL,
          cron_expression TEXT,
          enabled INTEGER DEFAULT 1,
          last_executed_at INTEGER,
          next_execute_at INTEGER,
          created_at INTEGER NOT NULL,
          updated_at INTEGER NOT NULL,
          UNIQUE(worktree_id, name),
          FOREIGN KEY (worktree_id) REFERENCES worktrees(id) ON DELETE CASCADE
        );
      `),e.exec(`
        CREATE INDEX idx_scheduled_executions_worktree
          ON scheduled_executions(worktree_id);
      `),e.exec(`
        CREATE INDEX idx_scheduled_executions_enabled
          ON scheduled_executions(enabled);
      `),e.exec(`
        CREATE TABLE execution_logs (
          id TEXT PRIMARY KEY,
          schedule_id TEXT NOT NULL,
          worktree_id TEXT NOT NULL,
          message TEXT NOT NULL,
          result TEXT,
          exit_code INTEGER,
          status TEXT DEFAULT 'running' CHECK(status IN ('running', 'completed', 'failed', 'timeout', 'cancelled')),
          started_at INTEGER NOT NULL,
          completed_at INTEGER,
          created_at INTEGER NOT NULL,
          FOREIGN KEY (schedule_id) REFERENCES scheduled_executions(id) ON DELETE CASCADE,
          FOREIGN KEY (worktree_id) REFERENCES worktrees(id) ON DELETE CASCADE
        );
      `),e.exec(`
        CREATE INDEX idx_execution_logs_schedule
          ON execution_logs(schedule_id);
      `),e.exec(`
        CREATE INDEX idx_execution_logs_worktree
          ON execution_logs(worktree_id);
      `),e.exec(`
        CREATE INDEX idx_execution_logs_status
          ON execution_logs(status);
      `),console.log("✓ Cleaned up orphan records"),console.log("✓ Created scheduled_executions table"),console.log("✓ Created execution_logs table"),console.log("✓ Created indexes for schedule tables")},down:e=>{e.exec("DROP INDEX IF EXISTS idx_execution_logs_status"),e.exec("DROP INDEX IF EXISTS idx_execution_logs_worktree"),e.exec("DROP INDEX IF EXISTS idx_execution_logs_schedule"),e.exec("DROP TABLE IF EXISTS execution_logs"),e.exec("DROP INDEX IF EXISTS idx_scheduled_executions_enabled"),e.exec("DROP INDEX IF EXISTS idx_scheduled_executions_worktree"),e.exec("DROP TABLE IF EXISTS scheduled_executions"),console.log("✓ Dropped scheduled_executions and execution_logs tables")}},{version:18,name:"add-selected-agents-column",up:e=>{e.exec(`
        ALTER TABLE worktrees ADD COLUMN selected_agents TEXT;
      `),e.exec(`
        UPDATE worktrees SET selected_agents =
          CASE
            WHEN cli_tool_id NOT IN ('claude', 'codex')
            THEN json_array(cli_tool_id, 'claude')
            ELSE '["claude","codex"]'
          END;
      `),console.log("✓ Added selected_agents column to worktrees table"),console.log("✓ Initialized selected_agents based on cli_tool_id")},down:()=>{console.log("No rollback for selected_agents column (SQLite limitation)")}},{version:19,name:"add-vibe-local-model-column",up:e=>{e.exec(`
        ALTER TABLE worktrees ADD COLUMN vibe_local_model TEXT DEFAULT NULL;
      `),console.log("✓ Added vibe_local_model column to worktrees table")},down:()=>{console.log("No rollback for vibe_local_model column (SQLite limitation)")}},{version:20,name:"add-vibe-local-context-window-column",up:e=>{e.exec(`
        ALTER TABLE worktrees ADD COLUMN vibe_local_context_window INTEGER DEFAULT NULL;
      `),console.log("✓ Added vibe_local_context_window column to worktrees table")},down:()=>{console.log("No rollback for vibe_local_context_window column (SQLite limitation)")}}];function _(e){let t=s(92048),r=e;for(;r!==i().dirname(r);){let e=i().join(r,".git");if(t.existsSync(e)){let s=t.statSync(e);if(s.isDirectory())return r;if(s.isFile()){let s=t.readFileSync(e,"utf-8").trim().match(/^gitdir:\s*(.+)$/);if(s)return s[1].split("/.git/")[0]}}r=i().dirname(r)}return e}function E(e){try{let t=e.prepare("SELECT MAX(version) as version FROM schema_version").get();return t?.version??0}catch{return 0}}var d=s(98838);let T=null;function c(){if(!T){let e=(0,d.dU)().CM_DB_PATH,t=s(92048),r=i().dirname(e);t.existsSync(r)||t.mkdirSync(r,{recursive:!0,mode:448}),(T=new(o())(e)).pragma("foreign_keys = ON"),function(e){!function(e){e.exec(`
    CREATE TABLE IF NOT EXISTS schema_version (
      version INTEGER PRIMARY KEY,
      name TEXT NOT NULL,
      applied_at INTEGER NOT NULL
    );
  `)}(e);let t=E(e);console.log(`Current schema version: ${t}`);let s=l.filter(e=>e.version>t);if(0===s.length){console.log("✓ Schema is up to date");return}for(let t of(console.log(`Found ${s.length} pending migration(s)`),s)){console.log(`Applying migration ${t.version}: ${t.name}...`);try{e.transaction(()=>{t.up(e),e.prepare(`
          INSERT INTO schema_version (version, name, applied_at)
          VALUES (?, ?, ?)
        `).run(t.version,t.name,Date.now())})(),console.log(`✓ Migration ${t.version} applied successfully`)}catch(s){let e=s instanceof Error?s.message:String(s);throw console.error(`✗ Migration ${t.version} failed:`,e),Error(`Migration ${t.version} (${t.name}) failed: ${e}`)}}console.log(`✓ All migrations completed. Current version: ${E(e)}`)}(T)}return T}function p(){T&&(T.close(),T=null)}},75748:(e,t,s)=>{s.d(t,{DF:()=>W,Db:()=>b,ER:()=>l,Ek:()=>B,GA:()=>S,GP:()=>x,GZ:()=>R,HE:()=>N,IH:()=>g,Mf:()=>I,Nf:()=>C,Nr:()=>M,OK:()=>A,Of:()=>c,Pv:()=>G,Q7:()=>H,R3:()=>k,S$:()=>D,VW:()=>h,Xv:()=>n,Yg:()=>f,ZI:()=>v,_U:()=>u,_e:()=>P,dD:()=>y,dl:()=>U,ey:()=>X,gU:()=>_,j8:()=>O,ls:()=>L,ly:()=>E,pM:()=>Y,qZ:()=>i,tn:()=>p,vX:()=>m,xr:()=>d,y:()=>T,zl:()=>w});var r=s(84770),o=s(55483);function a(e){return{id:e.id,worktreeId:e.worktree_id,role:e.role,content:e.content,summary:e.summary||void 0,timestamp:new Date(e.timestamp),logFileName:e.log_file_name||void 0,requestId:e.request_id||void 0,messageType:e.message_type||"normal",promptData:e.prompt_data?JSON.parse(e.prompt_data):void 0,cliToolId:e.cli_tool_id??"claude"}}function i(e){e.exec(`
    CREATE TABLE IF NOT EXISTS worktrees (
      id TEXT PRIMARY KEY,
      name TEXT NOT NULL,
      path TEXT NOT NULL UNIQUE,
      last_message_summary TEXT,
      updated_at INTEGER
    );
  `),e.exec(`
    CREATE INDEX IF NOT EXISTS idx_worktrees_updated_at
    ON worktrees(updated_at DESC);
  `),e.exec(`
    CREATE TABLE IF NOT EXISTS chat_messages (
      id TEXT PRIMARY KEY,
      worktree_id TEXT NOT NULL,
      role TEXT NOT NULL CHECK(role IN ('user', 'assistant')),
      content TEXT NOT NULL,
      summary TEXT,
      timestamp INTEGER NOT NULL,
      log_file_name TEXT,
      request_id TEXT,
      message_type TEXT DEFAULT 'normal',
      prompt_data TEXT,
      cli_tool_id TEXT DEFAULT 'claude',

      FOREIGN KEY (worktree_id) REFERENCES worktrees(id) ON DELETE CASCADE
    );
  `),e.exec(`
    CREATE INDEX IF NOT EXISTS idx_messages_worktree_time
    ON chat_messages(worktree_id, timestamp DESC);
  `),e.exec(`
    CREATE INDEX IF NOT EXISTS idx_messages_request_id
    ON chat_messages(request_id);
  `),e.exec(`
    CREATE INDEX IF NOT EXISTS idx_messages_type
    ON chat_messages(message_type, worktree_id);
  `),e.exec(`
    CREATE INDEX IF NOT EXISTS idx_messages_cli_tool
    ON chat_messages(worktree_id, cli_tool_id, timestamp DESC);
  `),e.exec(`
    CREATE TABLE IF NOT EXISTS session_states (
      worktree_id TEXT NOT NULL,
      cli_tool_id TEXT NOT NULL DEFAULT 'claude',
      last_captured_line INTEGER DEFAULT 0,

      PRIMARY KEY (worktree_id, cli_tool_id),
      FOREIGN KEY (worktree_id) REFERENCES worktrees(id) ON DELETE CASCADE
    );
  `)}function n(e,t){let s=`
    SELECT
      w.id, w.name, w.path, w.repository_path, w.repository_name, w.description,
      w.last_user_message, w.last_user_message_at, w.last_message_summary,
      w.updated_at, w.favorite, w.status, w.link, w.cli_tool_id, w.last_viewed_at,
      w.selected_agents, w.vibe_local_model, w.vibe_local_context_window,
      (SELECT MAX(timestamp) FROM chat_messages
       WHERE worktree_id = w.id AND role = 'assistant') as last_assistant_message_at
    FROM worktrees w
  `,r=[];t&&(s+=" WHERE w.repository_path = ?",r.push(t)),s+=" ORDER BY w.updated_at DESC NULLS LAST";let a=e.prepare(s).all(...r),i=function(e,t){if(0===t.length)return new Map;let s=t.map(()=>"?").join(","),r=e.prepare(`
    WITH ranked_messages AS (
      SELECT
        worktree_id,
        cli_tool_id,
        content,
        ROW_NUMBER() OVER (
          PARTITION BY worktree_id, cli_tool_id
          ORDER BY timestamp DESC
        ) as rn
      FROM chat_messages
      WHERE worktree_id IN (${s})
        AND role = 'user'
    )
    SELECT worktree_id, cli_tool_id, content
    FROM ranked_messages
    WHERE rn = 1
  `).all(...t),o=new Map;for(let e of t)o.set(e,{});for(let e of r){let t=o.get(e.worktree_id)||{};t[e.cli_tool_id]=e.content.substring(0,50),o.set(e.worktree_id,t)}return o}(e,a.map(e=>e.id));return a.map(e=>{let t=i.get(e.id)||{};return{id:e.id,name:e.name,path:e.path,repositoryPath:e.repository_path||"",repositoryName:e.repository_name||"",description:e.description||void 0,lastUserMessage:e.last_user_message||void 0,lastUserMessageAt:e.last_user_message_at?new Date(e.last_user_message_at):void 0,lastMessageSummary:e.last_message_summary||void 0,lastMessagesByCli:t,updatedAt:e.updated_at?new Date(e.updated_at):void 0,lastViewedAt:e.last_viewed_at?new Date(e.last_viewed_at):void 0,lastAssistantMessageAt:e.last_assistant_message_at?new Date(e.last_assistant_message_at):void 0,favorite:1===e.favorite,status:e.status||null,link:e.link||void 0,cliToolId:e.cli_tool_id??"claude",selectedAgents:(0,o.e7)(e.selected_agents),vibeLocalModel:e.vibe_local_model??null,vibeLocalContextWindow:e.vibe_local_context_window??null}})}function l(e){return e.prepare(`
    SELECT
      repository_path as path,
      repository_name as name,
      COUNT(*) as worktree_count
    FROM worktrees
    WHERE repository_path IS NOT NULL
    GROUP BY repository_path, repository_name
    ORDER BY repository_name ASC
  `).all().map(e=>({path:e.path,name:e.name,worktreeCount:e.worktree_count}))}function _(e,t){let s=e.prepare(`
    SELECT
      w.id, w.name, w.path, w.repository_path, w.repository_name, w.description,
      w.last_user_message, w.last_user_message_at, w.last_message_summary,
      w.updated_at, w.favorite, w.status, w.link, w.cli_tool_id, w.last_viewed_at,
      w.selected_agents, w.vibe_local_model, w.vibe_local_context_window,
      (SELECT MAX(timestamp) FROM chat_messages
       WHERE worktree_id = w.id AND role = 'assistant') as last_assistant_message_at
    FROM worktrees w
    WHERE w.id = ?
  `).get(t);return s?{id:s.id,name:s.name,path:s.path,repositoryPath:s.repository_path||"",repositoryName:s.repository_name||"",description:s.description||void 0,lastUserMessage:s.last_user_message||void 0,lastUserMessageAt:s.last_user_message_at?new Date(s.last_user_message_at):void 0,lastMessageSummary:s.last_message_summary||void 0,updatedAt:s.updated_at?new Date(s.updated_at):void 0,lastViewedAt:s.last_viewed_at?new Date(s.last_viewed_at):void 0,lastAssistantMessageAt:s.last_assistant_message_at?new Date(s.last_assistant_message_at):void 0,favorite:1===s.favorite,status:s.status||null,link:s.link||void 0,cliToolId:s.cli_tool_id??"claude",selectedAgents:(0,o.e7)(s.selected_agents),vibeLocalModel:s.vibe_local_model??null,vibeLocalContextWindow:s.vibe_local_context_window??null}:null}function E(e,t){e.prepare("DELETE FROM worktrees WHERE path = ? AND id != ?").run(t.path,t.id),e.prepare(`
    INSERT INTO worktrees (
      id, name, path, repository_path, repository_name, description,
      last_user_message, last_user_message_at, last_message_summary, updated_at, cli_tool_id
    )
    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    ON CONFLICT(id) DO UPDATE SET
      name = excluded.name,
      path = excluded.path,
      repository_path = excluded.repository_path,
      repository_name = excluded.repository_name,
      description = COALESCE(excluded.description, worktrees.description),
      last_user_message = COALESCE(excluded.last_user_message, worktrees.last_user_message),
      last_user_message_at = COALESCE(excluded.last_user_message_at, worktrees.last_user_message_at),
      last_message_summary = COALESCE(excluded.last_message_summary, worktrees.last_message_summary),
      updated_at = COALESCE(excluded.updated_at, worktrees.updated_at),
      cli_tool_id = COALESCE(excluded.cli_tool_id, worktrees.cli_tool_id)
  `).run(t.id,t.name,t.path,t.repositoryPath||null,t.repositoryName||null,t.description||null,t.lastUserMessage||null,t.lastUserMessageAt?.getTime()||null,t.lastMessageSummary||null,t.updatedAt?.getTime()||null,t.cliToolId||"claude")}function d(e,t,s){e.prepare(`
    UPDATE worktrees
    SET description = ?
    WHERE id = ?
  `).run(s||null,t)}function T(e,t,s){e.prepare(`
    UPDATE worktrees
    SET link = ?
    WHERE id = ?
  `).run(s||null,t)}function c(e,t,s){e.prepare(`
    UPDATE worktrees
    SET last_viewed_at = ?
    WHERE id = ?
  `).run(s.toISOString(),t)}function p(e,t){let s=(0,r.randomUUID)();return e.prepare(`
    INSERT INTO chat_messages
    (id, worktree_id, role, content, summary, timestamp, log_file_name, request_id, message_type, prompt_data, cli_tool_id)
    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
  `).run(s,t.worktreeId,t.role,t.content,t.summary||null,t.timestamp.getTime(),t.logFileName||null,t.requestId||null,t.messageType||"normal",t.promptData?JSON.stringify(t.promptData):null,t.cliToolId||"claude"),function(e,t,s){e.prepare(`
    UPDATE worktrees
    SET updated_at = ?
    WHERE id = ?
  `).run(s.getTime(),t)}(e,t.worktreeId,t.timestamp),"user"===t.role&&A(e,t.worktreeId,t.content,t.timestamp),{id:s,...t}}function u(e,t,s,r=50,o){let i=`
    SELECT id, worktree_id, role, content, summary, timestamp, log_file_name, request_id, message_type, prompt_data, cli_tool_id
    FROM chat_messages
    WHERE worktree_id = ? AND (? IS NULL OR timestamp < ?)
  `,n=[t,s?.getTime()||null,s?.getTime()||null];return o&&(i+=" AND cli_tool_id = ?",n.push(o)),i+=" ORDER BY timestamp DESC LIMIT ?",n.push(r),e.prepare(i).all(...n).map(a)}function m(e,t){let s=e.prepare(`
    SELECT id, worktree_id, role, content, summary, timestamp, log_file_name, request_id, message_type, prompt_data, cli_tool_id
    FROM chat_messages
    WHERE worktree_id = ? AND role = 'user'
    ORDER BY timestamp DESC
    LIMIT 1
  `).get(t);return s?a(s):null}function N(e,t){e.prepare(`
    DELETE FROM chat_messages
    WHERE worktree_id = ?
  `).run(t),console.log(`[deleteAllMessages] Deleted all messages for worktree: ${t}`)}function L(e,t){return e.prepare(`
    DELETE FROM chat_messages
    WHERE id = ?
  `).run(t).changes>0}function R(e,t,s){let r=e.prepare(`
    DELETE FROM chat_messages
    WHERE worktree_id = ? AND cli_tool_id = ?
  `).run(t,s);return console.log(`[deleteMessagesByCliTool] Deleted ${r.changes} messages for worktree: ${t}, cliTool: ${s}`),r.changes}function w(e,t,s="claude"){let r=e.prepare(`
    SELECT worktree_id, cli_tool_id, last_captured_line, in_progress_message_id
    FROM session_states
    WHERE worktree_id = ? AND cli_tool_id = ?
  `).get(t,s);return r?{worktreeId:r.worktree_id,cliToolId:r.cli_tool_id,lastCapturedLine:r.last_captured_line,inProgressMessageId:r.in_progress_message_id||null}:null}function g(e,t,s,r){e.prepare(`
    INSERT INTO session_states (worktree_id, cli_tool_id, last_captured_line)
    VALUES (?, ?, ?)
    ON CONFLICT(worktree_id, cli_tool_id) DO UPDATE SET
      last_captured_line = excluded.last_captured_line
  `).run(t,s,r)}function I(e,t,s){!function(e,t,s,r){e.prepare(`
    INSERT INTO session_states (worktree_id, cli_tool_id, last_captured_line, in_progress_message_id)
    VALUES (?, ?, 0, ?)
    ON CONFLICT(worktree_id, cli_tool_id) DO UPDATE SET
      in_progress_message_id = excluded.in_progress_message_id
  `).run(t,s,null)}(e,t,s,0)}function O(e,t,s){s?e.prepare(`
      DELETE FROM session_states
      WHERE worktree_id = ? AND cli_tool_id = ?
    `).run(t,s):e.prepare(`
      DELETE FROM session_states
      WHERE worktree_id = ?
    `).run(t)}function A(e,t,s,r){let o=e.prepare(`
    UPDATE worktrees
    SET last_user_message = ?,
        last_user_message_at = ?
    WHERE id = ?
  `),a=s.substring(0,200);o.run(a,r.getTime(),t)}function D(e,t){let s=e.prepare(`
    SELECT id, worktree_id, role, content, summary, timestamp, log_file_name, request_id, message_type, prompt_data, cli_tool_id
    FROM chat_messages
    WHERE id = ?
  `).get(t);return s?a(s):null}function S(e,t,s){e.prepare(`
    UPDATE chat_messages
    SET prompt_data = ?
    WHERE id = ?
  `).run(JSON.stringify(s),t)}function x(e,t,s){let r=e.prepare(`
    SELECT id, prompt_data
    FROM chat_messages
    WHERE worktree_id = ?
      AND cli_tool_id = ?
      AND message_type = 'prompt'
      AND json_extract(prompt_data, '$.status') = 'pending'
    ORDER BY timestamp DESC
  `).all(t,s);if(0===r.length)return 0;let o=e.prepare(`
    UPDATE chat_messages
    SET prompt_data = ?
    WHERE id = ?
  `),a=0;for(let e of r)try{let t=JSON.parse(e.prompt_data);t.status="answered",t.answer="(answered via terminal)",t.answeredAt=new Date().toISOString(),o.run(JSON.stringify(t),e.id),a++}catch{}return a}function k(e,t,s){e.prepare(`
    UPDATE worktrees
    SET favorite = ?
    WHERE id = ?
  `).run(s?1:0,t)}function C(e,t,s){e.prepare(`
    UPDATE worktrees
    SET status = ?
    WHERE id = ?
  `).run(s,t)}function h(e,t,s){e.prepare(`
    UPDATE worktrees
    SET cli_tool_id = ?
    WHERE id = ?
  `).run(s,t)}function X(e,t,s){e.prepare(`
    UPDATE worktrees
    SET selected_agents = ?
    WHERE id = ?
  `).run(JSON.stringify(s),t)}function U(e,t,s){e.prepare(`
    UPDATE worktrees
    SET vibe_local_model = ?
    WHERE id = ?
  `).run(s,t)}function f(e,t,s){e.prepare(`
    UPDATE worktrees
    SET vibe_local_context_window = ?
    WHERE id = ?
  `).run(s,t)}function F(e){return{id:e.id,worktreeId:e.worktree_id,title:e.title,content:e.content,position:e.position,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function b(e,t){return e.prepare(`
    SELECT id, worktree_id, title, content, position, created_at, updated_at
    FROM worktree_memos
    WHERE worktree_id = ?
    ORDER BY position ASC
  `).all(t).map(F)}function v(e,t){let s=e.prepare(`
    SELECT id, worktree_id, title, content, position, created_at, updated_at
    FROM worktree_memos
    WHERE id = ?
  `).get(t);return s?F(s):null}function y(e,t,s){let o=(0,r.randomUUID)(),a=Date.now(),i=s.title??"Memo",n=s.content??"";return e.prepare(`
    INSERT INTO worktree_memos (id, worktree_id, title, content, position, created_at, updated_at)
    VALUES (?, ?, ?, ?, ?, ?, ?)
  `).run(o,t,i,n,s.position,a,a),{id:o,worktreeId:t,title:i,content:n,position:s.position,createdAt:new Date(a),updatedAt:new Date(a)}}function M(e,t,s){let r=Date.now(),o=["updated_at = ?"],a=[r];void 0!==s.title&&(o.push("title = ?"),a.push(s.title)),void 0!==s.content&&(o.push("content = ?"),a.push(s.content)),a.push(t),e.prepare(`
    UPDATE worktree_memos
    SET ${o.join(", ")}
    WHERE id = ?
  `).run(...a)}function P(e,t){e.prepare(`
    DELETE FROM worktree_memos
    WHERE id = ?
  `).run(t)}function B(e,t,s){e.prepare(`
    UPDATE worktrees
    SET initial_branch = ?
    WHERE id = ?
  `).run(s,t)}function H(e,t){let s=e.prepare(`
    SELECT initial_branch
    FROM worktrees
    WHERE id = ?
  `).get(t);return s?.initial_branch??null}function G(e,t){return e.prepare(`
    SELECT id FROM worktrees WHERE repository_path = ?
  `).all(t).map(e=>e.id)}function W(e,t){return{deletedCount:e.prepare(`
    DELETE FROM worktrees WHERE repository_path = ?
  `).run(t).changes}}function Y(e,t){if(0===t.length)return{deletedCount:0};let s=t.map(()=>"?").join(",");return{deletedCount:e.prepare(`
    DELETE FROM worktrees WHERE id IN (${s})
  `).run(...t).changes}}},98838:(e,t,s)=>{s.d(t,{dU:()=>u,Hb:()=>T,LI:()=>p});var r=s(55315),o=s.n(r),a=s(19801),i=s(16672),n=s(43753);function l(){return(0,i.ZP)()?o().join((0,a.homedir)(),".commandmate","data","cm.db"):o().resolve(process.cwd(),"data","cm.db")}function _(e){let t=o().resolve(e);if((0,i.ZP)()){let e=(0,a.homedir)();if(!t.startsWith(e))throw Error(`Security error: DB path must be within home directory: ${t}`)}else if((0,n.F)(t))throw Error(`Security error: DB path cannot be in system directory: ${t}`);return t}let E={CM_ROOT_DIR:"MCBD_ROOT_DIR",CM_PORT:"MCBD_PORT",CM_BIND:"MCBD_BIND",CM_LOG_LEVEL:"MCBD_LOG_LEVEL",CM_LOG_FORMAT:"MCBD_LOG_FORMAT",CM_LOG_DIR:"MCBD_LOG_DIR",CM_DB_PATH:"MCBD_DB_PATH"},d=new Set;function T(e){return function(e,t){let s=process.env[e];if(void 0!==s)return s;let r=process.env[t];if(void 0!==r)return d.has(t)||(console.warn(`[DEPRECATED] ${t} is deprecated, use ${e} instead`),d.add(t)),r}(e,E[e])}let c=!1;function p(){let e=T("CM_LOG_LEVEL")?.toLowerCase(),t=T("CM_LOG_FORMAT")?.toLowerCase();return{level:void 0!==e&&["debug","info","warn","error"].includes(e)?e:"info",format:"json"===t?"json":"text"}}function u(){let e;let t=T("CM_ROOT_DIR")||process.cwd(),s=parseInt(T("CM_PORT")||"3000",10),r=T("CM_BIND")||"127.0.0.1",a=T("CM_DB_PATH")||function(){let e=process.env.DATABASE_PATH;return e&&!c&&(console.warn("[DEPRECATED] DATABASE_PATH is deprecated. Use CM_DB_PATH instead."),c=!0),e}()||l();if(!t)throw Error("CM_ROOT_DIR (or MCBD_ROOT_DIR) is required");if(isNaN(s)||s<1||s>65535)throw Error(`Invalid CM_PORT: ${T("CM_PORT")}. Must be between 1 and 65535.`);if("127.0.0.1"!==r&&"0.0.0.0"!==r&&"localhost"!==r)throw Error(`Invalid CM_BIND: ${r}. Must be '127.0.0.1', '0.0.0.0', or 'localhost'.`);try{e=_(a)}catch{console.warn(`[Security] Invalid DB path "${a}", using default.`),e=_(l())}return{CM_ROOT_DIR:o().resolve(t),CM_PORT:s,CM_BIND:r,CM_DB_PATH:e}}},55483:(e,t,s)=>{s.d(t,{KE:()=>_,e7:()=>l});var r=s(83513);let o=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07]*\x07|\[[0-9;]*m/g;function a(e){return e.replace(o,"").replace(/[\n\r]/g," ").substring(0,100)}let i=["claude","codex"];function n(e){return 2!==e.length?{valid:!1,error:"Must be 2 elements"}:e.every(e=>"string"==typeof e&&r.tK.includes(e))?e[0]===e[1]?{valid:!1,error:"Duplicate tool IDs not allowed"}:{valid:!0,value:e}:{valid:!1,error:"Invalid CLI tool ID"}}function l(e){if(!e)return i;try{let t=JSON.parse(e);if(!Array.isArray(t))return console.warn(`[selected-agents] Invalid format in DB, falling back to default: ${a(e)}`),i;let s=n(t);if(!s.valid)return console.warn(`[selected-agents] Invalid data in DB (${s.error}), falling back to default: ${a(e)}`),i;return s.value}catch{return console.warn(`[selected-agents] JSON parse error in DB, falling back to default: ${a(e)}`),i}}function _(e){return Array.isArray(e)&&2===e.length?n(e):{valid:!1,error:"selected_agents must be an array of 2 elements"}}}};