@aiderdesk/aiderdesk 0.76.0 → 0.77.0

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.
Files changed (90) hide show
  1. package/out/cli.js +124 -17
  2. package/out/renderer/assets/{AgentSettings-Dc8h1zSI.js → AgentSettings-B73lGg-P.js} +2 -2
  3. package/out/renderer/assets/{InfoIcon-BuABw5oZ.js → InfoIcon-BaDK-htg.js} +1 -1
  4. package/out/renderer/assets/{Onboarding-lX23sGcW.js → Onboarding-CttlAepw.js} +4 -4
  5. package/out/renderer/assets/{ProviderHeader-s7JSikLR.js → ProviderHeader-B0-K9908.js} +2 -2
  6. package/out/renderer/assets/{SettingsPage-CcsH6kmE.js → SettingsPage-BtyX7Wv1.js} +40 -11
  7. package/out/renderer/assets/{UsageDashboard-oAQNYvYh.js → UsageDashboard-CKuev9SP.js} +3 -3
  8. package/out/renderer/assets/{arc-BiaIwS79.js → arc-CDCMm4PF.js} +1 -1
  9. package/out/renderer/assets/{architectureDiagram-3BPJPVTR-d7fu6X13.js → architectureDiagram-3BPJPVTR-DoyTFQYe.js} +3 -3
  10. package/out/renderer/assets/{blockDiagram-GPEHLZMM-CWD8GVpw.js → blockDiagram-GPEHLZMM-CophuS51.js} +4 -4
  11. package/out/renderer/assets/{c4Diagram-AAUBKEIU-b5nYOm14.js → c4Diagram-AAUBKEIU-Dc3YxNWW.js} +2 -2
  12. package/out/renderer/assets/{channel-B99g0IUF.js → channel-cZzRDUFG.js} +1 -1
  13. package/out/renderer/assets/{chunk-2J33WTMH-DmrXuNY-.js → chunk-2J33WTMH-YV6ZtOyU.js} +1 -1
  14. package/out/renderer/assets/{chunk-4BX2VUAB-4Soxfj2i.js → chunk-4BX2VUAB-DKNGjk29.js} +1 -1
  15. package/out/renderer/assets/{chunk-55IACEB6-BtS727h4.js → chunk-55IACEB6-MkIW5gHI.js} +1 -1
  16. package/out/renderer/assets/{chunk-727SXJPM-CVxcBF7D.js → chunk-727SXJPM-CPUXDO_8.js} +5 -5
  17. package/out/renderer/assets/{chunk-AQP2D5EJ-m8ArTZfD.js → chunk-AQP2D5EJ-CYCp3XBh.js} +3 -3
  18. package/out/renderer/assets/{chunk-FMBD7UC4-yWO_9Kky.js → chunk-FMBD7UC4-DIj-DOVN.js} +1 -1
  19. package/out/renderer/assets/{chunk-ND2GUHAM-BkVCmcvx.js → chunk-ND2GUHAM-BWiS_Ttp.js} +1 -1
  20. package/out/renderer/assets/{chunk-QZHKN3VN-DwLbWeqf.js → chunk-QZHKN3VN-4NHol9Dz.js} +1 -1
  21. package/out/renderer/assets/{classDiagram-4FO5ZUOK-B3t9RWJZ.js → classDiagram-4FO5ZUOK-C1yfJEIb.js} +6 -6
  22. package/out/renderer/assets/{classDiagram-v2-Q7XG4LA2-B3t9RWJZ.js → classDiagram-v2-Q7XG4LA2-C1yfJEIb.js} +6 -6
  23. package/out/renderer/assets/{cose-bilkent-S5V4N54A-W70GNPEp.js → cose-bilkent-S5V4N54A-B8D60fQa.js} +1 -1
  24. package/out/renderer/assets/{dagre-BM42HDAG-D_Val_ih.js → dagre-BM42HDAG-5_V5lQc0.js} +3 -3
  25. package/out/renderer/assets/{diagram-2AECGRRQ-Z7UeOtJN.js → diagram-2AECGRRQ-Bb4cbiKY.js} +3 -3
  26. package/out/renderer/assets/{diagram-5GNKFQAL-DY9Yifty.js → diagram-5GNKFQAL-DQ_vjlxb.js} +4 -4
  27. package/out/renderer/assets/{diagram-KO2AKTUF-CGi0HZww.js → diagram-KO2AKTUF-So0t9fVd.js} +3 -3
  28. package/out/renderer/assets/{diagram-LMA3HP47-bdoVxL2p.js → diagram-LMA3HP47-CbSRJgt4.js} +3 -3
  29. package/out/renderer/assets/{diagram-OG6HWLK6-2K829auL.js → diagram-OG6HWLK6-Bls2tZCJ.js} +4 -4
  30. package/out/renderer/assets/{erDiagram-TEJ5UH35-D4sO1GH8.js → erDiagram-TEJ5UH35-CESbOlvh.js} +4 -4
  31. package/out/renderer/assets/{flowDiagram-I6XJVG4X-DQNz4Jg_.js → flowDiagram-I6XJVG4X-B-35DKDx.js} +6 -6
  32. package/out/renderer/assets/{ganttDiagram-6RSMTGT7-B3dUFX1p.js → ganttDiagram-6RSMTGT7-BL1OQkTj.js} +3 -3
  33. package/out/renderer/assets/{gitGraphDiagram-PVQCEYII-B95Lrq_7.js → gitGraphDiagram-PVQCEYII-SJkGLAAz.js} +4 -4
  34. package/out/renderer/assets/{graph-7kCtdoo_.js → graph-BSxR7Gef.js} +1 -1
  35. package/out/renderer/assets/{index-B2TL7Kll.js → index-BVOpoJw8.js} +1 -1
  36. package/out/renderer/assets/{index-58fbbmhI.js → index-BqZxyppq.js} +1 -1
  37. package/out/renderer/assets/{index-CNgsMipO.js → index-Cmn9J2p1.js} +4692 -1953
  38. package/out/renderer/assets/{index-BnFS7uhp.js → index-DFODyrlX.js} +3 -3
  39. package/out/renderer/assets/{index-BoogYopJ.js → index-DGcKtfCM.js} +1 -1
  40. package/out/renderer/assets/{index-DcD881Q1.css → index-DVEVSdXO.css} +21 -0
  41. package/out/renderer/assets/{index-pvhejocY.js → index-DgDxO_E3.js} +1 -1
  42. package/out/renderer/assets/{index-CRfveI6m.js → index-HJk8ZKtm.js} +1 -1
  43. package/out/renderer/assets/{index-Bihcg0ql.js → index-NF_MxNl9.js} +1 -1
  44. package/out/renderer/assets/{index-BHaWBJe9.js → index-VX8ukL4o.js} +1 -1
  45. package/out/renderer/assets/{index-GRVDmgjb.js → index-xCqv98zj.js} +1 -1
  46. package/out/renderer/assets/{infoDiagram-5YYISTIA-C0OH2to7.js → infoDiagram-5YYISTIA-lRTvqfXx.js} +2 -2
  47. package/out/renderer/assets/{ishikawaDiagram-YF4QCWOH-DsgR-cKp.js → ishikawaDiagram-YF4QCWOH-CtsU-ctO.js} +1 -1
  48. package/out/renderer/assets/{journeyDiagram-JHISSGLW-Bg6okgzG.js → journeyDiagram-JHISSGLW-3MrLeKXj.js} +4 -4
  49. package/out/renderer/assets/{jsx-dev-runtime-DLJNe6VM.js → jsx-dev-runtime-BTcJ8PkQ.js} +1 -1
  50. package/out/renderer/assets/{kanban-definition-UN3LZRKU-1UvLCrWk.js → kanban-definition-UN3LZRKU-CinUVJ12.js} +2 -2
  51. package/out/renderer/assets/{layout-9w0fH2nL.js → layout-C9eRMSnE.js} +2 -2
  52. package/out/renderer/assets/{linear-WTE7GZY2.js → linear-WwW43_Ig.js} +1 -1
  53. package/out/renderer/assets/{mindmap-definition-RKZ34NQL-BlxjYw-a.js → mindmap-definition-RKZ34NQL-B-K0dkdA.js} +3 -3
  54. package/out/renderer/assets/{pieDiagram-4H26LBE5-C4jZuzAH.js → pieDiagram-4H26LBE5-eotxzUOT.js} +4 -4
  55. package/out/renderer/assets/pierre-dark-BL-l9r39.js +4 -0
  56. package/out/renderer/assets/pierre-dark-protanopia-deuteranopia-BBjGuJQU.js +4 -0
  57. package/out/renderer/assets/pierre-dark-soft-B6TBhICr.js +4 -0
  58. package/out/renderer/assets/pierre-dark-tritanopia-f-j_EX9A.js +4 -0
  59. package/out/renderer/assets/pierre-dark-vibrant-yElMGqZN.js +4 -0
  60. package/out/renderer/assets/pierre-light-BUzWTcjO.js +4 -0
  61. package/out/renderer/assets/pierre-light-protanopia-deuteranopia-DlvVSCaI.js +4 -0
  62. package/out/renderer/assets/pierre-light-soft-CCMU-Zh0.js +4 -0
  63. package/out/renderer/assets/pierre-light-tritanopia-v4xacE1C.js +4 -0
  64. package/out/renderer/assets/pierre-light-vibrant-BRUbQnMc.js +4 -0
  65. package/out/renderer/assets/{quadrantDiagram-W4KKPZXB-BLG4PrcM.js → quadrantDiagram-W4KKPZXB-BtKKvYmW.js} +2 -2
  66. package/out/renderer/assets/{requirementDiagram-4Y6WPE33-CTTFFDvR.js → requirementDiagram-4Y6WPE33-k_JQl4AM.js} +3 -3
  67. package/out/renderer/assets/{sankeyDiagram-5OEKKPKP-CjDlOfXf.js → sankeyDiagram-5OEKKPKP-BVDWaFSn.js} +1 -1
  68. package/out/renderer/assets/{sequenceDiagram-3UESZ5HK-6PJo_0SQ.js → sequenceDiagram-3UESZ5HK-dpVnolZO.js} +3 -3
  69. package/out/renderer/assets/{stateDiagram-AJRCARHV-Cnhm9mmx.js → stateDiagram-AJRCARHV-DYd-R9tJ.js} +6 -6
  70. package/out/renderer/assets/{stateDiagram-v2-BHNVJYJU-BxKTEg-3.js → stateDiagram-v2-BHNVJYJU-CyE2HX6z.js} +4 -4
  71. package/out/renderer/assets/{time-YGhgEMYh.js → time-Claj2vse.js} +1 -1
  72. package/out/renderer/assets/{timeline-definition-PNZ67QCA-ooi5Tti4.js → timeline-definition-PNZ67QCA-0vKYrH6S.js} +2 -2
  73. package/out/renderer/assets/{vennDiagram-CIIHVFJN-B_kwCHhU.js → vennDiagram-CIIHVFJN-op3DVQGG.js} +1 -1
  74. package/out/renderer/assets/{wardley-L42UT6IY-Dnx4ZTc4.js → wardley-L42UT6IY-CsNzYaF9.js} +1 -1
  75. package/out/renderer/assets/{wardleyDiagram-YWT4CUSO-cqZcXF7R.js → wardleyDiagram-YWT4CUSO-D3jK8kAv.js} +3 -3
  76. package/out/renderer/assets/{worker-BdXuKH1Q.js → worker-CdcPcIJG.js} +322 -102
  77. package/out/renderer/assets/{xychartDiagram-2RQKCTM6-BBUpFNY4.js → xychartDiagram-2RQKCTM6-C9wPvZAU.js} +2 -2
  78. package/out/renderer/index.html +2 -2
  79. package/out/resources/connector/connector.py +3 -1
  80. package/out/resources/prompts/init-project.hbs +16 -42
  81. package/out/resources/prompts/system-prompt.hbs +25 -60
  82. package/out/resources/prompts/workflow.hbs +17 -52
  83. package/out/resources/skills/extension-creator/SKILL.md +1 -0
  84. package/out/resources/skills/extension-creator/references/event-types.md +13 -1
  85. package/out/runner.js +819 -156
  86. package/package.json +2 -2
  87. package/out/renderer/assets/pierre-dark-C-Drv5KU.js +0 -4
  88. package/out/renderer/assets/pierre-dark-soft-Cd74uQaL.js +0 -4
  89. package/out/renderer/assets/pierre-light-CfQnmt6J.js +0 -4
  90. package/out/renderer/assets/pierre-light-soft-DMVdU74b.js +0 -4
package/out/runner.js CHANGED
@@ -49,6 +49,7 @@ const AdmZip = require("adm-zip");
49
49
  const Turndown = require("turndown");
50
50
  const cheerio = require("cheerio");
51
51
  const gpt4o = require("gpt-tokenizer/model/gpt-4o");
