@aiderdesk/aiderdesk 0.75.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.
- package/out/cli.js +124 -17
- package/out/renderer/assets/{AgentSettings-DX34HLFv.js → AgentSettings-B73lGg-P.js} +2 -2
- package/out/renderer/assets/{InfoIcon-DzyZQ7Ye.js → InfoIcon-BaDK-htg.js} +1 -1
- package/out/renderer/assets/{Onboarding-FwXfKZ8B.js → Onboarding-CttlAepw.js} +4 -4
- package/out/renderer/assets/{ProviderHeader-Cii9aAmV.js → ProviderHeader-B0-K9908.js} +2 -2
- package/out/renderer/assets/{SettingsPage-XanGltUZ.js → SettingsPage-BtyX7Wv1.js} +351 -284
- package/out/renderer/assets/{UsageDashboard-eHbvZTZC.js → UsageDashboard-CKuev9SP.js} +3 -3
- package/out/renderer/assets/{arc-CVfdiTl1.js → arc-CDCMm4PF.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-3BPJPVTR-DsLLo_Ek.js → architectureDiagram-3BPJPVTR-DoyTFQYe.js} +4 -4
- package/out/renderer/assets/{blockDiagram-GPEHLZMM-eWy47S0_.js → blockDiagram-GPEHLZMM-CophuS51.js} +4 -4
- package/out/renderer/assets/{c4Diagram-AAUBKEIU-BH9b_e6y.js → c4Diagram-AAUBKEIU-Dc3YxNWW.js} +2 -2
- package/out/renderer/assets/{channel-D1z_mPGJ.js → channel-cZzRDUFG.js} +1 -1
- package/out/renderer/assets/{chunk-2J33WTMH-DK0Yw_7f.js → chunk-2J33WTMH-YV6ZtOyU.js} +1 -1
- package/out/renderer/assets/{chunk-4BX2VUAB-DIGR8Y5b.js → chunk-4BX2VUAB-DKNGjk29.js} +1 -1
- package/out/renderer/assets/{chunk-55IACEB6-DoCkLI5e.js → chunk-55IACEB6-MkIW5gHI.js} +1 -1
- package/out/renderer/assets/{chunk-727SXJPM-C2gQLzLi.js → chunk-727SXJPM-CPUXDO_8.js} +5 -5
- package/out/renderer/assets/{chunk-AQP2D5EJ-D83_SlRR.js → chunk-AQP2D5EJ-CYCp3XBh.js} +3 -3
- package/out/renderer/assets/{chunk-FMBD7UC4-CyiPoUsC.js → chunk-FMBD7UC4-DIj-DOVN.js} +1 -1
- package/out/renderer/assets/{chunk-ND2GUHAM-DfGsUYDD.js → chunk-ND2GUHAM-BWiS_Ttp.js} +1 -1
- package/out/renderer/assets/{chunk-QZHKN3VN-BhnTFlht.js → chunk-QZHKN3VN-4NHol9Dz.js} +1 -1
- package/out/renderer/assets/{classDiagram-4FO5ZUOK-Dy7E8tVe.js → classDiagram-4FO5ZUOK-C1yfJEIb.js} +6 -6
- package/out/renderer/assets/{classDiagram-v2-Q7XG4LA2-Dy7E8tVe.js → classDiagram-v2-Q7XG4LA2-C1yfJEIb.js} +6 -6
- package/out/renderer/assets/{cose-bilkent-S5V4N54A-Dsl61WN3.js → cose-bilkent-S5V4N54A-B8D60fQa.js} +2 -2
- package/out/renderer/assets/{cytoscape.esm-Bm8DJGmZ.js → cytoscape.esm-BNSvh83I.js} +957 -957
- package/out/renderer/assets/{dagre-BM42HDAG-D-u18G94.js → dagre-BM42HDAG-5_V5lQc0.js} +3 -3
- package/out/renderer/assets/{diagram-2AECGRRQ-BumP49Qp.js → diagram-2AECGRRQ-Bb4cbiKY.js} +3 -3
- package/out/renderer/assets/{diagram-5GNKFQAL-VpUN87Sw.js → diagram-5GNKFQAL-DQ_vjlxb.js} +4 -4
- package/out/renderer/assets/{diagram-KO2AKTUF-CXCWwzRa.js → diagram-KO2AKTUF-So0t9fVd.js} +3 -3
- package/out/renderer/assets/{diagram-LMA3HP47-vlOcStwn.js → diagram-LMA3HP47-CbSRJgt4.js} +3 -3
- package/out/renderer/assets/{diagram-OG6HWLK6-DS1BscxN.js → diagram-OG6HWLK6-Bls2tZCJ.js} +4 -4
- package/out/renderer/assets/{erDiagram-TEJ5UH35-DPi6-CLL.js → erDiagram-TEJ5UH35-CESbOlvh.js} +4 -4
- package/out/renderer/assets/{flowDiagram-I6XJVG4X-BYlX12Cd.js → flowDiagram-I6XJVG4X-B-35DKDx.js} +6 -6
- package/out/renderer/assets/{ganttDiagram-6RSMTGT7-BJQl-A9d.js → ganttDiagram-6RSMTGT7-BL1OQkTj.js} +3 -3
- package/out/renderer/assets/{gitGraphDiagram-PVQCEYII-CUFXx3IZ.js → gitGraphDiagram-PVQCEYII-SJkGLAAz.js} +4 -4
- package/out/renderer/assets/{graph-CbFubTTc.js → graph-BSxR7Gef.js} +1 -1
- package/out/renderer/assets/{index-BkdacTnN.js → index-BVOpoJw8.js} +1 -1
- package/out/renderer/assets/{index-B9iW9QmT.js → index-BqZxyppq.js} +1 -1
- package/out/renderer/assets/{index-DNlMJMPg.js → index-Cmn9J2p1.js} +11166 -7522
- package/out/renderer/assets/{index-Cg7tn967.js → index-DFODyrlX.js} +4 -4
- package/out/renderer/assets/{index-DeoI6jti.js → index-DGcKtfCM.js} +1 -1
- package/out/renderer/assets/{index-DCILJy4w.css → index-DVEVSdXO.css} +72 -884
- package/out/renderer/assets/{index-fD843lMX.js → index-DgDxO_E3.js} +1 -1
- package/out/renderer/assets/{index-C7885gEz.js → index-HJk8ZKtm.js} +1 -1
- package/out/renderer/assets/{index-B6R_BNfE.js → index-NF_MxNl9.js} +1 -1
- package/out/renderer/assets/{index-9GNr8q1O.js → index-VX8ukL4o.js} +1 -1
- package/out/renderer/assets/{index-DYKLRIHT.js → index-xCqv98zj.js} +1 -1
- package/out/renderer/assets/{infoDiagram-5YYISTIA-IWJLFUYz.js → infoDiagram-5YYISTIA-lRTvqfXx.js} +2 -2
- package/out/renderer/assets/{ishikawaDiagram-YF4QCWOH-BuNfm7cB.js → ishikawaDiagram-YF4QCWOH-CtsU-ctO.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-JHISSGLW-CfceKUHO.js → journeyDiagram-JHISSGLW-3MrLeKXj.js} +4 -4
- package/out/renderer/assets/{jsx-dev-runtime-DT3FTts0.js → jsx-dev-runtime-BTcJ8PkQ.js} +1 -1
- package/out/renderer/assets/{kanban-definition-UN3LZRKU-Bb6YnEgS.js → kanban-definition-UN3LZRKU-CinUVJ12.js} +2 -2
- package/out/renderer/assets/{katex-DK1nL-FM.js → katex-Co8xHYNH.js} +193 -193
- package/out/renderer/assets/{layout-BkrDn6V9.js → layout-C9eRMSnE.js} +2 -2
- package/out/renderer/assets/{linear-jxO_dc8P.js → linear-WwW43_Ig.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-RKZ34NQL-BPRx7p9A.js → mindmap-definition-RKZ34NQL-B-K0dkdA.js} +3 -3
- package/out/renderer/assets/{pieDiagram-4H26LBE5-CPR4AuPM.js → pieDiagram-4H26LBE5-eotxzUOT.js} +4 -4
- package/out/renderer/assets/pierre-dark-BL-l9r39.js +4 -0
- package/out/renderer/assets/pierre-dark-protanopia-deuteranopia-BBjGuJQU.js +4 -0
- package/out/renderer/assets/pierre-dark-soft-B6TBhICr.js +4 -0
- package/out/renderer/assets/pierre-dark-tritanopia-f-j_EX9A.js +4 -0
- package/out/renderer/assets/pierre-dark-vibrant-yElMGqZN.js +4 -0
- package/out/renderer/assets/pierre-light-BUzWTcjO.js +4 -0
- package/out/renderer/assets/pierre-light-protanopia-deuteranopia-DlvVSCaI.js +4 -0
- package/out/renderer/assets/pierre-light-soft-CCMU-Zh0.js +4 -0
- package/out/renderer/assets/pierre-light-tritanopia-v4xacE1C.js +4 -0
- package/out/renderer/assets/pierre-light-vibrant-BRUbQnMc.js +4 -0
- package/out/renderer/assets/{quadrantDiagram-W4KKPZXB-BKzlAr7m.js → quadrantDiagram-W4KKPZXB-BtKKvYmW.js} +2 -2
- package/out/renderer/assets/{requirementDiagram-4Y6WPE33-CUan3EZI.js → requirementDiagram-4Y6WPE33-k_JQl4AM.js} +3 -3
- package/out/renderer/assets/{sankeyDiagram-5OEKKPKP-y8X8qnX2.js → sankeyDiagram-5OEKKPKP-BVDWaFSn.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-3UESZ5HK-B4xv8iDW.js → sequenceDiagram-3UESZ5HK-dpVnolZO.js} +3 -3
- package/out/renderer/assets/{stateDiagram-AJRCARHV-DTPE2Z4L.js → stateDiagram-AJRCARHV-DYd-R9tJ.js} +6 -6
- package/out/renderer/assets/{stateDiagram-v2-BHNVJYJU-BmZ9o6q3.js → stateDiagram-v2-BHNVJYJU-CyE2HX6z.js} +4 -4
- package/out/renderer/assets/{time-D391Z6zp.js → time-Claj2vse.js} +1 -1
- package/out/renderer/assets/{timeline-definition-PNZ67QCA-DVLUB2HD.js → timeline-definition-PNZ67QCA-0vKYrH6S.js} +2 -2
- package/out/renderer/assets/{vennDiagram-CIIHVFJN-BGGBlVN1.js → vennDiagram-CIIHVFJN-op3DVQGG.js} +1 -1
- package/out/renderer/assets/{wardley-L42UT6IY-ZVVSjQUD.js → wardley-L42UT6IY-CsNzYaF9.js} +1 -1
- package/out/renderer/assets/{wardleyDiagram-YWT4CUSO-CRAH-LRw.js → wardleyDiagram-YWT4CUSO-D3jK8kAv.js} +3 -3
- package/out/renderer/assets/{worker-BdXuKH1Q.js → worker-CdcPcIJG.js} +322 -102
- package/out/renderer/assets/{xychartDiagram-2RQKCTM6-DQqvm7M3.js → xychartDiagram-2RQKCTM6-C9wPvZAU.js} +2 -2
- package/out/renderer/index.html +2 -2
- package/out/resources/connector/connector.py +3 -1
- package/out/resources/prompts/init-project.hbs +16 -42
- package/out/resources/prompts/system-prompt.hbs +25 -60
- package/out/resources/prompts/workflow.hbs +17 -52
- package/out/resources/skills/extension-creator/SKILL.md +1 -0
- package/out/resources/skills/extension-creator/references/event-types.md +38 -1
- package/out/resources/skills/extension-creator/references/extension-interface.md +50 -0
- package/out/resources/skills/extension-creator/references/ui-components.md +6 -0
- package/out/runner.js +1284 -242
- package/package.json +16 -16
- package/patches/{ai+7.0.28.patch → ai+7.0.37.patch} +3 -3
- package/out/renderer/assets/pierre-dark-C-Drv5KU.js +0 -4
- package/out/renderer/assets/pierre-dark-soft-Cd74uQaL.js +0 -4
- package/out/renderer/assets/pierre-light-CfQnmt6J.js +0 -4
- package/out/renderer/assets/pierre-light-soft-DMVdU74b.js +0 -4
- package/out/resources/linux/probe +0 -0
- package/out/resources/linux-x64/probe +0 -0
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
|
|
148
|
-
Use this tool
|
|
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.
|
|
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.
|
|
158
149
|
|
|
159
|
-
|
|
160
|
-
- A clear, complete, and standalone natural language prompt describing the coding task.
|
|
161
|
-
|
|
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
|
|
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
|
|
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
|
|
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.",
|
|
@@ -386,7 +372,7 @@ const TaskDataSchema = zod.z.object({
|
|
|
386
372
|
lastMergeState: MergeStateSchema.optional(),
|
|
387
373
|
aiderTotalCost: zod.z.number(),
|
|
388
374
|
agentTotalCost: zod.z.number(),
|
|
389
|
-
autonomyMode: zod.z.
|
|
375
|
+
autonomyMode: zod.z.enum(AutonomyMode).optional(),
|
|
390
376
|
agentProfileId: zod.z.string().optional(),
|
|
391
377
|
provider: zod.z.string().optional(),
|
|
392
378
|
model: zod.z.string().optional(),
|
|
@@ -413,6 +399,7 @@ var DefaultTaskState = /* @__PURE__ */ ((DefaultTaskState2) => {
|
|
|
413
399
|
DefaultTaskState2["Done"] = "DONE";
|
|
414
400
|
return DefaultTaskState2;
|
|
415
401
|
})(DefaultTaskState || {});
|
|
402
|
+
new Set(Object.values(DefaultTaskState));
|
|
416
403
|
const TaskStateEmoji = {
|
|
417
404
|
[
|
|
418
405
|
"TODO"
|
|
@@ -584,7 +571,44 @@ const extractProviderModel = (modelId) => {
|
|
|
584
571
|
return [providerId, modelParts.join("/")];
|
|
585
572
|
};
|
|
586
573
|
const isUuid = (id) => /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id);
|
|
574
|
+
const parseCommandArgs = (input) => {
|
|
575
|
+
const args = [];
|
|
576
|
+
let current = "";
|
|
577
|
+
let inQuotes = false;
|
|
578
|
+
let wasQuoted = false;
|
|
579
|
+
for (let i = 0; i < input.length; i++) {
|
|
580
|
+
const char = input[i];
|
|
581
|
+
if (char === '"') {
|
|
582
|
+
wasQuoted = true;
|
|
583
|
+
inQuotes = !inQuotes;
|
|
584
|
+
} else if (char === " " && !inQuotes) {
|
|
585
|
+
if (current || wasQuoted) {
|
|
586
|
+
args.push(current);
|
|
587
|
+
current = "";
|
|
588
|
+
wasQuoted = false;
|
|
589
|
+
}
|
|
590
|
+
} else {
|
|
591
|
+
current += char;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (current || wasQuoted) {
|
|
595
|
+
args.push(current);
|
|
596
|
+
}
|
|
597
|
+
return args;
|
|
598
|
+
};
|
|
587
599
|
const DEFAULT_PAGE_SIZE = 100;
|
|
600
|
+
const safeStringify = (obj) => {
|
|
601
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
602
|
+
return JSON.stringify(obj, (_key, value) => {
|
|
603
|
+
if (typeof value === "object" && value !== null) {
|
|
604
|
+
if (seen.has(value)) {
|
|
605
|
+
return "[Circular]";
|
|
606
|
+
}
|
|
607
|
+
seen.add(value);
|
|
608
|
+
}
|
|
609
|
+
return value;
|
|
610
|
+
});
|
|
611
|
+
};
|
|
588
612
|
class LogBuffer {
|
|
589
613
|
db = null;
|
|
590
614
|
/**
|
|
@@ -618,8 +642,12 @@ class LogBuffer {
|
|
|
618
642
|
INSERT INTO system_logs (timestamp, level, message, extension, metadata)
|
|
619
643
|
VALUES (?, ?, ?, ?, ?)
|
|
620
644
|
`;
|
|
645
|
+
const metadata = entry.metadata ? safeStringify(entry.metadata) : null;
|
|
646
|
+
if (metadata) {
|
|
647
|
+
entry.metadata = JSON.parse(metadata);
|
|
648
|
+
}
|
|
621
649
|
const stmt = this.db.prepare(sql);
|
|
622
|
-
const result = stmt.run(entry.timestamp, entry.level, entry.message, entry.extension || null,
|
|
650
|
+
const result = stmt.run(entry.timestamp, entry.level, entry.message, entry.extension || null, metadata);
|
|
623
651
|
return result.lastInsertRowid;
|
|
624
652
|
}
|
|
625
653
|
/**
|
|
@@ -855,11 +883,13 @@ const EXTENSIONS_REPOS_CACHE_DIR = path.join(AIDER_DESK_CACHE_DIR, "extensions")
|
|
|
855
883
|
const POSTHOG_PUBLIC_API_KEY = "phc_AF4zkjrcziXLh8PBFsRSvVr4VZ38p3ezsdX0KDYuElI";
|
|
856
884
|
const POSTHOG_HOST = "https://eu.i.posthog.com";
|
|
857
885
|
const HEADLESS_MODE = process.env.AIDER_DESK_HEADLESS === "true";
|
|
886
|
+
const READONLY_MODE = process.env.AIDER_DESK_READONLY === "true";
|
|
858
887
|
const APP_TYPE = process.env.AIDER_DESK_APP_TYPE || (HEADLESS_MODE ? "docker" : "electron");
|
|
859
888
|
process.env.AIDER_DESK_DISABLE_MENU === "true";
|
|
860
889
|
const AUTH_USERNAME = process.env.AIDER_DESK_USERNAME;
|
|
861
890
|
const AUTH_PASSWORD = process.env.AIDER_DESK_PASSWORD;
|
|
862
891
|
const CORS_ALLOWED_ORIGINS = process.env.AIDER_DESK_CORS_ALLOWED_ORIGINS;
|
|
892
|
+
const READONLY_EXTENSION_UI = process.env.AIDER_DESK_READONLY_EXTENSION_UI;
|
|
863
893
|
const PROBE_BINARY_PATH = path.join(
|
|
864
894
|
RESOURCES_DIR,
|
|
865
895
|
process.platform === "win32" ? "win" : process.platform === "darwin" ? "macos" : "linux",
|
|
@@ -1210,7 +1240,9 @@ const getShellPath = () => {
|
|
|
1210
1240
|
pathLength: shellPath.split(":").length
|
|
1211
1241
|
});
|
|
1212
1242
|
} catch (error) {
|
|
1213
|
-
logger.error("Failed to load PATH from shell config:",
|
|
1243
|
+
logger.error("Failed to load PATH from shell config:", {
|
|
1244
|
+
error: error instanceof Error ? { message: error.message, name: error.name } : String(error)
|
|
1245
|
+
});
|
|
1214
1246
|
try {
|
|
1215
1247
|
shellPath = extractPathFromOutput(
|
|
1216
1248
|
child_process.execSync(shellCommand, {
|
|
@@ -1227,7 +1259,9 @@ const getShellPath = () => {
|
|
|
1227
1259
|
);
|
|
1228
1260
|
logger.debug("Loaded PATH using login shell flags");
|
|
1229
1261
|
} catch (loginError) {
|
|
1230
|
-
logger.error("Failed to load PATH from login shell:",
|
|
1262
|
+
logger.error("Failed to load PATH from login shell:", {
|
|
1263
|
+
error: loginError instanceof Error ? { message: loginError.message, name: loginError.name } : String(loginError)
|
|
1264
|
+
});
|
|
1231
1265
|
shellPath = process.env.PATH || "";
|
|
1232
1266
|
}
|
|
1233
1267
|
}
|
|
@@ -1354,7 +1388,7 @@ const getShellPath = () => {
|
|
|
1354
1388
|
return cachedPath;
|
|
1355
1389
|
} catch (error) {
|
|
1356
1390
|
logger.error("ERROR: Failed to get shell PATH", {
|
|
1357
|
-
error,
|
|
1391
|
+
error: error instanceof Error ? { message: error.message, name: error.name } : String(error),
|
|
1358
1392
|
stack: error instanceof Error ? error.stack : "No stack trace available"
|
|
1359
1393
|
});
|
|
1360
1394
|
if (!isWindows) {
|
|
@@ -1403,7 +1437,7 @@ const getShellPath = () => {
|
|
|
1403
1437
|
}
|
|
1404
1438
|
} catch (configError) {
|
|
1405
1439
|
logger.error("ERROR: Failed to read shell config files", {
|
|
1406
|
-
error: configError,
|
|
1440
|
+
error: configError instanceof Error ? { message: configError.message, name: configError.name } : String(configError),
|
|
1407
1441
|
stack: configError instanceof Error ? configError.stack : "No stack trace"
|
|
1408
1442
|
});
|
|
1409
1443
|
}
|
|
@@ -1416,6 +1450,29 @@ const getShellPath = () => {
|
|
|
1416
1450
|
return fallbackPath;
|
|
1417
1451
|
}
|
|
1418
1452
|
};
|
|
1453
|
+
const getShellInitCommand = () => {
|
|
1454
|
+
const shellInfo = ShellDetector.getDefaultShell();
|
|
1455
|
+
const homeDir = os__namespace.homedir();
|
|
1456
|
+
switch (shellInfo.name) {
|
|
1457
|
+
case "bash": {
|
|
1458
|
+
const sourceCmd = `source /etc/profile >/dev/null 2>&1 || true; source ${homeDir}/.bash_profile >/dev/null 2>&1 || true; source ${homeDir}/.bashrc >/dev/null 2>&1 || true; `;
|
|
1459
|
+
const direnvCmd = 'command -v direnv >/dev/null 2>&1 && eval "$(direnv export bash 2>/dev/null)" 2>/dev/null || true; ';
|
|
1460
|
+
return sourceCmd + direnvCmd;
|
|
1461
|
+
}
|
|
1462
|
+
case "zsh": {
|
|
1463
|
+
const sourceCmd = `source /etc/zprofile >/dev/null 2>&1 || true; source ${homeDir}/.zprofile >/dev/null 2>&1 || true; source /etc/zshrc >/dev/null 2>&1 || true; source ${homeDir}/.zshrc >/dev/null 2>&1 || true; `;
|
|
1464
|
+
const direnvCmd = 'command -v direnv >/dev/null 2>&1 && eval "$(direnv export zsh 2>/dev/null)" 2>/dev/null || true; ';
|
|
1465
|
+
return sourceCmd + direnvCmd;
|
|
1466
|
+
}
|
|
1467
|
+
case "fish": {
|
|
1468
|
+
const sourceCmd = `source ${homeDir}/.config/fish/config.fish >/dev/null 2>&1 || true; `;
|
|
1469
|
+
const direnvCmd = "command -v direnv >/dev/null 2>&1 && direnv export fish 2>/dev/null | source || true; ";
|
|
1470
|
+
return sourceCmd + direnvCmd;
|
|
1471
|
+
}
|
|
1472
|
+
default:
|
|
1473
|
+
return "";
|
|
1474
|
+
}
|
|
1475
|
+
};
|
|
1419
1476
|
const getShellCommandArgs = (command) => {
|
|
1420
1477
|
return ShellDetector.getShellCommandArgs(command);
|
|
1421
1478
|
};
|
|
@@ -1508,6 +1565,7 @@ const AVAILABLE_PROVIDERS = [
|
|
|
1508
1565
|
var OpenAiVoiceModel = /* @__PURE__ */ ((OpenAiVoiceModel2) => {
|
|
1509
1566
|
OpenAiVoiceModel2["Gpt4oMiniTranscribe"] = "gpt-4o-mini-transcribe";
|
|
1510
1567
|
OpenAiVoiceModel2["Gpt4oTranscribe"] = "gpt-4o-transcribe";
|
|
1568
|
+
OpenAiVoiceModel2["GptLiveTranscribe"] = "gpt-live-transcribe";
|
|
1511
1569
|
OpenAiVoiceModel2["GptRealtimeWhisper"] = "gpt-realtime-whisper";
|
|
1512
1570
|
return OpenAiVoiceModel2;
|
|
1513
1571
|
})(OpenAiVoiceModel || {});
|
|
@@ -1792,7 +1850,7 @@ const getDefaultProviderParams = (providerName) => {
|
|
|
1792
1850
|
voice: {
|
|
1793
1851
|
idleTimeoutMs: 5e3,
|
|
1794
1852
|
systemInstructions: DEFAULT_VOICE_SYSTEM_INSTRUCTIONS,
|
|
1795
|
-
model: "gpt-
|
|
1853
|
+
model: "gpt-live-transcribe",
|
|
1796
1854
|
language: "en"
|
|
1797
1855
|
}
|
|
1798
1856
|
};
|
|
@@ -3097,7 +3155,7 @@ const ensureRipgrepBinary = async () => {
|
|
|
3097
3155
|
return false;
|
|
3098
3156
|
}
|
|
3099
3157
|
};
|
|
3100
|
-
const isAbortError = (error) => {
|
|
3158
|
+
const isAbortError$1 = (error) => {
|
|
3101
3159
|
if (!(error instanceof Error)) {
|
|
3102
3160
|
return false;
|
|
3103
3161
|
}
|
|
@@ -3157,7 +3215,7 @@ class WebScraper {
|
|
|
3157
3215
|
}
|
|
3158
3216
|
return content;
|
|
3159
3217
|
} catch (error) {
|
|
3160
|
-
if (isAbortError(error)) {
|
|
3218
|
+
if (isAbortError$1(error)) {
|
|
3161
3219
|
return "Operation was cancelled by user.";
|
|
3162
3220
|
}
|
|
3163
3221
|
return `Error: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -3225,7 +3283,7 @@ class WebScraper {
|
|
|
3225
3283
|
return await response.text();
|
|
3226
3284
|
} catch (error) {
|
|
3227
3285
|
clearTimeout(timeoutId);
|
|
3228
|
-
if (isAbortError(error)) {
|
|
3286
|
+
if (isAbortError$1(error)) {
|
|
3229
3287
|
return "Operation was cancelled by user.";
|
|
3230
3288
|
}
|
|
3231
3289
|
return `Error: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -3605,7 +3663,7 @@ Do not use escape characters \\ in the string like \\n or \\" and others. Do not
|
|
|
3605
3663
|
});
|
|
3606
3664
|
return `Successfully edited '${filePath}'.`;
|
|
3607
3665
|
} catch (error) {
|
|
3608
|
-
if (isAbortError(error)) {
|
|
3666
|
+
if (isAbortError$1(error)) {
|
|
3609
3667
|
return "Operation was cancelled by user.";
|
|
3610
3668
|
}
|
|
3611
3669
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -3653,7 +3711,7 @@ Do not use escape characters \\ in the string like \\n or \\" and others. Do not
|
|
|
3653
3711
|
try {
|
|
3654
3712
|
return await readFileContent(absolutePath, withLines, lineOffset, lineLimit);
|
|
3655
3713
|
} catch (error) {
|
|
3656
|
-
if (isAbortError(error)) {
|
|
3714
|
+
if (isAbortError$1(error)) {
|
|
3657
3715
|
return "Operation was cancelled by user.";
|
|
3658
3716
|
}
|
|
3659
3717
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -4013,7 +4071,7 @@ Do not use escape characters \\ in the string like \\n or \\" and others. Do not
|
|
|
4013
4071
|
}
|
|
4014
4072
|
return await truncateToolResult(markdownLines.join("\n"), 1e3, 50, 1e4);
|
|
4015
4073
|
} catch (error) {
|
|
4016
|
-
if (isAbortError(error)) {
|
|
4074
|
+
if (isAbortError$1(error)) {
|
|
4017
4075
|
return "Operation was cancelled by user.";
|
|
4018
4076
|
}
|
|
4019
4077
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -4120,7 +4178,9 @@ Timeout: ${timeout}ms`;
|
|
|
4120
4178
|
};
|
|
4121
4179
|
abortSignal?.addEventListener("abort", abortListener);
|
|
4122
4180
|
try {
|
|
4123
|
-
const
|
|
4181
|
+
const shellInitCommand = getShellInitCommand();
|
|
4182
|
+
const fullCommand = shellInitCommand ? `${shellInitCommand} ${command}` : command;
|
|
4183
|
+
const { shell: shellExec, args: shellArgs } = getShellCommandArgs(fullCommand);
|
|
4124
4184
|
childProcess = child_process.spawn(shellExec, shellArgs, {
|
|
4125
4185
|
cwd: absoluteCwd,
|
|
4126
4186
|
env: { ...process.env, TERM: "dumb", DEBIAN_FRONTEND: "noninteractive", PATH: getShellPath() },
|
|
@@ -4248,7 +4308,7 @@ Format: ${format}`;
|
|
|
4248
4308
|
const content = await scrapeWeb(url, timeout, abortSignal, format);
|
|
4249
4309
|
return await truncateToolResult(content, 1e3, 50, 1e4);
|
|
4250
4310
|
} catch (error) {
|
|
4251
|
-
if (isAbortError(error)) {
|
|
4311
|
+
if (isAbortError$1(error)) {
|
|
4252
4312
|
return "Operation was cancelled by user.";
|
|
4253
4313
|
}
|
|
4254
4314
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -4359,7 +4419,7 @@ Language: ${language || "all"}`;
|
|
|
4359
4419
|
logger.debug(`Search results: ${JSON.stringify(results)}`);
|
|
4360
4420
|
return results;
|
|
4361
4421
|
} catch (error) {
|
|
4362
|
-
if (isAbortError(error)) {
|
|
4422
|
+
if (isAbortError$1(error)) {
|
|
4363
4423
|
return "Operation was cancelled by user.";
|
|
4364
4424
|
}
|
|
4365
4425
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -4516,38 +4576,103 @@ Items: ${JSON.stringify(items)}`;
|
|
|
4516
4576
|
}
|
|
4517
4577
|
return filteredTools;
|
|
4518
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
|
+
});
|
|
4519
4613
|
const createTasksToolset = (settings, task, profile, promptContext) => {
|
|
4520
4614
|
const approvalManager = new ApprovalManager(task, profile);
|
|
4521
4615
|
const listTasksTool = ai.tool({
|
|
4522
4616
|
description: TASKS_TOOL_DESCRIPTIONS[TASKS_TOOL_LIST_TASKS],
|
|
4523
|
-
inputSchema:
|
|
4524
|
-
offset: zod.z.coerce.number().optional().describe("The number of tasks to skip (for pagination)"),
|
|
4525
|
-
limit: zod.z.coerce.number().optional().describe("The maximum number of tasks to return"),
|
|
4526
|
-
state: zod.z.string().optional().describe("Filter tasks by state (e.g., TODO, IN_PROGRESS, DONE)")
|
|
4527
|
-
}),
|
|
4617
|
+
inputSchema: listTasksInputSchema,
|
|
4528
4618
|
execute: async (input, { toolCallId }) => {
|
|
4529
|
-
const {
|
|
4530
|
-
|
|
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);
|
|
4531
4638
|
const toolName = `${TASKS_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${TASKS_TOOL_LIST_TASKS}`;
|
|
4532
4639
|
const questionKey = toolName;
|
|
4533
4640
|
const questionText = "Approve listing tasks?";
|
|
4534
|
-
const questionSubject =
|
|
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(", ");
|
|
4535
4653
|
const [isApproved, userInput] = await approvalManager.handleToolApproval(toolName, input, questionKey, questionText, questionSubject);
|
|
4536
4654
|
if (!isApproved) {
|
|
4537
4655
|
return `Listing tasks denied by user. Reason: ${userInput}`;
|
|
4538
4656
|
}
|
|
4539
4657
|
try {
|
|
4540
4658
|
let allTasks = await task.getProject().getTasks();
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
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
|
+
});
|
|
4544
4669
|
allTasks.sort((a, b) => {
|
|
4545
4670
|
const dateA = a.updatedAt ? new Date(a.updatedAt).getTime() : 0;
|
|
4546
4671
|
const dateB = b.updatedAt ? new Date(b.updatedAt).getTime() : 0;
|
|
4547
4672
|
return dateB - dateA;
|
|
4548
4673
|
});
|
|
4549
4674
|
const startIndex = Math.max(0, offset);
|
|
4550
|
-
const endIndex = startIndex + Math.max(0, limit
|
|
4675
|
+
const endIndex = startIndex + (limit === void 0 ? allTasks.length : Math.max(0, limit));
|
|
4551
4676
|
const paginatedTasks = allTasks.slice(startIndex, endIndex);
|
|
4552
4677
|
return paginatedTasks.map((t) => {
|
|
4553
4678
|
const subtaskIds = allTasks.filter((subtask) => subtask.parentId === t.id).map((s) => s.id);
|
|
@@ -4557,6 +4682,8 @@ const createTasksToolset = (settings, task, profile, promptContext) => {
|
|
|
4557
4682
|
createdAt: t.createdAt,
|
|
4558
4683
|
updatedAt: t.updatedAt,
|
|
4559
4684
|
archived: t.archived,
|
|
4685
|
+
pinned: t.pinned,
|
|
4686
|
+
workingMode: t.workingMode,
|
|
4560
4687
|
state: t.state,
|
|
4561
4688
|
...t.parentId && { parentId: t.parentId },
|
|
4562
4689
|
...subtaskIds.length > 0 && { subtaskIds }
|
|
@@ -4691,44 +4818,40 @@ const createTasksToolset = (settings, task, profile, promptContext) => {
|
|
|
4691
4818
|
execute: async (input, { toolCallId }) => {
|
|
4692
4819
|
const { prompt, name, agentProfileId, modelId, mode = "agent", asSubtask = false, autonomyMode, worktree, executeAndWait, executeInBackground } = input;
|
|
4693
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("/");
|
|
4694
4829
|
task.addToolMessage(toolCallId, TASKS_TOOL_GROUP_NAME, TASKS_TOOL_CREATE_TASK, input, void 0, void 0, promptContext);
|
|
4695
4830
|
const toolName = `${TASKS_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${TASKS_TOOL_CREATE_TASK}`;
|
|
4696
4831
|
const questionKey = toolName;
|
|
4697
4832
|
const questionText = "Approve creating a new task?";
|
|
4698
4833
|
const questionSubject = `Prompt: ${prompt}
|
|
4699
|
-
Agent Profile: ${
|
|
4700
|
-
Model: ${
|
|
4834
|
+
Agent Profile: ${resolvedProfile.id}
|
|
4835
|
+
Model: ${effectiveModelId}${executeAndWait ? "\nExecute and wait: true" : executeInBackground ? "\nExecute in background: true" : ""}${parentTaskId !== void 0 ? `
|
|
4701
4836
|
Parent Task ID: ${parentTaskId || "none (top-level task)"}` : ""}`;
|
|
4702
4837
|
const [isApproved, userInput] = await approvalManager.handleToolApproval(toolName, input, questionKey, questionText, questionSubject);
|
|
4703
4838
|
if (!isApproved) {
|
|
4704
4839
|
return `Creating task denied by user. Reason: ${userInput}`;
|
|
4705
4840
|
}
|
|
4706
4841
|
try {
|
|
4842
|
+
const updates = {
|
|
4843
|
+
agentProfileId: resolvedProfile.id,
|
|
4844
|
+
provider,
|
|
4845
|
+
model,
|
|
4846
|
+
mainModel: effectiveModelId
|
|
4847
|
+
};
|
|
4707
4848
|
const newTask = await task.getProject().createNewTask({
|
|
4708
4849
|
parentId: parentTaskId || null,
|
|
4709
4850
|
name: name || "",
|
|
4710
4851
|
autonomyMode,
|
|
4711
|
-
workingMode: worktree ? "worktree" : "local"
|
|
4852
|
+
workingMode: worktree ? "worktree" : "local",
|
|
4853
|
+
...updates
|
|
4712
4854
|
});
|
|
4713
|
-
const updates = {};
|
|
4714
|
-
if (agentProfileId) {
|
|
4715
|
-
const resolvedProfile = task.getProject().resolveAgentProfile(agentProfileId);
|
|
4716
|
-
if (resolvedProfile) {
|
|
4717
|
-
updates.agentProfileId = resolvedProfile.id;
|
|
4718
|
-
} else {
|
|
4719
|
-
const availableProfiles = task.getProject().getAgentProfiles().map((p) => `"${p.name}"`).join(", ");
|
|
4720
|
-
return `Agent profile '${agentProfileId}' not found. Available profiles: ${availableProfiles}`;
|
|
4721
|
-
}
|
|
4722
|
-
}
|
|
4723
|
-
if (modelId) {
|
|
4724
|
-
const [provider, ...modelParts] = modelId.split("/");
|
|
4725
|
-
updates.provider = provider;
|
|
4726
|
-
updates.model = modelParts.join("/");
|
|
4727
|
-
updates.mainModel = modelId;
|
|
4728
|
-
} else {
|
|
4729
|
-
updates.provider = void 0;
|
|
4730
|
-
updates.model = void 0;
|
|
4731
|
-
}
|
|
4732
4855
|
const taskInstance = task.getProject().getTask(newTask.id);
|
|
4733
4856
|
if (!taskInstance) {
|
|
4734
4857
|
throw new Error(`Failed to get task instance for newly created task ${newTask.id}`);
|
|
@@ -4888,7 +5011,7 @@ Task ID: ${taskId}`;
|
|
|
4888
5011
|
logger.debug(`Task search results: ${JSON.stringify(results)}`);
|
|
4889
5012
|
return results;
|
|
4890
5013
|
} catch (error) {
|
|
4891
|
-
if (isAbortError(error)) {
|
|
5014
|
+
if (isAbortError$1(error)) {
|
|
4892
5015
|
return "Operation was cancelled by user.";
|
|
4893
5016
|
}
|
|
4894
5017
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -4964,7 +5087,7 @@ const createSearchParentTaskTool = (task, promptContext) => {
|
|
|
4964
5087
|
logger.debug(`Parent task search results: ${JSON.stringify(results)}`);
|
|
4965
5088
|
return results;
|
|
4966
5089
|
} catch (error) {
|
|
4967
|
-
if (isAbortError(error)) {
|
|
5090
|
+
if (isAbortError$1(error)) {
|
|
4968
5091
|
return "Operation was cancelled by user.";
|
|
4969
5092
|
}
|
|
4970
5093
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -7969,6 +8092,10 @@ ${fileList}${readOnlyNote}`
|
|
|
7969
8092
|
const providers = this.modelManager.getProviders();
|
|
7970
8093
|
let provider = providers.find((p) => p.id === profile.provider);
|
|
7971
8094
|
let modelName = profile.model;
|
|
8095
|
+
let modelCallSettings = {
|
|
8096
|
+
maxRetries: MAX_RETRIES,
|
|
8097
|
+
abortSignal
|
|
8098
|
+
};
|
|
7972
8099
|
if (provider) {
|
|
7973
8100
|
const extensionResult = await this.extensionManager.dispatchEvent(
|
|
7974
8101
|
"onAgentStarted",
|
|
@@ -7983,7 +8110,8 @@ ${fileList}${readOnlyNote}`
|
|
|
7983
8110
|
contextFiles,
|
|
7984
8111
|
systemPrompt,
|
|
7985
8112
|
images,
|
|
7986
|
-
skillsToActivate
|
|
8113
|
+
skillsToActivate,
|
|
8114
|
+
modelCallSettings
|
|
7987
8115
|
},
|
|
7988
8116
|
task.project,
|
|
7989
8117
|
task
|
|
@@ -8002,6 +8130,10 @@ ${fileList}${readOnlyNote}`
|
|
|
8002
8130
|
systemPrompt = extensionResult.systemPrompt;
|
|
8003
8131
|
images = extensionResult.images ?? images;
|
|
8004
8132
|
skillsToActivate = extensionResult.skillsToActivate;
|
|
8133
|
+
modelCallSettings = {
|
|
8134
|
+
...modelCallSettings,
|
|
8135
|
+
...extensionResult.modelCallSettings
|
|
8136
|
+
};
|
|
8005
8137
|
}
|
|
8006
8138
|
const userRequestMessage = prompt ? {
|
|
8007
8139
|
id: promptContext?.id || uuid.v4(),
|
|
@@ -8066,7 +8198,7 @@ ${fileList}${readOnlyNote}`
|
|
|
8066
8198
|
contextFiles,
|
|
8067
8199
|
systemPrompt: systemPrompt?.substring(0, 100)
|
|
8068
8200
|
});
|
|
8069
|
-
const shouldCreateAbortController = !abortSignal;
|
|
8201
|
+
const shouldCreateAbortController = !modelCallSettings.abortSignal;
|
|
8070
8202
|
let controllerId = null;
|
|
8071
8203
|
if (shouldCreateAbortController) {
|
|
8072
8204
|
controllerId = uuid.v4();
|
|
@@ -8077,10 +8209,10 @@ ${fileList}${readOnlyNote}`
|
|
|
8077
8209
|
const newController = new AbortController();
|
|
8078
8210
|
this.abortControllers.set(controllerId, newController);
|
|
8079
8211
|
}
|
|
8080
|
-
const effectiveAbortSignal = abortSignal || (controllerId ? this.abortControllers.get(controllerId)?.signal : void 0);
|
|
8212
|
+
const effectiveAbortSignal = modelCallSettings.abortSignal || (controllerId ? this.abortControllers.get(controllerId)?.signal : void 0);
|
|
8081
8213
|
const cacheControl = this.modelManager.getCacheControl(provider, modelName);
|
|
8082
|
-
const
|
|
8083
|
-
const
|
|
8214
|
+
const providerParameters = this.modelManager.getProviderParameters(provider, modelName, modelCallSettings.reasoning);
|
|
8215
|
+
const providerOptions = this.modelManager.getProviderOptions(provider, modelName, modelCallSettings?.reasoning);
|
|
8084
8216
|
const firstUserMessage = contextMessages.length > 0 ? contextMessages[0] : null;
|
|
8085
8217
|
let messages = await this.prepareMessages(task, profile, contextMessages, contextFiles);
|
|
8086
8218
|
const initialUserRequestMessageIndex = firstUserMessage ? messages.findIndex((message) => message.role === "user" && message.content === firstUserMessage.content) : messages.length;
|
|
@@ -8274,12 +8406,13 @@ ${fileList}${readOnlyNote}`
|
|
|
8274
8406
|
instructions: systemPrompt,
|
|
8275
8407
|
messages: optimizedMessages,
|
|
8276
8408
|
tools: toolSet,
|
|
8277
|
-
abortSignal: effectiveAbortSignal,
|
|
8278
8409
|
maxOutputTokens: effectiveMaxOutputTokens,
|
|
8279
|
-
maxRetries:
|
|
8410
|
+
maxRetries: MAX_RETRIES,
|
|
8280
8411
|
temperature: effectiveTemperature,
|
|
8281
8412
|
telemetry: this.getTelemetrySettings(),
|
|
8282
|
-
...
|
|
8413
|
+
...modelCallSettings,
|
|
8414
|
+
...providerParameters,
|
|
8415
|
+
abortSignal: effectiveAbortSignal
|
|
8283
8416
|
};
|
|
8284
8417
|
};
|
|
8285
8418
|
let iterationCount = 0;
|
|
@@ -8311,7 +8444,7 @@ ${fileList}${readOnlyNote}`
|
|
|
8311
8444
|
logger.info("Prompt aborted by user");
|
|
8312
8445
|
return;
|
|
8313
8446
|
}
|
|
8314
|
-
currentStepMessages = await this.processStep(currentResponseId, stepResult, task, provider, modelName, promptContext,
|
|
8447
|
+
currentStepMessages = await this.processStep(currentResponseId, stepResult, task, provider, modelName, promptContext, effectiveAbortSignal);
|
|
8315
8448
|
const extensionResult2 = await this.extensionManager.dispatchEvent(
|
|
8316
8449
|
"onAgentStepFinished",
|
|
8317
8450
|
{
|
|
@@ -8404,6 +8537,7 @@ ${fileList}${readOnlyNote}`
|
|
|
8404
8537
|
onStepEnd,
|
|
8405
8538
|
experimental_repairToolCall: repairToolCall
|
|
8406
8539
|
});
|
|
8540
|
+
let currentMessageHasReasoning = false;
|
|
8407
8541
|
try {
|
|
8408
8542
|
for await (const chunk of result.stream) {
|
|
8409
8543
|
logger.debug("Chunk:", { chunk, responseMessageIndex });
|
|
@@ -8411,6 +8545,7 @@ ${fileList}${readOnlyNote}`
|
|
|
8411
8545
|
if (chunk.type === "text-start") {
|
|
8412
8546
|
} else if (chunk.type === "text-end") {
|
|
8413
8547
|
responseMessageIndex++;
|
|
8548
|
+
currentMessageHasReasoning = false;
|
|
8414
8549
|
} else if (chunk.type === "text-delta") {
|
|
8415
8550
|
if (chunk.text.trim()) {
|
|
8416
8551
|
streamingMessageIds.add(responseMessageId);
|
|
@@ -8424,8 +8559,19 @@ ${fileList}${readOnlyNote}`
|
|
|
8424
8559
|
}
|
|
8425
8560
|
} else if (chunk.type === "reasoning-start") {
|
|
8426
8561
|
streamingMessageIds.add(responseMessageId);
|
|
8562
|
+
if (currentMessageHasReasoning) {
|
|
8563
|
+
await task.processResponseMessage({
|
|
8564
|
+
id: responseMessageId,
|
|
8565
|
+
action: "response",
|
|
8566
|
+
content: "",
|
|
8567
|
+
reasoning: "\n\n",
|
|
8568
|
+
finished: false,
|
|
8569
|
+
promptContext
|
|
8570
|
+
});
|
|
8571
|
+
}
|
|
8427
8572
|
} else if (chunk.type === "reasoning-delta") {
|
|
8428
8573
|
streamingMessageIds.add(responseMessageId);
|
|
8574
|
+
currentMessageHasReasoning = true;
|
|
8429
8575
|
await task.processResponseMessage({
|
|
8430
8576
|
id: responseMessageId,
|
|
8431
8577
|
action: "response",
|
|
@@ -8992,6 +9138,8 @@ ${fileList}${readOnlyNote}`
|
|
|
8992
9138
|
}
|
|
8993
9139
|
const hasAssistantMessage = content.some((part) => (part.type === "text" || part.type === "reasoning") && part.text?.trim());
|
|
8994
9140
|
let responseMessageIndex = 0;
|
|
9141
|
+
let localReasoningText;
|
|
9142
|
+
let localText;
|
|
8995
9143
|
const processToolResult = (toolResult, isLast) => {
|
|
8996
9144
|
const [serverName, toolName] = extractServerNameToolName(toolResult.toolName);
|
|
8997
9145
|
const toolPromptContext = extractPromptContextFromToolResult(toolResult.output) ?? promptContext;
|
|
@@ -9006,31 +9154,34 @@ ${fileList}${readOnlyNote}`
|
|
|
9006
9154
|
);
|
|
9007
9155
|
};
|
|
9008
9156
|
for (let i = 0; i < content.length; i++) {
|
|
9009
|
-
|
|
9157
|
+
const part = content[i];
|
|
9010
9158
|
if (part.type === "reasoning") {
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
|
|
9159
|
+
if (localReasoningText) {
|
|
9160
|
+
localReasoningText += "\n\n" + part.text;
|
|
9161
|
+
} else {
|
|
9162
|
+
localReasoningText = part.text;
|
|
9163
|
+
}
|
|
9164
|
+
continue;
|
|
9014
9165
|
}
|
|
9015
|
-
if (part
|
|
9016
|
-
|
|
9166
|
+
if (part.type === "text") {
|
|
9167
|
+
localText = part.text;
|
|
9017
9168
|
}
|
|
9018
|
-
if (
|
|
9169
|
+
if (localText || localReasoningText) {
|
|
9019
9170
|
const message = {
|
|
9020
9171
|
id: responseMessageIndex > 0 ? `${currentResponseId}-${responseMessageIndex}` : currentResponseId,
|
|
9021
9172
|
action: "response",
|
|
9022
|
-
content:
|
|
9023
|
-
reasoning:
|
|
9173
|
+
content: localText || "",
|
|
9174
|
+
reasoning: localReasoningText?.trim() || void 0,
|
|
9024
9175
|
finished: true,
|
|
9025
9176
|
usageReport: hasAssistantMessage ? usageReport : void 0,
|
|
9026
9177
|
promptContext
|
|
9027
9178
|
};
|
|
9028
9179
|
await task.processResponseMessage(message);
|
|
9029
|
-
|
|
9030
|
-
|
|
9180
|
+
localText = void 0;
|
|
9181
|
+
localReasoningText = void 0;
|
|
9031
9182
|
responseMessageIndex++;
|
|
9032
9183
|
}
|
|
9033
|
-
if (part
|
|
9184
|
+
if (part.type === "tool-result") {
|
|
9034
9185
|
const toolResult = toolResults.find((toolResult2) => toolResult2.toolCallId === part.toolCallId);
|
|
9035
9186
|
if (toolResult) {
|
|
9036
9187
|
toolResults = toolResults.filter((toolResult2) => toolResult2.toolCallId !== part.toolCallId);
|
|
@@ -9038,6 +9189,19 @@ ${fileList}${readOnlyNote}`
|
|
|
9038
9189
|
}
|
|
9039
9190
|
}
|
|
9040
9191
|
}
|
|
9192
|
+
if (localReasoningText) {
|
|
9193
|
+
const message = {
|
|
9194
|
+
id: responseMessageIndex > 0 ? `${currentResponseId}-${responseMessageIndex}` : currentResponseId,
|
|
9195
|
+
action: "response",
|
|
9196
|
+
content: "",
|
|
9197
|
+
reasoning: localReasoningText.trim() || void 0,
|
|
9198
|
+
finished: true,
|
|
9199
|
+
usageReport: hasAssistantMessage ? usageReport : void 0,
|
|
9200
|
+
promptContext
|
|
9201
|
+
};
|
|
9202
|
+
await task.processResponseMessage(message);
|
|
9203
|
+
localReasoningText = void 0;
|
|
9204
|
+
}
|
|
9041
9205
|
for (let i = 0; i < toolResults.length; i++) {
|
|
9042
9206
|
const toolResult = toolResults[i];
|
|
9043
9207
|
processToolResult(toolResult, i === toolResults.length - 1);
|
|
@@ -10125,6 +10289,9 @@ const SavePromptSchema = zod.z.object({
|
|
|
10125
10289
|
taskId: zod.z.string().min(1, "Task ID is required"),
|
|
10126
10290
|
prompt: zod.z.string().min(1, "Prompt is required")
|
|
10127
10291
|
});
|
|
10292
|
+
const SaveEditedPromptSchema = SavePromptSchema.extend({
|
|
10293
|
+
messageId: zod.z.string().min(1, "Message ID is required")
|
|
10294
|
+
});
|
|
10128
10295
|
const SSE_ALLOWED_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
10129
10296
|
"response-chunk",
|
|
10130
10297
|
"response-completed",
|
|
@@ -10175,6 +10342,18 @@ class PromptApi extends BaseApi {
|
|
|
10175
10342
|
res.status(200).json({ message: "Prompt saved successfully" });
|
|
10176
10343
|
})
|
|
10177
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
|
+
);
|
|
10178
10357
|
}
|
|
10179
10358
|
async handleRunPromptJSON(res, projectDir, prompt, taskId, mode, images, model, agentProfileId, autonomyMode) {
|
|
10180
10359
|
if (taskId) {
|
|
@@ -10714,6 +10893,10 @@ const CommitChangesSchema = zod.z.object({
|
|
|
10714
10893
|
message: zod.z.string(),
|
|
10715
10894
|
amend: zod.z.boolean()
|
|
10716
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
|
+
});
|
|
10717
10900
|
const ListBranchesSchema = zod.z.object({
|
|
10718
10901
|
projectDir: zod.z.string().min(1, "Project directory is required")
|
|
10719
10902
|
});
|
|
@@ -10932,6 +11115,18 @@ class ProjectApi extends BaseApi {
|
|
|
10932
11115
|
res.status(200).json(tasks);
|
|
10933
11116
|
})
|
|
10934
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
|
+
);
|
|
10935
11130
|
router.post(
|
|
10936
11131
|
"/project/tasks/delete",
|
|
10937
11132
|
this.handleRequest(async (req, res) => {
|
|
@@ -11255,6 +11450,18 @@ class ProjectApi extends BaseApi {
|
|
|
11255
11450
|
res.status(200).json({ message: "Changes committed" });
|
|
11256
11451
|
})
|
|
11257
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
|
+
);
|
|
11258
11465
|
router.get(
|
|
11259
11466
|
"/project/worktree/branches",
|
|
11260
11467
|
this.handleRequest(async (req, res) => {
|
|
@@ -12163,6 +12370,10 @@ const UpdateExtensionSchema = zod.z.object({
|
|
|
12163
12370
|
repositoryUrl: zod.z.string().url("Repository URL must be a valid URL"),
|
|
12164
12371
|
projectDir: zod.z.string().optional()
|
|
12165
12372
|
});
|
|
12373
|
+
const ReloadExtensionSchema = zod.z.object({
|
|
12374
|
+
filePath: zod.z.string().min(1, "File path is required"),
|
|
12375
|
+
projectDir: zod.z.string().optional()
|
|
12376
|
+
});
|
|
12166
12377
|
class ExtensionsApi extends BaseApi {
|
|
12167
12378
|
constructor(eventsHandler) {
|
|
12168
12379
|
super();
|
|
@@ -12254,6 +12465,22 @@ class ExtensionsApi extends BaseApi {
|
|
|
12254
12465
|
}
|
|
12255
12466
|
})
|
|
12256
12467
|
);
|
|
12468
|
+
router.post(
|
|
12469
|
+
"/extensions/reload",
|
|
12470
|
+
this.handleRequest(async (req, res) => {
|
|
12471
|
+
const parsed = this.validateRequest(ReloadExtensionSchema, req.body, res);
|
|
12472
|
+
if (!parsed) {
|
|
12473
|
+
return;
|
|
12474
|
+
}
|
|
12475
|
+
const { filePath, projectDir } = parsed;
|
|
12476
|
+
const success = await this.eventsHandler.reloadExtension(filePath, projectDir);
|
|
12477
|
+
if (success) {
|
|
12478
|
+
res.status(200).json({ message: "Extension reloaded successfully", success: true });
|
|
12479
|
+
} else {
|
|
12480
|
+
res.status(500).json({ message: "Failed to reload extension", success: false });
|
|
12481
|
+
}
|
|
12482
|
+
})
|
|
12483
|
+
);
|
|
12257
12484
|
router.get(
|
|
12258
12485
|
"/extensions/ui-components",
|
|
12259
12486
|
this.handleRequest(async (req, res) => {
|
|
@@ -12390,6 +12617,217 @@ class SkillsApi extends BaseApi {
|
|
|
12390
12617
|
);
|
|
12391
12618
|
}
|
|
12392
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
|
+
}
|
|
12393
12831
|
const createCorsOriginValidator = (store) => (origin, callback) => {
|
|
12394
12832
|
if (CORS_ALLOWED_ORIGINS) {
|
|
12395
12833
|
const origins = CORS_ALLOWED_ORIGINS.split(",").map((o) => o.trim()).filter(Boolean);
|
|
@@ -12428,6 +12866,10 @@ class ServerController {
|
|
|
12428
12866
|
pythonInstaller;
|
|
12429
12867
|
app = express();
|
|
12430
12868
|
isStarted = false;
|
|
12869
|
+
readonlyReady = !READONLY_MODE;
|
|
12870
|
+
get isReadonlyMode() {
|
|
12871
|
+
return READONLY_MODE || this.store.getSettings().server.readonly === true;
|
|
12872
|
+
}
|
|
12431
12873
|
serverGuardMiddleware(req, res, next) {
|
|
12432
12874
|
if (req.path === "/api/health") {
|
|
12433
12875
|
next();
|
|
@@ -12480,6 +12922,23 @@ class ServerController {
|
|
|
12480
12922
|
next();
|
|
12481
12923
|
}
|
|
12482
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
|
+
});
|
|
12483
12942
|
const apiRouter = express.Router();
|
|
12484
12943
|
new ContextApi(this.projectManager, this.eventsHandler).registerRoutes(apiRouter);
|
|
12485
12944
|
new PromptApi(this.eventsHandler).registerRoutes(apiRouter);
|
|
@@ -12515,7 +12974,11 @@ class ServerController {
|
|
|
12515
12974
|
});
|
|
12516
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");
|
|
12517
12976
|
this.app.use(express.static(rendererDir));
|
|
12518
|
-
this.app.get("*", (
|
|
12977
|
+
this.app.get("*", (req, res) => {
|
|
12978
|
+
if (this.isReadonlyMode && req.path !== "/") {
|
|
12979
|
+
res.redirect("/#/readonly");
|
|
12980
|
+
return;
|
|
12981
|
+
}
|
|
12519
12982
|
res.sendFile(path.join(rendererDir, "index.html"));
|
|
12520
12983
|
});
|
|
12521
12984
|
}
|
|
@@ -12523,6 +12986,9 @@ class ServerController {
|
|
|
12523
12986
|
this.server.on("request", this.app);
|
|
12524
12987
|
this.isStarted = this.store.getSettings().server.enabled;
|
|
12525
12988
|
}
|
|
12989
|
+
setReadonlyReady() {
|
|
12990
|
+
this.readonlyReady = true;
|
|
12991
|
+
}
|
|
12526
12992
|
async close() {
|
|
12527
12993
|
this.server.off("request", this.app);
|
|
12528
12994
|
}
|
|
@@ -12776,6 +13242,32 @@ const isSubscribeEventsMessage = (message) => {
|
|
|
12776
13242
|
const isUnsubscribeEventsMessage = (message) => {
|
|
12777
13243
|
return message.action === "unsubscribe-events";
|
|
12778
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);
|
|
12779
13271
|
class ConnectorManager {
|
|
12780
13272
|
constructor(httpServer, projectManager, eventManager, store) {
|
|
12781
13273
|
this.projectManager = projectManager;
|
|
@@ -12788,6 +13280,9 @@ class ConnectorManager {
|
|
|
12788
13280
|
store;
|
|
12789
13281
|
io = null;
|
|
12790
13282
|
connectors = [];
|
|
13283
|
+
get isReadonlyMode() {
|
|
13284
|
+
return READONLY_MODE || this.store.getSettings().server.readonly === true;
|
|
13285
|
+
}
|
|
12791
13286
|
init(httpServer) {
|
|
12792
13287
|
this.io = new socket_io.Server(httpServer, {
|
|
12793
13288
|
cors: {
|
|
@@ -12799,6 +13294,24 @@ class ConnectorManager {
|
|
|
12799
13294
|
maxHttpBufferSize: 1e8
|
|
12800
13295
|
// Increase payload size to 100 MB
|
|
12801
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
|
+
});
|
|
12802
13315
|
this.io.engine.on("connection_error", (err) => {
|
|
12803
13316
|
logger.warn("Socket.IO engine connection error", { error: err.message });
|
|
12804
13317
|
});
|
|
@@ -12811,7 +13324,13 @@ class ConnectorManager {
|
|
|
12811
13324
|
}
|
|
12812
13325
|
});
|
|
12813
13326
|
socket.on("message", (message) => this.processMessage(socket, message));
|
|
12814
|
-
socket.on("log", (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
|
+
});
|
|
12815
13334
|
socket.on("disconnect", (reason) => {
|
|
12816
13335
|
const connector = this.findConnectorBySocket(socket);
|
|
12817
13336
|
logger.info("Socket.IO client disconnected", {
|
|
@@ -12834,6 +13353,28 @@ class ConnectorManager {
|
|
|
12834
13353
|
}
|
|
12835
13354
|
processMessage = (socket, message) => {
|
|
12836
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
|
+
}
|
|
12837
13378
|
logger.debug("Message:", {
|
|
12838
13379
|
message: JSON.stringify(message).slice(0, 1e3)
|
|
12839
13380
|
});
|
|
@@ -13016,6 +13557,10 @@ class ConnectorManager {
|
|
|
13016
13557
|
}
|
|
13017
13558
|
};
|
|
13018
13559
|
processLogMessage = (socket, message) => {
|
|
13560
|
+
if (this.isReadonlyMode && socket.data.clientRole !== "connector") {
|
|
13561
|
+
socket.disconnect(true);
|
|
13562
|
+
return;
|
|
13563
|
+
}
|
|
13019
13564
|
logger.debug("Received log message from connector", { message });
|
|
13020
13565
|
const connector = this.findConnectorBySocket(socket);
|
|
13021
13566
|
if (!connector) {
|
|
@@ -14027,25 +14572,59 @@ ${JSON.stringify(part.output.value)}`
|
|
|
14027
14572
|
this.enableAutosave();
|
|
14028
14573
|
}
|
|
14029
14574
|
}
|
|
14030
|
-
async
|
|
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() {
|
|
14031
14605
|
if (!await fileExists(this.storagePath)) {
|
|
14032
14606
|
logger.debug("No existing task context found:", {
|
|
14033
14607
|
taskId: this.taskId
|
|
14034
14608
|
});
|
|
14035
|
-
|
|
14036
|
-
return;
|
|
14609
|
+
return null;
|
|
14037
14610
|
}
|
|
14038
|
-
this.disableAutosave();
|
|
14039
14611
|
const content = await fs$1.promises.readFile(this.storagePath, "utf8");
|
|
14040
14612
|
const contextData = content ? JSON.parse(content) : null;
|
|
14041
14613
|
if (!contextData) {
|
|
14042
14614
|
logger.debug("Empty task context found:", { taskId: this.taskId });
|
|
14043
|
-
|
|
14044
|
-
|
|
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 || [];
|
|
14045
14627
|
}
|
|
14046
|
-
const migratedData = await this.migrateContext(contextData);
|
|
14047
|
-
this.messages = migratedData.contextMessages || [];
|
|
14048
|
-
this.files = migratedData.contextFiles || [];
|
|
14049
14628
|
this.loaded = true;
|
|
14050
14629
|
await this.cleanupContext();
|
|
14051
14630
|
}
|
|
@@ -14141,8 +14720,12 @@ ${JSON.stringify(part.output.value)}`
|
|
|
14141
14720
|
let subHasText = false;
|
|
14142
14721
|
for (const subPart of subMessage.content) {
|
|
14143
14722
|
if (subPart.type === "reasoning" && subPart.text?.trim()) {
|
|
14144
|
-
|
|
14145
|
-
|
|
14723
|
+
if (subHasReasoning) {
|
|
14724
|
+
subReasoningContent += "\n\n" + subPart.text.trim();
|
|
14725
|
+
} else {
|
|
14726
|
+
subReasoningContent = subPart.text.trim();
|
|
14727
|
+
subHasReasoning = true;
|
|
14728
|
+
}
|
|
14146
14729
|
} else if (subPart.type === "text" && subPart.text) {
|
|
14147
14730
|
subTextContent = subPart.text.trim();
|
|
14148
14731
|
subHasText = true;
|
|
@@ -14238,7 +14821,11 @@ ${JSON.stringify(part.output.value)}`
|
|
|
14238
14821
|
};
|
|
14239
14822
|
for (const part of message.content) {
|
|
14240
14823
|
if (part.type === "reasoning" && part.text?.trim()) {
|
|
14241
|
-
|
|
14824
|
+
if (reasoning) {
|
|
14825
|
+
reasoning += "\n\n" + part.text.trim();
|
|
14826
|
+
} else {
|
|
14827
|
+
reasoning = part.text.trim();
|
|
14828
|
+
}
|
|
14242
14829
|
} else if (part.type === "text" && part.text) {
|
|
14243
14830
|
pushResponseCompletedData(part.text);
|
|
14244
14831
|
} else if (part.type === "tool-call") {
|
|
@@ -14633,6 +15220,8 @@ class AiderManager {
|
|
|
14633
15220
|
aiderStarting = false;
|
|
14634
15221
|
aiderStartPromise = null;
|
|
14635
15222
|
aiderStartResolve = null;
|
|
15223
|
+
aiderStartReject = null;
|
|
15224
|
+
aiderStartError = null;
|
|
14636
15225
|
aiderModelsData = null;
|
|
14637
15226
|
currentCommand = null;
|
|
14638
15227
|
commandOutputs = /* @__PURE__ */ new Map();
|
|
@@ -14645,6 +15234,7 @@ class AiderManager {
|
|
|
14645
15234
|
await this.kill();
|
|
14646
15235
|
}
|
|
14647
15236
|
await this.checkAndCleanupPidFile();
|
|
15237
|
+
this.aiderStartError = null;
|
|
14648
15238
|
this.aiderStarting = true;
|
|
14649
15239
|
this.eventManager.sendAiderConnectorStatus({ state: "starting-connector" }, this.task.getProjectDir(), this.task.taskId);
|
|
14650
15240
|
const settings = this.store.getSettings();
|
|
@@ -14741,6 +15331,7 @@ class AiderManager {
|
|
|
14741
15331
|
TASK_ID: this.task.task.id,
|
|
14742
15332
|
TASK_DIR: this.task.getTaskDir(),
|
|
14743
15333
|
CONNECTOR_SERVER_URL: `http://localhost:${SERVER_PORT}`,
|
|
15334
|
+
AIDER_DESK_CONNECTOR_TOKEN: CONNECTOR_TOKEN,
|
|
14744
15335
|
CONNECTOR_CONFIRM_BEFORE_EDIT: settings.aider.confirmBeforeEdit ? "1" : "0"
|
|
14745
15336
|
};
|
|
14746
15337
|
this.aiderProcess = child_process.spawn(PYTHON_COMMAND, args, {
|
|
@@ -14779,13 +15370,8 @@ class AiderManager {
|
|
|
14779
15370
|
error: output
|
|
14780
15371
|
});
|
|
14781
15372
|
});
|
|
14782
|
-
this.aiderProcess
|
|
14783
|
-
|
|
14784
|
-
baseDir: this.task.getTaskDir(),
|
|
14785
|
-
taskId: this.task.task.id,
|
|
14786
|
-
code
|
|
14787
|
-
});
|
|
14788
|
-
});
|
|
15373
|
+
const aiderProcess = this.aiderProcess;
|
|
15374
|
+
aiderProcess.on("close", (code) => this.handleAiderProcessExit(aiderProcess, code));
|
|
14789
15375
|
void this.writeAiderProcessPidFile();
|
|
14790
15376
|
}
|
|
14791
15377
|
async kill() {
|
|
@@ -14826,12 +15412,37 @@ class AiderManager {
|
|
|
14826
15412
|
isStarted() {
|
|
14827
15413
|
return !!this.aiderProcess;
|
|
14828
15414
|
}
|
|
15415
|
+
handleAiderProcessExit(process2, code) {
|
|
15416
|
+
logger.info("Aider process exited:", {
|
|
15417
|
+
baseDir: this.task.getTaskDir(),
|
|
15418
|
+
taskId: this.task.task.id,
|
|
15419
|
+
code
|
|
15420
|
+
});
|
|
15421
|
+
if (this.aiderProcess !== process2) {
|
|
15422
|
+
return;
|
|
15423
|
+
}
|
|
15424
|
+
this.aiderProcess = null;
|
|
15425
|
+
this.aiderStarting = false;
|
|
15426
|
+
this.removeAiderProcessPidFile();
|
|
15427
|
+
this.currentCommand = null;
|
|
15428
|
+
const error = new Error(`Aider process exited before the connector became ready (code ${code ?? "unknown"})`);
|
|
15429
|
+
this.aiderStartError = error;
|
|
15430
|
+
this.eventManager.sendAiderConnectorStatus({ state: "failed", error: error.message }, this.task.getProjectDir(), this.task.taskId);
|
|
15431
|
+
this.aiderStartReject?.(error);
|
|
15432
|
+
this.aiderStartReject = null;
|
|
15433
|
+
this.aiderStartResolve = null;
|
|
15434
|
+
this.aiderStartPromise = null;
|
|
15435
|
+
}
|
|
14829
15436
|
createAiderStartPromise() {
|
|
15437
|
+
if (this.aiderStartError) {
|
|
15438
|
+
return Promise.reject(this.aiderStartError);
|
|
15439
|
+
}
|
|
14830
15440
|
if (this.aiderStartPromise) {
|
|
14831
15441
|
return this.aiderStartPromise;
|
|
14832
15442
|
}
|
|
14833
|
-
this.aiderStartPromise = new Promise((resolve) => {
|
|
15443
|
+
this.aiderStartPromise = new Promise((resolve, reject) => {
|
|
14834
15444
|
this.aiderStartResolve = resolve;
|
|
15445
|
+
this.aiderStartReject = reject;
|
|
14835
15446
|
if (!this.aiderStarting) {
|
|
14836
15447
|
resolve();
|
|
14837
15448
|
}
|
|
@@ -14907,10 +15518,12 @@ class AiderManager {
|
|
|
14907
15518
|
handleConnectorAdded(connector) {
|
|
14908
15519
|
if (connector.source === "aider") {
|
|
14909
15520
|
this.aiderStarting = false;
|
|
15521
|
+
this.aiderStartError = null;
|
|
14910
15522
|
this.eventManager.sendAiderConnectorStatus({ state: "ready" }, this.task.getProjectDir(), this.task.taskId);
|
|
14911
15523
|
if (this.aiderStartResolve) {
|
|
14912
15524
|
this.aiderStartResolve();
|
|
14913
15525
|
this.aiderStartResolve = null;
|
|
15526
|
+
this.aiderStartReject = null;
|
|
14914
15527
|
this.aiderStartPromise = null;
|
|
14915
15528
|
}
|
|
14916
15529
|
}
|
|
@@ -15226,7 +15839,11 @@ Original Error: ${this.originalError.message}`;
|
|
|
15226
15839
|
return details;
|
|
15227
15840
|
}
|
|
15228
15841
|
}
|
|
15842
|
+
const isAbortError = (error) => {
|
|
15843
|
+
return error instanceof Error && (error.name === "AbortError" || error.code === "ABORT_ERR");
|
|
15844
|
+
};
|
|
15229
15845
|
class WorktreeManager {
|
|
15846
|
+
commitCancelControllers = /* @__PURE__ */ new Map();
|
|
15230
15847
|
getWorktreePath(projectPath, taskId) {
|
|
15231
15848
|
return path.join(projectPath, AIDER_DESK_TASKS_DIR, taskId, "worktree");
|
|
15232
15849
|
}
|
|
@@ -16515,7 +17132,7 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
16515
17132
|
try {
|
|
16516
17133
|
await execWithShellPath("git rev-parse HEAD", { cwd: worktreePath });
|
|
16517
17134
|
} catch {
|
|
16518
|
-
return files;
|
|
17135
|
+
return files.concat(await this.getNoHeadUpdatedFiles(worktreePath));
|
|
16519
17136
|
}
|
|
16520
17137
|
try {
|
|
16521
17138
|
const { stdout: uncommittedNumstat } = await execWithShellPath("git diff --numstat -z HEAD", {
|
|
@@ -16624,7 +17241,7 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
16624
17241
|
try {
|
|
16625
17242
|
await execWithShellPath("git rev-parse HEAD", { cwd: worktreePath });
|
|
16626
17243
|
} catch {
|
|
16627
|
-
return
|
|
17244
|
+
return await this.getNoHeadUpdatedFiles(worktreePath);
|
|
16628
17245
|
}
|
|
16629
17246
|
const { stdout } = await execWithShellPath("git diff --numstat -z HEAD", {
|
|
16630
17247
|
cwd: worktreePath
|
|
@@ -16671,6 +17288,67 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
16671
17288
|
}
|
|
16672
17289
|
return files;
|
|
16673
17290
|
}
|
|
17291
|
+
/**
|
|
17292
|
+
* No-HEAD mode: repo has no commits yet. Uses the well-known empty tree hash
|
|
17293
|
+
* as the diff base, which is equivalent to `git diff HEAD` against an empty repo.
|
|
17294
|
+
* Shows staged files and unstaged modifications to staged files (same as `git diff HEAD`
|
|
17295
|
+
* would show if HEAD pointed to an empty commit). Untracked files are not shown,
|
|
17296
|
+
* consistent with the existing HEAD-based behavior.
|
|
17297
|
+
*/
|
|
17298
|
+
async getNoHeadUpdatedFiles(worktreePath) {
|
|
17299
|
+
const EMPTY_TREE_HASH = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
|
|
17300
|
+
const files = [];
|
|
17301
|
+
try {
|
|
17302
|
+
const { stdout } = await execWithShellPath(`git diff --numstat -z ${EMPTY_TREE_HASH}`, {
|
|
17303
|
+
cwd: worktreePath
|
|
17304
|
+
});
|
|
17305
|
+
const entries = stdout.split("\0").filter((entry) => entry.trim() !== "");
|
|
17306
|
+
for (const entry of entries) {
|
|
17307
|
+
const parts = entry.split(" ");
|
|
17308
|
+
if (parts.length < 3) {
|
|
17309
|
+
continue;
|
|
17310
|
+
}
|
|
17311
|
+
const additions = parts[0] === "-" ? 0 : parseInt(parts[0], 10);
|
|
17312
|
+
const deletions = parts[1] === "-" ? 0 : parseInt(parts[1], 10);
|
|
17313
|
+
const filePath = parts.slice(2).join(" ");
|
|
17314
|
+
if (!filePath) {
|
|
17315
|
+
continue;
|
|
17316
|
+
}
|
|
17317
|
+
if (this.isSymlinkPath(worktreePath, filePath)) {
|
|
17318
|
+
continue;
|
|
17319
|
+
}
|
|
17320
|
+
const absoluteFilePath = path.join(worktreePath, filePath);
|
|
17321
|
+
let diff = "";
|
|
17322
|
+
try {
|
|
17323
|
+
const fileExists2 = await fs.access(absoluteFilePath).then(() => true).catch(() => false);
|
|
17324
|
+
if (fileExists2) {
|
|
17325
|
+
const fileContentBuffer = await fs.readFile(absoluteFilePath);
|
|
17326
|
+
if (istextorbinary.isBinary(filePath, fileContentBuffer)) {
|
|
17327
|
+
files.push({ path: filePath, additions, deletions, diff });
|
|
17328
|
+
continue;
|
|
17329
|
+
}
|
|
17330
|
+
}
|
|
17331
|
+
const escapedPath = filePath.replace(/"/g, '\\"');
|
|
17332
|
+
const { stdout: diffOutput } = await execWithShellPath(`git diff --unified=3 ${EMPTY_TREE_HASH} -- "${escapedPath}"`, {
|
|
17333
|
+
cwd: worktreePath,
|
|
17334
|
+
maxBuffer: 10 * 1024 * 1024
|
|
17335
|
+
});
|
|
17336
|
+
diff = diffOutput;
|
|
17337
|
+
} catch (diffError) {
|
|
17338
|
+
logger.warn(`Failed to get diff for file ${filePath}:`, {
|
|
17339
|
+
error: diffError instanceof Error ? diffError.message : String(diffError)
|
|
17340
|
+
});
|
|
17341
|
+
diff = "";
|
|
17342
|
+
}
|
|
17343
|
+
files.push({ path: filePath, additions, deletions, diff });
|
|
17344
|
+
}
|
|
17345
|
+
} catch (error) {
|
|
17346
|
+
logger.warn("Failed to get updated files for repo with no commits:", {
|
|
17347
|
+
error: error instanceof Error ? error.message : String(error)
|
|
17348
|
+
});
|
|
17349
|
+
}
|
|
17350
|
+
return files;
|
|
17351
|
+
}
|
|
16674
17352
|
/**
|
|
16675
17353
|
* Parse the output of `git diff-tree -p -r` into a map of filePath -> diff text.
|
|
16676
17354
|
* Splits on "diff --git" boundaries to isolate per-file patches.
|
|
@@ -16755,33 +17433,55 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
16755
17433
|
return null;
|
|
16756
17434
|
}
|
|
16757
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
|
+
}
|
|
16758
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" };
|
|
16759
17448
|
try {
|
|
16760
17449
|
logger.info(`Committing changes${amend ? " (amend)" : ""}`, { worktreePath });
|
|
16761
17450
|
const updatedFiles = await this.getUpdatedFiles(worktreePath);
|
|
16762
17451
|
if (updatedFiles.length === 0 && !amend) {
|
|
16763
17452
|
logger.info("No updated files to commit");
|
|
16764
|
-
return;
|
|
17453
|
+
return true;
|
|
16765
17454
|
}
|
|
16766
17455
|
if (updatedFiles.length > 0) {
|
|
16767
17456
|
for (const file of updatedFiles) {
|
|
17457
|
+
if (cancelController.signal.aborted) {
|
|
17458
|
+
logger.info("Commit cancelled while staging files", { worktreePath });
|
|
17459
|
+
return false;
|
|
17460
|
+
}
|
|
16768
17461
|
const escapedPath = file.path.replace(/"/g, '\\"');
|
|
16769
|
-
await execWithShellPath(`git add -- "${escapedPath}"`,
|
|
16770
|
-
cwd: worktreePath
|
|
16771
|
-
});
|
|
17462
|
+
await execWithShellPath(`git add -- "${escapedPath}"`, options);
|
|
16772
17463
|
}
|
|
16773
17464
|
logger.info(`Staged ${updatedFiles.length} file(s) for commit`);
|
|
16774
17465
|
}
|
|
17466
|
+
if (cancelController.signal.aborted) {
|
|
17467
|
+
logger.info("Commit cancelled before committing", { worktreePath });
|
|
17468
|
+
return false;
|
|
17469
|
+
}
|
|
16775
17470
|
const escapedMessage = message.replace(/"/g, '\\"');
|
|
16776
17471
|
const amendFlag = amend ? " --amend" : "";
|
|
16777
17472
|
const commitCommand = amend && !message.trim() ? "git commit --amend --no-edit" : `git commit${amendFlag} -m "${escapedMessage}"`;
|
|
16778
|
-
await execWithShellPath(commitCommand,
|
|
16779
|
-
cwd: worktreePath
|
|
16780
|
-
});
|
|
17473
|
+
await execWithShellPath(commitCommand, options);
|
|
16781
17474
|
logger.info(`Successfully committed changes${amend ? " (amended)" : ""}`);
|
|
17475
|
+
return true;
|
|
16782
17476
|
} catch (error) {
|
|
17477
|
+
if (isAbortError(error)) {
|
|
17478
|
+
logger.info(`Commit changes cancelled${amend ? " (amend)" : ""}`, { worktreePath });
|
|
17479
|
+
return false;
|
|
17480
|
+
}
|
|
16783
17481
|
logger.debug("Failed to commit changes:", error);
|
|
16784
17482
|
throw error;
|
|
17483
|
+
} finally {
|
|
17484
|
+
this.commitCancelControllers.delete(worktreePath);
|
|
16785
17485
|
}
|
|
16786
17486
|
}
|
|
16787
17487
|
async getRebaseState(worktreePath) {
|
|
@@ -17191,7 +17891,7 @@ class Task {
|
|
|
17191
17891
|
agent: { cost: 0, tokens: 0 }
|
|
17192
17892
|
};
|
|
17193
17893
|
this.aiderManager = new AiderManager(this, this.store, this.modelManager, this.eventManager, () => this.connectors, this.pythonInstaller);
|
|
17194
|
-
|
|
17894
|
+
this.taskDataLoadPromise = this.loadTaskData();
|
|
17195
17895
|
}
|
|
17196
17896
|
project;
|
|
17197
17897
|
taskId;
|
|
@@ -17231,11 +17931,15 @@ class Task {
|
|
|
17231
17931
|
lastSmartCompactionMessageCount = 0;
|
|
17232
17932
|
smartCompactionLevel = CompactionLevel.One;
|
|
17233
17933
|
taskDataPath;
|
|
17934
|
+
taskDataLoadPromise;
|
|
17234
17935
|
contextManager;
|
|
17235
17936
|
agent;
|
|
17236
17937
|
aiderManager;
|
|
17237
17938
|
skillManager;
|
|
17238
17939
|
task;
|
|
17940
|
+
async waitForTaskDataLoad() {
|
|
17941
|
+
await this.taskDataLoadPromise;
|
|
17942
|
+
}
|
|
17239
17943
|
async getTaskAgentProfile() {
|
|
17240
17944
|
let agentProfileId = this.task.agentProfileId;
|
|
17241
17945
|
if (!agentProfileId) {
|
|
@@ -17270,19 +17974,60 @@ class Task {
|
|
|
17270
17974
|
baseDir: this.project.baseDir,
|
|
17271
17975
|
taskId: this.taskId
|
|
17272
17976
|
});
|
|
17273
|
-
|
|
17274
|
-
|
|
17275
|
-
|
|
17276
|
-
|
|
17277
|
-
|
|
17278
|
-
|
|
17279
|
-
|
|
17280
|
-
|
|
17281
|
-
|
|
17282
|
-
|
|
17283
|
-
|
|
17284
|
-
|
|
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();
|
|
17285
18029
|
}
|
|
18030
|
+
return { taskDataChanged, contextChanged };
|
|
17286
18031
|
}
|
|
17287
18032
|
/**
|
|
17288
18033
|
* Generate a branch name from task name (first 7 words, separated by '-')
|
|
@@ -17312,16 +18057,13 @@ class Task {
|
|
|
17312
18057
|
await this.renameWorktreeBranch(newBranch);
|
|
17313
18058
|
}
|
|
17314
18059
|
/**
|
|
17315
|
-
*
|
|
17316
|
-
*
|
|
17317
|
-
* Can be removed once all users have migrated past v0.64.0.
|
|
18060
|
+
* Resolves missing `baseBranch` for worktrees created while the main repo
|
|
18061
|
+
* was in detached HEAD state, where `baseBranch` was never stored.
|
|
17318
18062
|
*/
|
|
17319
|
-
async
|
|
17320
|
-
if (!this.task.worktree || this.task.worktree.
|
|
17321
|
-
return;
|
|
18063
|
+
async resolveMissingWorktreeBaseBranch() {
|
|
18064
|
+
if (!this.task.worktree || this.task.worktree.baseBranch) {
|
|
18065
|
+
return false;
|
|
17322
18066
|
}
|
|
17323
|
-
const currentBranch = this.task.worktree.baseBranch;
|
|
17324
|
-
this.task.worktree.branch = currentBranch;
|
|
17325
18067
|
let resolvedBase = "";
|
|
17326
18068
|
if (this.task.worktree.baseCommit) {
|
|
17327
18069
|
const branches = await this.worktreeManager.getBranchesContainingCommit(this.project.baseDir, this.task.worktree.baseCommit);
|
|
@@ -17337,7 +18079,8 @@ class Task {
|
|
|
17337
18079
|
}
|
|
17338
18080
|
}
|
|
17339
18081
|
this.task.worktree.baseBranch = resolvedBase || void 0;
|
|
17340
|
-
await this.saveTask({ worktree: this.task.worktree });
|
|
18082
|
+
await this.saveTask({ worktree: this.task.worktree }, false);
|
|
18083
|
+
return true;
|
|
17341
18084
|
}
|
|
17342
18085
|
isInternal() {
|
|
17343
18086
|
return this.taskId === INTERNAL_TASK_ID;
|
|
@@ -17380,13 +18123,16 @@ class Task {
|
|
|
17380
18123
|
});
|
|
17381
18124
|
return this.task;
|
|
17382
18125
|
}
|
|
17383
|
-
async init() {
|
|
18126
|
+
async init(readonly = false) {
|
|
17384
18127
|
if (this.initialized) {
|
|
17385
18128
|
logger.debug("Task already initialized, skipping", {
|
|
17386
18129
|
baseDir: this.project.baseDir,
|
|
17387
18130
|
taskId: this.taskId
|
|
17388
18131
|
});
|
|
17389
18132
|
this.eventManager.sendTaskInitialized(this.task);
|
|
18133
|
+
if (readonly) {
|
|
18134
|
+
return;
|
|
18135
|
+
}
|
|
17390
18136
|
this.aiderManager.sendUpdateAiderModels();
|
|
17391
18137
|
await this.updateAutocompletionData(void 0, true);
|
|
17392
18138
|
await this.updateContextInfo();
|
|
@@ -17396,11 +18142,21 @@ class Task {
|
|
|
17396
18142
|
await this.initPromise;
|
|
17397
18143
|
return;
|
|
17398
18144
|
}
|
|
17399
|
-
this.initPromise = this.initInternal();
|
|
18145
|
+
this.initPromise = this.initInternal(readonly);
|
|
17400
18146
|
await this.initPromise;
|
|
17401
18147
|
this.initPromise = null;
|
|
17402
18148
|
}
|
|
17403
|
-
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
|
+
}
|
|
17404
18160
|
const workingMode = this.task.workingMode;
|
|
17405
18161
|
const existingWorktree = await this.worktreeManager.getTaskWorktree(this.project.baseDir, this.taskId);
|
|
17406
18162
|
if (workingMode === "worktree") {
|
|
@@ -17441,7 +18197,10 @@ class Task {
|
|
|
17441
18197
|
this.task.workingMode = "local";
|
|
17442
18198
|
}
|
|
17443
18199
|
}
|
|
17444
|
-
await this.
|
|
18200
|
+
const worktreeBaseBranchResolved = await this.resolveMissingWorktreeBaseBranch();
|
|
18201
|
+
if (worktreeBaseBranchResolved && this.task.worktree) {
|
|
18202
|
+
void this.sendWorktreeIntegrationStatusUpdated();
|
|
18203
|
+
}
|
|
17445
18204
|
if (await fileExists(this.getTaskDir())) {
|
|
17446
18205
|
this.git = simpleGit.simpleGit(this.getTaskDir());
|
|
17447
18206
|
}
|
|
@@ -17455,12 +18214,12 @@ class Task {
|
|
|
17455
18214
|
this.initialized = true;
|
|
17456
18215
|
await this.extensionManager.dispatchEvent("onTaskInitialized", { task: this.task }, this.project, this);
|
|
17457
18216
|
}
|
|
17458
|
-
async load() {
|
|
18217
|
+
async load(readonly = false) {
|
|
17459
18218
|
logger.info("Loading task", {
|
|
17460
18219
|
baseDir: this.project.baseDir,
|
|
17461
18220
|
taskId: this.taskId
|
|
17462
18221
|
});
|
|
17463
|
-
await this.init();
|
|
18222
|
+
await this.init(readonly);
|
|
17464
18223
|
const mode = this.getCurrentMode();
|
|
17465
18224
|
return {
|
|
17466
18225
|
messages: this.contextManager.getContextMessagesData(),
|
|
@@ -17752,6 +18511,17 @@ class Task {
|
|
|
17752
18511
|
state: DefaultTaskState.Todo
|
|
17753
18512
|
});
|
|
17754
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
|
+
}
|
|
17755
18525
|
async runNextQueuedPrompt() {
|
|
17756
18526
|
if (this.queuedPrompts.length > 0) {
|
|
17757
18527
|
const nextPrompt = this.queuedPrompts.shift();
|
|
@@ -19508,6 +20278,11 @@ ${contentText}</agent-response>`;
|
|
|
19508
20278
|
const originalText = extractTextContent(originalUserMessage.content);
|
|
19509
20279
|
const promptToRun = updatedPrompt ?? originalText;
|
|
19510
20280
|
const imagesToRun = updatedImages ?? (updatedPrompt !== void 0 ? void 0 : extractImagesFromContent(originalUserMessage.content));
|
|
20281
|
+
if (this.tryCustomCommand(promptToRun, mode)) {
|
|
20282
|
+
this.sendTaskMessageRemoved(removedMessages.map((msg) => msg.id));
|
|
20283
|
+
await this.updateContextInfo();
|
|
20284
|
+
return;
|
|
20285
|
+
}
|
|
19511
20286
|
if (promptToRun) {
|
|
19512
20287
|
logger.info("Found message content to run, reloading and re-running prompt.", {
|
|
19513
20288
|
remainingMessagesCount: (await this.contextManager.getContextMessages()).length
|
|
@@ -19525,6 +20300,13 @@ ${contentText}</agent-response>`;
|
|
|
19525
20300
|
taskId: this.taskId
|
|
19526
20301
|
});
|
|
19527
20302
|
const mode = this.getCurrentMode();
|
|
20303
|
+
const contextMessages = await this.contextManager.getContextMessages();
|
|
20304
|
+
const lastMessage = contextMessages[contextMessages.length - 1];
|
|
20305
|
+
if (lastMessage?.role === MessageRole.User && this.tryCustomCommand(extractTextContent(lastMessage.content), mode)) {
|
|
20306
|
+
const removedMessageIds = this.contextManager.removeMessageById(lastMessage.id);
|
|
20307
|
+
this.sendTaskMessageRemoved(removedMessageIds);
|
|
20308
|
+
return;
|
|
20309
|
+
}
|
|
19528
20310
|
if (!AIDER_MODES.includes(mode)) {
|
|
19529
20311
|
const profile = await this.getTaskAgentProfile();
|
|
19530
20312
|
if (!profile) {
|
|
@@ -19539,8 +20321,6 @@ ${contentText}</agent-response>`;
|
|
|
19539
20321
|
this.addLogMessage("loading", "Resuming task...");
|
|
19540
20322
|
void this.runPromptInAgent(profile, mode, null);
|
|
19541
20323
|
} else {
|
|
19542
|
-
const contextMessages = await this.contextManager.getContextMessages();
|
|
19543
|
-
const lastMessage = contextMessages[contextMessages.length - 1];
|
|
19544
20324
|
if (lastMessage && lastMessage.role === MessageRole.User) {
|
|
19545
20325
|
logger.info("Last message is from user, redoing prompt");
|
|
19546
20326
|
this.addLogMessage("loading", "Resuming task...");
|
|
@@ -19551,6 +20331,23 @@ ${contentText}</agent-response>`;
|
|
|
19551
20331
|
}
|
|
19552
20332
|
}
|
|
19553
20333
|
}
|
|
20334
|
+
tryCustomCommand(prompt, mode) {
|
|
20335
|
+
if (!prompt.startsWith("/")) {
|
|
20336
|
+
return false;
|
|
20337
|
+
}
|
|
20338
|
+
const [name, ...args] = parseCommandArgs(prompt.slice(1));
|
|
20339
|
+
if (!name) {
|
|
20340
|
+
return false;
|
|
20341
|
+
}
|
|
20342
|
+
const isExtensionCommand = this.extensionManager.getCommands(this.project).some(({ command }) => command.name === name);
|
|
20343
|
+
const isCustomCommand = !!this.customCommandManager.getCommand(name);
|
|
20344
|
+
if (!isExtensionCommand && !isCustomCommand) {
|
|
20345
|
+
return false;
|
|
20346
|
+
}
|
|
20347
|
+
logger.info("Executing custom command from user prompt", { name, args });
|
|
20348
|
+
void this.runCustomCommand(name, args, mode);
|
|
20349
|
+
return true;
|
|
20350
|
+
}
|
|
19554
20351
|
getCurrentMode() {
|
|
19555
20352
|
return this.task.currentMode || this.store.getProjectSettings(this.project.baseDir).currentMode || "agent";
|
|
19556
20353
|
}
|
|
@@ -20618,10 +21415,18 @@ ${diff}
|
|
|
20618
21415
|
message = beforeResult.message;
|
|
20619
21416
|
amend = beforeResult.amend;
|
|
20620
21417
|
const taskDir = this.getTaskDir();
|
|
20621
|
-
await this.worktreeManager.commitChanges(taskDir, message, amend);
|
|
21418
|
+
const committed = await this.worktreeManager.commitChanges(taskDir, message, amend);
|
|
20622
21419
|
await this.sendUpdatedFilesUpdated();
|
|
20623
21420
|
await this.sendWorktreeIntegrationStatusUpdated();
|
|
20624
|
-
|
|
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);
|
|
20625
21430
|
}
|
|
20626
21431
|
async getWorktreeIntegrationStatus(targetBranch) {
|
|
20627
21432
|
if (!this.task.worktree) {
|
|
@@ -21173,16 +21978,23 @@ class Project {
|
|
|
21173
21978
|
customCommandManager;
|
|
21174
21979
|
tasksLoadingPromise = null;
|
|
21175
21980
|
tasks = /* @__PURE__ */ new Map();
|
|
21981
|
+
tasksReloadingPromise = null;
|
|
21176
21982
|
connectors = [];
|
|
21177
21983
|
inputHistoryFile = ".aider.input.history";
|
|
21178
|
-
|
|
21179
|
-
|
|
21180
|
-
|
|
21181
|
-
|
|
21182
|
-
|
|
21183
|
-
|
|
21184
|
-
|
|
21185
|
-
|
|
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;
|
|
21186
21998
|
}
|
|
21187
21999
|
async prepareInternalTask() {
|
|
21188
22000
|
const task = await this.prepareTask(INTERNAL_TASK_ID);
|
|
@@ -21287,6 +22099,7 @@ class Project {
|
|
|
21287
22099
|
this.pythonInstaller,
|
|
21288
22100
|
initialTaskData
|
|
21289
22101
|
);
|
|
22102
|
+
await task.waitForTaskDataLoad();
|
|
21290
22103
|
this.tasks.set(taskId, task);
|
|
21291
22104
|
const extResult = await this.extensionManager.dispatchEvent("onTaskPrepared", { task: task.task }, this, task);
|
|
21292
22105
|
if (extResult.task) {
|
|
@@ -21294,20 +22107,20 @@ class Project {
|
|
|
21294
22107
|
}
|
|
21295
22108
|
return task;
|
|
21296
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
|
+
}
|
|
21297
22118
|
async loadTasks() {
|
|
21298
22119
|
await this.prepareInternalTask();
|
|
21299
22120
|
await migrateSessionsToTasks(this);
|
|
21300
|
-
const tasksDir = path.join(this.baseDir,
|
|
22121
|
+
const tasksDir = path.join(this.baseDir, AIDER_DESK_TASKS_DIR);
|
|
21301
22122
|
try {
|
|
21302
|
-
|
|
21303
|
-
logger.debug("Tasks directory does not exist, skipping loadTasks", {
|
|
21304
|
-
baseDir: this.baseDir,
|
|
21305
|
-
tasksDir
|
|
21306
|
-
});
|
|
21307
|
-
return;
|
|
21308
|
-
}
|
|
21309
|
-
const taskFolders = await fs.readdir(tasksDir, { withFileTypes: true });
|
|
21310
|
-
const taskDirs = taskFolders.filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name).filter((taskId) => taskId !== INTERNAL_TASK_ID);
|
|
22123
|
+
const taskDirs = await this.getTaskIdsFromDisk();
|
|
21311
22124
|
logger.debug(`Loading ${taskDirs.length} tasks from directory`, {
|
|
21312
22125
|
baseDir: this.baseDir,
|
|
21313
22126
|
tasksDir
|
|
@@ -21451,27 +22264,37 @@ class Project {
|
|
|
21451
22264
|
}
|
|
21452
22265
|
return false;
|
|
21453
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
|
+
}
|
|
21454
22282
|
async deleteTaskInternal(taskId) {
|
|
21455
|
-
const taskDir = path.join(this.baseDir,
|
|
22283
|
+
const taskDir = path.join(this.baseDir, AIDER_DESK_TASKS_DIR, taskId);
|
|
21456
22284
|
const task = this.tasks.get(taskId);
|
|
21457
|
-
if (task) {
|
|
21458
|
-
await task.close();
|
|
21459
|
-
this.tasks.delete(taskId);
|
|
21460
|
-
this.eventManager.sendTaskDeleted(task.task);
|
|
21461
|
-
}
|
|
21462
22285
|
const taskData = task?.task;
|
|
21463
|
-
if (
|
|
21464
|
-
|
|
21465
|
-
|
|
21466
|
-
|
|
21467
|
-
|
|
21468
|
-
|
|
21469
|
-
|
|
21470
|
-
worktreePath: taskData.worktree.path,
|
|
21471
|
-
error: error instanceof Error ? error.message : String(error)
|
|
21472
|
-
});
|
|
21473
|
-
}
|
|
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`);
|
|
21474
22293
|
}
|
|
22294
|
+
await task.close();
|
|
22295
|
+
this.tasks.delete(taskId);
|
|
22296
|
+
this.eventManager.sendTaskDeleted(task.task);
|
|
22297
|
+
await this.removeTaskWorktree(taskId, taskData);
|
|
21475
22298
|
await fs.rm(taskDir, { recursive: true, force: true });
|
|
21476
22299
|
}
|
|
21477
22300
|
async deleteTask(taskId) {
|
|
@@ -21538,6 +22361,48 @@ class Project {
|
|
|
21538
22361
|
await this.tasksLoadingPromise;
|
|
21539
22362
|
return Array.from(this.tasks.values()).map((task) => task.task).filter((task) => task.id !== INTERNAL_TASK_ID);
|
|
21540
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
|
+
}
|
|
21541
22406
|
forEachTask(callback, initializedOnly = true) {
|
|
21542
22407
|
this.tasks.values().filter((task) => !initializedOnly || task.isInitialized()).forEach(callback);
|
|
21543
22408
|
}
|
|
@@ -21553,6 +22418,8 @@ class Project {
|
|
|
21553
22418
|
});
|
|
21554
22419
|
}
|
|
21555
22420
|
async close() {
|
|
22421
|
+
await this.startPromise;
|
|
22422
|
+
this.startPromise = null;
|
|
21556
22423
|
await this.extensionManager.dispatchEvent("onProjectStopped", { baseDir: this.baseDir }, this);
|
|
21557
22424
|
this.customCommandManager.dispose();
|
|
21558
22425
|
this.agentProfileManager.removeProject(this.baseDir);
|
|
@@ -21629,6 +22496,9 @@ class ProjectManager {
|
|
|
21629
22496
|
}
|
|
21630
22497
|
return project;
|
|
21631
22498
|
}
|
|
22499
|
+
getOpenProject(baseDir) {
|
|
22500
|
+
return this.findProject(baseDir);
|
|
22501
|
+
}
|
|
21632
22502
|
async startProject(baseDir) {
|
|
21633
22503
|
logger.info("Starting project", { baseDir });
|
|
21634
22504
|
const project = this.getProject(baseDir);
|
|
@@ -21978,12 +22848,14 @@ class EventManager {
|
|
|
21978
22848
|
this.eventsConnectors = this.eventsConnectors.filter((connector) => connector.socket.id !== socket.id);
|
|
21979
22849
|
logger.info("Subscribing to events", {
|
|
21980
22850
|
eventTypes: config.eventTypes,
|
|
21981
|
-
baseDirs: config.baseDirs
|
|
22851
|
+
baseDirs: config.baseDirs,
|
|
22852
|
+
readonly: config.readonly
|
|
21982
22853
|
});
|
|
21983
22854
|
this.eventsConnectors.push({
|
|
21984
22855
|
socket,
|
|
21985
22856
|
eventTypes: config.eventTypes,
|
|
21986
|
-
baseDirs: config.baseDirs
|
|
22857
|
+
baseDirs: config.baseDirs,
|
|
22858
|
+
readonly: config.readonly
|
|
21987
22859
|
});
|
|
21988
22860
|
}
|
|
21989
22861
|
unsubscribe(socket, log = true) {
|
|
@@ -22024,10 +22896,10 @@ class EventManager {
|
|
|
22024
22896
|
}
|
|
22025
22897
|
return;
|
|
22026
22898
|
}
|
|
22027
|
-
const
|
|
22028
|
-
if (connector.baseDirs &&
|
|
22899
|
+
const eventProjectDir = data && typeof data === "object" ? data.baseDir ?? data.projectDir : void 0;
|
|
22900
|
+
if (connector.baseDirs && (!eventProjectDir || !connector.baseDirs.includes(eventProjectDir))) {
|
|
22029
22901
|
if (log) {
|
|
22030
|
-
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 });
|
|
22031
22903
|
}
|
|
22032
22904
|
return;
|
|
22033
22905
|
}
|
|
@@ -22035,7 +22907,7 @@ class EventManager {
|
|
|
22035
22907
|
if (log) {
|
|
22036
22908
|
logger.debug("Broadcasting event to connector:", {
|
|
22037
22909
|
eventType,
|
|
22038
|
-
baseDir
|
|
22910
|
+
baseDir: eventProjectDir
|
|
22039
22911
|
});
|
|
22040
22912
|
}
|
|
22041
22913
|
connector.socket.emit("event", { type: eventType, data });
|
|
@@ -22228,8 +23100,8 @@ const getAnthropicCacheControl = () => {
|
|
|
22228
23100
|
placement: "message"
|
|
22229
23101
|
};
|
|
22230
23102
|
};
|
|
22231
|
-
const getAnthropicProviderOptions = (llmProvider, _model) => {
|
|
22232
|
-
if (!isAnthropicProvider(llmProvider)) {
|
|
23103
|
+
const getAnthropicProviderOptions = (llmProvider, _model, reasoning) => {
|
|
23104
|
+
if (!isAnthropicProvider(llmProvider) || reasoning && reasoning !== "provider-default") {
|
|
22233
23105
|
return void 0;
|
|
22234
23106
|
}
|
|
22235
23107
|
return {
|
|
@@ -22359,8 +23231,8 @@ const createAnthropicCompatibleLlm = (profile, model, settings, projectDir) => {
|
|
|
22359
23231
|
});
|
|
22360
23232
|
return anthropicProvider(model.id);
|
|
22361
23233
|
};
|
|
22362
|
-
const getAnthropicCompatibleProviderOptions = (llmProvider, _model) => {
|
|
22363
|
-
if (!isAnthropicCompatibleProvider(llmProvider)) {
|
|
23234
|
+
const getAnthropicCompatibleProviderOptions = (llmProvider, _model, reasoning) => {
|
|
23235
|
+
if (!isAnthropicCompatibleProvider(llmProvider) || reasoning && reasoning !== "provider-default") {
|
|
22364
23236
|
return void 0;
|
|
22365
23237
|
}
|
|
22366
23238
|
return {
|
|
@@ -22447,8 +23319,15 @@ const createAzureLlm = (profile, model, settings, projectDir) => {
|
|
|
22447
23319
|
});
|
|
22448
23320
|
return azureProvider.responses(model.id);
|
|
22449
23321
|
};
|
|
22450
|
-
const getAzureProviderOptions = (llmProvider, model) => {
|
|
23322
|
+
const getAzureProviderOptions = (llmProvider, model, reasoning) => {
|
|
22451
23323
|
if (isAzureProvider(llmProvider)) {
|
|
23324
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
23325
|
+
return {
|
|
23326
|
+
openai: {
|
|
23327
|
+
reasoningSummary: "auto"
|
|
23328
|
+
}
|
|
23329
|
+
};
|
|
23330
|
+
}
|
|
22452
23331
|
const providerOverrides = model.providerOverrides;
|
|
22453
23332
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? llmProvider.reasoningEffort;
|
|
22454
23333
|
const mappedReasoningEffort = reasoningEffort === void 0 || reasoningEffort === ReasoningEffort.None ? void 0 : reasoningEffort.toLowerCase();
|
|
@@ -22467,12 +23346,13 @@ const getAzureProviderOptions = (llmProvider, model) => {
|
|
|
22467
23346
|
}
|
|
22468
23347
|
return void 0;
|
|
22469
23348
|
};
|
|
22470
|
-
const getAzureProviderParameters = (llmProvider, model) => {
|
|
23349
|
+
const getAzureProviderParameters = (llmProvider, model, reasoning) => {
|
|
22471
23350
|
if (isAzureProvider(llmProvider)) {
|
|
22472
23351
|
const providerOverrides = model.providerOverrides;
|
|
22473
23352
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? llmProvider.reasoningEffort;
|
|
22474
|
-
|
|
22475
|
-
|
|
23353
|
+
const reasoningEnabled = reasoning && reasoning !== "provider-default" ? reasoning !== "none" : !!reasoningEffort && reasoningEffort !== ReasoningEffort.None;
|
|
23354
|
+
if (reasoningEnabled) {
|
|
23355
|
+
logger.debug("Clearing temperature and maxOutputTokens for Azure with reasoning:", { reasoning: reasoning ?? reasoningEffort });
|
|
22476
23356
|
return {
|
|
22477
23357
|
// not supported by Azure with reasoning models
|
|
22478
23358
|
maxOutputTokens: void 0,
|
|
@@ -23061,10 +23941,20 @@ const createDeepseekLlm = (profile, model, settings, projectDir) => {
|
|
|
23061
23941
|
});
|
|
23062
23942
|
return deepseekProvider(model.id);
|
|
23063
23943
|
};
|
|
23064
|
-
const getDeepseekProviderOptions = (llmProvider, model) => {
|
|
23944
|
+
const getDeepseekProviderOptions = (llmProvider, model, reasoning) => {
|
|
23065
23945
|
if (!isDeepseekProvider(llmProvider)) {
|
|
23066
23946
|
return void 0;
|
|
23067
23947
|
}
|
|
23948
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
23949
|
+
if (reasoning === "none") {
|
|
23950
|
+
return {
|
|
23951
|
+
deepseek: {
|
|
23952
|
+
thinking: { type: "disabled" }
|
|
23953
|
+
}
|
|
23954
|
+
};
|
|
23955
|
+
}
|
|
23956
|
+
return void 0;
|
|
23957
|
+
}
|
|
23068
23958
|
const providerOverrides = model.providerOverrides;
|
|
23069
23959
|
const thinkingEnabled = providerOverrides?.thinkingEnabled ?? llmProvider.thinkingEnabled ?? true;
|
|
23070
23960
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? llmProvider.reasoningEffort ?? "high";
|
|
@@ -23075,12 +23965,13 @@ const getDeepseekProviderOptions = (llmProvider, model) => {
|
|
|
23075
23965
|
}
|
|
23076
23966
|
};
|
|
23077
23967
|
};
|
|
23078
|
-
const getDeepseekProviderParameters = (llmProvider, model) => {
|
|
23968
|
+
const getDeepseekProviderParameters = (llmProvider, model, reasoning) => {
|
|
23079
23969
|
if (!isDeepseekProvider(llmProvider)) {
|
|
23080
23970
|
return {};
|
|
23081
23971
|
}
|
|
23082
23972
|
const providerOverrides = model.providerOverrides;
|
|
23083
|
-
const
|
|
23973
|
+
const configuredThinkingEnabled = providerOverrides?.thinkingEnabled ?? llmProvider.thinkingEnabled ?? true;
|
|
23974
|
+
const thinkingEnabled = reasoning && reasoning !== "provider-default" ? reasoning !== "none" : configuredThinkingEnabled;
|
|
23084
23975
|
if (thinkingEnabled) {
|
|
23085
23976
|
return {
|
|
23086
23977
|
temperature: void 0,
|
|
@@ -23204,11 +24095,22 @@ const getGeminiUsageReport = (task, provider, model, usage, providerMetadata) =>
|
|
|
23204
24095
|
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
23205
24096
|
};
|
|
23206
24097
|
};
|
|
23207
|
-
const getGeminiProviderOptions = (llmProvider, model) => {
|
|
24098
|
+
const getGeminiProviderOptions = (llmProvider, model, reasoning) => {
|
|
23208
24099
|
if (isGeminiProvider(llmProvider)) {
|
|
23209
24100
|
const providerOverrides = model.providerOverrides;
|
|
23210
24101
|
const includeThoughts = providerOverrides?.includeThoughts ?? llmProvider.includeThoughts;
|
|
23211
24102
|
const thinkingBudget = providerOverrides?.thinkingBudget ?? llmProvider.thinkingBudget;
|
|
24103
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
24104
|
+
return {
|
|
24105
|
+
google: {
|
|
24106
|
+
...includeThoughts && {
|
|
24107
|
+
thinkingConfig: {
|
|
24108
|
+
includeThoughts: true
|
|
24109
|
+
}
|
|
24110
|
+
}
|
|
24111
|
+
}
|
|
24112
|
+
};
|
|
24113
|
+
}
|
|
23212
24114
|
return {
|
|
23213
24115
|
google: {
|
|
23214
24116
|
...(includeThoughts || thinkingBudget) && {
|
|
@@ -23596,9 +24498,12 @@ const createAlibabaPlanLlm = (profile, model, settings, projectDir) => {
|
|
|
23596
24498
|
});
|
|
23597
24499
|
return alibabaPlanProvider(model.id);
|
|
23598
24500
|
};
|
|
23599
|
-
const getAlibabaPlanProviderOptions = (llmProvider, model) => {
|
|
24501
|
+
const getAlibabaPlanProviderOptions = (llmProvider, model, reasoning) => {
|
|
23600
24502
|
if (isAlibabaPlanProvider(llmProvider)) {
|
|
23601
24503
|
const providerOverrides = model.providerOverrides;
|
|
24504
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
24505
|
+
return void 0;
|
|
24506
|
+
}
|
|
23602
24507
|
const thinkingEnabled = providerOverrides?.thinkingEnabled ?? llmProvider.thinkingEnabled ?? true;
|
|
23603
24508
|
const thinkingBudget = providerOverrides?.thinkingBudget ?? llmProvider.thinkingBudget ?? 8192;
|
|
23604
24509
|
logger.info(`Alibaba Plan provider options: thinkingEnabled=${thinkingEnabled}, thinkingBudget=${thinkingBudget}`);
|
|
@@ -24098,8 +25003,8 @@ const getMinimaxCacheControl = () => {
|
|
|
24098
25003
|
placement: "message"
|
|
24099
25004
|
};
|
|
24100
25005
|
};
|
|
24101
|
-
const getMinimaxProviderOptions = (llmProvider, _model) => {
|
|
24102
|
-
if (!isMinimaxProvider(llmProvider)) {
|
|
25006
|
+
const getMinimaxProviderOptions = (llmProvider, _model, reasoning) => {
|
|
25007
|
+
if (!isMinimaxProvider(llmProvider) || reasoning && reasoning !== "provider-default") {
|
|
24103
25008
|
return void 0;
|
|
24104
25009
|
}
|
|
24105
25010
|
return {
|
|
@@ -24288,10 +25193,13 @@ const createNeuralwattLlm = (profile, model, settings, projectDir) => {
|
|
|
24288
25193
|
});
|
|
24289
25194
|
return compatibleProvider(model.id);
|
|
24290
25195
|
};
|
|
24291
|
-
const getNeuralwattProviderOptions = (llmProvider, model) => {
|
|
25196
|
+
const getNeuralwattProviderOptions = (llmProvider, model, reasoning) => {
|
|
24292
25197
|
if (!isNeuralwattProvider(llmProvider)) {
|
|
24293
25198
|
return void 0;
|
|
24294
25199
|
}
|
|
25200
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
25201
|
+
return void 0;
|
|
25202
|
+
}
|
|
24295
25203
|
const neuralwattProvider = llmProvider;
|
|
24296
25204
|
const providerOverrides = model.providerOverrides;
|
|
24297
25205
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? neuralwattProvider.reasoningEffort;
|
|
@@ -24493,11 +25401,18 @@ const createOpenAiLlm = (profile, model, settings, projectDir) => {
|
|
|
24493
25401
|
});
|
|
24494
25402
|
return openAIProvider(model.id);
|
|
24495
25403
|
};
|
|
24496
|
-
const getOpenAiProviderOptions = (provider, model) => {
|
|
25404
|
+
const getOpenAiProviderOptions = (provider, model, reasoning) => {
|
|
24497
25405
|
if (!isOpenAiProvider(provider)) {
|
|
24498
25406
|
return void 0;
|
|
24499
25407
|
}
|
|
24500
25408
|
const openAiProvider = provider;
|
|
25409
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
25410
|
+
return {
|
|
25411
|
+
openai: {
|
|
25412
|
+
reasoningSummary: "auto"
|
|
25413
|
+
}
|
|
25414
|
+
};
|
|
25415
|
+
}
|
|
24501
25416
|
const providerOverrides = model.providerOverrides;
|
|
24502
25417
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? openAiProvider.reasoningEffort;
|
|
24503
25418
|
const mappedReasoningEffort = reasoningEffort === void 0 || reasoningEffort === ReasoningEffort.None ? void 0 : reasoningEffort.toLowerCase();
|
|
@@ -24546,11 +25461,12 @@ const createOpenAIVoiceSession = async (profile, settings) => {
|
|
|
24546
25461
|
throw new Error("OpenAI API key is required for voice session");
|
|
24547
25462
|
}
|
|
24548
25463
|
try {
|
|
24549
|
-
const model = provider.voice?.model ?? OpenAiVoiceModel.
|
|
25464
|
+
const model = provider.voice?.model ?? OpenAiVoiceModel.GptLiveTranscribe;
|
|
24550
25465
|
const language = provider.voice?.language ?? "en";
|
|
24551
25466
|
const prompt = provider.voice?.systemInstructions ?? DEFAULT_VOICE_SYSTEM_INSTRUCTIONS;
|
|
24552
25467
|
const idleTimeoutMs = provider.voice?.idleTimeoutMs ?? 5e3;
|
|
24553
|
-
const supportsTranscriptionParams = model !== OpenAiVoiceModel.GptRealtimeWhisper;
|
|
25468
|
+
const supportsTranscriptionParams = model !== OpenAiVoiceModel.GptRealtimeWhisper && model !== OpenAiVoiceModel.GptLiveTranscribe;
|
|
25469
|
+
const usesLanguageHints = model === OpenAiVoiceModel.GptLiveTranscribe;
|
|
24554
25470
|
const response = await fetch("https://api.openai.com/v1/realtime/client_secrets", {
|
|
24555
25471
|
method: "POST",
|
|
24556
25472
|
headers: {
|
|
@@ -24563,8 +25479,8 @@ const createOpenAIVoiceSession = async (profile, settings) => {
|
|
|
24563
25479
|
audio: {
|
|
24564
25480
|
input: {
|
|
24565
25481
|
transcription: {
|
|
24566
|
-
language,
|
|
24567
25482
|
model,
|
|
25483
|
+
...usesLanguageHints ? { languages: [language] } : { language },
|
|
24568
25484
|
...supportsTranscriptionParams && { prompt }
|
|
24569
25485
|
},
|
|
24570
25486
|
...supportsTranscriptionParams && {
|
|
@@ -24718,7 +25634,7 @@ const createOpenAiCompatibleLlm = (profile, model, settings, projectDir) => {
|
|
|
24718
25634
|
});
|
|
24719
25635
|
return compatibleProvider(model.id);
|
|
24720
25636
|
};
|
|
24721
|
-
const getOpenAiCompatibleProviderOptions = (provider, model) => {
|
|
25637
|
+
const getOpenAiCompatibleProviderOptions = (provider, model, reasoning) => {
|
|
24722
25638
|
if (!isOpenAiCompatibleProvider(provider)) {
|
|
24723
25639
|
return void 0;
|
|
24724
25640
|
}
|
|
@@ -24726,17 +25642,19 @@ const getOpenAiCompatibleProviderOptions = (provider, model) => {
|
|
|
24726
25642
|
const providerOverrides = model.providerOverrides;
|
|
24727
25643
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? openAiCompatibleProvider.reasoningEffort;
|
|
24728
25644
|
const extraBody = providerOverrides?.extraBody ?? openAiCompatibleProvider.extraBody;
|
|
24729
|
-
const mappedReasoningEffort = reasoningEffort === void 0 || reasoningEffort === ReasoningEffort.None ? void 0 : reasoningEffort.toLowerCase();
|
|
24730
25645
|
const providerOptions = {};
|
|
24731
|
-
if (
|
|
24732
|
-
|
|
25646
|
+
if (!reasoning || reasoning === "provider-default") {
|
|
25647
|
+
const mappedReasoningEffort = reasoningEffort === void 0 || reasoningEffort === ReasoningEffort.None ? void 0 : reasoningEffort.toLowerCase();
|
|
25648
|
+
if (mappedReasoningEffort) {
|
|
25649
|
+
providerOptions.reasoningEffort = mappedReasoningEffort;
|
|
25650
|
+
}
|
|
24733
25651
|
}
|
|
24734
25652
|
if (extraBody) {
|
|
24735
25653
|
Object.assign(providerOptions, extraBody);
|
|
24736
25654
|
}
|
|
24737
25655
|
if (Object.keys(providerOptions).length > 0) {
|
|
24738
25656
|
logger.debug("Using provider options for OpenAI Compatible:", {
|
|
24739
|
-
|
|
25657
|
+
reasoning,
|
|
24740
25658
|
hasExtraBody: !!extraBody
|
|
24741
25659
|
});
|
|
24742
25660
|
return {
|
|
@@ -25198,13 +26116,13 @@ const getRequestyUsageReport = (task, provider, model, usage, providerMetadata)
|
|
|
25198
26116
|
const totalSentTokens = usage.inputTokens || 0;
|
|
25199
26117
|
const receivedTokens = usage.outputTokens || 0;
|
|
25200
26118
|
const { requesty } = providerMetadata ? providerMetadata : {};
|
|
25201
|
-
logger.
|
|
26119
|
+
logger.debug("Requesty usage report", {
|
|
25202
26120
|
requesty,
|
|
25203
26121
|
usage
|
|
25204
26122
|
});
|
|
25205
|
-
const cacheWriteTokens = requesty?.usage?.cachingTokens ?? 0;
|
|
25206
|
-
const cacheReadTokens = requesty?.usage?.cachedTokens ?? 0;
|
|
25207
|
-
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;
|
|
25208
26126
|
const messageCost = calculateRequestyCost(model, sentTokens, receivedTokens, cacheWriteTokens, cacheReadTokens);
|
|
25209
26127
|
return {
|
|
25210
26128
|
model: `${provider.id}/${model.id}`,
|
|
@@ -25472,11 +26390,22 @@ const getVertexAiUsageReport = (task, provider, model, usage, providerMetadata)
|
|
|
25472
26390
|
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
25473
26391
|
};
|
|
25474
26392
|
};
|
|
25475
|
-
const getVertexAiProviderOptions = (llmProvider, model) => {
|
|
26393
|
+
const getVertexAiProviderOptions = (llmProvider, model, reasoning) => {
|
|
25476
26394
|
if (isVertexAiProvider(llmProvider)) {
|
|
25477
26395
|
const providerOverrides = model.providerOverrides;
|
|
25478
26396
|
const includeThoughts = providerOverrides?.includeThoughts ?? llmProvider.includeThoughts;
|
|
25479
26397
|
const thinkingBudget = providerOverrides?.thinkingBudget ?? llmProvider.thinkingBudget;
|
|
26398
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
26399
|
+
return {
|
|
26400
|
+
vertex: {
|
|
26401
|
+
...includeThoughts && {
|
|
26402
|
+
thinkingConfig: {
|
|
26403
|
+
includeThoughts: true
|
|
26404
|
+
}
|
|
26405
|
+
}
|
|
26406
|
+
}
|
|
26407
|
+
};
|
|
26408
|
+
}
|
|
25480
26409
|
return {
|
|
25481
26410
|
vertex: {
|
|
25482
26411
|
...(includeThoughts || thinkingBudget) && {
|
|
@@ -25586,13 +26515,29 @@ const getZaiPlanModelInfo = (_provider, modelId, allModelInfos) => {
|
|
|
25586
26515
|
const fullModelId = `zai-coding-plan/${modelId}`;
|
|
25587
26516
|
return allModelInfos[fullModelId];
|
|
25588
26517
|
};
|
|
25589
|
-
const getZaiPlanProviderOptions = (llmProvider, model) => {
|
|
26518
|
+
const getZaiPlanProviderOptions = (llmProvider, model, reasoning) => {
|
|
25590
26519
|
if (isZaiPlanProvider(llmProvider)) {
|
|
25591
26520
|
const providerOverrides = model.providerOverrides;
|
|
25592
26521
|
const thinkingEnabled = providerOverrides?.thinkingEnabled ?? llmProvider.thinkingEnabled ?? true;
|
|
25593
26522
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? llmProvider.reasoningEffort ?? ReasoningEffort.Max;
|
|
25594
26523
|
const toolCallStreamingDisabled = providerOverrides?.disableToolCallStreaming ?? llmProvider.disableToolCallStreaming ?? false;
|
|
25595
26524
|
const toolStreamOption = toolCallStreamingDisabled ? {} : { tool_stream: true };
|
|
26525
|
+
if (reasoning && reasoning !== "provider-default") {
|
|
26526
|
+
if (reasoning === "none") {
|
|
26527
|
+
return {
|
|
26528
|
+
zaiPlan: {
|
|
26529
|
+
thinking: { type: "disabled" },
|
|
26530
|
+
...toolStreamOption
|
|
26531
|
+
}
|
|
26532
|
+
};
|
|
26533
|
+
}
|
|
26534
|
+
if (Object.keys(toolStreamOption).length > 0) {
|
|
26535
|
+
return {
|
|
26536
|
+
zaiPlan: toolStreamOption
|
|
26537
|
+
};
|
|
26538
|
+
}
|
|
26539
|
+
return void 0;
|
|
26540
|
+
}
|
|
25596
26541
|
if (thinkingEnabled === false) {
|
|
25597
26542
|
return {
|
|
25598
26543
|
zaiPlan: {
|
|
@@ -25704,6 +26649,9 @@ class ModelManager {
|
|
|
25704
26649
|
logger.error("Error initializing ModelInfoManager:", error);
|
|
25705
26650
|
}
|
|
25706
26651
|
}
|
|
26652
|
+
async waitForInit() {
|
|
26653
|
+
await this.initPromise;
|
|
26654
|
+
}
|
|
25707
26655
|
async loadModelsInfo() {
|
|
25708
26656
|
const cacheFile = path.join(AIDER_DESK_CACHE_DIR, "models-meta.json");
|
|
25709
26657
|
let cacheLoaded = false;
|
|
@@ -26235,7 +27183,7 @@ class ModelManager {
|
|
|
26235
27183
|
}
|
|
26236
27184
|
return typeof modelObj.providerOverrides?.disableToolCallStreaming === "boolean" ? modelObj.providerOverrides.disableToolCallStreaming : llmProvider.disableToolCallStreaming ?? false;
|
|
26237
27185
|
}
|
|
26238
|
-
getProviderOptions(provider, modelId) {
|
|
27186
|
+
getProviderOptions(provider, modelId, reasoning) {
|
|
26239
27187
|
const llmProvider = provider.provider;
|
|
26240
27188
|
const strategy = this.providerRegistry[llmProvider.name];
|
|
26241
27189
|
if (!strategy?.getProviderOptions) {
|
|
@@ -26253,14 +27201,14 @@ class ModelManager {
|
|
|
26253
27201
|
id: modelId,
|
|
26254
27202
|
providerId: provider.id
|
|
26255
27203
|
};
|
|
26256
|
-
return strategy.getProviderOptions(llmProvider, fallbackModel);
|
|
27204
|
+
return strategy.getProviderOptions(llmProvider, fallbackModel, reasoning);
|
|
26257
27205
|
}
|
|
26258
27206
|
logger.debug(`Found model object for ${modelId} in provider ${provider.id}`, {
|
|
26259
27207
|
hasProviderOverrides: !!modelObj.providerOverrides
|
|
26260
27208
|
});
|
|
26261
|
-
return strategy.getProviderOptions(llmProvider, modelObj);
|
|
27209
|
+
return strategy.getProviderOptions(llmProvider, modelObj, reasoning);
|
|
26262
27210
|
}
|
|
26263
|
-
getProviderParameters(provider, modelId) {
|
|
27211
|
+
getProviderParameters(provider, modelId, reasoning) {
|
|
26264
27212
|
const llmProvider = provider.provider;
|
|
26265
27213
|
const strategy = this.providerRegistry[llmProvider.name];
|
|
26266
27214
|
if (!strategy?.getProviderParameters) {
|
|
@@ -26278,12 +27226,12 @@ class ModelManager {
|
|
|
26278
27226
|
id: modelId,
|
|
26279
27227
|
providerId: provider.id
|
|
26280
27228
|
};
|
|
26281
|
-
return strategy.getProviderParameters(llmProvider, fallbackModel);
|
|
27229
|
+
return strategy.getProviderParameters(llmProvider, fallbackModel, reasoning);
|
|
26282
27230
|
}
|
|
26283
27231
|
logger.debug(`Found model object for ${modelId} in provider ${provider.id}`, {
|
|
26284
27232
|
hasProviderOverrides: !!modelObj.providerOverrides
|
|
26285
27233
|
});
|
|
26286
|
-
return strategy.getProviderParameters(llmProvider, modelObj);
|
|
27234
|
+
return strategy.getProviderParameters(llmProvider, modelObj, reasoning);
|
|
26287
27235
|
}
|
|
26288
27236
|
/**
|
|
26289
27237
|
* Returns provider-specific tools for the given provider and model
|
|
@@ -26350,9 +27298,9 @@ class ModelManager {
|
|
|
26350
27298
|
...provider.strategy,
|
|
26351
27299
|
createLlm: (profile2, model, settings, projectDir, toolSet, systemPrompt, providerMetadata) => provider.strategy.createLlm(profile2, model, settings, projectDir, toolSet, systemPrompt, providerMetadata),
|
|
26352
27300
|
getUsageReport: provider.strategy.getUsageReport || getDefaultUsageReport,
|
|
26353
|
-
getProviderOptions: provider.strategy.getProviderOptions ? (_provider, model) => provider.strategy.getProviderOptions(model) : void 0,
|
|
27301
|
+
getProviderOptions: provider.strategy.getProviderOptions ? (_provider, model, reasoning) => provider.strategy.getProviderOptions(model, reasoning) : void 0,
|
|
26354
27302
|
getProviderTools: provider.strategy.getProviderTools ? (_provider, model) => provider.strategy.getProviderTools(model) : void 0,
|
|
26355
|
-
getProviderParameters: provider.strategy.getProviderParameters ? (_provider, model) => provider.strategy.getProviderParameters(model) : void 0,
|
|
27303
|
+
getProviderParameters: provider.strategy.getProviderParameters ? (_provider, model, reasoning) => provider.strategy.getProviderParameters(model, reasoning) : void 0,
|
|
26356
27304
|
getCacheControl: provider.strategy.getCacheControl ? (_provider, model) => provider.strategy.getCacheControl(model) : void 0,
|
|
26357
27305
|
hasEnvVars: () => false,
|
|
26358
27306
|
getAiderMapping: provider.strategy.getAiderMapping ? provider.strategy.getAiderMapping : (_provider, modelId) => ({
|
|
@@ -27810,6 +28758,9 @@ class TaskContextImpl {
|
|
|
27810
28758
|
async mergeWorktreeToWorktree(targetWorktreeDir, includeUncommitted) {
|
|
27811
28759
|
await this.task.mergeWorktreeToWorktree(targetWorktreeDir, includeUncommitted);
|
|
27812
28760
|
}
|
|
28761
|
+
async resumeTask() {
|
|
28762
|
+
await this.task.resumeTask();
|
|
28763
|
+
}
|
|
27813
28764
|
}
|
|
27814
28765
|
class ProjectContextImpl {
|
|
27815
28766
|
constructor(project) {
|
|
@@ -27829,6 +28780,9 @@ class ProjectContextImpl {
|
|
|
27829
28780
|
async getTasks() {
|
|
27830
28781
|
return this.project.getTasks();
|
|
27831
28782
|
}
|
|
28783
|
+
async reloadTasks() {
|
|
28784
|
+
return this.project.reloadTasks();
|
|
28785
|
+
}
|
|
27832
28786
|
getMostRecentTask() {
|
|
27833
28787
|
const task = this.project.getMostRecentTask();
|
|
27834
28788
|
return task ? new TaskContextImpl(task) : null;
|
|
@@ -27885,6 +28839,17 @@ class ExtensionContextImpl {
|
|
|
27885
28839
|
getProjectDir() {
|
|
27886
28840
|
return this.project?.baseDir ?? "";
|
|
27887
28841
|
}
|
|
28842
|
+
getOpenProjectDirs() {
|
|
28843
|
+
if (!this.store) {
|
|
28844
|
+
return [];
|
|
28845
|
+
}
|
|
28846
|
+
try {
|
|
28847
|
+
return this.store.getOpenProjects().map((project) => project.baseDir);
|
|
28848
|
+
} catch (error) {
|
|
28849
|
+
this.log(`Failed to get open project dirs: ${error}`, "error");
|
|
28850
|
+
return [];
|
|
28851
|
+
}
|
|
28852
|
+
}
|
|
27888
28853
|
getTaskContext() {
|
|
27889
28854
|
return this.taskContext;
|
|
27890
28855
|
}
|
|
@@ -28755,6 +29720,11 @@ class ExtensionManager {
|
|
|
28755
29720
|
isInitialized() {
|
|
28756
29721
|
return this.initialized;
|
|
28757
29722
|
}
|
|
29723
|
+
async waitForInit() {
|
|
29724
|
+
while (!this.initialized) {
|
|
29725
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
29726
|
+
}
|
|
29727
|
+
}
|
|
28758
29728
|
/**
|
|
28759
29729
|
* @deprecated Migration helper: converts old name-based disabled list to filePath-based.
|
|
28760
29730
|
* Will be removed in a future version.
|
|
@@ -28848,6 +29818,29 @@ class ExtensionManager {
|
|
|
28848
29818
|
this.modelManager.unregisterExtensionProviders(extension.id);
|
|
28849
29819
|
logger.debug(`[Extensions] Unloaded extension: ${filePath}`);
|
|
28850
29820
|
}
|
|
29821
|
+
async reloadExtension(filePath, project) {
|
|
29822
|
+
const extension = this.findExtensionByPath(filePath);
|
|
29823
|
+
if (!extension) {
|
|
29824
|
+
logger.warn(`[Extensions] Cannot reload: extension not found at ${filePath}`);
|
|
29825
|
+
return false;
|
|
29826
|
+
}
|
|
29827
|
+
logger.info(`[Extensions] Reloading extension: ${extension.metadata.name} (${filePath})`);
|
|
29828
|
+
const hadUIComponents = extension.instance.getUIComponents !== void 0;
|
|
29829
|
+
await this.unloadExtension(filePath);
|
|
29830
|
+
const { success, hasUIComponents } = await this.loadAndInitializeExtension(filePath, project);
|
|
29831
|
+
if (success && (hasUIComponents || hadUIComponents)) {
|
|
29832
|
+
this.eventManager.sendExtensionUIRefresh({
|
|
29833
|
+
projectDir: project?.baseDir,
|
|
29834
|
+
reloadComponents: true
|
|
29835
|
+
});
|
|
29836
|
+
}
|
|
29837
|
+
const providers = this.getProviders(project);
|
|
29838
|
+
if (providers.length > 0) {
|
|
29839
|
+
this.modelManager.registerExtensionProviders(providers);
|
|
29840
|
+
}
|
|
29841
|
+
this.debouncedNotifyListeners();
|
|
29842
|
+
return success;
|
|
29843
|
+
}
|
|
28851
29844
|
findExtensionByPath(filePath) {
|
|
28852
29845
|
const extensions = this.registry.getExtensions();
|
|
28853
29846
|
return extensions.find((ext) => ext.filePath === filePath);
|
|
@@ -30178,9 +31171,15 @@ class EventsHandler {
|
|
|
30178
31171
|
if (!existingProject) {
|
|
30179
31172
|
logger.info("EventsHandler: addOpenProject", { baseDir });
|
|
30180
31173
|
const providerModels = await this.modelManager.getProviderModels();
|
|
31174
|
+
const defaultAgentProfileId = this.agentProfileManager.getDefaultAgentProfileId();
|
|
31175
|
+
const settings = getDefaultProjectSettings(this.store, providerModels.models || [], baseDir, defaultAgentProfileId);
|
|
31176
|
+
const agentProfile = this.agentProfileManager.getProfile(settings.agentProfileId);
|
|
31177
|
+
if (!agentProfile || agentProfile.projectDir && !compareBaseDirs$1(agentProfile.projectDir, baseDir)) {
|
|
31178
|
+
settings.agentProfileId = defaultAgentProfileId;
|
|
31179
|
+
}
|
|
30181
31180
|
const newProject = {
|
|
30182
31181
|
baseDir: baseDir.endsWith("/") ? baseDir.slice(0, -1) : baseDir,
|
|
30183
|
-
settings
|
|
31182
|
+
settings,
|
|
30184
31183
|
active: true
|
|
30185
31184
|
};
|
|
30186
31185
|
const updatedProjects = [...projects.map((p) => ({ ...p, active: false })), newProject];
|
|
@@ -30354,6 +31353,7 @@ class EventsHandler {
|
|
|
30354
31353
|
this.projectManager.getProject(baseDir).getTask(taskId)?.applyEdits(edits);
|
|
30355
31354
|
}
|
|
30356
31355
|
async runPrompt(baseDir, taskId, prompt, mode, images) {
|
|
31356
|
+
await Promise.all([this.modelManager.waitForInit(), this.extensionManager.waitForInit()]);
|
|
30357
31357
|
return this.projectManager.getProject(baseDir).getTask(taskId)?.runPrompt(prompt, mode, true, void 0, true, images) || [];
|
|
30358
31358
|
}
|
|
30359
31359
|
async waitForTaskIdle(baseDir, taskId) {
|
|
@@ -30365,6 +31365,7 @@ class EventsHandler {
|
|
|
30365
31365
|
await task.waitForIdle();
|
|
30366
31366
|
}
|
|
30367
31367
|
async ensureProjectAndCreateTask(projectDir, params) {
|
|
31368
|
+
await Promise.all([this.modelManager.waitForInit(), this.extensionManager.waitForInit()]);
|
|
30368
31369
|
const projects = this.store.getOpenProjects();
|
|
30369
31370
|
const baseDir = projectDir.endsWith("/") ? projectDir.slice(0, -1) : projectDir;
|
|
30370
31371
|
const existingProject = projects.find((p) => compareBaseDirs$1(p.baseDir, baseDir));
|
|
@@ -30381,6 +31382,9 @@ class EventsHandler {
|
|
|
30381
31382
|
async savePrompt(baseDir, taskId, prompt) {
|
|
30382
31383
|
return this.projectManager.getProject(baseDir).getTask(taskId)?.savePromptOnly(prompt);
|
|
30383
31384
|
}
|
|
31385
|
+
async saveEditedPrompt(baseDir, taskId, messageId, prompt) {
|
|
31386
|
+
return this.projectManager.getProject(baseDir).getTask(taskId)?.saveEditedPrompt(messageId, prompt);
|
|
31387
|
+
}
|
|
30384
31388
|
async answerQuestion(baseDir, taskId, answer) {
|
|
30385
31389
|
await this.projectManager.getProject(baseDir).getTask(taskId)?.answerQuestion(answer);
|
|
30386
31390
|
}
|
|
@@ -30575,6 +31579,13 @@ class EventsHandler {
|
|
|
30575
31579
|
}
|
|
30576
31580
|
await task.commitChanges(message, amend);
|
|
30577
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
|
+
}
|
|
30578
31589
|
async listBranches(projectDir) {
|
|
30579
31590
|
return await this.projectManager.worktreeManager.listBranches(projectDir);
|
|
30580
31591
|
}
|
|
@@ -30698,6 +31709,9 @@ ${error instanceof Error ? error.message : String(error)}`);
|
|
|
30698
31709
|
async getTasks(baseDir) {
|
|
30699
31710
|
return this.projectManager.getProject(baseDir).getTasks();
|
|
30700
31711
|
}
|
|
31712
|
+
async reloadTasks(baseDir) {
|
|
31713
|
+
return this.projectManager.getProject(baseDir).reloadTasks();
|
|
31714
|
+
}
|
|
30701
31715
|
async loadTask(baseDir, taskId) {
|
|
30702
31716
|
return this.projectManager.getProject(baseDir).getTask(taskId)?.load() || {
|
|
30703
31717
|
messages: [],
|
|
@@ -31027,6 +32041,16 @@ ${error instanceof Error ? error.message : String(error)}`);
|
|
|
31027
32041
|
async uninstallExtension(extensionId, projectDir) {
|
|
31028
32042
|
return await this.extensionManager.uninstallExtension(extensionId, projectDir);
|
|
31029
32043
|
}
|
|
32044
|
+
async reloadExtension(filePath, projectDir) {
|
|
32045
|
+
let project = void 0;
|
|
32046
|
+
if (projectDir) {
|
|
32047
|
+
project = this.projectManager.getProject(projectDir);
|
|
32048
|
+
if (!project) {
|
|
32049
|
+
throw new Error("Project not found");
|
|
32050
|
+
}
|
|
32051
|
+
}
|
|
32052
|
+
return await this.extensionManager.reloadExtension(filePath, project);
|
|
32053
|
+
}
|
|
31030
32054
|
async updateExtension(extensionId, repositoryUrl, projectDir) {
|
|
31031
32055
|
let project = void 0;
|
|
31032
32056
|
if (projectDir) {
|
|
@@ -31680,7 +32704,7 @@ class PythonDependenciesInstaller {
|
|
|
31680
32704
|
}
|
|
31681
32705
|
async createVirtualEnvInternal() {
|
|
31682
32706
|
this.setStatus({ state: "creating-venv" });
|
|
31683
|
-
const command = `"${await getResolvedUvPath()}" venv "${PYTHON_VENV_DIR}" --python 3.12`;
|
|
32707
|
+
const command = `"${await getResolvedUvPath()}" venv "${PYTHON_VENV_DIR}" --python 3.12 --clear`;
|
|
31684
32708
|
logger.info(`Creating virtual environment with uv: ${command}`, {
|
|
31685
32709
|
virtualEnv: PYTHON_VENV_DIR
|
|
31686
32710
|
});
|
|
@@ -31920,7 +32944,8 @@ const initManagers = async (store, windowManager) => {
|
|
|
31920
32944
|
modelManager,
|
|
31921
32945
|
agentProfileManager,
|
|
31922
32946
|
extensionManager,
|
|
31923
|
-
pythonInstaller
|
|
32947
|
+
pythonInstaller,
|
|
32948
|
+
projectManager
|
|
31924
32949
|
};
|
|
31925
32950
|
};
|
|
31926
32951
|
const performStartUp = async (pythonInstaller, updateProgress) => {
|
|
@@ -32443,6 +33468,8 @@ const DEFAULT_SETTINGS = {
|
|
|
32443
33468
|
},
|
|
32444
33469
|
server: {
|
|
32445
33470
|
enabled: false,
|
|
33471
|
+
readonly: false,
|
|
33472
|
+
readonlyExtensionUi: true,
|
|
32446
33473
|
basicAuth: {
|
|
32447
33474
|
enabled: false,
|
|
32448
33475
|
username: "",
|
|
@@ -32769,10 +33796,16 @@ class Store {
|
|
|
32769
33796
|
const addProjectsFromEnv = async (store, modelManager, agentProfileManager) => {
|
|
32770
33797
|
const aiderDeskProjectsEnv = process.env.AIDER_DESK_PROJECTS;
|
|
32771
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
|
+
}
|
|
32772
33802
|
return;
|
|
32773
33803
|
}
|
|
32774
33804
|
const projectPaths = aiderDeskProjectsEnv.split(",").map((p) => p.trim()).filter((p) => p.length > 0);
|
|
32775
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
|
+
}
|
|
32776
33809
|
return;
|
|
32777
33810
|
}
|
|
32778
33811
|
logger.info("AIDER_DESK_PROJECTS environment variable found", { projectPaths });
|
|
@@ -32817,11 +33850,20 @@ const main = async () => {
|
|
|
32817
33850
|
};
|
|
32818
33851
|
const store = new Store();
|
|
32819
33852
|
await store.init(AIDER_DESK_DATA_DIR);
|
|
32820
|
-
const { modelManager, agentProfileManager, pythonInstaller } = await initManagers(store);
|
|
33853
|
+
const { modelManager, agentProfileManager, pythonInstaller, projectManager, serverController } = await initManagers(store);
|
|
32821
33854
|
try {
|
|
32822
33855
|
await performStartUp(pythonInstaller, updateProgress);
|
|
32823
33856
|
logger.info("Startup complete");
|
|
32824
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
|
+
}
|
|
32825
33867
|
logger.info(`AiderDesk Runner is ready and running on port ${SERVER_PORT}. You can now open http://localhost:${SERVER_PORT} in your browser.`);
|
|
32826
33868
|
} catch (error) {
|
|
32827
33869
|
logger.error("Failed to start AiderDesk Node Runner:", error);
|