@shawnstack/quickforge 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -12
- package/dist/assets/{AgentProfilesPage-BToo_R3Y.js → AgentProfilesPage-CGm7ZzRM.js} +1 -1
- package/dist/assets/ChatPanelHost-nzOC6Tbg.js +242 -0
- package/dist/assets/{PluginsPage-DwzV2vQ4.js → PluginsPage-K3o4AB2E.js} +1 -1
- package/dist/assets/{ScheduledTasksPage-Cbm6LVk3.js → ScheduledTasksPage-BVjejep8.js} +1 -1
- package/dist/assets/{SharedConversationPage-CHE9qABz.js → SharedConversationPage-BwmUajLr.js} +1 -1
- package/dist/assets/{TerminalDock-Loi8A4pJ.js → TerminalDock-D-GWlS7P.js} +1 -1
- package/dist/assets/{WorkspaceInspector-Nf5xELW7.js → WorkspaceInspector-CEU6nnM-.js} +2 -2
- package/dist/assets/{WorkspaceReaderDialog-Bai7v3V0.js → WorkspaceReaderDialog-D9Qy6LUm.js} +1 -1
- package/dist/assets/{diff-line-counts-CCPYa_e0.js → diff-line-counts-DCot_pZu.js} +1 -1
- package/dist/assets/index-CkQWeO9c.css +3 -0
- package/dist/assets/index-DTiIspXQ.js +1482 -0
- package/dist/favicon.svg +16 -16
- package/dist/index.html +2 -2
- package/dist/pwa-icon-192.png +0 -0
- package/dist/pwa-icon-512.png +0 -0
- package/dist/pwa-maskable-512.png +0 -0
- package/package.json +2 -1
- package/server/index.mjs +76 -6
- package/server/public-api.mjs +196 -0
- package/server/routes/system.mjs +2 -1
- package/server/update-supervisor.mjs +121 -0
- package/dist/assets/ChatPanelHost-BTqhhkWK.js +0 -242
- package/dist/assets/index-Bt_dRvdG.js +0 -1476
- package/dist/assets/index-BzaZg9Br.css +0 -3
|
@@ -0,0 +1,1482 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatPanelHost-nzOC6Tbg.js","assets/rolldown-runtime-DWdDZTNf.js","assets/pi-web-ui-CBet4bMl.js","assets/pi-ai-Cx633yhb.js","assets/lit-vendor-Dr3cpBGF.js","assets/icons-DzxBk7tb.js","assets/react-vendor-DsAeMFcm.js","assets/plugin-api-YfYj_Bd7.js","assets/logger-B65Akg8A.js","assets/TerminalDock-D-GWlS7P.js","assets/xterm-5XDrJ343.js","assets/xterm-BrP-ENHg.css","assets/ScheduledTasksPage-BVjejep8.js","assets/AgentProfilesPage-CGm7ZzRM.js","assets/PluginsPage-K3o4AB2E.js","assets/SharedConversationPage-BwmUajLr.js","assets/WorkspaceInspector-CEU6nnM-.js","assets/diff-line-counts-DCot_pZu.js","assets/monaco-dMY7_GLO.js","assets/WorkspaceReaderDialog-D9Qy6LUm.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{B as t,C as n,Ct as r,D as i,E as a,F as o,H as s,M as c,N as l,O as u,R as d,S as f,St as p,T as m,V as h,Z as g,_,a as v,b as y,c as b,d as x,dt as S,f as C,ft as w,gt as T,h as E,ht as D,i as ee,it as te,j as O,lt as k,m as A,mt as j,n as M,p as ne,rt as N,s as P,st as re,tt as F,u as I,v as ie,vt as L,w as ae,wt as R,x as oe,xt as se,y as ce,yt as le,z as ue}from"./icons-DzxBk7tb.js";import{i as de,n as fe,r as pe}from"./react-vendor-DsAeMFcm.js";import{f as me,p as z,u as he}from"./lit-vendor-Dr3cpBGF.js";import{n as ge,r as _e,t as ve}from"./css-utils-rkE68RDy.js";import{_ as ye,a as be,d as B,f as xe,g as Se,h as Ce,i as we,m as Te,n as Ee,o as De,p as Oe,r as ke,t as Ae,u as je}from"./pi-web-ui-CBet4bMl.js";import{_ as Me,p as Ne,y as Pe}from"./pi-ai-Cx633yhb.js";import{t as V}from"./logger-B65Akg8A.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var H=e(R(),1),Fe=pe(),Ie=`language`,Le=[`en`,`zh`],Re={en:{language:`Language`,displayLanguage:`Display language`,languageDescription:`Choose the display language for 速构 QuickForge. The page will reload to apply the change.`,simplifiedChinese:`Simplified Chinese`,english:`English`,apply:`Apply`,noLanguageChange:`The selected language is already active.`,newChat:`New chat`,newChatEmptyTitle:`What do you want to get done today?`,chooseProject:`Select project`,searchProjects:`Search projects`,newProject:`Add project`,createBlankProject:`Add project`,useExistingFolder:`Select project directory`,useNoProject:`No project`,noMatchingProjects:`No matching projects`,loadingChatWorkspace:`Loading chat workspace...`,localServiceUnavailableTitle:`Local QuickForge service unavailable`,localServiceUnavailableDescription:`QuickForge requires the local service for storage. Start QuickForge with npm run dev or the quickforge command, then reload this page.`,project:`Project`,projects:`Projects`,loadingProject:`Loading project...`,addProject:`Add project`,noProjects:`No projects yet.`,expandProject:`Expand project`,collapseProject:`Collapse project`,expandAllProjects:`Expand all projects`,collapseAllProjects:`Collapse all projects`,dragToReorder:`Drag to reorder`,newProjectChat:`New project chat`,projectChat:`Project chat`,normalChat:`Chat`,conversations:`Conversations`,noConversations:`No conversations`,filter:`Filter`,selecting:`Selecting...`,chooseFolder:`Choose folder`,selectProjectDirectory:`Select project directory`,selectProjectDirectoryDescription:`Browse local folders or paste a path, then choose the folder to add it as a project.`,quickAccess:`Quick access`,path:`Path`,go:`Go`,parentDirectory:`Parent directory`,noFolders:`No folders in this directory.`,selectThisFolder:`Select this folder`,folderPickerPathPlaceholder:`Enter or paste a folder path`,filesystemRootsFailed:`Failed to load filesystem roots.`,directoryLoadFailed:`Failed to load directory.`,noSavedConversations:`No saved conversations yet.`,rename:`Rename`,renameSession:`Rename conversation`,sessionName:`Conversation name`,deleteProject:`Delete project`,deleteProjectConfirm:`Are you sure you want to delete project "{name}"? Its conversations will be kept.`,deleteSession:`Delete session`,deleteSessionConfirm:`Are you sure you want to delete this conversation? This cannot be undone.`,deleteSessionFailed:`Failed to delete conversation.`,archiveSession:`Archive conversation`,confirmArchive:`Archive`,archivedConversations:`Archived conversations`,archivedConversationsDescription:`Archived conversations are hidden from the sidebar. Restore them here or delete them permanently.`,searchArchivedConversations:`Search archived conversations`,noArchivedConversations:`No archived conversations yet.`,archivedAt:`Archived at`,lastModified:`Last modified`,restoreSession:`Restore`,restoreSessionFailed:`Failed to restore conversation.`,sessionRestored:`Conversation restored.`,sessionNotFound:`Conversation not found.`,deletePermanently:`Delete`,deleteAll:`Delete all`,deleteArchivedSessionConfirm:`Permanently delete "{title}"? This cannot be undone.`,deleteAllArchivedSessionsConfirm:`Permanently delete all archived conversations? This cannot be undone.`,archivedSessionDeleted:`Archived conversation deleted.`,archivedSessionsDeleted:`Archived conversations deleted.`,allProjects:`All projects`,unknownProject:`Unknown project`,conversationCount:`{count} conversations`,confirm:`Confirm`,confirmDelete:`Delete`,settings:`Settings`,toggleSidebar:`Toggle sidebar`,failedToSelectProjectDirectory:`Failed to select project directory.`,projectSwitchFailed:`Failed to switch to the project for this conversation. Workspace tools were not started.`,copy:`Copy`,copied:`Copied`,svgDisplayMode:`SVG display mode`,svgPreviewMode:`Preview`,svgSourceMode:`Source`,svgEnlargePreview:`Click to enlarge SVG preview`,copySvgSource:`Copy SVG source`,downloadSvg:`Download SVG`,rollback:`Rollback`,retry:`Retry`,reloadPage:`Reload page`,fork:`Fork`,forkConversation:`Fork conversation from here`,yoloEnabledTitle:`Workspace access enabled: local tools can use this project`,yoloDisabledTitle:`Workspace access locked: local tools are blocked`,agentAccessMenuLabel:`Agent access mode`,agentAccessDefaultLabel:`Default permissions`,agentAccessFullLabel:`Full access`,agentAccessDefaultTitle:`Default permissions: work inside the current repository; ask before actions that may affect the system.`,agentAccessFullTitle:`Full access: developer-level authorization; tools can run automatically within the configured workspace boundaries.`,agentAccessModeSyncFailed:`Failed to sync Agent access mode.`,planModeLabel:`Plan`,planModeEnabledTitle:`Plan mode enabled: send the next message as /plan. Click to remove. Shortcut: Shift+Tab`,planModeDisabledTitle:`Plan mode: send the next message as /plan. Shortcut: Shift+Tab`,composerPlaceholder:`Describe what you want to do`,assistantWaitingThinking:`Thinking`,assistantWaitingOrganizing:`Organizing the answer`,assistantWaitingContinuing:`This may take a little longer`,assistantWaitingAriaLabel:`Assistant is preparing a response`,customCommandsHint:`Custom commands`,customCommandsEmptyHint:`No project commands yet.`,customCommandsListDescription:`List project custom commands`,customCommandsNewDescription:`Create a project custom command`,planCommandDescription:`Create a plan first; this turn cannot edit files or run commands.`,reviewCommandDescription:`Review pending code changes before commit; this turn cannot edit files.`,summaryCommandDescription:`Create a new chat with this conversation summarized to reduce context usage.`,compactCommandDescription:`Compact this conversation context in place using the same rolling summary as auto-compaction.`,clearCommandDescription:`Clear the current chat history and context without calling the model.`,helpCommandDescription:`Show all available commands and their usage.`,yoloBlockedReason:`Local tool {name} was blocked by the current Agent permission mode. Switch to Full access or approve the tool call when prompted.`,globalToolBlockedReason:`Local tool {name} was blocked because this is a normal chat with no project attached. Start or open a project chat to use workspace tools.`,noActiveProjectToolBlockedReason:`Local tool {name} was blocked because there is no active project. Add or select a project to use workspace tools.`,generationStillRunning:`Generation is still running. Stop it or wait until it finishes before rolling back.`,noConversationTurnToRollback:`There is no conversation turn to roll back.`,rollbackConfirmTitle:`Confirm rollback?`,rollbackConfirm:`Roll back to before this message? This message and all following conversation history will be removed, and the message content will be restored to the composer.`,sharedRollbackConfirmTitle:`Confirm shared conversation rollback?`,sharedRollbackConfirm:`This will directly modify the sharer's original conversation. This message and all following conversation history will be removed, and the message content will be restored to the composer.`,confirmRollback:`Confirm rollback`,rollingBack:`Rolling back...`,rollbackFailed:`Rollback failed.`,retryFailed:`Retry failed.`,copyFailed:`Copy failed. Please check clipboard permissions.`,errorBoundaryTitle:`Something went wrong`,errorBoundaryUnexpected:`An unexpected error occurred.`,errorBoundaryTryAgain:`Try again`,execute:`Run`,addCustomModelFirst:`Please add a custom model in Settings and make sure the model ID is filled in before saving.`,modelSetupRequired:`Please add a model before starting a new chat.`,modelSetupTitle:`No model configured yet`,modelSetupDescription:`Add an OpenAI-Compatible or Anthropic-compatible model to start chatting. QuickForge will only use models that you configure.`,modelSetupSupports:`Supports LiteLLM, OpenRouter, DeepSeek, Qwen, Zhipu, Ollama, and most /v1/chat/completions services.`,modelSetupLocalStorage:`Providers, model IDs, and API keys are stored locally by the QuickForge service on this machine.`,modelSetupAddModel:`Add model`,modelSetupUseLiteLlmExample:`Use LiteLLM example`,firstUseGuideTitle:`Start with a safe workflow`,firstUseGuideDescription:`Add a project, ask QuickForge to understand it, and use /plan before granting local tool access for code changes.`,firstUseGuideStepModel:`Confirm the model you want to use.`,firstUseGuideStepProject:`Add a local project so AI can use workspace context.`,firstUseGuideStepPlan:`Use /plan first; that turn cannot edit files or run commands.`,firstUseGuideConfigureModel:`Configure model`,firstUseGuideAddProject:`Add project`,firstUseGuideUsePrompt:`Try example prompt`,firstUseGuideCopyPrompt:`Copy /plan example`,firstUseGuideDismiss:`Got it`,firstUseGuideProjectPrompt:`/plan Read this project and explain its structure, run commands, and main risks. Do not modify files yet.`,firstUseGuideGeneralPrompt:`/plan Break this request into implementation steps and risks first. Do not modify files yet.`,defaultOptions:`Default Options`,defaultOptionsDescription:`Configure the default model, thinking level, tool display, and context management for new chats and scheduled tasks.`,defaultModel:`Default model`,defaultThinkingLevel:`Default thinking level`,toolDisplay:`Tool Display`,showToolDetails:`Show detailed tool JSON`,expandToolsByDefault:`Expand tool calls by default`,showToolDetailsDescription:`When disabled, tool input and details JSON are hidden. Console output, status, summaries, and diffs remain visible.`,fontSize:`Font size`,fontSizeDescription:`Adjust the global base font size and common body text size.`,baseFontSize:`Base font size (px)`,bodyFontSize:`Body text size (px)`,bodyFontSizeNote:`Applies to the Tailwind text-sm utility used by common interface text.`,appearance:`Appearance`,appearanceDescription:`Customize the interface theme and font size.`,theme:`Theme`,themeDescription:`Switch between light and dark. Changes apply instantly.`,lightTheme:`Light`,darkTheme:`Dark`,appearanceSaved:`Appearance saved`,interfaceFontSize:`Interface font size`,messageFontSize:`Conversation font size`,messageFontSizeNote:`Applies to the main text in chat messages.`,customFontSize:`Custom`,fontSizeSmall:`Small`,fontSizeDefault:`Default`,fontSizeLarge:`Large`,fontSizeExtraLarge:`Extra Large`,advancedFontSizeSettings:`Advanced font size settings`,restoreDefault:`Restore default`,fontSizeSaved:`Font size saved`,toolDetailsHidden:`Tool details are hidden. Enable detailed tool JSON in Settings to view full parameters.`,toolArgsSummary:`Arguments summary`,saveDefaultOptions:`Save defaults`,saving:`Saving...`,defaultOptionsSaved:`Default options saved`,contextManagement:`Context Management`,autoCompactEnabled:`Automatically compact context`,autoCompactRequireConfirmation:`Ask before compacting automatically`,autoCompactTriggerNote:`Checks run before each model request. Lower the threshold or reduce the model Context Window to test triggering.`,autoCompactThresholdPercent:`Compact when context reaches (%)`,autoCompactKeepRecentTurns:`Keep recent user turns`,autoCompactDescription:`When the estimated next request reaches the configured share of the model context window, QuickForge summarizes older history and continues the current task. This uses one extra model call.`,autoCompactHistoryPreserved:`The full chat history remains visible; only the context sent to the model is compacted.`,thinkingLevel:`Thinking level`,thinkingOff:`Off`,thinkingLow:`Low`,thinkingMedium:`Medium`,thinkingHigh:`High`,thinkingXHigh:`XHigh`,currentConfiguration:`Current configuration`,thinkingSupported:`Thinking`,thinkingNotSupported:`This model does not support thinking levels.`,thinkingRequiresReasoningModel:`Thinking levels require a reasoning / thinking model.`,customModels:`Custom Models`,customModelsTitle:`Custom models`,customModelsDescription:`Only use custom OpenAI-Compatible models that you configure.`,addModel:`Add model`,editModel:`Edit model`,delete:`Delete`,editCustomModel:`Edit custom model`,addCustomModel:`Add custom model`,providerName:`Provider name`,providerNamePlaceholder:`e.g., LiteLLM`,protocolType:`Protocol type`,protocolHelp:`Use OpenAI Compatible for LiteLLM, OpenRouter, and most /v1/chat/completions services. Use Anthropic Messages only for the direct Anthropic API.`,apiKey:`API Key`,apiKeyPlaceholder:`Leave empty if not required`,showApiKey:`Show API Key`,hideApiKey:`Hide API Key`,customHeaders:`Custom Headers JSON`,customHeadersPlaceholder:`{
|
|
3
|
+
"X-Custom-Header": "value"
|
|
4
|
+
}`,customHeadersHelp:`Optional provider-level HTTP headers. Must be a JSON object with string values. Headers are saved locally with this model configuration.`,invalidHeadersJson:`Custom headers must be a valid JSON object with string key-value pairs.`,modelId:`Model ID`,modelIdPlaceholder:`e.g., anthropic/claude-sonnet-4`,contextWindow:`Context Window`,maxTokens:`Max Tokens`,reasoningModel:`Reasoning / Thinking model (DeepSeek V4, Qwen, etc.)`,providerProtocol:`Protocol`,model:`Model`,reasoning:`Reasoning`,noModelAdded:`No model added`,modelsCount:`{count} model(s)`,modelIndex:`Model #{index}`,modelsList:`Models`,atLeastOneModel:`At least one model is required.`,duplicateModelId:`Duplicate model IDs are not allowed.`,cancel:`Cancel`,save:`Save`,yes:`Yes`,no:`No`,loading:`Loading...`,noCustomModels:`No custom models yet. Click "Add model".`,fillProviderBaseUrlModel:`Please fill in provider name and Base URL.`,saveCustomModelFailed:`Failed to save custom model.`,confirmDeleteProvider:`Delete {name}?`,deleteFailed:`Delete failed.`,selectCustomModel:`Select custom model`,close:`Close`,back:`Back`,searchModels:`Search models...`,noMatchingCustomModels:`No matching custom models`,presets:`Quick templates`,presetOpenai:`OpenAI`,presetDeepseek:`DeepSeek`,presetGlm:`Zhipu GLM`,presetOllama:`Local Ollama`,presetLitellm:`LiteLLM Proxy`,presetCustom:`Custom`,providerAdvanced:`Advanced options`,expandModel:`Adjust context window, max tokens, reasoning`,addHeader:`Add header`,headerName:`Header name`,headerValue:`Value`,removeHeader:`Remove header`,testConnection:`Test connection`,testingConnection:`Testing...`,connectionOk:`Connection OK`,connectionFailed:`Connection failed`,testRequiresFields:`Fill in Base URL and at least one model ID.`,readFile:`Read File`,searchFiles:`Search Files`,writeFile:`Write File`,editFile:`Edit File`,runCommand:`Run Command`,presentFiles:`Present Files`,executeInTerminal:`Run in terminal`,confirmExecuteCommandTitle:`Run command in terminal?`,confirmExecuteMultipleCommands:`This will run multiple lines in your local terminal. Continue?`,confirmExecuteDangerousCommand:`This command may modify your system, publish packages, push code, or run a remote script. Continue?`,terminalCommandExecuteFailed:`Failed to run command in terminal.`,runSubagent:`Run subagent`,subagentGeneral:`General`,subagentExplore:`Explore`,subagentRunning:`{name} running`,subagentCompleted:`{name} completed`,subagentFailed:`{name} failed`,subagentTask:`Task`,subagentContext:`Context`,subagentExpectedOutput:`Expected output`,subagentResult:`Result`,subagentToolCalls:`Tool calls`,subagentToolApprovalWaiting:`{source} requests approval: {toolName}`,toolApprovalSourceSubagent:`Source: {source} subagent`,activateSkill:`Activate Skill`,readSkillResource:`Read Skill Resource`,yoloModeSyncFailed:`Failed to sync Agent access mode. The previous state has been restored.`,toolApprovalFailed:`Failed to submit tool approval. Please try again.`,toolApprovalSubmitting:`Submitting...`,terminateCommand:`Terminate`,terminateCommandTitle:`Terminate this running command`,commandTerminateRequested:`Terminating...`,running:`Running`,done:`Done`,error:`Error`,taskCompleted:`Task completed`,taskError:`Task error`,called:`Called`,input:`Input`,output:`Output`,details:`Details`,scheduledTasks:`Scheduled Tasks`,scheduledTasksDescription:`Tasks are saved in the local backend service and run by the cron expression parsed by AI.`,createTask:`Create task`,editTask:`Edit`,cancelEditTask:`Cancel edit`,saveTask:`Save task`,taskScheduleDescriptionLabel:`Schedule description`,taskScheduleDescriptionPlaceholder:`e.g., Every day at 9 AM, send this to AI: generate my daily sales report.`,quickAiParseTask:`AI parses this description into a cron expression. The system stores and runs by cron.`,taskTitleLabel:`Task name`,taskTitlePlaceholder:`e.g., Daily work summary`,promptContentLabel:`AI will send this content`,promptContentPlaceholder:`Write the exact content that should be sent to AI when this task runs.`,taskEnabledSwitch:`Enable this task`,taskInstructionPlaceholder:`e.g., Generate a daily sales report at 9 AM every day`,aiParseTask:`AI Parse`,confirmCreate:`Confirm create`,taskList:`Task list`,noScheduledTasks:`No scheduled tasks yet. Enter a natural language instruction above to create one.`,taskEnabled:`Enabled`,taskRunning:`Running`,taskPaused:`Paused`,taskFinished:`Completed`,taskFailed:`Failed`,executeNow:`Run now`,enable:`Enable`,pauseTask:`Pause`,deleteTask:`Delete`,recentExecutions:`Recent executions`,executionSuccess:`Success`,executionRunning:`Running`,nextExecution:`Next`,lastExecution:`Last`,noModelAvailable:`No models available`,noProjectBound:`No project`,aiParsed:`AI parsed, please confirm`,taskName:`Task name`,executionRule:`Execution rule`,nextExecutionTime:`Next execution`,taskProject:`Project`,taskThinkingLevel:`Thinking`,aiInstruction:`AI instruction`,taskModel:`Model`,taskThinking:`Thinking`,taskProjectLabel:`Project`,taskExecutionMode:`Execution mode`,taskExecutionModeSerial:`Serial`,taskExecutionModeParallel:`Parallel`,taskExecutionModeHelp:`This only controls whether the same task may overlap. Different scheduled tasks still run in parallel.`,tasksCount:`{total} tasks, {enabled} enabled`,confirmDeleteTask:`Are you sure you want to delete this scheduled task? This cannot be undone.`,waitingForResult:`Waiting for result`,autoRun:`Auto`,manualRun:`Manual test`,runInputContent:`Sent to AI`,runAiResult:`AI result`,runDuration:`Duration: `,taskListTab:`Task list`,executionHistoryTab:`Execution history`,agentsTab:`Agents`,agentsDescription:`Create reusable Agent Profiles for scheduled tasks and run_subagent delegation.`,createAgent:`Create agent`,editAgent:`Edit agent`,builtinAgent:`Built-in`,builtinAgentReadonly:`Built-in agents are read-only in this version.`,enabledAsSubagent:`Enabled as subagent`,enableAsSubagent:`Enable as subagent`,disableAsSubagent:`Disable as subagent`,noDescription:`No description.`,maxRuntimeMs:`Max runtime: `,maxToolCalls:`Max tool calls: `,defaultAgent:`Default Agent`,executionAgent:`Execution Agent: `,agentName:`Agent name`,agentLabel:`Display name`,agentLabelPlaceholder:`e.g., Code Review Agent`,agentDescription:`Description`,agentSystemPrompt:`System prompt`,allowedTools:`Allowed tools`,highRiskTool:`High risk`,confirmDeleteAgent:`Are you sure you want to delete this custom agent? Scheduled tasks using it will fall back to the default agent.`,aiFillAgent:`AI fill`,aiFillAgentDescription:`Describe the agent you want. AI will only fill agent name, display name, description, and system prompt.`,aiFillAgentPlaceholder:`e.g., Create a read-only code review agent focused on architecture, bugs, and test coverage.`,aiFillAgentLoading:`Generating...`,aiFillAgentNoModel:`Please configure a default model first.`,aiFillAgentFailed:`AI fill failed. Please check model configuration and API key, then try again.`,aiFillAgentInputRequired:`Please describe the agent you want to create.`,taskContent:`Task content`,viewDetails:`View details`,moreActions:`More actions`,historyFilters:`Filters`,allTasks:`All tasks`,allStatuses:`All statuses`,allTriggers:`All triggers`,triggerType:`Trigger`,keyword:`Keyword`,keywordPlaceholder:`Search input, result, or error`,startTime:`Start time`,endTime:`End time`,query:`Search`,reset:`Reset`,previousPage:`Previous`,nextPage:`Next`,pageSize:`{size} / page`,paginationSummary:`Page {page} / {pages}, {total} total`,noExecutionHistory:`No execution history yet.`,viewConversation:`View conversation`,createdAt:`Created at`,status:`Status`,search:`Search`,searchDialog:`Search conversations...`,noSearchResults:`No matching conversations found`,searchHint:`Enter keywords to search loaded conversations`,scheduledTasksLabel:`Scheduled Tasks`,skills:`Skills`,mcp:`MCP`,mcpServers:`MCP Servers`,plugins:`Plugins`,pluginMentionHeader:`Plugins`,composerAddMenu:`Add`,composerAddAttachment:`Attachment`,composerAddPlugins:`Plugins`,composerAddBack:`Back`,pluginOpenaiDocumentsName:`Documents`,pluginOpenaiDocumentsDescription:`Create and edit document artifacts`,pluginOpenaiSpreadsheetsName:`Spreadsheets`,pluginOpenaiSpreadsheetsDescription:`Create, analyze, and structure spreadsheet files`,pluginOpenaiPresentationsName:`Presentations`,pluginOpenaiPresentationsDescription:`Create and edit presentations`,pluginsDescription:`Manage local QuickForge plugins. This first version supports manifest-based plugins that contribute Agent tools.`,pluginsReload:`Reload plugins`,loadingPlugins:`Loading plugins...`,noPlugins:`No plugins found`,noPluginsDescription:`Place a plugin folder with plugin.json under one of these search paths, then reload.`,pluginsCount:`{total} plugins, {enabled} enabled`,pluginToolsCount:`{count} tools`,pluginPermissionsCount:`{count} permissions`,pluginDetails:`Plugin details`,pluginVersion:`Version`,pluginStatusLoaded:`Loaded`,pluginStatusDisabled:`Disabled`,pluginStatusError:`Error`,pluginTools:`Tools`,pluginPermissions:`Declared permissions`,pluginNoTools:`No tools declared.`,pluginNoPermissions:`No permissions declared.`,pluginTrustedNotice:`Plugins are local trusted Node.js code in this MVP; permissions are displayed for review and future enforcement.`,pluginDiscoveryErrors:`Plugin discovery errors`,enablePlugin:`Enable`,disablePlugin:`Disable`,pluginsLoadFailed:`Failed to load plugins.`,pluginsSaveFailed:`Failed to update plugin.`,manageMcpServers:`Manage MCP servers`,mcpNoServersDescription:`No MCP servers configured yet. Click "Add server" or paste an mcpServers JSON on the right.`,mcpConfiguredServers:`Configured servers`,mcpReconnect:`Reconnect`,mcpAddServer:`Add server`,mcpEditServer:`Edit server`,mcpServerName:`Server name`,mcpCommand:`Command`,mcpTransport:`Transport`,mcpUrl:`URL`,mcpArgs:`Arguments, one per line`,mcpCwd:`Working directory`,mcpEnv:`Environment variables, KEY=value per line`,mcpToolsCount:`{count} tools`,mcpLoadFailed:`Failed to load MCP servers.`,mcpSaveFailed:`Failed to save MCP server.`,mcpDeleteFailed:`Failed to delete MCP server.`,mcpReconnectFailed:`Failed to reconnect MCP servers.`,mcpDeleteConfirm:`Delete MCP server "{name}"?`,mcpImportConfig:`Import MCP JSON`,mcpImportConfigDescription:"Paste an MCP JSON configuration in mcpServers format. QuickForge supports stdio, HTTP, and SSE transports. For remote servers, headers are accepted and resolved from backend environment variables when using ${...}.",mcpUseExample:`Use example`,mcpImportUpdate:`Import / update`,mcpReplaceAll:`Replace all`,mcpReplaceConfirm:`This will remove MCP servers that are not included in the JSON. Continue?`,mcpInvalidJson:`MCP configuration must be valid JSON.`,mcpInvalidConfigJson:`MCP configuration must contain a mcpServers object.`,mcpEmptyConfigJson:`mcpServers cannot be empty.`,mcpInvalidServerName:`Invalid MCP server name: {name}. Use lowercase letters, numbers, and hyphens only.`,mcpInvalidServerConfig:`MCP server "{name}" must be an object.`,mcpInvalidTransport:`MCP server "{name}" transport must be stdio, http, or sse.`,mcpMissingCommand:`MCP server "{name}" requires command for stdio transport.`,mcpMissingUrl:`MCP server "{name}" requires url for HTTP/SSE transport.`,mcpArgsMustBeArray:`MCP server "{name}" args must be an array.`,mcpEnvMustBeObject:`MCP server "{name}" env must be an object.`,mcpHeadersMustBeObject:`MCP server "{name}" headers must be an object.`,mcpHeaders:`Headers, KEY=value per line`,mcpReconnectServer:`Reconnect`,mcpMoreTools:`+{count}`,mcpNamePlaceholder:`e.g. my-server`,mcpUrlPlaceholder:`https://example.com/mcp`,mcpCommandPlaceholder:`e.g. npx`,mcpTabServer:`Server`,mcpTabJson:`JSON`,optional:`Optional`,globalSkills:`Global Skills`,projectSkills:`Project Skills`,help:`Help`,projectCommands:`Project Commands`,projectCommandsDescription:`Configure extra Markdown slash-command directories for the current project. QuickForge also reads user-level commands from ~/.quickforge/commands/ (shared across all projects), then project directories .claude/commands, .opencode/commands, .ai/commands, and these configured directories in order. Later duplicate command names override earlier ones.`,selectProjectForCommands:`Please select or add a project before configuring project commands.`,commandDirectory:`Command directory`,commandDirectories:`Command directories`,commandDirectoryPlaceholder:`.claude/commands
|
|
5
|
+
.opencode/commands
|
|
6
|
+
D:\\shared\\ai-commands`,commandDirectoryHelp:`One directory per line. Supports relative paths and absolute paths. Relative paths are resolved from the current project root. Leave empty to use the built-in compatible command directories only.`,commandDirectoryExamples:`Examples`,projectCommandsSaved:`Project command settings saved.`,loadedCommands:`Loaded commands ({count})`,noCommandsLoaded:`No commands loaded yet. Add a directory above or create a command to get started.`,openCommandDir:`Open command directory`,createCommand:`New command`,newCommandPrompt:`Enter a command name (lowercase letters, numbers, hyphens):`,commandCreated:`Command created: {name}`,commandAlreadyExists:`Command already exists: {name}`,invalidCommandName:`Invalid command name. Use lowercase letters, numbers, and hyphens.`,manageSkills:`Manage skills`,manageGlobalSkills:`Manage global skills`,manageProjectSkills:`Manage project skills`,openFolder:`Open folder`,openInExplorer:`Open in Explorer`,openInExplorerFailed:`Failed to open the project folder.`,moreOptions:`More options`,pinSession:`Pin conversation`,unpinSession:`Unpin conversation`,shareSession:`Share conversation`,selectProjectForSkills:`Please select or add a project before managing skills.`,skillsDescription:`Select reusable Agent Skills enabled for project "{project}". QuickForge discloses only name/description in the prompt; full SKILL.md instructions are loaded on demand with activate_skill.`,globalSkillsDescription:`Select reusable Agent Skills enabled globally for QuickForge. Skills are discovered from ~/.claude/skills, ~/.opencode/skills, ~/.agents/skills, and ~/.quickforge/skills. Only the catalog is injected into new chats; instructions load on demand.`,projectSkillsDescription:`Select project Agent Skills for "{project}". Project skills are discovered from .claude/skills, .opencode/skills, .agents/skills, and .quickforge/skills; they override global skills with the same name and load on demand in new project chats.`,searchSkills:`Search skills...`,availableSkills:`Available skills`,selectedSkillsCount:`{count} selected`,noMatchingSkills:`No matching skills found`,skillSearchPaths:`Search paths`,failedToLoadSkills:`Failed to load skills.`,failedToSaveSkills:`Failed to save skills.`,readSkill:`Read skill`,readSkillContent:`Read skill content`,backToSkillList:`Back to skill list`,failedToReadSkill:`Failed to read skill content.`,noSkillContent:`This skill has no readable content.`,requestFailed:`Request failed`,backupRestore:`Backup & Restore`,backupRestoreDescription:`Export or restore QuickForge settings, providers, projects, scheduled tasks, and conversations. Imports create a safety backup on the local service before writing data. Backups may contain sensitive conversations, local paths, code snippets, and optionally API keys.`,exportData:`Export data`,exportDataDescription:`Download a JSON backup that you can keep or move to another QuickForge installation. API keys are excluded unless you explicitly include them.`,exportScope:`Export scope`,exportScopeAll:`Everything`,exportScopeConfig:`Configuration only`,exportScopeSessions:`Conversations only`,includeApiKeys:`Include API keys`,includeApiKeysDescription:`API keys are sensitive. Only enable this for private encrypted storage or trusted migration.`,backupExportSecretsConfirm:`This backup will contain API keys. Do not commit it to Git or share it with untrusted people. Continue?`,exportBackup:`Export backup`,backupExported:`Backup exported.`,backupExportFailed:`Backup export failed.`,importData:`Import data`,importDataDescription:`Restore a previously exported JSON backup. The file will be inspected first, then matching sections in the current local data will be replaced.`,importBackup:`Import backup`,backupInspectTitle:`Backup preview`,backupInspectExportedAt:`Exported at`,backupInspectVersion:`Version`,backupInspectScope:`Scope`,backupInspectSecrets:`Contains API keys`,backupInspectSections:`Sections`,backupInspectFailed:`Backup inspection failed.`,backupInspected:`Backup inspected. Choose what to restore below.`,selectRestoreSections:`Select data to restore`,restoreMode:`Restore mode`,restoreModeReplace:`Replace`,restoreModeReplaceDescription:`Replace local data in the selected sections entirely with the backup. Existing local data will be overwritten.`,restoreModeMerge:`Merge`,restoreModeMergeDescription:`Merge backup data into local. On conflict the backup wins; local-only entries are preserved.`,confirmImportSelected:`Import selected data`,selectAtLeastOneRestoreSection:`Select at least one data section to restore.`,restoreSettings:`Settings`,restoreSettingsDescription:`App preferences such as language and default options.`,restoreMcp:`MCP servers`,restoreMcpDescription:`Global MCP server definitions and their enable/disable state.`,restoreProviderKeys:`API keys`,restoreProviderKeysDescription:`Sensitive provider API keys. Restoring replaces current saved keys.`,restoreCustomProviders:`Custom providers and models`,restoreCustomProvidersDescription:`Custom model providers, endpoints, model IDs, and related configuration.`,restoreProjects:`Projects`,restoreProjectsDescription:`Project list, active project, and selected skills.`,restoreScheduledTasks:`Scheduled tasks`,restoreScheduledTasksDescription:`Saved scheduled AI tasks.`,restoreConversations:`Conversations`,restoreConversationsDescription:`Conversation history and metadata. This is restored as one consistent unit.`,backupImportConfirm:`Importing will replace matching local QuickForge data. A safety backup will be created first. Continue?`,backupImported:`Backup imported. The app will reload.`,backupImportFailed:`Backup import failed.`,backupSafetyBackupPath:`Safety backup saved at`,about:`About`,aboutQuickForge:`About QuickForge`,aboutQuickForgeDescription:`View project information, GitHub repository, and install updates from npm.`,projectInfo:`Project information`,packageName:`Package`,currentVersion:`Current version`,latestVersion:`Latest version`,github:`GitHub`,checkUpdate:`Check for updates`,checkingUpdate:`Checking...`,checkUpdateDescription:`Check npm for the latest QuickForge release. Updating starts an external updater, restarts the local backend, and keeps qf update/manual npm install available as fallbacks.`,updateAvailableMessage:`A new version is available: {current} → {latest}.`,localVersionNewerMessage:`Local version {current} is newer than npm latest {latest}.`,alreadyLatestVersion:`QuickForge is up to date ({version}).`,updateNow:`Update now`,updatingQuickForge:`Starting QuickForge updater...`,updateStarted:`Update started. QuickForge will restart automatically; this page will reconnect when it is back online.`,updateRestarted:`Update completed. Reloading...`,updateRestartTimeout:`Update is taking longer than expected. Check the update log, or run qf update / npm install manually.`,updateCompleted:`Update completed. Please restart QuickForge and refresh this page.`,updateFailed:`Update failed.`,updateCheckFailed:`Failed to check for updates.`,updateCommand:`Command`,updateLog:`Update log`,updateLogFile:`Log: {path}`,updateConfirm:`QuickForge will start an external updater to run this command on your computer, then restart the local backend:
|
|
7
|
+
{command}
|
|
8
|
+
|
|
9
|
+
Running generations will be interrupted. If the update fails, you can still run qf update or the npm command manually. Continue?`,updateFrequencySection:`Auto-check for updates`,updateFrequencyDescription:`Check for new releases in the background on startup. When a newer version is found, a gentle reminder appears in the bottom-left corner.`,frequencyStartup:`On every startup`,frequencyDaily:`Once a day`,frequencyWeekly:`Once a week`,frequencyOff:`Off`,lastCheckedAt:`Last checked: {time}`,lastCheckedNever:`Not checked yet`,newVersionAvailable:`New version {version} available`,newVersionAvailableSub:`Current {current} · click to view`,updateLater:`Later`,backendService:`Backend Service`,backendServiceDescription:`Restart the local QuickForge backend service. Running generations will be interrupted and the page will reconnect automatically.`,backendServiceStatus:`Service status`,restartBackendService:`Restart backend service`,restartBackendServiceDescription:`Use this when the local backend is stuck or after changing environment-level service settings.`,restartBackendConfirm:`Restart the backend service now? Running generations will be interrupted and the page will reconnect automatically.`,backendRestarting:`Backend is restarting...`,backendRestarted:`Backend restarted. Reloading...`,backendRestartFailed:`Backend restart failed.`,backendRestartTimeout:`Backend restart timed out. Please restart QuickForge manually.`,backendRestartUnsupported:`This launch mode does not support restarting from the UI. Please restart QuickForge manually.`,serviceMode:`Mode`,servicePid:`PID`,serviceStartedAt:`Started at`,serviceDataDir:`Data directory`,serviceWorkspace:`Workspace`,terminalShell:`Terminal shell`,terminalShellDescription:`QuickForge auto-detects common macOS, Windows, and Linux shells. Pick the checked default, or add a custom command/path only when it is missing. QUICKFORGE_TERMINAL_SHELL still takes priority.`,terminalShellAutoDetectedHint:`Detected entries are shown automatically for this computer.`,terminalShellDefault:`Default shell`,terminalShellSaved:`Terminal shell setting saved. New terminal sessions will use it.`,terminalShellProfilesSaved:`Terminal shell profiles saved.`,terminalShellCommand:`Custom shell command or path`,terminalShellCommandPlaceholder:`C:\\Program Files\\Git\\bin\\bash.exe`,terminalShellAdd:`Add`,terminalShellSetDefault:`Set as default`,terminalShellDefaultBadge:`Default`,terminalShellDetected:`Detected`,terminalShellNoDetected:`No shell was detected. Add a custom shell command or path below.`,terminalShellProfileRequired:`Enter a shell command or executable path before saving.`,terminalShellDeleteConfirm:`Delete terminal shell profile "{name}"?`,channels:`Channels`,channelsDescription:`Manage local communication channels that bridge external apps to QuickForge agents.`,channelsSecurityWarning:`Channel operations can start local processes on this computer. They are available only from the local machine.`,channelsEmpty:`No channels are available yet.`,start:`Start`,stop:`Stop`,restart:`Restart`,channelProvider:`Provider`,channelCommand:`Command`,channelPid:`PID`,channelStartedAt:`Started at`,channelWorkspace:`Launch workspace`,channelWorkspaceDescription:`WeChat ACP sessions start in the selected workspace. Use the default workspace for global, non-project chats.`,channelDefaultWorkspace:`Default workspace`,channelCurrentWorkspace:`Current workspace`,channelNoWorkspaces:`No workspace is available. Configure the default workspace before starting this channel.`,channelRequirements:`Requirements`,channelRecentLogs:`Recent logs`,channelNoLogs:`No logs yet.`,channelQrTitle:`Scan with WeChat`,channelQrDescription:`Use WeChat to scan the QR code shown below. If the terminal QR code is hard to scan, open the link instead.`,channelQrLink:`Login link`,channelStatusStopped:`Stopped`,channelStatusStarting:`Starting`,channelStatusWaitingScan:`Waiting for scan`,channelStatusRunning:`Running`,channelStatusStopping:`Stopping`,channelStatusError:`Error`,channelRestartConfirm:`Restart channel "{name}"?`,channelLogoutConfirm:`Log out channel "{name}"? You will need to scan again before using it.`,channelReloginConfirm:`Re-login channel "{name}"? The current process will stop and a new QR code will be generated.`,terminalNew:`New terminal`,terminalNewWith:`New terminal with`,terminalNewWithProfile:`New terminal: {name}`,terminalSelectShell:`Choose shell for new terminal`,terminalCollapse:`Collapse terminal`,terminalFullscreen:`Fullscreen terminal`,terminalExitFullscreen:`Exit fullscreen`,terminalStarting:`Starting terminal...`,terminalUnavailable:`Terminal unavailable`,terminalNoSessions:`No terminal sessions`,terminalCreateFailed:`Failed to create terminal`,terminalCloseFailed:`Failed to close terminal`,terminalConnectionFailed:`Failed to connect to terminal.`,terminalConnectionClosedUnexpectedly:`Terminal connection closed unexpectedly.`,terminalCloseSession:`Close {name}`,workspaceNoFilesToDisplay:`No files to display.`,workspaceNoWorkingTreeChanges:`No working tree changes.`,noProjectSelected:`No project selected`,workspacePanel:`Workspace`,workspaceExpandRightPanel:`Expand right panel`,workspaceCollapseRightPanel:`Collapse right panel`,workspaceOverview:`Overview`,workspaceFiles:`Workspace Files`,workspaceBrowser:`Browser`,workspaceChanges:`Changes`,workspaceCurrentArtifacts:`Review`,workspaceNoArtifacts:`No AI-produced files detected in this session yet.`,workspacePresentedArtifact:`Presented artifact`,workspaceInferredArtifact:`Inferred artifact`,workspaceCommands:`Commands`,workspaceCommandOutput:`Output`,workspaceCurrentBranch:`Current branch`,workspaceChangeCount:`changes`,workspaceNotGitRepository:`This project is not a Git repository.`,workspaceSelectProject:`Select a project to inspect its workspace.`,workspaceLoading:`Loading workspace...`,workspaceLoadFailed:`Failed to load workspace.`,workspaceFilterFiles:`Filter files by name or path`,workspaceOpenFileFailed:`Failed to open file.`,workspaceOpenDiffFailed:`Failed to open diff.`,workspaceViewDiff:`View diff`,refreshWorkspace:`Refresh workspace`,closeWorkspace:`Close workspace`,workspaceFullscreen:`Fullscreen workspace`,workspaceExitFullscreen:`Exit fullscreen`,workspaceStaged:`Staged`,workspaceUntracked:`Untracked`,workspaceConflicts:`Conflicts`,workspaceStagedChanges:`Staged Changes`,workspaceReview:`Review`,workspaceCommitMessage:`Commit msg`,workspaceReviewPrompt:`Please review the current workspace changes and generate a concise summary, risk assessment, verification plan, and a suggested commit message.
|
|
10
|
+
|
|
11
|
+
Changed files:
|
|
12
|
+
{list}`,workspaceCommitMessagePrompt:`Please generate a concise Conventional Commit message for the current Git changes. Include a one-line subject and an optional short body if useful.
|
|
13
|
+
|
|
14
|
+
Changed files:
|
|
15
|
+
{list}`,unknown:`Unknown`,webPreview:`Web Preview`,artifactPreview:`Artifacts`,artifactPreviewFiles:`Show artifact files`,artifactPreviewEmpty:`No artifact files to preview.`,artifactPreviewLoadFailed:`Failed to load artifact preview.`,artifactPreviewUnsupported:`This file type cannot be rendered directly.`,artifactPreviewViewSource:`View source`,artifactPreviewPin:`Pin artifact tools`,artifactPreviewUnpin:`Unpin artifact tools`,artifacts:`Artifacts`,previewArtifact:`Preview artifact`,previewUrl:`Preview URL`,previewUrlPlaceholder:`Enter a preview URL`,openPreview:`Open`,refreshPreview:`Refresh preview`,openInBrowser:`Open in browser`,invalidPreviewUrl:`Please enter a valid http:// or https:// URL.`,noPreviewUrlTitle:`Enter a preview URL`,noPreviewUrlDescription:`Run your project dev server in the terminal, then enter its local URL here. Vite, Next, Astro and similar tools usually update live through HMR.`,workspaceStatusAdded:`Added`,workspaceStatusDeleted:`Deleted`,workspaceStatusRenamed:`Renamed`,workspaceStatusUntracked:`Untracked`,workspaceStatusConflict:`Conflict`,workspaceStatusModified:`Modified`,copyPath:`Copy path`,copyContent:`Copy content`,copyDiffContent:`Copy diff content`,askAiAboutThis:`Ask AI about this`,readerFileMarkdownPrompt:"Please read the Markdown document `{path}` in the current workspace. Summarize its purpose, key sections, important instructions, outdated or risky parts, and suggest concise improvements.",readerFilePrompt:"Please inspect `{path}` in the current workspace and explain its role, important implementation details, and any risks or improvement opportunities.",readerDiffPrompt:"Please review the working-tree changes in `{path}`. Summarize what changed, point out possible bugs or regressions, and suggest focused verification steps.",openingReader:`Opening...`,markdownPreview:`Preview`,markdownSource:`Source`,lanAccess:`LAN Access`,lanAccessDescription:`Allow trusted devices on the same LAN to access the full QuickForge app after entering a password.`,lanAccessRiskWarning:`High risk: LAN devices that pass this password can access your conversations, projects, and available tools. Enable only on trusted networks.`,lanAccessStatus:`LAN access status`,lanAccessEnabled:`Full LAN access`,lanAccessPassword:`Access password`,lanAccessActiveDevices:`Unlocked devices`,lanAccessUrls:`LAN URLs`,lanAccessAllowFull:`Allow LAN devices to access full QuickForge`,lanAccessPasswordPlaceholder:`At least 8 characters`,lanAccessPasswordPlaceholderConfigured:`Leave empty to keep current password`,lanAccessSessionTtl:`Login validity`,lanAccessRevokeAll:`Sign out all LAN devices`,lanAccessRevokeAllConfirm:`Sign out all unlocked LAN devices now?`,lanAccessEnableConfirm:`Enable full LAN access? Only continue on a trusted network.`,lanAccessPasswordRequired:`Set an access password before enabling LAN access.`,lanAccessPasswordTooShort:`The access password must be at least 8 characters.`,lanAccessSaved:`LAN access settings saved.`,lanAccessRevoked:`All LAN devices have been signed out.`,enabled:`Enabled`,disabled:`Disabled`,configured:`Configured`,notConfigured:`Not configured`,generatePassword:`Generate password`,hour:`hour`,hours:`hours`,days:`days`,toolApprovalWaiting:`Waiting for approval: {toolName}`,autoCompactApprovalWaiting:`Context reached {percent}% of the {threshold}% threshold. Compact now?`,autoCompactApprovalPreview:`QuickForge will summarize older history and continue with the summary plus the latest {keepRecentTurns} user turn(s). Full chat history remains visible.`,autoCompactFailed:`Automatic context compaction failed; continuing with the current history.`,contextCompactedTimelineLabel:`Earlier context is summarized for the model`,contextCompactedLabel:`Compressed context`,contextCompactedTooltip:`This chat is using a summarized context for model requests while keeping the full history visible.`,contextCompactedViewSummary:`View summary`,contextCompactedHideSummary:`Hide summary`,contextCompactedSummaryTitle:`Summary used by the model`,contextCompactedCopySummary:`Copy summary`,toolApprovalAccept:`✓ Accept`,toolApprovalReject:`✗ Reject`,toolApprovalTimeout:`Timeout`,toolApprovalTruncated:`... (truncated)`,processed:`Processed`,processing:`Processing`,processFailed:`Failed`,processAborted:`Aborted`,expandProcess:`Expand processing details`,collapseProcess:`Collapse processing details`,relativeMinuteShort:`{count}m`,relativeHourShort:`{count}h`,relativeDayShort:`{count}d`,relativeWeekShort:`{count}w`,relativeYearShort:`{count}y`},zh:{language:`语言`,displayLanguage:`界面语言`,languageDescription:`选择速构 QuickForge 的界面显示语言。切换后页面会刷新以应用到所有组件。`,simplifiedChinese:`简体中文`,english:`English`,apply:`应用`,noLanguageChange:`当前已经是所选语言。`,newChat:`新建对话`,newChatEmptyTitle:`今天想推进什么?`,chooseProject:`选择项目`,searchProjects:`搜索项目`,newProject:`添加项目`,createBlankProject:`添加项目`,useExistingFolder:`选择项目目录`,useNoProject:`无项目`,noMatchingProjects:`没有匹配的项目`,loadingChatWorkspace:`正在加载聊天工作区...`,localServiceUnavailableTitle:`QuickForge 本地服务不可用`,localServiceUnavailableDescription:`QuickForge 需要通过本地服务进行存储。请使用 npm run dev 或 quickforge 命令启动后刷新此页面。`,project:`项目`,projects:`项目`,loadingProject:`正在加载项目...`,addProject:`添加项目`,noProjects:`暂无项目。`,expandProject:`展开项目`,collapseProject:`折叠项目`,expandAllProjects:`展开所有项目`,collapseAllProjects:`折叠所有项目`,dragToReorder:`拖拽排序`,newProjectChat:`新建项目对话`,projectChat:`项目对话`,normalChat:`普通对话`,conversations:`对话`,noConversations:`暂无对话`,filter:`筛选`,selecting:`选择中...`,chooseFolder:`选择文件夹`,selectProjectDirectory:`选择项目目录`,selectProjectDirectoryDescription:`浏览本地文件夹或粘贴路径,然后选择一个文件夹作为项目。`,quickAccess:`快捷入口`,path:`路径`,go:`前往`,parentDirectory:`上级目录`,noFolders:`该目录下没有文件夹。`,selectThisFolder:`选择此文件夹`,folderPickerPathPlaceholder:`输入或粘贴文件夹路径`,filesystemRootsFailed:`加载文件系统入口失败。`,directoryLoadFailed:`加载目录失败。`,noSavedConversations:`暂无保存的对话。`,deleteProject:`删除项目`,deleteProjectConfirm:`确定要删除项目「{name}」吗?该项目的对话记录将保留。`,deleteSession:`删除会话`,deleteSessionConfirm:`确定要删除该对话吗?删除后不可恢复。`,deleteSessionFailed:`删除对话失败。`,archiveSession:`归档对话`,confirmArchive:`确认归档`,archivedConversations:`已归档对话`,archivedConversationsDescription:`已归档的对话会从侧边栏隐藏,你可以在这里恢复或永久删除。`,searchArchivedConversations:`搜索已归档对话`,noArchivedConversations:`暂无已归档对话。`,archivedAt:`归档时间`,lastModified:`最后更新`,restoreSession:`恢复`,restoreSessionFailed:`恢复对话失败。`,sessionRestored:`对话已恢复。`,sessionNotFound:`未找到该对话。`,deletePermanently:`删除`,deleteAll:`全部删除`,deleteArchivedSessionConfirm:`确定要永久删除「{title}」吗?此操作不可恢复。`,deleteAllArchivedSessionsConfirm:`确定要永久删除所有已归档对话吗?此操作不可恢复。`,archivedSessionDeleted:`已归档对话已删除。`,archivedSessionsDeleted:`已归档对话已删除。`,allProjects:`所有项目`,unknownProject:`未知项目`,conversationCount:`{count} 个对话`,confirm:`确认`,confirmDelete:`确认删除`,rename:`重命名`,renameSession:`重命名对话`,sessionName:`对话名称`,settings:`设置`,toggleSidebar:`切换侧边栏`,failedToSelectProjectDirectory:`选择项目目录失败。`,projectSwitchFailed:`切换到该对话绑定的项目失败,工作区工具未启动。`,copy:`复制`,copied:`已复制`,svgDisplayMode:`SVG 显示模式`,svgPreviewMode:`预览`,svgSourceMode:`源码`,svgEnlargePreview:`点击放大 SVG 预览`,copySvgSource:`复制 SVG 源码`,downloadSvg:`下载 SVG`,rollback:`回滚`,retry:`重试`,reloadPage:`刷新页面`,fork:`分支`,forkConversation:`从此处分支新对话`,yoloEnabledTitle:`工作区授权已开启:本地工具可使用当前项目`,yoloDisabledTitle:`工作区授权已锁定:本地工具已阻止`,agentAccessMenuLabel:`Agent 权限模式`,agentAccessDefaultLabel:`默认权限`,agentAccessFullLabel:`完全访问权限`,agentAccessDefaultTitle:`默认权限:仅在当前代码仓库内工作,可能影响系统的操作需要确认。`,agentAccessFullTitle:`完全访问权限:等同开发者授权,工具可在既有工作区边界内自动执行。`,agentAccessModeSyncFailed:`同步 Agent 权限模式失败。`,planModeLabel:`计划`,planModeEnabledTitle:`计划模式已开启:下一条消息会按 /plan 发送。点击可移除。快捷键:Shift+Tab`,planModeDisabledTitle:`计划模式:下一条消息按 /plan 发送。快捷键:Shift+Tab`,composerPlaceholder:`描述你想做的事`,assistantWaitingThinking:`正在思考`,assistantWaitingOrganizing:`正在整理答案`,assistantWaitingContinuing:`内容较多,正在继续处理`,assistantWaitingAriaLabel:`AI 正在准备回复`,customCommandsHint:`自定义指令`,customCommandsEmptyHint:`还没有项目指令。`,customCommandsListDescription:`列出项目自定义指令`,customCommandsNewDescription:`创建项目自定义指令`,planCommandDescription:`先生成计划;本轮禁止编辑文件或运行命令。`,reviewCommandDescription:`提交前自检待提交代码;本轮禁止编辑文件。`,summaryCommandDescription:`基于当前对话创建总结后的新对话,减少上下文占用。`,compactCommandDescription:`在当前对话内压缩上下文,使用与自动压缩一致的滚动摘要。`,clearCommandDescription:`清除当前对话历史和上下文,不调用模型。`,helpCommandDescription:`显示所有可用命令及其用法。`,yoloBlockedReason:`本地工具 {name} 已被当前 Agent 权限模式阻止。请切换到完全访问权限,或在弹出审批时确认该工具调用。`,globalToolBlockedReason:`本地工具 {name} 已被阻止,因为这是未绑定项目的普通对话。请新建或打开项目对话后使用工作区工具。`,noActiveProjectToolBlockedReason:`本地工具 {name} 已被阻止,因为当前没有激活项目。请添加或选择项目后再使用工作区工具。`,generationStillRunning:`生成仍在进行中。请停止生成或等待完成后再回滚。`,noConversationTurnToRollback:`没有可回滚的对话轮次。`,rollbackConfirmTitle:`确认回滚?`,rollbackConfirm:`确定回滚到这条消息之前吗?该消息及其之后的对话记录会被移除,消息内容会恢复到输入框。`,sharedRollbackConfirmTitle:`确认回滚分享对话?`,sharedRollbackConfirm:`该操作会直接影响分享者本机中的原始对话。该消息及其之后的对话记录会被移除,消息内容会恢复到输入框。`,confirmRollback:`确认回滚`,rollingBack:`回滚中...`,rollbackFailed:`回滚失败。`,retryFailed:`重试失败。`,copyFailed:`复制失败,请检查剪贴板权限。`,errorBoundaryTitle:`出错了`,errorBoundaryUnexpected:`发生了意外错误。`,errorBoundaryTryAgain:`重试`,execute:`执行`,addCustomModelFirst:`请先在设置里添加自定义模型,并确保填写了模型 ID 后保存。`,modelSetupRequired:`请先添加模型后再新建对话。`,modelSetupTitle:`还没有配置模型`,modelSetupDescription:`添加一个 OpenAI-Compatible 或 Anthropic 兼容模型后即可开始对话。QuickForge 只会使用你自己配置的模型。`,modelSetupSupports:`支持 LiteLLM、OpenRouter、DeepSeek、通义千问、智谱、Ollama,以及大多数 /v1/chat/completions 服务。`,modelSetupLocalStorage:`提供商、模型 ID 和 API Key 会由本机 QuickForge 本地服务保存。`,modelSetupAddModel:`添加模型`,modelSetupUseLiteLlmExample:`使用 LiteLLM 示例配置`,firstUseGuideTitle:`从安全工作流开始`,firstUseGuideDescription:`添加项目后,先让 QuickForge 理解项目;涉及代码修改时,建议先用 /plan 生成计划,再授权本地工具执行。`,firstUseGuideStepModel:`确认要使用的模型配置。`,firstUseGuideStepProject:`添加本地项目,让 AI 使用工作区上下文。`,firstUseGuideStepPlan:`先使用 /plan;该轮不会编辑文件或运行命令。`,firstUseGuideConfigureModel:`配置模型`,firstUseGuideAddProject:`添加项目`,firstUseGuideUsePrompt:`试用示例提示词`,firstUseGuideCopyPrompt:`复制 /plan 示例`,firstUseGuideDismiss:`我知道了`,firstUseGuideProjectPrompt:`/plan 阅读这个项目,说明项目结构、运行方式和主要风险。先不要修改文件。`,firstUseGuideGeneralPrompt:`/plan 先把这个需求拆成实现步骤和风险点。暂时不要修改文件。`,defaultOptions:`默认选项`,defaultOptionsDescription:`配置新建对话和定时任务默认使用的模型、思考等级、工具展示和上下文管理。`,defaultModel:`默认模型`,defaultThinkingLevel:`默认思考等级`,toolDisplay:`工具展示`,showToolDetails:`显示 Tool 详细 JSON`,expandToolsByDefault:`默认展开 Tool 调用`,showToolDetailsDescription:`关闭后将隐藏 Tool 参数和 details JSON,但仍会显示控制台输出、状态、摘要和 diff。`,fontSize:`字号`,fontSizeDescription:`调整全局基础字号和常用正文字号。`,baseFontSize:`基础字号(px)`,bodyFontSize:`正文字号(px)`,bodyFontSizeNote:`应用到界面常用文字使用的 Tailwind text-sm 工具类。`,appearance:`外观`,appearanceDescription:`自定义界面的主题和字号。`,theme:`主题`,themeDescription:`在浅色和深色之间切换,即时生效。`,lightTheme:`浅色`,darkTheme:`深色`,appearanceSaved:`外观已保存`,interfaceFontSize:`界面字号`,messageFontSize:`对话字号`,messageFontSizeNote:`应用到聊天消息里的主要正文。`,customFontSize:`自定义`,fontSizeSmall:`小`,fontSizeDefault:`默认`,fontSizeLarge:`大`,fontSizeExtraLarge:`超大`,advancedFontSizeSettings:`高级字号设置`,restoreDefault:`恢复默认`,fontSizeSaved:`字号已保存`,toolDetailsHidden:`Tool 详细信息已隐藏。可在设置中开启“显示 Tool 详细 JSON”查看完整参数。`,toolArgsSummary:`参数摘要`,saveDefaultOptions:`保存默认选项`,saving:`保存中...`,defaultOptionsSaved:`默认选项已保存`,contextManagement:`上下文管理`,autoCompactEnabled:`自动压缩上下文`,autoCompactRequireConfirmation:`自动压缩前先询问确认`,autoCompactTriggerNote:`系统会在每次请求模型前检查。测试时可降低阈值,或调小模型 Context Window。`,autoCompactThresholdPercent:`上下文达到多少百分比时压缩`,autoCompactKeepRecentTurns:`保留最近用户回合数`,autoCompactDescription:`当预计下一次请求达到模型上下文窗口的指定比例时,QuickForge 会总结较早历史并继续当前任务。该过程会额外消耗一次模型调用。`,autoCompactHistoryPreserved:`完整聊天历史仍会保留在界面中;只有发送给模型的上下文会被压缩。`,thinkingLevel:`思考等级`,thinkingOff:`关`,thinkingLow:`低`,thinkingMedium:`中`,thinkingHigh:`高`,thinkingXHigh:`超高`,currentConfiguration:`当前配置`,thinkingSupported:`支持思考`,thinkingNotSupported:`该模型不支持思考等级。`,thinkingRequiresReasoningModel:`思考等级需要推理/思考模型。`,customModels:`自定义模型`,customModelsTitle:`自定义模型`,customModelsDescription:`只使用你配置的自定义 OpenAI-Compatible 模型。`,addModel:`添加模型`,editModel:`编辑模型`,delete:`删除`,editCustomModel:`编辑自定义模型`,addCustomModel:`添加自定义模型`,providerName:`提供商名称`,providerNamePlaceholder:`例如:LiteLLM`,protocolType:`协议类型`,protocolHelp:`LiteLLM、OpenRouter、大多数 /v1/chat/completions 服务请选择 OpenAI Compatible;直连 Anthropic API 才选 Anthropic Messages。`,apiKey:`API Key`,apiKeyPlaceholder:`没有可以留空`,showApiKey:`查看 API Key`,hideApiKey:`隐藏 API Key`,customHeaders:`自定义 Headers JSON`,customHeadersPlaceholder:`{
|
|
16
|
+
"X-Custom-Header": "value"
|
|
17
|
+
}`,customHeadersHelp:`可选的提供商级 HTTP Headers。必须是值为字符串的 JSON 对象,会随模型配置保存在本地。`,invalidHeadersJson:`自定义 Headers 必须是有效 JSON 对象,并且键和值都必须是字符串。`,modelId:`模型 ID`,modelIdPlaceholder:`例如:anthropic/claude-sonnet-4`,contextWindow:`Context Window`,maxTokens:`Max Tokens`,reasoningModel:`推理/思考模型(DeepSeek V4、Qwen 等)`,providerProtocol:`协议`,model:`模型`,reasoning:`推理`,noModelAdded:`未添加模型`,modelsCount:`{count} 个模型`,modelIndex:`模型 #{index}`,modelsList:`模型列表`,atLeastOneModel:`至少需要一个模型。`,duplicateModelId:`模型 ID 不能重复。`,cancel:`取消`,save:`保存`,yes:`是`,no:`否`,loading:`加载中...`,noCustomModels:`还没有自定义模型,请点击"添加模型"。`,fillProviderBaseUrlModel:`请填写提供商名称和 Base URL。`,saveCustomModelFailed:`保存自定义模型失败。`,confirmDeleteProvider:`确定删除 {name} 吗?`,deleteFailed:`删除失败。`,selectCustomModel:`选择自定义模型`,close:`关闭`,back:`返回`,searchModels:`搜索模型...`,noMatchingCustomModels:`没有匹配的自定义模型`,presets:`快速模板`,presetOpenai:`OpenAI`,presetDeepseek:`DeepSeek`,presetGlm:`智谱 GLM`,presetOllama:`本地 Ollama`,presetLitellm:`LiteLLM 代理`,presetCustom:`自定义`,providerAdvanced:`高级选项`,expandModel:`调整上下文窗口、最大输出、推理`,addHeader:`添加请求头`,headerName:`请求头名称`,headerValue:`值`,removeHeader:`移除请求头`,testConnection:`测试连接`,testingConnection:`测试中…`,connectionOk:`连接成功`,connectionFailed:`连接失败`,testRequiresFields:`请填写 Base URL 和至少一个模型 ID。`,readFile:`读取文件`,searchFiles:`搜索文件`,writeFile:`写入文件`,editFile:`编辑文件`,runCommand:`运行命令`,presentFiles:`展示文件`,executeInTerminal:`在终端中执行`,confirmExecuteCommandTitle:`在终端中执行命令?`,confirmExecuteMultipleCommands:`即将在本地终端中执行多行命令,是否继续?`,confirmExecuteDangerousCommand:`该命令可能修改系统、发布包、推送代码或执行远程脚本,是否继续?`,terminalCommandExecuteFailed:`在终端中执行命令失败。`,runSubagent:`运行 subagent`,subagentGeneral:`General`,subagentExplore:`Explore`,subagentRunning:`{name} 运行中`,subagentCompleted:`{name} 已完成`,subagentFailed:`{name} 失败`,subagentTask:`任务`,subagentContext:`上下文`,subagentExpectedOutput:`期望输出`,subagentResult:`结果`,subagentToolCalls:`工具调用`,subagentToolApprovalWaiting:`{source} 请求审批:{toolName}`,toolApprovalSourceSubagent:`来源:{source} subagent`,activateSkill:`激活技能`,readSkillResource:`读取技能资源`,yoloModeSyncFailed:`同步 Agent 权限模式失败,已恢复为之前的状态。`,toolApprovalFailed:`提交工具审批失败,请重试。`,toolApprovalSubmitting:`提交中...`,terminateCommand:`终止`,terminateCommandTitle:`终止这个正在运行的命令`,commandTerminateRequested:`正在终止...`,running:`运行中`,done:`完成`,error:`错误`,taskCompleted:`对话任务完成`,taskError:`对话任务出错`,called:`已调用`,input:`输入`,output:`输出`,details:`详情`,scheduledTasks:`定时任务`,scheduledTasksDescription:`任务保存在本地后台服务中,并按 AI 解析出的 cron 表达式执行。`,createTask:`创建任务`,editTask:`编辑`,cancelEditTask:`取消编辑`,saveTask:`保存任务`,taskScheduleDescriptionLabel:`定时描述`,taskScheduleDescriptionPlaceholder:`例如:每天早上 9 点,把这段内容发给 AI:帮我生成销售日报。`,quickAiParseTask:`AI 会把这段描述解析为 cron 表达式,系统只保存并按 cron 执行。`,taskTitleLabel:`任务名称`,taskTitlePlaceholder:`例如:每日工作总结`,promptContentLabel:`AI 将发送的内容`,promptContentPlaceholder:`填写到点后原样发送给 AI 的内容。`,taskEnabledSwitch:`启用这个任务`,taskInstructionPlaceholder:`例如:每天早上 9 点帮我生成销售日报`,aiParseTask:`AI 解析任务`,confirmCreate:`确认创建`,taskList:`任务列表`,noScheduledTasks:`还没有定时任务。先输入一句自然语言指令创建一个。`,taskEnabled:`启用中`,taskRunning:`执行中`,taskPaused:`已暂停`,taskFinished:`已完成`,taskFailed:`执行失败`,executeNow:`立即执行`,enable:`启用`,pauseTask:`暂停`,deleteTask:`删除`,recentExecutions:`最近执行记录`,executionSuccess:`成功`,executionRunning:`执行中`,nextExecution:`下一次:`,lastExecution:`上次:`,noModelAvailable:`暂无可用模型`,noProjectBound:`不绑定项目`,aiParsed:`AI 已解析,请确认`,taskName:`任务名称:`,executionRule:`执行规则:`,nextExecutionTime:`下一次执行:`,taskProject:`项目:`,taskThinkingLevel:`思考:`,aiInstruction:`AI 指令:`,taskModel:`模型`,taskThinking:`思考`,taskProjectLabel:`项目`,taskExecutionMode:`执行模式`,taskExecutionModeSerial:`串行`,taskExecutionModeParallel:`并行`,taskExecutionModeHelp:`该设置只控制同一个任务是否允许重叠执行;不同定时任务之间仍可并行执行。`,tasksCount:`共 {total} 个任务,{enabled} 个启用中`,confirmDeleteTask:`确定要删除这个定时任务吗?删除后不可恢复。`,waitingForResult:`等待结果`,autoRun:`自动执行`,manualRun:`手动测试`,runInputContent:`发送给 AI 的内容`,runAiResult:`AI 结果`,runDuration:`耗时:`,taskListTab:`任务列表`,executionHistoryTab:`执行历史`,agentsTab:`Agents`,agentsDescription:`创建可复用的 Agent Profile,用于定时任务和 run_subagent 委派。`,createAgent:`创建 Agent`,editAgent:`编辑 Agent`,builtinAgent:`内置`,builtinAgentReadonly:`内置 Agent 在当前版本中只读。`,enabledAsSubagent:`允许作为 sub agent`,enableAsSubagent:`启用作为 sub agent`,disableAsSubagent:`禁用作为 sub agent`,noDescription:`暂无描述。`,maxRuntimeMs:`最大运行时间:`,maxToolCalls:`最大工具调用:`,defaultAgent:`默认 Agent`,executionAgent:`执行 Agent:`,agentName:`Agent 名称`,agentLabel:`显示名称`,agentLabelPlaceholder:`例如:代码审查 Agent`,agentDescription:`描述`,agentSystemPrompt:`系统提示词`,allowedTools:`可用工具`,highRiskTool:`高风险`,confirmDeleteAgent:`确定删除这个自定义 Agent 吗?使用它的定时任务将回退到默认 Agent。`,aiFillAgent:`AI 填充`,aiFillAgentDescription:`描述你想创建的 Agent,AI 只会填充 Agent 名称、显示名称、描述和系统提示词。`,aiFillAgentPlaceholder:`例如:生成一个只读代码审查 Agent,重点检查架构、潜在 bug 和测试覆盖。`,aiFillAgentLoading:`生成中...`,aiFillAgentNoModel:`请先配置默认模型。`,aiFillAgentFailed:`AI 填充失败,请检查模型配置和 API Key 后重试。`,aiFillAgentInputRequired:`请描述你想创建的 Agent。`,taskContent:`任务内容`,viewDetails:`查看详情`,moreActions:`更多操作`,historyFilters:`筛选条件`,allTasks:`全部任务`,allStatuses:`全部状态`,allTriggers:`全部触发方式`,triggerType:`触发方式`,keyword:`关键词`,keywordPlaceholder:`搜索输入、结果或错误`,startTime:`开始时间`,endTime:`结束时间`,query:`查询`,reset:`重置`,previousPage:`上一页`,nextPage:`下一页`,pageSize:`每页 {size} 条`,paginationSummary:`第 {page} / {pages} 页,共 {total} 条`,noExecutionHistory:`暂无执行历史。`,viewConversation:`查看对话`,createdAt:`创建时间`,status:`状态`,search:`搜索`,searchDialog:`搜索对话记录...`,noSearchResults:`没有找到相关对话`,searchHint:`输入关键词搜索已加载的对话记录`,scheduledTasksLabel:`定时任务`,skills:`技能`,mcp:`MCP`,mcpServers:`MCP 服务`,plugins:`插件`,pluginMentionHeader:`插件`,composerAddMenu:`添加`,composerAddAttachment:`附件`,composerAddPlugins:`插件`,composerAddBack:`返回`,pluginOpenaiDocumentsName:`文档`,pluginOpenaiDocumentsDescription:`创建和编辑文档产物`,pluginOpenaiSpreadsheetsName:`表格`,pluginOpenaiSpreadsheetsDescription:`创建、分析和整理表格文件`,pluginOpenaiPresentationsName:`演示文稿`,pluginOpenaiPresentationsDescription:`创建和编辑演示文稿`,pluginsDescription:`管理本地 QuickForge 插件。当前首版支持通过 manifest 声明并贡献 Agent 工具的插件。`,pluginsReload:`重新加载插件`,loadingPlugins:`正在加载插件...`,noPlugins:`未发现插件`,noPluginsDescription:`将包含 plugin.json 的插件目录放到以下任一搜索路径,然后重新加载。`,pluginsCount:`共 {total} 个插件,{enabled} 个已启用`,pluginToolsCount:`{count} 个工具`,pluginPermissionsCount:`{count} 个权限`,pluginDetails:`插件详情`,pluginVersion:`版本`,pluginStatusLoaded:`已加载`,pluginStatusDisabled:`已停用`,pluginStatusError:`错误`,pluginTools:`工具`,pluginPermissions:`声明权限`,pluginNoTools:`未声明工具。`,pluginNoPermissions:`未声明权限。`,pluginTrustedNotice:`首版插件属于本地可信 Node.js 代码;权限目前用于展示和后续强校验。`,pluginDiscoveryErrors:`插件发现错误`,enablePlugin:`启用`,disablePlugin:`禁用`,pluginsLoadFailed:`加载插件失败。`,pluginsSaveFailed:`更新插件失败。`,manageMcpServers:`管理 MCP 服务`,mcpNoServersDescription:`还没有配置 MCP 服务。点击「添加服务」,或在右侧粘贴 mcpServers JSON 配置。`,mcpConfiguredServers:`已配置服务`,mcpReconnect:`重新连接`,mcpAddServer:`添加服务`,mcpEditServer:`编辑服务`,mcpServerName:`服务名称`,mcpCommand:`命令`,mcpTransport:`传输方式`,mcpUrl:`URL`,mcpArgs:`参数,每行一个`,mcpCwd:`工作目录`,mcpEnv:`环境变量,每行 KEY=value`,mcpToolsCount:`{count} 个工具`,mcpLoadFailed:`加载 MCP 服务失败。`,mcpSaveFailed:`保存 MCP 服务失败。`,mcpDeleteFailed:`删除 MCP 服务失败。`,mcpReconnectFailed:`重新连接 MCP 服务失败。`,mcpDeleteConfirm:`确定删除 MCP 服务「{name}」吗?`,mcpImportConfig:`导入 MCP JSON`,mcpImportConfigDescription:"直接粘贴 mcpServers 格式的 MCP JSON 配置。QuickForge 支持 stdio、HTTP 和 SSE 传输;远程服务可使用 headers,并支持通过 ${...} 从后端进程环境变量读取。",mcpUseExample:`使用示例`,mcpImportUpdate:`导入 / 更新`,mcpReplaceAll:`替换全部`,mcpReplaceConfirm:`这会删除当前未包含在 JSON 中的 MCP 服务,确定继续吗?`,mcpInvalidJson:`MCP 配置必须是合法 JSON。`,mcpInvalidConfigJson:`MCP 配置必须包含 mcpServers 对象。`,mcpEmptyConfigJson:`mcpServers 不能为空。`,mcpInvalidServerName:`MCP 服务名称无效:{name}。请只使用小写字母、数字和连字符。`,mcpInvalidServerConfig:`MCP 服务「{name}」必须是对象。`,mcpInvalidTransport:`MCP 服务「{name}」的传输方式必须是 stdio、http 或 sse。`,mcpMissingCommand:`MCP 服务「{name}」使用 stdio 传输时必须提供 command。`,mcpMissingUrl:`MCP 服务「{name}」使用 HTTP/SSE 传输时必须提供 url。`,mcpArgsMustBeArray:`MCP 服务「{name}」的 args 必须是数组。`,mcpEnvMustBeObject:`MCP 服务「{name}」的 env 必须是对象。`,mcpHeadersMustBeObject:`MCP 服务「{name}」的 headers 必须是对象。`,mcpHeaders:`Headers,每行 KEY=value`,mcpReconnectServer:`重连`,mcpMoreTools:`+{count}`,mcpNamePlaceholder:`例如 my-server`,mcpUrlPlaceholder:`https://example.com/mcp`,mcpCommandPlaceholder:`例如 npx`,mcpTabServer:`服务`,mcpTabJson:`JSON`,optional:`可选`,globalSkills:`全局技能`,projectSkills:`项目技能`,help:`帮助`,projectCommands:`项目命令`,projectCommandsDescription:`为当前项目配置额外的 Markdown slash command 目录。QuickForge 还会读取用户级目录 ~/.quickforge/commands/(所有项目共享),然后依次读取项目目录 .claude/commands、.opencode/commands、.ai/commands 及此处的配置目录;同名 command 以后面的目录覆盖前面的目录。`,selectProjectForCommands:`请先选择或添加一个项目,再配置项目命令。`,commandDirectory:`命令目录`,commandDirectories:`命令目录`,commandDirectoryPlaceholder:`.claude/commands
|
|
18
|
+
.opencode/commands
|
|
19
|
+
D:\\shared\\ai-commands`,commandDirectoryHelp:`一行一个目录。支持相对路径和绝对路径。相对路径会基于当前项目根目录解析。留空则只使用内置兼容命令目录。`,commandDirectoryExamples:`示例`,projectCommandsSaved:`项目命令设置已保存。`,loadedCommands:`已加载命令({count})`,noCommandsLoaded:`暂未加载到任何命令。请在上方添加目录或新建命令后重试。`,openCommandDir:`打开命令目录`,createCommand:`新建命令`,newCommandPrompt:`请输入命令名(小写字母、数字、连字符):`,commandCreated:`命令已创建:{name}`,commandAlreadyExists:`命令已存在:{name}`,invalidCommandName:`命令名无效,请使用小写字母、数字和连字符。`,manageSkills:`管理技能`,manageGlobalSkills:`管理全局技能`,manageProjectSkills:`管理项目技能`,openFolder:`打开文件夹`,openInExplorer:`在资源管理器打开`,openInExplorerFailed:`打开项目目录失败。`,moreOptions:`更多选项`,pinSession:`置顶对话`,unpinSession:`取消置顶`,shareSession:`分享对话`,selectProjectForSkills:`请先选择或添加一个项目,再管理技能。`,skillsDescription:`选择项目「{project}」启用的 Agent Skills。QuickForge 只在提示词中披露名称/描述;完整 SKILL.md 指令会在需要时通过 activate_skill 按需加载。`,globalSkillsDescription:`选择 QuickForge 全局启用的 Agent Skills。技能会从 ~/.claude/skills、~/.opencode/skills、~/.agents/skills 和 ~/.quickforge/skills 发现。新对话只注入目录,完整指令按需加载。`,projectSkillsDescription:`选择项目「{project}」启用的 Agent Skills。项目技能从 .claude/skills、.opencode/skills、.agents/skills 和 .quickforge/skills 发现;同名项目技能会覆盖全局技能,并只在新项目对话中按需加载。`,searchSkills:`搜索技能...`,availableSkills:`可用技能`,selectedSkillsCount:`已选择 {count} 个`,noMatchingSkills:`没有匹配的技能`,skillSearchPaths:`搜索路径`,failedToLoadSkills:`加载技能失败。`,failedToSaveSkills:`保存技能失败。`,readSkill:`阅读技能`,readSkillContent:`阅读技能内容`,backToSkillList:`返回技能列表`,failedToReadSkill:`读取技能内容失败。`,noSkillContent:`该技能没有可阅读的内容。`,requestFailed:`请求失败`,backupRestore:`备份与恢复`,backupRestoreDescription:`导出或恢复 QuickForge 的设置、模型提供商、项目、定时任务和对话。导入前本地服务会先创建一份安全备份。备份可能包含敏感对话、本机路径、代码片段,并可选包含 API Key。`,exportData:`导出数据`,exportDataDescription:`下载 JSON 备份文件,可自行保存或迁移到其他 QuickForge 安装。默认不包含 API Key,除非你明确勾选。`,exportScope:`导出范围`,exportScopeAll:`全部数据`,exportScopeConfig:`仅配置`,exportScopeSessions:`仅对话`,includeApiKeys:`包含 API Key`,includeApiKeysDescription:`API Key 属于敏感信息。仅在私密加密保存或可信迁移时启用。`,backupExportSecretsConfirm:`此备份将包含 API Key。请不要提交到 Git 或分享给不可信人员。是否继续?`,exportBackup:`导出备份`,backupExported:`备份已导出。`,backupExportFailed:`导出备份失败。`,importData:`导入数据`,importDataDescription:`恢复之前导出的 JSON 备份。系统会先检查文件内容,然后替换当前本地数据中对应的部分。`,importBackup:`导入备份`,backupInspectTitle:`备份预览`,backupInspectExportedAt:`导出时间`,backupInspectVersion:`版本`,backupInspectScope:`范围`,backupInspectSecrets:`包含 API Key`,backupInspectSections:`数据项`,backupInspectFailed:`检查备份失败。`,backupInspected:`备份已检查,请在下方选择要恢复的数据。`,selectRestoreSections:`选择要恢复的数据`,restoreMode:`恢复模式`,restoreModeReplace:`替换`,restoreModeReplaceDescription:`用备份内容完全替换所选分区的本地数据,现有本地数据将被覆盖。`,restoreModeMerge:`合并`,restoreModeMergeDescription:`将备份内容合并到本地,冲突时以备份为准,本地独有的条目将被保留。`,confirmImportSelected:`导入所选数据`,selectAtLeastOneRestoreSection:`请至少选择一个要恢复的数据项。`,restoreSettings:`设置`,restoreSettingsDescription:`语言、默认选项等应用偏好设置。`,restoreMcp:`MCP 服务`,restoreMcpDescription:`全局 MCP 服务定义及其启用/停用状态。`,restoreProviderKeys:`API Key`,restoreProviderKeysDescription:`敏感的模型提供商 API Key。恢复后会替换当前保存的密钥。`,restoreCustomProviders:`自定义提供商和模型`,restoreCustomProvidersDescription:`自定义模型提供商、端点、模型 ID 及相关配置。`,restoreProjects:`项目`,restoreProjectsDescription:`项目列表、当前项目和已选择的技能。`,restoreScheduledTasks:`定时任务`,restoreScheduledTasksDescription:`已保存的 AI 定时任务。`,restoreConversations:`对话`,restoreConversationsDescription:`对话历史和元数据。会作为一个一致的整体恢复。`,backupImportConfirm:`导入会替换当前 QuickForge 本地数据中对应的部分。系统会先创建安全备份。是否继续?`,backupImported:`备份已导入,应用即将刷新。`,backupImportFailed:`导入备份失败。`,backupSafetyBackupPath:`安全备份保存位置`,about:`关于`,aboutQuickForge:`关于 QuickForge`,aboutQuickForgeDescription:`查看项目信息、GitHub 仓库,并从 npm 安装更新。`,projectInfo:`项目信息`,packageName:`包名`,currentVersion:`当前版本`,latestVersion:`最新版本`,github:`GitHub`,checkUpdate:`检查更新`,checkingUpdate:`检查中...`,checkUpdateDescription:`从 npm 检查 QuickForge 最新版本。点击更新会启动外部更新器、重启本地后端,同时仍可使用 qf update 或手动 npm install 作为备用方式。`,updateAvailableMessage:`发现新版本:{current} → {latest}。`,localVersionNewerMessage:`本地版本 {current} 高于 npm 最新版本 {latest}。`,alreadyLatestVersion:`QuickForge 已是最新版本({version})。`,updateNow:`立即更新`,updatingQuickForge:`正在启动 QuickForge 更新器...`,updateStarted:`更新已开始。QuickForge 会自动重启,服务恢复后页面会自动重新连接。`,updateRestarted:`更新完成,正在刷新页面...`,updateRestartTimeout:`更新时间超过预期。请查看更新日志,或手动运行 qf update / npm install。`,updateCompleted:`更新完成。请重启 QuickForge 并刷新页面。`,updateFailed:`更新失败。`,updateCheckFailed:`检查更新失败。`,updateCommand:`命令`,updateLog:`更新日志`,updateLogFile:`日志:{path}`,updateConfirm:`QuickForge 将启动外部更新器,在这台电脑上执行以下命令,然后重启本地后端:
|
|
20
|
+
{command}
|
|
21
|
+
|
|
22
|
+
正在运行的生成会被中断。如果更新失败,仍可手动运行 qf update 或该 npm 命令。是否继续?`,updateFrequencySection:`自动检查更新`,updateFrequencyDescription:`启动时在后台检测新版本。发现新版本时,会在左下角轻轻提醒。`,frequencyStartup:`每次启动检查`,frequencyDaily:`每天一次`,frequencyWeekly:`每周一次`,frequencyOff:`关闭`,lastCheckedAt:`上次检查:{time}`,lastCheckedNever:`尚未检查`,newVersionAvailable:`发现新版本 {version}`,newVersionAvailableSub:`当前 {current} · 点击查看`,updateLater:`稍后`,backendService:`后端服务`,backendServiceDescription:`重启 QuickForge 本地后端服务。正在运行的生成会被中断,页面会自动重新连接。`,backendServiceStatus:`服务状态`,restartBackendService:`重启后端服务`,restartBackendServiceDescription:`当本地后端卡住,或调整了服务级环境配置后,可以在这里重启。`,restartBackendConfirm:`确定现在重启后端服务吗?正在运行的生成会被中断,页面会自动重新连接。`,backendRestarting:`后端正在重启...`,backendRestarted:`后端已重启,正在刷新页面...`,backendRestartFailed:`后端重启失败。`,backendRestartTimeout:`后端重启超时,请手动重启 QuickForge。`,backendRestartUnsupported:`当前启动方式不支持从界面重启,请手动重启 QuickForge。`,serviceMode:`模式`,servicePid:`PID`,serviceStartedAt:`启动时间`,serviceDataDir:`数据目录`,serviceWorkspace:`工作区`,terminalShell:`终端 Shell`,terminalShellDescription:`QuickForge 会自动识别这台电脑上常见的 macOS、Windows 和 Linux Shell。勾选默认项即可;只有缺少时才需要添加自定义命令或路径。QUICKFORGE_TERMINAL_SHELL 仍会优先生效。`,terminalShellAutoDetectedHint:`已识别的条目会自动显示在列表中。`,terminalShellDefault:`默认 Shell`,terminalShellSaved:`终端 Shell 设置已保存,新建终端会话会使用该设置。`,terminalShellProfilesSaved:`终端 Shell 配置已保存。`,terminalShellCommand:`自定义 Shell 命令或路径`,terminalShellCommandPlaceholder:`C:\\Program Files\\Git\\bin\\bash.exe`,terminalShellAdd:`添加`,terminalShellSetDefault:`设为默认`,terminalShellDefaultBadge:`默认`,terminalShellDetected:`已识别`,terminalShellNoDetected:`未识别到可用 Shell,请在下方添加自定义 Shell 命令或路径。`,terminalShellProfileRequired:`保存前请输入 Shell 命令或可执行文件路径。`,terminalShellDeleteConfirm:`确定删除终端 Shell 配置“{name}”吗?`,channels:`渠道`,channelsDescription:`管理把外部应用接入 QuickForge Agent 的本地通信渠道。`,channelsSecurityWarning:`渠道操作会在本机启动本地进程。出于安全考虑,仅允许从本机访问。`,channelsEmpty:`暂无可用渠道。`,start:`启动`,stop:`停止`,restart:`重启`,channelProvider:`提供方`,channelCommand:`命令`,channelPid:`PID`,channelStartedAt:`启动时间`,channelWorkspace:`启动工作区`,channelWorkspaceDescription:`微信 ACP 会话会在所选工作区启动。使用默认工作区时,对应非项目的全局对话。`,channelDefaultWorkspace:`默认工作区`,channelCurrentWorkspace:`当前工作区`,channelNoWorkspaces:`当前没有可用工作区。请先配置默认工作区再启动此渠道。`,channelRequirements:`要求`,channelRecentLogs:`最近日志`,channelNoLogs:`暂无日志。`,channelQrTitle:`使用微信扫码`,channelQrDescription:`请用微信扫描下方二维码。如果终端二维码不易扫描,也可以打开登录链接。`,channelQrLink:`登录链接`,channelStatusStopped:`已停止`,channelStatusStarting:`启动中`,channelStatusWaitingScan:`等待扫码`,channelStatusRunning:`运行中`,channelStatusStopping:`停止中`,channelStatusError:`出错`,channelRestartConfirm:`确定重启渠道“{name}”吗?`,channelLogoutConfirm:`确定退出渠道“{name}”的登录吗?再次使用前需要重新扫码。`,channelReloginConfirm:`确定重新登录渠道“{name}”吗?当前进程会停止,并生成新的二维码。`,terminalNew:`新建终端`,terminalNewWith:`新建终端使用`,terminalNewWithProfile:`新建终端:{name}`,terminalSelectShell:`选择 Shell 新建终端`,terminalCollapse:`收起终端`,terminalFullscreen:`全屏终端`,terminalExitFullscreen:`退出全屏`,terminalStarting:`正在启动终端...`,terminalUnavailable:`终端不可用`,terminalNoSessions:`没有终端会话`,terminalCreateFailed:`创建终端失败`,terminalCloseFailed:`关闭终端失败`,terminalConnectionFailed:`连接终端失败。`,terminalConnectionClosedUnexpectedly:`终端连接异常断开。`,terminalCloseSession:`关闭 {name}`,workspaceNoFilesToDisplay:`没有可显示的文件。`,workspaceNoWorkingTreeChanges:`工作区没有变更。`,noProjectSelected:`未选择项目`,workspacePanel:`工作空间`,workspaceExpandRightPanel:`展开右侧边栏`,workspaceCollapseRightPanel:`关闭右侧边栏`,workspaceOverview:`概览`,workspaceFiles:`工作空间文件`,workspaceBrowser:`浏览器`,workspaceChanges:`变更`,workspaceCurrentArtifacts:`审查`,workspaceNoArtifacts:`当前 Session 尚未检测到 AI 产生的文件。`,workspacePresentedArtifact:`展示产物`,workspaceInferredArtifact:`推断产物`,workspaceCommands:`命令`,workspaceCommandOutput:`输出`,workspaceCurrentBranch:`当前分支`,workspaceChangeCount:`项变更`,workspaceNotGitRepository:`此项目不是 Git 仓库。`,workspaceSelectProject:`请选择一个项目来查看工作空间。`,workspaceLoading:`正在加载工作空间...`,workspaceLoadFailed:`加载工作空间失败。`,workspaceFilterFiles:`按名称或路径筛选文件`,workspaceOpenFileFailed:`打开文件失败。`,workspaceOpenDiffFailed:`打开 diff 失败。`,workspaceViewDiff:`查看 diff`,refreshWorkspace:`刷新工作空间`,closeWorkspace:`关闭工作空间`,workspaceFullscreen:`全屏工作空间`,workspaceExitFullscreen:`退出全屏`,workspaceStaged:`已暂存`,workspaceUntracked:`未跟踪`,workspaceConflicts:`冲突`,workspaceStagedChanges:`已暂存变更`,workspaceReview:`审查`,workspaceCommitMessage:`提交信息`,workspaceReviewPrompt:`请审查当前工作空间的变更,并生成一份简要的总结、风险评估、验证计划以及建议的提交信息。
|
|
23
|
+
|
|
24
|
+
变更文件:
|
|
25
|
+
{list}`,workspaceCommitMessagePrompt:`请为当前的 Git 变更生成一条简洁的 Conventional Commit 提交信息。包含一行标题,必要时可附带简短的正文。
|
|
26
|
+
|
|
27
|
+
变更文件:
|
|
28
|
+
{list}`,unknown:`未知`,webPreview:`网页预览`,artifactPreview:`产物`,artifactPreviewFiles:`显示产物文件`,artifactPreviewEmpty:`没有可预览的产物文件。`,artifactPreviewLoadFailed:`加载产物预览失败。`,artifactPreviewUnsupported:`此文件类型不能直接渲染。`,artifactPreviewViewSource:`查看源码`,artifactPreviewPin:`固定产物工具`,artifactPreviewUnpin:`取消固定产物工具`,artifacts:`产物`,previewArtifact:`预览产物`,previewUrl:`预览地址`,previewUrlPlaceholder:`输入预览地址`,openPreview:`打开`,refreshPreview:`刷新预览`,openInBrowser:`在浏览器中打开`,invalidPreviewUrl:`请输入有效的 http:// 或 https:// 地址。`,noPreviewUrlTitle:`输入预览地址`,noPreviewUrlDescription:`先在终端中运行项目开发服务器,然后在这里输入本地地址。Vite、Next、Astro 等工具通常会通过 HMR 实时更新。`,workspaceStatusAdded:`新增`,workspaceStatusDeleted:`删除`,workspaceStatusRenamed:`重命名`,workspaceStatusUntracked:`未跟踪`,workspaceStatusConflict:`冲突`,workspaceStatusModified:`修改`,copyPath:`复制路径`,copyContent:`复制内容`,copyDiffContent:`复制差异内容`,askAiAboutThis:`就此询问 AI`,readerFileMarkdownPrompt:"请阅读当前工作空间中的 Markdown 文档 `{path}`。总结其用途、关键章节、重要说明、过时或有风险的部分,并给出简洁的改进建议。",readerFilePrompt:"请检查当前工作空间中的 `{path}`,说明它的作用、重要的实现细节,以及任何风险或改进机会。",readerDiffPrompt:"请审查 `{path}` 的工作区变更。总结改了什么,指出可能的 bug 或回归,并给出有针对性的验证步骤。",openingReader:`打开中...`,markdownPreview:`预览`,markdownSource:`源码`,lanAccess:`局域网访问`,lanAccessDescription:`允许同一局域网内可信设备在输入密码后访问完整 QuickForge。`,lanAccessRiskWarning:`高风险:通过密码的局域网设备可以访问你的对话、项目和可用工具。请只在可信网络中开启。`,lanAccessStatus:`局域网访问状态`,lanAccessEnabled:`完整局域网访问`,lanAccessPassword:`访问密码`,lanAccessActiveDevices:`已解锁设备`,lanAccessUrls:`局域网地址`,lanAccessAllowFull:`允许局域网设备访问完整 QuickForge`,lanAccessPasswordPlaceholder:`至少 8 个字符`,lanAccessPasswordPlaceholderConfigured:`留空则保留当前密码`,lanAccessSessionTtl:`登录有效期`,lanAccessRevokeAll:`踢掉所有局域网设备`,lanAccessRevokeAllConfirm:`确定要让所有已解锁的局域网设备退出登录吗?`,lanAccessEnableConfirm:`确定开启完整局域网访问吗?请仅在可信网络中继续。`,lanAccessPasswordRequired:`开启局域网访问前请先设置访问密码。`,lanAccessPasswordTooShort:`访问密码至少需要 8 个字符。`,lanAccessSaved:`局域网访问设置已保存。`,lanAccessRevoked:`所有局域网设备已退出登录。`,enabled:`已开启`,disabled:`已关闭`,configured:`已设置`,notConfigured:`未设置`,generatePassword:`生成密码`,hour:`小时`,hours:`小时`,days:`天`,toolApprovalWaiting:`等待审批:{toolName}`,autoCompactApprovalWaiting:`上下文已达到 {percent}%(阈值 {threshold}%),是否现在压缩?`,autoCompactApprovalPreview:`QuickForge 会总结较早历史,并使用摘要加最近 {keepRecentTurns} 个用户回合继续任务。完整聊天历史仍会保留在界面中。`,autoCompactFailed:`自动上下文压缩失败,将继续使用当前历史。`,contextCompactedTimelineLabel:`较早上下文已整理为摘要供模型使用`,contextCompactedLabel:`已压缩上下文`,contextCompactedTooltip:`此对话的模型请求正在使用摘要上下文,完整聊天历史仍会保留在界面中。`,contextCompactedViewSummary:`查看摘要`,contextCompactedHideSummary:`收起摘要`,contextCompactedSummaryTitle:`模型正在使用的压缩摘要`,contextCompactedCopySummary:`复制摘要`,toolApprovalAccept:`✓ 允许`,toolApprovalReject:`✗ 拒绝`,toolApprovalTimeout:`超时时间`,toolApprovalTruncated:`...(内容已截断)`,processed:`已处理`,processing:`处理中`,processFailed:`处理出错`,processAborted:`已中止`,expandProcess:`展开处理详情`,collapseProcess:`收起处理详情`,relativeMinuteShort:`{count}分`,relativeHourShort:`{count}小时`,relativeDayShort:`{count}天`,relativeWeekShort:`{count}周`,relativeYearShort:`{count}年`}},ze={...Oe.en,"Configure API keys for LLM providers. Keys are stored locally in your browser.":`Configure API keys for LLM providers. Keys are stored by the local QuickForge service on this machine.`,"Settings are stored locally in your browser":`Settings are stored by the local QuickForge service on this machine`,"Storage Permission Required":`Local Service Required`,"This app needs persistent storage to save your conversations":`This app needs the local QuickForge service to save your conversations`,"Without persistent storage, your browser may delete saved conversations when it needs disk space. Granting this permission ensures your chat history is preserved.":`QuickForge saves data to local files through the local service on this machine so your chat history is preserved.`,"Your conversations will be saved locally in your browser":`Your conversations will be saved to local files by the local QuickForge service`,"Cloud LLM providers with predefined models. API keys are stored locally in your browser.":`Cloud LLM providers with predefined models. API keys are stored by the local QuickForge service on this machine.`},Be={...Oe.en,Free:`免费`,"Input Required":`需要输入`,Cancel:`取消`,Confirm:`确认`,"Select Model":`选择模型`,"Search models...":`搜索模型...`,Format:`格式`,Thinking:`思考`,Vision:`视觉`,You:`你`,Assistant:`助手`,"Thinking...":`正在思考...`,"Type your message...":`输入你的消息...`,"API Keys Configuration":`API Key 配置`,"Configure API keys for LLM providers. Keys are stored locally in your browser.":`配置 LLM 提供商的 API Key。密钥会由本机 QuickForge 本地服务保存。`,Configured:`已配置`,"Not configured":`未配置`,"✓ Valid":`✓ 有效`,"✗ Invalid":`✗ 无效`,"Testing...":`测试中...`,Update:`更新`,Test:`测试`,Remove:`移除`,Save:`保存`,"Update API key":`更新 API Key`,"Enter API key":`输入 API Key`,"Type a message...":`输入消息...`,"Failed to fetch file":`获取文件失败`,"Invalid source type":`无效的来源类型`,PDF:`PDF`,Document:`文档`,Presentation:`演示文稿`,Spreadsheet:`电子表格`,Text:`文本`,"Error loading file":`加载文件出错`,"No text content available":`没有可用的文本内容`,"Failed to load PDF":`加载 PDF 失败`,"Failed to load document":`加载文档失败`,"Failed to load spreadsheet":`加载电子表格失败`,"Error loading PDF":`加载 PDF 出错`,"Error loading document":`加载文档出错`,"Error loading spreadsheet":`加载电子表格出错`,"Preview not available for this file type.":`此文件类型不支持预览。`,"Click the download button above to view it on your computer.":`点击上方下载按钮在电脑上查看。`,"No content available":`没有可用内容`,"Failed to display text content":`显示文本内容失败`,"API keys are required to use AI models. Get your keys from the provider's website.":`使用 AI 模型需要 API Key。请从提供商网站获取。`,console:`控制台`,"Copy output":`复制输出`,"Copied!":`已复制!`,"Error:":`错误:`,"Request aborted":`请求已中止`,Call:`调用`,Result:`结果`,"(no result)":`(无结果)`,"Waiting for tool result…":`等待工具结果…`,"Call was aborted; no result.":`调用已中止,没有结果。`,"No session available":`没有可用会话`,"No session set":`未设置会话`,"Preparing tool parameters...":`正在准备工具参数...`,"(no output)":`(无输出)`,Input:`输入`,Output:`输出`,"Writing expression...":`正在写入表达式...`,"Waiting for expression...":`等待表达式...`,Calculating:`计算中`,"Getting current time in":`正在获取当前时间:`,"Getting current date and time":`正在获取当前日期和时间`,"Waiting for command...":`等待命令...`,"Writing command...":`正在写入命令...`,"Running command...":`正在运行命令...`,"Command failed:":`命令失败:`,"Enter Auth Token":`输入认证令牌`,"Please enter your auth token.":`请输入你的认证令牌。`,"Execution aborted":`执行已中止`,"Code parameter is required":`需要代码参数`,"Unknown error":`未知错误`,"Code executed successfully (no output)":`代码执行成功(无输出)`,"Execution failed":`执行失败`,"JavaScript REPL":`JavaScript REPL`,"JavaScript code to execute":`要执行的 JavaScript 代码`,"Writing JavaScript code...":`正在写入 JavaScript 代码...`,"Executing JavaScript":`正在执行 JavaScript`,"Preparing JavaScript...":`正在准备 JavaScript...`,"Preparing command...":`正在准备命令...`,"Preparing calculation...":`正在准备计算...`,"Preparing tool...":`正在准备工具...`,"Getting time...":`正在获取时间...`,"Processing artifact...":`正在处理产物...`,"Preparing artifact...":`正在准备产物...`,"Processing artifact":`正在处理产物`,"Processed artifact":`已处理产物`,"Creating artifact":`正在创建产物`,"Created artifact":`已创建产物`,"Updating artifact":`正在更新产物`,"Updated artifact":`已更新产物`,"Rewriting artifact":`正在重写产物`,"Rewrote artifact":`已重写产物`,"Getting artifact":`正在获取产物`,"Got artifact":`已获取产物`,"Deleting artifact":`正在删除产物`,"Deleted artifact":`已删除产物`,"Getting logs":`正在获取日志`,"Got logs":`已获取日志`,"An error occurred":`发生错误`,"Copy logs":`复制日志`,"Autoscroll enabled":`已启用自动滚动`,"Autoscroll disabled":`已关闭自动滚动`,Processing:`处理中`,Create:`创建`,Rewrite:`重写`,Get:`获取`,Delete:`删除`,"Get logs":`获取日志`,"Show artifacts":`显示产物`,"Close artifacts":`关闭产物`,Artifacts:`产物`,"Copy HTML":`复制 HTML`,"Download HTML":`下载 HTML`,"Reload HTML":`重新加载 HTML`,"Copy SVG":`复制 SVG`,"Download SVG":`下载 SVG`,"Copy Markdown":`复制 Markdown`,"Download Markdown":`下载 Markdown`,Download:`下载`,"No logs for {filename}":`{filename} 没有日志`,"API Keys Settings":`API Key 设置`,Settings:`设置`,"API Keys":`API Key`,"Settings are stored locally in your browser":`设置会由本机 QuickForge 本地服务保存`,Clear:`清除`,"API Key Required":`需要 API Key`,"Enter your API key for {provider}":`输入 {provider} 的 API Key`,Off:`关闭`,Minimal:`最小`,Low:`低`,Medium:`中`,High:`高`,"Storage Permission Required":`需要本地服务`,"This app needs persistent storage to save your conversations":`此应用需要 QuickForge 本地服务来保存你的对话`,"Why is this needed?":`为什么需要?`,"Without persistent storage, your browser may delete saved conversations when it needs disk space. Granting this permission ensures your chat history is preserved.":`QuickForge 会通过本机本地服务把数据保存到本地文件中,确保聊天历史可持久保留。`,"What this means:":`这意味着:`,"Your conversations will be saved locally in your browser":`你的对话会由本机 QuickForge 本地服务保存到本地文件`,"Data will not be deleted automatically to free up space":`数据不会被自动删除来释放空间`,"You can still manually clear data at any time":`你仍然可以随时手动清除数据`,"No data is sent to external servers":`不会向外部服务器发送数据`,"Continue Anyway":`仍然继续`,"Requesting...":`请求中...`,"Grant Permission":`授予权限`,Sessions:`会话`,"Load a previous conversation":`加载之前的对话`,"No sessions yet":`暂无会话`,"Delete this session?":`删除此会话?`,Today:`今天`,Yesterday:`昨天`,"{days} days ago":`{days} 天前`,messages:`条消息`,tokens:`tokens`,"Drop files here":`将文件拖到这里`,"Providers & Models":`提供商与模型`,"Cloud Providers":`云提供商`,"Cloud LLM providers with predefined models. API keys are stored locally in your browser.":`带有预定义模型的云 LLM 提供商。API Key 会由本机 QuickForge 本地服务保存。`,"Custom Providers":`自定义提供商`,"User-configured servers with auto-discovered or manually defined models.":`用户配置的服务器,支持自动发现或手动定义模型。`,"Add Provider":`添加提供商`,"No custom providers configured. Click 'Add Provider' to get started.":`尚未配置自定义提供商。点击"添加提供商"开始。`,Models:`模型`,"auto-discovered":`自动发现`,Refresh:`刷新`,Edit:`编辑`,"Are you sure you want to delete this provider?":`确定删除这个提供商吗?`,"Edit Provider":`编辑提供商`,"Provider Name":`提供商名称`,"e.g., My Ollama Server":`例如:我的 Ollama 服务`,"Provider Type":`提供商类型`,"Base URL":`Base URL`,"e.g., http://localhost:11434":`例如:http://localhost:11434`,"API Key (Optional)":`API Key(可选)`,"Leave empty if not required":`不需要可以留空`,"Test Connection":`测试连接`,Discovered:`已发现`,models:`个模型`,and:`以及`,more:`更多`,"For manual provider types, add models after saving the provider.":`手动提供商类型需要保存提供商后再添加模型。`,"Please fill in all required fields":`请填写所有必填项`,"Failed to save provider":`保存提供商失败`,"OpenAI Completions Compatible":`OpenAI Completions 兼容`,"OpenAI Responses Compatible":`OpenAI Responses 兼容`,"Anthropic Messages Compatible":`Anthropic Messages 兼容`,"Checking...":`检查中...`,Disconnected:`未连接`,"*":`*`,Copy:`复制`,"Copy code":`复制代码`,Close:`关闭`,Preview:`预览`,Code:`代码`,"Loading...":`加载中...`,"Select an option":`选择一个选项`,"Mode 1":`模式 1`,"Mode 2":`模式 2`,Required:`必填`,Optional:`可选`},U=Ve();function Ve(){return typeof navigator<`u`&&navigator.language.toLowerCase().startsWith(`zh`)?`zh`:`en`}function He(e){return typeof e==`string`&&Le.includes(e)}function Ue(e){typeof document>`u`||(document.documentElement.lang=e===`zh`?`zh-CN`:`en`,document.documentElement.dir=`ltr`)}function We(e){let t=e===`zh`?Be:ze;for(let e of Object.keys(Oe))Oe[e]=t}function Ge(e){U=e,We(e),Ue(e)}Oe.zh=Be,Ge(U);function Ke(){return U}function W(e,t){let n=Re[Ke()][e]??Re.en[e];if(!t)return n;for(let[e,r]of Object.entries(t))n=n.replaceAll(`{${e}}`,String(r));return n}function qe(){return Ke()===`zh`?`zh-CN`:`en-US`}async function Je(e){let t=await e.settings.get(Ie),n=He(t)?t:Ve();return He(t)||await e.settings.set(Ie,n),Ge(n),n}async function Ye(e,t){return t===Ke()?!1:(await e.settings.set(Ie,t),Ge(t),window.location.reload(),!0)}var Xe=new Set([`off`,`low`,`medium`,`high`,`xhigh`]),Ze=[{value:`off`,label:()=>ye(`Off`)},{value:`low`,label:()=>ye(`Low`)},{value:`medium`,label:()=>ye(`Medium`)},{value:`high`,label:()=>ye(`High`)},{value:`xhigh`,label:()=>Ke()===`zh`?`极高`:`XHigh`}];function Qe(e){return typeof e==`string`&&Xe.has(e)}function $e(e){return Array.from(e.querySelectorAll(`.flex.gap-2.items-center`)).find(e=>e.querySelector(`button[role="combobox"]`)||e.querySelector(`[data-quickforge-thinking-selector]`))}function et(e,t){me(Te({value:Qe(t.thinkingLevel)?t.thinkingLevel:`off`,placeholder:ye(`Off`),options:Ze.map(e=>({value:e.value,label:e.label(),icon:Ce(Se,`sm`)})),onChange:e=>{let n=Qe(e)?e:`off`;t.thinkingLevel=n,t.onThinkingChange?.(n),t.requestUpdate?.()},width:`80px`,size:`sm`,variant:`ghost`,fitContent:!0}),e)}function tt(e){let t=e;Qe(t.thinkingLevel)||(t.thinkingLevel=`off`,t.onThinkingChange?.(`off`));let n=$e(e);if(!n)return;let r=n.querySelector(`[data-quickforge-thinking-selector]`);if(r){et(r,t);return}let i=n.querySelector(`button[role="combobox"]`);if(!i)return;i.style.display=`none`,i.setAttribute(`aria-hidden`,`true`);let a=document.createElement(`span`);a.dataset.quickforgeThinkingSelector=`true`,i.insertAdjacentElement(`afterend`,a),et(a,t)}function nt(e={}){let{hideSelector:t=!1}=e,n=()=>{let e=customElements.get(`message-editor`);if(!e?.prototype.render||e.prototype.render.__quickforgePatched)return;let n=e.prototype.render;e.prototype.render=function(){let e=n.call(this);return queueMicrotask(()=>{if(t){let e=this;e.showThinkingSelector!==!1&&(e.showThinkingSelector=!1,e.requestUpdate?.());return}tt(this)}),e},e.prototype.render.__quickforgePatched=!0};if(customElements.get(`message-editor`)){n();return}customElements.whenDefined(`message-editor`).then(n).catch(()=>{})}function rt(e){return new Promise((t,n)=>{let r=document.createElement(`textarea`);r.value=e,r.style.position=`fixed`,r.style.left=`-9999px`,r.style.top=`-9999px`,r.style.opacity=`0`,document.body.append(r),r.select();try{document.execCommand(`copy`)?t():n(Error(`execCommand("copy") returned false`))}catch(e){n(e)}finally{r.remove()}})}function it(){navigator.clipboard||Object.defineProperty(navigator,`clipboard`,{value:{writeText:rt,readText:()=>Promise.reject(Error(`Clipboard read is not available in non-secure contexts`)),read:()=>Promise.reject(Error(`Clipboard read is not available in non-secure contexts`)),write:()=>Promise.reject(Error(`Clipboard write is not available in non-secure contexts`))},configurable:!0,enumerable:!0,writable:!1})}function G(...e){return _e(ge(e))}var K=fe(),at=ve(`inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-input bg-background hover:bg-accent hover:text-accent-foreground`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground`},size:{default:`h-9 px-4 py-2`,sm:`h-8 rounded-md px-3`,icon:`size-9`}},defaultVariants:{variant:`default`,size:`default`}}),q=H.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,K.jsx)(`button`,{className:G(at({variant:t,size:n,className:e})),ref:i,...r}));q.displayName=`Button`;var ot=class extends H.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){V.error(`ErrorBoundary caught an error:`,e,t)}handleRetry=()=>{this.setState({error:null})};handleReload=()=>{window.location.reload()};render(){return this.state.error?this.props.fallback?this.props.fallback:(0,K.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-background p-6 text-foreground`,children:(0,K.jsxs)(`div`,{className:`max-w-md rounded-lg border border-border bg-background p-5 text-center`,children:[(0,K.jsx)(`h1`,{className:`text-base font-medium`,children:W(`errorBoundaryTitle`)}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground break-all`,children:this.state.error.message||W(`errorBoundaryUnexpected`)}),(0,K.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,K.jsx)(q,{variant:`outline`,size:`sm`,onClick:this.handleRetry,children:W(`errorBoundaryTryAgain`)}),(0,K.jsx)(q,{variant:`default`,size:`sm`,onClick:this.handleReload,children:W(`reloadPage`)})]})]})}):this.props.children}};async function st(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`HTTP ${e.status}`);return t}function ct({open:e,initialPath:n,disabled:r,onOpenChange:i,onSelect:a}){let s=(0,H.useRef)(null),[c,l]=(0,H.useState)([]),[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(``),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)([]),[v,y]=(0,H.useState)(!1),[b,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(``),w=async e=>{if(e.trim()){y(!0),C(``);try{let t=await st(await fetch(`/api/filesystem/directories?path=${encodeURIComponent(e.trim())}`));d(t.path),p(t.path),h(t.parent),_(Array.isArray(t.directories)?t.directories:[])}catch(e){C(e instanceof Error?e.message:W(`directoryLoadFailed`))}finally{y(!1)}}};return(0,H.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{y(!0),C(``);try{let e=await st(await fetch(`/api/filesystem/roots`));if(t)return;let r=Array.isArray(e.roots)?e.roots:[];l(r);let i=n||r[0]?.path||``;i&&await w(i)}catch(e){t||C(e instanceof Error?e.message:W(`filesystemRootsFailed`))}finally{t||y(!1)}})(),window.setTimeout(()=>s.current?.focus(),0),()=>{t=!0}},[n,e]),(0,H.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&!b&&i(!1)};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[i,e,b]),e?(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,onClick:e=>{e.target===e.currentTarget&&!b&&i(!1)},children:(0,K.jsxs)(`div`,{className:`flex max-h-[85vh] w-full max-w-2xl flex-col rounded-lg border border-border bg-background shadow-quickforge`,children:[(0,K.jsxs)(`div`,{className:`border-b border-border p-4`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:W(`selectProjectDirectory`)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:W(`selectProjectDirectoryDescription`)})]}),(0,K.jsxs)(`div`,{className:`space-y-4 overflow-y-auto p-4`,children:[c.length>0?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:W(`quickAccess`)}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:c.map(e=>(0,K.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>w(e.path),disabled:v||b,children:e.name},`${e.name}:${e.path}`))})]}):null,(0,K.jsxs)(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),w(f)},children:[(0,K.jsx)(`label`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,htmlFor:`project-path-input`,children:W(`path`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{id:`project-path-input`,ref:s,className:G(`min-w-0 flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground shadow-sm`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`),value:f,onChange:e=>p(e.target.value),placeholder:W(`folderPickerPathPlaceholder`),disabled:v||b}),(0,K.jsx)(q,{type:`submit`,variant:`outline`,disabled:v||b||!f.trim(),children:W(`go`)})]})]}),S?(0,K.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:S}):null,(0,K.jsxs)(`div`,{className:`rounded-md border border-border`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,K.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium`,title:u,children:u||W(`loading`)}),v?(0,K.jsx)(o,{className:`size-4 shrink-0 animate-spin text-muted-foreground`}):null]}),(0,K.jsxs)(`div`,{className:`max-h-80 overflow-y-auto p-1`,children:[m?(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm hover:bg-muted/28 disabled:opacity-50`,onClick:()=>w(m),disabled:v||b,children:[(0,K.jsx)(T,{className:`size-4 text-muted-foreground`}),(0,K.jsx)(`span`,{children:W(`parentDirectory`)})]}):null,!v&&g.length===0?(0,K.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:W(`noFolders`)}):null,g.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm hover:bg-muted/28 disabled:opacity-50`,onClick:()=>w(e.path),disabled:v||b,title:e.path,children:[(0,K.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))]})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-border p-4`,children:[(0,K.jsx)(q,{type:`button`,variant:`outline`,onClick:()=>i(!1),disabled:b,children:W(`cancel`)}),(0,K.jsx)(q,{type:`button`,onClick:async()=>{let e=f.trim()||u;if(!(!e||b||r)){x(!0),C(``);try{await a(e),i(!1)}catch(e){C(e instanceof Error?e.message:W(`failedToSelectProjectDirectory`))}finally{x(!1)}}},disabled:v||b||r||!(f.trim()||u),children:W(b?`selecting`:`selectThisFolder`)})]})]})}):null}var lt=class extends he{static properties={label:{type:String}};_open=!1;_popover=null;_hoverTimer;createRenderRoot(){return this}_clearHoverTimer(){this._hoverTimer&&=(clearTimeout(this._hoverTimer),void 0)}_openPopover(){this._clearHoverTimer(),!this._open&&(this._open=!0,this._renderPopover(),this._updateTriggerAria())}_closePopover(){this._clearHoverTimer(),this._open&&(this._open=!1,this._removePopover(),this._updateTriggerAria())}_togglePopover(){this._clearHoverTimer(),this._open?this._closePopover():this._openPopover()}_updateTriggerAria(){this.querySelector(`.quickforge-info-tip-trigger`)?.setAttribute(`aria-expanded`,this._open?`true`:`false`)}_renderPopover(){if(this._removePopover(),!this.label)return;let e=this.querySelector(`.quickforge-info-tip-trigger`);if(!e)return;let t=document.createElement(`div`);t.className=`quickforge-info-tip-popover`,t.setAttribute(`role`,`tooltip`),t.textContent=this.label,document.body.appendChild(t),this._popover=t,this._positionPopover(e,t)}_positionPopover(e,t){let n=e.getBoundingClientRect(),{width:r,height:i}=t.getBoundingClientRect(),a=n.left;a+r>window.innerWidth-8&&(a=window.innerWidth-r-8),a<8&&(a=8);let o=n.bottom+6;if(o+i>window.innerHeight-8){let e=n.top-6-i;o=e>8?e:n.bottom+6}t.style.top=`${Math.round(o)}px`,t.style.left=`${Math.round(a)}px`}_removePopover(){this._popover&&=(this._popover.remove(),null)}_handleEnter=()=>{this._clearHoverTimer(),this._hoverTimer=setTimeout(()=>this._openPopover(),150)};_handleLeave=()=>{this._clearHoverTimer(),this._hoverTimer=setTimeout(()=>this._closePopover(),120)};_handleFocus=()=>{this._clearHoverTimer(),this._openPopover()};_handleOutsidePointerDown=e=>{if(!this._open)return;let t=e.target;t&&(this.contains(t)||this._popover?.contains(t))||this._closePopover()};_handleKeyDown=e=>{!this._open||e.key!==`Escape`||(e.preventDefault(),e.stopPropagation(),this._closePopover())};_handleScrollOrResize=()=>{if(!this._open)return;let e=this.querySelector(`.quickforge-info-tip-trigger`);e&&this._popover&&this._positionPopover(e,this._popover)};connectedCallback(){super.connectedCallback(),document.addEventListener(`pointerdown`,this._handleOutsidePointerDown,!0),document.addEventListener(`keydown`,this._handleKeyDown,!0),window.addEventListener(`scroll`,this._handleScrollOrResize,!0),window.addEventListener(`resize`,this._handleScrollOrResize)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`pointerdown`,this._handleOutsidePointerDown,!0),document.removeEventListener(`keydown`,this._handleKeyDown,!0),window.removeEventListener(`scroll`,this._handleScrollOrResize,!0),window.removeEventListener(`resize`,this._handleScrollOrResize),this._clearHoverTimer(),this._removePopover()}render(){return z`
|
|
29
|
+
<span class="quickforge-info-tip">
|
|
30
|
+
<button
|
|
31
|
+
type="button"
|
|
32
|
+
class="quickforge-info-tip-trigger"
|
|
33
|
+
aria-label=${W(`help`)}
|
|
34
|
+
aria-expanded="false"
|
|
35
|
+
@mouseenter=${this._handleEnter}
|
|
36
|
+
@mouseleave=${this._handleLeave}
|
|
37
|
+
@focus=${this._handleFocus}
|
|
38
|
+
@blur=${this._handleLeave}
|
|
39
|
+
@click=${this._togglePopover}
|
|
40
|
+
>
|
|
41
|
+
<svg
|
|
42
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
43
|
+
width="14"
|
|
44
|
+
height="14"
|
|
45
|
+
viewBox="0 0 24 24"
|
|
46
|
+
fill="none"
|
|
47
|
+
stroke="currentColor"
|
|
48
|
+
stroke-width="2"
|
|
49
|
+
stroke-linecap="round"
|
|
50
|
+
stroke-linejoin="round"
|
|
51
|
+
aria-hidden="true"
|
|
52
|
+
>
|
|
53
|
+
<circle cx="12" cy="12" r="10" />
|
|
54
|
+
<path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" />
|
|
55
|
+
<path d="M12 17h.01" />
|
|
56
|
+
</svg>
|
|
57
|
+
</button>
|
|
58
|
+
</span>
|
|
59
|
+
`}},ut=`quickforge-info-tip`;customElements.get(ut)||customElements.define(ut,lt);function dt({label:e}){return(0,H.createElement)(`quickforge-info-tip`,{label:e})}async function ft(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`HTTP ${e.status}`);return t}function pt({open:e,scope:t,project:n,onOpenChange:r,onSaved:i}){let[a,s]=(0,H.useState)([]),[c,l]=(0,H.useState)(()=>new Set),[u,d]=(0,H.useState)(``),[f,m]=(0,H.useState)([]),[h,g]=(0,H.useState)(!1),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(``),x=t===`project`,[S,C]=(0,H.useState)(null),[w,D]=(0,H.useState)(null),[ee,te]=(0,H.useState)(!1),[O,k]=(0,H.useState)(``),A=(0,H.useCallback)(()=>{C(null),D(null),k(``)},[]),j=(0,H.useCallback)(()=>{A(),r(!1)},[r,A]);(0,H.useEffect)(()=>{if(!e||x&&!n)return;let t=!1;return(async()=>{g(!0),b(``);try{let e=x?`/api/skills?projectId=${encodeURIComponent(n.id)}`:`/api/skills?scope=global`,r=await ft(await fetch(e));if(t)return;s(Array.isArray(r.skills)?r.skills:[]),l(new Set(Array.isArray(r.selectedSkills)?r.selectedSkills:[])),m(Array.isArray(r.searchPaths)?r.searchPaths:[])}catch(e){t||b(e instanceof Error?e.message:W(`failedToLoadSkills`))}finally{t||g(!1)}})(),()=>{t=!0}},[e,n,x]),(0,H.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(S?A():_||j())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[j,e,_,S,A]);let M=(0,H.useMemo)(()=>{let e=u.trim().toLowerCase();return e?a.filter(t=>[t.name,t.displayName,t.description,t.source,t.compatibility,t.allowedTools,...t.tags??[],...t.triggers??[]].filter(Boolean).join(` `).toLowerCase().includes(e)):a},[u,a]),ne=async e=>{C(e),D(null),k(``),te(!0);try{let t=new URLSearchParams({name:e});x&&n?(t.set(`scope`,`project`),t.set(`projectId`,n.id)):t.set(`scope`,`global`),D(await ft(await fetch(`/api/skills/content?${t}`)))}catch(e){k(e instanceof Error?e.message:W(`failedToReadSkill`))}finally{te(!1)}},N=()=>{A()};if(!e||x&&!n)return null;let P=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},re=async()=>{if(!_){v(!0),b(``);try{let e=await ft(await fetch(x?`/api/skills/project`:`/api/skills/global`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(x?{projectId:n.id,selectedSkills:[...c]}:{selectedSkills:[...c]})}));i({scope:t,project:x?e.projects?.find(e=>e.id===n.id)??{...n,skills:e.selectedSkills}:void 0,projects:e.projects,selectedSkills:e.selectedSkills}),j()}catch(e){b(e instanceof Error?e.message:W(`failedToSaveSkills`))}finally{v(!1)}}},F=W(x?`projectSkills`:`globalSkills`),I=x?W(`projectSkillsDescription`,{project:n.name}):W(`globalSkillsDescription`),ie=!!S;return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,onClick:e=>{e.target===e.currentTarget&&!_&&j()},children:(0,K.jsxs)(`div`,{className:`flex max-h-[85vh] w-full max-w-2xl flex-col rounded-lg border border-border bg-background shadow-quickforge`,children:[(0,K.jsx)(`div`,{className:`border-b border-border p-4`,children:ie?(0,K.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors`,onClick:N,children:[(0,K.jsx)(T,{className:`size-4`}),W(`backToSkillList`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`h2`,{className:`inline-flex items-center gap-1.5 text-base font-semibold text-foreground`,children:[F,(0,K.jsx)(dt,{label:I})]}),f.length?(0,K.jsxs)(`p`,{className:`mt-2 break-all text-xs text-muted-foreground/65`,children:[W(`skillSearchPaths`),`: `,f.join(` · `)]}):null]})}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:ie?ee?(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground`,children:[(0,K.jsx)(o,{className:`size-4 animate-spin`}),W(`loading`)]}):O?(0,K.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:O}):w?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-2 text-sm space-y-1`,children:[(0,K.jsxs)(`div`,{className:`font-medium text-foreground/90`,children:[w.displayName||w.name,w.version?(0,K.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`v`,w.version]}):null]}),w.description?(0,K.jsx)(`div`,{className:`text-muted-foreground/70`,children:w.description}):null,(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-0.5 text-xs text-muted-foreground/60`,children:[w.source?(0,K.jsx)(`span`,{children:w.source}):null,w.compatibility?(0,K.jsxs)(`span`,{children:[`· `,w.compatibility]}):null,w.allowedTools?(0,K.jsxs)(`span`,{children:[`· `,w.allowedTools]}):null,w.license?(0,K.jsxs)(`span`,{children:[`· `,w.license]}):null]}),w.tags?.length?(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:w.tags.map(e=>(0,K.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`,children:e},e))}):null,w.triggers?.length?(0,K.jsxs)(`div`,{className:`text-xs text-muted-foreground/60`,children:[`Triggers: `,w.triggers.join(`, `)]}):null]}),w.instructions?(0,K.jsx)(`pre`,{className:`whitespace-pre-wrap break-words rounded-md border border-border bg-muted/30 px-4 py-3 text-sm leading-6 text-foreground/80 font-mono`,children:w.instructions}):(0,K.jsx)(`div`,{className:`py-4 text-center text-sm text-muted-foreground`,children:W(`noSkillContent`)})]}):null:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-input bg-background px-3 py-2`,children:[(0,K.jsx)(E,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,K.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:W(`searchSkills`),className:`min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground/45`,disabled:h||_})]}),y?(0,K.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:y}):null,(0,K.jsxs)(`div`,{className:`rounded-md border border-border`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:W(`availableSkills`)}),(0,K.jsx)(`span`,{children:W(`selectedSkillsCount`,{count:c.size})})]}),(0,K.jsx)(`div`,{className:`max-h-[46vh] overflow-y-auto p-1`,children:h?(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2 px-3 py-8 text-sm text-muted-foreground`,children:[(0,K.jsx)(o,{className:`size-4 animate-spin`}),W(`loading`)]}):M.length===0?(0,K.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:W(`noMatchingSkills`)}):M.map(e=>{let t=c.has(e.name);return(0,K.jsxs)(`div`,{className:G(`flex w-full items-start gap-3 rounded-md px-3 py-3 text-left text-sm transition-colors hover:bg-muted/28 disabled:opacity-50`,t&&`bg-muted/28`),children:[(0,K.jsx)(`button`,{type:`button`,className:G(`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded border border-input`,t&&`border-primary bg-primary text-primary-foreground`),onClick:()=>P(e.name),disabled:_,"aria-label":t?`Deselect ${e.name}`:`Select ${e.name}`,children:t?(0,K.jsx)(L,{className:`size-3.5`}):null}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 cursor-pointer`,onClick:()=>P(e.name),children:[(0,K.jsx)(`span`,{className:`block truncate font-medium text-foreground/90`,children:e.displayName||e.name}),e.description?(0,K.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-muted-foreground/70`,children:e.description}):null,(0,K.jsxs)(`span`,{className:`mt-1 flex flex-wrap gap-1 text-[11px] text-muted-foreground/60`,children:[e.source?(0,K.jsx)(`span`,{children:e.source}):null,e.compatibility?(0,K.jsxs)(`span`,{children:[`· `,e.compatibility]}):null,e.allowedTools?(0,K.jsxs)(`span`,{children:[`· `,e.allowedTools]}):null]}),e.tags?.length?(0,K.jsx)(`span`,{className:`mt-2 flex flex-wrap gap-1`,children:e.tags.slice(0,5).map(e=>(0,K.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`,children:e},e))}):null]}),(0,K.jsx)(`button`,{type:`button`,className:`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-muted/28 hover:text-foreground`,onClick:()=>void ne(e.name),disabled:_||ee,title:W(`readSkill`),"aria-label":`${W(`readSkill`)}: ${e.displayName||e.name}`,children:(0,K.jsx)(p,{className:`size-4`})})]},e.name)})})]})]})}),ie?null:(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-border p-4`,children:[(0,K.jsx)(q,{type:`button`,variant:`outline`,onClick:j,disabled:_,children:W(`cancel`)}),(0,K.jsx)(q,{type:`button`,onClick:re,disabled:h||_,children:W(_?`saving`:`save`)})]})]})})}var mt=de();function ht({title:e,description:t,actions:n,onCancel:r}){let i=(0,H.useRef)(null),a=(0,H.useRef)(!1),o=(0,H.useCallback)(()=>{a.current||(a.current=!0,r())},[r]),s=(0,H.useCallback)(e=>{a.current||(a.current=!0,e.onClick())},[]);return(0,H.useEffect)(()=>{i.current?.focus();let e=e=>{if(e.key===`Escape`&&o(),e.key===`Enter`){let e;for(let t=n.length-1;t>=0;t--)if(n[t].enter!==!1){e=n[t];break}e&&s(e)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o,s,n]),(0,mt.createPortal)((0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/45 px-4 py-6`,onMouseDown:e=>{e.target===e.currentTarget&&o()},children:(0,K.jsxs)(`div`,{className:G(`w-full max-w-[420px] rounded-2xl border border-border bg-background p-5 shadow-quickforge`),role:`dialog`,"aria-modal":`true`,"aria-labelledby":e?`message-dialog-title`:void 0,"aria-describedby":`message-dialog-description`,onMouseDown:e=>e.stopPropagation(),children:[e?(0,K.jsx)(`h2`,{id:`message-dialog-title`,className:`text-base font-semibold text-foreground/90`,children:e}):null,(0,K.jsx)(`p`,{id:`message-dialog-description`,className:G(`text-sm leading-6 text-muted-foreground/72`,e?`mt-2`:void 0),children:t}),(0,K.jsx)(`div`,{className:`mt-6 flex justify-end gap-2`,children:n.map((e,t)=>(0,K.jsx)(q,{ref:e.autoFocus?i:void 0,variant:e.variant,size:`sm`,onClick:()=>s(e),children:e.label},`${e.label}-${t}`))})]})}),document.body)}function gt(e){return new Promise(t=>{let n=document.createElement(`div`);document.body.appendChild(n);let r=(0,Fe.createRoot)(n);function i(){r.unmount(),setTimeout(()=>n.remove(),0)}function a(e){i(),t(e)}r.render(e(a))})}function J(e){return gt(t=>(0,K.jsx)(ht,{title:e.title,description:e.description,onCancel:()=>t(!1),actions:[{label:e.cancelLabel??`Cancel`,variant:`outline`,onClick:()=>t(!1),autoFocus:e.variant===`destructive`},{label:e.confirmLabel??`Confirm`,variant:e.variant===`destructive`?`destructive`:`default`,autoFocus:e.variant!==`destructive`,enter:e.variant!==`destructive`,onClick:()=>t(!0)}]}))}function Y(e){let t=typeof e==`string`?{description:e}:e;return gt(e=>(0,K.jsx)(ht,{title:t.title,description:t.description,onCancel:()=>e(),actions:[{label:t.confirmLabel??`OK`,autoFocus:!0,onClick:()=>e()}]}))}function _t(e){return e===`connected`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`error`?`bg-destructive/12 text-destructive`:e===`disabled`?`bg-muted text-muted-foreground`:`bg-amber-500/12 text-amber-700 dark:text-amber-300`}var vt=12;function yt({server:e,toggling:t,reconnecting:n,onToggle:r,onEdit:i,onDelete:a,onReconnect:s}){let c=e.tools?.slice(0,vt)??[],l=e.toolCount??e.tools?.length??0,u=Math.max(0,l-c.length),d=e.enabled&&e.status!==`connected`;return(0,K.jsxs)(`div`,{className:`rounded-lg border border-border p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground/90`,children:e.name}),(0,K.jsx)(`span`,{className:G(`rounded-full px-2 py-0.5 text-[11px]`,_t(e.status)),children:e.status||`unknown`}),(0,K.jsx)(`span`,{className:`text-[11px] text-muted-foreground/60`,children:W(`mcpToolsCount`,{count:l})})]}),(0,K.jsx)(`div`,{className:`mt-1 truncate text-xs text-muted-foreground/65`,children:e.transport===`stdio`?`${e.command} ${(e.args||[]).join(` `)}`:e.url}),e.error?(0,K.jsx)(`div`,{className:`mt-1 text-xs text-destructive`,children:e.error}):null]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,disabled:t,className:G(`relative h-6 w-11 rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-60`,e.enabled?`bg-emerald-500`:`bg-muted-foreground/30`),onClick:()=>r(e),title:e.enabled?W(`pauseTask`):W(`enable`),children:(0,K.jsx)(`span`,{className:G(`absolute left-0.5 top-0.5 size-5 rounded-full bg-white shadow transition-transform`,e.enabled?`translate-x-5`:`translate-x-0`)})}),d?(0,K.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-muted-foreground`,onClick:()=>s(e.name),disabled:n,"aria-label":W(`mcpReconnectServer`),title:W(`mcpReconnectServer`),children:n?(0,K.jsx)(o,{className:`size-4 animate-spin`}):(0,K.jsx)(_,{className:`size-4`})}):null,(0,K.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-muted-foreground`,onClick:()=>i(e),"aria-label":W(`editTask`),title:W(`editTask`),children:(0,K.jsx)(m,{className:`size-4`})}),(0,K.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-destructive`,onClick:()=>a(e.name),"aria-label":W(`delete`),title:W(`delete`),children:(0,K.jsx)(v,{className:`size-4`})})]})]}),c.length>0?(0,K.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[c.map(e=>(0,K.jsx)(`span`,{className:`rounded-md bg-muted/28 px-1.5 py-0.5 text-[11px] text-muted-foreground/75`,title:e.quickForgeName,children:e.name},e.quickForgeName)),u>0?(0,K.jsx)(`span`,{className:`rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground/55`,children:W(`mcpMoreTools`,{count:u})}):null]}):null]})}var bt=H.forwardRef(({className:e,type:t,...n},r)=>(0,K.jsx)(`input`,{type:t,className:G(`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:border-primary focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));bt.displayName=`Input`;function xt(){return{name:``,transport:`stdio`,command:``,args:[],url:``,cwd:``,env:{}}}function St(e){return{name:e.name,transport:e.transport,command:e.command,args:e.args||[],url:e.url||``,cwd:e.cwd||``,env:e.env||{}}}function Ct(e){return(e||[]).join(`
|
|
60
|
+
`)}function wt(e){return Object.entries(e||{}).map(([e,t])=>`${e}=${t}`).join(`
|
|
61
|
+
`)}function Tt(e){return e.split(`
|
|
62
|
+
`).map(e=>e.trim()).filter(Boolean)}function Et(e){let t={};for(let n of e.split(`
|
|
63
|
+
`)){let e=n.trim();if(!e)continue;let r=e.indexOf(`=`);if(r<=0)continue;let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();i&&(t[i]=a)}return t}function Dt(e){let t={type:e.transport||`stdio`};e.transport===`stdio`?(t.command=e.command||``,t.args=e.args||[],e.cwd&&(t.cwd=e.cwd),e.env&&Object.keys(e.env).length>0&&(t.env=e.env)):(t.url=e.url||``,e.env&&Object.keys(e.env).length>0&&(t.headers=e.env));let n=e.name||`server`;return JSON.stringify({mcpServers:{[n]:t}},null,2)}function Ot(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function kt(e){let t;try{t=JSON.parse(e)}catch{throw Error(W(`mcpInvalidJson`))}if(!Ot(t))throw Error(W(`mcpInvalidConfigJson`));let n=``,r=null;if(Ot(t.mcpServers)){let e=Object.entries(t.mcpServers);if(e.length===0)throw Error(W(`mcpEmptyConfigJson`));let[i,a]=e[0];n=i,Ot(a)&&(r=a)}else r=t;if(!r)throw Error(W(`mcpInvalidConfigJson`));let i=String(r.transport||r.type||`stdio`);if(![`stdio`,`http`,`sse`].includes(i))throw Error(W(`mcpInvalidTransport`,{name:n||`server`}));let a=r.env??r.headers??{};return{name:n,transport:i,command:String(r.command||``),args:Array.isArray(r.args)?r.args:[],url:String(r.url||``),cwd:String(r.cwd||``),env:Ot(a)?a:{}}}var At=`mb-1 block text-xs text-muted-foreground/72`,jt=`min-h-20 w-full resize-y rounded-md border border-input bg-background px-2 py-1.5 font-mono text-xs text-foreground outline-none focus:border-ring`,Mt=`flex h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm outline-none focus:border-ring`;function Nt({value:e,onChange:t,isEdit:n,disabled:r}){let i=e.transport===`stdio`,a=n=>t({...e,...n});return(0,K.jsxs)(`div`,{className:`space-y-3 p-3`,children:[(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground/60`,children:W(n?`mcpEditServer`:`mcpAddServer`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:At,htmlFor:`mcp-server-name`,children:W(`mcpServerName`)}),(0,K.jsx)(bt,{id:`mcp-server-name`,value:e.name,onChange:e=>a({name:e.target.value}),placeholder:W(`mcpNamePlaceholder`),disabled:n||r})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:At,htmlFor:`mcp-server-transport`,children:W(`mcpTransport`)}),(0,K.jsxs)(`select`,{id:`mcp-server-transport`,className:Mt,value:e.transport,onChange:e=>a({transport:e.target.value}),disabled:r,children:[(0,K.jsx)(`option`,{value:`stdio`,children:`stdio`}),(0,K.jsx)(`option`,{value:`http`,children:`http`}),(0,K.jsx)(`option`,{value:`sse`,children:`sse`})]})]}),i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:At,htmlFor:`mcp-server-command`,children:W(`mcpCommand`)}),(0,K.jsx)(bt,{id:`mcp-server-command`,value:e.command,onChange:e=>a({command:e.target.value}),placeholder:W(`mcpCommandPlaceholder`),disabled:r})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:At,htmlFor:`mcp-server-args`,children:W(`mcpArgs`)}),(0,K.jsx)(`textarea`,{id:`mcp-server-args`,className:jt,value:Ct(e.args),onChange:e=>a({args:Tt(e.target.value)}),spellCheck:!1,disabled:r})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:At,htmlFor:`mcp-server-cwd`,children:W(`mcpCwd`)}),(0,K.jsx)(bt,{id:`mcp-server-cwd`,value:e.cwd,onChange:e=>a({cwd:e.target.value}),disabled:r})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:At,htmlFor:`mcp-server-env`,children:W(`mcpEnv`)}),(0,K.jsx)(`textarea`,{id:`mcp-server-env`,className:jt,value:wt(e.env),onChange:e=>a({env:Et(e.target.value)}),spellCheck:!1,disabled:r})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:At,htmlFor:`mcp-server-url`,children:W(`mcpUrl`)}),(0,K.jsx)(bt,{id:`mcp-server-url`,value:e.url,onChange:e=>a({url:e.target.value}),placeholder:W(`mcpUrlPlaceholder`),disabled:r})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:At,htmlFor:`mcp-server-headers`,children:W(`mcpHeaders`)}),(0,K.jsx)(`textarea`,{id:`mcp-server-headers`,className:jt,value:wt(e.env),onChange:e=>a({env:Et(e.target.value)}),spellCheck:!1,disabled:r})]})]})]})}function Pt({configText:e,onConfigTextChange:t,onImport:n,onUseExample:r,saving:i}){return(0,K.jsxs)(`div`,{className:`space-y-3 p-3`,children:[(0,K.jsxs)(`div`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-foreground/90`,children:[W(`mcpImportConfig`),(0,K.jsx)(dt,{label:W(`mcpImportConfigDescription`)})]}),(0,K.jsx)(`textarea`,{className:`min-h-96 w-full resize-y rounded-md border border-input bg-background px-2 py-1.5 font-mono text-xs text-foreground outline-none focus:border-ring`,value:e,onChange:e=>t(e.target.value),spellCheck:!1}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,disabled:i,children:W(`mcpUseExample`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(q,{type:`button`,size:`sm`,onClick:()=>n(`merge`),disabled:i||!e.trim(),children:[i?(0,K.jsx)(o,{className:`mr-1.5 size-3.5 animate-spin`}):(0,K.jsx)(y,{className:`mr-1.5 size-3.5`}),W(`mcpImportUpdate`)]}),(0,K.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(`replace`),disabled:i||!e.trim(),children:W(`mcpReplaceAll`)})]})]})]})}var Ft=`{
|
|
64
|
+
"mcpServers": {
|
|
65
|
+
"zai-mcp-server": {
|
|
66
|
+
"type": "stdio",
|
|
67
|
+
"command": "npx",
|
|
68
|
+
"args": [
|
|
69
|
+
"-y",
|
|
70
|
+
"@z_ai/mcp-server"
|
|
71
|
+
],
|
|
72
|
+
"env": {
|
|
73
|
+
"Z_AI_API_KEY": "\${Z_AI_API_KEY}",
|
|
74
|
+
"Z_AI_MODE": "ZHIPU"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}`;async function It(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`HTTP ${e.status}`);return t}function Lt(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function Rt(e){let t;try{t=JSON.parse(e)}catch{throw Error(W(`mcpInvalidJson`))}if(!Lt(t)||!Lt(t.mcpServers))throw Error(W(`mcpInvalidConfigJson`));let n=Object.entries(t.mcpServers);if(n.length===0)throw Error(W(`mcpEmptyConfigJson`));for(let[e,t]of n){if(!/^(?!.*--)[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(e))throw Error(W(`mcpInvalidServerName`,{name:e}));if(!Lt(t))throw Error(W(`mcpInvalidServerConfig`,{name:e}));let n=String(t.transport||t.type||`stdio`);if(![`stdio`,`http`,`sse`].includes(n))throw Error(W(`mcpInvalidTransport`,{name:e}));if(n===`stdio`&&typeof t.command!=`string`)throw Error(W(`mcpMissingCommand`,{name:e}));if(n!==`stdio`&&typeof t.url!=`string`)throw Error(W(`mcpMissingUrl`,{name:e}));if(t.args!==void 0&&!Array.isArray(t.args))throw Error(W(`mcpArgsMustBeArray`,{name:e}));if(t.env!==void 0&&!Lt(t.env))throw Error(W(`mcpEnvMustBeObject`,{name:e}));if(t.headers!==void 0&&!Lt(t.headers))throw Error(W(`mcpHeadersMustBeObject`,{name:e}))}return t}function zt({open:e,onOpenChange:t}){let[n,r]=(0,H.useState)([]),[i,a]=(0,H.useState)(Ft),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(new Set),[h,_]=(0,H.useState)(null),[v,b]=(0,H.useState)(``),[x,S]=(0,H.useState)(!1),[C,w]=(0,H.useState)(null),[T,E]=(0,H.useState)(xt),[D,ee]=(0,H.useState)(`form`),[te,O]=(0,H.useState)(``),[k,j]=(0,H.useState)(``),ne=l||d,N=(0,H.useCallback)(e=>{r(e?.servers??[])},[]),P=(0,H.useCallback)(async()=>{c(!0),b(``);try{N(await It(await fetch(`/api/mcp/servers`)))}catch(e){b(e instanceof Error?e.message:W(`mcpLoadFailed`))}finally{c(!1)}},[N]);if((0,H.useEffect)(()=>{if(!e)return;let t=window.setTimeout(()=>{P()},0);return()=>window.clearTimeout(t)},[e,P]),!e)return null;let re=e=>{e===`json`&&(O(Dt(T)),j(``)),ee(e)},F=()=>{w(null),E(xt()),ee(`form`),S(!0),b(``)},I=e=>{let t=St(e);w(e),E(t),O(Dt(t)),j(``),ee(`form`),S(!0),b(``)},L=()=>{S(!1),w(null),O(``),j(``),b(``)},ae=e=>{E(e)},R=e=>{O(e);try{let t=kt(e);E(e=>({...t,name:t.name||e.name})),j(``)}catch(e){j(e instanceof Error?e.message:W(`mcpInvalidJson`))}},se=async e=>{if(!d&&!(e===`replace`&&!await J({description:W(`mcpReplaceConfirm`),confirmLabel:W(`mcpReplaceAll`),cancelLabel:W(`cancel`)}))){f(!0),b(``);try{let t=Rt(i);N(await It(await fetch(`/api/mcp/config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({mode:e,...t})})))}catch(e){b(e instanceof Error?e.message:W(`mcpSaveFailed`))}finally{f(!1)}}},ce=async()=>{if(!l){if(k&&D===`json`){b(k);return}u(!0),b(``);try{N(await It(await fetch(`/api/mcp/servers`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({server:{...T,enabled:C?.enabled??!0}})}))),L()}catch(e){b(e instanceof Error?e.message:W(`mcpSaveFailed`))}finally{u(!1)}}},le=async e=>{if(await J({description:W(`mcpDeleteConfirm`,{name:e}),confirmLabel:W(`confirmDelete`),cancelLabel:W(`cancel`),variant:`destructive`})){b(``);try{N(await It(await fetch(`/api/mcp/servers/${encodeURIComponent(e)}`,{method:`DELETE`})))}catch(e){b(e instanceof Error?e.message:W(`mcpDeleteFailed`))}}},ue=async e=>{if(!p.has(e.name)){m(t=>new Set(t).add(e.name)),b(``);try{N(await It(await fetch(`/api/mcp/servers/${encodeURIComponent(e.name)}/enabled`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:!e.enabled})})))}catch(e){b(e instanceof Error?e.message:W(`mcpSaveFailed`))}finally{m(t=>{let n=new Set(t);return n.delete(e.name),n})}}},de=async()=>{c(!0),b(``);try{N(await It(await fetch(`/api/mcp/reconnect`,{method:`POST`})))}catch(e){b(e instanceof Error?e.message:W(`mcpReconnectFailed`))}finally{c(!1)}},fe=async e=>{if(!h){_(e),b(``);try{N(await It(await fetch(`/api/mcp/reconnect/${encodeURIComponent(e)}`,{method:`POST`})))}catch(e){b(e instanceof Error?e.message:W(`mcpReconnectFailed`))}finally{_(null)}}},pe=!!C,me=!!T.name.trim()&&!!(T.transport===`stdio`?T.command.trim():T.url.trim());return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`mcp-servers-title`,onClick:e=>{e.target===e.currentTarget&&!ne&&t(!1)},children:(0,K.jsxs)(`div`,{className:`flex max-h-[88vh] w-full max-w-5xl flex-col rounded-lg border border-border bg-background shadow-quickforge`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-border p-4`,children:[(0,K.jsx)(`span`,{className:`mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-full bg-muted/40 text-muted-foreground`,children:(0,K.jsx)(oe,{className:`size-4`})}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(`h2`,{id:`mcp-servers-title`,className:`text-base font-semibold text-foreground`,children:W(`mcpServers`)})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0 rounded-full text-muted-foreground`,onClick:()=>t(!1),disabled:ne,"aria-label":W(`close`),children:(0,K.jsx)(M,{className:`size-4`})})]}),(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[v?(0,K.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:v}):null,(0,K.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1fr_28rem]`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-foreground/90`,children:W(`mcpConfiguredServers`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:F,disabled:x&&!pe,children:[(0,K.jsx)(y,{className:`mr-1.5 size-3.5`}),W(`mcpAddServer`)]}),(0,K.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:de,disabled:s,children:[s?(0,K.jsx)(o,{className:`mr-1.5 size-3.5 animate-spin`}):(0,K.jsx)(ie,{className:`mr-1.5 size-3.5`}),W(`mcpReconnect`)]})]})]}),s&&n.length===0?(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2 rounded-lg border border-border py-8 text-sm text-muted-foreground`,children:[(0,K.jsx)(o,{className:`size-4 animate-spin`}),W(`loading`)]}):n.length===0?(0,K.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/15 p-4 text-sm text-muted-foreground/72`,children:W(`mcpNoServersDescription`)}):n.map(e=>(0,K.jsx)(yt,{server:e,toggling:p.has(e.name),reconnecting:h===e.name,onToggle:e=>{ue(e)},onEdit:I,onDelete:e=>{le(e)},onReconnect:e=>{fe(e)}},e.name))]}),(0,K.jsx)(`div`,{className:`flex min-h-0 flex-col rounded-lg border border-border`,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex border-b border-border`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>re(`form`),className:G(`flex flex-1 items-center justify-center gap-1.5 px-3 py-2.5 text-xs font-medium transition-colors`,D===`form`?`border-b-2 border-primary text-foreground/90 -mb-px`:`text-muted-foreground/60 hover:text-foreground/85`),children:[(0,K.jsx)(A,{className:`size-3.5`}),W(`mcpTabServer`)]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>re(`json`),className:G(`flex flex-1 items-center justify-center gap-1.5 px-3 py-2.5 text-xs font-medium transition-colors`,D===`json`?`border-b-2 border-primary text-foreground/90 -mb-px`:`text-muted-foreground/60 hover:text-foreground/85`),children:[(0,K.jsx)(g,{className:`size-3.5`}),W(`mcpTabJson`)]})]}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:D===`form`?(0,K.jsx)(Nt,{value:T,onChange:ae,isEdit:pe,disabled:l}):(0,K.jsxs)(`div`,{className:`space-y-2 p-3`,children:[(0,K.jsx)(`textarea`,{className:`min-h-96 w-full resize-y rounded-md border border-input bg-background px-2 py-1.5 font-mono text-xs text-foreground outline-none focus:border-ring`,value:te,onChange:e=>R(e.target.value),spellCheck:!1}),k?(0,K.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:k}):null,(0,K.jsxs)(`div`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-foreground/90`,children:[W(`mcpTabJson`),(0,K.jsx)(dt,{label:W(`mcpImportConfigDescription`)})]})]})}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-border p-3`,children:[(0,K.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:L,disabled:l,children:W(`cancel`)}),(0,K.jsxs)(q,{type:`button`,size:`sm`,onClick:()=>{ce()},disabled:l||!me,children:[l?(0,K.jsx)(o,{className:`mr-1.5 size-3.5 animate-spin`}):null,W(`save`)]})]})]}):(0,K.jsx)(Pt,{configText:i,onConfigTextChange:a,onImport:e=>{se(e)},onUseExample:()=>{a(Ft),b(``)},saving:d})})]})]})]})})}var Bt=new Set;function Vt(e){return typeof e[Symbol.iterator]==`function`}var Ht=class{baseUrl;blockedStores;storeOverrides;fakeProviderKeys;constructor(e=``,t=Bt){this.baseUrl=e,Vt(t)?(this.blockedStores=new Set(t),this.storeOverrides={},this.fakeProviderKeys=new Set):(this.blockedStores=new Set(t.blockedStores??Bt),this.storeOverrides=t.storeOverrides??{},this.fakeProviderKeys=new Set(t.fakeProviderKeys??[]))}assertStoreAccess(e){if(this.blockedStores.has(e))throw Error(`This storage area is not available in the current page.`)}static async isAvailable(e=``){let t=new AbortController,n=window.setTimeout(()=>t.abort(),1e3);try{let n=await fetch(`${e}/api/health`,{method:`GET`,cache:`no-store`,signal:t.signal});return n.ok?(await n.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(n)}}path(...e){return`${this.baseUrl}/api/storage/${e.map(e=>encodeURIComponent(e)).join(`/`)}`}async request(e,t){let n=await fetch(e,{...t,cache:`no-store`,headers:{...t?.body?{"content-type":`application/json`}:void 0,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Local storage request failed: ${n.status}`);return r}async get(e,t){if(e===`provider-keys`&&this.fakeProviderKeys.has(t))return`shared-server-managed-key`;let n=this.storeOverrides[e];return n?.get?n.get(t):(this.assertStoreAccess(e),(await this.request(this.path(e,`key`,t))).value??null)}async set(e,t,n){this.assertStoreAccess(e),await this.request(this.path(e,`key`,t),{method:`PUT`,body:JSON.stringify({value:n})})}async delete(e,t){this.assertStoreAccess(e),await this.request(this.path(e,`key`,t),{method:`DELETE`})}async keys(e,t){if(e===`provider-keys`&&this.fakeProviderKeys.size>0)return[...this.fakeProviderKeys];let n=this.storeOverrides[e];if(n?.keys)return n.keys(t);this.assertStoreAccess(e);let r=t?`?prefix=${encodeURIComponent(t)}`:``;return(await this.request(`${this.path(e,`keys`)}${r}`)).keys}async getAllFromIndex(e,t,n=`asc`){return this.assertStoreAccess(e),(await this.request(`${this.path(e,`index`,t)}?direction=${encodeURIComponent(n)}`)).values}async fetchPaginatedFromIndex(e,t,n){this.assertStoreAccess(e);let r=new URLSearchParams;return r.set(`direction`,n.direction||`desc`),r.set(`limit`,String(n.limit)),r.set(`offset`,String(n.offset)),n.scope&&r.set(`scope`,n.scope),n.projectId&&r.set(`projectId`,n.projectId),n.archived&&r.set(`archived`,n.archived),this.request(`${this.path(e,`index`,t)}?${r.toString()}`)}async clear(e){this.assertStoreAccess(e),await this.request(this.path(e),{method:`DELETE`})}async has(e,t){if(e===`provider-keys`&&this.fakeProviderKeys.has(t))return!0;let n=this.storeOverrides[e];return n?.has?n.has(t):(this.assertStoreAccess(e),(await this.request(this.path(e,`has`,t))).exists)}async transaction(e,t,n){for(let t of e)t===`provider-keys`&&this.fakeProviderKeys.size>0||this.storeOverrides[t]||this.assertStoreAccess(t);return n({get:(e,t)=>this.get(e,t),set:(e,t,n)=>this.set(e,t,n),delete:(e,t)=>this.delete(e,t)})}async getQuotaInfo(){return this.request(`${this.baseUrl}/api/storage/quota`)}async requestPersistence(){return!0}};function X(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`));return`${t.slice(0,4).join(``)}-${t.slice(4,6).join(``)}-${t.slice(6,8).join(``)}-${t.slice(8,10).join(``)}-${t.slice(10).join(``)}`}function Ut(e){return e===!0||e===`true`?`full-access`:`default`}function Z(e,t=`default`){return e===`default`||e===`full-access`?e:e===!0||e===`true`?`full-access`:e===!1||e===`false`||t===e?`default`:Z(t,`default`)}function Wt(e){return e===`full-access`}function Gt(e){return e?.scope===`project`?`project`:`global`}function Kt(e){return e===`New chat`?W(`newChat`):e}var qt=`active-model`,Jt=`agent-access-mode`,Yt=`agent-access-mode-project:`,Xt=`yolo-mode`,Zt=`yolo-mode-project:`,Qt=`default-options`,$t={id:`default-litellm-anthropic`,name:`LiteLLM Anthropic`,baseUrl:`http://localhost:4000/v1`,apiKey:``,modelId:`anthropic/claude-sonnet-4`,contextWindow:2e5,maxTokens:8192};function en(e,t,n=``){let r=e.toLowerCase(),i=t.toLowerCase(),a=n.toLowerCase();return r.includes(`deepseek-v4`)&&(a.includes(`deepseek`)||i.includes(`api.deepseek.com`)||i.includes(`deepseek.com`))}function tn(){return{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:`deepseek`}}var nn={low:`high`,medium:`high`,high:`high`,xhigh:`max`};function rn(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n.includes(`deepseek`)||r.includes(`api.deepseek.com`)||r.includes(`deepseek.com`)?`deepseek`:r.includes(`openrouter.ai`)?`openrouter`:n===`zai`||r.includes(`bigmodel.cn`)||r.includes(`z.ai`)?`zai`:`openai`}function an(e){let t={...e.compat,...e.reasoning===!0&&e.compat?.supportsReasoningEffort===void 0?{supportsReasoningEffort:!0}:{},thinkingFormat:e.compat?.thinkingFormat??rn(e.provider,e.baseUrl)};return{...e,compat:t}}function on(e){if(e.api!==`openai-completions`)return e;let t=an(e);return en(t.id,t.baseUrl,t.provider)?{...t,reasoning:!0,thinkingLevelMap:{...t.thinkingLevelMap,...nn},compat:{...t.compat,supportsReasoningEffort:!0,...tn()}}:t}function sn(e){let t=e.baseUrl.trim().replace(/\/$/,``),n=e.modelId.trim(),r=e.name.trim(),i=en(n,t,r),a=e.reasoning===!0||i;return on({id:n,name:`${n} (${r})`,api:`openai-completions`,provider:r,baseUrl:t,reasoning:a,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:Number(e.contextWindow)||$t.contextWindow,maxTokens:Number(e.maxTokens)||$t.maxTokens,thinkingLevelMap:i?nn:void 0,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:a,supportsUsageInStreaming:!1,supportsStrictMode:!1,maxTokensField:`max_tokens`,...i?tn():{}}})}function cn(){return{settings:new Ae,providerKeys:new ke,sessions:new Ee,customProviders:new we}}function Q(e,t){e.settings.setBackend(t),e.providerKeys.setBackend(t),e.sessions.setBackend(t),e.customProviders.setBackend(t)}async function ln(e){if(!await Ht.isAvailable())throw Error(`QuickForge local service is unavailable.`);return new Ht(``,e)}async function un(e={}){let t=cn(),n=await ln(e.blockedStores);Q(t,n);let r=new je(t.settings,t.providerKeys,t.sessions,t.customProviders,n);return xe(r),r}async function dn(e,t){await e.settings.set(qt,on(t))}function fn(e){return e?.reasoning?`medium`:`off`}function pn(e){return e===`off`||e===`low`||e===`medium`||e===`high`||e===`xhigh`}async function mn(e,t){await e.settings.set(Qt,{model:t.model?on(t.model):void 0,thinkingLevel:pn(t.thinkingLevel)?t.thinkingLevel:void 0})}async function hn(e){let t=await e.settings.get(Qt);return!t||typeof t!=`object`?{}:{model:t.model?on(t.model):void 0,thinkingLevel:pn(t.thinkingLevel)?t.thinkingLevel:void 0}}async function gn(e){let t=await e.settings.get(qt);return!t||typeof t!=`object`||!t.id||!t.provider||!t.api||!t.baseUrl?null:on(t)}function _n(e,t){return(e??``).trim().replace(/\/$/,``)===(t??``).trim().replace(/\/$/,``)}function vn(e,t){return e.id===t.id&&e.provider===t.provider&&e.api===t.api&&_n(e.baseUrl,t.baseUrl)}function yn(e){let t=e;return!!(t?.id&&t.provider&&t.api&&t.baseUrl)}function bn(e){return e.flatMap(e=>e.models??[]).filter(yn).map(e=>on(e))}async function xn(e){return bn(await e.customProviders.getAll())}async function Sn(e){let t=await xn(e);if(t.length===0)return null;let n=await gn(e);if(n){let e=t.find(e=>vn(e,n));if(e)return e}return t[0]}function Cn(e,t){return e.customProviders.getAll().then(e=>{for(let n of e){let e=(n.models??[]).find(e=>e.id===t.id&&e.api===t.api&&e.provider===t.provider&&_n(e.baseUrl,t.baseUrl));if(e)return e}})}async function wn(e,t){try{let n=await Cn(e,t);if(n)return n.reasoning===!0?on(n):n}catch(e){V.warn(`Failed to resolve configured model:`,e)}return on(t)}async function Tn(e,t,n){let r=Z(t),i=n?`${Yt}${n}`:Jt;await e.settings.set(i,r);let a=n?`${Zt}${n}`:Xt;await e.settings.set(a,Wt(r))}async function En(e,t){if(t){let n=`${Yt}${t}`,r=await e.settings.get(n);if(r!=null)return Z(r);let i=`${Zt}${t}`,a=await e.settings.get(i);if(a!=null)return Z(a)}let n=await e.settings.get(Jt);if(n!=null)return Z(n);let r=await e.settings.get(Xt);return r==null?(await Tn(e,`default`),`default`):Z(r)}async function Dn(e,t,n){let r=t.id||X(),i={id:r,name:t.name.trim(),type:`openai-completions`,baseUrl:n.baseUrl,apiKey:t.apiKey.trim()||void 0,models:[n]};return await e.customProviders.set(i),t.apiKey.trim()&&await e.providerKeys.set(n.provider,t.apiKey.trim()),r}function On({hasProject:e,onConfigureModel:t,onAddProject:n,onCopyExamplePrompt:r,onDismiss:i}){return(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-20 flex items-center justify-center bg-background/35 p-3 backdrop-blur-sm sm:p-6`,children:(0,K.jsx)(`div`,{className:`pointer-events-auto w-full max-w-4xl rounded-2xl border border-border bg-background/95 p-5 shadow-quickforge backdrop-blur-md sm:p-6`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`mt-0.5 flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary`,children:(0,K.jsx)(se,{className:`size-5`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-foreground sm:text-lg`,children:W(`firstUseGuideTitle`)}),(0,K.jsx)(`p`,{className:`mt-1.5 text-sm leading-6 text-muted-foreground`,children:W(`firstUseGuideDescription`)})]}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:`-mr-1 -mt-1 size-7 shrink-0`,onClick:i,"aria-label":W(`firstUseGuideDismiss`),children:(0,K.jsx)(M,{className:`size-4`})})]}),(0,K.jsxs)(`div`,{className:`mt-4 grid gap-3 text-sm text-muted-foreground sm:grid-cols-3`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2.5 rounded-xl border border-border/70 bg-muted/15 p-3`,children:[(0,K.jsx)(C,{className:`mt-0.5 size-4 shrink-0 text-primary`}),(0,K.jsx)(`span`,{children:W(`firstUseGuideStepModel`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2.5 rounded-xl border border-border/70 bg-muted/15 p-3`,children:[(0,K.jsx)(h,{className:`mt-0.5 size-4 shrink-0 text-primary`}),(0,K.jsx)(`span`,{children:W(`firstUseGuideStepProject`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2.5 rounded-xl border border-border/70 bg-muted/15 p-3`,children:[(0,K.jsx)(I,{className:`mt-0.5 size-4 shrink-0 text-primary`}),(0,K.jsx)(`span`,{children:W(`firstUseGuideStepPlan`)})]})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2.5`,children:[(0,K.jsxs)(q,{size:`sm`,onClick:t,children:[(0,K.jsx)(C,{className:`size-4`}),W(`firstUseGuideConfigureModel`)]}),(0,K.jsxs)(q,{size:`sm`,variant:e?`outline`:`default`,onClick:n,children:[(0,K.jsx)(h,{className:`size-4`}),W(`firstUseGuideAddProject`)]}),(0,K.jsxs)(q,{size:`sm`,variant:`outline`,onClick:r,children:[(0,K.jsx)(O,{className:`size-4`}),W(`firstUseGuideCopyPrompt`)]}),(0,K.jsx)(q,{size:`sm`,variant:`ghost`,onClick:i,children:W(`firstUseGuideDismiss`)})]})]})]})})})}function kn({onAddModel:e,onUseExample:t}){return(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-6`,children:(0,K.jsxs)(`div`,{className:`w-full max-w-xl rounded-xl border border-border bg-background p-6 text-center`,children:[(0,K.jsx)(`div`,{className:`mx-auto flex size-12 items-center justify-center rounded-2xl bg-primary/10 text-primary`,children:(0,K.jsx)(se,{className:`size-6`})}),(0,K.jsx)(`h2`,{className:`mt-4 text-lg font-medium text-foreground`,children:W(`modelSetupTitle`)}),(0,K.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:W(`modelSetupDescription`)}),(0,K.jsxs)(`div`,{className:`mt-5 grid gap-3 rounded-xl border border-border bg-muted/20 p-4 text-left text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(b,{className:`mt-0.5 size-4 shrink-0 text-primary`}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:W(`modelSetupSupports`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(N,{className:`mt-0.5 size-4 shrink-0 text-primary`}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:W(`modelSetupLocalStorage`)})]})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex flex-col justify-center gap-3 sm:flex-row`,children:[(0,K.jsxs)(q,{onClick:e,className:`gap-2`,children:[(0,K.jsx)(y,{className:`size-4`}),W(`modelSetupAddModel`)]}),(0,K.jsx)(q,{variant:`outline`,onClick:t,children:W(`modelSetupUseLiteLlmExample`)})]})]})})}function An({projects:e,selectedProject:n,chatScope:r,onSelectProject:i,onClearProject:a,onNewProject:o,className:s}){let c=(0,H.useRef)(null),l=(0,H.useRef)(null),u=(0,H.useRef)(null),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(``),[h,g]=(0,H.useState)(),_=r===`project`?n?.id:void 0,v=(0,H.useMemo)(()=>{let t=p.trim().toLowerCase();return t?e.filter(e=>{let n=e.name.toLowerCase(),r=e.path.toLowerCase();return n.includes(t)||r.includes(t)}):e},[e,p]),y=(0,H.useCallback)(()=>{let e=l.current;if(!e)return;let t=e.getBoundingClientRect(),n=Math.min(350,window.innerWidth-24);g({position:`fixed`,left:Math.min(Math.max(12,t.left),window.innerWidth-n-12),bottom:Math.max(12,window.innerHeight-t.top+10),width:n})},[]);(0,H.useEffect)(()=>{if(!d)return;y();let e=()=>y();return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[d,y]),(0,H.useEffect)(()=>{if(!d)return;let e=e=>{let t=e.target;!c.current?.contains(t)&&!u.current?.contains(t)&&f(!1)},t=e=>{e.key===`Escape`&&f(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[d]);let b=e=>{f(!1),i(e)},x=()=>{f(!1),o()},S={ref:l,role:`button`,tabIndex:0,onClick:(0,H.useCallback)(()=>{f(e=>!e)},[]),onKeyDown:(0,H.useCallback)(e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f(e=>!e))},[]),"aria-haspopup":`menu`,"aria-expanded":d},C=d&&h?(0,K.jsxs)(`div`,{ref:u,className:`quickforge-project-picker-popover`,style:h,role:`menu`,children:[(0,K.jsxs)(`label`,{className:`quickforge-project-picker-search`,children:[(0,K.jsx)(E,{className:`size-4`,"aria-hidden":`true`}),(0,K.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:W(`searchProjects`),autoFocus:!0})]}),(0,K.jsx)(`div`,{className:`quickforge-project-picker-list`,children:v.length>0?v.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`quickforge-project-picker-item`,onClick:()=>b(e),role:`menuitem`,children:[(0,K.jsx)(t,{className:`size-4 quickforge-project-picker-item-leading`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.name}),_===e.id?(0,K.jsx)(L,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},e.id)):(0,K.jsx)(`div`,{className:`quickforge-project-picker-empty`,children:W(`noMatchingProjects`)})}),(0,K.jsx)(`div`,{className:`quickforge-project-picker-separator`}),(0,K.jsxs)(`button`,{type:`button`,className:`quickforge-project-picker-item quickforge-project-picker-item-emphasis`,onClick:x,role:`menuitem`,children:[(0,K.jsx)(t,{className:`size-4 quickforge-project-picker-item-leading`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`truncate`,children:W(`selectProjectDirectory`)})]})]}):null;return(0,K.jsxs)(`div`,{ref:c,className:G(`quickforge-empty-project-picker`,d?`quickforge-empty-project-picker-open`:void 0,s),children:[(0,K.jsx)(`div`,{className:`quickforge-empty-project-trigger`,children:_?(0,K.jsxs)(`span`,{className:`quickforge-empty-project-chip`,...S,children:[(0,K.jsxs)(`span`,{className:`quickforge-empty-project-chip-action`,children:[(0,K.jsx)(t,{className:`size-3.5 quickforge-empty-project-chip-folder`,"aria-hidden":`true`}),(0,K.jsx)(`button`,{type:`button`,className:`quickforge-empty-project-chip-clear`,onClick:e=>{e.stopPropagation(),f(!1),a()},"aria-label":W(`useNoProject`),title:W(`useNoProject`),children:(0,K.jsx)(M,{className:`size-3`,"aria-hidden":`true`})})]}),(0,K.jsx)(`span`,{className:`truncate`,children:n?.name})]}):(0,K.jsxs)(`span`,{className:`quickforge-empty-project-pill`,...S,children:[(0,K.jsx)(t,{className:`size-4`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`truncate`,children:W(`chooseProject`)})]})}),typeof document<`u`?(0,mt.createPortal)(C,document.body):null]})}function jn(){var e=[...arguments];return(0,H.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var Mn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Nn(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Pn(e){return`nodeType`in e}function Fn(e){return e?Nn(e)?e:Pn(e)?e.ownerDocument?.defaultView??window:window:window}function In(e){let{Document:t}=Fn(e);return e instanceof t}function Ln(e){return Nn(e)?!1:e instanceof Fn(e).HTMLElement}function Rn(e){return e instanceof Fn(e).SVGElement}function zn(e){return e?Nn(e)?e.document:Pn(e)?In(e)?e:Ln(e)||Rn(e)?e.ownerDocument:document:document:document}var Bn=Mn?H.useLayoutEffect:H.useEffect;function Vn(e){let t=(0,H.useRef)(e);return Bn(()=>{t.current=e}),(0,H.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function Hn(){let e=(0,H.useRef)(null);return[(0,H.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,H.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function Un(e,t){t===void 0&&(t=[e]);let n=(0,H.useRef)(e);return Bn(()=>{n.current!==e&&(n.current=e)},t),n}function Wn(e,t){let n=(0,H.useRef)();return(0,H.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function Gn(e){let t=Vn(e),n=(0,H.useRef)(null);return[n,(0,H.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function Kn(e){let t=(0,H.useRef)();return(0,H.useEffect)(()=>{t.current=e},[e]),t.current}var qn={};function Jn(e,t){return(0,H.useMemo)(()=>{if(t)return t;let n=qn[e]==null?0:qn[e]+1;return qn[e]=n,e+`-`+n},[e,t])}function Yn(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var Xn=Yn(1),Zn=Yn(-1);function Qn(e){return`clientX`in e&&`clientY`in e}function $n(e){if(!e)return!1;let{KeyboardEvent:t}=Fn(e.target);return t&&e instanceof t}function er(e){if(!e)return!1;let{TouchEvent:t}=Fn(e.target);return t&&e instanceof t}function tr(e){if(er(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Qn(e)?{x:e.clientX,y:e.clientY}:null}var nr=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[nr.Translate.toString(e),nr.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),rr=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function ir(e){return e.matches(rr)?e:e.querySelector(rr)}var ar={display:`none`};function or(e){let{id:t,value:n}=e;return H.createElement(`div`,{id:t,style:ar},n)}function sr(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return H.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function cr(){let[e,t]=(0,H.useState)(``);return{announce:(0,H.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var lr=(0,H.createContext)(null);function ur(e){let t=(0,H.useContext)(lr);(0,H.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function dr(){let[e]=(0,H.useState)(()=>new Set),t=(0,H.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,H.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var fr={draggable:`
|
|
79
|
+
To pick up a draggable item, press the space bar.
|
|
80
|
+
While dragging, use the arrow keys to move the item.
|
|
81
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
82
|
+
`},pr={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function mr(e){let{announcements:t=pr,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=fr}=e,{announce:a,announcement:o}=cr(),s=Jn(`DndLiveRegion`),[c,l]=(0,H.useState)(!1);if((0,H.useEffect)(()=>{l(!0)},[]),ur((0,H.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=H.createElement(H.Fragment,null,H.createElement(or,{id:r,value:i.draggable}),H.createElement(sr,{id:s,announcement:o}));return n?(0,mt.createPortal)(u,n):u}var hr;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(hr||={});function gr(){}function _r(e,t){return(0,H.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function vr(){var e=[...arguments];return(0,H.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var yr=Object.freeze({x:0,y:0});function br(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function xr(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Sr(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Cr(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function wr(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var Tr=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=wr(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=br(wr(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(xr)};function Er(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var Dr=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=Er(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Sr)};function Or(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function kr(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:yr}function Ar(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var jr=Ar(1);function Mr(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Nr(e,t,n){let r=Mr(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var Pr={ignoreTransform:!1};function Fr(e,t){t===void 0&&(t=Pr);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=Fn(e).getComputedStyle(e);t&&(n=Nr(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function Ir(e){return Fr(e,{ignoreTransform:!0})}function Lr(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Rr(e,t){return t===void 0&&(t=Fn(e).getComputedStyle(e)),t.position===`fixed`}function zr(e,t){t===void 0&&(t=Fn(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function Br(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(In(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Ln(i)||Rn(i)||n.includes(i))return n;let a=Fn(e).getComputedStyle(i);return i!==e&&zr(i,a)&&n.push(i),Rr(i,a)?n:r(i.parentNode)}return e?r(e):n}function Vr(e){let[t]=Br(e,1);return t??null}function Hr(e){return!Mn||!e?null:Nn(e)?e:Pn(e)?In(e)||e===zn(e).scrollingElement?window:Ln(e)?e:null:null}function Ur(e){return Nn(e)?e.scrollX:e.scrollLeft}function Wr(e){return Nn(e)?e.scrollY:e.scrollTop}function Gr(e){return{x:Ur(e),y:Wr(e)}}var Kr;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Kr||={});function qr(e){return!Mn||!e?!1:e===document.scrollingElement}function Jr(e){let t={x:0,y:0},n=qr(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var Yr={x:.2,y:.2};function Xr(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Yr);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Jr(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=Kr.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Kr.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Kr.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Kr.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Zr(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function Qr(e){return e.reduce((e,t)=>Xn(e,Gr(t)),yr)}function $r(e){return e.reduce((e,t)=>e+Ur(t),0)}function ei(e){return e.reduce((e,t)=>e+Wr(t),0)}function ti(e,t){if(t===void 0&&(t=Fr),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);Vr(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var ni=[[`x`,[`left`,`right`],$r],[`y`,[`top`,`bottom`],ei]],ri=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=Br(t),r=Qr(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of ni)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},ii=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function ai(e){let{EventTarget:t}=Fn(e);return e instanceof t?e:zn(e)}function oi(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var si;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(si||={});function ci(e){e.preventDefault()}function li(e){e.stopPropagation()}var $;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})($||={});var ui={start:[$.Space,$.Enter],cancel:[$.Esc],end:[$.Space,$.Enter,$.Tab]},di=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case $.Right:return{...n,x:n.x+25};case $.Left:return{...n,x:n.x-25};case $.Down:return{...n,y:n.y+25};case $.Up:return{...n,y:n.y-25}}},fi=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new ii(zn(t)),this.windowListeners=new ii(Fn(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(si.Resize,this.handleCancel),this.windowListeners.add(si.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(si.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&ti(n),t(yr)}handleKeyDown(e){if($n(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=ui,coordinateGetter:a=di,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:yr;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Zn(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=Jr(n),p=Zr(n),m={x:Math.min(i===$.Right?p.right-p.width/2:p.right,Math.max(i===$.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===$.Down?p.bottom-p.height/2:p.bottom,Math.max(i===$.Down?p.top:p.top+p.height/2,u.y))},h=i===$.Right&&!s||i===$.Left&&!c,g=i===$.Down&&!l||i===$.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===$.Right&&e<=d.x||i===$.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===$.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===$.Down&&e<=d.y||i===$.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===$.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Xn(Zn(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};fi.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=ui,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function pi(e){return!!(e&&`distance`in e)}function mi(e){return!!(e&&`delay`in e)}var hi=class{constructor(e,t,n){n===void 0&&(n=ai(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=zn(i),this.documentListeners=new ii(this.document),this.listeners=new ii(n),this.windowListeners=new ii(Fn(i)),this.initialCoordinates=tr(r)??yr,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(si.Resize,this.handleCancel),this.windowListeners.add(si.DragStart,ci),this.windowListeners.add(si.VisibilityChange,this.handleCancel),this.windowListeners.add(si.ContextMenu,ci),this.documentListeners.add(si.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(mi(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(pi(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(si.Click,li,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(si.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=tr(e)??yr,s=Zn(n,o);if(!t&&a){if(pi(a)){if(a.tolerance!=null&&oi(s,a.tolerance))return this.handleCancel();if(oi(s,a.distance))return this.handleStart()}if(mi(a)&&oi(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===$.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},gi={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},_i=class extends hi{constructor(e){let{event:t}=e,n=zn(t.target);super(e,gi,n)}};_i.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var vi={move:{name:`mousemove`},end:{name:`mouseup`}},yi;(function(e){e[e.RightClick=2]=`RightClick`})(yi||={});var bi=class extends hi{constructor(e){super(e,vi,zn(e.event.target))}};bi.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===yi.RightClick?!1:(r?.({event:n}),!0)}}];var xi={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Si=class extends hi{constructor(e){super(e,xi)}static setup(){return window.addEventListener(xi.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(xi.move.name,e)};function e(){}}};Si.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Ci;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Ci||={});var wi;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(wi||={});function Ti(e){let{acceleration:t,activator:n=Ci.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=wi.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=Di({delta:d,disabled:!a}),[m,h]=Hn(),g=(0,H.useRef)({x:0,y:0}),_=(0,H.useRef)({x:0,y:0}),v=(0,H.useMemo)(()=>{switch(n){case Ci.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Ci.DraggableRect:return i}},[n,i,c]),y=(0,H.useRef)(null),b=(0,H.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,H.useMemo)(()=>s===wi.TreeOrder?[...l].reverse():l,[s,l]);(0,H.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=Xr(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var Ei={x:{[Kr.Backward]:!1,[Kr.Forward]:!1},y:{[Kr.Backward]:!1,[Kr.Forward]:!1}};function Di(e){let{delta:t,disabled:n}=e,r=Kn(t);return Wn(e=>{if(n||!r||!e)return Ei;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Kr.Backward]:e.x[Kr.Backward]||i.x===-1,[Kr.Forward]:e.x[Kr.Forward]||i.x===1},y:{[Kr.Backward]:e.y[Kr.Backward]||i.y===-1,[Kr.Forward]:e.y[Kr.Forward]||i.y===1}}},[n,t,r])}function Oi(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Wn(e=>t==null?null:r??e??null,[r,t])}function ki(e,t){return(0,H.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var Ai;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Ai||={});var ji;(function(e){e.Optimized=`optimized`})(ji||={});var Mi=new Map;function Ni(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,H.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,H.useRef)(e),d=g(),f=Un(d),p=(0,H.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,H.useRef)(null),h=Wn(t=>{if(d&&!n)return Mi;if(!t||t===Mi||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new ri(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,H.useEffect)(()=>{u.current=e},[e]),(0,H.useEffect)(()=>{d||p()},[n,d]),(0,H.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,H.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case Ai.Always:return!1;case Ai.BeforeDragging:return n;default:return!n}}}function Pi(e,t){return Wn(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Fi(e,t){return Pi(e,t)}function Ii(e){let{callback:t,disabled:n}=e,r=Vn(t),i=(0,H.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,H.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Li(e){let{callback:t,disabled:n}=e,r=Vn(t),i=(0,H.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,H.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Ri(e){return new ri(Fr(e),e)}function zi(e,t,n){t===void 0&&(t=Ri);let[r,i]=(0,H.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=Ii({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=Li({callback:a});return Bn(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Bi(e){return kr(e,Pi(e))}var Vi=[];function Hi(e){let t=(0,H.useRef)(e),n=Wn(n=>e?n&&n!==Vi&&e&&t.current&&e.parentNode===t.current.parentNode?n:Br(e):Vi,[e]);return(0,H.useEffect)(()=>{t.current=e},[e]),n}function Ui(e){let[t,n]=(0,H.useState)(null),r=(0,H.useRef)(e),i=(0,H.useCallback)(e=>{let t=Hr(e.target);t&&n(e=>e?(e.set(t,Gr(t)),new Map(e)):null)},[]);return(0,H.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Hr(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,Gr(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{Hr(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,H.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Xn(e,t),yr):Qr(e):yr,[e,t])}function Wi(e,t){t===void 0&&(t=[]);let n=(0,H.useRef)(null);return(0,H.useEffect)(()=>{n.current=null},t),(0,H.useEffect)(()=>{let t=e!==yr;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Zn(e,n.current):yr}function Gi(e){(0,H.useEffect)(()=>{if(!Mn)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Ki(e,t){return(0,H.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function qi(e){return(0,H.useMemo)(()=>e?Lr(e):null,[e])}var Ji=[];function Yi(e,t){t===void 0&&(t=Fr);let[n]=e,r=qi(n?Fn(n):null),[i,a]=(0,H.useState)(Ji);function o(){a(()=>e.length?e.map(e=>qr(e)?r:new ri(t(e),e)):Ji)}let s=Li({callback:o});return Bn(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Xi(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Ln(t)?t:e}function Zi(e){let{measure:t}=e,[n,r]=(0,H.useState)(null),i=Li({callback:(0,H.useCallback)(e=>{for(let{target:n}of e)if(Ln(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=Gn((0,H.useCallback)(e=>{let n=Xi(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,H.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Qi=[{sensor:_i,options:{}},{sensor:fi,options:{}}],$i={current:{}},ea={draggable:{measure:Ir},droppable:{measure:Ir,strategy:Ai.WhileDragging,frequency:ji.Optimized},dragOverlay:{measure:Fr}},ta=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},na={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ta,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:gr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ea,measureDroppableContainers:gr,windowRect:null,measuringScheduled:!1},ra={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:gr,draggableNodes:new Map,over:null,measureDroppableContainers:gr},ia=(0,H.createContext)(ra),aa=(0,H.createContext)(na);function oa(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ta}}}function sa(e,t){switch(t.type){case hr.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case hr.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case hr.DragEnd:case hr.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case hr.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new ta(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case hr.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new ta(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case hr.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new ta(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function ca(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,H.useContext)(ia),a=Kn(r),o=Kn(n?.id);return(0,H.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!$n(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=ir(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function la(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function ua(e){return(0,H.useMemo)(()=>({draggable:{...ea.draggable,...e?.draggable},droppable:{...ea.droppable,...e?.droppable},dragOverlay:{...ea.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function da(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,H.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;Bn(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=kr(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=Vr(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var fa=(0,H.createContext)({...yr,scaleX:1,scaleY:1}),pa;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(pa||={});var ma=(0,H.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Qi,collisionDetection:o=Dr,measuring:s,modifiers:c,...l}=e,[u,d]=(0,H.useReducer)(sa,void 0,oa),[f,p]=dr(),[m,h]=(0,H.useState)(pa.Uninitialized),g=m===pa.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,H.useRef)({initial:null,translated:null}),C=(0,H.useMemo)(()=>_==null?null:{id:_,data:x?.data??$i,rect:S},[_,x]),w=(0,H.useRef)(null),[T,E]=(0,H.useState)(null),[D,ee]=(0,H.useState)(null),te=Un(l,Object.values(l)),O=Jn(`DndDescribedBy`,t),k=(0,H.useMemo)(()=>b.getEnabled(),[b]),A=ua(s),{droppableRects:j,measureDroppableContainers:M,measuringScheduled:ne}=Ni(k,{dragging:g,dependencies:[y.x,y.y],config:A.droppable}),N=Oi(v,_),P=(0,H.useMemo)(()=>D?tr(D):null,[D]),re=Oe(),F=Fi(N,A.draggable.measure);da({activeNode:_==null?null:v.get(_),config:re.layoutShiftCompensation,initialRect:F,measure:A.draggable.measure});let I=zi(N,A.draggable.measure,F),ie=zi(N?N.parentElement:null),L=(0,H.useRef)({activatorEvent:null,active:null,activeNode:N,collisionRect:null,collisions:null,droppableRects:j,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ae=b.getNodeFor(L.current.over?.id),R=Zi({measure:A.dragOverlay.measure}),oe=R.nodeRef.current??N,se=g?R.rect??I:null,ce=!!(R.nodeRef.current&&R.rect),le=Bi(ce?null:I),ue=qi(oe?Fn(oe):null),de=Hi(g?ae??N:null),fe=Yi(de),pe=la(c,{transform:{x:y.x-le.x,y:y.y-le.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:I,containerNodeRect:ie,draggingNodeRect:se,over:L.current.over,overlayNodeRect:R.rect,scrollableAncestors:de,scrollableAncestorRects:fe,windowRect:ue}),me=P?Xn(P,y):null,z=Ui(de),he=Wi(z),ge=Wi(z,[I]),_e=Xn(pe,he),ve=se?jr(se,pe):null,ye=C&&ve?o({active:C,collisionRect:ve,droppableRects:j,droppableContainers:k,pointerCoordinates:me}):null,be=Cr(ye,`id`),[B,xe]=(0,H.useState)(null),Se=Or(ce?pe:Xn(pe,ge),B?.rect??null,I),Ce=(0,H.useRef)(null),we=(0,H.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;Ce.current=new n({active:w.current,activeNode:i,event:a,options:r,context:L,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=te.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=te.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=te.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,mt.unstable_batchedUpdates)(()=>{r?.(i),h(pa.Initializing),d({type:hr.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Ce.current),ee(a)})},onMove(e){d({type:hr.DragMove,coordinates:e})},onEnd:o(hr.DragEnd),onCancel:o(hr.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=L.current,o=null;if(t&&i){let{cancelDrop:s}=te.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===hr.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=hr.DragCancel)}w.current=null,(0,mt.unstable_batchedUpdates)(()=>{d({type:e}),h(pa.Uninitialized),xe(null),E(null),ee(null),Ce.current=null;let t=e===hr.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=te.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Te=ki(a,(0,H.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,we(n,t))},[v,we]));Gi(a),Bn(()=>{I&&m===pa.Initializing&&h(pa.Initialized)},[I,m]),(0,H.useEffect)(()=>{let{onDragMove:e}=te.current,{active:t,activatorEvent:n,collisions:r,over:i}=L.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:_e.x,y:_e.y},over:i};(0,mt.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[_e.x,_e.y]),(0,H.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=L.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=te.current,o=r.get(be),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,mt.unstable_batchedUpdates)(()=>{xe(s),a?.(c),f({type:`onDragOver`,event:c})})},[be]),Bn(()=>{L.current={activatorEvent:D,active:C,activeNode:N,collisionRect:ve,collisions:ye,droppableRects:j,draggableNodes:v,draggingNode:oe,draggingNodeRect:se,droppableContainers:b,over:B,scrollableAncestors:de,scrollAdjustedTranslate:_e},S.current={initial:se,translated:ve}},[C,N,ye,ve,v,oe,se,j,b,B,de,_e]),Ti({...re,delta:y,draggingRect:ve,pointerCoordinates:me,scrollableAncestors:de,scrollableAncestorRects:fe});let Ee=(0,H.useMemo)(()=>({active:C,activeNode:N,activeNodeRect:I,activatorEvent:D,collisions:ye,containerNodeRect:ie,dragOverlay:R,draggableNodes:v,droppableContainers:b,droppableRects:j,over:B,measureDroppableContainers:M,scrollableAncestors:de,scrollableAncestorRects:fe,measuringConfiguration:A,measuringScheduled:ne,windowRect:ue}),[C,N,I,D,ye,ie,R,v,b,j,B,M,de,fe,A,ne,ue]),De=(0,H.useMemo)(()=>({activatorEvent:D,activators:Te,active:C,activeNodeRect:I,ariaDescribedById:{draggable:O},dispatch:d,draggableNodes:v,over:B,measureDroppableContainers:M}),[D,Te,C,I,d,O,v,B,M]);return H.createElement(lr.Provider,{value:p},H.createElement(ia.Provider,{value:De},H.createElement(aa.Provider,{value:Ee},H.createElement(fa.Provider,{value:Se},i)),H.createElement(ca,{disabled:n?.restoreFocus===!1})),H.createElement(mr,{...n,hiddenTextDescribedById:O}));function Oe(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),ha=(0,H.createContext)(null),ga=`button`,_a=`Draggable`;function va(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Jn(_a),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,H.useContext)(ia),{role:p=ga,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,H.useContext)(g?fa:ha),[v,y]=Gn(),[b,x]=Gn(),S=Ki(o,t),C=Un(n);return Bn(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,H.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===ga?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function ya(){return(0,H.useContext)(aa)}var ba=`Droppable`,xa={timeout:25};function Sa(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Jn(ba),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,H.useContext)(ia),u=(0,H.useRef)({disabled:n}),d=(0,H.useRef)(!1),f=(0,H.useRef)(null),p=(0,H.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...xa,...i},_=Un(h??r),v=Li({callback:(0,H.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=Gn((0,H.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=Un(t);return(0,H.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,H.useEffect)(()=>(s({type:hr.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:hr.UnregisterDroppable,key:a,id:r})),[r]),(0,H.useEffect)(()=>{n!==u.current.disabled&&(s({type:hr.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function Ca(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function wa(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function Ta(e){return e!==null&&e>=0}function Ea(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Da(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var Oa=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=Ca(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},ka={scaleX:1,scaleY:1},Aa=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...ka}:null}let s=ja(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...ka}:r<t&&r>=a?{x:0,y:o.height+s,...ka}:{x:0,y:0,...ka}};function ja(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var Ma=`Sortable`,Na=H.createContext({activeIndex:-1,containerId:Ma,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Oa,disabled:{draggable:!1,droppable:!1}});function Pa(e){let{children:t,id:n,items:r,strategy:i=Oa,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=ya(),d=Jn(Ma,n),f=s.rect!==null,p=(0,H.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,H.useRef)(p),v=!Ea(p,_.current),y=g!==-1&&h===-1||v,b=Da(a);Bn(()=>{v&&m&&u(p)},[v,p,m,u]),(0,H.useEffect)(()=>{_.current=p},[p]);let x=(0,H.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:wa(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return H.createElement(Na.Provider,{value:x},t)}var Fa=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return Ca(n,r,i).indexOf(t)},Ia=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},La={duration:200,easing:`ease`},Ra=`transform`,za=nr.Transition.toString({property:Ra,duration:0,easing:`linear`}),Ba={roleDescription:`sortable`};function Va(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,H.useState)(null),s=(0,H.useRef)(n);return Bn(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=Fr(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,H.useEffect)(()=>{a&&o(null)},[a]),a}function Ha(e){let{animateLayoutChanges:t=Ia,attributes:n,disabled:r,data:i,getNewIndex:a=Fa,id:o,strategy:s,resizeObserverConfig:c,transition:l=La}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,H.useContext)(Na),y=Ua(r,p),b=u.indexOf(o),x=(0,H.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,H.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=Sa({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:D,activatorEvent:ee,activeNodeRect:te,attributes:O,setNodeRef:k,listeners:A,isDragging:j,over:M,setActivatorNodeRef:ne,transform:N}=va({id:o,data:x,attributes:{...Ba,...n},disabled:y.draggable}),P=jn(E,k),re=!!D,F=re&&!m&&Ta(f)&&Ta(g),I=!_&&j,ie=F?(I&&F?N:null)??(s??v)({rects:h,activeNodeRect:te,activeIndex:f,overIndex:g,index:b}):null,L=Ta(f)&&Ta(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,ae=D?.id,R=(0,H.useRef)({activeId:ae,items:u,newIndex:L,containerId:d}),oe=u!==R.current.items,se=t({active:D,containerId:d,isDragging:j,isSorting:re,id:o,index:b,items:u,newIndex:R.current.newIndex,previousItems:R.current.items,previousContainerId:R.current.containerId,transition:l,wasDragging:R.current.activeId!=null}),ce=Va({disabled:!se,index:b,node:w,rect:C});return(0,H.useEffect)(()=>{re&&R.current.newIndex!==L&&(R.current.newIndex=L),d!==R.current.containerId&&(R.current.containerId=d),u!==R.current.items&&(R.current.items=u)},[re,L,d,u]),(0,H.useEffect)(()=>{if(ae===R.current.activeId)return;if(ae!=null&&R.current.activeId==null){R.current.activeId=ae;return}let e=setTimeout(()=>{R.current.activeId=ae},50);return()=>clearTimeout(e)},[ae]),{active:D,activeIndex:f,attributes:O,data:x,rect:C,index:b,newIndex:L,items:u,isOver:T,isSorting:re,isDragging:j,listeners:A,node:w,overIndex:g,over:M,setNodeRef:P,setActivatorNodeRef:ne,setDroppableNodeRef:E,setDraggableNodeRef:k,transform:ce??ie,transition:le()};function le(){if(ce||oe&&R.current.newIndex===b)return za;if(!(I&&!$n(ee)||!l)&&(re||se))return nr.Transition.toString({...l,property:Ra})}}function Ua(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}$.Down,$.Right,$.Up,$.Left;function Wa(e,t){let n=(0,H.useRef)(null),r=(0,H.useRef)(e);(0,H.useEffect)(()=>{r.current=e},[e]);let i=(0,H.useCallback)(e=>{n.current=e},[]);return(0,H.useEffect)(()=>{let e=n.current;if(!e||!t)return;let i=new IntersectionObserver(e=>{e[0]?.isIntersecting&&r.current()},{root:null,rootMargin:`100px`,threshold:0});return i.observe(e),()=>i.disconnect()},[t]),i}var Ga=60*1e3,Ka=60*Ga,qa=24*Ka,Ja=7*qa,Ya=365*qa,Xa=360,Za=300,Qa=192,$a=120;function eo(e){let t=new Date(e).getTime();if(Number.isNaN(t))return``;let n=Math.max(0,Date.now()-t);return n<Ka?W(`relativeMinuteShort`,{count:Math.max(1,Math.floor(n/Ga))}):n<qa?W(`relativeHourShort`,{count:Math.floor(n/Ka)}):n<Ja?W(`relativeDayShort`,{count:Math.floor(n/qa)}):n<Ya?W(`relativeWeekShort`,{count:Math.floor(n/Ja)}):W(`relativeYearShort`,{count:Math.floor(n/Ya)})}function to({onLoadMore:e,enabled:t}){let n=Wa(e,t);return t?(0,K.jsx)(`div`,{ref:n,className:`flex items-center justify-center py-1`,children:(0,K.jsx)(o,{className:`size-3 animate-spin text-muted-foreground/45`})}):null}function no({id:e,children:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=Ha({id:e});return(0,K.jsx)(`div`,{ref:i,style:{transform:nr.Transform.toString(a),transition:o},className:G(s&&`relative z-50 opacity-40`),children:t({listeners:r,attributes:n})})}var ro=(0,H.memo)(function({sidebarOpen:e,variant:n=`desktop`,scheduledTasksActive:a,agentProfilesActive:l,pluginsActive:p,projectsCollapsed:m,conversationsCollapsed:h,projects:g,expandedProjectIds:_,activeProject:x,currentSessionId:S,globalSessions:C,sessionsForProject:T,globalHasMore:ee,globalLoading:te,onLoadMoreGlobal:O,projectHasMore:k,projectLoading:A,projectLoaded:M,onLoadMoreProject:N,sessionTaskStatus:P,selectingProject:I,onToggleProjectsCollapsed:ie,onToggleConversationsCollapsed:L,onToggleProjectExpanded:R,onToggleAllProjectsExpanded:de,onReorderProjects:fe,onSelectProjectDirectory:pe,onStartNewProjectChat:me,onOpenGlobalSkills:z,onOpenMcpServers:he,onOpenProjectSkills:ge,onOpenProjectInExplorer:_e,onDeleteProject:ve,onLoadSession:ye,onTogglePinSession:be,onRenameSession:B,onDeleteSession:xe,onStartNewGlobalChat:Se,onOpenScheduledTasks:Ce,onOpenAgentProfiles:we,onOpenPlugins:Te,onOpenSettings:Ee,onOpenUpdate:De,onDismissUpdate:Oe,updateAvailable:ke,latestVersion:Ae,currentVersion:je,onToggleSidebar:Me,currentSessionHoverInfo:Ne}){let Pe=`hover:bg-[var(--quickforge-sidebar-hover-bg)]`,V=`group mb-1 flex w-full items-center gap-1 rounded-lg px-2 py-1 text-sm font-medium leading-5 text-muted-foreground/72 transition-colors ${Pe}`,Fe=`flex min-w-0 flex-1 items-center gap-1 text-left transition-colors hover:text-foreground/80`,Ie=`size-4 shrink-0 transition-transform duration-200 ease-out motion-reduce:transition-none`,Le=`grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,Re=`grid-rows-[1fr] opacity-100`,ze=`pointer-events-none grid-rows-[0fr] opacity-0`,Be=`min-h-0 overflow-hidden`,U=`hover:shadow-[0_6px_14px_-14px_rgb(15_23_42_/_0.35)]`,Ve=`group relative flex items-center gap-2 overflow-hidden rounded-lg px-2 py-1.5 text-left transition-[background-color,color,box-shadow] duration-160 ease-out hover:shadow-[0_8px_20px_-18px_rgb(15_23_42_/_0.35)]`,He=`group relative flex items-center gap-2 overflow-hidden px-2 py-1.5 text-left transition-[background-color,color,box-shadow] duration-160 ease-out`,Ue=`bg-[var(--quickforge-sidebar-active-bg)] text-foreground/92 shadow-[0_8px_22px_-20px_rgb(15_23_42_/_0.32)]`,We=`text-foreground/84 ${Pe}`,Ge=`text-muted-foreground/72 ${Pe} hover:text-foreground/86`,Ke=`text-muted-foreground/76 ${Pe} hover:text-foreground/90`,qe=`inline-flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground/55 transition-colors group-hover:text-foreground/70`,Je=`size-7 shrink-0 rounded-full text-muted-foreground/55 transition-[background-color,color,box-shadow,opacity] duration-160 ease-out ${Pe} hover:text-foreground/85 ${U}`,Ye=`${Je} pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100`,Xe=`pointer-events-none absolute inset-y-0 right-1 flex items-center gap-px rounded-r-lg bg-gradient-to-l from-[var(--quickforge-sidebar-hover-bg)] via-[var(--quickforge-sidebar-hover-bg)]/95 to-transparent pl-4 opacity-0 transition-opacity duration-160 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100`,Ze=`size-6 shrink-0 rounded-full text-muted-foreground/55 transition-[background-color,color,box-shadow] duration-160 ease-out ${Pe} hover:text-foreground/85 ${U}`,Qe=`truncate text-sm leading-5`,$e=`flex min-w-0 flex-1 items-center gap-2 text-left`,et=`flex min-w-0 flex-1 items-center gap-1 truncate transition-[padding] duration-160 group-hover:pr-14 group-focus-within:pr-14`,tt=`relative z-10 inline-flex size-5 shrink-0 items-center justify-center rounded-full text-muted-foreground/55 transition-opacity duration-160 transition-colors ${Pe} hover:text-foreground/85`,nt=`group-hover:opacity-0 group-focus-within:opacity-0`,rt=`font-medium text-foreground/92`,it=`shrink-0 text-[11px] leading-4 text-muted-foreground/55 transition-opacity duration-160`,at=`mt-2 flex items-center gap-2 text-sm leading-5 text-muted-foreground/72`,ot=n===`mobile`,[st,ct]=(0,H.useState)(!1),[lt,ut]=(0,H.useState)(``),[dt,ft]=(0,H.useState)(null),[pt,ht]=(0,H.useState)(null),[gt,J]=(0,H.useState)(null),[Y,_t]=(0,H.useState)(null),[vt,yt]=(0,H.useState)(null),[bt,xt]=(0,H.useState)(null),[St,Ct]=(0,H.useState)(null),[wt,Tt]=(0,H.useState)(null),Et=(0,H.useRef)(null),Dt=(0,H.useRef)(null),Ot=(0,H.useRef)(null),kt=vr(_r(_i,{activationConstraint:{distance:6}})),At=(0,H.useCallback)(e=>({...e.transform,x:0}),[]),jt=(0,H.useMemo)(()=>g.map(e=>e.id),[g]),Mt=(0,H.useMemo)(()=>g.find(e=>e.id===dt),[dt,g]),Nt=(0,H.useCallback)(e=>{let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=jt.indexOf(t.id),i=jt.indexOf(n.id);if(r===-1||i===-1)return;let a=[...jt];a.splice(r,1),a.splice(i,0,t.id),fe(a)},[jt,fe]),Pt=(0,H.useRef)(null),Ft=(0,H.useMemo)(()=>{let e=g.flatMap(e=>T(e.id).map(t=>({session:t,projectName:e.name}))),t=C.map(e=>({session:e,projectName:``})),n=new Set;return[...e,...t].filter(({session:e})=>n.has(e.id)?!1:(n.add(e.id),!0))},[C,g,T]),It=lt.trim()?Ft.filter(({session:e,projectName:t})=>`${Kt(e.title)} ${t}`.toLowerCase().includes(lt.trim().toLowerCase())).slice(0,8):[],Lt=()=>{ct(!0),window.setTimeout(()=>Pt.current?.focus(),0)},Rt=e=>{ye(e),ct(!1),ut(``)},zt=()=>{Ot.current!==null&&(window.clearTimeout(Ot.current),Ot.current=null)},Bt=(e,t)=>{if(ot)return;let n=e.currentTarget.getBoundingClientRect(),r=Math.max(8,Math.min(n.right+8,window.innerWidth-392)),i=n.top+n.height/2;zt(),Ot.current=window.setTimeout(()=>{Ot.current=null,Tt({sessionId:t,x:r,y:i})},Za)},Vt=e=>{zt(),Tt(t=>t?.sessionId===e?null:t)},Ht=(e,t)=>{e.stopPropagation();let n=e.currentTarget.getBoundingClientRect();J(null),ft(e=>e===t?(ht(null),null):(ht({x:Math.max(8,Math.min(n.right-Qa,window.innerWidth-Qa-8)),y:Math.max(8,Math.min(n.bottom+4,window.innerHeight-$a-8))}),t))},X=(0,H.useCallback)(()=>{ft(null),ht(null),J(null)},[]),Ut=(e,t)=>{e.stopPropagation(),J(t)},Z=(e,t)=>{e.stopPropagation(),ft(null),ht(null),_t(t),Dt.current!==null&&window.clearTimeout(Dt.current),Dt.current=window.setTimeout(()=>{Dt.current=null,J(e=>e===t?null:e),Promise.resolve(ve(t)).catch(()=>{_t(e=>e===t?null:e)})},Xa)},Wt=(e,t)=>{e.currentTarget.blur(),yt(t),be(t)},Gt=(e,t)=>{e.stopPropagation(),e.currentTarget.blur(),xt(t)},qt=(e,t)=>{e.stopPropagation(),Ct(t),Vt(t),Et.current!==null&&window.clearTimeout(Et.current),Et.current=window.setTimeout(()=>{Et.current=null,xt(e=>e===t?null:e),Promise.resolve(xe(t)).catch(()=>{Ct(e=>e===t?null:e)})},Xa)};return(0,H.useEffect)(()=>()=>{Et.current!==null&&window.clearTimeout(Et.current),Dt.current!==null&&window.clearTimeout(Dt.current),Ot.current!==null&&window.clearTimeout(Ot.current)},[]),(0,H.useEffect)(()=>{if(dt)return window.addEventListener(`click`,X),window.addEventListener(`blur`,X),window.addEventListener(`resize`,X),()=>{window.removeEventListener(`click`,X),window.removeEventListener(`blur`,X),window.removeEventListener(`resize`,X)}},[dt,X]),(0,K.jsxs)(`aside`,{className:G(`relative z-10 min-h-0 shrink-0 overflow-hidden border-r border-border/60 bg-[var(--quickforge-sidebar-bg)] transition-[width] duration-200 ease-out motion-reduce:transition-none md:border-r-0`,ot?`flex h-full flex-col w-80 max-w-[85vw]`:`hidden md:flex md:flex-col`,e?`w-80`:`w-14`),children:[(0,K.jsxs)(`div`,{className:`shrink-0 px-3 pt-3 pb-1`,children:[(0,K.jsxs)(`button`,{type:`button`,className:G(Ve,`w-full`,Ge),onClick:Me,"aria-label":W(`toggleSidebar`),children:[(0,K.jsxs)(`span`,{className:G(qe,`relative`),children:[(0,K.jsx)(b,{className:G(`size-4 transition-opacity duration-160`,!e&&`group-hover:opacity-0`)}),e?null:(0,K.jsx)(u,{className:`absolute size-4 opacity-0 transition-opacity duration-160 group-hover:opacity-100`})]}),(0,K.jsx)(`span`,{className:G(`ml-auto inline-flex size-6 items-center justify-center text-muted-foreground/55 transition-opacity duration-100 group-hover:text-foreground/70`,!e&&`opacity-0`),children:(0,K.jsx)(i,{className:`size-4`})})]}),(0,K.jsxs)(`button`,{type:`button`,className:G(Ve,`mt-4 w-full`,Ge),onClick:Lt,"aria-label":W(`search`),children:[(0,K.jsx)(`span`,{className:qe,children:(0,K.jsx)(E,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:Qe,children:W(`search`)}):null]}),(0,K.jsxs)(`button`,{type:`button`,className:G(Ve,`w-full`,Ge),onClick:z,"aria-label":W(`manageGlobalSkills`),title:W(`manageGlobalSkills`),children:[(0,K.jsx)(`span`,{className:qe,children:(0,K.jsx)(ce,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:Qe,children:W(`skills`)}):null]}),(0,K.jsxs)(`button`,{type:`button`,className:G(Ve,`w-full`,Ge),onClick:he,"aria-label":W(`manageMcpServers`),title:W(`manageMcpServers`),children:[(0,K.jsx)(`span`,{className:qe,children:(0,K.jsx)(oe,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:Qe,children:W(`mcp`)}):null]}),(0,K.jsxs)(`button`,{type:`button`,className:G(Ve,`w-full`,a?Ue:Ge),onClick:Ce,"aria-label":W(`scheduledTasksLabel`),children:[(0,K.jsx)(`span`,{className:qe,children:(0,K.jsx)(le,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:G(Qe,a&&rt),children:W(`scheduledTasksLabel`)}):null]}),(0,K.jsxs)(`button`,{type:`button`,className:G(Ve,`w-full`,l?Ue:Ge),onClick:we,"aria-label":W(`agentsTab`),title:W(`agentsTab`),children:[(0,K.jsx)(`span`,{className:qe,children:(0,K.jsx)(se,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:G(Qe,l&&rt),children:W(`agentsTab`)}):null]}),(0,K.jsxs)(`button`,{type:`button`,className:G(Ve,`w-full`,p?Ue:Ge),onClick:Te,"aria-label":W(`plugins`),title:W(`plugins`),children:[(0,K.jsx)(`span`,{className:qe,children:(0,K.jsx)(ce,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:G(Qe,p&&rt),children:W(`plugins`)}):null]})]}),e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`shrink-0 px-3 max-h-[55%] flex flex-col min-h-0 overflow-hidden`,children:(0,K.jsxs)(`div`,{className:`shrink-0 mb-0.5`,children:[(0,K.jsxs)(`div`,{className:V,children:[(0,K.jsxs)(`button`,{type:`button`,className:Fe,onClick:ie,"aria-expanded":!m,children:[(0,K.jsx)(D,{className:G(Ie,!m&&`rotate-90`)}),(0,K.jsx)(`span`,{className:`flex-1 truncate`,children:W(`projects`)})]}),g.length>0&&(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:Ye,onClick:de,"aria-label":_.size===g.length?W(`collapseAllProjects`):W(`expandAllProjects`),children:_.size===g.length?(0,K.jsx)(j,{className:`size-4`}):(0,K.jsx)(w,{className:`size-4`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:Ye,onClick:pe,disabled:I,"aria-label":W(`addProject`),children:(0,K.jsx)(y,{className:`size-4`})})]}),(0,K.jsx)(`div`,{className:G(Le,`flex-1 min-h-0`,m?ze:Re),children:(0,K.jsx)(`div`,{className:Be,children:(0,K.jsx)(`div`,{className:`h-full overflow-y-auto`,children:(0,K.jsx)(`div`,{className:`space-y-0.5`,children:g.length===0?(0,K.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:W(`noProjects`)}):(0,K.jsx)(ma,{sensors:kt,collisionDetection:Tr,onDragEnd:Nt,modifiers:[At],children:(0,K.jsx)(Pa,{items:jt,strategy:Aa,children:g.map(e=>{let n=T(e.id),i=_.has(e.id),a=x?.id===e.id,l=M(e.id),u=dt===e.id,d=Y===e.id;return(0,K.jsx)(no,{id:e.id,children:({listeners:p,attributes:m})=>(0,K.jsx)(`div`,{className:G(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,d?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,K.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:G(Ve,a?We:Ge,u&&`z-20 overflow-visible`,d&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),style:{touchAction:`none`},...p,...m,children:[(0,K.jsx)(`button`,{type:`button`,className:qe,onClick:()=>R(e.id),"aria-label":W(i?`collapseProject`:`expandProject`),children:i?(0,K.jsx)(s,{className:`size-4`}):(0,K.jsx)(t,{className:`size-4`})}),(0,K.jsx)(`button`,{className:`flex min-w-0 flex-1 items-center text-left`,type:`button`,title:e.path,onClick:()=>R(e.id),children:(0,K.jsx)(`span`,{className:G(Qe,a&&`font-medium text-foreground/84`),children:e.name})}),(0,K.jsxs)(`div`,{className:Xe,children:[(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:Ze,onClick:t=>Ht(t,e.id),"aria-label":W(`moreOptions`),"aria-expanded":u,children:(0,K.jsx)(F,{className:`size-4`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:Ze,onClick:()=>me(e),"aria-label":W(`newProjectChat`),children:(0,K.jsx)(c,{className:`size-4`})})]})]}),(0,K.jsx)(`div`,{className:G(Le,i?Re:ze),children:(0,K.jsx)(`div`,{className:Be,children:(0,K.jsx)(`div`,{className:`mt-0.5 space-y-0.5 pl-8 max-h-[35vh] overflow-y-auto`,children:n.length===0&&!l||n.length===0&&A(e.id)?(0,K.jsxs)(`div`,{className:`flex items-center px-2 py-1.5 text-xs text-muted-foreground/55`,children:[(0,K.jsx)(o,{className:`mr-1.5 size-3 animate-spin`}),W(`loadingChatWorkspace`)]}):n.length===0&&!k(e.id)?(0,K.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground/55`,children:W(`noConversations`)}):(0,K.jsxs)(K.Fragment,{children:[n.map(e=>{let t=S===e.id,n=vt===e.id,i=St===e.id;return(0,K.jsx)(`div`,{className:G(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,i?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,K.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,K.jsxs)(`div`,{className:G(Ve,`gap-1`,t?Ue:Ke,i&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),onMouseEnter:t=>Bt(t,e.id),onMouseLeave:()=>{yt(t=>t===e.id?null:t),i||xt(t=>t===e.id?null:t),Vt(e.id)},children:[(0,K.jsxs)(`button`,{className:$e,type:`button`,onClick:()=>ye(e.id),children:[(0,K.jsxs)(`div`,{className:et,children:[P(e)===`running`?(0,K.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-emerald-500`}):null,(0,K.jsx)(`span`,{className:G(Qe,t&&rt),children:Kt(e.title)})]}),e.pinnedAt?(0,K.jsx)(`button`,{type:`button`,className:G(tt,!n&&nt),onClick:t=>{t.stopPropagation(),be(e.id)},"aria-label":W(`unpinSession`),title:W(`unpinSession`),children:(0,K.jsx)(f,{className:`size-3`})}):null,(0,K.jsx)(`span`,{className:G(it,!n&&nt),children:eo(e.lastModified)})]}),(0,K.jsx)(`div`,{className:G(Xe,n&&`hidden`),children:bt===e.id?(0,K.jsx)(q,{variant:`destructive`,size:`sm`,className:`h-6 rounded-full px-2 text-xs`,onClick:t=>qt(t,e.id),"aria-label":W(`confirmArchive`),title:W(`confirmArchive`),children:W(`confirm`)}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:Ze,onClick:t=>Wt(t,e.id),"aria-label":e.pinnedAt?W(`unpinSession`):W(`pinSession`),children:(0,K.jsx)(f,{className:`size-3.5`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:Ze,onClick:()=>B(e.id,e.title),"aria-label":W(`renameSession`),children:(0,K.jsx)(ae,{className:`size-3.5`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:Ze,onClick:t=>Gt(t,e.id),"aria-label":W(`archiveSession`),children:(0,K.jsx)(r,{className:`size-3.5`})})]})})]})})},e.id)}),(0,K.jsx)(to,{onLoadMore:()=>N(e.id),enabled:k(e.id)&&!A(e.id)})]})})})})]})})},e.id)})})})})})})})]})}),(0,K.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col px-3 pb-3`,children:[(0,K.jsxs)(`div`,{className:V,children:[(0,K.jsxs)(`button`,{type:`button`,className:Fe,onClick:L,"aria-expanded":!h,children:[(0,K.jsx)(D,{className:G(Ie,!h&&`rotate-90`)}),(0,K.jsx)(`span`,{className:`flex-1 truncate`,children:W(`conversations`)})]}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:Je,onClick:Se,"aria-label":W(`newChat`),children:(0,K.jsx)(c,{className:`size-4`})})]}),(0,K.jsx)(`div`,{className:G(Le,`flex-1 min-h-0`,h?ze:Re),children:(0,K.jsx)(`div`,{className:Be,children:(0,K.jsx)(`div`,{className:`h-full overflow-y-auto`,children:C.length===0&&!ee?(0,K.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:W(`noSavedConversations`)}):(0,K.jsxs)(`div`,{className:`space-y-0.5`,children:[C.map(e=>{let t=S===e.id,n=vt===e.id,i=St===e.id;return(0,K.jsx)(`div`,{className:G(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,i?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,K.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,K.jsxs)(`div`,{className:G(Ve,t?Ue:Ke,i&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),onMouseEnter:t=>Bt(t,e.id),onMouseLeave:()=>{yt(t=>t===e.id?null:t),i||xt(t=>t===e.id?null:t),Vt(e.id)},children:[(0,K.jsxs)(`button`,{className:$e,type:`button`,onClick:()=>ye(e.id),children:[(0,K.jsxs)(`div`,{className:et,children:[P(e)===`running`?(0,K.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-emerald-500`}):null,(0,K.jsx)(`span`,{className:G(Qe,t&&rt),children:Kt(e.title)})]}),e.pinnedAt?(0,K.jsx)(`button`,{type:`button`,className:G(tt,!n&&nt),onClick:t=>{t.stopPropagation(),be(e.id)},"aria-label":W(`unpinSession`),title:W(`unpinSession`),children:(0,K.jsx)(f,{className:`size-3`})}):null,(0,K.jsx)(`span`,{className:G(it,!n&&nt),children:eo(e.lastModified)})]}),(0,K.jsx)(`div`,{className:G(Xe,n&&`hidden`),children:bt===e.id?(0,K.jsx)(q,{variant:`destructive`,size:`sm`,className:`h-6 rounded-full px-2 text-xs`,onClick:t=>qt(t,e.id),"aria-label":W(`confirmArchive`),title:W(`confirmArchive`),children:W(`confirm`)}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:Ze,onClick:t=>Wt(t,e.id),"aria-label":e.pinnedAt?W(`unpinSession`):W(`pinSession`),children:(0,K.jsx)(f,{className:`size-3.5`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:Ze,onClick:()=>B(e.id,e.title),"aria-label":W(`renameSession`),children:(0,K.jsx)(ae,{className:`size-3.5`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:Ze,onClick:t=>Gt(t,e.id),"aria-label":W(`archiveSession`),children:(0,K.jsx)(r,{className:`size-4`})})]})})]})})},e.id)}),(0,K.jsx)(to,{onLoadMore:O,enabled:ee&&!te})]})})})})]})]}):null,(0,K.jsxs)(`div`,{className:`mt-auto shrink-0 border-t border-border px-3 py-3`,children:[ke&&Ae?(0,K.jsxs)(`button`,{type:`button`,className:G(He,`relative mb-2 w-full border border-primary/30 bg-primary/5 text-primary hover:bg-primary/10`),onClick:De,"aria-label":W(`newVersionAvailable`,{version:Ae}),title:W(`newVersionAvailable`,{version:Ae}),children:[(0,K.jsx)(`span`,{className:G(qe,`text-primary/80`),children:(0,K.jsx)(re,{className:`size-4`})}),e?(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate text-xs font-medium leading-tight`,children:W(`newVersionAvailable`,{version:Ae})}),je?(0,K.jsx)(`span`,{className:`block truncate text-[11px] leading-tight text-primary/70`,children:W(`newVersionAvailableSub`,{current:je})}):null]}):null,e&&Oe?(0,K.jsx)(`span`,{className:`shrink-0 rounded-full px-1.5 py-0.5 text-[11px] text-primary/60 transition-colors hover:bg-primary/15 hover:text-primary`,role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),Oe()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),Oe())},children:W(`updateLater`)}):null,e?null:(0,K.jsx)(`span`,{className:`absolute right-1 top-1 size-2 rounded-full bg-primary`})]}):null,(0,K.jsxs)(`button`,{type:`button`,className:G(He,`w-full`,Ge),onClick:Ee,"aria-label":W(`settings`),title:W(`settings`),children:[(0,K.jsx)(`span`,{className:qe,children:(0,K.jsx)(ne,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:Qe,children:W(`settings`)}):null]})]}),wt?(()=>{let e=Ft.find(e=>e.session.id===wt.sessionId)?.session;if(!e)return null;let t=Ne?.sessionId===e.id;return(0,K.jsxs)(`div`,{className:`pointer-events-none fixed z-50 w-[min(24rem,calc(100vw-1rem))] max-w-sm rounded-2xl border border-border bg-popover px-4 py-3 text-left shadow-quickforge`,style:{left:wt.x,top:wt.y,transform:`translateY(-50%)`},children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-medium leading-5 text-foreground/92`,children:Kt(e.title)}),t&&Ne?.gitBranch?(0,K.jsxs)(`div`,{className:at,children:[(0,K.jsx)(d,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,K.jsx)(`span`,{className:`truncate`,children:Ne.gitBranch})]}):null,t&&Ne?.context?(0,K.jsxs)(`div`,{className:at,title:Ne.context.title,children:[(0,K.jsx)(ue,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,K.jsx)(`span`,{className:`size-2 shrink-0 rounded-full`,style:{backgroundColor:Ne.context.color}}),(0,K.jsx)(`span`,{className:`truncate`,children:Ne.context.label})]}):null]})})():null,Mt&&pt?(0,mt.createPortal)((0,K.jsxs)(`div`,{className:`fixed z-50 min-w-48 overflow-hidden rounded-lg border border-border bg-background p-1 shadow-quickforge`,style:{left:pt.x,top:pt.y},onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm text-foreground/86 transition-colors hover:bg-muted`,title:W(`openInExplorer`),"aria-label":W(`openInExplorer`),onClick:()=>{X(),_e(Mt)},children:[(0,K.jsx)(s,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,K.jsx)(`span`,{children:W(`openFolder`)})]}),(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm text-foreground/86 transition-colors hover:bg-muted`,onClick:()=>{X(),ge(Mt)},children:[(0,K.jsx)(ce,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,K.jsx)(`span`,{children:W(`manageProjectSkills`)})]}),gt===Mt.id?(0,K.jsx)(`button`,{type:`button`,className:`flex w-full items-center justify-center gap-2 whitespace-nowrap rounded-md bg-destructive px-2 py-1.5 text-left text-sm font-medium text-destructive-foreground transition-colors hover:bg-destructive/90`,"aria-label":W(`confirmDelete`),onClick:e=>Z(e,Mt.id),children:(0,K.jsx)(`span`,{children:W(`confirm`)})}):(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm text-destructive transition-colors hover:bg-destructive/10`,"aria-label":W(`deleteProject`),onClick:e=>Ut(e,Mt.id),children:[(0,K.jsx)(v,{className:`size-4 shrink-0`}),(0,K.jsx)(`span`,{children:W(`deleteProject`)})]})]}),document.body):null,st?(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center bg-background/50 px-4 pt-[12vh] backdrop-blur-sm`,role:`dialog`,"aria-modal":`true`,onMouseDown:()=>ct(!1),children:(0,K.jsxs)(`div`,{className:`w-full max-w-xl rounded-2xl border border-border bg-popover p-3 shadow-quickforge`,onMouseDown:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl border border-input bg-background px-3 py-2`,children:[(0,K.jsx)(E,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,K.jsx)(`input`,{ref:Pt,value:lt,onChange:e=>ut(e.target.value),onKeyDown:e=>{e.key===`Escape`&&ct(!1)},placeholder:W(`searchDialog`),className:`min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground/45`})]}),(0,K.jsx)(`div`,{className:`mt-2 max-h-[50vh] overflow-y-auto`,children:lt.trim()?It.length>0?It.map(({session:e,projectName:t})=>(0,K.jsxs)(`button`,{type:`button`,className:`block w-full rounded-xl px-3 py-2 text-left transition-colors hover:bg-muted/28`,onClick:()=>Rt(e.id),children:[(0,K.jsx)(`div`,{className:`truncate text-sm text-foreground/90`,children:Kt(e.title)}),(0,K.jsxs)(`div`,{className:`truncate text-[11px] text-muted-foreground/55`,children:[t||W(`normalChat`),` · `,eo(e.lastModified)]})]},e.id)):(0,K.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:W(`noSearchResults`)}):(0,K.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:W(`searchHint`)})})]})}):null]})});function io(){let[e,t]=(0,H.useState)(),[n,r]=(0,H.useState)([]),[i,a]=(0,H.useState)(),[o,s]=(0,H.useState)(()=>new Set),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(!1);return{activeProject:e,projects:n,defaultWorkspace:i,expandedProjectIds:o,selectingProject:c,projectPickerOpen:u,loadProject:(0,H.useCallback)(async()=>{try{let e=await fetch(`/api/project`);if(!e.ok)return;let n=await e.json();t(n.project),r(Array.isArray(n.projects)?n.projects:[]),a(typeof n.defaultWorkspaceRoot==`string`&&n.defaultWorkspaceRoot?{id:`default`,name:`workspace`,path:n.defaultWorkspaceRoot,lastOpenedAt:``}:void 0),s(e=>{let t=new Set(e);for(let e of Array.isArray(n.projects)?n.projects:[])t.add(e.id);return t})}catch(e){V.error(`Failed to load project:`,e)}},[]),switchActiveProject:(0,H.useCallback)(async e=>{let n=await fetch(`/api/project/active`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:e})}),i=await n.json().catch(()=>null);if(!n.ok)throw Error(i?.error||`Project switch failed with HTTP ${n.status}`);return t(i.project),r(Array.isArray(i.projects)?i.projects:[]),s(e=>{let t=new Set(e);for(let e of Array.isArray(i.projects)?i.projects:[])t.add(e.id);return t}),i.project},[]),handleSelectProjectPath:(0,H.useCallback)(async e=>{l(!0);try{let n=await fetch(`/api/project/path`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e})}),i=await n.json().catch(()=>null);if(!n.ok)throw Error(i?.error||`Project selection failed with HTTP ${n.status}`);i?.project&&(t(i.project),r(Array.isArray(i.projects)?i.projects:[]),s(e=>{let t=new Set(e);for(let e of Array.isArray(i.projects)?i.projects:[])t.add(e.id);return t}))}catch(e){throw V.error(`Failed to select project:`,e),e}finally{l(!1)}},[]),selectProjectDirectory:(0,H.useCallback)(()=>{d(!0)},[]),setProjectPickerOpen:d,toggleProjectExpanded:(0,H.useCallback)(e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),toggleAllProjectsExpanded:(0,H.useCallback)(()=>{s(e=>e.size===n.length&&n.length>0?new Set:new Set(n.map(e=>e.id)))},[n]),reorderProjects:(0,H.useCallback)(async e=>{r(t=>{let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of e){let e=n.get(t);e&&(r.push(e),n.delete(t))}return r});try{let t=await fetch(`/api/project/reorder`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({orderedIds:e})}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`Reorder failed with HTTP ${t.status}`);Array.isArray(n?.projects)&&r(n.projects)}catch(e){V.error(`Failed to reorder projects:`,e)}},[]),setActiveProject:t,setProjects:r,setExpandedProjectIds:s}}function ao(){let[e,t]=(0,H.useState)(`default`);return{agentAccessMode:e,setAgentAccessMode:t,initialize:(0,H.useCallback)(async e=>{let n=await En(e);return t(n),n},[])}}var oo=`quickforge-sync`;function so(e){let t=(0,H.useRef)(e);(0,H.useEffect)(()=>{t.current=e});let n=(0,H.useRef)(X()),r=(0,H.useRef)(null);(0,H.useEffect)(()=>{if(typeof BroadcastChannel<`u`)try{let e=new BroadcastChannel(oo);r.current=e;let i=e=>{let r=e.data;if(!(!r||r.sourceTabId===n.current))switch(r.type){case`sessions-changed`:t.current.onSessionsChanged();break;case`projects-changed`:t.current.onProjectsChanged();break;case`settings-changed`:t.current.onSettingsChanged();break}};return e.addEventListener(`message`,i),()=>{e.removeEventListener(`message`,i),e.close()}}catch{r.current=null}},[]),(0,H.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&(t.current.onSessionsChanged(),t.current.onProjectsChanged())};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[]);let i=(0,H.useCallback)(e=>{let t={type:e,sourceTabId:n.current,timestamp:Date.now()};r.current?.postMessage(t)},[]);return{notifySessionsChanged:(0,H.useCallback)(()=>i(`sessions-changed`),[i]),notifyProjectsChanged:(0,H.useCallback)(()=>i(`projects-changed`),[i]),notifySettingsChanged:(0,H.useCallback)(()=>i(`settings-changed`),[i])}}function co(e,t){let n=t.toolCallId;if(t.role===`toolResult`&&typeof n==`string`){let r=e.findIndex(e=>e.role===`toolResult`&&e.toolCallId===n);if(r>=0){let n=e.slice();return n[r]=t,n}}if(t.role===`assistant`){let n=t.timestamp;if(n!==void 0){let r=e.findIndex(e=>e.role===`assistant`&&e.timestamp===n);if(r>=0){let n=e.slice();return n[r]=t,n}}}let r=e.slice(),i=r.length-1;return i>=0&&r[i]?.role===t.role?r[i]=t:r.push(t),r}function lo(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function uo(e){if(!lo(e))return;let t=e.quickforgeTiming;if(!lo(t))return;let n=typeof t.startedAt==`number`?t.startedAt:void 0,r=typeof t.finishedAt==`number`?t.finishedAt:void 0,i=typeof t.durationMs==`number`?t.durationMs:void 0;if(!(n===void 0&&r===void 0&&i===void 0))return{startedAt:n,finishedAt:r,durationMs:i}}function fo(e,t){return lo(e)?{...e,quickforgeTiming:t}:{quickforgeTiming:t}}function po(e,t){let n=e.quickforgeTiming??uo(e.partialResult?.details)??{startedAt:Date.now()};return{...e,partialResult:e.partialResult??{content:[],details:{quickforgeTiming:n,sessionId:t,toolCallId:e.toolCallId}}}}function mo(e,t,n){if(!t.toolCallId||!t.toolName)return e;let r=n?t.partialResult:t.result;if(!r)return e;let i=uo(r.details)??t.quickforgeTiming;if(!i){let n=e.findIndex(e=>e.role===`toolResult`&&e.toolCallId===t.toolCallId);n>=0&&(i=uo(e[n].details))}let a=i?fo(r.details,i):r.details,o=lo(a)?{...a,sessionId:a.sessionId??t.sessionId,toolCallId:a.toolCallId??t.toolCallId}:a;return co(e,{role:`toolResult`,toolCallId:t.toolCallId,toolName:t.toolName,content:r.content??[],details:o,isError:n?!1:t.isError,timestamp:Date.now()})}function ho(){return``}var go=5e3,_o=15e3,vo=new class{eventSource=null;handlersBySession=new Map;baseUrl=``;reconnectTimer=null;reconnectDelay=1e3;directBaseUrl=ho();fallbackBaseUrl=``;subscribe(e,t,n){this.fallbackBaseUrl=t;let r=this.directBaseUrl||this.fallbackBaseUrl;(!this.eventSource||this.baseUrl!==r)&&(this.disconnect(),this.baseUrl=r,this.connect());let i=this.handlersBySession.get(e);return i||(i=new Set,this.handlersBySession.set(e,i)),i.add(n),()=>{let t=this.handlersBySession.get(e);t?.delete(n),t?.size===0&&this.handlersBySession.delete(e),this.handlersBySession.size===0&&this.globalHandlers.size===0&&this.disconnect()}}globalHandlers=new Set;subscribeAll(e,t){this.fallbackBaseUrl=e;let n=this.directBaseUrl||this.fallbackBaseUrl;return(!this.eventSource||this.baseUrl!==n)&&(this.disconnect(),this.baseUrl=n,this.connect()),this.globalHandlers.add(t),()=>{this.globalHandlers.delete(t),this.handlersBySession.size===0&&this.globalHandlers.size===0&&this.disconnect()}}connect(){let e=`${this.baseUrl}/api/agents/events`;this.eventSource=new EventSource(e),this.eventSource.onopen=()=>{this.reconnectDelay=1e3};let t=[`state`,`agent_start`,`agent_end`,`message_start`,`message_end`,`turn_start`,`turn_end`,`message_update`,`tool_execution_start`,`tool_execution_update`,`tool_execution_end`,`error`,`title_updated`,`session_forked`,`scheduled_task_notification`,`scheduled_task_started`,`tool_approval_required`,`auto_compact_threshold_reached`,`auto_compact_approval_required`,`auto_compact_completed`,`auto_compact_failed`,`messages_replaced`],n=e=>t=>{try{let n=JSON.parse(t.data),r=n.sessionId;if(!r&&e!==`scheduled_task_notification`)return;let i=e?{type:e,...n}:n;r?this.emit(r,i):this.emitGlobal(i)}catch{}};this.eventSource.onmessage=n();for(let e of t)this.eventSource.addEventListener(e,n(e));this.eventSource.onerror=()=>{if(this.eventSource?.close(),this.eventSource=null,this.baseUrl===this.directBaseUrl&&this.fallbackBaseUrl!==this.directBaseUrl){this.baseUrl=this.fallbackBaseUrl,this.connect();return}this.scheduleReconnect()}}scheduleReconnect(){this.reconnectTimer||this.handlersBySession.size===0&&this.globalHandlers.size===0||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,!(this.handlersBySession.size===0&&this.globalHandlers.size===0)&&(this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4),this.connect())},this.reconnectDelay))}emitGlobal(e){for(let t of this.globalHandlers)try{t(e)}catch{}}emit(e,t){this.emitGlobal(t);let n=this.handlersBySession.get(e);if(n)for(let e of n)try{e(t)}catch{}}disconnect(){this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.eventSource?.close(),this.eventSource=null}};async function yo(e=``){let t=await fetch(`${e}/api/agents`,{cache:`no-store`});if(!t.ok)return[];let n=await t.json().catch(()=>null);return Array.isArray(n?.sessions)?n.sessions:[]}function bo(e,t=``){return vo.subscribeAll(t,e)}var xo=class e{state;streamFn=Ne;getApiKey;sessionId;listeners=new Set;unsubscribeSse;baseUrl;disposed=!1;_syncingThinkingLevel=!1;pollTimer=null;refreshPromise=null;statusPromise=null;lastSseEventAt=Date.now();lastServerStateVersion=0;nextPromptCapabilities=[];planMode=!1;onPlanModeConsumed;stateVersion=0;constructor(e){this.sessionId=e.sessionId,this.baseUrl=e.baseUrl??``;let t=e.initialState??{};this.lastServerStateVersion=typeof t.stateVersion==`number`?t.stateVersion:0;let n={systemPrompt:t.systemPrompt??``,model:t.model??null,thinkingLevel:t.thinkingLevel??`off`,messages:t.messages?.slice()??[],tools:t.tools??[],accessMode:Z(t.accessMode,Ut(t.yoloMode)),yoloMode:Wt(Z(t.accessMode,Ut(t.yoloMode))),isStreaming:t.isStreaming??!1,streamingMessage:void 0,pendingToolCalls:new Set,errorMessage:t.errorMessage,contextCompaction:t.contextCompaction??null,contextUsage:t.contextUsage??null};this.state=new Proxy(n,{set:(e,t,n)=>{let r=e[t];return e[t]=n,t===`thinkingLevel`&&!this._syncingThinkingLevel&&n!==r&&this.updateThinkingLevel(n),!0}}),this.unsubscribeSse=vo.subscribe(this.sessionId,this.baseUrl,e=>this.handleSseEvent(e)),this.state.isStreaming&&this.startStateWatchdog()}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setNextPromptCapabilities(e){this.nextPromptCapabilities=Array.isArray(e)?e.slice(0,4):[]}setPlanMode(e,t){this.planMode=e,this.onPlanModeConsumed=e?t:void 0}async prompt(e){if(this.disposed)return;let t;t=typeof e==`string`?{role:`user`,content:e,timestamp:Date.now()}:Array.isArray(e)?[...e].reverse().find(e=>e.role===`user`||e.role===`user-with-attachments`)??e[e.length-1]:e;let n=this.nextPromptCapabilities,r=this.planMode?{type:`plan`}:void 0;if(this.nextPromptCapabilities=[],this.planMode){this.planMode=!1;let e=this.onPlanModeConsumed;this.onPlanModeConsumed=void 0,e?.()}let i=t;this.state.messages=[...this.state.messages,i],this.state.contextUsage=null,this.emitToListeners({type:`message_start`,message:i}),this.state.isStreaming||(this.state.isStreaming=!0,this.state.errorMessage=void 0,this.emitToListeners({type:`agent_start`}));let a=new AbortController,o=setTimeout(()=>a.abort(),3e4),s=this.state.messages.length,c=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/prompt`;fetch(c,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:i,selectedCapabilities:n,command:r}),signal:a.signal}).then(e=>{if(clearTimeout(o),!e.ok)throw Error(`Failed to send prompt: HTTP ${e.status}`)}).catch(e=>{clearTimeout(o);let t=e instanceof Error?e.message:String(e);V.error(`Failed to send prompt:`,e),this.state.messages.length===s+1&&(this.state.messages=this.state.messages.slice(0,-1)),this.state.errorMessage=t,this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.stopStateWatchdog(),this.emitToListeners({type:`error`,error:t}),this.emitToListeners({type:`agent_end`,messages:this.state.messages})}),this.startStateWatchdog()}abort(){let e=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/abort`;fetch(e,{method:`POST`}).catch(e=>{V.error(`Failed to abort:`,e)})}steer(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/steer`;fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:e})}).catch(e=>{V.error(`Failed to send steer:`,e)})}followUp(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/follow-up`;fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:e})}).catch(e=>{V.error(`Failed to send follow-up:`,e)})}reset(){this.state.messages=[],this.state.errorMessage=void 0,this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.state.pendingToolCalls=new Set}async updateAccessMode(e){let t=Z(e),n=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/access-mode`,r=await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({accessMode:t})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(e?.error||`Failed to sync Agent access mode: HTTP ${r.status}`)}this.state.accessMode=t,this.state.yoloMode=Wt(t)}async updateYoloMode(e){await this.updateAccessMode(e?`full-access`:`default`)}async updateModel(e){this.state.model=e,this.state.contextUsage=null;let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/model`;fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({model:e})}).catch(e=>{V.error(`Failed to sync model update to server:`,e)})}async updateThinkingLevel(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/thinking-level`;fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({thinkingLevel:e})}).catch(e=>{V.error(`Failed to sync thinking level update to server:`,e)})}async rollback(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/rollback`,n=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({messageIndex:e})}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Failed to roll back: HTTP ${n.status}`);return r}async continue(){let e=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/continue`,t=await fetch(e,{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||`Failed to continue: HTTP ${t.status}`)}this.state.isStreaming=!0,this.state.errorMessage=void 0,this.startStateWatchdog()}async approveToolCall(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/approve-tool`,n=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({toolCallId:e})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`Failed to approve tool call: HTTP ${n.status}`)}}async rejectToolCall(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/reject-tool`,n=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({toolCallId:e})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`Failed to reject tool call: HTTP ${n.status}`)}}async approveAutoCompact(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/approve-auto-compact`,n=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({approvalId:e})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`Failed to approve auto compact: HTTP ${n.status}`)}}async rejectAutoCompact(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/reject-auto-compact`,n=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({approvalId:e})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`Failed to reject auto compact: HTTP ${n.status}`)}}dispose(){this.disposed=!0,this.pollTimer&&=(clearInterval(this.pollTimer),null),this.statusPromise=null,this.unsubscribeSse?.(),this.unsubscribeSse=void 0,this.listeners.clear()}handleSseEvent(e){switch(this.noteSseEvent(e),e.type){case`state`:{let t=e;if(t.systemPrompt!==void 0&&(this.state.systemPrompt=t.systemPrompt),t.messages&&(t.messages.length>this.state.messages.length||!this.state.isStreaming&&t.messages.length===this.state.messages.length)&&(this.state.messages=t.messages,this.stateVersion++),t.model&&(this.state.model=t.model),t.thinkingLevel&&(this._syncingThinkingLevel=!0,this.state.thinkingLevel=t.thinkingLevel,this._syncingThinkingLevel=!1),t.accessMode!==void 0||t.yoloMode!==void 0){let e=Z(t.accessMode,Ut(t.yoloMode));this.state.accessMode=e,this.state.yoloMode=Wt(e)}t.tools&&(this.state.tools=t.tools),t.contextCompaction!==void 0&&(this.state.contextCompaction=t.contextCompaction),t.contextUsage===void 0?t.messages&&(this.state.contextUsage=null):this.state.contextUsage=t.contextUsage;let n=this.state.isStreaming;t.isStreaming!==void 0&&(n=this.state.isStreaming,this.state.isStreaming=t.isStreaming,t.isStreaming?this.startStateWatchdog():this.stopStateWatchdog()),t.isStreaming?(this.state.errorMessage=void 0,this.emitToListeners({type:`agent_start`})):n&&(this.stateVersion++,this.emitToListeners({type:`agent_end`,messages:this.state.messages}));return}case`agent_start`:this.state.isStreaming=!0,this.state.errorMessage=void 0,this.startStateWatchdog();break;case`agent_end`:{this.stopStateWatchdog();let t=e;if(t.messages&&t.messages.length>=this.state.messages.length){this.state.messages=t.messages,this.state.contextUsage=t.contextUsage===void 0?null:t.contextUsage,this.state.isStreaming=!1,this.state.streamingMessage=void 0,t.errorMessage&&(this.state.errorMessage=t.errorMessage),this.stateVersion++,this.emitToListeners(e);return}this.refreshStateFromServer({forceMessages:!0}).finally(()=>{this.state.isStreaming=!1,this.state.streamingMessage=void 0,t.errorMessage&&(this.state.errorMessage=t.errorMessage),this.emitToListeners(e)});return}case`message_end`:{let t=e;if(t.message){this.state.messages=co(this.state.messages,t.message),this.state.contextUsage=t.contextUsage===void 0?null:t.contextUsage,this.stateVersion++,this.emitToListeners(e);return}if(t.messages&&t.messages.length>=this.state.messages.length){this.state.messages=t.messages,this.state.contextUsage=t.contextUsage===void 0?null:t.contextUsage,this.stateVersion++,this.emitToListeners(e);return}this.refreshStateFromServer().finally(()=>{this.emitToListeners(e)});return}case`turn_end`:{let t=e;if(t.messages&&t.messages.length>=this.state.messages.length){this.state.messages=t.messages,this.state.contextUsage=t.contextUsage===void 0?null:t.contextUsage,this.stateVersion++,this.emitToListeners(e);return}this.refreshStateFromServer().finally(()=>{this.emitToListeners(e)});return}case`messages_replaced`:{let t=e;t.messages&&(this.state.messages=t.messages,this.state.streamingMessage=void 0,this.stateVersion++),t.contextCompaction!==void 0&&(this.state.contextCompaction=t.contextCompaction),t.contextUsage===void 0?t.messages&&(this.state.contextUsage=null):this.state.contextUsage=t.contextUsage;break}case`error`:{this.stopStateWatchdog();let t=e.error;this.state.errorMessage=t||`Unknown error`,this.state.isStreaming=!1;break}case`title_updated`:break;case`session_forked`:break;case`tool_execution_start`:{let t=e;t.toolCallId&&(this.state.messages=mo(this.state.messages,po(t,this.sessionId),!0),this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId]),this.stateVersion++);break}case`tool_execution_update`:{let t=e;this.state.messages=mo(this.state.messages,t,!0),t.toolCallId&&(this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId])),this.stateVersion++;break}case`tool_execution_end`:{let t=e;if(this.state.messages=mo(this.state.messages,t,!1),t.toolCallId){let e=new Set(this.state.pendingToolCalls);e.delete(t.toolCallId),this.state.pendingToolCalls=e}this.stateVersion++;break}case`auto_compact_completed`:{let t=e;t.contextCompaction!==void 0&&(this.state.contextCompaction=t.contextCompaction),t.contextUsage!==void 0&&(this.state.contextUsage=t.contextUsage);break}case`auto_compact_failed`:case`message_start`:case`message_update`:case`turn_start`:case`tool_approval_required`:case`auto_compact_threshold_reached`:case`auto_compact_approval_required`:break}this.emitToListeners(e)}emitToListeners(e){for(let t of this.listeners)try{t(e)}catch{}}noteSseEvent(e){this.lastSseEventAt=Date.now();let t=e.stateVersion;typeof t==`number`&&Number.isFinite(t)&&(this.lastServerStateVersion=Math.max(this.lastServerStateVersion,t))}startStateWatchdog(){this.pollTimer||this.disposed||(this.lastSseEventAt=Date.now(),this.pollTimer=setInterval(()=>{if(this.disposed||!this.state.isStreaming){this.stopStateWatchdog();return}Date.now()-this.lastSseEventAt<_o||this.refreshStatusFromServer()},go))}stopStateWatchdog(){this.pollTimer&&=(clearInterval(this.pollTimer),null)}async refreshStatusFromServer(){return this.statusPromise||=this._doRefreshStatusFromServer().finally(()=>{this.statusPromise=null}),this.statusPromise}async _doRefreshStatusFromServer(){let e=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/status`;try{let t=await fetch(e);if(!t.ok){t.status===404&&this.state.isStreaming&&(this.state.isStreaming=!1,this.stopStateWatchdog(),this.emitToListeners({type:`agent_end`,messages:this.state.messages}));return}let n=await t.json();this.lastSseEventAt=Date.now();let r=typeof n.stateVersion==`number`&&Number.isFinite(n.stateVersion)?n.stateVersion:this.lastServerStateVersion;if(n.isStreaming===!1){this.stopStateWatchdog(),await this.refreshStateFromServer({notify:!0,forceMessages:!0});return}n.isStreaming===!0&&(this.state.isStreaming=!0,this.state.errorMessage=n.errorMessage),r>this.lastServerStateVersion&&await this.refreshStateFromServer({notify:!0,forceMessages:!0})}catch{}}async refreshStateFromServer(e){return this.refreshPromise||=this._doRefreshStateFromServer(e).finally(()=>{this.refreshPromise=null}),this.refreshPromise}async _doRefreshStateFromServer(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/state`;try{let n=this.stateVersion,r=await fetch(t);if(!r.ok){r.status===404&&this.state.isStreaming&&(this.state.isStreaming=!1,this.stopStateWatchdog(),this.emitToListeners({type:`agent_end`,messages:this.state.messages}));return}let i=await r.json();if(typeof i.stateVersion==`number`&&Number.isFinite(i.stateVersion)&&(this.lastServerStateVersion=Math.max(this.lastServerStateVersion,i.stateVersion)),!e?.forceMessages&&n!==this.stateVersion)return;let a=!!(i.messages&&(e?.forceMessages||i.messages.length>this.state.messages.length||!this.state.isStreaming&&i.messages.length===this.state.messages.length));if(a&&(this.state.messages=i.messages,this.state.contextUsage=i.contextUsage===void 0?null:i.contextUsage,this.stateVersion++),i.systemPrompt!==void 0&&(this.state.systemPrompt=i.systemPrompt),i.model&&(this.state.model=i.model),i.thinkingLevel&&(this._syncingThinkingLevel=!0,this.state.thinkingLevel=i.thinkingLevel,this._syncingThinkingLevel=!1),i.accessMode!==void 0||i.yoloMode!==void 0){let e=Z(i.accessMode,Ut(i.yoloMode));this.state.accessMode=e,this.state.yoloMode=Wt(e)}if(i.tools&&(this.state.tools=i.tools),i.contextCompaction!==void 0&&(this.state.contextCompaction=i.contextCompaction),i.contextUsage!==void 0&&(this.state.contextUsage=i.contextUsage),i.isStreaming!==void 0){let t=this.state.isStreaming;if(this.state.isStreaming=!!i.isStreaming,i.isStreaming?(this.state.errorMessage=void 0,t||this.emitToListeners({type:`agent_start`})):this.stopStateWatchdog(),e?.notify&&t&&!i.isStreaming){this.stateVersion++,this.emitToListeners({type:`agent_end`,messages:this.state.messages});return}}if(e?.notify)if(i.isStreaming&&a){let e=this.state.messages[this.state.messages.length-1];e&&this.emitToListeners({type:`message_update`,message:e})}else i.isStreaming||this.emitToListeners({type:`message_end`})}catch{}}static async create(t,n={}){let r=n.baseUrl??``,i=await fetch(`${r}/api/agents/${encodeURIComponent(t)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({scope:n.scope??`global`,projectId:n.projectId,accessMode:n.accessMode,yoloMode:n.yoloMode??Wt(Z(n.accessMode)),model:n.model,thinkingLevel:n.thinkingLevel??`off`,messages:n.messages??[],title:n.title??`New chat`,contextCompaction:n.contextCompaction})});if(!i.ok){let e=await i.json().catch(()=>({error:`Failed to create agent`}));throw Error(e.error||`Failed to create agent`)}let a={};try{let e=await fetch(`${r}/api/agents/${encodeURIComponent(t)}/state`);e.ok&&(a=await e.json())}catch{}return new e({sessionId:t,baseUrl:r,initialState:{systemPrompt:a.systemPrompt??``,model:a.model??n.model??null,thinkingLevel:a.thinkingLevel??n.thinkingLevel??`off`,messages:a.messages??n.messages??[],tools:a.tools??[],accessMode:Z(a.accessMode,n.accessMode??a.yoloMode??n.yoloMode),yoloMode:!!(a.yoloMode??n.yoloMode),isStreaming:!!a.isStreaming,errorMessage:a.errorMessage,contextCompaction:a.contextCompaction,contextUsage:a.contextUsage,stateVersion:a.stateVersion}})}},So=class{sessionId;streamFn=Ne;getApiKey;scope;project;createAgent;listeners=new Set;disposed=!1;realAgentPromise;promotedAgent;nextPromptCapabilities=[];planMode=!1;onPlanModeConsumed;state;constructor(e){this.sessionId=`pending-${X()}`,this.scope=e.scope,this.project=e.project,this.createAgent=e.createAgent;let t=Z(e.accessMode,e.yoloMode?`full-access`:`default`);this.state={systemPrompt:``,model:e.model,thinkingLevel:e.thinkingLevel,messages:[],tools:[],accessMode:t,yoloMode:Wt(t),isStreaming:!1,pendingToolCalls:new Set,contextCompaction:null,contextUsage:null}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setNextPromptCapabilities(e){this.nextPromptCapabilities=Array.isArray(e)?e.slice(0,4):[]}setPlanMode(e,t){this.planMode=e,this.onPlanModeConsumed=e?t:void 0}async prompt(e){if(this.disposed)return;let t=await this.ensureRealAgent();t.setNextPromptCapabilities(this.nextPromptCapabilities),t.setPlanMode(this.planMode,this.onPlanModeConsumed),this.nextPromptCapabilities=[],this.planMode=!1,this.onPlanModeConsumed=void 0,await t.prompt(e)}abort(){this.realAgentPromise?.then(e=>e.abort())}reset(){this.state.messages=[],this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.state.pendingToolCalls=new Set,this.state.errorMessage=void 0}async rollback(){throw Error(`Cannot roll back a pending chat`)}async continue(){await(await this.ensureRealAgent()).continue()}async approveToolCall(){throw Error(`No pending tool call`)}async rejectToolCall(){throw Error(`No pending tool call`)}async approveAutoCompact(){throw Error(`No pending auto compact request`)}async rejectAutoCompact(){throw Error(`No pending auto compact request`)}async updateAccessMode(e){let t=Z(e);this.state.accessMode=t,this.state.yoloMode=Wt(t);let n=await this.realAgentPromise;n&&await n.updateAccessMode(t)}async updateYoloMode(e){await this.updateAccessMode(e?`full-access`:`default`)}async updateModel(e){this.state.model=e;let t=await this.realAgentPromise;t&&await t.updateModel(e)}async updateThinkingLevel(e){this.state.thinkingLevel=e;let t=await this.realAgentPromise;t&&await t.updateThinkingLevel(e)}dispose(){this.disposed=!0,this.listeners.clear(),this.promotedAgent||this.realAgentPromise?.then(e=>{this.promotedAgent!==e&&e.dispose()}).catch(()=>{})}promoteTo(e){this.promotedAgent=e,this.listeners.clear()}async ensureRealAgent(){if(!this.realAgentPromise){let e=X();this.realAgentPromise=this.createAgent({model:this.state.model,thinkingLevel:this.state.thinkingLevel,tools:[]},e,{scope:this.scope,project:this.project,attachToView:!0,accessMode:this.state.accessMode,yoloMode:this.state.yoloMode}).then(e=>(this.disposed&&this.promotedAgent!==e&&e.dispose(),e))}return this.realAgentPromise}};function Co(e,t=` `){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`text`&&`text`in e&&typeof e.text==`string`).map(e=>e.text).join(t):``}function wo(e){return e.role===`assistant`?Co(e.content,`
|
|
83
|
+
|
|
84
|
+
`).trim():``}function To(e,t){let n=t;if(e[t]?.role===`assistant`){for(let r=t-1;r>=0;r--)if(e[r].role===`user`||e[r].role===`user-with-attachments`){n=r;break}}let r=e[n];return!r||r.role!==`user`&&r.role!==`user-with-attachments`?-1:n}function Eo(e){return e.role!==`user`&&e.role!==`user-with-attachments`?``:typeof e.content==`string`?e.content:Co(e.content,`
|
|
85
|
+
|
|
86
|
+
`)}async function Do(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,document.body.append(t),t.select(),document.execCommand(`copy`),t.remove()}function Oo(e){let t=e.find(e=>e.role===`user`||e.role===`user-with-attachments`);if(!t||t.role!==`user`&&t.role!==`user-with-attachments`)return`New chat`;let n=t.content,r=(typeof n==`string`?n:Co(n)).trim().replace(/\s+/g,` `);return r?r.length>46?`${r.slice(0,43)}...`:r:`New chat`}function ko(e){return e===`New chat`||e===W(`newChat`)}function Ao(e){return e.some(e=>e.role===`user`||e.role===`user-with-attachments`)}function jo(e){return Ao(e)&&e.some(e=>e.role===`assistant`)}function Mo(e){let t=e;if(t?.role!==`user`)return!1;let n=t.content;return(typeof n==`string`?n:Array.isArray(n)?n.filter(e=>e?.type===`text`).map(e=>String(e.text??``)).join(`
|
|
87
|
+
`):``).includes(`<compact_summary>`)}function No(e){let t=e.findIndex(Mo);return t<0?null:{summaryMessage:e[t],compactedUpToIndex:Math.min(e.length,t+2)}}function Po(e){let{storageRef:t,activeModelRef:n,agentAccessModeRef:r,activeProjectRef:i,defaultWorkspaceRef:a,setAgentAccessMode:o,switchActiveProject:s,sessions:c,refreshSessions:l}=e,u=(0,H.useRef)(null),d=(0,H.useRef)(new Map),f=(0,H.useRef)(`global`),p=(0,H.useRef)(void 0),m=(0,H.useRef)(`New chat`),h=(0,H.useRef)(void 0),g=(0,H.useRef)(null),_=(0,H.useRef)(e.onTaskComplete);(0,H.useEffect)(()=>{_.current=e.onTaskComplete});let[v,y]=(0,H.useState)(null),[b,x]=(0,H.useState)(),[S,C]=(0,H.useState)(`New chat`),[w,T]=(0,H.useState)(`global`),[E,D]=(0,H.useState)(),[ee,te]=(0,H.useState)({}),[O,k]=(0,H.useState)(0),A=(0,H.useCallback)((e,t)=>{!e||e===t||[...d.current.values()].some(t=>t.agent===e)||e.dispose()},[d]),j=(0,H.useCallback)(async e=>{if(p.current===e.sessionId){let t=e.agent.state.messages,n=e.title;ko(n)&&(n=Oo(t)),h.current=e.createdAt??new Date().toISOString(),m.current=n,C(n)}await l({broadcast:!0})},[l]),M=(0,H.useCallback)(e=>{A(u.current,e.agent),f.current=e.scope,p.current=e.sessionId,h.current=e.createdAt,m.current=e.title,T(e.scope),x(e.sessionId),C(e.title),D(e.project),u.current=e.agent,y(e.agent);let t=new URL(window.location.href);t.searchParams.set(`session`,e.sessionId),window.history.replaceState({},``,t)},[A]),ne=(0,H.useCallback)(async(e,s=X(),c)=>{let h=u.current,v=d.current.get(s);if(v)return c?.attachToView!==!1&&(A(h,v.agent),M(v)),v.agent;let y=c?.scope??f.current,b=y===`project`?c?.project??i.current:c?.project??a.current;if(y===`project`&&!b?.id)throw Error(`Cannot create project chat without an active project.`);let x=new Date().toISOString(),{model:S,thinkingLevel:w,tools:T,...E}=e??{},D=t.current,ee=D?await hn(D):{},O=S??ee.model??n.current,k=D?await wn(D,O):on(O),ne=w??ee.thinkingLevel??fn(k);n.current=k;let N=Z(c?.accessMode,c?.yoloMode??r.current);r.current=N,o(N);let P=await xo.create(s,{scope:y,projectId:y===`project`?b?.id:void 0,accessMode:N,yoloMode:Wt(N),model:k,thinkingLevel:ne,messages:E.messages??[],title:c?.title,contextCompaction:E.contextCompaction});E.contextCompaction&&!P.state.contextCompaction&&(P.state.contextCompaction=E.contextCompaction);let re=P.state.isStreaming?`running`:P.state.errorMessage?`error`:`idle`,F={sessionId:P.sessionId,agent:P,scope:y,project:b,title:c?.title??`New chat`,createdAt:c?.createdAt??x,status:re,startedAt:x,unsubscribe:()=>void 0};return F.unsubscribe=P.subscribe(e=>{if(e.type===`agent_start`&&(F.status=`running`,F.startedAt=F.startedAt??new Date().toISOString(),F.finishedAt=void 0,te(e=>({...e,[F.sessionId]:F.status}))),e.type===`message_end`&&(P.state.messages=[...P.state.messages]),e.type===`agent_end`){let t=F.status===`running`,n=e;F.status=n.status===`aborted`?`aborted`:n.errorMessage||P.state.errorMessage?`error`:`idle`,F.finishedAt=new Date().toISOString(),te(e=>({...e,[F.sessionId]:F.status})),j(F).catch(e=>V.error(`Failed to sync session UI:`,e)),t&&_.current?.(F.sessionId,F.title,F.status)}if(e.type===`title_updated`){let t=e;t.title&&(F.title=t.title),F.sessionId===p.current&&t.title&&(m.current=t.title,C(t.title)),l({broadcast:!0}).catch(e=>V.error(`Failed to refresh sessions:`,e))}if(e.type===`session_forked`){let t=e;if(!t.targetSessionId)return;l({broadcast:!0}).catch(e=>V.error(`Failed to refresh sessions:`,e)),g.current?.(t.targetSessionId,{title:t.title,createdAt:t.createdAt,scope:t.scope,projectId:t.projectId??void 0})}}),d.current.set(s,F),F.status!==`idle`&&te(e=>({...e,[F.sessionId]:F.status})),c?.attachToView!==!1&&(h instanceof So?h.promoteTo(F.agent):u.current===h&&A(h,F.agent),M(F)),c?.refreshSessions!==!1&&P.state.messages.length>0&&await l({broadcast:!0}),P},[M,A,l,j,t,n,r,i,a,o]),N=(0,H.useCallback)(async e=>{let i=t.current,o=i?await hn(i):{},s=o.model??n.current,c=i?await wn(i,s):on(s),l=o.thinkingLevel??fn(c);n.current=c;let d=e.scope,g=d===`project`?e.project:e.project??a.current,_=new So({scope:d,project:g,model:c,thinkingLevel:l,accessMode:r.current,yoloMode:Wt(r.current),createAgent:ne});A(u.current),f.current=d,p.current=void 0,h.current=void 0,m.current=`New chat`,T(d),x(void 0),C(`New chat`),D(g),u.current=_,y(_);let v=new URL(window.location.href);return v.searchParams.delete(`session`),window.history.replaceState({},``,v),_},[n,ne,a,A,t,r]),P=(0,H.useCallback)(async(e,r)=>{let a=d.current.get(e);if(a){if(a.scope===`project`&&a.project?.id&&i.current?.id!==a.project.id)try{await s(a.project.id)}catch(e){V.error(`Failed to switch project for running session:`,e)}M(a);return}let o=t.current;if(!o){await ne({tools:[]},e,{scope:r?.scope??`global`,attachToView:!0,createdAt:r?.createdAt,title:r?.title});return}let l=await o.sessions.get(e);if(!l)return;let u=c.find(t=>t.id===e)??await o.sessions.getMetadata(e),f=r?.scope??Gt(u??l),p=r?.projectId??u?.projectId??l.projectId,m;if(f===`project`&&p){let e=p;if(i.current?.id!==e)try{m=await s(e)}catch(e){V.error(`Failed to switch project for session:`,e),Y(W(`projectSwitchFailed`));return}else m=i.current}n.current=l.model,await ne({model:l.model,thinkingLevel:l.thinkingLevel,messages:l.messages,contextCompaction:l.contextCompaction??No(l.messages)},l.id,{scope:f,project:m,attachToView:!0,createdAt:l.createdAt??r?.createdAt,title:l.title??r?.title,accessMode:Z(l.accessMode,l.yoloMode),refreshSessions:!1})},[M,ne,c,s,t,n,i]);return(0,H.useEffect)(()=>{g.current=P},[P]),{agentRef:u,taskMapRef:d,currentSessionIdRef:p,currentChatScopeRef:f,agent:v,currentSessionId:b,currentTitle:S,chatScope:w,currentToolProject:E,taskStatuses:ee,chatPanelRevision:O,createAgent:ne,startDeferredSession:N,loadSession:P,syncSessionUI:j,setChatPanelRevision:k,setCurrentAgentMessages:(0,H.useCallback)(e=>{u.current&&(u.current.state.messages=e)},[]),updateCurrentAgentModel:(0,H.useCallback)(e=>{u.current&&(u.current.state.model=e,u.current.updateModel(e).catch(e=>{V.error(`Failed to sync model to server:`,e)}))},[]),setCurrentTitleRef:(0,H.useCallback)(e=>{m.current=e},[])}}var Fo=20;function Io(e){if(!e)return 0;let t=new Date(e).getTime();return Number.isNaN(t)?0:t}function Lo(e){return[...e].sort((e,t)=>{let n=Io(t.pinnedAt)-Io(e.pinnedAt);return n===0?e.pinnedAt&&!t.pinnedAt?-1:!e.pinnedAt&&t.pinnedAt?1:Io(t.lastModified)-Io(e.lastModified):n})}function Ro({backendRef:e,expandedProjectIds:t,externalProjectIds:n,onBroadcastSessionsChanged:r}){let[i,a]=(0,H.useState)({items:[],total:0,loading:!1}),[o,s]=(0,H.useState)({}),c=(0,H.useRef)(o),l=(0,H.useRef)(t),u=(0,H.useRef)(n??new Set);(0,H.useEffect)(()=>{c.current=o},[o]),(0,H.useEffect)(()=>{l.current=t},[t]),(0,H.useEffect)(()=>{u.current=n??new Set},[n]);let d=(0,H.useMemo)(()=>[...i.items,...Object.values(o).flatMap(e=>e.items)],[i.items,o]),f=(0,H.useCallback)(async t=>{let n=e.current;if(n){a(e=>({...e,loading:!0}));try{let e=await n.fetchPaginatedFromIndex(`sessions-metadata`,`lastModified`,{direction:`desc`,limit:Fo,offset:t,scope:`global`});a(n=>({items:Lo(t===0?e.values:[...n.items,...e.values]),total:e.total,loading:!1}))}catch{a(e=>({...e,loading:!1}))}}},[e]),p=(0,H.useCallback)(async(t,n)=>{let r=e.current;if(r){s(e=>{let n=e[t];return{...e,[t]:{...n??{items:[],total:0},loading:!0}}});try{let e=await r.fetchPaginatedFromIndex(`sessions-metadata`,`lastModified`,{direction:`desc`,limit:Fo,offset:n,scope:`project`,projectId:t});s(r=>{let i=r[t]?.items??[];return{...r,[t]:{items:Lo(n===0?e.values:[...i,...e.values]),total:e.total,loading:!1}}})}catch{s(e=>{let n=e[t];return{...e,[t]:{...n??{items:[],total:0},loading:!1}}})}}},[e]),m=(0,H.useCallback)(async e=>{await f(0);let t=new Set([...Object.keys(c.current),...l.current,...u.current]);t.size===0?s({}):(s(e=>{let n={};for(let r of t)n[r]={...e[r]??{items:[],total:0},loading:!0};return n}),await Promise.all([...t].map(e=>p(e,0)))),e?.broadcast&&r?.()},[f,p,r]),h=(0,H.useCallback)(e=>o[e]?.items??[],[o]),g=(0,H.useCallback)(e=>{let t=o[e];return t?t.items.length<t.total:!0},[o]),_=(0,H.useCallback)(e=>o[e]?.loading??!1,[o]),v=(0,H.useCallback)(e=>e in o,[o]),y=(0,H.useCallback)(()=>{f(i.items.length)},[i.items.length,f]),b=(0,H.useCallback)(e=>{let t=o[e];p(e,t?.items.length??0)},[p,o]);return{allLoadedSessions:d,globalSessions:i.items,sessionsForProject:h,globalHasMore:i.items.length<i.total,projectHasMore:g,globalLoading:i.loading,projectLoading:_,projectLoaded:v,loadGlobalSessions:f,loadProjectSessions:p,refreshSessions:m,loadMoreGlobal:y,loadMoreProject:b}}function zo(){let[e,t]=(0,H.useState)([]),n=(0,H.useCallback)(e=>{t(t=>[...t,{...e,id:X(),createdAt:Date.now()}])},[]);return{toasts:e,handleTaskComplete:(0,H.useCallback)((e,t,r)=>{n({sessionId:e,title:t,status:r})},[n]),addToast:n,dismissToast:(0,H.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[])}}var Bo=`tool-display-settings`,Vo={showToolDetails:!1,expandToolsByDefault:!1},Ho={...Vo};function Uo(e){if(!e||typeof e!=`object`)return{...Vo};let t=e;return{showToolDetails:t.showToolDetails===!0,expandToolsByDefault:t.expandToolsByDefault===!0}}function Wo(){return Ho}async function Go(e){let t=Uo(await e.settings.get(Bo));return Ho=t,t}async function Ko(e,t){let n=Uo(t);await e.settings.set(Bo,n),Ho=n}var qo=`font-size-settings`,Jo={baseFontSizePx:14,bodyFontSizePx:12,messageFontSizePx:16};function Yo(e,t,n,r){let i=Number(e);return Number.isFinite(i)?Math.min(r,Math.max(n,Math.round(i))):t}function Xo(e){if(!e||typeof e!=`object`)return{...Jo};let t=e;return{baseFontSizePx:Yo(t.baseFontSizePx,Jo.baseFontSizePx,12,18),bodyFontSizePx:Yo(t.bodyFontSizePx,Jo.bodyFontSizePx,11,16),messageFontSizePx:Yo(t.messageFontSizePx,Jo.messageFontSizePx,13,20)}}function Zo(e){if(typeof document>`u`)return;let t=Xo(e),n=document.documentElement;n.style.fontSize=`${t.baseFontSizePx}px`,n.style.setProperty(`--text-sm`,`${t.bodyFontSizePx}px`),n.style.setProperty(`--text-sm--line-height`,String(16/t.bodyFontSizePx)),n.style.setProperty(`--quickforge-message-font-size`,`${t.messageFontSizePx}px`),n.style.setProperty(`--quickforge-message-line-height`,`1.625`)}async function Qo(e){return Xo(await e.settings.get(qo))}async function $o(e){let t=await Qo(e);return Zo(t),t}async function es(e,t){let n=Xo(t);await e.settings.set(qo,n),Zo(n)}var ts=`appearance-settings`,ns={theme:`light`};function rs(e){return!e||typeof e!=`object`?{...ns}:{theme:e.theme===`dark`?`dark`:`light`}}function is(e){if(typeof document>`u`)return;let t=rs(e),n=document.documentElement;n.classList.toggle(`dark`,t.theme===`dark`),n.style.setProperty(`color-scheme`,t.theme)}function as(){return typeof document>`u`?ns.theme:document.documentElement.classList.contains(`dark`)?`dark`:`light`}async function os(e){return rs(await e.settings.get(ts))}async function ss(e){let t=await os(e);return is(t),t}async function cs(e,t){let n=rs(t);await e.settings.set(ts,n),is(n)}function ls({storageRef:e,backendRef:t,activeModelRef:n,agentAccessModeRef:r,activeProjectRef:i,setAgentAccessMode:a,taskMapRef:o,loadGlobalSessions:s,loadProject:c,initAgentAccessMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p}){let[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(),[v,y]=(0,H.useState)(0),b=(0,H.useRef)({loadGlobalSessions:s,loadProject:c,initAgentAccessMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p});return(0,H.useEffect)(()=>{b.current={loadGlobalSessions:s,loadProject:c,initAgentAccessMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p}}),(0,H.useEffect)(()=>{let s=!1;async function c(){let{loadGlobalSessions:o,loadProject:c,initAgentAccessMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p}=b.current;try{h(!1),_(void 0);let m=await un();if(s)return;e.current=m,p?.(m),t.current=m.backend,await Je(m),await Go(m),await ss(m),await $o(m),await Promise.all([o(0),c()]),r.current=await l(m);let g=await Sn(m),v=await hn(m);g&&(n.current=v.model??g);let y=new URLSearchParams(window.location.search).get(`session`);if(y){let e=await m.sessions.get(y);if(e){let t=await m.sessions.getMetadata(e.id),o=Gt(t??e),s;if(o===`project`&&(t?.projectId||e.projectId)){let n=t?.projectId??e.projectId;if(i.current?.id!==n)try{s=await u(n)}catch(e){V.error(`Failed to switch project for initial session:`,e),Y(W(`projectSwitchFailed`)),g?await d({model:v.model??g,thinkingLevel:v.thinkingLevel,tools:[]},X(),{scope:`global`,attachToView:!0}):f(!0),h(!0);return}else s=i.current}n.current=e.model;let c=Z(e.accessMode,e.yoloMode);r.current=c,a(c),await d({model:e.model,thinkingLevel:e.thinkingLevel,messages:e.messages,tools:[]},e.id,{scope:o,project:s,attachToView:!0,createdAt:e.createdAt,title:e.title,accessMode:c})}else g?await d({model:v.model??g,thinkingLevel:v.thinkingLevel,tools:[]},X(),{scope:`global`,attachToView:!0}):f(!0)}else g?await d({model:v.model??g,thinkingLevel:v.thinkingLevel,tools:[]},X(),{scope:`global`,attachToView:!0}):f(!0);h(!0)}catch(e){V.error(`Failed to bootstrap QuickForge:`,e),s||_(W(`localServiceUnavailableDescription`))}}c();let l=o.current;return()=>{s=!0;for(let e of l.values())e.unsubscribe(),e.agent.dispose();l.clear()}},[e,t,n,r,i,a,o,v]),{ready:m,startupError:g,retryBootstrap:(0,H.useCallback)(()=>{h(!1),_(void 0),y(e=>e+1)},[])}}var us=`update-check-settings`,ds={frequency:`startup`,lastCheckAt:null,ignoredVersion:null};function fs(e){if(!e||typeof e!=`object`)return{...ds};let t=e;return{frequency:[`startup`,`daily`,`weekly`,`off`].includes(t.frequency)?t.frequency:ds.frequency,lastCheckAt:typeof t.lastCheckAt==`string`?t.lastCheckAt:null,ignoredVersion:typeof t.ignoredVersion==`string`?t.ignoredVersion:null}}var ps=1440*60*1e3;function ms(e,t=Date.now()){switch(e.frequency){case`off`:return!1;case`startup`:return!0;case`daily`:case`weekly`:{if(!e.lastCheckAt)return!0;let n=Date.parse(e.lastCheckAt);if(Number.isNaN(n))return!0;let r=e.frequency===`daily`?ps:7*ps;return t-n>=r}default:return!1}}async function hs(e){return fs(await e.settings.get(us))}async function gs(e,t){await e.settings.set(us,fs(t))}var _s={status:`idle`,updateAvailable:!1};function vs(e,t){let[n,r]=(0,H.useState)(_s),i=(0,H.useRef)(!1);return(0,H.useEffect)(()=>{if(!t||i.current)return;let n=e.current;n&&(i.current=!0,(async()=>{let e;try{e=await hs(n)}catch(e){V.error(`Failed to load update-check settings:`,e);return}if(ms(e)){r(e=>({...e,status:`checking`}));try{let t=await fetch(`/api/system/update/check`,{cache:`no-store`});if(!t.ok){r(e=>({...e,status:`error`}));return}let i=await t.json(),a=i.updateAvailable&&i.latestVersion!==e.ignoredVersion;try{await gs(n,{...e,lastCheckAt:new Date().toISOString()})}catch(e){V.error(`Failed to persist last update-check time:`,e)}r({status:`done`,currentVersion:i.currentVersion,latestVersion:i.latestVersion,updateAvailable:a})}catch(e){V.error(`Startup update check failed:`,e),r(e=>({...e,status:`error`}))}}})())},[t,e]),{result:n,dismissUpdate:(0,H.useCallback)(()=>{let t=e.current,i=n.latestVersion;!t||!i||(r(e=>({...e,updateAvailable:!1})),(async()=>{try{await gs(t,{...await hs(t),ignoredVersion:i})}catch(e){V.error(`Failed to persist ignored update version:`,e)}})())},[n.latestVersion,e])}}var ys={openai:{name:`OpenAI`,baseUrl:`https://api.openai.com/v1`,protocol:`openai-completions`,modelId:`gpt-4o`},deepseek:{name:`DeepSeek`,baseUrl:`https://api.deepseek.com/v1`,protocol:`openai-completions`,modelId:`deepseek-chat`},glm:{name:`Zhipu GLM`,baseUrl:`https://open.bigmodel.cn/api/paas/v4`,protocol:`openai-completions`,modelId:`glm-4-plus`},ollama:{name:`Ollama`,baseUrl:`http://localhost:11434/v1`,protocol:`openai-completions`,modelId:`llama3.1`},litellm:{name:$t.name,baseUrl:$t.baseUrl,protocol:`openai-completions`,modelId:$t.modelId}},bs=[{key:`openai`,label:W(`presetOpenai`)},{key:`deepseek`,label:W(`presetDeepseek`)},{key:`glm`,label:W(`presetGlm`)},{key:`ollama`,label:W(`presetOllama`)},{key:`litellm`,label:W(`presetLitellm`)},{key:`custom`,label:W(`presetCustom`)}],xs=()=>({modelId:``,contextWindow:$t.contextWindow,maxTokens:$t.maxTokens,reasoning:!0,open:!1}),Ss=()=>({name:$t.name,baseUrl:$t.baseUrl,apiKey:``,headerRows:[],protocol:`openai-completions`,models:[xs()]}),Cs=class extends De{providers=[];form=Ss();editingProviderId;formOpen=!1;loading=!0;apiKeyVisible=!1;advancedOpen=!1;activePreset=``;testing=!1;testResult=`idle`;testError=``;autoEditProviderName=null;async connectedCallback(){if(super.connectedCallback(),await this.loadProviders(),this.autoEditProviderName){let e=this.providers.find(e=>e.name===this.autoEditProviderName);e&&await this.openEditForm(e),this.autoEditProviderName=null}}getTabName(){return W(`customModels`)}async loadProviders(){this.loading=!0,this.requestUpdate();try{this.providers=await B().customProviders.getAll()}catch(e){V.error(`Failed to load custom providers:`,e),this.providers=[]}finally{this.loading=!1,this.requestUpdate()}}resetTestState(){this.testing=!1,this.testResult=`idle`,this.testError=``}openAddForm(){this.editingProviderId=void 0,this.form=Ss(),this.apiKeyVisible=!1,this.advancedOpen=!1,this.activePreset=``,this.resetTestState(),this.formOpen=!0,this.requestUpdate()}async openEditForm(e){let t=await B().providerKeys.get(e.name)??e.apiKey??``,n=e.models??[],r=n.length>0?n.map(e=>({modelId:e.id,contextWindow:e.contextWindow??$t.contextWindow,maxTokens:e.maxTokens??$t.maxTokens,reasoning:e.reasoning===!0,open:!1})):[xs()],i=n[0]?.headers??{},a=Object.entries(i).map(([e,t])=>({key:e,value:String(t)}));this.editingProviderId=e.id,this.form={providerId:e.id,id:e.id,name:e.name,baseUrl:e.baseUrl,apiKey:t,headerRows:a,protocol:e.type===`anthropic-messages`?`anthropic-messages`:`openai-completions`,models:r},this.apiKeyVisible=!1,this.advancedOpen=a.length>0||e.type===`anthropic-messages`,this.activePreset=``,this.resetTestState(),this.formOpen=!0,this.requestUpdate()}closeForm(){this.formOpen=!1,this.editingProviderId=void 0,this.form=Ss(),this.apiKeyVisible=!1,this.advancedOpen=!1,this.activePreset=``,this.resetTestState(),this.requestUpdate()}toggleApiKeyVisibility(){this.apiKeyVisible=!this.apiKeyVisible,this.requestUpdate()}updateForm(e,t){this.form={...this.form,[e]:t},(e===`name`||e===`baseUrl`)&&(this.activePreset=``),this.resetTestState(),this.requestUpdate()}updateModelField(e,t,n){let r=this.form.models.map((r,i)=>i===e?{...r,[t]:n}:r);this.form={...this.form,models:r},t===`modelId`&&(this.activePreset=``,this.resetTestState()),this.requestUpdate()}addModelRow(){this.form={...this.form,models:[...this.form.models,xs()]},this.requestUpdate()}removeModelRow(e){let t=this.form.models.filter((t,n)=>n!==e);this.form={...this.form,models:t},this.requestUpdate()}toggleModelExpanded(e){let t=this.form.models.map((t,n)=>n===e?{...t,open:!t.open}:t);this.form={...this.form,models:t},this.requestUpdate()}addHeaderRow(){this.form={...this.form,headerRows:[...this.form.headerRows,{key:``,value:``}]},this.requestUpdate()}updateHeaderRow(e,t,n){let r=this.form.headerRows.map((r,i)=>i===e?{...r,[t]:n}:r);this.form={...this.form,headerRows:r},this.requestUpdate()}removeHeaderRow(e){let t=this.form.headerRows.filter((t,n)=>n!==e);this.form={...this.form,headerRows:t},this.requestUpdate()}applyPreset(e){if(this.activePreset=e,e===`custom`)this.form={...this.form,name:``,baseUrl:``,protocol:`openai-completions`,models:[xs()]};else{let t=ys[e];this.form={...this.form,name:t.name,baseUrl:t.baseUrl,protocol:t.protocol,models:[{...xs(),modelId:t.modelId,open:!1}]}}this.resetTestState(),this.requestUpdate()}buildHeadersFromRows(){let e={};for(let t of this.form.headerRows){let n=t.key.trim(),r=t.value.trim();n&&r&&(e[n]=r)}return e}buildModel(e,t){let n=this.form.name.trim(),r=this.form.baseUrl.trim(),i=e.reasoning===!0,a=r.includes(`api.deepseek.com`);return on({id:e.modelId,name:`${e.modelId} (${n})`,api:this.form.protocol,provider:n,baseUrl:r.replace(/\/$/,``),reasoning:i,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:Number(e.contextWindow)||$t.contextWindow,maxTokens:Number(e.maxTokens)||$t.maxTokens,headers:Object.keys(t).length>0?t:void 0,thinkingLevelMap:a&&i?{low:`high`,medium:`high`,high:`high`,xhigh:`max`}:void 0,compat:this.form.protocol===`openai-completions`?{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:i,supportsUsageInStreaming:!1,supportsStrictMode:!1,maxTokensField:`max_tokens`,...a&&i?{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:`deepseek`}:{}}:void 0})}async testConnection(){let e=this.form.baseUrl.trim(),t=this.form.models.find(e=>e.modelId.trim());if(!e||!t){this.testing=!1,this.testResult=`fail`,this.testError=W(`testRequiresFields`),this.requestUpdate();return}let n=this.buildHeadersFromRows(),r=this.buildModel(t,n);this.testing=!0,this.testResult=`idle`,this.testError=``,this.requestUpdate();try{let e=await(await fetch(`/api/models/test-connection`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({model:r,apiKey:this.form.apiKey.trim()})})).json().catch(()=>({}));e?.ok?(this.testResult=`ok`,this.testError=``):(this.testResult=`fail`,this.testError=e?.error||W(`connectionFailed`))}catch(e){this.testResult=`fail`,this.testError=e?.message||W(`connectionFailed`)}finally{this.testing=!1,this.requestUpdate()}}async saveModel(){let e=this.form.name.trim(),t=this.form.baseUrl.trim();if(!e||!t){Y(W(`fillProviderBaseUrlModel`));return}let n=this.form.models.filter(e=>e.modelId.trim());if(n.length===0){Y(W(`atLeastOneModel`));return}let r=n.map(e=>e.modelId.trim());if(new Set(r).size!==r.length){Y(W(`duplicateModelId`));return}let i=this.buildHeadersFromRows(),a=n.map(e=>this.buildModel(e,i)),o=this.form.apiKey.trim(),s=this.editingProviderId?this.providers.find(e=>e.id===this.editingProviderId):void 0,c={id:this.editingProviderId??X(),name:e,type:this.form.protocol,baseUrl:a[0].baseUrl,apiKey:o||void 0,models:a};try{let e=B();await e.customProviders.set(c),s&&s.name!==c.name&&await e.providerKeys.delete(s.name),o?await e.providerKeys.set(c.name,o):await e.providerKeys.delete(c.name),this.closeForm(),await this.loadProviders()}catch(e){V.error(`Failed to save custom model:`,e),Y(W(`saveCustomModelFailed`))}}async deleteProvider(e){if(await J({description:W(`confirmDeleteProvider`,{name:e.name}),confirmLabel:W(`confirmDelete`),cancelLabel:W(`cancel`),variant:`destructive`}))try{let t=B();await t.customProviders.delete(e.id),await t.providerKeys.delete(e.name),await this.loadProviders()}catch(e){V.error(`Failed to delete custom provider:`,e),Y(W(`deleteFailed`))}}renderProvider(e){let t=e.models??[],n=t.length;return z`
|
|
88
|
+
<div class="rounded-lg border border-border p-4">
|
|
89
|
+
<div class="flex items-start justify-between gap-4">
|
|
90
|
+
<div class="min-w-0 flex-1">
|
|
91
|
+
<div class="text-sm font-medium text-foreground">${e.name}</div>
|
|
92
|
+
<div class="mt-1 break-all text-xs text-muted-foreground">${e.baseUrl}</div>
|
|
93
|
+
<div class="mt-2 text-xs text-muted-foreground">
|
|
94
|
+
${W(`providerProtocol`)}: ${e.type===`anthropic-messages`?`Anthropic Messages`:`OpenAI Compatible`}
|
|
95
|
+
</div>
|
|
96
|
+
${n===0?z`<div class="mt-1 text-xs text-muted-foreground">${W(`noModelAdded`)}</div>`:z`
|
|
97
|
+
<div class="mt-2 text-xs text-muted-foreground">${W(`modelsCount`,{count:n})}</div>
|
|
98
|
+
<div class="mt-1 flex flex-wrap gap-1">
|
|
99
|
+
${t.map(e=>z`
|
|
100
|
+
<span class="inline-flex items-center gap-1 rounded-md border border-border bg-muted px-2 py-0.5 text-xs text-foreground">
|
|
101
|
+
<span class="font-medium">${e.id}</span>
|
|
102
|
+
<span class="text-muted-foreground">${e.contextWindow}/${e.maxTokens}</span>
|
|
103
|
+
</span>
|
|
104
|
+
`)}
|
|
105
|
+
</div>
|
|
106
|
+
`}
|
|
107
|
+
</div>
|
|
108
|
+
<div class="flex shrink-0 gap-2">
|
|
109
|
+
<button
|
|
110
|
+
class="rounded-md px-3 py-1.5 text-sm hover:bg-secondary"
|
|
111
|
+
type="button"
|
|
112
|
+
@click=${()=>this.openEditForm(e)}
|
|
113
|
+
>
|
|
114
|
+
${W(`editModel`)}
|
|
115
|
+
</button>
|
|
116
|
+
<button
|
|
117
|
+
class="rounded-md px-3 py-1.5 text-sm text-destructive hover:bg-secondary"
|
|
118
|
+
type="button"
|
|
119
|
+
@click=${()=>this.deleteProvider(e)}
|
|
120
|
+
>
|
|
121
|
+
${W(`delete`)}
|
|
122
|
+
</button>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
`}renderPresetChips(){return z`
|
|
127
|
+
<div class="grid gap-1.5">
|
|
128
|
+
<span class="text-xs text-muted-foreground">${W(`presets`)}</span>
|
|
129
|
+
<div class="flex flex-wrap gap-1.5">
|
|
130
|
+
${bs.map(e=>z`
|
|
131
|
+
<button
|
|
132
|
+
class="rounded-full border px-3 py-1 text-xs ${this.activePreset===e.key?`border-primary bg-primary text-primary-foreground`:`border-border text-muted-foreground hover:border-foreground/40 hover:text-foreground`}"
|
|
133
|
+
type="button"
|
|
134
|
+
@click=${()=>this.applyPreset(e.key)}
|
|
135
|
+
>
|
|
136
|
+
${e.label}
|
|
137
|
+
</button>
|
|
138
|
+
`)}
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
`}renderModelRow(e,t){let n=e.open===!0;return z`
|
|
142
|
+
<div class="rounded-md border border-border">
|
|
143
|
+
<div class="flex items-center gap-2 p-2">
|
|
144
|
+
<button
|
|
145
|
+
class="shrink-0 inline-flex size-6 items-center justify-center rounded text-xs text-muted-foreground hover:bg-secondary hover:text-foreground"
|
|
146
|
+
type="button"
|
|
147
|
+
title=${W(`expandModel`)}
|
|
148
|
+
aria-expanded=${n?`true`:`false`}
|
|
149
|
+
@click=${()=>this.toggleModelExpanded(t)}
|
|
150
|
+
>
|
|
151
|
+
${n?`▾`:`▸`}
|
|
152
|
+
</button>
|
|
153
|
+
<input
|
|
154
|
+
class="min-w-0 flex-1 rounded-md border border-input bg-background px-3 py-1.5 text-sm"
|
|
155
|
+
.value=${e.modelId}
|
|
156
|
+
@input=${e=>this.updateModelField(t,`modelId`,e.target.value)}
|
|
157
|
+
placeholder=${W(`modelIdPlaceholder`)}
|
|
158
|
+
/>
|
|
159
|
+
${this.form.models.length>1?z`
|
|
160
|
+
<button
|
|
161
|
+
class="shrink-0 rounded px-1.5 py-0.5 text-xs text-muted-foreground hover:bg-secondary hover:text-destructive"
|
|
162
|
+
type="button"
|
|
163
|
+
title=${W(`delete`)}
|
|
164
|
+
@click=${()=>this.removeModelRow(t)}
|
|
165
|
+
>
|
|
166
|
+
✕
|
|
167
|
+
</button>
|
|
168
|
+
`:``}
|
|
169
|
+
</div>
|
|
170
|
+
${n?z`
|
|
171
|
+
<div class="grid gap-3 border-t border-border p-3">
|
|
172
|
+
<div class="grid grid-cols-2 gap-3">
|
|
173
|
+
<label class="grid gap-1 text-xs">
|
|
174
|
+
<span class="text-muted-foreground">${W(`contextWindow`)}</span>
|
|
175
|
+
<input
|
|
176
|
+
class="rounded-md border border-input bg-background px-3 py-1.5 text-sm"
|
|
177
|
+
.value=${String(e.contextWindow)}
|
|
178
|
+
type="number"
|
|
179
|
+
@input=${e=>this.updateModelField(t,`contextWindow`,Number(e.target.value))}
|
|
180
|
+
/>
|
|
181
|
+
</label>
|
|
182
|
+
<label class="grid gap-1 text-xs">
|
|
183
|
+
<span class="text-muted-foreground">${W(`maxTokens`)}</span>
|
|
184
|
+
<input
|
|
185
|
+
class="rounded-md border border-input bg-background px-3 py-1.5 text-sm"
|
|
186
|
+
.value=${String(e.maxTokens)}
|
|
187
|
+
type="number"
|
|
188
|
+
@input=${e=>this.updateModelField(t,`maxTokens`,Number(e.target.value))}
|
|
189
|
+
/>
|
|
190
|
+
</label>
|
|
191
|
+
</div>
|
|
192
|
+
<label class="mt-1 flex items-center gap-2 text-xs">
|
|
193
|
+
<input
|
|
194
|
+
class="rounded border-border"
|
|
195
|
+
type="checkbox"
|
|
196
|
+
.checked=${e.reasoning}
|
|
197
|
+
@change=${e=>this.updateModelField(t,`reasoning`,e.target.checked)}
|
|
198
|
+
/>
|
|
199
|
+
<span class="text-muted-foreground">${W(`reasoningModel`)}</span>
|
|
200
|
+
</label>
|
|
201
|
+
</div>
|
|
202
|
+
`:``}
|
|
203
|
+
</div>
|
|
204
|
+
`}renderHeadersEditor(){return z`
|
|
205
|
+
<div class="grid gap-1.5">
|
|
206
|
+
<span class="inline-flex items-center gap-1.5 text-xs text-muted-foreground">
|
|
207
|
+
${W(`customHeaders`)}
|
|
208
|
+
<quickforge-info-tip .label=${W(`customHeadersHelp`)}></quickforge-info-tip>
|
|
209
|
+
</span>
|
|
210
|
+
${this.form.headerRows.length===0?z``:z`
|
|
211
|
+
<div class="grid gap-2">
|
|
212
|
+
${this.form.headerRows.map((e,t)=>z`
|
|
213
|
+
<div class="grid grid-cols-[1fr_1fr_auto] items-center gap-2">
|
|
214
|
+
<input
|
|
215
|
+
class="rounded-md border border-input bg-background px-3 py-1.5 text-sm"
|
|
216
|
+
.value=${e.key}
|
|
217
|
+
@input=${e=>this.updateHeaderRow(t,`key`,e.target.value)}
|
|
218
|
+
placeholder=${W(`headerName`)}
|
|
219
|
+
/>
|
|
220
|
+
<input
|
|
221
|
+
class="rounded-md border border-input bg-background px-3 py-1.5 text-sm"
|
|
222
|
+
.value=${e.value}
|
|
223
|
+
@input=${e=>this.updateHeaderRow(t,`value`,e.target.value)}
|
|
224
|
+
placeholder=${W(`headerValue`)}
|
|
225
|
+
/>
|
|
226
|
+
<button
|
|
227
|
+
class="shrink-0 rounded px-1.5 py-1.5 text-xs text-muted-foreground hover:bg-secondary hover:text-destructive"
|
|
228
|
+
type="button"
|
|
229
|
+
title=${W(`removeHeader`)}
|
|
230
|
+
@click=${()=>this.removeHeaderRow(t)}
|
|
231
|
+
>
|
|
232
|
+
✕
|
|
233
|
+
</button>
|
|
234
|
+
</div>
|
|
235
|
+
`)}
|
|
236
|
+
</div>
|
|
237
|
+
`}
|
|
238
|
+
<button
|
|
239
|
+
class="justify-self-start rounded px-1 py-0.5 text-xs text-muted-foreground hover:text-foreground"
|
|
240
|
+
type="button"
|
|
241
|
+
@click=${()=>this.addHeaderRow()}
|
|
242
|
+
>
|
|
243
|
+
+ ${W(`addHeader`)}
|
|
244
|
+
</button>
|
|
245
|
+
</div>
|
|
246
|
+
`}renderTestStatus(){return this.testResult===`idle`&&!this.testing?z``:this.testing?z`<span class="text-xs text-muted-foreground">${W(`testingConnection`)}</span>`:this.testResult===`ok`?z`<span class="text-xs text-green-600">✓ ${W(`connectionOk`)}</span>`:z`<span class="break-all text-xs text-destructive">✗ ${this.testError||W(`connectionFailed`)}</span>`}renderForm(){return z`
|
|
247
|
+
<div class="rounded-lg border border-border p-4">
|
|
248
|
+
<div class="mb-4 text-sm font-semibold text-foreground">
|
|
249
|
+
${this.editingProviderId?W(`editCustomModel`):W(`addCustomModel`)}
|
|
250
|
+
</div>
|
|
251
|
+
|
|
252
|
+
<div class="grid gap-4">
|
|
253
|
+
${this.renderPresetChips()}
|
|
254
|
+
|
|
255
|
+
<label class="grid gap-1.5 text-sm">
|
|
256
|
+
<span class="text-foreground">${W(`providerName`)}</span>
|
|
257
|
+
<input
|
|
258
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
259
|
+
.value=${this.form.name}
|
|
260
|
+
@input=${e=>this.updateForm(`name`,e.target.value)}
|
|
261
|
+
placeholder=${W(`providerNamePlaceholder`)}
|
|
262
|
+
/>
|
|
263
|
+
</label>
|
|
264
|
+
|
|
265
|
+
<label class="grid gap-1.5 text-sm">
|
|
266
|
+
<span class="text-foreground">Base URL</span>
|
|
267
|
+
<input
|
|
268
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
269
|
+
.value=${this.form.baseUrl}
|
|
270
|
+
@input=${e=>this.updateForm(`baseUrl`,e.target.value)}
|
|
271
|
+
placeholder=${this.form.protocol===`anthropic-messages`?`e.g., https://api.anthropic.com`:`e.g., http://localhost:4000/v1`}
|
|
272
|
+
/>
|
|
273
|
+
</label>
|
|
274
|
+
|
|
275
|
+
<label class="grid gap-1.5 text-sm">
|
|
276
|
+
<span class="text-foreground">${W(`apiKey`)}</span>
|
|
277
|
+
<div class="relative">
|
|
278
|
+
<input
|
|
279
|
+
class="w-full rounded-md border border-input bg-background px-3 py-2 pr-10 text-sm"
|
|
280
|
+
.value=${this.form.apiKey}
|
|
281
|
+
type=${this.apiKeyVisible?`text`:`password`}
|
|
282
|
+
@input=${e=>this.updateForm(`apiKey`,e.target.value)}
|
|
283
|
+
placeholder=${W(`apiKeyPlaceholder`)}
|
|
284
|
+
/>
|
|
285
|
+
<button
|
|
286
|
+
class="absolute inset-y-0 right-0 flex w-10 items-center justify-center rounded-r-md text-muted-foreground hover:text-foreground/85 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
|
287
|
+
type="button"
|
|
288
|
+
title=${this.apiKeyVisible?W(`hideApiKey`):W(`showApiKey`)}
|
|
289
|
+
aria-label=${this.apiKeyVisible?W(`hideApiKey`):W(`showApiKey`)}
|
|
290
|
+
aria-pressed=${this.apiKeyVisible?`true`:`false`}
|
|
291
|
+
@click=${()=>this.toggleApiKeyVisibility()}
|
|
292
|
+
>
|
|
293
|
+
${this.apiKeyVisible?z`<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.53 13.53 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" y1="2" x2="22" y2="22"/><path d="M8.53 8.53A5 5 0 0 0 12 17a5 5 0 0 0 3.47-8.53"/></svg>`:z`<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`}
|
|
294
|
+
</button>
|
|
295
|
+
</div>
|
|
296
|
+
</label>
|
|
297
|
+
|
|
298
|
+
<div class="grid gap-2">
|
|
299
|
+
<div class="flex items-center justify-between">
|
|
300
|
+
<span class="text-sm font-medium text-foreground">${W(`modelsList`)}</span>
|
|
301
|
+
<button
|
|
302
|
+
class="rounded-md px-2 py-1 text-xs hover:bg-secondary"
|
|
303
|
+
type="button"
|
|
304
|
+
@click=${()=>this.addModelRow()}
|
|
305
|
+
>
|
|
306
|
+
+ ${W(`addModel`)}
|
|
307
|
+
</button>
|
|
308
|
+
</div>
|
|
309
|
+
${this.form.models.map((e,t)=>this.renderModelRow(e,t))}
|
|
310
|
+
</div>
|
|
311
|
+
|
|
312
|
+
<button
|
|
313
|
+
class="flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground"
|
|
314
|
+
type="button"
|
|
315
|
+
aria-expanded=${this.advancedOpen?`true`:`false`}
|
|
316
|
+
@click=${()=>{this.advancedOpen=!this.advancedOpen,this.requestUpdate()}}
|
|
317
|
+
>
|
|
318
|
+
<span>${this.advancedOpen?`▾`:`▸`}</span>
|
|
319
|
+
${W(`providerAdvanced`)}
|
|
320
|
+
</button>
|
|
321
|
+
|
|
322
|
+
${this.advancedOpen?z`
|
|
323
|
+
<div class="grid gap-4 rounded-md border border-border p-3">
|
|
324
|
+
<label class="grid gap-1.5 text-sm">
|
|
325
|
+
<span class="inline-flex items-center gap-1.5 text-foreground">
|
|
326
|
+
${W(`protocolType`)}
|
|
327
|
+
<quickforge-info-tip .label=${W(`protocolHelp`)}></quickforge-info-tip>
|
|
328
|
+
</span>
|
|
329
|
+
<select
|
|
330
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
331
|
+
.value=${this.form.protocol}
|
|
332
|
+
@change=${e=>this.updateForm(`protocol`,e.target.value)}
|
|
333
|
+
>
|
|
334
|
+
<option value="openai-completions">OpenAI Compatible / Chat Completions</option>
|
|
335
|
+
<option value="anthropic-messages">Anthropic Messages</option>
|
|
336
|
+
</select>
|
|
337
|
+
</label>
|
|
338
|
+
${this.renderHeadersEditor()}
|
|
339
|
+
</div>
|
|
340
|
+
`:``}
|
|
341
|
+
</div>
|
|
342
|
+
|
|
343
|
+
<div class="mt-4 flex items-center gap-2">
|
|
344
|
+
<span class="mr-auto">${this.renderTestStatus()}</span>
|
|
345
|
+
<button
|
|
346
|
+
class="rounded-md px-3 py-2 text-sm hover:bg-secondary"
|
|
347
|
+
type="button"
|
|
348
|
+
@click=${()=>this.closeForm()}
|
|
349
|
+
>
|
|
350
|
+
${W(`cancel`)}
|
|
351
|
+
</button>
|
|
352
|
+
<button
|
|
353
|
+
class="rounded-md px-3 py-2 text-sm hover:bg-secondary ${this.testing?`opacity-50 pointer-events-none`:``}"
|
|
354
|
+
type="button"
|
|
355
|
+
?disabled=${this.testing}
|
|
356
|
+
@click=${()=>this.testConnection()}
|
|
357
|
+
>
|
|
358
|
+
${W(`testConnection`)}
|
|
359
|
+
</button>
|
|
360
|
+
<button
|
|
361
|
+
class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground"
|
|
362
|
+
type="button"
|
|
363
|
+
@click=${()=>this.saveModel()}
|
|
364
|
+
>
|
|
365
|
+
${W(`save`)}
|
|
366
|
+
</button>
|
|
367
|
+
</div>
|
|
368
|
+
</div>
|
|
369
|
+
`}render(){return z`
|
|
370
|
+
<div class="flex flex-col gap-6">
|
|
371
|
+
<div class="flex items-center justify-between gap-4">
|
|
372
|
+
<div>
|
|
373
|
+
<h3 class="mb-2 inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
374
|
+
${W(`customModelsTitle`)}
|
|
375
|
+
<quickforge-info-tip .label=${W(`customModelsDescription`)}></quickforge-info-tip>
|
|
376
|
+
</h3>
|
|
377
|
+
</div>
|
|
378
|
+
<button
|
|
379
|
+
class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground"
|
|
380
|
+
type="button"
|
|
381
|
+
@click=${()=>this.openAddForm()}
|
|
382
|
+
>
|
|
383
|
+
${W(`addModel`)}
|
|
384
|
+
</button>
|
|
385
|
+
</div>
|
|
386
|
+
|
|
387
|
+
${this.formOpen?this.renderForm():``}
|
|
388
|
+
|
|
389
|
+
${this.loading?z`<div class="py-8 text-center text-sm text-muted-foreground">${W(`loading`)}</div>`:this.providers.length===0?z`<div class="py-8 text-center text-sm text-muted-foreground">${W(`noCustomModels`)}</div>`:z`<div class="flex flex-col gap-3">${this.providers.map(e=>this.renderProvider(e))}</div>`}
|
|
390
|
+
</div>
|
|
391
|
+
`}},ws=`quickforge-custom-providers-only-tab`;customElements.get(ws)||customElements.define(ws,Cs);function Ts(e){let t=document.createElement(ws);return e&&(t.autoEditProviderName=e),t}var Es=class extends De{selectedLanguage=Ke();getTabName(){return W(`language`)}updateLanguage(e){this.selectedLanguage=e===`zh`?`zh`:`en`,this.requestUpdate()}async applyLanguage(){await Ye(B(),this.selectedLanguage)||Y(W(`noLanguageChange`))}render(){return z`
|
|
392
|
+
<div class="flex flex-col gap-6">
|
|
393
|
+
<div>
|
|
394
|
+
<h3 class="mb-2 inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
395
|
+
${W(`language`)}
|
|
396
|
+
<quickforge-info-tip .label=${W(`languageDescription`)}></quickforge-info-tip>
|
|
397
|
+
</h3>
|
|
398
|
+
</div>
|
|
399
|
+
|
|
400
|
+
<label class="grid max-w-sm gap-1.5 text-sm">
|
|
401
|
+
<span class="text-foreground">${W(`displayLanguage`)}</span>
|
|
402
|
+
<select
|
|
403
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
404
|
+
.value=${this.selectedLanguage}
|
|
405
|
+
@change=${e=>this.updateLanguage(e.target.value)}
|
|
406
|
+
>
|
|
407
|
+
<option value="zh">${W(`simplifiedChinese`)}</option>
|
|
408
|
+
<option value="en">${W(`english`)}</option>
|
|
409
|
+
</select>
|
|
410
|
+
</label>
|
|
411
|
+
|
|
412
|
+
<div>
|
|
413
|
+
<button
|
|
414
|
+
class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground"
|
|
415
|
+
type="button"
|
|
416
|
+
@click=${()=>this.applyLanguage()}
|
|
417
|
+
>
|
|
418
|
+
${W(`apply`)}
|
|
419
|
+
</button>
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
422
|
+
`}},Ds=`quickforge-language-settings-tab`;customElements.get(Ds)||customElements.define(Ds,Es);function Os(){return document.createElement(Ds)}var ks=[{value:`light`,label:()=>W(`lightTheme`)},{value:`dark`,label:()=>W(`darkTheme`)}],As=[{value:`small`,label:()=>W(`fontSizeSmall`),settings:{baseFontSizePx:13,bodyFontSizePx:11}},{value:`default`,label:()=>W(`fontSizeDefault`),settings:Jo},{value:`large`,label:()=>W(`fontSizeLarge`),settings:{baseFontSizePx:15,bodyFontSizePx:13}},{value:`extraLarge`,label:()=>W(`fontSizeExtraLarge`),settings:{baseFontSizePx:16,bodyFontSizePx:14}}],js=[{value:`small`,label:()=>W(`fontSizeSmall`),messageFontSizePx:14},{value:`default`,label:()=>W(`fontSizeDefault`),messageFontSizePx:Jo.messageFontSizePx},{value:`large`,label:()=>W(`fontSizeLarge`),messageFontSizePx:17},{value:`extraLarge`,label:()=>W(`fontSizeExtraLarge`),messageFontSizePx:18}],Ms=class extends De{theme=as();baseFontSizePx=Jo.baseFontSizePx;bodyFontSizePx=Jo.bodyFontSizePx;messageFontSizePx=Jo.messageFontSizePx;advancedFontSizeOpen=!1;loading=!0;fontSizeSaved=!1;error=``;fontSizePreviewTimer=null;getTabName(){return W(`appearance`)}async connectedCallback(){super.connectedCallback(),await this.loadSettings()}disconnectedCallback(){super.disconnectedCallback(),this.fontSizePreviewTimer&&=(clearTimeout(this.fontSizePreviewTimer),null)}async loadSettings(){this.loading=!0,this.error=``,this.requestUpdate();try{let e=B(),[t,n]=await Promise.all([os(e),Qo(e)]);this.theme=t.theme,this.baseFontSizePx=n.baseFontSizePx,this.bodyFontSizePx=n.bodyFontSizePx,this.messageFontSizePx=n.messageFontSizePx,this.advancedFontSizeOpen=!this.currentInterfaceFontSizePreset()||!this.currentMessageFontSizePreset()}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.loading=!1,this.requestUpdate()}}async selectTheme(e){if(this.theme!==e){this.theme=e,this.requestUpdate();try{await cs(B(),{theme:e}),this.error=``,this.requestUpdate()}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`),this.requestUpdate()}}}currentFontSizeSettings(){return Xo({baseFontSizePx:this.baseFontSizePx,bodyFontSizePx:this.bodyFontSizePx,messageFontSizePx:this.messageFontSizePx})}currentInterfaceFontSizePreset(){let e=this.currentFontSizeSettings();return As.find(t=>t.settings.baseFontSizePx===e.baseFontSizePx&&t.settings.bodyFontSizePx===e.bodyFontSizePx)}currentMessageFontSizePreset(){let e=this.currentFontSizeSettings();return js.find(t=>t.messageFontSizePx===e.messageFontSizePx)}async applyAndSaveFontSize(e){let t=Xo(e);this.baseFontSizePx=t.baseFontSizePx,this.bodyFontSizePx=t.bodyFontSizePx,this.messageFontSizePx=t.messageFontSizePx,this.fontSizeSaved=!1,Zo(t),this.requestUpdate();try{await es(B(),t),this.fontSizeSaved=!0,this.error=``,this.requestUpdate()}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`),this.requestUpdate()}}async selectInterfaceFontSizePreset(e){this.advancedFontSizeOpen=!1,await this.applyAndSaveFontSize({...this.currentFontSizeSettings(),...e.settings})}async selectMessageFontSizePreset(e){this.advancedFontSizeOpen=!1,await this.applyAndSaveFontSize({...this.currentFontSizeSettings(),messageFontSizePx:e.messageFontSizePx})}scheduleFontSizePreview(){this.fontSizePreviewTimer&&clearTimeout(this.fontSizePreviewTimer),this.fontSizePreviewTimer=setTimeout(()=>{this.fontSizePreviewTimer=null,Zo(this.currentFontSizeSettings()),this.requestUpdate()},120)}updateBaseFontSize(e){this.baseFontSizePx=Number(e)||Jo.baseFontSizePx,this.fontSizeSaved=!1,this.scheduleFontSizePreview()}updateBodyFontSize(e){this.bodyFontSizePx=Number(e)||Jo.bodyFontSizePx,this.fontSizeSaved=!1,this.scheduleFontSizePreview()}updateMessageFontSize(e){this.messageFontSizePx=Number(e)||Jo.messageFontSizePx,this.fontSizeSaved=!1,this.scheduleFontSizePreview()}async saveFontSize(){await this.applyAndSaveFontSize(this.currentFontSizeSettings())}async resetFontSize(){await this.applyAndSaveFontSize(Jo)}toggleAdvancedFontSize(){this.advancedFontSizeOpen=!this.advancedFontSizeOpen,this.requestUpdate()}renderThemeOption(e){let t=this.theme===e.value,n=e.value===`dark`;return z`
|
|
423
|
+
<button
|
|
424
|
+
type="button"
|
|
425
|
+
class="group flex flex-col gap-2 rounded-lg border p-3 text-left transition-colors ${t?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground/30`}"
|
|
426
|
+
@click=${()=>this.selectTheme(e.value)}
|
|
427
|
+
>
|
|
428
|
+
<div
|
|
429
|
+
class="flex h-16 overflow-hidden rounded-md border ${n?`border-zinc-700 bg-zinc-900`:`border-zinc-200 bg-white`}"
|
|
430
|
+
>
|
|
431
|
+
<div class="w-1/4 ${n?`bg-zinc-800`:`bg-zinc-100`}"></div>
|
|
432
|
+
<div class="flex flex-1 flex-col gap-1.5 p-2">
|
|
433
|
+
<div class="h-1.5 w-3/4 rounded-full ${n?`bg-zinc-600`:`bg-zinc-300`}"></div>
|
|
434
|
+
<div class="h-1.5 w-1/2 rounded-full ${n?`bg-zinc-700`:`bg-zinc-200`}"></div>
|
|
435
|
+
<div class="h-1.5 w-2/3 rounded-full ${n?`bg-zinc-700`:`bg-zinc-200`}"></div>
|
|
436
|
+
</div>
|
|
437
|
+
</div>
|
|
438
|
+
<div class="flex items-center justify-between">
|
|
439
|
+
<span class="text-sm font-medium text-foreground">${e.label()}</span>
|
|
440
|
+
<span
|
|
441
|
+
class="flex size-4 items-center justify-center rounded-full border ${t?`border-primary bg-primary`:`border-muted-foreground/40`}"
|
|
442
|
+
>
|
|
443
|
+
${t?z`<svg class="size-3 text-primary-foreground" viewBox="0 0 12 12" fill="none">
|
|
444
|
+
<path
|
|
445
|
+
d="M2.5 6l2.5 2.5 4.5-5"
|
|
446
|
+
stroke="currentColor"
|
|
447
|
+
stroke-width="1.6"
|
|
448
|
+
stroke-linecap="round"
|
|
449
|
+
stroke-linejoin="round"
|
|
450
|
+
/>
|
|
451
|
+
</svg>`:null}
|
|
452
|
+
</span>
|
|
453
|
+
</div>
|
|
454
|
+
</button>
|
|
455
|
+
`}renderInterfaceFontSizePreset(e){let t=this.currentInterfaceFontSizePreset()?.value===e.value;return this.renderFontSizePresetButton(t,e.label(),()=>this.selectInterfaceFontSizePreset(e))}renderMessageFontSizePreset(e){let t=this.currentMessageFontSizePreset()?.value===e.value;return this.renderFontSizePresetButton(t,e.label(),()=>this.selectMessageFontSizePreset(e))}renderFontSizePresetButton(e,t,n){return z`
|
|
456
|
+
<button
|
|
457
|
+
type="button"
|
|
458
|
+
class="rounded-md border px-3 py-2 text-sm transition-colors ${e?`border-primary bg-primary text-primary-foreground`:`border-border bg-background text-foreground hover:bg-accent`}"
|
|
459
|
+
@click=${n}
|
|
460
|
+
>
|
|
461
|
+
${t}
|
|
462
|
+
</button>
|
|
463
|
+
`}render(){if(this.loading)return z`<div class="text-sm text-muted-foreground">${W(`loading`)}</div>`;let e=this.currentInterfaceFontSizePreset(),t=this.currentMessageFontSizePreset();return z`
|
|
464
|
+
<div class="flex flex-col gap-6">
|
|
465
|
+
<div>
|
|
466
|
+
<h3 class="mb-2 inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
467
|
+
${W(`appearance`)}
|
|
468
|
+
<quickforge-info-tip .label=${W(`appearanceDescription`)}></quickforge-info-tip>
|
|
469
|
+
</h3>
|
|
470
|
+
</div>
|
|
471
|
+
|
|
472
|
+
<div class="grid max-w-xl gap-3 rounded-lg border border-border p-4">
|
|
473
|
+
<div>
|
|
474
|
+
<h4 class="inline-flex items-center gap-1.5 text-sm font-medium text-foreground">
|
|
475
|
+
${W(`theme`)}
|
|
476
|
+
<quickforge-info-tip .label=${W(`themeDescription`)}></quickforge-info-tip>
|
|
477
|
+
</h4>
|
|
478
|
+
</div>
|
|
479
|
+
<div class="grid grid-cols-2 gap-3">
|
|
480
|
+
${ks.map(e=>this.renderThemeOption(e))}
|
|
481
|
+
</div>
|
|
482
|
+
</div>
|
|
483
|
+
|
|
484
|
+
<div class="grid max-w-xl gap-4 rounded-lg border border-border p-4">
|
|
485
|
+
<div>
|
|
486
|
+
<h4 class="inline-flex items-center gap-1.5 text-sm font-medium text-foreground">
|
|
487
|
+
${W(`fontSize`)}
|
|
488
|
+
<quickforge-info-tip .label=${W(`fontSizeDescription`)}></quickforge-info-tip>
|
|
489
|
+
</h4>
|
|
490
|
+
</div>
|
|
491
|
+
|
|
492
|
+
<div class="grid gap-2">
|
|
493
|
+
<div class="flex items-center gap-2 text-sm text-foreground">
|
|
494
|
+
<span>${W(`interfaceFontSize`)}</span>
|
|
495
|
+
${e?null:z`<span class="text-xs text-muted-foreground">${W(`customFontSize`)}</span>`}
|
|
496
|
+
</div>
|
|
497
|
+
<div class="grid max-w-md grid-cols-2 gap-2 sm:grid-cols-4">
|
|
498
|
+
${As.map(e=>this.renderInterfaceFontSizePreset(e))}
|
|
499
|
+
</div>
|
|
500
|
+
</div>
|
|
501
|
+
|
|
502
|
+
<div class="grid gap-2">
|
|
503
|
+
<div class="flex items-center gap-2 text-sm text-foreground">
|
|
504
|
+
<span>${W(`messageFontSize`)}</span>
|
|
505
|
+
<quickforge-info-tip .label=${W(`messageFontSizeNote`)}></quickforge-info-tip>
|
|
506
|
+
${t?null:z`<span class="text-xs text-muted-foreground">${W(`customFontSize`)}</span>`}
|
|
507
|
+
</div>
|
|
508
|
+
<div class="grid max-w-md grid-cols-2 gap-2 sm:grid-cols-4">
|
|
509
|
+
${js.map(e=>this.renderMessageFontSizePreset(e))}
|
|
510
|
+
</div>
|
|
511
|
+
</div>
|
|
512
|
+
|
|
513
|
+
<button
|
|
514
|
+
type="button"
|
|
515
|
+
class="inline-flex w-fit items-center gap-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground"
|
|
516
|
+
@click=${()=>this.toggleAdvancedFontSize()}
|
|
517
|
+
>
|
|
518
|
+
<span>${this.advancedFontSizeOpen?`▾`:`▸`}</span>
|
|
519
|
+
<span>${W(`advancedFontSizeSettings`)}</span>
|
|
520
|
+
</button>
|
|
521
|
+
|
|
522
|
+
${this.advancedFontSizeOpen?z`
|
|
523
|
+
<div class="grid gap-3 border-t border-border pt-3">
|
|
524
|
+
<div class="grid gap-3 md:grid-cols-3">
|
|
525
|
+
<label class="grid max-w-xs gap-1.5 text-sm">
|
|
526
|
+
<span class="text-foreground">${W(`baseFontSize`)}</span>
|
|
527
|
+
<input
|
|
528
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
529
|
+
type="number"
|
|
530
|
+
min="12"
|
|
531
|
+
max="18"
|
|
532
|
+
step="1"
|
|
533
|
+
.value=${String(this.baseFontSizePx)}
|
|
534
|
+
@input=${e=>this.updateBaseFontSize(e.target.value)}
|
|
535
|
+
/>
|
|
536
|
+
</label>
|
|
537
|
+
<label class="grid max-w-xs gap-1.5 text-sm">
|
|
538
|
+
<span class="inline-flex items-center gap-1.5 text-foreground">
|
|
539
|
+
${W(`bodyFontSize`)}
|
|
540
|
+
<quickforge-info-tip .label=${W(`bodyFontSizeNote`)}></quickforge-info-tip>
|
|
541
|
+
</span>
|
|
542
|
+
<input
|
|
543
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
544
|
+
type="number"
|
|
545
|
+
min="11"
|
|
546
|
+
max="16"
|
|
547
|
+
step="1"
|
|
548
|
+
.value=${String(this.bodyFontSizePx)}
|
|
549
|
+
@input=${e=>this.updateBodyFontSize(e.target.value)}
|
|
550
|
+
/>
|
|
551
|
+
</label>
|
|
552
|
+
<label class="grid max-w-xs gap-1.5 text-sm">
|
|
553
|
+
<span class="inline-flex items-center gap-1.5 text-foreground">
|
|
554
|
+
${W(`messageFontSize`)}
|
|
555
|
+
<quickforge-info-tip .label=${W(`messageFontSizeNote`)}></quickforge-info-tip>
|
|
556
|
+
</span>
|
|
557
|
+
<input
|
|
558
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
559
|
+
type="number"
|
|
560
|
+
min="13"
|
|
561
|
+
max="20"
|
|
562
|
+
step="1"
|
|
563
|
+
.value=${String(this.messageFontSizePx)}
|
|
564
|
+
@input=${e=>this.updateMessageFontSize(e.target.value)}
|
|
565
|
+
/>
|
|
566
|
+
</label>
|
|
567
|
+
</div>
|
|
568
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
569
|
+
<button
|
|
570
|
+
class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground"
|
|
571
|
+
type="button"
|
|
572
|
+
@click=${()=>this.saveFontSize()}
|
|
573
|
+
>
|
|
574
|
+
${W(`save`)}
|
|
575
|
+
</button>
|
|
576
|
+
<button
|
|
577
|
+
class="rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground hover:bg-accent"
|
|
578
|
+
type="button"
|
|
579
|
+
@click=${()=>this.resetFontSize()}
|
|
580
|
+
>
|
|
581
|
+
${W(`restoreDefault`)}
|
|
582
|
+
</button>
|
|
583
|
+
</div>
|
|
584
|
+
</div>
|
|
585
|
+
`:null}
|
|
586
|
+
|
|
587
|
+
${this.fontSizeSaved?z`<span class="text-sm text-muted-foreground">${W(`fontSizeSaved`)}</span>`:null}
|
|
588
|
+
</div>
|
|
589
|
+
|
|
590
|
+
${this.error?z`<span class="text-sm text-destructive">${this.error}</span>`:null}
|
|
591
|
+
</div>
|
|
592
|
+
`}},Ns=`quickforge-appearance-settings-tab`;customElements.get(Ns)||customElements.define(Ns,Ms);function Ps(){return document.createElement(Ns)}var Fs=`auto-compact-settings`,Is={enabled:!1,thresholdPercent:80,keepRecentTurns:2,minSourceChars:1600,requireConfirmation:!0};function Ls(e,t,n,r){let i=Number(e);return Number.isFinite(i)?Math.min(r,Math.max(n,Math.round(i))):t}function Rs(e){if(!e||typeof e!=`object`)return{...Is};let t=e;return{enabled:t.enabled===!0,thresholdPercent:Ls(t.thresholdPercent,Is.thresholdPercent,50,95),keepRecentTurns:Ls(t.keepRecentTurns,Is.keepRecentTurns,1,20),minSourceChars:Ls(t.minSourceChars,Is.minSourceChars,0,2e5),requireConfirmation:t.requireConfirmation!==!1}}async function zs(e){return Rs(await e.settings.get(Fs))}async function Bs(e,t){await e.settings.set(Fs,Rs(t))}var Vs=[{value:`off`,label:()=>W(`thinkingOff`)},{value:`low`,label:()=>W(`thinkingLow`)},{value:`medium`,label:()=>W(`thinkingMedium`)},{value:`high`,label:()=>W(`thinkingHigh`)},{value:`xhigh`,label:()=>W(`thinkingXHigh`)}];function Hs(e){return(e??``).trim().replace(/\/$/,``)}function Us(e){return JSON.stringify([e.provider,e.id,e.api,Hs(e.baseUrl)])}function Ws(e){return`${e.provider} / ${e.id}`}var Gs=class extends De{models=[];selectedModel;thinkingLevel=`off`;showToolDetails=!1;expandToolsByDefault=!1;autoCompactEnabled=!1;autoCompactRequireConfirmation=!0;autoCompactThresholdPercent=80;autoCompactThresholdPercentInput=`80`;autoCompactKeepRecentTurns=2;loading=!0;saved=!1;error=``;getTabName(){return W(`defaultOptions`)}async connectedCallback(){super.connectedCallback(),await this.loadSettings()}updated(){this.syncSelectValues()}syncSelectValues(){let e=this.querySelector(`[data-default-model-select]`);e&&this.selectedModel&&(e.value=Us(this.selectedModel));let t=this.querySelector(`[data-default-thinking-select]`);t&&(t.value=this.thinkingLevel)}async loadSettings(){this.loading=!0,this.error=``,this.requestUpdate();try{let e=B(),[t,n,r,i]=await Promise.all([xn(e),hn(e),Go(e),zs(e)]);this.models=t,this.selectedModel=n.model?t.find(e=>Us(e)===Us(n.model))??n.model:t[0],this.thinkingLevel=n.thinkingLevel??fn(this.selectedModel),this.showToolDetails=r.showToolDetails,this.expandToolsByDefault=r.expandToolsByDefault,this.autoCompactEnabled=i.enabled,this.autoCompactRequireConfirmation=i.requireConfirmation,this.autoCompactThresholdPercent=i.thresholdPercent,this.autoCompactThresholdPercentInput=String(i.thresholdPercent),this.autoCompactKeepRecentTurns=i.keepRecentTurns}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.loading=!1,this.requestUpdate()}}updateModel(e){let t=this.models.find(t=>Us(t)===e);this.selectedModel=t,this.thinkingLevel=fn(t),this.saved=!1,this.requestUpdate()}updateThinkingLevel(e){this.thinkingLevel=Vs.some(t=>t.value===e)?e:`off`,this.saved=!1,this.requestUpdate()}updateShowToolDetails(e){this.showToolDetails=e,this.saved=!1,this.requestUpdate()}updateExpandToolsByDefault(e){this.expandToolsByDefault=e,this.saved=!1,this.requestUpdate()}updateAutoCompactEnabled(e){this.autoCompactEnabled=e,this.saved=!1,this.requestUpdate()}updateAutoCompactRequireConfirmation(e){this.autoCompactRequireConfirmation=e,this.saved=!1,this.requestUpdate()}updateAutoCompactThresholdPercent(e){this.autoCompactThresholdPercentInput=e;let t=Number(e);e!==``&&Number.isFinite(t)&&(this.autoCompactThresholdPercent=t),this.saved=!1,this.requestUpdate()}updateAutoCompactKeepRecentTurns(e){this.autoCompactKeepRecentTurns=Number(e)||2,this.saved=!1,this.requestUpdate()}modelOptions(){if(!this.selectedModel)return this.models;let e=Us(this.selectedModel);return this.models.some(t=>Us(t)===e)?this.models:[this.selectedModel,...this.models]}async save(){try{let e=this.selectedModel?.reasoning?this.thinkingLevel:`off`;await mn(B(),{model:this.selectedModel,thinkingLevel:e}),await Ko(B(),{showToolDetails:this.showToolDetails,expandToolsByDefault:this.expandToolsByDefault}),await Bs(B(),{enabled:this.autoCompactEnabled,thresholdPercent:this.autoCompactThresholdPercent,keepRecentTurns:this.autoCompactKeepRecentTurns,minSourceChars:1600,requireConfirmation:this.autoCompactRequireConfirmation}),await this.loadSettings(),this.saved=!0,this.error=``,this.requestUpdate()}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`),this.requestUpdate()}}render(){return this.loading?z`<div class="text-sm text-muted-foreground">${W(`loading`)}</div>`:z`
|
|
593
|
+
<div class="flex flex-col gap-6">
|
|
594
|
+
<div>
|
|
595
|
+
<h3 class="mb-2 inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
596
|
+
${W(`defaultOptions`)}
|
|
597
|
+
<quickforge-info-tip .label=${W(`defaultOptionsDescription`)}></quickforge-info-tip>
|
|
598
|
+
</h3>
|
|
599
|
+
</div>
|
|
600
|
+
|
|
601
|
+
<label class="grid max-w-md gap-1.5 text-sm">
|
|
602
|
+
<span class="text-foreground">${W(`defaultModel`)}</span>
|
|
603
|
+
<select
|
|
604
|
+
data-default-model-select
|
|
605
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
606
|
+
.value=${this.selectedModel?Us(this.selectedModel):``}
|
|
607
|
+
@change=${e=>this.updateModel(e.target.value)}
|
|
608
|
+
>
|
|
609
|
+
${this.modelOptions().length===0?z`<option value="">${W(`noModelAvailable`)}</option>`:this.modelOptions().map(e=>z`
|
|
610
|
+
<option .value=${Us(e)}>${Ws(e)}</option>
|
|
611
|
+
`)}
|
|
612
|
+
</select>
|
|
613
|
+
</label>
|
|
614
|
+
|
|
615
|
+
<label class="grid max-w-sm gap-1.5 text-sm">
|
|
616
|
+
<span class="text-foreground">${W(`defaultThinkingLevel`)}</span>
|
|
617
|
+
<select
|
|
618
|
+
data-default-thinking-select
|
|
619
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm disabled:opacity-60"
|
|
620
|
+
.value=${this.thinkingLevel}
|
|
621
|
+
?disabled=${!this.selectedModel?.reasoning}
|
|
622
|
+
@change=${e=>this.updateThinkingLevel(e.target.value)}
|
|
623
|
+
>
|
|
624
|
+
${Vs.map(e=>z`
|
|
625
|
+
<option .value=${e.value}>${e.label()}</option>
|
|
626
|
+
`)}
|
|
627
|
+
</select>
|
|
628
|
+
${this.selectedModel?.reasoning?null:z`<span class="text-xs text-muted-foreground">${W(`thinkingRequiresReasoningModel`)}</span>`}
|
|
629
|
+
</label>
|
|
630
|
+
|
|
631
|
+
<div class="grid max-w-xl gap-3 rounded-lg border border-border p-4">
|
|
632
|
+
<div>
|
|
633
|
+
<h4 class="inline-flex items-center gap-1.5 text-sm font-medium text-foreground">
|
|
634
|
+
${W(`toolDisplay`)}
|
|
635
|
+
<quickforge-info-tip .label=${W(`showToolDetailsDescription`)}></quickforge-info-tip>
|
|
636
|
+
</h4>
|
|
637
|
+
</div>
|
|
638
|
+
<label class="flex items-center gap-2 text-sm text-foreground">
|
|
639
|
+
<input
|
|
640
|
+
type="checkbox"
|
|
641
|
+
class="size-4 rounded border-input"
|
|
642
|
+
.checked=${this.showToolDetails}
|
|
643
|
+
@change=${e=>this.updateShowToolDetails(e.target.checked)}
|
|
644
|
+
/>
|
|
645
|
+
<span>${W(`showToolDetails`)}</span>
|
|
646
|
+
</label>
|
|
647
|
+
<label class="flex items-center gap-2 text-sm text-foreground">
|
|
648
|
+
<input
|
|
649
|
+
type="checkbox"
|
|
650
|
+
class="size-4 rounded border-input"
|
|
651
|
+
.checked=${this.expandToolsByDefault}
|
|
652
|
+
@change=${e=>this.updateExpandToolsByDefault(e.target.checked)}
|
|
653
|
+
/>
|
|
654
|
+
<span>${W(`expandToolsByDefault`)}</span>
|
|
655
|
+
</label>
|
|
656
|
+
</div>
|
|
657
|
+
|
|
658
|
+
<div class="grid max-w-xl gap-3 rounded-lg border border-border p-4">
|
|
659
|
+
<div>
|
|
660
|
+
<h4 class="inline-flex items-center gap-1.5 text-sm font-medium text-foreground">
|
|
661
|
+
${W(`contextManagement`)}
|
|
662
|
+
<quickforge-info-tip .label=${W(`autoCompactDescription`)}></quickforge-info-tip>
|
|
663
|
+
</h4>
|
|
664
|
+
</div>
|
|
665
|
+
<label class="flex items-center gap-2 text-sm text-foreground">
|
|
666
|
+
<input
|
|
667
|
+
type="checkbox"
|
|
668
|
+
class="size-4 rounded border-input"
|
|
669
|
+
.checked=${this.autoCompactEnabled}
|
|
670
|
+
@change=${e=>this.updateAutoCompactEnabled(e.target.checked)}
|
|
671
|
+
/>
|
|
672
|
+
<span class="inline-flex items-center gap-1.5">
|
|
673
|
+
${W(`autoCompactEnabled`)}
|
|
674
|
+
<quickforge-info-tip .label=${W(`autoCompactTriggerNote`)}></quickforge-info-tip>
|
|
675
|
+
</span>
|
|
676
|
+
</label>
|
|
677
|
+
<label class="flex items-center gap-2 text-sm text-foreground">
|
|
678
|
+
<input
|
|
679
|
+
type="checkbox"
|
|
680
|
+
class="size-4 rounded border-input disabled:opacity-60"
|
|
681
|
+
.checked=${this.autoCompactRequireConfirmation}
|
|
682
|
+
?disabled=${!this.autoCompactEnabled}
|
|
683
|
+
@change=${e=>this.updateAutoCompactRequireConfirmation(e.target.checked)}
|
|
684
|
+
/>
|
|
685
|
+
<span>${W(`autoCompactRequireConfirmation`)}</span>
|
|
686
|
+
</label>
|
|
687
|
+
<label class="grid max-w-xs gap-1.5 text-sm">
|
|
688
|
+
<span class="text-foreground">${W(`autoCompactThresholdPercent`)}</span>
|
|
689
|
+
<input
|
|
690
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm disabled:opacity-60"
|
|
691
|
+
type="number"
|
|
692
|
+
min="50"
|
|
693
|
+
max="95"
|
|
694
|
+
step="1"
|
|
695
|
+
.value=${this.autoCompactThresholdPercentInput}
|
|
696
|
+
?disabled=${!this.autoCompactEnabled}
|
|
697
|
+
@input=${e=>this.updateAutoCompactThresholdPercent(e.target.value)}
|
|
698
|
+
/>
|
|
699
|
+
</label>
|
|
700
|
+
<label class="grid max-w-xs gap-1.5 text-sm">
|
|
701
|
+
<span class="inline-flex items-center gap-1.5 text-foreground">
|
|
702
|
+
${W(`autoCompactKeepRecentTurns`)}
|
|
703
|
+
<quickforge-info-tip .label=${W(`autoCompactHistoryPreserved`)}></quickforge-info-tip>
|
|
704
|
+
</span>
|
|
705
|
+
<input
|
|
706
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm disabled:opacity-60"
|
|
707
|
+
type="number"
|
|
708
|
+
min="1"
|
|
709
|
+
max="20"
|
|
710
|
+
step="1"
|
|
711
|
+
.value=${String(this.autoCompactKeepRecentTurns)}
|
|
712
|
+
?disabled=${!this.autoCompactEnabled}
|
|
713
|
+
@input=${e=>this.updateAutoCompactKeepRecentTurns(e.target.value)}
|
|
714
|
+
/>
|
|
715
|
+
</label>
|
|
716
|
+
</div>
|
|
717
|
+
|
|
718
|
+
<div class="flex items-center gap-3">
|
|
719
|
+
<button
|
|
720
|
+
class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-60"
|
|
721
|
+
type="button"
|
|
722
|
+
?disabled=${!this.selectedModel}
|
|
723
|
+
@click=${()=>this.save()}
|
|
724
|
+
>
|
|
725
|
+
${W(`saveDefaultOptions`)}
|
|
726
|
+
</button>
|
|
727
|
+
${this.saved?z`<span class="text-sm text-muted-foreground">${W(`defaultOptionsSaved`)}</span>`:null}
|
|
728
|
+
${this.error?z`<span class="text-sm text-destructive">${this.error}</span>`:null}
|
|
729
|
+
</div>
|
|
730
|
+
</div>
|
|
731
|
+
`}},Ks=`quickforge-default-options-settings-tab`;customElements.get(Ks)||customElements.define(Ks,Gs);function qs(){return document.createElement(Ks)}var Js=`quickforge-backup`,Ys=[{id:`settings`,countKey:`settings`,label:()=>W(`restoreSettings`),description:()=>W(`restoreSettingsDescription`)},{id:`mcp`,countKey:`mcp`,label:()=>W(`restoreMcp`),description:()=>W(`restoreMcpDescription`)},{id:`providerKeys`,countKey:`providerKeys`,label:()=>W(`restoreProviderKeys`),description:()=>W(`restoreProviderKeysDescription`)},{id:`customProviders`,countKey:`customProviders`,label:()=>W(`restoreCustomProviders`),description:()=>W(`restoreCustomProvidersDescription`)},{id:`projects`,countKey:`projects`,label:()=>W(`restoreProjects`),description:()=>W(`restoreProjectsDescription`)},{id:`scheduledTasks`,countKey:`scheduledTasks`,label:()=>W(`restoreScheduledTasks`),description:()=>W(`restoreScheduledTasksDescription`)},{id:`conversations`,countKey:`sessions`,label:()=>W(`restoreConversations`),description:()=>W(`restoreConversationsDescription`)}];function Xs(e,t){let n=new Blob([`${JSON.stringify(t,null,2)}\n`],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function Zs(){return new Date().toISOString().replace(/[:.]/g,`-`)}function Qs(e){return e?Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(`, `):``}function $s(e){return Ys.filter(t=>(e.sections?.[t.countKey]??0)>0)}var ec=class extends De{exportScope=`all`;includeSecrets=!1;busy=!1;message=``;error=``;safetyBackupPath=``;pendingImport=null;getTabName(){return W(`backupRestore`)}setScope(e){this.exportScope=e===`config`||e===`sessions`?e:`all`,this.exportScope===`sessions`&&(this.includeSecrets=!1),this.clearStatus(),this.requestUpdate()}clearStatus(){this.message=``,this.error=``,this.safetyBackupPath=``}setIncludeSecrets(e){this.includeSecrets=e&&this.exportScope!==`sessions`,this.message=``,this.error=``,this.requestUpdate()}async exportBackup(){if(!(this.includeSecrets&&!await J({description:W(`backupExportSecretsConfirm`),confirmLabel:W(`exportBackup`),cancelLabel:W(`cancel`)}))){this.busy=!0,this.clearStatus(),this.requestUpdate();try{let e=new URLSearchParams({scope:this.exportScope,includeSecrets:this.includeSecrets?`1`:`0`}),t=await fetch(`/api/backup/export?${e.toString()}`,{cache:`no-store`}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||W(`backupExportFailed`));let r=this.includeSecrets?`with-secrets`:`no-secrets`;Xs(`${Js}-${this.exportScope}-${r}-${Zs()}.json`,n),this.message=W(`backupExported`)}catch(e){this.error=e instanceof Error?e.message:W(`backupExportFailed`)}finally{this.busy=!1,this.requestUpdate()}}}async inspectBackup(e){let t=await fetch(`/api/backup/inspect`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||W(`backupInspectFailed`));if(!n)throw Error(W(`backupInspectFailed`));return n}async importBackupFromFile(e){this.busy=!0,this.clearStatus(),this.pendingImport=null,this.requestUpdate();try{let t=await e.text(),n=JSON.parse(t),r=await this.inspectBackup(n),i=new Set($s(r).map(e=>e.id));this.pendingImport={backup:n,inspect:r,selectedSections:i,mode:`replace`},this.message=W(`backupInspected`)}catch(e){this.error=e instanceof Error?e.message:W(`backupImportFailed`)}finally{this.busy=!1,this.requestUpdate()}}togglePendingSection(e,t){this.pendingImport&&(t?this.pendingImport.selectedSections.add(e):this.pendingImport.selectedSections.delete(e),this.message=``,this.error=``,this.requestUpdate())}setRestoreMode(e){this.pendingImport&&(this.pendingImport.mode=e,this.message=``,this.error=``,this.requestUpdate())}cancelPendingImport(){this.pendingImport=null,this.message=``,this.error=``,this.requestUpdate()}async confirmPendingImport(){if(this.pendingImport){if(this.pendingImport.selectedSections.size===0){this.error=W(`selectAtLeastOneRestoreSection`),this.requestUpdate();return}this.busy=!0,this.clearStatus(),this.requestUpdate();try{let e=await fetch(`/api/backup/import`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({backup:this.pendingImport.backup,sections:[...this.pendingImport.selectedSections],mode:this.pendingImport.mode})}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||W(`backupImportFailed`));let n=Qs(t?.summary);this.safetyBackupPath=t?.safetyBackupPath||``,this.pendingImport=null,this.message=n?`${W(`backupImported`)} ${n}`:W(`backupImported`),window.setTimeout(()=>window.location.reload(),1500)}catch(e){this.error=e instanceof Error?e.message:W(`backupImportFailed`)}finally{this.busy=!1,this.requestUpdate()}}}handleFileChange(e){let t=e.target,n=t.files?.[0];t.value=``,n&&this.importBackupFromFile(n)}renderPendingImport(){if(!this.pendingImport)return null;let{inspect:e,selectedSections:t}=this.pendingImport,n=$s(e);return z`
|
|
732
|
+
<section class="rounded-lg border border-amber-500/30 bg-amber-500/5 p-4">
|
|
733
|
+
<h4 class="text-sm font-semibold text-foreground">${W(`backupInspectTitle`)}</h4>
|
|
734
|
+
<dl class="mt-3 grid gap-1 text-sm text-muted-foreground">
|
|
735
|
+
<div><span class="text-foreground">${W(`backupInspectExportedAt`)}:</span> ${e.exportedAt||`-`}</div>
|
|
736
|
+
<div><span class="text-foreground">${W(`backupInspectVersion`)}:</span> ${e.version??`-`}</div>
|
|
737
|
+
<div><span class="text-foreground">${W(`backupInspectScope`)}:</span> ${e.scope||`-`}</div>
|
|
738
|
+
<div><span class="text-foreground">${W(`backupInspectSecrets`)}:</span> ${e.includeSecrets?W(`yes`):W(`no`)}</div>
|
|
739
|
+
</dl>
|
|
740
|
+
|
|
741
|
+
${e.warnings?.length?z`
|
|
742
|
+
<div class="mt-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300">
|
|
743
|
+
${e.warnings.map(e=>z`<div>⚠ ${e}</div>`)}
|
|
744
|
+
</div>
|
|
745
|
+
`:null}
|
|
746
|
+
|
|
747
|
+
<div class="mt-4">
|
|
748
|
+
<div class="text-sm font-medium text-foreground">${W(`restoreMode`)}</div>
|
|
749
|
+
<div class="mt-2 grid gap-2">
|
|
750
|
+
<label class="flex items-start gap-2 rounded-md border border-border bg-background/60 p-3 text-sm ${this.pendingImport.mode===`replace`?`border-primary`:``}">
|
|
751
|
+
<input
|
|
752
|
+
class="mt-1"
|
|
753
|
+
type="radio"
|
|
754
|
+
name="restore-mode"
|
|
755
|
+
.checked=${this.pendingImport.mode===`replace`}
|
|
756
|
+
?disabled=${this.busy}
|
|
757
|
+
@change=${()=>this.setRestoreMode(`replace`)}
|
|
758
|
+
/>
|
|
759
|
+
<span>
|
|
760
|
+
<span class="block text-foreground">${W(`restoreModeReplace`)}</span>
|
|
761
|
+
<span class="block text-xs text-muted-foreground">${W(`restoreModeReplaceDescription`)}</span>
|
|
762
|
+
</span>
|
|
763
|
+
</label>
|
|
764
|
+
<label class="flex items-start gap-2 rounded-md border border-border bg-background/60 p-3 text-sm ${this.pendingImport.mode===`merge`?`border-primary`:``}">
|
|
765
|
+
<input
|
|
766
|
+
class="mt-1"
|
|
767
|
+
type="radio"
|
|
768
|
+
name="restore-mode"
|
|
769
|
+
.checked=${this.pendingImport.mode===`merge`}
|
|
770
|
+
?disabled=${this.busy}
|
|
771
|
+
@change=${()=>this.setRestoreMode(`merge`)}
|
|
772
|
+
/>
|
|
773
|
+
<span>
|
|
774
|
+
<span class="block text-foreground">${W(`restoreModeMerge`)}</span>
|
|
775
|
+
<span class="block text-xs text-muted-foreground">${W(`restoreModeMergeDescription`)}</span>
|
|
776
|
+
</span>
|
|
777
|
+
</label>
|
|
778
|
+
</div>
|
|
779
|
+
</div>
|
|
780
|
+
|
|
781
|
+
<div class="mt-4">
|
|
782
|
+
<div class="text-sm font-medium text-foreground">${W(`selectRestoreSections`)}</div>
|
|
783
|
+
<div class="mt-2 grid gap-2">
|
|
784
|
+
${n.map(n=>z`
|
|
785
|
+
<label class="flex items-start gap-2 rounded-md border border-border bg-background/60 p-3 text-sm">
|
|
786
|
+
<input
|
|
787
|
+
class="mt-1"
|
|
788
|
+
type="checkbox"
|
|
789
|
+
.checked=${t.has(n.id)}
|
|
790
|
+
?disabled=${this.busy}
|
|
791
|
+
@change=${e=>this.togglePendingSection(n.id,e.target.checked)}
|
|
792
|
+
/>
|
|
793
|
+
<span>
|
|
794
|
+
<span class="block text-foreground">${n.label()} (${e.sections?.[n.countKey]??0})</span>
|
|
795
|
+
<span class="block text-xs text-muted-foreground">${n.description()}</span>
|
|
796
|
+
</span>
|
|
797
|
+
</label>
|
|
798
|
+
`)}
|
|
799
|
+
</div>
|
|
800
|
+
</div>
|
|
801
|
+
|
|
802
|
+
<div class="mt-4 flex flex-wrap gap-2">
|
|
803
|
+
<button
|
|
804
|
+
class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-60"
|
|
805
|
+
type="button"
|
|
806
|
+
?disabled=${this.busy||t.size===0}
|
|
807
|
+
@click=${()=>this.confirmPendingImport()}
|
|
808
|
+
>
|
|
809
|
+
${this.busy?W(`loading`):W(`confirmImportSelected`)}
|
|
810
|
+
</button>
|
|
811
|
+
<button
|
|
812
|
+
class="rounded-md border border-input px-3 py-2 text-sm hover:bg-muted/60 disabled:opacity-60"
|
|
813
|
+
type="button"
|
|
814
|
+
?disabled=${this.busy}
|
|
815
|
+
@click=${()=>this.cancelPendingImport()}
|
|
816
|
+
>
|
|
817
|
+
${W(`cancel`)}
|
|
818
|
+
</button>
|
|
819
|
+
</div>
|
|
820
|
+
</section>
|
|
821
|
+
`}render(){return z`
|
|
822
|
+
<div class="flex flex-col gap-6">
|
|
823
|
+
<div>
|
|
824
|
+
<h3 class="mb-2 inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
825
|
+
${W(`backupRestore`)}
|
|
826
|
+
<quickforge-info-tip .label=${W(`backupRestoreDescription`)}></quickforge-info-tip>
|
|
827
|
+
</h3>
|
|
828
|
+
</div>
|
|
829
|
+
|
|
830
|
+
<section class="rounded-lg border border-border p-4">
|
|
831
|
+
<h4 class="inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
832
|
+
${W(`exportData`)}
|
|
833
|
+
<quickforge-info-tip .label=${W(`exportDataDescription`)}></quickforge-info-tip>
|
|
834
|
+
</h4>
|
|
835
|
+
|
|
836
|
+
<label class="mt-4 grid max-w-sm gap-1.5 text-sm">
|
|
837
|
+
<span class="text-foreground">${W(`exportScope`)}</span>
|
|
838
|
+
<select
|
|
839
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
840
|
+
.value=${this.exportScope}
|
|
841
|
+
?disabled=${this.busy}
|
|
842
|
+
@change=${e=>this.setScope(e.target.value)}
|
|
843
|
+
>
|
|
844
|
+
<option value="all">${W(`exportScopeAll`)}</option>
|
|
845
|
+
<option value="config">${W(`exportScopeConfig`)}</option>
|
|
846
|
+
<option value="sessions">${W(`exportScopeSessions`)}</option>
|
|
847
|
+
</select>
|
|
848
|
+
</label>
|
|
849
|
+
|
|
850
|
+
<label class="mt-4 flex max-w-sm items-start gap-2 text-sm text-foreground ${this.exportScope===`sessions`?`opacity-60`:``}">
|
|
851
|
+
<input
|
|
852
|
+
class="mt-1"
|
|
853
|
+
type="checkbox"
|
|
854
|
+
.checked=${this.includeSecrets}
|
|
855
|
+
?disabled=${this.busy||this.exportScope===`sessions`}
|
|
856
|
+
@change=${e=>this.setIncludeSecrets(e.target.checked)}
|
|
857
|
+
/>
|
|
858
|
+
<span>
|
|
859
|
+
<span class="block">${W(`includeApiKeys`)}</span>
|
|
860
|
+
<span class="block text-xs text-muted-foreground">${W(`includeApiKeysDescription`)}</span>
|
|
861
|
+
</span>
|
|
862
|
+
</label>
|
|
863
|
+
|
|
864
|
+
<button
|
|
865
|
+
class="mt-4 rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-60"
|
|
866
|
+
type="button"
|
|
867
|
+
?disabled=${this.busy}
|
|
868
|
+
@click=${()=>this.exportBackup()}
|
|
869
|
+
>
|
|
870
|
+
${this.busy?W(`loading`):W(`exportBackup`)}
|
|
871
|
+
</button>
|
|
872
|
+
</section>
|
|
873
|
+
|
|
874
|
+
<section class="rounded-lg border border-border p-4">
|
|
875
|
+
<h4 class="inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
876
|
+
${W(`importData`)}
|
|
877
|
+
<quickforge-info-tip .label=${W(`importDataDescription`)}></quickforge-info-tip>
|
|
878
|
+
</h4>
|
|
879
|
+
|
|
880
|
+
<label class="mt-4 inline-flex cursor-pointer rounded-md border border-input px-3 py-2 text-sm hover:bg-muted/60 ${this.busy?`pointer-events-none opacity-60`:``}">
|
|
881
|
+
<input
|
|
882
|
+
class="hidden"
|
|
883
|
+
type="file"
|
|
884
|
+
accept="application/json,.json"
|
|
885
|
+
?disabled=${this.busy}
|
|
886
|
+
@change=${e=>this.handleFileChange(e)}
|
|
887
|
+
/>
|
|
888
|
+
${W(`importBackup`)}
|
|
889
|
+
</label>
|
|
890
|
+
</section>
|
|
891
|
+
|
|
892
|
+
${this.renderPendingImport()}
|
|
893
|
+
${this.message?z`<div class="rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300">${this.message}</div>`:null}
|
|
894
|
+
${this.safetyBackupPath?z`<div class="rounded-md border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground">${W(`backupSafetyBackupPath`)}: <code>${this.safetyBackupPath}</code></div>`:null}
|
|
895
|
+
${this.error?z`<div class="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">${this.error}</div>`:null}
|
|
896
|
+
</div>
|
|
897
|
+
`}},tc=`quickforge-backup-settings-tab`;customElements.get(tc)||customElements.define(tc,ec);function nc(){return document.createElement(tc)}function rc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(qe())}function ic(e){let t={...e};return delete t.archivedAt,t}function ac(){if(!(typeof BroadcastChannel>`u`))try{let e=new BroadcastChannel(`quickforge-sync`);e.postMessage({type:`sessions-changed`,sourceTabId:`archived-conversations-settings-tab`,timestamp:Date.now()}),e.close()}catch{}}var oc=class extends De{sessions=[];projects=[];loading=!0;busySessionId=``;query=``;projectFilter=`all`;message=``;error=``;getTabName(){return W(`archivedConversations`)}async connectedCallback(){super.connectedCallback(),await this.loadData()}get projectNameById(){return new Map(this.projects.map(e=>[e.id,e.name]))}async loadData(){this.loading=!0,this.error=``,this.requestUpdate();try{let[e,t]=await Promise.all([fetch(`/api/storage/sessions-metadata/index/lastModified?direction=desc&limit=1000&offset=0&archived=only`,{cache:`no-store`}),fetch(`/api/project`,{cache:`no-store`}).catch(()=>null)]),n=await e.json().catch(()=>null);if(!e.ok)throw Error(n?.error||W(`requestFailed`));if(this.sessions=Array.isArray(n?.values)?n.values:[],t?.ok){let e=await t.json().catch(()=>null);this.projects=Array.isArray(e?.projects)?e.projects:[]}}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.loading=!1,this.requestUpdate()}}filteredSessions(){let e=this.query.trim().toLowerCase();return this.sessions.filter(t=>{if(this.projectFilter!==`all`&&(this.projectFilter===`global`&&t.scope===`project`||this.projectFilter!==`global`&&t.projectId!==this.projectFilter))return!1;if(!e)return!0;let n=t.projectId&&this.projectNameById.get(t.projectId)||``;return`${Kt(t.title)} ${n}`.toLowerCase().includes(e)})}groupedSessions(){let e=new Map;for(let t of this.filteredSessions()){let n=t.scope===`project`&&t.projectId?t.projectId:`global`;e.set(n,[...e.get(n)??[],t])}return[...e.entries()]}projectLabel(e){return e===`global`?W(`normalChat`):this.projectNameById.get(e)||W(`unknownProject`)}async restoreSession(e){if(!this.busySessionId){this.busySessionId=e,this.message=``,this.error=``,this.requestUpdate();try{let t=B(),n=await t.sessions.get(e),r=await t.sessions.getMetadata(e);if(!n||!r)throw Error(W(`sessionNotFound`));await t.sessions.save(ic(n),ic(r)),this.sessions=this.sessions.filter(t=>t.id!==e),this.message=W(`sessionRestored`),ac()}catch(e){this.error=e instanceof Error?e.message:W(`restoreSessionFailed`)}finally{this.busySessionId=``,this.requestUpdate()}}}async deleteSession(e){if(!this.busySessionId&&await J({description:W(`deleteArchivedSessionConfirm`,{title:Kt(e.title)}),confirmLabel:W(`confirmDelete`),cancelLabel:W(`cancel`),variant:`destructive`})){this.busySessionId=e.id,this.message=``,this.error=``,this.requestUpdate();try{await B().sessions.delete(e.id),this.sessions=this.sessions.filter(t=>t.id!==e.id),this.message=W(`archivedSessionDeleted`),ac()}catch(e){this.error=e instanceof Error?e.message:W(`deleteSessionFailed`)}finally{this.busySessionId=``,this.requestUpdate()}}}async deleteAllArchivedSessions(){if(!(this.busySessionId||this.sessions.length===0)&&await J({description:W(`deleteAllArchivedSessionsConfirm`),confirmLabel:W(`confirmDelete`),cancelLabel:W(`cancel`),variant:`destructive`})){this.busySessionId=`__all__`,this.message=``,this.error=``,this.requestUpdate();try{let e=B();await Promise.all(this.sessions.map(t=>e.sessions.delete(t.id))),this.sessions=[],this.message=W(`archivedSessionsDeleted`),ac()}catch(e){this.error=e instanceof Error?e.message:W(`deleteSessionFailed`)}finally{this.busySessionId=``,this.requestUpdate()}}}renderSession(e){let t=this.busySessionId===e.id||this.busySessionId===`__all__`;return z`
|
|
898
|
+
<div class="border-t border-border px-4 py-3 first:border-t-0">
|
|
899
|
+
<div class="flex items-start justify-between gap-3">
|
|
900
|
+
<div class="min-w-0">
|
|
901
|
+
<div class="truncate text-sm font-medium text-foreground">${Kt(e.title)}</div>
|
|
902
|
+
<div class="mt-1 text-xs text-muted-foreground">
|
|
903
|
+
${W(`lastModified`)}: ${rc(e.lastModified)} · ${W(`archivedAt`)}: ${rc(e.archivedAt)}
|
|
904
|
+
</div>
|
|
905
|
+
</div>
|
|
906
|
+
<div class="flex shrink-0 items-center gap-2">
|
|
907
|
+
<button
|
|
908
|
+
class="rounded-md border border-input px-2.5 py-1 text-xs hover:bg-muted/60 disabled:opacity-60"
|
|
909
|
+
type="button"
|
|
910
|
+
?disabled=${t}
|
|
911
|
+
@click=${()=>this.restoreSession(e.id)}
|
|
912
|
+
>
|
|
913
|
+
${W(`restoreSession`)}
|
|
914
|
+
</button>
|
|
915
|
+
<button
|
|
916
|
+
class="rounded-md px-2.5 py-1 text-xs text-destructive hover:bg-destructive/10 disabled:opacity-60"
|
|
917
|
+
type="button"
|
|
918
|
+
?disabled=${t}
|
|
919
|
+
@click=${()=>this.deleteSession(e)}
|
|
920
|
+
>
|
|
921
|
+
${W(`deletePermanently`)}
|
|
922
|
+
</button>
|
|
923
|
+
</div>
|
|
924
|
+
</div>
|
|
925
|
+
</div>
|
|
926
|
+
`}render(){let e=this.groupedSessions(),t=!!this.busySessionId;return z`
|
|
927
|
+
<div class="flex flex-col gap-4">
|
|
928
|
+
<div class="flex items-center justify-between gap-3">
|
|
929
|
+
<div>
|
|
930
|
+
<h3 class="text-sm font-semibold text-foreground">${W(`archivedConversations`)}</h3>
|
|
931
|
+
<p class="mt-1 text-xs text-muted-foreground">${W(`archivedConversationsDescription`)}</p>
|
|
932
|
+
</div>
|
|
933
|
+
<button
|
|
934
|
+
class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive hover:bg-destructive/15 disabled:opacity-60"
|
|
935
|
+
type="button"
|
|
936
|
+
?disabled=${t||this.sessions.length===0}
|
|
937
|
+
@click=${()=>this.deleteAllArchivedSessions()}
|
|
938
|
+
>
|
|
939
|
+
${W(`deleteAll`)}
|
|
940
|
+
</button>
|
|
941
|
+
</div>
|
|
942
|
+
|
|
943
|
+
<section class="rounded-lg border border-border">
|
|
944
|
+
<div class="grid gap-2 border-b border-border p-3 sm:grid-cols-[minmax(0,1fr)_12rem]">
|
|
945
|
+
<input
|
|
946
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring/30"
|
|
947
|
+
type="search"
|
|
948
|
+
.value=${this.query}
|
|
949
|
+
placeholder=${W(`searchArchivedConversations`)}
|
|
950
|
+
@input=${e=>{this.query=e.target.value,this.requestUpdate()}}
|
|
951
|
+
/>
|
|
952
|
+
<select
|
|
953
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
954
|
+
.value=${this.projectFilter}
|
|
955
|
+
@change=${e=>{this.projectFilter=e.target.value,this.requestUpdate()}}
|
|
956
|
+
>
|
|
957
|
+
<option value="all">${W(`allProjects`)}</option>
|
|
958
|
+
<option value="global">${W(`normalChat`)}</option>
|
|
959
|
+
${this.projects.map(e=>z`<option value=${e.id}>${e.name}</option>`)}
|
|
960
|
+
</select>
|
|
961
|
+
</div>
|
|
962
|
+
|
|
963
|
+
${this.loading?z`
|
|
964
|
+
<div class="px-4 py-8 text-center text-sm text-muted-foreground">${W(`loading`)}</div>
|
|
965
|
+
`:e.length===0?z`
|
|
966
|
+
<div class="px-4 py-8 text-center text-sm text-muted-foreground">${W(`noArchivedConversations`)}</div>
|
|
967
|
+
`:z`
|
|
968
|
+
<div>
|
|
969
|
+
${e.map(([e,t])=>z`
|
|
970
|
+
<div class="border-b border-border last:border-b-0">
|
|
971
|
+
<div class="flex items-center justify-between gap-3 bg-muted/20 px-4 py-2 text-sm text-muted-foreground">
|
|
972
|
+
<div class="truncate">${this.projectLabel(e)}</div>
|
|
973
|
+
<div class="shrink-0">${W(`conversationCount`,{count:t.length})}</div>
|
|
974
|
+
</div>
|
|
975
|
+
${t.map(e=>this.renderSession(e))}
|
|
976
|
+
</div>
|
|
977
|
+
`)}
|
|
978
|
+
</div>
|
|
979
|
+
`}
|
|
980
|
+
</section>
|
|
981
|
+
|
|
982
|
+
${this.message?z`<div class="rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300">${this.message}</div>`:null}
|
|
983
|
+
${this.error?z`<div class="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">${this.error}</div>`:null}
|
|
984
|
+
</div>
|
|
985
|
+
`}},sc=`quickforge-archived-conversations-settings-tab`;customElements.get(sc)||customElements.define(sc,oc);function cc(){return document.createElement(sc)}var lc=3e4,uc=800;function dc(e){return new Promise(t=>window.setTimeout(t,e))}function fc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(qe())}function pc(){return`custom_${globalThis.crypto?.randomUUID?.().slice(0,8)||Date.now().toString(36)}`}function mc(e){let t=e.trim(),n=t.split(/[\\/]/).pop()?.replace(/^"|"$/g,``)||t;return/^bash(\.exe)?$/i.test(n)?`Bash`:/^zsh$/i.test(n)?`Zsh`:/^fish$/i.test(n)?`Fish`:/^cmd(\.exe)?$/i.test(n)?`Command Prompt`:/^powershell(\.exe)?$/i.test(n)?`Windows PowerShell`:/^pwsh(\.exe)?$/i.test(n)?`PowerShell 7+`:n||`Custom Shell`}var hc=z`
|
|
986
|
+
<svg class="size-3.5" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
987
|
+
<path d="M3.5 8.2 6.6 11.3 12.7 4.7" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" />
|
|
988
|
+
</svg>
|
|
989
|
+
`,gc=z`
|
|
990
|
+
<svg class="size-3.5" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
991
|
+
<circle cx="8" cy="8" r="4.8" stroke="currentColor" stroke-width="1.5" />
|
|
992
|
+
</svg>
|
|
993
|
+
`,_c=z`
|
|
994
|
+
<svg class="size-3.5" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
995
|
+
<path d="M4.5 4.5 11.5 11.5M11.5 4.5 4.5 11.5" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" />
|
|
996
|
+
</svg>
|
|
997
|
+
`,vc=class extends De{status;loading=!0;restarting=!1;message=``;error=``;terminalShellConfig={terminalShell:`auto`,defaultProfileId:`auto`,profiles:[]};customShellCommand=``;getTabName(){return W(`backendService`)}async connectedCallback(){super.connectedCallback(),await Promise.all([this.loadStatus(),this.loadTerminalShell()])}customShellProfiles(){return this.terminalShellConfig.profiles.filter(e=>!e.builtin)}async loadTerminalShell(){try{let e=await fetch(`/api/system/terminal-shell`,{cache:`no-store`}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||W(`requestFailed`));this.terminalShellConfig={terminalShell:t?.terminalShell||`auto`,defaultProfileId:t?.defaultProfileId||`auto`,profiles:Array.isArray(t?.profiles)?t.profiles:[]}}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.requestUpdate()}}async saveTerminalShellConfig(e,t=this.customShellProfiles(),n=W(`terminalShellSaved`)){try{let r=await fetch(`/api/system/terminal-shell`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({defaultProfileId:e,profiles:t})}),i=await r.json().catch(()=>null);if(!r.ok)throw Error(i?.error||W(`requestFailed`));this.terminalShellConfig=i,this.message=n,this.error=``}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.requestUpdate()}}async addCustomTerminalShell(){let e=this.customShellCommand.trim();if(!e){this.error=W(`terminalShellProfileRequired`),this.requestUpdate();return}let t=[...this.customShellProfiles(),{id:pc(),name:mc(e),command:e,builtin:!1}];this.customShellCommand=``,await this.saveTerminalShellConfig(this.terminalShellConfig.defaultProfileId,t,W(`terminalShellProfilesSaved`))}async deleteCustomTerminalShell(e){let t=this.terminalShellConfig.profiles.find(t=>t.id===e);if(!t||t.builtin||!await J({description:W(`terminalShellDeleteConfirm`,{name:t.name}),confirmLabel:W(`confirmDelete`),cancelLabel:W(`cancel`),variant:`destructive`}))return;let n=this.customShellProfiles().filter(t=>t.id!==e),r=this.terminalShellConfig.defaultProfileId===e?`auto`:this.terminalShellConfig.defaultProfileId;await this.saveTerminalShellConfig(r,n,W(`terminalShellProfilesSaved`))}async loadStatus(){this.loading=!0,this.error=``,this.requestUpdate();try{let e=await fetch(`/api/health`,{cache:`no-store`}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||W(`requestFailed`));this.status=t}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.loading=!1,this.requestUpdate()}}async pollUntilRestarted(e){let t=Date.now();for(;Date.now()-t<lc;){await dc(uc);try{let t=await fetch(`/api/health?restartPoll=${Date.now()}`,{cache:`no-store`}),n=await t.json().catch(()=>null);if(t.ok&&n?.ok&&n.bootId&&n.bootId!==e){this.message=W(`backendRestarted`),this.requestUpdate(),window.setTimeout(()=>window.location.reload(),300);return}}catch{}}throw Error(W(`backendRestartTimeout`))}async restartService(){if(!this.status||this.restarting||!await J({description:W(`restartBackendConfirm`),confirmLabel:W(`restartBackendService`),cancelLabel:W(`cancel`)}))return;this.restarting=!0,this.message=W(`backendRestarting`),this.error=``,this.requestUpdate();let e=this.status.bootId;try{let t=await fetch(`/api/system/restart`,{method:`POST`,headers:{"x-quickforge-action":`restart`}}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||W(`backendRestartFailed`));await this.pollUntilRestarted(e)}catch(e){this.error=e instanceof Error?e.message:W(`backendRestartFailed`),this.message=``,this.restarting=!1,this.requestUpdate()}}statusRows(){return this.status?z`
|
|
998
|
+
<dl class="grid gap-3 text-sm">
|
|
999
|
+
${[[W(`serviceMode`),this.status.mode],[W(`servicePid`),String(this.status.pid)],[W(`serviceStartedAt`),fc(this.status.startedAt)],[W(`serviceDataDir`),this.status.dataDir],[W(`serviceWorkspace`),this.status.workspaceRoot]].map(([e,t])=>z`
|
|
1000
|
+
<div class="grid gap-1 sm:grid-cols-[120px_1fr] sm:gap-3">
|
|
1001
|
+
<dt class="text-muted-foreground">${e}</dt>
|
|
1002
|
+
<dd class="min-w-0 break-all text-foreground">${t}</dd>
|
|
1003
|
+
</div>
|
|
1004
|
+
`)}
|
|
1005
|
+
</dl>
|
|
1006
|
+
`:null}shellProfileRow(e,t=!1){let n=e.id===this.terminalShellConfig.defaultProfileId||this.terminalShellConfig.defaultProfileId===`auto`&&t;return z`
|
|
1007
|
+
<div class="flex min-w-0 items-center gap-3 border-b px-1.5 py-2 last:border-b-0 hover:bg-muted/5" style="border-bottom-color: color-mix(in oklab, var(--border) 32%, transparent);">
|
|
1008
|
+
<div class="min-w-0 flex-1">
|
|
1009
|
+
<div class="truncate text-sm font-medium text-foreground/90">${e.name}</div>
|
|
1010
|
+
<div class="truncate font-mono text-xs text-muted-foreground/55" title=${e.command}>${e.command}</div>
|
|
1011
|
+
</div>
|
|
1012
|
+
<div class="flex shrink-0 items-center gap-1">
|
|
1013
|
+
${n?z`
|
|
1014
|
+
<span class="inline-flex size-7 items-center justify-center rounded-md text-emerald-500/85" title=${W(`terminalShellDefaultBadge`)} aria-label=${W(`terminalShellDefaultBadge`)}>
|
|
1015
|
+
${hc}
|
|
1016
|
+
</span>
|
|
1017
|
+
`:z`
|
|
1018
|
+
<button
|
|
1019
|
+
class="inline-flex size-7 items-center justify-center rounded-md text-muted-foreground/55 hover:bg-muted/20 hover:text-foreground/85"
|
|
1020
|
+
type="button"
|
|
1021
|
+
title=${W(`terminalShellSetDefault`)}
|
|
1022
|
+
aria-label=${W(`terminalShellSetDefault`)}
|
|
1023
|
+
@click=${()=>this.saveTerminalShellConfig(e.id)}
|
|
1024
|
+
>
|
|
1025
|
+
${gc}
|
|
1026
|
+
</button>
|
|
1027
|
+
`}
|
|
1028
|
+
${e.builtin?null:z`
|
|
1029
|
+
<button
|
|
1030
|
+
class="inline-flex size-7 items-center justify-center rounded-md text-muted-foreground/55 hover:bg-destructive/10 hover:text-destructive"
|
|
1031
|
+
type="button"
|
|
1032
|
+
title=${W(`delete`)}
|
|
1033
|
+
aria-label=${W(`delete`)}
|
|
1034
|
+
@click=${()=>this.deleteCustomTerminalShell(e.id)}
|
|
1035
|
+
>
|
|
1036
|
+
${_c}
|
|
1037
|
+
</button>
|
|
1038
|
+
`}
|
|
1039
|
+
</div>
|
|
1040
|
+
</div>
|
|
1041
|
+
`}terminalShellSettings(){let e=this.terminalShellConfig.profiles;return z`
|
|
1042
|
+
<section class="rounded-lg border border-border p-4">
|
|
1043
|
+
<div>
|
|
1044
|
+
<h4 class="inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
1045
|
+
${W(`terminalShell`)}
|
|
1046
|
+
<quickforge-info-tip .label=${W(`terminalShellDescription`)}></quickforge-info-tip>
|
|
1047
|
+
</h4>
|
|
1048
|
+
<p class="mt-1 text-xs text-muted-foreground/60">${W(`terminalShellAutoDetectedHint`)}</p>
|
|
1049
|
+
</div>
|
|
1050
|
+
|
|
1051
|
+
<div class="mt-4 overflow-hidden rounded-lg border bg-transparent" style="border-color: color-mix(in oklab, var(--border) 36%, transparent);">
|
|
1052
|
+
${e.length>0?e.map((e,t)=>this.shellProfileRow(e,t===0)):z`<div class="px-2 py-3 text-sm text-muted-foreground">${W(`terminalShellNoDetected`)}</div>`}
|
|
1053
|
+
</div>
|
|
1054
|
+
|
|
1055
|
+
<div class="mt-3 grid gap-2 sm:grid-cols-[1fr_auto] sm:items-end">
|
|
1056
|
+
<label class="grid gap-1 text-sm">
|
|
1057
|
+
<span class="text-xs text-muted-foreground/70">${W(`terminalShellCommand`)}</span>
|
|
1058
|
+
<input
|
|
1059
|
+
class="h-9 rounded-md border border-border bg-background px-3 font-mono text-sm text-foreground outline-none focus:border-ring"
|
|
1060
|
+
type="text"
|
|
1061
|
+
.value=${this.customShellCommand}
|
|
1062
|
+
placeholder=${W(`terminalShellCommandPlaceholder`)}
|
|
1063
|
+
@input=${e=>{this.customShellCommand=e.target.value}}
|
|
1064
|
+
/>
|
|
1065
|
+
</label>
|
|
1066
|
+
<button
|
|
1067
|
+
class="h-9 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-60"
|
|
1068
|
+
type="button"
|
|
1069
|
+
title=${W(`terminalShellAdd`)}
|
|
1070
|
+
aria-label=${W(`terminalShellAdd`)}
|
|
1071
|
+
@click=${()=>this.addCustomTerminalShell()}
|
|
1072
|
+
>
|
|
1073
|
+
${W(`terminalShellAdd`)}
|
|
1074
|
+
</button>
|
|
1075
|
+
</div>
|
|
1076
|
+
</section>
|
|
1077
|
+
`}render(){if(this.loading)return z`<div class="text-sm text-muted-foreground">${W(`loading`)}</div>`;let e=this.status?.restartUnsupportedReason||W(`backendRestartUnsupported`),t=this.restarting||!this.status?.restartSupported;return z`
|
|
1078
|
+
<div class="flex flex-col gap-6">
|
|
1079
|
+
<div>
|
|
1080
|
+
<h3 class="mb-2 inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
1081
|
+
${W(`backendService`)}
|
|
1082
|
+
<quickforge-info-tip .label=${W(`backendServiceDescription`)}></quickforge-info-tip>
|
|
1083
|
+
</h3>
|
|
1084
|
+
</div>
|
|
1085
|
+
|
|
1086
|
+
<section class="rounded-lg border border-border p-4">
|
|
1087
|
+
<h4 class="text-sm font-semibold text-foreground">${W(`backendServiceStatus`)}</h4>
|
|
1088
|
+
<div class="mt-4">${this.statusRows()}</div>
|
|
1089
|
+
</section>
|
|
1090
|
+
|
|
1091
|
+
${this.terminalShellSettings()}
|
|
1092
|
+
|
|
1093
|
+
<section class="rounded-lg border border-border p-4">
|
|
1094
|
+
<h4 class="inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
1095
|
+
${W(`restartBackendService`)}
|
|
1096
|
+
<quickforge-info-tip .label=${W(`restartBackendServiceDescription`)}></quickforge-info-tip>
|
|
1097
|
+
</h4>
|
|
1098
|
+
|
|
1099
|
+
${this.status?.restartSupported?null:z`<div class="mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-700 dark:text-amber-300">${e}</div>`}
|
|
1100
|
+
|
|
1101
|
+
<button
|
|
1102
|
+
class="mt-4 rounded-md bg-destructive px-3 py-2 text-sm text-destructive-foreground disabled:opacity-60"
|
|
1103
|
+
type="button"
|
|
1104
|
+
?disabled=${t}
|
|
1105
|
+
@click=${()=>this.restartService()}
|
|
1106
|
+
>
|
|
1107
|
+
${this.restarting?W(`backendRestarting`):W(`restartBackendService`)}
|
|
1108
|
+
</button>
|
|
1109
|
+
</section>
|
|
1110
|
+
|
|
1111
|
+
${this.message?z`<div class="rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300">${this.message}</div>`:null}
|
|
1112
|
+
${this.error?z`<div class="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">${this.error}</div>`:null}
|
|
1113
|
+
</div>
|
|
1114
|
+
`}},yc=`quickforge-service-settings-tab`;customElements.get(yc)||customElements.define(yc,vc);function bc(){return document.createElement(yc)}function xc(){return Array.from({length:16},()=>`ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%^&*`[Math.floor(Math.random()*65)]).join(``)}var Sc=class extends De{loading=!0;saving=!1;enabled=!1;hasPassword=!1;password=``;sessionTtlHours=12;activeTokenCount=0;lanUrls=[];error=``;message=``;getTabName(){return W(`lanAccess`)}async connectedCallback(){super.connectedCallback(),await this.loadStatus()}async request(e,t){let n=await fetch(e,{...t,cache:`no-store`,headers:{...t?.body?{"content-type":`application/json`}:void 0,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||W(`requestFailed`));return r}applyStatus(e){this.enabled=!!e.enabled,this.hasPassword=!!e.hasPassword,this.sessionTtlHours=Number(e.sessionTtlHours||12),this.activeTokenCount=Number(e.activeTokenCount||0),this.lanUrls=Array.isArray(e.lanUrls)?e.lanUrls:[]}async loadStatus(){this.loading=!0,this.error=``,this.requestUpdate();try{this.applyStatus(await this.request(`/api/lan-access/status`))}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.loading=!1,this.requestUpdate()}}updatePassword(e){this.password=e,this.requestUpdate()}updateEnabled(e){this.enabled=e,this.requestUpdate()}updateTtl(e){this.sessionTtlHours=Number(e)||12,this.requestUpdate()}async saveSettings(){if(!this.saving){if(this.enabled&&!this.hasPassword&&!this.password.trim()){this.error=W(`lanAccessPasswordRequired`),this.requestUpdate();return}if(this.password.trim()&&this.password.trim().length<8){this.error=W(`lanAccessPasswordTooShort`),this.requestUpdate();return}if(!(this.enabled&&!await J({description:W(`lanAccessEnableConfirm`),confirmLabel:W(`enabled`),cancelLabel:W(`cancel`)}))){this.saving=!0,this.error=``,this.message=``,this.requestUpdate();try{let e=await this.request(`/api/lan-access/settings`,{method:`PUT`,body:JSON.stringify({enabled:this.enabled,password:this.password.trim()||void 0,sessionTtlHours:this.sessionTtlHours})});this.applyStatus(e),this.password=``,this.message=W(`lanAccessSaved`)}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.saving=!1,this.requestUpdate()}}}}async revokeAll(){if(await J({description:W(`lanAccessRevokeAllConfirm`),confirmLabel:W(`lanAccessRevokeAll`),cancelLabel:W(`cancel`),variant:`destructive`})){this.saving=!0,this.error=``,this.message=``,this.requestUpdate();try{let e=await this.request(`/api/lan-access/revoke-all`,{method:`POST`});this.applyStatus(e),this.message=W(`lanAccessRevoked`)}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.saving=!1,this.requestUpdate()}}}render(){return this.loading?z`<div class="text-sm text-muted-foreground">${W(`loading`)}</div>`:z`
|
|
1115
|
+
<div class="flex flex-col gap-6">
|
|
1116
|
+
<div>
|
|
1117
|
+
<h3 class="mb-2 inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
1118
|
+
${W(`lanAccess`)}
|
|
1119
|
+
<quickforge-info-tip .label=${W(`lanAccessDescription`)}></quickforge-info-tip>
|
|
1120
|
+
</h3>
|
|
1121
|
+
</div>
|
|
1122
|
+
|
|
1123
|
+
<section class="rounded-lg border border-amber-500/30 bg-amber-500/10 p-4 text-sm text-amber-800 dark:text-amber-200">
|
|
1124
|
+
${W(`lanAccessRiskWarning`)}
|
|
1125
|
+
</section>
|
|
1126
|
+
|
|
1127
|
+
<section class="rounded-lg border border-border p-4">
|
|
1128
|
+
<h4 class="text-sm font-semibold text-foreground">${W(`lanAccessStatus`)}</h4>
|
|
1129
|
+
<dl class="mt-4 grid gap-3 text-sm">
|
|
1130
|
+
<div class="grid gap-1 sm:grid-cols-[140px_1fr] sm:gap-3">
|
|
1131
|
+
<dt class="text-muted-foreground">${W(`lanAccessEnabled`)}</dt>
|
|
1132
|
+
<dd>${this.enabled?W(`enabled`):W(`disabled`)}</dd>
|
|
1133
|
+
</div>
|
|
1134
|
+
<div class="grid gap-1 sm:grid-cols-[140px_1fr] sm:gap-3">
|
|
1135
|
+
<dt class="text-muted-foreground">${W(`lanAccessPassword`)}</dt>
|
|
1136
|
+
<dd>${this.hasPassword?W(`configured`):W(`notConfigured`)}</dd>
|
|
1137
|
+
</div>
|
|
1138
|
+
<div class="grid gap-1 sm:grid-cols-[140px_1fr] sm:gap-3">
|
|
1139
|
+
<dt class="text-muted-foreground">${W(`lanAccessActiveDevices`)}</dt>
|
|
1140
|
+
<dd>${this.activeTokenCount}</dd>
|
|
1141
|
+
</div>
|
|
1142
|
+
<div class="grid gap-1 sm:grid-cols-[140px_1fr] sm:gap-3">
|
|
1143
|
+
<dt class="text-muted-foreground">${W(`lanAccessUrls`)}</dt>
|
|
1144
|
+
<dd class="min-w-0 break-all">${this.lanUrls.length?this.lanUrls.map(e=>z`<div>${e}</div>`):`-`}</dd>
|
|
1145
|
+
</div>
|
|
1146
|
+
</dl>
|
|
1147
|
+
</section>
|
|
1148
|
+
|
|
1149
|
+
<section class="rounded-lg border border-border p-4">
|
|
1150
|
+
<label class="flex items-center gap-2 text-sm font-medium text-foreground">
|
|
1151
|
+
<input type="checkbox" .checked=${this.enabled} @change=${e=>this.updateEnabled(e.target.checked)} />
|
|
1152
|
+
${W(`lanAccessAllowFull`)}
|
|
1153
|
+
</label>
|
|
1154
|
+
|
|
1155
|
+
<label class="mt-4 block text-sm font-medium text-foreground">
|
|
1156
|
+
${W(`lanAccessPassword`)}
|
|
1157
|
+
<div class="mt-2 flex flex-col gap-3 sm:flex-row">
|
|
1158
|
+
<input class="h-10 min-w-0 flex-1 rounded-md border border-input bg-background px-3 text-sm" type="password" .value=${this.password} @input=${e=>this.updatePassword(e.target.value)} placeholder=${this.hasPassword?W(`lanAccessPasswordPlaceholderConfigured`):W(`lanAccessPasswordPlaceholder`)} />
|
|
1159
|
+
<button class="rounded-md border border-input px-3 py-2 text-sm" type="button" @click=${()=>this.updatePassword(xc())}>${W(`generatePassword`)}</button>
|
|
1160
|
+
</div>
|
|
1161
|
+
</label>
|
|
1162
|
+
|
|
1163
|
+
<label class="mt-4 block text-sm font-medium text-foreground">
|
|
1164
|
+
${W(`lanAccessSessionTtl`)}
|
|
1165
|
+
<select class="mt-2 h-10 w-full rounded-md border border-input bg-background px-3 text-sm" .value=${String(this.sessionTtlHours)} @change=${e=>this.updateTtl(e.target.value)}>
|
|
1166
|
+
<option value="1">1 ${W(`hour`)}</option>
|
|
1167
|
+
<option value="12">12 ${W(`hours`)}</option>
|
|
1168
|
+
<option value="24">24 ${W(`hours`)}</option>
|
|
1169
|
+
<option value="168">7 ${W(`days`)}</option>
|
|
1170
|
+
</select>
|
|
1171
|
+
</label>
|
|
1172
|
+
|
|
1173
|
+
<div class="mt-4 flex flex-wrap gap-2">
|
|
1174
|
+
<button class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-60" type="button" ?disabled=${this.saving} @click=${()=>this.saveSettings()}>${this.saving?W(`saving`):W(`save`)}</button>
|
|
1175
|
+
<button class="rounded-md border border-destructive/40 px-3 py-2 text-sm text-destructive disabled:opacity-60" type="button" ?disabled=${this.saving} @click=${()=>this.revokeAll()}>${W(`lanAccessRevokeAll`)}</button>
|
|
1176
|
+
</div>
|
|
1177
|
+
</section>
|
|
1178
|
+
|
|
1179
|
+
${this.message?z`<div class="rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300">${this.message}</div>`:null}
|
|
1180
|
+
${this.error?z`<div class="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">${this.error}</div>`:null}
|
|
1181
|
+
</div>
|
|
1182
|
+
`}},Cc=`quickforge-lan-access-settings-tab`;customElements.get(Cc)||customElements.define(Cc,Sc);function wc(){return document.createElement(Cc)}var Tc=18e4,Ec=1e3;function Dc(e){return new Promise(t=>window.setTimeout(t,e))}var Oc=[{value:`startup`,label:()=>W(`frequencyStartup`)},{value:`daily`,label:()=>W(`frequencyDaily`)},{value:`weekly`,label:()=>W(`frequencyWeekly`)},{value:`off`,label:()=>W(`frequencyOff`)}],kc=class extends De{about;updateInfo;loading=!0;checking=!1;updating=!1;message=``;error=``;frequency=ds.frequency;lastCheckAt=null;getTabName(){return W(`about`)}async connectedCallback(){super.connectedCallback(),await this.loadAbout()}async loadAbout(){this.loading=!0,this.error=``,this.requestUpdate();try{let e=await fetch(`/api/system/about`,{cache:`no-store`}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||W(`requestFailed`));this.about=t;try{let e=await hs(B());this.frequency=e.frequency,this.lastCheckAt=e.lastCheckAt}catch{}}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.loading=!1,this.requestUpdate()}}async checkUpdate(){if(!(this.checking||this.updating)){this.checking=!0,this.message=``,this.error=``,this.requestUpdate();try{let e=await fetch(`/api/system/update/check`,{cache:`no-store`}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||W(`updateCheckFailed`));this.updateInfo=t,this.about=t,this.updateInfo.updateAvailable?this.message=W(`updateAvailableMessage`,{current:this.updateInfo.currentVersion,latest:this.updateInfo.latestVersion}):this.updateInfo.localVersionIsNewer?this.message=W(`localVersionNewerMessage`,{current:this.updateInfo.currentVersion,latest:this.updateInfo.latestVersion}):this.message=W(`alreadyLatestVersion`,{version:this.updateInfo.currentVersion})}catch(e){this.error=e instanceof Error?e.message:W(`updateCheckFailed`)}finally{this.checking=!1,this.requestUpdate()}}}async pollUntilUpdated(e){let t=Date.now();for(;Date.now()-t<Tc;){await Dc(Ec);try{let t=await fetch(`/api/health?updatePoll=${Date.now()}`,{cache:`no-store`}),n=await t.json().catch(()=>null);if(t.ok&&n?.ok&&n.bootId&&n.bootId!==e){this.message=W(`updateRestarted`),this.requestUpdate(),window.setTimeout(()=>window.location.reload(),300);return}}catch{}}throw Error(W(`updateRestartTimeout`))}async updateQuickForge(){if(!(!this.updateInfo?.updateAvailable||this.updating)&&await J({description:W(`updateConfirm`,{command:this.updateInfo.installCommand}),confirmLabel:W(`updateNow`),cancelLabel:W(`cancel`)})){this.updating=!0,this.message=W(`updatingQuickForge`),this.error=``,this.requestUpdate();try{let e=await fetch(`/api/system/update`,{method:`POST`,headers:{"x-quickforge-action":`update`}}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||W(`updateFailed`));if(this.updateInfo=t,t?.updateStarted){let e=t.logFile?` ${W(`updateLogFile`,{path:t.logFile})}`:``;this.message=`${W(`updateStarted`)}${e}`,this.requestUpdate(),await this.pollUntilUpdated(t.bootId)}else this.message=t?.updated?W(`updateCompleted`):W(`alreadyLatestVersion`,{version:t?.currentVersion||this.about?.version||`-`}),this.updating=!1}catch(e){this.error=e instanceof Error?e.message:W(`updateFailed`),this.message=``,this.updating=!1}finally{this.requestUpdate()}}}async selectFrequency(e){if(this.frequency!==e){this.frequency=e,this.requestUpdate();try{let t=B();await gs(t,{...await hs(t),frequency:e}),this.error=``}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.requestUpdate()}}}renderFrequencyOption(e){return z`
|
|
1183
|
+
<button
|
|
1184
|
+
type="button"
|
|
1185
|
+
class="rounded-md border px-3 py-1.5 text-sm transition-colors ${this.frequency===e.value?`border-primary bg-primary text-primary-foreground`:`border-border bg-background text-foreground hover:bg-accent`}"
|
|
1186
|
+
@click=${()=>this.selectFrequency(e.value)}
|
|
1187
|
+
>
|
|
1188
|
+
${e.label()}
|
|
1189
|
+
</button>
|
|
1190
|
+
`}infoRows(){let e=this.about;return e?z`
|
|
1191
|
+
<dl class="grid gap-3 text-sm">
|
|
1192
|
+
${[[W(`packageName`),e.name],[W(`currentVersion`),e.version]].map(([e,t])=>z`
|
|
1193
|
+
<div class="grid gap-1 sm:grid-cols-[120px_1fr] sm:gap-3">
|
|
1194
|
+
<dt class="text-muted-foreground">${e}</dt>
|
|
1195
|
+
<dd class="min-w-0 break-all text-foreground">${t}</dd>
|
|
1196
|
+
</div>
|
|
1197
|
+
`)}
|
|
1198
|
+
<div class="grid gap-1 sm:grid-cols-[120px_1fr] sm:gap-3">
|
|
1199
|
+
<dt class="text-muted-foreground">${W(`github`)}</dt>
|
|
1200
|
+
<dd class="min-w-0 break-all">
|
|
1201
|
+
<a class="text-primary underline-offset-4 hover:underline" href=${e.repositoryUrl} target="_blank" rel="noreferrer">
|
|
1202
|
+
${e.repositoryUrl}
|
|
1203
|
+
</a>
|
|
1204
|
+
</dd>
|
|
1205
|
+
</div>
|
|
1206
|
+
</dl>
|
|
1207
|
+
`:null}updateStatus(){return this.updateInfo?z`
|
|
1208
|
+
<div class="mt-4 rounded-lg border bg-transparent p-3 text-sm" style="border-color: color-mix(in oklab, var(--border) 36%, transparent);">
|
|
1209
|
+
<div class="grid gap-2 sm:grid-cols-[120px_1fr] sm:gap-3">
|
|
1210
|
+
<span class="text-muted-foreground">${W(`latestVersion`)}</span>
|
|
1211
|
+
<span class="text-foreground">${this.updateInfo.latestVersion}</span>
|
|
1212
|
+
</div>
|
|
1213
|
+
<div class="mt-2 grid gap-2 sm:grid-cols-[120px_1fr] sm:gap-3">
|
|
1214
|
+
<span class="text-muted-foreground">${W(`updateCommand`)}</span>
|
|
1215
|
+
<code class="min-w-0 break-all rounded bg-muted/20 px-1.5 py-0.5 font-mono text-xs text-foreground/90">${this.updateInfo.installCommand}</code>
|
|
1216
|
+
</div>
|
|
1217
|
+
${this.updateInfo.logFile?z`
|
|
1218
|
+
<div class="mt-2 grid gap-2 sm:grid-cols-[120px_1fr] sm:gap-3">
|
|
1219
|
+
<span class="text-muted-foreground">${W(`updateLog`)}</span>
|
|
1220
|
+
<code class="min-w-0 break-all rounded bg-muted/20 px-1.5 py-0.5 font-mono text-xs text-foreground/90">${this.updateInfo.logFile}</code>
|
|
1221
|
+
</div>
|
|
1222
|
+
`:null}
|
|
1223
|
+
</div>
|
|
1224
|
+
`:null}render(){if(this.loading)return z`<div class="text-sm text-muted-foreground">${W(`loading`)}</div>`;let e=this.checking||this.updating||!this.updateInfo?.updateAvailable;return z`
|
|
1225
|
+
<div class="flex flex-col gap-6">
|
|
1226
|
+
<div>
|
|
1227
|
+
<h3 class="mb-2 inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
1228
|
+
${W(`aboutQuickForge`)}
|
|
1229
|
+
<quickforge-info-tip .label=${W(`aboutQuickForgeDescription`)}></quickforge-info-tip>
|
|
1230
|
+
</h3>
|
|
1231
|
+
</div>
|
|
1232
|
+
|
|
1233
|
+
<section class="rounded-lg border border-border p-4">
|
|
1234
|
+
<h4 class="text-sm font-semibold text-foreground">${W(`projectInfo`)}</h4>
|
|
1235
|
+
<div class="mt-4">${this.infoRows()}</div>
|
|
1236
|
+
</section>
|
|
1237
|
+
|
|
1238
|
+
<section class="rounded-lg border border-border p-4">
|
|
1239
|
+
<h4 class="inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
1240
|
+
${W(`checkUpdate`)}
|
|
1241
|
+
<quickforge-info-tip .label=${W(`checkUpdateDescription`)}></quickforge-info-tip>
|
|
1242
|
+
</h4>
|
|
1243
|
+
|
|
1244
|
+
<div class="mt-4">
|
|
1245
|
+
<div class="text-sm font-medium text-foreground">${W(`updateFrequencySection`)}</div>
|
|
1246
|
+
<div class="mt-1 text-xs text-muted-foreground">${W(`updateFrequencyDescription`)}</div>
|
|
1247
|
+
<div class="mt-2 flex flex-wrap gap-2">
|
|
1248
|
+
${Oc.map(e=>this.renderFrequencyOption(e))}
|
|
1249
|
+
</div>
|
|
1250
|
+
<div class="mt-2 text-xs text-muted-foreground">${this.lastCheckAt?W(`lastCheckedAt`,{time:new Date(this.lastCheckAt).toLocaleString(qe())}):W(`lastCheckedNever`)}</div>
|
|
1251
|
+
</div>
|
|
1252
|
+
|
|
1253
|
+
<div class="my-4 border-t border-border"></div>
|
|
1254
|
+
|
|
1255
|
+
${this.updateStatus()}
|
|
1256
|
+
|
|
1257
|
+
<div class="mt-4 flex flex-wrap gap-2">
|
|
1258
|
+
<button
|
|
1259
|
+
class="rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground hover:bg-muted/20 disabled:opacity-60"
|
|
1260
|
+
type="button"
|
|
1261
|
+
?disabled=${this.checking||this.updating}
|
|
1262
|
+
@click=${()=>this.checkUpdate()}
|
|
1263
|
+
>
|
|
1264
|
+
${this.checking?W(`checkingUpdate`):W(`checkUpdate`)}
|
|
1265
|
+
</button>
|
|
1266
|
+
<button
|
|
1267
|
+
class="rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-60"
|
|
1268
|
+
type="button"
|
|
1269
|
+
?disabled=${e}
|
|
1270
|
+
@click=${()=>this.updateQuickForge()}
|
|
1271
|
+
>
|
|
1272
|
+
${this.updating?W(`updatingQuickForge`):W(`updateNow`)}
|
|
1273
|
+
</button>
|
|
1274
|
+
</div>
|
|
1275
|
+
</section>
|
|
1276
|
+
|
|
1277
|
+
${this.message?z`<div class="rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300">${this.message}</div>`:null}
|
|
1278
|
+
${this.error?z`<div class="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">${this.error}</div>`:null}
|
|
1279
|
+
</div>
|
|
1280
|
+
`}},Ac=`quickforge-about-settings-tab`;customElements.get(Ac)||customElements.define(Ac,kc);function jc(){return document.createElement(Ac)}var Mc=class extends De{loading=!0;saving=!1;saved=!1;error=``;message=``;projects=[];project;commandDir=``;commands=[];loadingCommands=!1;getTabName(){return W(`projectCommands`)}async connectedCallback(){super.connectedCallback(),await this.loadProjects()}async request(e,t){let n=await fetch(e,{...t,cache:`no-store`,headers:{...t?.body?{"content-type":`application/json`}:void 0,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||W(`requestFailed`));return r}async loadProjects(){this.loading=!0,this.error=``,this.requestUpdate();try{let e=await this.request(`/api/project`);this.projects=e?.projects??(e?.project?[e.project]:[]),this.project=e?.project??this.projects[0],this.commandDir=typeof this.project?.commandDir==`string`?this.project.commandDir:``,await this.loadCommands()}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.loading=!1,this.requestUpdate()}}selectProject(e){let t=e.target,n=this.projects.find(e=>e.id===t.value);n&&(this.project=n,this.commandDir=typeof n.commandDir==`string`?n.commandDir:``,this.saved=!1,this.message=``,this.error=``,this.commands=[],this.requestUpdate(),this.loadCommands())}async loadCommands(){if(this.project?.id){this.loadingCommands=!0,this.requestUpdate();try{let e=await this.request(`/api/project/commands?projectId=${encodeURIComponent(this.project.id)}`);this.commands=e?.commands??[]}catch{this.commands=[]}finally{this.loadingCommands=!1,this.requestUpdate()}}}updateCommandDir(e){this.commandDir=e,this.saved=!1,this.message=``,this.requestUpdate()}async save(){if(!(!this.project||this.saving)){this.saving=!0,this.saved=!1,this.error=``,this.message=``,this.requestUpdate();try{let e=await this.request(`/api/project/${encodeURIComponent(this.project.id)}/command-dir`,{method:`PUT`,body:JSON.stringify({commandDir:this.commandDir})});if(this.project=e?.project??this.project,this.project){let e=this.projects.findIndex(e=>e.id===this.project.id);e>=0&&(this.projects[e]=this.project)}this.commandDir=typeof this.project?.commandDir==`string`?this.project.commandDir:``,this.saved=!0,await this.loadCommands()}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.saving=!1,this.requestUpdate()}}}async openCommandDir(){if(this.project){this.error=``,this.message=``,this.requestUpdate();try{await this.request(`/api/project/open-path`,{method:`POST`,body:JSON.stringify({path:`.ai/commands`,projectId:this.project.id})})}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`),this.requestUpdate()}}}async createCommand(){if(!this.project)return;let e=window.prompt(W(`newCommandPrompt`));if(e?.trim()){this.error=``,this.message=``,this.requestUpdate();try{let t=await this.request(`/api/project/command`,{method:`POST`,body:JSON.stringify({name:e.trim(),projectId:this.project.id})});t.ok?(this.message=W(`commandCreated`,{name:t.name??e.trim()}),await this.loadCommands()):t.reason===`exists`?this.error=W(`commandAlreadyExists`,{name:t.name??e.trim()}):this.error=W(`invalidCommandName`)}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.requestUpdate()}}}render(){return this.loading?z`<div class="text-sm text-muted-foreground">${W(`loading`)}</div>`:this.projects.length===0?z`
|
|
1281
|
+
<div class="flex flex-col gap-3">
|
|
1282
|
+
<h3 class="text-sm font-semibold text-foreground">${W(`projectCommands`)}</h3>
|
|
1283
|
+
<p class="text-sm text-muted-foreground">${W(`selectProjectForCommands`)}</p>
|
|
1284
|
+
${this.error?z`<div class="text-sm text-destructive">${this.error}</div>`:null}
|
|
1285
|
+
</div>
|
|
1286
|
+
`:z`
|
|
1287
|
+
<div class="flex flex-col gap-6">
|
|
1288
|
+
<div>
|
|
1289
|
+
<h3 class="mb-2 text-sm font-semibold text-foreground">
|
|
1290
|
+
${W(`projectCommands`)}
|
|
1291
|
+
<quickforge-info-tip .label=${W(`projectCommandsDescription`)}></quickforge-info-tip>
|
|
1292
|
+
</h3>
|
|
1293
|
+
</div>
|
|
1294
|
+
|
|
1295
|
+
<div class="grid max-w-xl gap-1.5 text-sm">
|
|
1296
|
+
<span class="text-foreground">${W(`project`)}</span>
|
|
1297
|
+
<select
|
|
1298
|
+
class="rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
1299
|
+
.value=${this.project?.id??``}
|
|
1300
|
+
@change=${e=>this.selectProject(e)}
|
|
1301
|
+
>
|
|
1302
|
+
${this.projects.map(e=>z`<option value=${e.id} ?selected=${e.id===this.project?.id}>${e.name}</option>`)}
|
|
1303
|
+
</select>
|
|
1304
|
+
${this.project?.path?z`<span class="break-all text-xs text-muted-foreground">${this.project.path}</span>`:null}
|
|
1305
|
+
</div>
|
|
1306
|
+
|
|
1307
|
+
<label class="grid max-w-xl gap-1.5 text-sm">
|
|
1308
|
+
<span class="inline-flex items-center gap-1.5 text-foreground">
|
|
1309
|
+
${W(`commandDirectories`)}
|
|
1310
|
+
<quickforge-info-tip .label=${W(`commandDirectoryHelp`)}></quickforge-info-tip>
|
|
1311
|
+
</span>
|
|
1312
|
+
<textarea
|
|
1313
|
+
class="min-h-28 rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
1314
|
+
.value=${this.commandDir}
|
|
1315
|
+
placeholder=${W(`commandDirectoryPlaceholder`)}
|
|
1316
|
+
@input=${e=>this.updateCommandDir(e.target.value)}
|
|
1317
|
+
></textarea>
|
|
1318
|
+
</label>
|
|
1319
|
+
|
|
1320
|
+
<div class="rounded-lg border border-border p-4 text-xs leading-5 text-muted-foreground">
|
|
1321
|
+
<div class="mb-1 font-medium text-foreground">${W(`commandDirectoryExamples`)}</div>
|
|
1322
|
+
<ul class="list-disc space-y-1 pl-5">
|
|
1323
|
+
<li>.ai/commands</li>
|
|
1324
|
+
<li>.claude/commands</li>
|
|
1325
|
+
<li>.opencode/commands</li>
|
|
1326
|
+
<li>D:\\shared\\ai-commands</li>
|
|
1327
|
+
</ul>
|
|
1328
|
+
</div>
|
|
1329
|
+
|
|
1330
|
+
<div class="flex flex-wrap items-center gap-3">
|
|
1331
|
+
<button
|
|
1332
|
+
class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-60"
|
|
1333
|
+
type="button"
|
|
1334
|
+
?disabled=${this.saving}
|
|
1335
|
+
@click=${()=>this.save()}
|
|
1336
|
+
>
|
|
1337
|
+
${this.saving?W(`saving`):W(`save`)}
|
|
1338
|
+
</button>
|
|
1339
|
+
${this.saved?z`<span class="text-sm text-muted-foreground">${W(`projectCommandsSaved`)}</span>`:null}
|
|
1340
|
+
${this.message?z`<span class="text-sm text-muted-foreground">${this.message}</span>`:null}
|
|
1341
|
+
${this.error?z`<span class="text-sm text-destructive">${this.error}</span>`:null}
|
|
1342
|
+
</div>
|
|
1343
|
+
|
|
1344
|
+
<section class="rounded-lg border border-border p-4">
|
|
1345
|
+
<div class="mb-3 flex flex-wrap items-center justify-between gap-2">
|
|
1346
|
+
<h4 class="text-sm font-semibold text-foreground">
|
|
1347
|
+
${W(`loadedCommands`,{count:this.commands.length})}
|
|
1348
|
+
</h4>
|
|
1349
|
+
<div class="flex items-center gap-2">
|
|
1350
|
+
<button
|
|
1351
|
+
class="rounded-md border border-border px-3 py-1.5 text-xs text-foreground hover:bg-muted/50 disabled:opacity-60"
|
|
1352
|
+
type="button"
|
|
1353
|
+
?disabled=${this.loadingCommands}
|
|
1354
|
+
@click=${()=>this.openCommandDir()}
|
|
1355
|
+
>
|
|
1356
|
+
${W(`openCommandDir`)}
|
|
1357
|
+
</button>
|
|
1358
|
+
<button
|
|
1359
|
+
class="rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 disabled:opacity-60"
|
|
1360
|
+
type="button"
|
|
1361
|
+
?disabled=${this.loadingCommands}
|
|
1362
|
+
@click=${()=>this.createCommand()}
|
|
1363
|
+
>
|
|
1364
|
+
${W(`createCommand`)}
|
|
1365
|
+
</button>
|
|
1366
|
+
</div>
|
|
1367
|
+
</div>
|
|
1368
|
+
|
|
1369
|
+
${this.loadingCommands?z`<div class="text-sm text-muted-foreground">${W(`loading`)}</div>`:this.commands.length===0?z`<p class="text-sm text-muted-foreground">${W(`noCommandsLoaded`)}</p>`:z`<ul class="grid gap-2">
|
|
1370
|
+
${this.commands.map(e=>{let t=e.argumentHint?` ${e.argumentHint}`:``;return z`
|
|
1371
|
+
<li class="grid gap-0.5 text-sm">
|
|
1372
|
+
<span class="text-foreground">
|
|
1373
|
+
<code class="text-xs">/${e.name}${t}</code>
|
|
1374
|
+
${e.description?z` — <span class="text-muted-foreground">${e.description}</span>`:null}
|
|
1375
|
+
</span>
|
|
1376
|
+
${e.relativePath?z`<span class="text-xs text-muted-foreground">${e.relativePath}</span>`:null}
|
|
1377
|
+
</li>
|
|
1378
|
+
`})}
|
|
1379
|
+
</ul>`}
|
|
1380
|
+
</section>
|
|
1381
|
+
</div>
|
|
1382
|
+
`}},Nc=`quickforge-project-commands-settings-tab`;customElements.get(Nc)||customElements.define(Nc,Mc);function Pc(){return document.createElement(Nc)}var Fc={"x-quickforge-action":`channel-action`};function Ic(e){switch(e){case`running`:return`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`;case`waiting_scan`:case`starting`:case`stopping`:return`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`;case`error`:return`border-destructive/30 bg-destructive/10 text-destructive`;default:return`border-border bg-muted/15 text-muted-foreground`}}function Lc(e){switch(e){case`starting`:return W(`channelStatusStarting`);case`waiting_scan`:return W(`channelStatusWaitingScan`);case`running`:return W(`channelStatusRunning`);case`stopping`:return W(`channelStatusStopping`);case`error`:return W(`channelStatusError`);default:return W(`channelStatusStopped`)}}function Rc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}var zc=class extends De{loading=!0;channels=[];workspaces=[];selectedWorkspaceIdByChannel={};error=``;message=``;eventSource;busyChannelId=``;getTabName(){return W(`channels`)}async connectedCallback(){super.connectedCallback(),await Promise.all([this.loadChannels(),this.loadWorkspaces()]),this.connectEvents()}disconnectedCallback(){this.eventSource?.close(),this.eventSource=void 0,super.disconnectedCallback()}async request(e,t){let n=await fetch(e,{...t,cache:`no-store`,headers:{...t?.headers||{}}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||W(`requestFailed`));return r}async loadChannels(){this.loading=!0,this.error=``,this.requestUpdate();try{let e=await this.request(`/api/channels`);this.channels=Array.isArray(e.channels)?e.channels:[],this.ensureWorkspaceSelections()}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.loading=!1,this.requestUpdate()}}async loadWorkspaces(){try{let e=await this.request(`/api/project`),t=e.defaultWorkspaceRoot||``,n=t?[{id:`default`,name:W(`channelDefaultWorkspace`),path:t,kind:`default`}]:[],r=(Array.isArray(e.projects)?e.projects:[]).map(e=>({id:e.id,name:e.name,path:e.path,kind:`project`}));this.workspaces=[...n,...r],this.ensureWorkspaceSelections()}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.requestUpdate()}}ensureWorkspaceSelections(){let e=new Set(this.workspaces.map(e=>e.id)),t={...this.selectedWorkspaceIdByChannel};for(let n of this.channels){if(!n.supportsWorkspaceSelection)continue;let r=t[n.id],i=n.launchWorkspace?.id,a=n.status!==`stopped`&&n.status!==`error`;if(i&&e.has(i)&&a){t[n.id]=i;continue}r&&e.has(r)||(t[n.id]=i&&e.has(i)?i:`default`)}this.selectedWorkspaceIdByChannel=t}connectEvents(){this.eventSource?.close();let e=new EventSource(`/api/channels/events`);this.eventSource=e;let t=e=>{try{let t=JSON.parse(e.data);this.applyChannelEvent(t)}catch{}};e.addEventListener(`snapshot`,t),e.addEventListener(`status`,t),e.addEventListener(`log`,t),e.addEventListener(`qrcode`,t),e.addEventListener(`error`,()=>{})}applyChannelEvent(e){if(Array.isArray(e.channels)){this.channels=e.channels,this.ensureWorkspaceSelections(),this.requestUpdate();return}if(e.snapshot){this.upsertChannel(e.snapshot);return}if(e.channelId&&e.log){let t=this.channels.find(t=>t.id===e.channelId);t&&(t.logs=[...t.logs||[],e.log].slice(-300),this.requestUpdate())}}upsertChannel(e){let t=this.channels.findIndex(t=>t.id===e.id);t>=0?this.channels=[...this.channels.slice(0,t),e,...this.channels.slice(t+1)]:this.channels=[...this.channels,e],this.ensureWorkspaceSelections(),this.requestUpdate()}selectedWorkspaceId(e){return this.selectedWorkspaceIdByChannel[e.id]||e.launchWorkspace?.id||`default`}handleWorkspaceChange(e,t){let n=t.currentTarget;n&&(this.selectedWorkspaceIdByChannel={...this.selectedWorkspaceIdByChannel,[e.id]:n.value||`default`},this.requestUpdate())}startOptions(e){return e.supportsWorkspaceSelection?{projectId:this.selectedWorkspaceId(e)}:void 0}async invoke(e,t){if(!this.busyChannelId&&!(t===`restart`&&!await J({description:W(`channelRestartConfirm`,{name:e.name}),confirmLabel:W(`restart`),cancelLabel:W(`cancel`)}))){this.busyChannelId=e.id,this.error=``,this.message=``,this.requestUpdate();try{let n=t===`start`||t===`restart`?this.startOptions(e):void 0,r=await this.request(`/api/channels/${encodeURIComponent(e.id)}/${t}`,{method:`POST`,headers:n?{...Fc,"content-type":`application/json`}:Fc,body:n?JSON.stringify(n):void 0});this.upsertChannel(r)}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.busyChannelId=``,this.requestUpdate()}}}async invokeAction(e,t){if(!this.busyChannelId&&!((t.destructive||t.id===`relogin`)&&!await J({description:t.id===`relogin`?W(`channelReloginConfirm`,{name:e.name}):W(`channelLogoutConfirm`,{name:e.name}),confirmLabel:t.label,cancelLabel:W(`cancel`),variant:t.destructive?`destructive`:void 0}))){this.busyChannelId=e.id,this.error=``,this.message=``,this.requestUpdate();try{let n=t.id===`relogin`?this.startOptions(e):void 0,r=await this.request(`/api/channels/${encodeURIComponent(e.id)}/actions/${encodeURIComponent(t.id)}`,{method:`POST`,headers:n?{...Fc,"content-type":`application/json`}:Fc,body:n?JSON.stringify(n):void 0});this.upsertChannel(r)}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.busyChannelId=``,this.requestUpdate()}}}workspaceSection(e,t){if(!e.supportsWorkspaceSelection)return null;let n=this.selectedWorkspaceId(e),r=e.launchWorkspace;return z`
|
|
1383
|
+
<div class="mt-4 rounded-lg border border-border bg-muted/10 p-3">
|
|
1384
|
+
<label class="inline-flex items-center gap-1.5 text-sm font-medium text-foreground" for=${`channel-workspace-${e.id}`}>
|
|
1385
|
+
${W(`channelWorkspace`)}
|
|
1386
|
+
<quickforge-info-tip .label=${W(`channelWorkspaceDescription`)}></quickforge-info-tip>
|
|
1387
|
+
</label>
|
|
1388
|
+
<select
|
|
1389
|
+
id=${`channel-workspace-${e.id}`}
|
|
1390
|
+
class="mt-3 w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground disabled:opacity-60"
|
|
1391
|
+
?disabled=${t}
|
|
1392
|
+
.value=${n}
|
|
1393
|
+
@change=${t=>this.handleWorkspaceChange(e,t)}
|
|
1394
|
+
>
|
|
1395
|
+
${this.workspaces.map(e=>z`
|
|
1396
|
+
<option value=${e.id}>${e.kind===`default`?W(`channelDefaultWorkspace`):e.name} — ${e.path}</option>
|
|
1397
|
+
`)}
|
|
1398
|
+
</select>
|
|
1399
|
+
${r?z`<div class="mt-2 text-xs text-muted-foreground">${W(`channelCurrentWorkspace`)}: <span class="font-mono">${r.path}</span></div>`:null}
|
|
1400
|
+
</div>
|
|
1401
|
+
`}channelMeta(e){return z`
|
|
1402
|
+
<dl class="grid gap-2 text-sm">
|
|
1403
|
+
${[[W(`channelProvider`),e.provider||`-`],[W(`channelCommand`),e.commandLabel||`-`],[W(`channelPid`),e.pid?String(e.pid):`-`],[W(`channelStartedAt`),Rc(e.startedAt)]].map(([e,t])=>z`
|
|
1404
|
+
<div class="grid gap-1 sm:grid-cols-[112px_1fr] sm:gap-3">
|
|
1405
|
+
<dt class="text-muted-foreground">${e}</dt>
|
|
1406
|
+
<dd class="min-w-0 break-all ${e===W(`channelCommand`)?`font-mono text-xs`:`text-foreground`}">${t}</dd>
|
|
1407
|
+
</div>
|
|
1408
|
+
`)}
|
|
1409
|
+
</dl>
|
|
1410
|
+
`}qrSection(e){return!e.qrCodeText&&!e.qrCodeUrl&&e.status!==`waiting_scan`?null:z`
|
|
1411
|
+
<div class="mt-4 rounded-lg border border-border bg-muted/10 p-3">
|
|
1412
|
+
<div class="inline-flex items-center gap-1.5 text-sm font-medium text-foreground">
|
|
1413
|
+
${W(`channelQrTitle`)}
|
|
1414
|
+
<quickforge-info-tip .label=${W(`channelQrDescription`)}></quickforge-info-tip>
|
|
1415
|
+
</div>
|
|
1416
|
+
${e.qrCodeText?z`<pre class="mt-3 max-h-96 overflow-auto whitespace-pre font-mono text-[10px] leading-none text-foreground">${e.qrCodeText}</pre>`:null}
|
|
1417
|
+
${e.qrCodeUrl?z`
|
|
1418
|
+
<div class="mt-3 text-xs text-muted-foreground">${W(`channelQrLink`)}</div>
|
|
1419
|
+
<a class="mt-1 block break-all font-mono text-xs text-primary hover:underline" href=${e.qrCodeUrl} target="_blank" rel="noreferrer">${e.qrCodeUrl}</a>
|
|
1420
|
+
`:null}
|
|
1421
|
+
</div>
|
|
1422
|
+
`}logsSection(e){let t=e.logs||[];return z`
|
|
1423
|
+
<details class="mt-4 rounded-lg border border-border bg-muted/10" open>
|
|
1424
|
+
<summary class="quickforge-channel-logs-summary cursor-pointer px-3 py-2 text-sm font-medium text-foreground">${W(`channelRecentLogs`)}</summary>
|
|
1425
|
+
<div class="max-h-72 overflow-auto p-3 font-mono text-xs leading-5">
|
|
1426
|
+
${t.length?t.slice(-80).map(e=>z`
|
|
1427
|
+
<div class="grid gap-1 py-0.5 sm:grid-cols-[72px_56px_1fr]">
|
|
1428
|
+
<span class="text-muted-foreground/55">${new Date(e.time).toLocaleTimeString()}</span>
|
|
1429
|
+
<span class=${e.stream===`stderr`?`text-destructive/80`:`text-muted-foreground/70`}>${e.stream}</span>
|
|
1430
|
+
<span class="min-w-0 whitespace-pre-wrap break-words text-foreground/85">${e.text}</span>
|
|
1431
|
+
</div>
|
|
1432
|
+
`):z`<div class="text-muted-foreground">${W(`channelNoLogs`)}</div>`}
|
|
1433
|
+
</div>
|
|
1434
|
+
</details>
|
|
1435
|
+
`}channelCard(e){let t=this.busyChannelId===e.id||!!e.activeAction,n=e.status===`running`||e.status===`waiting_scan`||e.status===`starting`,r=e.status===`stopping`,i=!!(e.supportsWorkspaceSelection&&this.workspaces.length===0);return z`
|
|
1436
|
+
<section class="rounded-lg border border-border p-4">
|
|
1437
|
+
<div class="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
|
|
1438
|
+
<div class="min-w-0">
|
|
1439
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
1440
|
+
<h4 class="text-sm font-semibold text-foreground">${e.name}</h4>
|
|
1441
|
+
<span class="inline-flex rounded-full border px-2 py-0.5 text-xs ${Ic(e.status)}">${Lc(e.status)}</span>
|
|
1442
|
+
</div>
|
|
1443
|
+
<p class="mt-1 text-sm text-muted-foreground">${e.description}</p>
|
|
1444
|
+
${e.requirements?.length?z`<div class="mt-2 text-xs text-muted-foreground/70">${W(`channelRequirements`)}: ${e.requirements.join(` · `)}</div>`:null}
|
|
1445
|
+
</div>
|
|
1446
|
+
<div class="flex shrink-0 flex-wrap gap-2">
|
|
1447
|
+
<button class="rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-60" type="button" ?disabled=${t||n||r||i} @click=${()=>this.invoke(e,`start`)}>${W(`start`)}</button>
|
|
1448
|
+
<button class="rounded-md border border-input px-3 py-2 text-sm hover:bg-muted/20 disabled:opacity-60" type="button" ?disabled=${t||!n||r} @click=${()=>this.invoke(e,`stop`)}>${W(`stop`)}</button>
|
|
1449
|
+
<button class="rounded-md border border-input px-3 py-2 text-sm hover:bg-muted/20 disabled:opacity-60" type="button" ?disabled=${t||r||i} @click=${()=>this.invoke(e,`restart`)}>${W(`restart`)}</button>
|
|
1450
|
+
${e.actions?.map(n=>z`
|
|
1451
|
+
<button class=${n.destructive?`rounded-md border border-destructive/40 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 disabled:opacity-60`:`rounded-md border border-input px-3 py-2 text-sm hover:bg-muted/20 disabled:opacity-60`} type="button" ?disabled=${t} @click=${()=>this.invokeAction(e,n)}>${n.label}</button>
|
|
1452
|
+
`)}
|
|
1453
|
+
</div>
|
|
1454
|
+
</div>
|
|
1455
|
+
|
|
1456
|
+
${this.workspaceSection(e,t||n||r)}
|
|
1457
|
+
${i?z`<div class="mt-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">${W(`channelNoWorkspaces`)}</div>`:null}
|
|
1458
|
+
<div class="mt-4">${this.channelMeta(e)}</div>
|
|
1459
|
+
${e.error?z`<div class="mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">${e.error}</div>`:null}
|
|
1460
|
+
${this.qrSection(e)}
|
|
1461
|
+
${this.logsSection(e)}
|
|
1462
|
+
</section>
|
|
1463
|
+
`}render(){return this.loading?z`<div class="text-sm text-muted-foreground">${W(`loading`)}</div>`:z`
|
|
1464
|
+
<div class="flex flex-col gap-6">
|
|
1465
|
+
<div>
|
|
1466
|
+
<h3 class="mb-2 inline-flex items-center gap-1.5 text-sm font-semibold text-foreground">
|
|
1467
|
+
${W(`channels`)}
|
|
1468
|
+
<quickforge-info-tip .label=${W(`channelsDescription`)}></quickforge-info-tip>
|
|
1469
|
+
</h3>
|
|
1470
|
+
</div>
|
|
1471
|
+
|
|
1472
|
+
<section class="rounded-lg border border-amber-500/30 bg-amber-500/10 p-4 text-sm text-amber-800 dark:text-amber-200">
|
|
1473
|
+
${W(`channelsSecurityWarning`)}
|
|
1474
|
+
</section>
|
|
1475
|
+
|
|
1476
|
+
${this.channels.length?z`<div class="grid gap-4">${this.channels.map(e=>this.channelCard(e))}</div>`:z`<div class="rounded-lg border border-border p-4 text-sm text-muted-foreground">${W(`channelsEmpty`)}</div>`}
|
|
1477
|
+
|
|
1478
|
+
${this.message?z`<div class="rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300">${this.message}</div>`:null}
|
|
1479
|
+
${this.error?z`<div class="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">${this.error}</div>`:null}
|
|
1480
|
+
</div>
|
|
1481
|
+
`}},Bc=`quickforge-channels-settings-tab`;customElements.get(Bc)||customElements.define(Bc,zc);function Vc(){return document.createElement(Bc)}var Hc=[`low`,`medium`,`high`,`xhigh`];function Uc(e){switch(e){case`low`:return W(`thinkingLow`);case`medium`:return W(`thinkingMedium`);case`high`:return W(`thinkingHigh`);case`xhigh`:return W(`thinkingXHigh`);default:return W(`thinkingOff`)}}function Wc(e){return e.id}function Gc(e,t=``){let n=document.createElement(`button`);return n.type=`button`,n.className=e,n.textContent=t,n}function Kc(e){document.querySelectorAll(`.quickforge-model-menu, .quickforge-model-submenu`).forEach(e=>{e.__quickforgeCleanup?.(),e.remove()}),e?.setAttribute(`aria-expanded`,`false`)}function qc(e){return e??document.querySelector(`.quickforge-model-trigger`)}function Jc(e,t){let n=qc(t),r=Math.min(260,window.innerWidth-24);e.style.width=`${r}px`;let i=e.offsetHeight||360;if(!n){e.style.left=`${Math.max(12,Math.round((window.innerWidth-r)/2))}px`,e.style.top=`${Math.max(12,Math.round((window.innerHeight-i)/2))}px`;return}let a=n.getBoundingClientRect(),o=Math.max(12,Math.min(a.right-r,window.innerWidth-r-12)),s=a.top-i-8,c=a.bottom+8,l=s>=12?s:Math.min(c,window.innerHeight-i-12);e.style.left=`${o}px`,e.style.top=`${Math.max(12,l)}px`}function Yc(e,t){let n=Math.min(252,window.innerWidth-24);e.style.width=`${n}px`;let r=t.getBoundingClientRect(),i=e.offsetHeight||320,a=r.left-n-0>=12?r.left-n-0:Math.min(r.right+0,window.innerWidth-n-12),o=Math.max(12,Math.min(r.top,window.innerHeight-i-12));e.style.left=`${a}px`,e.style.top=`${o}px`}function Xc(e){let t=Gc(`quickforge-model-menu-item`);t.setAttribute(`role`,`menuitemradio`),t.setAttribute(`aria-checked`,String(!!e.selected)),e.disabled&&(t.disabled=!0);let n=document.createElement(`span`);n.className=`quickforge-model-menu-item-label`,n.textContent=e.label;let r=document.createElement(`span`);return r.className=`quickforge-model-menu-item-suffix`,r.textContent=e.chevron?`›`:e.selected?`✓`:``,t.append(n,r),e.onPointerDown&&(t.onpointerdown=e.onPointerDown),e.onPointerEnter&&(t.onpointerenter=e.onPointerEnter),t}function Zc(e,t,n,r,i={}){let a=qc(i.anchor);if(document.querySelector(`.quickforge-model-menu`)){Kc(a);return}let o=i.thinkingLevel??`off`,s=e,c=null,l=document.createElement(`div`);l.className=`quickforge-model-menu`,l.setAttribute(`role`,`menu`),l.setAttribute(`aria-label`,W(`selectCustomModel`));let u=()=>{c?.remove(),c=document.createElement(`div`),c.className=`quickforge-model-submenu`,c.setAttribute(`role`,`menu`),c.setAttribute(`aria-label`,W(`model`));let e=document.createElement(`div`);e.className=`quickforge-model-menu-header`,e.textContent=W(`model`),c.append(e);let r=[...t].sort((e,t)=>Wc(e).localeCompare(Wc(t)));for(let e of r)c.append(Xc({label:Wc(e),selected:Me(s,e),onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),!e.reasoning&&o!==`off`&&(o=`off`,i.onThinkingLevelSelect?.(`off`)),s=e,n(e),Kc(a)}}));c.addEventListener(`pointerdown`,e=>e.stopPropagation()),document.body.append(c),Yc(c,l)},d=()=>{l.replaceChildren();let e=document.createElement(`div`);if(e.className=`quickforge-model-menu-header`,e.textContent=W(`reasoning`),l.append(e),s?.reasoning===!0)for(let e of Hc)l.append(Xc({label:Uc(e),selected:o===e,onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),o=e,i.onThinkingLevelSelect?.(e),d(),Jc(l,a)}}));else{let e=document.createElement(`div`);e.className=`quickforge-model-menu-note`,e.textContent=W(`thinkingNotSupported`),l.append(e)}let t=document.createElement(`div`);t.className=`quickforge-model-menu-separator`,l.append(t),l.append(Xc({label:s?Wc(s):W(`noModelAdded`),chevron:!0,onPointerEnter:u,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),u()}}))},f=()=>Kc(a),p=e=>{if(e.type===`resize`||e.type===`scroll`){Jc(l,a),c&&Yc(c,l);return}if(e instanceof KeyboardEvent){if(e.key!==`Escape`)return;e.preventDefault()}else{let t=e.target;if(l.contains(t)||c?.contains(t)||a?.contains(t))return}f()};l.__quickforgeCleanup=()=>{document.removeEventListener(`pointerdown`,p,!0),document.removeEventListener(`keydown`,p,!0),window.removeEventListener(`resize`,p,!0),window.removeEventListener(`scroll`,p,!0)},l.addEventListener(`pointerdown`,e=>e.stopPropagation()),d(),document.body.append(l),Jc(l,a),a?.setAttribute(`aria-expanded`,`true`),document.addEventListener(`pointerdown`,p,!0),document.addEventListener(`keydown`,p,!0),window.addEventListener(`resize`,p,!0),window.addEventListener(`scroll`,p,!0)}function Qc({storageRef:e,activeModelRef:t,agentRef:n,createAgent:r,updateCurrentAgentModel:i,setChatPanelRevision:a,needsModelSetup:o,setNeedsModelSetup:s,setRestoredDraft:c,notifySettingsChanged:l,setSettingsDialogOpen:u}){let d=(0,H.useCallback)(async()=>{let o=e.current;if(!o)return!1;let c=await Sn(o);return c?(t.current=c,s(!1),await dn(o,c),n.current?(i(c),a(e=>e+1)):await r({model:c,tools:[]},X(),{scope:`global`,attachToView:!0}),l(),!0):(s(!0),!1)},[e,t,n,r,i,a,s,l]),f=(0,H.useCallback)(e=>{u(!0),be.open([Os(),Ps(),qs(),Ts(),Pc(),nc(),cc(),bc(),Vc(),wc(),jc()],()=>{u(!1),(o||!n.current)&&d().catch(e=>V.error(`Failed to activate configured model:`,e))}),window.setTimeout(()=>{let t=document.querySelector(`settings-dialog`);t&&(t.activeTabIndex=e===`defaults`?2:e===`customModels`?3:10,t.requestUpdate?.())},0)},[d,o,n,u]),p=(0,H.useCallback)(()=>{f(`customModels`)},[f]);return{activateConfiguredModel:d,openModelSettings:p,openDefaultOptionsSettings:(0,H.useCallback)(()=>{f(`defaults`)},[f]),openAboutSettings:(0,H.useCallback)(()=>{f(`about`)},[f]),activateLiteLlmExampleModel:(0,H.useCallback)(async()=>{let o=e.current;if(!o)return;let c=sn($t);await Dn(o,$t,c),await dn(o,c),t.current=c,s(!1),n.current?(i(c),a(e=>e+1)):await r({model:c,tools:[]},X(),{scope:`global`,attachToView:!0}),l()},[e,t,n,r,i,a,s,l]),openCustomModelSelector:(0,H.useCallback)(async r=>{let o=e.current,s=n.current;if(!o||!s)return;let l=r instanceof HTMLElement?r:r?.currentTarget instanceof HTMLElement?r.currentTarget:document.querySelector(`.quickforge-model-trigger`),d=document.querySelector(`agent-interface message-editor textarea`),f=document.querySelector(`agent-interface message-editor`),m=d?.value??``,h=f?.attachments?[...f.attachments]:[],g=bn(await o.customProviders.getAll());if(g.length===0){await J({description:W(`addCustomModelFirst`),confirmLabel:W(`modelSetupAddModel`),cancelLabel:W(`cancel`)})&&p();return}Zc(s.state.model??t.current,g,e=>{let n=e,r=n.reasoning?s.state.thinkingLevel:`off`;s.state.thinkingLevel!==r&&(s.state.thinkingLevel=r,s.updateThinkingLevel(r).catch(e=>{V.error(`Failed to sync thinking level to server:`,e)})),t.current=n,i(n),(m||h.length>0)&&c({id:Date.now(),sessionId:s.sessionId,text:m,attachments:h}),a(e=>e+1),dn(o,n).catch(e=>{V.error(`Failed to save active model:`,e)})},async e=>{u(!0),await be.open([Os(),Ps(),qs(),Ts(e.provider),Pc(),nc(),cc(),bc(),Vc(),wc(),jc()],()=>u(!1));let t=document.querySelector(`settings-dialog`);t&&(t.activeTabIndex=3,t.requestUpdate?.())},{thinkingLevel:s.state.thinkingLevel,anchor:l,onThinkingLevelSelect:e=>{s.state.thinkingLevel=e,s.updateThinkingLevel(e).catch(e=>{V.error(`Failed to sync thinking level to server:`,e)}),a(e=>e+1)}})},[e,t,n,i,a,c,p,u])}}function $c(){let e=new URL(window.location.href);e.searchParams.delete(`session`),window.history.replaceState({},``,e)}function el(e){return!!(e&&!e.state.isStreaming&&e.state.messages.length===0)}function tl({storageRef:e,activeModelRef:t,activeProjectRef:n,currentChatScopeRef:r,currentSessionIdRef:i,taskMapRef:a,agentRef:o,startDeferredSession:s,createAgent:c,syncSessionUI:l,setCurrentAgentMessages:u,setChatPanelRevision:d,refreshSessions:f,needsModelSetup:p,switchActiveProject:m,closeWorkspacePage:h,setRestoredDraft:g}){let _=(0,H.useCallback)(async()=>{if(p){Y(W(`modelSetupRequired`));return}h(),!(el(o.current)&&r.current===`global`)&&(g(void 0),$c(),await s({scope:`global`}))},[o,r,p,g,h,s]),v=(0,H.useCallback)(async e=>{if(p){Y(W(`modelSetupRequired`));return}h();let t=e??n.current;t&&(el(o.current)&&r.current===`project`&&n.current?.id===t.id||(n.current?.id!==t.id&&await m(t.id),g(void 0),$c(),await s({scope:`project`,project:t})))},[n,o,r,p,g,h,s,m]),y=(0,H.useCallback)(async s=>{let p=o.current;if(!p)return;if(p.state.isStreaming){Y(W(`generationStillRunning`));return}let m=To(p.state.messages,s),h=m>=0?p.state.messages[m]:void 0;if(m<0||!h){Y(W(`noConversationTurnToRollback`));return}let _={id:Date.now(),sessionId:p.sessionId,text:Eo(h),attachments:h.role===`user-with-attachments`?h.attachments:void 0},v=p.state.messages.slice(0,m);try{v=(await p.rollback(s)).session.messages??v}catch(e){V.error(`Failed to rollback conversation:`,e),Y(e instanceof Error?e.message:W(`rollbackFailed`));return}u(v);let y=i.current?a.current.get(i.current):void 0;if(jo(v)&&y){_&&g(_),d(e=>e+1),l(y).catch(e=>V.error(`Failed to sync session UI:`,e));return}let b=e.current,x=i.current,S=r.current,C=S===`project`?n.current:void 0,w=p.state.model??t.current,T=p.state.thinkingLevel;if(x){let e=a.current.get(x);e?.unsubscribe(),e?.agent.dispose(),a.current.delete(x)}if(b&&x)try{await b.sessions.delete(x),await f({broadcast:!0})}catch(e){V.error(`Failed to delete rolled back empty session:`,e)}let E=X();await c({model:w,thinkingLevel:T,messages:[],tools:[]},E,{scope:S,project:C,attachToView:!0,title:`New chat`}),g({..._,sessionId:E}),d(e=>e+1)},[t,n,o,c,r,i,f,d,u,g,e,l,a]),b=(0,H.useCallback)(async e=>{try{await Do(e)}catch(e){throw V.error(`Failed to copy answer:`,e),Y(W(`copyFailed`)),e}},[]),x=(0,H.useCallback)(async i=>{let a=o.current;if(!a)return;if(a.state.isStreaming){Y(W(`generationStillRunning`));return}let s=a.state.messages.slice(0,i+1);if(!Ao(s))return;let l=r.current,u=l===`project`?n.current:void 0,d=X(),p=Oo(s),m=e.current;await c({model:a.state.model??t.current,thinkingLevel:a.state.thinkingLevel,messages:s,tools:[]},d,{scope:l,project:u,attachToView:!0,title:p}),m&&f({broadcast:!0}).catch(e=>V.error(`Failed to refresh sessions:`,e))},[t,n,o,c,r,f,e]);return{startNewGlobalChat:_,startNewProjectChat:v,rollbackFromMessage:y,retryFromMessage:(0,H.useCallback)(async e=>{let t=o.current;if(!t)return;if(t.state.isStreaming){Y(W(`generationStillRunning`));return}let n=t.state.messages;if(e<0||e>=n.length)return;let r=n[e];if(r.role!==`user`&&r.role!==`user-with-attachments`)return;u(n.slice(0,e+1)),d(e=>e+1);try{await t.continue()}catch(e){V.error(`Failed to retry:`,e),Y(e instanceof Error?e.message:W(`retryFailed`));return}let s=i.current?a.current.get(i.current):void 0;s&&(l(s).catch(e=>V.error(`Failed to sync session UI after retry:`,e)),d(e=>e+1))},[o,i,d,u,l,a]),copyAnswer:b,forkFromMessage:x}}function nl({activeProjectRef:e,refreshSessions:t,notifyProjectsChanged:n,setActiveProject:r,setProjects:i,setExpandedProjectIds:a,setChatPanelRevision:o}){return{deleteProjectInline:(0,H.useCallback)(async s=>{let c=await fetch(`/api/project/${encodeURIComponent(s)}`,{method:`DELETE`}),l=await c.json().catch(()=>null);if(!c.ok)throw Error(l?.error||`Failed to delete project`);r(l.project),i(l.projects),a(e=>{let t=new Set(e);return t.delete(s),t}),await t({broadcast:!0}),n(),e.current?.id===s&&(e.current=l.project,o(e=>e+1))},[e,t,n,r,i,a,o])}}function rl({options:e,onResolve:t}){let n=(0,H.useRef)(null),[r,i]=(0,H.useState)(e.defaultValue??``),a=(0,H.useRef)(r);return(0,H.useEffect)(()=>{a.current=r},[r]),(0,H.useEffect)(()=>{n.current?.focus(),n.current?.select()},[]),(0,H.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t(null),e.key===`Enter`&&a.current.trim()&&t(a.current.trim())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),(0,mt.createPortal)((0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onClick:e=>{e.target===e.currentTarget&&t(null)},children:(0,K.jsxs)(`div`,{className:G(`w-full max-w-sm rounded-lg border border-border bg-background p-6 shadow-quickforge`,`mx-4`),children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:e.title}),e.description?(0,K.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e.description}):null,(0,K.jsx)(`div`,{className:`mt-4`,children:(0,K.jsx)(bt,{ref:n,value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder,className:`w-full`})}),(0,K.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,K.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>t(null),children:e.cancelLabel??`Cancel`}),(0,K.jsx)(q,{size:`sm`,onClick:()=>r.trim()?t(r.trim()):void 0,disabled:!r.trim(),children:e.confirmLabel??`Save`})]})]})}),document.body)}function il(e){return new Promise(t=>{let n=document.createElement(`div`);document.body.appendChild(n);let r=(0,Fe.createRoot)(n);function i(){r.unmount(),setTimeout(()=>n.remove(),0)}function a(e){i(),t(e)}r.render((0,K.jsx)(rl,{options:e,onResolve:a}))})}function al({storageRef:e,taskMapRef:t,currentSessionIdRef:n,loadAgentSession:r,setCurrentTitleRef:i,refreshSessions:a,closeWorkspacePage:o,startNewGlobalChat:s}){return{loadSession:(0,H.useCallback)(e=>{o(),r(e)},[r,o]),renameSession:(0,H.useCallback)(async(t,r)=>{let o=e.current;if(!o)return;let s=await il({title:W(`renameSession`),description:W(`sessionName`),defaultValue:r,confirmLabel:W(`save`),cancelLabel:W(`cancel`)});if(!s||s===r)return;let c=await o.sessions.get(t);if(!c)return;let l=await o.sessions.getMetadata(t);l&&(await o.sessions.save(c,{...l,title:s}),await a({broadcast:!0}),n.current===t&&i(s))},[n,a,i,e]),togglePinSession:(0,H.useCallback)(async t=>{let n=e.current;if(!n)return;let r=await n.sessions.get(t);if(!r)return;let i=await n.sessions.getMetadata(t);if(!i)return;let o=i.pinnedAt?void 0:new Date().toISOString(),s={...r,pinnedAt:o},c={...i,pinnedAt:o};await n.sessions.save(s,c),await a({broadcast:!0})},[a,e]),archiveSession:(0,H.useCallback)(async r=>{let i=e.current;if(!i)return;let c=t.current.get(r);c?.unsubscribe(),c?.agent.dispose(),t.current.delete(r);let l=await i.sessions.get(r);if(!l)return;let u=await i.sessions.getMetadata(r);if(!u)return;let d=new Date().toISOString(),f={...l,archivedAt:d},p={...u,archivedAt:d};await i.sessions.save(f,p),await a({broadcast:!0}),n.current===r&&(o(),await s())},[n,a,o,s,e,t]),startNewGlobalSession:(0,H.useCallback)(()=>{o(),s()},[o,s])}}var ol=e=>e===`full-access`;function sl({storageRef:e,agentAccessModeRef:t,setAgentAccessMode:n,agentRef:r,setChatPanelRevision:i,notifySettingsChanged:a}){let o=(0,H.useCallback)(o=>{let s=e.current,c=r.current,l=t.current;if(l===o)return;n(o),t.current=o;let u=()=>{t.current=l,n(l),i(e=>e+1)};(async()=>{try{c&&await c.updateAccessMode(o),s&&await Tn(s,o),i(e=>e+1),a()}catch(e){V.error(`Failed to sync agent access mode:`,e),u(),Y(e instanceof Error?e.message:W(`agentAccessModeSyncFailed`))}})()},[t,r,a,n,i,e]);return{setAccessMode:o,toggleYoloMode:(0,H.useCallback)(()=>{o(ol(t.current)?`default`:`full-access`)},[t,o])}}function cl(){let[e,t]=(0,H.useState)(!0),[n,r]=(0,H.useState)(!1),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(`overview`),[b,x]=(0,H.useState)(),[S,C]=(0,H.useState)(``),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(),[ee,te]=(0,H.useState)(!1),[O,k]=(0,H.useState)(),[A,j]=(0,H.useState)(!1),[M,ne]=(0,H.useState)(),[N,P]=(0,H.useState)(!1),[re,F]=(0,H.useState)(!1);return{sidebarOpen:e,setSidebarOpen:t,mobileSidebarOpen:n,setMobileSidebarOpen:r,projectsCollapsed:i,setProjectsCollapsed:a,conversationsCollapsed:o,setConversationsCollapsed:s,mcpServersDialogOpen:c,setMcpServersDialogOpen:l,skillsDialog:u,setSkillsDialog:d,shareDialogOpen:f,setShareDialogOpen:p,conversationMenuOpen:m,setConversationMenuOpen:h,workspaceInspectorOpen:g,setWorkspaceInspectorOpen:_,workspacePanelView:v,setWorkspacePanelView:y,workspaceInspectorFocusTarget:b,setWorkspaceInspectorFocusTarget:x,webPreviewUrl:S,setWebPreviewUrl:C,artifactPreviewOpen:w,setArtifactPreviewOpen:T,activeArtifactPath:E,setActiveArtifactPath:D,inlineReaderOpen:ee,setInlineReaderOpen:te,inlineReaderFile:O,setInlineReaderFile:k,inlineReaderLoading:A,setInlineReaderLoading:j,inlineReaderError:M,setInlineReaderError:ne,firstUseGuideDismissed:N,setFirstUseGuideDismissed:P,settingsDialogOpen:re,setSettingsDialogOpen:F,toggleProjectsCollapsed:(0,H.useCallback)(()=>a(e=>!e),[]),toggleConversationsCollapsed:(0,H.useCallback)(()=>s(e=>!e),[])}}function ll(e){return e===`running`||e===`idle`||e===`error`||e===`aborted`?e:void 0}function ul(e){let[t,n]=(0,H.useState)({}),r=(0,H.useMemo)(()=>new Set(e.map(e=>e.id)),[e]),i=(0,H.useMemo)(()=>e.map(e=>e.id).sort().join(`
|
|
1482
|
+
`),[e]),a=(0,H.useCallback)(async()=>{if(r.size===0){n({});return}try{let e=await yo(),t=new Map(e.map(e=>[e.sessionId,ll(e.status)]).filter(e=>!!e[1]));n(e=>{let n={};for(let i of r){let r=t.get(i),a=e[i];r?n[i]=r:a===`running`?n[i]=`idle`:a&&a!==`idle`&&(n[i]=a)}return n})}catch(e){V.error(`Failed to refresh visible agent statuses:`,e)}},[r]);return(0,H.useEffect)(()=>{let e=window.setTimeout(()=>{a()},0);return()=>window.clearTimeout(e)},[a,i]),(0,H.useEffect)(()=>bo(e=>{let t=e.sessionId;if(!(!t||!r.has(t))){if(e.type===`agent_start`){n(e=>({...e,[t]:`running`}));return}if(e.type===`agent_end`){let r=ll(e.status)===`aborted`?`aborted`:e.errorMessage?`error`:`idle`;n(e=>({...e,[t]:r}))}}}),[r]),(0,H.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&a()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a]),t}function dl(e){return e===`idle`?{tone:`success`,message:W(`taskCompleted`)}:e===`error`?{tone:`error`,message:W(`taskError`)}:e===`aborted`?{tone:`aborted`,message:W(`processAborted`)}:e===`running`?{tone:`running`,message:W(`taskRunning`)}:{tone:`neutral`,message:W(`taskRunning`)}}function fl({toast:e,onDismiss:t,onClick:n}){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null);(0,H.useEffect)(()=>{let n=window.setTimeout(()=>i(!0),10);return s.current=window.setTimeout(()=>{o(!0),s.current=window.setTimeout(()=>t(e.id),200)},5e3),()=>{window.clearTimeout(n),s.current!==null&&window.clearTimeout(s.current)}},[e.id,t]);let c=()=>{o(!0),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>t(e.id),200)},l=dl(e.status),u=l.tone===`error`,d=l.tone===`success`,f=G(`size-5`,u&&`text-destructive`,d&&`text-emerald-500`,l.tone===`aborted`&&`text-amber-600`,l.tone===`running`&&`text-blue-600`,l.tone===`neutral`&&`text-muted-foreground`);return(0,K.jsxs)(`div`,{role:`alert`,onClick:()=>n(e.sessionId),className:G(`pointer-events-auto flex w-80 cursor-pointer items-start gap-3 rounded-xl border border-border bg-background p-3 shadow-quickforge transition-all duration-200 ease-out`,r&&!a?`translate-x-0 opacity-100`:`translate-x-4 opacity-0`),children:[(0,K.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:d?(0,K.jsx)(S,{className:f}):(0,K.jsx)(k,{className:f})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground/90`,children:e.title}),(0,K.jsx)(`p`,{className:`mt-0.5 line-clamp-3 text-xs text-muted-foreground`,children:e.message||l.message})]}),(0,K.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},className:`shrink-0 rounded-md p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground`,"aria-label":W(`close`),children:(0,K.jsx)(M,{className:`size-4`})})]})}function pl({toasts:e,onDismiss:t,onClick:n}){return e.length===0?null:(0,K.jsx)(`div`,{className:`pointer-events-none fixed right-4 top-16 z-50 flex flex-col gap-2`,children:e.map(e=>(0,K.jsx)(fl,{toast:e,onDismiss:t,onClick:n},e.id))})}async function ml(e,t){let n=await fetch(e,{...t,cache:`no-store`,headers:{...t?.body?{"content-type":`application/json`}:void 0,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Request failed: ${n.status}`);return r}function hl(e){if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`){let t=new Uint8Array(1);return crypto.getRandomValues(t),e[t[0]%e.length]}return e[Math.floor(Math.random()*e.length)]}function gl(){let e=()=>Array.from({length:6},()=>hl(`ABCDEFGHJKLMNPQRSTUVWXYZ23456789`)).join(``);return`${e()}-${e()}`}function _l(e=24){return new Date(Date.now()+e*60*60*1e3).toISOString()}async function vl(e){return ml(`/api/shares`,{method:`POST`,body:JSON.stringify(e)})}async function yl(e){return ml(`/api/shares${e?`?sessionId=${encodeURIComponent(e)}`:``}`)}async function bl(e){return ml(`/api/shares/${encodeURIComponent(e)}`,{method:`DELETE`})}async function xl(e){return ml(`/api/shared/${encodeURIComponent(e)}/meta`)}async function Sl(e,t=``){return ml(`/api/shared/${encodeURIComponent(e)}/unlock`,{method:`POST`,body:JSON.stringify({password:t})})}async function Cl(e){return ml(`/api/shared/${encodeURIComponent(e)}/models`)}function wl({open:e,sessionId:t,title:n,onOpenChange:r}){let i=(0,H.useId)(),[a,o]=(0,H.useState)(`read`),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(`24h`),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(``),[h,g]=(0,H.useState)([]),[_,y]=(0,H.useState)(!1),[b,x]=(0,H.useState)(),S=(0,H.useMemo)(()=>{if(l!==`never`)return _l(l===`1h`?1:l===`7d`?168:24)},[l]);if((0,H.useEffect)(()=>{!e||!t||yl(t).then(e=>g(e.shares)).catch(e=>x(e instanceof Error?e.message:`Failed to load shares`))},[e,t]),!e)return null;let C=a===`operate`,w=!!t&&(a!==`operate`||d&&s.trim()),T=async()=>{if(!(!t||!w)){if(C&&!s.trim()){x(`可操作分享必须设置密码。`);return}y(!0),x(void 0);try{let e=await vl({sessionId:t,permission:a,password:s.trim(),expiresAt:S});m(e.url),await Do(e.url),f(!1),g((await yl(t)).shares)}catch(e){x(e instanceof Error?e.message:`Failed to create share`)}finally{y(!1)}}},E=async e=>{let t=e.url||`${window.location.origin}/share/${encodeURIComponent(e.id)}`;m(t),await Do(t)},D=async e=>{try{await bl(e),g(t=>t.map(t=>t.id===e?{...t,revokedAt:new Date().toISOString()}:t))}catch(e){x(e instanceof Error?e.message:`Failed to revoke share`)}};return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,onMouseDown:e=>{e.target===e.currentTarget&&r(!1)},children:(0,K.jsxs)(`div`,{className:`flex max-h-[90vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-border bg-background shadow-quickforge`,onMouseDown:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`shrink-0 border-b border-border px-5 py-4`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold`,children:`分享到局域网`}),(0,K.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`当前对话:`,n,`。同一个对话只会有一个固定分享链接;只读分享密码可选,可操作分享必须设置密码。`]})]}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-2 text-sm font-medium`,children:`权限`}),(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`rounded-xl border p-3 text-left text-sm ${a===`read`?`border-primary bg-primary/10`:`border-border`}`,onClick:()=>o(`read`),children:[(0,K.jsx)(`div`,{className:`font-medium`,children:`仅阅读`}),(0,K.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:`只能查看这一个对话。`})]}),(0,K.jsxs)(`button`,{type:`button`,className:`rounded-xl border p-3 text-left text-sm ${a===`operate`?`border-red-400 bg-red-50 text-red-950`:`border-border`}`,onClick:()=>o(`operate`),children:[(0,K.jsx)(`div`,{className:`font-medium text-red-700`,children:`可操作(高危)`}),(0,K.jsx)(`div`,{className:`mt-1 text-xs text-red-700`,children:`允许对方操作这个原对话,禁止 Fork。`})]})]})]}),a===`operate`?(0,K.jsxs)(`div`,{className:`rounded-xl border border-red-300 bg-red-50 p-3 text-sm text-red-900`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2 font-semibold`,children:[(0,K.jsx)(ee,{className:`mt-0.5 size-4`}),`高危可操作权限`]}),(0,K.jsx)(`p`,{className:`mt-2 text-xs leading-5`,children:`拥有链接和密码的人只能操作这一个原对话,但对方的消息、停止生成、回滚、模型/思考等级选择、YOLO 状态下可用工具等操作会按正常对话权限直接影响你的本机原对话。可操作分享必须设置密码。`}),(0,K.jsxs)(`label`,{className:`mt-3 flex items-center gap-2 text-xs font-medium`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),`我已了解风险,仍然允许可操作权限。`]})]}):null,(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`label`,{htmlFor:i,className:`block text-sm font-medium`,children:C?`密码(可操作必填)`:`密码(可选)`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,K.jsx)(`input`,{id:i,value:s,onChange:e=>c(e.target.value),className:`h-10 w-full min-w-0 rounded-md border border-input bg-background px-3 text-sm`,placeholder:C?`可操作分享必须设置密码`:`留空则打开链接无需密码`}),(0,K.jsxs)(q,{variant:`outline`,className:`h-10 sm:shrink-0`,onClick:()=>c(gl()),children:[(0,K.jsx)(ie,{className:`mr-2 size-4`}),`生成密码`]})]}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:C?`可操作分享必须设置非空密码;修改密码后旧密码和已解锁状态会失效。`:`留空保存会取消密码保护;填写新密码保存后旧密码和已解锁状态会失效。`})]}),(0,K.jsxs)(`label`,{className:`block text-sm font-medium`,children:[`有效期`,(0,K.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),className:`mt-2 h-10 w-full rounded-md border border-input bg-background px-3 text-sm`,children:[(0,K.jsx)(`option`,{value:`1h`,children:`1 小时`}),(0,K.jsx)(`option`,{value:`24h`,children:`24 小时`}),(0,K.jsx)(`option`,{value:`7d`,children:`7 天`}),(0,K.jsx)(`option`,{value:`never`,children:`永久,需手动撤销`})]})]}),p?(0,K.jsxs)(`div`,{className:`rounded-xl border border-emerald-300 bg-emerald-50 p-3 text-sm text-emerald-900`,children:[`已复制到剪切板。`,(0,K.jsx)(`pre`,{className:`mt-2 max-h-36 overflow-auto whitespace-pre-wrap text-xs`,children:p})]}):null,b?(0,K.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:b}):null,h.length?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-2 text-sm font-medium`,children:`已有分享`}),(0,K.jsx)(`div`,{className:`space-y-2`,children:h.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border p-2 text-xs`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`truncate font-mono`,children:e.id}),(0,K.jsxs)(`div`,{className:`text-muted-foreground`,children:[e.permission===`operate`?`可操作`:`只读`,` · `,e.hasPassword?`有密码`:`无密码`,` · `,e.revokedAt?`已撤销`:e.expiresAt?`到期 ${new Date(e.expiresAt).toLocaleString()}`:`永久`]})]}),e.revokedAt?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>void E(e),"aria-label":`复制分享链接`,title:`复制分享链接`,children:(0,K.jsx)(te,{className:`size-4`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:`text-destructive`,onClick:()=>void D(e.id),"aria-label":`撤销分享`,title:`撤销分享`,children:(0,K.jsx)(v,{className:`size-4`})})]})]},e.id))})]}):null]})}),(0,K.jsx)(`div`,{className:`shrink-0 border-t border-border px-5 py-4`,children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(q,{variant:`outline`,onClick:()=>r(!1),children:W(`cancel`)}),(0,K.jsxs)(q,{variant:a===`operate`?`destructive`:`default`,disabled:!w||_,onClick:()=>void T(),title:a===`operate`&&!s.trim()?`可操作分享必须设置密码`:void 0,children:[(0,K.jsx)(te,{className:`mr-2 size-4`}),a===`operate`?`保存配置并复制高危可操作链接`:`保存配置并复制链接`]})]})})]})})}async function Tl(e){let t=await fetch(e,{cache:`no-store`}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`Request failed: ${t.status}`);return n}async function El(e,t){let n=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Request failed: ${n.status}`);return r}function Dl(e){return`projectId=${encodeURIComponent(e)}`}function Ol(e){return Tl(`/api/workspace/tree?${Dl(e)}`)}function kl(e,t){return Tl(`/api/workspace/file?${Dl(e)}&path=${encodeURIComponent(t)}`)}function Al(e,t){return El(`/api/workspace/resolve-path`,{projectId:e,path:t})}function jl(e){return Tl(`/api/git/status?${Dl(e)}`)}function Ml(e,t){return Tl(`/api/git/file-diff?${Dl(e)}&path=${encodeURIComponent(t)}`)}function Nl(e){let t=e.replace(/\\/g,`/`);return t.split(`/`).filter(Boolean).pop()||t||`artifact`}function Pl(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)?`html`:/\.(svg|png|jpe?g|webp|gif|bmp|ico)$/i.test(t)?`image`:t.endsWith(`.md`)||t.endsWith(`.mdx`)?`markdown`:/\.(ts|tsx|js|jsx|mjs|cjs|css|scss|less|json|jsonc|txt|xml|yml|yaml|toml|ini|py|rb|go|rs|java|c|h|cpp|hpp|cs|php|sh|bash|zsh|ps1)$/i.test(t)?`code`:`unknown`}function Fl(e){return Pl(e)!==`unknown`}var Il=/\.(svg|png|jpe?g|webp|gif|ico)$/i;function Ll(e){return Pl(e)===`html`||Il.test(e)}function Rl(e,t){let n=t.replace(/\\/g,`/`);return!e?.trim()||n.startsWith(`/`)||/^[a-zA-Z]:\//.test(n)?t:`${e.trim().replace(/\\/g,`/`).replace(/\/+$/,``)}/${n.replace(/^\/+/,``)}`}function zl(e,t,n){let r=t.replace(/\\/g,`/`),i=r.match(/^\/+/)?.[0]??``,a=i+r.slice(i.length).split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`),o=`/api/workspace/preview/${encodeURIComponent(e)}/${a}`;return n?`${o}?r=${n}`:o}function Bl(e){return e.replace(/\\/g,`/`).toLowerCase()}function Vl(e){let t=Nl(e.path).toLowerCase();return e.defaultPreview?0:e.explicit&&e.preview?1:e.explicit?2:t===`index.html`?3:e.kind===`html`?4:e.kind===`image`?5:e.kind===`markdown`?6:e.kind===`code`?7:20}function Hl(e){let t=new Map;for(let n of e){if(!n.path)continue;let e=Bl(n.path),r=n.kind??Pl(n.path),i=t.get(e),a=n.preview??Fl(n.path),o=n.source===`present_files`||n.presentation===`explicit`;if(!i){t.set(e,{id:e,path:n.path,title:n.title,description:n.description,kind:r,preview:a,defaultPreview:!!n.defaultPreview,explicit:o,addedLines:n.addedLines,removedLines:n.removedLines,sources:[n.source],toolCallIds:n.toolCallId?[n.toolCallId]:[]});continue}i.preview=i.preview||a,i.defaultPreview=i.defaultPreview||!!n.defaultPreview,i.explicit=i.explicit||o,i.title=n.title||i.title,i.description=n.description||i.description,typeof n.addedLines==`number`&&(i.addedLines=(i.addedLines??0)+n.addedLines),typeof n.removedLines==`number`&&(i.removedLines=(i.removedLines??0)+n.removedLines),i.kind=i.kind===`unknown`?r:i.kind,i.sources.includes(n.source)||i.sources.push(n.source),n.toolCallId&&!i.toolCallIds.includes(n.toolCallId)&&i.toolCallIds.push(n.toolCallId)}return[...t.values()].sort((e,t)=>Vl(e)-Vl(t))}function Ul(e){let t=Hl(e).filter(e=>e.preview&&e.explicit);if(t.length<=1)return t[0];let n=new Map;for(let t=0;t<e.length;t++){let r=e[t]?.toolCallId;r&&n.set(r,t)}let r=e=>{let t=e.toolCallIds,r=-1;for(let e of t){let t=n.get(e);typeof t==`number`&&t>r&&(r=t)}return r};return[...t].sort((e,t)=>r(t)-r(e))[0]}var Wl=(0,H.lazy)(()=>Pe(()=>import(`./ChatPanelHost-nzOC6Tbg.js`).then(e=>({default:e.ChatPanelHost})),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),Gl=(0,H.lazy)(()=>Pe(()=>import(`./TerminalDock-D-GWlS7P.js`).then(e=>({default:e.TerminalDock})),__vite__mapDeps([9,1,10,11,5,6]))),Kl=(0,H.lazy)(()=>Pe(()=>import(`./ScheduledTasksPage-BVjejep8.js`).then(e=>({default:e.ScheduledTasksPage})),__vite__mapDeps([12,1,5,6]))),ql=(0,H.lazy)(()=>Pe(()=>import(`./AgentProfilesPage-CGm7ZzRM.js`).then(e=>({default:e.AgentProfilesPage})),__vite__mapDeps([13,1,5,6]))),Jl=(0,H.lazy)(()=>Pe(()=>import(`./PluginsPage-K3o4AB2E.js`).then(e=>({default:e.PluginsPage})),__vite__mapDeps([14,1,5,6,7]))),Yl=(0,H.lazy)(()=>Pe(()=>import(`./SharedConversationPage-BwmUajLr.js`).then(e=>({default:e.SharedConversationPage})),__vite__mapDeps([15,1,3,2,4,5,6,0,7,8]))),Xl=(0,H.lazy)(()=>Pe(()=>import(`./WorkspaceInspector-CEU6nnM-.js`).then(e=>({default:e.WorkspaceInspector})),__vite__mapDeps([16,1,5,6,17,18]))),Zl=(0,H.lazy)(()=>Pe(()=>import(`./WorkspaceReaderDialog-D9Qy6LUm.js`).then(e=>({default:e.WorkspaceReaderDialog})),__vite__mapDeps([19,1,5,6,17,18]))),Ql=`quickforge:auto-preview-seen-signatures`,$l=200;function eu(){if(typeof window>`u`)return new Set;try{let e=window.sessionStorage.getItem(Ql),t=e?JSON.parse(e):void 0;return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`&&e.length>0)):new Set}catch{return new Set}}function tu(e){return eu().has(e)}function nu(e){if(!(typeof window>`u`))try{let t=[...eu(),e].slice(-$l);window.sessionStorage.setItem(Ql,JSON.stringify(t))}catch{}}function ru(){return(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:W(`loading`)})}function iu(){return null}function au(e){return e===`idle`||e===`running`||e===`error`||e===`aborted`}function ou(e){return e.type===`scheduled_task_notification`}function su(e){return e.type===`scheduled_task_started`}function cu(e){return e===`starting`||e===`waiting_scan`||e===`running`||e===`stopping`}function lu(e){return Array.isArray(e.channels)?e.channels.some(e=>cu(e.status)):cu(e.snapshot?.status)||cu(e.status)}function uu(e){return[...Array.isArray(e.channels)?e.channels:[],...e.snapshot?[e.snapshot]:[]].filter(e=>cu(e.status)).map(e=>e.launchWorkspace).filter(e=>e?.kind===`project`&&typeof e.id==`string`&&e.id.length>0).map(e=>e.id)}function du(){let e=(0,H.useRef)(null),t=(0,H.useRef)(sn($t)),r=(0,H.useRef)(`default`),i=(0,H.useRef)(void 0),o=(0,H.useRef)(void 0),{activeProject:s,projects:c,defaultWorkspace:u,expandedProjectIds:d,selectingProject:p,projectPickerOpen:m,loadProject:h,switchActiveProject:g,handleSelectProjectPath:_,selectProjectDirectory:v,setProjectPickerOpen:y,toggleProjectExpanded:b,toggleAllProjectsExpanded:S,reorderProjects:C,setActiveProject:w,setProjects:T,setExpandedProjectIds:E}=io(),{agentAccessMode:D,setAgentAccessMode:ee,initialize:te}=ao(),O=cl(),{setArtifactPreviewOpen:k,setWorkspaceInspectorOpen:A}=O,[j,M]=(0,H.useState)(!1),[ne,N]=(0,H.useState)(),[re,I]=(0,H.useState)(`chat`),[ie,L]=(0,H.useState)(!1),[R,oe]=(0,H.useState)(null),[se,ce]=(0,H.useState)([]),le=(0,H.useRef)(``),[ue,de]=(0,H.useState)(),[fe,pe]=(0,H.useState)(()=>new Set),me=(0,H.useRef)(0),[z,he]=(0,H.useState)(null),{toasts:ge,handleTaskComplete:_e,addToast:ve,dismissToast:ye}=zo(),be=re===`scheduledTasks`,B=re===`agentProfiles`,xe=re===`plugins`,Se=re!==`chat`,Ce=(0,H.useCallback)(()=>I(`chat`),[]),we=(0,H.useRef)(null),Te=(0,H.useRef)(null),{allLoadedSessions:Ee,globalSessions:De,sessionsForProject:Oe,globalHasMore:ke,projectHasMore:Ae,globalLoading:je,projectLoading:Me,projectLoaded:Ne,loadGlobalSessions:Pe,loadProjectSessions:Fe,refreshSessions:Ie,loadMoreGlobal:Le,loadMoreProject:Re}=Ro({backendRef:Te,expandedProjectIds:d,externalProjectIds:fe,onBroadcastSessionsChanged:(0,H.useCallback)(()=>we.current?.notifySessionsChanged(),[])}),ze=so({onSessionsChanged:()=>{Ie()},onProjectsChanged:()=>{h()},onSettingsChanged:()=>{Ie()}});(0,H.useEffect)(()=>{r.current=D},[D]),(0,H.useEffect)(()=>{i.current=s},[s]),(0,H.useEffect)(()=>{o.current=u},[u]),(0,H.useEffect)(()=>{we.current=ze},[ze]);let Be=(0,H.useCallback)((e,t)=>{de({sessionId:e,...t})},[]),U=Po({storageRef:e,activeModelRef:t,agentAccessModeRef:r,activeProjectRef:i,defaultWorkspaceRef:o,setAgentAccessMode:ee,switchActiveProject:g,sessions:Ee,refreshSessions:Ie,onTaskComplete:_e}),{createAgent:Ve,startDeferredSession:He,loadSession:Ue,syncSessionUI:We,setCurrentAgentMessages:Ge,updateCurrentAgentModel:Ke,setChatPanelRevision:qe,setCurrentTitleRef:Je,agentRef:Ye,taskMapRef:Xe,currentSessionIdRef:Ze,currentChatScopeRef:Qe}=U,$e=(0,H.useCallback)(e=>{e&&(Ce(),Ue(e))},[Ce,Ue]),et=(0,H.useCallback)(e=>{e.trim()&&(Ce(),N({id:Date.now(),sessionId:Ye.current?.sessionId,text:e}))},[Ye,Ce]),tt=(0,H.useCallback)(()=>{U.currentToolProject?.id&&(Ce(),k(!1),O.setWorkspacePanelView(`changes`),O.setWorkspaceInspectorFocusTarget({tab:`git`,nonce:Date.now()}),O.setWorkspaceInspectorOpen(!0))},[U.currentToolProject?.id,Ce,k,O]),nt=(0,H.useCallback)(async e=>{let t=U.currentToolProject?.id;if(!t){ve({sessionId:U.currentSessionId??``,title:`无法打开文件`,status:`error`,message:`当前对话没有关联项目。`});return}O.setInlineReaderOpen(!0),O.setInlineReaderLoading(!0),O.setInlineReaderError(void 0),O.setInlineReaderFile(void 0);try{let n=await kl(t,(await Al(t,e)).relativePath);O.setInlineReaderFile(n)}catch(e){let t=e instanceof Error?e.message:`打开文件失败`;O.setInlineReaderError(t),ve({sessionId:U.currentSessionId??``,title:`无法打开文件`,status:`error`,message:t})}finally{O.setInlineReaderLoading(!1)}},[ve,U.currentSessionId,U.currentToolProject?.id,O]),rt=(0,H.useCallback)(e=>{let t=U.currentToolProject;!t?.id||!Ll(e)||(Ce(),k(!1),O.setWebPreviewUrl(Rl(t.path,e)),O.setWorkspacePanelView(`browser`),A(!0))},[U.currentToolProject,Ce,k,A,O]);(0,H.useEffect)(()=>{let e=U.currentToolProject,t=e?.id;if(!t)return;let n=Ul(se);if(!n?.path)return;let r=n.toolCallIds[n.toolCallIds.length-1],i=`${t}:${n.path}:${n.defaultPreview?`default`:n.explicit?`explicit`:`inferred`}:${r??``}`;if(i!==le.current){if(tu(i)){le.current=i;return}le.current=i,nu(i),queueMicrotask(()=>{Ce(),k(!1),n.kind===`markdown`||n.kind===`code`?(O.setWorkspacePanelView(`files`),O.setWorkspaceInspectorFocusTarget({tab:`files`,filePath:n.path,nonce:Date.now()})):(O.setWebPreviewUrl(Rl(e.path,n.path)),O.setWorkspacePanelView(`browser`)),A(!0)})}},[U.currentToolProject,Ce,se,k,A,O]),(0,H.useEffect)(()=>{le.current=``,k(!1)},[U.currentToolProject?.id,k]),(0,H.useEffect)(()=>{if(!rt)return;let e=e=>{let t=e.detail;t&&typeof t.path==`string`&&rt(t.path)};return window.addEventListener(`quickforge:preview-artifact`,e),()=>window.removeEventListener(`quickforge:preview-artifact`,e)},[rt]),(0,H.useEffect)(()=>bo(e=>{if(su(e)){let t=typeof e.projectId==`string`?e.projectId:void 0;t&&(E(e=>{let n=new Set(e);return n.add(t),n}),Fe(t,0)),Ie({broadcast:!0});return}if((e.type===`agent_end`||e.type===`title_updated`||e.type===`session_forked`)&&Ie({broadcast:!0}),!ou(e))return;let t=typeof e.sessionId==`string`?e.sessionId:void 0,n=typeof e.title==`string`?e.title:W(`scheduledTasks`),r=au(e.status)?e.status:`idle`,i=typeof e.message==`string`?e.message:void 0;ve({sessionId:t??``,title:n,status:r,message:i})}),[ve,Fe,Ie,E]);let{ready:it,startupError:at,retryBootstrap:st}=ls({storageRef:e,backendRef:Te,activeModelRef:t,agentAccessModeRef:r,activeProjectRef:i,setAgentAccessMode:ee,taskMapRef:Xe,loadGlobalSessions:Pe,loadProject:h,initAgentAccessMode:te,switchActiveProject:g,createAgent:Ve,setNeedsModelSetup:M,onStorageReady:he}),lt=vs(e,it);(0,H.useEffect)(()=>{if(!it)return;let e=0,t,n=(t=[])=>{let n=Date.now();if(t.length>0&&pe(e=>{let n=new Set(e);for(let e of t)n.add(e);return n}),!(n-e<5e3)){e=n,h(),Ie();for(let e of t)Fe(e,0)}},r=e=>{if(!e){t&&window.clearInterval(t),t=void 0;return}t||=window.setInterval(n,15e3)},i=new EventSource(`/api/channels/events`),a=e=>{try{let t=JSON.parse(e.data),i=uu(t);lu(t)?(r(!0),n(i)):(t.type===`snapshot`||t.type===`status`)&&r(!1)}catch{}};return i.addEventListener(`snapshot`,a),i.addEventListener(`status`,a),i.addEventListener(`log`,a),()=>{i.close(),t&&window.clearInterval(t)}},[h,Fe,it,Ie]),(0,H.useEffect)(()=>{if(it)for(let e of d)!Ne(e)&&!Me(e)&&Fe(e,0)},[it,d,Ne,Me,Fe]);let{startNewGlobalChat:ut,startNewProjectChat:dt,rollbackFromMessage:ft,retryFromMessage:mt,copyAnswer:ht,forkFromMessage:gt}=tl({storageRef:e,activeModelRef:t,activeProjectRef:i,currentChatScopeRef:Qe,currentSessionIdRef:Ze,taskMapRef:Xe,agentRef:Ye,createAgent:Ve,startDeferredSession:He,syncSessionUI:We,setCurrentAgentMessages:Ge,setChatPanelRevision:qe,refreshSessions:Ie,needsModelSetup:j,switchActiveProject:g,closeWorkspacePage:Ce,setRestoredDraft:N}),{deleteProjectInline:_t}=nl({activeProjectRef:i,refreshSessions:Ie,notifyProjectsChanged:ze.notifyProjectsChanged,setActiveProject:w,setProjects:T,setExpandedProjectIds:E,setChatPanelRevision:qe}),{setAccessMode:vt}=sl({storageRef:e,agentAccessModeRef:r,setAgentAccessMode:ee,agentRef:Ye,setChatPanelRevision:qe,notifySettingsChanged:ze.notifySettingsChanged}),yt=(0,H.useCallback)(async e=>{let t=Ye.current;if(!t)throw Error(W(`toolApprovalFailed`));try{await t.approveToolCall(e)}catch(e){throw V.error(`Failed to approve tool call:`,e),e instanceof Error?e:Error(W(`toolApprovalFailed`))}},[Ye]),bt=(0,H.useCallback)(async e=>{let t=Ye.current;if(!t)throw Error(W(`toolApprovalFailed`));try{await t.rejectToolCall(e)}catch(e){throw V.error(`Failed to reject tool call:`,e),e instanceof Error?e:Error(W(`toolApprovalFailed`))}},[Ye]),xt=(0,H.useCallback)(async e=>{let t=Ye.current;if(!t?.approveAutoCompact)throw Error(W(`toolApprovalFailed`));await t.approveAutoCompact(e)},[Ye]),St=(0,H.useCallback)(async e=>{let t=Ye.current;if(!t?.rejectAutoCompact)throw Error(W(`toolApprovalFailed`));await t.rejectAutoCompact(e)},[Ye]),{loadSession:Ct,renameSession:wt,togglePinSession:Tt,archiveSession:Et,startNewGlobalSession:Dt}=al({storageRef:e,taskMapRef:Xe,currentSessionIdRef:Ze,loadAgentSession:Ue,setCurrentTitleRef:Je,refreshSessions:Ie,closeWorkspacePage:Ce,startNewGlobalChat:ut}),{openModelSettings:Ot,openDefaultOptionsSettings:kt,openAboutSettings:At,activateLiteLlmExampleModel:jt,openCustomModelSelector:Mt}=Qc({storageRef:e,activeModelRef:t,agentRef:Ye,createAgent:Ve,updateCurrentAgentModel:Ke,setChatPanelRevision:qe,needsModelSetup:j,setNeedsModelSetup:M,setRestoredDraft:N,notifySettingsChanged:ze.notifySettingsChanged,setSettingsDialogOpen:O.setSettingsDialogOpen}),Nt=(0,H.useMemo)(()=>[...De,...c.flatMap(e=>Oe(e.id))],[De,c,Oe]),Pt=!!(0,H.useMemo)(()=>{if(U.currentSessionId)return Nt.find(e=>e.id===U.currentSessionId)},[U.currentSessionId,Nt])?.pinnedAt,Ft=ul(Nt),It=(0,H.useCallback)(e=>U.taskStatuses[e.id]??Ft[e.id]??e.taskStatus??`idle`,[U.taskStatuses,Ft]);(0,H.useEffect)(()=>{if(!O.conversationMenuOpen)return;let e=()=>O.setConversationMenuOpen(!1);return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e)}},[O,O.conversationMenuOpen]),(0,H.useEffect)(()=>{let e=e=>{let t=e.detail,n=typeof t?.command==`string`?t.command.trim():``;n&&(async()=>{(t?.confirm||t?.dangerous)&&!await J({title:W(`confirmExecuteCommandTitle`),description:t?.dangerous?W(`confirmExecuteDangerousCommand`):W(`confirmExecuteMultipleCommands`),confirmLabel:W(`executeInTerminal`),cancelLabel:W(`cancel`),variant:t?.dangerous?`destructive`:`default`})||(L(!0),oe({id:++me.current,command:n,execute:!0}))})().catch(e=>{V.error(`Failed to execute markdown command:`,e),Y(e instanceof Error?e.message:W(`terminalCommandExecuteFailed`))})};return window.addEventListener(`quickforge:execute-markdown-command`,e),()=>window.removeEventListener(`quickforge:execute-markdown-command`,e)},[]);let Lt=(0,H.useCallback)(e=>{oe(t=>t?.id===e?null:t)},[]),Rt=(0,H.useCallback)(()=>{O.setFirstUseGuideDismissed(!0)},[O]),Bt=(0,H.useCallback)(()=>{let e=U.currentToolProject?.id?W(`firstUseGuideProjectPrompt`):W(`firstUseGuideGeneralPrompt`);navigator.clipboard.writeText(e).then(()=>ve({sessionId:U.currentSessionId??``,title:W(`copied`),status:`idle`,message:e})).catch(e=>{V.error(`Failed to copy first-use guide prompt:`,e),Y(W(`copyFailed`))})},[ve,U.currentSessionId,U.currentToolProject?.id]),Vt=!j&&!Se&&!!U.agent&&!U.agent?.state.isStreaming&&(U.agent?.state.messages.length??0)===0,Ht=(0,H.useCallback)(e=>{dt(e)},[dt]),X=(0,H.useCallback)(()=>{Dt()},[Dt]),Ut=(0,H.useCallback)(()=>{v()},[v]),Z=!!z&&!O.firstUseGuideDismissed&&!ie&&!Vt&&c.length===0&&De.length===0,Wt=(0,H.useCallback)(()=>{let e=U.currentSessionId;e&&(O.setConversationMenuOpen(!1),Tt(e))},[U.currentSessionId,Tt,O]),Gt=(0,H.useCallback)(()=>{let e=U.currentSessionId;e&&(O.setConversationMenuOpen(!1),wt(e,U.currentTitle))},[U.currentSessionId,U.currentTitle,wt,O]),qt=(0,H.useCallback)(()=>{O.setConversationMenuOpen(!1),O.setShareDialogOpen(!0)},[O]),{setSkillsDialog:Jt,setMcpServersDialogOpen:Yt,setSidebarOpen:Xt}=O,Zt=(0,H.useCallback)(()=>{Jt({scope:`global`})},[Jt]),Qt=(0,H.useCallback)(e=>{Jt({scope:`project`,project:e})},[Jt]),en=(0,H.useCallback)(async e=>{let t=await fetch(`/api/project/${encodeURIComponent(e.id)}/open-in-explorer`,{method:`POST`});if(t.ok)return;let n=await t.json().catch(()=>null);throw Error(n?.error||W(`openInExplorerFailed`))},[]),tn=(0,H.useCallback)(()=>{Yt(!0)},[Yt]),nn=(0,H.useCallback)(e=>{en(e).catch(e=>{V.error(`Failed to open project in explorer:`,e),Y(e instanceof Error?e.message:W(`openInExplorerFailed`))})},[en]),rn=(0,H.useCallback)(()=>I(`scheduledTasks`),[I]),an=(0,H.useCallback)(()=>I(`agentProfiles`),[I]),on=(0,H.useCallback)(()=>I(`plugins`),[I]),cn=(0,H.useCallback)(()=>Xt(e=>!e),[Xt]),Q=(0,H.useCallback)(()=>{O.setMobileSidebarOpen(!1)},[O]),ln=(0,H.useCallback)(e=>{Q(),Ct(e)},[Q,Ct]),un=(0,H.useCallback)(()=>{Q(),Dt()},[Q,Dt]),dn=(0,H.useCallback)(e=>{Q(),dt(e)},[Q,dt]),fn=(0,H.useCallback)(()=>{Q(),I(`scheduledTasks`)},[Q]),pn=(0,H.useCallback)(()=>{Q(),I(`agentProfiles`)},[Q]),mn=(0,H.useCallback)(()=>{Q(),Zt()},[Q,Zt]),hn=(0,H.useCallback)(()=>{Q(),O.setMcpServersDialogOpen(!0)},[Q,O]),gn=(0,H.useCallback)(e=>{Q(),Qt(e)},[Q,Qt]),_n=(0,H.useCallback)(e=>{if(e.scope===`project`&&e.project&&e.projects){T(e.projects),O.setSkillsDialog({scope:`project`,project:e.project}),i.current?.id===e.project.id&&(w(e.project),i.current=e.project),ze.notifyProjectsChanged();return}ze.notifyProjectsChanged()},[ze,w,T,O]),vn=(0,K.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-muted-foreground`,children:W(`loadingChatWorkspace`)});return at?(0,K.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-background p-6 text-foreground`,children:(0,K.jsxs)(`div`,{className:`max-w-md rounded-lg border border-border bg-background p-5 text-center`,children:[(0,K.jsx)(`h1`,{className:`text-base font-semibold`,children:W(`localServiceUnavailableTitle`)}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:at}),(0,K.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,K.jsx)(q,{variant:`outline`,size:`sm`,onClick:st,children:W(`retry`)}),(0,K.jsx)(q,{variant:`default`,size:`sm`,onClick:()=>window.location.reload(),children:W(`reloadPage`)})]})]})}):!it||!U.agent&&!j?(0,K.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-background text-foreground`,children:(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:W(`loadingChatWorkspace`)})}):(0,K.jsxs)(K.Fragment,{children:[!O.settingsDialogOpen&&(0,K.jsxs)(`div`,{className:`quickforge-window-toolbar fixed right-2 top-2 z-[60] flex items-center gap-1`,"aria-label":W(`workspacePanel`),children:[(0,K.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>L(e=>!e),disabled:Se||j,"aria-label":`终端`,title:`终端`,className:ie?`bg-accent text-accent-foreground`:void 0,children:(0,K.jsx)(P,{className:`size-4`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>{k(!1),O.setWorkspaceInspectorOpen(e=>!e)},disabled:!U.currentToolProject?.id||Se||j,"aria-label":O.workspaceInspectorOpen?W(`workspaceCollapseRightPanel`):W(`workspaceExpandRightPanel`),title:O.workspaceInspectorOpen?W(`workspaceCollapseRightPanel`):W(`workspaceExpandRightPanel`),className:G(`hidden lg:inline-flex`,O.workspaceInspectorOpen?`bg-accent text-accent-foreground`:void 0),children:(0,K.jsx)(a,{className:`size-4`})})]}),(0,K.jsxs)(`div`,{className:`flex h-screen min-h-0 bg-[var(--quickforge-sidebar-bg)] text-foreground`,children:[(0,K.jsx)(ro,{sidebarOpen:O.sidebarOpen,scheduledTasksActive:be,agentProfilesActive:B,pluginsActive:xe,projectsCollapsed:O.projectsCollapsed,conversationsCollapsed:O.conversationsCollapsed,projects:c,expandedProjectIds:d,activeProject:s,currentSessionId:U.currentSessionId,globalSessions:De,sessionsForProject:Oe,globalHasMore:ke,globalLoading:je,onLoadMoreGlobal:Le,projectHasMore:Ae,projectLoading:Me,projectLoaded:Ne,onLoadMoreProject:Re,sessionTaskStatus:It,selectingProject:p,onToggleProjectsCollapsed:O.toggleProjectsCollapsed,onToggleConversationsCollapsed:O.toggleConversationsCollapsed,onToggleProjectExpanded:b,onToggleAllProjectsExpanded:S,onReorderProjects:C,onSelectProjectDirectory:v,onStartNewProjectChat:dt,onOpenGlobalSkills:Zt,onOpenMcpServers:tn,onOpenProjectSkills:Qt,onOpenProjectInExplorer:nn,onDeleteProject:_t,onLoadSession:Ct,onTogglePinSession:Tt,onRenameSession:wt,onDeleteSession:Et,onStartNewGlobalChat:Dt,onOpenScheduledTasks:rn,onOpenAgentProfiles:an,onOpenPlugins:on,onOpenSettings:kt,updateAvailable:lt.result.updateAvailable,latestVersion:lt.result.latestVersion,currentVersion:lt.result.currentVersion,onOpenUpdate:At,onDismissUpdate:lt.dismissUpdate,onToggleSidebar:cn,currentSessionHoverInfo:ue}),O.mobileSidebarOpen?(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 md:hidden`,role:`dialog`,"aria-modal":`true`,children:[(0,K.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-background/65 backdrop-blur-sm`,onClick:Q,"aria-label":W(`toggleSidebar`)}),(0,K.jsx)(`div`,{className:`absolute inset-y-0 left-0 max-w-[85vw] shadow-quickforge`,children:(0,K.jsx)(ro,{variant:`mobile`,sidebarOpen:!0,scheduledTasksActive:be,agentProfilesActive:B,pluginsActive:xe,projectsCollapsed:O.projectsCollapsed,conversationsCollapsed:O.conversationsCollapsed,projects:c,expandedProjectIds:d,activeProject:s,currentSessionId:U.currentSessionId,globalSessions:De,sessionsForProject:Oe,globalHasMore:ke,globalLoading:je,onLoadMoreGlobal:Le,projectHasMore:Ae,projectLoading:Me,projectLoaded:Ne,onLoadMoreProject:Re,sessionTaskStatus:It,selectingProject:p,onToggleProjectsCollapsed:O.toggleProjectsCollapsed,onToggleConversationsCollapsed:O.toggleConversationsCollapsed,onToggleProjectExpanded:b,onToggleAllProjectsExpanded:S,onReorderProjects:C,onSelectProjectDirectory:()=>{Q(),v()},onStartNewProjectChat:dn,onOpenGlobalSkills:mn,onOpenMcpServers:hn,onOpenProjectSkills:gn,onOpenProjectInExplorer:e=>{Q(),en(e).catch(e=>{V.error(`Failed to open project in explorer:`,e),Y(e instanceof Error?e.message:W(`openInExplorerFailed`))})},onDeleteProject:_t,onLoadSession:ln,onTogglePinSession:Tt,onRenameSession:wt,onDeleteSession:Et,onStartNewGlobalChat:un,onOpenScheduledTasks:fn,onOpenAgentProfiles:pn,onOpenPlugins:()=>{Q(),I(`plugins`)},onOpenSettings:()=>{Q(),kt()},updateAvailable:lt.result.updateAvailable,latestVersion:lt.result.latestVersion,currentVersion:lt.result.currentVersion,onOpenUpdate:()=>{Q(),At()},onDismissUpdate:lt.dismissUpdate,onToggleSidebar:Q,currentSessionHoverInfo:ue})})]}):null,(0,K.jsxs)(`main`,{className:G(`flex min-w-0 flex-1 flex-col bg-[var(--quickforge-main-bg)] md:overflow-hidden md:rounded-l-2xl`,O.workspaceInspectorOpen&&U.currentToolProject?.id?`lg:rounded-r-2xl`:void 0),children:[(0,K.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-3 pr-20`,children:[(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:()=>O.setMobileSidebarOpen(!0),"aria-label":W(`toggleSidebar`),children:(0,K.jsx)(l,{className:`size-4`})}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:be?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:`AI Workspace`}),(0,K.jsx)(`div`,{className:`truncate text-sm font-medium`,children:W(`scheduledTasks`)})]}):B?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:`AI Workspace`}),(0,K.jsx)(`div`,{className:`truncate text-sm font-medium`,children:W(`agentsTab`)})]}):xe?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:`AI Workspace`}),(0,K.jsx)(`div`,{className:`truncate text-sm font-medium`,children:W(`plugins`)})]}):(0,K.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center`,children:[U.currentToolProject?.name?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`min-w-0 truncate text-sm text-muted-foreground/60`,children:U.currentToolProject.name}),(0,K.jsx)(`div`,{className:`mx-1 shrink-0 text-sm text-muted-foreground/45`,children:`/`})]}):null,(0,K.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium text-foreground/90`,children:Kt(U.currentTitle)}),(0,K.jsxs)(`div`,{className:`relative ml-0.5 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:()=>O.setConversationMenuOpen(e=>!e),disabled:!U.currentSessionId||j,"aria-label":W(`moreOptions`),"aria-expanded":O.conversationMenuOpen,children:(0,K.jsx)(F,{className:`size-4`})}),O.conversationMenuOpen?(0,K.jsxs)(`div`,{className:`absolute left-0 top-8 z-30 min-w-44 rounded-lg border border-border bg-popover p-1 shadow-quickforge`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm text-foreground/86 transition-colors hover:bg-muted`,onClick:Wt,children:[Pt?(0,K.jsx)(n,{className:`size-4`}):(0,K.jsx)(f,{className:`size-4`}),(0,K.jsx)(`span`,{children:W(Pt?`unpinSession`:`pinSession`)})]}),(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm text-foreground/86 transition-colors hover:bg-muted`,onClick:Gt,children:[(0,K.jsx)(ae,{className:`size-4`}),(0,K.jsx)(`span`,{children:W(`renameSession`)})]}),(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm text-foreground/86 transition-colors hover:bg-muted`,onClick:qt,children:[(0,K.jsx)(x,{className:`size-4`}),(0,K.jsx)(`span`,{children:W(`shareSession`)})]})]}):null]})]})})]}),(0,K.jsx)(`section`,{className:`relative flex min-h-0 flex-1 flex-col`,children:be?(0,K.jsx)(H.Suspense,{fallback:vn,children:(0,K.jsx)(Kl,{onOpenSession:$e})}):B?(0,K.jsx)(H.Suspense,{fallback:vn,children:(0,K.jsx)(ql,{})}):xe?(0,K.jsx)(H.Suspense,{fallback:vn,children:(0,K.jsx)(Jl,{})}):j?(0,K.jsx)(kn,{onAddModel:Ot,onUseExample:()=>{jt().catch(e=>V.error(`Failed to use LiteLLM example:`,e))}}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:G(`flex min-h-0 flex-1 flex-col`,Vt?`quickforge-empty-chat`:void 0),children:[Vt?(0,K.jsx)(`div`,{className:`quickforge-empty-chat-hero`,"aria-hidden":`true`,children:(0,K.jsx)(`h1`,{className:`quickforge-empty-chat-title`,children:W(`newChatEmptyTitle`)})}):null,(0,K.jsx)(ot,{children:(0,K.jsx)(H.Suspense,{fallback:(0,K.jsx)(ru,{}),children:(0,K.jsx)(Wl,{agent:U.agent,onModelSelect:Mt,revision:U.chatPanelRevision,agentAccessMode:D,workspaceToolsEnabled:!!U.currentToolProject?.id,project:U.currentToolProject,projectId:U.currentToolProject?.id,chatScope:U.chatScope,onAccessModeChange:vt,onRollbackFromMessage:ft,onRetryFromMessage:mt,onCopyAnswer:ht,onForkFromMessage:gt,onApproveToolCall:yt,onRejectToolCall:bt,onApproveAutoCompact:xt,onRejectAutoCompact:St,onOpenWorkspaceGitChanges:tt,onOpenLocalFilePath:nt,onArtifactsChange:ce,onContextUsageDisplayChange:Be,disableFork:!1,restoredDraft:ne,newChatEmptyState:Vt})})}),Vt?(0,K.jsx)(An,{projects:c,selectedProject:U.currentToolProject,chatScope:U.chatScope,onSelectProject:Ht,onClearProject:X,onNewProject:Ut}):null]}),Z?(0,K.jsx)(On,{hasProject:!!U.currentToolProject?.id,onConfigureModel:Ot,onAddProject:v,onCopyExamplePrompt:Bt,onDismiss:Rt}):null,ie?(0,K.jsx)(H.Suspense,{fallback:null,children:(0,K.jsx)(Gl,{project:U.currentToolProject,pendingCommand:R,onPendingCommandHandled:Lt,onCollapse:()=>L(!1)})}):null]})})]}),O.workspaceInspectorOpen&&U.currentToolProject?.id?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`hidden w-px shrink-0 bg-[color-mix(in_oklab,var(--border)_30%,var(--quickforge-sidebar-bg))] lg:block`}),(0,K.jsx)(H.Suspense,{fallback:(0,K.jsx)(iu,{}),children:(0,K.jsx)(Xl,{project:U.currentToolProject,open:!0,view:O.workspacePanelView,onViewChange:O.setWorkspacePanelView,onPreviewArtifact:rt,onDraftRequest:et,focusTarget:O.workspaceInspectorFocusTarget,previewUrl:O.webPreviewUrl,onPreviewUrlChange:O.setWebPreviewUrl,artifacts:se})})]}):null,O.inlineReaderOpen?(0,K.jsx)(H.Suspense,{fallback:(0,K.jsx)(iu,{}),children:(0,K.jsx)(Zl,{open:!0,mode:`file`,file:O.inlineReaderFile,loading:O.inlineReaderLoading,error:O.inlineReaderError,onOpenChange:O.setInlineReaderOpen,onDraftRequest:et})}):null]}),(0,K.jsx)(ct,{open:m,initialPath:s?.path,disabled:p,onOpenChange:y,onSelect:_}),(0,K.jsx)(pt,{open:!!O.skillsDialog,scope:O.skillsDialog?.scope??`global`,project:O.skillsDialog?.project,onOpenChange:e=>{e||O.setSkillsDialog(void 0)},onSaved:_n}),(0,K.jsx)(zt,{open:O.mcpServersDialogOpen,onOpenChange:O.setMcpServersDialogOpen}),(0,K.jsx)(wl,{open:O.shareDialogOpen,sessionId:U.currentSessionId,title:Kt(U.currentTitle),onOpenChange:O.setShareDialogOpen}),(0,K.jsx)(pl,{toasts:ge,onDismiss:ye,onClick:$e})]})}function fu(){let e=window.location.pathname.match(/^\/share\/([^/]+)\/?$/)?.[1];return e?(0,K.jsx)(H.Suspense,{fallback:(0,K.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-background text-sm text-muted-foreground`,children:W(`loadingChatWorkspace`)}),children:(0,K.jsx)(Yl,{shareId:decodeURIComponent(e)})}):(0,K.jsx)(du,{})}nt({hideSelector:!0}),it(),window.addEventListener(`error`,e=>{V.error(`Uncaught error:`,e.error??e.message)}),window.addEventListener(`unhandledrejection`,e=>{V.error(`Unhandled promise rejection:`,e.reason)}),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`).catch(()=>{})}),(0,Fe.createRoot)(document.getElementById(`root`)).render((0,K.jsx)(H.StrictMode,{children:(0,K.jsx)(ot,{children:(0,K.jsx)(fu,{})})}));export{Ht as A,co as C,un as D,xn as E,G as F,W as I,J as M,dt as N,hn as O,q as P,po as S,fn as T,wo as _,Hl as a,To as b,jl as c,xl as d,Cl as f,Wo as g,as as h,Fl as i,Y as j,Sn as k,kl as l,Zc as m,Pl as n,zl as o,Sl as p,Ll as r,Ml as s,Nl as t,Ol as u,Do as v,mo as w,uo as x,Eo as y};
|