52
+ const ai = require("ai");
52
53
  const uuid = require("uuid");
53
54
  const index_js = require("@modelcontextprotocol/sdk/client/index.js");
54
55
  const stdio_js = require("@modelcontextprotocol/sdk/client/stdio.js");
@@ -60,12 +61,11 @@ const express = require("express");
60
61
  const cors = require("cors");
61
62
  const cloudflared = require("cloudflared");
62
63
  const socket_io = require("socket.io");
64
+ const crypto = require("crypto");
63
65
  const yamlFrontMatter = require("yaml-front-matter");
64
66
  const debounce = require("lodash/debounce.js");
65
- const crypto = require("crypto");
66
67
  const undici = require("undici");
67
68
  const globalAgent = require("global-agent");
68
- const ai = require("ai");
69
69
  const fileType = require("file-type");
70
70
  const anthropic = require("@ai-sdk/anthropic");
71
71
  const azure = require("@ai-sdk/azure");
@@ -144,24 +144,10 @@ Prerequisite: Before using, check the current context with 'get_context_files'.
144
144
  Use relative file path(s) for files intended for editing within the project. Use absolute file path(s) for read-only files (e.g., outside the project).`,
145
145
  [AIDER_TOOL_DROP_CONTEXT_FILES]: `Removes file(s) from the Aider context.
146
146
  Note: Unless explicitly requested by the user to remove specific file(s), this tool should primarily be used to remove files that were previously added using 'add_context_files' (e.g., after a related 'run_prompt' task is completed).`,
147
- [AIDER_TOOL_RUN_PROMPT]: `Delegates a natural language coding task to the Aider assistant for execution within the current project context.
148
- Use this tool for:
149
- - Writing new code.
150
- - Modifying or refactoring existing code.
151
- - Explaining code segments.
152
- - Debugging code.
153
- - Implementing new features.
154
- - This tools must be preferred (if not specified by user otherwise) over other tools creating or modifying files, as it is more efficient and effective.
155
-
156
- Prerequisites
157
- - All relevant existing project files for the task MUST be added to the Aider context using 'add_context_files' BEFORE calling this tool.
158
-
159
- Input:
160
- - A clear, complete, and standalone natural language prompt describing the coding task.
147
+ [AIDER_TOOL_RUN_PROMPT]: `Delegates a context-aware coding task to the Aider assistant for execution within the current project context.
148
+ Use this tool when implementing, modifying, refactoring, debugging, or otherwise making non-trivial code changes.
161
149
 
162
- Restrictions:
163
- - Prompts MUST be language-agnostic. Do NOT mention specific programming languages (e.g., Python, JavaScript), libraries, or syntax elements.
164
- - Treat Aider as a capable programmer; provide sufficient detail but avoid excessive handholding.
150
+ Before calling it, add the relevant files that are not already in Aider's context. Provide a clear, standalone prompt with the task goal, constraints, and context Aider needs; let Aider use its judgment on implementation details.
165
151
  `
166
152
  };
167
153
  const MEMORY_TOOL_GROUP_NAME = "memory";
@@ -171,7 +157,7 @@ const MEMORY_TOOL_DELETE = "delete_memory";
171
157
  const MEMORY_TOOL_LIST = "list_memories";
172
158
  const MEMORY_TOOL_UPDATE = "update_memory";
173
159
  const MEMORY_TOOL_DESCRIPTIONS = {
174
- [MEMORY_TOOL_STORE]: "Stores important information, patterns, or preferences into memory for future tasks",
160
+ [MEMORY_TOOL_STORE]: "Stores durable, reusable, actionable user preferences, architectural decisions, or repeated codebase patterns for future tasks. Do not store secrets, personal data, task status, transient details, logs, or facts directly readable from a single file.",
175
161
  [MEMORY_TOOL_RETRIEVE]: `Searches and retrieves relevant memories using semantic vector search.
176
162
 
177
163
  RETRIEVAL STRATEGY:
@@ -206,7 +192,7 @@ const myFunction = () => {
206
192
  [POWER_TOOL_FILE_WRITE]: "Writes content to a specified file. Can create a new file, overwrite an existing file, or append to an existing file.",
207
193
  [POWER_TOOL_GLOB]: "Finds files and directories matching a specified glob pattern within the project. Useful for discovering files based on patterns.",
208
194
  [POWER_TOOL_GREP]: "Searches for content matching a regular expression pattern within files specified by a glob pattern. Returns matching lines and their context.",
209
- [POWER_TOOL_SEMANTIC_SEARCH]: "Search code in repository using semantic search. Use natural language queries with 2-5 descriptive words including key concepts and context. Can filter results with hints like ext:ts, dir:src, or lang:typescript. Use this tool first for any code-related questions to find relationships between files and identify files to change.",
195
+ [POWER_TOOL_SEMANTIC_SEARCH]: "Search code in the repository using natural-language queries with 2-5 descriptive words including key concepts and context. Use it to locate related implementations, explore unfamiliar areas, or identify potentially affected files. It can filter results with hints such as ext:ts, dir:src, or lang:typescript.",
210
196
  [POWER_TOOL_BASH]: "Executes a shell command. For safety, commands may be sandboxed or require user approval (approval handled by Agent).",
211
197
  [POWER_TOOL_FETCH]: 'Fetches and returns the content of a web page from a specified URL. Useful for retrieving web content, documentation, or external resources. Supports three formats: "markdown" (default, converts HTML to markdown), "html" (returns raw HTML), "raw" (fetches raw content via HTTP, ideal for API responses or raw files like GitHub raw files).',
212
198
  [SUBAGENTS_TOOL_RUN_TASK]: "Description is generated dynamically based on enabled agent profiles with subagent functionality."
@@ -232,7 +218,7 @@ const TASKS_TOOL_SEARCH_TASK = "search_task";
232
218
  const TASKS_TOOL_RUN_PROMPT = "run_prompt";
233
219
  const TASKS_TOOL_SEARCH_PARENT_TASK = "search_parent_task";
234
220
  const TASKS_TOOL_DESCRIPTIONS = {
235
- [TASKS_TOOL_LIST_TASKS]: "List all tasks in the current project. Returns basic information for each task including id, name, and creation/update timestamps. Use this to get an overview of all available tasks before performing specific task operations.",
221
+ [TASKS_TOOL_LIST_TASKS]: "List tasks in the current project. Supports pagination and filtering by state, created/updated date ranges, working mode (local or worktree), archived/pinned status, parent task, name, agent profile, provider, and model. Returns basic information for each matching task including id, name, dates, state, and working mode.",
236
222
  [TASKS_TOOL_GET_TASK]: "Get comprehensive details about a specific task by its ID. Returns task metadata, current state, list of context files with their read-only status, and the total count of context messages. Use this to understand a task's configuration and context before working with it or its messages.",
237
223
  [TASKS_TOOL_GET_TASK_MESSAGE]: "Retrieve a specific message from a task's conversation history by message index and task ID. The first message (index 0) is always the user's initial prompt, and subsequent messages alternate between user and assistant. Use this to examine the conversation flow, understand previous interactions, or extract specific information from the task history.",
238
224
  [TASKS_TOOL_CREATE_TASK]: "Create a new task in the current project with an initial prompt. Optionally use user-provided agentProfileId to use a different agent, a modelId to override the model, or a parentTaskId (if available) to create a subtask of another task. The new task will start with the provided prompt as its first user message. Use this to begin new work streams, separate different aspects of a project, or break down complex tasks into manageable subtasks. Use execute to create a task and wait for the task to be finished. Use executeInBackground to create a task in the background without waiting for the task to be finished.",
@@ -897,11 +883,13 @@ const EXTENSIONS_REPOS_CACHE_DIR = path.join(AIDER_DESK_CACHE_DIR, "extensions")
897
883
  const POSTHOG_PUBLIC_API_KEY = "phc_AF4zkjrcziXLh8PBFsRSvVr4VZ38p3ezsdX0KDYuElI";
898
884
  const POSTHOG_HOST = "https://eu.i.posthog.com";
899
885
  const HEADLESS_MODE = process.env.AIDER_DESK_HEADLESS === "true";
886
+ const READONLY_MODE = process.env.AIDER_DESK_READONLY === "true";
900
887
  const APP_TYPE = process.env.AIDER_DESK_APP_TYPE || (HEADLESS_MODE ? "docker" : "electron");
901
888
  process.env.AIDER_DESK_DISABLE_MENU === "true";
902
889
  const AUTH_USERNAME = process.env.AIDER_DESK_USERNAME;
903
890
  const AUTH_PASSWORD = process.env.AIDER_DESK_PASSWORD;
904
891
  const CORS_ALLOWED_ORIGINS = process.env.AIDER_DESK_CORS_ALLOWED_ORIGINS;
892
+ const READONLY_EXTENSION_UI = process.env.AIDER_DESK_READONLY_EXTENSION_UI;
905
893
  const PROBE_BINARY_PATH = path.join(
906
894
  RESOURCES_DIR,
907
895
  process.platform === "win32" ? "win" : process.platform === "darwin" ? "macos" : "linux",
@@ -1577,6 +1565,7 @@ const AVAILABLE_PROVIDERS = [
1577
1565
  var OpenAiVoiceModel = /* @__PURE__ */ ((OpenAiVoiceModel2) => {
1578
1566
  OpenAiVoiceModel2["Gpt4oMiniTranscribe"] = "gpt-4o-mini-transcribe";
1579
1567
  OpenAiVoiceModel2["Gpt4oTranscribe"] = "gpt-4o-transcribe";
1568
+ OpenAiVoiceModel2["GptLiveTranscribe"] = "gpt-live-transcribe";
1580
1569
  OpenAiVoiceModel2["GptRealtimeWhisper"] = "gpt-realtime-whisper";
1581
1570
  return OpenAiVoiceModel2;
1582
1571
  })(OpenAiVoiceModel || {});
@@ -1861,7 +1850,7 @@ const getDefaultProviderParams = (providerName) => {
1861
1850
  voice: {
1862
1851
  idleTimeoutMs: 5e3,
1863
1852
  systemInstructions: DEFAULT_VOICE_SYSTEM_INSTRUCTIONS,
1864
- model: "gpt-realtime-whisper",
1853
+ model: "gpt-live-transcribe",
1865
1854
  language: "en"
1866
1855
  }
1867
1856
  };
@@ -3166,7 +3155,7 @@ const ensureRipgrepBinary = async () => {
3166
3155
  return false;
3167
3156
  }
3168
3157
  };
3169
- const isAbortError = (error) => {
3158
+ const isAbortError$1 = (error) => {
3170
3159
  if (!(error instanceof Error)) {
3171
3160
  return false;
3172
3161
  }
@@ -3226,7 +3215,7 @@ class WebScraper {
3226
3215
  }
3227
3216
  return content;
3228
3217
  } catch (error) {
3229
- if (isAbortError(error)) {
3218
+ if (isAbortError$1(error)) {
3230
3219
  return "Operation was cancelled by user.";
3231
3220
  }
3232
3221
  return `Error: ${error instanceof Error ? error.message : String(error)}`;
@@ -3294,7 +3283,7 @@ class WebScraper {
3294
3283
  return await response.text();
3295
3284
  } catch (error) {
3296
3285
  clearTimeout(timeoutId);
3297
- if (isAbortError(error)) {
3286
+ if (isAbortError$1(error)) {
3298
3287
  return "Operation was cancelled by user.";
3299
3288
  }
3300
3289
  return `Error: ${error instanceof Error ? error.message : String(error)}`;
@@ -3674,7 +3663,7 @@ Do not use escape characters \\ in the string like \\n or \\" and others. Do not
3674
3663
  });
3675
3664
  return `Successfully edited '${filePath}'.`;
3676
3665
  } catch (error) {
3677
- if (isAbortError(error)) {
3666
+ if (isAbortError$1(error)) {
3678
3667
  return "Operation was cancelled by user.";
3679
3668
  }
3680
3669
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -3722,7 +3711,7 @@ Do not use escape characters \\ in the string like \\n or \\" and others. Do not
3722
3711
  try {
3723
3712
  return await readFileContent(absolutePath, withLines, lineOffset, lineLimit);
3724
3713
  } catch (error) {
3725
- if (isAbortError(error)) {
3714
+ if (isAbortError$1(error)) {
3726
3715
  return "Operation was cancelled by user.";
3727
3716
  }
3728
3717
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -4082,7 +4071,7 @@ Do not use escape characters \\ in the string like \\n or \\" and others. Do not
4082
4071
  }
4083
4072
  return await truncateToolResult(markdownLines.join("\n"), 1e3, 50, 1e4);
4084
4073
  } catch (error) {
4085
- if (isAbortError(error)) {
4074
+ if (isAbortError$1(error)) {
4086
4075
  return "Operation was cancelled by user.";
4087
4076
  }
4088
4077
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -4319,7 +4308,7 @@ Format: ${format}`;
4319
4308
  const content = await scrapeWeb(url, timeout, abortSignal, format);
4320
4309
  return await truncateToolResult(content, 1e3, 50, 1e4);
4321
4310
  } catch (error) {
4322
- if (isAbortError(error)) {
4311
+ if (isAbortError$1(error)) {
4323
4312
  return "Operation was cancelled by user.";
4324
4313
  }
4325
4314
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -4430,7 +4419,7 @@ Language: ${language || "all"}`;
4430
4419
  logger.debug(`Search results: ${JSON.stringify(results)}`);
4431
4420
  return results;
4432
4421
  } catch (error) {
4433
- if (isAbortError(error)) {
4422
+ if (isAbortError$1(error)) {
4434
4423
  return "Operation was cancelled by user.";
4435
4424
  }
4436
4425
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -4587,38 +4576,103 @@ Items: ${JSON.stringify(items)}`;
4587
4576
  }
4588
4577
  return filteredTools;
4589
4578
  };
