Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

142 KB
Raw Blame
<!doctype html>
<!-- `<html lang>` is updated to the user's preferred language by i18n.js at
     script-load (line 1118), based on the sync bundle preload exposed on
     window.__orkasI18nBoot. The fallback `en` here is what shows if both the
     preload bridge and the IPC handler are unavailable. -->
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>Orkas</title>
  <link rel="stylesheet" href="./style.css" />
</head>
<body>
  <div class="app-container">
    <aside class="sidebar">
      <div class="sidebar-logo">
        <img class="logo-icon" src="../resources/icons/logo.png" alt="" draggable="false" />
        <div class="logo-text">Orkas</div>
        <button class="sidebar-logo-version" id="sidebar-version" type="button"></button>
      </div>
      <button class="sidebar-search-btn" id="sidebar-search-btn" data-i18n-title="sidebar.search_title" title="Global search (Cmd/Ctrl+K)">
        <span data-ui-icon="search" data-ui-icon-class="sidebar-search-icon"></span>
        <span class="sidebar-search-label" data-i18n="sidebar.search">Search</span>
        <span class="sidebar-search-kbd">
          <span data-ui-icon="command" data-ui-icon-class="ui-icon sidebar-search-command-icon"></span><span>K</span>
        </span>
      </button>
      <div class="sidebar-actions">
        <button class="sidebar-btn primary" id="new-chat-btn"><span data-ui-icon="message-square" data-ui-icon-class="sidebar-btn-icon"></span><span data-i18n="sidebar.new_chat">New Task</span><span class="sidebar-btn-running-chip" id="commander-running-chip" hidden></span></button>
        <!-- One flat list, in the release_1.8.0 order. -->
        <button class="sidebar-btn" id="todos-btn"><span data-ui-icon="clipboard-list" data-ui-icon-class="sidebar-btn-icon"></span><span data-i18n="project.todo.title">To-do</span></button>
        <button class="sidebar-btn" id="auto-btn"><span data-ui-icon="clock" data-ui-icon-class="sidebar-btn-icon"></span><span data-i18n="sidebar.auto">Auto</span></button>
        <button class="sidebar-btn" id="agents-btn"><span data-ui-icon="users" data-ui-icon-class="sidebar-btn-icon"></span><span data-i18n="sidebar.agents">Agents</span></button>
        <button class="sidebar-btn" id="skills-btn"><span data-ui-icon="sparkles" data-ui-icon-class="sidebar-btn-icon"></span><span data-i18n="sidebar.skills">Skills</span></button>
        <button class="sidebar-btn" id="connectors-btn"><span data-ui-icon="plug" data-ui-icon-class="sidebar-btn-icon"></span><span data-i18n="sidebar.connectors">Connectors</span></button>
        <button class="sidebar-btn" id="contexts-btn"><span data-ui-icon="database" data-ui-icon-class="sidebar-btn-icon"></span><span data-i18n="sidebar.contexts">Library</span></button>
        <button class="sidebar-btn" id="apps-btn"><span data-ui-icon="layout-grid" data-ui-icon-class="sidebar-btn-icon"></span><span data-i18n="sidebar.apps">Apps</span></button>
      </div>
      <div class="sidebar-conversation-nav">
        <div class="sidebar-section sidebar-today-section">
          <div class="sidebar-section-title-row">
            <button class="sidebar-section-toggle" id="today-section-toggle" type="button"
                    aria-controls="today-list" aria-expanded="true">
              <span data-ui-icon="chevron-down" data-ui-icon-class="sidebar-section-chevron"></span>
              <span class="sidebar-section-title" data-i18n="sidebar.today_tasks">Recent Tasks</span>
              <span class="task-unread-dot" id="today-unread-dot" hidden aria-hidden="true"></span>
            </button>
          </div>
          <div class="today-list" id="today-list"></div>
        </div>
        <div class="sidebar-section sidebar-projects-section">
          <div class="sidebar-section-title-row">
            <button class="sidebar-section-toggle" id="projects-section-toggle" type="button"
                    aria-controls="projects-list" aria-expanded="true">
              <span data-ui-icon="chevron-down" data-ui-icon-class="sidebar-section-chevron"></span>
              <span class="sidebar-section-title" data-i18n="sidebar.projects">Projects</span>
              <span class="task-unread-dot" id="projects-unread-dot" hidden aria-hidden="true"></span>
            </button>
            <button class="sidebar-section-add" id="projects-add-btn"
                    data-i18n-title="sidebar.project_create_title"
                    data-i18n-aria-label="sidebar.project_create_title"
                    title="New project" aria-label="New project">+</button>
          </div>
          <div class="projects-list" id="projects-list"></div>
        </div>
        <div class="sidebar-section sidebar-conversations-section">
          <div class="sidebar-section-title-row">
            <button class="sidebar-section-toggle" id="tasks-section-toggle" type="button"
                    aria-controls="conversation-list" aria-expanded="true">
              <span data-ui-icon="chevron-down" data-ui-icon-class="sidebar-section-chevron"></span>
              <span class="sidebar-section-title" data-i18n="sidebar.conversations">Tasks</span>
              <span class="task-unread-dot" id="tasks-unread-dot" hidden aria-hidden="true"></span>
              <span class="sidebar-btn-running-chip" id="tasks-running-chip" hidden></span>
            </button>
          </div>
          <div class="conversation-list" id="conversation-list">
            <div class="conv-empty" data-i18n="sidebar.conv_empty">No conversations yet</div>
          </div>
        </div>
      </div>
      <div class="sidebar-footer-actions">
        <div class="sidebar-footer-action-row">
          <button class="sidebar-footer-btn" id="settings-btn" data-i18n-title="sidebar.settings_title" title="Settings">
            <span data-ui-icon="settings" data-ui-icon-class="sidebar-footer-icon"></span>
            <span class="sidebar-footer-label" data-i18n="sidebar.settings">Settings</span>
          </button>
        </div>
      </div>
      <div class="sidebar-resize-handle" id="sidebar-resize-handle"
           role="separator" aria-orientation="vertical" tabindex="0"
           data-i18n-aria-label="sidebar.resize_title"
           aria-label="Drag to resize · double-click to reset"
           data-i18n-title="sidebar.resize_title"
           title="Drag to resize · double-click to reset"></div>
    </aside>

    <main class="main-content">
      <!-- Commander home: the composer stays above the scrollable work list. -->
      <section class="panel active" id="panel-new-chat" data-home-state="pending">
        <div class="new-chat-center">
          <div class="new-chat-header">
            <h1 class="new-chat-greeting" id="new-chat-greeting" data-i18n="new_chat.title_fallback">Friend, what do you want to accomplish?</h1>
          </div>
          <div class="new-chat-input-wrapper">
            <div class="new-chat-input-area">
              <!-- Floats above the input box. Attachments wrap on the left;
                   the workspace chip moved into .chat-bottom-bar below
                   (next to recipient / project chips) so the overlay only
                   carries attachments now. -->
              <div class="chat-input-overlay">
                <div class="chat-attachments" id="new-chat-attachments" style="display:none"></div>
              </div>
              <div class="chat-quote-preview" id="new-chat-quote-preview" style="display:none"></div>
              <div data-composer="1" id="new-chat-input" data-i18n-placeholder="new_chat.home.input_placeholder" placeholder="Describe what you want to accomplish, or attach the files to work on"></div>
              <!-- Composer bottom bar order matches PC/docs/design/PATTERNS.md
                   P11: [+] | divider | [To] | [workspace - JS-injected] |
                   [skill] | spacer | [microphone] | [send]. -->
              <div class="chat-bottom-bar">
                <button type="button" class="chat-attach-btn" id="new-chat-attach-btn" data-i18n-title="new_chat.attach_title" title="Upload attachment (documents, spreadsheets, presentations, archives, images, audio, and video)">+</button>
                <span class="chat-composer-divider" aria-hidden="true"></span>
                <button type="button" class="chat-recipient-chip" id="new-chat-recipient-chip" data-i18n-title="chat.recipient_picker_title_with_library" title="Choose agent, skill, connector, or Library file">
                  <span class="chat-recipient-prefix" data-i18n="chat.recipient_label">To: </span>
                  <span class="chat-recipient-name" id="new-chat-recipient-name" data-i18n="chat.recipient_commander">Commander</span>
                </button>
                <!-- Workspace chip is injected by user-workspace.js::initUserWorkspace
                     immediately after the recipient chip; mounting position is
                     centralized there so the open-conversation composer stays in
                     sync without duplicating the markup. -->
                <div class="chat-skill-chip" id="new-chat-skill-chip" data-target="new-chat" style="display:none">
                  <span class="chip-label"></span>
                  <button type="button" class="chip-close" data-i18n-title="chat.chip_remove_title" data-i18n-aria-label="chat.chip_remove_title" title="Remove" aria-label="Remove">
                    <span data-ui-icon="x" data-ui-icon-class="chip-close-icon"></span>
                  </button>
                </div>
                <button type="button" class="chat-attach-btn chat-mic-btn" id="new-chat-mic-btn" data-i18n-title="chat.mic_title" title="Voice input">
                  <span data-ui-icon="mic" data-ui-icon-class="chat-mic-icon"></span>
                </button>
                <button id="new-chat-send-btn" class="chat-send-btn" data-i18n-title="new_chat.send_title" title="Send">
                  <span data-ui-icon="send" data-ui-icon-class="send-icon"></span>
                </button>
              </div>
            </div>
          </div>
          <!-- Everything below the composer. This is the only part of the
               home that scrolls, so the composer is never inside a scroller. -->
          <div class="home-below">
            <!-- Empty: two equal ways to start. Copy only; the one control is the
                 connect link that home.js renders inside the context line. -->
            <div class="home-paths">
              <section class="home-path" aria-labelledby="home-goal-title">
                <h2 class="home-path-title" id="home-goal-title" data-i18n="new_chat.home.goal_title">Have a clear goal? Hand it to Commander.</h2>
                <p class="home-path-body" data-i18n="new_chat.home.goal_body">Tell Commander what you want to accomplish, and it will coordinate your AI team to get it done.</p>
                <p class="home-path-note" data-i18n="new_chat.home.goal_example">For example: research 3 similar products, compare their features and pricing, and turn the findings into a presentation.</p>
              </section>
              <section class="home-path" aria-labelledby="home-explore-title">
                <h2 class="home-path-title" id="home-explore-title" data-i18n="new_chat.home.explore_title">Not sure yet? Let Orkas get to know you first.</h2>
                <p class="home-path-body" data-i18n="new_chat.home.explore_body">Talk about your work, your business, or what's on your mind, and Orkas will help you find the right goals and keep them moving.</p>
                <p class="home-path-note" id="home-explore-context"></p>
              </section>
            </div>
            <!-- Server-orderable quick start list. Main-process client config
                 supplies the ordered ids; conversation.js renders localized
                 cards and binds their matching built-in/default agent. -->
            <section class="new-chat-scenarios quick-panel" id="new-chat-scenarios" aria-labelledby="quick-panel-title">
              <div class="quick-panel-head">
                <span class="quick-panel-title" id="quick-panel-title" data-i18n="new_chat.quick.title">Try one of these tasks — one click to get started</span>
                <span class="quick-panel-rule" aria-hidden="true"></span>
              </div>
              <div class="quick-grid" id="new-chat-scenario-grid"></div>
            </section>
            <!-- Populated: the three groups are rendered by home.js. -->
            <section class="home-work" id="home-work" aria-labelledby="home-continue-title">
              <div class="home-continue-label" id="home-continue-title">
                <span data-i18n="new_chat.home.continue_label">Keep things moving</span>
                <span class="home-continue-rule" aria-hidden="true"></span>
              </div>
              <div class="home-groups" id="home-groups"></div>
            </section>
          </div>
        </div>
      </section>

      <!-- Conversation Detail -->
      <section class="panel" id="panel-conversation">
        <div class="chat-container">
          <div class="chat-main-pane">
            <!-- Conversation header — Surface C top per PC/docs/design/PATTERNS.md.
                 Title + project swatch + name + stacked agent
                 avatars + counts + 详情 toggle. Filled in by JS lifecycle hook
                 `_refreshChatHeader()` in conversation.js. -->
            <div class="chat-header" id="chat-header">
              <button type="button" class="btn btn-sm" id="chat-cleanup-back" data-i18n="common.back" hidden>Back</button>
              <div class="chat-header-main">
                <div class="chat-header-title-row">
                  <h1 class="chat-header-title" id="chat-header-title"></h1>
                  <input type="text" class="chat-header-title-input" id="chat-header-title-input"
                         autocomplete="off" spellcheck="false" hidden />
                </div>
                <div class="chat-header-meta" id="chat-header-meta"></div>
              </div>
              <div class="chat-header-actions">
                <button type="button" class="chat-header-menu-btn" id="chat-header-menu-btn"
                        title="More actions" aria-label="More actions">
                  <span data-ui-icon="more-horizontal" data-ui-icon-class="chat-header-menu-icon"></span>
                </button>
                <button type="button" class="chat-header-details-btn" id="video-review-toggle" hidden
                        data-i18n-title="video_review.toggle_title"
                        data-i18n-aria-label="video_review.toggle_title"
                        title="Video review" aria-label="Video review" aria-expanded="false">
                  <span data-ui-icon="film" data-ui-icon-class="chat-header-details-icon"></span>
                </button>
                <button type="button" class="chat-header-details-btn" id="conversation-info-toggle"
                        data-i18n-title="conversation_info.toggle_title"
                        data-i18n-aria-label="conversation_info.toggle_title"
                        title="Conversation info" aria-label="Conversation info" aria-expanded="false">
                  <span data-ui-icon="panel" data-ui-icon-class="chat-header-details-icon"></span>
                </button>
              </div>
            </div>
            <div id="chat-history" class="chat-history">
              <div class="empty" data-i18n="chat.empty">No messages yet...</div>
            </div>
            <nav id="chat-turn-nav" class="chat-turn-nav"
                 data-i18n-aria-label="chat.turn_nav_label"
                 aria-label="Conversation turns" hidden>
              <div id="chat-turn-nav-markers" class="chat-turn-nav-markers"></div>
              <div id="chat-turn-nav-preview" class="chat-turn-nav-preview" role="tooltip" hidden>
                <div id="chat-turn-nav-preview-title" class="chat-turn-nav-preview-title"></div>
                <div id="chat-turn-nav-preview-body" class="chat-turn-nav-preview-body"></div>
              </div>
            </nav>
            <div class="chat-input-wrapper">
              <div class="chat-composer-panels">
                <div id="chat-cli-questions" hidden></div>
                <!-- Conversation task board: surfaces when a second live task
                     exists, then stays PINNED above the composer showing the
                     latest batch's state; the header toggles collapse (wired by
                     task-board.js). Reuses the chat-queue style family. -->
                <div class="chat-queue" id="chat-task-board" style="display:none">
                  <div class="chat-queue-header">
                    <span class="chat-queue-label"><span class="chat-queue-chevron" id="chat-task-board-chevron" aria-hidden="true" data-ui-icon="chevron-down" data-ui-icon-class="ui-icon chat-queue-agent-chevron"></span><span data-i18n="chat.task_board_label">Tasks</span> <span class="chat-queue-count" id="chat-task-board-count">0</span></span>
                    <span class="chat-queue-hint" id="chat-task-board-hint"></span>
                  </div>
                  <div class="chat-queue-list" id="chat-task-board-list"></div>
                </div>
                <div class="chat-input-overlay">
                  <div class="chat-attachments" id="chat-attachments" style="display:none"></div>
                </div>
              </div>
              <div class="chat-input-area">
                <div class="chat-quote-preview" id="chat-quote-preview" style="display:none"></div>
                <div data-composer="1" id="chat-input" data-i18n-placeholder="chat.input_placeholder" placeholder="Type @ to choose agents, skills, connectors, Library files."></div>
                <!-- Composer bottom bar order matches PC/docs/design/PATTERNS.md
                     P11: [+] | divider | [To] | [workspace - JS-injected] |
                     [skill] | spacer | [send].                      by `chat-send-btn { margin-left: auto }`. -->
                <div class="chat-bottom-bar">
                  <button type="button" class="chat-attach-btn" id="chat-attach-btn" data-i18n-title="chat.attach_title" title="Upload attachment (documents, spreadsheets, presentations, archives, images, audio, and video)">+</button>
                  <span class="chat-composer-divider" aria-hidden="true"></span>
                  <button type="button" class="chat-recipient-chip" id="chat-recipient-chip" data-i18n-title="chat.recipient_picker_title" title="Choose agent, skill, or connector">
                    <span class="chat-recipient-prefix" data-i18n="chat.recipient_label">To: </span>
                    <span class="chat-recipient-name" id="chat-recipient-name" data-i18n="chat.recipient_commander">Commander</span>
                  </button>
                  <!-- Workspace chip is injected by user-workspace.js right after
                       the recipient chip — see initUserWorkspace(). -->
                  <div class="chat-skill-chip" id="chat-skill-chip" data-target="conversation" style="display:none">
                    <span class="chip-label"></span>
                    <button type="button" class="chip-close" data-i18n-title="chat.chip_remove_title" data-i18n-aria-label="chat.chip_remove_title" title="Remove" aria-label="Remove">
                      <span data-ui-icon="x" data-ui-icon-class="chip-close-icon"></span>
                    </button>
                  </div>
                  <button type="button" class="chat-attach-btn chat-mic-btn" id="chat-mic-btn" data-i18n-title="chat.mic_title" title="Voice input">
                    <span data-ui-icon="mic" data-ui-icon-class="chat-mic-icon"></span>
                  </button>
                <button id="chat-send-btn" class="chat-send-btn" data-i18n-title="chat.send_title" title="Send">
                    <span data-ui-icon="check" data-ui-icon-class="queue-save-icon"></span>
                    <span data-ui-icon="send" data-ui-icon-class="send-icon"></span>
                    <span data-ui-icon="stop" data-ui-icon-class="stop-icon"></span>
                  </button>
                </div>
              </div>
            </div>
          </div>
          <aside class="conversation-info-panel task-side-panel" id="conversation-info-panel" hidden>
            <div class="conversation-info-resize task-side-panel-resize" id="conversation-info-resize" role="separator"
                 tabindex="0" aria-orientation="vertical"
                 data-i18n-title="conversation_info.resize" data-i18n-aria-label="conversation_info.resize"
                 title="Resize task details" aria-label="Resize task details"></div>
            <div class="conversation-info-header">
              <div class="conversation-info-title" data-i18n="conversation_info.title">Conversation info</div>
              <button type="button" class="conversation-info-icon-btn conversation-info-close" id="conversation-info-close"
                      data-i18n-title="common.close" data-i18n-aria-label="common.close"
                      title="Close" aria-label="Close">
                <span data-ui-icon="x" data-ui-icon-class="conversation-info-icon-svg"></span>
              </button>
            </div>
            <!-- Tabs: each carries an icon + label + count chip filled by
                 ConversationInfo._renderBody() from the snapshot. Active tab
                 chrome (underline + bold + soft-primary chip) handled in CSS
                 via .is-active. -->
            <div class="conversation-info-tabs" role="tablist">
              <button type="button" class="conversation-info-tab is-active" data-info-tab="files">
                <span data-ui-icon="folder" data-ui-icon-class="conversation-info-tab-icon"></span>
                <span class="conversation-info-tab-label" data-i18n="conversation_info.tab_files">Files</span>
                <span class="conversation-info-tab-count" id="conversation-info-tab-count-files"></span>
              </button>
              <button type="button" class="conversation-info-tab" data-info-tab="attachments">
                <span data-ui-icon="paperclip" data-ui-icon-class="conversation-info-tab-icon"></span>
                <span class="conversation-info-tab-label" data-i18n="conversation_info.tab_attachments">Attachments</span>
                <span class="conversation-info-tab-count" id="conversation-info-tab-count-attachments"></span>
              </button>
              <button type="button" class="conversation-info-tab" data-info-tab="browser">
                <span data-ui-icon="globe" data-ui-icon-class="conversation-info-tab-icon"></span>
                <span class="conversation-info-tab-label" data-i18n="conversation_info.tab_browser">Browser</span>
                <span class="conversation-info-tab-count" id="conversation-info-tab-count-browser"></span>
              </button>
            </div>
            <div class="conversation-info-body" id="conversation-info-body"></div>
          </aside>
          <!-- Markdown viewer / editor drawer. Hosts the shared mountMdViewEdit
               component (modules/md-view-edit.js) for either an assistant-
               generated .md file (workspace source) or a free-form scratch
               edit triggered from a chat-selection context menu (ephemeral
               source). Slides in from the right just like conversation-info,
               but is its own single-purpose surface. -->
          <aside class="chat-md-drawer-panel" id="chat-md-drawer-panel" hidden>
            <div class="chat-md-drawer-header">
              <div class="chat-md-drawer-title" id="chat-md-drawer-title"></div>
              <div class="chat-md-drawer-actions detail-actions" id="chat-md-drawer-actions"></div>
              <button type="button" class="chat-md-drawer-close" id="chat-md-drawer-close"
                      data-i18n-title="common.close" data-i18n-aria-label="common.close"
                      title="Close" aria-label="Close">×</button>
            </div>
            <div class="chat-md-drawer-body markdown-body" id="chat-md-drawer-body"></div>
          </aside>
          <!-- Host-owned VideoStudio review panel (P2): renders scenes,
               preview evidence, and narration audition for the CURRENT
               production straight from production state. Read-only; its
               action buttons only prefill the composer.
               See modules/video-review-panel.js. -->
          <aside class="video-review-panel task-side-panel" id="video-review-panel" hidden>
            <div class="task-side-panel-resize" id="video-review-resize" role="separator"
                 tabindex="0" aria-orientation="vertical" aria-labelledby="video-review-panel-title"></div>
            <div class="chat-md-drawer-header">
              <div class="chat-md-drawer-title" id="video-review-panel-title" data-i18n="video_review.title">Video production</div>
              <div class="chat-md-drawer-actions detail-actions">
                <button type="button" class="btn btn-sm" id="video-review-panel-refresh"
                        data-i18n="video_review.refresh">Refresh</button>
              </div>
              <button type="button" class="chat-md-drawer-close" id="video-review-panel-close"
                      data-i18n-title="common.close" data-i18n-aria-label="common.close"
                      title="Close" aria-label="Close">×</button>
            </div>
            <div class="chat-md-drawer-body" id="video-review-panel-body"></div>
          </aside>
        </div>
      </section>

      <!-- Skills -->
      <section class="panel" id="panel-skills">
        <!-- Grid view (default) -->
        <div class="skills-grid-view" id="skills-grid-view">
          <div class="skills-grid-header">
            <span data-i18n="skills.title">Skills</span>
            <!-- Skills entry cluster. Same named-entry treatment as the AI
                 Team header above: the icon carries the old `+`, and each
                 label says what it opens. Ids and targets are unchanged:
                 `skills-more-btn` still opens the skill marketplace. -->
            <div class="header-actions header-entry-actions">
              <button class="btn header-entry-btn header-entry-btn-create" id="create-skill-btn">
                <span data-ui-icon="plus" data-ui-icon-class="header-entry-icon"></span>
                <span data-i18n="skills.add">Create skill</span>
              </button>
              <button class="btn header-entry-btn header-entry-btn-market" id="skills-more-btn">
                <span data-ui-icon="shopping-cart" data-ui-icon-class="header-entry-icon"></span>
                <span data-i18n="skills.more_btn">Skill marketplace</span>
              </button>
            </div>
          </div>
          <div class="marketplace-reconcile-banner" data-reconcile-banner data-reconcile-kind="skill" style="display:none"></div>
          <!-- Category chip strip — see the parallel comment on agents-categories. -->
          <div class="marketplace-categories skills-categories" id="skills-categories"></div>
          <div class="skills-grid-scroll">
            <div class="skills-grid" id="skills-grid"></div>
            <div class="skills-empty" id="skills-empty" data-i18n="skills.empty">No skills yet</div>
          </div>
        </div>

        <!-- Detail view (replaces grid when a card is opened) -->
        <div class="skills-detail-view" id="skills-detail-view" style="display:none">
          <div class="skills-detail-col" id="skills-detail-col">
            <div class="skills-detail-content" id="skills-detail-content" style="display:none">
              <div class="skills-doc-headline">
                <button type="button" class="btn btn-sm" id="skills-back-btn" data-i18n="common.back">Back</button>
                <h1 class="skills-doc-title" id="skills-detail-name" data-editable="false"></h1>
                <span class="skills-doc-source" id="skills-detail-source"></span>
                <div class="skills-doc-actions" id="skills-detail-actions">
                  <button type="button" class="skill-card-use skill-dialog-btn" id="skill-use-btn" data-i18n="skills.use" data-i18n-title="skills.use_tooltip" data-i18n-aria-label="skills.use_tooltip" aria-label="Use this skill">Use</button>
                  <button class="btn btn-sm" id="skill-edit-btn" data-i18n="skills.edit">Edit</button>
                  <button class="btn btn-sm" id="skill-enabled-btn" data-i18n="component.disable">Disable</button>
                  <button class="btn btn-sm" id="skill-upload-marketplace-btn" style="display:none" data-i18n="marketplace.upload">Upload to marketplace (dev)</button>
                  <button class="btn btn-sm btn-danger" id="skill-delete-btn" data-i18n="skills.delete">Delete</button>
                </div>
              </div>

              <section class="skills-doc-section" id="skills-section-summary">
                <h3 class="skills-doc-section-label" data-i18n="skills.label_summary">Summary</h3>
                <div class="skills-doc-section-body" id="skills-detail-summary"></div>
              </section>

              <section class="skills-doc-section" id="skills-section-category">
                <h3 class="skills-doc-section-label" data-i18n="skills.label_category">Category</h3>
                <div class="skills-doc-section-body">
                  <div class="skills-detail-category" id="skills-detail-category"></div>
                </div>
              </section>

              <section class="skills-doc-section" id="skills-section-extra" style="display:none">
                <h3 class="skills-doc-section-label" data-i18n="skills.label_extra">Other attributes</h3>
                <div class="skills-doc-section-body" id="skills-detail-extra"></div>
              </section>

              <section class="skills-doc-section skills-usage-section">
                <h3 class="skills-doc-section-label skills-usage-label">
                  <span data-i18n="skills.label_usage">Usage</span>
                  <button type="button" class="skills-source-toggle" id="skills-source-toggle" aria-expanded="false">
                    <span class="skills-source-toggle-caret" aria-hidden="true" data-ui-icon="chevron-right" data-ui-icon-class="ui-icon"></span>
                    <span data-i18n="skills.label_source">View source</span>
                  </button>
                </h3>
                <div class="skills-source-panel" id="skills-source-panel" style="display:none">
                  <div class="skills-source-tree" id="skills-source-tree"></div>
                </div>
                <div class="skills-doc-section-body markdown-body" id="skills-detail-body"></div>
              </section>
            </div>
          </div>
          <!-- Shown when a URL import was installed as an external package: no
               skill content to edit; point the user to package management. -->
          <div class="skills-detail-content" id="skills-as-package" style="display:none">
            <div class="skills-doc-headline">
              <button type="button" class="btn btn-sm" id="skills-as-package-back" data-i18n="common.back">Back</button>
              <h1 class="skills-doc-title" id="skills-as-package-name"></h1>
            </div>
            <section class="skills-doc-section">
              <div class="skills-doc-section-body" id="skills-as-package-desc"></div>
              <button class="btn btn-sm" id="skills-as-package-manage" data-i18n="skills.as_package.manage">Manage packages</button>
            </section>
          </div>
          <!-- Inline chat for custom skill editing -->
          <div class="skills-chat-col" id="skills-chat-col" style="display:none">
            <div class="skills-chat-toolbar">
              <button id="skill-chat-clear-btn" class="skill-chat-link" data-i18n-title="skills.clear_chat_title" title="Clear the edit chat for this skill" data-i18n="skills.clear_chat">Clear</button>
            </div>
            <div class="skills-chat-messages" id="skills-chat-messages"></div>
            <div class="chat-queue" id="skills-chat-queue" style="display:none">
              <div class="chat-queue-header">
                <span class="chat-queue-label"><span data-i18n="chat.queue_label">Queued</span> <span class="chat-queue-count" id="skills-chat-queue-count">0</span></span>
                <span class="chat-queue-hint" data-i18n="chat.queue_hint">Drag to reorder · Edit · Delete</span>
              </div>
              <div class="chat-queue-list" id="skills-chat-queue-list"></div>
            </div>
            <div class="skills-chat-input-area">
              <div class="chat-attachments edit-chat-attachments" id="skills-chat-attachments" style="display:none"></div>
              <button type="button" class="chat-attach-btn edit-chat-attach-btn" id="skills-chat-attach-btn" data-i18n-title="chat.attach_title" title="Upload attachment (documents, spreadsheets, presentations, archives, images, audio, and video)">+</button>
              <textarea id="skills-chat-input" data-i18n-placeholder="skills.chat_input_placeholder" placeholder="Describe what to change..." rows="1"></textarea>
              <button id="skills-chat-send-btn" class="chat-send-btn" data-i18n-title="chat.send_title" title="Send">
                <span data-ui-icon="send" data-ui-icon-class="send-icon"></span>
                <span data-ui-icon="stop" data-ui-icon-class="stop-icon"></span>
              </button>
            </div>
          </div>
        </div>
      </section>

      <!-- Agents -->
      <section class="panel" id="panel-agents">
        <!-- Grid view (default) -->
        <div class="agents-grid-view" id="agents-grid-view">
          <div class="agents-grid-header">
            <div class="agents-grid-header-titles">
              <span class="agents-grid-title" data-i18n="agents.title">AI Team</span>
              <span class="agents-grid-subtitle" data-i18n="agents.subtitle">Every member is an agent — @ it, form squads, assign tasks.</span>
            </div>
            <!-- AI Team entry cluster. The old icon-less `+ Create` / `More`
                 chips were too small to find, so each entry now names what it
                 opens and the coding-CLI flow — previously only the create
                 dialog's second tab — gets its own button. Ids and targets are
                 unchanged: `agents-more-btn` still opens the agent
                 marketplace. -->
            <div class="header-actions header-entry-actions">
              <button class="btn header-entry-btn header-entry-btn-create" id="create-agent-btn">
                <span data-ui-icon="plus" data-ui-icon-class="header-entry-icon"></span>
                <span data-i18n="agents.create_btn">Create agent</span>
              </button>
              <button class="btn header-entry-btn header-entry-btn-cli" id="agents-connect-cli-btn">
                <span data-ui-icon="terminal" data-ui-icon-class="header-entry-icon"></span>
                <span class="header-entry-copy">
                  <span data-i18n="agents.connect_cli_btn">Connect an agent</span>
                  <small data-i18n="agents.connect_cli_sub">Claude Code / Codex CLIs</small>
                </span>
              </button>
              <button class="btn header-entry-btn header-entry-btn-market" id="agents-more-btn">
                <span data-ui-icon="shopping-cart" data-ui-icon-class="header-entry-icon"></span>
                <span data-i18n="agents.market_btn">Agent marketplace</span>
              </button>
            </div>
          </div>
          <div class="marketplace-reconcile-banner" data-reconcile-banner data-reconcile-kind="agent" style="display:none"></div>
          <!-- Category chip strip — mirrors `.marketplace-categories` above the
               grid. Chips are injected by renderAgentsGrid() from the same
               `_mpCategoriesCache` that drives the marketplace strip. -->
          <div class="marketplace-categories agents-categories" id="agents-categories"></div>
          <div class="agents-grid-scroll">
            <div class="agents-grid" id="agents-grid"></div>
            <div class="agents-empty" id="agents-empty" data-i18n="agents.empty">No agents yet</div>
          </div>
        </div>

        <!-- Detail view (replaces grid when a card is opened) -->
        <div class="agents-detail-view" id="agents-detail-view" style="display:none">
          <div class="agents-detail-col" id="agents-detail-col">
            <div class="agents-detail-content" id="agents-detail-content" style="display:none">
              <div class="agents-detail-header">
                <div class="agents-detail-title-row">
                  <button type="button" class="btn btn-sm" id="agents-back-btn" data-i18n="common.back">Back</button>
                  <span class="agents-detail-avatar-slot" id="agents-detail-avatar"></span>
                  <div class="agents-detail-name" id="agents-detail-name" contenteditable="false"></div>
                  <input type="text" class="agents-detail-name-input" id="agents-detail-name-input" autocomplete="off" spellcheck="false" hidden />
                  <span class="agents-detail-source" id="agents-detail-source"></span>
                  <div class="detail-actions" id="agents-detail-actions">
                    <button type="button" class="agent-card-use agent-dialog-btn" id="agent-use-btn" data-i18n="agents.use" data-i18n-title="agents.use_tooltip" data-i18n-aria-label="agents.use_tooltip" aria-label="Use this agent">Use</button>
                    <button class="btn btn-sm" id="agent-edit-btn" data-i18n="agents.edit_btn_edit">Edit</button>
                    <button class="btn btn-sm" id="agent-enabled-btn" data-i18n="component.disable">Disable</button>
                    <button class="btn btn-sm" id="agent-upload-marketplace-btn" style="display:none" data-i18n="marketplace.upload">Upload to marketplace (dev)</button>
                    <button class="btn btn-sm btn-danger" id="agent-delete-btn" data-i18n="agents.delete">Delete</button>
                  </div>
                </div>
              </div>
              <div class="agents-detail-body">
                <div class="agents-detail-hero">
                  <div class="agents-detail-section agents-detail-intro-section" id="agents-detail-intro-section">
                    <div class="agents-detail-label" data-i18n="agents.label_desc">Summary</div>
                    <div class="agents-detail-desc" id="agents-detail-desc" contenteditable="false"></div>
                  </div>
                  <div class="agents-detail-section agents-detail-stats-section" id="agents-detail-stats-section" style="display:none">
                    <div class="agents-detail-label" data-i18n="agents.label_runtime_stats">Runtime data</div>
                    <div class="agents-detail-stats" id="agents-detail-stats"></div>
                  </div>
                  <div class="agents-detail-section" id="agents-detail-runtime-section" style="display:none">
                    <div class="agents-detail-label" data-i18n="agents.label_runtime">External agent</div>
                    <div class="agents-detail-runtime" id="agents-detail-runtime"></div>
                  </div>
                  <div class="agents-detail-section" id="agents-detail-cli-settings-section" style="display:none">
                    <div class="agents-detail-label" data-i18n="agents.label_cli_settings">Runtime settings</div>
                    <div class="agents-detail-cli-settings" id="agents-detail-cli-settings"></div>
                  </div>
                  <div class="agents-detail-section" id="agents-detail-cli-usage-section" hidden>
                    <div class="agents-detail-label" data-i18n="agents.cli_usage_title">Remaining allowance</div>
                    <div id="agents-detail-cli-usage" aria-live="polite"></div>
                  </div>
                  <div class="agents-detail-section" id="agents-detail-project-dir-section" style="display:none">
                    <div class="agents-detail-label" data-i18n="agents.label_project_dir">Project directory</div>
                    <div class="agents-detail-project-dir" id="agents-detail-project-dir"></div>
                  </div>
                </div>
                <div class="agents-detail-section" id="agents-detail-memory-section" style="display:none">
                  <div class="agents-detail-label" data-i18n="agents.label_core_memory">Core memory</div>
                  <p class="agents-detail-section-desc" data-i18n="agents.core_memory_desc">Persistent memory this agent has built with you.</p>
                  <div class="agents-detail-list" id="agents-detail-memory"></div>
                </div>
                <div class="agents-detail-section" id="agents-detail-knowhow-section" style="display:none">
                  <div class="agents-detail-label" data-i18n="agents.label_knowhow">Know-how</div>
                  <p class="agents-detail-section-desc" data-i18n="agents.knowhow_desc">Task areas this agent is better at.</p>
                  <div class="agents-detail-list" id="agents-detail-knowhow"></div>
                </div>
                <div class="agents-detail-section" id="agents-detail-output-standards-section" style="display:none">
                  <div class="agents-detail-label" data-i18n="agents.label_delivery_standards">Delivery standards</div>
                  <p class="agents-detail-section-desc" data-i18n="agents.delivery_standards_desc">Standards this agent checks before delivering.</p>
                  <div class="agents-detail-list" id="agents-detail-output-standards"></div>
                </div>
                <div class="agents-detail-section" id="agents-detail-input-output-section" style="display:none">
                  <div class="agents-detail-label" data-i18n="agents.label_input_output">Input / output</div>
                  <div class="agents-detail-io" id="agents-detail-input-output">
                    <div class="agents-detail-io-row" id="agents-detail-inputs-row">
                      <div class="agents-detail-io-label" data-i18n="agents.label_inputs">Inputs</div>
                      <div class="agents-detail-tag-row" id="agents-detail-inputs"></div>
                    </div>
                    <div class="agents-detail-io-row" id="agents-detail-output-format-control">
                      <div class="agents-detail-io-label" data-i18n="agents.label_output_format">Output format</div>
                      <div class="agents-detail-output-format" id="agents-detail-output-format"></div>
                    </div>
                  </div>
                </div>
                <div class="agents-detail-section agents-detail-section-workflow">
                  <div class="agents-detail-label" data-i18n="agents.label_workflow">Workflow</div>
                  <div class="agents-detail-workflow markdown-body" id="agents-detail-workflow" contenteditable="false"></div>
                </div>
              </div>
            </div>
          </div>
          <!-- Inline chat for agent editing -->
          <div class="agents-chat-col" id="agents-chat-col" style="display:none">
            <div class="agents-chat-toolbar">
              <button id="agent-chat-clear-btn" class="agent-chat-link" data-i18n-title="agents.clear_chat_title" title="Clear the edit chat for this agent" data-i18n="agents.clear_chat">Clear</button>
            </div>
            <div class="agents-chat-messages" id="agents-chat-messages"></div>
            <div class="chat-queue" id="agents-chat-queue" style="display:none">
              <div class="chat-queue-header">
                <span class="chat-queue-label"><span data-i18n="chat.queue_label">Queued</span> <span class="chat-queue-count" id="agents-chat-queue-count">0</span></span>
                <span class="chat-queue-hint" data-i18n="chat.queue_hint">Drag to reorder · Edit · Delete</span>
              </div>
              <div class="chat-queue-list" id="agents-chat-queue-list"></div>
            </div>
            <div class="agents-chat-input-area">
              <div class="chat-attachments edit-chat-attachments" id="agents-chat-attachments" style="display:none"></div>
              <button type="button" class="chat-attach-btn edit-chat-attach-btn" id="agents-chat-attach-btn" data-i18n-title="chat.attach_title" title="Upload attachment (documents, spreadsheets, presentations, archives, images, audio, and video)">+</button>
              <textarea id="agents-chat-input" data-i18n-placeholder="agents.chat_input_placeholder" placeholder="Describe what to adjust..." rows="1"></textarea>
              <button id="agents-chat-send-btn" class="chat-send-btn" data-i18n-title="chat.send_title" title="Send">
                <span data-ui-icon="send" data-ui-icon-class="send-icon"></span>
                <span data-ui-icon="stop" data-ui-icon-class="stop-icon"></span>
              </button>
            </div>
          </div>
        </div>
      </section>

      <!-- Marketplace (entered via the More button on agents / skills tabs;
           closes back to its origin view via openMarketplace's return-stack).
           Two sub-views — grid (browse + categories) and detail (full content + install). -->
      <section class="panel" id="panel-marketplace">
        <!-- Grid view (default) -->
        <div class="marketplace-grid-view" id="marketplace-grid-view">
          <div class="marketplace-header">
            <button type="button" class="btn btn-sm" data-mp-close data-i18n="common.back">Back</button>
            <div class="marketplace-tabs">
              <button type="button" class="marketplace-tab" data-mp-tab="agent" data-i18n="marketplace.tab_agent">Agents</button>
              <button type="button" class="marketplace-tab" data-mp-tab="skill" data-i18n="marketplace.tab_skill">Skills</button>
              <button type="button" class="marketplace-tab marketplace-tab--oss" data-mp-tab="oss"><span data-i18n="marketplace.tab_oss">Open Source</span><span class="marketplace-tab-new" data-i18n="marketplace.tab_new">NEW</span></button>
            </div>
            <div class="marketplace-search-wrap">
              <input type="text" class="marketplace-search" data-mp-search data-i18n-placeholder="marketplace.search_ph" />
              <button type="button" class="marketplace-search-clear" data-mp-search-clear data-i18n-title="common.clear" hidden>&times;</button>
            </div>
            <button type="button" class="btn btn-sm btn-primary marketplace-search-btn" data-mp-search-btn data-i18n="marketplace.search">Search</button>
          </div>
          <div class="marketplace-categories" data-mp-categories></div>
          <div class="marketplace-body" data-mp-body></div>
        </div>

        <!-- Detail view (replaces grid when a card is clicked) -->
        <div class="marketplace-detail-view" id="marketplace-detail-view" style="display:none">
          <div class="marketplace-detail-header">
            <button type="button" class="btn btn-sm" data-mp-detail-back data-i18n="common.back">Back</button>
            <span class="marketplace-detail-avatar-slot" data-mp-detail-avatar></span>
            <div class="marketplace-detail-title-wrap">
              <span class="marketplace-detail-title" data-mp-detail-name></span>
              <span class="marketplace-detail-meta-row" data-mp-detail-meta></span>
            </div>
            <button type="button" class="btn btn-sm btn-primary" data-mp-detail-install></button>
          </div>
          <div class="marketplace-detail-body" data-mp-detail-body></div>
        </div>
      </section>

      <!-- Project detail — Surface inherits new-chat / conversation chrome.
           Page header (P1) above a centered composer, a tabbed task
           workspace, and a right rail for project agents + Library. -->
      <section class="panel" id="panel-todos">
        <div class="project-detail-view">
          <div class="project-detail-content">
            <header class="project-detail-header">
              <div class="project-detail-header-main">
                <h1 class="project-detail-title" data-i18n="project.todo.title">To-do</h1>
              </div>
              <div class="project-detail-actions todo-page-actions">
                <div class="project-detail-tab-group" role="group" data-i18n-aria-label="todo.grouping" aria-label="Group tasks">
                  <button class="btn btn-sm" type="button" data-todo-group="project" aria-pressed="true" data-i18n="todo.by_project">By project</button>
                  <button class="btn btn-sm" type="button" data-todo-group="status" aria-pressed="false" data-i18n="todo.by_status">By status</button>
                </div>
                <button class="btn btn-sm" id="todos-add-btn" type="button" data-i18n="todo.add_short">+ Create</button>
              </div>
            </header>
            <div class="todos-workarea">
              <div class="todo-load-error" id="todos-error" role="status" hidden><span data-i18n="todo.load_failed">Could not load tasks. Try again.</span><button class="btn btn-sm" id="todos-retry" data-i18n="chat.retry_btn">Retry</button></div>
              <div class="todos-scroll" id="todos-content" aria-live="polite"></div>
            </div>
          </div>
        </div>
      </section>
      <section class="panel" id="panel-project">
        <div class="project-detail-view">
          <div class="project-detail-content" id="project-detail-content">
            <!-- Local rename and delete use the shared header menu. -->
            <header class="project-detail-header">
              <div class="project-detail-header-main">
                <div class="project-detail-header-title-row">
                  <h1 class="project-detail-title" id="project-detail-title"></h1>
                  <input type="text" class="project-detail-title-input" id="project-detail-title-input"
                         style="display:none" autocomplete="off" spellcheck="false" />
                </div>
              </div>
              <div class="project-detail-actions">
                <button type="button" class="btn btn-sm" id="project-action-rename" data-i18n="project.action.done" hidden>Done</button>
                <button type="button" class="project-header-icon-btn" id="project-action-more" aria-haspopup="menu"
                        data-i18n-title="project.menu.more_actions" data-i18n-aria-label="project.menu.more_actions" title="More actions" aria-label="More actions">
                  <span data-ui-icon="more-horizontal" data-ui-icon-class="project-header-icon"></span>
                </button>
              </div>
            </header>

            <div class="project-detail-grid">
              <div class="project-detail-main">
                <!-- Shared P11 composer chrome. Re-uses `.chat-input-area` so
                     border / radius / shadow / focus state stay in sync with
                     the empty-state and conversation composers. -->
                <div class="chat-input-area is-project">
                  <div class="chat-input-overlay">
                    <div class="chat-attachments" id="project-chat-attachments" style="display:none"></div>
                  </div>
                  <div class="chat-quote-preview" id="project-chat-quote-preview" style="display:none"></div>
                  <div data-composer="1" id="project-chat-input" data-i18n-placeholder="project.chat.placeholder" placeholder="Type @ to choose agents, skills, connectors, Library files."></div>
                  <!-- Bottom bar: attach | divider | model (JS-injected) | recipient | workspace (JS-injected) | order toggle | skill | send. -->
                  <div class="chat-bottom-bar">
                    <button type="button" class="chat-attach-btn" id="project-chat-attach-btn" data-i18n-title="chat.attach_title" title="Upload attachment (documents, spreadsheets, presentations, archives, images, audio, and video)">+</button>
                    <span class="chat-composer-divider" aria-hidden="true"></span>
                    <button type="button" class="chat-recipient-chip" id="project-chat-recipient-chip" data-i18n-title="chat.recipient_picker_title" title="Choose agent, skill, or connector">
                      <span class="chat-recipient-prefix" data-i18n="chat.recipient_label">To: </span>
                      <span class="chat-recipient-name" id="project-chat-recipient-name" data-i18n="chat.recipient_commander">Commander</span>
                    </button>
                    <!-- Workspace chip is injected by user-workspace.js right after
                         the recipient chip — see initUserWorkspace(). -->
                    <div class="chat-skill-chip" id="project-chat-skill-chip" data-target="project" style="display:none">
                      <span class="chip-label"></span>
                      <button type="button" class="chip-close" data-i18n-title="chat.chip_remove_title" data-i18n-aria-label="chat.chip_remove_title" title="Remove" aria-label="Remove">
                        <span data-ui-icon="x" data-ui-icon-class="chip-close-icon"></span>
                      </button>
                    </div>
                    <button type="button" class="chat-attach-btn chat-mic-btn" id="project-chat-mic-btn" data-i18n-title="chat.mic_title" title="Voice input">
                      <span data-ui-icon="mic" data-ui-icon-class="chat-mic-icon"></span>
                    </button>
                    <button type="button" class="chat-send-btn" id="project-chat-send-btn" data-i18n-title="chat.send_title" title="Send">
                      <span data-ui-icon="send" data-ui-icon-class="send-icon"></span>
                    </button>
                  </div>
                </div>

                <!-- Tabbed workspace: project tasks, automation and to-dos. The
                     active tab's tools share the tab row. Agents and Library
                     live in the right rail. -->
                <section class="project-workbench">
                  <div class="project-detail-tabs">
                    <div class="project-detail-tab-group" role="tablist">
                      <button type="button" class="project-detail-tab is-active" data-project-tab="tasks">
                        <span data-i18n="project.tab_tasks">Tasks</span>
                        <span class="project-detail-tab-count" id="project-tasks-count">0</span>
                      </button>
                      <button type="button" class="project-detail-tab" data-project-tab="auto">
                        <span data-i18n="project.tab_auto">Automation</span>
                        <span class="project-detail-tab-count" id="project-auto-tab-count">0</span>
                      </button>
                      <button type="button" class="project-detail-tab" data-project-tab="todo">
                        <span data-i18n="project.todo.title">To-do</span>
                        <span class="project-detail-tab-count" id="project-todo-count">0</span>
                      </button>
                    </div>
                    <!-- _syncProjectDetailTabState shows the active tab's group. -->
                    <div class="project-tab-tools" data-project-tools="auto" hidden>
                      <button type="button" class="btn btn-sm" id="project-auto-add-btn" data-i18n="auto.add_btn">+ Create</button>
                    </div>
                    <div class="project-tab-tools" data-project-tools="todo" hidden>
                      <!-- All / Mine, filled for shared projects by _renderProjectTodosList. -->
                      <div class="project-todo-filter" id="project-todo-filter"></div>
                      <button type="button" class="project-driver-toggle is-switch" id="project-driver-toggle"
                              data-i18n-title="project.driver.toggle_hint"
                              title="AI handles to-dos automatically for you to review when finished. Runs only on the device where you turn it on." aria-pressed="false"><span class="project-driver-switch" aria-hidden="true"></span><span data-i18n="project.driver.toggle">Auto</span><span id="project-driver-device"></span></button>
                      <button type="button" class="project-driver-hint" id="project-driver-hint"
                              data-i18n-aria-label="project.driver.toggle_hint" aria-label="AI handles to-dos automatically for you to review when finished. Runs only on the device where you turn it on."
                              aria-describedby="project-driver-tooltip"><span data-ui-icon="info" data-ui-icon-class="project-driver-hint-icon"></span></button>
                      <button type="button" class="btn btn-sm" id="project-todo-add-btn"
                              data-i18n="todo.add_short" data-i18n-title="project.todo.add" title="Create task">+ Create</button>
                    </div>
                  </div>
                  <div class="project-detail-tab-panel" data-project-panel="tasks">
                    <div class="project-tasks-list" id="project-tasks-list"></div>
                    <div class="project-tasks-empty empty muted" id="project-tasks-empty" data-i18n="project.tasks_empty">No tasks yet</div>
                  </div>
                  <div class="project-detail-tab-panel" data-project-panel="auto" hidden>
                    <div class="auto-sync-note" id="project-auto-sync-note" hidden></div>
                    <div class="auto-list" id="project-auto-list"></div>
                    <div class="empty muted" id="project-auto-empty" data-i18n="auto.empty">No auto tasks yet</div>
                  </div>
                  <div class="project-detail-tab-panel" data-project-panel="todo" hidden>
                    <div class="todo-load-error" id="project-todo-error" role="status" hidden><span data-i18n="todo.load_failed">Could not load tasks. Try again.</span><button class="btn btn-sm" id="project-todo-retry" data-i18n="chat.retry_btn">Retry</button></div>
                    <div class="project-tasks-list project-todo-list" id="project-todo-list"></div>
                  </div>
                </section>
              </div>
              <aside class="project-detail-side" aria-label="Project resources">
                <section class="project-side-card project-side-context">
                  <!-- Head is two rows: the card identity, then the context
                       type tabs. Instructions and memory are different
                       long-lived stores, so the tabs get their own line
                       instead of sharing one 44px strip with the title. -->
                  <div class="project-side-card-head project-side-card-head-tabs">
                    <div class="project-side-card-head-top">
                      <div class="project-side-card-title-wrap">
                        <span class="project-side-card-title" data-i18n="project.context.title">Context</span>
                      </div>
                      <span class="project-side-card-scope" data-i18n="project.context.scope">Shared by every conversation</span>
                    </div>
                    <div class="project-side-tabs" role="tablist" data-project-side-tabs="context">
                      <button type="button" class="project-side-tab is-active" data-project-side-tab="instructions">
                        <span data-i18n="project.context.instructions_tab">Goals &amp; rules</span>
                      </button>
                      <button type="button" class="project-side-tab" data-project-side-tab="memory">
                        <span data-i18n="project.context.memory_tab">Memory</span>
                        <span class="project-side-tab-count" id="project-memory-count"></span>
                      </button>
                    </div>
                  </div>
                  <!-- Instructions read first, edit on demand: the saved rules
                       are what every conversation actually gets, so the panel
                       shows them as copy and moves the editor into a dialog
                       instead of parking an empty textarea in the rail. -->
                  <div class="project-side-panel project-side-instructions-panel" data-project-side-panel="instructions">
                    <div class="project-context-section-head">
                      <h3 class="project-context-section-title" data-i18n="project.instructions.heading">Rules in effect</h3>
                      <button type="button" class="btn btn-sm project-context-action" id="project-instructions-edit-btn"
                              data-i18n="common.edit">Edit</button>
                    </div>
                    <div class="project-instructions-read" id="project-instructions-read"></div>
                    <div class="project-instructions-empty" id="project-instructions-empty" hidden>
                      <p class="project-context-help" data-i18n="project.instructions.subtitle">Set project goals, priorities, and rules. The AI follows them in every conversation.</p>
                      <button type="button" class="btn btn-sm" id="project-instructions-setup-btn"
                              data-i18n="project.instructions.setup">Set goals and rules</button>
                    </div>
                    <div class="project-context-status" id="project-instructions-status" role="status"></div>
                  </div>
                  <div class="project-side-panel project-side-memory-panel" data-project-side-panel="memory" hidden>
                    <!-- Same shape as the rules panel: guidance while the
                         store is empty, heading once there is something to
                         read. -->
                    <div class="project-context-section-head" id="project-memory-section-head" hidden>
                      <h3 class="project-context-section-title" data-i18n="project.memory.heading">Saved facts and decisions</h3>
                      <button type="button" class="btn btn-sm project-context-action" id="project-memory-add-btn"
                              data-project-context-action="memory" hidden
                              data-i18n="project.memory.add_short"
                              data-i18n-title="project.memory.add" title="Add memory"
                              data-i18n-aria-label="project.memory.add" aria-label="Add memory">Add</button>
                    </div>
                    <p class="project-context-help project-memory-full" id="project-memory-full" role="status" hidden
                       data-i18n="memory.full_notice">Memory is full. Before saving something new, the AI will merge existing entries.</p>
                    <div class="project-memory-editor" id="project-memory-editor" hidden>
                      <textarea class="project-memory-editor-input" id="project-memory-editor-input" rows="3" maxlength="2500"
                                data-i18n-placeholder="project.memory.placeholder" placeholder="Record a durable fact, decision, or project update"></textarea>
                      <div class="project-memory-editor-foot">
                        <span class="project-memory-editor-counter muted" id="project-memory-editor-counter">0/2500</span>
                        <span class="project-memory-editor-actions">
                          <button type="button" class="btn btn-sm" id="project-memory-editor-cancel" data-i18n="project.memory.cancel">Cancel</button>
                          <button type="button" class="btn btn-sm btn-primary" id="project-memory-editor-save" data-i18n="project.memory.save">Save</button>
                        </span>
                      </div>
                    </div>
                    <div class="project-side-card-list project-memory-list" id="project-memory-list"></div>
                    <div class="empty project-memory-empty-state" id="project-memory-empty">
                      <p class="project-context-help" data-i18n="project.memory.subtitle">Record project facts, decisions, and progress for the AI to reference in future conversations.</p>
                      <button type="button" class="btn btn-sm" id="project-memory-add-empty-btn"
                              data-i18n="project.memory.add">Add memory</button>
                    </div>
                  </div>
                </section>

                <section class="project-side-card project-side-resources">
                  <div class="project-side-card-head project-side-card-head-tabs">
                    <div class="project-side-card-head-top">
                      <div class="project-side-card-title-wrap">
                        <span class="project-side-card-title" data-i18n="project.resources.title">Resources</span>
                      </div>
                      <button type="button" class="project-side-icon-btn" id="project-add-agent-btn"
                              data-project-resource-action="agents"
                              data-i18n-title="project.bindings.add_agent" title="Add"
                              data-i18n-aria-label="project.bindings.add_agent" aria-label="Add">
                        <span data-ui-icon="plus" data-ui-icon-class="project-side-add-icon"></span>
                      </button>
                      <button type="button" class="project-side-icon-btn project-library-add-btn ctx-row-menu-btn ctx-root-menu-btn" id="project-library-root-menu-btn"
                              data-project-resource-action="files" hidden
                              data-i18n-title="contexts.menu.more_actions" title="More actions"
                              data-i18n-aria-label="contexts.menu.more_actions" aria-label="More actions">
                        <span data-ui-icon="plus" data-ui-icon-class="project-side-add-icon"></span>
                      </button>
                    </div>
                    <div class="project-side-tabs" role="tablist" data-project-side-tabs="resources">
                      <button type="button" class="project-side-tab is-active" data-project-side-tab="agents">
                        <span data-i18n="project.resources.agents_tab">Agents</span>
                        <span class="project-side-tab-count" id="project-detail-agents-count"></span>
                      </button>
                      <button type="button" class="project-side-tab" data-project-side-tab="files">
                        <span data-i18n="project.resources.files_tab">Library</span>
                        <span class="project-side-tab-count" id="project-detail-files-count"></span>
                      </button>
                    </div>
                  </div>
                  <div class="project-side-panel project-side-agents-panel" data-project-side-panel="agents">
                    <div class="project-side-card-list project-agent-rail-list" id="project-agents-list"></div>
                    <div class="empty muted" id="project-agents-empty" data-i18n="project.bindings.empty_agents_short">No agents yet</div>
                  </div>
                  <div class="project-side-panel project-side-files-panel" data-project-side-panel="files" hidden>
                    <div class="project-files-status muted" id="project-files-status"></div>
                    <div class="contexts-tree project-library-tree project-side-card-list project-library-side-list" id="project-files-list">
                      <div class="empty" data-i18n="project.files.empty">No project files</div>
                    </div>
                  </div>
                </section>

              </aside>
            </div>

            <!-- Goals & rules editor. The rail shows saved rules; writing
                 them happens here so the draft has room and never looks like
                 the live value. Save path is unchanged. -->
            <div class="modal-overlay project-instructions-modal" id="project-instructions-modal" aria-hidden="true">
              <div class="modal project-instructions-dialog" role="dialog" aria-modal="true" aria-labelledby="project-instructions-dialog-title">
                <div class="modal-header">
                  <h3 class="modal-title" id="project-instructions-dialog-title" data-i18n="project.instructions.edit_title">Goals and rules</h3>
                  <button type="button" class="modal-close-btn" id="project-instructions-close-btn"
                          data-i18n-title="common.close" title="Close"
                          data-i18n-aria-label="common.close" aria-label="Close">
                    <span data-ui-icon="x" data-ui-icon-class="modal-close-icon"></span>
                  </button>
                </div>
                <div class="modal-body">
                  <p class="project-context-help" data-i18n="project.instructions.subtitle">Set project goals, priorities, and rules. The AI follows them in every conversation.</p>
                  <textarea class="project-instructions-input" id="project-instructions-input" rows="12"
                            data-i18n-placeholder="project.instructions.placeholder"
                            placeholder="Rules and context every conversation in this project should follow"></textarea>
                </div>
                <div class="project-instructions-foot">
                  <span class="project-instructions-counter muted" id="project-instructions-counter"></span>
                  <span class="project-instructions-foot-actions">
                    <button type="button" class="btn btn-sm" id="project-instructions-cancel-btn" data-i18n="common.cancel">Cancel</button>
                    <button type="button" class="btn btn-sm btn-primary" id="project-instructions-save-btn"
                            data-i18n="project.instructions.save" disabled>Save</button>
                  </span>
                </div>
              </div>
            </div>

            <div class="modal-overlay project-library-viewer-modal" id="project-library-viewer-modal" aria-hidden="true">
              <div class="modal project-library-viewer-dialog" role="dialog" aria-modal="true" aria-labelledby="project-library-editor-path">
                <div class="contexts-editor-empty" id="project-library-editor-empty">
                  <div data-i18n="contexts.editor_empty">Select a file on the left</div>
                </div>
                <div class="contexts-viewer-wrap" id="project-library-viewer-wrap" style="display:none">
                  <div class="contexts-editor-header project-library-modal-header">
                    <div class="contexts-editor-path" id="project-library-editor-path"></div>
                    <div class="project-library-modal-actions">
                      <div class="detail-actions" id="project-library-viewer-actions"></div>
                      <button type="button" class="modal-close-btn project-library-modal-close" data-action="project-library-viewer-close"
                              data-i18n-title="project.bindings.picker_close" title="Close"
                              data-i18n-aria-label="project.bindings.picker_close" aria-label="Close">
                        <span data-ui-icon="x" data-ui-icon-class="modal-close-icon"></span>
                      </button>
                    </div>
                  </div>
                  <div class="contexts-viewer-body markdown-body" id="project-library-viewer-body"></div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>

      <!-- Connectors — Surface E per PC/docs/design/PATTERNS.md.
           Page header (P1) above two grouped grids. The custom MCP action
           lives in the top bar; per-connector actions live on each card.
           Card chrome restyled in CSS; the
           per-card markup stays the same as today (no functional change). -->
      <section class="panel" id="panel-connectors">
        <div class="connectors-grid-view" id="connectors-grid-view">
          <div class="connectors-page-header">
            <div class="connectors-page-header-main">
              <div class="connectors-page-header-title-row">
                <h1 class="connectors-page-header-title" data-i18n="connectors.title">Connectors</h1>
              </div>
            </div>
            <div class="connectors-page-header-actions">
              <label class="connectors-search" for="connectors-search-input">
                <span data-ui-icon="search" data-ui-icon-class="connectors-search-icon"></span>
                <input type="search" id="connectors-search-input"
                       data-i18n-placeholder="connectors.search.placeholder"
                       data-i18n-aria-label="connectors.search.placeholder"
                       placeholder="Search connectors" aria-label="Search connectors"
                       autocomplete="off" spellcheck="false" />
              </label>
              <button class="btn btn-sm connectors-page-header-action" id="connectors-add-custom-btn" data-i18n="connectors.action.add_custom">Add MCP server</button>
            </div>
          </div>
          <div class="connectors-grid-scroll">
            <div class="connectors-group" id="connectors-group-connected" style="display:none">
              <div class="connectors-group-label-row">
                <span class="connectors-group-label" data-i18n="connectors.group.connected">Connected</span>
                <span class="connectors-group-count" id="connectors-group-connected-count"></span>
              </div>
              <div class="connectors-grid" id="connectors-grid-connected"></div>
            </div>
            <div class="connectors-group" id="connectors-group-available" style="display:none">
              <div class="connectors-group-label-row">
                <span class="connectors-group-label" data-i18n="connectors.group.available">Available</span>
                <span class="connectors-group-count" id="connectors-group-available-count"></span>
              </div>
              <div class="marketplace-categories connectors-categories" id="connectors-categories"></div>
              <div class="connectors-grid" id="connectors-grid-available"></div>
            </div>
            <div class="connectors-empty empty" id="connectors-empty" style="display:none" data-i18n="connectors.empty">No connectors available.</div>
          </div>
        </div>
      </section>

      <!-- Library — Surface D per PC/docs/design/PATTERNS.md.
           Page header (P1) above the existing two-column layout. The body
           layout / interactions stay exactly as today — chrome only. -->
      <section class="panel" id="panel-contexts">
        <div class="contexts-page-header">
          <div class="contexts-page-header-main">
            <div class="contexts-page-header-title-row">
              <h1 class="contexts-page-header-title" data-i18n="contexts.title">Library</h1>
            </div>
          </div>
          <button type="button" class="contexts-page-header-search" id="contexts-page-header-search"
                  data-i18n-title="sidebar.search_title" title="Search (Cmd/Ctrl+K)">
            <span data-ui-icon="search" data-ui-icon-class="contexts-page-header-search-icon"></span>
            <span data-i18n="sidebar.search">Search</span>
          </button>
        </div>
        <div class="contexts-layout">
          <div class="contexts-tree-col" id="contexts-tree-col">
            <div class="contexts-section-header">
              <div id="contexts-project-select" class="contexts-project-select ai-select-compact"></div>
              <span class="contexts-section-count" id="contexts-tree-count"></span>
              <button type="button" class="ctx-row-menu-btn ctx-root-menu-btn" id="ctx-root-menu-btn"
                      data-i18n-title="contexts.menu.more_actions" title="More actions"
                      data-i18n-aria-label="contexts.menu.more_actions" aria-label="More actions">
                <span data-ui-icon="more-horizontal" data-ui-icon-class="ctx-row-menu-icon"></span>
              </button>
            </div>
            <div class="ctx-upload-status" id="ctx-upload-status" style="display:none">
              <span class="ctx-upload-spinner"></span>
              <span id="ctx-upload-status-label"></span>
            </div>
            <div class="contexts-tree" id="contexts-tree">
              <div class="empty" data-i18n="contexts.empty">Library is empty</div>
            </div>
          </div>
          <div class="contexts-editor-col" id="contexts-editor-col">
            <div class="contexts-editor-empty" id="contexts-editor-empty">
              <div data-i18n="contexts.editor_empty">Select a file on the left</div>
            </div>
            <div class="contexts-viewer-wrap" id="contexts-viewer-wrap" style="display:none">
              <div class="contexts-editor-header">
                <div class="contexts-editor-path" id="contexts-editor-path"></div>
                <div class="detail-actions" id="contexts-viewer-actions"></div>
              </div>
              <div class="contexts-viewer-body markdown-body" id="contexts-viewer-body"></div>
            </div>
          </div>
        </div>
      </section>

      <!-- Auto — scheduled tasks (see modules/auto.js). Sidebar sibling to
           Commander. Main content: header + list. Create / edit happen in
           the reusable modal `#auto-task-dialog-overlay` below (also
           opened from the project-detail page's Automation tab). -->
      <section class="panel" id="panel-auto">
        <div class="auto-view">
          <header class="project-detail-header">
            <div class="project-detail-header-title-row">
              <h1 class="project-detail-title" data-i18n="auto.title">Auto</h1>
              <span class="auto-header-count" id="auto-header-count"></span>
            </div>
            <button type="button" class="btn btn-sm auto-header-add" id="auto-add-btn" data-i18n="auto.add_btn">+ Create</button>
          </header>
          <div class="auto-scroll">
            <div class="auto-sync-note" id="auto-sync-note" hidden></div>
            <div class="auto-list" id="auto-list"></div>
            <div class="auto-empty empty" id="auto-empty" data-i18n="auto.empty">No auto tasks yet</div>
          </div>
        </div>
      </section>

      <!-- My Apps — user-kept copies of create_artifact bundles (see modules/saved-apps.js) -->
      <section class="panel" id="panel-apps">
        <div class="agents-grid-view">
          <div class="apps-page-header">
            <div class="apps-page-header-main">
              <div class="apps-page-header-title-row">
                <h1 class="apps-page-header-title" data-i18n="apps.title">Apps</h1>
                <span class="apps-page-header-count" id="apps-page-header-count"></span>
              </div>
            </div>
            <button type="button" class="btn btn-sm" id="apps-create-btn" aria-haspopup="dialog">
              <span data-ui-icon="plus" aria-hidden="true"></span><span data-i18n="apps.create">Create</span>
            </button>
          </div>
          <div class="agents-grid-scroll" id="apps-content">
            <div class="apps-grid" id="apps-grid"></div>
            <div class="agents-empty" id="apps-empty" data-i18n="apps.empty">No apps</div>
          </div>
        </div>
      </section>

      <!-- Settings -->
      <section class="panel" id="panel-settings">
        <div class="settings-container">
          <div class="settings-nav">
            <div class="settings-header">
              <div class="settings-heading">
                <h2 data-i18n="settings.title">Settings</h2>
              </div>
            </div>
            <div class="settings-tabs" role="tablist" aria-orientation="horizontal">
              <button class="settings-tab is-active" type="button" role="tab" aria-selected="true" data-settings-tab="data"><span data-ui-icon="database" data-ui-icon-class="settings-tab-icon"></span><span class="settings-tab-label" data-i18n="settings.tab.data">数据</span></button>
              <button class="settings-tab" type="button" role="tab" aria-selected="false" tabindex="-1" data-settings-tab="credentials"><span data-ui-icon="sparkles" data-ui-icon-class="settings-tab-icon"></span><span class="settings-tab-label" data-i18n="settings.tab.credentials">Models</span></button>
              <button class="settings-tab" type="button" role="tab" aria-selected="false" tabindex="-1" data-settings-tab="general"><span data-ui-icon="settings" data-ui-icon-class="settings-tab-icon"></span><span class="settings-tab-label" data-i18n="settings.tab.general">通用</span></button>
            </div>
          </div>

          <div class="settings-body">
            <!-- ───────────────────────── 数据 ───────────────────────── -->
            <div class="settings-tab-pane" data-settings-pane="data">
              <div class="settings-page">
                <header class="settings-page-head">
                  <h1 data-i18n="settings.tab.data">数据</h1>
                  <p data-i18n="settings.data.page_sub">管理记忆、回收站与本地数据。</p>
                </header>

                <section class="settings-section" id="settings-section-memory">
                  <div class="settings-sheet">
                    <button type="button" class="settings-row settings-row-btn memory-entry-card" id="memory-entry-card">
                      <span class="memory-entry-icon" data-ui-icon="sparkles"></span>
                      <span class="settings-row-copy memory-entry-body">
                        <span class="settings-row-title memory-entry-title" data-i18n="memory.entry_title">记忆</span>
                        <span class="settings-row-desc memory-entry-desc" id="memory-entry-desc"></span>
                      </span>
                      <span class="memory-entry-chevron" data-ui-icon="chevron-right"></span>
                    </button>
                  </div>
                </section>

                <section class="settings-section" id="settings-section-local">
                  <div class="settings-section-title">
                    <h2 data-i18n="settings.data_root.title">数据目录</h2>
                    <span class="settings-section-hint" data-i18n="settings.data.local_hint">仅此设备</span>
                  </div>
                  <div class="settings-sheet">
                    <div class="settings-row settings-data-root-row">
                      <div class="settings-row-copy">
                        <div class="settings-row-desc" data-i18n="settings.data_root.sub">All conversations, agents, skills, and Library content live under this directory. Click the path to open it in the OS file manager.</div>
                        <span class="settings-mono" id="settings-data-root-path"></span>
                      </div>
                      <button class="btn btn-sm" id="settings-data-root-btn" type="button" title="" data-i18n-title="settings.data_root.open_tooltip" data-i18n="settings.data_root.open">打开目录</button>
                    </div>
                  </div>
                </section>

                <section class="settings-section" id="settings-task-cleanup">
                  <div class="settings-section-title"><h2 data-i18n="settings.cleanup.title">Clean up task history</h2></div>
                  <div class="settings-sheet">
                    <div class="settings-row">
                      <div class="settings-row-copy">
                        <div class="settings-row-title" data-i18n="settings.cleanup.age">Last active</div>
                        <div class="settings-row-desc" data-i18n="settings.cleanup.scope">Filter all task history by age, then clean up by project or task.</div>
                      </div>
                      <div class="ai-select" id="settings-task-cleanup-age"></div>
                    </div>
                    <div id="settings-task-cleanup-body" aria-live="polite"></div>
                  </div>
                </section>

                <section class="settings-section" id="settings-recycle-group">
                  <div class="settings-section-title">
                    <div class="settings-section-copy">
                      <h2 data-i18n="settings.recycle.title">回收站</h2>
                      <p class="settings-section-sub" data-i18n="settings.recycle.sub">本机删除会保留完整快照,可手动恢复或删除。</p>
                    </div>
                  </div>
                  <div class="settings-sheet settings-recycle-body" id="settings-recycle-body">
                    <div class="settings-empty" data-i18n="settings.recycle.empty">暂无可恢复数据</div>
                  </div>
                </section>
              </div>
            </div>

            <!-- ───────────────────────── 通用 ───────────────────────── -->
            <div class="settings-tab-pane" data-settings-pane="general" hidden>
              <div class="settings-page">
                <header class="settings-page-head">
                  <h1 data-i18n="settings.tab.general">通用</h1>
                  <p data-i18n="settings.general.page_sub">调整使用偏好与智能体权限。</p>
                </header>

                <section class="settings-section">
                  <div class="settings-section-title">
                    <h2 data-i18n="settings.general.preferences_title">使用偏好</h2>
                  </div>
                  <div class="settings-sheet">
                    <div class="settings-row" id="settings-language-row">
                      <div class="settings-row-copy">
                        <div class="settings-row-title" data-i18n="settings.language.title">语言 / Language</div>
                        <div class="settings-row-desc" data-i18n="settings.language.sub">设置 Orkas 的界面语言</div>
                      </div>
                      <div class="ai-select settings-row-select" id="settings-language-select"></div>
                    </div>
                    <div class="settings-row">
                      <div class="settings-row-copy">
                        <div class="settings-row-title" id="settings-task-notifications-title" data-i18n="settings.task_notifications.title">任务通知</div>
                        <div class="settings-row-desc" data-i18n="settings.task_notifications.sub">当 Orkas 不在前台时,在任务完成、失败或需要你操作时发送系统通知。</div>
                      </div>
                      <label class="toggle-switch settings-switch">
                        <input type="checkbox" id="settings-task-notifications-toggle" checked aria-labelledby="settings-task-notifications-title" />
                      </label>
                    </div>
                    <div class="settings-row settings-task-notification-permission" id="settings-task-notification-permission" role="status" aria-live="polite" hidden>
                      <span class="settings-task-notification-permission-text" id="settings-task-notification-permission-text" data-i18n="settings.task_notifications.permission_disabled">系统已关闭 Orkas 的通知权限。请前往系统设置开启,否则无法收到任务进度提醒。</span>
                      <button type="button" class="btn btn-sm" id="settings-task-notification-open-settings" data-i18n="settings.task_notifications.open_settings">打开系统设置</button>
                    </div>
                    <div class="settings-row">
                      <div class="settings-row-copy">
                        <div class="settings-row-title" id="settings-operator-title" data-i18n="quality.operator.title">Custom validation</div>
                        <div class="settings-row-desc" data-i18n="quality.operator.scope">Checks scripts, executable SKILL.md code blocks, metadata and Agent JSON before saving or installing. This is not a runtime sandbox.</div>
                        <div class="settings-row-desc" id="settings-operator-status" role="status" aria-live="polite"></div>
                      </div>
                      <button class="btn btn-sm" id="settings-operator-file" data-i18n="quality.operator.file">Rule file</button>
                      <button class="btn btn-sm" id="settings-operator-reload" data-i18n="quality.operator.reload">Reload</button>
                      <label class="toggle-switch settings-switch"><input type="checkbox" id="settings-operator-toggle" aria-labelledby="settings-operator-title" /></label>
                    </div>
                  </div>
                </section>

                <section class="settings-section">
                  <div class="settings-section-title">
                    <h2 data-i18n="settings.general.agent_title">智能体行为</h2>
                  </div>
                  <div class="settings-sheet">
                    <div class="settings-row settings-row-stack">
                      <div class="settings-row-copy">
                        <div class="settings-row-title" data-i18n="settings.localexec.title">Local operation permissions</div>
                        <div class="settings-row-desc" data-i18n="settings.localexec.sub">Control which files agents can access and whether they must ask before running sensitive commands, deleting files, accessing sensitive folders, or performing administrator-level actions.</div>
                      </div>
                      <div class="settings-mode-list" id="settings-localexec-modes" role="radiogroup">
                        <label class="settings-mode-opt">
                          <input type="radio" name="localexec-mode" value="workspace_approval" />
                          <span class="settings-mode-text">
                            <span class="settings-mode-label" data-i18n="settings.localexec.mode.workspace_approval">Cautious</span>
                            <span class="settings-mode-desc" data-i18n="settings.localexec.mode.workspace_approval_desc">Workspace files only, approve sensitive actions</span>
                          </span>
                        </label>
                        <label class="settings-mode-opt">
                          <input type="radio" name="localexec-mode" value="all_files_approval" />
                          <span class="settings-mode-text">
                            <span class="settings-mode-label" data-i18n="settings.localexec.mode.all_files_approval">Standard</span>
                            <span class="settings-mode-desc" data-i18n="settings.localexec.mode.all_files_approval_desc">All files, approve sensitive actions</span>
                          </span>
                        </label>
                        <label class="settings-mode-opt">
                          <input type="radio" name="localexec-mode" value="all_files_auto" />
                          <span class="settings-mode-text">
                            <span class="settings-mode-label" data-i18n="settings.localexec.mode.all_files_auto">Trusted</span>
                            <span class="settings-mode-desc" data-i18n="settings.localexec.mode.all_files_auto_desc">All files, no sensitive approvals</span>
                          </span>
                        </label>
                      </div>
                    </div>
                    <div class="settings-row">
                      <div class="settings-row-copy">
                        <div class="settings-row-title" id="settings-metacognition-title" data-i18n="settings.metacognition.title">Automatic agent review</div>
                        <div class="settings-row-desc" data-i18n="settings.metacognition.sub">When enabled, agents periodically review recent performance, learn from it, and adjust how they work. Disable it to stop automatic reviews.</div>
                        <span class="settings-status muted" id="settings-metacognition-status"></span>
                      </div>
                      <label class="toggle-switch settings-switch">
                        <input type="checkbox" id="settings-metacognition-toggle" aria-labelledby="settings-metacognition-title" />
                      </label>
                    </div>
                  </div>
                </section>
              </div>
            </div>

            <!-- ───────────────────────── 模型 ───────────────────────── -->
            <div class="settings-tab-pane" data-settings-pane="credentials" hidden>
              <div class="settings-page">
                <header class="settings-page-head">
                  <h1 data-i18n="settings.tab.credentials">Models</h1>
                  <p data-i18n="settings.models.page_sub">Configure services by purpose and set the default model and fallback order.</p>
                </header>

                <div class="settings-group settings-orkas-api-group" id="settings-orkas-api-group">
                  <div class="settings-group-head settings-orkas-api-head">
                    <div class="settings-group-head-main">
                      <div class="settings-orkas-api-title-row">
                        <div class="settings-group-title" data-i18n="settings.orkas_api.title">Orkas API Key</div>
                        <span class="settings-orkas-api-savings" data-i18n="price_comparison.maximum">Model costs up to 50% less than provider API pricing</span>
                      </div>
                      <div class="settings-group-sub" data-i18n="settings.orkas_api.sub">Shared by Orkas models, search, images, speech, video, and credit-based connectors. The key is encrypted on this device.</div>
                    </div>
                    <button type="button" class="btn btn-sm" id="settings-orkas-api-create-key" data-i18n="settings.orkas_api.create_key">Create API Key</button>
                  </div>
                  <div class="settings-orkas-api-saved" id="settings-orkas-api-saved" hidden>
                    <div class="settings-orkas-api-key-summary">
                      <code id="settings-orkas-api-key-masked"></code>
                    </div>
                    <div class="settings-orkas-api-actions">
                      <button type="button" class="btn btn-sm" id="settings-orkas-api-edit" data-i18n="settings.orkas_api.edit">Edit</button>
                      <button type="button" class="btn btn-sm btn-danger" id="settings-orkas-api-delete" data-i18n="settings.orkas_api.delete">Delete</button>
                    </div>
                  </div>
                  <div class="settings-row settings-orkas-api-configure-row" id="settings-orkas-api-editor">
                    <input type="password" class="form-input" id="settings-orkas-api-key-input" autocomplete="new-password" spellcheck="false" data-i18n-placeholder="settings.orkas_api.key_placeholder" placeholder="Enter API Key" />
                    <div class="settings-orkas-api-editor-actions">
                      <button type="button" class="btn" id="settings-orkas-api-cancel" data-i18n="common.cancel" hidden>Cancel</button>
                      <button type="button" class="btn btn-primary" id="settings-orkas-api-configure" data-i18n="settings.orkas_api.configure">Configure</button>
                    </div>
                  </div>
                  <div class="settings-status settings-orkas-api-status" id="settings-orkas-api-status" aria-live="polite"></div>
                </div>

                <div class="settings-note settings-section-note">
                  <span data-ui-icon="lock" data-ui-icon-class="settings-note-icon"></span>
                  <span data-i18n="settings.section.models_note">API keys and authorization data are stored only on this device — never synced or sent elsewhere.</span>
                </div>

                <div class="settings-subnav" role="tablist" aria-orientation="horizontal" data-i18n-aria-label="settings.models.subnav_aria" aria-label="Model purpose">
                  <button type="button" class="settings-subnav-tab is-active" role="tab" id="settings-model-tab-chat" aria-selected="true" aria-controls="settings-model-panel-chat" data-settings-model-tab="chat" data-i18n="settings.models.chat">对话</button>
                  <button type="button" class="settings-subnav-tab" role="tab" id="settings-model-tab-search" aria-selected="false" tabindex="-1" aria-controls="settings-model-panel-search" data-settings-model-tab="search" data-i18n="settings.models.search">搜索</button>
                  <button type="button" class="settings-subnav-tab" role="tab" id="settings-model-tab-image" aria-selected="false" tabindex="-1" aria-controls="settings-model-panel-image" data-settings-model-tab="image" data-i18n="settings.models.image">图片</button>
                  <button type="button" class="settings-subnav-tab" role="tab" id="settings-model-tab-video" aria-selected="false" tabindex="-1" aria-controls="settings-model-panel-video" data-settings-model-tab="video" data-i18n="settings.models.video">视频</button>
                  <button type="button" class="settings-subnav-tab" role="tab" id="settings-model-tab-tts" aria-selected="false" tabindex="-1" aria-controls="settings-model-panel-tts" data-settings-model-tab="tts" data-i18n="settings.models.tts">语音</button>
                </div>

                <div class="settings-model-panel" id="settings-model-panel-chat" role="tabpanel" aria-labelledby="settings-model-tab-chat" data-settings-model-panel="chat">
                  <div class="settings-list-head">
                    <div class="settings-section-copy">
                      <h2 data-i18n="settings.models.chat_title">对话模型</h2>
                      <p class="settings-section-sub" data-i18n="settings.configured_sub">The first entry is the default model; later entries are the fallback chain. Drag to reorder.</p>
                    </div>
                    <button type="button" class="btn btn-sm btn-primary settings-add-btn" data-settings-add="chat" data-i18n="settings.models.add_chat">添加模型</button>
                  </div>
                  <div class="settings-sheet settings-entries" id="settings-entries">
                    <div class="settings-empty" data-i18n="settings.loading">Loading…</div>
                  </div>
                  <p class="settings-foot-note" data-i18n="settings.models.order_hint">拖动列表调整优先级,也可使用上下箭头。停用的官方模型不参与轮转。</p>
                </div>

                <div class="settings-model-panel" id="settings-model-panel-search" role="tabpanel" aria-labelledby="settings-model-tab-search" data-settings-model-panel="search" hidden>
                  <div class="settings-list-head">
                    <div class="settings-section-copy">
                      <h2 data-i18n="settings.models.search_title">搜索服务</h2>
                      <p class="settings-section-sub" data-i18n="settings.models.search_sub">配置独立搜索服务的使用优先级。</p>
                    </div>
                    <button type="button" class="btn btn-sm btn-primary settings-add-btn" data-settings-add="search" data-i18n="settings.models.add_search">添加搜索服务</button>
                  </div>
                  <div class="settings-sheet settings-entries" id="settings-search-entries">
                    <div class="settings-empty" data-i18n="settings.loading">Loading…</div>
                  </div>
                  <p class="settings-foot-note" data-i18n="settings.search.sub">Search uses these in order: configured search services, the model's built-in search, then free local search.</p>
                </div>

                <div class="settings-model-panel" id="settings-model-panel-image" role="tabpanel" aria-labelledby="settings-model-tab-image" data-settings-model-panel="image" hidden>
                  <div class="settings-list-head">
                    <div class="settings-section-copy">
                      <h2 data-i18n="settings.models.image_title">图片生成</h2>
                      <p class="settings-section-sub" data-i18n="settings.models.image_sub">按服务商与模型配置独立生成服务。</p>
                    </div>
                    <button type="button" class="btn btn-sm btn-primary settings-add-btn" data-settings-add="image" data-i18n="settings.models.add_image">添加图片服务</button>
                  </div>
                  <div class="settings-sheet settings-entries" id="settings-image-entries">
                    <div class="settings-empty" data-i18n="settings.loading">Loading…</div>
                  </div>
                  <p class="settings-foot-note" data-i18n="settings.image.sub">If no separate service is configured, the current model will be used when it uses an API key and supports image generation.</p>
                </div>

                <div class="settings-model-panel" id="settings-model-panel-video" role="tabpanel" aria-labelledby="settings-model-tab-video" data-settings-model-panel="video" hidden>
                  <div class="settings-list-head">
                    <div class="settings-section-copy">
                      <h2 data-i18n="settings.models.video_title">视频生成</h2>
                      <p class="settings-section-sub" data-i18n="settings.models.video_sub">管理视频服务及其备用顺序。</p>
                    </div>
                    <button type="button" class="btn btn-sm btn-primary settings-add-btn" data-settings-add="video" data-i18n="settings.models.add_video">添加视频服务</button>
                  </div>
                  <div class="settings-sheet settings-entries" id="settings-video-entries">
                    <div class="settings-empty" data-i18n="settings.loading">Loading…</div>
                  </div>
                </div>

                <div class="settings-model-panel" id="settings-model-panel-tts" role="tabpanel" aria-labelledby="settings-model-tab-tts" data-settings-model-panel="tts" hidden>
                  <div class="settings-list-head">
                    <div class="settings-section-copy">
                      <h2 data-i18n="settings.models.tts_title">语音合成</h2>
                      <p class="settings-section-sub" data-i18n="settings.models.tts_sub">管理语音服务;根据服务商显示所需参数。</p>
                    </div>
                    <button type="button" class="btn btn-sm btn-primary settings-add-btn" data-settings-add="tts" data-i18n="settings.models.add_tts">添加语音服务</button>
                  </div>
                  <div class="settings-sheet settings-entries" id="settings-tts-entries">
                    <div class="settings-empty" data-i18n="settings.loading">Loading…</div>
                  </div>
                  <p class="settings-foot-note" data-i18n="settings.models.tts_note">已知服务使用预设参数。自定义服务需填写 Base URL、模型和音色。</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>

      <!-- Memory detail page (reached from Settings › 数据 › 记忆).
           memory.js renders the whole page (breadcrumb + header + sections) and
           the import/export modals into the body overlay. Personal cross-session
           memory over features/memory.ts — view / edit / import / export. -->
      <section class="panel" id="panel-memory">
        <div class="memory-page" id="memory-page"></div>
      </section>
    </main>
  </div>

  <!-- Shared global/project to-do editor -->
  <div class="modal-overlay ui-dialog-overlay" id="todo-editor-modal">
    <div class="modal modal-standard todo-editor-dialog" role="dialog" aria-modal="true" aria-labelledby="project-todo-editor-title">
      <div class="modal-header todo-editor-header">
        <h2 class="modal-title" id="project-todo-editor-title" data-i18n="project.todo.add">Create task</h2>
      </div>
      <div class="project-todo-add" id="project-todo-add" hidden>
        <label class="todo-editor-field todo-editor-content-field"><span data-i18n="todo.task_title">What needs to be done</span>
          <div class="todo-editor-composer" id="project-todo-composer">
            <div class="chat-input-overlay">
              <div class="chat-attachments project-todo-attachments" id="project-todo-attachments" hidden></div>
            </div>
            <textarea id="project-todo-input" rows="6" maxlength="4000"
                      data-i18n-placeholder="project.todo.placeholder" placeholder="Create a task…"></textarea>
            <div class="chat-bottom-bar todo-editor-composer-bar">
              <button type="button" class="chat-attach-btn project-todo-attach-btn" id="project-todo-attach-btn"
                      data-i18n-title="project.todo.attach" data-i18n-aria-label="project.todo.attach" title="Attach files" aria-label="Attach files">+</button>
              <span class="chat-composer-divider" aria-hidden="true"></span>
              <span class="project-memory-editor-counter muted" id="project-todo-counter">0/4000</span>
            </div>
          </div>
        </label>
        <input type="file" id="project-todo-file-input" multiple hidden />
        <div class="todo-editor-field-grid">
          <label class="todo-editor-field"><span data-i18n="todo.project">Project</span><span class="todo-editor-select" id="project-todo-project"></span></label>
          <label class="todo-editor-field"><span data-i18n="project.todo.assign">Agent</span><span class="todo-editor-select" id="project-todo-agent"></span></label>
          <label class="todo-editor-field"><span data-i18n="todo.status">Status</span><span class="todo-editor-select" id="project-todo-status"></span></label>
          <div class="todo-editor-field" id="project-todo-due-field"><label for="project-todo-due" data-i18n="project.todo.due_label">Due date</label>
            <div class="auto-date-picker todo-editor-date" id="project-todo-due-picker">
              <input type="text" id="project-todo-due" inputmode="numeric" autocomplete="off" placeholder="YYYY-MM-DD" />
              <button type="button" class="auto-date-picker-toggle" aria-haspopup="dialog" aria-controls="project-todo-due-popover" data-i18n-aria-label="auto.calendar_open" data-i18n-title="auto.calendar_open"></button>
              <div class="auto-date-picker-popover" id="project-todo-due-popover" role="dialog" hidden></div>
            </div>
          </div>
        </div>
        <div class="modal-actions todo-editor-actions">
          <button type="button" class="btn" id="project-todo-cancel" data-i18n="project.todo.cancel">Cancel</button>
          <button type="button" class="btn btn-primary" id="project-todo-save" data-i18n="project.todo.save" disabled>Save</button>
        </div>
      </div>
    </div>
  </div>

  <div class="modal-overlay" id="agent-modal">
    <div class="modal modal-standard" role="dialog" aria-modal="true" aria-labelledby="agent-modal-title">
      <h3 class="modal-title" id="agent-modal-title" data-i18n="agent_modal.title">New agent</h3>

      <!-- Mode tabs: Create (in-process) / External (cli runtime). Mirrors the
           skill-modal tab pattern; reuses the same .skill-modal-tab styles
           via the agent-modal-tab class for consistent chrome. -->
      <div class="skill-modal-tabs" id="agent-modal-tabs">
        <button type="button" class="skill-modal-tab is-active" data-agent-tab="create" data-i18n="agent_modal.tab_create">Create</button>
        <button type="button" class="skill-modal-tab" data-agent-tab="external" data-i18n="agent_modal.tab_external">External</button>
      </div>

      <!-- Create panel (default): manual authoring. Runtime selector is
           intentionally absent here — that flow lives in the External tab. -->
      <div class="skill-modal-panel is-active" data-agent-panel="create">
        <div class="form-row">
          <label data-i18n="agent_modal.name">Name</label>
          <input type="text" id="agent-name-input" data-i18n-placeholder="agent_modal.name_placeholder" placeholder="e.g. CodeReviewAssistant" />
        </div>
        <div class="form-row">
          <label data-i18n="agents.label_output_format">Output format</label>
          <div class="ai-select" id="agent-output-format-select"></div>
        </div>
        <div class="form-row">
          <label><span data-i18n="agent_modal.desc">Summary</span> <span class="form-hint" data-i18n="agent_modal.desc_hint">One line on what it does — the AI will generate a workflow from this</span></label>
          <textarea id="agent-desc-input" rows="4" data-i18n-placeholder="agent_modal.desc_placeholder" placeholder="e.g. Review my code before commit, focus on logic bugs and security issues..."></textarea>
        </div>
      </div>

      <!-- External panel: bind a local CLI as the runtime. CLI selector
           appears first; name + description are pre-filled from the chosen
           CLI's defaults but stay editable. Coding CLIs get a
           project-directory setting on the detail page after creation. -->
      <div class="skill-modal-panel" data-agent-panel="external">
        <div class="agent-cli-prerequisite" role="note">
          <span data-i18n="agent_modal.ext_cli_prerequisite_body">Supports Claude Code, Codex, OpenClaw, OpenCode, and Hermes. Install and configure one to connect.</span>
        </div>
        <div class="form-row">
          <label>
            <span data-i18n="agent_modal.ext_cli_label">Agent</span>
            <span class="agent-cli-detection-status" id="agent-modal-ext-cli-status" role="status" aria-live="polite" hidden>
              <span class="agent-cli-detection-spinner" aria-hidden="true"></span>
              <span data-i18n="agent_modal.ext_cli_updating">Updating…</span>
            </span>
          </label>
          <div class="agent-cli-select-row">
            <div class="ai-select" id="agent-modal-ext-cli-select"></div>
          </div>
          <div id="agent-modal-ext-cli-upgrades"></div>
            <span
              class="agent-cli-selection-warning"
              id="agent-modal-ext-cli-warning"
              role="status"
              aria-live="polite"
              hidden
            ></span>
        </div>
        <div class="form-row">
          <label data-i18n="agent_modal.ext_name">Name</label>
          <input type="text" id="agent-ext-name-input" data-i18n-placeholder="agent_modal.ext_name_placeholder" placeholder="e.g. ClaudeCode" />
        </div>
        <div class="form-row">
          <label data-i18n="agent_modal.ext_desc">Summary</label>
          <textarea id="agent-ext-desc-input" rows="4" data-i18n-placeholder="agent_modal.ext_desc_placeholder" placeholder="(auto-filled when a CLI is picked; can be overridden)"></textarea>
        </div>
      </div>

      <div class="form-msg" id="agent-form-msg"></div>
      <div class="modal-actions">
        <button class="btn" onclick="cancelAgentModal()" data-i18n="common.cancel">Cancel</button>
        <button class="btn btn-primary" id="agent-save-btn" onclick="saveAgentModal()" data-i18n="common.confirm">Confirm</button>
      </div>
    </div>
  </div>

  <!-- Create/Edit Skill Modal -->
  <div class="modal-overlay" id="skill-modal">
    <div class="modal modal-standard" role="dialog" aria-modal="true" aria-labelledby="skill-modal-title">
      <h3 class="modal-title" id="skill-modal-title" data-i18n="skill_modal.title_create">New skill</h3>
      <input type="hidden" id="skill-edit-id" value="" />

      <!-- Import-method tabs. Only shown in create mode (hidden when editing). -->
      <div class="skill-modal-tabs" id="skill-modal-tabs">
        <button type="button" class="skill-modal-tab is-active" data-skill-tab="manual" data-i18n="skill_modal.tab_manual">Manual</button>
        <button type="button" class="skill-modal-tab" data-skill-tab="url" data-i18n="skill_modal.tab_url">From URL</button>
        <button type="button" class="skill-modal-tab" data-skill-tab="dir" data-i18n="skill_modal.tab_dir">From folder</button>
      </div>

      <!-- Manual panel (default) -->
      <div class="skill-modal-panel is-active" data-skill-panel="manual">
        <div class="form-row">
          <label><span data-i18n="skill_modal.name">Name (English)</span><span class="form-hint" data-i18n="skill_modal.name_hint">Starts with a letter; digits, -, _, no spaces</span></label>
          <input type="text" id="skill-name" data-i18n-placeholder="skill_modal.name_placeholder" placeholder="e.g. web-summary" />
        </div>
        <div class="form-row">
          <label data-i18n="skill_modal.description">Summary</label>
          <textarea id="skill-description" rows="4" data-i18n-placeholder="skill_modal.desc_placeholder" placeholder="One line on what this skill does and when to use it..."></textarea>
        </div>
      </div>

      <!-- URL import panel: name/summary are produced by the model during the import chat -->
      <div class="skill-modal-panel" data-skill-panel="url">
        <div class="form-row">
          <label><span data-i18n="skill_modal.url">URL</span><span class="form-hint" data-i18n="skill_modal.url_hint">clawhub / GitHub / skill intro pages, etc.</span></label>
          <input type="text" id="skill-url-input" data-i18n-placeholder="skill_modal.url_placeholder" placeholder="https://..." />
        </div>
      </div>

      <!-- Dir import panel: name/summary are produced by the model during the import chat -->
      <div class="skill-modal-panel" data-skill-panel="dir">
        <div class="form-row">
          <label><span data-i18n="skill_modal.dir">Folder to import</span><span class="form-hint" data-i18n="skill_modal.dir_hint">Up to 200 files, 10 MB total</span></label>
          <div class="skill-dir-pick-row">
            <button type="button" class="btn btn-sm" id="skill-dir-pick-btn" onclick="pickSkillImportDir()" data-i18n="skill_modal.dir_pick_btn">Pick folder</button>
            <span class="skill-dir-selected" id="skill-dir-selected" data-i18n="skill_modal.dir_none">(not picked)</span>
          </div>
          <input type="hidden" id="skill-dir-path" value="" />
        </div>
      </div>

      <div class="form-msg" id="skill-form-msg"></div>
      <div class="modal-actions">
        <button class="btn" onclick="closeSkillModal()" data-i18n="common.cancel">Cancel</button>
        <button class="btn btn-primary" id="skill-save-btn" onclick="saveSkill()" data-i18n="common.confirm">Confirm</button>
      </div>
    </div>
  </div>

  <!-- Agent / skill / connector picker popup -->
  <div class="skill-picker" id="agent-picker" style="display:none">
    <div class="skill-picker-tabs" role="tablist" aria-label="Picker type">
      <button type="button" class="skill-picker-tab active" data-agent-picker-tab="agents" data-i18n="agent_picker.tab_agents">Agents</button>
      <button type="button" class="skill-picker-tab" data-agent-picker-tab="skills" data-i18n="agent_picker.tab_skills">Skills</button>
      <button type="button" class="skill-picker-tab" data-agent-picker-tab="connectors" data-i18n="agent_picker.tab_connectors">Connectors</button>
      <button type="button" class="skill-picker-tab" data-agent-picker-tab="library" data-i18n="agent_picker.tab_library">Library</button>
    </div>
    <div class="skill-picker-header">
      <div class="recipient-picker-selected" id="agent-picker-selected" hidden></div>
      <input type="text" id="agent-picker-search" data-i18n-placeholder="agent_picker.search_placeholder" placeholder="Search agents..." autocomplete="off" />
    </div>
    <div class="skill-picker-list" id="agent-picker-list"></div>
    <!-- Coding-CLI entry, pinned below the list so neither scrolling nor a
         search that matches nothing can hide it. Shown on the Agents tab only,
         and only for the composer anchors: the automation dialog is a
         `.ui-dialog-overlay` (z-index 13000) and the create modal it opens is a
         plain `.modal-overlay` (z-index 100), which would land behind it. -->
    <div class="skill-picker-footer" id="agent-picker-cli-footer" hidden>
      <button type="button" class="skill-picker-cli-entry" id="agent-picker-connect-cli">
        <span data-ui-icon="terminal" data-ui-icon-class="skill-picker-cli-icon"></span>
        <span class="skill-picker-cli-copy">
          <span data-i18n="agents.connect_cli_btn">Connect an agent</span>
          <small data-i18n="agents.connect_cli_sub">Claude Code / Codex CLIs</small>
        </span>
        <span data-ui-icon="chevron-right" data-ui-icon-class="skill-picker-cli-arrow"></span>
      </button>
    </div>
  </div>

  <div class="agent-row-menu" id="agent-row-menu" style="display:none">
    <div class="agent-row-menu-item" data-action="edit" data-i18n="agents.edit">Edit</div>
    <div class="agent-row-menu-item is-danger" data-action="delete" data-i18n="agents.delete">Delete</div>
  </div>

  <!-- Add-account modal (settings page) -->
  <div class="modal-overlay" id="add-account-modal">
    <div class="modal add-account-modal modal-standard" role="dialog" aria-modal="true" aria-labelledby="add-account-title">
      <h3 class="modal-title" id="add-account-title" data-i18n="add_account.title">Add account</h3>
      <div class="modal-body add-account-body" id="add-account-body"></div>
      <div class="modal-actions" id="add-account-actions"></div>
    </div>
  </div>

  <!-- Settings › Models: add-model / add-service dialog. Forms stay mounted
       so provider pickers keep their state while the active purpose changes. -->
  <div class="modal-overlay" id="settings-add-modal">
    <div class="modal settings-add-modal modal-standard" role="dialog" aria-modal="true" aria-labelledby="settings-add-modal-title">
      <div class="modal-header">
        <h3 class="modal-title" id="settings-add-modal-title" data-i18n="settings.models.add_chat">Add model</h3>
        <button type="button" class="modal-close-btn settings-add-modal-close" id="settings-add-modal-close"
                data-i18n-title="common.close" title="Close"
                data-i18n-aria-label="common.close" aria-label="Close">
          <span data-ui-icon="x" data-ui-icon-class="modal-close-icon"></span>
        </button>
      </div>
      <div class="modal-body settings-add-modal-body">
        <div class="settings-add-form" data-settings-add-form="chat">
          <p class="settings-add-form-hint" data-i18n="settings.add_auth_sub">Choose a model or enter a custom endpoint, then sign in or add an API key.</p>
          <div class="settings-row settings-form-row">
            <label data-i18n="settings.provider">Provider</label>
            <div class="ai-select" id="settings-picker-provider"></div>
          </div>
          <div class="settings-row settings-form-row" id="settings-picker-model-row">
            <label data-i18n="settings.model">Model</label>
            <div class="ai-select" id="settings-picker-model"></div>
          </div>
          <div class="settings-form-status"><span class="settings-status" id="settings-picker-status"></span></div>
          <div class="modal-actions settings-add-form-actions">
            <button type="button" class="btn" data-settings-add-cancel data-i18n="common.cancel">Cancel</button>
            <button type="button" class="btn btn-primary" id="settings-add-entry-btn" data-i18n="settings.add_account">+ Add account</button>
          </div>
        </div>

        <div class="settings-add-form" data-settings-add-form="search" hidden>
          <div class="settings-row settings-form-row">
            <label data-i18n="settings.search.provider">Provider</label>
            <div class="ai-select" id="settings-search-provider"></div>
          </div>
          <div class="settings-row settings-form-row" id="settings-search-key-row">
            <label data-i18n="settings.search.api_key">API Key</label>
            <input type="password" class="form-input" id="settings-search-key-input" autocomplete="new-password" spellcheck="false" />
          </div>
          <div class="settings-form-status"><span class="settings-status" id="settings-search-status"></span></div>
          <div class="modal-actions settings-add-form-actions">
            <button type="button" class="btn" data-settings-add-cancel data-i18n="common.cancel">Cancel</button>
            <button type="button" class="btn btn-primary" id="settings-search-add-btn" data-i18n="settings.search.add">+ Add search key</button>
          </div>
        </div>

        <div class="settings-add-form" data-settings-add-form="image" hidden>
          <div class="settings-row settings-form-row">
            <label data-i18n="settings.image.provider">Provider</label>
            <div class="ai-select" id="settings-image-provider"></div>
          </div>
          <div class="settings-row settings-form-row" id="settings-image-key-row">
            <label data-i18n="settings.image.api_key">API Key</label>
            <input type="password" class="form-input" id="settings-image-key-input" autocomplete="new-password" spellcheck="false" />
          </div>
          <div class="settings-form-status"><span class="settings-status" id="settings-image-status"></span></div>
          <div class="modal-actions settings-add-form-actions">
            <button type="button" class="btn" data-settings-add-cancel data-i18n="common.cancel">Cancel</button>
            <button type="button" class="btn btn-primary" id="settings-image-add-btn" data-i18n="settings.image.add">+ Add image key</button>
          </div>
        </div>

        <div class="settings-add-form" data-settings-add-form="video" hidden>
          <div class="settings-row settings-form-row">
            <label data-i18n="settings.video.provider">Provider</label>
            <div class="ai-select" id="settings-video-provider"></div>
          </div>
          <div class="settings-row settings-form-row" id="settings-video-key-row">
            <label data-i18n="settings.video.api_key">API Key</label>
            <input type="password" class="form-input" id="settings-video-key-input" autocomplete="new-password" spellcheck="false" />
          </div>
          <div class="settings-form-status"><span class="settings-status" id="settings-video-status"></span></div>
          <div class="modal-actions settings-add-form-actions">
            <button type="button" class="btn" data-settings-add-cancel data-i18n="common.cancel">Cancel</button>
            <button type="button" class="btn btn-primary" id="settings-video-add-btn" data-i18n="settings.video.add">+ Add video key</button>
          </div>
        </div>

        <div class="settings-add-form" data-settings-add-form="tts" hidden>
          <div class="settings-row settings-form-row">
            <label data-i18n="settings.tts.provider">Provider</label>
            <div class="ai-select" id="settings-tts-provider"></div>
          </div>
          <div class="settings-row settings-form-row" id="settings-tts-key-row">
            <label data-i18n="settings.tts.api_key">API Key</label>
            <input type="password" class="form-input" id="settings-tts-key-input" autocomplete="new-password" spellcheck="false" />
          </div>
          <div class="settings-row settings-form-row tts-row-voice" hidden>
            <label data-i18n="settings.tts.voice">Voice</label>
            <input type="text" class="form-input" id="settings-tts-voice-input" placeholder="alloy / zh_female_…_bigtts" autocomplete="off" spellcheck="false" />
          </div>
          <div class="settings-row settings-form-row tts-row-base" hidden>
            <label data-i18n="settings.tts.base_url">Base URL</label>
            <input type="text" class="form-input" id="settings-tts-base-input" placeholder="https://api.openai.com/v1" autocomplete="off" spellcheck="false" />
          </div>
          <div class="settings-row settings-form-row tts-row-model" hidden>
            <label data-i18n="settings.tts.model">Model</label>
            <input type="text" class="form-input" id="settings-tts-model-input" autocomplete="off" spellcheck="false" />
          </div>
          <div class="settings-row settings-form-row tts-row-doubao-res" hidden>
            <label><span data-i18n="settings.tts.doubao_resource">Voice resource ID</span> <span class="form-hint" data-i18n="settings.tts.doubao_resource_hint">Filled in automatically when you select a voice. You can also edit it manually.</span></label>
            <input type="text" class="form-input" id="settings-tts-doubao-resource" placeholder="auto (seed-tts-2.0 / 1.0 / icl-2.0)" autocomplete="off" spellcheck="false" />
          </div>
          <div class="settings-form-status"><span class="settings-status" id="settings-tts-status"></span></div>
          <div class="modal-actions settings-add-form-actions">
            <button type="button" class="btn" data-settings-add-cancel data-i18n="common.cancel">Cancel</button>
            <button type="button" class="btn btn-primary" id="settings-tts-add-btn" data-i18n="settings.tts.add">+ Add speech key</button>
          </div>
        </div>
      </div>
    </div>
  </div>

  <!-- OAuth login flow modal -->
  <div class="modal-overlay" id="oauth-flow-modal">
    <div class="modal oauth-flow-modal modal-standard" role="dialog" aria-modal="true" aria-labelledby="oauth-flow-title">
      <div class="modal-header">
        <h3 class="modal-title" id="oauth-flow-title" data-i18n="oauth_flow.title">OAuth sign-in</h3>
        <button type="button" class="modal-close-btn oauth-flow-close-btn" id="oauth-flow-close-btn"
                data-i18n-title="common.close" title="Close"
                data-i18n-aria-label="common.close" aria-label="Close">
          <span data-ui-icon="x" data-ui-icon-class="modal-close-icon"></span>
        </button>
      </div>
      <div class="modal-body oauth-flow-body" id="oauth-flow-body">
        <div class="oauth-flow-stage" data-i18n="oauth_flow.preparing">Preparing authorization…</div>
      </div>
    </div>
  </div>

  <!-- Auto-task create / edit modal (see modules/auto.js). Reused by the
       Automation tab AND the project-detail page's "自动化" tab. Opens via
       `window.openAutoTaskDialog({ task?, projectId?, onSaved? })`. -->
  <div class="modal-overlay ui-dialog-overlay" id="auto-task-dialog-overlay" style="display:none">
    <div class="modal ui-dialog auto-task-dialog modal-standard" role="dialog" aria-modal="true" aria-labelledby="auto-task-dialog-title">
      <div class="modal-title ui-dialog-title auto-task-dialog-title" id="auto-task-dialog-title" data-i18n="auto.create_section_title">New auto task</div>
      <div class="modal-body auto-task-dialog-body">
        <!-- Composer chrome cloned 1:1 from #new-chat-input-area. -->
        <div class="new-chat-input-wrapper auto-composer-wrapper">
          <div class="new-chat-input-area">
            <div class="chat-input-overlay">
              <div class="chat-attachments" id="auto-task-attachments" style="display:none"></div>
            </div>
            <div data-composer="1" id="auto-task-input"
                      data-i18n-placeholder="auto.content_placeholder"
                      placeholder="Type @ to choose agents, skills, connectors, Library files."></div>
            <div class="chat-bottom-bar">
              <button type="button" class="chat-attach-btn" id="auto-attach-btn" data-i18n-title="new_chat.attach_title" title="Upload attachment (documents, spreadsheets, presentations, archives, images, audio, and video)">+</button>
              <span class="chat-composer-divider" aria-hidden="true"></span>
              <button type="button" class="chat-recipient-chip" id="auto-recipient-chip" data-i18n-title="chat.recipient_picker_title_with_library" title="Choose agent, skill, connector, or Library file">
                <span class="chat-recipient-prefix" data-i18n="chat.recipient_label">To: </span>
                <span class="chat-recipient-name" id="auto-recipient-name" data-i18n="chat.recipient_commander">Commander</span>
              </button>
              <button type="button" class="chat-attach-btn chat-mic-btn" id="auto-mic-btn" data-i18n-title="chat.mic_title" title="Voice input">
                <span data-ui-icon="mic" data-ui-icon-class="chat-mic-icon"></span>
              </button>
            </div>
          </div>
        </div>

        <div class="auto-schedule-row">
          <div class="form-row auto-schedule-cell">
            <label data-i18n="auto.freq_label">Frequency</label>
            <div id="auto-freq-select"></div>
          </div>
          <div class="form-row auto-schedule-cell" id="auto-row-hourly-interval" hidden>
            <label data-i18n="auto.hourly_interval_label">Interval</label>
            <div class="auto-number-with-unit">
              <input type="number" id="auto-hourly-interval-input" min="1" max="876000" step="1" inputmode="numeric" />
              <span data-i18n="auto.hours_unit">hours</span>
            </div>
          </div>
          <div class="form-row auto-schedule-cell" id="auto-row-date" hidden>
            <label for="auto-date-input" data-i18n="auto.date_label">Date</label>
            <div class="auto-date-picker" id="auto-date-picker">
              <input type="text" id="auto-date-input" inputmode="numeric" autocomplete="off" placeholder="YYYY-MM-DD" />
              <button type="button" class="auto-date-picker-toggle" aria-haspopup="dialog" aria-controls="auto-date-picker-popover" data-i18n-aria-label="auto.calendar_open" data-i18n-title="auto.calendar_open"></button>
              <div class="auto-date-picker-popover" id="auto-date-picker-popover" role="dialog" hidden></div>
            </div>
          </div>
          <div class="form-row auto-schedule-cell" id="auto-row-weekday" hidden>
            <label data-i18n="auto.weekday_label">Weekday</label>
            <div id="auto-weekday-select"></div>
          </div>
          <div class="form-row auto-schedule-cell" id="auto-row-monthly-day" hidden>
            <label data-i18n="auto.day_label">Day</label>
            <div id="auto-monthly-day-select"></div>
          </div>
          <div class="form-row auto-schedule-cell" id="auto-row-time" hidden>
            <label data-i18n="auto.time_label">Time</label>
            <div class="auto-time-row">
              <div id="auto-hour-select"></div>
              <span class="auto-time-sep">:</span>
              <div id="auto-minute-select"></div>
            </div>
          </div>
        </div>

        <div class="auto-end-row" id="auto-row-end">
          <div class="form-row auto-schedule-cell">
            <label data-i18n="auto.end_label">Ends</label>
            <div id="auto-end-select"></div>
          </div>
          <div class="form-row auto-schedule-cell" id="auto-row-end-date" hidden>
            <label for="auto-end-date-input" data-i18n="auto.end_date_label">End date</label>
            <div class="auto-date-picker" id="auto-end-date-picker">
              <input type="text" id="auto-end-date-input" inputmode="numeric" autocomplete="off" placeholder="YYYY-MM-DD" />
              <button type="button" class="auto-date-picker-toggle" aria-haspopup="dialog" aria-controls="auto-end-date-picker-popover" data-i18n-aria-label="auto.calendar_open" data-i18n-title="auto.calendar_open"></button>
              <div class="auto-date-picker-popover" id="auto-end-date-picker-popover" role="dialog" hidden></div>
            </div>
          </div>
          <div class="form-row auto-schedule-cell" id="auto-row-end-count" hidden>
            <label data-i18n="auto.end_count_label">Run count</label>
            <input type="number" id="auto-end-count-input" min="1" step="1" inputmode="numeric" />
          </div>
        </div>

        <!-- Project picker. Visibility decided per-open by auto.js:
             - hidden when opened from project-detail (locked mode); the
               host page already pins the project
             - hidden when the user has no projects at all (no options to
               pick from — the "default = none" outcome is automatic)
             - otherwise visible, defaulting to "no project" (`value=''`). -->
        <div class="form-row" id="auto-row-project" hidden>
          <label data-i18n="auto.project_label">Project</label>
          <div id="auto-project-select"></div>
        </div>

        <div class="form-row" id="auto-row-run-device" hidden>
          <label data-i18n="auto.run_label">Run on</label>
          <div id="auto-run-device-select"></div>
        </div>

        <div class="form-row">
          <label data-i18n="auto.title_label">Title (optional)</label>
          <input type="text" id="auto-title-input"
                 data-i18n-placeholder="auto.title_placeholder" />
        </div>

        <div class="form-row">
          <label class="auto-enabled-label">
            <input type="checkbox" id="auto-enabled-input" checked />
            <span data-i18n="auto.enabled_label">Enabled</span>
          </label>
        </div>

      </div>

      <div class="modal-actions">
        <button type="button" class="btn" id="auto-dialog-cancel-btn" data-i18n="auto.cancel_btn">Cancel</button>
        <button type="button" class="btn btn-primary" id="auto-submit-btn" data-i18n="auto.create_btn">Create</button>
      </div>
    </div>
  </div>

  <!-- Library "new directory" modal. Text-file creation no longer
       goes through this modal — + Text creates an "Untitled.md" inline and
       drops the tree into rename mode + the viewer into edit mode. -->
  <div class="modal-overlay" id="ctx-new-modal">
    <div class="modal modal-standard" role="dialog" aria-modal="true" aria-labelledby="ctx-new-modal-title">
      <h3 class="modal-title" id="ctx-new-modal-title" data-i18n="contexts.new.modal_title_dir">New Folder</h3>
      <div class="form-row ctx-new-target" id="ctx-new-target"></div>
      <div class="form-row">
        <label data-i18n="contexts.new.dir_name">Folder name</label>
        <input type="text" id="ctx-new-name" data-i18n-placeholder="contexts.new.dir_name_placeholder" placeholder="Enter folder name" autocomplete="off" />
      </div>
      <div class="form-msg" id="ctx-new-msg"></div>
      <div class="modal-actions">
        <button class="btn" onclick="closeCtxNewModal()" data-i18n="common.cancel">Cancel</button>
        <button class="btn btn-primary" onclick="saveCtxNew()" data-i18n="common.confirm">Confirm</button>
      </div>
    </div>
  </div>

  <!-- Unauthorized banner -->
  <div class="access-denied" id="access-denied">
    <div class="access-denied-box">
      <div class="access-denied-title">Access denied</div>
      <div class="access-denied-msg">
        Append <code>?password=&lt;access-password&gt;</code> to the URL.<br />
        The password is in the server startup log or <code>data/users/_password.json</code>.
      </div>
    </div>
  </div>

  <!-- Library location picker (chat archive + produced-file imports) -->
  <div class="modal-overlay" id="kb-picker-modal">
    <div class="modal kb-picker modal-standard" role="dialog" aria-modal="true" aria-labelledby="kb-picker-title">
      <h3 class="modal-title" id="kb-picker-title" data-i18n="kb_picker.title">Save to Library</h3>
      <div class="form-row">
        <label><span data-i18n="kb_picker.name">Filename</span> <span class="form-hint" data-i18n="kb_picker.name_hint">Missing extension will be auto-filled as .md</span></label>
        <input type="text" id="kb-picker-name" autocomplete="off" />
      </div>
      <div class="form-row">
        <label data-i18n="kb_picker.folder">Choose folder</label>
        <div class="kb-picker-tree" id="kb-picker-tree"></div>
        <div class="kb-picker-target" id="kb-picker-target"></div>
      </div>
      <div class="form-msg" id="kb-picker-msg"></div>
      <div class="modal-actions">
        <button class="btn" id="kb-picker-cancel" type="button" data-i18n="common.cancel">Cancel</button>
        <button class="btn btn-primary" id="kb-picker-confirm" type="button" data-i18n="common.confirm">Confirm</button>
      </div>
    </div>
  </div>

  <!-- Global search overlay (Cmd+K) -->
  <div class="search-overlay" id="search-overlay" style="display:none">
    <div class="search-modal">
      <div class="search-input-row">
        <span data-ui-icon="search" data-ui-icon-class="search-input-icon"></span>
        <input type="text" id="search-input" data-i18n-placeholder="search.input_placeholder" placeholder="Search tasks and Library…" autocomplete="off" spellcheck="false" />
        <button class="search-close-btn" id="search-close-btn" data-i18n-title="search.close_title" title="Close (Esc)">
          <span data-ui-icon="x" data-ui-icon-class="search-close-icon"></span>
        </button>
      </div>
      <div class="search-tabs" id="search-tabs" role="tablist">
        <button class="search-tab is-active" data-tab="all" data-i18n="search.tab.all">All</button>
        <button class="search-tab" data-tab="chat" data-i18n="search.tab.chat">Chats</button>
        <button class="search-tab" data-tab="agent" data-i18n="search.tab.agent">Agents</button>
        <button class="search-tab" data-tab="skill" data-i18n="search.tab.skill">Skills</button>
        <button class="search-tab" data-tab="context" data-i18n="search.tab.context">Library</button>
      </div>
      <div class="search-body is-start-state" id="search-body">
        <div class="search-empty" data-i18n="search.empty_hint">Type a keyword to start searching</div>
      </div>
    </div>
  </div>

  <!--
    Renderer is vanilla JS (no build step). Modules are classic <script> tags
    loaded in the order they appeared in the old single-file app.js — top-level
    `let`/`const` bindings are shared across classic scripts via the same global
    lexical environment, so inter-module refs Just Work without explicit exports.
    Adding new code: put it in the module whose section it belongs to, or add a
    new file and insert it here in the right position.
  -->
  <script src="./modules/logger.js"></script>
  <script src="./modules/state.js"></script>
  <script src="./modules/task-unread.js"></script>
  <script src="./modules/dialogs.js"></script>
  <script src="./modules/ipc-shim.js"></script>
  <script src="./modules/lazy-features.js"></script>
  <script src="./modules/i18n.js"></script>
  <script src="./modules/chat-use.js"></script>
  <script src="./modules/user-error.js"></script>
  <script src="./modules/overlay-manager.js"></script>
  <script src="./modules/model-guard.js"></script>
  <script src="./modules/dropdown-placement.js"></script>
  <script src="./modules/composer-model-picker.js"></script>
  <script src="./modules/delete-file-confirm.js"></script>
  <script src="./modules/boot.js"></script>
  <script src="./modules/avatar.js"></script>
  <script src="./modules/avatar-picker.js"></script>
  <script src="./modules/chat-input-form.js"></script>
  <script src="./modules/local_agent_user_input.js"></script>
  <script src="./modules/cli_async_input.js"></script>
  <script src="./modules/chat-lightbox.js"></script>
  <script src="./modules/icons.js"></script>
  <script src="./modules/web-assist.js"></script>
  <script src="./modules/file-operation-policy.js"></script>
  <script src="./modules/app-save-recovery.js"></script>
  <script src="./modules/chat-file-viewer.js"></script>
  <script src="./modules/preview-windows.js"></script>
  <script src="./modules/delimited-preview.js"></script>
  <script src="./modules/md-view-edit.js"></script>
  <script src="./modules/text-view-edit.js"></script>
  <script src="./modules/context-menu.js"></script>
  <script src="./modules/chat-md-drawer.js"></script>
  <script src="./modules/task-side-panel.js"></script>
  <script src="./modules/video-review-panel.js"></script>
  <script src="./modules/strip-structural-blocks.js"></script>
  <script src="./modules/name-limit.js"></script>
  <script src="./modules/projects.js"></script>
  <script src="./modules/conv-bucket.js"></script>
  <script src="./modules/today-tasks.js"></script>
  <script src="./modules/conversation-view-model.js"></script>
  <script src="./vendor/prosemirror/prosemirror.min.js"></script>
  <script src="./modules/composer-input.js"></script>
  <script src="./modules/voice-input.js"></script>
  <script src="./modules/commercial-entry.js"></script>
  <script src="./modules/conversation.js"></script>
  <script src="./modules/conversation-to-project.js"></script>
  <script src="./modules/home.js"></script>
  <script src="./modules/conversation-turn-nav.js"></script>
  <script src="./modules/web-app-host.js"></script>
  <script src="./modules/artifact-security.js"></script>
  <script src="./modules/chat-artifact.js"></script>
  <script src="./modules/conversation-info.js"></script>
  <script src="./modules/task-board.js"></script>
  <script src="./modules/queue-draft.js"></script>
  <script src="./modules/connectors.js"></script>
  <script src="./modules/connector-action-dialog.js"></script>
  <script src="./modules/connector-account-dialog.js"></script>
  <script src="./modules/bash_permission.js"></script>
  <script src="./modules/interactive-cli.js"></script>
  <script src="./modules/search.js"></script>
  <script src="./modules/user-workspace.js"></script>
  <script src="./modules/local-agents.js"></script>
  <script src="./vendor/pinyin-firstletter/data.js"></script>
  <!-- DOMPurify must load before utils.js so inline connector SVGs are sanitized, not disabled. -->
  <script src="./vendor/dompurify/purify.min.js"></script>
  <script src="./modules/pinyin-firstletter.js"></script>
  <script src="./modules/cli-account-usage.js"></script>
  <script src="./modules/agents.js"></script>
  <script src="./modules/auto-title.js"></script>
  <script src="./modules/auto-events.js"></script>
  <script src="./modules/utils.js"></script>
  <script src="./modules/validation-report-view.js"></script>
  <script src="./modules/oss.js"></script>
  <script src="./modules/settings_tabs.js"></script>

  <!--
    MathJax v3.2.2 — TeX → CommonHTML.
    Config must be set BEFORE the script loads. `typeset: false` prevents
    MathJax from scanning the whole page at startup; renderer/modules/math.js
    calls `MathJax.typesetPromise([el])` on a per-bubble basis instead.
    `processEscapes` lets users / models write `\$` for a literal dollar.
  -->
  <script>
    // Stick to what the `tex-chtml` bundle ships out-of-box. Extra TeX
    // extensions (noerrors / boldsymbol / color / mhchem / ...) are loaded
    // on demand from the script-relative directory — and we only vendor the
    // combined bundle + fonts, so requesting them would 404 and freeze the
    // startup promise. `ams` is already in the bundle's defaults.
    window.MathJax = {
      tex: {
        inlineMath: [['$', '$'], ['\\(', '\\)']],
        displayMath: [['$$', '$$'], ['\\[', '\\]']],
        processEscapes: true,
      },
      options: {
        skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'],
        menuOptions: { settings: { zoom: 'NoZoom' } },
      },
      startup: {
        typeset: false,
        ready() {
          // Log once, then hand off to default startup. Shows up in DevTools
          // if MathJax finished loading; absence of this line = the bundle
          // never executed (path / CSP / syntax error).
          // eslint-disable-next-line no-console
          console.info('[mathjax] ready');
          window.MathJax.startup.defaultReady();
        },
      },
    };
  </script>
  <script src="./modules/math.js"></script>
  <script src="./modules/sidebar-sections.js"></script>
  <script src="./modules/sidebar-resize.js"></script>
</body>
</html>