4579
+ const taskDateSchema = zod.z.string().refine((value) => !Number.isNaN(Date.parse(value)), "Must be a valid date or ISO 8601 timestamp");
4580
+ const listTasksInputSchema = zod.z.object({
4581
+ offset: zod.z.coerce.number().optional().describe("The number of tasks to skip (for pagination)"),
4582
+ limit: zod.z.coerce.number().optional().describe("The maximum number of tasks to return"),
4583
+ state: zod.z.string().optional().describe(
4584
+ "Filter tasks by state. Built-in states: TODO, READY_FOR_IMPLEMENTATION, IN_PROGRESS, INTERRUPTED, DELEGATED, MORE_INFO_NEEDED, READY_FOR_REVIEW, DONE."
4585
+ ),
4586
+ createdAfter: taskDateSchema.optional().describe("Include tasks created at or after this date or ISO 8601 timestamp"),
4587
+ createdBefore: taskDateSchema.optional().describe("Include tasks created at or before this date or ISO 8601 timestamp"),
4588
+ updatedAfter: taskDateSchema.optional().describe("Include tasks updated at or after this date or ISO 8601 timestamp"),
4589
+ updatedBefore: taskDateSchema.optional().describe("Include tasks updated at or before this date or ISO 8601 timestamp"),
4590
+ workingMode: zod.z.enum(["local", "worktree"]).optional().describe("Filter tasks by working mode"),
4591
+ archived: zod.z.boolean().optional().describe("Filter tasks by archived status"),
4592
+ pinned: zod.z.boolean().optional().describe("Filter tasks by pinned status"),
4593
+ parentId: zod.z.string().nullable().optional().describe("Filter by parent task ID; use null for top-level tasks"),
4594
+ nameQuery: zod.z.string().optional().describe("Case-insensitive substring to match in task names"),
4595
+ agentProfileId: zod.z.string().optional().describe("Filter tasks by agent profile ID"),
4596
+ provider: zod.z.string().optional().describe("Filter tasks by model provider"),
4597
+ model: zod.z.string().optional().describe("Filter tasks by model")
4598
+ }).superRefine((input, context) => {
4599
+ const dateRanges = [
4600
+ ["createdAfter", input.createdAfter, "createdBefore", input.createdBefore],
4601
+ ["updatedAfter", input.updatedAfter, "updatedBefore", input.updatedBefore]
4602
+ ];
4603
+ for (const [lowerName, lowerValue, upperName, upperValue] of dateRanges) {
4604
+ if (lowerValue && upperValue && Date.parse(lowerValue) > Date.parse(upperValue)) {
4605
+ context.addIssue({
4606
+ code: "custom",
4607
+ path: [upperName],
4608
+ message: `${upperName} must be greater than or equal to ${lowerName}`
4609
+ });
4610
+ }
4611
+ }
4612
+ });
4590
4613
  const createTasksToolset = (settings, task, profile, promptContext) => {
4591
4614
  const approvalManager = new ApprovalManager(task, profile);
4592
4615
  const listTasksTool = ai.tool({
4593
4616
  description: TASKS_TOOL_DESCRIPTIONS[TASKS_TOOL_LIST_TASKS],
4594
- inputSchema: zod.z.object({
4595
- offset: zod.z.coerce.number().optional().describe("The number of tasks to skip (for pagination)"),
4596
- limit: zod.z.coerce.number().optional().describe("The maximum number of tasks to return"),
4597
- state: zod.z.string().optional().describe("Filter tasks by state (e.g., TODO, IN_PROGRESS, DONE)")
4598
- }),
4617
+ inputSchema: listTasksInputSchema,
4599
4618
  execute: async (input, { toolCallId }) => {
4600
- const { offset = 0, limit, state } = input;
4601
- task.addToolMessage(toolCallId, TASKS_TOOL_GROUP_NAME, TASKS_TOOL_LIST_TASKS, { offset, limit, state }, void 0, void 0, promptContext);
4619
+ const {
4620
+ offset = 0,
4621
+ limit,
4622
+ state,
4623
+ createdAfter,
4624
+ createdBefore,
4625
+ updatedAfter,
4626
+ updatedBefore,
4627
+ workingMode,
4628
+ archived,
4629
+ pinned,
4630
+ parentId,
4631
+ nameQuery,
4632
+ agentProfileId,
4633
+ provider,
4634
+ model
4635
+ } = input;
4636
+ const toolInput = { ...input, offset, limit, state };
4637
+ task.addToolMessage(toolCallId, TASKS_TOOL_GROUP_NAME, TASKS_TOOL_LIST_TASKS, toolInput, void 0, void 0, promptContext);
4602
4638
  const toolName = `${TASKS_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${TASKS_TOOL_LIST_TASKS}`;
4603
4639
  const questionKey = toolName;
4604
4640
  const questionText = "Approve listing tasks?";
4605
- const questionSubject = `Offset: ${offset}, Limit: ${limit}, State: ${state || "all"}`;
4641
+ const questionSubject = [
4642
+ `Offset: ${offset}`,
4643
+ `Limit: ${limit ?? "all"}`,
4644
+ `State: ${state || "all"}`,
4645
+ `Created: ${createdAfter || "*"} to ${createdBefore || "*"}`,
4646
+ `Updated: ${updatedAfter || "*"} to ${updatedBefore || "*"}`,
4647
+ `Working mode: ${workingMode || "all"}`,
4648
+ `Archived: ${archived === void 0 ? "all" : archived}`,
4649
+ `Pinned: ${pinned === void 0 ? "all" : pinned}`,
4650
+ ...parentId !== void 0 ? [`Parent ID: ${parentId || "none"}`] : [],
4651
+ ...nameQuery ? [`Name: ${nameQuery}`] : []
4652
+ ].join(", ");
4606
4653
  const [isApproved, userInput] = await approvalManager.handleToolApproval(toolName, input, questionKey, questionText, questionSubject);
4607
4654
  if (!isApproved) {
4608
4655
  return `Listing tasks denied by user. Reason: ${userInput}`;
4609
4656
  }
4610
4657
  try {
4611
4658
  let allTasks = await task.getProject().getTasks();
4612
- if (state) {
4613
- allTasks = allTasks.filter((t) => t.state === state);
4614
- }
4659
+ const createdAfterTime = createdAfter ? Date.parse(createdAfter) : void 0;
4660
+ const createdBeforeTime = createdBefore ? Date.parse(createdBefore) : void 0;
4661
+ const updatedAfterTime = updatedAfter ? Date.parse(updatedAfter) : void 0;
4662
+ const updatedBeforeTime = updatedBefore ? Date.parse(updatedBefore) : void 0;
4663
+ const normalizedNameQuery = nameQuery?.toLocaleLowerCase();
4664
+ allTasks = allTasks.filter((taskData) => {
4665
+ const createdAt = taskData.createdAt ? Date.parse(taskData.createdAt) : void 0;
4666
+ const updatedAt = taskData.updatedAt ? Date.parse(taskData.updatedAt) : void 0;
4667
+ return (!state || taskData.state === state) && (createdAfterTime === void 0 || createdAt !== void 0 && createdAt >= createdAfterTime) && (createdBeforeTime === void 0 || createdAt !== void 0 && createdAt <= createdBeforeTime) && (updatedAfterTime === void 0 || updatedAt !== void 0 && updatedAt >= updatedAfterTime) && (updatedBeforeTime === void 0 || updatedAt !== void 0 && updatedAt <= updatedBeforeTime) && (!workingMode || taskData.workingMode === workingMode) && (archived === void 0 || Boolean(taskData.archived) === archived) && (pinned === void 0 || Boolean(taskData.pinned) === pinned) && (parentId === void 0 || (parentId === null ? taskData.parentId == null : taskData.parentId === parentId)) && (!normalizedNameQuery || taskData.name.toLocaleLowerCase().includes(normalizedNameQuery)) && (!agentProfileId || taskData.agentProfileId === agentProfileId) && (!provider || taskData.provider === provider) && (!model || taskData.model === model);
4668
+ });
4615
4669
  allTasks.sort((a, b) => {
4616
4670
  const dateA = a.updatedAt ? new Date(a.updatedAt).getTime() : 0;
4617
4671
  const dateB = b.updatedAt ? new Date(b.updatedAt).getTime() : 0;
4618
4672
  return dateB - dateA;
4619
4673
  });
4620
4674
  const startIndex = Math.max(0, offset);
4621
- const endIndex = startIndex + Math.max(0, limit || allTasks.length);
4675
+ const endIndex = startIndex + (limit === void 0 ? allTasks.length : Math.max(0, limit));
4622
4676
  const paginatedTasks = allTasks.slice(startIndex, endIndex);
4623
4677
  return paginatedTasks.map((t) => {
4624
4678
  const subtaskIds = allTasks.filter((subtask) => subtask.parentId === t.id).map((s) => s.id);
@@ -4628,6 +4682,8 @@ const createTasksToolset = (settings, task, profile, promptContext) => {
4628
4682
  createdAt: t.createdAt,
4629
4683
  updatedAt: t.updatedAt,
4630
4684
  archived: t.archived,
4685
+ pinned: t.pinned,
4686
+ workingMode: t.workingMode,
4631
4687
  state: t.state,
4632
4688
  ...t.parentId && { parentId: t.parentId },
4633
4689
  ...subtaskIds.length > 0 && { subtaskIds }
@@ -4762,44 +4818,40 @@ const createTasksToolset = (settings, task, profile, promptContext) => {
4762
4818
  execute: async (input, { toolCallId }) => {
4763
4819
  const { prompt, name, agentProfileId, modelId, mode = "agent", asSubtask = false, autonomyMode, worktree, executeAndWait, executeInBackground } = input;
4764
4820
  const parentTaskId = asSubtask ? task.task.parentId || task.taskId : "parentTaskId" in input ? input.parentTaskId : void 0;
4821
+ const resolvedProfile = agentProfileId ? task.getProject().resolveAgentProfile(agentProfileId) : profile;
4822
+ if (!resolvedProfile) {
4823
+ const availableProfiles = task.getProject().getAgentProfiles().map((p) => `"${p.name}"`).join(", ");
4824
+ return `Agent profile '${agentProfileId}' not found. Available profiles: ${availableProfiles}`;
4825
+ }
4826
+ const effectiveModelId = modelId || `${profile.provider}/${profile.model}`;
4827
+ const [provider, ...modelParts] = effectiveModelId.split("/");
4828
+ const model = modelParts.join("/");
4765
4829
  task.addToolMessage(toolCallId, TASKS_TOOL_GROUP_NAME, TASKS_TOOL_CREATE_TASK, input, void 0, void 0, promptContext);
4766
4830
  const toolName = `${TASKS_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${TASKS_TOOL_CREATE_TASK}`;
4767
4831
  const questionKey = toolName;
4768
4832
  const questionText = "Approve creating a new task?";
4769
4833
  const questionSubject = `Prompt: ${prompt}
4770
- Agent Profile: ${agentProfileId || "default"}
4771
- Model: ${modelId || "default"}${executeAndWait ? "\nExecute and wait: true" : executeInBackground ? "\nExecute in background: true" : ""}${parentTaskId !== void 0 ? `
4834
+ Agent Profile: ${resolvedProfile.id}
4835
+ Model: ${effectiveModelId}${executeAndWait ? "\nExecute and wait: true" : executeInBackground ? "\nExecute in background: true" : ""}${parentTaskId !== void 0 ? `
4772
4836
  Parent Task ID: ${parentTaskId || "none (top-level task)"}` : ""}`;
4773
4837
  const [isApproved, userInput] = await approvalManager.handleToolApproval(toolName, input, questionKey, questionText, questionSubject);
4774
4838
  if (!isApproved) {
4775
4839
  return `Creating task denied by user. Reason: ${userInput}`;
4776
4840
  }
4777
4841
  try {
4842
+ const updates = {
4843
+ agentProfileId: resolvedProfile.id,
4844
+ provider,
4845
+ model,
4846
+ mainModel: effectiveModelId
4847
+ };
4778
4848
  const newTask = await task.getProject().createNewTask({
4779
4849
  parentId: parentTaskId || null,
4780
4850
  name: name || "",
4781
4851
  autonomyMode,
4782
- workingMode: worktree ? "worktree" : "local"
4852
+ workingMode: worktree ? "worktree" : "local",
4853
+ ...updates
4783
4854
  });
4784
- const updates = {};
4785
- if (agentProfileId) {
4786
- const resolvedProfile = task.getProject().resolveAgentProfile(agentProfileId);
4787
- if (resolvedProfile) {
4788
- updates.agentProfileId = resolvedProfile.id;
4789
- } else {
4790
- const availableProfiles = task.getProject().getAgentProfiles().map((p) => `"${p.name}"`).join(", ");
4791
- return `Agent profile '${agentProfileId}' not found. Available profiles: ${availableProfiles}`;
4792
- }
4793
- }
4794
- if (modelId) {
4795
- const [provider, ...modelParts] = modelId.split("/");
4796
- updates.provider = provider;
4797
- updates.model = modelParts.join("/");
4798
- updates.mainModel = modelId;
4799
- } else {
4800
- updates.provider = void 0;
4801
- updates.model = void 0;
4802
- }
4803
4855
  const taskInstance = task.getProject().getTask(newTask.id);
4804
4856
  if (!taskInstance) {
4805
4857
  throw new Error(`Failed to get task instance for newly created task ${newTask.id}`);
@@ -4959,7 +5011,7 @@ Task ID: ${taskId}`;
4959
5011
  logger.debug(`Task search results: ${JSON.stringify(results)}`);
4960
5012
  return results;
4961
5013
  } catch (error) {
4962
- if (isAbortError(error)) {
5014
+ if (isAbortError$1(error)) {
4963
5015
  return "Operation was cancelled by user.";
4964
5016
  }
4965
5017
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -5035,7 +5087,7 @@ const createSearchParentTaskTool = (task, promptContext) => {
5035
5087
  logger.debug(`Parent task search results: ${JSON.stringify(results)}`);
5036
5088
  return results;
5037
5089
  } catch (error) {
5038
- if (isAbortError(error)) {
5090
+ if (isAbortError$1(error)) {
5039
5091
  return "Operation was cancelled by user.";
5040
5092
  }
5041
5093
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -10237,6 +10289,9 @@ const SavePromptSchema = zod.z.object({
10237
10289
  taskId: zod.z.string().min(1, "Task ID is required"),
10238
10290
  prompt: zod.z.string().min(1, "Prompt is required")
10239
10291
  });
10292
+ const SaveEditedPromptSchema = SavePromptSchema.extend({
10293
+ messageId: zod.z.string().min(1, "Message ID is required")
10294
+ });
10240
10295
  const SSE_ALLOWED_EVENT_TYPES = /* @__PURE__ */ new Set([
10241
10296
  "response-chunk",
10242
10297
  "response-completed",
@@ -10287,6 +10342,18 @@ class PromptApi extends BaseApi {
10287
10342
  res.status(200).json({ message: "Prompt saved successfully" });
10288
10343
  })
10289
10344
  );
10345
+ router.post(
10346
+ "/save-edited-prompt",
10347
+ this.handleRequest(async (req, res) => {
10348
+ const parsed = this.validateRequest(SaveEditedPromptSchema, req.body, res);
10349
+ if (!parsed) {
10350
+ return;
10351
+ }
10352
+ const { projectDir, taskId, messageId, prompt } = parsed;
10353
+ await this.eventsHandler.saveEditedPrompt(projectDir, taskId, messageId, prompt);
10354
+ res.status(200).json({ message: "Edited prompt saved successfully" });
10355
+ })
10356
+ );
10290
10357
  }
10291
10358
  async handleRunPromptJSON(res, projectDir, prompt, taskId, mode, images, model, agentProfileId, autonomyMode) {
10292
10359
  if (taskId) {
@@ -10826,6 +10893,10 @@ const CommitChangesSchema = zod.z.object({
10826
10893
  message: zod.z.string(),
10827
10894
  amend: zod.z.boolean()
10828
10895
  }).refine((data) => data.amend || data.message.trim().length > 0, { message: "Commit message is required", path: ["message"] });
10896
+ const CancelCommitChangesSchema = zod.z.object({
10897
+ projectDir: zod.z.string().min(1, "Project directory is required"),
10898
+ taskId: zod.z.string().min(1, "Task id is required")
10899
+ });
10829
10900
  const ListBranchesSchema = zod.z.object({
10830
10901
  projectDir: zod.z.string().min(1, "Project directory is required")
10831
10902
  });
@@ -11044,6 +11115,18 @@ class ProjectApi extends BaseApi {
11044
11115
  res.status(200).json(tasks);
11045
11116
  })
11046
11117
  );
11118
+ router.post(
11119
+ "/project/tasks/reload",
11120
+ this.handleRequest(async (req, res) => {
11121
+ const parsed = this.validateRequest(ListTasksSchema, req.body, res);
11122
+ if (!parsed) {
11123
+ return;
11124
+ }
11125
+ const { projectDir } = parsed;
11126
+ const tasks = await this.eventsHandler.reloadTasks(projectDir);
11127
+ res.status(200).json(tasks);
11128
+ })
11129
+ );
11047
11130
  router.post(
11048
11131
  "/project/tasks/delete",
11049
11132
  this.handleRequest(async (req, res) => {
@@ -11367,6 +11450,18 @@ class ProjectApi extends BaseApi {
11367
11450
  res.status(200).json({ message: "Changes committed" });
11368
11451
  })
11369
11452
  );
11453
+ router.post(
11454
+ "/project/worktree/cancel-commit-changes",
11455
+ this.handleRequest(async (req, res) => {
11456
+ const parsed = this.validateRequest(CancelCommitChangesSchema, req.body, res);
11457
+ if (!parsed) {
11458
+ return;
11459
+ }
11460
+ const { projectDir, taskId } = parsed;
11461
+ this.eventsHandler.cancelCommitChanges(projectDir, taskId);
11462
+ res.status(200).json({ message: "Commit cancellation requested" });
11463
+ })
11464
+ );
11370
11465
  router.get(
11371
11466
  "/project/worktree/branches",
11372
11467
  this.handleRequest(async (req, res) => {
@@ -12522,6 +12617,217 @@ class SkillsApi extends BaseApi {
12522
12617
  );
12523
12618
  }
12524
12619
  }
12620
+ const isReadonlyExtensionUiEnabled = (store) => {
12621
+ if (READONLY_EXTENSION_UI === "true") {
12622
+ return true;
12623
+ }
12624
+ if (READONLY_EXTENSION_UI === "false") {
12625
+ return false;
12626
+ }
12627
+ return store.getSettings().server.readonlyExtensionUi ?? true;
12628
+ };
12629
+ const ProjectQuerySchema = zod.z.object({
12630
+ projectDir: zod.z.string().min(1)
12631
+ });
12632
+ const TaskQuerySchema = ProjectQuerySchema.extend({
12633
+ taskId: zod.z.string().min(1).optional()
12634
+ });
12635
+ const ComponentsQuerySchema = TaskQuerySchema.extend({
12636
+ placement: zod.z.string().min(1)
12637
+ });
12638
+ const ComponentQuerySchema = TaskQuerySchema.extend({
12639
+ extensionId: zod.z.string().min(1),
12640
+ componentId: zod.z.string().min(1)
12641
+ });
12642
+ const LibraryQuerySchema = TaskQuerySchema.extend({
12643
+ spec: zod.z.string().min(1)
12644
+ });
12645
+ const ActionSchema = ComponentQuerySchema.extend({
12646
+ action: zod.z.string().min(1),
12647
+ args: zod.z.array(zod.z.unknown()).default([])
12648
+ });
12649
+ class ReadonlyApi extends BaseApi {
12650
+ constructor(projectManager, eventsHandler, store, isReady) {
12651
+ super();
12652
+ this.projectManager = projectManager;
12653
+ this.eventsHandler = eventsHandler;
12654
+ this.store = store;
12655
+ this.isReady = isReady;
12656
+ }
12657
+ projectManager;
12658
+ eventsHandler;
12659
+ store;
12660
+ isReady;
12661
+ get isReadonlyMode() {
12662
+ return READONLY_MODE || this.store.getSettings().server.readonly === true;
12663
+ }
12664
+ resolveProject(projectDir, res) {
12665
+ const project = this.projectManager.getOpenProject(projectDir);
12666
+ if (!project || project.baseDir !== projectDir) {
12667
+ res.status(404).json({ error: "Project not found" });
12668
+ return null;
12669
+ }
12670
+ return project;
12671
+ }
12672
+ validateTask(projectDir, taskId, res) {
12673
+ if (!taskId) {
12674
+ return true;
12675
+ }
12676
+ const project = this.resolveProject(projectDir, res);
12677
+ if (!project) {
12678
+ return false;
12679
+ }
12680
+ if (!project.getTask(taskId)) {
12681
+ res.status(404).json({ error: "Task not found" });
12682
+ return false;
12683
+ }
12684
+ return true;
12685
+ }
12686
+ findComponent(projectDir, extensionId, componentId, taskId) {
12687
+ return this.eventsHandler.getUIComponents(void 0, projectDir, taskId).find((component) => component.extensionId === extensionId && component.componentId === componentId);
12688
+ }
12689
+ registerRoutes(router) {
12690
+ router.use("/extensions", (_req, res, next) => {
12691
+ if (isReadonlyExtensionUiEnabled(this.store)) {
12692
+ next();
12693
+ return;
12694
+ }
12695
+ res.status(403).json({
12696
+ error: "Extension UI is disabled in readonly mode.",
12697
+ code: "EXTENSION_UI_DISABLED"
12698
+ });
12699
+ });
12700
+ router.get(
12701
+ "/bootstrap",
12702
+ this.handleRequest(async (_req, res) => {
12703
+ if (!this.isReadonlyMode) {
12704
+ const bootstrap2 = { mode: "standard" };
12705
+ res.status(200).json(bootstrap2);
12706
+ return;
12707
+ }
12708
+ if (!this.isReady()) {
12709
+ res.status(503).json({ error: "Readonly projects are still starting" });
12710
+ return;
12711
+ }
12712
+ const settings = this.store.getSettings();
12713
+ const projects = this.store.getOpenProjects().map((project) => ({
12714
+ baseDir: project.baseDir,
12715
+ name: path.basename(project.baseDir),
12716
+ active: project.active
12717
+ }));
12718
+ const bootstrap = {
12719
+ mode: "readonly",
12720
+ projects,
12721
+ display: {
12722
+ language: settings.language,
12723
+ theme: settings.theme ?? "dark",
12724
+ font: settings.font ?? "Sono",
12725
+ fontSize: settings.fontSize ?? 16,
12726
+ renderMarkdown: settings.renderMarkdown,
12727
+ fullMessageRendering: settings.fullMessageRendering,
12728
+ messageViewMode: settings.messageViewMode,
12729
+ enableExtensionUi: isReadonlyExtensionUiEnabled(this.store)
12730
+ }
12731
+ };
12732
+ res.status(200).json(bootstrap);
12733
+ })
12734
+ );
12735
+ router.get(
12736
+ "/tasks",
12737
+ this.handleRequest(async (req, res) => {
12738
+ const parsed = this.validateRequest(ProjectQuerySchema, req.query, res);
12739
+ if (!parsed) {
12740
+ return;
12741
+ }
12742
+ const project = this.resolveProject(parsed.projectDir, res);
12743
+ if (!project) {
12744
+ return;
12745
+ }
12746
+ res.status(200).json(await project.getTasks());
12747
+ })
12748
+ );
12749
+ router.get(
12750
+ "/tasks/:taskId",
12751
+ this.handleRequest(async (req, res) => {
12752
+ const parsed = this.validateRequest(ProjectQuerySchema.extend({ taskId: zod.z.string().min(1) }), { ...req.query, taskId: req.params.taskId }, res);
12753
+ if (!parsed) {
12754
+ return;
12755
+ }
12756
+ const project = this.resolveProject(parsed.projectDir, res);
12757
+ if (!project) {
12758
+ return;
12759
+ }
12760
+ const task = project.getTask(parsed.taskId);
12761
+ if (!task) {
12762
+ res.status(404).json({ error: "Task not found" });
12763
+ return;
12764
+ }
12765
+ res.status(200).json(await task.load(READONLY_MODE));
12766
+ })
12767
+ );
12768
+ router.get(
12769
+ "/extensions/ui-components",
12770
+ this.handleRequest(async (req, res) => {
12771
+ const parsed = this.validateRequest(ComponentsQuerySchema, req.query, res);
12772
+ if (!parsed || !this.resolveProject(parsed.projectDir, res) || !this.validateTask(parsed.projectDir, parsed.taskId, res)) {
12773
+ return;
12774
+ }
12775
+ res.status(200).json(this.eventsHandler.getUIComponents(parsed.placement, parsed.projectDir, parsed.taskId));
12776
+ })
12777
+ );
12778
+ router.get(
12779
+ "/extensions/ui-data",
12780
+ this.handleRequest(async (req, res) => {
12781
+ const parsed = this.validateRequest(ComponentQuerySchema, req.query, res);
12782
+ if (!parsed || !this.resolveProject(parsed.projectDir, res) || !this.validateTask(parsed.projectDir, parsed.taskId, res)) {
12783
+ return;
12784
+ }
12785
+ if (!this.findComponent(parsed.projectDir, parsed.extensionId, parsed.componentId, parsed.taskId)) {
12786
+ res.status(404).json({ error: "Extension component not found" });
12787
+ return;
12788
+ }
12789
+ res.status(200).json(await this.eventsHandler.getUIExtensionData(parsed.extensionId, parsed.componentId, parsed.projectDir, parsed.taskId));
12790
+ })
12791
+ );
12792
+ router.get(
12793
+ "/extensions/library",
12794
+ this.handleRequest(async (req, res) => {
12795
+ const parsed = this.validateRequest(LibraryQuerySchema, req.query, res);
12796
+ if (!parsed || !this.resolveProject(parsed.projectDir, res) || !this.validateTask(parsed.projectDir, parsed.taskId, res)) {
12797
+ return;
12798
+ }
12799
+ const declared = this.eventsHandler.getUIComponents(void 0, parsed.projectDir, parsed.taskId).some((component) => Object.values(component.libraries ?? {}).includes(parsed.spec));
12800
+ if (!declared) {
12801
+ res.status(404).json({ error: "Extension library not found" });
12802
+ return;
12803
+ }
12804
+ res.status(200).type("application/javascript").send(await this.eventsHandler.loadExtensionLibrary(parsed.spec));
12805
+ })
12806
+ );
12807
+ router.post(
12808
+ "/extensions/ui-action",
12809
+ this.handleRequest(async (req, res) => {
12810
+ const parsed = this.validateRequest(ActionSchema, req.body, res);
12811
+ if (!parsed || !this.resolveProject(parsed.projectDir, res) || !this.validateTask(parsed.projectDir, parsed.taskId, res)) {
12812
+ return;
12813
+ }
12814
+ if (!this.findComponent(parsed.projectDir, parsed.extensionId, parsed.componentId, parsed.taskId)) {
12815
+ res.status(404).json({ error: "Extension component not found" });
12816
+ return;
12817
+ }
12818
+ const result = await this.eventsHandler.executeUIExtensionAction(
12819
+ parsed.extensionId,
12820
+ parsed.componentId,
12821
+ parsed.action,
12822
+ parsed.args,
12823
+ parsed.projectDir,
12824
+ parsed.taskId
12825
+ );
12826
+ res.status(200).json(result);
12827
+ })
12828
+ );
12829
+ }
12830
+ }
12525
12831
  const createCorsOriginValidator = (store) => (origin, callback) => {
12526
12832
  if (CORS_ALLOWED_ORIGINS) {
12527
12833
  const origins = CORS_ALLOWED_ORIGINS.split(",").map((o) => o.trim()).filter(Boolean);
@@ -12560,6 +12866,10 @@ class ServerController {
12560
12866
  pythonInstaller;
12561
12867
  app = express();
12562
12868
  isStarted = false;
12869
+ readonlyReady = !READONLY_MODE;
12870
+ get isReadonlyMode() {
12871
+ return READONLY_MODE || this.store.getSettings().server.readonly === true;
12872
+ }
12563
12873
  serverGuardMiddleware(req, res, next) {
12564
12874
  if (req.path === "/api/health") {
12565
12875
  next();
@@ -12612,6 +12922,23 @@ class ServerController {
12612
12922
  next();
12613
12923
  }
12614
12924
  setupApiRoutes() {
12925
+ const readonlyRouter = express.Router();
12926
+ new ReadonlyApi(this.projectManager, this.eventsHandler, this.store, () => this.readonlyReady).registerRoutes(readonlyRouter);
12927
+ this.app.use("/api/readonly", readonlyRouter);
12928
+ this.app.use("/api", (req, res, next) => {
12929
+ if (req.path === "/health" || req.path.startsWith("/readonly")) {
12930
+ next();
12931
+ return;
12932
+ }
12933
+ if (this.isReadonlyMode) {
12934
+ res.status(403).json({
12935
+ error: "This action is unavailable in readonly mode.",
12936
+ code: "READ_ONLY_MODE"
12937
+ });
12938
+ return;
12939
+ }
12940
+ next();
12941
+ });
12615
12942
  const apiRouter = express.Router();
12616
12943
  new ContextApi(this.projectManager, this.eventsHandler).registerRoutes(apiRouter);
12617
12944
  new PromptApi(this.eventsHandler).registerRoutes(apiRouter);
@@ -12647,7 +12974,11 @@ class ServerController {
12647
12974
  });
12648
12975
  const rendererDir = process.env.AIDER_DESK_RENDERER_DIR ? path.isAbsolute(process.env.AIDER_DESK_RENDERER_DIR) ? process.env.AIDER_DESK_RENDERER_DIR : path.join(__dirname, process.env.AIDER_DESK_RENDERER_DIR) : path.join(__dirname, "../renderer");
12649
12976
  this.app.use(express.static(rendererDir));
12650
- this.app.get("*", (_, res) => {
12977
+ this.app.get("*", (req, res) => {
12978
+ if (this.isReadonlyMode && req.path !== "/") {
12979
+ res.redirect("/#/readonly");
12980
+ return;
12981
+ }
12651
12982
  res.sendFile(path.join(rendererDir, "index.html"));
12652
12983
  });
12653
12984
  }
@@ -12655,6 +12986,9 @@ class ServerController {
12655
12986
  this.server.on("request", this.app);
12656
12987
  this.isStarted = this.store.getSettings().server.enabled;
12657
12988
  }
12989
+ setReadonlyReady() {
12990
+ this.readonlyReady = true;
12991
+ }
12658
12992
  async close() {
12659
12993
  this.server.off("request", this.app);
12660
12994
  }
@@ -12908,6 +13242,32 @@ const isSubscribeEventsMessage = (message) => {
12908
13242
  const isUnsubscribeEventsMessage = (message) => {
12909
13243
  return message.action === "unsubscribe-events";
12910
13244
  };
13245
+ const isReadonlySubscribeEventsMessage = (message) => {
13246
+ return message.action === "readonly-subscribe-events";
13247
+ };
13248
+ const isReadonlyUnsubscribeEventsMessage = (message) => {
13249
+ return message.action === "readonly-unsubscribe-events";
13250
+ };
13251
+ const CONNECTOR_TOKEN = crypto.randomBytes(32).toString("hex");
13252
+ const READONLY_EVENT_TYPES = [
13253
+ "task-created",
13254
+ "task-updated",
13255
+ "task-started",
13256
+ "task-completed",
13257
+ "task-cancelled",
13258
+ "task-deleted",
13259
+ "user-message",
13260
+ "response-chunk",
13261
+ "response-completed",
13262
+ "tool",
13263
+ "tool-input-chunk",
13264
+ "log",
13265
+ "command-output",
13266
+ "clear-task",
13267
+ "message-removed",
13268
+ "extension-ui-refresh"
13269
+ ];
13270
+ const readonlyEventTypes = new Set(READONLY_EVENT_TYPES);
12911
13271
  class ConnectorManager {
12912
13272
  constructor(httpServer, projectManager, eventManager, store) {
12913
13273
  this.projectManager = projectManager;
@@ -12920,6 +13280,9 @@ class ConnectorManager {
12920
13280
  store;
12921
13281
  io = null;
12922
13282
  connectors = [];
13283
+ get isReadonlyMode() {
13284
+ return READONLY_MODE || this.store.getSettings().server.readonly === true;
13285
+ }
12923
13286
  init(httpServer) {
12924
13287
  this.io = new socket_io.Server(httpServer, {
12925
13288
  cors: {
@@ -12931,6 +13294,24 @@ class ConnectorManager {
12931
13294
  maxHttpBufferSize: 1e8
12932
13295
  // Increase payload size to 100 MB
12933
13296
  });
13297
+ this.io.use((socket, next) => {
13298
+ if (!this.isReadonlyMode) {
13299
+ next();
13300
+ return;
13301
+ }
13302
+ const connectorToken = socket.handshake.auth.connectorToken;
13303
+ if (typeof connectorToken === "string" && connectorToken === CONNECTOR_TOKEN) {
13304
+ socket.data.clientRole = "connector";
13305
+ next();
13306
+ return;
13307
+ }
13308
+ if (socket.handshake.auth.readonly === true) {
13309
+ socket.data.clientRole = "readonly";
13310
+ next();
13311
+ return;
13312
+ }
13313
+ next(new Error("Unauthorized Socket.IO client"));
13314
+ });
12934
13315
  this.io.engine.on("connection_error", (err) => {
12935
13316
  logger.warn("Socket.IO engine connection error", { error: err.message });
12936
13317
  });
@@ -12943,7 +13324,13 @@ class ConnectorManager {
12943
13324
  }
12944
13325
  });
12945
13326
  socket.on("message", (message) => this.processMessage(socket, message));
12946
- socket.on("log", (message) => this.processLogMessage(socket, message));
13327
+ socket.on("log", (message) => {
13328
+ if (this.isReadonlyMode && socket.data.clientRole !== "connector") {
13329
+ socket.disconnect(true);
13330
+ return;
13331
+ }
13332
+ this.processLogMessage(socket, message);
13333
+ });
12947
13334
  socket.on("disconnect", (reason) => {
12948
13335
  const connector = this.findConnectorBySocket(socket);
12949
13336
  logger.info("Socket.IO client disconnected", {
@@ -12966,6 +13353,28 @@ class ConnectorManager {
12966
13353
  }
12967
13354
  processMessage = (socket, message) => {
12968
13355
  try {
13356
+ if (this.isReadonlyMode && socket.data.clientRole === "readonly") {
13357
+ if (isReadonlySubscribeEventsMessage(message)) {
13358
+ const project = this.projectManager.getOpenProject(message.projectDir);
13359
+ const validEventTypes = message.eventTypes.every((eventType) => readonlyEventTypes.has(eventType));
13360
+ if (!project || project.baseDir !== message.projectDir || !validEventTypes) {
13361
+ socket.disconnect(true);
13362
+ return;
13363
+ }
13364
+ this.eventManager.subscribe(socket, {
13365
+ eventTypes: message.eventTypes,
13366
+ baseDirs: [message.projectDir],
13367
+ readonly: true
13368
+ });
13369
+ return;
13370
+ }
13371
+ if (isReadonlyUnsubscribeEventsMessage(message)) {
13372
+ this.eventManager.unsubscribe(socket);
13373
+ return;
13374
+ }
13375
+ socket.disconnect(true);
13376
+ return;
13377
+ }
12969
13378
  logger.debug("Message:", {
12970
13379
  message: JSON.stringify(message).slice(0, 1e3)
12971
13380
  });
@@ -13148,6 +13557,10 @@ class ConnectorManager {
13148
13557
  }
13149
13558
  };
13150
13559
  processLogMessage = (socket, message) => {
13560
+ if (this.isReadonlyMode && socket.data.clientRole !== "connector") {
13561
+ socket.disconnect(true);
13562
+ return;
13563
+ }
13151
13564
  logger.debug("Received log message from connector", { message });
13152
13565
  const connector = this.findConnectorBySocket(socket);
13153
13566
  if (!connector) {
@@ -14159,25 +14572,59 @@ ${JSON.stringify(part.output.value)}`
14159
14572
  this.enableAutosave();
14160
14573
  }
14161
14574
  }
14162
- async loadInternal() {
14575
+ async reloadFromDisk() {
14576
+ if (!this.loaded) {
14577
+ return false;
14578
+ }
14579
+ if (this.loadPromise) {
14580
+ await this.loadPromise;
14581
+ }
14582
+ const previousContext = {
14583
+ messages: this.messages,
14584
+ files: this.files
14585
+ };
14586
+ this.disableAutosave();
14587
+ this.debouncedAutosave.cancel();
14588
+ try {
14589
+ const contextData = await this.readContextFromDisk();
14590
+ const messages = contextData?.contextMessages || [];
14591
+ const files = contextData?.contextFiles || [];
14592
+ const changed = !lodash.isEqual(previousContext.messages, messages) || !lodash.isEqual(previousContext.files, files);
14593
+ if (changed) {
14594
+ this.messages = messages;
14595
+ this.files = files;
14596
+ this.undoSnapshot = null;
14597
+ await this.cleanupContext();
14598
+ }
14599
+ return changed;
14600
+ } finally {
14601
+ this.enableAutosave();
14602
+ }
14603
+ }
14604
+ async readContextFromDisk() {
14163
14605
  if (!await fileExists(this.storagePath)) {
14164
14606
  logger.debug("No existing task context found:", {
14165
14607
  taskId: this.taskId
14166
14608
  });
14167
- this.loaded = true;
14168
- return;
14609
+ return null;
14169
14610
  }
14170
- this.disableAutosave();
14171
14611
  const content = await fs$1.promises.readFile(this.storagePath, "utf8");
14172
14612
  const contextData = content ? JSON.parse(content) : null;
14173
14613
  if (!contextData) {
14174
14614
  logger.debug("Empty task context found:", { taskId: this.taskId });
14175
- this.loaded = true;
14176
- return;
14615
+ return {
14616
+ contextMessages: [],
14617
+ contextFiles: []
14618
+ };
14619
+ }
14620
+ return this.migrateContext(contextData);
14621
+ }
14622
+ async loadInternal() {
14623
+ const contextData = await this.readContextFromDisk();
14624
+ if (contextData) {
14625
+ this.messages = contextData.contextMessages || [];
14626
+ this.files = contextData.contextFiles || [];
14177
14627
  }
14178
- const migratedData = await this.migrateContext(contextData);
14179
- this.messages = migratedData.contextMessages || [];
14180
- this.files = migratedData.contextFiles || [];
14181
14628
  this.loaded = true;
14182
14629
  await this.cleanupContext();
14183
14630
  }
@@ -14884,6 +15331,7 @@ class AiderManager {
14884
15331
  TASK_ID: this.task.task.id,
14885
15332
  TASK_DIR: this.task.getTaskDir(),
14886
15333
  CONNECTOR_SERVER_URL: `http://localhost:${SERVER_PORT}`,
15334
+ AIDER_DESK_CONNECTOR_TOKEN: CONNECTOR_TOKEN,
14887
15335
  CONNECTOR_CONFIRM_BEFORE_EDIT: settings.aider.confirmBeforeEdit ? "1" : "0"
14888
15336
  };
14889
15337
  this.aiderProcess = child_process.spawn(PYTHON_COMMAND, args, {
@@ -15391,7 +15839,11 @@ Original Error: ${this.originalError.message}`;
15391
15839
  return details;
15392
15840
  }
15393
15841
  }
15842
+ const isAbortError = (error) => {
15843
+ return error instanceof Error && (error.name === "AbortError" || error.code === "ABORT_ERR");
15844
+ };
15394
15845
  class WorktreeManager {
15846
+ commitCancelControllers = /* @__PURE__ */ new Map();
15395
15847
  getWorktreePath(projectPath, taskId) {
15396
15848
  return path.join(projectPath, AIDER_DESK_TASKS_DIR, taskId, "worktree");
15397
15849
  }
@@ -16981,33 +17433,55 @@ Git output: ${err.stderr || err.stdout || err.message}`
16981
17433
  return null;
16982
17434
  }
16983
17435
  }
17436
+ cancelCommitChanges(worktreePath) {
17437
+ const controller = this.commitCancelControllers.get(worktreePath);
17438
+ if (!controller) {
17439
+ return false;
17440
+ }
17441
+ controller.abort();
17442
+ return true;
17443
+ }
16984
17444
  async commitChanges(worktreePath, message, amend) {
17445
+ const cancelController = new AbortController();
17446
+ this.commitCancelControllers.set(worktreePath, cancelController);
17447
+ const options = { cwd: worktreePath, signal: cancelController.signal, killSignal: "SIGINT" };
16985
17448
  try {
16986
17449
  logger.info(`Committing changes${amend ? " (amend)" : ""}`, { worktreePath });
16987
17450
  const updatedFiles = await this.getUpdatedFiles(worktreePath);
16988
17451
  if (updatedFiles.length === 0 && !amend) {
16989
17452
  logger.info("No updated files to commit");
16990
- return;
17453
+ return true;
16991
17454
  }
16992
17455
  if (updatedFiles.length > 0) {
16993
17456
  for (const file of updatedFiles) {
17457
+ if (cancelController.signal.aborted) {
17458
+ logger.info("Commit cancelled while staging files", { worktreePath });
17459
+ return false;
17460
+ }
16994
17461
  const escapedPath = file.path.replace(/"/g, '\\"');
16995
- await execWithShellPath(`git add -- "${escapedPath}"`, {
16996
- cwd: worktreePath
16997
- });
17462
+ await execWithShellPath(`git add -- "${escapedPath}"`, options);
16998
17463
  }
16999
17464
  logger.info(`Staged ${updatedFiles.length} file(s) for commit`);
17000
17465
  }
17466
+ if (cancelController.signal.aborted) {
17467
+ logger.info("Commit cancelled before committing", { worktreePath });
17468
+ return false;
17469
+ }
17001
17470
  const escapedMessage = message.replace(/"/g, '\\"');
17002
17471
  const amendFlag = amend ? " --amend" : "";
17003
17472
  const commitCommand = amend && !message.trim() ? "git commit --amend --no-edit" : `git commit${amendFlag} -m "${escapedMessage}"`;
17004
- await execWithShellPath(commitCommand, {
17005
- cwd: worktreePath
17006
- });
17473
+ await execWithShellPath(commitCommand, options);
17007
17474
  logger.info(`Successfully committed changes${amend ? " (amended)" : ""}`);
17475
+ return true;
17008
17476
  } catch (error) {
17477
+ if (isAbortError(error)) {
17478
+ logger.info(`Commit changes cancelled${amend ? " (amend)" : ""}`, { worktreePath });
17479
+ return false;
17480
+ }
17009
17481
  logger.debug("Failed to commit changes:", error);
17010
17482
  throw error;
17483
+ } finally {
17484
+ this.commitCancelControllers.delete(worktreePath);
17011
17485
  }
17012
17486
  }
17013
17487
  async getRebaseState(worktreePath) {
@@ -17417,7 +17891,7 @@ class Task {
17417
17891
  agent: { cost: 0, tokens: 0 }
17418
17892
  };
17419
17893
  this.aiderManager = new AiderManager(this, this.store, this.modelManager, this.eventManager, () => this.connectors, this.pythonInstaller);
17420
- void this.loadTaskData();
17894
+ this.taskDataLoadPromise = this.loadTaskData();
17421
17895
  }
17422
17896
  project;
17423
17897
  taskId;
@@ -17457,11 +17931,15 @@ class Task {
17457
17931
  lastSmartCompactionMessageCount = 0;
17458
17932
  smartCompactionLevel = CompactionLevel.One;
17459
17933
  taskDataPath;
17934
+ taskDataLoadPromise;
17460
17935
  contextManager;
17461
17936
  agent;
17462
17937
  aiderManager;
17463
17938
  skillManager;
17464
17939
  task;
17940
+ async waitForTaskDataLoad() {
17941
+ await this.taskDataLoadPromise;
17942
+ }
17465
17943
  async getTaskAgentProfile() {
17466
17944
  let agentProfileId = this.task.agentProfileId;
17467
17945
  if (!agentProfileId) {
@@ -17496,19 +17974,60 @@ class Task {
17496
17974
  baseDir: this.project.baseDir,
17497
17975
  taskId: this.taskId
17498
17976
  });
17499
- if (await fileExists(this.taskDataPath)) {
17500
- const content = await fs.readFile(this.taskDataPath, "utf8");
17501
- const data = JSON.parse(content);
17502
- logger.debug("Loaded task data", {
17503
- baseDir: this.project.baseDir,
17504
- taskId: this.taskId,
17505
- data
17506
- });
17507
- for (const key of Object.keys(data)) {
17508
- this.task[key] = data[key];
17509
- }
17510
- this.task.baseDir = this.project.baseDir;
17977
+ const data = await this.readTaskDataFromDisk();
17978
+ if (data) {
17979
+ this.applyTaskData(data);
17980
+ }
17981
+ }
17982
+ async readTaskDataFromDisk() {
17983
+ if (!await fileExists(this.taskDataPath)) {
17984
+ return null;
17985
+ }
17986
+ const content = await fs.readFile(this.taskDataPath, "utf8");
17987
+ const data = JSON.parse(content);
17988
+ logger.debug("Loaded task data", {
17989
+ baseDir: this.project.baseDir,
17990
+ taskId: this.taskId,
17991
+ data
17992
+ });
17993
+ return data;
17994
+ }
17995
+ applyTaskData(data) {
17996
+ const nextTaskData = {
17997
+ ...EMPTY_TASK_DATA,
17998
+ ...data,
17999
+ id: this.taskId,
18000
+ baseDir: this.project.baseDir
18001
+ };
18002
+ for (const key of Object.keys(this.task)) {
18003
+ delete this.task[key];
18004
+ }
18005
+ Object.assign(this.task, nextTaskData);
18006
+ }
18007
+ async reloadFromDisk() {
18008
+ await this.waitForTaskDataLoad();
18009
+ const previousTaskData = { ...this.task };
18010
+ const data = await this.readTaskDataFromDisk();
18011
+ const nextTaskData = {
18012
+ ...EMPTY_TASK_DATA,
18013
+ ...data || {},
18014
+ id: this.taskId,
18015
+ baseDir: this.project.baseDir
18016
+ };
18017
+ const taskDataChanged = !lodash.isEqual(previousTaskData, nextTaskData);
18018
+ if (taskDataChanged) {
18019
+ this.applyTaskData(data || {});
18020
+ }
18021
+ const contextChanged = await this.contextManager.reloadFromDisk();
18022
+ if (contextChanged && this.initialized) {
18023
+ this.eventManager.sendClearTask(this.project.baseDir, this.taskId, true, false);
18024
+ this.reloadGroupMessages(await this.contextManager.getContextMessages());
18025
+ await this.reloadConnectorMessages();
18026
+ await this.sendContextFilesUpdated();
18027
+ await this.updateContextInfo();
18028
+ void this.sendSkillsUpdated();
17511
18029
  }
18030
+ return { taskDataChanged, contextChanged };
17512
18031
  }
17513
18032
  /**
17514
18033
  * Generate a branch name from task name (first 7 words, separated by '-')
@@ -17604,13 +18123,16 @@ class Task {
17604
18123
  });
17605
18124
  return this.task;
17606
18125
  }
17607
- async init() {
18126
+ async init(readonly = false) {
17608
18127
  if (this.initialized) {
17609
18128
  logger.debug("Task already initialized, skipping", {
17610
18129
  baseDir: this.project.baseDir,
17611
18130
  taskId: this.taskId
17612
18131
  });
17613
18132
  this.eventManager.sendTaskInitialized(this.task);
18133
+ if (readonly) {
18134
+ return;
18135
+ }
17614
18136
  this.aiderManager.sendUpdateAiderModels();
17615
18137
  await this.updateAutocompletionData(void 0, true);
17616
18138
  await this.updateContextInfo();
@@ -17620,11 +18142,21 @@ class Task {
17620
18142
  await this.initPromise;
17621
18143
  return;
17622
18144
  }
17623
- this.initPromise = this.initInternal();
18145
+ this.initPromise = this.initInternal(readonly);
17624
18146
  await this.initPromise;
17625
18147
  this.initPromise = null;
17626
18148
  }
17627
- async initInternal() {
18149
+ async initInternal(readonly) {
18150
+ if (readonly) {
18151
+ if (await fileExists(this.getTaskDir())) {
18152
+ this.git = simpleGit.simpleGit(this.getTaskDir());
18153
+ }
18154
+ await this.loadContext();
18155
+ this.eventManager.sendTaskInitialized(this.task);
18156
+ this.initialized = true;
18157
+ await this.extensionManager.dispatchEvent("onTaskInitialized", { task: this.task }, this.project, this);
18158
+ return;
18159
+ }
17628
18160
  const workingMode = this.task.workingMode;
17629
18161
  const existingWorktree = await this.worktreeManager.getTaskWorktree(this.project.baseDir, this.taskId);
17630
18162
  if (workingMode === "worktree") {
@@ -17682,12 +18214,12 @@ class Task {
17682
18214
  this.initialized = true;
17683
18215
  await this.extensionManager.dispatchEvent("onTaskInitialized", { task: this.task }, this.project, this);
17684
18216
  }
17685
- async load() {
18217
+ async load(readonly = false) {
17686
18218
  logger.info("Loading task", {
17687
18219
  baseDir: this.project.baseDir,
17688
18220
  taskId: this.taskId
17689
18221
  });
17690
- await this.init();
18222
+ await this.init(readonly);
17691
18223
  const mode = this.getCurrentMode();
17692
18224
  return {
17693
18225
  messages: this.contextManager.getContextMessagesData(),
@@ -17979,6 +18511,17 @@ class Task {
17979
18511
  state: DefaultTaskState.Todo
17980
18512
  });
17981
18513
  }
18514
+ async saveEditedPrompt(messageId, prompt) {
18515
+ const contextMessages = await this.contextManager.getContextMessages();
18516
+ const savedPrompt = contextMessages[0];
18517
+ if (contextMessages.length !== 1 || savedPrompt?.id !== messageId || savedPrompt.role !== MessageRole.User) {
18518
+ throw new Error("Only a task with a single saved prompt can be edited and saved.");
18519
+ }
18520
+ await this.project.addToInputHistory(prompt);
18521
+ this.contextManager.setContextMessages([{ ...savedPrompt, content: prompt }]);
18522
+ this.addUserMessage(savedPrompt.id, prompt, savedPrompt.promptContext);
18523
+ await this.saveTask({ state: DefaultTaskState.Todo });
18524
+ }
17982
18525
  async runNextQueuedPrompt() {
17983
18526
  if (this.queuedPrompts.length > 0) {
17984
18527
  const nextPrompt = this.queuedPrompts.shift();
@@ -20872,10 +21415,18 @@ ${diff}
20872
21415
  message = beforeResult.message;
20873
21416
  amend = beforeResult.amend;
20874
21417
  const taskDir = this.getTaskDir();
20875
- await this.worktreeManager.commitChanges(taskDir, message, amend);
21418
+ const committed = await this.worktreeManager.commitChanges(taskDir, message, amend);
20876
21419
  await this.sendUpdatedFilesUpdated();
20877
21420
  await this.sendWorktreeIntegrationStatusUpdated();
20878
- await this.extensionManager.dispatchEvent("onAfterCommit", { message, amend }, this.project, this);
21421
+ if (committed) {
21422
+ await this.extensionManager.dispatchEvent("onAfterCommit", { message, amend }, this.project, this);
21423
+ } else {
21424
+ logger.info("Commit cancelled by user", { baseDir: this.project.baseDir, taskId: this.taskId });
21425
+ }
21426
+ }
21427
+ cancelCommitChanges() {
21428
+ const taskDir = this.getTaskDir();
21429
+ this.worktreeManager.cancelCommitChanges(taskDir);
20879
21430
  }
20880
21431
  async getWorktreeIntegrationStatus(targetBranch) {
20881
21432
  if (!this.task.worktree) {
@@ -21427,16 +21978,23 @@ class Project {
21427
21978
  customCommandManager;
21428
21979
  tasksLoadingPromise = null;
21429
21980
  tasks = /* @__PURE__ */ new Map();
21981
+ tasksReloadingPromise = null;
21430
21982
  connectors = [];
21431
21983
  inputHistoryFile = ".aider.input.history";
21432
- async start() {
21433
- await this.customCommandManager.start();
21434
- await this.promptsManager.watchProject(this.baseDir);
21435
- await this.agentProfileManager.initializeForProject(this.baseDir);
21436
- await this.extensionManager.reloadProjectExtensions(this);
21437
- await this.sendInputHistoryUpdatedEvent();
21438
- await this.extensionManager.dispatchEvent("onProjectStarted", { baseDir: this.baseDir }, this);
21439
- this.eventManager.sendProjectStarted(this.baseDir);
21984
+ startPromise = null;
21985
+ start() {
21986
+ if (!this.startPromise) {
21987
+ this.startPromise = (async () => {
21988
+ await this.customCommandManager.start();
21989
+ await this.promptsManager.watchProject(this.baseDir);
21990
+ await this.agentProfileManager.initializeForProject(this.baseDir);
21991
+ await this.extensionManager.reloadProjectExtensions(this);
21992
+ await this.sendInputHistoryUpdatedEvent();
21993
+ await this.extensionManager.dispatchEvent("onProjectStarted", { baseDir: this.baseDir }, this);
21994
+ this.eventManager.sendProjectStarted(this.baseDir);
21995
+ })();
21996
+ }
21997
+ return this.startPromise;
21440
21998
  }
21441
21999
  async prepareInternalTask() {
21442
22000
  const task = await this.prepareTask(INTERNAL_TASK_ID);
@@ -21541,6 +22099,7 @@ class Project {
21541
22099
  this.pythonInstaller,
21542
22100
  initialTaskData
21543
22101
  );
22102
+ await task.waitForTaskDataLoad();
21544
22103
  this.tasks.set(taskId, task);
21545
22104
  const extResult = await this.extensionManager.dispatchEvent("onTaskPrepared", { task: task.task }, this, task);
21546
22105
  if (extResult.task) {
@@ -21548,20 +22107,20 @@ class Project {
21548
22107
  }
21549
22108
  return task;
21550
22109
  }
22110
+ async getTaskIdsFromDisk() {
22111
+ const tasksDir = path.join(this.baseDir, AIDER_DESK_TASKS_DIR);
22112
+ if (!await fileExists(tasksDir)) {
22113
+ return [];
22114
+ }
22115
+ const taskFolders = await fs.readdir(tasksDir, { withFileTypes: true });
22116
+ return taskFolders.filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name).filter((taskId) => taskId !== INTERNAL_TASK_ID);
22117
+ }
21551
22118
  async loadTasks() {
21552
22119
  await this.prepareInternalTask();
21553
22120
  await migrateSessionsToTasks(this);
21554
- const tasksDir = path.join(this.baseDir, ".aider-desk", "tasks");
22121
+ const tasksDir = path.join(this.baseDir, AIDER_DESK_TASKS_DIR);
21555
22122
  try {
21556
- if (!await fileExists(tasksDir)) {
21557
- logger.debug("Tasks directory does not exist, skipping loadTasks", {
21558
- baseDir: this.baseDir,
21559
- tasksDir
21560
- });
21561
- return;
21562
- }
21563
- const taskFolders = await fs.readdir(tasksDir, { withFileTypes: true });
21564
- const taskDirs = taskFolders.filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name).filter((taskId) => taskId !== INTERNAL_TASK_ID);
22123
+ const taskDirs = await this.getTaskIdsFromDisk();
21565
22124
  logger.debug(`Loading ${taskDirs.length} tasks from directory`, {
21566
22125
  baseDir: this.baseDir,
21567
22126
  tasksDir
@@ -21705,27 +22264,37 @@ class Project {
21705
22264
  }
21706
22265
  return false;
21707
22266
  }
22267
+ async removeTaskWorktree(taskId, taskData) {
22268
+ if (!taskData?.worktree || this.isWorktreeSharedWithOtherTasks(taskData.worktree.path, taskId)) {
22269
+ return;
22270
+ }
22271
+ try {
22272
+ await this.worktreeManager.removeWorktree(this.baseDir, taskData.worktree);
22273
+ } catch (error) {
22274
+ logger.warn("Failed to remove worktree during task deletion", {
22275
+ baseDir: this.baseDir,
22276
+ taskId,
22277
+ worktreePath: taskData.worktree.path,
22278
+ error: error instanceof Error ? error.message : String(error)
22279
+ });
22280
+ }
22281
+ }
21708
22282
  async deleteTaskInternal(taskId) {
21709
- const taskDir = path.join(this.baseDir, ".aider-desk", "tasks", taskId);
22283
+ const taskDir = path.join(this.baseDir, AIDER_DESK_TASKS_DIR, taskId);
21710
22284
  const task = this.tasks.get(taskId);
21711
- if (task) {
21712
- await task.close();
21713
- this.tasks.delete(taskId);
21714
- this.eventManager.sendTaskDeleted(task.task);
21715
- }
21716
22285
  const taskData = task?.task;
21717
- if (taskData?.worktree && !this.isWorktreeSharedWithOtherTasks(taskData.worktree.path, taskId)) {
21718
- try {
21719
- await this.worktreeManager.removeWorktree(this.baseDir, taskData.worktree);
21720
- } catch (error) {
21721
- logger.warn("Failed to remove worktree during task deletion", {
21722
- baseDir: this.baseDir,
21723
- taskId,
21724
- worktreePath: taskData.worktree.path,
21725
- error: error instanceof Error ? error.message : String(error)
21726
- });
21727
- }
22286
+ if (!task) {
22287
+ await fs.rm(taskDir, { recursive: true, force: true });
22288
+ return;
22289
+ }
22290
+ const extResult = await this.extensionManager.dispatchEvent("onTaskDeleted", { task: task.task }, this, task);
22291
+ if (extResult.blocked) {
22292
+ throw new Error(`Task ${taskId} deletion was blocked by an extension`);
21728
22293
  }
22294
+ await task.close();
22295
+ this.tasks.delete(taskId);
22296
+ this.eventManager.sendTaskDeleted(task.task);
22297
+ await this.removeTaskWorktree(taskId, taskData);
21729
22298
  await fs.rm(taskDir, { recursive: true, force: true });
21730
22299
  }
21731
22300
  async deleteTask(taskId) {
@@ -21792,6 +22361,48 @@ class Project {
21792
22361
  await this.tasksLoadingPromise;
21793
22362
  return Array.from(this.tasks.values()).map((task) => task.task).filter((task) => task.id !== INTERNAL_TASK_ID);
21794
22363
  }
22364
+ async reloadTasks() {
22365
+ await this.tasksLoadingPromise;
22366
+ if (!this.tasksReloadingPromise) {
22367
+ this.tasksReloadingPromise = this.reloadTasksInternal().finally(() => {
22368
+ this.tasksReloadingPromise = null;
22369
+ });
22370
+ }
22371
+ return this.tasksReloadingPromise;
22372
+ }
22373
+ async reloadTasksInternal() {
22374
+ const taskIdsOnDisk = await this.getTaskIdsFromDisk();
22375
+ const taskIdsOnDiskSet = new Set(taskIdsOnDisk);
22376
+ for (const [taskId, task] of this.tasks) {
22377
+ if (taskId === INTERNAL_TASK_ID || taskIdsOnDiskSet.has(taskId)) {
22378
+ continue;
22379
+ }
22380
+ if (task.task.state === DefaultTaskState.InProgress) {
22381
+ continue;
22382
+ }
22383
+ const taskData = task.task;
22384
+ await task.close(false, false);
22385
+ this.tasks.delete(taskId);
22386
+ await this.removeTaskWorktree(taskId, taskData);
22387
+ this.eventManager.sendTaskDeleted(taskData);
22388
+ }
22389
+ for (const taskId of taskIdsOnDisk) {
22390
+ const task = this.tasks.get(taskId);
22391
+ if (!task) {
22392
+ const newTask = await this.prepareTask(taskId);
22393
+ this.eventManager.sendTaskCreated(newTask.task);
22394
+ continue;
22395
+ }
22396
+ if (task.task.state === DefaultTaskState.InProgress) {
22397
+ continue;
22398
+ }
22399
+ const { taskDataChanged } = await task.reloadFromDisk();
22400
+ if (taskDataChanged) {
22401
+ this.eventManager.sendTaskUpdated(task.task);
22402
+ }
22403
+ }
22404
+ return this.getTasks();
22405
+ }
21795
22406
  forEachTask(callback, initializedOnly = true) {
21796
22407
  this.tasks.values().filter((task) => !initializedOnly || task.isInitialized()).forEach(callback);
21797
22408
  }
@@ -21807,6 +22418,8 @@ class Project {
21807
22418
  });
21808
22419
  }
21809
22420
  async close() {
22421
+ await this.startPromise;
22422
+ this.startPromise = null;
21810
22423
  await this.extensionManager.dispatchEvent("onProjectStopped", { baseDir: this.baseDir }, this);
21811
22424
  this.customCommandManager.dispose();
21812
22425
  this.agentProfileManager.removeProject(this.baseDir);
@@ -21883,6 +22496,9 @@ class ProjectManager {
21883
22496
  }
21884
22497
  return project;
21885
22498
  }
22499
+ getOpenProject(baseDir) {
22500
+ return this.findProject(baseDir);
22501
+ }
21886
22502
  async startProject(baseDir) {
21887
22503
  logger.info("Starting project", { baseDir });
21888
22504
  const project = this.getProject(baseDir);
@@ -22232,12 +22848,14 @@ class EventManager {
22232
22848
  this.eventsConnectors = this.eventsConnectors.filter((connector) => connector.socket.id !== socket.id);
22233
22849
  logger.info("Subscribing to events", {
22234
22850
  eventTypes: config.eventTypes,
22235
- baseDirs: config.baseDirs
22851
+ baseDirs: config.baseDirs,
22852
+ readonly: config.readonly
22236
22853
  });
22237
22854
  this.eventsConnectors.push({
22238
22855
  socket,
22239
22856
  eventTypes: config.eventTypes,
22240
- baseDirs: config.baseDirs
22857
+ baseDirs: config.baseDirs,
22858
+ readonly: config.readonly
22241
22859
  });
22242
22860
  }
22243
22861
  unsubscribe(socket, log = true) {
@@ -22278,10 +22896,10 @@ class EventManager {
22278
22896
  }
22279
22897
  return;
22280
22898
  }
22281
- const baseDir = data?.baseDir;
22282
- if (connector.baseDirs && baseDir && !connector.baseDirs.includes(baseDir)) {
22899
+ const eventProjectDir = data && typeof data === "object" ? data.baseDir ?? data.projectDir : void 0;
22900
+ if (connector.baseDirs && (!eventProjectDir || !connector.baseDirs.includes(eventProjectDir))) {
22283
22901
  if (log) {
22284
- logger.debug("Skipping event broadcast to connector, base dir not included:", { baseDir, connectorBaseDirs: connector.baseDirs });
22902
+ logger.debug("Skipping event broadcast to connector, base dir not included:", { baseDir: eventProjectDir, connectorBaseDirs: connector.baseDirs });
22285
22903
  }
22286
22904
  return;
22287
22905
  }
@@ -22289,7 +22907,7 @@ class EventManager {
22289
22907
  if (log) {
22290
22908
  logger.debug("Broadcasting event to connector:", {
22291
22909
  eventType,
22292
- baseDir
22910
+ baseDir: eventProjectDir
22293
22911
  });
22294
22912
  }
22295
22913
  connector.socket.emit("event", { type: eventType, data });
@@ -24843,11 +25461,12 @@ const createOpenAIVoiceSession = async (profile, settings) => {
24843
25461
  throw new Error("OpenAI API key is required for voice session");
24844
25462
  }
24845
25463
  try {
24846
- const model = provider.voice?.model ?? OpenAiVoiceModel.GptRealtimeWhisper;
25464
+ const model = provider.voice?.model ?? OpenAiVoiceModel.GptLiveTranscribe;
24847
25465
  const language = provider.voice?.language ?? "en";
24848
25466
  const prompt = provider.voice?.systemInstructions ?? DEFAULT_VOICE_SYSTEM_INSTRUCTIONS;
24849
25467
  const idleTimeoutMs = provider.voice?.idleTimeoutMs ?? 5e3;
24850
- const supportsTranscriptionParams = model !== OpenAiVoiceModel.GptRealtimeWhisper;
25468
+ const supportsTranscriptionParams = model !== OpenAiVoiceModel.GptRealtimeWhisper && model !== OpenAiVoiceModel.GptLiveTranscribe;
25469
+ const usesLanguageHints = model === OpenAiVoiceModel.GptLiveTranscribe;
24851
25470
  const response = await fetch("https://api.openai.com/v1/realtime/client_secrets", {
24852
25471
  method: "POST",
24853
25472
  headers: {
@@ -24860,8 +25479,8 @@ const createOpenAIVoiceSession = async (profile, settings) => {
24860
25479
  audio: {
24861
25480
  input: {
24862
25481
  transcription: {
24863
- language,
24864
25482
  model,
25483
+ ...usesLanguageHints ? { languages: [language] } : { language },
24865
25484
  ...supportsTranscriptionParams && { prompt }
24866
25485
  },
24867
25486
  ...supportsTranscriptionParams && {
@@ -25497,13 +26116,13 @@ const getRequestyUsageReport = (task, provider, model, usage, providerMetadata)
25497
26116
  const totalSentTokens = usage.inputTokens || 0;
25498
26117
  const receivedTokens = usage.outputTokens || 0;
25499
26118
  const { requesty } = providerMetadata ? providerMetadata : {};
25500
- logger.info("Requesty usage report", {
26119
+ logger.debug("Requesty usage report", {
25501
26120
  requesty,
25502
26121
  usage
25503
26122
  });
25504
- const cacheWriteTokens = requesty?.usage?.cachingTokens ?? 0;
25505
- const cacheReadTokens = requesty?.usage?.cachedTokens ?? 0;
25506
- const sentTokens = totalSentTokens - cacheReadTokens;
26123
+ const cacheWriteTokens = usage.inputTokenDetails?.cacheWriteTokens ?? requesty?.usage?.cachingTokens ?? 0;
26124
+ const cacheReadTokens = usage.inputTokenDetails?.cacheReadTokens ?? requesty?.usage?.cachedTokens ?? 0;
26125
+ const sentTokens = usage.inputTokenDetails?.noCacheTokens ?? totalSentTokens - cacheReadTokens;
25507
26126
  const messageCost = calculateRequestyCost(model, sentTokens, receivedTokens, cacheWriteTokens, cacheReadTokens);
25508
26127
  return {
25509
26128
  model: `${provider.id}/${model.id}`,
@@ -26030,6 +26649,9 @@ class ModelManager {
26030
26649
  logger.error("Error initializing ModelInfoManager:", error);
26031
26650
  }
26032
26651
  }
26652
+ async waitForInit() {
26653
+ await this.initPromise;
26654
+ }
26033
26655
  async loadModelsInfo() {
26034
26656
  const cacheFile = path.join(AIDER_DESK_CACHE_DIR, "models-meta.json");
26035
26657
  let cacheLoaded = false;
@@ -28158,6 +28780,9 @@ class ProjectContextImpl {
28158
28780
  async getTasks() {
28159
28781
  return this.project.getTasks();
28160
28782
  }
28783
+ async reloadTasks() {
28784
+ return this.project.reloadTasks();
28785
+ }
28161
28786
  getMostRecentTask() {
28162
28787
  const task = this.project.getMostRecentTask();
28163
28788
  return task ? new TaskContextImpl(task) : null;
@@ -29095,6 +29720,11 @@ class ExtensionManager {
29095
29720
  isInitialized() {
29096
29721
  return this.initialized;
29097
29722
  }
29723
+ async waitForInit() {
29724
+ while (!this.initialized) {
29725
+ await new Promise((resolve) => setTimeout(resolve, 50));
29726
+ }
29727
+ }
29098
29728
  /**
29099
29729
  * @deprecated Migration helper: converts old name-based disabled list to filePath-based.
29100
29730
  * Will be removed in a future version.
@@ -30723,6 +31353,7 @@ class EventsHandler {
30723
31353
  this.projectManager.getProject(baseDir).getTask(taskId)?.applyEdits(edits);
30724
31354
  }
30725
31355
  async runPrompt(baseDir, taskId, prompt, mode, images) {
31356
+ await Promise.all([this.modelManager.waitForInit(), this.extensionManager.waitForInit()]);
30726
31357
  return this.projectManager.getProject(baseDir).getTask(taskId)?.runPrompt(prompt, mode, true, void 0, true, images) || [];
30727
31358
  }
30728
31359
  async waitForTaskIdle(baseDir, taskId) {
@@ -30734,6 +31365,7 @@ class EventsHandler {
30734
31365
  await task.waitForIdle();
30735
31366
  }
30736
31367
  async ensureProjectAndCreateTask(projectDir, params) {
31368
+ await Promise.all([this.modelManager.waitForInit(), this.extensionManager.waitForInit()]);
30737
31369
  const projects = this.store.getOpenProjects();
30738
31370
  const baseDir = projectDir.endsWith("/") ? projectDir.slice(0, -1) : projectDir;
30739
31371
  const existingProject = projects.find((p) => compareBaseDirs$1(p.baseDir, baseDir));
@@ -30750,6 +31382,9 @@ class EventsHandler {
30750
31382
  async savePrompt(baseDir, taskId, prompt) {
30751
31383
  return this.projectManager.getProject(baseDir).getTask(taskId)?.savePromptOnly(prompt);
30752
31384
  }
31385
+ async saveEditedPrompt(baseDir, taskId, messageId, prompt) {
31386
+ return this.projectManager.getProject(baseDir).getTask(taskId)?.saveEditedPrompt(messageId, prompt);
31387
+ }
30753
31388
  async answerQuestion(baseDir, taskId, answer) {
30754
31389
  await this.projectManager.getProject(baseDir).getTask(taskId)?.answerQuestion(answer);
30755
31390
  }
@@ -30944,6 +31579,13 @@ class EventsHandler {
30944
31579
  }
30945
31580
  await task.commitChanges(message, amend);
30946
31581
  }
31582
+ cancelCommitChanges(baseDir, taskId) {
31583
+ const task = this.projectManager.getProject(baseDir).getTask(taskId);
31584
+ if (!task) {
31585
+ throw new Error(`Task ${taskId} not found`);
31586
+ }
31587
+ task.cancelCommitChanges();
31588
+ }
30947
31589
  async listBranches(projectDir) {
30948
31590
  return await this.projectManager.worktreeManager.listBranches(projectDir);
30949
31591
  }
@@ -31067,6 +31709,9 @@ ${error instanceof Error ? error.message : String(error)}`);
31067
31709
  async getTasks(baseDir) {
31068
31710
  return this.projectManager.getProject(baseDir).getTasks();
31069
31711
  }
31712
+ async reloadTasks(baseDir) {
31713
+ return this.projectManager.getProject(baseDir).reloadTasks();
31714
+ }
31070
31715
  async loadTask(baseDir, taskId) {
31071
31716
  return this.projectManager.getProject(baseDir).getTask(taskId)?.load() || {
31072
31717
  messages: [],
@@ -32059,7 +32704,7 @@ class PythonDependenciesInstaller {
32059
32704
  }
32060
32705
  async createVirtualEnvInternal() {
32061
32706
  this.setStatus({ state: "creating-venv" });
32062
- const command = `"${await getResolvedUvPath()}" venv "${PYTHON_VENV_DIR}" --python 3.12`;
32707
+ const command = `"${await getResolvedUvPath()}" venv "${PYTHON_VENV_DIR}" --python 3.12 --clear`;
32063
32708
  logger.info(`Creating virtual environment with uv: ${command}`, {
32064
32709
  virtualEnv: PYTHON_VENV_DIR
32065
32710
  });
@@ -32299,7 +32944,8 @@ const initManagers = async (store, windowManager) => {
32299
32944
  modelManager,
32300
32945
  agentProfileManager,
32301
32946
  extensionManager,
32302
- pythonInstaller
32947
+ pythonInstaller,
32948
+ projectManager
32303
32949
  };
32304
32950
  };
32305
32951
  const performStartUp = async (pythonInstaller, updateProgress) => {
@@ -32822,6 +33468,8 @@ const DEFAULT_SETTINGS = {
32822
33468
  },
32823
33469
  server: {
32824
33470
  enabled: false,
33471
+ readonly: false,
33472
+ readonlyExtensionUi: true,
32825
33473
  basicAuth: {
32826
33474
  enabled: false,
32827
33475
  username: "",
@@ -33148,10 +33796,16 @@ class Store {
33148
33796
  const addProjectsFromEnv = async (store, modelManager, agentProfileManager) => {
33149
33797
  const aiderDeskProjectsEnv = process.env.AIDER_DESK_PROJECTS;
33150
33798
  if (!aiderDeskProjectsEnv) {
33799
+ if (READONLY_MODE) {
33800
+ throw new Error("AIDER_DESK_PROJECTS must contain at least one project when readonly mode is enabled.");
33801
+ }
33151
33802
  return;
33152
33803
  }
33153
33804
  const projectPaths = aiderDeskProjectsEnv.split(",").map((p) => p.trim()).filter((p) => p.length > 0);
33154
33805
  if (projectPaths.length === 0) {
33806
+ if (READONLY_MODE) {
33807
+ throw new Error("AIDER_DESK_PROJECTS must contain at least one project when readonly mode is enabled.");
33808
+ }
33155
33809
  return;
33156
33810
  }
33157
33811
  logger.info("AIDER_DESK_PROJECTS environment variable found", { projectPaths });
@@ -33196,11 +33850,20 @@ const main = async () => {
33196
33850
  };
33197
33851
  const store = new Store();
33198
33852
  await store.init(AIDER_DESK_DATA_DIR);
33199
- const { modelManager, agentProfileManager, pythonInstaller } = await initManagers(store);
33853
+ const { modelManager, agentProfileManager, pythonInstaller, projectManager, serverController } = await initManagers(store);
33200
33854
  try {
33201
33855
  await performStartUp(pythonInstaller, updateProgress);
33202
33856
  logger.info("Startup complete");
33203
33857
  await addProjectsFromEnv(store, modelManager, agentProfileManager);
33858
+ if (READONLY_MODE) {
33859
+ const configuredProjects = process.env.AIDER_DESK_PROJECTS?.split(",").map((project) => project.trim()).filter(Boolean) ?? [];
33860
+ if (configuredProjects.length === 0) {
33861
+ throw new Error("AIDER_DESK_PROJECTS must contain at least one project in readonly mode");
33862
+ }
33863
+ const projects = store.getOpenProjects();
33864
+ await Promise.all(projects.map((project) => projectManager.startProject(project.baseDir)));
33865
+ serverController.setReadonlyReady();
33866
+ }
33204
33867
  logger.info(`AiderDesk Runner is ready and running on port ${SERVER_PORT}. You can now open http://localhost:${SERVER_PORT} in your browser.`);
33205
33868
  } catch (error) {
33206
33869
  logger.error("Failed to start AiderDesk Node Runner:", error);